diff --git a/src/launcher/launcher.cpp b/src/launcher/launcher.cpp index 4fc0fbb..fc0c5b2 100644 --- a/src/launcher/launcher.cpp +++ b/src/launcher/launcher.cpp @@ -1,6 +1,7 @@ #include +#include + #include "launcher.hpp" -#include "utils/nt.hpp" launcher::launcher() { diff --git a/src/loader/binary_loader.cpp b/src/loader/binary_loader.cpp index 7d25cd3..d67ec87 100644 --- a/src/loader/binary_loader.cpp +++ b/src/loader/binary_loader.cpp @@ -1,10 +1,11 @@ #include +#include +#include +#include +#include +#include + #include "binary_loader.hpp" -#include "utils/nt.hpp" -#include "utils/io.hpp" -#include "utils/cryptography.hpp" -#include "utils/string.hpp" -#include "utils/compression.hpp" #define DEDI_HASH "F271C305117B79242E254E9F64BD5AA2993CAC8E57975243EBD44CD576418D20" diff --git a/src/loader/loader.cpp b/src/loader/loader.cpp index 38089ae..1e2e5e2 100644 --- a/src/loader/loader.cpp +++ b/src/loader/loader.cpp @@ -1,7 +1,8 @@ #include +#include + #include "loader.hpp" #include "binary_loader.hpp" -#include "utils/string.hpp" loader::loader(const launcher::mode mode) : mode_(mode) { diff --git a/src/loader/loader.hpp b/src/loader/loader.hpp index 10307b3..ae9461f 100644 --- a/src/loader/loader.hpp +++ b/src/loader/loader.hpp @@ -1,6 +1,6 @@ #pragma once -#include "utils/nt.hpp" -#include "launcher/launcher.hpp" +#include +#include class loader final { diff --git a/src/main.cpp b/src/main.cpp index 92447a5..3d2731e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ -#include +#include "std_include.hpp" #include "launcher/launcher.hpp" #include "loader/loader.hpp" #include "loader/module_loader.hpp" diff --git a/src/module/ceg.cpp b/src/module/ceg.cpp index ba1d851..29274fc 100644 --- a/src/module/ceg.cpp +++ b/src/module/ceg.cpp @@ -1,6 +1,7 @@ #include -#include "loader/module_loader.hpp" -#include "utils/hook.hpp" +#include +#include + #include "game/game.hpp" class ceg final : public module diff --git a/src/module/client_command.cpp b/src/module/client_command.cpp index 7236959..cb30cdc 100644 --- a/src/module/client_command.cpp +++ b/src/module/client_command.cpp @@ -1,9 +1,9 @@ #include -#include "loader/module_loader.hpp" -#include "command.hpp" -#include "game/game.hpp" +#include +#include -#include "utils/string.hpp" +#include "game/game.hpp" +#include "command.hpp" class client_command final : public module { diff --git a/src/module/command.cpp b/src/module/command.cpp index 2b4e78a..3a83b86 100644 --- a/src/module/command.cpp +++ b/src/module/command.cpp @@ -1,8 +1,12 @@ #include -#include "command.hpp" +#include +#include +#include -#include "utils/string.hpp" -#include "utils/hook.hpp" +#include "game/structs.hpp" +#include "game/game.hpp" + +#include "command.hpp" utils::memory::allocator command::allocator_; std::unordered_map> command::handlers; diff --git a/src/module/command.hpp b/src/module/command.hpp index 6f22252..f274609 100644 --- a/src/module/command.hpp +++ b/src/module/command.hpp @@ -1,10 +1,5 @@ #pragma once -#include "loader/module_loader.hpp" - -#include "game/structs.hpp" -#include "game/game.hpp" - -#include "utils/memory.hpp" +#include class command final : public module { diff --git a/src/module/console.cpp b/src/module/console.cpp index 47d9cda..920aa54 100644 --- a/src/module/console.cpp +++ b/src/module/console.cpp @@ -1,5 +1,6 @@ #include -#include "loader/module_loader.hpp" +#include + #include "game/game.hpp" #include "scheduler.hpp" diff --git a/src/module/discord.cpp b/src/module/discord.cpp index cc8f4ad..e76a8a8 100644 --- a/src/module/discord.cpp +++ b/src/module/discord.cpp @@ -1,8 +1,10 @@ #include +#include + #include -#include "loader/module_loader.hpp" -#include "scheduler.hpp" + #include "game/game.hpp" +#include "scheduler.hpp" class discord final : public module { diff --git a/src/module/dw.cpp b/src/module/dw.cpp index b68c45b..c7c2276 100644 --- a/src/module/dw.cpp +++ b/src/module/dw.cpp @@ -1,9 +1,7 @@ #include -#include "dw.hpp" -#include "utils/hook.hpp" -#include "game/game.hpp" -#include "utils/nt.hpp" -#include "utils/cryptography.hpp" +#include +#include +#include #include "game/demonware/services/bdLSGHello.hpp" // 7 #include "game/demonware/services/bdStorage.hpp" // 10 @@ -13,6 +11,9 @@ #include "game/demonware/services/bdDediRSAAuth.hpp" // 26 #include "game/demonware/services/bdSteamAuth.hpp" // 28 +#include "game/game.hpp" +#include "dw.hpp" + namespace demonware { namespace io diff --git a/src/module/dw.hpp b/src/module/dw.hpp index dfe7335..fd3997a 100644 --- a/src/module/dw.hpp +++ b/src/module/dw.hpp @@ -1,5 +1,6 @@ #pragma once -#include "loader/module_loader.hpp" +#include + #include "game/demonware/stun_server.hpp" #include "game/demonware/service_server.hpp" diff --git a/src/module/fastfiles.cpp b/src/module/fastfiles.cpp index b089166..7907b4e 100644 --- a/src/module/fastfiles.cpp +++ b/src/module/fastfiles.cpp @@ -1,7 +1,8 @@ #include -#include "loader/module_loader.hpp" +#include +#include + #include "game/game.hpp" -#include "utils/hook.hpp" static __declspec(naked) void db_load_stub_client(game::native::XZoneInfo*, unsigned int, int) { diff --git a/src/module/fov.cpp b/src/module/fov.cpp index 2958b12..19ae102 100644 --- a/src/module/fov.cpp +++ b/src/module/fov.cpp @@ -1,6 +1,7 @@ #include -#include "loader/module_loader.hpp" -#include "utils/hook.hpp" +#include +#include + #include "game/game.hpp" class fov final : public module diff --git a/src/module/game_launcher.cpp b/src/module/game_launcher.cpp index 65e1496..85f7993 100644 --- a/src/module/game_launcher.cpp +++ b/src/module/game_launcher.cpp @@ -1,7 +1,7 @@ #include -#include "loader/module_loader.hpp" -#include "utils/nt.hpp" -#include "utils/string.hpp" +#include +#include +#include class game_launcher final : public module { diff --git a/src/module/patches.cpp b/src/module/patches.cpp index e8dda4d..2408de0 100644 --- a/src/module/patches.cpp +++ b/src/module/patches.cpp @@ -1,6 +1,7 @@ #include -#include "loader/module_loader.hpp" -#include "utils/hook.hpp" +#include +#include + #include "game/game.hpp" class patches final : public module diff --git a/src/module/player_movement.cpp b/src/module/player_movement.cpp index 602fa9e..c2c9ac3 100644 --- a/src/module/player_movement.cpp +++ b/src/module/player_movement.cpp @@ -1,8 +1,8 @@ #include +#include +#include + #include "game/game.hpp" - -#include "utils/hook.hpp" - #include "player_movement.hpp" const game::native::dvar_t* player_movement::player_sustainAmmo; @@ -13,6 +13,7 @@ const game::native::dvar_t* player_movement::jump_height; const game::native::dvar_t* player_movement::jump_stepSize; const game::native::dvar_t* player_movement::jump_spreadAdd; const game::native::dvar_t* player_movement::pm_bounces; +const game::native::dvar_t* player_movement::pm_bouncesAllAngles; const game::native::dvar_t* player_movement::pm_playerEjection; const game::native::dvar_t* player_movement::pm_playerCollision; const game::native::dvar_t* player_movement::pm_rocketJump; @@ -309,6 +310,33 @@ __declspec(naked) void player_movement::jump_start_stub() } } +void player_movement::pm_project_velocity_stub(const float* vel_in, const float* normal, float* vel_out) +{ + const auto length_squared_2d = vel_in[0] * vel_in[0] + vel_in[1] * vel_in[1]; + + if (std::fabsf(normal[2]) < 0.001f || length_squared_2d == 0.0f) + { + vel_out[0] = vel_in[0]; + vel_out[1] = vel_in[1]; + vel_out[2] = vel_in[2]; + return; + } + + auto new_z = vel_in[0] * normal[0] + vel_in[1] * normal[1]; + new_z = -new_z / normal[2]; + + const auto length_scale = std::sqrtf((vel_in[2] * vel_in[2] + length_squared_2d) / + (new_z * new_z + length_squared_2d)); + + if (player_movement::pm_bouncesAllAngles->current.enabled + || (length_scale < 1.f || new_z < 0.f || vel_in[2] > 0.f)) + { + vel_out[0] = vel_in[0] * length_scale; + vel_out[1] = vel_in[1] * length_scale; + vel_out[2] = new_z * length_scale; + } +} + const game::native::dvar_t* player_movement::dvar_register_player_sustain_ammo(const char* dvar_name, bool value, unsigned __int16 /*flags*/, const char* description) { @@ -414,6 +442,8 @@ void player_movement::patch_mp() // Modify the hardcoded value of the spread with the value of jump_spreadAdd utils::hook(0x4166F0, &player_movement::jump_start_stub, HOOK_JUMP).install()->quick(); utils::hook::nop(0x4166F5, 1); // Nop skipped opcode + + utils::hook(0x424E0A, &player_movement::pm_project_velocity_stub, HOOK_CALL).install()->quick(); // PM_StepSlideMove } void player_movement::patch_sp() @@ -454,6 +484,8 @@ void player_movement::patch_sp() // Modify the hardcoded value of the spread with the value of jump_spreadAdd utils::hook(0x63E90A, &player_movement::jump_start_stub, HOOK_JUMP).install()->quick(); utils::hook::nop(0x63E90F, 1); // Nop skipped opcode + + utils::hook(0x43D9D1, &player_movement::pm_project_velocity_stub, HOOK_CALL).install()->quick(); // PM_StepSlideMove } void player_movement::post_load() @@ -473,6 +505,8 @@ void player_movement::post_load() player_movement::pm_bounces = game::native::Dvar_RegisterBool("pm_bounces", false, game::native::dvar_flags::DVAR_CODINFO, "CoD4 Bounces"); + player_movement::pm_bouncesAllAngles = game::native::Dvar_RegisterBool("pm_bouncesAllAngles", false, + game::native::dvar_flags::DVAR_CODINFO, "Force bounces from all angles"); player_movement::pm_playerCollision = game::native::Dvar_RegisterBool("pm_playerCollision", true, game::native::DVAR_CODINFO, "Push intersecting players away from each other"); player_movement::pm_elevators = game::native::Dvar_RegisterBool("pm_elevators", diff --git a/src/module/player_movement.hpp b/src/module/player_movement.hpp index b3f2cd5..24c8f8f 100644 --- a/src/module/player_movement.hpp +++ b/src/module/player_movement.hpp @@ -1,5 +1,4 @@ #pragma once -#include "loader/module_loader.hpp" class player_movement final : public module { @@ -15,6 +14,7 @@ private: static const game::native::dvar_t* jump_stepSize; static const game::native::dvar_t* jump_spreadAdd; static const game::native::dvar_t* pm_bounces; + static const game::native::dvar_t* pm_bouncesAllAngles; static const game::native::dvar_t* pm_playerEjection; static const game::native::dvar_t* pm_playerCollision; static const game::native::dvar_t* pm_rocketJump; @@ -75,6 +75,8 @@ private: static void jump_start_stub(); + static void pm_project_velocity_stub(const float* vel_in, const float* normal, float* vel_out); + static void patch_mp(); static void patch_sp(); }; diff --git a/src/module/scheduler.cpp b/src/module/scheduler.cpp index 58e316b..e3b3eba 100644 --- a/src/module/scheduler.cpp +++ b/src/module/scheduler.cpp @@ -1,8 +1,10 @@ #include -#include "scheduler.hpp" -#include "utils/string.hpp" +#include +#include +#include + #include "game/game.hpp" -#include "utils/hook.hpp" +#include "scheduler.hpp" std::mutex scheduler::mutex_; std::queue> scheduler::errors_; diff --git a/src/module/scheduler.hpp b/src/module/scheduler.hpp index 6de4541..a249c90 100644 --- a/src/module/scheduler.hpp +++ b/src/module/scheduler.hpp @@ -1,5 +1,4 @@ #pragma once -#include "loader/module_loader.hpp" #include "utils/concurrent_list.hpp" class scheduler final : public module diff --git a/src/module/scripting.cpp b/src/module/scripting.cpp index 05c78e0..8d3b263 100644 --- a/src/module/scripting.cpp +++ b/src/module/scripting.cpp @@ -1,7 +1,8 @@ #include -#include "loader/module_loader.hpp" -#include "utils/hook.hpp" -#include "utils/io.hpp" +#include +#include +#include + #include "game/scripting/context.hpp" #include "scheduler.hpp" diff --git a/src/module/security.cpp b/src/module/security.cpp index 88b57b4..07e73f3 100644 --- a/src/module/security.cpp +++ b/src/module/security.cpp @@ -1,7 +1,8 @@ #include -#include "loader/module_loader.hpp" +#include +#include + #include "game/game.hpp" -#include "utils/hook.hpp" class security final : public module { diff --git a/src/module/steam_proxy.cpp b/src/module/steam_proxy.cpp index 86d20f0..9fb3760 100644 --- a/src/module/steam_proxy.cpp +++ b/src/module/steam_proxy.cpp @@ -1,10 +1,12 @@ #include -#include "loader/module_loader.hpp" -#include "game/game.hpp" -#include "utils/nt.hpp" +#include +#include +#include + #include "steam/steam.hpp" #include "steam/interface.hpp" -#include "utils/string.hpp" + +#include "game/game.hpp" #include "scheduler.hpp" class steam_proxy final : public module diff --git a/src/module/test_clients.cpp b/src/module/test_clients.cpp index 0c69ec8..dc05d3d 100644 --- a/src/module/test_clients.cpp +++ b/src/module/test_clients.cpp @@ -1,10 +1,11 @@ #include +#include +#include +#include "game/game.hpp" #include "test_clients.hpp" #include "command.hpp" -#include "utils/hook.hpp" - bool test_clients::can_add() { auto i = 0; diff --git a/src/module/test_clients.hpp b/src/module/test_clients.hpp index 78529c9..81e1a40 100644 --- a/src/module/test_clients.hpp +++ b/src/module/test_clients.hpp @@ -1,6 +1,4 @@ #pragma once -#include "loader/module_loader.hpp" -#include "game/game.hpp" class test_clients final : public module { diff --git a/src/std_include.cpp b/src/std_include.cpp index ad0bf52..59964e2 100644 --- a/src/std_include.cpp +++ b/src/std_include.cpp @@ -1,4 +1,4 @@ -#include +#include "std_include.hpp" #pragma comment(linker, "/merge:.data=.cld") #pragma comment(linker, "/merge:.rdata=.clr") @@ -11,24 +11,25 @@ #pragma bss_seg(".payload") char payload_data[BINARY_PAYLOAD_SIZE]; -extern "C" { -int s_read_arc4random(void*, size_t) +extern "C" { - return -1; -} + int s_read_arc4random(void*, size_t) + { + return -1; + } -int s_read_getrandom(void*, size_t) -{ - return -1; -} + int s_read_getrandom(void*, size_t) + { + return -1; + } -int s_read_urandom(void*, size_t) -{ - return -1; -} + int s_read_urandom(void*, size_t) + { + return -1; + } -int s_read_ltm_rng(void*, size_t) -{ - return -1; -} + int s_read_ltm_rng(void*, size_t) + { + return -1; + } } diff --git a/src/utils/io.cpp b/src/utils/io.cpp index e09f10a..f57412f 100644 --- a/src/utils/io.cpp +++ b/src/utils/io.cpp @@ -53,7 +53,7 @@ namespace utils::io if (size > -1) { data->resize(static_cast(size)); - stream.read(const_cast(data->data()), size); + stream.read(data->data(), size); stream.close(); return true; } diff --git a/src/utils/memory.hpp b/src/utils/memory.hpp index 5a9a3d2..acf45a0 100644 --- a/src/utils/memory.hpp +++ b/src/utils/memory.hpp @@ -42,13 +42,13 @@ namespace utils static void* allocate(size_t length); template - static inline T* allocate() + static T* allocate() { return allocate_array(1); } template - static inline T* allocate_array(const size_t count = 1) + static T* allocate_array(const size_t count = 1) { return static_cast(allocate(count * sizeof(T))); } diff --git a/src/utils/nt.cpp b/src/utils/nt.cpp index 77df056..3bf7538 100644 --- a/src/utils/nt.cpp +++ b/src/utils/nt.cpp @@ -228,7 +228,7 @@ namespace utils::nt void relaunch_self() { - const utils::nt::library self; + const library self; STARTUPINFOA startup_info; PROCESS_INFORMATION process_info;