diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index 898048c0c..918abbb80 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -46,7 +46,6 @@ names.c order.c pathfinder.c plane.c -player.c pool.c race.c region.c diff --git a/src/kernel/faction.h b/src/kernel/faction.h index c43d48089..52f3c271a 100644 --- a/src/kernel/faction.h +++ b/src/kernel/faction.h @@ -25,7 +25,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. extern "C" { #endif - struct player; struct alliance; struct item; struct seen_region; @@ -60,7 +59,6 @@ typedef struct faction { struct faction *next; struct faction *nexthash; - struct player *owner; #ifdef SMART_INTERVALS struct region *first; struct region *last; diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 9ac975789..a0b82f5b9 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -1,11 +1,39 @@ #include #include +#include #include +#include #include "faction.h" #include #include -void test_get_monsters(CuTest *tc) { +static void test_addfaction(CuTest *tc) { + faction *f = 0; + const struct race *rc = rc_get_or_create("human"); + const struct locale *lang = get_or_create_locale("en"); + + f = addfaction("test@eressea.de", "hurrdurr", rc, lang, 1234); + CuAssertPtrNotNull(tc, f); + CuAssertPtrNotNull(tc, f->name); + CuAssertPtrEquals(tc, NULL, (void *)f->units); + CuAssertPtrEquals(tc, NULL, (void *)f->next); + CuAssertPtrEquals(tc, NULL, (void *)f->banner); + CuAssertPtrEquals(tc, NULL, (void *)f->spellbook); + CuAssertPtrEquals(tc, NULL, (void *)f->ursprung); + CuAssertPtrEquals(tc, (void *)factions, (void *)f); + CuAssertStrEquals(tc, "test@eressea.de", f->email); + CuAssertStrEquals(tc, "hurrdurr", f->passw); + CuAssertPtrEquals(tc, (void *)lang, (void *)f->locale); + CuAssertIntEquals(tc, 1234, f->subscription); + CuAssertIntEquals(tc, 0, f->flags); + CuAssertIntEquals(tc, 0, f->age); + CuAssertIntEquals(tc, 1, f->alive); + CuAssertIntEquals(tc, M_GRAY, f->magiegebiet); + CuAssertIntEquals(tc, turn, f->lastorders); + CuAssertPtrEquals(tc, f, findfaction(f->no)); +} + +static void test_get_monsters(CuTest *tc) { faction *f; CuAssertPtrEquals(tc, NULL, get_monsters()); f = get_or_create_monsters(); @@ -22,6 +50,7 @@ void test_get_monsters(CuTest *tc) { CuSuite *get_faction_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_addfaction); SUITE_ADD_TEST(suite, test_get_monsters); return suite; } diff --git a/src/kernel/order.c b/src/kernel/order.c index 1c85d3d0c..8434b5dbd 100644 --- a/src/kernel/order.c +++ b/src/kernel/order.c @@ -256,6 +256,11 @@ static order *create_order_i(keyword_t kwd, const char *sptr, int persistent, order *ord = NULL; int lindex; + if (keyword_disabled(kwd)) { + log_error("trying to create an order for disabled keyword %s.", keyword(kwd)); + return NULL; + } + /* if this is just nonsense, then we skip it. */ if (lomem) { switch (kwd) { diff --git a/src/kernel/player.c b/src/kernel/player.c deleted file mode 100644 index 55261714c..000000000 --- a/src/kernel/player.c +++ /dev/null @@ -1,103 +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 "player.h" - -#include -#include - -#include -#include -#include - -#define PMAXHASH 1021 - -typedef struct player_hash { - struct player *entries; -} player_hash; - -static player_hash *players[PMAXHASH]; - -player *make_player(const struct faction *f) -{ - player *p = calloc(sizeof(player), 1); - unsigned int hash; - - for (p->id = rng_int();; p->id++) { - /* if there is a hashing conflict, resolve it */ - player *pi = get_player(p->id); - if (pi) - p->id++; - else - break; - } - hash = p->id % PMAXHASH; - p->faction = f; - p->nexthash = players[hash]->entries; - players[hash]->entries = p; - - return p; -} - -player *next_player(player * p) -{ - if (p->nexthash) - return p->nexthash; - else { - unsigned int hash = p->id % PMAXHASH; - p = NULL; - while (++hash != PMAXHASH) { - if (players[hash]->entries != NULL) { - p = players[hash]->entries; - break; - } - } - return p; - } -} - -player *get_player(unsigned int id) -{ - unsigned int hash = id % PMAXHASH; - struct player *p = players[hash]->entries; - - while (p && p->id != id) - p = p->nexthash; - return p; -} - -player *get_players(void) -{ - struct player *p = NULL; - unsigned int hash = 0; - - while (p != NULL && hash != PMAXHASH) { - p = players[hash++]->entries; - } - return p; -} - -void players_done(void) -{ - int i; - for (i = 0; i != PMAXHASH; ++i) { - player *p = players[i]->entries; - players[i]->entries = p->nexthash; - free(p->name); - if (p->email) - free(p->email); - if (p->name) - free(p->name); - free(p); - } -} diff --git a/src/kernel/player.h b/src/kernel/player.h deleted file mode 100644 index a53a9e75a..000000000 --- a/src/kernel/player.h +++ /dev/null @@ -1,43 +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_KRNL_PLAYER -#define H_KRNL_PLAYER -#ifdef __cplusplus -extern "C" { -#endif - - struct faction; - - typedef struct player { - unsigned int id; - char *name; - char *email; - char *address; - struct vacation { - int weeks; - char *email; - } *vacation; - const struct faction *faction; - - struct player *nexthash; /* don't use! */ - } player; - - extern struct player *get_players(void); - extern struct player *get_player(unsigned int id); - extern struct player *make_player(const struct faction *f); - extern struct player *next_player(struct player *p); - -#ifdef __cplusplus -} -#endif -#endif