diff --git a/core/src/gamecode/creport.c b/core/src/gamecode/creport.c index 5f2ec83ba..fd49853f5 100644 --- a/core/src/gamecode/creport.c +++ b/core/src/gamecode/creport.c @@ -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; diff --git a/core/src/kernel/spell.c b/core/src/kernel/spell.c index 1a40e4067..6184d4b43 100644 --- a/core/src/kernel/spell.c +++ b/core/src/kernel/spell.c @@ -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); } } diff --git a/core/src/util/message.c b/core/src/util/message.c index 006ddc15e..7e9c1a9f0 100644 --- a/core/src/util/message.c +++ b/core/src/util/message.c @@ -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;