From 51582936c4f853adf7e418ea9c29818d69e52ef1 Mon Sep 17 00:00:00 2001 From: Jari van der Kaap Date: Mon, 10 Apr 2023 16:37:32 +0200 Subject: [PATCH] fix: added serverinfo struct --- src/client/component/server_list.cpp | 10 +++++----- src/client/game/structs.hpp | 26 ++++++++++++++++++++++++++ src/client/game/symbols.hpp | 2 +- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/client/component/server_list.cpp b/src/client/component/server_list.cpp index ab0d291f..7c0ca6ad 100644 --- a/src/client/component/server_list.cpp +++ b/src/client/component/server_list.cpp @@ -15,7 +15,7 @@ namespace server_list { namespace { - utils::hook::detour lua_gameitem_to_table_hook; + utils::hook::detour lua_serverinfo_to_table_hook; struct state { @@ -77,13 +77,13 @@ namespace server_list 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) { - auto botCount = atoi(game::Info_ValueForKey(gameItem + 276, "bots")); + auto botCount = atoi(game::Info_ValueForKey(serverInfo.tags, "bots")); game::Lua_SetTableInt("botCount", botCount, state); } } @@ -147,7 +147,7 @@ namespace server_list }); }, 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 diff --git a/src/client/game/structs.hpp b/src/client/game/structs.hpp index ca9b7904..57d38e2c 100644 --- a/src/client/game/structs.hpp +++ b/src/client/game/structs.hpp @@ -1032,6 +1032,32 @@ namespace game Agreement debugAgreement; JoinType joinType; 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 diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index 820d68c6..205c0348 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -76,7 +76,7 @@ namespace game WEAK symbol Live_GetConnectivityInformation{0x141E0C380}; // Info - WEAK symbol Info_ValueForKey{ 0x1422E87B0 }; + WEAK symbol Info_ValueForKey{ 0x1422E87B0 }; // MSG WEAK symbol MSG_ReadByte{0x142155450, 0x14050D1B0};