Changeset - r3322:fcb97823ac14
[Not reviewed]
master
0 3 0
celestar - 19 years ago 2006-03-24 15:24:16
celestar@openttd.org
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
3 files changed with 22 insertions and 9 deletions:
0 comments (0 inline, 0 general)
road_cmd.c
Show inline comments
 
@@ -776,7 +776,7 @@ static void DrawTile_Road(TileInfo *ti)
 

	
 
			if (GetCrossingRoadAxis(ti->tile) == AXIS_X) image++;
 

	
 
			if ((ti->map5 & 4) != 0) image += 2;
 
			if (IsCrossingBarred(ti->tile)) image += 2;
 

	
 
			if ( _m[ti->tile].m4 & 0x80) {
 
				image += 8;
 
@@ -1059,10 +1059,10 @@ static uint32 VehicleEnter_Road(Vehicle 
 
{
 
	switch (GetRoadType(tile)) {
 
		case ROAD_CROSSING:
 
			if (v->type == VEH_Train && GB(_m[tile].m5, 2, 1) == 0) {
 
			if (v->type == VEH_Train && !IsCrossingBarred(tile)) {
 
				/* train crossing a road */
 
				SndPlayVehicleFx(SND_0E_LEVEL_CROSSING, v);
 
				SB(_m[tile].m5, 2, 1, 1);
 
				BarCrossing(tile);
 
				MarkTileDirtyByTile(tile);
 
			}
 
			break;
 
@@ -1084,8 +1084,7 @@ static uint32 VehicleEnter_Road(Vehicle 
 
static void VehicleLeave_Road(Vehicle *v, TileIndex tile, int x, int y)
 
{
 
	if (IsLevelCrossing(tile) && v->type == VEH_Train && v->next == NULL) {
 
		// Turn off level crossing lights
 
		SB(_m[tile].m5, 2, 1, 0);
 
		UnbarCrossing(tile);
 
		MarkTileDirtyByTile(tile);
 
	}
 
}
road_map.h
Show inline comments
 
@@ -66,6 +66,20 @@ static inline void SetCrossingRoadOwner(
 
	_m[t].m3 = o;
 
}
 

	
 
static inline void UnbarCrossing(TileIndex t)
 
{
 
	CLRBIT(_m[t].m5, 2);
 
}
 

	
 
static inline void BarCrossing(TileIndex t)
 
{
 
	SETBIT(_m[t].m5, 2);
 
}
 

	
 
static inline bool IsCrossingBarred(TileIndex t)
 
{
 
	return HASBIT(_m[t].m5, 2);
 
}
 

	
 
typedef enum RoadType {
 
	ROAD_NORMAL,
train_cmd.c
Show inline comments
 
@@ -1482,8 +1482,8 @@ static void DisableTrainCrossing(TileInd
 
	if (IsTileType(tile, MP_STREET) &&
 
			IsLevelCrossing(tile) &&
 
			VehicleFromPos(tile, &tile, TestTrainOnCrossing) == NULL && // empty?
 
			GB(_m[tile].m5, 2, 1) != 0) { // Lights on?
 
		SB(_m[tile].m5, 2, 1, 0); // Switch lights off
 
			IsCrossingBarred(tile)) {
 
		UnbarCrossing(tile);
 
		MarkTileDirtyByTile(tile);
 
	}
 
}
 
@@ -3206,8 +3206,8 @@ static bool TrainCheckIfLineEnds(Vehicle
 
		if ((ts &= (ts >> 16)) == 0) {
 
			// make a rail/road crossing red
 
			if (IsTileType(tile, MP_STREET) && IsLevelCrossing(tile)) {
 
				if (GB(_m[tile].m5, 2, 1) == 0) {
 
					SB(_m[tile].m5, 2, 1, 1);
 
				if (!IsCrossingBarred(tile)) {
 
					BarCrossing(tile);
 
					SndPlayVehicleFx(SND_0E_LEVEL_CROSSING, v);
 
					MarkTileDirtyByTile(tile);
 
				}
0 comments (0 inline, 0 general)