newterrain sucks.

This commit is contained in:
Enno Rehling 2017-11-05 19:15:43 +01:00
parent 440679da87
commit 96ff0815c4
2 changed files with 13 additions and 16 deletions

View File

@ -1067,7 +1067,7 @@ static int required(int want, variant save)
{
int req = (int)(want * save.sa[0] / save.sa[1]);
int r = want * save.sa[0] % save.sa[1];
if (r>0) ++req;
if (r > 0) ++req;
return req;
}
@ -1173,7 +1173,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist)
int x = avail * want / nreq;
int rx = (avail * want) % nreq;
/* Wenn Rest, dann wuerfeln, ob ich was bekomme: */
if (rx>0 && rng_int() % nreq < rx) ++x;
if (rx > 0 && rng_int() % nreq < rx) ++x;
avail -= x;
nreq -= want;
al->get = x * al->save.sa[1] / al->save.sa[0];
@ -1590,17 +1590,10 @@ static void buy(unit * u, request ** buyorders, struct order *ord)
return;
}
if (u_race(u) == get_race(RC_INSECT)) {
/* entweder man ist insekt, oder... */
if (r->terrain != newterrain(T_SWAMP) && r->terrain != newterrain(T_DESERT)
&& !rbuildings(r)) {
cmistake(u, ord, 119, MSG_COMMERCE);
return;
}
}
else {
/* ...oder in der Region mu<6D> es eine Burg geben. */
building *b = 0;
/* Entweder man ist Insekt in Sumpf/Wueste, oder es muss
* einen Handelsposten in der Region geben: */
if (u_race(u) != get_race(RC_INSECT) || (r->terrain == newterrain(T_SWAMP) || r->terrain == newterrain(T_DESERT))) {
building *b = NULL;
if (r->buildings) {
static int cache;
static const struct building_type *bt_castle;
@ -2719,7 +2712,7 @@ static void expandloot(region * r, request * lootorders)
/* Lowering morale by 1 depending on the looted money (+20%) */
m = region_get_morale(r);
if (m && startmoney>0) {
if (m && startmoney > 0) {
if (rng_int() % 100 < 20 + (looted * 80) / startmoney) {
/*Nur Moral -1, turns is not changed, so the first time nothing happens if the morale is good*/
region_set_morale(r, m - 1, -1);

View File

@ -181,7 +181,9 @@ static void setup_terrains(CuTest *tc) {
test_create_terrain("ocean", SEA_REGION | SWIM_INTO | FLY_INTO);
test_create_terrain("swamp", LAND_REGION | WALK_INTO | FLY_INTO);
test_create_terrain("desert", LAND_REGION | WALK_INTO | FLY_INTO);
test_create_terrain("mountain", LAND_REGION | WALK_INTO | FLY_INTO);
init_terrains();
CuAssertPtrNotNull(tc, newterrain(T_MOUNTAIN));
CuAssertPtrNotNull(tc, newterrain(T_OCEAN));
CuAssertPtrNotNull(tc, newterrain(T_PLAIN));
CuAssertPtrNotNull(tc, newterrain(T_SWAMP));
@ -225,7 +227,7 @@ static void test_trade_insect(CuTest *tc) {
init_resources();
test_create_locale();
setup_terrains(tc);
r = setup_trade_region(tc, test_create_terrain("swamp", LAND_REGION));
r = setup_trade_region(tc, get_terrain("swamp"));
init_terrains();
it_luxury = r_luxury(r);
@ -240,6 +242,8 @@ static void test_trade_insect(CuTest *tc) {
produce(u->region);
CuAssertIntEquals(tc, 1, get_item(u, it_luxury));
CuAssertIntEquals(tc, 5, get_item(u, it_silver));
terraform_region(r, get_terrain("swamp"));
test_cleanup();
}