Changeset - r2824:e9055417341e
[Not reviewed]
master
0 1 0
peter1138 - 19 years ago 2006-01-06 17:45:43
peter1138@openttd.org
(svn r3372) - Fix: update signal states when building or removing rail station blocks
1 file changed with 9 insertions and 1 deletions:
0 comments (0 inline, 0 general)
station_cmd.c
Show inline comments
 
@@ -1013,12 +1013,13 @@ int32 CmdBuildRailroadStation(int x, int
 

	
 
	if (flags & DC_EXEC) {
 
		TileIndexDiff tile_delta;
 
		byte *layout_ptr;
 
		StationID station_index = st->index;
 
		const StationSpec *statspec;
 
		Track track;
 

	
 
		// Now really clear the land below the station
 
		// It should never return CMD_ERROR.. but you never know ;)
 
		//  (a bit strange function name for it, but it really does clear the land, when DC_EXEC is in flags)
 
		if (CmdFailed(CheckFlatLandBelow(tile_org, w_org, h_org, flags, 5 << direction, _patches.nonuniform_stations ? &est : NULL))) return CMD_ERROR;
 

	
 
@@ -1030,12 +1031,13 @@ int32 CmdBuildRailroadStation(int x, int
 
		st->trainst_w = finalvalues[1];
 
		st->trainst_h = finalvalues[2];
 

	
 
		st->build_date = _date;
 

	
 
		tile_delta = direction ? TileDiffXY(0, 1) : TileDiffXY(1, 0);
 
		track = direction ? TRACK_DIAG2 : TRACK_DIAG1;
 

	
 
		statspec = (p2 & 0x10) != 0 ? GetCustomStation(STAT_CLASS_DFLT, p2 >> 8) : NULL;
 
		layout_ptr = alloca(numtracks * plat_len);
 
		GetStationLayout(layout_ptr, numtracks, plat_len, statspec);
 

	
 
		do {
 
@@ -1051,12 +1053,13 @@ int32 CmdBuildRailroadStation(int x, int
 
					p2 >> 8,       /* map3hi parameter */
 
					(*layout_ptr++) + direction   /* map5 parameter */
 
				);
 

	
 
				tile += tile_delta;
 
			} while (--w);
 
			SetSignalsOnBothDir(tile_org, track);
 
			tile_org += tile_delta ^ TileDiffXY(1, 1); // perpendicular to tile_delta
 
		} while (--numtracks);
 

	
 
		UpdateStationVirtCoordDirty(st);
 
		UpdateStationAcceptance(st, false);
 
		InvalidateWindow(WC_STATION_LIST, st->owner);
 
@@ -1144,13 +1147,15 @@ int32 CmdRemoveFromRailroadStation(int x
 
	if (!IsTileType(tile, MP_STATION) || _m[tile].m5 >= 8 || !_patches.nonuniform_stations) return CMD_ERROR;
 
	st = GetStation(_m[tile].m2);
 
	if (_current_player != OWNER_WATER && (!CheckOwnership(st->owner) || !EnsureNoVehicle(tile))) return CMD_ERROR;
 

	
 
	// if we reached here, it means we can actually delete it. do that.
 
	if (flags & DC_EXEC) {
 
		Track track = HASBIT(_m[tile].m5, 0) ? TRACK_DIAG2 : TRACK_DIAG1;
 
		DoClearSquare(tile);
 
		SetSignalsOnBothDir(tile, track);
 
		// now we need to make the "spanned" area of the railway station smaller if we deleted something at the edges.
 
		// we also need to adjust train_tile.
 
		MakeRailwayStationAreaSmaller(st);
 

	
 
		// if we deleted the whole station, delete the train facility.
 
		if (st->train_tile == 0) {
 
@@ -1304,14 +1309,17 @@ static int32 RemoveRailroadStation(Stati
 
		int w_bak = w;
 
		do {
 
			// for nonuniform stations, only remove tiles that are actually train station tiles
 
			if (TileBelongsToRailStation(st, tile)) {
 
				if (!EnsureNoVehicle(tile))
 
					return CMD_ERROR;
 
				if (flags & DC_EXEC)
 
				if (flags & DC_EXEC) {
 
					Track track = HASBIT(_m[tile].m5, 0) ? TRACK_DIAG2 : TRACK_DIAG1;
 
					DoClearSquare(tile);
 
					SetSignalsOnBothDir(tile, track);
 
				}
 
			}
 
			tile += TileDiffXY(1, 0);
 
		} while (--w);
 
		w = w_bak;
 
		tile += TileDiffXY(-w, 1);
 
	} while (--h);
0 comments (0 inline, 0 general)