insects trying to land in glaciers should not damage ships (cf. #1729)

This commit is contained in:
Enno Rehling 2011-03-09 20:49:55 +01:00
parent f0039bc58f
commit 2c02c38803
1 changed files with 15 additions and 8 deletions

View File

@ -628,7 +628,12 @@ static boolean is_freezing(const unit * u)
return true; return true;
} }
static boolean ship_allowed(const struct ship *sh, const region * r) #define SA_HARBOUR 1
#define SA_COAST 1
#define SA_NO_INSECT -1
#define SA_NO_COAST -2
static int ship_allowed(const struct ship *sh, const region * r)
{ {
int c = 0; int c = 0;
static const building_type *bt_harbour = NULL; static const building_type *bt_harbour = NULL;
@ -651,19 +656,19 @@ static boolean ship_allowed(const struct ship *sh, const region * r)
"unit region", u, r)); "unit region", u, r));
} }
return false; return SA_NO_INSECT;
} }
} }
} }
if (buildingtype_exists(r, bt_harbour, true)) if (buildingtype_exists(r, bt_harbour, true))
return true; return SA_HARBOUR;
for (c = 0; sh->type->coasts[c] != NULL; ++c) { for (c = 0; sh->type->coasts[c] != NULL; ++c) {
if (sh->type->coasts[c] == r->terrain) if (sh->type->coasts[c] == r->terrain)
return true; return SA_COAST;
} }
return false; return SA_NO_COAST;
} }
static boolean flying_ship(const ship * sh) static boolean flying_ship(const ship * sh)
@ -747,7 +752,7 @@ static void drifting_ships(region * r)
region *rn; region *rn;
dir = (direction_t) ((d + d_offset) % MAXDIRECTIONS); dir = (direction_t) ((d + d_offset) % MAXDIRECTIONS);
rn = rconnect(r, dir); rn = rconnect(r, dir);
if (rn != NULL && fval(rn->terrain, SAIL_INTO) && ship_allowed(sh, rn)) { if (rn != NULL && fval(rn->terrain, SAIL_INTO) && ship_allowed(sh, rn) > 0) {
rnext = rn; rnext = rn;
if (!fval(rnext->terrain, SEA_REGION)) if (!fval(rnext->terrain, SEA_REGION))
break; break;
@ -1726,6 +1731,7 @@ sail(unit * u, order * ord, boolean move_on_land, region_list ** routep)
int stormchance; int stormchance;
static int stormyness; static int stormyness;
static int gamecookie = -1; static int gamecookie = -1;
int reason;
if (gamecookie != global.cookie) { if (gamecookie != global.cookie) {
gamedate date; gamedate date;
@ -1813,9 +1819,10 @@ sail(unit * u, order * ord, boolean move_on_land, region_list ** routep)
} }
} }
if (!ship_allowed(sh, next_point)) { reason = ship_allowed(sh, next_point);
if (reason<0) {
/* for some reason or another, we aren't allowed in there.. */ /* for some reason or another, we aren't allowed in there.. */
if (check_leuchtturm(current_point, NULL)) { if (check_leuchtturm(current_point, NULL) || reason == SA_NO_INSECT) {
ADDMSG(&f->msgs, msg_message("sailnolandingstorm", "ship", sh)); ADDMSG(&f->msgs, msg_message("sailnolandingstorm", "ship", sh));
} else { } else {
float dmg = float dmg =