joel16 / PSV-VSH-Menu

A VSH menu tai-hen plugin for the PS VITA.
GNU General Public License v3.0
110 stars 11 forks source link

Changing colour to less than red or more than white crashes the current game. #6

Closed dude22072 closed 6 years ago

dude22072 commented 6 years ago

If you press left to change the VSH menu colour while it is red or right to change the colour while it is white the game will crash. If I had to take a blind guess it's probably an ArrayIndexOutOfBounds error, but I have not looked at the code so I don;t know.

joel16 commented 6 years ago

Do me a favour and delete the entire VSH folder in ur0:data/vsh. It does sound like a out of bounds error, but I tested this quite a bit with multiple titles (excluding adrenaline - not yet set up and PSX games - don't have any) and I didn't encounter this issue.

joel16 commented 6 years ago

Here's a video showing that it works fine here: https://www.youtube.com/watch?v=Gpdcfh_-WPM (Child of light is a nonpdrm backup and the other is a cart game.) Do you perhaps have some other plugin enabled that might be conflicting?

dude22072 commented 6 years ago

After deleting ur0:data/vsh/ and rebooting this error is still happening to me on a NoNpDRM game, a cartridge game (actual cart in slot, not backup), and an old VPK installed game. The only plugin I have other than VSH is NoNpDRM.

I got curious and checked ur0:data/vsh/config.cfg after one of these crashes and noticed when crashing from pressing left on red the config had "bar_colour = -1" and when crashing by pressing right on white the config had "bar_colour = 9". Attempting the open the VSH menu at all without correcting the config.cfg results in the game instantly crashing, as these values are obviously out of bounds.

joel16 commented 6 years ago

That is indeed weird, I actually do have a check that prevents that from happening as you can see here: https://github.com/joel16/PSV-VSH-Menu/blob/master/source/vsh.c#L315

Basically it sets the colour data to 0 if it goes beyond 8, and it sets it to 8 if it goes less than 0. Seems to be completely ignoring that check in your case.

I gave it a different approach this time. Tell me if this works any better: https://drive.google.com/open?id=1DWS_guNG_ga-HVM0cwcWLxJDcGSTcHEU

dude22072 commented 6 years ago

Your new approach is functioning properly.

But to critique a little here, in your old code (the section you linked):

colour++;
Config_SaveMenuConfig(batteryPercent, batteryLifeTime, batteryTemp, colour);
Config_LoadConfig();

this is (probably) where the issue lies. You are allowing the index to go out-of-bounds and then saving to the config and loading that out-of-bounds index. The >8 or <0 checks should be happening before you save the config, not after the incorrect index is loaded. (I'm assuming that's what you're doing on the new suprx you gave me). If i were to guess why it was an issue for me but not you I saw in your video you overclocked the vita whereas I left speed at default. The fact you had the system overclocked might have allowed it to catch the error and correct it before crash, unlike my vita being on default speeds.

joel16 commented 6 years ago

Yes you're correct I should be doing that first, however I've used this code in other programs before and they worked just fine. Those were mostly under some sort of loop, so it would've been fine then. Also I had to set the max to 8, even though it should be checking if it's less than 9. (0-8 is less than 9).

However you can see what I did if you like: https://github.com/joel16/PSV-VSH-Menu/commit/05497ef48ef7c37451adba87d8e1958a8878b2c0 It's basically what you said, except it actually doesn't let it increment/decrement unless it's in bounds.