equal
deleted
inserted
replaced
94 } |
94 } |
95 } |
95 } |
96 |
96 |
97 /** |
97 /** |
98 * Makes a tile canal or water depending on the surroundings. |
98 * Makes a tile canal or water depending on the surroundings. |
|
99 * |
|
100 * Must only be used for converting old savegames. Use WaterClass now. |
|
101 * |
99 * This as for example docks and shipdepots do not store |
102 * This as for example docks and shipdepots do not store |
100 * whether the tile used to be canal or 'normal' water. |
103 * whether the tile used to be canal or 'normal' water. |
101 * @param t the tile to change. |
104 * @param t the tile to change. |
102 * @param o the owner of the new tile. |
105 * @param o the owner of the new tile. |
103 */ |
106 */ |
114 |
117 |
115 for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) { |
118 for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) { |
116 TileIndex neighbour = TileAddByDiagDir(t, dir); |
119 TileIndex neighbour = TileAddByDiagDir(t, dir); |
117 switch (GetTileType(neighbour)) { |
120 switch (GetTileType(neighbour)) { |
118 case MP_WATER: |
121 case MP_WATER: |
119 has_water |= IsSea(neighbour) || IsCoast(neighbour) || (IsShipDepot(neighbour) && GetShipDepotWaterOwner(neighbour) == OWNER_WATER); |
122 /* clear water and shipdepots have already a WaterClass associated */ |
120 has_canal |= IsCanal(neighbour) || (IsShipDepot(neighbour) && GetShipDepotWaterOwner(neighbour) != OWNER_WATER); |
123 if (IsCoast(neighbour)) { |
121 has_river |= IsRiver(neighbour); |
124 has_water = true; |
|
125 } else if (!IsLock(neighbour)) { |
|
126 switch (GetWaterClass(neighbour)) { |
|
127 case WATER_CLASS_SEA: has_water = true; break; |
|
128 case WATER_CLASS_CANAL: has_canal = true; break; |
|
129 case WATER_CLASS_RIVER: has_river = true; break; |
|
130 default: NOT_REACHED(); |
|
131 } |
|
132 } |
122 break; |
133 break; |
123 |
134 |
124 case MP_RAILWAY: |
135 case MP_RAILWAY: |
125 /* Shore or flooded halftile */ |
136 /* Shore or flooded halftile */ |
126 has_water |= (GetRailGroundType(neighbour) == RAIL_GROUND_WATER); |
137 has_water |= (GetRailGroundType(neighbour) == RAIL_GROUND_WATER); |
172 return_cmd_error(STR_0239_SITE_UNSUITABLE); |
183 return_cmd_error(STR_0239_SITE_UNSUITABLE); |
173 } |
184 } |
174 |
185 |
175 WaterClass wc1 = GetWaterClass(tile); |
186 WaterClass wc1 = GetWaterClass(tile); |
176 WaterClass wc2 = GetWaterClass(tile2); |
187 WaterClass wc2 = GetWaterClass(tile2); |
177 Owner o1 = GetTileOwner(tile); |
|
178 Owner o2 = GetTileOwner(tile2); |
|
179 ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
188 ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
180 if (CmdFailed(ret)) return CMD_ERROR; |
189 if (CmdFailed(ret)) return CMD_ERROR; |
181 ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
190 ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
182 if (CmdFailed(ret)) return CMD_ERROR; |
191 if (CmdFailed(ret)) return CMD_ERROR; |
183 |
192 |
186 AutoPtrT<Depot> d_auto_delete = depot; |
195 AutoPtrT<Depot> d_auto_delete = depot; |
187 |
196 |
188 if (flags & DC_EXEC) { |
197 if (flags & DC_EXEC) { |
189 depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
198 depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
190 |
199 |
191 MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis, wc1, o1); |
200 MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis, wc1); |
192 MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis, wc2, o2); |
201 MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis, wc2); |
193 MarkTileDirtyByTile(tile); |
202 MarkTileDirtyByTile(tile); |
194 MarkTileDirtyByTile(tile2); |
203 MarkTileDirtyByTile(tile2); |
195 d_auto_delete.Detach(); |
204 d_auto_delete.Detach(); |
196 } |
205 } |
197 |
206 |
223 |
232 |
224 if (flags & DC_EXEC) { |
233 if (flags & DC_EXEC) { |
225 /* Kill the depot, which is registered at the northernmost tile. Use that one */ |
234 /* Kill the depot, which is registered at the northernmost tile. Use that one */ |
226 delete GetDepotByTile(tile2 < tile ? tile2 : tile); |
235 delete GetDepotByTile(tile2 < tile ? tile2 : tile); |
227 |
236 |
228 MakeWaterKeepingClass(tile, GetShipDepotWaterOwner(tile)); |
237 MakeWaterKeepingClass(tile, GetTileOwner(tile)); |
229 MakeWaterKeepingClass(tile2, GetShipDepotWaterOwner(tile2)); |
238 MakeWaterKeepingClass(tile2, GetTileOwner(tile2)); |
230 MarkTileDirtyByTile(tile); |
239 MarkTileDirtyByTile(tile); |
231 MarkTileDirtyByTile(tile2); |
240 MarkTileDirtyByTile(tile2); |
232 } |
241 } |
233 |
242 |
234 return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_ship_depot); |
243 return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_ship_depot); |