From 3911217fb59702920eab778175189b6f3f780a83 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 26 Dec 2017 07:25:42 +0100 Subject: [PATCH] eliminate some TODO comments. --- src/creport.c | 11 +++++------ src/creport.h | 4 ++-- src/creport.test.c | 18 +++++++++--------- src/kernel/building.c | 13 +++++++------ 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/creport.c b/src/creport.c index 5f34cba54..428e47398 100644 --- a/src/creport.c +++ b/src/creport.c @@ -735,7 +735,6 @@ static void cr_output_spells(stream *out, const unit * u, int maxlevel) for (ql = book->spells, qi = 0; ql; selist_advance(&ql, &qi, 1)) { spellbook_entry * sbe = (spellbook_entry *)selist_get(ql, qi); if (sbe->level <= maxlevel) { - /* TODO: no need to deref spref here, spref->name == sp->sname */ spell * sp = sbe->sp; const char *name = translate(mkname("spell", sp->sname), spell_name(sp, f->locale)); if (!header) { @@ -752,7 +751,7 @@ static void cr_output_spells(stream *out, const unit * u, int maxlevel) * @param f observers faction * @param u unit to report */ -void cr_output_unit(stream *out, const region * r, const faction * f, +void cr_output_unit(stream *out, const faction * f, const unit * u, seen_mode mode) { /* Race attributes are always plural and item attributes always @@ -771,7 +770,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f, const struct locale *lang = f->locale; assert(u && u->number); - assert(u->region == r); /* TODO: if this holds true, then why did we pass in r? */ + if (fval(u_race(u), RCF_INVISIBLE)) return; @@ -996,13 +995,13 @@ void cr_output_unit(stream *out, const region * r, const faction * f, cr_output_curses(out, f, u, TYP_UNIT); } -static void cr_output_unit_compat(FILE * F, const region * r, const faction * f, +static void cr_output_unit_compat(FILE * F, const faction * f, const unit * u, int mode) { /* TODO: eliminate this function */ stream strm; fstream_init(&strm, F); - cr_output_unit(&strm, r, f, u, mode); + cr_output_unit(&strm, f, u, mode); } /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ @@ -1482,7 +1481,7 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r) for (u = r->units; u; u = u->next) { if (visible_unit(u, f, stealthmod, r->seen.mode)) { - cr_output_unit_compat(F, r, f, u, r->seen.mode); + cr_output_unit_compat(F, f, u, r->seen.mode); } } } diff --git a/src/creport.h b/src/creport.h index 435bb637f..ed8f3bfbd 100644 --- a/src/creport.h +++ b/src/creport.h @@ -27,8 +27,8 @@ extern "C" { void register_cr(void); int crwritemap(const char *filename); - void cr_output_unit(struct stream *out, const struct region * r, - const struct faction * f, const struct unit * u, seen_mode mode); + void cr_output_unit(struct stream *out, const struct faction * f, + const struct unit * u, seen_mode mode); void cr_output_resources(struct stream *out, const struct faction * f, const struct region *r, bool see_unit); #ifdef __cplusplus diff --git a/src/creport.test.c b/src/creport.test.c index e87de235e..dba9667cc 100644 --- a/src/creport.test.c +++ b/src/creport.test.c @@ -43,7 +43,7 @@ static void test_cr_unit(CuTest *tc) { renumber_unit(u, 1234); mstream_init(&strm); - cr_output_unit(&strm, r, f, u, seen_unit); + cr_output_unit(&strm, f, u, seen_unit); strm.api->rewind(strm.handle); CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertStrEquals(tc, line, "EINHEIT 1234"); @@ -237,7 +237,7 @@ static void test_cr_factionstealth(CuTest *tc) { /* report to ourselves */ mstream_init(&strm); - cr_output_unit(&strm, u->region, f1, u, seen_unit); + cr_output_unit(&strm, f1, u, seen_unit); CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); @@ -247,7 +247,7 @@ static void test_cr_factionstealth(CuTest *tc) { /* ... also when we are anonymous */ u->flags |= UFL_ANON_FACTION; mstream_init(&strm); - cr_output_unit(&strm, u->region, f1, u, seen_unit); + cr_output_unit(&strm, f1, u, seen_unit); CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); @@ -259,7 +259,7 @@ static void test_cr_factionstealth(CuTest *tc) { set_factionstealth(u, f2); CuAssertPtrNotNull(tc, u->attribs); mstream_init(&strm); - cr_output_unit(&strm, u->region, f1, u, seen_unit); + cr_output_unit(&strm, f1, u, seen_unit); CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); @@ -269,7 +269,7 @@ static void test_cr_factionstealth(CuTest *tc) { /* ... also when we are anonymous */ u->flags |= UFL_ANON_FACTION; mstream_init(&strm); - cr_output_unit(&strm, u->region, f1, u, seen_unit); + cr_output_unit(&strm, f1, u, seen_unit); CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); @@ -279,7 +279,7 @@ static void test_cr_factionstealth(CuTest *tc) { /* we can tell that someone is presenting as us */ mstream_init(&strm); - cr_output_unit(&strm, u->region, f2, u, seen_unit); + cr_output_unit(&strm, f2, u, seen_unit); CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Partei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, 1, cr_get_int(&strm, ";Verraeter", -1)); @@ -289,7 +289,7 @@ static void test_cr_factionstealth(CuTest *tc) { /* ... but not if they are anonymous */ u->flags |= UFL_ANON_FACTION; mstream_init(&strm); - cr_output_unit(&strm, u->region, f2, u, seen_unit); + cr_output_unit(&strm, f2, u, seen_unit); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Partei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); @@ -301,7 +301,7 @@ static void test_cr_factionstealth(CuTest *tc) { al = ally_add(&f1->allies, f2); al->status = HELP_FSTEALTH; mstream_init(&strm); - cr_output_unit(&strm, u->region, f2, u, seen_unit); + cr_output_unit(&strm, f2, u, seen_unit); CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); @@ -311,7 +311,7 @@ static void test_cr_factionstealth(CuTest *tc) { /* ... also when they are anonymous */ u->flags |= UFL_ANON_FACTION; mstream_init(&strm); - cr_output_unit(&strm, u->region, f2, u, seen_unit); + cr_output_unit(&strm, f2, u, seen_unit); CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); diff --git a/src/kernel/building.c b/src/kernel/building.c index 26d261e97..5688c99ce 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -385,14 +385,16 @@ static building *deleted_buildings; void remove_building(building ** blist, building * b) { unit *u; - const struct building_type *bt_caravan, *bt_dam, *bt_tunnel; + static const struct building_type *bt_caravan, *bt_dam, *bt_tunnel; + static int btypes; assert(bfindhash(b->no)); - bt_caravan = bt_find("caravan"); - bt_dam = bt_find("dam"); - bt_tunnel = bt_find("tunnel"); - + if (bt_changed(&btypes)) { + bt_caravan = bt_find("caravan"); + bt_dam = bt_find("dam"); + bt_tunnel = bt_find("tunnel"); + } handle_event(b->attribs, "destroy", b); for (u = b->region->units; u; u = u->next) { if (u->building == b) leave(u, true); @@ -404,7 +406,6 @@ void remove_building(building ** blist, building * b) /* Falls Karawanserei, Damm oder Tunnel einst�rzen, wird die schon * gebaute Strasse zur Haelfte vernichtet */ - /* TODO: caravan, tunnel, dam modularization ? is_building_type ? */ if (b->type == bt_caravan || b->type == bt_dam || b->type == bt_tunnel) { region *r = b->region; int d;