-
Notifications
You must be signed in to change notification settings - Fork 141
bugfix(object): Fix crash when an object is created with veterancy and an upgrade that applies a terrain decal #1359
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
Conversation
d41c7e4 to
b2cf90c
Compare
b2cf90c to
c4331d1
Compare
|
Updated now. |
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.
How about we rename GameLogic::sendObjectCreated to GameLogic::sendObjectInitialized, which modifies the object and drawable states. Called from Object::initObject.
And then we create a new GameLogic::sendObjectCreated that allocates the drawable and binds object and drawable together. Called from Object::Object.
And GameLogic::sendObjectDestroyed stays as is. Called from Object::~Object.
That would be logically cleaner and fit more into the original code design.
Unless there is a reason why we cannot create a drawable inside constructor of Object. But that looks to be ok.
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.
if anything, the drawable could be set within GameLogic::friend_createObject it can't be done within the objects constructor since it won't have the template data at that point to set the relevant drawable information.
The object and drawable binding also can't happen too soon otherwise it changes the order of execution of some other operations and can cause it to mismatch with retail.
Which was why i just create and set the drawable early but don't fully bind or initialise it till it would happen within the original code.
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.
Just looking at this more, the thingFactory is managing the creation of the object and drawable. Using templated data to initialise them to the correct object / drawable.
I don't think it is necessarily going to be any cleaner to do it from within Object::Object since the thing factory still needs to get called and needs to be known about by an object then.
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.
Please check if this change works as a fix:
xezon@f563b0e
I tested this against the Golden Replay and it passed.
It also looks as if it should prevent the crash and it would be the cleanest solution I can think of.
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.
Yeah this tweak appears to help resolve the issue without mismatching.
Originally i tried moving the call to obj->initObject(); within ThingFactory::newObject to be before the behaviour module onCreate() loop, but that caused mismatching. So considered that anything within it might casue a mismatch if performed too soon.
Will update the PR and push the changes with the extra context comments in a sec.
c4331d1 to
934f5de
Compare
|
quick rebase before making tweaks |
934f5de to
6c610ee
Compare
|
Tweaked with recommendations and tested against multiple replays. I created a replay with the fix and created troops with chemical suits, then ran it back in a build without the fix and it did not mismatch. |
6c610ee to
efceddc
Compare
|
Tweaked based on feedback, should be good now |
efceddc to
b38d423
Compare
|
Ditto |
|
Is the Description of this Pull up-to-date? |
…rancy being applied to it
b38d423 to
858ad72
Compare
Yes i already tweaked it. |
xezon
left a comment
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.
…d an upgrade that applies a terrain decal (TheSuperHackers#1359) Most notably happens when spawning the USA Pilot with the Chemical Suits upgrade
This PR fixes a game crash caused when a unit is created with veterancy and the object has an upgrade unlocked that attempts to apply a terrain decal. This can be reproduced with the chemical suits upgrade of the USA and is likely the reason why the chemical suit upgrade is disabled on USA pilots.
When an object is created the thing factory runs through all of it's behaviour modules and calls their
onCreate()function if there is one available.Units created with veterancy have the veterancyGainCreate module applied to them. This module iterates over all of the objects behaviour modules and forces them to update their status.
If the chemical suits upgrade or any other upgrade that applies a terrain decal is unlocked then it will crash the game. This is due to the objects drawable not being applied yet.
Normally the object will get its drawble created and bound to it after the behaviour modules have been iterated over. But to get around the veterancyGainCreate issue, we call the
sendObjectCreated()at the end of the objects constructor.originally it would be called within
initObjectthat gets called after the behaviour modulesonCreateloop withinThingFactory::newObject.This then allows modules that would update the drawable to do so without crashing the game.
This is also fully retail compatible due to the ordering being maintained in the original initialisation sequence beyond creating the drawable and applying it to the object.