forked from github/server
- Regionsbotschaften parteigezogen. Nicht wirklich getestet.
This commit is contained in:
parent
9e49e7ef47
commit
ba59e334a8
|
@ -379,37 +379,39 @@ render_messages(FILE * F, faction * f, message_list *msgs)
|
||||||
{
|
{
|
||||||
struct mlist* m = msgs->begin;
|
struct mlist* m = msgs->begin;
|
||||||
while (m) {
|
while (m) {
|
||||||
char crbuffer[1024*32]; /* gross, wegen spionage-messages :-( */
|
if(m->msg->receiver == NULL || m->msg->receiver == f) {
|
||||||
boolean printed = false;
|
char crbuffer[1024*32]; /* gross, wegen spionage-messages :-( */
|
||||||
const struct message_type * mtype = m->msg->type;
|
boolean printed = false;
|
||||||
unsigned int hash = hashstring(mtype->name);
|
const struct message_type * mtype = m->msg->type;
|
||||||
|
unsigned int hash = hashstring(mtype->name);
|
||||||
#if RENDER_CRMESSAGES
|
#if RENDER_CRMESSAGES
|
||||||
char nrbuffer[1024*32];
|
char nrbuffer[1024*32];
|
||||||
nrbuffer[0] = '\0';
|
nrbuffer[0] = '\0';
|
||||||
if (nr_render(m->msg, f->locale, nrbuffer, f)==0 && nrbuffer[0]) {
|
if (nr_render(m->msg, f->locale, nrbuffer, f)==0 && nrbuffer[0]) {
|
||||||
fprintf(F, "MESSAGE %d\n", ++msgno);
|
fprintf(F, "MESSAGE %d\n", ++msgno);
|
||||||
fprintf(F, "%d;type\n", hash);
|
fprintf(F, "%d;type\n", hash);
|
||||||
fputs("\"", F);
|
fputs("\"", F);
|
||||||
fputs(nrbuffer, F);
|
fputs(nrbuffer, F);
|
||||||
fputs("\";rendered\n", F);
|
fputs("\";rendered\n", F);
|
||||||
printed = true;
|
printed = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
crbuffer[0] = '\0';
|
crbuffer[0] = '\0';
|
||||||
if (cr_render(m->msg, crbuffer, (const void*)f)==0 && crbuffer[0]) {
|
if (cr_render(m->msg, crbuffer, (const void*)f)==0 && crbuffer[0]) {
|
||||||
if (!printed) fprintf(F, "MESSAGE %d\n", ++msgno);
|
if (!printed) fprintf(F, "MESSAGE %d\n", ++msgno);
|
||||||
fputs(crbuffer, F);
|
fputs(crbuffer, F);
|
||||||
}
|
}
|
||||||
else log_error(("could not render cr-message %p\n", m->msg));
|
else log_error(("could not render cr-message %p\n", m->msg));
|
||||||
if (printed) {
|
if (printed) {
|
||||||
unsigned int ihash = hash % MTMAXHASH;
|
unsigned int ihash = hash % MTMAXHASH;
|
||||||
struct known_mtype * kmt = mtypehash[ihash];
|
struct known_mtype * kmt = mtypehash[ihash];
|
||||||
while (kmt && kmt->mtype != mtype) kmt = kmt->nexthash;
|
while (kmt && kmt->mtype != mtype) kmt = kmt->nexthash;
|
||||||
if (kmt==NULL) {
|
if (kmt==NULL) {
|
||||||
kmt = (struct known_mtype*)malloc(sizeof(struct known_mtype));
|
kmt = (struct known_mtype*)malloc(sizeof(struct known_mtype));
|
||||||
kmt->nexthash = mtypehash[ihash];
|
kmt->nexthash = mtypehash[ihash];
|
||||||
kmt->mtype = mtype;
|
kmt->mtype = mtype;
|
||||||
mtypehash[ihash] = kmt;
|
mtypehash[ihash] = kmt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m = m->next;
|
m = m->next;
|
||||||
|
|
|
@ -752,7 +752,8 @@ rp_messages(FILE * F, message_list * msgs, faction * viewer, int indent, boolean
|
||||||
if (!debug && get_msglevel(viewer->warnings, viewer->msglevels, m->type) < m->level) continue;
|
if (!debug && get_msglevel(viewer->warnings, viewer->msglevels, m->type) < m->level) continue;
|
||||||
#endif
|
#endif
|
||||||
/* messagetype * mt = m->type; */
|
/* messagetype * mt = m->type; */
|
||||||
if (strcmp(nr_section(m->msg), category->name)==0)
|
if (strcmp(nr_section(m->msg), category->name)==0
|
||||||
|
&& (m->msg->receiver == NULL || m->msg->receiver == viewer))
|
||||||
{
|
{
|
||||||
char buf[4096], *s = buf;
|
char buf[4096], *s = buf;
|
||||||
nr_render(m->msg, viewer->locale, s, viewer);
|
nr_render(m->msg, viewer->locale, s, viewer);
|
||||||
|
|
|
@ -291,7 +291,7 @@ msg_error(const struct unit * u, const char * cmd, const char * name, const char
|
||||||
}
|
}
|
||||||
va_end(marker);
|
va_end(marker);
|
||||||
|
|
||||||
return msg_create(mtype, (void**)args);
|
return msg_create(mtype, u->faction, (void**)args);
|
||||||
}
|
}
|
||||||
|
|
||||||
message *
|
message *
|
||||||
|
@ -322,7 +322,7 @@ msg_message(const char * name, const char* sig, ...)
|
||||||
}
|
}
|
||||||
va_end(marker);
|
va_end(marker);
|
||||||
|
|
||||||
return msg_create(mtype, (void**)args);
|
return msg_create(mtype, NULL, (void**)args);
|
||||||
}
|
}
|
||||||
|
|
||||||
message *
|
message *
|
||||||
|
@ -423,7 +423,7 @@ new_message(struct faction * receiver, const char* sig, ...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
va_end(marker);
|
va_end(marker);
|
||||||
return msg_create(mtype, (void**)args);
|
return msg_create(mtype, receiver, (void**)args);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -73,10 +73,11 @@ mt_new_va(const char * name, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
message *
|
message *
|
||||||
msg_create(const struct message_type * type, void * args[])
|
msg_create(const struct message_type * type, struct faction *receiver, void * args[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
message * msg = (message *)malloc(sizeof(message));
|
message * msg = (message *)malloc(sizeof(message));
|
||||||
|
msg->receiver = receiver;
|
||||||
msg->type = type;
|
msg->type = type;
|
||||||
msg->parameters = calloc(sizeof(void*), type->nparameters);
|
msg->parameters = calloc(sizeof(void*), type->nparameters);
|
||||||
for (i=0;i!=type->nparameters;++i) {
|
for (i=0;i!=type->nparameters;++i) {
|
||||||
|
@ -86,7 +87,7 @@ msg_create(const struct message_type * type, void * args[])
|
||||||
}
|
}
|
||||||
|
|
||||||
message *
|
message *
|
||||||
msg_create_va(const struct message_type * type, ...)
|
msg_create_va(const struct message_type * type, struct faction *receiver, ...)
|
||||||
/* sets a messages parameters */
|
/* sets a messages parameters */
|
||||||
{
|
{
|
||||||
void * args[16];
|
void * args[16];
|
||||||
|
@ -97,7 +98,7 @@ msg_create_va(const struct message_type * type, ...)
|
||||||
args[i] = va_arg(marker, void*);
|
args[i] = va_arg(marker, void*);
|
||||||
}
|
}
|
||||||
va_end(marker);
|
va_end(marker);
|
||||||
return msg_create(type, args);
|
return msg_create(type, receiver, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct messagetype_list {
|
typedef struct messagetype_list {
|
||||||
|
|
|
@ -20,6 +20,7 @@ typedef struct message_type {
|
||||||
} message_type;
|
} message_type;
|
||||||
|
|
||||||
typedef struct message {
|
typedef struct message {
|
||||||
|
struct faction *receiver;
|
||||||
const struct message_type * type;
|
const struct message_type * type;
|
||||||
const void ** parameters;
|
const void ** parameters;
|
||||||
} message;
|
} message;
|
||||||
|
@ -29,8 +30,8 @@ extern struct message_type * mt_new_va(const char * name, ...);
|
||||||
/* mt_new("simple_sentence", "subject:string", "predicate:string",
|
/* mt_new("simple_sentence", "subject:string", "predicate:string",
|
||||||
* "object:string", "lang:locale", NULL); */
|
* "object:string", "lang:locale", NULL); */
|
||||||
|
|
||||||
extern struct message * msg_create(const struct message_type * type, void * args[]);
|
extern struct message * msg_create(const struct message_type * type, struct faction *receiver, void * args[]);
|
||||||
extern struct message * msg_create_va(const struct message_type * type, ...);
|
extern struct message * msg_create_va(const struct message_type * type, struct faction *receiver, ...);
|
||||||
/* msg_create(&mt_simplesentence, "enno", "eats", "chocolate", &locale_de);
|
/* msg_create(&mt_simplesentence, "enno", "eats", "chocolate", &locale_de);
|
||||||
* parameters must be in the same order as they were for mt_new! */
|
* parameters must be in the same order as they were for mt_new! */
|
||||||
extern void msg_free(struct message *m);
|
extern void msg_free(struct message *m);
|
||||||
|
|
|
@ -4107,7 +4107,7 @@
|
||||||
</nr>
|
</nr>
|
||||||
</locale>
|
</locale>
|
||||||
<locale name="en">
|
<locale name="en">
|
||||||
<nr section="none">
|
<nr section="events">
|
||||||
<text>"$faction($from) donates $int($amount) silver to $faction($to)."</text>
|
<text>"$faction($from) donates $int($amount) silver to $faction($to)."</text>
|
||||||
</nr>
|
</nr>
|
||||||
</locale>
|
</locale>
|
||||||
|
|
Loading…
Reference in New Issue