-
Notifications
You must be signed in to change notification settings - Fork 61
[GEN][ZH] Fix drawable assignment in StealthUpdate::changeVisualDisguise() #730
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
[GEN][ZH] Fix drawable assignment in StealthUpdate::changeVisualDisguise() #730
Conversation
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.
Looks good to me. We should add @helmutbuhler as Co-Author when Squash-merging
885f5ac
to
882ffab
Compare
Rebased with main and pushed so ready for testing |
Created a replay with gla where i disguised some bomb trucks and then replayed it on this pr exes VC6 replay ok |
882ffab
to
98af79c
Compare
98af79c
to
095f6a3
Compare
Cleaned up comment, should be good to go. |
I removed the Bug label because there is no evidence that this was a runtime problem in the retail game. Additionally, in a debug session with VS2022 we observed that calling TheGameClient->destroyDrawable( draw );
TheThingFactory->newDrawable( tTemplate ); amazingly did not pose an issue because the new pointer returned by Other than that, we also did not manage to enter the |
I just got this to trigger and it throws a memory exception. It occurs when the bomb truck is returning to its original visual, either by being discovered or exploding.
Exception occurs when it's trying to access the module data from the drawable. |
…ise() (#730) Co-authored-by: Helmut Buhler <buhler@8gadgetpack.net>
095f6a3
to
388879e
Compare
Did you test that with the Null Memory or with regular Game Memory implementation?
Deallocating is pushing that memory blob to the free list as its first element. void MemoryPoolBlob::freeSingleBlock(MemoryPoolSingleBlock *block)
{
DEBUG_ASSERTCRASH(block->getOwningBlob() == this, ("block does not belong to this blob"));
block->setNextFreeBlock(m_firstFreeBlock);
m_firstFreeBlock = block;
--m_usedBlocksInBlob;
... Allocating is using that memory blob from the first element in the free list. MemoryPoolSingleBlock *MemoryPoolBlob::allocateSingleBlock(DECLARE_LITERALSTRING_ARG1)
{
DEBUG_ASSERTCRASH(m_firstFreeBlock, ("no free blocks available in MemoryPoolBlob"));
MemoryPoolSingleBlock *block = m_firstFreeBlock;
m_firstFreeBlock = block->getNextFreeBlock();
++m_usedBlocksInBlob;
... |
The null memory implementation, so as you mentioned this likely only works because an object still exists at the location in the memory manager. Visually the truck fully returns to looking like the truck before exploding when i have it set the draw variable as per the fix. |
Yes, I tested and it certainly does not crash with Game Memory because of that MemoryPoolBlob behaviour. So no retail bug, but certainly a problem that is good to fix. |
Just testing retail compared to this and it looks like this fix does create a visual difference. With this fix the truck fully returns to looking like the truck just before it explodes. |
I was unable to confirm this observation. The Bomb Truck will undisguise normally before this change. |
I think it was just timing in the end, i had the bomb truck right next to an enemy building before having it attack. |
This fix was originally discovered by @helmutbuhler and split out of the original PR it was contained in.
This fix corrects the behaviour where when the drawable was not being set for a new visual disguise on a stealth unit.
The call to get the new drawable was not being handled correctly and was not updating the draw variable.
This would have resulted in a memory leak, possible use after free and unexpected behaviour with stealthing units.