fix: added serverinfo struct

This commit is contained in:
Jari van der Kaap 2023-04-10 16:37:32 +02:00
parent d31fe6e855
commit 51582936c4
3 changed files with 32 additions and 6 deletions

View File

@ -15,7 +15,7 @@ namespace server_list
{ {
namespace namespace
{ {
utils::hook::detour lua_gameitem_to_table_hook; utils::hook::detour lua_serverinfo_to_table_hook;
struct state struct state
{ {
@ -77,13 +77,13 @@ namespace server_list
callback(true, result); callback(true, result);
} }
void lua_gameitem_to_table_stub(game::hks::lua_State* state, __int64 gameItem, int index) void lua_serverinfo_to_table_stub(game::hks::lua_State* state, game::ServerInfo serverInfo, int index)
{ {
lua_gameitem_to_table_hook.invoke(state, gameItem, index); lua_serverinfo_to_table_hook.invoke(state, serverInfo, index);
if (state) if (state)
{ {
auto botCount = atoi(game::Info_ValueForKey(gameItem + 276, "bots")); auto botCount = atoi(game::Info_ValueForKey(serverInfo.tags, "bots"));
game::Lua_SetTableInt("botCount", botCount, state); game::Lua_SetTableInt("botCount", botCount, state);
} }
} }
@ -147,7 +147,7 @@ namespace server_list
}); });
}, scheduler::async, 200ms); }, scheduler::async, 200ms);
lua_gameitem_to_table_hook.create(0x141F1FD10_g, lua_gameitem_to_table_stub); lua_serverinfo_to_table_hook.create(0x141F1FD10_g, lua_serverinfo_to_table_stub);
} }
void pre_destroy() override void pre_destroy() override

View File

@ -1032,6 +1032,32 @@ namespace game
Agreement debugAgreement; Agreement debugAgreement;
JoinType joinType; JoinType joinType;
JoinResult joinResult; JoinResult joinResult;
};
struct ServerInfo
{
uint16_t m_usConnectionPort;
uint16_t m_usQueryPort;
uint32_t m_unIP;
int m_nPing;
byte unk[0x22];
char mapname[32];
char description[64];
char gamemode[16];
char modname[32];
int playerCount;
int maxPlayers;
int unk2;
int unk3;
int unk4;
bool dedicated;
bool ranked;
bool hardcore;
bool zombies;
char servername[64];
char tags[128];
int unk5;
int unk6;
}; };
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -76,7 +76,7 @@ namespace game
WEAK symbol<bool(uint64_t, int*, bool)> Live_GetConnectivityInformation{0x141E0C380}; WEAK symbol<bool(uint64_t, int*, bool)> Live_GetConnectivityInformation{0x141E0C380};
// Info // Info
WEAK symbol<const char* (__int64, const char* key)> Info_ValueForKey{ 0x1422E87B0 }; WEAK symbol<const char* (const char*, const char* key)> Info_ValueForKey{ 0x1422E87B0 };
// MSG // MSG
WEAK symbol<uint8_t(msg_t* msg)> MSG_ReadByte{0x142155450, 0x14050D1B0}; WEAK symbol<uint8_t(msg_t* msg)> MSG_ReadByte{0x142155450, 0x14050D1B0};