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
Devs: objects/UUID compare problems (inner rollbacks problem) #4407
Comments
Good findings! 👍 |
Very good finding!! A use the project Lombok jar often, which is a library that creates constructors, getters, setters and equal methods automatically for you with just an annotation |
Interesting, does it impact OneShotEffects too (since they're presumably reverted along with the rollback), or is only a problem for continuous effects in practice? |
@Zzooouhh yes, replacement bugs from restore/rollback function. That's it. It use save state before cast and then restored after cast (e.g. all data checks after restore will be dangerous to use by refs): |
|
As a fast workaround it may be good idea do not remove all old state on restore, but moved it to temp object (e.g. ensure that all old refs will works to the end). Maybe debugger or JVM have feature to find out all refs to that object after it was moved to temp -- that's can help to find wrong code. |
Normally Players or MageObjects won't be checked directly. So I don't see that bugy anywhere. But indeed we have to replace == checks on the UUIDs with equals. |
Are all "==" replaced and this can be closed? |
Well, I've checked and fixed warning from IDE about |
Found real life proof (#5784) of that problem: |
Another one example of rollback and game state problem (#5835 with
|
Continue from #4402
You can't compare UUID or objects by
==
operand. Need to use onlyobj.equals()
.IntelliJ IDEA have inspections on that problems (use custom inspect settings to filter only needed data):
Current project have 72 warnings with
==
on objects (exported list to web page here):BUT some xmage objects do not overrides Equals method and use default one, e.g. compare objects by
==
(compare refs, not data) .As example,
Player
objects do not have Equals. All players data searched from game'sstate
object:But game
state
can be changed and reverted. In particular, it's saved to history every step by COPY (e.g. new state's players is not equals to old one). And on rollback step can broke something if you save ref object to somewhere (is that can cause of "buggy rollback" function?) or if you have another thread (is xmage use one thread per game?):I don't known confirmed bug with that issue like with static filters (#4402). But devs have to be careful about this.
Howto fix that:
==
toequals
for xmage and UUID objects compare;equals
method. Example forPlayerImp.java
(players with same ID will be equal):The text was updated successfully, but these errors were encountered: