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

CasualtyOrderOfLosses#sortUnitsForCasualtiesWithSupport can build identical keys for different unit type lists #7020

Closed
1 task done
trevan opened this issue Jul 3, 2020 · 2 comments · Fixed by #7022
Closed
1 task done
Assignees
Labels
Problem A problem, bug, defect - something to fix

Comments

@trevan
Copy link
Contributor

trevan commented Jul 3, 2020

How can the problem be recreated?

Play the save game.

In CasualtyOrderOfLosses#sortUnitsForCasualtiesWithSupport, a key is generated to look up in CasualtyOrderOfLosses#oolCache. This key is generated by summing up all of the hash codes of the types in the targets.

In Warcraft War Heroes, there are some combination of types that have the same hashcode as other combinations of types.

An example is:

Unit Type HashCode
Footmen 984658568
Veteran-Pikemen 2139503253
SUM 3124161821

And

Unit Type HashCode
Pikemen 1093844931
Veteran-Footmen 2030316890
SUM 3124161821

Do you have any ideas for an expected fix?

The hashcode of unittype either needs to be changed to not just be the name or the key needs to be more than a sum.

Attach a Save Game

wow-u25.zip

If playing a prerelease, which version are you using?

Game Version: Master

If playing a prerelease, does this happen on the latest release?

  • yes
  • [] no

Is there anything else we should know?

This causes an exception java.lang.IllegalStateException: sortedTargetsToPickFrom must have the same size as targetsToPickFrom list so it is visible.

@trevan trevan added the Problem A problem, bug, defect - something to fix label Jul 3, 2020
@DanVanAtta
Copy link
Member

DanVanAtta commented Jul 3, 2020

This is a good spot. 🦅
The manual computation of hashcode likely should be replaced with either a hashcode builder or lombok EqualsAndHashCode

@trevan trevan self-assigned this Jul 3, 2020
@trevan
Copy link
Contributor Author

trevan commented Jul 3, 2020

I've gone through git history and the code to calculate the key was better. But during a refactoring in 57f1145 (back in 2015), the key calculation was converted into the sum and has been that way since.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Problem A problem, bug, defect - something to fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants