Skip to content

Commit

Permalink
Load Gmod's CUserMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelIT7 committed May 14, 2024
1 parent c845570 commit a03163c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions source/detours.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ extern TGetAmmoDef func_GetAmmoDef;
const Symbol GetAmmoDefSym = Symbol::FromName("_Z10GetAmmoDefv");

const Symbol CGameRules_Sym = Symbol::FromName("g_pGameRules");
const Symbol CUserMessages_Sym = Symbol::FromName("usermessages");

/*
CLuaGameCallback stuff
Expand Down
7 changes: 7 additions & 0 deletions source/lua_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ void InitInterfaces()
server_loader, CGameRules_Sym
);
}

if (usermessages == nullptr)
{
usermessages = ResolveSymbol<CUserMessages>(
server_loader, CUserMessages_Sym
);
}
}

int interfaces_count = 0;
Expand Down
4 changes: 2 additions & 2 deletions source/source_usermessages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,6 @@ bool CUserMessages::DispatchUserMessage( int msg_type, bf_read &msg_data )
}

// Singleton
static CUserMessages g_UserMessages;
//static CUserMessages g_UserMessages;
// Expose to rest of .dll
CUserMessages *usermessages = &g_UserMessages;
CUserMessages *usermessages = nullptr; //&g_UserMessages;

0 comments on commit a03163c

Please sign in to comment.