From 3a313515c046de5ffd7c16b8c96b6adece9250a8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 29 Jan 2006 15:50:38 +0000 Subject: [PATCH] you should be able to guard even after combat (and if UFL_MOVED is set). --- src/common/gamecode/laws.c | 1 - src/common/gamecode/monster.c | 2 +- src/common/modules/gmcmd.c | 2 +- src/common/util/command.c | 45 +++++++++++++++++++---------------- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index bff7c47bd..e4b59740f 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -2758,7 +2758,6 @@ update_guards(void) static int guard_on_cmd(unit * u, struct order * ord) { - if (fval(u, UFL_MOVED)) return 0; assert(get_keyword(ord)==K_GUARD); init_tokens(ord); diff --git a/src/common/gamecode/monster.c b/src/common/gamecode/monster.c index e8f70a192..bf06d75a2 100644 --- a/src/common/gamecode/monster.c +++ b/src/common/gamecode/monster.c @@ -119,7 +119,7 @@ reduce_weight(unit * u) static boolean is_waiting(const unit * u) { - if (fval(u, UFL_ISNEW|UFL_MOVED)) return true; + if (fval(u, UFL_ISNEW|UFL_MOVED)) return true; return false; } diff --git a/src/common/modules/gmcmd.c b/src/common/modules/gmcmd.c index 957f44a37..c97635e9b 100644 --- a/src/common/modules/gmcmd.c +++ b/src/common/modules/gmcmd.c @@ -591,7 +591,7 @@ init_gmcmd(void) void gmcommands(void) { - region ** rp = ®ions; + region ** rp = ®ions; while (*rp) { region * r = *rp; unit **up = &r->units; diff --git a/src/common/util/command.c b/src/common/util/command.c index 1af090c61..899f3325d 100644 --- a/src/common/util/command.c +++ b/src/common/util/command.c @@ -15,6 +15,7 @@ #include "umlaut.h" #include "language.h" +#include "log.h" /* libc includes */ #include @@ -65,38 +66,42 @@ add_command(struct tnode * keys, struct tnode * tnext, addtoken(keys, str, var); } -static void +static int do_command_i(const struct tnode * keys, void * u, const char * str, struct order * ord) { - size_t i; - char zText[16]; - const char * c; + size_t i; + char zText[16]; + const char * c; variant var; - while (isspace(*str)) ++str; - c = str; - while (isalnum(*c)) ++c; - i = min(16, c-str); - strncpy(zText, str, i); - zText[i]=0; - if (findtoken(keys, zText, &var)==E_TOK_SUCCESS) { + while (isspace(*str)) ++str; + c = str; + while (isalnum(*c)) ++c; + i = min(16, c-str); + strncpy(zText, str, i); + zText[i]=0; + if (findtoken(keys, zText, &var)==E_TOK_SUCCESS) { command * cmd = (command *)var.v; - if (cmd->nodes) { - assert(!cmd->fun); - do_command_i(cmd->nodes, u, ++c, ord); - return; - } - assert(cmd->fun); - cmd->fun(cmd->nodes, ++c, u, ord); - } + if (cmd->nodes && *c) { + assert(!cmd->fun); + return do_command_i(cmd->nodes, u, ++c, ord); + } else if (cmd->fun) { + cmd->fun(cmd->nodes, ++c, u, ord); + return E_TOK_SUCCESS; + } + } + return E_TOK_NOMATCH; } extern char * getcommand(struct order * ord); +extern char * unitname(struct unit * u); void do_command(const struct tnode * keys, void * u, struct order * ord) { char * cmd = getcommand(ord); - do_command_i(keys, u, cmd, ord); + if (do_command_i(keys, u, cmd, ord)!=E_TOK_SUCCESS) { + log_warning(("%s failed GM command '%s'\n", unitname(u), cmd)); + } free(cmd); }