use the syntax_error function where appropriate.

fix bug w. releasing message too soon.
This commit is contained in:
Enno Rehling 2015-05-18 11:34:52 +02:00
parent dbf022b757
commit d0f8825240
4 changed files with 5 additions and 7 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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) {

View File

@ -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));