hohav / peppi

Rust parser for Slippi SSBM replay files
MIT License
37 stars 9 forks source link

Fix previous character state tracking during deserialization #33

Closed NickCondron closed 9 months ago

NickCondron commented 1 year ago

The new test I added fails on the master branch. This bug caused some very strange behavior. Basically, the follower's pre-frame update would overwrite the last character state for the port so that the pre-frame update of the leader on the next frame (on the same port) would have Nana as the character.

I fixed the bug and took the chance to refactor the code a bit.

NickCondron commented 1 year ago

Would you consider it an issue if the code I wrote doesn't handle non-Nana followers? I think technically the game can load any character as a follower. At one point someone wrote a code that made 'mario climbers' and some people used it to have fun on netplay.

https://www.youtube.com/watch?v=iqVJJxquXL4

I think I played against them once, so I think I have a replay I could find.

From a comment on that video:

Hey, I created this. I found an existing code used to load 1 character over another character on the CSS, and spent a few hours trying values that exceeded what the game had used for actual, real characters, just to see what would happen, and found this! I honestly have no idea why or how it does this or works at all but yeah. My guess if that it defaults to Mario for the player characters and that the flag the Ice Climbers have set to be a “duo” fighter is checked, but again no data so the partner is defaulted to Mario as well. And there’s no delay between them coded in because that’s a separate value. But yeah. Character still works in direct connect :D

hohav commented 1 year ago

Would you consider it an issue if the code I wrote doesn't handle non-Nana followers? I think technically the game can load any character as a follower. At one point someone wrote a code that made 'mario climbers' and some people used it to have fun on netplay.

I'd forgotten about the Mario Climbers. How much work do you think it would be to support that?

NickCondron commented 1 year ago

rebased and took a new approach that should handle mario climbers. However, I don't yet have a slp file to test them.

NickCondron commented 1 year ago

I simplified the transformation tracking. The first frame of a Sheik/Zelda change will always be the character in one of their TRANSFORM_*_ENDING states. We can check the action state ID in the pre frame update against those values to determine when the character changes. To avoid false positives, we maintain a flag is_transforming that tracks if Zelda/Sheik were in the one of their TRANSFORM_* states on the previous frame.

hohav commented 9 months ago

Closing since we no longer need to do character prediction.