-
Notifications
You must be signed in to change notification settings - Fork 126
fix(tunnel): Fix undefined behavior in TunnelTracker::onTunnelDestroyed and incomplete asset transfer in Team::setControllingPlayer #1958
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
base: main
Are you sure you want to change the base?
Conversation
…omplete asset transfer in Team::setControllingPlayer
| } | ||
| else | ||
| { | ||
| obj->onCapture(oldOwner, newController); |
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.
It worked ok in GLA 03 mission and avoids the tunnel transfer issue, but I do not know if it creates new problems. Something to keep an eye on.
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.
handlePartitionCellMaintenance gets called within object::onCapture so shouldn't need calling here.
it also gets called within tunnelContain::onCapture as well which will get triggered by object::onCapture as it loops through all behaviour modules and calls their onCapture function.
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.
They are exclusive calls depending on RETAIL_COMPATIBLE_CRC
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.
Maybe we test if the object is a tunnel and perform TunnelContain::onCapture() only on the tunnels? since they are a special case in this instance due to the tunnel system needing to be updated properly.
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.
The reason I used RETAIL_COMPATIBLE_CRC is to avoid any chance of mismatch because it looks risky for any object.
The crash is avoided anyway with the fix in TunnelTracker::onTunnelDestroyed.
|
Keeping track of the container size in a separate variable is quite unfortunate, and it's done in quite a bunch of places. |
They do this because STLPort |
| // The Team doesn't change, it just starts to return a different answer when you ask for | ||
| // the controlling player. I don't want to make the major change of onCapture on everyone, | ||
| // so I will do the minor fix for the specific bug, which is harmless even when misused. | ||
| // TheSuperHackers @fix xezon 07/12/2025 Now does onCapture on everyone. |
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.
Might be worth cleaning up the legacy comment as it no longer applies anymore
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.
I did not want to nuke the EA comment so I just appended information. If you have a suggestion for how to rewrite the EA comment, please write.
This change fixes undefined behavior in
TunnelTracker::onTunnelDestroyedand incomplete asset transfer inTeam::setControllingPlayer.This issue happens in GLA 03 mission, where at least 2 tunnels are transfered by script and
Team::setControllingPlayerto the local player but are not unregistered from the tunnel tracker of the previous owner. This then causes undefined behavior inTunnelTracker::onTunnelDestroyedon mission end when all objects are destroyed and unregistered from the tunnel trackers.