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);
{
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;

View File

@ -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 */

View File

@ -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!");

View File

@ -30,6 +30,7 @@
#include "plane.h"
#include "region.h"
#include "curse.h"
#include "message.h"
/* util includes */
#include <resolve.h>
@ -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);
}

View File

@ -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;