you should be able to guard even after combat (and if UFL_MOVED is set).

This commit is contained in:
Enno Rehling 2006-01-29 15:50:38 +00:00
parent 7580c0fd72
commit 3a313515c0
4 changed files with 27 additions and 23 deletions

View File

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

View File

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

View File

@ -591,7 +591,7 @@ init_gmcmd(void)
void
gmcommands(void)
{
region ** rp = &regions;
region ** rp = &regions;
while (*rp) {
region * r = *rp;
unit **up = &r->units;

View File

@ -15,6 +15,7 @@
#include "umlaut.h"
#include "language.h"
#include "log.h"
/* libc includes */
#include <assert.h>
@ -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);
}