Skip to content

Commit

Permalink
Fixed the bug where the menu gets reset when the player jumps on MW2 …
Browse files Browse the repository at this point in the history
…Spec Ops
  • Loading branch information
ClementDreptin committed Oct 3, 2021
1 parent 0351f16 commit f9222e1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
33 changes: 26 additions & 7 deletions Hayzen/src/Games/SpecOps/MW2/MW2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
#include "Games\SpecOps\MW2\MenuFunctions.h"


//--------------------------------------------------------------------------------------
// Static members definitions
//--------------------------------------------------------------------------------------
BOOL SpecOpsMW2::s_bJumped = FALSE;


//--------------------------------------------------------------------------------------
// Name: Init()
// Desc: Set the draw function pointers and the function hooks.
Expand Down Expand Up @@ -71,16 +77,29 @@ VOID SpecOpsMW2::ClientCommandHook(INT clientNum, LPCSTR s)
// Call the original ClientCommand function
ClientCommandStub(clientNum, s);

// Register when the user pressed the A button
if (!strcmp(s, "n 7"))
s_bJumped = TRUE;

// The 'n 42' event means the game started
if (!strcmp(s, "n 42"))
{
// We have no way of knowing the game ends so, if the menu was already
// initialized, reset it first
if (s_Menu.IsInitialized())
s_Menu.Stop();

// Initialize the menu
s_Menu.Init(0, &s_RootOption);
// The 'n 42' event also occurs when the A button is released so, to avoid
// resetting the menu every time the player jumps, we need to make sure the
// 'n 7' event didn't occur just before.
if (!s_bJumped)
{
// We have no way of knowing when the game ends so, if the menu was already
// initialized, reset it first
if (s_Menu.IsInitialized())
s_Menu.Stop();

// Initialize the menu
s_Menu.Init(0, &s_RootOption);
}

// Register that the user released the A button
s_bJumped = FALSE;
}
}

Expand Down
2 changes: 2 additions & 0 deletions Hayzen/src/Games/SpecOps/MW2/MW2.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class SpecOpsMW2 : public Game
public:
virtual VOID Init();
private:
static BOOL s_bJumped;

virtual VOID CreateStructure();

static VOID ClientCommandStub(INT clientNum, LPCSTR s);
Expand Down

0 comments on commit f9222e1

Please sign in to comment.