forked from github/server
Merge branch 'master' of github.com:badgerman/eressea
This commit is contained in:
commit
0566dca971
|
@ -57,6 +57,7 @@ static void test_build_requires_materials(CuTest *tc) {
|
||||||
i_change(&u->items, itype, 2);
|
i_change(&u->items, itype, 2);
|
||||||
CuAssertIntEquals(tc, 1, build(u, &bf.cons, 0, 1));
|
CuAssertIntEquals(tc, 1, build(u, &bf.cons, 0, 1));
|
||||||
CuAssertIntEquals(tc, 1, i_get(u->items, itype));
|
CuAssertIntEquals(tc, 1, i_get(u->items, itype));
|
||||||
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_build_requires_building(CuTest *tc) {
|
static void test_build_requires_building(CuTest *tc) {
|
||||||
|
@ -78,6 +79,7 @@ static void test_build_requires_building(CuTest *tc) {
|
||||||
CuAssertIntEquals(tc, 1, build(u, &bf.cons, 0, 1));
|
CuAssertIntEquals(tc, 1, build(u, &bf.cons, 0, 1));
|
||||||
btype->maxcapacity = 0;
|
btype->maxcapacity = 0;
|
||||||
CuAssertIntEquals_Msg(tc, "cannot build when production building capacity exceeded", EBUILDINGREQ, build(u, &bf.cons, 0, 1));
|
CuAssertIntEquals_Msg(tc, "cannot build when production building capacity exceeded", EBUILDINGREQ, build(u, &bf.cons, 0, 1));
|
||||||
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_build_failure_missing_skill(CuTest *tc) {
|
static void test_build_failure_missing_skill(CuTest *tc) {
|
||||||
|
@ -89,6 +91,7 @@ static void test_build_failure_missing_skill(CuTest *tc) {
|
||||||
rtype = bf.cons.materials[0].rtype;
|
rtype = bf.cons.materials[0].rtype;
|
||||||
i_change(&u->items, rtype->itype, 1);
|
i_change(&u->items, rtype->itype, 1);
|
||||||
CuAssertIntEquals(tc, ENEEDSKILL, build(u, &bf.cons, 1, 1));
|
CuAssertIntEquals(tc, ENEEDSKILL, build(u, &bf.cons, 1, 1));
|
||||||
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_build_failure_low_skill(CuTest *tc) {
|
static void test_build_failure_low_skill(CuTest *tc) {
|
||||||
|
@ -101,6 +104,7 @@ static void test_build_failure_low_skill(CuTest *tc) {
|
||||||
i_change(&u->items, rtype->itype, 1);
|
i_change(&u->items, rtype->itype, 1);
|
||||||
set_level(u, SK_ARMORER, bf.cons.minskill-1);
|
set_level(u, SK_ARMORER, bf.cons.minskill-1);
|
||||||
CuAssertIntEquals(tc, ELOWSKILL, build(u, &bf.cons, 0, 10));
|
CuAssertIntEquals(tc, ELOWSKILL, build(u, &bf.cons, 0, 10));
|
||||||
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_build_failure_completed(CuTest *tc) {
|
static void test_build_failure_completed(CuTest *tc) {
|
||||||
|
@ -115,6 +119,7 @@ static void test_build_failure_completed(CuTest *tc) {
|
||||||
bf.cons.maxsize = 1;
|
bf.cons.maxsize = 1;
|
||||||
CuAssertIntEquals(tc, ECOMPLETE, build(u, &bf.cons, bf.cons.maxsize, 10));
|
CuAssertIntEquals(tc, ECOMPLETE, build(u, &bf.cons, bf.cons.maxsize, 10));
|
||||||
CuAssertIntEquals(tc, 1, i_get(u->items, rtype->itype));
|
CuAssertIntEquals(tc, 1, i_get(u->items, rtype->itype));
|
||||||
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_build_limits(CuTest *tc) {
|
static void test_build_limits(CuTest *tc) {
|
||||||
|
@ -202,6 +207,7 @@ static void test_build_building_no_materials(CuTest *tc) {
|
||||||
CuAssertIntEquals(tc, ENOMATERIALS, build_building(u, btype, 0, 4, 0));
|
CuAssertIntEquals(tc, ENOMATERIALS, build_building(u, btype, 0, 4, 0));
|
||||||
CuAssertPtrEquals(tc, 0, u->region->buildings);
|
CuAssertPtrEquals(tc, 0, u->region->buildings);
|
||||||
CuAssertPtrEquals(tc, 0, u->building);
|
CuAssertPtrEquals(tc, 0, u->building);
|
||||||
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_build_building_with_golem(CuTest *tc) {
|
static void test_build_building_with_golem(CuTest *tc) {
|
||||||
|
@ -220,6 +226,7 @@ static void test_build_building_with_golem(CuTest *tc) {
|
||||||
CuAssertPtrNotNull(tc, u->region->buildings);
|
CuAssertPtrNotNull(tc, u->region->buildings);
|
||||||
CuAssertIntEquals(tc, 1, u->region->buildings->size);
|
CuAssertIntEquals(tc, 1, u->region->buildings->size);
|
||||||
CuAssertIntEquals(tc, 0, u->number);
|
CuAssertIntEquals(tc, 0, u->number);
|
||||||
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_build_building_success(CuTest *tc) {
|
static void test_build_building_success(CuTest *tc) {
|
||||||
|
@ -243,6 +250,7 @@ static void test_build_building_success(CuTest *tc) {
|
||||||
CuAssertPtrEquals(tc, u->region->buildings, u->building);
|
CuAssertPtrEquals(tc, u->region->buildings, u->building);
|
||||||
CuAssertIntEquals(tc, 1, u->building->size);
|
CuAssertIntEquals(tc, 1, u->building->size);
|
||||||
CuAssertIntEquals(tc, 0, i_get(u->items, rtype->itype));
|
CuAssertIntEquals(tc, 0, i_get(u->items, rtype->itype));
|
||||||
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
CuSuite *get_build_suite(void)
|
CuSuite *get_build_suite(void)
|
||||||
|
|
|
@ -92,8 +92,14 @@ void bt_register(building_type * type)
|
||||||
ql_push(&buildingtypes, (void *)type);
|
ql_push(&buildingtypes, (void *)type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void free_buildingtype(void *ptr) {
|
||||||
|
building_type *btype =(building_type *)ptr;
|
||||||
|
free(btype->_name);
|
||||||
|
free(btype);
|
||||||
|
}
|
||||||
|
|
||||||
void free_buildingtypes(void) {
|
void free_buildingtypes(void) {
|
||||||
ql_foreach(buildingtypes, free);
|
ql_foreach(buildingtypes, free_buildingtype);
|
||||||
ql_free(buildingtypes);
|
ql_free(buildingtypes);
|
||||||
buildingtypes = 0;
|
buildingtypes = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ extern "C" {
|
||||||
#define BTF_NAMECHANGE 0x100 /* name and description can be changed more than once */
|
#define BTF_NAMECHANGE 0x100 /* name and description can be changed more than once */
|
||||||
|
|
||||||
typedef struct building_type {
|
typedef struct building_type {
|
||||||
const char *_name;
|
char *_name;
|
||||||
|
|
||||||
int flags; /* flags */
|
int flags; /* flags */
|
||||||
int capacity; /* Kapazität pro Größenpunkt */
|
int capacity; /* Kapazität pro Größenpunkt */
|
||||||
|
|
|
@ -22,6 +22,8 @@ static void test_register_building(CuTest * tc)
|
||||||
bt_register(btype);
|
bt_register(btype);
|
||||||
|
|
||||||
CuAssertPtrNotNull(tc, bt_find("herp"));
|
CuAssertPtrNotNull(tc, bt_find("herp"));
|
||||||
|
// free(btype->_name);
|
||||||
|
// free(btype);
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,7 +238,8 @@ void free_ship(ship * s)
|
||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_shiptype(ship_type *stype) {
|
static void free_shiptype(void *ptr) {
|
||||||
|
ship_type *stype = (ship_type *)ptr;
|
||||||
free(stype->_name);
|
free(stype->_name);
|
||||||
free(stype);
|
free(stype);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <tests.h>
|
#include <tests.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
static void test_market_curse(CuTest * tc)
|
static void test_market_curse(CuTest * tc)
|
||||||
{
|
{
|
||||||
|
@ -45,7 +46,7 @@ static void test_market_curse(CuTest * tc)
|
||||||
set_param(&global.parameters, "rules.region_owners", "1");
|
set_param(&global.parameters, "rules.region_owners", "1");
|
||||||
|
|
||||||
btype = (building_type *)calloc(1, sizeof(building_type));
|
btype = (building_type *)calloc(1, sizeof(building_type));
|
||||||
btype->_name = "market";
|
btype->_name = _strdup("market");
|
||||||
bt_register(btype);
|
bt_register(btype);
|
||||||
|
|
||||||
terrain = get_terrain("plain");
|
terrain = get_terrain("plain");
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <kernel/types.h>
|
#include <kernel/types.h>
|
||||||
#include <kernel/item.h>
|
#include <kernel/item.h>
|
||||||
#include <kernel/region.h>
|
#include <kernel/region.h>
|
||||||
|
#include <kernel/terrain.h>
|
||||||
|
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
|
|
||||||
|
@ -45,6 +46,8 @@ static void test_recreate_world(CuTest * tc)
|
||||||
CuAssertPtrEquals(tc, default_locale, get_locale("de"));
|
CuAssertPtrEquals(tc, default_locale, get_locale("de"));
|
||||||
CuAssertPtrNotNull(tc, default_locale);
|
CuAssertPtrNotNull(tc, default_locale);
|
||||||
CuAssertPtrNotNull(tc, findregion(0, 0));
|
CuAssertPtrNotNull(tc, findregion(0, 0));
|
||||||
|
CuAssertPtrNotNull(tc, get_terrain("plain"));
|
||||||
|
CuAssertPtrNotNull(tc, get_terrain("ocean"));
|
||||||
CuAssertPtrNotNull(tc, (void *)rt_find("horse"));
|
CuAssertPtrNotNull(tc, (void *)rt_find("horse"));
|
||||||
CuAssertPtrNotNull(tc, get_resourcetype(R_HORSE));
|
CuAssertPtrNotNull(tc, get_resourcetype(R_HORSE));
|
||||||
CuAssertPtrNotNull(tc, (void *)rt_find("money"));
|
CuAssertPtrNotNull(tc, (void *)rt_find("money"));
|
||||||
|
@ -56,6 +59,8 @@ static void test_recreate_world(CuTest * tc)
|
||||||
|
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
CuAssertPtrEquals(tc, 0, get_locale("de"));
|
CuAssertPtrEquals(tc, 0, get_locale("de"));
|
||||||
|
CuAssertPtrEquals(tc, 0, (void*)get_terrain("plain"));
|
||||||
|
CuAssertPtrEquals(tc, 0, (void*)get_terrain("ocean"));
|
||||||
CuAssertPtrEquals(tc, 0, (void*)rt_find("horse"));
|
CuAssertPtrEquals(tc, 0, (void*)rt_find("horse"));
|
||||||
CuAssertPtrEquals(tc, 0, (void*)get_resourcetype(R_HORSE));
|
CuAssertPtrEquals(tc, 0, (void*)get_resourcetype(R_HORSE));
|
||||||
CuAssertPtrNotNull(tc, (void *)rt_find("money"));
|
CuAssertPtrNotNull(tc, (void *)rt_find("money"));
|
||||||
|
|
|
@ -61,7 +61,9 @@ static void a_initdirection(attrib * a)
|
||||||
|
|
||||||
static void a_freedirection(attrib * a)
|
static void a_freedirection(attrib * a)
|
||||||
{
|
{
|
||||||
free(a->data.v);
|
spec_direction *d = (spec_direction *)(a->data.v);
|
||||||
|
free(d->desc);
|
||||||
|
free(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int a_agedirection(attrib * a)
|
static int a_agedirection(attrib * a)
|
||||||
|
|
Loading…
Reference in New Issue