src/road_cmd.cpp
changeset 6689 84811200d69c
parent 6683 b88ae30866ce
child 6691 f9adbb0be102
equal deleted inserted replaced
6688:e2403f390add 6689:84811200d69c
  1198 
  1198 
  1199 
  1199 
  1200 static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID new_player)
  1200 static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID new_player)
  1201 {
  1201 {
  1202 	if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) {
  1202 	if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) {
  1203 		DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
  1203 		if (new_player == PLAYER_SPECTATOR) {
       
  1204 			DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
       
  1205 		} else {
       
  1206 			SetTileOwner(tile, new_player);
       
  1207 		}
  1204 		return;
  1208 		return;
  1205 	}
  1209 	}
  1206 
  1210 
  1207 	for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
  1211 	for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
  1208 		if (!HASBIT(GetRoadTypes(tile), rt)) continue;
  1212 		if (!HASBIT(GetRoadTypes(tile), rt)) continue;
  1209 
  1213 
  1210 		if (GetRoadOwner(tile, rt) == old_player) {
  1214 		if (GetRoadOwner(tile, rt) == old_player) {
  1211 			SetRoadOwner(tile, rt, new_player == PLAYER_SPECTATOR ? OWNER_NONE : new_player);
  1215 			SetRoadOwner(tile, rt, new_player == PLAYER_SPECTATOR ? OWNER_NONE : new_player);
  1212 
       
  1213 			if (rt == ROADTYPE_TRAM) {
       
  1214 				DoCommand(tile, ROADTYPE_TRAM << 4 | GetRoadBits(tile, ROADTYPE_ROAD), 0, DC_EXEC, CMD_REMOVE_ROAD);
       
  1215 			}
       
  1216 		}
  1216 		}
  1217 	}
  1217 	}
  1218 
  1218 
  1219 	if (IsLevelCrossing(tile)) {
  1219 	if (IsLevelCrossing(tile)) {
  1220 		MakeRoadNormal(tile, GetCrossingRoadBits(tile), GetRoadTypes(tile), GetTownIndex(tile), GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM), GetRoadOwner(tile, ROADTYPE_HWAY));
  1220 		if (GetTileOwner(tile) == old_player) {
       
  1221 			if (new_player == PLAYER_SPECTATOR) {
       
  1222 				MakeRoadNormal(tile, GetCrossingRoadBits(tile), GetRoadTypes(tile), GetTownIndex(tile), GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM), GetRoadOwner(tile, ROADTYPE_HWAY));
       
  1223 			} else {
       
  1224 				SetTileOwner(tile, new_player);
       
  1225 			}
       
  1226 		}
  1221 	}
  1227 	}
  1222 }
  1228 }
  1223 
  1229 
  1224 
  1230 
  1225 extern const TileTypeProcs _tile_type_road_procs = {
  1231 extern const TileTypeProcs _tile_type_road_procs = {