remove the SAIL_INTO flag

This commit is contained in:
Enno Rehling 2016-06-10 20:55:27 +02:00
parent 7fd1d3d616
commit 78fa6d3a47
8 changed files with 19 additions and 20 deletions

View File

@ -458,7 +458,7 @@ static void test_terrains(CuTest * tc)
"\"size\": 4000, "
"\"road\": 50, "
"\"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;
cJSON *json = cJSON_Parse(data);
@ -470,7 +470,7 @@ static void test_terrains(CuTest * tc)
json_config(json);
ter = get_terrain("plain");
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, 50, ter->max_road);
CuAssertIntEquals(tc, 3, ter->distribution);

View File

@ -31,7 +31,6 @@ extern "C" {
#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! */
#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 SWIM_INTO (1<<8) /* man darf hierhin schwimmen */
#define WALK_INTO (1<<9) /* man darf hierhin laufen */

View File

@ -55,7 +55,7 @@ static void create_monsters(faction **player, faction **monsters, unit **u, unit
fset(*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);
r = test_create_region(0, 0, 0);

View File

@ -784,7 +784,7 @@ region * drift_target(ship *sh) {
region *rn;
direction_t dir = (direction_t)((d + d_offset) % MAXDIRECTIONS);
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;
if (!fval(rnext->terrain, SEA_REGION)) {
// prefer drifting towards non-ocean regions

View File

@ -35,8 +35,8 @@ static void test_ship_not_allowed_in_coast(CuTest * tc)
ship_type *stype;
test_cleanup();
ttype = test_create_terrain("glacier", LAND_REGION | ARCTIC_REGION | WALK_INTO | SAIL_INTO);
otype = test_create_terrain("ocean", SEA_REGION | SAIL_INTO);
ttype = test_create_terrain("glacier", LAND_REGION | ARCTIC_REGION | WALK_INTO);
otype = test_create_terrain("ocean", SEA_REGION);
stype = test_create_shiptype("derp");
free(stype->coasts);
stype->coasts = (struct terrain_type **)calloc(2, sizeof(struct terrain_type *));
@ -69,7 +69,7 @@ static void setup_harbor(move_fixture *mf) {
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");
sh = test_create_ship(0, 0);
@ -232,7 +232,7 @@ static void test_ship_trails(CuTest *tc) {
region_list *route = 0;
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);
r2 = test_create_region(1, 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->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);
u_set_ship(fix->u, fix->sh = test_create_ship(fix->u->region, fix->st_boat));
assert(fix->f && fix->u && fix->sh);
@ -504,8 +504,8 @@ static void test_drifting_ships(CuTest *tc) {
terrain_type *t_ocean, *t_plain;
ship_type *st_boat;
test_cleanup();
t_ocean = test_create_terrain("ocean", SEA_REGION|SAIL_INTO);
t_plain = test_create_terrain("plain", LAND_REGION|SAIL_INTO);
t_ocean = test_create_terrain("ocean", SEA_REGION);
t_plain = test_create_terrain("plain", LAND_REGION);
r1 = test_create_region(0, 0, t_ocean);
r2 = test_create_region(1, 0, t_ocean);
st_boat = test_create_shiptype("boat");

View File

@ -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)
// which will be prevented by move_cmd below
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)))) {
for (sh2 = rc->ships; sh2; sh2 = sh2->next) {

View File

@ -26,7 +26,7 @@ static void setup_piracy(void) {
lang = get_or_create_locale("de");
locale_setstring(lang, directions[D_EAST], "OSTEN");
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->cargo = 1000;
}
@ -184,7 +184,7 @@ static void test_piracy_cmd_land_to_land(CuTest * tc) {
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);
r = pirate->region;

View File

@ -54,7 +54,7 @@ struct region *test_create_region(int x, int y, const terrain_type *terrain)
if (!terrain) {
terrain_type *t = get_or_create_terrain("plain");
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);
}
else {
@ -197,8 +197,8 @@ ship_type * test_create_shiptype(const char * name)
}
stype->coasts =
(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[1] = test_create_terrain("ocean", SEA_REGION | SWIM_INTO | 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 | FLY_INTO);
stype->coasts[2] = NULL;
if (default_locale) {
locale_setstring(default_locale, name, name);
@ -323,10 +323,10 @@ void test_create_world(void)
test_create_itemtype("iron");
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->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;
island[0] = test_create_region(0, 0, t_plain);