Skip to content

Fix Hard Lock - #2

Open
StarlitLuna wants to merge 1 commit into
MainMemory:masterfrom
StarlitLuna:fix-win-hardlock
Open

Fix Hard Lock#2
StarlitLuna wants to merge 1 commit into
MainMemory:masterfrom
StarlitLuna:fix-win-hardlock

Conversation

@StarlitLuna

Copy link
Copy Markdown

Change check to use gamestate instead of gamemode. Fixes #1

@MainMemory

Copy link
Copy Markdown
Owner

should probably check both to be safe

@StarlitLuna

StarlitLuna commented May 29, 2024

Copy link
Copy Markdown
Author

I don't think it's possible for you to be anywhere but inside a stage when GameState is Ingame

In the GameStateHandler that's where all the code for handling exits from stages and in game pausing takes place is when you're in the Ingame state. So the only side effect of this is that you can't instant win if the game is paused but I think that's fine personally.

       case GameStates_Ingame:
            ...
            switch ( Cheats_ExitStage )
            {
                case 8:
                    GameState = GameStates_NormalExit;
                    sub_43C340();
                    goto LABEL_369;
                case 1:
                    SetNextLevel();
                    sub_43C340();
                    if ( !HaveChaoKey
                      && (CurrentLevel < LevelIDs_CannonsCoreE || CurrentLevel > LevelIDs_CannonsCoreK)
                      && HIBYTE(word_1DEB31F) )
                    {
                        ++byte_1DEB31E;
                        byte_1DEB321 = 1;
                    }
                    goto LABEL_369;
                case 2:
                    if ( Life_Count[0] > 0 )
                    {
                        switch ( CurrentLevel )
                        {
                            case LevelIDs_CannonsCoreS:
                            case LevelIDs_CannonsCoreE:
                            case LevelIDs_CannonsCoreR:
                            case LevelIDs_CannonsCoreK:
                                if ( MissionNum != 3 )
                                {
                                    goto LABEL_59;
                                }
                                NextLevel = LevelIDs_CannonsCoreT;
                                byte_174B00D = 0;
                                HaveChaoKey = 0;
                                GameState = GameStates_Exit_3;
                                sub_43C340();
                                break;
                            case LevelIDs_KingBoomBoo:
                                dword_1A55940 = dword_1A557D8;
                                v10 = HIBYTE(dword_1A557D8);
                                LOBYTE(v10) = 0;
                                sub_426620(0, v10, 0);
                                GameState = GameStates_RestartLevel_NoLifeLost;
                                sub_43C340();
                                break;
                            default:
LABEL_59:
                                GameState = GameStates_RestartLevel_NoLifeLost;
                                sub_43C340();
                                break;
                        }
                    }
                    else
                    {
                        GameState = GameStates_NormalExit;
                        NextLevel = 0;
                        sub_43C340();
                    }
                    goto LABEL_369;
                case 3:
                    GameState = GameStates_Exit_3;
                    sub_43C340();
                    goto LABEL_369;
                case 7:
                    if ( CurrentLevel == LevelIDs_CannonsCoreS )
                    {
                        NextLevel = LevelIDs_CannonsCoreT;
                        byte_174B00D = 1;
                        GameState = GameStates_Exit_3;
                    }
                    else
                    {
                        GameState = GameStates_ReturnRing;
                    }
                    sub_43C340();
                    goto LABEL_369;
                case 4:
                    GameState = GameStates_RestartLevel_1;
                    sub_43C340();
                    goto LABEL_369;
                case 5:
                    switch ( CurrentLevel )
                    {
                        case LevelIDs_CannonsCoreS:
                        case LevelIDs_CannonsCoreE:
                        case LevelIDs_CannonsCoreR:
                        case LevelIDs_CannonsCoreK:
                            NextLevel = LevelIDs_CannonsCoreT;
                            byte_174B00D = 0;
                            HaveChaoKey = 0;
                            GameState = GameStates_Exit_3;
                            break;
                        default:
                            GameState = GameStates_NormalRestart;
                            break;
                    }
                    sub_43C340();
                    sub_437E90();
                    byte_174AFD9 = 0;
                    goto LABEL_369;
            }
            if ( v8 ) // PAUSING
            {
                PlaySoundProbably(0x8002, 0, 0, 0);
                dword_1A55940 = dword_1A557D8;
                v11 = HIBYTE(dword_1A557D8);
                GameState = GameStates_Pause;
                LOBYTE(v11) = 0;
                PauseSelection = 0;
                sub_426620(0, v11, GameStates_Inactive);
                dword_17472BC = 1;
                dword_1A558B8 = 0;
                dword_1A558BC = 0;
                MenuButtons_SomethingWasPressed = 0;
                sub_436020(v12);
                sub_439060();
                ...

Edit:
GameStateHandler also is only called within GameModes 5 and 10 which is GameMode_Level and some other mode idk about respectively

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.

Game Gets Bugged

2 participants