From 3b5979bbe2432c1adba3a87dd2d4f76c310f3976 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Fri, 1 Jul 2022 22:24:13 +0200 Subject: [PATCH] Fix spectator bug --- src/client/component/patches.cpp | 6 ++++++ src/client/game/structs.hpp | 27 +++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/client/component/patches.cpp b/src/client/component/patches.cpp index f9ef180d..ef6a6b7d 100644 --- a/src/client/component/patches.cpp +++ b/src/client/component/patches.cpp @@ -123,6 +123,12 @@ namespace patches const auto menu_id = atoi(params.get(1)); const auto client = &svs_clients[ent->s.entityNum]; + // 13 => change class + if (menu_id == 13 && ent->client->team == game::mp::TEAM_SPECTATOR) + { + return; + } + // 32 => "end_game" if (menu_id == 32 && client->header.remoteAddress.type != game::NA_LOOPBACK) { diff --git a/src/client/game/structs.hpp b/src/client/game/structs.hpp index 7ea4d8b4..02ee96aa 100644 --- a/src/client/game/structs.hpp +++ b/src/client/game/structs.hpp @@ -1519,16 +1519,39 @@ namespace game int usesDelta; }; + enum sessionState_t + { + SESS_STATE_PLAYING = 0x0, + SESS_STATE_DEAD = 0x1, + SESS_STATE_SPECTATOR = 0x2, + SESS_STATE_INTERMISSION = 0x3, + }; + + enum team_t + { + TEAM_FREE = 0x0, + TEAM_BAD = 0x0, + TEAM_AXIS = 0x1, + TEAM_ALLIES = 0x2, + TEAM_SPECTATOR = 0x3, + TEAM_NUM_TEAMS = 0x4, + }; + struct gclient_s { char __pad0[2]; char pm_type; // 2 - char __pad1[18831]; + char __pad1[18573]; + sessionState_t sessionState; + char __pad2[220]; // 254 + team_t team; + char __pad3[30]; char name[32]; // 18834 - char __pad2[622]; + char __pad4[622]; int flags; // 19488 }; // size = ? + static_assert(offsetof(gclient_s, team) == 18800); static_assert(offsetof(gclient_s, name) == 18834); static_assert(offsetof(gclient_s, flags) == 19488);