eliminate invalid assertions, remove unnecessary arguments (plant/breed/trees)

This commit is contained in:
Enno Rehling 2015-08-27 16:53:36 +02:00
parent de808bf146
commit 564a041b0d
3 changed files with 16 additions and 15 deletions

View File

@ -46,11 +46,11 @@ int u_geteffstealth(const unit *u)
return -1; return -1;
} }
/* r != u->region when called by cansee (see comment there) */
int eff_stealth(const unit * u, const region * r) int eff_stealth(const unit * u, const region * r)
{ {
int e = 0; int e = 0;
assert(u->region == r); // TODO: param r is useless
/* Auf Schiffen keine Tarnung! */ /* Auf Schiffen keine Tarnung! */
if (!u->ship && skill_enabled(SK_STEALTH)) { if (!u->ship && skill_enabled(SK_STEALTH)) {
e = effskill(u, SK_STEALTH, r); e = effskill(u, SK_STEALTH, r);

View File

@ -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; int n, i, skill, planted = 0;
const item_type *itype; const item_type *itype;
const resource_type *rt_water = get_resourcetype(R_WATER_OF_LIFE); const resource_type *rt_water = get_resourcetype(R_WATER_OF_LIFE);
region *r = u->region;
assert(rt_water != NULL); assert(rt_water != NULL);
if (!fval(r->terrain, LAND_REGION)) { if (!fval(r->terrain, LAND_REGION)) {
@ -2320,12 +2321,12 @@ static void plant(region * r, unit * u, int raw)
u, r, planted, itype->rtype)); 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; int n, i, skill, planted = 0;
const resource_type *rtype; const resource_type *rtype;
region * r = u->region;
assert(r == u->region); // TODO: param r is unnecessary
if (!fval(r->terrain, LAND_REGION)) { if (!fval(r->terrain, LAND_REGION)) {
return; return;
} }
@ -2374,14 +2375,14 @@ static void planttrees(region * r, unit * u, int raw)
} }
/* züchte bäume */ /* 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; int n, i, skill, planted = 0;
const resource_type *rtype; const resource_type *rtype;
static int gamecookie = -1; static int gamecookie = -1;
static int current_season; static int current_season;
region *r = u->region;
assert(r == u->region); // TODO: param r is unnecessary
if (gamecookie != global.cookie) { if (gamecookie != global.cookie) {
gamedate date; gamedate date;
get_gamedate(turn, &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 */ /* Bäume züchten geht nur im Frühling */
if (current_season != SEASON_SPRING) { if (current_season != SEASON_SPRING) {
planttrees(r, u, raw); planttrees(u, raw);
return; return;
} }
@ -2405,7 +2406,7 @@ static void breedtrees(region * r, unit * u, int raw)
/* Skill prüfen */ /* Skill prüfen */
skill = effskill(u, SK_HERBALISM, 0); skill = effskill(u, SK_HERBALISM, 0);
if (skill < 12) { if (skill < 12) {
planttrees(r, u, raw); planttrees(u, raw);
return; return;
} }
@ -2506,16 +2507,16 @@ static void breed_cmd(unit * u, struct order *ord)
switch (p) { switch (p) {
case P_HERBS: case P_HERBS:
plant(r, u, m); plant(u, m);
break; break;
case P_TREES: case P_TREES:
breedtrees(r, u, m); breedtrees(u, m);
break; break;
default: default:
if (p != P_ANY) { if (p != P_ANY) {
rtype = findresourcetype(s, u->faction->locale); rtype = findresourcetype(s, u->faction->locale);
if (rtype == get_resourcetype(R_SEED) || rtype == get_resourcetype(R_MALLORNSEED)) { if (rtype == get_resourcetype(R_SEED) || rtype == get_resourcetype(R_MALLORNSEED)) {
breedtrees(r, u, m); breedtrees(u, m);
break; break;
} }
else if (rtype != get_resourcetype(R_HORSE)) { else if (rtype != get_resourcetype(R_HORSE)) {

View File

@ -4597,14 +4597,14 @@ void update_subscriptions(void)
bool bool
cansee(const faction * f, const region * r, const unit * u, int modifier) cansee(const faction * f, const region * r, const unit * u, int modifier)
/* r kann != u->region sein, wenn es um durchreisen geht */ /* r kann != u->region sein, wenn es um Durchreisen geht,
/* und es muss niemand aus f in der region sein, wenn sie vom Turm * oder Zauber (sp_generous, sp_fetchastral).
* erblickt wird */ * Es muss auch niemand aus f in der region sein, wenn sie vom Turm
* erblickt wird */
{ {
int stealth, rings; int stealth, rings;
unit *u2 = r->units; unit *u2 = r->units;
assert(u->region == r); // TODO: param r is unnecessary
if (u->faction == f || omniscient(f)) { if (u->faction == f || omniscient(f)) {
return true; return true;
} }