Changeset - r6723:76bfb6080f45
[Not reviewed]
master
0 1 0
maedhros - 17 years ago 2007-05-27 09:17:30
maedhros@openttd.org
(svn r9955) -Codechange: Make _roadveh_enter_depot_unk0 slightly less mysterious.
1 file changed with 7 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/road_cmd.cpp
Show inline comments
 
@@ -1229,68 +1229,72 @@ static uint32 GetTileTrackStatus_Road(Ti
 
	return 0;
 
}
 

	
 
static const StringID _road_tile_strings[] = {
 
	STR_1814_ROAD,
 
	STR_1814_ROAD,
 
	STR_1814_ROAD,
 
	STR_1815_ROAD_WITH_STREETLIGHTS,
 
	STR_1814_ROAD,
 
	STR_1816_TREE_LINED_ROAD,
 
	STR_1814_ROAD,
 
	STR_1814_ROAD,
 
};
 

	
 
static void GetTileDesc_Road(TileIndex tile, TileDesc *td)
 
{
 
	td->owner = GetTileOwner(tile);
 
	switch (GetRoadTileType(tile)) {
 
		case ROAD_TILE_CROSSING: td->str = STR_1818_ROAD_RAIL_LEVEL_CROSSING; break;
 
		case ROAD_TILE_DEPOT: td->str = STR_1817_ROAD_VEHICLE_DEPOT; break;
 
		default: td->str = _road_tile_strings[GetRoadside(tile)]; break;
 
	}
 
}
 

	
 
static const byte _roadveh_enter_depot_unk0[4] = {
 
	8, 9, 0, 1
 
/**
 
 * Given the direction the road depot is pointing, this is the direction the
 
 * vehicle should be travelling in in order to enter the depot.
 
 */
 
static const byte _roadveh_enter_depot_dir[4] = {
 
	TRACKDIR_X_SW, TRACKDIR_Y_NW, TRACKDIR_X_NE, TRACKDIR_Y_SE
 
};
 

	
 
static uint32 VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y)
 
{
 
	switch (GetRoadTileType(tile)) {
 
		case ROAD_TILE_CROSSING:
 
			if (v->type == VEH_TRAIN && !IsCrossingBarred(tile)) {
 
				/* train crossing a road */
 
				SndPlayVehicleFx(SND_0E_LEVEL_CROSSING, v);
 
				BarCrossing(tile);
 
				MarkTileDirtyByTile(tile);
 
			}
 
			break;
 

	
 
		case ROAD_TILE_DEPOT:
 
			if (v->type == VEH_ROAD &&
 
					v->u.road.frame == 11 &&
 
					_roadveh_enter_depot_unk0[GetRoadDepotDirection(tile)] == v->u.road.state) {
 
					_roadveh_enter_depot_dir[GetRoadDepotDirection(tile)] == v->u.road.state) {
 
				VehicleEnterDepot(v);
 
				return VETSB_ENTERED_WORMHOLE;
 
			}
 
			break;
 

	
 
		default: break;
 
	}
 
	return VETSB_CONTINUE;
 
}
 

	
 

	
 
static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID new_player)
 
{
 
	if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) {
 
		if (GetTileOwner(tile) == old_player) {
 
			if (new_player == PLAYER_SPECTATOR) {
 
				DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 
			} else {
 
				SetTileOwner(tile, new_player);
 
			}
 
		}
 
		return;
 
	}
 

	
0 comments (0 inline, 0 general)