From d0f8825240d2eea0779b0c9d5e832da987883285 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 18 May 2015 11:34:52 +0200 Subject: [PATCH] use the syntax_error function where appropriate. fix bug w. releasing message too soon. --- scripts/run-turn.lua | 4 +--- src/kernel/messages.c | 2 +- src/laws.c | 2 +- src/magic.c | 4 ++-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/run-turn.lua b/scripts/run-turn.lua index ebbc978f6..60f2b6f63 100644 --- a/scripts/run-turn.lua +++ b/scripts/run-turn.lua @@ -142,6 +142,7 @@ function process(rules, orders) callbacks(rules, 'update') write_files(config.locales) + dbupdate() file = '' .. get_turn() .. '.dat' if eressea.write_game(file)~=0 then @@ -161,9 +162,6 @@ function run_turn(rules) orderfile = orderfile or config.basepath .. '/orders.' .. turn eressea.log.debug("executing turn " .. get_turn() .. " with " .. orderfile .. " with rules=" .. config.rules) local result = process(rules, orderfile) - if result==0 then - dbupdate() - end return result end diff --git a/src/kernel/messages.c b/src/kernel/messages.c index 49542ce4a..9fa861bc6 100644 --- a/src/kernel/messages.c +++ b/src/kernel/messages.c @@ -287,7 +287,6 @@ void syntax_error(const struct unit *u, struct order *ord) message * result; result = msg_error(u, ord, 10); ADDMSG(&u->faction->msgs, result); - msg_release(result); } extern unsigned int new_hashstring(const char *s); @@ -306,6 +305,7 @@ void free_messagelist(message_list * msgs) message *add_message(message_list ** pm, message * m) { + assert(m->type); if (!lomem && m != NULL) { struct mlist *mnew = malloc(sizeof(struct mlist)); if (*pm == NULL) { diff --git a/src/laws.c b/src/laws.c index cabbe2651..abab90a12 100755 --- a/src/laws.c +++ b/src/laws.c @@ -2894,7 +2894,7 @@ void restack_units(void) cmistake(u, ord, 260, MSG_EVENT); } else if (v == u) { - cmistake(u, ord, 10, MSG_EVENT); + syntax_error(u, ord); } else { switch (p) { diff --git a/src/magic.c b/src/magic.c index e50393d40..d91bd9658 100644 --- a/src/magic.c +++ b/src/magic.c @@ -2527,7 +2527,7 @@ static castorder *cast_cmd(unit * u, order * ord) level = _min(p, level); if (level < 1) { /* Fehler "Das macht wenig Sinn" */ - cmistake(u, ord, 10, MSG_MAGIC); + syntax_error(u, ord); return 0; } s = gettoken(token, sizeof(token)); @@ -2557,7 +2557,7 @@ static castorder *cast_cmd(unit * u, order * ord) level = _min(p, level); if (level < 1) { /* Fehler "Das macht wenig Sinn" */ - cmistake(u, ord, 10, MSG_MAGIC); + syntax_error(u, ord); return 0; } s = gettoken(token, sizeof(token));