Initial commit
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
#include <include.h>
|
||||
|
||||
using namespace respawn;
|
||||
|
||||
void* c_entity::get_model()
|
||||
{
|
||||
auto address = DYN_ADDR("fn_get_model");
|
||||
using type = void* (__thiscall*)(void*);
|
||||
|
||||
return reinterpret_cast<type>(address)(this);
|
||||
}
|
||||
|
||||
bool c_entity::set_model(const char* name)
|
||||
{
|
||||
auto address = DYN_ADDR("fn_set_model");
|
||||
using type = bool(__thiscall*)(void*, const char*);
|
||||
|
||||
return reinterpret_cast<type>(address)(this, name);
|
||||
}
|
||||
|
||||
bool c_entity::set_model_index(int index)
|
||||
{
|
||||
auto address = DYN_ADDR("fn_set_model_index");
|
||||
using type = bool(__thiscall*)(void*, int);
|
||||
|
||||
return reinterpret_cast<type>(address)(this, index);
|
||||
}
|
||||
|
||||
void c_entity::set_abs_angles(math::Angle3 angle)
|
||||
{
|
||||
auto address = DYN_ADDR("fn_set_abs_angles");
|
||||
using type = void(__thiscall*)(void*, math::Angle3);
|
||||
|
||||
return reinterpret_cast<type>(address)(this, angle);
|
||||
}
|
||||
|
||||
uint32_t c_entity::get_sequence_activity(int sequence)
|
||||
{
|
||||
auto model = get_model();
|
||||
|
||||
if (model)
|
||||
{
|
||||
auto desc = respawn::seq_desc(model, sequence);
|
||||
|
||||
if (desc)
|
||||
{
|
||||
auto name = desc->pszActivityName();
|
||||
|
||||
if (name && *name)
|
||||
return util::string_hash(name, stl::strlen(name));
|
||||
}
|
||||
}
|
||||
|
||||
return UINT32_MAX;
|
||||
}
|
||||
|
||||
uint32_t c_entity::get_activity_sequence(uint32_t activity)
|
||||
{
|
||||
if (activity != UINT32_MAX)
|
||||
{
|
||||
auto model = get_model();
|
||||
|
||||
if (model)
|
||||
{
|
||||
auto seqcount = get_sequence_count(model);
|
||||
|
||||
for (int sequence = 0; sequence < seqcount; sequence++)
|
||||
{
|
||||
auto desc = respawn::seq_desc(model, sequence);
|
||||
|
||||
if (desc)
|
||||
{
|
||||
auto name = desc->pszActivityName();
|
||||
|
||||
if (name && *name && util::string_hash(name, stl::strlen(name)) == activity)
|
||||
return sequence;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return UINT32_MAX;
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
#include <include.h>
|
||||
|
||||
bool c_netvar_manager::initialize()
|
||||
{
|
||||
auto* const head = ix::base_client->get_all_classes();
|
||||
|
||||
if (head == nullptr)
|
||||
return false;
|
||||
|
||||
log_info_("initializing the netvar table.");
|
||||
|
||||
for (auto* client_class = head; client_class != nullptr; client_class = client_class->next)
|
||||
{
|
||||
auto* const table = client_class->table;
|
||||
|
||||
if (table == nullptr)
|
||||
continue;
|
||||
|
||||
process_table(table);
|
||||
}
|
||||
|
||||
log_info("netvar table was set up, there is a total of %i tables.", m_list.count());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool c_netvar_manager::is_prop_garbage(const char* name)
|
||||
{
|
||||
if (stl::strstr(name, _XS("baseclass")) ||
|
||||
stl::strstr(name, _XS("0")) ||
|
||||
stl::strstr(name, _XS("1")) ||
|
||||
stl::strstr(name, _XS("2")))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void c_netvar_manager::process_table(respawn::recv_table* table)
|
||||
{
|
||||
auto** const head = table->props;
|
||||
|
||||
if (head == nullptr)
|
||||
return;
|
||||
|
||||
netvar_table_t table_entry{};
|
||||
|
||||
stl::strcpy(table_entry.name, table->name);
|
||||
|
||||
for (auto i = 0ull; i < table->num_props; i++)
|
||||
{
|
||||
auto* const prop = head[i];
|
||||
|
||||
//
|
||||
// validate the prop pointer, at first.
|
||||
//
|
||||
if (prop == nullptr)
|
||||
continue;
|
||||
|
||||
//
|
||||
// validate that the prop is not garbage data.
|
||||
//
|
||||
if (is_prop_garbage(prop->name))
|
||||
continue;
|
||||
|
||||
//
|
||||
// process the actual prop here.
|
||||
//
|
||||
process_prop(table, prop, table_entry.props);
|
||||
|
||||
//
|
||||
// if this prop has a table, then recursively process it.
|
||||
//
|
||||
if (prop->data_table != nullptr)
|
||||
process_table(prop->data_table);
|
||||
}
|
||||
|
||||
m_list.insert(table_entry);
|
||||
}
|
||||
|
||||
void c_netvar_manager::process_prop(respawn::recv_table* table, respawn::recv_prop* prop, stl::c_linked_list<netvar_t>& list)
|
||||
{
|
||||
netvar_t entry{};
|
||||
|
||||
stl::strcpy(entry.name, prop->name);
|
||||
entry.offset = prop->offset;
|
||||
|
||||
list.insert(entry);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
#include <include.h>
|
||||
|
||||
using namespace respawn;
|
||||
|
||||
bool c_player::is_visible() noexcept
|
||||
{
|
||||
const auto curr_time = *gv::engine_time;
|
||||
const auto visible_time = last_visible_time();
|
||||
const auto visible_time_cp = visible_time + 1.f;
|
||||
|
||||
if (visible_time_cp >= curr_time)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool c_player::get_bone_position(size_t index, math::Vector3& result) noexcept
|
||||
{
|
||||
auto my_origin = origin();
|
||||
auto bone_cache_base = *(uintptr_t*)(BASE_OF(this) + 0xF38);
|
||||
auto bone_cache_offs = (index * 0x30);
|
||||
|
||||
if (!bone_cache_base)
|
||||
return false;
|
||||
|
||||
result =
|
||||
{
|
||||
my_origin.x + *(float*)(bone_cache_base + bone_cache_offs + 0xCC),
|
||||
my_origin.y + *(float*)(bone_cache_base + bone_cache_offs + 0xDC),
|
||||
my_origin.z + *(float*)(bone_cache_base + bone_cache_offs + 0xEC),
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
c_weapon* c_player::get_active_weapon() noexcept
|
||||
{
|
||||
int wpn_index{ };
|
||||
ulong wpn_handle = latest_primary_weapon();
|
||||
|
||||
if (!wpn_handle)
|
||||
return nullptr;
|
||||
|
||||
wpn_index = ENTITY_INDEX_BY_HANDLE(wpn_handle);
|
||||
|
||||
if (!wpn_index)
|
||||
return nullptr;
|
||||
|
||||
return ix::entity_list->get_client_entity<c_weapon>(wpn_index);
|
||||
}
|
||||
|
||||
c_view_model* c_player::get_view_model() noexcept
|
||||
{
|
||||
int vm_index{ };
|
||||
ulong vm_handle = view_model();
|
||||
|
||||
if (!vm_handle)
|
||||
return nullptr;
|
||||
|
||||
vm_index = ENTITY_INDEX_BY_HANDLE(vm_handle);
|
||||
|
||||
if (!vm_index)
|
||||
return nullptr;
|
||||
|
||||
return ix::entity_list->get_client_entity<c_view_model>(vm_index);
|
||||
}
|
||||
@@ -0,0 +1,434 @@
|
||||
#include <include.h>
|
||||
|
||||
bool respawn::initialize()
|
||||
{
|
||||
_ident_table.insert({ _XC(0x726579616c70), entity_types::PLAYER });
|
||||
_ident_table.insert({ _XC(0x6d6d75645f63706e), entity_types::DUMMIE });
|
||||
_ident_table.insert({ _XC(0x776f72705f63706e), entity_types::PROWLER });
|
||||
_ident_table.insert({ _XC(0x7275735f706f7270), entity_types::PROP_SURVIVAL });
|
||||
_ident_table.insert({ _XC(0x6e79645f706f7270), entity_types::PROP_DYNAMIC });
|
||||
_ident_table.insert({ _XC(0x7263735f706f7270), entity_types::PROP_SCRIPT });
|
||||
_ident_table.insert({ _XC(0x6165645f706f7270), entity_types::PROP_DEATH_BOX });
|
||||
|
||||
_heirloom_table.insert(_XS("mdl/weapons/kunai/ptpov_kunai_wraith.rmdl"));
|
||||
_heirloom_table.insert(_XS("mdl/weapons/bloodhound_axe/ptpov_bloodhound_axe.rmdl"));
|
||||
_heirloom_table.insert(_XS("mdl/weapons/drumstick/ptpov_baton_lifeline.rmdl"));
|
||||
_heirloom_table.insert(_XS("mdl/weapons/pathfinder_gloves/ptpov_pathfinder_gloves.rmdl"));
|
||||
_heirloom_table.insert(_XS("mdl/weapons/octane_knife/ptpov_octane_knife.rmdl"));
|
||||
_heirloom_table.insert(_XS("mdl/weapons/mirage_heirloom/ptpov_mirage_heirloom.rmdl"));
|
||||
_heirloom_table.insert(_XS("mdl/weapons/caustic_heirloom/ptpov_caustic_heirloom.rmdl"));
|
||||
_heirloom_table.insert(_XS("mdl/weapons/gibraltar_heirloom/gibraltar_heirloom_v.rmdl"));
|
||||
_heirloom_table.insert(_XS("mdl/weapons/bangalore_heirloom/ptpov_bangalore_heirloom.rmdl"));
|
||||
_heirloom_table.insert(_XS("mdl/weapons/revenant_heirloom/revenant_heirloom_v21_base_v.rmdl"));
|
||||
_heirloom_table.insert(_XS("mdl/weapons/rampart_heirloom/ptpov_rampart_heirloom.rmdl"));
|
||||
_heirloom_table.insert(_XS("mdl/weapons/wattson_heirloom/wattson_heirloom_v21_base_v.rmdl"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
respawn::c_player* respawn::get_local_player()
|
||||
{
|
||||
if (!ix::engine_client->is_in_game())
|
||||
return nullptr;
|
||||
|
||||
const auto index = ix::engine_client->get_local_player();
|
||||
const auto result = ix::entity_list->get_client_entity<respawn::c_player>(index);
|
||||
|
||||
if (result == nullptr || !respawn::is_player(result))
|
||||
return nullptr;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
respawn::color_t respawn::get_player_color(respawn::c_player* player)
|
||||
{
|
||||
const auto& local_player = g::p::cache.local_player;
|
||||
|
||||
if (player == nullptr || player->life_state() != 0)
|
||||
return colors::white;
|
||||
|
||||
//
|
||||
// dummy
|
||||
// skip do bleed out checks and such.
|
||||
//
|
||||
if (respawn::is_dummy(player))
|
||||
return colors::yellow;
|
||||
|
||||
//
|
||||
// bleeding out
|
||||
//
|
||||
if (player->bleed_out_state() != 0)
|
||||
return colors::red;
|
||||
|
||||
//
|
||||
// team mate
|
||||
//
|
||||
if (is_teammate(player))
|
||||
return colors::cyan;
|
||||
|
||||
//
|
||||
// opponent
|
||||
//
|
||||
return colors::yellow;
|
||||
}
|
||||
|
||||
void* get_create_interface()
|
||||
{
|
||||
using fn = void* (__fastcall)();
|
||||
|
||||
const auto fn_address = dyn_addr::get_dynamic_address(_XS("fn_create_interface"));
|
||||
auto* const fn_ptr = mem::addr(fn_address).As<fn*>();
|
||||
|
||||
return fn_ptr();
|
||||
}
|
||||
|
||||
void* respawn::create_interface(const char* name)
|
||||
{
|
||||
auto* const fn_ptr = mem::addr(get_create_interface()).As<create_interface_fn>();
|
||||
|
||||
if (fn_ptr == nullptr)
|
||||
return nullptr;
|
||||
|
||||
return fn_ptr(name, 0);
|
||||
}
|
||||
|
||||
int respawn::get_sequence_count(void* model)
|
||||
{
|
||||
auto v6 = *(uint64_t*)(BASE_OF(model) + 16);
|
||||
|
||||
int numseq = v6 ? *(uint32_t*)(v6 + 32) : *(uint32_t*)(*(uint64_t*)(BASE_OF(model) + 8) + 192i64);
|
||||
|
||||
return numseq;
|
||||
}
|
||||
|
||||
respawn::mstudioseqdesc_t* respawn::seq_desc(void* model, int sequence)
|
||||
{
|
||||
using fn = mstudioseqdesc_t* (__fastcall*)(void*, int);
|
||||
|
||||
const auto fn_address = dyn_addr::get_dynamic_address(_XS("fn_seq_desc"));
|
||||
auto* const fn_ptr = mem::addr(fn_address).As<fn>();
|
||||
|
||||
return fn_ptr(model, sequence);
|
||||
}
|
||||
|
||||
respawn::entity_types respawn::get_entity_type(c_entity* entity)
|
||||
{
|
||||
auto identifier = entity->identifier();
|
||||
|
||||
if (!identifier)
|
||||
return entity_types::NONE;
|
||||
|
||||
auto hash = *(uint64_t*)( identifier );
|
||||
auto result = respawn::entity_types{};
|
||||
|
||||
for (auto i = 0ull; i < _ident_table.count(); i++)
|
||||
{
|
||||
auto* const entry = _ident_table[i];
|
||||
|
||||
if (entry == nullptr)
|
||||
continue;
|
||||
|
||||
if (hash == _XC(entry->first))
|
||||
return entry->second;
|
||||
}
|
||||
|
||||
return entity_types::UNKNOWN;
|
||||
}
|
||||
|
||||
uint64_t respawn::get_entity_identifier(c_entity* entity)
|
||||
{
|
||||
auto identifier = entity->identifier();
|
||||
|
||||
if (!identifier)
|
||||
return 0;
|
||||
|
||||
auto hash = *(uint64_t*)(identifier);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
bool respawn::is_player(respawn::c_entity* entity, bool player, bool dummy)
|
||||
{
|
||||
auto type = get_entity_type(entity);
|
||||
|
||||
if ((player && type == entity_types::PLAYER) ||
|
||||
(dummy && type == entity_types::DUMMIE)
|
||||
)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool respawn::is_survival_prop(respawn::c_entity* entity)
|
||||
{
|
||||
return get_entity_type(entity) == entity_types::PROP_SURVIVAL;
|
||||
}
|
||||
|
||||
bool respawn::is_of_type(respawn::c_entity* entity, const char* name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool respawn::is_alive(respawn::c_player* player)
|
||||
{
|
||||
return (player->life_state() == LIFE_ALIVE);
|
||||
}
|
||||
|
||||
bool respawn::is_knocked(respawn::c_player* player)
|
||||
{
|
||||
return (player->bleed_out_state() != NULL);
|
||||
}
|
||||
|
||||
respawn::game_modes respawn::get_game_mode()
|
||||
{
|
||||
const auto address = DYN_ADDR("ptr_game_instance_data");
|
||||
|
||||
if (address)
|
||||
{
|
||||
auto base = *(uintptr_t*)address;
|
||||
|
||||
if (base)
|
||||
{
|
||||
auto name = *(const char**)(base + 0x58);
|
||||
auto length = stl::strlen(name);
|
||||
|
||||
if (length)
|
||||
{
|
||||
auto hash = crc_calculate32(name, length);
|
||||
|
||||
switch (hash)
|
||||
{
|
||||
case 0xe765d4cd: return game_modes::survival;
|
||||
case 0xeddb2c4b: return game_modes::control;
|
||||
case 0x0a235588: return game_modes::arenas;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return game_modes::invalid;
|
||||
}
|
||||
|
||||
void respawn::start_drawing(respawn::c_mat_system_surface* mssf)
|
||||
{
|
||||
if (mssf == nullptr)
|
||||
return;
|
||||
|
||||
using fn = void(__fastcall*)(void*);
|
||||
|
||||
const auto address = dyn_addr::get_dynamic_address(_XS("paint_start_drawing"));
|
||||
const auto function = reinterpret_cast<fn>(address);
|
||||
|
||||
if (!address || !function)
|
||||
return;
|
||||
|
||||
return function(mssf);
|
||||
}
|
||||
|
||||
void respawn::finish_drawing()
|
||||
{
|
||||
using fn = void(__fastcall*)();
|
||||
|
||||
const auto address = dyn_addr::get_dynamic_address(_XS("paint_finish_drawing"));
|
||||
const auto function = reinterpret_cast<fn>(address);
|
||||
|
||||
if (!address || !function)
|
||||
return;
|
||||
|
||||
return function();
|
||||
}
|
||||
|
||||
bool respawn::world_to_screen(math::Vector3& vIn, math::Vector3& vOut)
|
||||
{
|
||||
auto pvMatrix = ix::view_render->get_view_matrix();
|
||||
|
||||
if (pvMatrix == nullptr)
|
||||
return false;
|
||||
|
||||
auto vMatrix = *pvMatrix;
|
||||
|
||||
vOut.x = vMatrix.m[0][0] * vIn.x + vMatrix.m[0][1] * vIn.y + vMatrix.m[0][2] * vIn.z + vMatrix.m[0][3];
|
||||
vOut.y = vMatrix.m[1][0] * vIn.x + vMatrix.m[1][1] * vIn.y + vMatrix.m[1][2] * vIn.z + vMatrix.m[1][3];
|
||||
|
||||
float w = vMatrix.m[3][0] * vIn.x + vMatrix.m[3][1] * vIn.y + vMatrix.m[3][2] * vIn.z + vMatrix.m[3][3];
|
||||
|
||||
if (w < 0.01)
|
||||
return false;
|
||||
|
||||
float invw = 1.0f / w;
|
||||
|
||||
vOut.x *= invw;
|
||||
vOut.y *= invw;
|
||||
|
||||
const auto Cl_width = g::p::screen.w;
|
||||
const auto Cl_height = g::p::screen.h;
|
||||
|
||||
auto x = static_cast<float>(Cl_width) / 2.f;
|
||||
auto y = static_cast<float>(Cl_height) / 2.f;
|
||||
|
||||
x += 0.5f * vOut.x * Cl_width + 0.5f;
|
||||
y -= 0.5f * vOut.y * Cl_height + 0.5f;
|
||||
|
||||
vOut.x = x;
|
||||
vOut.y = y;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void respawn::on_update_cache(respawn::c_player* me, respawn::c_weapon* my_wpn, respawn::c_net_chan* nc)
|
||||
{
|
||||
auto& cache = g::p::cache;
|
||||
|
||||
auto& local_player_data = cache.local_player;
|
||||
auto& local_weapon_data = cache.local_weapon;
|
||||
|
||||
auto& net_chan_data = cache.net_chan;
|
||||
|
||||
local_player_data.index = ix::engine_client->get_local_player();
|
||||
local_player_data.address = mem::addr(me).Base();
|
||||
local_player_data.team_number = me->team_number();
|
||||
local_player_data.origin = me->origin();
|
||||
local_player_data.eye_angle = me->eye_angles();
|
||||
local_player_data.zooming = me->is_zooming();
|
||||
local_player_data.shoot_pos = me->view_offset();
|
||||
|
||||
if ( !(my_wpn == nullptr) )
|
||||
{
|
||||
local_weapon_data.address = mem::addr(my_wpn).Base();
|
||||
local_weapon_data.reloading = my_wpn->is_reloading();
|
||||
local_weapon_data.next_primary_attack = my_wpn->next_primary_attack();
|
||||
local_weapon_data.next_ready_time = my_wpn->next_ready_time();
|
||||
local_weapon_data.can_fire = my_wpn->can_fire(me);
|
||||
}
|
||||
|
||||
net_chan_data.out_sequence_nr = nc->out_sequence_nr();
|
||||
net_chan_data.num_choked_packets = nc->num_choked_packets();
|
||||
}
|
||||
|
||||
bool respawn::is_teammate(c_player* player)
|
||||
{
|
||||
if (player == nullptr)
|
||||
return false;
|
||||
|
||||
const auto& lp_data = g::p::cache.local_player;
|
||||
const auto is_control = (g::p::game_mode == game_modes::control);
|
||||
|
||||
if (is_control)
|
||||
{
|
||||
auto convert_team = [](int num)
|
||||
{
|
||||
return ( (num % 2) ? 1: 2 );
|
||||
};
|
||||
|
||||
return (convert_team(player->team_number()) == convert_team(lp_data.team_number));
|
||||
}
|
||||
|
||||
return (player->team_number() == lp_data.team_number);
|
||||
}
|
||||
|
||||
bool respawn::get_entity_center_pos(respawn::c_entity* entity, math::Vector3& result)
|
||||
{
|
||||
if (entity == nullptr)
|
||||
return false;
|
||||
|
||||
auto collision = entity->collision();
|
||||
|
||||
if (collision == nullptr)
|
||||
return false;
|
||||
|
||||
auto mins = collision->vec_mins();
|
||||
auto maxs = collision->vec_maxs();
|
||||
|
||||
result = entity->origin();
|
||||
result.z += (mins.z + maxs.z) * 0.5f;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void respawn::script::dump_to_disk(const char* name, char* buffer, size_t length)
|
||||
{
|
||||
if (!name || !buffer || !length)
|
||||
{
|
||||
log_info_("invalid params!");
|
||||
return;
|
||||
}
|
||||
|
||||
char path_fmt[MAX_PATH];
|
||||
char path_base[MAX_PATH];
|
||||
|
||||
memset(path_fmt, 0, sizeof(path_fmt));
|
||||
memset(path_base, 0, sizeof(path_base));
|
||||
|
||||
if (!util::get_desktop_directory(path_base, sizeof(path_base)))
|
||||
{
|
||||
log_info_("failed to get desktop directory.");
|
||||
return;
|
||||
}
|
||||
|
||||
util::format_string(path_fmt, sizeof(path_fmt), _XS("%s\\RSPN\\%s"), path_base, stl::basename(name));
|
||||
|
||||
if (util::file_exists(path_fmt))
|
||||
{
|
||||
log_info_("!! skipping existing script file.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (util::write_data_reg(buffer, length, path_fmt))
|
||||
{
|
||||
log_info_("!! dumped file to disk.");
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info_("!! failed to dump file.");
|
||||
}
|
||||
}
|
||||
|
||||
void respawn::script::override_from_disk(const char* name, char* buffer, size_t* length)
|
||||
{
|
||||
char override_file_path[MAX_PATH];
|
||||
char path_base[MAX_PATH];
|
||||
|
||||
wchar_t override_file_path_wide[MAX_PATH];
|
||||
|
||||
memset(override_file_path, 0, sizeof(override_file_path));
|
||||
memset(override_file_path_wide, 0, sizeof(override_file_path_wide));
|
||||
memset(path_base, 0, sizeof(path_base));
|
||||
|
||||
if (!util::get_desktop_directory(path_base, sizeof(path_base)))
|
||||
{
|
||||
log_info_("failed to get desktop directory.");
|
||||
return;
|
||||
}
|
||||
|
||||
util::format_string(override_file_path, sizeof(override_file_path), _XS("\\??\\%s\\RSPN\\%s"), path_base, stl::basename(name));
|
||||
stl::mbstowcs(override_file_path_wide, override_file_path, 0, sizeof(override_file_path_wide));
|
||||
|
||||
if (!util::file_exists(override_file_path))
|
||||
{
|
||||
dump_to_disk(name, buffer, *length);
|
||||
return;
|
||||
}
|
||||
|
||||
auto override_file_length = util::get_file_size(override_file_path);
|
||||
|
||||
if (override_file_length <= 0)
|
||||
return;
|
||||
|
||||
auto override_file_buffer = stl::mem_alloc<char*>( static_cast<size_t>(override_file_length) + 1);
|
||||
|
||||
if (!override_file_buffer)
|
||||
return;
|
||||
|
||||
memset(override_file_buffer, 0, static_cast<size_t>(override_file_length) + 1);
|
||||
|
||||
if (util::read_file_ex(override_file_path_wide, override_file_buffer, override_file_length))
|
||||
{
|
||||
*length = override_file_length;
|
||||
|
||||
memcpy(buffer, override_file_buffer, static_cast<size_t>(override_file_length) + 1);
|
||||
|
||||
//log_info("!! overridden the script file '%s'.", stl::basename(name));
|
||||
}
|
||||
|
||||
stl::mem_free(override_file_buffer);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#include <include.h>
|
||||
|
||||
using namespace respawn;
|
||||
|
||||
bool c_weapon::can_fire(c_player* owner) noexcept
|
||||
{
|
||||
auto np_attack = next_primary_attack();
|
||||
auto current_time = owner->server_time();
|
||||
|
||||
if (is_reloading())
|
||||
return false;
|
||||
|
||||
return ( np_attack <= current_time);
|
||||
}
|
||||
|
||||
void c_weapon::set_legendary_view_model_index(int64_t idx) noexcept
|
||||
{
|
||||
auto address = DYN_ADDR("fn_set_legendary_view_model");
|
||||
|
||||
if (!address)
|
||||
return report_failure();
|
||||
|
||||
using fn = int64_t(__thiscall*)(c_weapon*, int64_t);
|
||||
auto func = reinterpret_cast<fn>(address);
|
||||
|
||||
func(this, idx);
|
||||
}
|
||||
Reference in New Issue
Block a user