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
Bugfix: Missiles calculating damage in Process functions instead of Add functions #6327
base: master
Are you sure you want to change the base?
Bugfix: Missiles calculating damage in Process functions instead of Add functions #6327
Conversation
14d8a52
to
75f24c2
Compare
@@ -1396,7 +1396,7 @@ void AddSpectralArrow(Missile &missile, AddMissileParameter ¶meter) | |||
int av = 0; | |||
|
|||
if (missile.sourceType() == MissileSource::Player) { | |||
const Player &player = *missile.sourcePlayer(); | |||
Player &player = *missile.sourcePlayer(); |
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.
Why remove the const
? I don't think player
is modified her?
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.
Can't iterate through equipment if it's const
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.
Would it be better to use a traditional for loop to retain player as const?
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.
Ah, right, this will be easy to fix once we have C++17 but for now non-const is fine.
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'll add a comment by it so we know to readd const at a later time
@@ -1956,10 +2033,19 @@ void AddMissileExplosion(Missile &missile, AddMissileParameter ¶meter) | |||
void AddWeaponExplosion(Missile &missile, AddMissileParameter ¶meter) | |||
{ | |||
missile.var2 = parameter.dst.x; | |||
if (parameter.dst.x == 1) | |||
|
|||
const Player &player = *missile.sourcePlayer(); |
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.
Need to verify that missile source is player first before defining player
Moves damage calculations from the Process functions into the Add functions, so that damage is added to the missile struct rather than calculated every time the Process functions are called, which can also lead to undefined behavior if the source of the missile dies or leaves the game.
Also fixes: #4656