This repository has been archived on 2026-11-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2026-11-05 02:19:09 +01:00

159 lines
3.4 KiB
C++

#include <include.h>
void __fastcall hooks::frame_stage_notify(void* this_ptr, int stage)
{
auto* const original_fn = o::frame_stage_notify;
r5::on_fsn(stage);
return original_fn(this_ptr, stage);
}
void __fastcall hooks::create_move(void* this_ptr, int seq_nr, float sample_time, bool active)
{
auto* const original_fn = o::create_move;
g::p::ent_cache.on_createmove();
original_fn(this_ptr, seq_nr, sample_time, active);
if (!seq_nr)
return;
auto* const cmd = ix::input->get_user_cmd(seq_nr);
if (!cmd || !cmd->command_number)
return;
r5::on_createmove(cmd);
}
bool __fastcall hooks::write_user_cmd_delta_to_buffer(void* this_ptr, __int64 unused_0, __int64 pBuffer2, __int64 from_, int to)
{
return false;
}
int __fastcall hooks::vgui_paint(void* this_ptr, int mode)
{
auto* const original_fn = o::vgui_paint;
return 0;
}
int64_t __fastcall hooks::unk0(void* this_ptr)
{
return 0;
}
void __fastcall hooks::write_user_cmd(void* buf, respawn::user_cmd_t* to, respawn::user_cmd_t* from)
{
auto* const original_fn = o::write_user_cmd;
return original_fn(buf, to, from);
}
void __fastcall hooks::paint_fn(void* this_ptr, uint8_t* unk0, int64_t unk1)
{
auto* const original_fn = o::paint_fn;
original_fn(this_ptr, unk0, unk1);
r5::on_paint();
}
void __fastcall hooks::view_render_start(void* this_ptr)
{
auto* const original_fn = o::view_render_start;
original_fn(this_ptr);
if (respawn::is_playing())
{
auto* const inst = mem::addr(this_ptr).As<respawn::c_view_render*>();
if (!(inst == nullptr))
{
if (cfg::custom_fov)
{
if (g::p::cache.local_player.zooming)
{
if(cfg::custom_fov_override_zoomed)
*reinterpret_cast<float*>(BASE_OF(inst) + 0xD0) = cfg::no_zoom ? cfg::custom_fov_scale : cfg::custom_fov_scale_zoomed;
}
else
*reinterpret_cast<float*>(BASE_OF(inst) + 0xD0) = cfg::custom_fov_scale;
}
if (cfg::no_sway)
{
ix::engine_client->get_view_angles(g::p::eye_angles);
g::p::sway_angles = *reinterpret_cast<math::Angle3*>(BASE_OF(inst) + 0xEC);
*reinterpret_cast<math::Angle3*>(BASE_OF(inst) + 0xEC) = g::p::eye_angles;
}
}
}
}
void __fastcall hooks::cl_move(void)
{
auto* const original_fn = o::cl_move;
r5::on_clmove();
return original_fn();
}
void __fastcall hooks::cl_move_send(__int64 a1, __int64 a2, __int64 a3)
{
auto* const original_fn = o::cl_move_send;
return original_fn(a1, a2, a3);
}
bool __fastcall hooks::lookup_file(void* this_ptr, const char* name, __int64 a3)
{
auto* const original_fn = o::lookup_file;
const auto result = original_fn(this_ptr, name, a3);
if (stl::strstr(name, _XS("nut")))
{
//
// A script file has been attempted to look up.
//
//log_info("lookup_script('%s').", name);
auto file_info = *(uintptr_t*)(a3 + 0x10);
auto file_buffer = *(char**)file_info;
auto file_primary_size = (size_t*)(*(uintptr_t*)(a3 + 0x8) + 0x20);
//dump_to_disk(name, file_buffer, *file_primary_size);
respawn::script::override_from_disk(name, file_buffer, file_primary_size);
}
return result;
}
bool __fastcall hooks::get_player_info(void* this_ptr, int index, respawn::player_info_t* buffer)
{
auto* const original_fn = o::get_player_info;
auto result = original_fn(this_ptr, index, buffer);
if (cfg::other_anonymous_mode)
{
if (result && !r5::is_within_self(_ReturnAddress()))
{
if (util::is_valid_address(buffer))
{
stl::strcpy(buffer->pad, _XS("Player1337"));
}
}
}
return result;
}