Changeset - r11640:aa6c71abbdce
[Not reviewed]
master
0 3 0
rubidium - 15 years ago 2009-04-10 22:47:19
rubidium@openttd.org
(svn r16025) -Fix [FS#2818]: "build separate station" in the station picker would reuse deleted stations.
3 files changed with 14 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/station_cmd.cpp
Show inline comments
 
@@ -922,6 +922,8 @@ CommandCost CmdBuildRailroadStation(Tile
 
	}
 

	
 
	StationID station_to_join = GB(p2, 16, 16);
 
	bool reuse = (station_to_join != NEW_STATION);
 
	if (!reuse) station_to_join = INVALID_STATION;
 
	bool distant_join = (station_to_join != INVALID_STATION);
 

	
 
	if (distant_join && (!_settings_game.station.distant_join_stations || !IsValidStationID(station_to_join))) return CMD_ERROR;
 
@@ -975,7 +977,7 @@ CommandCost CmdBuildRailroadStation(Tile
 
	if (st == NULL && distant_join) st = GetStation(station_to_join);
 

	
 
	/* See if there is a deleted station close to us. */
 
	if (st == NULL) st = GetClosestDeletedStation(tile_org);
 
	if (st == NULL && reuse) st = GetClosestDeletedStation(tile_org);
 

	
 
	if (st != NULL) {
 
		/* Reuse an existing station. */
 
@@ -1403,6 +1405,8 @@ CommandCost CmdBuildRoadStop(TileIndex t
 
	bool build_over_road  = is_drive_through && IsNormalRoadTile(tile);
 
	RoadTypes rts = (RoadTypes)GB(p2, 2, 2);
 
	StationID station_to_join = GB(p2, 16, 16);
 
	bool reuse = (station_to_join != NEW_STATION);
 
	if (!reuse) station_to_join = INVALID_STATION;
 
	bool distant_join = (station_to_join != INVALID_STATION);
 
	Owner tram_owner = _current_company;
 
	Owner road_owner = _current_company;
 
@@ -1470,7 +1474,7 @@ CommandCost CmdBuildRoadStop(TileIndex t
 
	if (st == NULL && distant_join) st = GetStation(station_to_join);
 

	
 
	/* Find a deleted station close to us */
 
	if (st == NULL) st = GetClosestDeletedStation(tile);
 
	if (st == NULL && reuse) st = GetClosestDeletedStation(tile);
 

	
 
	/* give us a road stop in the list, and check if something went wrong */
 
	if (!RoadStop::CanAllocateItem()) return_cmd_error(type ? STR_TOO_MANY_TRUCK_STOPS : STR_TOO_MANY_BUS_STOPS);
 
@@ -1855,6 +1859,8 @@ CommandCost CmdBuildAirport(TileIndex ti
 
{
 
	bool airport_upgrade = true;
 
	StationID station_to_join = GB(p2, 16, 16);
 
	bool reuse = (station_to_join != NEW_STATION);
 
	if (!reuse) station_to_join = INVALID_STATION;
 
	bool distant_join = (station_to_join != INVALID_STATION);
 

	
 
	if (distant_join && (!_settings_game.station.distant_join_stations || !IsValidStationID(station_to_join))) return CMD_ERROR;
 
@@ -1919,7 +1925,7 @@ CommandCost CmdBuildAirport(TileIndex ti
 
	if (st == NULL && distant_join) st = GetStation(station_to_join);
 

	
 
	/* Find a deleted station close to us */
 
	if (st == NULL) st = GetClosestDeletedStation(tile);
 
	if (st == NULL && reuse) st = GetClosestDeletedStation(tile);
 

	
 
	if (st != NULL) {
 
		if (st->owner != _current_company) {
 
@@ -2175,6 +2181,8 @@ static const byte _dock_h_chk[4] = { 1, 
 
CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	StationID station_to_join = GB(p2, 16, 16);
 
	bool reuse = (station_to_join != NEW_STATION);
 
	if (!reuse) station_to_join = INVALID_STATION;
 
	bool distant_join = (station_to_join != INVALID_STATION);
 

	
 
	if (distant_join && (!_settings_game.station.distant_join_stations || !IsValidStationID(station_to_join))) return CMD_ERROR;
 
@@ -2224,7 +2232,7 @@ CommandCost CmdBuildDock(TileIndex tile,
 
	if (st == NULL && distant_join) st = GetStation(station_to_join);
 

	
 
	/* Find a deleted station close to us */
 
	if (st == NULL) st = GetClosestDeletedStation(tile);
 
	if (st == NULL && reuse) st = GetClosestDeletedStation(tile);
 

	
 
	if (st != NULL) {
 
		if (st->owner != _current_company) {
src/station_gui.cpp
Show inline comments
 
@@ -1170,7 +1170,7 @@ struct SelectStationWindow : Window {
 

	
 
		/* Insert station to be joined into stored command */
 
		SB(this->select_station_cmd.p2, 16, 16,
 
		   (distant_join ? _stations_nearby_list[st_index] : INVALID_STATION));
 
		   (distant_join ? _stations_nearby_list[st_index] : NEW_STATION));
 

	
 
		/* Execute stored Command */
 
		DoCommandP(&this->select_station_cmd);
src/station_type.h
Show inline comments
 
@@ -12,6 +12,7 @@ struct Station;
 
struct RoadStop;
 
struct StationSpec;
 

	
 
static const StationID NEW_STATION = 0xFFFE;
 
static const StationID INVALID_STATION = 0xFFFF;
 

	
 
/** Station types */
0 comments (0 inline, 0 general)