From 01877f5169a1c171562653609a0de52631e45653 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 10 Dec 2014 09:39:11 +0100 Subject: [PATCH] cleanup, fix a TODO, eliminate dead code. --- src/alchemy.c | 4 ---- src/battle.c | 21 +++--------------- src/bind_building.c | 4 ---- src/kernel/config.c | 14 ------------ src/kernel/item.c | 3 --- src/kernel/xmlreader.c | 37 -------------------------------- src/spells.c | 41 ------------------------------------ src/triggers/changefaction.c | 2 +- 8 files changed, 4 insertions(+), 122 deletions(-) diff --git a/src/alchemy.c b/src/alchemy.c index 0b0a506e7..7e055b4a8 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -215,10 +215,6 @@ static int age_potiondelay(attrib * a) return AT_AGE_REMOVE; } -/* TODO: - * - this should be a more general item_delay - * - it should not just happen in age(), but be done with eventhandling - */ attrib_type at_potiondelay = { "potiondelay", init_potiondelay, diff --git a/src/battle.c b/src/battle.c index d796b27ac..d1adc22a1 100644 --- a/src/battle.c +++ b/src/battle.c @@ -2052,9 +2052,6 @@ void dazzle(battle * b, troop * td) td->fighter->person[td->index].defence--; } -/* TODO: Gebäude/Schiffe sollten auch zerstörbar sein. Schwierig im Kampf, - * besonders bei Schiffen. */ - void damage_building(battle * b, building * bldg, int damage_abs) { bldg->size = _max(1, bldg->size - damage_abs); @@ -2262,9 +2259,9 @@ static void attack(battle * b, troop ta, const att * a, int numattack) ta.fighter->person[ta.index].last_action = b->turn; } if (td.fighter->unit->ship) { - /* FIXME should use damage_ship here? */ - td.fighter->unit->ship->damage += - DAMAGE_SCALE * dice_rand(a->data.dice); + int dice = dice_rand(a->data.dice); + ship * sh = td.fighter->unit->ship; + damage_ship(sh, dice / sh->type->damage / sh->size); } else if (td.fighter->unit->building) { damage_building(b, td.fighter->unit->building, dice_rand(a->data.dice)); @@ -3689,18 +3686,6 @@ static void free_battle(battle * b) static int *get_alive(side * s) { -#if 0 - static int alive[NUMROWS]; - fighter *fig; - memset(alive, 0, NUMROWS * sizeof(int)); - for (fig = s->fighters; fig; fig = fig->next) { - if (fig->alive > 0) { - int row = statusrow(fig); - alive[row] += fig->alive; - } - } - return alive; -#endif return s->size; } diff --git a/src/bind_building.c b/src/bind_building.c index 58fdceb00..491b9a7d7 100644 --- a/src/bind_building.c +++ b/src/bind_building.c @@ -243,10 +243,6 @@ void tolua_building_open(lua_State * L) tolua_variable(L, TOLUA_CAST "size", tolua_building_get_size, tolua_building_set_size); tolua_function(L, TOLUA_CAST "get_typename", tolua_building_get_typename); -#ifdef TODO - .property("type", &building_gettype) - .def_readwrite("size", &building::size) -#endif tolua_variable(L, TOLUA_CAST "objects", tolua_building_get_objects, 0); tolua_variable(L, TOLUA_CAST "working", tolua_building_get_working, tolua_building_set_working); diff --git a/src/kernel/config.c b/src/kernel/config.c index 9355234e7..4e25e385d 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -734,20 +734,6 @@ int alliedunit(const unit * u, const faction * f2, int mode) return 0; } -#ifndef NDEBUG -const char *strcheck(const char *s, size_t maxlen) -{ - static char buffer[16 * 1024]; // FIXME: static return value - if (strlen(s) > maxlen) { - assert(maxlen < 16 * 1024); - log_warning("[strcheck] string was shortened to %d bytes:\n%s\n", (int)maxlen, s); - strlcpy(buffer, s, maxlen); - return buffer; - } - return s; -} -#endif - static attrib_type at_lighthouse = { "lighthouse" /* Rest ist NULL; temporäres, nicht alterndes Attribut */ diff --git a/src/kernel/item.c b/src/kernel/item.c index 12adf9e01..f0baa0c78 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -480,9 +480,6 @@ item *i_change(item ** pi, const item_type * itype, int delta) i->number += delta; if (i->number < 0) { log_error("serious accounting error. number of items is %d.\n", i->number); - /* FIXME what's this supposed to mean?? - assert(i >= 0); - */ i->number = 0; } if (i->number == 0) { diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 361504b5f..eb06803d2 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -552,43 +552,6 @@ static int parse_ships(xmlDocPtr doc) return 0; } -#if 0 -static void race_compat(void) -{ - /* required for old_race, do not change order! */ - const char *oldracenames[MAXRACES] = { - "dwarf", "elf", NULL, "goblin", "human", "troll", "demon", "insect", - "halfling", "cat", "aquarian", "orc", "snotling", "undead", "illusion", - "youngdragon", "dragon", "wyrm", "ent", "catdragon", "dracoid", - "special", "spell", "irongolem", "stonegolem", "shadowdemon", - "shadowmaster", "mountainguard", "alp", "toad", "braineater", "peasant", - "wolf", NULL, NULL, NULL, NULL, "songdragon", NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, "seaserpent", - "shadowknight", "centaur", "skeleton", "skeletonlord", "zombie", - "juju-zombie", "ghoul", "ghast", "museumghost", "gnome", "template", - "clone" - }; - int i; - - for (i = 0; i != MAXRACES; ++i) { - const char *rcname = oldracenames[i]; - if (rcname == NULL) { - new_race[i] = NULL; - } else { - race *rc = rc_get_or_create(oldracenames[i]); - if (rc) { - new_race[i] = rc; - if (rc == new_race[RC_TROLL]) { - a_add(&rc->attribs, make_skillmod(NOSKILL, SMF_RIDING, NULL, 0.0, - -1)); - } - } - } - } -} -#endif - static potion_type *xml_readpotion(xmlXPathContextPtr xpath, item_type * itype) { int level = xml_ivalue(xpath->node, "level", 0); diff --git a/src/spells.c b/src/spells.c index c2ec72c24..1ec53875c 100644 --- a/src/spells.c +++ b/src/spells.c @@ -394,46 +394,10 @@ int report_action(region * r, unit * actor, message * msg, int flags) static void report_effect(region * r, unit * mage, message * seen, message * unseen) { -#if 0 - unit *u; - - /* melden, 1x pro Partei */ - freset(mage->faction, FFL_SELECT); - for (u = r->units; u; u = u->next) - freset(u->faction, FFL_SELECT); - for (u = r->units; u; u = u->next) { - if (!fval(u->faction, FFL_SELECT)) { - fset(u->faction, FFL_SELECT); - - /* Bei Fernzaubern sieht nur die eigene Partei den Magier */ - if (u->faction != mage->faction) { - if (r == mage->region) { - /* kein Fernzauber, pruefe, ob der Magier ueberhaupt gesehen - * wird */ - if (cansee(u->faction, r, mage, 0)) { - r_addmessage(r, u->faction, seen); - } else { - r_addmessage(r, u->faction, unseen); - } - } else { /* Fernzauber, fremde Partei sieht den Magier niemals */ - r_addmessage(r, u->faction, unseen); - } - } else { /* Partei des Magiers, sieht diesen immer */ - r_addmessage(r, u->faction, seen); - } - } - } - /* Ist niemand von der Partei des Magiers in der Region, dem Magier - * nochmal gesondert melden */ - if (!fval(mage->faction, FFL_SELECT)) { - add_message(&mage->faction->msgs, seen); - } -#else int err = report_action(r, mage, seen, ACTION_RESET | ACTION_CANSEE); if (err) { report_action(r, mage, seen, ACTION_CANNOTSEE); } -#endif } /* ------------------------------------------------------------- */ @@ -3613,11 +3577,6 @@ static int sp_charmingsong(castorder * co) /* Magieresistenz */ if (target_resists_magic(mage, target, TYP_UNIT, resist_bonus)) { report_failure(mage, co->order); -#if 0 - sprintf(buf, "%s fuehlt sich einen Moment lang benommen und desorientiert.", - unitname(target)); - addmessage(target->region, target->faction, buf, MSG_EVENT, ML_WARN); -#endif return 0; } diff --git a/src/triggers/changefaction.c b/src/triggers/changefaction.c index 5339fc2db..dfdaf80a2 100644 --- a/src/triggers/changefaction.c +++ b/src/triggers/changefaction.c @@ -23,7 +23,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* kernel includes */ #include #include -#include /* FIXME: resolve_faction */ +#include /* util includes */ #include