forked from github/server
you should be able to guard even after combat (and if UFL_MOVED is set).
This commit is contained in:
parent
7580c0fd72
commit
3a313515c0
4 changed files with 27 additions and 23 deletions
|
@ -2758,7 +2758,6 @@ update_guards(void)
|
||||||
static int
|
static int
|
||||||
guard_on_cmd(unit * u, struct order * ord)
|
guard_on_cmd(unit * u, struct order * ord)
|
||||||
{
|
{
|
||||||
if (fval(u, UFL_MOVED)) return 0;
|
|
||||||
assert(get_keyword(ord)==K_GUARD);
|
assert(get_keyword(ord)==K_GUARD);
|
||||||
|
|
||||||
init_tokens(ord);
|
init_tokens(ord);
|
||||||
|
|
|
@ -119,7 +119,7 @@ reduce_weight(unit * u)
|
||||||
static boolean
|
static boolean
|
||||||
is_waiting(const unit * u)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -591,7 +591,7 @@ init_gmcmd(void)
|
||||||
void
|
void
|
||||||
gmcommands(void)
|
gmcommands(void)
|
||||||
{
|
{
|
||||||
region ** rp = ®ions;
|
region ** rp = ®ions;
|
||||||
while (*rp) {
|
while (*rp) {
|
||||||
region * r = *rp;
|
region * r = *rp;
|
||||||
unit **up = &r->units;
|
unit **up = &r->units;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "umlaut.h"
|
#include "umlaut.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -65,38 +66,42 @@ add_command(struct tnode * keys, struct tnode * tnext,
|
||||||
addtoken(keys, str, var);
|
addtoken(keys, str, var);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static int
|
||||||
do_command_i(const struct tnode * keys, void * u, const char * str, struct order * ord)
|
do_command_i(const struct tnode * keys, void * u, const char * str, struct order * ord)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
char zText[16];
|
char zText[16];
|
||||||
const char * c;
|
const char * c;
|
||||||
variant var;
|
variant var;
|
||||||
|
|
||||||
while (isspace(*str)) ++str;
|
while (isspace(*str)) ++str;
|
||||||
c = str;
|
c = str;
|
||||||
while (isalnum(*c)) ++c;
|
while (isalnum(*c)) ++c;
|
||||||
i = min(16, c-str);
|
i = min(16, c-str);
|
||||||
strncpy(zText, str, i);
|
strncpy(zText, str, i);
|
||||||
zText[i]=0;
|
zText[i]=0;
|
||||||
if (findtoken(keys, zText, &var)==E_TOK_SUCCESS) {
|
if (findtoken(keys, zText, &var)==E_TOK_SUCCESS) {
|
||||||
command * cmd = (command *)var.v;
|
command * cmd = (command *)var.v;
|
||||||
if (cmd->nodes) {
|
if (cmd->nodes && *c) {
|
||||||
assert(!cmd->fun);
|
assert(!cmd->fun);
|
||||||
do_command_i(cmd->nodes, u, ++c, ord);
|
return do_command_i(cmd->nodes, u, ++c, ord);
|
||||||
return;
|
} else if (cmd->fun) {
|
||||||
}
|
cmd->fun(cmd->nodes, ++c, u, ord);
|
||||||
assert(cmd->fun);
|
return E_TOK_SUCCESS;
|
||||||
cmd->fun(cmd->nodes, ++c, u, ord);
|
}
|
||||||
}
|
}
|
||||||
|
return E_TOK_NOMATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern char * getcommand(struct order * ord);
|
extern char * getcommand(struct order * ord);
|
||||||
|
extern char * unitname(struct unit * u);
|
||||||
|
|
||||||
void
|
void
|
||||||
do_command(const struct tnode * keys, void * u, struct order * ord)
|
do_command(const struct tnode * keys, void * u, struct order * ord)
|
||||||
{
|
{
|
||||||
char * cmd = getcommand(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);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue