forked from github/server
fix demand in terraformed regions.
https://bugs.eressea.de/view.php?id=2249
This commit is contained in:
parent
2fbc7a44d5
commit
cd69936922
|
@ -474,9 +474,6 @@ static int tolua_region_create(lua_State * L)
|
|||
}
|
||||
if (result) {
|
||||
terraform_region(result, terrain);
|
||||
if (result->land) {
|
||||
fix_demand(result);
|
||||
}
|
||||
}
|
||||
|
||||
tolua_pushusertype(L, result, TOLUA_CAST "region");
|
||||
|
|
|
@ -20,7 +20,7 @@ order.test.c
|
|||
plane.test.c
|
||||
pool.test.c
|
||||
race.test.c
|
||||
# region.test.c
|
||||
region.test.c
|
||||
# resources.test.c
|
||||
save.test.c
|
||||
ship.test.c
|
||||
|
|
|
@ -1057,7 +1057,6 @@ void terraform_region(region * r, const terrain_type * terrain)
|
|||
rsetmoney(r, 0);
|
||||
freset(r, RF_ENCOUNTER);
|
||||
freset(r, RF_MALLORN);
|
||||
/* Beschreibung und Namen löschen */
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1082,6 +1081,7 @@ void terraform_region(region * r, const terrain_type * terrain)
|
|||
r->land->ownership = NULL;
|
||||
region_set_morale(r, MORALE_DEFAULT, -1);
|
||||
region_setname(r, makename());
|
||||
fix_demand(r);
|
||||
for (d = 0; d != MAXDIRECTIONS; ++d) {
|
||||
region *nr = rconnect(r, d);
|
||||
if (nr && nr->land) {
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
#include <platform.h>
|
||||
|
||||
#include "region.h"
|
||||
#include "terrain.h"
|
||||
#include "item.h"
|
||||
|
||||
#include <CuTest.h>
|
||||
#include <tests.h>
|
||||
|
||||
void test_terraform(CuTest *tc) {
|
||||
region *r;
|
||||
terrain_type *t_plain, *t_ocean;
|
||||
item_type *itype;
|
||||
|
||||
test_setup();
|
||||
itype = test_create_itemtype("ointment");
|
||||
itype->rtype->flags |= (RTF_ITEM | RTF_POOLED);
|
||||
new_luxurytype(itype, 0);
|
||||
|
||||
t_plain = test_create_terrain("plain", LAND_REGION);
|
||||
t_ocean = test_create_terrain("ocean", SEA_REGION);
|
||||
r = test_create_region(0, 0, t_ocean);
|
||||
CuAssertPtrEquals(tc, 0, r->land);
|
||||
terraform_region(r, t_plain);
|
||||
CuAssertPtrNotNull(tc, r->land);
|
||||
CuAssertPtrNotNull(tc, r->land->demands);
|
||||
CuAssertPtrEquals(tc, itype, (void *)r->land->demands->type->itype);
|
||||
CuAssertIntEquals(tc, 0, r->land->demands->type->price);
|
||||
terraform_region(r, t_ocean);
|
||||
CuAssertPtrEquals(tc, 0, r->land);
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
CuSuite *get_region_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_terraform);
|
||||
return suite;
|
||||
}
|
|
@ -100,6 +100,7 @@ int RunAllTests(int argc, char *argv[])
|
|||
ADD_SUITE(magic);
|
||||
ADD_SUITE(alchemy);
|
||||
ADD_SUITE(reports);
|
||||
ADD_SUITE(region);
|
||||
ADD_SUITE(save);
|
||||
ADD_SUITE(ship);
|
||||
ADD_SUITE(spellbook);
|
||||
|
@ -111,7 +112,7 @@ int RunAllTests(int argc, char *argv[])
|
|||
ADD_SUITE(messages);
|
||||
/* gamecode */
|
||||
ADD_SUITE(report);
|
||||
// ADD_SUITE(creport);
|
||||
ADD_SUITE(creport);
|
||||
ADD_SUITE(prefix);
|
||||
ADD_SUITE(summary);
|
||||
ADD_SUITE(names);
|
||||
|
|
Loading…
Reference in New Issue