parteispezifische regionsmessages, ungetestet!

This commit is contained in:
Enno Rehling 2001-05-20 07:46:13 +00:00
parent 81ff6bc2fa
commit 5ff5e62af4
5 changed files with 52 additions and 15 deletions

View File

@ -1091,6 +1091,10 @@ report_computer(FILE * F, faction * f, const time_t report_time)
} }
} }
cr_output_messages(F, r->msgs, f); cr_output_messages(F, r->msgs, f);
{
message_list * mlist = r_getmessages(r, f);
if (mlist) cr_output_messages(F, mlist, f);
}
/* buildings */ /* buildings */
for (b = rbuildings(r); b; b = b->next) { for (b = rbuildings(r); b; b = b->next) {
int fno = -1; int fno = -1;

View File

@ -1960,7 +1960,9 @@ report(FILE *F, faction * f, const char * pzTime)
/* Nachrichten an REGION in der Region */ /* Nachrichten an REGION in der Region */
if (unit_in_region || durchgezogen_in_region) { if (unit_in_region || durchgezogen_in_region) {
message_list * mlist = r_getmessages(r, f);
rp_messages(F, r->msgs, f, 0, true, true); rp_messages(F, r->msgs, f, 0, true, true);
if (mlist) rp_messages(F, mlist, f, 0, true, true);
} }
/* Burgen und ihre Einheiten */ /* Burgen und ihre Einheiten */

View File

@ -26,6 +26,7 @@
#include "plane.h" #include "plane.h"
#include "faction.h" #include "faction.h"
#include "unit.h" #include "unit.h"
#include "region.h"
#include "item.h" #include "item.h"
#include "building.h" #include "building.h"
@ -434,43 +435,37 @@ caddmessage(region * r, faction * f, const char *s, msg_t mtype, int level)
switch (mtype) { switch (mtype) {
case MSG_INCOME: case MSG_INCOME:
assert(f); assert(f);
m = add_message(&f->msgs, msg_message("msg_economy", "string", s)); add_message(&f->msgs, msg_message("msg_economy", "string", s));
break; break;
case MSG_BATTLE: case MSG_BATTLE:
assert(0 || !"battle-meldungen nicht über addmessage machen"); assert(0 || !"battle-meldungen nicht über addmessage machen");
break; break;
case MSG_MOVE: case MSG_MOVE:
assert(f); assert(f);
m = add_message(&f->msgs, msg_message("msg_movement", "string", s)); add_message(&f->msgs, msg_message("msg_movement", "string", s));
break; break;
case MSG_COMMERCE: case MSG_COMMERCE:
assert(f); assert(f);
m = add_message(&f->msgs, msg_message("msg_economy", "string", s)); add_message(&f->msgs, msg_message("msg_economy", "string", s));
break; break;
case MSG_PRODUCE: case MSG_PRODUCE:
assert(f); assert(f);
m = add_message(&f->msgs, msg_message("msg_production", "string", s)); add_message(&f->msgs, msg_message("msg_production", "string", s));
break; break;
case MSG_MAGIC: case MSG_MAGIC:
case MSG_COMMENT: case MSG_COMMENT:
case MSG_MESSAGE: 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_ORCVERMEHRUNG:
case MSG_EVENT: case MSG_EVENT:
/* Botschaften an REGION oder einzelne PARTEI */ /* Botschaften an REGION oder einzelne PARTEI */
m = msg_message("msg_event", "string", s);
if (!r) { if (!r) {
assert(f); 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; break;
default: default:
assert(!"Ungültige Msg-Klasse!"); assert(!"Ungültige Msg-Klasse!");

View File

@ -30,6 +30,7 @@
#include "plane.h" #include "plane.h"
#include "region.h" #include "region.h"
#include "curse.h" #include "curse.h"
#include "message.h"
/* util includes */ /* util includes */
#include <resolve.h> #include <resolve.h>
@ -911,3 +912,28 @@ resolve_region(void * id) {
return findregion(x, y); 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);
}

View File

@ -39,6 +39,8 @@
#define RF_ALL 0xFFFFFF #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) #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 { typedef struct land_region {
char *name; char *name;
@ -69,6 +71,11 @@ typedef struct region {
char *display; char *display;
unsigned int flags; unsigned int flags;
struct message_list *msgs; 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 attrib *attribs;
struct region *nexthash; struct region *nexthash;
terrain_t terrain; terrain_t terrain;
@ -78,6 +85,9 @@ typedef struct region {
#endif #endif
} region; } 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 { typedef struct {
int x; int x;
int y; int y;