equal
deleted
inserted
replaced
32 if (_game_mode == GM_EDITOR) return true; |
32 if (_game_mode == GM_EDITOR) return true; |
33 |
33 |
34 // Only do the special processing for actual players. |
34 // Only do the special processing for actual players. |
35 if (_current_player >= MAX_PLAYERS) return true; |
35 if (_current_player >= MAX_PLAYERS) return true; |
36 |
36 |
37 // A railway crossing has the road owner in the map3_lo byte. |
|
38 if (IsTileType(tile, MP_STREET) && IsLevelCrossing(tile)) { |
37 if (IsTileType(tile, MP_STREET) && IsLevelCrossing(tile)) { |
39 owner = _m[tile].m3; |
38 owner = GetCrossingRoadOwner(tile); |
40 } else { |
39 } else { |
41 owner = GetTileOwner(tile); |
40 owner = GetTileOwner(tile); |
42 } |
41 } |
43 // Only do the special processing if the road is owned |
42 // Only do the special processing if the road is owned |
44 // by a town |
43 // by a town |
104 FindLandscapeHeight(&ti, x, y); |
103 FindLandscapeHeight(&ti, x, y); |
105 tile = ti.tile; |
104 tile = ti.tile; |
106 |
105 |
107 if (!IsTileType(tile, MP_STREET) && !IsTileType(tile, MP_TUNNELBRIDGE)) return CMD_ERROR; |
106 if (!IsTileType(tile, MP_STREET) && !IsTileType(tile, MP_TUNNELBRIDGE)) return CMD_ERROR; |
108 |
107 |
109 // owner for railroad crossing is stored somewhere else |
108 owner = IsLevelCrossing(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile); |
110 // XXX - Fix this so for a given tiletype the owner of the type is in the same variable |
|
111 owner = IsLevelCrossing(tile) ? _m[tile].m3 : GetTileOwner(tile); |
|
112 |
109 |
113 if (owner == OWNER_TOWN && _game_mode != GM_EDITOR) { |
110 if (owner == OWNER_TOWN && _game_mode != GM_EDITOR) { |
114 if (IsTileType(tile, MP_TUNNELBRIDGE)) { // index of town is not saved for bridge (no space) |
111 if (IsTileType(tile, MP_TUNNELBRIDGE)) { // index of town is not saved for bridge (no space) |
115 t = ClosestTownFromTile(tile, _patches.dist_local_authority); |
112 t = ClosestTownFromTile(tile, _patches.dist_local_authority); |
116 } else { |
113 } else { |
1125 } |
1122 } |
1126 } |
1123 } |
1127 |
1124 |
1128 static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID new_player) |
1125 static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID new_player) |
1129 { |
1126 { |
1130 // road/rail crossing where the road is owned by the current player? |
1127 if (IsLevelCrossing(tile) && GetCrossingRoadOwner(tile) == old_player) { |
1131 if (old_player == _m[tile].m3 && IsLevelCrossing(tile)) { |
1128 SetCrossingRoadOwner(tile, new_player == OWNER_SPECTATOR ? OWNER_NONE : new_player); |
1132 _m[tile].m3 = (new_player == OWNER_SPECTATOR) ? OWNER_NONE : new_player; |
|
1133 } |
1129 } |
1134 |
1130 |
1135 if (!IsTileOwner(tile, old_player)) return; |
1131 if (!IsTileOwner(tile, old_player)) return; |
1136 |
1132 |
1137 if (new_player != OWNER_SPECTATOR) { |
1133 if (new_player != OWNER_SPECTATOR) { |
1141 case ROAD_NORMAL: |
1137 case ROAD_NORMAL: |
1142 SetTileOwner(tile, OWNER_NONE); |
1138 SetTileOwner(tile, OWNER_NONE); |
1143 break; |
1139 break; |
1144 |
1140 |
1145 case ROAD_CROSSING: |
1141 case ROAD_CROSSING: |
1146 MakeRoadNormal(tile, _m[tile].m3, GetCrossingRoadBits(tile), _m[tile].m2); |
1142 MakeRoadNormal(tile, GetCrossingRoadOwner(tile), GetCrossingRoadBits(tile), _m[tile].m2); |
1147 break; |
1143 break; |
1148 |
1144 |
1149 default: |
1145 default: |
1150 case ROAD_DEPOT: |
1146 case ROAD_DEPOT: |
1151 DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); |
1147 DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); |