Initial implementation of two rail types per tile

This commit is contained in:
Jonathan G Rennison
2018-12-21 03:27:58 +00:00
parent 8128d027c0
commit 65b9a103ad
24 changed files with 768 additions and 225 deletions

View File

@@ -1410,6 +1410,15 @@ bool AfterLoadGame()
}
}
if (SlXvIsFeatureMissing(XSLFI_DUAL_RAIL_TYPES)) {
/* Introduced dual rail types. */
for (TileIndex t = 0; t < map_size; t++) {
if (IsPlainRailTile(t) || (IsRailTunnelBridgeTile(t) && IsBridge(t))) {
SetSecondaryRailType(t, GetRailType(t));
}
}
}
if (SlXvIsFeaturePresent(XSLFI_SIG_TUNNEL_BRIDGE, 1, 6)) {
/* m2 signal state bit allocation has shrunk */
for (TileIndex t = 0; t < map_size; t++) {
@@ -3308,7 +3317,7 @@ bool AfterLoadGame()
t->grow_counter = TownTicksToGameTicks(t->grow_counter) + t->index % TOWN_GROWTH_TICKS;
}
}
if (IsSavegameVersionBefore(202)) {
/* Make sure added industry cargo slots are cleared */
Industry *i;

View File

@@ -116,8 +116,12 @@ void AfterLoadCompanyStats()
uint pieces = 1;
if (IsPlainRail(tile)) {
TrackBits bits = GetTrackBits(tile);
pieces = CountBits(bits);
if (TracksOverlap(bits)) pieces *= pieces;
if (bits == TRACK_BIT_HORZ || bits == TRACK_BIT_VERT) {
c->infrastructure.rail[GetSecondaryRailType(tile)]++;
} else {
pieces = CountBits(bits);
if (TracksOverlap(bits)) pieces *= pieces;
}
}
c->infrastructure.rail[GetRailType(tile)] += pieces;
@@ -205,13 +209,7 @@ void AfterLoadCompanyStats()
switch (GetTunnelBridgeTransportType(tile)) {
case TRANSPORT_RAIL:
c = Company::GetIfValid(GetTileOwner(tile));
if (c != NULL) {
c->infrastructure.rail[GetRailType(tile)] += middle_len + GetTunnelBridgeHeadOnlyRailInfrastructureCount(tile) + GetTunnelBridgeHeadOnlyRailInfrastructureCount(other_end);
if (IsTunnelBridgeWithSignalSimulation(tile)) {
c->infrastructure.signal += GetTunnelBridgeSignalSimulationSignalCount(tile, other_end);
}
}
AddRailTunnelBridgeInfrastructure(tile, other_end);
break;
case TRANSPORT_ROAD: {

View File

@@ -90,6 +90,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
{ XSLFI_ST_LAST_VEH_TYPE, XSCF_NULL, 1, 1, "station_last_veh_type", NULL, NULL, NULL },
{ XSLFI_SELL_AT_DEPOT_ORDER, XSCF_NULL, 1, 1, "sell_at_depot_order", NULL, NULL, NULL },
{ XSLFI_BUY_LAND_RATE_LIMIT, XSCF_NULL, 1, 1, "buy_land_rate_limit", NULL, NULL, NULL },
{ XSLFI_DUAL_RAIL_TYPES, XSCF_NULL, 1, 1, "dual_rail_types", NULL, NULL, NULL },
{ XSLFI_NULL, XSCF_NULL, 0, 0, NULL, NULL, NULL, NULL },// This is the end marker
};

View File

@@ -64,6 +64,7 @@ enum SlXvFeatureIndex {
XSLFI_ST_LAST_VEH_TYPE, ///< Per-cargo station last vehicle type
XSLFI_SELL_AT_DEPOT_ORDER, ///< Sell vehicle on arrival at depot orders
XSLFI_BUY_LAND_RATE_LIMIT, ///< Buy land rate limit
XSLFI_DUAL_RAIL_TYPES, ///< Two rail-types per tile
XSLFI_RIFF_HEADER_60_BIT, ///< Size field in RIFF chunk header is 60 bit
XSLFI_HEIGHT_8_BIT, ///< Map tile height is 8 bit instead of 4 bit, but savegame version may be before this became true in trunk