Cleanup bad code by yours truly
This commit is contained in:
parent
7bac826c8a
commit
c80385298d
2
make.bat
2
make.bat
@ -10,7 +10,7 @@ for /F "tokens=*" %%a in ('find_my_visual_studio.exe msbuild_exe') do set msbuil
|
|||||||
|
|
||||||
echo msbuild is located at %msbuild_folder%
|
echo msbuild is located at %msbuild_folder%
|
||||||
|
|
||||||
"%msbuild_folder%\\msbuild" /property:GenerateFullPaths=true /t:build premake\workspace.sln /p:Configuration=Debug /verbosity:minimal
|
"%msbuild_folder%\\msbuild" /property:GenerateFullPaths=true /t:build premake\doghook.sln /p:Configuration=Debug /verbosity:minimal
|
||||||
|
|
||||||
echo done.
|
echo done.
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ call create_projects
|
|||||||
for /F "tokens=*" %%a in ('find_my_visual_studio.exe msbuild_exe') do set msbuild_folder=%%a
|
for /F "tokens=*" %%a in ('find_my_visual_studio.exe msbuild_exe') do set msbuild_folder=%%a
|
||||||
echo msbuild is located at %msbuild_folder%
|
echo msbuild is located at %msbuild_folder%
|
||||||
|
|
||||||
"%msbuild_folder%\\msbuild" /property:GenerateFullPaths=true /t:build premake\workspace.sln /p:Configuration=Release /verbosity:minimal
|
"%msbuild_folder%\\msbuild" /property:GenerateFullPaths=true /t:build premake\doghook.sln /p:Configuration=Release /verbosity:minimal
|
||||||
|
|
||||||
echo done.
|
echo done.
|
||||||
|
|
||||||
|
@ -81,21 +81,33 @@ public:
|
|||||||
IFace<sdk::Client>::set_from_interface("client", "VClient");
|
IFace<sdk::Client>::set_from_interface("client", "VClient");
|
||||||
IFace<sdk::Engine>::set_from_interface("engine", "VEngineClient");
|
IFace<sdk::Engine>::set_from_interface("engine", "VEngineClient");
|
||||||
IFace<sdk::EntList>::set_from_interface("client", "VClientEntityList");
|
IFace<sdk::EntList>::set_from_interface("client", "VClientEntityList");
|
||||||
|
IFace<sdk::Cvar>::set_from_interface("vstdlib", "VEngineCvar");
|
||||||
|
IFace<sdk::ModelInfo>::set_from_interface("engine", "VModelInfoClient");
|
||||||
|
IFace<sdk::Trace>::set_from_interface("engine", "EngineTraceClient");
|
||||||
|
IFace<sdk::DebugOverlay>::set_from_interface("engine", "VDebugOverlay");
|
||||||
|
IFace<sdk::GameMovement>::set_from_interface("client", "GameMovement");
|
||||||
|
IFace<sdk::Prediction>::set_from_interface("client", "VClientPrediction");
|
||||||
|
IFace<sdk::InputSystem>::set_from_interface("inputsystem", "InputSystemVersion");
|
||||||
|
|
||||||
if constexpr (doghook_platform::windows())
|
if constexpr (doghook_platform::windows()) {
|
||||||
IFace<sdk::Input>::set_from_pointer(**reinterpret_cast<sdk::Input ***>(
|
IFace<sdk::Input>::set_from_pointer(**reinterpret_cast<sdk::Input ***>(
|
||||||
vfunc::get_func<u8 *>(sdk::iface::client, 15, 0) + 0x2));
|
vfunc::get_func<u8 *>(sdk::iface::client, 15, 0) + 0x2));
|
||||||
else if constexpr (doghook_platform::linux())
|
|
||||||
IFace<sdk::Input>::set_from_pointer(**reinterpret_cast<sdk::Input ***>(
|
|
||||||
vfunc::get_func<u8 *>(sdk::iface::client, 15, 0) + 0x1));
|
|
||||||
|
|
||||||
IFace<sdk::Cvar>::set_from_interface("vstdlib", "VEngineCvar");
|
|
||||||
|
|
||||||
if constexpr (doghook_platform::windows())
|
|
||||||
IFace<sdk::ClientMode>::set_from_pointer(
|
IFace<sdk::ClientMode>::set_from_pointer(
|
||||||
*signature::find_pattern<sdk::ClientMode **>(
|
*signature::find_pattern<sdk::ClientMode **>(
|
||||||
"client", "B9 ? ? ? ? A3 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? E8 ? ? ? ? 83 C4 04 C7 05", 1));
|
"client", "B9 ? ? ? ? A3 ? ? ? ? E8 ? ? ? ? 68 ? ? ? ? E8 ? ? ? ? 83 C4 04 C7 05", 1));
|
||||||
else if constexpr (doghook_platform::linux()) {
|
|
||||||
|
auto globals_real_address = (u32)*signature::find_pattern<sdk::Globals **>("engine", "A1 ? ? ? ? 8B 11 68", 8);
|
||||||
|
IFace<sdk::Globals>::set_from_pointer((sdk::Globals *)globals_real_address);
|
||||||
|
|
||||||
|
IFace<sdk::MoveHelper>::set_from_pointer(
|
||||||
|
*signature::find_pattern<sdk::MoveHelper **>(
|
||||||
|
"client", "8B 0D ? ? ? ? 8B 01 FF 50 28 56", 2));
|
||||||
|
|
||||||
|
} else if constexpr (doghook_platform::linux()) {
|
||||||
|
IFace<sdk::Input>::set_from_pointer(**reinterpret_cast<sdk::Input ***>(
|
||||||
|
vfunc::get_func<u8 *>(sdk::iface::client, 15, 0) + 0x1));
|
||||||
|
|
||||||
// ClientMode is a magic static. So getting a sig for it is difficult (conflicts with all other magic statics)
|
// ClientMode is a magic static. So getting a sig for it is difficult (conflicts with all other magic statics)
|
||||||
// So we are going to do some multistage shit in order to retrieve it
|
// So we are going to do some multistage shit in order to retrieve it
|
||||||
auto outer_function = signature::find_pattern<void *>("client", "55 89 E5 83 EC 18 E8 ? ? ? ? A3 ? ? ? ? E8", 6);
|
auto outer_function = signature::find_pattern<void *>("client", "55 89 E5 83 EC 18 E8 ? ? ? ? A3 ? ? ? ? E8", 6);
|
||||||
@ -106,11 +118,13 @@ public:
|
|||||||
|
|
||||||
IFace<sdk::ClientMode>::set_from_pointer(*reinterpret_cast<sdk::ClientMode **>(inner_function + 10));
|
IFace<sdk::ClientMode>::set_from_pointer(*reinterpret_cast<sdk::ClientMode **>(inner_function + 10));
|
||||||
assert(sdk::iface::client_mode);
|
assert(sdk::iface::client_mode);
|
||||||
}
|
|
||||||
|
|
||||||
IFace<sdk::ModelInfo>::set_from_interface("engine", "VModelInfoClient");
|
auto globals_real_address = (u32) * *signature::find_pattern<sdk::Globals ***>("client", "8B 15 ? ? ? ? F3 0F 10 88 D0 08 00 00", 2);
|
||||||
IFace<sdk::Trace>::set_from_interface("engine", "EngineTraceClient");
|
|
||||||
IFace<sdk::DebugOverlay>::set_from_interface("engine", "VDebugOverlay");
|
IFace<sdk::Globals>::set_from_pointer((sdk::Globals *)globals_real_address);
|
||||||
|
|
||||||
|
IFace<sdk::MoveHelper>::set_from_pointer(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
IFace<sdk::PlayerInfoManager>::set_from_interface("server", "PlayerInfoManager");
|
IFace<sdk::PlayerInfoManager>::set_from_interface("server", "PlayerInfoManager");
|
||||||
@ -118,27 +132,6 @@ public:
|
|||||||
auto globals_server_address = (u32)iface::sdk::Globals.get();
|
auto globals_server_address = (u32)iface::sdk::Globals.get();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if constexpr (doghook_platform::windows()) {
|
|
||||||
auto globals_real_address = (u32)*signature::find_pattern<sdk::Globals **>("engine", "A1 ? ? ? ? 8B 11 68", 8);
|
|
||||||
IFace<sdk::Globals>::set_from_pointer((sdk::Globals *)globals_real_address);
|
|
||||||
} else if constexpr (doghook_platform::linux()) {
|
|
||||||
auto globals_real_address = (u32) * *signature::find_pattern<sdk::Globals ***>("client", "8B 15 ? ? ? ? F3 0F 10 88 D0 08 00 00", 2);
|
|
||||||
|
|
||||||
IFace<sdk::Globals>::set_from_pointer((sdk::Globals *)globals_real_address);
|
|
||||||
}
|
|
||||||
|
|
||||||
IFace<sdk::GameMovement>::set_from_interface("client", "GameMovement");
|
|
||||||
IFace<sdk::Prediction>::set_from_interface("client", "VClientPrediction");
|
|
||||||
|
|
||||||
if constexpr (doghook_platform::windows())
|
|
||||||
IFace<sdk::MoveHelper>::set_from_pointer(
|
|
||||||
*signature::find_pattern<sdk::MoveHelper **>(
|
|
||||||
"client", "8B 0D ? ? ? ? 8B 01 FF 50 28 56", 2));
|
|
||||||
else if constexpr (doghook_platform::linux())
|
|
||||||
IFace<sdk::MoveHelper>::set_from_pointer(nullptr);
|
|
||||||
|
|
||||||
IFace<sdk::InputSystem>::set_from_interface("inputsystem", "InputSystemVersion");
|
|
||||||
|
|
||||||
inited = true;
|
inited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,10 +64,6 @@ static inline auto local_player_prediction(Player *local, UserCmd *cmd) {
|
|||||||
iface::globals->curtime = old_cur_time;
|
iface::globals->curtime = old_cur_time;
|
||||||
iface::globals->frametime = old_frame_time;
|
iface::globals->frametime = old_frame_time;
|
||||||
iface::globals->tickcount = old_tick_count;
|
iface::globals->tickcount = old_tick_count;
|
||||||
|
|
||||||
// TODO: if you do this then make sure to change the fov time calculation
|
|
||||||
// in aimbot::try_autoshoot!!
|
|
||||||
//local->tick_base() += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<hooks::HookFunction<ClientMode, 0>> create_move_hook;
|
std::unique_ptr<hooks::HookFunction<ClientMode, 0>> create_move_hook;
|
||||||
@ -85,8 +81,7 @@ bool hooked_create_move(void *instance, float sample_framerate, UserCmd *user_cm
|
|||||||
__asm mov ebp_address, ebp;
|
__asm mov ebp_address, ebp;
|
||||||
send_packet_ptr = reinterpret_cast<bool *>(***(uptr ***)ebp_address - 1);
|
send_packet_ptr = reinterpret_cast<bool *>(***(uptr ***)ebp_address - 1);
|
||||||
#else
|
#else
|
||||||
// kotm's method
|
uptr **fp;
|
||||||
uintptr_t **fp;
|
|
||||||
__asm__("mov %%ebp, %0"
|
__asm__("mov %%ebp, %0"
|
||||||
: "=r"(fp));
|
: "=r"(fp));
|
||||||
send_packet_ptr = reinterpret_cast<bool *>(**fp - 8);
|
send_packet_ptr = reinterpret_cast<bool *>(**fp - 8);
|
||||||
|
@ -145,24 +145,26 @@ static auto find_best_box() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Convar<bool> doghook_aimbot_enable_backtrack{"doghook_aimbot_enable_backtrack", true, nullptr};
|
static Convar<bool> doghook_aimbot_enable_backtrack{"doghook_aimbot_enable_backtrack", true, nullptr};
|
||||||
static Convar<bool> doghook_aimbot_reverse_backtrack_order{"doghook_aimbot_reverse_backtrack_order", true, nullptr};
|
static Convar<bool> doghook_aimbot_reverse_backtrack_order{"doghook_aimbot_reverse_backtrack_order", false, nullptr};
|
||||||
|
|
||||||
auto visible_target_inner(Player *player, std::pair<int, bool> best_box, u32 tick, math::Vector &pos) {
|
auto visible_target_inner(Player *player, std::pair<int, bool> best_box, u32 tick, math::Vector &pos) {
|
||||||
PlayerHitboxes hitboxes;
|
PlayerHitboxes hitboxes;
|
||||||
u32 hitboxes_count;
|
u32 hitboxes_count;
|
||||||
|
|
||||||
|
auto [best_hitbox, only_use_best] = best_box;
|
||||||
|
|
||||||
hitboxes_count = backtrack::hitboxes_for_player(player, tick, hitboxes);
|
hitboxes_count = backtrack::hitboxes_for_player(player, tick, hitboxes);
|
||||||
|
|
||||||
// check best hitbox first
|
// check best hitbox first
|
||||||
if (visible(player, hitboxes.centre[best_box.first], best_box.first)) {
|
if (visible(player, hitboxes.centre[best_hitbox], best_hitbox)) {
|
||||||
pos = hitboxes.centre[best_box.first];
|
pos = hitboxes.centre[best_hitbox];
|
||||||
return true;
|
return true;
|
||||||
} else if (multipoint(player, best_box.first, hitboxes.centre[best_box.first], hitboxes.min[best_box.first], hitboxes.max[best_box.first], pos)) {
|
} else if (multipoint(player, best_hitbox, hitboxes.centre[best_hitbox], hitboxes.min[best_hitbox], hitboxes.max[best_hitbox], pos)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// .second is whether we should only check the best box
|
// .second is whether we should only check the best box
|
||||||
if (!best_box.second) {
|
if (!only_use_best) {
|
||||||
for (u32 i = 0; i < hitboxes_count; i++) {
|
for (u32 i = 0; i < hitboxes_count; i++) {
|
||||||
if (visible(player, hitboxes.centre[i], i)) {
|
if (visible(player, hitboxes.centre[i], i)) {
|
||||||
pos = hitboxes.centre[i];
|
pos = hitboxes.centre[i];
|
||||||
@ -171,7 +173,7 @@ auto visible_target_inner(Player *player, std::pair<int, bool> best_box, u32 tic
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// Perform multiboxing after confirming that we do not have any other options
|
// TODO: Perform multiboxing after confirming that we do not have any other options
|
||||||
for (u32 i = 0; i < hitboxes_count; i++) {
|
for (u32 i = 0; i < hitboxes_count; i++) {
|
||||||
if (multipoint(player, i, hitboxes.centre[i], hitboxes.min[i], hitboxes.max[i], pos)) {
|
if (multipoint(player, i, hitboxes.centre[i], hitboxes.min[i], hitboxes.max[i], pos)) {
|
||||||
return true;
|
return true;
|
||||||
@ -204,9 +206,6 @@ auto valid_target(Entity *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void finished_target(Target t) {
|
void finished_target(Target t) {
|
||||||
// iface::overlay->add_entity_text_overlay(t.e->index(), 1, 0, 255, 255, 255, 255, "finished");
|
|
||||||
// iface::overlay->add_entity_text_overlay(t.e->index(), 2, 0, 255, 255, 255, 255, "%d", t.cmd_delta);
|
|
||||||
|
|
||||||
targets.push_back(t);
|
targets.push_back(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,19 +227,19 @@ auto find_targets() {
|
|||||||
for (auto e : iface::ent_list->get_range()) {
|
for (auto e : iface::ent_list->get_range()) {
|
||||||
if (!e->is_valid()) continue;
|
if (!e->is_valid()) continue;
|
||||||
|
|
||||||
if (valid_target(e)) {
|
if (!valid_target(e)) continue;
|
||||||
|
|
||||||
auto pos = math::Vector::invalid();
|
auto pos = math::Vector::invalid();
|
||||||
|
|
||||||
if (auto p = e->to_player()) {
|
if (auto p = e->to_player()) {
|
||||||
if (visible_player(p, best_box, tick, pos)) {
|
if (!visible_player(p, best_box, tick, pos)) continue;
|
||||||
|
|
||||||
finished_target(Target{e, pos, delta});
|
finished_target(Target{e, pos, delta});
|
||||||
|
|
||||||
// TODO: only do this when we want to do speedy targets!
|
// TODO: only do this when we want to do speedy targets!
|
||||||
//break;
|
//break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
auto current_tick = iface::globals->tickcount;
|
auto current_tick = iface::globals->tickcount;
|
||||||
@ -248,25 +247,23 @@ auto find_targets() {
|
|||||||
bool reverse_order = doghook_aimbot_reverse_backtrack_order;
|
bool reverse_order = doghook_aimbot_reverse_backtrack_order;
|
||||||
|
|
||||||
// Easy out
|
// Easy out
|
||||||
if (!reverse_order || !doghook_aimbot_enable_backtrack) {
|
if (!doghook_aimbot_enable_backtrack) {
|
||||||
find_target_inner(current_tick, 0);
|
find_target_inner(current_tick, 0);
|
||||||
if (targets.size() > 0) {
|
if (targets.size() > 0) sort_targets();
|
||||||
sort_targets();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!doghook_aimbot_enable_backtrack) return;
|
|
||||||
|
|
||||||
|
// Change
|
||||||
const auto delta_delta = reverse_order ? -1 : 1;
|
const auto delta_delta = reverse_order ? -1 : 1;
|
||||||
auto delta = reverse_order ? backtrack::max_ticks : 1;
|
|
||||||
|
|
||||||
u32 new_tick;
|
// Starting position
|
||||||
|
auto delta = reverse_order ? backtrack::max_ticks : 1;
|
||||||
|
|
||||||
backtrack::RewindState rewind;
|
backtrack::RewindState rewind;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
new_tick = current_tick - delta;
|
u32 new_tick = current_tick - delta;
|
||||||
|
|
||||||
if (backtrack::tick_valid(new_tick)) {
|
if (backtrack::tick_valid(new_tick)) {
|
||||||
rewind.to_tick(new_tick);
|
rewind.to_tick(new_tick);
|
||||||
@ -349,7 +346,7 @@ static Convar<bool> doghook_aimbot_disallow_attack_if_no_target = Convar<bool>{"
|
|||||||
void create_move(sdk::UserCmd *cmd) {
|
void create_move(sdk::UserCmd *cmd) {
|
||||||
profiler_profile_function();
|
profiler_profile_function();
|
||||||
|
|
||||||
if (local_weapon == nullptr || !can_find_targets) return;
|
if (!can_find_targets) return;
|
||||||
|
|
||||||
find_targets();
|
find_targets();
|
||||||
|
|
||||||
|
@ -143,6 +143,7 @@ Convar<float> doghook_backtrack_latency{"doghook_backtrack_latency", 0, 0, 1, nu
|
|||||||
struct sequence {
|
struct sequence {
|
||||||
u32 in_state;
|
u32 in_state;
|
||||||
u32 out_state;
|
u32 out_state;
|
||||||
|
|
||||||
u32 in_sequence;
|
u32 in_sequence;
|
||||||
u32 out_sequence;
|
u32 out_sequence;
|
||||||
float cur_time;
|
float cur_time;
|
||||||
@ -274,35 +275,26 @@ static bool restore_player_to_record(sdk::Player *p, const Record &r) {
|
|||||||
|
|
||||||
// This offset already seems to account for the + 4 needed...
|
// This offset already seems to account for the + 4 needed...
|
||||||
static auto hitbox_bone_cache_handle_offset = *signature::find_pattern<u32 *>("client", "FF B6 ? ? ? ? E8 ? ? ? ? 8B F8 83 C4 04 85 FF 74 47", 2);
|
static auto hitbox_bone_cache_handle_offset = *signature::find_pattern<u32 *>("client", "FF B6 ? ? ? ? E8 ? ? ? ? 8B F8 83 C4 04 85 FF 74 47", 2);
|
||||||
|
|
||||||
auto hitbox_bone_cache_handle = p->get<u32>(hitbox_bone_cache_handle_offset);
|
|
||||||
if (hitbox_bone_cache_handle == 0) return true;
|
|
||||||
|
|
||||||
static auto studio_get_bone_cache = signature::find_pattern<GetBoneCacheFn>("client", "55 8B EC 83 EC 20 56 6A 01 68 ? ? ? ? 68", 0);
|
static auto studio_get_bone_cache = signature::find_pattern<GetBoneCacheFn>("client", "55 8B EC 83 EC 20 56 6A 01 68 ? ? ? ? 68", 0);
|
||||||
BoneCache * bone_cache = studio_get_bone_cache(hitbox_bone_cache_handle);
|
|
||||||
|
|
||||||
static auto bone_cache_update_bones = signature::find_pattern<BoneCache_UpdateBonesFn>("client", "55 8B EC 83 EC 08 56 8B F1 33 D2", 0);
|
static auto bone_cache_update_bones = signature::find_pattern<BoneCache_UpdateBonesFn>("client", "55 8B EC 83 EC 08 56 8B F1 33 D2", 0);
|
||||||
|
|
||||||
if (bone_cache != nullptr) bone_cache_update_bones(bone_cache, r.hitboxes.bone_to_world, 128, iface::globals->curtime);
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// 8B 86 ? ? ? ? 89 04 24 E8 ? ? ? ? 85 C0 89 C3 74 48 -> hitbox_bone_cache_handle_offset
|
// 8B 86 ? ? ? ? 89 04 24 E8 ? ? ? ? 85 C0 89 C3 74 48 -> hitbox_bone_cache_handle_offset
|
||||||
// 55 89 E5 56 53 BB ? ? ? ? 83 EC 50 C7 45 D8 -> GetBoneCache
|
// 55 89 E5 56 53 BB ? ? ? ? 83 EC 50 C7 45 D8 -> GetBoneCache
|
||||||
// 55 89 E5 57 31 FF 56 53 83 EC 1C 8B 5D 08 0F B7 53 10 -> UpdateBoneCache
|
// 55 89 E5 57 31 FF 56 53 83 EC 1C 8B 5D 08 0F B7 53 10 -> UpdateBoneCache
|
||||||
|
|
||||||
static auto hitbox_bone_cache_handle_offset = *signature::find_pattern<u32 *>("client", "8B 86 ? ? ? ? 89 04 24 E8 ? ? ? ? 85 C0 89 C3 74 48", 2);
|
static auto hitbox_bone_cache_handle_offset = *signature::find_pattern<u32 *>("client", "8B 86 ? ? ? ? 89 04 24 E8 ? ? ? ? 85 C0 89 C3 74 48", 2);
|
||||||
|
static auto studio_get_bone_cache = signature::find_pattern<GetBoneCacheFn>("client", "55 89 E5 56 53 BB ? ? ? ? 83 EC 50 C7 45 D8", 0);
|
||||||
|
static auto bone_cache_update_bones = signature::find_pattern<BoneCache_UpdateBonesFn>("client", "55 89 E5 57 31 FF 56 53 83 EC 1C 8B 5D 08 0F B7 53 10", 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
auto hitbox_bone_cache_handle = p->get<u32>(hitbox_bone_cache_handle_offset);
|
auto hitbox_bone_cache_handle = p->get<u32>(hitbox_bone_cache_handle_offset);
|
||||||
if (hitbox_bone_cache_handle == 0) return true;
|
if (hitbox_bone_cache_handle == 0) return true;
|
||||||
|
|
||||||
static auto studio_get_bone_cache = signature::find_pattern<GetBoneCacheFn>("client", "55 89 E5 56 53 BB ? ? ? ? 83 EC 50 C7 45 D8", 0);
|
BoneCache *bone_cache = studio_get_bone_cache(hitbox_bone_cache_handle);
|
||||||
BoneCache * bone_cache = studio_get_bone_cache(hitbox_bone_cache_handle);
|
|
||||||
|
|
||||||
static auto bone_cache_update_bones = signature::find_pattern<BoneCache_UpdateBonesFn>("client", "55 89 E5 57 31 FF 56 53 83 EC 1C 8B 5D 08 0F B7 53 10", 0);
|
|
||||||
if (bone_cache != nullptr) bone_cache_update_bones(bone_cache, r.hitboxes.bone_to_world, 128, iface::globals->curtime);
|
if (bone_cache != nullptr) bone_cache_update_bones(bone_cache, r.hitboxes.bone_to_world, 128, iface::globals->curtime);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -460,7 +452,7 @@ void create_move(sdk::UserCmd *cmd) {
|
|||||||
|
|
||||||
iface::overlay->add_box_overlay(r.hitboxes.origin[0], {-2, -2, -2}, {2, 2, 2}, {0, 0, 0}, 0, 255, 0, 100, 0);
|
iface::overlay->add_box_overlay(r.hitboxes.origin[0], {-2, -2, -2}, {2, 2, 2}, {0, 0, 0}, 0, 255, 0, 100, 0);
|
||||||
|
|
||||||
#if 0
|
#if 0 && _DEBUG
|
||||||
auto &hitboxes = r.hitboxes;
|
auto &hitboxes = r.hitboxes;
|
||||||
for (u32 i = 0; i < r.max_hitboxes; i++) {
|
for (u32 i = 0; i < r.max_hitboxes; i++) {
|
||||||
|
|
||||||
@ -469,7 +461,7 @@ void create_move(sdk::UserCmd *cmd) {
|
|||||||
auto g = (int)(255.0f * hullcolor[j].y);
|
auto g = (int)(255.0f * hullcolor[j].y);
|
||||||
auto b = (int)(255.0f * hullcolor[j].z);
|
auto b = (int)(255.0f * hullcolor[j].z);
|
||||||
|
|
||||||
iface::DebugOverlay->add_box_overlay(hitboxes.origin[i], hitboxes.raw_min[i], hitboxes.raw_max[i], hitboxes.rotation[i], r, g, b, 100, 0);
|
iface::overlay->add_box_overlay(hitboxes.origin[i], hitboxes.raw_min[i], hitboxes.raw_max[i], hitboxes.rotation[i], r, g, b, 100, 0);
|
||||||
|
|
||||||
//math::Vector origin;
|
//math::Vector origin;
|
||||||
//math::Vector angles;
|
//math::Vector angles;
|
||||||
@ -479,7 +471,7 @@ void create_move(sdk::UserCmd *cmd) {
|
|||||||
//g = 255;
|
//g = 255;
|
||||||
//b = 0;
|
//b = 0;
|
||||||
|
|
||||||
//iface::DebugOverlay->add_box_overlay(origin, hitboxes.raw_min[i], hitboxes.raw_max[i], angles, r, g, b, 100, 0);
|
//iface::overlay->add_box_overlay(origin, hitboxes.raw_min[i], hitboxes.raw_max[i], angles, r, g, b, 100, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -60,14 +60,14 @@ Netvar local_angles{"DT_BasePlayer", "pl", "deadflag"};
|
|||||||
void init_all() {
|
void init_all() {
|
||||||
for (auto c : sdk::ConvarWrapper::get_range()) {
|
for (auto c : sdk::ConvarWrapper::get_range()) {
|
||||||
auto flags = c.flags();
|
auto flags = c.flags();
|
||||||
flags &= ~FCVAR_CHEAT;
|
flags &= ~(FCVAR_CHEAT |
|
||||||
flags &= ~FCVAR_DEVELOPMENTONLY;
|
FCVAR_DEVELOPMENTONLY |
|
||||||
flags &= ~FCVAR_PROTECTED;
|
FCVAR_PROTECTED |
|
||||||
flags &= ~FCVAR_SPONLY;
|
FCVAR_SPONLY |
|
||||||
flags &= ~FCVAR_CHEAT;
|
FCVAR_CHEAT |
|
||||||
flags &= ~FCVAR_REPLICATED;
|
FCVAR_REPLICATED |
|
||||||
flags &= ~FCVAR_NOT_CONNECTED;
|
FCVAR_NOT_CONNECTED |
|
||||||
flags &= ~FCVAR_HIDDEN;
|
FCVAR_HIDDEN);
|
||||||
|
|
||||||
c.set_flags(flags);
|
c.set_flags(flags);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,9 @@ public:
|
|||||||
|
|
||||||
// For debug builds we want to be able to check our classids are correct and issue warnings if they are not correct
|
// For debug builds we want to be able to check our classids are correct and issue warnings if they are not correct
|
||||||
// So that we can update the value for next time.
|
// So that we can update the value for next time.
|
||||||
|
|
||||||
|
// This macro is required as inline variables have multiple constructors / destructors per compilation unit.
|
||||||
|
// Since this calss relies on consctruction and destruction we can only create the checkers in 1 compilation unit.
|
||||||
#if defined(_DEBUG) && defined(PLACE_CHECKER)
|
#if defined(_DEBUG) && defined(PLACE_CHECKER)
|
||||||
#define ID(name, value) \
|
#define ID(name, value) \
|
||||||
enum { name = value }; \
|
enum { name = value }; \
|
||||||
@ -40,6 +43,9 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Put ids here
|
// Put ids here
|
||||||
|
ID(CFuncRespawnRoomVisualizer, 64);
|
||||||
|
ID(CTFMedigunShield, 230);
|
||||||
|
ID(CFuncAreaPortalWindow, 55);
|
||||||
ID(CTFPlayer, 246);
|
ID(CTFPlayer, 246);
|
||||||
ID(CTFRevolver, 285);
|
ID(CTFRevolver, 285);
|
||||||
ID(CTFSniperRifle, 306);
|
ID(CTFSniperRifle, 306);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include "log.hh"
|
#include "log.hh"
|
||||||
#include "sdk.hh"
|
#include "sdk.hh"
|
||||||
|
|
||||||
// implementation of a source convar
|
// implementation of a source engine convar
|
||||||
namespace sdk {
|
namespace sdk {
|
||||||
|
|
||||||
// Helper to prevent crashes if Cvar isnt initied properly yet
|
// Helper to prevent crashes if Cvar isnt initied properly yet
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
// Convar types into their own templated class so that you can static_cast
|
// Convar types into their own templated class so that you can static_cast
|
||||||
// to it once you know what you are dealing with.
|
// to it once you know what you are dealing with.
|
||||||
|
|
||||||
|
// TODO: there is no reason why there should be any virtual functions here!
|
||||||
|
|
||||||
namespace sdk {
|
namespace sdk {
|
||||||
class ConCommandBase;
|
class ConCommandBase;
|
||||||
class IConVar;
|
class IConVar;
|
||||||
|
@ -121,7 +121,7 @@ public:
|
|||||||
virtual void post_render() override {}
|
virtual void post_render() override {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: GameSystem could be in a namespace...
|
// TODO: GameSystem could be in a namespace (not directly required for the rtti hack)...
|
||||||
|
|
||||||
class GameSystem : public CBaseGameSystemPerFrame {
|
class GameSystem : public CBaseGameSystemPerFrame {
|
||||||
GameSystem *next;
|
GameSystem *next;
|
||||||
|
@ -178,8 +178,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Call the original function
|
// Call the original function
|
||||||
// Only pass the return value as a template param as the args
|
// Only pass the return value as a template param.
|
||||||
// will be automatically infered from what you pass to the function
|
// as the arg will be automatically infered from what you pass to the function
|
||||||
template <typename ret, typename... Args>
|
template <typename ret, typename... Args>
|
||||||
auto call_original(Args... args) {
|
auto call_original(Args... args) {
|
||||||
#if doghook_platform_linux()
|
#if doghook_platform_linux()
|
||||||
|
@ -160,5 +160,5 @@ enum player_controls {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// TODO: mb add enumerated key array
|
// TODO: mb add enumerated key array
|
||||||
// ToDo: make seperate convar type for keys
|
// TODO: make seperate convar type for keys
|
||||||
} // namespace sdk
|
} // namespace sdk
|
||||||
|
@ -43,24 +43,25 @@ uptr Netvar::Tree::find_offset(std::vector<const char *> t) {
|
|||||||
auto nodes = &prop_tree;
|
auto nodes = &prop_tree;
|
||||||
|
|
||||||
for (auto &name : t) {
|
for (auto &name : t) {
|
||||||
|
|
||||||
auto old_nodes = nodes;
|
auto old_nodes = nodes;
|
||||||
|
|
||||||
auto end = nodes->end();
|
auto end = nodes->end();
|
||||||
for (auto it = nodes->begin(); it != end; ++it) {
|
for (auto it = nodes->begin(); it != end; ++it) {
|
||||||
auto p = *it;
|
auto p = *it;
|
||||||
|
|
||||||
if (strcmp(name, p.first) == 0) {
|
auto [node_name, child_node] = p;
|
||||||
nodes = &p.second->children;
|
|
||||||
if (p.second->p != nullptr)
|
if (strcmp(name, node_name) == 0) {
|
||||||
total += p.second->p->offset;
|
nodes = &child_node->children;
|
||||||
|
if (child_node->p != nullptr)
|
||||||
|
total += child_node->p->offset;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodes == old_nodes) {
|
if (nodes == old_nodes) {
|
||||||
// TODO:
|
// TODO:
|
||||||
//logging::msg("[Netvar] Unable to find '%s'", name);
|
// logging::msg("[Netvar] Unable to find '%s'", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ namespace sdk {
|
|||||||
class Netvar {
|
class Netvar {
|
||||||
|
|
||||||
class Tree {
|
class Tree {
|
||||||
|
|
||||||
struct Node;
|
struct Node;
|
||||||
using TreeNode = std::vector<std::pair<const char *, std::shared_ptr<Node>>>;
|
using TreeNode = std::vector<std::pair<const char *, std::shared_ptr<Node>>>;
|
||||||
|
|
||||||
|
@ -515,6 +515,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Wrappers around the IFace<type> system: iface::<type>
|
||||||
namespace iface {
|
namespace iface {
|
||||||
extern IFace<Client> client;
|
extern IFace<Client> client;
|
||||||
extern IFace<ClientMode> client_mode;
|
extern IFace<ClientMode> client_mode;
|
||||||
@ -532,6 +533,24 @@ extern IFace<MoveHelper> move_helper;
|
|||||||
extern IFace<GameMovement> game_movement;
|
extern IFace<GameMovement> game_movement;
|
||||||
extern IFace<EngineVgui> engine_vgui;
|
extern IFace<EngineVgui> engine_vgui;
|
||||||
extern IFace<InputSystem> input_system;
|
extern IFace<InputSystem> input_system;
|
||||||
|
|
||||||
|
// TODO: update to use type aliases instead of extern vars
|
||||||
|
// using client = IFace<Client>;
|
||||||
|
// using client_mode = IFace<ClientMode>;
|
||||||
|
// using cvar = IFace<Cvar>;
|
||||||
|
// using engine = IFace<Engine>;
|
||||||
|
// using engine_vgui = IFace<EngineVgui>;
|
||||||
|
// using ent_list = IFace<EntList>;
|
||||||
|
// using game_movement = IFace<GameMovement>;
|
||||||
|
// using globals = IFace<Globals>;
|
||||||
|
// using info_manager = IFace<PlayerInfoManager>;
|
||||||
|
// using input = IFace<Input>;
|
||||||
|
// using input_system = IFace<InputSystem>;
|
||||||
|
// using model_info = IFace<ModelInfo>;
|
||||||
|
// using move_helper = IFace<MoveHelper>;
|
||||||
|
// using overlay = IFace<DebugOverlay>;
|
||||||
|
// using prediction = IFace<Prediction>;
|
||||||
|
// using trace = IFace<Trace>;
|
||||||
} // namespace iface
|
} // namespace iface
|
||||||
|
|
||||||
} // namespace sdk
|
} // namespace sdk
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include "sdk.hh"
|
#include "sdk.hh"
|
||||||
|
|
||||||
|
#include "class_id.hh"
|
||||||
|
|
||||||
bool trace::Filter::should_hit_entity(sdk::Entity *handle_entity, int contents_mask) {
|
bool trace::Filter::should_hit_entity(sdk::Entity *handle_entity, int contents_mask) {
|
||||||
auto handle = handle_entity->to_handle();
|
auto handle = handle_entity->to_handle();
|
||||||
auto real_entity = sdk::iface::ent_list->from_handle(handle);
|
auto real_entity = sdk::iface::ent_list->from_handle(handle);
|
||||||
@ -14,9 +16,9 @@ bool trace::Filter::should_hit_entity(sdk::Entity *handle_entity, int contents_m
|
|||||||
|
|
||||||
// ignore "bad" entities
|
// ignore "bad" entities
|
||||||
switch (client_class->class_id) {
|
switch (client_class->class_id) {
|
||||||
case 64: // CFuncRespawnRoomVisualizer
|
case sdk::class_id::CFuncRespawnRoomVisualizer:
|
||||||
case 230: // CTFMedigunShield
|
case sdk::class_id::CTFMedigunShield:
|
||||||
case 55: // CFuncAreaPortalWindow
|
case sdk::class_id::CFuncAreaPortalWindow:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user