forked from github/server
remove superfluous argument from herbsearch
use effskill, not eff_skill
This commit is contained in:
parent
71dea1eca7
commit
6889cb0c80
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue