mirror of
https://github.com/diamante0018/BlackOpsPlugin.git
synced 2025-04-20 02:22:52 +00:00
fix status on mp
This commit is contained in:
parent
a740236858
commit
e4c5748fc1
@ -1,93 +0,0 @@
|
|||||||
#include <std_include.hpp>
|
|
||||||
#include "loader/component_loader.hpp"
|
|
||||||
|
|
||||||
#include <utils/hook.hpp>
|
|
||||||
|
|
||||||
namespace gameplay {
|
|
||||||
namespace {
|
|
||||||
game::dvar_s** player_sustainAmmo = nullptr;
|
|
||||||
game::dvar_s** player_sprintStrafeSpeedScale = nullptr;
|
|
||||||
|
|
||||||
game::dvar_s** jump_height = nullptr;
|
|
||||||
|
|
||||||
utils::hook::detour pm_weapon_use_ammo_hook;
|
|
||||||
|
|
||||||
void pm_weapon_use_ammo_stub(void* ps, int wp, int amount) {
|
|
||||||
if (!(*player_sustainAmmo)->current.enabled) {
|
|
||||||
pm_weapon_use_ammo_hook.invoke<void>(ps, wp, amount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void __declspec(naked) bg_get_sprint_strafe_speed_scale_stub() {
|
|
||||||
__asm {
|
|
||||||
push eax
|
|
||||||
|
|
||||||
mov eax, player_sprintStrafeSpeedScale
|
|
||||||
mov eax, [eax] // Access pointer
|
|
||||||
fld dword ptr [eax + 0x18] // dvar_s.current.value
|
|
||||||
|
|
||||||
pop eax
|
|
||||||
ret
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void __declspec(naked) jump_start_mp_stub() {
|
|
||||||
static DWORD func = 0x7AEF10;
|
|
||||||
|
|
||||||
__asm {
|
|
||||||
mov esi, jump_height
|
|
||||||
mov esi, [esi] // Access pointer
|
|
||||||
movss xmm0, dword ptr [esi + 0x18] // dvar_s.current.value
|
|
||||||
|
|
||||||
// Game's code
|
|
||||||
mov ecx, ebp
|
|
||||||
mov esi, ebx
|
|
||||||
|
|
||||||
push 0x5CE940 // return address
|
|
||||||
jmp func
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void __declspec(naked) jump_start_sp_stub() {
|
|
||||||
static DWORD func = 0x75BDD0;
|
|
||||||
|
|
||||||
__asm {
|
|
||||||
mov esi, jump_height
|
|
||||||
mov esi, [esi] // Access pointer
|
|
||||||
movss xmm0, dword ptr [esi + 0x18] // dvar_s.current.value
|
|
||||||
|
|
||||||
// Game's code
|
|
||||||
mov edx, ebp
|
|
||||||
mov esi, ebx
|
|
||||||
|
|
||||||
push 0x5D0440 // return address
|
|
||||||
jmp func
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
class component final : public component_interface {
|
|
||||||
public:
|
|
||||||
void post_unpack() override {
|
|
||||||
if (game::environment::is_mp()) {
|
|
||||||
jump_height = reinterpret_cast<game::dvar_s**>(0xC4F7D8);
|
|
||||||
utils::hook::jump(0x5CE92F, jump_start_mp_stub);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (game::environment::is_sp()) {
|
|
||||||
player_sustainAmmo = reinterpret_cast<game::dvar_s**>(0xBCD250);
|
|
||||||
pm_weapon_use_ammo_hook.create(0x6979B0, &pm_weapon_use_ammo_stub);
|
|
||||||
|
|
||||||
jump_height = reinterpret_cast<game::dvar_s**>(0xBCAE58);
|
|
||||||
utils::hook::jump(0x5D042F, jump_start_sp_stub);
|
|
||||||
}
|
|
||||||
|
|
||||||
player_sprintStrafeSpeedScale =
|
|
||||||
reinterpret_cast<game::dvar_s**>(SELECT_VALUE(0xC51AE8, 0xBCD18C));
|
|
||||||
utils::hook::jump(SELECT_VALUE(0x6344B0, 0x611BC0),
|
|
||||||
bg_get_sprint_strafe_speed_scale_stub);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace gameplay
|
|
||||||
|
|
||||||
REGISTER_COMPONENT(gameplay::component)
|
|
139
src/client/component/patches.cpp
Normal file
139
src/client/component/patches.cpp
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
#include <std_include.hpp>
|
||||||
|
#include "loader/component_loader.hpp"
|
||||||
|
|
||||||
|
#include "game/structs.hpp"
|
||||||
|
#include "game/game.hpp"
|
||||||
|
|
||||||
|
#include <utils/hook.hpp>
|
||||||
|
#include <utils/string.hpp>
|
||||||
|
|
||||||
|
namespace patches {
|
||||||
|
namespace {
|
||||||
|
int client_num_;
|
||||||
|
std::string status_;
|
||||||
|
|
||||||
|
void server_status_basic_print([[maybe_unused]] const int channel,
|
||||||
|
const char* fmt) {
|
||||||
|
status_.append(fmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void server_status_map_print([[maybe_unused]] const int channel,
|
||||||
|
const char* fmt, const char* map) {
|
||||||
|
status_.append(utils::string::va(fmt, map));
|
||||||
|
}
|
||||||
|
|
||||||
|
void server_status_header_print([[maybe_unused]] const int channel,
|
||||||
|
[[maybe_unused]] const char* fmt) {
|
||||||
|
status_.append("num score bot ping guid name "
|
||||||
|
"lastmsg address qport rate\n");
|
||||||
|
}
|
||||||
|
void server_status_body_print([[maybe_unused]] const int channel,
|
||||||
|
[[maybe_unused]] const char* fmt) {
|
||||||
|
status_.append("--- ----- --- ---- ---------- --------------- ------- "
|
||||||
|
"--------------------- ------ -----\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void server_status_client_number_print([[maybe_unused]] const int channel,
|
||||||
|
const char* fmt, const int client_num) {
|
||||||
|
client_num_ = client_num;
|
||||||
|
status_.append(utils::string::va(fmt, client_num));
|
||||||
|
}
|
||||||
|
|
||||||
|
void server_status_score_print([[maybe_unused]] const int channel,
|
||||||
|
const char* fmt, const int score) {
|
||||||
|
status_.append(utils::string::va(fmt, score));
|
||||||
|
status_.append(utils::string::va("%3i ", game::SV_IsTestClient(client_num_)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void server_status_ping_print([[maybe_unused]] const int channel,
|
||||||
|
const char* fmt, const int ping) {
|
||||||
|
status_.append(utils::string::va(fmt, ping));
|
||||||
|
}
|
||||||
|
|
||||||
|
void server_status_guid_print([[maybe_unused]] const int channel,
|
||||||
|
const char* fmt, const int guid) {
|
||||||
|
status_.append(utils::string::va(fmt, guid));
|
||||||
|
}
|
||||||
|
|
||||||
|
void server_status_name_print([[maybe_unused]] const int channel,
|
||||||
|
const char* fmt, const char* name) {
|
||||||
|
status_.append(utils::string::va(fmt, name));
|
||||||
|
}
|
||||||
|
|
||||||
|
void server_status_last_msg_print([[maybe_unused]] const int channel,
|
||||||
|
const char* fmt, const int last_msg) {
|
||||||
|
status_.append(utils::string::va(fmt, last_msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
void server_status_address_print([[maybe_unused]] const int channel,
|
||||||
|
const char* fmt, const char* address) {
|
||||||
|
status_.append(utils::string::va(fmt, address));
|
||||||
|
}
|
||||||
|
|
||||||
|
void server_status_qport_print([[maybe_unused]] const int channel,
|
||||||
|
const char* fmt, const int qport) {
|
||||||
|
status_.append(utils::string::va(fmt, qport));
|
||||||
|
}
|
||||||
|
|
||||||
|
void server_status_rate_print([[maybe_unused]] const int channel,
|
||||||
|
const char* fmt, const int rate) {
|
||||||
|
status_.append(utils::string::va(fmt, rate));
|
||||||
|
}
|
||||||
|
|
||||||
|
void server_status_terminating_print([[maybe_unused]] const int channel,
|
||||||
|
const char* fmt) {
|
||||||
|
status_.append(fmt); // final new line
|
||||||
|
game::Com_Printf(game::CON_CHANNEL_DONT_FILTER, "%s", status_.data());
|
||||||
|
|
||||||
|
// clear the buffer
|
||||||
|
status_.clear();
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
class component final : public component_interface {
|
||||||
|
public:
|
||||||
|
void post_unpack() override {
|
||||||
|
if (game::environment::is_sp()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
utils::hook::call(0x8760E2, server_status_map_print);
|
||||||
|
|
||||||
|
utils::hook::call(0x8760EE, server_status_header_print);
|
||||||
|
|
||||||
|
utils::hook::call(0x8760FA, server_status_body_print);
|
||||||
|
|
||||||
|
utils::hook::call(0x876131, server_status_client_number_print);
|
||||||
|
|
||||||
|
utils::hook::call(0x876165, server_status_score_print);
|
||||||
|
|
||||||
|
utils::hook::call(0x87617B, server_status_basic_print); // connecting print
|
||||||
|
|
||||||
|
utils::hook::call(0x876191, server_status_basic_print); // zombie print
|
||||||
|
|
||||||
|
utils::hook::call(0x8761B5, server_status_ping_print);
|
||||||
|
|
||||||
|
utils::hook::call(0x8761CB, server_status_guid_print);
|
||||||
|
|
||||||
|
utils::hook::call(0x8761DE, server_status_name_print);
|
||||||
|
|
||||||
|
utils::hook::call(0x876207, server_status_basic_print); // space print
|
||||||
|
|
||||||
|
utils::hook::call(0x876227, server_status_last_msg_print);
|
||||||
|
|
||||||
|
utils::hook::call(0x876251, server_status_address_print);
|
||||||
|
|
||||||
|
utils::hook::call(0x876287, server_status_basic_print); // space print
|
||||||
|
|
||||||
|
utils::hook::call(0x87629F, server_status_qport_print);
|
||||||
|
|
||||||
|
utils::hook::call(0x8762B2, server_status_rate_print);
|
||||||
|
|
||||||
|
utils::hook::call(0x8762BE, server_status_basic_print); // new line print
|
||||||
|
|
||||||
|
utils::hook::call(0x8762E2, server_status_terminating_print);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace patches
|
||||||
|
|
||||||
|
REGISTER_COMPONENT(patches::component)
|
@ -10,4 +10,8 @@ bool is_mp() { return current == gamemode::multiplayer; }
|
|||||||
|
|
||||||
bool is_sp() { return current == gamemode::zombies; }
|
bool is_sp() { return current == gamemode::zombies; }
|
||||||
} // namespace environment
|
} // namespace environment
|
||||||
|
|
||||||
|
bool SV_IsTestClient(int clientNum) {
|
||||||
|
return svs_clients[clientNum].bIsTestClient == 1;
|
||||||
|
}
|
||||||
} // namespace game
|
} // namespace game
|
||||||
|
@ -34,6 +34,7 @@ private:
|
|||||||
T* t5zm_;
|
T* t5zm_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern bool SV_IsTestClient(int clientNum);
|
||||||
} // namespace game
|
} // namespace game
|
||||||
|
|
||||||
#include "symbols.hpp"
|
#include "symbols.hpp"
|
||||||
|
@ -491,8 +491,11 @@ struct client_s {
|
|||||||
char name[32]; // 21872
|
char name[32]; // 21872
|
||||||
char clanAbbrev[5]; // 21904
|
char clanAbbrev[5]; // 21904
|
||||||
unsigned __int64 xuid; // 21912
|
unsigned __int64 xuid; // 21912
|
||||||
unsigned char __pad0[0x76D48];
|
char __pad0[0x54FB0];
|
||||||
|
int bIsTestClient;
|
||||||
|
unsigned char __pad1[0x21D90];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static_assert(offsetof(client_s, bIsTestClient) == 0x5A550);
|
||||||
static_assert(sizeof(client_s) == 0x7C2E8);
|
static_assert(sizeof(client_s) == 0x7C2E8);
|
||||||
} // namespace game
|
} // namespace game
|
||||||
|
Loading…
x
Reference in New Issue
Block a user