From 6aa08b60fd54e3b436768501239d24ec3d122c06 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 10 Jun 2012 05:28:19 -0700 Subject: [PATCH] more process-related bindings and tests --- scripts/tests/bindings.lua | 7 +++++++ src/bindings/bind_process.c | 30 ++++++++++++++++++++++++++++++ src/bindings/bind_process.h | 7 +++++++ src/bindings/process.pkg | 24 +++++++++++++++--------- src/gamecode/laws.c | 16 ++++++++-------- src/gamecode/laws.h | 11 +++++++++-- 6 files changed, 76 insertions(+), 19 deletions(-) diff --git a/scripts/tests/bindings.lua b/scripts/tests/bindings.lua index 90be5e1a9..eb81b21f6 100755 --- a/scripts/tests/bindings.lua +++ b/scripts/tests/bindings.lua @@ -13,10 +13,17 @@ function test_eressea() end function test_process() + assert_equal("function", _G.type(eressea.process.update_long_order)) assert_equal("function", _G.type(eressea.process.markets)) assert_equal("function", _G.type(eressea.process.produce)) + assert_equal("function", _G.type(eressea.process.make_temp)) assert_equal("function", _G.type(eressea.process.settings)) + assert_equal("function", _G.type(eressea.process.set_allies)) + assert_equal("function", _G.type(eressea.process.set_prefix)) + assert_equal("function", _G.type(eressea.process.set_stealth)) + assert_equal("function", _G.type(eressea.process.set_status)) + assert_equal("function", _G.type(eressea.process.set_description)) assert_equal("function", _G.type(eressea.process.set_group)) assert_equal("function", _G.type(eressea.process.set_origin)) assert_equal("function", _G.type(eressea.process.quit)) diff --git a/src/bindings/bind_process.c b/src/bindings/bind_process.c index 4b68bc7bd..105a68480 100755 --- a/src/bindings/bind_process.c +++ b/src/bindings/bind_process.c @@ -16,6 +16,16 @@ void process_produce(void) { } } +void process_update_long_order(void) { + region * r; + for (r=regions; r; r=r->next) { + unit * u; + for (u=r->units; u; u=u->next) { + update_long_order(u); + } + } +} + void process_markets(void) { do_markets(); } @@ -65,6 +75,26 @@ static void process_cmd(keyword_t kwd, int (*callback)(unit *, order *)) } } +void process_ally(void) { + process_cmd(K_ALLY, ally_cmd); +} + +void process_prefix(void) { + process_cmd(K_PREFIX, prefix_cmd); +} + +void process_setstealth(void) { + process_cmd(K_SETSTEALTH, setstealth_cmd); +} + +void process_status(void) { + process_cmd(K_STATUS, status_cmd); +} + +void process_display(void) { + process_cmd(K_DISPLAY, display_cmd); +} + void process_group(void) { process_cmd(K_GROUP, group_cmd); } diff --git a/src/bindings/bind_process.h b/src/bindings/bind_process.h index bd42c63a1..2cd754135 100755 --- a/src/bindings/bind_process.h +++ b/src/bindings/bind_process.h @@ -6,8 +6,15 @@ extern "C" { void process_produce(void); void process_markets(void); +void process_update_long_order(void); + void process_make_temp(void); void process_settings(void); +void process_ally(void); +void process_prefix(void); +void process_setstealth(void); +void process_status(void); +void process_display(void); void process_group(void); void process_origin(void); void process_quit(void); diff --git a/src/bindings/process.pkg b/src/bindings/process.pkg index 662536caf..37086e1cf 100755 --- a/src/bindings/process.pkg +++ b/src/bindings/process.pkg @@ -1,13 +1,19 @@ $#include module eressea { - module process { - void process_markets @ markets(void); - void process_produce @ produce(void); - void process_make_temp @ make_temp(void); - void process_settings @ settings(void); - void process_group @ set_group(void); - void process_origin @ set_origin(void); - void process_quit @ quit(void); - } + module process { + void process_update_long_order @ update_long_order(void); + void process_markets @ markets(void); /* operate the e3 markets */ + void process_produce @ produce(void); /* BUY/SELL/ENTERTAIN/WORK/TAX/STEAL/SPY/SABOTAGE/PLANT/BREED/RESEARCH */ + void process_make_temp @ make_temp(void); /* MAKE TEMP */ + void process_settings @ settings(void); /* EMAIL/PASSWORD/BANNER/OPTION */ + void process_ally @ set_allies(void); /* HELP */ + void process_prefix @ set_prefix(void); /* PREFIX */ + void process_setstealth @ set_stealth(void); /* STEALTH */ + void process_status @ set_status(void); /* STATUS */ + void process_display @ set_description(void); /* DESCRIBE */ + void process_group @ set_group(void); /* GROUP */ + void process_origin @ set_origin(void); /* ORIGIN */ + void process_quit @ quit(void); /* QUIT */ + } } diff --git a/src/gamecode/laws.c b/src/gamecode/laws.c index fee370335..4ad866a11 100755 --- a/src/gamecode/laws.c +++ b/src/gamecode/laws.c @@ -1306,7 +1306,7 @@ static void parse_restart(void) /* HELFE partei [] [NICHT] */ -static int ally_cmd(unit * u, struct order *ord) +int ally_cmd(unit * u, struct order *ord) { ally *sf, **sfp; faction *f; @@ -1461,7 +1461,7 @@ static void init_prefixnames(void) } } -static int prefix_cmd(unit * u, struct order *ord) +int prefix_cmd(unit * u, struct order *ord) { attrib **ap; const char *s; @@ -1523,7 +1523,7 @@ static cmp_building_cb get_cmp_region_owner(void) } } -static int display_cmd(unit * u, struct order *ord) +int display_cmd(unit * u, struct order *ord) { char **s = NULL; const char *str; @@ -1689,7 +1689,7 @@ rename_building(unit * u, order * ord, building * b, const char *name) return rename_cmd(u, ord, &b->name, name); } -static int name_cmd(unit * u, struct order *ord) +int name_cmd(struct unit *u, struct order *ord) { building *b = u->building; region *r = u->region; @@ -2572,7 +2572,7 @@ static int reshow_cmd(unit * u, struct order *ord) return 0; } -static int status_cmd(unit * u, struct order *ord) +int status_cmd(unit * u, struct order *ord) { const char *param; @@ -3429,7 +3429,7 @@ void check_long_orders(unit * u) } } -static void setdefaults(unit * u) +void update_long_order(unit * u) { order *ord; boolean trade = false; @@ -4043,7 +4043,7 @@ void process(void) cmistake(u, ord, 224, MSG_MAGIC); ord = NULL; } else if (fval(u, UFL_LONGACTION)) { - /* this message was already given in laws.setdefaults + /* this message was already given in laws.update_long_order cmistake(u, ord, 52, MSG_PRODUCE); */ ord = NULL; @@ -4153,7 +4153,7 @@ void init_processor(void) add_proc_global(p, &new_units, "Neue Einheiten erschaffen"); p += 10; - add_proc_unit(p, &setdefaults, "Default-Befehle"); + add_proc_unit(p, update_long_order, "Langen Befehl aktualisieren"); add_proc_order(p, K_BANNER, banner_cmd, 0, NULL); add_proc_order(p, K_EMAIL, &email_cmd, 0, NULL); add_proc_order(p, K_PASSWORD, &password_cmd, 0, NULL); diff --git a/src/gamecode/laws.h b/src/gamecode/laws.h index 228c84b6a..2d9cc2ce7 100755 --- a/src/gamecode/laws.h +++ b/src/gamecode/laws.h @@ -47,14 +47,21 @@ extern "C" { extern void new_units(void); extern void quit(void); + extern void update_long_order(struct unit * u); extern int password_cmd(struct unit *u, struct order *ord); extern int banner_cmd(struct unit *u, struct order *ord); extern int email_cmd(struct unit *u, struct order *ord); extern int send_cmd(struct unit *u, struct order *ord); - extern int origin_cmd(struct unit *u, struct order *ord); + extern int ally_cmd(struct unit* u, struct order *ord); + extern int prefix_cmd(struct unit *u, struct order *ord); + extern int setstealth_cmd(struct unit *u, struct order *ord); + extern int status_cmd(struct unit *u, struct order *ord); + extern int display_cmd(struct unit *u, struct order *ord); extern int group_cmd(struct unit *u, struct order *ord); + extern int origin_cmd(struct unit *u, struct order *ord); extern int quit_cmd(struct unit *u, struct order *ord); - + extern int name_cmd(struct unit *u, struct order *ord); + #ifdef __cplusplus } #endif