mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-31 03:12:41 +00:00
(svn r8871) [0.5] -Backport from trunk (r8689, r8794, r8802, r8808):
- Crash when an old savegame had buoys on the northern edge of the map (r8689) - It was possible to take over buoys by building a station next to them (r8794) - Adhere order types for ship order insertion to determine destination type (r8802) - Do not show the 'edit sign' window for spectators (r8808)
This commit is contained in:
parent
edc2ac8bbf
commit
36134a7285
@ -1585,6 +1585,15 @@ bool AfterLoadGame(void)
|
||||
SettingsDisableElrail(_patches.disable_elrails);
|
||||
}
|
||||
|
||||
/* Buoys do now store the owner of the previous water tile, which can never
|
||||
* be OWNER_NONE. So replace OWNER_NONE with OWNER_WATER. */
|
||||
if (CheckSavegameVersion(46)) {
|
||||
Station *st;
|
||||
FOR_ALL_STATIONS(st) {
|
||||
if (IsBuoy(st) && IsTileOwner(st->xy, OWNER_NONE)) SetTileOwner(st->xy, OWNER_WATER);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
44
order_cmd.c
44
order_cmd.c
@ -167,6 +167,16 @@ static void DeleteOrderWarnings(const Vehicle* v)
|
||||
}
|
||||
|
||||
|
||||
static TileIndex GetOrderLocation(const Order *o)
|
||||
{
|
||||
switch (o->type) {
|
||||
default: NOT_REACHED();
|
||||
case OT_GOTO_STATION: return GetStation(o->dest)->xy;
|
||||
case OT_GOTO_DEPOT: return GetDepot(o->dest)->xy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Add an order to the orderlist of a vehicle.
|
||||
* @param tile unused
|
||||
* @param p1 various bitstuffed elements
|
||||
@ -343,18 +353,30 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
* handle any more then this.. */
|
||||
if (v->num_orders >= MAX_BACKUP_ORDER_COUNT) return_cmd_error(STR_8832_TOO_MANY_ORDERS);
|
||||
|
||||
/* For ships, make sure that the station is not too far away from the
|
||||
* previous destination, for human players with new pathfinding disabled */
|
||||
if (v->type == VEH_Ship && IsHumanPlayer(v->owner) &&
|
||||
sel_ord != 0 && GetVehicleOrder(v, sel_ord - 1)->type == OT_GOTO_STATION
|
||||
&& !_patches.new_pathfinding_all) {
|
||||
if (v->type == VEH_Ship &&
|
||||
IsHumanPlayer(v->owner) &&
|
||||
!_patches.new_pathfinding_all) {
|
||||
// Make sure the new destination is not too far away from the previous
|
||||
const Order *prev = NULL;
|
||||
const Order *o;
|
||||
uint n = 0;
|
||||
|
||||
int dist = DistanceManhattan(
|
||||
GetStation(GetVehicleOrder(v, sel_ord - 1)->dest)->xy,
|
||||
GetStation(new_order.dest)->xy // XXX type != OT_GOTO_STATION?
|
||||
);
|
||||
if (dist >= 130)
|
||||
return_cmd_error(STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO);
|
||||
/* Find the last goto station or depot order before the insert location.
|
||||
* If the order is to be inserted at the beginning of the order list this
|
||||
* finds the last order in the list. */
|
||||
for (o = v->orders; o != NULL; o = o->next) {
|
||||
if (o->type == OT_GOTO_STATION || o->type == OT_GOTO_DEPOT) prev = o;
|
||||
if (++n == sel_ord && prev != NULL) break;
|
||||
}
|
||||
if (prev != NULL) {
|
||||
uint dist = DistanceManhattan(
|
||||
GetOrderLocation(prev),
|
||||
GetOrderLocation(&new_order)
|
||||
);
|
||||
if (dist >= 130) {
|
||||
return_cmd_error(STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
|
@ -231,12 +231,6 @@ static Station* GetStationAround(TileIndex tile, int w, int h, StationID closest
|
||||
BEGIN_TILE_LOOP(tile_cur, w + 2, h + 2, tile - TileDiffXY(1, 1))
|
||||
if (IsTileType(tile_cur, MP_STATION)) {
|
||||
StationID t = GetStationIndex(tile_cur);
|
||||
{
|
||||
Station *st = GetStation(t);
|
||||
// you cannot take control of an oilrig!!
|
||||
if (st->airport_type == AT_OILRIG && st->facilities == (FACIL_AIRPORT|FACIL_DOCK))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (closest_station == INVALID_STATION) {
|
||||
closest_station = t;
|
||||
@ -1016,7 +1010,7 @@ int32 CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint3
|
||||
|
||||
if (st != NULL) {
|
||||
// Reuse an existing station.
|
||||
if (st->owner != OWNER_NONE && st->owner != _current_player)
|
||||
if (st->owner != _current_player)
|
||||
return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);
|
||||
|
||||
if (st->train_tile != 0) {
|
||||
@ -1451,7 +1445,7 @@ int32 CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
}
|
||||
|
||||
if (st != NULL) {
|
||||
if (st->owner != OWNER_NONE && st->owner != _current_player) {
|
||||
if (st->owner != _current_player) {
|
||||
return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);
|
||||
}
|
||||
|
||||
@ -1706,7 +1700,7 @@ int32 CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
}
|
||||
|
||||
if (st != NULL) {
|
||||
if (st->owner != OWNER_NONE && st->owner != _current_player)
|
||||
if (st->owner != _current_player)
|
||||
return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);
|
||||
|
||||
if (!StationRect_BeforeAddRect(st, tile, w, h, RECT_MODE_TEST)) return CMD_ERROR;
|
||||
@ -1987,7 +1981,7 @@ int32 CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
}
|
||||
|
||||
if (st != NULL) {
|
||||
if (st->owner != OWNER_NONE && st->owner != _current_player)
|
||||
if (st->owner != _current_player)
|
||||
return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);
|
||||
|
||||
if (!StationRect_BeforeAddRect(st, tile, _dock_w_chk[direction], _dock_h_chk[direction], RECT_MODE_TEST)) return CMD_ERROR;
|
||||
|
@ -1617,7 +1617,7 @@ static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
|
||||
{
|
||||
const Sign *si;
|
||||
|
||||
if (!(_display_opt & DO_SHOW_SIGNS)) return false;
|
||||
if (!(_display_opt & DO_SHOW_SIGNS) || _current_player == PLAYER_SPECTATOR) return false;
|
||||
|
||||
switch (vp->zoom) {
|
||||
case 0:
|
||||
|
Loading…
Reference in New Issue
Block a user