Skip to content
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 unsigned vs signed issues in D2DamageStrc #147

Conversation

nooperation
Copy link
Contributor

the original codebase has dwDmgTotal being treated as a signed value (jle) on this comparison. This causes differences to the original client when dwDmgTotal is negative

…ever dwDmgTotal is currently unsigned in the D2DamageStrc struct
@@ -1290,7 +1290,7 @@ void __fastcall SUNITDMG_ExecuteEvents(D2GameStrc* pGame, D2UnitStrc* pAttacker,
STATLIST_SetUnitStat(pDefender, STAT_HITPOINTS, nNewHp, 0);
}

if (pDamage->dwDmgTotal > 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should change dwDmgTotal to be signed instead of fixing it only here.
For example it appears in D2Game.0x6FD049D0 too, and it also checks for negative values.

Copy link
Member

@Lectem Lectem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to merge the type change of dwDmgTotal instead

@nooperation
Copy link
Contributor Author

I'd prefer to merge the type change of dwDmgTotal instead

True. I looked at the D2DamageStrc and found several unsigned values that should be signed. This pr is now about signed vs unsigned in D2DamageStrc. dwDamageRate is very likely also signed, but I cannot confirm at this time

@nooperation nooperation requested a review from Lectem February 28, 2024 03:07
@nooperation nooperation changed the title fix SUNITDMG_ExecuteEvents signed comparison dwDmgTotal fix unsigned vs signed issues in D2DamageStrc Feb 28, 2024
@Lectem
Copy link
Member

Lectem commented Feb 28, 2024

dwDamageRate is very likely also signed, but I cannot confirm at this time

I think it would be fine to put it as signed since it's passed to STATLIST_SetUnitStat

@nooperation
Copy link
Contributor Author

dwDamageRate is very likely also signed, but I cannot confirm at this time

I think it would be fine to put it as signed since it's passed to STATLIST_SetUnitStat

Updated

@Lectem Lectem merged commit dff4668 into ThePhrozenKeep:master Mar 3, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants