Fix new station joining

This commit is contained in:
dP
2023-02-04 02:59:06 +04:00
parent 7e8052d955
commit c5ed17dc91
3 changed files with 13 additions and 16 deletions

View File

@@ -149,15 +149,9 @@ void OnStationTileSetChange(const Station *station, bool adding, StationType typ
if (station == _viewport_highlight_station) MarkCoverageAreaDirty(_viewport_highlight_station);
}
// CommandContainer _last_station_bulid_cmd;
void OnStationPartBuilt(const Station *station, TileIndex tile, uint32 p1, uint32 p2) {
if (_current_company != _local_company) return;
// FIXME
// if (tile != _last_station_bulid_cmd.tile ||
// p1 != _last_station_bulid_cmd.p1 ||
// p2 != _last_station_bulid_cmd.p2) return;
_station_to_join = station;
const Station *_last_built_station;
void OnStationPartBuilt(const Station *station) {
_last_built_station = station;
CheckRedrawStationCoverage();
}
@@ -214,8 +208,11 @@ void JoinAndBuild(Tcommand command, Tcallback *callback) {
if (citymania::_fn_mod) command.station_to_join = NEW_STATION;
else if (join_to) command.station_to_join = join_to->index;
//FIXME _last_station_bulid_cmd = cmdcont;
command.post(callback);
command.with_callback([] (bool res)->bool {
if (!res) return false;
_station_to_join = _last_built_station;
return true;
}).post(callback);
}
static DiagDirection TileFractCoordsToDiagDir(Point pt) {

View File

@@ -26,7 +26,7 @@ enum class StationBuildingStatus {
// void SetStationTileSelectSize(int w, int h, int catchment);
bool UseImprovedStationJoin();
void OnStationTileSetChange(const Station *station, bool adding, StationType type);
void OnStationPartBuilt(const Station *station, TileIndex tile, uint32 p1, uint32 p2);
void OnStationPartBuilt(const Station *station);
void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, RoadStopType stop_type, bool adjacent, RoadType rt, StringID err_msg);
void HandleStationPlacement(TileIndex start, TileIndex end);
void PlaceRail_Station(TileIndex tile);

View File

@@ -1464,7 +1464,7 @@ CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailTyp
st->MarkTilesDirty(false);
st->AfterStationTileSetChange(true, STATION_RAIL);
// FIXME citymania::OnStationPartBuilt(st, tile_org, p1, p2);
citymania::OnStationPartBuilt(st);
}
return cost;
@@ -1929,7 +1929,7 @@ CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, u
}
if (st != nullptr) {
// FIXME citymania::OnStationPartBuilt(st, tile, p1, p2);
citymania::OnStationPartBuilt(st);
st->AfterStationTileSetChange(true, is_truck_stop ? STATION_TRUCK: STATION_BUS);
}
}
@@ -2325,7 +2325,7 @@ CommandCost CmdBuildAirport(DoCommandFlag flags, TileIndex tile, byte airport_ty
Company::Get(st->owner)->infrastructure.airport++;
st->AfterStationTileSetChange(true, STATION_AIRPORT);
// FIXME citymania::OnStationPartBuilt(st, tile, p1, p2);
citymania::OnStationPartBuilt(st);
InvalidateWindowData(WC_STATION_VIEW, st->index, -1);
if (_settings_game.economy.station_noise_level) {
@@ -2557,7 +2557,7 @@ CommandCost CmdBuildDock(DoCommandFlag flags, TileIndex tile, StationID station_
UpdateStationDockingTiles(st);
st->AfterStationTileSetChange(true, STATION_DOCK);
// FIXME citymania::OnStationPartBuilt(st, tile, p1, p2);
citymania::OnStationPartBuilt(st);
}
return cost;