MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / MakeWaterKeepingClass

Function MakeWaterKeepingClass

src/water_cmd.cpp:218–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218void MakeWaterKeepingClass(TileIndex tile, Owner o)
219{
220 WaterClass wc = GetWaterClass(tile);
221
222 /* Autoslope might turn an originally canal or river tile into land */
223 auto [slope, z] = GetTileSlopeZ(tile);
224
225 if (slope != SLOPE_FLAT) {
226 if (wc == WaterClass::Canal) {
227 /* If we clear the canal, we have to remove it from the infrastructure count as well. */
228 Company *c = Company::GetIfValid(o);
229 if (c != nullptr) {
230 c->infrastructure.water--;
231 DirtyCompanyInfrastructureWindows(c->index);
232 }
233 /* Sloped canals are locks and no natural water remains whatever the slope direction */
234 wc = WaterClass::Invalid;
235 }
236
237 /* Only river water should be restored on appropriate slopes. Other water would be invalid on slopes */
238 if (wc != WaterClass::River || GetInclinedSlopeDirection(slope) == INVALID_DIAGDIR) {
239 wc = WaterClass::Invalid;
240 }
241 }
242
243 if (wc == WaterClass::Sea && z > 0) {
244 /* Update company infrastructure count. */
245 Company *c = Company::GetIfValid(o);
246 if (c != nullptr) {
247 c->infrastructure.water++;
248 DirtyCompanyInfrastructureWindows(c->index);
249 }
250
251 wc = WaterClass::Canal;
252 }
253
254 /* Zero map array and terminate animation */
255 DoClearSquare(tile);
256
257 /* Maybe change to water */
258 switch (wc) {
259 case WaterClass::Sea: MakeSea(tile); break;
260 case WaterClass::Canal: MakeCanal(tile, o, Random()); break;
261 case WaterClass::River: MakeRiver(tile, Random()); break;
262 default: break;
263 }
264
265 if (wc != WaterClass::Invalid) CheckForDockingTile(tile);
266 MarkTileDirtyByTile(tile);
267}
268
269static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlags flags)
270{

Callers 7

~IndustryMethod · 0.85
RemoveShipDepotFunction · 0.85
RemoveLockFunction · 0.85
RemoveBuoyFunction · 0.85
ReallyClearObjectTileFunction · 0.85
RemoveDockFunction · 0.85
DeleteOilRigFunction · 0.85

Calls 11

GetWaterClassFunction · 0.85
GetTileSlopeZFunction · 0.85
DoClearSquareFunction · 0.85
MakeSeaFunction · 0.85
MakeCanalFunction · 0.85
MakeRiverFunction · 0.85
CheckForDockingTileFunction · 0.85
MarkTileDirtyByTileFunction · 0.70
RandomFunction · 0.50

Tested by

no test coverage detected