New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: [AI/GS] AreWaterTilesConnected wasn't handling aqueducts properly #8074
Fix: [AI/GS] AreWaterTilesConnected wasn't handling aqueducts properly #8074
Conversation
This bug is missing a root cause analysis. The real issue seems to be, that the direction passed to GetTileTrackStatus needs an additional GetReverseDiagDir, since GetTileTrackStatus expects an exitdir, while to_other_tile seems to be an enterdir. |
src/script/api/script_marine.cpp
Outdated
@@ -62,13 +63,20 @@ | |||
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, INVALID_DIAGDIR)) & ::DiagdirReachesTracks(to_other_tile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing root cause analysis.
c5d33e1
to
03c4fed
Compare
03c4fed
to
b42ebb4
Compare
Maybe you also want to check the same for roads and rails. |
PR 8074 test AI.zip
aqueduct scenario.zip
There are 2 bugs being fixed. I have attached a scenario and an AI that must run with each other.
Bug 1: As an example, tiles 1700 and 1764 are connected, but AreWaterTilesConnected reports that they're not. There are others similar tiles that fall into the same bug.
Bug 2: As an example, tiles 2032 and 2096 aren't connected, but AreWaterTilesConnected reports that they are.
This PR attempts to fix those cases while still maintaining the results the same for the other test cases. I'm sure I didn't handle all the possible cases, but I hope the fixes don't break anything.