From 5ff5e62af4d3305254ef8785b257396633426f88 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 20 May 2001 07:46:13 +0000 Subject: [PATCH] parteispezifische regionsmessages, ungetestet! --- src/common/gamecode/creport.c | 4 ++++ src/common/gamecode/report.c | 2 ++ src/common/kernel/message.c | 25 ++++++++++--------------- src/common/kernel/region.c | 26 ++++++++++++++++++++++++++ src/common/kernel/region.h | 10 ++++++++++ 5 files changed, 52 insertions(+), 15 deletions(-) diff --git a/src/common/gamecode/creport.c b/src/common/gamecode/creport.c index cb72a3697..6a59bf921 100644 --- a/src/common/gamecode/creport.c +++ b/src/common/gamecode/creport.c @@ -1091,6 +1091,10 @@ report_computer(FILE * F, faction * f, const time_t report_time) } } cr_output_messages(F, r->msgs, f); + { + message_list * mlist = r_getmessages(r, f); + if (mlist) cr_output_messages(F, mlist, f); + } /* buildings */ for (b = rbuildings(r); b; b = b->next) { int fno = -1; diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index 43859b746..6d9efb44b 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -1960,7 +1960,9 @@ report(FILE *F, faction * f, const char * pzTime) /* Nachrichten an REGION in der Region */ if (unit_in_region || durchgezogen_in_region) { + message_list * mlist = r_getmessages(r, f); rp_messages(F, r->msgs, f, 0, true, true); + if (mlist) rp_messages(F, mlist, f, 0, true, true); } /* Burgen und ihre Einheiten */ diff --git a/src/common/kernel/message.c b/src/common/kernel/message.c index fb0e1cf63..ac588644f 100644 --- a/src/common/kernel/message.c +++ b/src/common/kernel/message.c @@ -26,6 +26,7 @@ #include "plane.h" #include "faction.h" #include "unit.h" +#include "region.h" #include "item.h" #include "building.h" @@ -434,43 +435,37 @@ caddmessage(region * r, faction * f, const char *s, msg_t mtype, int level) switch (mtype) { case MSG_INCOME: assert(f); - m = add_message(&f->msgs, msg_message("msg_economy", "string", s)); + add_message(&f->msgs, msg_message("msg_economy", "string", s)); break; case MSG_BATTLE: assert(0 || !"battle-meldungen nicht über addmessage machen"); break; case MSG_MOVE: assert(f); - m = add_message(&f->msgs, msg_message("msg_movement", "string", s)); + add_message(&f->msgs, msg_message("msg_movement", "string", s)); break; case MSG_COMMERCE: assert(f); - m = add_message(&f->msgs, msg_message("msg_economy", "string", s)); + add_message(&f->msgs, msg_message("msg_economy", "string", s)); break; case MSG_PRODUCE: assert(f); - m = add_message(&f->msgs, msg_message("msg_production", "string", s)); + add_message(&f->msgs, msg_message("msg_production", "string", s)); break; case MSG_MAGIC: case MSG_COMMENT: case MSG_MESSAGE: - /* Botschaften an REGION oder einzelne PARTEI */ - if (!r) { - assert(f); - m = add_message(&f->msgs, msg_message("msg_event", "string", s)); - } - else - m = add_message(&r->msgs, msg_message("msg_event", "string", s)); - break; case MSG_ORCVERMEHRUNG: case MSG_EVENT: /* Botschaften an REGION oder einzelne PARTEI */ + m = msg_message("msg_event", "string", s); if (!r) { assert(f); - m = add_message(&f->msgs, msg_message("msg_event", "string", s)); + m = add_message(&f->msgs, m); + } else { + if (f) add_message(&r->msgs, m); + else r_addmessage(r, f, m); } - else - m = add_message(&r->msgs, msg_message("msg_event", "string", s)); break; default: assert(!"Ungültige Msg-Klasse!"); diff --git a/src/common/kernel/region.c b/src/common/kernel/region.c index 03d10e767..333e19b7b 100644 --- a/src/common/kernel/region.c +++ b/src/common/kernel/region.c @@ -30,6 +30,7 @@ #include "plane.h" #include "region.h" #include "curse.h" +#include "message.h" /* util includes */ #include @@ -911,3 +912,28 @@ resolve_region(void * id) { return findregion(x, y); } + +struct message_list * +r_getmessages(struct region * r, const struct faction * viewer) +{ + struct individual_message * imsg = r->individual_messages; + while (imsg && (imsg)->viewer!=viewer) imsg = imsg->next; + if (imsg) return imsg->msgs; + return NULL; +} + +void +r_addmessage(struct region * r, const struct faction * viewer, struct message * msg) +{ + struct individual_message * imsg; + assert(r); + imsg = r->individual_messages; + while (imsg && imsg->viewer!=viewer) imsg = imsg->next; + if (imsg==NULL) { + imsg = malloc(sizeof(struct individual_message)); + imsg->next = r->individual_messages; + r->individual_messages = imsg; + imsg->viewer = viewer; + } + add_message(&imsg->msgs, msg); +} \ No newline at end of file diff --git a/src/common/kernel/region.h b/src/common/kernel/region.h index e9149576f..3bcb93302 100644 --- a/src/common/kernel/region.h +++ b/src/common/kernel/region.h @@ -39,6 +39,8 @@ #define RF_ALL 0xFFFFFF #define RF_SAVEMASK (RF_CHAOTIC|RF_MALLORN|RF_BLOCKED|RF_BLOCK_NORTHWEST|RF_BLOCK_NORTHEAST|RF_BLOCK_EAST|RF_BLOCK_SOUTHEAST|RF_BLOCK_SOUTHWEST|RF_BLOCK_WEST|RF_ENCOUNTER|RF_ORCIFIED) +struct message; +struct message_list; typedef struct land_region { char *name; @@ -69,6 +71,11 @@ typedef struct region { char *display; unsigned int flags; struct message_list *msgs; + struct individual_message { + struct individual_message * next; + const struct faction * viewer; + struct message_list *msgs; + } * individual_messages; struct attrib *attribs; struct region *nexthash; terrain_t terrain; @@ -78,6 +85,9 @@ typedef struct region { #endif } region; +extern struct message_list * r_getmessages(struct region * r, const struct faction * viewer); +extern void r_addmessage(struct region * r, const struct faction * viewer, struct message * msg); + typedef struct { int x; int y;