(svn r4572) Remove vehicle_leave_tile_proc
There's exactly one implemented function (unbarring a level crossing) and one place where it can be triggered (a train leaves a level crossing) It's a bit overkill, so just handle this one case where it can happen
This commit is contained in:
		@@ -745,6 +745,5 @@ const TileTypeProcs _tile_type_clear_procs = {
 | 
				
			|||||||
	ChangeTileOwner_Clear,		/* change_tile_owner_clear */
 | 
						ChangeTileOwner_Clear,		/* change_tile_owner_clear */
 | 
				
			||||||
	NULL,											/* get_produced_cargo_proc */
 | 
						NULL,											/* get_produced_cargo_proc */
 | 
				
			||||||
	NULL,											/* vehicle_enter_tile_proc */
 | 
						NULL,											/* vehicle_enter_tile_proc */
 | 
				
			||||||
	NULL,											/* vehicle_leave_tile_proc */
 | 
					 | 
				
			||||||
	GetSlopeTileh_Clear,			/* get_slope_tileh_proc */
 | 
						GetSlopeTileh_Clear,			/* get_slope_tileh_proc */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,6 +79,5 @@ const TileTypeProcs _tile_type_dummy_procs = {
 | 
				
			|||||||
	ChangeTileOwner_Dummy,		/* change_tile_owner_clear */
 | 
						ChangeTileOwner_Dummy,		/* change_tile_owner_clear */
 | 
				
			||||||
	NULL,											/* get_produced_cargo_proc */
 | 
						NULL,											/* get_produced_cargo_proc */
 | 
				
			||||||
	NULL,											/* vehicle_enter_tile_proc */
 | 
						NULL,											/* vehicle_enter_tile_proc */
 | 
				
			||||||
	NULL,											/* vehicle_leave_tile_proc */
 | 
					 | 
				
			||||||
	GetSlopeTileh_Dummy,			/* get_slope_tileh_proc */
 | 
						GetSlopeTileh_Dummy,			/* get_slope_tileh_proc */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1891,7 +1891,6 @@ const TileTypeProcs _tile_type_industry_procs = {
 | 
				
			|||||||
	ChangeTileOwner_Industry,		/* change_tile_owner_proc */
 | 
						ChangeTileOwner_Industry,		/* change_tile_owner_proc */
 | 
				
			||||||
	GetProducedCargo_Industry,  /* get_produced_cargo_proc */
 | 
						GetProducedCargo_Industry,  /* get_produced_cargo_proc */
 | 
				
			||||||
	NULL,												/* vehicle_enter_tile_proc */
 | 
						NULL,												/* vehicle_enter_tile_proc */
 | 
				
			||||||
	NULL,												/* vehicle_leave_tile_proc */
 | 
					 | 
				
			||||||
	GetSlopeTileh_Industry,			/* get_slope_tileh_proc */
 | 
						GetSlopeTileh_Industry,			/* get_slope_tileh_proc */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -331,7 +331,6 @@ typedef void ChangeTileOwnerProc(TileIndex tile, PlayerID old_player, PlayerID n
 | 
				
			|||||||
 * bit 0x8 set, the vehicle could not and did not enter the tile. Are there
 | 
					 * bit 0x8 set, the vehicle could not and did not enter the tile. Are there
 | 
				
			||||||
 * other bits that can be set? */
 | 
					 * other bits that can be set? */
 | 
				
			||||||
typedef uint32 VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y);
 | 
					typedef uint32 VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y);
 | 
				
			||||||
typedef void VehicleLeaveTileProc(Vehicle *v, TileIndex tile, int x, int y);
 | 
					 | 
				
			||||||
typedef Slope GetSlopeTilehProc(TileIndex, Slope tileh);
 | 
					typedef Slope GetSlopeTilehProc(TileIndex, Slope tileh);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
@@ -347,7 +346,6 @@ typedef struct {
 | 
				
			|||||||
	ChangeTileOwnerProc *change_tile_owner_proc;
 | 
						ChangeTileOwnerProc *change_tile_owner_proc;
 | 
				
			||||||
	GetProducedCargoProc *get_produced_cargo_proc;
 | 
						GetProducedCargoProc *get_produced_cargo_proc;
 | 
				
			||||||
	VehicleEnterTileProc *vehicle_enter_tile_proc;
 | 
						VehicleEnterTileProc *vehicle_enter_tile_proc;
 | 
				
			||||||
	VehicleLeaveTileProc *vehicle_leave_tile_proc;
 | 
					 | 
				
			||||||
	GetSlopeTilehProc *get_slope_tileh_proc;
 | 
						GetSlopeTilehProc *get_slope_tileh_proc;
 | 
				
			||||||
} TileTypeProcs;
 | 
					} TileTypeProcs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2028,6 +2028,5 @@ const TileTypeProcs _tile_type_rail_procs = {
 | 
				
			|||||||
	ChangeTileOwner_Track,		/* change_tile_owner_clear */
 | 
						ChangeTileOwner_Track,		/* change_tile_owner_clear */
 | 
				
			||||||
	NULL,											/* get_produced_cargo_proc */
 | 
						NULL,											/* get_produced_cargo_proc */
 | 
				
			||||||
	VehicleEnter_Track,				/* vehicle_enter_tile_proc */
 | 
						VehicleEnter_Track,				/* vehicle_enter_tile_proc */
 | 
				
			||||||
	NULL,											/* vehicle_leave_tile_proc */
 | 
					 | 
				
			||||||
	GetSlopeTileh_Track,			/* get_slope_tileh_proc */
 | 
						GetSlopeTileh_Track,			/* get_slope_tileh_proc */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1049,13 +1049,6 @@ static uint32 VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y)
 | 
				
			|||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void VehicleLeave_Road(Vehicle *v, TileIndex tile, int x, int y)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (IsLevelCrossing(tile) && v->type == VEH_Train && v->next == NULL) {
 | 
					 | 
				
			||||||
		UnbarCrossing(tile);
 | 
					 | 
				
			||||||
		MarkTileDirtyByTile(tile);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID new_player)
 | 
					static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID new_player)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -1103,6 +1096,5 @@ const TileTypeProcs _tile_type_road_procs = {
 | 
				
			|||||||
	ChangeTileOwner_Road,			/* change_tile_owner_clear */
 | 
						ChangeTileOwner_Road,			/* change_tile_owner_clear */
 | 
				
			||||||
	NULL,											/* get_produced_cargo_proc */
 | 
						NULL,											/* get_produced_cargo_proc */
 | 
				
			||||||
	VehicleEnter_Road,				/* vehicle_enter_tile_proc */
 | 
						VehicleEnter_Road,				/* vehicle_enter_tile_proc */
 | 
				
			||||||
	VehicleLeave_Road,				/* vehicle_leave_tile_proc */
 | 
					 | 
				
			||||||
	GetSlopeTileh_Road,				/* get_slope_tileh_proc */
 | 
						GetSlopeTileh_Road,				/* get_slope_tileh_proc */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2782,7 +2782,6 @@ const TileTypeProcs _tile_type_station_procs = {
 | 
				
			|||||||
	ChangeTileOwner_Station,    /* change_tile_owner_clear */
 | 
						ChangeTileOwner_Station,    /* change_tile_owner_clear */
 | 
				
			||||||
	NULL,                       /* get_produced_cargo_proc */
 | 
						NULL,                       /* get_produced_cargo_proc */
 | 
				
			||||||
	VehicleEnter_Station,       /* vehicle_enter_tile_proc */
 | 
						VehicleEnter_Station,       /* vehicle_enter_tile_proc */
 | 
				
			||||||
	NULL,                       /* vehicle_leave_tile_proc */
 | 
					 | 
				
			||||||
	GetSlopeTileh_Station,      /* get_slope_tileh_proc */
 | 
						GetSlopeTileh_Station,      /* get_slope_tileh_proc */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1866,7 +1866,6 @@ const TileTypeProcs _tile_type_town_procs = {
 | 
				
			|||||||
	ChangeTileOwner_Town,			/* change_tile_owner_clear */
 | 
						ChangeTileOwner_Town,			/* change_tile_owner_clear */
 | 
				
			||||||
	NULL,											/* get_produced_cargo_proc */
 | 
						NULL,											/* get_produced_cargo_proc */
 | 
				
			||||||
	NULL,											/* vehicle_enter_tile_proc */
 | 
						NULL,											/* vehicle_enter_tile_proc */
 | 
				
			||||||
	NULL,											/* vehicle_leave_tile_proc */
 | 
					 | 
				
			||||||
	GetSlopeTileh_Town,				/* get_slope_tileh_proc */
 | 
						GetSlopeTileh_Town,				/* get_slope_tileh_proc */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2931,6 +2931,11 @@ static void TrainController(Vehicle *v)
 | 
				
			|||||||
					goto invalid_rail;
 | 
										goto invalid_rail;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if (IsLevelCrossingTile(v->tile) && v->next == NULL) {
 | 
				
			||||||
 | 
										UnbarCrossing(v->tile);
 | 
				
			||||||
 | 
										MarkTileDirtyByTile(v->tile);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if (IsFrontEngine(v)) v->load_unload_time_rem = 0;
 | 
									if (IsFrontEngine(v)) v->load_unload_time_rem = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if (!(r&0x4)) {
 | 
									if (!(r&0x4)) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -591,6 +591,5 @@ const TileTypeProcs _tile_type_trees_procs = {
 | 
				
			|||||||
	ChangeTileOwner_Trees,		/* change_tile_owner_clear */
 | 
						ChangeTileOwner_Trees,		/* change_tile_owner_clear */
 | 
				
			||||||
	NULL,											/* get_produced_cargo_proc */
 | 
						NULL,											/* get_produced_cargo_proc */
 | 
				
			||||||
	NULL,											/* vehicle_enter_tile_proc */
 | 
						NULL,											/* vehicle_enter_tile_proc */
 | 
				
			||||||
	NULL,											/* vehicle_leave_tile_proc */
 | 
					 | 
				
			||||||
	GetSlopeTileh_Trees,			/* get_slope_tileh_proc */
 | 
						GetSlopeTileh_Trees,			/* get_slope_tileh_proc */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1398,6 +1398,5 @@ const TileTypeProcs _tile_type_tunnelbridge_procs = {
 | 
				
			|||||||
	ChangeTileOwner_TunnelBridge,		/* change_tile_owner_clear */
 | 
						ChangeTileOwner_TunnelBridge,		/* change_tile_owner_clear */
 | 
				
			||||||
	NULL,														/* get_produced_cargo_proc */
 | 
						NULL,														/* get_produced_cargo_proc */
 | 
				
			||||||
	VehicleEnter_TunnelBridge,			/* vehicle_enter_tile_proc */
 | 
						VehicleEnter_TunnelBridge,			/* vehicle_enter_tile_proc */
 | 
				
			||||||
	NULL,														/* vehicle_leave_tile_proc */
 | 
					 | 
				
			||||||
	GetSlopeTileh_TunnelBridge,			/* get_slope_tileh_proc */
 | 
						GetSlopeTileh_TunnelBridge,			/* get_slope_tileh_proc */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -393,6 +393,5 @@ const TileTypeProcs _tile_type_unmovable_procs = {
 | 
				
			|||||||
	ChangeTileOwner_Unmovable,      /* change_tile_owner_clear */
 | 
						ChangeTileOwner_Unmovable,      /* change_tile_owner_clear */
 | 
				
			||||||
	NULL,                           /* get_produced_cargo_proc */
 | 
						NULL,                           /* get_produced_cargo_proc */
 | 
				
			||||||
	NULL,                           /* vehicle_enter_tile_proc */
 | 
						NULL,                           /* vehicle_enter_tile_proc */
 | 
				
			||||||
	NULL,                           /* vehicle_leave_tile_proc */
 | 
					 | 
				
			||||||
	GetSlopeTileh_Unmovable,        /* get_slope_tileh_proc */
 | 
						GetSlopeTileh_Unmovable,        /* get_slope_tileh_proc */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										13
									
								
								vehicle.c
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								vehicle.c
									
									
									
									
									
								
							@@ -2012,18 +2012,7 @@ Trackdir GetVehicleTrackdir(const Vehicle* v)
 | 
				
			|||||||
 * other bits that can be set? */
 | 
					 * other bits that can be set? */
 | 
				
			||||||
uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y)
 | 
					uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	TileIndex old_tile = v->tile;
 | 
						return _tile_type_procs[GetTileType(tile)]->vehicle_enter_tile_proc(v, tile, x, y);
 | 
				
			||||||
	uint32 result = _tile_type_procs[GetTileType(tile)]->vehicle_enter_tile_proc(v, tile, x, y);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* When vehicle_enter_tile_proc returns 8, that apparently means that
 | 
					 | 
				
			||||||
	 * we cannot enter the tile at all. In that case, don't call
 | 
					 | 
				
			||||||
	 * leave_tile. */
 | 
					 | 
				
			||||||
	if (!(result & 8) && old_tile != tile) {
 | 
					 | 
				
			||||||
		VehicleLeaveTileProc *proc = _tile_type_procs[GetTileType(old_tile)]->vehicle_leave_tile_proc;
 | 
					 | 
				
			||||||
		if (proc != NULL)
 | 
					 | 
				
			||||||
			proc(v, old_tile, x, y);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return result;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
UnitID GetFreeUnitNumber(byte type)
 | 
					UnitID GetFreeUnitNumber(byte type)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -716,6 +716,5 @@ const TileTypeProcs _tile_type_water_procs = {
 | 
				
			|||||||
	ChangeTileOwner_Water,		/* change_tile_owner_clear */
 | 
						ChangeTileOwner_Water,		/* change_tile_owner_clear */
 | 
				
			||||||
	NULL,											/* get_produced_cargo_proc */
 | 
						NULL,											/* get_produced_cargo_proc */
 | 
				
			||||||
	VehicleEnter_Water,				/* vehicle_enter_tile_proc */
 | 
						VehicleEnter_Water,				/* vehicle_enter_tile_proc */
 | 
				
			||||||
	NULL,											/* vehicle_leave_tile_proc */
 | 
					 | 
				
			||||||
	GetSlopeTileh_Water,			/* get_slope_tileh_proc */
 | 
						GetSlopeTileh_Water,			/* get_slope_tileh_proc */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user