From f11005c686f672db9cd7991a5d04e4072dace986 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 17 Jun 2012 11:08:48 -0700 Subject: [PATCH] remove the XONTORMIA & WEREWOLF commands. --- src/CMakeLists.txt | 1 - src/gamecode/laws.c | 19 ++------ src/items/xerewards.c | 2 +- src/kernel/config.c | 19 +------- src/kernel/config.h | 4 -- src/kernel/order.c | 4 -- src/kernel/types.h | 2 - src/modules/xecmd.c | 108 ------------------------------------------ src/modules/xecmd.h | 26 ---------- src/settings.h | 1 - src/util/attrib.c | 59 ++++++++++++++++------- src/util/attrib.h | 1 + 12 files changed, 50 insertions(+), 196 deletions(-) delete mode 100644 src/modules/xecmd.c delete mode 100644 src/modules/xecmd.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c4ae79c8d..c5166356c 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -160,7 +160,6 @@ set (LIB_SRC modules/score.c modules/weather.c modules/wormhole.c - modules/xecmd.c modules/xmas.c triggers/changefaction.c triggers/changerace.c diff --git a/src/gamecode/laws.c b/src/gamecode/laws.c index dddbde16f..57756a569 100755 --- a/src/gamecode/laws.c +++ b/src/gamecode/laws.c @@ -88,7 +88,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -#include #include /* libc includes */ @@ -3639,8 +3638,6 @@ void check_long_orders(unit * u) cmistake(u, ord, 52, MSG_EVENT); } break; - case K_WEREWOLF: - /* don't know what WEREWOLF does... */ default: cmistake(u, ord, 52, MSG_EVENT); } @@ -3696,7 +3693,10 @@ void update_long_order(unit * u) case K_BUY: case K_SELL: /* Wenn die Einheit handelt, muß der Default-Befehl gelöscht - * werden. */ + * werden. + * Wird je diese Ausschliesslichkeit aufgehoben, muss man aufpassen + * mit der Reihenfolge von Kaufen, Verkaufen etc., damit es Spielern + * nicht moeglich ist, Schulden zu machen. */ trade = true; break; @@ -3706,13 +3706,6 @@ void update_long_order(unit * u) set_order(&u->thisorder, NULL); break; - case K_WEREWOLF: - set_order(&u->thisorder, copy_order(ord)); - break; - - /* Wird je diese Ausschliesslichkeit aufgehoben, muss man aufpassen - * mit der Reihenfolge von Kaufen, Verkaufen etc., damit es Spielern - * nicht moeglich ist, Schulden zu machen. */ default: break; } @@ -4580,10 +4573,6 @@ void init_processor(void) p += 10; add_proc_order(p, K_GUARD, &guard_on_cmd, 0, "Bewache (an)"); -#if XECMD_MODULE - /* can do together with guard */ - add_proc_order(p, K_XE, &xecmd, 0, "Zeitung"); -#endif p += 10; add_proc_global(p, &encounters, "Zufallsbegegnungen"); diff --git a/src/items/xerewards.c b/src/items/xerewards.c index fb1a9595d..26cd621bb 100644 --- a/src/items/xerewards.c +++ b/src/items/xerewards.c @@ -54,7 +54,7 @@ use_skillpotion(struct unit *u, const struct item_type *itype, int amount, while (sv != u->skills + u->skill_size) { int i; for (i = 0; i != 3; ++i) - learn_skill(u, sv->id, 1.0); + learn_skill(u, (skill_t)sv->id, 1.0); ++sv; } } diff --git a/src/kernel/config.c b/src/kernel/config.c index 63b66f127..eb7dd489e 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -99,18 +99,6 @@ boolean sqlpatch = false; boolean battledebug = false; int turn = 0; -#if XECMD_MODULE -attrib_type at_xontormiaexpress = { - "xontormiaexpress", - DEFAULT_INIT, - DEFAULT_FINALIZE, - DEFAULT_AGE, - a_writeint, - a_readint, - ATF_UNIQUE -}; -#endif - int NewbieImmunity(void) { static int value = -1; @@ -458,8 +446,6 @@ const char *keywords[MAXKEYWORDS] = { "INFO", "PRAEFIX", "PFLANZEN", - "WERWESEN", - "XONTORMIA", "ALLIANZ", "BEANSPRUCHEN", "PROMOTION", @@ -3021,9 +3007,8 @@ void attrib_init(void) register_function((pf_generic) & minimum_wage, "minimum_wage"); at_register(&at_germs); -#if XECMD_MODULE - at_register(&at_xontormiaexpress); /* required for old datafiles */ -#endif + + at_deprecate("xontormiaexpress", a_readint); /* required for old datafiles */ at_register(&at_speedup); at_register(&at_building_action); } diff --git a/src/kernel/config.h b/src/kernel/config.h index 510678c27..6e8a1a142 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -458,10 +458,6 @@ extern "C" { # define count_unit(u) 1 #endif -#if XECMD_MODULE - extern struct attrib_type at_xontormiaexpress; -#endif - #ifdef __cplusplus } #endif diff --git a/src/kernel/order.c b/src/kernel/order.c index 9547d4446..9004fd4db 100644 --- a/src/kernel/order.c +++ b/src/kernel/order.c @@ -447,8 +447,6 @@ int is_exclusive(const order * ord) switch (kwd) { case K_MOVE: - case K_WEREWOLF: - /* these should not become persistent */ case K_ROUTE: case K_DRIVE: case K_WORK: @@ -513,7 +511,6 @@ int is_long(const order * ord) case K_BUY: case K_SELL: case K_MOVE: - case K_WEREWOLF: case K_ROUTE: case K_DRIVE: case K_WORK: @@ -573,7 +570,6 @@ int is_persistent(const order * ord) int persist = ord->_persistent != 0; switch (kwd) { case K_MOVE: - case K_WEREWOLF: case NOKEYWORD: /* lang, aber niemals persistent! */ return false; diff --git a/src/kernel/types.h b/src/kernel/types.h index ca4a3bc06..3fec2174d 100644 --- a/src/kernel/types.h +++ b/src/kernel/types.h @@ -137,8 +137,6 @@ typedef enum { K_INFO, /* set player-info */ K_PREFIX, K_PLANT, - K_WEREWOLF, - K_XE, K_ALLIANCE, K_CLAIM, K_PROMOTION, diff --git a/src/modules/xecmd.c b/src/modules/xecmd.c deleted file mode 100644 index e45c611cd..000000000 --- a/src/modules/xecmd.c +++ /dev/null @@ -1,108 +0,0 @@ -/* vi: set ts=2: - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. -*/ - -#include -#include - -#if XECMD_MODULE -#include "xecmd.h" - -#include - -#include "xecmd.h" - -/* kernel includes */ -#include -#include -#include -#include -#include -#include -#include -#include - -/* util includes */ -#include -#include -#include - -/* libc includes */ -#include -#include -#include - -static void xe_givelaen(unit * u, struct order *ord) -{ - unit *u2 = getunitg(u->region, u->faction); - - if (!u2) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", - "")); - return; - } - i_change(&u2->items, olditemtype[I_LAEN], 5); -} - -static void xe_givepotion(unit * u, struct order *ord) -{ - unit *u2 = getunitg(u->region, u->faction); - - if (!u2) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", - "")); - return; - } - i_change(&u2->items, it_find("skillpotion"), 1); -} - -static void xe_giveballon(unit * u, struct order *ord) -{ - unit *u2 = getunitg(u->region, u->faction); - ship *sh; - - if (!u2) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", - "")); - return; - } - - sh = new_ship(st_find("balloon"), u2->region, u2->faction->locale); - sh->size = 5; - ship_setname(sh, "Xontormia-Ballon"); - leave(u2, true); - u_set_ship(u2, sh); -} - -int xecmd(unit * u, order * ord) -{ - faction *f = u->faction; - - if (a_find(f->attribs, &at_xontormiaexpress)) { - if (get_keyword(ord) == K_XE) { - param_t param; - - init_tokens(ord); - skip_token(); - param = findparam(getstrtoken(), f->locale); - if (param == P_XEPOTION) { - xe_givepotion(u, ord); - } else if (param == P_XEBALLOON) { - xe_giveballon(u, ord); - } else if (param == P_XELAEN) { - xe_givelaen(u, ord); - } - } - } - return 0; -} - -#endif diff --git a/src/modules/xecmd.h b/src/modules/xecmd.h deleted file mode 100644 index cf1beef00..000000000 --- a/src/modules/xecmd.h +++ /dev/null @@ -1,26 +0,0 @@ -/* vi: set ts=2: - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. -*/ - -#ifndef H_MOD_XECMD_H -#define H_MOD_XECMD_H -#ifdef __cplusplus -extern "C" { -#endif - -#if XECMD_MODULE - int xecmd(struct unit *u, struct order *ord); -#endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/settings.h b/src/settings.h index fd0607625..087f37cae 100644 --- a/src/settings.h +++ b/src/settings.h @@ -44,7 +44,6 @@ #define SCORE_MODULE 1 #define MUSEUM_MODULE 1 #define ARENA_MODULE 1 -#define XECMD_MODULE 1 #define DUNGEON_MODULE 0 #define CHANGED_CROSSBOWS 0 /* use the WTF_ARMORPIERCING flag */ #undef GLOBAL_WARMING /* number of turns before global warming sets in */ diff --git a/src/util/attrib.c b/src/util/attrib.c index 147b006b5..f76b48427 100644 --- a/src/util/attrib.c +++ b/src/util/attrib.c @@ -22,6 +22,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "log.h" #include "storage.h" +#include + #include #include #include @@ -261,6 +263,16 @@ int a_age(attrib ** p) return (*p != NULL); } +static critbit_tree cb_deprecated = { 0 }; + +void at_deprecate(const char * name, int (*reader)(attrib *, void *, struct storage *)) +{ + char buffer[64]; + size_t len = strlen(name); + len = cb_new_kv(name, len, &reader, sizeof(reader), buffer); + cb_insert(&cb_deprecated, buffer, len); +} + int a_read(struct storage *store, attrib ** attribs, void *owner) { int key, retval = AT_READ_OK; @@ -275,25 +287,38 @@ int a_read(struct storage *store, attrib ** attribs, void *owner) key = __at_hashkey(zText); while (key != -1) { + int (*reader)(attrib *, void *, struct storage *) = 0; attrib_type *at = at_find(key); - if (!at) { - fprintf(stderr, "attribute hash: %d (%s)\n", key, zText); - assert(at || !"attribute not registered"); + attrib * na = 0; + + if (at) { + reader = at->read; + na = a_new(at); + } else { + const void * kv; + cb_find_prefix(&cb_deprecated, zText, strlen(zText)+1, &kv, 1, 0); + if (kv) { + cb_get_kv(kv, &reader, sizeof(reader)); + } else { + fprintf(stderr, "attribute hash: %d (%s)\n", key, zText); + assert(at || !"attribute not registered"); + } } - if (at->read) { - attrib *na = a_new(at); - int i = at->read(na, owner, store); - switch (i) { - case AT_READ_OK: - a_add(attribs, na); - break; - case AT_READ_FAIL: - retval = AT_READ_FAIL; - a_free(na); - break; - default: - assert(!"invalid return value"); - break; + if (reader) { + int i = reader(na, owner, store); + if (na) { + switch (i) { + case AT_READ_OK: + a_add(attribs, na); + break; + case AT_READ_FAIL: + retval = AT_READ_FAIL; + a_free(na); + break; + default: + assert(!"invalid return value"); + break; + } } } else { assert(!"fehler: keine laderoutine für attribut"); diff --git a/src/util/attrib.h b/src/util/attrib.h index a2805e8c7..47c0e29fd 100644 --- a/src/util/attrib.h +++ b/src/util/attrib.h @@ -61,6 +61,7 @@ extern "C" { } attrib_type; extern void at_register(attrib_type * at); + extern void at_deprecate(const char * name, int (*reader)(attrib *, void *, struct storage *)); extern attrib *a_select(attrib * a, const void *data, boolean(*compare) (const attrib *, const void *));