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

Changed all checks for !gPlayState to `!GameInteractor::IsSaveLoade… #3441

Conversation

Malkierian
Copy link
Contributor

@Malkierian Malkierian commented Nov 25, 2023

Many cheats in mods.cpp were merely checking for !gPlayState to prevent running outside of a game, which isn't enough considering the title screen and demos. Using Change Age in the title screen, you could actually softlock saves that would require editing the json to remove that CVar. This changes all of those to !GameInteractor::IsSaveLoaded() and adds checks for the same to any of the rest that have no business running outside of a loaded game (even though they were probably benign, still shouldn't be allowed to happen).

Also changed RegisterSwitchAge to clear the CVar instead of just setting it to 0.

Build Artifacts

…d()` in mods.cpp for all the cheats, and added the same full check to others that really didn't need to be running outside of a game (like infinite rupees, magic, health, etc), and clear any triggering CVars.

Changed `RegisterSwitchAge()` to clear the CVar instead of setting it to 0.
@Archez
Copy link
Contributor

Archez commented Nov 25, 2023

One thing I'm not a big fan of with GameInteractor::IsSaveLoaded is that it prevents things from working in a non-savefile debug play state (using map select from the opening scene/file select). This is a useful and valid playstate in my mind for testing things without making/sacrificing a file slot.

I'd like to see an alternate method that still prevents some things from working on the opening sequence, but does allow them in non-savefile debug mode. I don't know what this would look like yet, might have to think about it.

@garrettjoecox
Copy link
Contributor

One thing I'm not a big fan of with GameInteractor::IsSaveLoaded is that it prevents things from working in a non-savefile debug play state (using map select from the opening scene/file select). This is a useful and valid playstate in my mind for testing things without making/sacrificing a file slot.

I'd like to see an alternate method that still prevents some things from working on the opening sequence, but does allow them in non-savefile debug mode. I don't know what this would look like yet, might have to think about it.

agreed this has been annoying, early on I had considered trying to just add checks for the cutscene indexes instead but never got around to it

@Malkierian
Copy link
Contributor Author

What does that actually look like? I assume it's something about the saveNum, does it have a specific saveNum that ends up being used there that isn't used elsewhere? Maybe we could make an exception just for that?

@jbodner09
Copy link
Contributor

nit: single line if statements still need brackets

@Malkierian
Copy link
Contributor Author

I was pretty sure that was the one time that no-bracket if statements were allowed, but that format wasn't even my code, aside from changing things how I mentioned that was already that way XD

@garrettjoecox
Copy link
Contributor

What does that actually look like? I assume it's something about the saveNum, does it have a specific saveNum that ends up being used there that isn't used elsewhere? Maybe we could make an exception just for that?

Iirc the fileNum is 0xFF for both the title sequence and the debug mode.

@briaguya-ai
Copy link
Contributor

what if we gave GameInteractor::IsSaveLoaded an optional bool param for debug-non-file state that defaults to false? at that point IsSaveLoaded may be a bit of a misnomer but we could at least use it everywhere and if we want to allow stuff in non-savefile LRZ mode we can just add true to the call

@garrettjoecox
Copy link
Contributor

gSaveContext.gameMode seems to be GAMEMODE_TITLE_SCREEN when on title screen, GAMEMODE_FILE_SELECT when on file select, and GAMEMODE_NORMAL when both in a normal file and in the debug file (warping from title screen)

Probably can safely use this along with the other indicators

@Malkierian
Copy link
Contributor Author

Do we want to make that a separate PR?

Copy link
Contributor

@aMannus aMannus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to change what's behind IsSaveLoaded(), we'd need everything in this PR anyway. Considering this is the part that actually fixes something, and the other thing is more a develop thing, I'd say let's get this in right now and PR the better check later.

Copy link
Contributor

@briaguya-ai briaguya-ai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree with @aMannus

let's :shipit: and do a follow up PR to restore/improve devex later

@aMannus aMannus merged commit 3ab16b7 into HarbourMasters:develop-macready Nov 27, 2023
8 checks passed
@Malkierian Malkierian deleted the prevent-cheats-outside-game branch November 28, 2023 19:41
A-Green-Spoon pushed a commit to A-Green-Spoon/Shipwright that referenced this pull request Nov 30, 2023
…d()` in mods.cpp for all the cheats, and added the same full check to others that really didn't need to be running outside of a game (like infinite rupees, magic, health, etc), and clear any triggering CVars. (HarbourMasters#3441)

Changed `RegisterSwitchAge()` to clear the CVar instead of setting it to 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Selecting file has Link often spawning out of bounds until void out or soft reset. [Switch]
6 participants