libretro / snes9x

Snes9x - Portable Super Nintendo Entertainment System (TM) emulator
http://www.snes9x.com
Other
47 stars 56 forks source link

Multiline Cheats not working correctly #196

Closed eriXD closed 4 years ago

eriXD commented 5 years ago

When using Multiline cheats (I tried it with a sequence of Action Replay codes using + as delimiter) only the first one gets activated.

In libretro.cpp's function retro_cheat_set (line 779) the code variable gets tokenized and the parts are supposedly (and indirectly) given over to cheats2.cpp's S9xCreateCheatgroup. The problem is that this function also creates tokens of the code string it is given, which (I guess due to the way strtok is implemented) somehow destroys the remains of the original code variable in libretro.cpp setting it immediately to Null.

An ugly workaround is to remove S9xCreateCheatGroup's for-loop (line 403 in cheat2.cpp) and change the rest of the function so that the correct string is given to S9xTextToCheat. Obviously this will not create a "cheat group" but merely several cheat groups consisting of only one cheat each. Unfortunately I'm no expert on this matter - I tried giving the S9xCreateCheatGroup function the entire multiline cheat string, which should then be split, put into a cheat group and be activated, but somehow it didn't work... I may have done it incorrectly...

bearoso commented 5 years ago

This is because strtok is non-reentrant. I'll fix the S9xCreateCheatGroup function to not use it.

bearoso commented 5 years ago

I believe I've fixed this upstream. ae1477d420461e8a602e62c36842bef5aa1780ab should fix it.

slacknk commented 4 years ago

This bug for multi-line cheats Action Replay detected on

snes9x2002-2018.06.24_c98e1c3
snes9x2005-2018.11.02_f4a5a7a

Please, fix it for other snes9x-20Xx_libretro don't work cheats with + from Online Updater > Update Cheats

hizzlekizzle commented 4 years ago

Those cores are old and unrelated to this up-to-date core, so different people would fix those. You can make issues on the other cores' respective issue trackers, if you like, though.

Since the original issue is fixed, I'm going to close this issue now.