diff --git a/src/battle.c b/src/battle.c index fdc29bcb7..1e0924aee 100644 --- a/src/battle.c +++ b/src/battle.c @@ -948,22 +948,6 @@ void drain_exp(struct unit *u, int n) } } -const char *rel_dam(int dam, int hp) -{ - double q = (double)dam / (double)hp; - - if (q > 0.75) { - return "eine klaffende Wunde"; - } - else if (q > 0.5) { - return "eine schwere Wunde"; - } - else if (q > 0.25) { - return "eine Wunde"; - } - return "eine kleine Wunde"; -} - static void vampirism(troop at, int damage) { if (rule_vampire > 0) { diff --git a/src/economy.test.c b/src/economy.test.c index 3e5d39007..0ed869ef0 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -250,7 +250,7 @@ static void test_trade_insect(CuTest *tc) { unit_addorder(u, create_order(K_BUY, u->faction->locale, "1 %s", LOC(u->faction->locale, resourcename(it_luxury->rtype, 0)))); - set_item(u, it_silver, 10); + test_set_item(u, it_silver, 10); CuAssertPtrEquals(tc, r, u->region); CuAssertPtrEquals(tc, (void *)it_luxury, (void *)r_luxury(u->region)); produce(u->region); @@ -283,7 +283,7 @@ static void test_buy_cmd(CuTest *tc) { u = test_create_unit(test_create_faction(NULL), r); unit_addorder(u, create_order(K_BUY, u->faction->locale, "1 %s", LOC(u->faction->locale, resourcename(it_luxury->rtype, 0)))); - set_item(u, rt_silver->itype, 1000); + test_set_item(u, rt_silver->itype, 1000); produce(r); CuAssertPtrNotNullMsg(tc, "trading requires a castle", test_find_messagetype(u->faction->msgs, "error119")); @@ -525,13 +525,13 @@ static void test_modify_material(CuTest *tc) { itype->construction->materials[0].rtype = rtype; itype->construction->materials[0].number = 2; - set_item(u, rtype->itype, 1); /* 1 iron should get us 1 sword */ + test_set_item(u, rtype->itype, 1); /* 1 iron should get us 1 sword */ make_item(u, itype, 1); CuAssertIntEquals(tc, 1, get_item(u, itype)); CuAssertIntEquals(tc, 0, get_item(u, rtype->itype)); u_setrace(u, test_create_race("smurf")); - set_item(u, rtype->itype, 2); /* 2 iron should be required now */ + test_set_item(u, rtype->itype, 2); /* 2 iron should be required now */ make_item(u, itype, 1); CuAssertIntEquals(tc, 2, get_item(u, itype)); CuAssertIntEquals(tc, 0, get_item(u, rtype->itype)); @@ -576,20 +576,20 @@ static void test_modify_skill(CuTest *tc) { mod[0].value.sa[1] = 1; mod[0].race_mask = rc_mask(u_race(u)); - set_item(u, rtype->itype, 2); /* 2 iron should get us 2 swords */ + test_set_item(u, rtype->itype, 2); /* 2 iron should get us 2 swords */ make_item(u, itype, 2); CuAssertIntEquals(tc, 2, get_item(u, itype)); CuAssertIntEquals(tc, 0, get_item(u, rtype->itype)); mod[0].value.sa[0] = NOSKILL; /* match any skill */ - set_item(u, rtype->itype, 2); + test_set_item(u, rtype->itype, 2); make_item(u, itype, 2); CuAssertIntEquals(tc, 4, get_item(u, itype)); CuAssertIntEquals(tc, 0, get_item(u, rtype->itype)); u_setrace(u, test_create_race("smurf")); - set_item(u, rtype->itype, 2); + test_set_item(u, rtype->itype, 2); make_item(u, itype, 1); /* only enough skill to make 1 now */ CuAssertIntEquals(tc, 5, get_item(u, itype)); CuAssertIntEquals(tc, 1, get_item(u, rtype->itype)); @@ -626,7 +626,7 @@ static void test_modify_production(CuTest *tc) { itype->construction->materials[0].rtype = rt_silver; itype->construction->materials[0].number = 1; set_level(u, SK_ALCHEMY, 1); - set_item(u, rt_silver->itype, 1); + test_set_item(u, rt_silver->itype, 1); make_item(u, itype, 1); CuAssertIntEquals(tc, 1, get_item(u, itype)); CuAssertIntEquals(tc, 0, get_item(u, rt_silver->itype)); diff --git a/src/kernel/connection.c b/src/kernel/connection.c index 9cfe9c140..014fce9d8 100644 --- a/src/kernel/connection.c +++ b/src/kernel/connection.c @@ -73,36 +73,6 @@ void free_borders(void) } } -connection *find_border(int id) -{ - int key; - for (key = 0; key != BORDER_MAXHASH; key++) { - connection *bhash; - for (bhash = borders[key]; bhash != NULL; bhash = bhash->nexthash) { - connection *b; - for (b = bhash; b; b = b->next) { - if (b->id == id) - return b; - } - } - } - return NULL; -} - -int resolve_borderid(variant id, void *addr) -{ - int result = 0; - connection *b = NULL; - if (id.i != 0) { - b = find_border(id.i); - if (b == NULL) { - result = -1; - } - } - *(connection **)addr = b; - return result; -} - static void walk_i(region *r, connection *b, void(*cb)(connection *, void *), void *data) { for (; b; b = b->nexthash) { if (b->from == r || b->to == r) { diff --git a/src/kernel/connection.h b/src/kernel/connection.h index 80177c638..c847f690f 100644 --- a/src/kernel/connection.h +++ b/src/kernel/connection.h @@ -97,8 +97,6 @@ extern "C" { struct border_type *next; /* for internal use only */ } border_type; - connection *find_border(int id); - int resolve_borderid(variant data, void *addr); void free_borders(void); void walk_connections(struct region *r, void(*cb)(struct connection *, void *), void *data); diff --git a/src/kernel/item.c b/src/kernel/item.c index 7307c82c2..d641e8837 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -582,22 +582,6 @@ int get_item(const unit * u, const item_type *itype) return i ? i->number : 0; } -int set_item(unit * u, const item_type *itype, int value) -{ - item *i; - - assert(itype); - i = *i_find(&u->items, itype); - if (!i) { - i = i_add(&u->items, i_new(itype, value)); - } - else { - i->number = value; - assert(i->number >= 0); - } - return value; -} - #include "move.h" static int diff --git a/src/kernel/item.h b/src/kernel/item.h index e08c95e57..789517e95 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -284,7 +284,6 @@ extern "C" { struct item *item_spoil(const struct race *rc, int size); int get_item(const struct unit * u, const struct item_type *itype); - int set_item(struct unit * u, const struct item_type *itype, int value); int get_money(const struct unit *); int set_money(struct unit *, int); int change_money(struct unit *, int); diff --git a/src/move.c b/src/move.c index f98da3431..c1ded5faa 100644 --- a/src/move.c +++ b/src/move.c @@ -2022,17 +2022,6 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting) * the token parser needs to be initialized before calling this function! */ -/** fleeing units use this function -*/ -void run_to(unit * u, region * to) -{ - region_list *route = NULL; - add_regionlist(&route, to); - travel_route(u, route, NULL, NULL, TRAVEL_RUNNING); - free_regionlist(route); - /* weder transport noch follow */ -} - static const region_list *travel_i(unit * u, const region_list * route_begin, const region_list * route_end, order * ord, int mode, follower ** followers) { diff --git a/src/tests.c b/src/tests.c index d69651b82..01767d801 100644 --- a/src/tests.c +++ b/src/tests.c @@ -37,6 +37,22 @@ #include #include +int test_set_item(unit * u, const item_type *itype, int value) +{ + item *i; + + assert(itype); + i = *i_find(&u->items, itype); + if (!i) { + i = i_add(&u->items, i_new(itype, value)); + } + else { + i->number = value; + assert(i->number >= 0); + } + return value; +} + struct race *test_create_race(const char *name) { race *rc = rc_get_or_create(name ? name : "smurf"); diff --git a/src/tests.h b/src/tests.h index c3eb6bae3..dd8bed3c8 100644 --- a/src/tests.h +++ b/src/tests.h @@ -58,6 +58,7 @@ extern "C" { struct building_type *test_create_buildingtype(const char *name); void test_create_castorder(struct castorder *co, struct unit *u, int level, float force, int range, struct spellparameter *par); struct spell * test_create_spell(void); + int test_set_item(struct unit * u, const struct item_type *itype, int value); void test_translate_param(const struct locale *lang, param_t param, const char *text); const char * test_get_messagetype(const struct message *msg);