Changeset - r24158:d64bbd0cb864
[Not reviewed]
master
0 1 0
SamuXarick - 4 years ago 2020-04-16 18:32:20
43006711+SamuXarick@users.noreply.github.com
Fix: [Script] ScriptMarine::AreWaterTilesConnected failed for aqueducts (#8074)
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/script/api/script_marine.cpp
Show inline comments
 
@@ -53,29 +53,29 @@
 

	
 
/* static */ bool ScriptMarine::AreWaterTilesConnected(TileIndex t1, TileIndex t2)
 
{
 
	if (!::IsValidTile(t1)) return false;
 
	if (!::IsValidTile(t2)) return false;
 

	
 
	/* Tiles not neighbouring */
 
	if (::DistanceManhattan(t1, t2) != 1) return false;
 

	
 
	DiagDirection to_other_tile = ::DiagdirBetweenTiles(t2, t1);
 

	
 
	/* Determine the reachable tracks from the shared edge */
 
	TrackBits gtts1 = ::TrackStatusToTrackBits(::GetTileTrackStatus(t1, TRANSPORT_WATER, 0, to_other_tile)) & ::DiagdirReachesTracks(to_other_tile);
 
	TrackBits gtts1 = ::TrackStatusToTrackBits(::GetTileTrackStatus(t1, TRANSPORT_WATER, 0, ReverseDiagDir(to_other_tile))) & ::DiagdirReachesTracks(to_other_tile);
 
	if (gtts1 == TRACK_BIT_NONE) return false;
 

	
 
	to_other_tile = ReverseDiagDir(to_other_tile);
 
	TrackBits gtts2 = ::TrackStatusToTrackBits(::GetTileTrackStatus(t2, TRANSPORT_WATER, 0, to_other_tile)) & ::DiagdirReachesTracks(to_other_tile);
 
	TrackBits gtts2 = ::TrackStatusToTrackBits(::GetTileTrackStatus(t2, TRANSPORT_WATER, 0, ReverseDiagDir(to_other_tile))) & ::DiagdirReachesTracks(to_other_tile);
 

	
 
	return gtts2 != TRACK_BIT_NONE;
 
}
 

	
 
/* static */ bool ScriptMarine::BuildWaterDepot(TileIndex tile, TileIndex front)
 
{
 
	EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
 
	EnforcePrecondition(false, ::IsValidTile(tile));
 
	EnforcePrecondition(false, ::IsValidTile(front));
 
	EnforcePrecondition(false, (::TileX(front) == ::TileX(tile)) != (::TileY(front) == ::TileY(tile)));
 

	
 
	return ScriptObject::DoCommand(tile, ::TileX(front) == ::TileX(tile), 0, CMD_BUILD_SHIP_DEPOT);
0 comments (0 inline, 0 general)