Signals on tunnel/bridges are now added to infrastructure stats.
This commit is contained in:
@@ -1097,6 +1097,8 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
|
Company * const c = Company::Get(GetTileOwner(tile));
|
||||||
|
if (IsTunnelBridgeWithSignalSimulation(tile)) c->infrastructure.signal -= GetTunnelBridgeSignalSimulationSignalCount(tile, tile_exit);
|
||||||
if (p2 == 0 && IsTunnelBridgeWithSignalSimulation(tile)) { // Toggle signal if already signals present.
|
if (p2 == 0 && IsTunnelBridgeWithSignalSimulation(tile)) { // Toggle signal if already signals present.
|
||||||
if (convert_signal) {
|
if (convert_signal) {
|
||||||
if (flip_variant) {
|
if (flip_variant) {
|
||||||
@@ -1149,6 +1151,8 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
|||||||
AddSideToSignalBuffer(tile_exit, INVALID_DIAGDIR, GetTileOwner(tile));
|
AddSideToSignalBuffer(tile_exit, INVALID_DIAGDIR, GetTileOwner(tile));
|
||||||
YapfNotifyTrackLayoutChange(tile, track);
|
YapfNotifyTrackLayoutChange(tile, track);
|
||||||
YapfNotifyTrackLayoutChange(tile_exit, track);
|
YapfNotifyTrackLayoutChange(tile_exit, track);
|
||||||
|
if (IsTunnelBridgeWithSignalSimulation(tile)) c->infrastructure.signal += GetTunnelBridgeSignalSimulationSignalCount(tile, tile_exit);
|
||||||
|
DirtyCompanyInfrastructureWindows(GetTileOwner(tile));
|
||||||
}
|
}
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
@@ -1600,6 +1604,7 @@ CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1
|
|||||||
|
|
||||||
if (IsTunnelBridgeWithSignalSimulation(tile)) { // handle tunnel/bridge signals.
|
if (IsTunnelBridgeWithSignalSimulation(tile)) { // handle tunnel/bridge signals.
|
||||||
TileIndex end = GetOtherTunnelBridgeEnd(tile);
|
TileIndex end = GetOtherTunnelBridgeEnd(tile);
|
||||||
|
Company::Get(GetTileOwner(tile))->infrastructure.signal -= GetTunnelBridgeSignalSimulationSignalCount(tile, end);
|
||||||
ClearBridgeTunnelSignalSimulation(end, tile);
|
ClearBridgeTunnelSignalSimulation(end, tile);
|
||||||
ClearBridgeTunnelSignalSimulation(tile, end);
|
ClearBridgeTunnelSignalSimulation(tile, end);
|
||||||
MarkBridgeOrTunnelDirty(tile);
|
MarkBridgeOrTunnelDirty(tile);
|
||||||
@@ -1607,6 +1612,7 @@ CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1
|
|||||||
AddSideToSignalBuffer(end, INVALID_DIAGDIR, GetTileOwner(tile));
|
AddSideToSignalBuffer(end, INVALID_DIAGDIR, GetTileOwner(tile));
|
||||||
YapfNotifyTrackLayoutChange(tile, track);
|
YapfNotifyTrackLayoutChange(tile, track);
|
||||||
YapfNotifyTrackLayoutChange(end, track);
|
YapfNotifyTrackLayoutChange(end, track);
|
||||||
|
DirtyCompanyInfrastructureWindows(GetTileOwner(tile));
|
||||||
return CommandCost(EXPENSES_CONSTRUCTION, cost);
|
return CommandCost(EXPENSES_CONSTRUCTION, cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -205,7 +205,12 @@ void AfterLoadCompanyStats()
|
|||||||
switch (GetTunnelBridgeTransportType(tile)) {
|
switch (GetTunnelBridgeTransportType(tile)) {
|
||||||
case TRANSPORT_RAIL:
|
case TRANSPORT_RAIL:
|
||||||
c = Company::GetIfValid(GetTileOwner(tile));
|
c = Company::GetIfValid(GetTileOwner(tile));
|
||||||
if (c != NULL) c->infrastructure.rail[GetRailType(tile)] += len;
|
if (c != NULL) {
|
||||||
|
c->infrastructure.rail[GetRailType(tile)] += len;
|
||||||
|
if (IsTunnelBridgeWithSignalSimulation(tile)) {
|
||||||
|
c->infrastructure.signal += GetTunnelBridgeSignalSimulationSignalCount(tile, other_end);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TRANSPORT_ROAD: {
|
case TRANSPORT_ROAD: {
|
||||||
|
@@ -1148,6 +1148,14 @@ static bool InvalidateCompanyWindow(int32 p1)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool SimulatedWormholeSignalsChanged(int32 p1)
|
||||||
|
{
|
||||||
|
extern void AfterLoadCompanyStats();
|
||||||
|
AfterLoadCompanyStats();
|
||||||
|
MarkWholeScreenDirty();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/** Checks if any settings are set to incorrect values, and sets them to correct values in that case. */
|
/** Checks if any settings are set to incorrect values, and sets them to correct values in that case. */
|
||||||
static void ValidateSettings()
|
static void ValidateSettings()
|
||||||
{
|
{
|
||||||
|
@@ -42,6 +42,7 @@ static bool InvalidateCompanyInfrastructureWindow(int32 p1);
|
|||||||
static bool InvalidateCompanyWindow(int32 p1);
|
static bool InvalidateCompanyWindow(int32 p1);
|
||||||
static bool ZoomMinMaxChanged(int32 p1);
|
static bool ZoomMinMaxChanged(int32 p1);
|
||||||
static bool MaxVehiclesChanged(int32 p1);
|
static bool MaxVehiclesChanged(int32 p1);
|
||||||
|
static bool SimulatedWormholeSignalsChanged(int32 p1);
|
||||||
|
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
static bool UpdateClientName(int32 p1);
|
static bool UpdateClientName(int32 p1);
|
||||||
@@ -553,7 +554,7 @@ min = 1
|
|||||||
max = 16
|
max = 16
|
||||||
str = STR_CONFIG_SETTING_SIMULATE_SIGNALS
|
str = STR_CONFIG_SETTING_SIMULATE_SIGNALS
|
||||||
strval = STR_CONFIG_SETTING_SIMULATE_SIGNALS_VALUE
|
strval = STR_CONFIG_SETTING_SIMULATE_SIGNALS_VALUE
|
||||||
proc = RedrawScreen
|
proc = SimulatedWormholeSignalsChanged
|
||||||
from = 0
|
from = 0
|
||||||
cat = SC_BASIC
|
cat = SC_BASIC
|
||||||
patxname = ""signal_tunnel_bridge.construction.simulated_wormhole_signals""
|
patxname = ""signal_tunnel_bridge.construction.simulated_wormhole_signals""
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height);
|
void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height);
|
||||||
void MarkBridgeDirty(TileIndex tile);
|
void MarkBridgeDirty(TileIndex tile);
|
||||||
void MarkBridgeOrTunnelDirty(TileIndex tile);
|
void MarkBridgeOrTunnelDirty(TileIndex tile);
|
||||||
|
uint GetTunnelBridgeSignalSimulationSignalCount(uint length);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the length of a tunnel or a bridge (without end tiles)
|
* Calculates the length of a tunnel or a bridge (without end tiles)
|
||||||
@@ -34,6 +35,17 @@ static inline uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
|
|||||||
return abs(x2 + y2 - x1 - y1) - 1;
|
return abs(x2 + y2 - x1 - y1) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get number of signals on bridge or tunnel with signal simulation.
|
||||||
|
* @param begin The begin of the tunnel or bridge.
|
||||||
|
* @param end The end of the tunnel or bridge.
|
||||||
|
* @pre IsTunnelBridgeWithSignalSimulation(begin)
|
||||||
|
*/
|
||||||
|
static inline uint GetTunnelBridgeSignalSimulationSignalCount(TileIndex begin, TileIndex end)
|
||||||
|
{
|
||||||
|
return GetTunnelBridgeSignalSimulationSignalCount(GetTunnelBridgeLength(begin, end));
|
||||||
|
}
|
||||||
|
|
||||||
extern TileIndex _build_tunnel_endtile;
|
extern TileIndex _build_tunnel_endtile;
|
||||||
|
|
||||||
#endif /* TUNNELBRIDGE_H */
|
#endif /* TUNNELBRIDGE_H */
|
||||||
|
@@ -95,6 +95,16 @@ void MarkBridgeOrTunnelDirty(TileIndex tile)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get number of signals on bridge or tunnel with signal simulation.
|
||||||
|
* @param length Length of bridge/tunnel middle
|
||||||
|
* @return Number of signals on signalled bridge/tunnel of this length
|
||||||
|
*/
|
||||||
|
uint GetTunnelBridgeSignalSimulationSignalCount(uint length)
|
||||||
|
{
|
||||||
|
return 2 + (length / _settings_game.construction.simulated_wormhole_signals);
|
||||||
|
}
|
||||||
|
|
||||||
/** Reset the data been eventually changed by the grf loaded. */
|
/** Reset the data been eventually changed by the grf loaded. */
|
||||||
void ResetBridges()
|
void ResetBridges()
|
||||||
{
|
{
|
||||||
@@ -854,6 +864,9 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
|
|||||||
|
|
||||||
if (Company::IsValidID(owner)) {
|
if (Company::IsValidID(owner)) {
|
||||||
Company::Get(owner)->infrastructure.rail[GetRailType(tile)] -= len * TUNNELBRIDGE_TRACKBIT_FACTOR;
|
Company::Get(owner)->infrastructure.rail[GetRailType(tile)] -= len * TUNNELBRIDGE_TRACKBIT_FACTOR;
|
||||||
|
if (IsTunnelBridgeWithSignalSimulation(tile)) { // handle tunnel/bridge signals.
|
||||||
|
Company::Get(GetTileOwner(tile))->infrastructure.signal -= GetTunnelBridgeSignalSimulationSignalCount(tile, endtile);
|
||||||
|
}
|
||||||
DirtyCompanyInfrastructureWindows(owner);
|
DirtyCompanyInfrastructureWindows(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -939,7 +952,12 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
|
|||||||
|
|
||||||
/* Update company infrastructure counts. */
|
/* Update company infrastructure counts. */
|
||||||
if (rail) {
|
if (rail) {
|
||||||
if (Company::IsValidID(owner)) Company::Get(owner)->infrastructure.rail[GetRailType(tile)] -= len * TUNNELBRIDGE_TRACKBIT_FACTOR;
|
if (Company::IsValidID(owner)) {
|
||||||
|
Company::Get(owner)->infrastructure.rail[GetRailType(tile)] -= len * TUNNELBRIDGE_TRACKBIT_FACTOR;
|
||||||
|
if (IsTunnelBridgeWithSignalSimulation(tile)) { // handle tunnel/bridge signals.
|
||||||
|
Company::Get(GetTileOwner(tile))->infrastructure.signal -= GetTunnelBridgeSignalSimulationSignalCount(tile, endtile);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD) {
|
} else if (GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD) {
|
||||||
RoadType rt;
|
RoadType rt;
|
||||||
FOR_EACH_SET_ROADTYPE(rt, GetRoadTypes(tile)) {
|
FOR_EACH_SET_ROADTYPE(rt, GetRoadTypes(tile)) {
|
||||||
@@ -1860,6 +1878,12 @@ static void ChangeTileOwner_TunnelBridge(TileIndex tile, Owner old_owner, Owner
|
|||||||
if (new_owner != INVALID_OWNER) Company::Get(new_owner)->infrastructure.water += num_pieces;
|
if (new_owner != INVALID_OWNER) Company::Get(new_owner)->infrastructure.water += num_pieces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsTunnelBridgeWithSignalSimulation(tile) && IsTunnelBridgeSignalSimulationEntrance(tile)) {
|
||||||
|
uint num_sigs = GetTunnelBridgeSignalSimulationSignalCount(tile, other_end);
|
||||||
|
Company::Get(old_owner)->infrastructure.signal -= num_sigs;
|
||||||
|
Company::Get(new_owner)->infrastructure.signal += num_sigs;
|
||||||
|
}
|
||||||
|
|
||||||
if (new_owner != INVALID_OWNER) {
|
if (new_owner != INVALID_OWNER) {
|
||||||
SetTileOwner(tile, new_owner);
|
SetTileOwner(tile, new_owner);
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user