forked from github/server
remove the SAIL_INTO flag
This commit is contained in:
parent
7fd1d3d616
commit
78fa6d3a47
|
@ -458,7 +458,7 @@ static void test_terrains(CuTest * tc)
|
||||||
"\"size\": 4000, "
|
"\"size\": 4000, "
|
||||||
"\"road\": 50, "
|
"\"road\": 50, "
|
||||||
"\"seed\": 3, "
|
"\"seed\": 3, "
|
||||||
"\"flags\" : [ \"forbidden\", \"arctic\", \"cavalry\", \"sea\", \"forest\", \"land\", \"sail\", \"fly\", \"swim\", \"walk\" ] } }}";
|
"\"flags\" : [ \"forbidden\", \"arctic\", \"cavalry\", \"sea\", \"forest\", \"land\", \"fly\", \"swim\", \"walk\" ] } }}";
|
||||||
const terrain_type *ter;
|
const terrain_type *ter;
|
||||||
|
|
||||||
cJSON *json = cJSON_Parse(data);
|
cJSON *json = cJSON_Parse(data);
|
||||||
|
@ -470,7 +470,7 @@ static void test_terrains(CuTest * tc)
|
||||||
json_config(json);
|
json_config(json);
|
||||||
ter = get_terrain("plain");
|
ter = get_terrain("plain");
|
||||||
CuAssertPtrNotNull(tc, ter);
|
CuAssertPtrNotNull(tc, ter);
|
||||||
CuAssertIntEquals(tc, ARCTIC_REGION | LAND_REGION | SEA_REGION | FOREST_REGION | CAVALRY_REGION | FORBIDDEN_REGION | FLY_INTO | WALK_INTO | SWIM_INTO | SAIL_INTO, ter->flags);
|
CuAssertIntEquals(tc, ARCTIC_REGION | LAND_REGION | SEA_REGION | FOREST_REGION | CAVALRY_REGION | FORBIDDEN_REGION | FLY_INTO | WALK_INTO | SWIM_INTO , ter->flags);
|
||||||
CuAssertIntEquals(tc, 4000, ter->size);
|
CuAssertIntEquals(tc, 4000, ter->size);
|
||||||
CuAssertIntEquals(tc, 50, ter->max_road);
|
CuAssertIntEquals(tc, 50, ter->max_road);
|
||||||
CuAssertIntEquals(tc, 3, ter->distribution);
|
CuAssertIntEquals(tc, 3, ter->distribution);
|
||||||
|
|
|
@ -31,7 +31,6 @@ extern "C" {
|
||||||
#define CAVALRY_REGION (1<<4) /* riding in combat is possible */
|
#define CAVALRY_REGION (1<<4) /* riding in combat is possible */
|
||||||
/* Achtung: SEA_REGION ist nicht das Gegenteil von LAND_REGION. Die zwei schliessen sich nichtmal aus! */
|
/* Achtung: SEA_REGION ist nicht das Gegenteil von LAND_REGION. Die zwei schliessen sich nichtmal aus! */
|
||||||
#define FORBIDDEN_REGION (1<<5) /* unpassierbare Blockade-struct region */
|
#define FORBIDDEN_REGION (1<<5) /* unpassierbare Blockade-struct region */
|
||||||
#define SAIL_INTO (1<<6) /* man darf hierhin segeln */
|
|
||||||
#define FLY_INTO (1<<7) /* man darf hierhin fliegen */
|
#define FLY_INTO (1<<7) /* man darf hierhin fliegen */
|
||||||
#define SWIM_INTO (1<<8) /* man darf hierhin schwimmen */
|
#define SWIM_INTO (1<<8) /* man darf hierhin schwimmen */
|
||||||
#define WALK_INTO (1<<9) /* man darf hierhin laufen */
|
#define WALK_INTO (1<<9) /* man darf hierhin laufen */
|
||||||
|
|
|
@ -55,7 +55,7 @@ static void create_monsters(faction **player, faction **monsters, unit **u, unit
|
||||||
fset(*monsters, FFL_NOIDLEOUT);
|
fset(*monsters, FFL_NOIDLEOUT);
|
||||||
assert(fval(*monsters, FFL_NPC) && fval((*monsters)->race, RCF_UNARMEDGUARD) && fval((*monsters)->race, RCF_NPC) && fval(*monsters, FFL_NOIDLEOUT));
|
assert(fval(*monsters, FFL_NPC) && fval((*monsters)->race, RCF_UNARMEDGUARD) && fval((*monsters)->race, RCF_NPC) && fval(*monsters, FFL_NOIDLEOUT));
|
||||||
|
|
||||||
test_create_region(-1, 0, test_create_terrain("ocean", SEA_REGION | SAIL_INTO | SWIM_INTO | FLY_INTO));
|
test_create_region(-1, 0, test_create_terrain("ocean", SEA_REGION | SWIM_INTO | FLY_INTO));
|
||||||
test_create_region(1, 0, 0);
|
test_create_region(1, 0, 0);
|
||||||
r = test_create_region(0, 0, 0);
|
r = test_create_region(0, 0, 0);
|
||||||
|
|
||||||
|
|
|
@ -784,7 +784,7 @@ region * drift_target(ship *sh) {
|
||||||
region *rn;
|
region *rn;
|
||||||
direction_t dir = (direction_t)((d + d_offset) % MAXDIRECTIONS);
|
direction_t dir = (direction_t)((d + d_offset) % MAXDIRECTIONS);
|
||||||
rn = rconnect(sh->region, dir);
|
rn = rconnect(sh->region, dir);
|
||||||
if (rn != NULL && fval(rn->terrain, SAIL_INTO) && check_ship_allowed(sh, rn) >= 0) {
|
if (rn != NULL && check_ship_allowed(sh, rn) >= 0) {
|
||||||
rnext = rn;
|
rnext = rn;
|
||||||
if (!fval(rnext->terrain, SEA_REGION)) {
|
if (!fval(rnext->terrain, SEA_REGION)) {
|
||||||
// prefer drifting towards non-ocean regions
|
// prefer drifting towards non-ocean regions
|
||||||
|
|
|
@ -35,8 +35,8 @@ static void test_ship_not_allowed_in_coast(CuTest * tc)
|
||||||
ship_type *stype;
|
ship_type *stype;
|
||||||
|
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
ttype = test_create_terrain("glacier", LAND_REGION | ARCTIC_REGION | WALK_INTO | SAIL_INTO);
|
ttype = test_create_terrain("glacier", LAND_REGION | ARCTIC_REGION | WALK_INTO);
|
||||||
otype = test_create_terrain("ocean", SEA_REGION | SAIL_INTO);
|
otype = test_create_terrain("ocean", SEA_REGION);
|
||||||
stype = test_create_shiptype("derp");
|
stype = test_create_shiptype("derp");
|
||||||
free(stype->coasts);
|
free(stype->coasts);
|
||||||
stype->coasts = (struct terrain_type **)calloc(2, sizeof(struct terrain_type *));
|
stype->coasts = (struct terrain_type **)calloc(2, sizeof(struct terrain_type *));
|
||||||
|
@ -69,7 +69,7 @@ static void setup_harbor(move_fixture *mf) {
|
||||||
|
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
|
|
||||||
ttype = test_create_terrain("glacier", LAND_REGION | ARCTIC_REGION | WALK_INTO | SAIL_INTO);
|
ttype = test_create_terrain("glacier", LAND_REGION | ARCTIC_REGION | WALK_INTO);
|
||||||
btype = test_create_buildingtype("harbour");
|
btype = test_create_buildingtype("harbour");
|
||||||
|
|
||||||
sh = test_create_ship(0, 0);
|
sh = test_create_ship(0, 0);
|
||||||
|
@ -232,7 +232,7 @@ static void test_ship_trails(CuTest *tc) {
|
||||||
region_list *route = 0;
|
region_list *route = 0;
|
||||||
|
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
otype = test_create_terrain("ocean", SEA_REGION | SAIL_INTO);
|
otype = test_create_terrain("ocean", SEA_REGION);
|
||||||
r1 = test_create_region(0, 0, otype);
|
r1 = test_create_region(0, 0, otype);
|
||||||
r2 = test_create_region(1, 0, otype);
|
r2 = test_create_region(1, 0, otype);
|
||||||
r3 = test_create_region(2, 0, otype);
|
r3 = test_create_region(2, 0, otype);
|
||||||
|
@ -298,7 +298,7 @@ void setup_drift (struct drift_fixture *fix) {
|
||||||
fix->st_boat->cabins = 20000;
|
fix->st_boat->cabins = 20000;
|
||||||
|
|
||||||
fix->u = test_create_unit(fix->f = test_create_faction(0), fix->r=findregion(-1,0));
|
fix->u = test_create_unit(fix->f = test_create_faction(0), fix->r=findregion(-1,0));
|
||||||
assert(fix->r && fix->r->terrain->flags & SAIL_INTO);
|
assert(fix->r);
|
||||||
set_level(fix->u, SK_SAILING, fix->st_boat->sumskill);
|
set_level(fix->u, SK_SAILING, fix->st_boat->sumskill);
|
||||||
u_set_ship(fix->u, fix->sh = test_create_ship(fix->u->region, fix->st_boat));
|
u_set_ship(fix->u, fix->sh = test_create_ship(fix->u->region, fix->st_boat));
|
||||||
assert(fix->f && fix->u && fix->sh);
|
assert(fix->f && fix->u && fix->sh);
|
||||||
|
@ -504,8 +504,8 @@ static void test_drifting_ships(CuTest *tc) {
|
||||||
terrain_type *t_ocean, *t_plain;
|
terrain_type *t_ocean, *t_plain;
|
||||||
ship_type *st_boat;
|
ship_type *st_boat;
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
t_ocean = test_create_terrain("ocean", SEA_REGION|SAIL_INTO);
|
t_ocean = test_create_terrain("ocean", SEA_REGION);
|
||||||
t_plain = test_create_terrain("plain", LAND_REGION|SAIL_INTO);
|
t_plain = test_create_terrain("plain", LAND_REGION);
|
||||||
r1 = test_create_region(0, 0, t_ocean);
|
r1 = test_create_region(0, 0, t_ocean);
|
||||||
r2 = test_create_region(1, 0, t_ocean);
|
r2 = test_create_region(1, 0, t_ocean);
|
||||||
st_boat = test_create_shiptype("boat");
|
st_boat = test_create_shiptype("boat");
|
||||||
|
|
|
@ -151,7 +151,7 @@ void piracy_cmd(unit * u, order *ord)
|
||||||
// TODO this could still result in an illegal movement order (through a wall or whatever)
|
// TODO this could still result in an illegal movement order (through a wall or whatever)
|
||||||
// which will be prevented by move_cmd below
|
// which will be prevented by move_cmd below
|
||||||
if (rc &&
|
if (rc &&
|
||||||
((sh && fval(rc->terrain, SAIL_INTO) && can_takeoff(sh, r, rc))
|
((sh && !fval(rc->terrain, FORBIDDEN_REGION) && can_takeoff(sh, r, rc))
|
||||||
|| (canswim(u) && fval(rc->terrain, SWIM_INTO) && fval(rc->terrain, SEA_REGION)))) {
|
|| (canswim(u) && fval(rc->terrain, SWIM_INTO) && fval(rc->terrain, SEA_REGION)))) {
|
||||||
|
|
||||||
for (sh2 = rc->ships; sh2; sh2 = sh2->next) {
|
for (sh2 = rc->ships; sh2; sh2 = sh2->next) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ static void setup_piracy(void) {
|
||||||
lang = get_or_create_locale("de");
|
lang = get_or_create_locale("de");
|
||||||
locale_setstring(lang, directions[D_EAST], "OSTEN");
|
locale_setstring(lang, directions[D_EAST], "OSTEN");
|
||||||
init_directions(lang);
|
init_directions(lang);
|
||||||
test_create_terrain("ocean", SAIL_INTO | SEA_REGION);
|
test_create_terrain("ocean", SEA_REGION);
|
||||||
st_boat = test_create_shiptype("boat");
|
st_boat = test_create_shiptype("boat");
|
||||||
st_boat->cargo = 1000;
|
st_boat->cargo = 1000;
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ static void test_piracy_cmd_land_to_land(CuTest * tc) {
|
||||||
|
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
|
|
||||||
setup_pirate(&pirate, 0, 0, "boat", &ord, &victim, SAIL_INTO, "boat");
|
setup_pirate(&pirate, 0, 0, "boat", &ord, &victim, SEA_REGION, "boat");
|
||||||
set_level(pirate, SK_SAILING, pirate->ship->type->sumskill);
|
set_level(pirate, SK_SAILING, pirate->ship->type->sumskill);
|
||||||
r = pirate->region;
|
r = pirate->region;
|
||||||
|
|
||||||
|
|
10
src/tests.c
10
src/tests.c
|
@ -54,7 +54,7 @@ struct region *test_create_region(int x, int y, const terrain_type *terrain)
|
||||||
if (!terrain) {
|
if (!terrain) {
|
||||||
terrain_type *t = get_or_create_terrain("plain");
|
terrain_type *t = get_or_create_terrain("plain");
|
||||||
t->size = 1000;
|
t->size = 1000;
|
||||||
fset(t, LAND_REGION|CAVALRY_REGION|FOREST_REGION|FLY_INTO|WALK_INTO|SAIL_INTO);
|
fset(t, LAND_REGION|CAVALRY_REGION|FOREST_REGION|FLY_INTO|WALK_INTO);
|
||||||
terraform_region(r, t);
|
terraform_region(r, t);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -197,8 +197,8 @@ ship_type * test_create_shiptype(const char * name)
|
||||||
}
|
}
|
||||||
stype->coasts =
|
stype->coasts =
|
||||||
(terrain_type **)malloc(sizeof(terrain_type *) * 3);
|
(terrain_type **)malloc(sizeof(terrain_type *) * 3);
|
||||||
stype->coasts[0] = test_create_terrain("plain", LAND_REGION | FOREST_REGION | WALK_INTO | CAVALRY_REGION | SAIL_INTO | FLY_INTO);
|
stype->coasts[0] = test_create_terrain("plain", LAND_REGION | FOREST_REGION | WALK_INTO | CAVALRY_REGION | FLY_INTO);
|
||||||
stype->coasts[1] = test_create_terrain("ocean", SEA_REGION | SWIM_INTO | SAIL_INTO | FLY_INTO);
|
stype->coasts[1] = test_create_terrain("ocean", SEA_REGION | SWIM_INTO | FLY_INTO);
|
||||||
stype->coasts[2] = NULL;
|
stype->coasts[2] = NULL;
|
||||||
if (default_locale) {
|
if (default_locale) {
|
||||||
locale_setstring(default_locale, name, name);
|
locale_setstring(default_locale, name, name);
|
||||||
|
@ -323,10 +323,10 @@ void test_create_world(void)
|
||||||
test_create_itemtype("iron");
|
test_create_itemtype("iron");
|
||||||
test_create_itemtype("stone");
|
test_create_itemtype("stone");
|
||||||
|
|
||||||
t_plain = test_create_terrain("plain", LAND_REGION | FOREST_REGION | WALK_INTO | CAVALRY_REGION | SAIL_INTO | FLY_INTO);
|
t_plain = test_create_terrain("plain", LAND_REGION | FOREST_REGION | WALK_INTO | CAVALRY_REGION | FLY_INTO);
|
||||||
t_plain->size = 1000;
|
t_plain->size = 1000;
|
||||||
t_plain->max_road = 100;
|
t_plain->max_road = 100;
|
||||||
t_ocean = test_create_terrain("ocean", SEA_REGION | SAIL_INTO | SWIM_INTO | FLY_INTO);
|
t_ocean = test_create_terrain("ocean", SEA_REGION | SWIM_INTO | FLY_INTO);
|
||||||
t_ocean->size = 0;
|
t_ocean->size = 0;
|
||||||
|
|
||||||
island[0] = test_create_region(0, 0, t_plain);
|
island[0] = test_create_region(0, 0, t_plain);
|
||||||
|
|
Loading…
Reference in New Issue