From 6889cb0c8086bb76c040784120d64f470f6b87bb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 27 Aug 2015 14:46:08 +0200 Subject: [PATCH] remove superfluous argument from herbsearch use effskill, not eff_skill --- src/alchemy.c | 10 ++++++---- src/alchemy.h | 2 +- src/alchemy.test.c | 10 +++++----- src/economy.c | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/alchemy.c b/src/alchemy.c index edd4746bc..3403d7c46 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -47,12 +47,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* ------------------------------------------------------------- */ -void herbsearch(region * r, unit * u, int max) +void herbsearch(unit * u, int max) { + region * r = u->region; int herbsfound; const item_type *whichherb; + int effsk = effskill(u, SK_HERBALISM); - if (eff_skill(u, SK_HERBALISM, r) == 0) { + if (effsk == 0) { cmistake(u, u->thisorder, 59, MSG_PRODUCE); return; } @@ -72,7 +74,7 @@ void herbsearch(region * r, unit * u, int max) max = _min(max, rherbs(r)); else max = rherbs(r); - herbsfound = ntimespprob(eff_skill(u, SK_HERBALISM, r) * u->number, + herbsfound = ntimespprob(effsk * u->number, (double)rherbs(r) / 100.0F, -0.01F); herbsfound = _min(herbsfound, max); rsetherbs(r, rherbs(r) - herbsfound); @@ -85,7 +87,7 @@ void herbsearch(region * r, unit * u, int max) } else { ADDMSG(&u->faction->msgs, msg_message("researchherb_none", - "unit region", u, u->region)); + "unit region", u, r)); } } diff --git a/src/alchemy.h b/src/alchemy.h index 79f771b45..6dec4120b 100644 --- a/src/alchemy.h +++ b/src/alchemy.h @@ -56,7 +56,7 @@ extern "C" { MAX_POTIONS }; - void herbsearch(struct region *r, struct unit *u, int max); + void herbsearch(struct unit *u, int max); extern int use_potion(struct unit *u, const struct item_type *itype, int amount, struct order *); extern int use_potion_delayed(struct unit *u, const struct item_type *itype, diff --git a/src/alchemy.test.c b/src/alchemy.test.c index 16811725a..fed4946f2 100644 --- a/src/alchemy.test.c +++ b/src/alchemy.test.c @@ -33,14 +33,14 @@ static void test_herbsearch(CuTest * tc) u = test_create_unit(f, r); itype = test_create_itemtype("rosemary"); - herbsearch(r, u, INT_MAX); + herbsearch(u, INT_MAX); CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error59")); free_messagelist(f->msgs); f->msgs = 0; set_level(u, SK_HERBALISM, 1); CuAssertPtrEquals(tc, u2, is_guarded(r, u, GUARD_PRODUCE)); - herbsearch(r, u, INT_MAX); + herbsearch(u, INT_MAX); CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error70")); CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "error59")); free_messagelist(f->msgs); @@ -49,7 +49,7 @@ static void test_herbsearch(CuTest * tc) guard(u2, GUARD_NONE); CuAssertPtrEquals(tc, 0, is_guarded(r, u, GUARD_PRODUCE)); CuAssertPtrEquals(tc, 0, (void *)rherbtype(r)); - herbsearch(r, u, INT_MAX); + herbsearch(u, INT_MAX); CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error108")); CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "error70")); CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "error59")); @@ -59,7 +59,7 @@ static void test_herbsearch(CuTest * tc) rsetherbtype(r, itype); CuAssertPtrEquals(tc, (void *)itype, (void *)rherbtype(r)); CuAssertIntEquals(tc, 0, rherbs(r)); - herbsearch(r, u, INT_MAX); + herbsearch(u, INT_MAX); CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "researchherb_none")); CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "error108")); CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "error70")); @@ -69,7 +69,7 @@ static void test_herbsearch(CuTest * tc) rsetherbs(r, 100); CuAssertIntEquals(tc, 100, rherbs(r)); - herbsearch(r, u, INT_MAX); + herbsearch(u, INT_MAX); CuAssertIntEquals(tc, 99, rherbs(r)); CuAssertIntEquals(tc, 1, i_get(u->items, itype)); CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "herbfound")); diff --git a/src/economy.c b/src/economy.c index 8cf46845b..f580f10b0 100644 --- a/src/economy.c +++ b/src/economy.c @@ -1546,7 +1546,7 @@ int make_cmd(unit * u, struct order *ord) return 0; } else if (p == P_HERBS) { - herbsearch(r, u, m); + herbsearch(u, m); return 0; }