From 2b97f38cd176d5638053c87199e6ac175d5ee1e4 Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 11 Jan 2010 18:46:09 +0000 Subject: (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not. -Fix: AIs did update their last cost incorrectly in network games if the cost of the DC_EXEC phase differed from the ~DC_EXEC phase. --- src/rail_gui.cpp | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'src/rail_gui.cpp') diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 4eadad6c0..3c9127a9f 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -66,9 +66,9 @@ static void ShowBuildWaypointPicker(Window *parent); static void ShowStationBuilder(Window *parent); static void ShowSignalBuilder(Window *parent); -void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2) +void CcPlaySound1E(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) { - if (success) SndPlayTileFx(SND_20_SPLAT_2, tile); + if (result.Succeeded()) SndPlayTileFx(SND_20_SPLAT_2, tile); } static void GenericPlaceRail(TileIndex tile, int cmd) @@ -128,21 +128,21 @@ static const uint16 _place_depot_extra[12] = { }; -void CcRailDepot(bool success, TileIndex tile, uint32 p1, uint32 p2) +void CcRailDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) { - if (success) { - DiagDirection dir = (DiagDirection)p2; + if (result.Failed()) return; - SndPlayTileFx(SND_20_SPLAT_2, tile); - if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); + DiagDirection dir = (DiagDirection)p2; - tile += TileOffsByDiagDir(dir); + SndPlayTileFx(SND_20_SPLAT_2, tile); + if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); - if (IsTileType(tile, MP_RAILWAY)) { - PlaceExtraDepotRail(tile, _place_depot_extra[dir]); - PlaceExtraDepotRail(tile, _place_depot_extra[dir + 4]); - PlaceExtraDepotRail(tile, _place_depot_extra[dir + 8]); - } + tile += TileOffsByDiagDir(dir); + + if (IsTileType(tile, MP_RAILWAY)) { + PlaceExtraDepotRail(tile, _place_depot_extra[dir]); + PlaceExtraDepotRail(tile, _place_depot_extra[dir + 4]); + PlaceExtraDepotRail(tile, _place_depot_extra[dir + 8]); } } @@ -171,13 +171,13 @@ static void PlaceRail_Waypoint(TileIndex tile) } } -void CcStation(bool success, TileIndex tile, uint32 p1, uint32 p2) +void CcStation(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) { - if (success) { - SndPlayTileFx(SND_20_SPLAT_2, tile); - /* Only close the station builder window if the default station and non persistent building is chosen. */ - if (_railstation.station_class == STAT_CLASS_DFLT && _railstation.station_type == 0 && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); - } + if (result.Failed()) return; + + SndPlayTileFx(SND_20_SPLAT_2, tile); + /* Only close the station builder window if the default station and non persistent building is chosen. */ + if (_railstation.station_class == STAT_CLASS_DFLT && _railstation.station_type == 0 && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } static void PlaceRail_Station(TileIndex tile) @@ -258,9 +258,9 @@ static void PlaceRail_Bridge(TileIndex tile) } /** Command callback for building a tunnel */ -void CcBuildRailTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2) +void CcBuildRailTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) { - if (success) { + if (result.Succeeded()) { SndPlayTileFx(SND_20_SPLAT_2, tile); if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } else { -- cgit v1.2.3-54-g00ecf