Changeset - r26833:d8c243dc47f3
[Not reviewed]
master
0 1 0
Jonathan G Rennison - 19 months ago 2023-01-29 16:51:32
j.g.rennison@gmail.com
Fix #10419: Water infrastructure accounting when building ship depots
1 file changed with 8 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/water_cmd.cpp
Show inline comments
 
@@ -136,11 +136,14 @@ CommandCost CmdBuildShipDepot(DoCommandF
 
		Depot *depot = new Depot(tile);
 
		depot->build_date = _date;
 

	
 
		if (wc1 == WATER_CLASS_CANAL || wc2 == WATER_CLASS_CANAL) {
 
			/* Update infrastructure counts after the unconditional clear earlier. */
 
			Company::Get(_current_company)->infrastructure.water += wc1 == WATER_CLASS_CANAL && wc2 == WATER_CLASS_CANAL ? 2 : 1;
 
		}
 
		Company::Get(_current_company)->infrastructure.water += 2 * LOCK_DEPOT_TILE_FACTOR;
 
		uint new_water_infra = 2 * LOCK_DEPOT_TILE_FACTOR;
 
		/* Update infrastructure counts after the tile clears earlier.
 
		 * Clearing object tiles may result in water tiles which are already accounted for in the water infrastructure total.
 
		 * See: MakeWaterKeepingClass() */
 
		if (wc1 == WATER_CLASS_CANAL && !(HasTileWaterClass(tile) && GetWaterClass(tile) == WATER_CLASS_CANAL && IsTileOwner(tile, _current_company))) new_water_infra++;
 
		if (wc2 == WATER_CLASS_CANAL && !(HasTileWaterClass(tile2) && GetWaterClass(tile2) == WATER_CLASS_CANAL && IsTileOwner(tile2, _current_company))) new_water_infra++;
 

	
 
		Company::Get(_current_company)->infrastructure.water += new_water_infra;
 
		DirtyCompanyInfrastructureWindows(_current_company);
 

	
 
		MakeShipDepot(tile,  _current_company, depot->index, DEPOT_PART_NORTH, axis, wc1);
0 comments (0 inline, 0 general)