diff --git a/src/game.cc b/src/game.cc index 1714a8e..89c3e4f 100644 --- a/src/game.cc +++ b/src/game.cc @@ -92,7 +92,7 @@ static char _aDec11199816543[] = VERSION_BUILD_TIME; static bool gGameUiDisabled = false; // 0x5186B8 -static int _game_state_cur = GAME_STATE_0; +static int gGameState = GAME_STATE_0; // 0x5186BC static bool gIsMapper = false; @@ -439,7 +439,7 @@ void gameExit() int gameHandleKey(int eventCode, bool isInCombatMode) { // NOTE: Uninline. - if (_game_state() == GAME_STATE_5) { + if (gameGetState() == GAME_STATE_5) { _gdialogSystemEnter(); } @@ -1041,48 +1041,48 @@ int globalVarsRead(const char* path, const char* section, int* variablesListLeng } // 0x443E2C -int _game_state() +int gameGetState() { - return _game_state_cur; + return gGameState; } // 0x443E34 -int _game_state_request(int a1) +int gameRequestState(int newGameState) { - if (a1 == GAME_STATE_0) { - a1 = GAME_STATE_1; - } else if (a1 == GAME_STATE_2) { - a1 = GAME_STATE_3; - } else if (a1 == GAME_STATE_4) { - a1 = GAME_STATE_5; + switch (newGameState) { + case GAME_STATE_0: + newGameState = GAME_STATE_1; + break; + case GAME_STATE_2: + newGameState = GAME_STATE_3; + break; + case GAME_STATE_4: + newGameState = GAME_STATE_5; + break; } - if (_game_state_cur != GAME_STATE_4 || a1 != GAME_STATE_5) { - _game_state_cur = a1; - return 0; + if (gGameState == GAME_STATE_4 && newGameState == GAME_STATE_5) { + return -1; } - return -1; + gGameState = newGameState; + return 0; } // 0x443E90 -void _game_state_update() +void gameUpdateState() { - int v0; - - v0 = _game_state_cur; - switch (_game_state_cur) { + switch (gGameState) { case GAME_STATE_1: - v0 = GAME_STATE_0; + gGameState = GAME_STATE_0; break; case GAME_STATE_3: - v0 = GAME_STATE_2; + gGameState = GAME_STATE_2; break; case GAME_STATE_5: - v0 = GAME_STATE_4; + gGameState = GAME_STATE_4; + break; } - - _game_state_cur = v0; } // 0x443EF0 diff --git a/src/game.h b/src/game.h index 992958e..c8db879 100644 --- a/src/game.h +++ b/src/game.h @@ -34,9 +34,9 @@ bool gameUiIsDisabled(); int gameGetGlobalVar(int var); int gameSetGlobalVar(int var, int value); int globalVarsRead(const char* path, const char* section, int* variablesListLengthPtr, int** variablesListPtr); -int _game_state(); -int _game_state_request(int a1); -void _game_state_update(); +int gameGetState(); +int gameRequestState(int newGameState); +void gameUpdateState(); int showQuitConfirmationDialog(); int gameShowDeathDialog(const char* message); diff --git a/src/game_dialog.cc b/src/game_dialog.cc index fee42e6..e6a1c17 100644 --- a/src/game_dialog.cc +++ b/src/game_dialog.cc @@ -792,7 +792,7 @@ void gameDialogEnter(Object* speaker, int a2) // 0x444FE4 void _gdialogSystemEnter() { - _game_state_update(); + gameUpdateState(); _gdDialogTurnMouseOff = true; @@ -808,9 +808,9 @@ void _gdialogSystemEnter() _tile_scroll_to(gGameDialogOldCenterTile, 2); } - _game_state_request(GAME_STATE_2); + gameRequestState(GAME_STATE_2); - _game_state_update(); + gameUpdateState(); } // 0x445050 diff --git a/src/interpreter_extra.cc b/src/interpreter_extra.cc index 575f389..f33cf48 100644 --- a/src/interpreter_extra.cc +++ b/src/interpreter_extra.cc @@ -2699,7 +2699,7 @@ static void opGameDialogSystemEnter(Program* program) return; } - if (_game_state_request(GAME_STATE_4) == -1) { + if (gameRequestState(GAME_STATE_4) == -1) { return; } diff --git a/src/inventory.cc b/src/inventory.cc index 720866e..52a5bd3 100644 --- a/src/inventory.cc +++ b/src/inventory.cc @@ -599,7 +599,7 @@ void inventoryOpen() _display_body(-1, INVENTORY_WINDOW_TYPE_NORMAL); - if (_game_state() == GAME_STATE_5) { + if (gameGetState() == GAME_STATE_5) { break; } diff --git a/src/scripts.cc b/src/scripts.cc index d993c16..43bb711 100644 --- a/src/scripts.cc +++ b/src/scripts.cc @@ -746,7 +746,7 @@ static void _script_chk_timed_events() v1 = true; } - if (_game_state() != GAME_STATE_4) { + if (gameGetState() != GAME_STATE_4) { if (getTicksBetween(v0, _last_light_time) >= 30000) { _last_light_time = v0; scriptsExecMapUpdateScripts(SCRIPT_PROC_MAP_UPDATE);