forked from github/server
when planting saplings, plant remaining seeds.
This commit is contained in:
parent
043949c8d0
commit
bfd89687cd
|
@ -71,14 +71,14 @@ function test_plant_spring_saplings()
|
||||||
r:set_resource('sapling', 0)
|
r:set_resource('sapling', 0)
|
||||||
r:set_resource('tree', 0)
|
r:set_resource('tree', 0)
|
||||||
local u = unit.create(f, r)
|
local u = unit.create(f, r)
|
||||||
u:set_skill('herbalism', 20)
|
u:set_skill('herbalism', 12)
|
||||||
u:add_item('seed', 40)
|
u:add_item('seed', 20)
|
||||||
u:add_order("PFLANZE 20 Samen")
|
u:add_order("PFLANZE 20 Samen") -- limited by herbalism
|
||||||
process_orders()
|
process_orders()
|
||||||
assert_equal(2, r:get_resource('sapling'))
|
assert_equal(1, r:get_resource('sapling'))
|
||||||
assert_equal(0, r:get_resource('seed'))
|
assert_equal(2, r:get_resource('seed'))
|
||||||
assert_equal(0, r:get_resource('tree'))
|
assert_equal(0, r:get_resource('tree'))
|
||||||
assert_equal(20, u:get_item('seed'))
|
assert_equal(8, u:get_item('seed'))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- herbalism < T12 means we are still planting seeds at 1:1
|
-- herbalism < T12 means we are still planting seeds at 1:1
|
||||||
|
|
|
@ -1684,13 +1684,15 @@ static void plant(unit * u, int raw)
|
||||||
|
|
||||||
static void planttrees(region * r, int type, int n)
|
static void planttrees(region * r, int type, int n)
|
||||||
{
|
{
|
||||||
rsettrees(r, type, rtrees(r, type) + n);
|
if (n > 0) {
|
||||||
|
rsettrees(r, type, rtrees(r, type) + n);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* zuechte baeume */
|
/* zuechte baeume */
|
||||||
static void breedtrees(unit * u, int raw)
|
static void breedtrees(unit * u, int raw)
|
||||||
{
|
{
|
||||||
int n, i, skill, planted;
|
int n, i, skill;
|
||||||
const resource_type *rtype;
|
const resource_type *rtype;
|
||||||
season_t current_season = calendar_season(turn);
|
season_t current_season = calendar_season(turn);
|
||||||
region *r = u->region;
|
region *r = u->region;
|
||||||
|
@ -1731,17 +1733,12 @@ static void breedtrees(unit * u, int raw)
|
||||||
if (n > raw) n = raw;
|
if (n > raw) n = raw;
|
||||||
|
|
||||||
if (skill >= 12 && current_season == SEASON_SPRING) {
|
if (skill >= 12 && current_season == SEASON_SPRING) {
|
||||||
// Plant saplings at a rate of 10:1
|
// Plant saplings for every 10 seeds
|
||||||
int remain = n % 10;
|
planttrees(r, 0, n % 10);
|
||||||
planted = n / 10;
|
planttrees(r, 1, n / 10);
|
||||||
if ((remain > 0) && (rng_int() % 10) < remain) {
|
|
||||||
++planted;
|
|
||||||
}
|
|
||||||
planttrees(r, 1, planted);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
planted = n;
|
planttrees(r, 0, n);
|
||||||
planttrees(r, 0, planted);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Alles ok. Samen abziehen. */
|
/* Alles ok. Samen abziehen. */
|
||||||
|
@ -1749,7 +1746,7 @@ static void breedtrees(unit * u, int raw)
|
||||||
use_pooled(u, rtype, GET_DEFAULT, n);
|
use_pooled(u, rtype, GET_DEFAULT, n);
|
||||||
|
|
||||||
ADDMSG(&u->faction->msgs, msg_message("plant",
|
ADDMSG(&u->faction->msgs, msg_message("plant",
|
||||||
"unit region amount herb", u, r, planted, rtype));
|
"unit region amount herb", u, r, n, rtype));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* zuechte pferde */
|
/* zuechte pferde */
|
||||||
|
|
Loading…
Reference in New Issue