eliminate some TODO comments.

This commit is contained in:
Enno Rehling 2017-12-26 07:25:42 +01:00
parent a7b7162c56
commit 3911217fb5
4 changed files with 23 additions and 23 deletions

View file

@ -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)) { for (ql = book->spells, qi = 0; ql; selist_advance(&ql, &qi, 1)) {
spellbook_entry * sbe = (spellbook_entry *)selist_get(ql, qi); spellbook_entry * sbe = (spellbook_entry *)selist_get(ql, qi);
if (sbe->level <= maxlevel) { if (sbe->level <= maxlevel) {
/* TODO: no need to deref spref here, spref->name == sp->sname */
spell * sp = sbe->sp; spell * sp = sbe->sp;
const char *name = translate(mkname("spell", sp->sname), spell_name(sp, f->locale)); const char *name = translate(mkname("spell", sp->sname), spell_name(sp, f->locale));
if (!header) { if (!header) {
@ -752,7 +751,7 @@ static void cr_output_spells(stream *out, const unit * u, int maxlevel)
* @param f observers faction * @param f observers faction
* @param u unit to report * @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) const unit * u, seen_mode mode)
{ {
/* Race attributes are always plural and item attributes always /* 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; const struct locale *lang = f->locale;
assert(u && u->number); 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)) if (fval(u_race(u), RCF_INVISIBLE))
return; 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); 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) const unit * u, int mode)
{ {
/* TODO: eliminate this function */ /* TODO: eliminate this function */
stream strm; stream strm;
fstream_init(&strm, F); 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) { for (u = r->units; u; u = u->next) {
if (visible_unit(u, f, stealthmod, r->seen.mode)) { 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);
} }
} }
} }

View file

@ -27,8 +27,8 @@ extern "C" {
void register_cr(void); void register_cr(void);
int crwritemap(const char *filename); int crwritemap(const char *filename);
void cr_output_unit(struct stream *out, const struct region * r, void cr_output_unit(struct stream *out, const struct faction * f,
const struct faction * f, const struct unit * u, seen_mode mode); const struct unit * u, seen_mode mode);
void cr_output_resources(struct stream *out, const struct faction * f, void cr_output_resources(struct stream *out, const struct faction * f,
const struct region *r, bool see_unit); const struct region *r, bool see_unit);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -43,7 +43,7 @@ static void test_cr_unit(CuTest *tc) {
renumber_unit(u, 1234); renumber_unit(u, 1234);
mstream_init(&strm); 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); strm.api->rewind(strm.handle);
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line))); CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
CuAssertStrEquals(tc, line, "EINHEIT 1234"); CuAssertStrEquals(tc, line, "EINHEIT 1234");
@ -237,7 +237,7 @@ static void test_cr_factionstealth(CuTest *tc) {
/* report to ourselves */ /* report to ourselves */
mstream_init(&strm); 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, f1->no, cr_get_int(&strm, ";Partei", -1));
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1));
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -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 */ /* ... also when we are anonymous */
u->flags |= UFL_ANON_FACTION; u->flags |= UFL_ANON_FACTION;
mstream_init(&strm); 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, f1->no, cr_get_int(&strm, ";Partei", -1));
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1));
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -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); set_factionstealth(u, f2);
CuAssertPtrNotNull(tc, u->attribs); CuAssertPtrNotNull(tc, u->attribs);
mstream_init(&strm); 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, f1->no, cr_get_int(&strm, ";Partei", -1));
CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1));
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -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 */ /* ... also when we are anonymous */
u->flags |= UFL_ANON_FACTION; u->flags |= UFL_ANON_FACTION;
mstream_init(&strm); 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, f1->no, cr_get_int(&strm, ";Partei", -1));
CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1));
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -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 */ /* we can tell that someone is presenting as us */
mstream_init(&strm); 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, f2->no, cr_get_int(&strm, ";Partei", -1));
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1));
CuAssertIntEquals(tc, 1, cr_get_int(&strm, ";Verraeter", -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 */ /* ... but not if they are anonymous */
u->flags |= UFL_ANON_FACTION; u->flags |= UFL_ANON_FACTION;
mstream_init(&strm); 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, ";Partei", -1));
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1));
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -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 = ally_add(&f1->allies, f2);
al->status = HELP_FSTEALTH; al->status = HELP_FSTEALTH;
mstream_init(&strm); 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, f1->no, cr_get_int(&strm, ";Partei", -1));
CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1));
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -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 */ /* ... also when they are anonymous */
u->flags |= UFL_ANON_FACTION; u->flags |= UFL_ANON_FACTION;
mstream_init(&strm); 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, f1->no, cr_get_int(&strm, ";Partei", -1));
CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1));
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1)); CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1));

View file

@ -385,14 +385,16 @@ static building *deleted_buildings;
void remove_building(building ** blist, building * b) void remove_building(building ** blist, building * b)
{ {
unit *u; 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)); assert(bfindhash(b->no));
bt_caravan = bt_find("caravan"); if (bt_changed(&btypes)) {
bt_dam = bt_find("dam"); bt_caravan = bt_find("caravan");
bt_tunnel = bt_find("tunnel"); bt_dam = bt_find("dam");
bt_tunnel = bt_find("tunnel");
}
handle_event(b->attribs, "destroy", b); handle_event(b->attribs, "destroy", b);
for (u = b->region->units; u; u = u->next) { for (u = b->region->units; u; u = u->next) {
if (u->building == b) leave(u, true); if (u->building == b) leave(u, true);
@ -404,7 +406,6 @@ void remove_building(building ** blist, building * b)
/* Falls Karawanserei, Damm oder Tunnel einst<73>rzen, wird die schon /* Falls Karawanserei, Damm oder Tunnel einst<73>rzen, wird die schon
* gebaute Strasse zur Haelfte vernichtet */ * 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) { if (b->type == bt_caravan || b->type == bt_dam || b->type == bt_tunnel) {
region *r = b->region; region *r = b->region;
int d; int d;