mirror of
https://github.com/diamante0018/BlackOpsPlugin.git
synced 2025-04-21 10:45:43 +00:00
Minor refactor
This commit is contained in:
parent
c6cb8257d5
commit
eec738e129
@ -60,7 +60,7 @@ void client_command(int client_number) {
|
|||||||
class component final : public component_interface {
|
class component final : public component_interface {
|
||||||
public:
|
public:
|
||||||
void post_unpack() override {
|
void post_unpack() override {
|
||||||
utils::hook::call(SELECT(0x58DA1C, 0x4FB3BD), client_command);
|
utils::hook::call(SELECT_VALUE(0x58DA1C, 0x4FB3BD), client_command);
|
||||||
|
|
||||||
add_chat_commands();
|
add_chat_commands();
|
||||||
}
|
}
|
||||||
|
@ -69,12 +69,12 @@ void __declspec(naked) jump_start_sp_stub() {
|
|||||||
class component final : public component_interface {
|
class component final : public component_interface {
|
||||||
public:
|
public:
|
||||||
void post_unpack() override {
|
void post_unpack() override {
|
||||||
if (game::environment::t5mp()) {
|
if (game::environment::is_mp()) {
|
||||||
jump_height = reinterpret_cast<game::dvar_s**>(0xC4F7D8);
|
jump_height = reinterpret_cast<game::dvar_s**>(0xC4F7D8);
|
||||||
utils::hook::jump(0x5CE92F, jump_start_mp_stub);
|
utils::hook::jump(0x5CE92F, jump_start_mp_stub);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game::environment::t5zm()) {
|
if (game::environment::is_sp()) {
|
||||||
player_sustainAmmo = reinterpret_cast<game::dvar_s**>(0xBCD250);
|
player_sustainAmmo = reinterpret_cast<game::dvar_s**>(0xBCD250);
|
||||||
pm_weapon_use_ammo_hook.create(0x6979B0, &pm_weapon_use_ammo_stub);
|
pm_weapon_use_ammo_hook.create(0x6979B0, &pm_weapon_use_ammo_stub);
|
||||||
|
|
||||||
@ -83,8 +83,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
player_sprintStrafeSpeedScale =
|
player_sprintStrafeSpeedScale =
|
||||||
reinterpret_cast<game::dvar_s**>(SELECT(0xC51AE8, 0xBCD18C));
|
reinterpret_cast<game::dvar_s**>(SELECT_VALUE(0xC51AE8, 0xBCD18C));
|
||||||
utils::hook::jump(SELECT(0x6344B0, 0x611BC0),
|
utils::hook::jump(SELECT_VALUE(0x6344B0, 0x611BC0),
|
||||||
bg_get_sprint_strafe_speed_scale_stub);
|
bg_get_sprint_strafe_speed_scale_stub);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
21
src/client/component/gsc_patches.cpp
Normal file
21
src/client/component/gsc_patches.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include <std_include.hpp>
|
||||||
|
|
||||||
|
#include "../loader/component_loader.hpp"
|
||||||
|
#include <utils/hook.hpp>
|
||||||
|
|
||||||
|
namespace gsc_patches {
|
||||||
|
namespace {
|
||||||
|
void g_log_printf(const char* fmt) { game::G_LogPrintf("%s", fmt); }
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
class component final : public component_interface {
|
||||||
|
public:
|
||||||
|
void post_unpack() override {
|
||||||
|
if (game::environment::is_mp()) {
|
||||||
|
utils::hook::call(0x8426D3, g_log_printf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace gsc_patches
|
||||||
|
|
||||||
|
REGISTER_COMPONENT(gsc_patches::component)
|
@ -6,8 +6,8 @@ gamemode current = reinterpret_cast<const char*>(0xA6840C) == "multiplayer"s
|
|||||||
: gamemode::zombies;
|
: gamemode::zombies;
|
||||||
|
|
||||||
namespace environment {
|
namespace environment {
|
||||||
bool t5mp() { return current == gamemode::multiplayer; }
|
bool is_mp() { return current == gamemode::multiplayer; }
|
||||||
|
|
||||||
bool t5zm() { return current == gamemode::zombies; }
|
bool is_sp() { return current == gamemode::zombies; }
|
||||||
} // namespace environment
|
} // namespace environment
|
||||||
} // namespace game
|
} // namespace game
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define SELECT(mp, zm) (game::environment::t5mp() ? mp : zm)
|
#define SELECT_VALUE(mp, zm) (game::environment::is_mp() ? (mp) : (zm))
|
||||||
|
|
||||||
namespace game {
|
namespace game {
|
||||||
enum gamemode { none, multiplayer, zombies };
|
enum gamemode { none, multiplayer, zombies };
|
||||||
@ -8,8 +8,8 @@ enum gamemode { none, multiplayer, zombies };
|
|||||||
extern gamemode current;
|
extern gamemode current;
|
||||||
|
|
||||||
namespace environment {
|
namespace environment {
|
||||||
bool t5mp();
|
bool is_mp();
|
||||||
bool t5zm();
|
bool is_sp();
|
||||||
} // namespace environment
|
} // namespace environment
|
||||||
|
|
||||||
template <typename T> class symbol {
|
template <typename T> class symbol {
|
||||||
@ -17,8 +17,8 @@ public:
|
|||||||
symbol(const size_t t5mp, const size_t t5zm)
|
symbol(const size_t t5mp, const size_t t5zm)
|
||||||
: t5mp_(reinterpret_cast<T*>(t5mp)), t5zm_(reinterpret_cast<T*>(t5zm)) {}
|
: t5mp_(reinterpret_cast<T*>(t5mp)), t5zm_(reinterpret_cast<T*>(t5zm)) {}
|
||||||
|
|
||||||
T* get() const {
|
[[nodiscard]] T* get() const {
|
||||||
if (environment::t5mp()) {
|
if (environment::is_mp()) {
|
||||||
return t5mp_;
|
return t5mp_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,8 +58,10 @@ WEAK symbol<char*(char*)> I_CleanStr{0x4B0700, 0x0};
|
|||||||
|
|
||||||
WEAK symbol<char*(int)> ConcatArgs{0x5D5F10, 0x4FB210};
|
WEAK symbol<char*(int)> ConcatArgs{0x5D5F10, 0x4FB210};
|
||||||
WEAK symbol<void(int)> ClientCommand{0x63DB70, 0x4AF770};
|
WEAK symbol<void(int)> ClientCommand{0x63DB70, 0x4AF770};
|
||||||
|
|
||||||
WEAK symbol<void(gentity_s*, gentity_s*, int, const char*)> G_Say{0x51BBD0,
|
WEAK symbol<void(gentity_s*, gentity_s*, int, const char*)> G_Say{0x51BBD0,
|
||||||
0x49A790};
|
0x49A790};
|
||||||
|
WEAK symbol<void(const char* fmt, ...)> G_LogPrintf{0x5CD250, 0x69EA30};
|
||||||
|
|
||||||
WEAK symbol<void(gentity_s*, unsigned __int16, unsigned int)> Scr_Notify{
|
WEAK symbol<void(gentity_s*, unsigned __int16, unsigned int)> Scr_Notify{
|
||||||
0x458D30, 0x0};
|
0x458D30, 0x0};
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define BINARY_PAYLOAD_SIZE 0x0A000000
|
|
||||||
#define TLS_PAYLOAD_SIZE 0x2000
|
|
||||||
|
|
||||||
#define DLL_EXPORT extern "C" __declspec(dllexport)
|
#define DLL_EXPORT extern "C" __declspec(dllexport)
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
Loading…
x
Reference in New Issue
Block a user