From 564a041b0d67ba491eba5a56f69b0af4ae6d334e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 27 Aug 2015 16:53:36 +0200 Subject: [PATCH] eliminate invalid assertions, remove unnecessary arguments (plant/breed/trees) --- src/attributes/stealth.c | 2 +- src/economy.c | 21 +++++++++++---------- src/laws.c | 8 ++++---- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/attributes/stealth.c b/src/attributes/stealth.c index e4da1ec5c..6f133f01c 100644 --- a/src/attributes/stealth.c +++ b/src/attributes/stealth.c @@ -46,11 +46,11 @@ int u_geteffstealth(const unit *u) return -1; } +/* r != u->region when called by cansee (see comment there) */ int eff_stealth(const unit * u, const region * r) { int e = 0; - assert(u->region == r); // TODO: param r is useless /* Auf Schiffen keine Tarnung! */ if (!u->ship && skill_enabled(SK_STEALTH)) { e = effskill(u, SK_STEALTH, r); diff --git a/src/economy.c b/src/economy.c index ea37c1e8b..8e790f666 100644 --- a/src/economy.c +++ b/src/economy.c @@ -2264,11 +2264,12 @@ static void expandstealing(region * r, request * stealorders) } /* ------------------------------------------------------------- */ -static void plant(region * r, unit * u, int raw) +static void plant(unit * u, int raw) { int n, i, skill, planted = 0; const item_type *itype; const resource_type *rt_water = get_resourcetype(R_WATER_OF_LIFE); + region *r = u->region; assert(rt_water != NULL); if (!fval(r->terrain, LAND_REGION)) { @@ -2320,12 +2321,12 @@ static void plant(region * r, unit * u, int raw) u, r, planted, itype->rtype)); } -static void planttrees(region * r, unit * u, int raw) +static void planttrees(unit * u, int raw) { int n, i, skill, planted = 0; const resource_type *rtype; + region * r = u->region; - assert(r == u->region); // TODO: param r is unnecessary if (!fval(r->terrain, LAND_REGION)) { return; } @@ -2374,14 +2375,14 @@ static void planttrees(region * r, unit * u, int raw) } /* züchte bäume */ -static void breedtrees(region * r, unit * u, int raw) +static void breedtrees(unit * u, int raw) { int n, i, skill, planted = 0; const resource_type *rtype; static int gamecookie = -1; static int current_season; + region *r = u->region; - assert(r == u->region); // TODO: param r is unnecessary if (gamecookie != global.cookie) { gamedate date; get_gamedate(turn, &date); @@ -2391,7 +2392,7 @@ static void breedtrees(region * r, unit * u, int raw) /* Bäume züchten geht nur im Frühling */ if (current_season != SEASON_SPRING) { - planttrees(r, u, raw); + planttrees(u, raw); return; } @@ -2405,7 +2406,7 @@ static void breedtrees(region * r, unit * u, int raw) /* Skill prüfen */ skill = effskill(u, SK_HERBALISM, 0); if (skill < 12) { - planttrees(r, u, raw); + planttrees(u, raw); return; } @@ -2506,16 +2507,16 @@ static void breed_cmd(unit * u, struct order *ord) switch (p) { case P_HERBS: - plant(r, u, m); + plant(u, m); break; case P_TREES: - breedtrees(r, u, m); + breedtrees(u, m); break; default: if (p != P_ANY) { rtype = findresourcetype(s, u->faction->locale); if (rtype == get_resourcetype(R_SEED) || rtype == get_resourcetype(R_MALLORNSEED)) { - breedtrees(r, u, m); + breedtrees(u, m); break; } else if (rtype != get_resourcetype(R_HORSE)) { diff --git a/src/laws.c b/src/laws.c index dfa97a34b..6e42bc736 100755 --- a/src/laws.c +++ b/src/laws.c @@ -4597,14 +4597,14 @@ void update_subscriptions(void) bool cansee(const faction * f, const region * r, const unit * u, int modifier) -/* r kann != u->region sein, wenn es um durchreisen geht */ -/* und es muss niemand aus f in der region sein, wenn sie vom Turm -* erblickt wird */ +/* r kann != u->region sein, wenn es um Durchreisen geht, + * oder Zauber (sp_generous, sp_fetchastral). + * Es muss auch niemand aus f in der region sein, wenn sie vom Turm + * erblickt wird */ { int stealth, rings; unit *u2 = r->units; - assert(u->region == r); // TODO: param r is unnecessary if (u->faction == f || omniscient(f)) { return true; }