message-type hashes were not initialized.
This commit is contained in:
Enno Rehling 2014-01-05 12:50:13 -08:00
parent 99151e209b
commit 0f0cda214f
3 changed files with 10 additions and 7 deletions

View File

@ -482,7 +482,8 @@ static void report_crtypes(FILE * F, const struct locale *lang)
const struct nrmessage_type *nrt = nrt_find(lang, kmt->mtype);
if (nrt) {
unsigned int hash = kmt->mtype->key;
fprintf(F, "MESSAGETYPE %d\n", hash);
assert(hash > 0);
fprintf(F, "MESSAGETYPE %u\n", hash);
fputc('\"', F);
fputs(escape_string(nrt_string(nrt), NULL, 0), F);
fputs("\";text\n", F);
@ -548,7 +549,7 @@ static void render_messages(FILE * F, faction * f, message_list * msgs)
nrbuffer[0] = '\0';
if (nr_render(m->msg, f->locale, nrbuffer, sizeof(nrbuffer), f) > 0) {
fprintf(F, "MESSAGE %u\n", messagehash(m->msg));
fprintf(F, "%d;type\n", hash);
fprintf(F, "%u;type\n", hash);
fwritestr(F, nrbuffer);
fputs(";rendered\n", F);
printed = true;

View File

@ -43,7 +43,7 @@ void free_spells(void) {
void add_spell(struct quicklist **slistp, spell * sp)
{
if (ql_set_insert(slistp, sp) != 0) {
if (!ql_set_insert(slistp, sp)) {
log_error("add_spell: the list already contains the spell '%s'.\n", sp->sname);
}
}

View File

@ -42,9 +42,11 @@ message_type *mt_new(const char *name, const char *args[])
log_error("Trying to create message_type with name=0x0\n");
return NULL;
}
if (args != NULL)
for (nparameters = 0; args[nparameters]; ++nparameters) ;
if (args != NULL) {
/* count the number of parameters */
while (args[nparameters]) ++nparameters;
}
mtype->key = 0;
mtype->name = _strdup(name);
mtype->nparameters = nparameters;
if (nparameters > 0) {
@ -188,7 +190,7 @@ const message_type *mt_register(message_type * type)
unsigned int hash = hashstring(type->name) % MT_MAXHASH;
quicklist **qlp = messagetypes + hash;
if (ql_set_insert(qlp, type) == 0) {
if (ql_set_insert(qlp, type)) {
type->key = mt_id(type);
}
return type;