forked from github/server
message-type hashes were not initialized.
This commit is contained in:
parent
99151e209b
commit
0f0cda214f
|
@ -482,7 +482,8 @@ static void report_crtypes(FILE * F, const struct locale *lang)
|
||||||
const struct nrmessage_type *nrt = nrt_find(lang, kmt->mtype);
|
const struct nrmessage_type *nrt = nrt_find(lang, kmt->mtype);
|
||||||
if (nrt) {
|
if (nrt) {
|
||||||
unsigned int hash = kmt->mtype->key;
|
unsigned int hash = kmt->mtype->key;
|
||||||
fprintf(F, "MESSAGETYPE %d\n", hash);
|
assert(hash > 0);
|
||||||
|
fprintf(F, "MESSAGETYPE %u\n", hash);
|
||||||
fputc('\"', F);
|
fputc('\"', F);
|
||||||
fputs(escape_string(nrt_string(nrt), NULL, 0), F);
|
fputs(escape_string(nrt_string(nrt), NULL, 0), F);
|
||||||
fputs("\";text\n", F);
|
fputs("\";text\n", F);
|
||||||
|
@ -548,7 +549,7 @@ static void render_messages(FILE * F, faction * f, message_list * msgs)
|
||||||
nrbuffer[0] = '\0';
|
nrbuffer[0] = '\0';
|
||||||
if (nr_render(m->msg, f->locale, nrbuffer, sizeof(nrbuffer), f) > 0) {
|
if (nr_render(m->msg, f->locale, nrbuffer, sizeof(nrbuffer), f) > 0) {
|
||||||
fprintf(F, "MESSAGE %u\n", messagehash(m->msg));
|
fprintf(F, "MESSAGE %u\n", messagehash(m->msg));
|
||||||
fprintf(F, "%d;type\n", hash);
|
fprintf(F, "%u;type\n", hash);
|
||||||
fwritestr(F, nrbuffer);
|
fwritestr(F, nrbuffer);
|
||||||
fputs(";rendered\n", F);
|
fputs(";rendered\n", F);
|
||||||
printed = true;
|
printed = true;
|
||||||
|
|
|
@ -43,7 +43,7 @@ void free_spells(void) {
|
||||||
|
|
||||||
void add_spell(struct quicklist **slistp, spell * sp)
|
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);
|
log_error("add_spell: the list already contains the spell '%s'.\n", sp->sname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
log_error("Trying to create message_type with name=0x0\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (args != NULL)
|
if (args != NULL) {
|
||||||
for (nparameters = 0; args[nparameters]; ++nparameters) ;
|
/* count the number of parameters */
|
||||||
|
while (args[nparameters]) ++nparameters;
|
||||||
|
}
|
||||||
|
mtype->key = 0;
|
||||||
mtype->name = _strdup(name);
|
mtype->name = _strdup(name);
|
||||||
mtype->nparameters = nparameters;
|
mtype->nparameters = nparameters;
|
||||||
if (nparameters > 0) {
|
if (nparameters > 0) {
|
||||||
|
@ -188,7 +190,7 @@ const message_type *mt_register(message_type * type)
|
||||||
unsigned int hash = hashstring(type->name) % MT_MAXHASH;
|
unsigned int hash = hashstring(type->name) % MT_MAXHASH;
|
||||||
quicklist **qlp = messagetypes + hash;
|
quicklist **qlp = messagetypes + hash;
|
||||||
|
|
||||||
if (ql_set_insert(qlp, type) == 0) {
|
if (ql_set_insert(qlp, type)) {
|
||||||
type->key = mt_id(type);
|
type->key = mt_id(type);
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
|
|
Loading…
Reference in New Issue