Merge branch 'master' into jgrpp-nrt
Merge trunk multiple docks implementation # Conflicts: # docs/landscape_grid.html # src/order_cmd.cpp # src/pathfinder/npf/npf.cpp # src/pathfinder/yapf/yapf_ship.cpp # src/rail_cmd.cpp # src/saveload/afterload.cpp # src/saveload/oldloader_sl.cpp # src/saveload/station_sl.cpp # src/script/api/script_order.cpp # src/ship_cmd.cpp # src/station.cpp # src/station_base.h # src/station_cmd.cpp # src/tunnelbridge_cmd.cpp
This commit is contained in:
@@ -31,7 +31,6 @@
|
||||
#include "../station_base.h"
|
||||
#include "../waypoint_base.h"
|
||||
#include "../roadstop_base.h"
|
||||
#include "../dock_base.h"
|
||||
#include "../tunnelbridge_map.h"
|
||||
#include "../pathfinder/yapf/yapf_cache.h"
|
||||
#include "../elrail_func.h"
|
||||
@@ -63,6 +62,7 @@
|
||||
#include "../tracerestrict.h"
|
||||
#include "../tunnel_map.h"
|
||||
#include "../bridge_signal_map.h"
|
||||
#include "../water.h"
|
||||
|
||||
|
||||
#include "saveload_internal.h"
|
||||
@@ -761,7 +761,6 @@ bool AfterLoadGame()
|
||||
Station *st;
|
||||
FOR_ALL_STATIONS(st) {
|
||||
if (st->airport.tile == 0) st->airport.tile = INVALID_TILE;
|
||||
if (st->dock_station.tile == 0) st->dock_station.tile = INVALID_TILE;
|
||||
if (st->train_station.tile == 0) st->train_station.tile = INVALID_TILE;
|
||||
}
|
||||
|
||||
@@ -890,7 +889,6 @@ bool AfterLoadGame()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (SlXvIsFeaturePresent(XSLFI_SPRINGPP)) {
|
||||
/*
|
||||
* Reject huge airports
|
||||
@@ -902,7 +900,7 @@ bool AfterLoadGame()
|
||||
if (st->airport.tile == INVALID_TILE) continue;
|
||||
StringID err = INVALID_STRING_ID;
|
||||
if (st->airport.type == 9) {
|
||||
if (st->dock_station.tile != INVALID_TILE && IsOilRig(st->dock_station.tile)) {
|
||||
if (st->ship_station.tile != INVALID_TILE && IsOilRig(st->ship_station.tile)) {
|
||||
/* this airport is probably an oil rig, not a huge airport */
|
||||
} else {
|
||||
err = STR_GAME_SAVELOAD_ERROR_HUGE_AIRPORTS_PRESENT;
|
||||
@@ -929,7 +927,7 @@ bool AfterLoadGame()
|
||||
Aircraft *v;
|
||||
FOR_ALL_AIRCRAFT(v) {
|
||||
Station *st = GetTargetAirportIfValid(v);
|
||||
if (st != nullptr && ((st->dock_station.tile != INVALID_TILE && IsOilRig(st->dock_station.tile)) || st->airport.type == AT_OILRIG)) {
|
||||
if (st != nullptr && ((st->ship_station.tile != INVALID_TILE && IsOilRig(st->ship_station.tile)) || st->airport.type == AT_OILRIG)) {
|
||||
/* aircraft is on approach to an oil rig, bail out now */
|
||||
SetSaveLoadError(STR_GAME_SAVELOAD_ERROR_HELI_OILRIG_BUG);
|
||||
/* Restore the signals */
|
||||
@@ -939,6 +937,13 @@ bool AfterLoadGame()
|
||||
}
|
||||
}
|
||||
|
||||
if (IsSavegameVersionBefore(SLV_MULTITILE_DOCKS)) {
|
||||
Station *st;
|
||||
FOR_ALL_STATIONS(st) {
|
||||
st->ship_station.tile = INVALID_TILE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Update all vehicles */
|
||||
AfterLoadVehicles(true);
|
||||
|
||||
@@ -1040,26 +1045,6 @@ bool AfterLoadGame()
|
||||
}
|
||||
}
|
||||
|
||||
if (SlXvIsFeatureMissing(XSLFI_MULTIPLE_DOCKS)) {
|
||||
/* Dock type has changed. */
|
||||
Station *st;
|
||||
FOR_ALL_STATIONS(st) {
|
||||
if (st->dock_station.tile == INVALID_TILE) continue;
|
||||
assert(Dock::CanAllocateItem());
|
||||
if (IsOilRig(st->dock_station.tile)) {
|
||||
/* Set dock station tile to dest tile instead of station. */
|
||||
st->docks = new Dock(st->dock_station.tile, st->dock_station.tile + ToTileIndexDiff({ 1, 0 }));
|
||||
} else if (IsDock(st->dock_station.tile)) {
|
||||
/* A normal two-tiles dock. */
|
||||
st->docks = new Dock(st->dock_station.tile, TileAddByDiagDir(st->dock_station.tile, GetDockDirection(st->dock_station.tile)));
|
||||
} else if (IsBuoy(st->dock_station.tile)) {
|
||||
/* A buoy. */
|
||||
} else {
|
||||
NOT_REACHED();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (TileIndex t = 0; t < map_size; t++) {
|
||||
switch (GetTileType(t)) {
|
||||
case MP_STATION: {
|
||||
@@ -3637,6 +3622,29 @@ bool AfterLoadGame()
|
||||
}
|
||||
}
|
||||
|
||||
/* Update structures for multitile docks */
|
||||
if (IsSavegameVersionBefore(SLV_MULTITILE_DOCKS)) {
|
||||
for (TileIndex t = 0; t < map_size; t++) {
|
||||
/* Clear docking tile flag from relevant tiles as it
|
||||
* was not previously cleared. */
|
||||
if (IsTileType(t, MP_WATER) || IsTileType(t, MP_RAILWAY) || IsTileType(t, MP_STATION) || IsTileType(t, MP_TUNNELBRIDGE)) {
|
||||
SetDockingTile(t, false);
|
||||
}
|
||||
/* Add docks and oilrigs to Station::ship_station. */
|
||||
if (IsTileType(t, MP_STATION)) {
|
||||
if (IsDock(t) || IsOilRig(t)) Station::GetByTile(t)->ship_station.Add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (IsSavegameVersionBefore(SLV_MULTITILE_DOCKS) || !SlXvIsFeaturePresent(XSLFI_MULTIPLE_DOCKS, 2)) {
|
||||
/* Scan for docking tiles */
|
||||
Station *st;
|
||||
FOR_ALL_STATIONS(st) {
|
||||
if (st->ship_station.tile != INVALID_TILE) UpdateStationDockingTiles(st);
|
||||
}
|
||||
}
|
||||
|
||||
/* Compute station catchment areas. This is needed here in case UpdateStationAcceptance is called below. */
|
||||
Station::RecomputeCatchmentForAll();
|
||||
|
||||
|
@@ -91,7 +91,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
||||
{ XSLFI_CHUNNEL, XSCF_NULL, 2, 2, "chunnel", nullptr, nullptr, "TUNN" },
|
||||
{ XSLFI_SCHEDULED_DISPATCH, XSCF_NULL, 1, 1, "scheduled_dispatch", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_MORE_TOWN_GROWTH_RATES, XSCF_NULL, 1, 1, "more_town_growth_rates", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_MULTIPLE_DOCKS, XSCF_NULL, 1, 1, "multiple_docks", nullptr, nullptr, "DOCK" },
|
||||
{ XSLFI_MULTIPLE_DOCKS, XSCF_NULL, 2, 2, "multiple_docks", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_TIMETABLE_EXTRA, XSCF_NULL, 6, 6, "timetable_extra", nullptr, nullptr, "ORDX" },
|
||||
{ XSLFI_TRAIN_FLAGS_EXTRA, XSCF_NULL, 1, 1, "train_flags_extra", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_TRAIN_THROUGH_LOAD, XSCF_NULL, 2, 2, "train_through_load", nullptr, nullptr, nullptr },
|
||||
|
@@ -725,7 +725,7 @@ static const OldChunks station_chunk[] = {
|
||||
OCL_NULL( 4 ), ///< bus/lorry tile
|
||||
OCL_SVAR( OC_TILE, Station, train_station.tile ),
|
||||
OCL_SVAR( OC_TILE, Station, airport.tile ),
|
||||
OCL_SVAR( OC_TILE, Station, dock_station.tile),
|
||||
OCL_NULL( 4 ), ///< dock tile
|
||||
OCL_SVAR( OC_FILE_U8 | OC_VAR_U16, Station, train_station.w ),
|
||||
|
||||
OCL_NULL( 1 ), ///< sort-index, no longer in use
|
||||
|
@@ -25,7 +25,6 @@
|
||||
#include "../stdafx.h"
|
||||
#include "../debug.h"
|
||||
#include "../station_base.h"
|
||||
#include "../dock_base.h"
|
||||
#include "../thread.h"
|
||||
#include "../town.h"
|
||||
#include "../network/network.h"
|
||||
@@ -1192,7 +1191,6 @@ static size_t ReferenceToInt(const void *obj, SLRefType rt)
|
||||
case REF_STORAGE: return ((const PersistentStorage*)obj)->index + 1;
|
||||
case REF_LINK_GRAPH: return ((const LinkGraph*)obj)->index + 1;
|
||||
case REF_LINK_GRAPH_JOB: return ((const LinkGraphJob*)obj)->index + 1;
|
||||
case REF_DOCKS: return ((const Dock*)obj)->index + 1;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
}
|
||||
@@ -1258,10 +1256,6 @@ static void *IntToReference(size_t index, SLRefType rt)
|
||||
if (RoadStop::IsValidID(index)) return RoadStop::Get(index);
|
||||
SlErrorCorrupt("Referencing invalid RoadStop");
|
||||
|
||||
case REF_DOCKS:
|
||||
if (Dock::IsValidID(index)) return Dock::Get(index);
|
||||
SlErrorCorrupt("Referencing invalid Dock");
|
||||
|
||||
case REF_ENGINE_RENEWS:
|
||||
if (EngineRenew::IsValidID(index)) return EngineRenew::Get(index);
|
||||
SlErrorCorrupt("Referencing invalid EngineRenew");
|
||||
|
@@ -304,6 +304,7 @@ enum SaveLoadVersion : uint16 {
|
||||
SLV_ROAD_TYPES, ///< 214 PR#6811 NewGRF road types.
|
||||
|
||||
SLV_SCRIPT_MEMLIMIT, ///< 215 PR#7516 Limit on AI/GS memory consumption.
|
||||
SLV_MULTITILE_DOCKS, ///< 216 PR#7380 Multiple docks per station.
|
||||
|
||||
SL_MAX_VERSION, ///< Highest possible saveload version
|
||||
|
||||
@@ -396,7 +397,6 @@ enum SLRefType {
|
||||
REF_LINK_GRAPH = 10, ///< Load/save a reference to a link graph.
|
||||
REF_LINK_GRAPH_JOB = 11, ///< Load/save a reference to a link graph job.
|
||||
REF_TEMPLATE_VEHICLE = 12, ///< Load/save a reference to a template vehicle
|
||||
REF_DOCKS = 13, ///< Load/save a reference to a dock.
|
||||
};
|
||||
|
||||
/** Flags of a chunk. */
|
||||
|
@@ -13,7 +13,6 @@
|
||||
#include "../station_base.h"
|
||||
#include "../waypoint_base.h"
|
||||
#include "../roadstop_base.h"
|
||||
#include "../dock_base.h"
|
||||
#include "../vehicle_base.h"
|
||||
#include "../newgrf_station.h"
|
||||
|
||||
@@ -127,11 +126,6 @@ void AfterLoadStations()
|
||||
Station *sta = Station::From(st);
|
||||
for (const RoadStop *rs = sta->bus_stops; rs != nullptr; rs = rs->next) sta->bus_station.Add(rs->xy);
|
||||
for (const RoadStop *rs = sta->truck_stops; rs != nullptr; rs = rs->next) sta->truck_station.Add(rs->xy);
|
||||
|
||||
for (const Dock *d = sta->docks; d != nullptr; d = d->next) {
|
||||
sta->dock_station.Add(d->sloped);
|
||||
sta->dock_station.Add(d->flat);
|
||||
}
|
||||
}
|
||||
|
||||
StationUpdateCachedTriggers(st);
|
||||
@@ -175,14 +169,6 @@ static const SaveLoad _roadstop_desc[] = {
|
||||
SLE_END()
|
||||
};
|
||||
|
||||
static const SaveLoad _dock_desc[] = {
|
||||
SLE_VAR(Dock, sloped, SLE_UINT32),
|
||||
SLE_VAR(Dock, flat, SLE_UINT32),
|
||||
SLE_REF(Dock, next, REF_DOCKS),
|
||||
|
||||
SLE_END()
|
||||
};
|
||||
|
||||
static const SaveLoad _old_station_desc[] = {
|
||||
SLE_CONDVAR(Station, xy, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_6),
|
||||
SLE_CONDVAR(Station, xy, SLE_UINT32, SLV_6, SL_MAX_VERSION),
|
||||
@@ -191,8 +177,8 @@ static const SaveLoad _old_station_desc[] = {
|
||||
SLE_CONDVAR(Station, train_station.tile, SLE_UINT32, SLV_6, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Station, airport.tile, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_6),
|
||||
SLE_CONDVAR(Station, airport.tile, SLE_UINT32, SLV_6, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Station, dock_station.tile, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_6),
|
||||
SLE_CONDVAR(Station, dock_station.tile, SLE_UINT32, SLV_6, SL_MAX_VERSION),
|
||||
SLE_CONDNULL(2, SL_MIN_VERSION, SLV_6),
|
||||
SLE_CONDNULL(4, SLV_6, SLV_MULTITILE_DOCKS),
|
||||
SLE_REF(Station, town, REF_TOWN),
|
||||
SLE_VAR(Station, train_station.w, SLE_FILE_U8 | SLE_VAR_U16),
|
||||
SLE_CONDVAR(Station, train_station.h, SLE_FILE_U8 | SLE_VAR_U16, SLV_2, SL_MAX_VERSION),
|
||||
@@ -447,8 +433,15 @@ static const SaveLoad _station_desc[] = {
|
||||
|
||||
SLE_REF(Station, bus_stops, REF_ROADSTOPS),
|
||||
SLE_REF(Station, truck_stops, REF_ROADSTOPS),
|
||||
SLE_CONDVAR_X(Station, dock_station.tile, SLE_UINT32, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_MULTIPLE_DOCKS, 0, 0)),
|
||||
SLE_CONDREF_X(Station, docks, REF_DOCKS, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_MULTIPLE_DOCKS, 1)),
|
||||
SLE_CONDVAR_X(Station, ship_station.tile, SLE_UINT32, SL_MIN_VERSION, SLV_MULTITILE_DOCKS, SlXvFeatureTest(XSLFTO_AND, XSLFI_MULTIPLE_DOCKS, 0, 0)),
|
||||
SLE_CONDNULL_X(4, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_MULTIPLE_DOCKS, 1, 1)),
|
||||
SLE_CONDVAR(Station, ship_station.tile, SLE_UINT32, SLV_MULTITILE_DOCKS, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Station, ship_station.w, SLE_FILE_U8 | SLE_VAR_U16, SLV_MULTITILE_DOCKS, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Station, ship_station.h, SLE_FILE_U8 | SLE_VAR_U16, SLV_MULTITILE_DOCKS, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Station, docking_station.tile, SLE_UINT32, SLV_MULTITILE_DOCKS, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Station, docking_station.w, SLE_FILE_U8 | SLE_VAR_U16, SLV_MULTITILE_DOCKS, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Station, docking_station.h, SLE_FILE_U8 | SLE_VAR_U16, SLV_MULTITILE_DOCKS, SL_MAX_VERSION),
|
||||
SLE_CONDVARVEC_X(Station, docking_tiles, SLE_UINT32, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_MULTIPLE_DOCKS, 2)),
|
||||
SLE_VAR(Station, airport.tile, SLE_UINT32),
|
||||
SLE_CONDVAR(Station, airport.w, SLE_FILE_U8 | SLE_VAR_U16, SLV_140, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Station, airport.h, SLE_FILE_U8 | SLE_VAR_U16, SLV_140, SL_MAX_VERSION),
|
||||
@@ -681,38 +674,15 @@ static void Ptrs_ROADSTOP()
|
||||
}
|
||||
}
|
||||
|
||||
static void Save_DOCK()
|
||||
{
|
||||
Dock *d;
|
||||
|
||||
FOR_ALL_DOCKS(d) {
|
||||
SlSetArrayIndex(d->index);
|
||||
SlObject(d, _dock_desc);
|
||||
}
|
||||
}
|
||||
|
||||
static void Load_DOCK()
|
||||
{
|
||||
int index;
|
||||
|
||||
while ((index = SlIterateArray()) != -1) {
|
||||
Dock *d = new (index) Dock();
|
||||
|
||||
SlObject(d, _dock_desc);
|
||||
}
|
||||
}
|
||||
|
||||
static void Ptrs_DOCK()
|
||||
{
|
||||
Dock *d;
|
||||
FOR_ALL_DOCKS(d) {
|
||||
SlObject(d, _dock_desc);
|
||||
}
|
||||
extern void SlSkipArray();
|
||||
SlSkipArray();
|
||||
}
|
||||
|
||||
extern const ChunkHandler _station_chunk_handlers[] = {
|
||||
{ 'STNS', nullptr, Load_STNS, Ptrs_STNS, nullptr, CH_ARRAY },
|
||||
{ 'STNN', Save_STNN, Load_STNN, Ptrs_STNN, nullptr, CH_ARRAY },
|
||||
{ 'ROAD', Save_ROADSTOP, Load_ROADSTOP, Ptrs_ROADSTOP, nullptr, CH_ARRAY},
|
||||
{ 'DOCK', Save_DOCK, Load_DOCK, Ptrs_DOCK, nullptr, CH_ARRAY | CH_LAST},
|
||||
{ 'DOCK', nullptr, Load_DOCK, nullptr, nullptr, CH_ARRAY | CH_LAST},
|
||||
};
|
||||
|
Reference in New Issue
Block a user