bugfixes zur kompatibilitaetsfunktion

This commit is contained in:
Enno Rehling 2001-03-01 01:38:12 +00:00
parent 2ccf6631e5
commit 4f105e3ae8
1 changed files with 26 additions and 15 deletions

View File

@ -1,6 +1,6 @@
/* vi: set ts=2: /* vi: set ts=2:
* *
* $Id: message.c,v 1.10 2001/02/28 23:28:54 enno Exp $ * $Id: message.c,v 1.11 2001/03/01 01:38:12 enno Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000 * Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de)
@ -145,6 +145,7 @@ new_message(struct faction * receiver, const char* sig, ...)
const char * c = sig; const char * c = sig;
const char * args[16]; const char * args[16];
memset(args, 0, sizeof(args));
strncpy(buffer, sig, signature-sig); strncpy(buffer, sig, signature-sig);
buffer[signature-sig] = '\0'; buffer[signature-sig] = '\0';
mtype = mt_find(buffer); mtype = mt_find(buffer);
@ -183,8 +184,10 @@ new_message(struct faction * receiver, const char* sig, ...)
for (i=0;i!=mtype->nparameters;++i) { for (i=0;i!=mtype->nparameters;++i) {
if (!strcmp(buffer, mtype->pnames[i])) break; if (!strcmp(buffer, mtype->pnames[i])) break;
} }
assert(i!=mtype->nparameters || !"unknown parameter"); if (i==mtype->nparameters) {
log_error(("unknown message-parameter for %s: %s (%p)\n", mtype->name, buffer, va_arg(marker, void*)));
continue;
}
switch(type) { switch(type) {
case 's': case 's':
args[i] = va_arg(marker, const char *); args[i] = va_arg(marker, const char *);
@ -195,17 +198,25 @@ new_message(struct faction * receiver, const char* sig, ...)
case 'f': case 'f':
args[i] = factionname(va_arg(marker, const struct faction*)); args[i] = factionname(va_arg(marker, const struct faction*));
break; break;
case 'u': case 'u': {
args[i] = unitname(va_arg(marker, const struct unit*)); const struct unit * u = va_arg(marker, const struct unit*);
if (u) args[i] = unitname(u);
}
break; break;
case 'r': case 'r': {
args[i] = rname(va_arg(marker, const struct region*), receiver->locale); const struct region * r = va_arg(marker, const struct region*);
if (r) args[i] = rname(r, receiver->locale);
}
break; break;
case 'h': case 'h': {
args[i] = shipname(va_arg(marker, const struct ship*)); const struct ship * sh = va_arg(marker, const struct ship*);
if (sh) args[i] = shipname(sh);
}
break; break;
case 'b': case 'b': {
args[i] = buildingname(va_arg(marker, const struct building*)); const struct building * b = va_arg(marker, const struct building*);
if (b) args[i] = buildingname(b);
}
break; break;
case 'X': case 'X':
args[i] = resourcename(va_arg(marker, const resource_type *), 0); args[i] = resourcename(va_arg(marker, const resource_type *), 0);