Add files via upload
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
# Set the default target
|
||||
all: build
|
||||
|
||||
# Custom LLVM compiler and its flags
|
||||
LLVM_CXX := $(LLVM_PATH)clang++
|
||||
LLVM_FLAGS := -m64 -nostdlib -fno-exceptions \
|
||||
-std=c++17 -Wno-macro-redefined -O1 -fno-builtin -Wno-microsoft-cast -ffreestanding \
|
||||
-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH -fuse-ld=lld-link \
|
||||
-Wl,-entry:_kb -Wl,-base:0x1400000 -Wl,-force:multiple \
|
||||
-mllvm -aesSeed=${GLCI_AES_SEED} -mllvm -csobf -fno-ident -I"C:/src/obfuscator-drause/Headers/" \
|
||||
-fdata-sections -ffunction-sections -Wno-unused-command-line-argument \
|
||||
-D_WATERMARKED_USER=${GLCI_WATERMARKED_USER} -D_COMPILED_AES_SEED_VALUE=${GLCI_AES_SEED}
|
||||
|
||||
LLVM_ASMFLAGS := -m64 -nostdlib \
|
||||
-O0 -Wno-microsoft-cast -fuse-ld=lld-link
|
||||
|
||||
LLVM_LD_FLAGS := -fno-unwind-tables \
|
||||
-shared -Wl,-entry:_kb -Wl,-base:0x1400000 -Wl,-force:multiple
|
||||
|
||||
# Source and object files
|
||||
SRCDIR := r5/src
|
||||
SRCFEATURESDIR := r5/src/features
|
||||
OBJDIR := obj
|
||||
|
||||
SRC := $(wildcard $(SRCDIR)/*.cpp) $(wildcard $(SRCDIR)/*/*.cpp) $(wildcard $(SRCDIR)/*.asm)
|
||||
OBJ := $(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.o, $(filter %.cpp,$(SRC))) \
|
||||
$(patsubst $(SRCDIR)/%.asm, $(OBJDIR)/%.o, $(filter %.asm,$(SRC)))
|
||||
|
||||
EXECUTABLE := r5.dll
|
||||
|
||||
# Build the project using the LLVM compiler
|
||||
build: $(OBJ)
|
||||
@echo "Linking..."
|
||||
$(LLVM_CXX) $(LLVM_FLAGS) $(OBJ) -o $(EXECUTABLE) $(LLVM_LD_FLAGS)
|
||||
|
||||
# Compile individual source files
|
||||
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp | $(OBJDIR)
|
||||
$(LLVM_CXX) $(LLVM_FLAGS) -c $< -o $@
|
||||
# Compile assembly
|
||||
$(OBJDIR)/%.o: $(SRCDIR)/%.asm | $(OBJDIR)
|
||||
$(LLVM_CXX) $(LLVM_ASMFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR):
|
||||
@if not exist "$(OBJDIR)" mkdir "$(OBJDIR)"
|
||||
@if not exist "$(OBJDIR)\features" mkdir "$(OBJDIR)\features"
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@echo "Cleaning up..."
|
||||
rm -f $(OBJ) $(EXECUTABLE)
|
||||
|
||||
# CAN SAFELY IGNORE ARG UNUSED WARNINGS AS LONG AS
|
||||
# THEY HAPPEN DURING LINKING PROCESS LIKE THIS:
|
||||
# clang++ -m64 -nostdlib -fno-exceptions -std=c++17 -Wno-macro-redefined -O1 -fno-builtin -Wno-microsoft-cast -ffreestanding -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH -fuse-ld=lld-link -mllvm -aesSeed=2717D2F4FD2CA7D1A7F5251A5EE4DB80 -mllvm -csobf -fno-ident -I"C:/src/obfuscator11/Headers/" obj/core.o obj/defs.o obj/entcache.o obj/entity.o obj/hooks.o obj/input.o obj/logger.o obj/main.o obj/math.o obj/menu.o obj/netvars.o obj/r5ac.o obj/renderer.o obj/respawn.o obj/spectator_list.o obj/stl.o obj/tools.o obj/vft.o obj/features/esp.o obj/features/movement.o obj/hook-tramps.o obj/stackcheck.o -o r5.dll -shared -Wl,-entry:_kb -Wl,-base:0x1400000 -Wl,-force:multiple -fno-unwind-tables -fdata-sections -ffunction-sections
|
||||
#clang++: warning: argument unused during compilation: '-mllvm -aesSeed=2717D2F4FD2CA7D1A7F5251A5EE4DB80' [-Wunused-command-line-argument]
|
||||
#clang++: warning: argument unused during compilation: '-mllvm -csobf' [-Wunused-command-line-argument]
|
||||
#clang++: warning: argument unused during compilation: '-fno-ident' [-Wunused-command-line-argument]
|
||||
#lld-link: warning: duplicate symbol: Xstr_decrypt
|
||||
# THEY ARE ACTUALLY USED DURING COMPILATION, BUT NOT DURING LINKAGE. I CBA TO MAINTAIN 2 ARG LISTS SO KEEP IT LIKE THIS.
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
del r5.dll
|
||||
rd /s /q obj
|
||||
make -j 4
|
||||
remove_compiler_padding.exe r5.dll 1> remove_comp_padding_results.txt 2> remove_comp_padding_errors.txt
|
||||
@@ -0,0 +1,9 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
void nv::collision::init()
|
||||
{
|
||||
NETVAR_ASSIGN(&vec_mins, "DT_CollisionProperty", "m_vecMins");
|
||||
NETVAR_ASSIGN(&vec_maxs, "DT_CollisionProperty", "m_vecMaxs");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
namespace core
|
||||
{
|
||||
#if defined(DECLARE_AS_DEBUG_BUILD)
|
||||
LLVM_NOOPT void test_render_apis(respawn::Mat_system_surface* mss) LLVMT(LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
mss->draw_text( 2, 14, { 50, 50 }, rs::clr::white, "Hello, World!" );
|
||||
|
||||
render::line( { 250, 250 }, {500, 500}, rs::clr::white );
|
||||
render::rect( {510, 510 }, {550, 550}, rs::clr::black );
|
||||
render::rect_filled( {560, 560}, {600, 600}, rs::clr::white );
|
||||
}
|
||||
#endif
|
||||
|
||||
LLVM_NOOPT void on_render(int mode) LLVMT(LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
if (!hooks::inited_deferred)
|
||||
{
|
||||
hooks::init_deferred();
|
||||
hooks::inited_deferred = true;
|
||||
}
|
||||
|
||||
auto mss = g.ix.mss;
|
||||
|
||||
g.inputs.ui.tick_begin();
|
||||
render::mss = mss;
|
||||
if (!is_valid_session())
|
||||
{
|
||||
g.inputs.ui.tick_end();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode == 2)
|
||||
{
|
||||
auto me = local_player();
|
||||
if (me.is_valid())
|
||||
{
|
||||
EC::tick(me);
|
||||
EC::render(mss);
|
||||
features::on_esp(mss, me);
|
||||
}
|
||||
|
||||
menu::on_render(mss);
|
||||
}
|
||||
|
||||
g.inputs.ui.tick_end();
|
||||
}
|
||||
|
||||
void on_level_init(const char *map) LLVMT(LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
auto map_hash = *reinterpret_cast<const u64 *>(map);
|
||||
if (map_hash != decrypt_constant(encrypt_constant(0x7962626f6c5f706d)))
|
||||
{
|
||||
/* in an actual game*/
|
||||
g.ix.mss->get_screen_size(g.screen_dim[0], g.screen_dim[1]);
|
||||
|
||||
g.ingame = true;
|
||||
} else
|
||||
{
|
||||
g.inlobby = true;
|
||||
}
|
||||
}
|
||||
|
||||
void on_level_shutdown() LLVMT(LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
g.ingame = false;
|
||||
g.inlobby = false;
|
||||
|
||||
EC::reset();
|
||||
g.r5ac_debug_pane_draw_time = 0.f;
|
||||
features::anonymizer_reset();
|
||||
}
|
||||
|
||||
LLVM_NOOPT bool is_firing_range() LLVMT(LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
for (int i = 0; i < RS_ENTITY_LIST_SPACE; i++)
|
||||
{
|
||||
auto field = &g.ent_list[i];
|
||||
if (!field->ptr)
|
||||
continue;
|
||||
|
||||
auto ent_base = field->ptr;
|
||||
|
||||
auto ent = Entity(ent_base);
|
||||
if (!ent.is_valid())
|
||||
continue;
|
||||
|
||||
if (ent.is_dummie())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
__declspec(noinline) u64 decrypt_constant(u64 value)
|
||||
{
|
||||
volatile u64 rs = __ROR8__(value ^ BUILD_SEED, 2);
|
||||
return rs;
|
||||
}
|
||||
@@ -0,0 +1,366 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
namespace EC
|
||||
{
|
||||
record* _table = nullptr;
|
||||
size_t _table_len = 0;
|
||||
size_t _table_cap = 0;
|
||||
session_data _session_data;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initial setup for the entity cache.
|
||||
* allocates required lists and sets boundaries.
|
||||
*/
|
||||
bool EC::init()
|
||||
{
|
||||
_table_cap = RS_ENTITY_LIST_SPACE;
|
||||
_table_len = (_table_cap * sizeof(record));
|
||||
|
||||
if(!_table_cap || !_table_len)
|
||||
return false;
|
||||
|
||||
_table = reinterpret_cast<record*>( g.ix.mm->alloc(_table_len) );
|
||||
|
||||
if(_table == nullptr)
|
||||
return false;
|
||||
|
||||
reset( );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Performs a reset of entity cache.
|
||||
* no data will be preserved after a call to here.
|
||||
*/
|
||||
void EC::reset()
|
||||
{
|
||||
memset( _table, 0, _table_len );
|
||||
memset( &_session_data, 0, sizeof(_session_data) );
|
||||
}
|
||||
|
||||
void EC::tick(Entity& me)
|
||||
{
|
||||
if(detail::should_refresh())
|
||||
{
|
||||
_session_data.tick_last_refreshed = Plat_FloatTick();
|
||||
update(me);
|
||||
}
|
||||
}
|
||||
|
||||
void EC::render(respawn::Mat_system_surface* mss)
|
||||
{
|
||||
show_debug_stats(mss);
|
||||
}
|
||||
|
||||
void EC::show_debug_stats(respawn::Mat_system_surface* mss)
|
||||
{
|
||||
#if defined(DECLARE_AS_DEBUG_BUILD)
|
||||
int push = 0;
|
||||
|
||||
int start_x = (g.screen_dim[0] / 2) - 400, start_y = 25;
|
||||
|
||||
mss->draw_text(2, 14, {start_x, start_y + push}, rs::clr::white, "EC_Tbl: %p", _table);
|
||||
push += 15;
|
||||
|
||||
mss->draw_text(2, 14, {start_x, start_y + push}, rs::clr::white, "EC_Cap: %i", _table_cap);
|
||||
push += 15;
|
||||
|
||||
mss->draw_text(2, 14, {start_x, start_y + push}, rs::clr::white, "EC_tick_last_refreshed: %i", _session_data.tick_last_refreshed);
|
||||
push += 15;
|
||||
|
||||
mss->draw_text(2, 14, {start_x, start_y + push}, rs::clr::white, "EC_num_invalidations: %i", _session_data.stats.num_invalidations);
|
||||
push += 15;
|
||||
|
||||
mss->draw_text(2, 14, {start_x, start_y + push}, rs::clr::white, "EC_HighestEIDX: %i", get_highest_eidx());
|
||||
push += 15;
|
||||
|
||||
mss->draw_text(2, 14, {start_x, start_y + push}, rs::clr::white, "R5_MaxClients: %i", g.gvars->MaxClients);
|
||||
push += 15;
|
||||
#endif
|
||||
}
|
||||
|
||||
void EC::update(Entity& me)
|
||||
{
|
||||
int highest_eidx = get_highest_eidx();
|
||||
|
||||
auto my_origin = me.origin();
|
||||
|
||||
for (int i = 0; i <= highest_eidx; i++)
|
||||
{
|
||||
auto field = &g.ent_list[i];
|
||||
if (!field->ptr)
|
||||
continue;
|
||||
|
||||
auto rec = get(i);
|
||||
auto ent_base = field->ptr;
|
||||
|
||||
auto ent = Entity(ent_base);
|
||||
|
||||
if(!handle_generic(ent, rec))
|
||||
{
|
||||
invalidate(rec);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* STARTING FROM HERE, WE GOT ENTITY SPECIFIC LIVE DATA (OR NOT) */
|
||||
|
||||
if (ent.is_player() || ent.is_dummie())
|
||||
{
|
||||
handle_combat_entity(me, my_origin, ent, rec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool EC::handle_generic(Entity &ent, record *rec)
|
||||
{
|
||||
/* we only want valid entities. */
|
||||
if (!ent.is_valid())
|
||||
return false;
|
||||
|
||||
/* at this point we only know it's a valid entity.
|
||||
* let's do some core details caching so we don't need to
|
||||
* request these expensive infos again about the current thing.
|
||||
*/
|
||||
bool has_cache_avail = (rec->valid && rec->eidx != -1);
|
||||
if(!has_cache_avail)
|
||||
{
|
||||
/* first occurrence */
|
||||
if(!make_initial_record_cache(ent, rec))
|
||||
{
|
||||
/* should not happen, but if it did, it seems like we couldn't
|
||||
* cache given entity at this time. that's weird! */
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
{
|
||||
if(!is_cached_record_valid(ent, rec))
|
||||
{
|
||||
/* seems like our cached record has expired :( */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* if it's still good, we got nothing to do, yay :) */
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void EC::handle_combat_entity(Entity& me, const Vec3& my_origin, Entity& ent, record* rec) LLVMT( LLVMOBF_INLINE_FP() )
|
||||
{
|
||||
/* we got an entity of our interest, that being related to combat. */
|
||||
|
||||
rec->is_alive = ent.is_alive();
|
||||
|
||||
if(rec->is_alive_prev == true && rec->is_alive == false)
|
||||
{
|
||||
/* seems like entity has just died. */
|
||||
rec->bounds[0] = 0.f;
|
||||
rec->bounds[1] = 0.f;
|
||||
rec->bscr_head_avail = false;
|
||||
rec->bscr_origin_avail = false;
|
||||
rec->bscr_center_avail = false;
|
||||
|
||||
rec->vec_head[0] = VEC_EMPTY;
|
||||
rec->vec_head[1] = VEC_EMPTY;
|
||||
rec->vec_origin[0] = VEC_EMPTY;
|
||||
rec->vec_origin[1] = VEC_EMPTY;
|
||||
rec->vec_center[0] = VEC_EMPTY;
|
||||
rec->vec_center[1] = VEC_EMPTY;
|
||||
}
|
||||
|
||||
rec->is_alive_prev = rec->is_alive;
|
||||
|
||||
if (rec->is_alive)
|
||||
{
|
||||
bool ignore_range = ( g.conf.visual_far == true || me.is_sky_diving() );
|
||||
|
||||
// skip objects that are too far.
|
||||
// if DIST exceeds LIMIT AND should NOT IGNORE_RANGE : mark it not available ;
|
||||
// if FAR_ESP is TRUE or LOCAL_PLAYER_IS_SKY_DIVING THEN IGNORE_RANGE TRUE ;
|
||||
bool outside_range = rec->dist_to_local > 10000.f && !ignore_range;
|
||||
|
||||
rec->vec_origin[0] = ent.origin();
|
||||
rec->vec_head[0] = ent.get_bone_pos(12);
|
||||
rec->vec_center[0] = ent.get_center_pos();
|
||||
|
||||
if (!outside_range)
|
||||
{
|
||||
rec->bscr_origin_avail = respawn::w2s(rec->vec_origin[0], rec->vec_origin[1]);
|
||||
rec->bscr_head_avail = respawn::w2s(rec->vec_head[0], rec->vec_head[1]);
|
||||
rec->bscr_center_avail = respawn::w2s(rec->vec_center[0], rec->vec_center[1]);
|
||||
|
||||
if (!rec->bscr_head_avail || !rec->bscr_origin_avail)
|
||||
{
|
||||
rec->fov_to_local = 2000.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
rec->fov_to_local = math::get_fov_difference(me.view_angle(), me.view_pos(), rec->vec_center[0]);
|
||||
}
|
||||
} else
|
||||
{
|
||||
rec->bscr_origin_avail = false;
|
||||
rec->bscr_head_avail = false;
|
||||
rec->bscr_center_avail = false;
|
||||
|
||||
rec->fov_to_local = 2000.f;
|
||||
}
|
||||
|
||||
rec->is_visible = ent.last_vis_time() >= Plat_FloatTime();
|
||||
|
||||
memcpy(&rec->rgfl_coordinate_frame, &ent.rgfl_coordinate_frame(), sizeof(matrix3x4));
|
||||
auto pcoll = ent.collision();
|
||||
if (pcoll != nullptr)
|
||||
{
|
||||
rec->vec_bounds[0] = pcoll->vec_mins();
|
||||
rec->vec_bounds[1] = pcoll->vec_maxs();
|
||||
}
|
||||
rec->rpts_avail = respawn::setup_render_points(
|
||||
rec->rgfl_coordinate_frame,
|
||||
rec->vec_bounds[0],
|
||||
rec->vec_bounds[1],
|
||||
rec->rpts);
|
||||
|
||||
if (!rec->tick_last_live_update || rec->tick_last_live_update != Plat_FloatTick())
|
||||
{
|
||||
rec->is_ally_of_local = ent.is_ally_of(me);
|
||||
rec->health[0] = ent.health();
|
||||
rec->health[1] = ent.health_max();
|
||||
rec->armor[0] = ent.armor();
|
||||
rec->armor[1] = ent.armor_max();
|
||||
|
||||
if (!outside_range)
|
||||
{
|
||||
if (rec->bscr_head_avail && rec->bscr_origin_avail)
|
||||
{
|
||||
rec->bounds[1] = math::fabsf(rec->vec_head[1].y - rec->vec_origin[1].y);
|
||||
float ratio = 2.5f;
|
||||
rec->bounds[0] = (rec->bounds[1] / ratio);
|
||||
} else
|
||||
{
|
||||
rec->bounds[0] = 0.f;
|
||||
rec->bounds[1] = 0.f;
|
||||
}
|
||||
} else
|
||||
{
|
||||
rec->bounds[0] = 0.f;
|
||||
rec->bounds[1] = 0.f;
|
||||
}
|
||||
|
||||
rec->tick_last_live_update = Plat_FloatTick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Below goes data fetches that are not time critical.
|
||||
*/
|
||||
if (!rec->time_last_deferred_update || (Plat_FloatTime() - rec->time_last_deferred_update) > 1.f)
|
||||
{
|
||||
/*
|
||||
* Determine the entity color theme.
|
||||
*/
|
||||
rec->clr = LColor(252, 131, 56);
|
||||
if (rec->is_ally_of_local)
|
||||
rec->clr = LColor(0, 206, 252);
|
||||
rec->dist_to_local = math::sqrtf(rec->vec_origin[0].dist_to(my_origin));
|
||||
|
||||
rec->time_last_deferred_update = Plat_FloatTime();
|
||||
}
|
||||
|
||||
if(!rec->is_ally_of_local)
|
||||
{
|
||||
if(rec->is_visible)
|
||||
{
|
||||
rec->clr = LColor(255, 65, 65);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EC::invalidate(record* rec)
|
||||
{
|
||||
memset(rec, 0, sizeof(record));
|
||||
|
||||
rec->eidx = -1;
|
||||
rec->ptr = 0;
|
||||
rec->identifier_hash = 0;
|
||||
rec->valid = false;
|
||||
|
||||
++_session_data.stats.num_invalidations;
|
||||
}
|
||||
|
||||
EC::record* EC::get(int idx)
|
||||
{
|
||||
if(idx >= _table_cap)
|
||||
return nullptr;
|
||||
|
||||
return &_table[ idx ];
|
||||
}
|
||||
|
||||
int EC::get_highest_eidx()
|
||||
{
|
||||
int result = g.gvars->MaxClients;
|
||||
|
||||
if(core::is_firing_range())
|
||||
result = _table_cap;
|
||||
|
||||
if(result >= _table_cap)
|
||||
result = _table_cap-1;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool EC::is_cached_record_valid(Entity& ent, record* rec)
|
||||
{
|
||||
if(!ent.is_valid())
|
||||
return false;
|
||||
|
||||
if(ent.eidx() == -1)
|
||||
return false;
|
||||
|
||||
if(ent.eidx() != rec->eidx)
|
||||
return false;
|
||||
|
||||
if(ent.base() != rec->ptr)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EC::make_initial_record_cache(Entity& ent, record* rec)
|
||||
{
|
||||
rec->eidx = ent.eidx();
|
||||
rec->ptr = ent.base();
|
||||
rec->identifier_hash = ent.identifier_hash();
|
||||
rec->valid = true;
|
||||
|
||||
if (ent.is_dummie())
|
||||
{
|
||||
strcpy(rec->name, _XS("dummy"));
|
||||
}
|
||||
else if(ent.is_player())
|
||||
{
|
||||
rec->level = ent.get_level();
|
||||
if (!respawn::get_name(ent, rec->name, sizeof(rec->name)))
|
||||
strcpy(rec->name, _XS("????"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EC::detail::should_refresh()
|
||||
{
|
||||
return true;
|
||||
if(!is_valid_session())
|
||||
return false;
|
||||
|
||||
/* updating cached entity core/base data. */
|
||||
|
||||
if(!_session_data.tick_last_refreshed)
|
||||
return true;
|
||||
|
||||
int tick_delta = Plat_FloatTick() - _session_data.tick_last_refreshed;
|
||||
/* for now, check cached core/base data every tick change. */
|
||||
return (tick_delta > 0);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
void nv::entity::init()
|
||||
{
|
||||
NETVAR_ASSIGN(&life_state, "DT_Player", "m_lifeState");
|
||||
NETVAR_ASSIGN(&team_num, "DT_BaseEntity", "m_iTeamNum");
|
||||
NETVAR_ASSIGN(&team_member_index, "DT_BaseEntity", "m_teamMemberIndex");
|
||||
NETVAR_ASSIGN(&squad_id, "DT_BaseEntity", "m_squadID");
|
||||
NETVAR_ASSIGN(&trav_progress, "DT_LocalPlayerExclusive", "m_traversalProgress");
|
||||
NETVAR_ASSIGN(&trav_start_time, "DT_LocalPlayerExclusive", "m_traversalStartTime");
|
||||
NETVAR_ASSIGN(&trav_release_time, "DT_LocalPlayerExclusive", "m_traversalReleaseTime");
|
||||
NETVAR_ASSIGN(&identifier_base, "DT_BaseEntity", "m_iSignifierName");
|
||||
NETVAR_ASSIGN(&health, "DT_Player", "m_iHealth");
|
||||
NETVAR_ASSIGN(&health_max, "DT_Player", "m_iMaxHealth");
|
||||
NETVAR_ASSIGN(&armor, "DT_BaseEntity", "m_shieldHealth");
|
||||
NETVAR_ASSIGN(&armor_max, "DT_BaseEntity", "m_shieldHealthMax");
|
||||
NETVAR_ASSIGN(&fflags, "DT_Player", "m_fFlags");
|
||||
NETVAR_ASSIGN(&bleed_out_state, "DT_Player", "m_bleedoutState");
|
||||
NETVAR_ASSIGN(&latest_primary_weapon, "DT_BaseCombatCharacter", "m_latestPrimaryWeapons");
|
||||
NETVAR_ASSIGN(&view_model, "DT_Player", "m_hViewModels");
|
||||
NETVAR_ASSIGN(&pcollision, "DT_BaseEntity", "m_Collision");
|
||||
}
|
||||
|
||||
u64 Entity::get_active_weapon()
|
||||
{
|
||||
int index = 0;
|
||||
ehandle handle = latest_primary_weapon();
|
||||
if (!handle)
|
||||
return 0;
|
||||
|
||||
index = RS_EHANDLE_TO_INDEX(handle);
|
||||
if (index == -1)
|
||||
return 0;
|
||||
if (index >= RS_ENTITY_LIST_SPACE)
|
||||
return 0;
|
||||
|
||||
return g.ent_list[index].ptr;
|
||||
}
|
||||
|
||||
u64 Entity::get_view_model()
|
||||
{
|
||||
int index = 0;
|
||||
ehandle handle = view_model();
|
||||
if (!handle)
|
||||
return 0;
|
||||
|
||||
index = RS_EHANDLE_TO_INDEX(handle);
|
||||
if (index == -1)
|
||||
return 0;
|
||||
if (index >= RS_ENTITY_LIST_SPACE)
|
||||
return 0;
|
||||
|
||||
return g.ent_list[index].ptr;
|
||||
}
|
||||
|
||||
bool Entity::is_ally_of(Entity &other)
|
||||
{
|
||||
if (is_dummie() || other.is_dummie())
|
||||
return false;
|
||||
|
||||
auto game_mode = g.game_mode;
|
||||
|
||||
switch (game_mode)
|
||||
{
|
||||
case GameModes::survival:
|
||||
return (other.team_num() == team_num());
|
||||
case GameModes::control:
|
||||
case GameModes::tdm:
|
||||
return (RS_CONVERT_TEAM_MODULO(other.team_num()) == RS_CONVERT_TEAM_MODULO(team_num()));
|
||||
case GameModes::gunrun:
|
||||
return (other.squad_id() == squad_id());
|
||||
}
|
||||
|
||||
/*
|
||||
* Default case should never happen, unless game has updated and a new mode was added.
|
||||
* Make sure to account for this later at some point, as it could be dangerous.
|
||||
*/
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
#include "../inc/include.h"
|
||||
|
||||
namespace features
|
||||
{
|
||||
LLVM_NOOPT Entity rotational_find_target(Entity &me,
|
||||
Vec3 &outpos, float max_dist, float max_fov, float dead_zone, bool& should_slow) LLVMT( LLVMOBF_INLINE_FP(), LLVMOBF_COMBO_STANDARD )
|
||||
{
|
||||
constexpr float fov_treshold = 0.4f;
|
||||
|
||||
auto my_origin = me.origin();
|
||||
auto my_shoot_pos = me.view_pos();
|
||||
auto my_ang = me.view_angle();
|
||||
auto target = Entity(0);
|
||||
|
||||
float closest_fov = max_fov;
|
||||
|
||||
for (int i = 0; i < RS_ENTITY_LIST_SPACE; i++)
|
||||
{
|
||||
auto field = &g.ent_list[i];
|
||||
if (!field->ptr)
|
||||
continue;
|
||||
|
||||
auto ent_base = field->ptr;
|
||||
|
||||
auto ent = Entity(ent_base);
|
||||
if (!ent.is_valid())
|
||||
continue;
|
||||
if (!ent.is_player() && !ent.is_dummie())
|
||||
continue;
|
||||
if (!ent.is_alive())
|
||||
continue;
|
||||
if (ent.base() == me.base())
|
||||
continue;
|
||||
if (ent.is_ally_of(me))
|
||||
continue;
|
||||
|
||||
auto rec = EC::get(ent.eidx());
|
||||
if (!EC::is_cached_record_valid(ent, rec))
|
||||
continue;
|
||||
|
||||
if(!rec->is_visible)
|
||||
continue;
|
||||
|
||||
auto aimpos = ent.get_center_pos();
|
||||
|
||||
auto origin = ent.origin();
|
||||
float dist = math::sqrtf(origin.dist_to(my_origin)) / 100.f;
|
||||
auto fov = math::get_fov_difference(my_ang, my_shoot_pos, aimpos);
|
||||
|
||||
if (dist > max_dist)
|
||||
continue;
|
||||
if (fov > max_fov)
|
||||
continue;
|
||||
|
||||
if(dead_zone > 0.f)
|
||||
{
|
||||
int bubble_begin[2];
|
||||
int bubble_end[2];
|
||||
|
||||
memset(bubble_begin, 0, sizeof(bubble_begin));
|
||||
memset(bubble_end, 0, sizeof(bubble_end));
|
||||
|
||||
if(!rs::math::screen_make_bubble_for_combat_ent(ent, bubble_begin, bubble_end, dead_zone))
|
||||
continue;
|
||||
|
||||
/* here we decide to stop the ROR-AA, because
|
||||
we have a target that is in the dead zone.
|
||||
you do not want it to swap to another target,
|
||||
because we already have one, so focus on that. */
|
||||
if(rs::math::screen_range_is_within_crosshair(bubble_begin, bubble_end))
|
||||
{
|
||||
should_slow = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fov < closest_fov && (closest_fov - fov) >= fov_treshold)
|
||||
{
|
||||
target = ent;
|
||||
outpos = aimpos;
|
||||
closest_fov = fov;
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
LLVM_NOOPT void rotational(Entity &me, float &x, float &y) LLVMT( LLVMOBF_INLINE_FP(),LLVMOBF_COMBO_STANDARD )
|
||||
{
|
||||
if (g.conf.aim_assist_mode == 0 && (x == 0.f && y == 0.f))
|
||||
return;
|
||||
|
||||
if (me.is_sky_diving())
|
||||
return;
|
||||
|
||||
auto my_ang = me.view_angle();
|
||||
auto my_shoot_pos = me.view_pos();
|
||||
auto target_pos = VEC_EMPTY;
|
||||
auto should_slow = false;
|
||||
auto target = rotational_find_target(me, target_pos,
|
||||
12.f, g.conf.aim_assist_fov, g.conf.aim_assist_dead_zone, should_slow);
|
||||
|
||||
if(g.conf.aim_assist_slow && should_slow)
|
||||
{
|
||||
x = (x * g.conf.aim_assist_internal_mouse_scale);
|
||||
y = (y * g.conf.aim_assist_internal_mouse_scale);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.is_valid())
|
||||
{
|
||||
Vec3 aim_ang = VEC_EMPTY;
|
||||
math::vec2ang((target_pos - my_shoot_pos), aim_ang);
|
||||
math::normalize_angle(aim_ang);
|
||||
|
||||
Vec3 aim_delta = (my_ang - aim_ang);
|
||||
math::normalize_angle(aim_delta);
|
||||
|
||||
aim_delta.x /= 0.022f;
|
||||
aim_delta.y /= 0.022f;
|
||||
|
||||
auto vec_mouse = Vec3(x, y, 0.f);
|
||||
auto vec_delta = Vec3(aim_delta.y, -aim_delta.x, 0.f);
|
||||
vec_delta += vec_mouse;
|
||||
|
||||
x += vec_delta.x * g.conf.aim_assist_strength_ror;
|
||||
}
|
||||
}
|
||||
|
||||
LLVM_NOOPT void on_aim_assist(Entity &me, float &x, float &y)
|
||||
{
|
||||
if (!g.conf.aim_assist)
|
||||
return;
|
||||
|
||||
if (g.conf.aim_assist_rotational)
|
||||
rotational(me, x, y);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#include "../inc/include.h"
|
||||
|
||||
namespace /* ANONYMOUS */
|
||||
{
|
||||
float time_last_update = 0.f;
|
||||
}
|
||||
|
||||
namespace features
|
||||
{
|
||||
LLVM_NOOPT void anonymize_player(Entity& ent) LLVMT(LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
auto name_ptr = respawn::get_name_ptr(ent);
|
||||
if(name_ptr != 0)
|
||||
{
|
||||
name_ptr[0] = '\0';
|
||||
}
|
||||
|
||||
auto clantag_ptr = respawn::get_clantag_ptr(ent);
|
||||
if(clantag_ptr != 0)
|
||||
{
|
||||
clantag_ptr[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
LLVM_NOOPT void on_anonymizer() LLVMT(LLVMOBF_INLINE_FP(),LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
if(!g.conf.anon_mode)
|
||||
return;
|
||||
|
||||
if (!time_last_update || (Plat_FloatTime() - time_last_update) > 1.f)
|
||||
{
|
||||
for (int i = 0; i <= RS_MAX_PLAYERS; i++)
|
||||
{
|
||||
auto field = &g.ent_list[i];
|
||||
if (!field->ptr)
|
||||
continue;
|
||||
|
||||
auto ent_base = field->ptr;
|
||||
auto ent = Entity(ent_base);
|
||||
|
||||
if (ent.is_valid() && ent.is_player())
|
||||
{
|
||||
anonymize_player(ent);
|
||||
}
|
||||
}
|
||||
time_last_update = Plat_FloatTime();
|
||||
}
|
||||
}
|
||||
|
||||
LLVM_NOOPT void anonymizer_reset()
|
||||
{
|
||||
time_last_update = 0.f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
#include "../inc/include.h"
|
||||
|
||||
namespace features
|
||||
{
|
||||
LLVM_NOOPT void draw_outline(const rs::math::render_points_t &rp, const LColor &sColor) LLVMT( LLVMOBF_INLINE_FP(),LLVMOBF_COMBO_STANDARD )
|
||||
{
|
||||
render::rect({rp.x - 1.0f, rp.y - 1.0f}, {rp.x + rp.w + 1.0f, rp.y + rp.h + 1.0f}, LColor(5, 5, 5));
|
||||
render::rect({rp.x, rp.y}, {rp.x + rp.w, rp.y + rp.h}, sColor);
|
||||
render::rect({rp.x + 1.0f, rp.y + 1.0f}, {rp.x + rp.w - 1.0f, rp.y + rp.h - 1.0f}, LColor(5, 5, 5));
|
||||
}
|
||||
|
||||
LLVM_NOOPT void draw_bar(const LColor& color, float flX, float flY, float flW, float flH, int current, const int max, bool bg = true) LLVMT( LLVMOBF_INLINE_FP(),LLVMOBF_COMBO_STANDARD )
|
||||
{
|
||||
if (current < 0)
|
||||
current = 0;
|
||||
|
||||
if (current > max)
|
||||
current = max;
|
||||
|
||||
flY -= flH;
|
||||
|
||||
const float base = flH / static_cast<float>(max) * static_cast<float>(current);
|
||||
const float delta = (flH - base);
|
||||
|
||||
const float bar_x = flX;
|
||||
|
||||
if (bg)
|
||||
render::rect_filled({bar_x, flY}, {bar_x + 5.0f, flY + flH}, LColor(5, 5, 5));
|
||||
|
||||
render::rect_filled({bar_x, flY + delta}, {bar_x + 5.0f, flY + flH}, color);
|
||||
|
||||
if (bg)
|
||||
render::rect({bar_x, flY}, {bar_x + 5.0f, flY + flH}, LColor(5, 5, 5));
|
||||
}
|
||||
|
||||
LLVM_NOOPT void draw_bar_vert(const LColor& color, float flX, float flY, float flW, float flH, int current, const int max, bool bg = true, bool outline = false) LLVMT( LLVMOBF_INLINE_FP(),LLVMOBF_COMBO_STANDARD )
|
||||
{
|
||||
if (current < 0)
|
||||
current = 0;
|
||||
|
||||
if (current > max)
|
||||
current = max;
|
||||
|
||||
flW *= 2.f;
|
||||
|
||||
const float base = flW / static_cast<float>(max) * static_cast<float>(current);
|
||||
const float delta = (flW - base);
|
||||
|
||||
const float bar_x = flX + 5.f;
|
||||
const float bar_y = flY + 7.f;
|
||||
const float height = 6.f;
|
||||
|
||||
if (bg)
|
||||
render::rect_filled({bar_x, bar_y}, {bar_x + flW, bar_y + height}, LColor(5, 5, 5));
|
||||
|
||||
render::rect_filled({bar_x, bar_y}, {bar_x + flW - delta, bar_y + height}, color);
|
||||
|
||||
if (bg || outline)
|
||||
render::rect({bar_x, bar_y}, {bar_x + flW, bar_y + height}, LColor(5, 5, 5));
|
||||
}
|
||||
|
||||
LLVM_NOOPT void process_player(respawn::Mat_system_surface *mss, Entity &me, Entity &pl) LLVMT(LLVMOBF_INLINE_FP(),LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
auto rec = EC::get(pl.eidx());
|
||||
if(!EC::is_cached_record_valid(pl, rec))
|
||||
return;
|
||||
|
||||
if (!rec->is_alive || rec->is_ally_of_local)
|
||||
return;
|
||||
|
||||
if(!rec->rpts_avail)
|
||||
return;
|
||||
|
||||
if(rec->rpts.x == 0 || rec->rpts.y == 0 ||
|
||||
rec->rpts.w == 0 || rec->rpts.h == 0)
|
||||
return;
|
||||
|
||||
auto vec_origin_pos = rec->vec_origin[0];
|
||||
auto vec_origin_scr = rec->vec_origin[1];
|
||||
|
||||
if (!rec->bscr_origin_avail)
|
||||
return;
|
||||
|
||||
auto health = rec->health[0];
|
||||
auto armor = rec->armor[0];
|
||||
|
||||
auto clr = rec->clr;
|
||||
auto rpts = rec->rpts;
|
||||
|
||||
const auto draw_pos_top_x = rpts.x;
|
||||
const auto draw_pos_top_y = rpts.y - 23.f;
|
||||
int draw_pos_top_push = 0;
|
||||
|
||||
auto name = rec->name;
|
||||
|
||||
float dist = rec->dist_to_local;
|
||||
if (dist > 10000.f && !me.is_sky_diving())
|
||||
{
|
||||
if (g.conf.visual_far)
|
||||
{
|
||||
if (!g.conf.anon_mode)
|
||||
{
|
||||
mss->draw_text(2, 12, {vec_origin_scr.x, vec_origin_scr.y},
|
||||
clr,
|
||||
name);
|
||||
}
|
||||
|
||||
mss->draw_text(2, 12, {vec_origin_scr.x, vec_origin_scr.y + 14},
|
||||
clr,
|
||||
_XS("[%02d]"), (int)dist);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!g.conf.anon_mode)
|
||||
{
|
||||
mss->draw_text(2, 12, {draw_pos_top_x, draw_pos_top_y - draw_pos_top_push},
|
||||
clr,
|
||||
name);
|
||||
draw_pos_top_push += 15;
|
||||
}
|
||||
|
||||
if (pl.is_player())
|
||||
{
|
||||
mss->draw_text(2, 12, {draw_pos_top_x, draw_pos_top_y - draw_pos_top_push},
|
||||
rs::clr::white,
|
||||
"LVL %i", rec->level);
|
||||
draw_pos_top_push += 15;
|
||||
}
|
||||
|
||||
draw_bar(
|
||||
LColor(25, 158, 25), rpts.x - ((10.f / 2.f) + 2.f),
|
||||
rpts.y + rpts.h, rpts.w, rpts.h,
|
||||
health, rec->health[1], true);
|
||||
|
||||
auto armor_max = rec->armor[1];
|
||||
if (armor_max != 0)
|
||||
{
|
||||
draw_bar_vert(
|
||||
LColor(82, 82, 242), rpts.x - 7.f, rpts.y - 15.f, rpts.w / 2.f, rpts.h,
|
||||
armor, armor_max, true, true);
|
||||
}
|
||||
|
||||
if(g.conf.visual_outline)
|
||||
{
|
||||
draw_outline( rpts, clr );
|
||||
}
|
||||
}
|
||||
|
||||
LLVM_NOOPT void on_esp(respawn::Mat_system_surface *mss, Entity &me) LLVMT( LLVMOBF_COMBO_STANDARD )
|
||||
{
|
||||
if (!g.conf.visual)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < RS_ENTITY_LIST_SPACE; i++)
|
||||
{
|
||||
auto field = &g.ent_list[i];
|
||||
if (!field->ptr)
|
||||
continue;
|
||||
|
||||
auto ent_base = field->ptr;
|
||||
|
||||
auto ent = Entity(ent_base);
|
||||
if (!ent.is_valid())
|
||||
continue;
|
||||
if (!ent.is_player() && !ent.is_dummie())
|
||||
continue;
|
||||
process_player(mss, me, ent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
#include "../inc/include.h"
|
||||
|
||||
namespace /* ANONYMOUS */
|
||||
{
|
||||
#define SUPERGLIDE_STATE_IDLE 0
|
||||
#define SUPERGLIDE_STATE_STARTED 1
|
||||
struct SuperGlideContext
|
||||
{
|
||||
u8 state;
|
||||
u8 force_duck;
|
||||
u8 force_reset;
|
||||
};
|
||||
|
||||
SuperGlideContext sgctx{};
|
||||
}
|
||||
|
||||
namespace features
|
||||
{
|
||||
LLVM_NOOPT void bunnyhop(Entity &me, const rs::In_state &key_duck, const rs::In_state &key_jump) LLVMT(LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
if (!g.hopping)
|
||||
{
|
||||
if (key_duck.active() && key_jump.active())
|
||||
{
|
||||
g.hopping = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (key_duck.state() != rs::InKeyStates::HOLDING)
|
||||
{
|
||||
g.hopping = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(me.flags() & FL_ONGROUND))
|
||||
{
|
||||
key_jump.block();
|
||||
key_jump.reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
key_jump.force();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LLVM_NOOPT bool super_glide(Entity &me, SuperGlideContext *ctx, const rs::In_state &key_duck, const rs::In_state &key_jump) LLVMT(LLVMOBF_INLINE_FP(),LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
auto trav_progress = me.trav_progress();
|
||||
auto trav_start_time = me.trav_start_time();
|
||||
auto trav_release_time = me.trav_release_time();
|
||||
|
||||
switch (ctx->state)
|
||||
{
|
||||
case SUPERGLIDE_STATE_IDLE:
|
||||
{
|
||||
if (trav_start_time >= g.gvars->Curtime)
|
||||
ctx->state = SUPERGLIDE_STATE_STARTED;
|
||||
|
||||
break;
|
||||
}
|
||||
case SUPERGLIDE_STATE_STARTED:
|
||||
{
|
||||
if (ctx->force_duck)
|
||||
{
|
||||
key_duck.tap();
|
||||
key_jump.tap();
|
||||
ctx->force_duck = 0;
|
||||
ctx->force_reset = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ctx->force_reset)
|
||||
{
|
||||
ctx->force_reset = 0;
|
||||
ctx->state = SUPERGLIDE_STATE_IDLE;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (trav_progress >= 0.90f)
|
||||
{
|
||||
key_jump.tap();
|
||||
ctx->force_duck = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void on_movement(Entity &me) LLVMT(LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
if (super_glide(me, &sgctx, g.in_states.duck, g.in_states.jump))
|
||||
{
|
||||
g.in_states.duck.reset();
|
||||
g.in_states.jump.reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
bunnyhop(me, g.in_states.duck, g.in_states.jump);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "../inc/include.h"
|
||||
|
||||
namespace features
|
||||
{
|
||||
LLVM_NOOPT void on_rcs(Entity &me, float &x, float &y) LLVMT( LLVMOBF_INLINE_FP(),LLVMOBF_COMBO_STANDARD )
|
||||
{
|
||||
if (!g.conf.rcs)
|
||||
return;
|
||||
|
||||
if(g.conf.rcs_mode == 0)
|
||||
{
|
||||
if(x == 0.f && y == 0.f)
|
||||
return;
|
||||
}
|
||||
|
||||
auto recoil = me.punch_angle();
|
||||
auto my_ang = me.view_angle();
|
||||
auto aim_ang = my_ang - recoil;
|
||||
|
||||
Vec3 aim_delta = (my_ang - aim_ang);
|
||||
|
||||
aim_delta.x /= gfloats.respawn_sens;
|
||||
aim_delta.y /= gfloats.respawn_sens;
|
||||
|
||||
auto vec_mouse = Vec3(x, y, 0.f);
|
||||
auto vec_delta = Vec3(aim_delta.y, -aim_delta.x, 0.f);
|
||||
vec_delta += vec_mouse;
|
||||
|
||||
x += vec_delta.x * g.conf.rcs_internal_mouse_scale;
|
||||
y += vec_delta.y * g.conf.rcs_internal_mouse_scale;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "../inc/include.h"
|
||||
|
||||
namespace features
|
||||
{
|
||||
LLVM_NOOPT void on_trigger(Entity &me) LLVMT(LLVMOBF_COMBO_STANDARD, LLVMOBF_INLINE_FP())
|
||||
{
|
||||
if(!g.conf.trigger)
|
||||
return;
|
||||
|
||||
if(!g.inputs.cmove.is_button_down(rs::Buttons::KB_KEY_SHIFT))
|
||||
return;
|
||||
|
||||
if(g.trigger_reset_attack)
|
||||
{
|
||||
g.in_states.attack.reset();
|
||||
g.in_states.attack.tap();
|
||||
|
||||
g.trigger_reset_attack = false;
|
||||
}
|
||||
|
||||
if (me.is_sky_diving())
|
||||
return;
|
||||
|
||||
auto my_ang = me.view_angle();
|
||||
auto my_shoot_pos = me.view_pos();
|
||||
auto target_pos = VEC_EMPTY;
|
||||
auto should_slow = false;
|
||||
auto target = rotational_find_target(me, target_pos,
|
||||
1200.f, 20.f /* fov does not matter much */, 0.1f /* low dead zone for best accuracy */, should_slow);
|
||||
|
||||
if(should_slow)
|
||||
{
|
||||
g.in_states.attack.force();
|
||||
g.trigger_reset_attack = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
.intel_syntax
|
||||
|
||||
.macro push_gp
|
||||
pushfq
|
||||
push rax
|
||||
push rbx
|
||||
push rcx
|
||||
push rdx
|
||||
push rsi
|
||||
push rdi
|
||||
push rbp
|
||||
push r8
|
||||
push r9
|
||||
push r10
|
||||
push r11
|
||||
push r12
|
||||
push r13
|
||||
push r14
|
||||
push r15
|
||||
.endm
|
||||
|
||||
.macro pop_gp
|
||||
pop r15
|
||||
pop r14
|
||||
pop r13
|
||||
pop r12
|
||||
pop r11
|
||||
pop r10
|
||||
pop r9
|
||||
pop r8
|
||||
pop rbp
|
||||
pop rdi
|
||||
pop rsi
|
||||
pop rdx
|
||||
pop rcx
|
||||
pop rbx
|
||||
pop rax
|
||||
popfq
|
||||
|
||||
.endm
|
||||
|
||||
.global tp_mkrctx_unk1
|
||||
tp_mkrctx_unk1:
|
||||
push_gp
|
||||
sub rsp, 0x28
|
||||
|
||||
mov r8, qword ptr [rsp+0x80+0x28]
|
||||
call hk_mkrctx_unk1
|
||||
|
||||
add rsp, 0x28
|
||||
pop_gp
|
||||
|
||||
jmp qword ptr [rip+ghk_orig_mkrctx_unk1]
|
||||
|
||||
.global tp_on_receive_server_info
|
||||
tp_on_receive_server_info:
|
||||
push_gp
|
||||
sub rsp, 0x28
|
||||
|
||||
call hk_on_receive_server_info
|
||||
|
||||
add rsp, 0x28
|
||||
pop_gp
|
||||
|
||||
jmp qword ptr [rip+ghk_orig_on_receive_server_info]
|
||||
|
||||
.global tp_on_dropped_by_server
|
||||
tp_on_dropped_by_server:
|
||||
push_gp
|
||||
sub rsp, 0x28
|
||||
|
||||
call hk_on_dropped_by_server
|
||||
|
||||
add rsp, 0x28
|
||||
pop_gp
|
||||
|
||||
jmp qword ptr [rip+ghk_orig_on_dropped_by_server]
|
||||
|
||||
.global tp_process_playlist_override
|
||||
tp_process_playlist_override:
|
||||
push_gp
|
||||
sub rsp, 0x28
|
||||
|
||||
call hk_process_playlist_override
|
||||
|
||||
add rsp, 0x28
|
||||
pop_gp
|
||||
|
||||
jmp qword ptr [rip+ghk_orig_process_playlist_override]
|
||||
|
||||
.global tp_init
|
||||
tp_init:
|
||||
push_gp
|
||||
sub rsp, 0x28
|
||||
|
||||
call main
|
||||
|
||||
add rsp, 0x28
|
||||
pop_gp
|
||||
|
||||
xor rax, rax
|
||||
lea rax, qword ptr [rip+gctx]
|
||||
mov rax, qword ptr [rax]
|
||||
|
||||
jmp qword ptr [rax+0x5]
|
||||
|
||||
.global tp_override_mouse
|
||||
tp_override_mouse:
|
||||
push_gp
|
||||
sub rsp, 0x28
|
||||
|
||||
mov rdx, qword ptr [rsp+0x80+0x28]
|
||||
call hk_override_mouse
|
||||
add rsp, 0x28
|
||||
pop_gp
|
||||
|
||||
jmp qword ptr [rip+ghk_orig_override_mouse]
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
uptr ghk_orig_mkrctx_unk1 = 0;
|
||||
uptr ghk_orig_on_receive_server_info = 0;
|
||||
uptr ghk_orig_on_dropped_by_server = 0;
|
||||
uptr ghk_orig_process_playlist_override = 0;
|
||||
uptr ghk_orig_override_mouse = 0;
|
||||
}
|
||||
|
||||
bool hooks::inited_deferred;
|
||||
u32 hooks::vft_disp;
|
||||
u32 hooks::vft_cave_cap;
|
||||
uptr hooks::vft_cave_begin;
|
||||
|
||||
bool hooks::init_early()
|
||||
{
|
||||
LMsg_Short("[hooks] initializing early.");
|
||||
|
||||
hooks::inited_deferred = false;
|
||||
hooks::vft_disp = 0;
|
||||
hooks::vft_cave_cap = 0xBD0;
|
||||
hooks::vft_cave_begin = gctx->game_base + gctx->offsets.vft_caves.generic_1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hooks::init()
|
||||
{
|
||||
LMsg_Short("[hooks] initializing regular.");
|
||||
|
||||
#if defined(DECLARE_AS_DEBUG_BUILD)
|
||||
LMsg(256, "hooks::init() -> vft_cave_01 = begin:%p, end:%p", vft_cave_begin, (vft_cave_begin + vft_cave_cap));
|
||||
#endif
|
||||
|
||||
const auto handle_client_state = [&]()
|
||||
{
|
||||
auto vftcnt = vft::calc_len( *(void**)g.ix.client_state ) + 1;
|
||||
auto vftlm = vft::cave_setup( vftcnt, vft_cave_begin, vft_cave_cap, vft_disp );
|
||||
|
||||
g.vmts.client_state.setup(vftcnt, PTR_OF(g.ix.client_state), vftlm);
|
||||
g.vmts.client_state.place(HOOK_IDX_ON_DROPPED_BY_SERVER, tp_on_dropped_by_server);
|
||||
ghk_orig_on_dropped_by_server = g.vmts.client_state.original<uptr>(HOOK_IDX_ON_DROPPED_BY_SERVER);
|
||||
g.vmts.client_state.enable();
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
const auto handle_client_state_vft3 = [&]()
|
||||
{
|
||||
auto vftcnt = vft::calc_len( *(void**)(BASE_OF(g.ix.client_state) + 0x10) ) + 1;
|
||||
auto vftlm = vft::cave_setup( vftcnt, vft_cave_begin, vft_cave_cap, vft_disp );
|
||||
|
||||
g.vmts.client_state_vft3.setup(vftcnt, PTR_OF((BASE_OF(g.ix.client_state) + 0x10)), vftlm);
|
||||
|
||||
g.vmts.client_state_vft3.place(HOOK_IDX_ON_RECEIVED_SERVER_INFO, tp_on_receive_server_info);
|
||||
ghk_orig_on_receive_server_info = g.vmts.client_state_vft3.original<uptr>(HOOK_IDX_ON_RECEIVED_SERVER_INFO);
|
||||
|
||||
#if !defined(PROD)
|
||||
g.vmts.client_state_vft3.place(HOOK_IDX_PROCESS_PLAYLIST_OVERRIDE, tp_process_playlist_override);
|
||||
ghk_orig_process_playlist_override = g.vmts.client_state_vft3.original<uptr>(HOOK_IDX_PROCESS_PLAYLIST_OVERRIDE);
|
||||
#endif
|
||||
g.vmts.client_state_vft3.enable();
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
const auto handle_kwewed_render_ctx = [&]()
|
||||
{
|
||||
auto vftcnt = vft::calc_len( *(void**)g.ix.mat_kwewed_render_ctx ) + 1;
|
||||
auto vftlm = vft::cave_setup( vftcnt, vft_cave_begin, vft_cave_cap, vft_disp );
|
||||
|
||||
g.vmts.mat_kwewed_render_ctx.setup(vftcnt, PTR_OF(g.ix.mat_kwewed_render_ctx), vftlm);
|
||||
g.vmts.mat_kwewed_render_ctx.place(HOOK_IDX_MKRCTX_UNK1, tp_mkrctx_unk1);
|
||||
ghk_orig_mkrctx_unk1 = g.vmts.mat_kwewed_render_ctx.original<uptr>(HOOK_IDX_MKRCTX_UNK1);
|
||||
g.vmts.mat_kwewed_render_ctx.enable();
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
if(!handle_client_state() || !handle_client_state_vft3())
|
||||
return false;
|
||||
|
||||
if(!handle_kwewed_render_ctx())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hooks::init_deferred()
|
||||
{
|
||||
LMsg_Short("[hooks] initializing deferred.");
|
||||
|
||||
const auto handle_client_mode = [&]()
|
||||
{
|
||||
auto pclient_mode = *g.ix.pclient_mode;
|
||||
|
||||
auto vftcnt = vft::calc_len(*(void **)pclient_mode) + 1;
|
||||
auto vftlm = vft::cave_setup(vftcnt, vft_cave_begin, vft_cave_cap, vft_disp);
|
||||
|
||||
g.vmts.client_mode.setup(vftcnt, PTR_OF(pclient_mode), vftlm);
|
||||
|
||||
g.vmts.client_mode.place(HOOK_IDX_OVERRIDE_MOUSE, tp_override_mouse);
|
||||
ghk_orig_override_mouse = g.vmts.client_mode.original<uptr>(HOOK_IDX_OVERRIDE_MOUSE);
|
||||
|
||||
g.vmts.client_mode.enable();
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
if(!handle_client_mode())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned short __fastcall hk_capture_stack_back_trace(unsigned long frames_to_skip, unsigned long frames_to_capture, void **trace, void *trace_hash)
|
||||
{
|
||||
auto retaddr = BASE_OF(_ReturnAddress()) - gctx->game_base;
|
||||
g.r5ac_stack_walk_last_call = retaddr;
|
||||
|
||||
if(g.conf.anon_mode)
|
||||
{
|
||||
*reinterpret_cast<uptr*>(gctx->game_base + gctx->offsets.string_dict_user_names) = 0;
|
||||
}
|
||||
|
||||
if (retaddr == gctx->offsets.ret_addrs.create_move)
|
||||
{
|
||||
g.inputs.cmove.tick_begin();
|
||||
|
||||
features::on_anonymizer();
|
||||
if (is_valid_session())
|
||||
{
|
||||
auto me = local_player();
|
||||
if (me.is_alive())
|
||||
{
|
||||
if (g.conf.rcs_strength > 0)
|
||||
{
|
||||
float rcs_strength = (static_cast<float>(g.conf.rcs_strength) / 1000.f);
|
||||
g.conf.rcs_internal_mouse_scale = rcs_strength;
|
||||
}
|
||||
|
||||
if (g.conf.aim_assist_strength > 0)
|
||||
{
|
||||
float aa_strength = (static_cast<float>(g.conf.aim_assist_strength) / 100.f);
|
||||
g.conf.aim_assist_internal_mouse_scale = (gfloats.one - aa_strength);
|
||||
}
|
||||
|
||||
features::on_movement(me);
|
||||
features::on_trigger(me);
|
||||
}
|
||||
}
|
||||
|
||||
g.inputs.cmove.tick_end();
|
||||
}
|
||||
|
||||
return 0; /* no traces are available */
|
||||
}
|
||||
|
||||
void __fastcall hk_mkrctx_unk1(void* inst, u64 a2, void* retaddr)
|
||||
{
|
||||
retaddr = reinterpret_cast<void*>( BASE_OF(retaddr) - gctx->game_base );
|
||||
if(retaddr == PTR_OF(gctx->offsets.ret_addrs.mkrctx_unk1))
|
||||
{
|
||||
core::on_render(2);
|
||||
}
|
||||
}
|
||||
|
||||
void __fastcall hk_on_receive_server_info(void* inst, uptr netmsg)
|
||||
{
|
||||
auto mapname = *(const char**)(netmsg + 0x60);
|
||||
|
||||
#if defined(DECLARE_AS_DEBUG_BUILD)
|
||||
LMsg(128, "recv_server_info: %s", mapname);
|
||||
#endif
|
||||
|
||||
core::on_level_init( mapname );
|
||||
}
|
||||
|
||||
/* actually gets called also when DCing manually and because of other shit. */
|
||||
void __fastcall hk_on_dropped_by_server(void* this_ptr, char unk_cond_1, const char* reason)
|
||||
{
|
||||
#if defined(DECLARE_AS_DEBUG_BUILD)
|
||||
LMsg(128, "disconnect: %s", reason);
|
||||
#endif
|
||||
|
||||
core::on_level_shutdown( );
|
||||
|
||||
strcpy(g.last_disconnect_reason, reason);
|
||||
|
||||
if(reason[0] == '#')
|
||||
{
|
||||
if(strstr(reason, "ANTICHEAT_BANNED"))
|
||||
{
|
||||
#if LOGGING_IS_ENABLED == 1
|
||||
msg("client has been exempt from server, account banned.");
|
||||
#endif
|
||||
stl::fps::sleep(20);
|
||||
__fastfail(decrypt_constant(encrypt_constant(0xD1A122)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __fastcall hk_process_playlist_override(void* inst, void* net_msg)
|
||||
{
|
||||
#if !defined(PROD)
|
||||
char* data = reinterpret_cast<char*>(BASE_OF(net_msg) + 0x21);
|
||||
respawn::hijack_playlist_data(data);
|
||||
#endif
|
||||
}
|
||||
|
||||
void __fastcall hk_override_mouse(void *inst, void *retaddr)
|
||||
{
|
||||
auto retaddr_rva = (BASE_OF(retaddr) - gctx->game_base);
|
||||
|
||||
if (retaddr_rva == gctx->offsets.ret_addrs.override_mouse)
|
||||
{
|
||||
if (is_valid_session())
|
||||
{
|
||||
auto me = local_player();
|
||||
if (me.is_valid())
|
||||
{
|
||||
float mouse_x = 0.f, mouse_y = 0.f;
|
||||
float orig_mouse_x = 0.f, orig_mouse_y = 0.f;
|
||||
|
||||
read_xmm7(&mouse_x);
|
||||
read_xmm8(&mouse_y);
|
||||
|
||||
orig_mouse_x = mouse_x;
|
||||
orig_mouse_y = mouse_y;
|
||||
|
||||
features::on_rcs(me, mouse_x, mouse_y);
|
||||
features::on_aim_assist(me, mouse_x, mouse_y);
|
||||
|
||||
if (orig_mouse_x != mouse_x)
|
||||
write_xmm7(mouse_x);
|
||||
if (orig_mouse_y != mouse_y)
|
||||
write_xmm8(mouse_y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
inline constexpr u64 BUILD_SEED = 0x19b67457b5b281be;
|
||||
@@ -0,0 +1,152 @@
|
||||
#pragma once
|
||||
|
||||
typedef struct alignas(16) _M128A
|
||||
{
|
||||
ULONGLONG Low;
|
||||
LONGLONG High;
|
||||
} M128A, *PM128A;
|
||||
|
||||
typedef struct alignas(16) _XSAVE_FORMAT
|
||||
{
|
||||
WORD ControlWord;
|
||||
WORD StatusWord;
|
||||
BYTE TagWord;
|
||||
BYTE Reserved1;
|
||||
WORD ErrorOpcode;
|
||||
DWORD ErrorOffset;
|
||||
WORD ErrorSelector;
|
||||
WORD Reserved2;
|
||||
DWORD DataOffset;
|
||||
WORD DataSelector;
|
||||
WORD Reserved3;
|
||||
DWORD MxCsr;
|
||||
DWORD MxCsr_Mask;
|
||||
M128A FloatRegisters[8];
|
||||
M128A XmmRegisters[16];
|
||||
BYTE Reserved4[96];
|
||||
|
||||
} XSAVE_FORMAT, *PXSAVE_FORMAT;
|
||||
|
||||
typedef XSAVE_FORMAT XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
|
||||
|
||||
typedef struct alignas(16) _CONTEXT
|
||||
{
|
||||
|
||||
//
|
||||
// Register parameter home addresses.
|
||||
//
|
||||
// N.B. These fields are for convience - they could be used to extend the
|
||||
// context record in the future.
|
||||
//
|
||||
|
||||
DWORD64 P1Home;
|
||||
DWORD64 P2Home;
|
||||
DWORD64 P3Home;
|
||||
DWORD64 P4Home;
|
||||
DWORD64 P5Home;
|
||||
DWORD64 P6Home;
|
||||
|
||||
//
|
||||
// Control flags.
|
||||
//
|
||||
|
||||
DWORD ContextFlags;
|
||||
DWORD MxCsr;
|
||||
|
||||
//
|
||||
// Segment Registers and processor flags.
|
||||
//
|
||||
|
||||
WORD SegCs;
|
||||
WORD SegDs;
|
||||
WORD SegEs;
|
||||
WORD SegFs;
|
||||
WORD SegGs;
|
||||
WORD SegSs;
|
||||
DWORD EFlags;
|
||||
|
||||
//
|
||||
// Debug registers
|
||||
//
|
||||
|
||||
DWORD64 Dr0;
|
||||
DWORD64 Dr1;
|
||||
DWORD64 Dr2;
|
||||
DWORD64 Dr3;
|
||||
DWORD64 Dr6;
|
||||
DWORD64 Dr7;
|
||||
|
||||
//
|
||||
// Integer registers.
|
||||
//
|
||||
|
||||
DWORD64 Rax;
|
||||
DWORD64 Rcx;
|
||||
DWORD64 Rdx;
|
||||
DWORD64 Rbx;
|
||||
DWORD64 Rsp;
|
||||
DWORD64 Rbp;
|
||||
DWORD64 Rsi;
|
||||
DWORD64 Rdi;
|
||||
DWORD64 R8;
|
||||
DWORD64 R9;
|
||||
DWORD64 R10;
|
||||
DWORD64 R11;
|
||||
DWORD64 R12;
|
||||
DWORD64 R13;
|
||||
DWORD64 R14;
|
||||
DWORD64 R15;
|
||||
|
||||
//
|
||||
// Program counter.
|
||||
//
|
||||
|
||||
DWORD64 Rip;
|
||||
|
||||
//
|
||||
// Floating point state.
|
||||
//
|
||||
|
||||
union
|
||||
{
|
||||
XMM_SAVE_AREA32 FltSave;
|
||||
struct
|
||||
{
|
||||
M128A Header[2];
|
||||
M128A Legacy[8];
|
||||
M128A Xmm0;
|
||||
M128A Xmm1;
|
||||
M128A Xmm2;
|
||||
M128A Xmm3;
|
||||
M128A Xmm4;
|
||||
M128A Xmm5;
|
||||
M128A Xmm6;
|
||||
M128A Xmm7;
|
||||
M128A Xmm8;
|
||||
M128A Xmm9;
|
||||
M128A Xmm10;
|
||||
M128A Xmm11;
|
||||
M128A Xmm12;
|
||||
M128A Xmm13;
|
||||
M128A Xmm14;
|
||||
M128A Xmm15;
|
||||
} DUMMYSTRUCTNAME;
|
||||
} DUMMYUNIONNAME;
|
||||
|
||||
//
|
||||
// Vector registers.
|
||||
//
|
||||
|
||||
M128A VectorRegister[26];
|
||||
DWORD64 VectorControl;
|
||||
|
||||
//
|
||||
// Special debug control registers.
|
||||
//
|
||||
|
||||
DWORD64 DebugControl;
|
||||
DWORD64 LastBranchToRip;
|
||||
DWORD64 LastBranchFromRip;
|
||||
DWORD64 LastExceptionToRip;
|
||||
DWORD64 LastExceptionFromRip;
|
||||
} CONTEXT, *PCONTEXT;
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
namespace core
|
||||
{
|
||||
void on_render(int mode);
|
||||
LLVM_NOOPT void on_level_init(const char* map);
|
||||
LLVM_NOOPT void on_level_shutdown();
|
||||
void erase_name(Entity &ent);
|
||||
bool is_firing_range();
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned long u32;
|
||||
typedef unsigned long long u64;
|
||||
typedef u64 uptr;
|
||||
typedef void* ptr;
|
||||
|
||||
typedef signed char n8;
|
||||
typedef signed short n16;
|
||||
typedef signed long n32;
|
||||
typedef signed long long n64;
|
||||
|
||||
#define OBFUS_FUNC __attribute__((__annotate__((""))))
|
||||
#define OBFUS_FUNC_EX __attribute__((__annotate__((""))))
|
||||
#define OBFUS_FUNC_SIG __attribute__((__annotate__((""))))
|
||||
#define OBFUS_FUNC_S __attribute__((__annotate__((""))))
|
||||
|
||||
#define LLVMT(...) __attribute__(( __VA_ARGS__ ))
|
||||
#define LLVM_INLINE inline
|
||||
#define LLVM_NOINLINE __attribute__((noinline))
|
||||
#define LLVM_NOOPT [[clang::optnone]]
|
||||
#define LLVMOBF_INLINE_FP() __annotate__(("inline-fps"))
|
||||
#define LLVMOBF_CALLS() __annotate__(("fneobfcll"))
|
||||
#define LLVMOBF_SUB(loop) __annotate__(("sub")), __annotate__(("sub_loop=" #loop))
|
||||
#define LLVMOBF_BCF(prob, loop) __annotate__(("bcf")), __annotate__(("bcf_prob=" #prob)), __annotate__(("bcf_loop=" #loop))
|
||||
#define LLVMOBF_SPLIT(num) __annotate__(("split")), __annotate__(("split_num=" #num))
|
||||
|
||||
#if defined(PROD)
|
||||
#define LLVMOBF_COMBO_STANDARD LLVMOBF_SUB(2), LLVMOBF_BCF(20, 2), LLVMOBF_SPLIT(2)
|
||||
#else
|
||||
#define LLVMOBF_COMBO_STANDARD
|
||||
#endif
|
||||
|
||||
#define OBFUS_FUNC_DISABLE __attribute__((__annotate__(("nobcf")), __annotate__(("nofla")), \
|
||||
__annotate__(("nosub")), __annotate__(("nosplit"))))
|
||||
|
||||
#define BASE_OF(X) ((u64)X)
|
||||
#define PTR_OF(X) ((void*)X)
|
||||
|
||||
#define FWD_DECLARE_CLASS(X) class X
|
||||
#define DECLARE_OFFSET(NAME, OFF) inline constexpr ptrdiff_t NAME = OFF
|
||||
|
||||
#ifndef __FLTUSED__
|
||||
#define __FLTUSED__
|
||||
extern "C" __declspec(selectany) int _fltused = 1;
|
||||
#endif
|
||||
|
||||
typedef u8 uint8;
|
||||
typedef u16 uint16;
|
||||
typedef u32 uint32;
|
||||
typedef u64 uint64;
|
||||
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned char uchar;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned long ulong;
|
||||
|
||||
using char256 = char[256];
|
||||
|
||||
template<class T> __forceinline T __ROL__(T value, int count)
|
||||
{
|
||||
const uint nbits = sizeof(T) * 8;
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
count %= nbits;
|
||||
T high = value >> (nbits - count);
|
||||
if (T(-1) < 0) // signed value
|
||||
high &= ~((T(-1) << count));
|
||||
value <<= count;
|
||||
value |= high;
|
||||
}
|
||||
else
|
||||
{
|
||||
count = -count % nbits;
|
||||
T low = value << (nbits - count);
|
||||
value >>= count;
|
||||
value |= low;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
__forceinline uint8 __ROL1__(uint8 value, int count) { return __ROL__((uint8)value, count); }
|
||||
__forceinline uint16 __ROL2__(uint16 value, int count) { return __ROL__((uint16)value, count); }
|
||||
__forceinline uint32 __ROL4__(uint32 value, int count) { return __ROL__((uint32)value, count); }
|
||||
__forceinline uint64 __ROL8__(uint64 value, int count) { return __ROL__((uint64)value, count); }
|
||||
__forceinline uint8 __ROR1__(uint8 value, int count) { return __ROL__((uint8)value, -count); }
|
||||
__forceinline uint16 __ROR2__(uint16 value, int count) { return __ROL__((uint16)value, -count); }
|
||||
__forceinline uint32 __ROR4__(uint32 value, int count) { return __ROL__((uint32)value, -count); }
|
||||
__forceinline uint64 __ROR8__(uint64 value, int count) { return __ROL__((uint64)value, -count); }
|
||||
|
||||
#define encrypt_constant(value) (__ROL8__((value), 2) ^ BUILD_SEED)
|
||||
LLVM_NOOPT extern u64 decrypt_constant(u64 value);
|
||||
#define _encoded_const(value) decrypt_constant( encrypt_constant(value) )
|
||||
|
||||
#define _scex(FUNC, ...) invoke(FUNC, __VA_ARGS__)
|
||||
#define _scex_wrt(RET, FUNC, ...) invoke_withrettype<RET>(FUNC, __VA_ARGS__)
|
||||
|
||||
#define DATA_FIELD(name, type, offset) __attribute__((always_inline)) inline type& name() { return *(type*)(m_base + offset); }
|
||||
#define DATA_FIELD_NR(NAME, INST, TYPE, OFFSET) __attribute__((always_inline)) inline TYPE* NAME() { return (TYPE*)( (uptr)INST + OFFSET); }
|
||||
|
||||
#define DATA_FIELD_DIRECT(name, type, offset) __attribute__((always_inline)) inline type& name() { return *(type*)(BASE_OF(this) + offset); }
|
||||
|
||||
#define Xsprintf stl::fps::sprintf
|
||||
|
||||
#define MAKE_LOG_BUF(NAME, LEN) \
|
||||
char NAME[LEN]; \
|
||||
memset(NAME, 0, sizeof(NAME));
|
||||
|
||||
#if defined(DECLARE_AS_DEBUG_BUILD)
|
||||
#define IS_DEBUG_BUILD() true
|
||||
#else
|
||||
#define IS_DEBUG_BUILD() false
|
||||
#endif
|
||||
|
||||
#if defined(_RI_ENABLE_LOGGING) || defined(DECLARE_AS_DEBUG_BUILD)
|
||||
#define LOGGING_IS_ENABLED 1
|
||||
#else
|
||||
#define LOGGING_IS_ENABLED 0
|
||||
#endif
|
||||
|
||||
#define Plat_FloatTime() g.gvars->Curtime
|
||||
#define Plat_FloatTick() g.gvars->TickCount
|
||||
|
||||
#define MmIsAddressValid(address) \
|
||||
(((uintptr_t)(address) >= 0x0000000000000000) && ((uintptr_t)(address) <= 0x00007fffffffffff))
|
||||
|
||||
|
||||
#define QUOTE(str) #str
|
||||
#define STRINGIFIED_DEF(str) QUOTE(str)
|
||||
@@ -0,0 +1,99 @@
|
||||
#pragma once
|
||||
|
||||
namespace EC
|
||||
{
|
||||
/*
|
||||
* A snapshot of an entity's version.
|
||||
*
|
||||
* WARNING: MAKE SURE TO USE ENTITY INSTANCE'S OWN VALIDATION FEATURES BEFORE USING THIS DATA!
|
||||
* IT MIGHT BE NOT IN SYNC WITH WHAT THE CURRENT EXECUTING THREAD IS IN STATE OF, BEWARE!
|
||||
* THIS IS MOSTLY FOR INTERNAL USAGE
|
||||
* DO NOT IGNORE THIS, OR YOU MAY CORRUPT DATA AND CRASH!
|
||||
*
|
||||
*/
|
||||
struct record
|
||||
{
|
||||
int eidx;
|
||||
uptr ptr;
|
||||
bool valid;
|
||||
|
||||
u64 identifier_hash;
|
||||
|
||||
char name[RS_PLAYER_MAX_NAME_LEN];
|
||||
|
||||
int tick_last_live_update;
|
||||
float time_last_deferred_update;
|
||||
float last_vis_time;
|
||||
|
||||
bool is_alive;
|
||||
bool is_alive_prev;
|
||||
bool is_ally_of_local;
|
||||
bool is_visible;
|
||||
|
||||
int health[2];
|
||||
int armor[2];
|
||||
int level;
|
||||
|
||||
Vec3 vec_origin[2];
|
||||
Vec3 vec_head[2];
|
||||
Vec3 vec_bounds[2];
|
||||
Vec3 vec_center[2];
|
||||
|
||||
matrix3x4 rgfl_coordinate_frame;
|
||||
rs::math::render_points_t rpts;
|
||||
|
||||
bool rpts_avail;
|
||||
bool bscr_origin_avail;
|
||||
bool bscr_head_avail;
|
||||
bool bscr_center_avail;
|
||||
|
||||
float dist_to_local;
|
||||
float fov_to_local;
|
||||
float bounds[2];
|
||||
|
||||
LColor clr;
|
||||
};
|
||||
|
||||
/*
|
||||
* Contains data that is only valid throughout the current game
|
||||
* or as said above, current session. reset this every level shutdown!
|
||||
*/
|
||||
struct session_data
|
||||
{
|
||||
int tick_last_refreshed;
|
||||
|
||||
struct
|
||||
{
|
||||
int num_invalidations;
|
||||
} stats;
|
||||
};
|
||||
|
||||
extern record* _table;
|
||||
extern size_t _table_len;
|
||||
extern size_t _table_cap;
|
||||
extern session_data _session_data;
|
||||
|
||||
bool init();
|
||||
void reset();
|
||||
void tick(Entity& me);
|
||||
void render(respawn::Mat_system_surface* mss);
|
||||
void show_debug_stats(respawn::Mat_system_surface* mss);
|
||||
void update(Entity& me);
|
||||
bool handle_generic(Entity& ent, record* rec);
|
||||
LLVM_NOOPT void handle_combat_entity(Entity& me, const Vec3& my_origin, Entity& ent, record* rec);
|
||||
void invalidate(record* rec);
|
||||
record* get(int idx);
|
||||
|
||||
int get_highest_eidx();
|
||||
|
||||
bool is_cached_record_valid(Entity& ent, record* rec);
|
||||
bool make_initial_record_cache(Entity& ent, record* rec);
|
||||
|
||||
/*
|
||||
* EntityCache -> DETAIL / INTERNAL section.
|
||||
*/
|
||||
namespace detail
|
||||
{
|
||||
bool should_refresh();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
namespace features
|
||||
{
|
||||
extern Entity rotational_find_target(Entity &me, Vec3 &outpos, float max_dist, float max_fov, float dead_zone, bool& should_slow);
|
||||
|
||||
extern void on_rcs(Entity &me, float &x, float &y);
|
||||
extern void on_aim_assist(Entity &me, float &x, float &y);
|
||||
extern void on_esp(respawn::Mat_system_surface* mss, Entity &me);
|
||||
extern void on_movement(Entity& me);
|
||||
extern void on_trigger(Entity& me);
|
||||
extern void on_anonymizer();
|
||||
extern void anonymizer_reset();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#define HOOK_IDX_ON_DROPPED_BY_SERVER 2
|
||||
#define HOOK_IDX_PROCESS_PLAYLIST_OVERRIDE 13 // #STR: "SVC_Playlists"
|
||||
#define HOOK_IDX_ON_RECEIVED_SERVER_INFO (HOOK_IDX_PROCESS_PLAYLIST_OVERRIDE-3) // #STR: "start caching non-common assets for level %s"
|
||||
#define HOOK_IDX_MKRCTX_UNK1 70 // 44 8B 84 24 ? ? ? ? 0F 57 C0 F3 0F 10 25 - xref it
|
||||
#define HOOK_IDX_OVERRIDE_MOUSE 33
|
||||
|
||||
namespace hooks
|
||||
{
|
||||
LLVM_NOOPT bool init(); // fires after the game has done base setup.
|
||||
LLVM_NOOPT bool init_early(); // fires before the game has done base setup.
|
||||
LLVM_NOOPT bool init_deferred(); // fires when first entering a match only once.
|
||||
|
||||
extern bool inited_deferred;
|
||||
extern u32 vft_disp;
|
||||
extern u32 vft_cave_cap;
|
||||
extern uptr vft_cave_begin;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern uptr ghk_orig_mkrctx_unk1;
|
||||
extern uptr ghk_orig_on_receive_server_info;
|
||||
extern uptr ghk_orig_on_dropped_by_server;
|
||||
extern uptr ghk_orig_process_playlist_override;
|
||||
|
||||
extern void tp_mkrctx_unk1();
|
||||
extern void tp_on_receive_server_info();
|
||||
extern void tp_on_dropped_by_server();
|
||||
extern void tp_init();
|
||||
extern void tp_process_playlist_override();
|
||||
extern void tp_override_mouse();
|
||||
|
||||
LLVM_NOOPT unsigned short __fastcall hk_capture_stack_back_trace(unsigned long frames_to_skip, unsigned long frames_to_capture, void **trace, void *trace_hash);
|
||||
LLVM_NOOPT void __fastcall hk_mkrctx_unk1(void* inst, u64 a2, void* retaddr);
|
||||
LLVM_NOOPT void __fastcall hk_on_receive_server_info(void* inst, uptr netmsg);
|
||||
LLVM_NOOPT void __fastcall hk_on_dropped_by_server(void *this_ptr, char unk_cond_1, const char *reason);
|
||||
LLVM_NOOPT void __fastcall hk_process_playlist_override(void* inst, void* net_msg);
|
||||
LLVM_NOOPT void __fastcall hk_override_mouse(void *inst, void* retaddr);
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
#pragma once
|
||||
|
||||
//#define _RI_ENABLE_LOGGING
|
||||
|
||||
#include <intrin.h>
|
||||
#include <xmmintrin.h>
|
||||
#include <stdint.h>
|
||||
#include <new>
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
#include "defs.h"
|
||||
#include "ntdefs.h"
|
||||
#include "context.h"
|
||||
#include "stl_base.h"
|
||||
#include "rotate.h"
|
||||
#include "string-table.h"
|
||||
#include "xorstr.h"
|
||||
#include "logger.h"
|
||||
#include "loader.h"
|
||||
#include "r5ac.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern LoaderContext* gctx;
|
||||
}
|
||||
|
||||
#include "vfunc.h"
|
||||
#include "xmmreg.h"
|
||||
#include "build.h"
|
||||
#include "stl.h"
|
||||
#include "math.h"
|
||||
#include "respawn.h"
|
||||
#include "tools.h"
|
||||
#include "vft.h"
|
||||
#include "vmthk.h"
|
||||
#include "input.h"
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct Globals
|
||||
{
|
||||
LoaderContext* ctx;
|
||||
u64 local_player_base;
|
||||
char hopping;
|
||||
char force_attack;
|
||||
int tea_bag_mode;
|
||||
entity_info_t* ent_list;
|
||||
GlobalVars* gvars;
|
||||
int* signon_state;
|
||||
GameModes game_mode;
|
||||
int screen_dim[2];
|
||||
bool ingame;
|
||||
bool inlobby;
|
||||
bool startup_debug_pane_finished;
|
||||
float startup_debug_pane_draw_time;
|
||||
bool trigger_reset_attack;
|
||||
|
||||
float r5ac_debug_pane_draw_time;
|
||||
u32 r5ac_stack_walk_last_call;
|
||||
u32 r5ac_num_stack_walks_disarmed;
|
||||
|
||||
char last_disconnect_reason[256];
|
||||
|
||||
struct
|
||||
{
|
||||
} funcs;
|
||||
|
||||
struct
|
||||
{
|
||||
u64 base_client;
|
||||
u64 client_state;
|
||||
u64* pclient_mode;
|
||||
u64 mat_kwewed_render_ctx;
|
||||
respawn::Mat_system_surface* mss;
|
||||
rs::Mem_alloc* mm;
|
||||
respawn::View_render* view_render;
|
||||
} ix;
|
||||
|
||||
struct
|
||||
{
|
||||
int* rs_controller_checks_enabled;
|
||||
double* rs_controller_checks_last;
|
||||
} gv;
|
||||
|
||||
struct
|
||||
{
|
||||
vmthk client_state;
|
||||
vmthk client_state_vft3;
|
||||
vmthk mat_kwewed_render_ctx;
|
||||
vmthk client_mode;
|
||||
} vmts;
|
||||
|
||||
struct
|
||||
{
|
||||
Input ui;
|
||||
Input cmove;
|
||||
} inputs;
|
||||
|
||||
struct
|
||||
{
|
||||
rs::In_state duck;
|
||||
rs::In_state jump;
|
||||
rs::In_state attack;
|
||||
} in_states;
|
||||
|
||||
struct
|
||||
{
|
||||
bool visual;
|
||||
bool visual_far;
|
||||
bool visual_outline;
|
||||
|
||||
bool rcs;
|
||||
int rcs_mode;
|
||||
int rcs_strength;
|
||||
float rcs_internal_mouse_scale;
|
||||
|
||||
bool aim_assist;
|
||||
bool aim_assist_slow;
|
||||
bool aim_assist_rotational;
|
||||
int aim_assist_mode;
|
||||
int aim_assist_strength;
|
||||
float aim_assist_fov;
|
||||
float aim_assist_dead_zone;
|
||||
float aim_assist_internal_mouse_scale; // for slow
|
||||
float aim_assist_strength_ror;
|
||||
|
||||
bool override_controller_aa;
|
||||
int override_controller_aa_value;
|
||||
|
||||
bool anon_mode;
|
||||
|
||||
bool trigger;
|
||||
|
||||
LLVM_NOOPT void init() LLVMT(LLVMOBF_INLINE_FP())
|
||||
{
|
||||
visual = true;
|
||||
visual_far = false;
|
||||
rcs = false;
|
||||
anon_mode = false;
|
||||
rcs_mode = 1;
|
||||
rcs_strength = 25;
|
||||
override_controller_aa = false;
|
||||
override_controller_aa_value = 100;
|
||||
|
||||
aim_assist = false;
|
||||
aim_assist_strength = 20;
|
||||
aim_assist_strength_ror = 0.034f;
|
||||
aim_assist_slow = true;
|
||||
aim_assist_rotational = true;
|
||||
aim_assist_dead_zone = 0.2f;
|
||||
aim_assist_fov = 9.25f;
|
||||
aim_assist_mode = 1;
|
||||
}
|
||||
} conf;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
extern Globals g;
|
||||
|
||||
#include "hooks.h"
|
||||
#include "features.h"
|
||||
#include "menu.h"
|
||||
#include "core.h"
|
||||
#include "renderer.h"
|
||||
#include "entcache.h"
|
||||
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
* Primary Input Manager, wraps around the game interfaces
|
||||
* to provide easy access to input detection.
|
||||
*/
|
||||
#define INPUT_MAX_KEYS_TO_TRACK 255
|
||||
|
||||
class Input
|
||||
{
|
||||
public:
|
||||
void init();
|
||||
void reset();
|
||||
|
||||
/*
|
||||
* Handles an Input Tick. Simply checks key states and updates our states.
|
||||
* In order for the input manager to work correctly,
|
||||
* each place where timing may be different should have its own Input Mgr.
|
||||
*/
|
||||
void tick_begin();
|
||||
void tick_end();
|
||||
|
||||
/*
|
||||
* Checks if the key with given ID is currently held.
|
||||
*/
|
||||
bool is_button_down(rs::Buttons key);
|
||||
|
||||
/*
|
||||
* CHecks if the key with given ID has been toggled.
|
||||
*/
|
||||
bool was_button_pressed(rs::Buttons key);
|
||||
private:
|
||||
bool _key_states[INPUT_MAX_KEYS_TO_TRACK];
|
||||
bool _key_states_prev[INPUT_MAX_KEYS_TO_TRACK];
|
||||
};
|
||||
@@ -0,0 +1,111 @@
|
||||
#pragma once
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
struct LoaderContext
|
||||
{
|
||||
unsigned int magic;
|
||||
u8 inited;
|
||||
/*
|
||||
* Keep this here and if you change anything above,
|
||||
* then ENSURE to update our trampoline offsets!
|
||||
*/
|
||||
struct Origs
|
||||
{
|
||||
u64 init;
|
||||
} origs;
|
||||
u64 game_base;
|
||||
u64 game_len;
|
||||
u64 game_rdata_base;
|
||||
u64 game_rdata_len;
|
||||
u64 game_cs_base;
|
||||
u64 game_cs_len;
|
||||
u64 game_data_base;
|
||||
u64 game_data_len;
|
||||
u64 libc_base;
|
||||
u64 libm_base;
|
||||
String_table* strtbl;
|
||||
u64 strtbl_decryption_key;
|
||||
|
||||
struct
|
||||
{
|
||||
uint32_t fopen;
|
||||
uint32_t fputs;
|
||||
uint32_t fclose;
|
||||
uint32_t sprintf;
|
||||
uint32_t sleep;
|
||||
} linuxcrt_cpp;
|
||||
|
||||
struct
|
||||
{
|
||||
uint32_t acosf;
|
||||
uint32_t atan2f;
|
||||
uint32_t fabsf;
|
||||
uint32_t sinf;
|
||||
uint32_t cosf;
|
||||
} linuxcrt_math;
|
||||
|
||||
struct
|
||||
{
|
||||
uptr create_file;
|
||||
uptr get_file_size;
|
||||
uptr close_handle;
|
||||
uptr read_file;
|
||||
uptr capture_stack_back_trace;
|
||||
} winapis;
|
||||
|
||||
struct Offsets
|
||||
{
|
||||
uint32_t entity_list;
|
||||
uint32_t signon_state;
|
||||
uint32_t input_system;
|
||||
uint32_t mp_gamemode;
|
||||
uint32_t global_vars;
|
||||
uint32_t game_movement;
|
||||
uint32_t map_name;
|
||||
uint32_t name_list;
|
||||
uint32_t tag_list;
|
||||
uint32_t client_class_head;
|
||||
uint32_t mat_system_surface;
|
||||
uint32_t base_client;
|
||||
uint32_t view_render;
|
||||
uint32_t client_state;
|
||||
uint32_t client_mode;
|
||||
uint32_t kwewed_render_ctx;
|
||||
uint32_t rs_cvar_gamepad_checks_enabled;
|
||||
uint32_t rs_gamepad_checks_last;
|
||||
uint32_t string_dict_user_names;
|
||||
|
||||
struct
|
||||
{
|
||||
uint32_t view_offset;
|
||||
uint32_t view_angle;
|
||||
} player;
|
||||
|
||||
struct
|
||||
{
|
||||
uint32_t get_mem_alloc;
|
||||
uint32_t mss_draw_filled_rect;
|
||||
uint32_t math_ang2vec;
|
||||
uint32_t math_vec2ang;
|
||||
} fns;
|
||||
|
||||
struct
|
||||
{
|
||||
uint32_t generic_1;
|
||||
} vft_caves;
|
||||
|
||||
struct
|
||||
{
|
||||
u64 mkrctx_unk1;
|
||||
u64 create_move;
|
||||
u64 override_mouse;
|
||||
} ret_addrs;
|
||||
} offsets;
|
||||
|
||||
struct
|
||||
{
|
||||
u64 base_client;
|
||||
} vft_orig_ptrs;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
namespace logger
|
||||
{
|
||||
void log2file(const char* contents);
|
||||
}
|
||||
|
||||
__attribute((noinline)) inline void msg(const char* contents)
|
||||
{
|
||||
logger::log2file(contents);
|
||||
}
|
||||
|
||||
#define LMsg(buflen, fmt, ...) \
|
||||
do { \
|
||||
char log_buf[buflen]; \
|
||||
Xsprintf(log_buf, fmt, ##__VA_ARGS__); \
|
||||
msg(log_buf); \
|
||||
} while (0)
|
||||
|
||||
#define LMsg_Short(fmt, ...) LMsg(256, fmt, __VA_ARGS__)
|
||||
@@ -0,0 +1,297 @@
|
||||
#pragma once
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4244)
|
||||
|
||||
#define VEC_EMPTY \
|
||||
Vec3 { 0.f, 0.f, 0.f }
|
||||
|
||||
namespace math
|
||||
{
|
||||
inline static u32 _FOPI = float2dword(1.27323954473516);
|
||||
|
||||
inline static u32 _DP1 = float2dword(0.78515625);
|
||||
inline static u32 _DP2 = float2dword(2.4187564849853515625e-4);
|
||||
inline static u32 _DP3 = float2dword(3.77489497744594108e-8);
|
||||
inline static u32 _lossth = float2dword(8192.);
|
||||
inline static u32 _T24M1 = float2dword(16777215.);
|
||||
|
||||
#define FOPI dword2float(_FOPI)
|
||||
#define DP1 dword2float(_DP1)
|
||||
#define DP2 dword2float(_DP2)
|
||||
#define DP3 dword2float(_DP3)
|
||||
#define lossth dword2float(_lossth)
|
||||
#define T24M1 dword2float(_T24M1)
|
||||
|
||||
extern float remainderf(float x, float y);
|
||||
|
||||
LLVM_NOOPT inline float sqrtf(float _X) { return _mm_cvtss_f32(_mm_sqrt_ss(_mm_set_ss(_X))); }
|
||||
|
||||
inline float acosf(float x) { return stl::Xacosf(x); }
|
||||
inline float atan2f(float y, float x) { return stl::Xatan2f(y, x); }
|
||||
inline float fabsf(float val) { return stl::Xfabsf(val); }
|
||||
}
|
||||
|
||||
#pragma warning(pop)
|
||||
|
||||
struct global_float_constants
|
||||
{
|
||||
float threesixty;
|
||||
float minus89;
|
||||
float plus89;
|
||||
float one;
|
||||
float point_one;
|
||||
float point_o5;
|
||||
float point_o1;
|
||||
float point_o2;
|
||||
float respawn_sens;
|
||||
|
||||
void init()
|
||||
{
|
||||
_fp(threesixty, 360.f);
|
||||
_fp(minus89, -89.f);
|
||||
_fp(plus89, +89.f);
|
||||
_fp(one, 1.f);
|
||||
_fp(point_one, 0.1f);
|
||||
_fp(point_o5, 0.05f);
|
||||
_fp(point_o1, 0.01f);
|
||||
_fp(point_o2, 0.02f);
|
||||
_fp(respawn_sens, 0.022f);
|
||||
|
||||
this->threesixty = threesixty;
|
||||
this->minus89 = minus89;
|
||||
this->plus89 = plus89;
|
||||
this->one = one;
|
||||
this->point_one = point_one;
|
||||
this->point_o5 = point_o5;
|
||||
this->point_o1 = point_o1;
|
||||
this->point_o2 = point_o2;
|
||||
this->respawn_sens = respawn_sens;
|
||||
}
|
||||
} inline gfloats;
|
||||
|
||||
struct Point2
|
||||
{
|
||||
Point2(int x, int y)
|
||||
{
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
}
|
||||
|
||||
Point2(float x, float y)
|
||||
{
|
||||
// WARNING: truncates everything except the decimal before comma!
|
||||
this->x = (int)x;
|
||||
this->y = (int)y;
|
||||
}
|
||||
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
class Vec3
|
||||
{
|
||||
public:
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
|
||||
public:
|
||||
Vec3() = default;
|
||||
Vec3(float x_, float y_, float z_)
|
||||
{
|
||||
x = x_;
|
||||
y = y_;
|
||||
z = z_;
|
||||
}
|
||||
|
||||
float *base()
|
||||
{
|
||||
return reinterpret_cast<float *>(reinterpret_cast<uintptr_t>(this));
|
||||
}
|
||||
|
||||
auto base_ro() const
|
||||
{
|
||||
return reinterpret_cast<const float * const>(reinterpret_cast<uintptr_t>(this));
|
||||
}
|
||||
|
||||
float &operator[](int index)
|
||||
{
|
||||
if (index == 0)
|
||||
return x;
|
||||
else if (index == 1)
|
||||
return y;
|
||||
else
|
||||
return z;
|
||||
}
|
||||
|
||||
bool operator==(const Vec3 &other) const
|
||||
{
|
||||
return (other.x == x && other.y == y && other.z == z);
|
||||
}
|
||||
|
||||
Vec3 operator-(const Vec3 &other) const
|
||||
{
|
||||
return Vec3{this->x - other.x, this->y - other.y, this->z - other.z};
|
||||
}
|
||||
|
||||
Vec3 operator+(const Vec3 &other) const
|
||||
{
|
||||
return Vec3{this->x + other.x, this->y + other.y, this->z + other.z};
|
||||
}
|
||||
|
||||
void operator+=(const Vec3 &other)
|
||||
{
|
||||
x += other.x;
|
||||
y += other.y;
|
||||
z += other.z;
|
||||
}
|
||||
|
||||
Vec3 &operator*=(const float multiplier)
|
||||
{
|
||||
x *= multiplier;
|
||||
y *= multiplier;
|
||||
z *= multiplier;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vec3 operator*(const Vec3 &other) const { return {x * other.x, y * other.y, z * other.z}; }
|
||||
Vec3 operator*(const float &other) const { return {x * other, y * other, z * other}; }
|
||||
|
||||
[[nodiscard]] float Length() const { return (x + y + z); }
|
||||
|
||||
[[nodiscard]] float Length2d() const { return math::sqrtf(x * x + y * y + z * z); }
|
||||
[[nodiscard]] float LengthSquare() const { return (x * x + y * y + z * z); }
|
||||
[[nodiscard]] bool Empty() const { return (Length() <= 0.0f); }
|
||||
|
||||
[[nodiscard]] float dist_to(const Vec3 &other)
|
||||
{
|
||||
auto delta = (other - *this);
|
||||
|
||||
return math::fabsf(delta.LengthSquare());
|
||||
}
|
||||
};
|
||||
|
||||
class Vec4 : public Vec3
|
||||
{
|
||||
public:
|
||||
float w;
|
||||
|
||||
public:
|
||||
Vec4() = default;
|
||||
Vec4(float x_, float y_, float z_, float w_)
|
||||
{
|
||||
x = x_;
|
||||
y = y_;
|
||||
z = z_;
|
||||
w = w_;
|
||||
}
|
||||
};
|
||||
|
||||
class __declspec(align(16)) Vec4A : public Vec4
|
||||
{
|
||||
public:
|
||||
void Zero()
|
||||
{
|
||||
x = 0.f;
|
||||
y = 0.f;
|
||||
z = 0.f;
|
||||
w = 0.f;
|
||||
}
|
||||
};
|
||||
|
||||
namespace math
|
||||
{
|
||||
namespace external
|
||||
{
|
||||
struct funs
|
||||
{
|
||||
void* ang2vec;
|
||||
void* vec2ang;
|
||||
} inline pfns;
|
||||
|
||||
extern void init();
|
||||
}
|
||||
|
||||
inline float dot_prod(const float *first, const float *second)
|
||||
{
|
||||
return ((first[0] * second[0]) + (first[1] * second[1]) + (first[2] * second[2]));
|
||||
}
|
||||
|
||||
inline float dot_prod_vec(const Vec3 &first, const Vec3 &second)
|
||||
{
|
||||
return ((first.x * second.x) + (first.y * second.y) + (first.z * second.z));
|
||||
}
|
||||
|
||||
LLVM_NOOPT inline float deg2rad(const float v) LLVMT( LLVMOBF_INLINE_FP() )
|
||||
{
|
||||
return (v * static_cast<float>(M_PI)) / 180.f;
|
||||
}
|
||||
|
||||
LLVM_NOOPT inline float rad2deg(const float v) LLVMT( LLVMOBF_INLINE_FP() )
|
||||
{
|
||||
return (v * 180.0f) / static_cast<float>(M_PI);
|
||||
}
|
||||
|
||||
LLVM_NOOPT inline void ang2vec(const Vec3 &in, Vec3 &out) LLVMT( LLVMOBF_INLINE_FP() )
|
||||
{
|
||||
using fun_ang2vec_t = void(__fastcall *)(const Vec3*, Vec3*);
|
||||
auto pfunc = reinterpret_cast<fun_ang2vec_t>(external::pfns.ang2vec);
|
||||
if(pfunc)
|
||||
{
|
||||
pfunc( &in, &out );
|
||||
}
|
||||
}
|
||||
|
||||
LLVM_NOOPT inline void vec2ang(const Vec3 &forward, Vec3 &angles) LLVMT( LLVMOBF_INLINE_FP() )
|
||||
{
|
||||
using fun_vec2ang_t = void(__fastcall *)(const Vec3*, Vec3*);
|
||||
auto pfunc = reinterpret_cast<fun_vec2ang_t>(external::pfns.vec2ang);
|
||||
if(pfunc)
|
||||
{
|
||||
pfunc( &forward, &angles );
|
||||
}
|
||||
}
|
||||
|
||||
LLVM_NOOPT inline float get_fov_difference(Vec3 angle, Vec3 start, Vec3 end) LLVMT( LLVMOBF_INLINE_FP() )
|
||||
{
|
||||
auto aim_angle = VEC_EMPTY;
|
||||
auto view_position = VEC_EMPTY, aim_position = VEC_EMPTY;
|
||||
|
||||
auto delta = end - start;
|
||||
|
||||
vec2ang(delta, aim_angle);
|
||||
|
||||
ang2vec(angle, view_position);
|
||||
ang2vec(aim_angle, aim_position);
|
||||
|
||||
const float aimplsq = aim_position.Length2d();
|
||||
const auto dotp = static_cast<float>(dot_prod_vec(aim_position, view_position) / aimplsq);
|
||||
|
||||
const float vcos = acosf(dotp);
|
||||
const float drad = math::rad2deg(vcos);
|
||||
|
||||
if (!__builtin_isnan(vcos))
|
||||
return drad;
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
LLVM_NOOPT inline void normalize_angle(Vec3 &angle) LLVMT( LLVMOBF_INLINE_FP() )
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
if (angle[i] > 180.0)
|
||||
{
|
||||
angle[i] -= 360.0;
|
||||
}
|
||||
else if (angle[i] < -180.0)
|
||||
{
|
||||
angle[i] += 360.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
namespace menu
|
||||
{
|
||||
struct state_t
|
||||
{
|
||||
bool inited;
|
||||
bool visible;
|
||||
int idx;
|
||||
int height;
|
||||
int nitems;
|
||||
int pos_x;
|
||||
int pos_y;
|
||||
int pos_w;
|
||||
int pos_h;
|
||||
|
||||
int render_pos_x;
|
||||
int render_pos_y;
|
||||
} extern state;
|
||||
|
||||
inline bool is_visible() { return state.visible; }
|
||||
|
||||
void checkbox(respawn::Mat_system_surface *mss, int &idx, const char *text, bool &pval);
|
||||
void slider_percentage(respawn::Mat_system_surface *mss, int &idx, const char *text, int &pval, int step);
|
||||
void init();
|
||||
void on_render(respawn::Mat_system_surface *mss);
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
#pragma once
|
||||
|
||||
#define LOCAL_PEB() reinterpret_cast<nt::PPEB>(__readgsqword(decrypt_constant(encrypt_constant(0x60))))
|
||||
|
||||
typedef long LONG;
|
||||
typedef u8 BYTE;
|
||||
typedef long long LONGLONG;
|
||||
typedef unsigned long long ULONGLONG;
|
||||
typedef u16 WORD;
|
||||
typedef u32 ULONG;
|
||||
typedef u32 DWORD;
|
||||
typedef u64 ULONG64;
|
||||
typedef uptr ULONG_PTR;
|
||||
typedef uptr DWORD64;
|
||||
typedef ptr PVOID;
|
||||
typedef ptr HANDLE;
|
||||
typedef u8 UCHAR;
|
||||
typedef u8 BOOLEAN;
|
||||
typedef unsigned short USHORT;
|
||||
|
||||
typedef char CHAR;
|
||||
typedef CHAR *PCHAR;
|
||||
typedef wchar_t WCHAR;
|
||||
typedef WCHAR *PWSTR;
|
||||
|
||||
#define IMAGE_DOS_SIGNATURE 0x5A4D // MZ
|
||||
#define IMAGE_OS2_SIGNATURE 0x454E // NE
|
||||
#define IMAGE_OS2_SIGNATURE_LE 0x454C // LE
|
||||
#define IMAGE_VXD_SIGNATURE 0x454C // LE
|
||||
#define IMAGE_NT_SIGNATURE 0x00004550 // PE00
|
||||
|
||||
#define IMAGE_DIRECTORY_ENTRY_EXPORT 0
|
||||
|
||||
#define EXCEPTION_MAXIMUM_PARAMETERS 15
|
||||
|
||||
#define EXCEPTION_EXECUTE_HANDLER 1
|
||||
#define EXCEPTION_CONTINUE_SEARCH 0
|
||||
#define EXCEPTION_CONTINUE_EXECUTION (-1)
|
||||
|
||||
//
|
||||
// These are the generic rights.
|
||||
//
|
||||
#define GENERIC_READ (0x80000000L)
|
||||
#define GENERIC_WRITE (0x40000000L)
|
||||
#define GENERIC_EXECUTE (0x20000000L)
|
||||
#define GENERIC_ALL (0x10000000L)
|
||||
|
||||
//
|
||||
// Define access rights to files and directories
|
||||
//
|
||||
|
||||
//
|
||||
// The FILE_READ_DATA and FILE_WRITE_DATA constants are also defined in
|
||||
// devioctl.h as FILE_READ_ACCESS and FILE_WRITE_ACCESS. The values for these
|
||||
// constants *MUST* always be in sync.
|
||||
// The values are redefined in devioctl.h because they must be available to
|
||||
// both DOS and NT.
|
||||
//
|
||||
|
||||
#define FILE_READ_DATA ( 0x0001 ) // file & pipe
|
||||
#define FILE_LIST_DIRECTORY ( 0x0001 ) // directory
|
||||
|
||||
#define FILE_WRITE_DATA ( 0x0002 ) // file & pipe
|
||||
#define FILE_ADD_FILE ( 0x0002 ) // directory
|
||||
|
||||
#define FILE_APPEND_DATA ( 0x0004 ) // file
|
||||
#define FILE_ADD_SUBDIRECTORY ( 0x0004 ) // directory
|
||||
#define FILE_CREATE_PIPE_INSTANCE ( 0x0004 ) // named pipe
|
||||
|
||||
|
||||
#define FILE_READ_EA ( 0x0008 ) // file & directory
|
||||
|
||||
#define FILE_WRITE_EA ( 0x0010 ) // file & directory
|
||||
|
||||
#define FILE_EXECUTE ( 0x0020 ) // file
|
||||
#define FILE_TRAVERSE ( 0x0020 ) // directory
|
||||
|
||||
#define FILE_DELETE_CHILD ( 0x0040 ) // directory
|
||||
|
||||
#define FILE_READ_ATTRIBUTES ( 0x0080 ) // all
|
||||
|
||||
#define FILE_WRITE_ATTRIBUTES ( 0x0100 ) // all
|
||||
|
||||
#define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF)
|
||||
|
||||
#define FILE_GENERIC_READ (STANDARD_RIGHTS_READ |\
|
||||
FILE_READ_DATA |\
|
||||
FILE_READ_ATTRIBUTES |\
|
||||
FILE_READ_EA |\
|
||||
SYNCHRONIZE)
|
||||
|
||||
|
||||
#define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\
|
||||
FILE_WRITE_DATA |\
|
||||
FILE_WRITE_ATTRIBUTES |\
|
||||
FILE_WRITE_EA |\
|
||||
FILE_APPEND_DATA |\
|
||||
SYNCHRONIZE)
|
||||
|
||||
|
||||
#define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\
|
||||
FILE_READ_ATTRIBUTES |\
|
||||
FILE_EXECUTE |\
|
||||
SYNCHRONIZE)
|
||||
|
||||
#define FILE_SHARE_READ 0x00000001
|
||||
#define FILE_SHARE_WRITE 0x00000002
|
||||
#define FILE_SHARE_DELETE 0x00000004
|
||||
#define FILE_ATTRIBUTE_READONLY 0x00000001
|
||||
#define FILE_ATTRIBUTE_HIDDEN 0x00000002
|
||||
#define FILE_ATTRIBUTE_SYSTEM 0x00000004
|
||||
#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
|
||||
#define FILE_ATTRIBUTE_ARCHIVE 0x00000020
|
||||
#define FILE_ATTRIBUTE_DEVICE 0x00000040
|
||||
#define FILE_ATTRIBUTE_NORMAL 0x00000080
|
||||
#define FILE_ATTRIBUTE_TEMPORARY 0x00000100
|
||||
#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
|
||||
#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
|
||||
#define FILE_ATTRIBUTE_COMPRESSED 0x00000800
|
||||
#define FILE_ATTRIBUTE_OFFLINE 0x00001000
|
||||
#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
|
||||
#define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
|
||||
#define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
|
||||
#define FILE_ATTRIBUTE_VIRTUAL 0x00010000
|
||||
#define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
|
||||
#define FILE_ATTRIBUTE_EA 0x00040000
|
||||
#define FILE_ATTRIBUTE_PINNED 0x00080000
|
||||
#define FILE_ATTRIBUTE_UNPINNED 0x00100000
|
||||
#define FILE_ATTRIBUTE_RECALL_ON_OPEN 0x00040000
|
||||
#define FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS 0x00400000
|
||||
#define TREE_CONNECT_ATTRIBUTE_PRIVACY 0x00004000
|
||||
#define TREE_CONNECT_ATTRIBUTE_INTEGRITY 0x00008000
|
||||
#define TREE_CONNECT_ATTRIBUTE_GLOBAL 0x00000004
|
||||
#define TREE_CONNECT_ATTRIBUTE_PINNED 0x00000002
|
||||
#define FILE_ATTRIBUTE_STRICTLY_SEQUENTIAL 0x20000000
|
||||
#define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
|
||||
#define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
|
||||
#define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
|
||||
#define FILE_NOTIFY_CHANGE_SIZE 0x00000008
|
||||
#define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
|
||||
#define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
|
||||
#define FILE_NOTIFY_CHANGE_CREATION 0x00000040
|
||||
#define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
|
||||
#define FILE_ACTION_ADDED 0x00000001
|
||||
#define FILE_ACTION_REMOVED 0x00000002
|
||||
#define FILE_ACTION_MODIFIED 0x00000003
|
||||
#define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
|
||||
#define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
|
||||
#define MAILSLOT_NO_MESSAGE ((DWORD)-1)
|
||||
#define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
|
||||
#define FILE_CASE_SENSITIVE_SEARCH 0x00000001
|
||||
#define FILE_CASE_PRESERVED_NAMES 0x00000002
|
||||
#define FILE_UNICODE_ON_DISK 0x00000004
|
||||
#define FILE_PERSISTENT_ACLS 0x00000008
|
||||
#define FILE_FILE_COMPRESSION 0x00000010
|
||||
#define FILE_VOLUME_QUOTAS 0x00000020
|
||||
#define FILE_SUPPORTS_SPARSE_FILES 0x00000040
|
||||
#define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
|
||||
#define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
|
||||
#define FILE_RETURNS_CLEANUP_RESULT_INFO 0x00000200
|
||||
#define FILE_SUPPORTS_POSIX_UNLINK_RENAME 0x00000400
|
||||
#define FILE_SUPPORTS_BYPASS_IO 0x00000800
|
||||
|
||||
|
||||
|
||||
#define FILE_VOLUME_IS_COMPRESSED 0x00008000
|
||||
#define FILE_SUPPORTS_OBJECT_IDS 0x00010000
|
||||
#define FILE_SUPPORTS_ENCRYPTION 0x00020000
|
||||
#define FILE_NAMED_STREAMS 0x00040000
|
||||
#define FILE_READ_ONLY_VOLUME 0x00080000
|
||||
#define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000
|
||||
#define FILE_SUPPORTS_TRANSACTIONS 0x00200000
|
||||
#define FILE_SUPPORTS_HARD_LINKS 0x00400000
|
||||
#define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
|
||||
#define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000
|
||||
#define FILE_SUPPORTS_USN_JOURNAL 0x02000000
|
||||
#define FILE_SUPPORTS_INTEGRITY_STREAMS 0x04000000
|
||||
#define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000
|
||||
#define FILE_SUPPORTS_SPARSE_VDL 0x10000000
|
||||
#define FILE_DAX_VOLUME 0x20000000
|
||||
#define FILE_SUPPORTS_GHOSTING 0x40000000
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
#define CREATE_NEW 1
|
||||
#define CREATE_ALWAYS 2
|
||||
#define OPEN_EXISTING 3
|
||||
#define OPEN_ALWAYS 4
|
||||
#define TRUNCATE_EXISTING 5
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
namespace r5::ac
|
||||
{
|
||||
struct ac_record_t
|
||||
{
|
||||
const char *name; // 0x00 - name of the 'flag'
|
||||
int tick_triggered; // 0x08 - flag trigger time or more likely count
|
||||
int unk2; // 0x0C - unknown (2)
|
||||
};
|
||||
static_assert((sizeof(ac_record_t) == 0x10));
|
||||
|
||||
struct ac_globals_t
|
||||
{
|
||||
int num_records_queued;
|
||||
int num_records_max;
|
||||
ac_record_t* records;
|
||||
};
|
||||
|
||||
extern bool disarm_stack_walker();
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
namespace render
|
||||
{
|
||||
inline respawn::Mat_system_surface* mss = nullptr;
|
||||
|
||||
void line(const Point2& start, const Point2& end, const LColor& clr);
|
||||
void rect(const Point2& start, const Point2& end, const LColor& clr);
|
||||
void rect_filled(const Point2& start, const Point2& end, const LColor& clr);
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
#pragma once
|
||||
|
||||
typedef u32 ehandle;
|
||||
|
||||
#define RS_ENTITY_LIST_SPACE 0x10000
|
||||
#define RS_EHANDLE_INVALID 0xFFFFFFFF
|
||||
#define EHANDLE_IS_VALID(X) (X != RS_EHANDLE_INVALID)
|
||||
#define RS_EHANDLE_TO_INDEX(h) \
|
||||
(!EHANDLE_IS_VALID(h) ? -1 : (int)(h & (u32)(RS_ENTITY_LIST_SPACE - 1)))
|
||||
|
||||
struct Color
|
||||
{
|
||||
Color(float r_, float g_, float b_)
|
||||
{
|
||||
r = r_;
|
||||
g = g_;
|
||||
b = b_;
|
||||
}
|
||||
|
||||
float r;
|
||||
float g;
|
||||
float b;
|
||||
};
|
||||
|
||||
struct LColor
|
||||
{
|
||||
LColor(int r, int g, int b, int a)
|
||||
{
|
||||
this->r = r;
|
||||
this->g = g;
|
||||
this->b = b;
|
||||
this->a = a;
|
||||
}
|
||||
|
||||
LColor(int r, int g, int b) : LColor(r, g, b, 255)
|
||||
{
|
||||
}
|
||||
|
||||
LColor() = default;
|
||||
|
||||
int r;
|
||||
int g;
|
||||
int b;
|
||||
int a;
|
||||
};
|
||||
|
||||
namespace rs::clr
|
||||
{
|
||||
inline LColor white;
|
||||
inline LColor black;
|
||||
inline LColor green;
|
||||
inline LColor blue;
|
||||
inline LColor light_blue;
|
||||
|
||||
inline void init()
|
||||
{
|
||||
white = LColor(255, 255, 255);
|
||||
black = LColor(0, 0, 0);
|
||||
green = LColor(45, 255, 45);
|
||||
blue = LColor(45, 45, 255);
|
||||
light_blue = LColor(66, 135, 245);
|
||||
}
|
||||
}
|
||||
|
||||
inline Vec4 to_vec4(Vec3 vec, float w)
|
||||
{
|
||||
return Vec4(vec.x, vec.y, vec.z, w);
|
||||
}
|
||||
|
||||
struct matrix3x4
|
||||
{
|
||||
float *operator[](int i)
|
||||
{
|
||||
return m_value[i];
|
||||
}
|
||||
|
||||
const float *operator[](int i) const
|
||||
{
|
||||
return m_value[i];
|
||||
}
|
||||
|
||||
float *Base()
|
||||
{
|
||||
return &m_value[0][0];
|
||||
}
|
||||
|
||||
const float *Base() const
|
||||
{
|
||||
return &m_value[0][0];
|
||||
}
|
||||
|
||||
float m_value[3][4];
|
||||
};
|
||||
|
||||
struct matrix4x4
|
||||
{
|
||||
float *operator[](int i)
|
||||
{
|
||||
return m_value[i];
|
||||
}
|
||||
|
||||
const float *operator[](int i) const
|
||||
{
|
||||
return m_value[i];
|
||||
}
|
||||
|
||||
float *Base()
|
||||
{
|
||||
return &m_value[0][0];
|
||||
}
|
||||
|
||||
const float *Base() const
|
||||
{
|
||||
return &m_value[0][0];
|
||||
}
|
||||
|
||||
float m_value[4][4];
|
||||
};
|
||||
|
||||
struct __declspec(align(16)) matrix3x4a : matrix3x4
|
||||
{
|
||||
};
|
||||
|
||||
#include "respawn/defs.h"
|
||||
#include "respawn/prototypes.h"
|
||||
#include "respawn/dt_recv.h"
|
||||
#include "respawn/netvars.h"
|
||||
#include "respawn/collision.h"
|
||||
#include "respawn/entity.h"
|
||||
#include "respawn/input_system_buttons.h"
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct entity_info_t
|
||||
{
|
||||
u64 ptr;
|
||||
n64 serial;
|
||||
u64 prev;
|
||||
u64 next;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
bool is_valid_session();
|
||||
Entity local_player(bool lenient = false);
|
||||
|
||||
#define RS_WAS_BUTTON_DOWN(a2) (((*(u32 *)((g.ctx->game_base + gctx->offsets.input_system) + 4 * ((u64)(a2) >> 5) + 0xB0)) & (1 << ((a2)&0x1F))) != 0)
|
||||
|
||||
enum class Legends
|
||||
{
|
||||
Invalid = -1,
|
||||
Unset,
|
||||
Octane,
|
||||
Gibby,
|
||||
Bang,
|
||||
Wraith,
|
||||
Pathy,
|
||||
Wifeline,
|
||||
};
|
||||
|
||||
class GlobalVars
|
||||
{
|
||||
public:
|
||||
char pad_0000[16]; // 0x0000
|
||||
float Curtime; // 0x0010
|
||||
char pad_0014[12]; // 0x0014
|
||||
float Frametime; // 0x0020
|
||||
char pad_0024[12]; // 0x0024
|
||||
float IntervalPerTick; // 0x0030
|
||||
int32_t MaxClients; // 0x0034
|
||||
char pad_0038[8]; // 0x0038
|
||||
int32_t TickCount; // 0x0040
|
||||
char pad_0044[1052]; // 0x0044
|
||||
}; // Size: 0x0460
|
||||
static_assert(sizeof(GlobalVars) == 0x460);
|
||||
|
||||
namespace d3d
|
||||
{
|
||||
typedef struct _D3DMATRIX
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
float _11, _12, _13, _14;
|
||||
float _21, _22, _23, _24;
|
||||
float _31, _32, _33, _34;
|
||||
float _41, _42, _43, _44;
|
||||
};
|
||||
float m[4][4];
|
||||
};
|
||||
} D3DMATRIX;
|
||||
}
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct R5_file_info
|
||||
{
|
||||
void* data;
|
||||
int32_t length;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
#include "respawn/math.h"
|
||||
#include "respawn/in_state.h"
|
||||
#include "respawn/iface/ifaces.h"
|
||||
|
||||
namespace respawn
|
||||
{
|
||||
bool init();
|
||||
void *get_mm_inst();
|
||||
char *get_name_ptr(Entity &ent);
|
||||
bool get_name(Entity &ent, char *buf, size_t len);
|
||||
char* get_clantag_ptr(Entity& ent);
|
||||
bool w2s(Vec3 &vIn, Vec3 &vOut);
|
||||
bool hijack_playlist_data(void* data);
|
||||
bool setup_render_points(const matrix3x4 &coordination_frame,
|
||||
const Vec3 &mins, const Vec3 &maxs, rs::math::render_points_t &out);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
namespace nv::collision
|
||||
{
|
||||
NETVAR_OFFSET_RECEIVER(vec_mins);
|
||||
NETVAR_OFFSET_RECEIVER(vec_maxs);
|
||||
|
||||
extern void init();
|
||||
}
|
||||
|
||||
class Collision
|
||||
{
|
||||
public:
|
||||
DATA_FIELD_DIRECT(vec_mins, Vec3, nv::collision::vec_mins);
|
||||
DATA_FIELD_DIRECT(vec_maxs, Vec3, nv::collision::vec_maxs);
|
||||
};
|
||||
@@ -0,0 +1,83 @@
|
||||
#pragma once
|
||||
|
||||
//
|
||||
// CUserCmd Inputs
|
||||
//
|
||||
#define IN_ATTACK (1 << 0)
|
||||
#define IN_JUMP (1 << 1)
|
||||
#define IN_DUCK (1 << 2)
|
||||
#define IN_FORWARD (1 << 3)
|
||||
#define IN_BACK (1 << 4)
|
||||
#define IN_USE (1 << 5)
|
||||
#define IN_CANCEL (1 << 6)
|
||||
#define IN_LEFT (1 << 7)
|
||||
#define IN_RIGHT (1 << 8)
|
||||
#define IN_MOVELEFT (1 << 9)
|
||||
#define IN_MOVERIGHT (1 << 10)
|
||||
#define IN_ATTACK2 (1 << 11)
|
||||
#define IN_RUN (1 << 12)
|
||||
#define IN_RELOAD (1 << 13)
|
||||
#define IN_ALT1 (1 << 14)
|
||||
#define IN_ALT2 (1 << 15)
|
||||
#define IN_SCORE (1 << 16) // Used by client.dll for when scoreboard is held down
|
||||
#define IN_SPEED (1 << 17) // Player is holding the speed key
|
||||
#define IN_WALK (1 << 18) // Player holding walk key
|
||||
#define IN_ZOOM (1 << 19) // Zoom key for HUD zoom
|
||||
#define IN_WEAPON1 (1 << 20) // weapon defines these bits
|
||||
#define IN_WEAPON2 (1 << 21) // weapon defines these bits
|
||||
#define IN_BULLRUSH (1 << 22)
|
||||
#define IN_GRENADE1 (1 << 23) // grenade 1
|
||||
#define IN_GRENADE2 (1 << 24) // grenade 2
|
||||
#define IN_ATTACK3 (1 << 25)
|
||||
|
||||
//
|
||||
// FFlags
|
||||
//
|
||||
#define FL_ONGROUND (1<<0) // At rest / on the ground
|
||||
#define FL_DUCKING (1<<1) // Player flag -- Player is fully crouched
|
||||
#define FL_WATERJUMP (1<<2) // player jumping out of water
|
||||
#define FL_ONTRAIN (1<<3) // Player is _controlling_ a train, so movement commands should be ignored on client during prediction.
|
||||
#define FL_INRAIN (1<<4) // Indicates the entity is standing in rain
|
||||
#define FL_FROZEN (1<<5) // Player is frozen for 3rd person camera
|
||||
#define FL_ATCONTROLS (1<<6) // Player can't move, but keeps key inputs for controlling another entity
|
||||
#define FL_CLIENT (1<<7) // Is a player
|
||||
#define FL_FAKECLIENT (1<<8) // Fake client, simulated server side; don't send network messages to them
|
||||
#define FL_INWATER (1<<9) // In water
|
||||
|
||||
//
|
||||
// Client Frame Stages
|
||||
//
|
||||
enum client_frame_stages
|
||||
{
|
||||
frame_undefined = -1,
|
||||
frame_start,
|
||||
|
||||
frame_net_update_start,
|
||||
frame_net_update_post_data_update_start,
|
||||
frame_net_update_post_data_update_end,
|
||||
frame_net_update_end,
|
||||
|
||||
frame_render_start,
|
||||
frame_render_end,
|
||||
frame_stage_count,
|
||||
};
|
||||
|
||||
//
|
||||
// Game Modes
|
||||
//
|
||||
enum class GameModes
|
||||
{
|
||||
invalid = -1,
|
||||
unset = 0,
|
||||
|
||||
survival, // BR, Ranked, FiringRange
|
||||
tdm, // TDM
|
||||
control,
|
||||
gunrun,
|
||||
};
|
||||
|
||||
#define RS_MAX_PLAYERS 100
|
||||
#define RS_PLAYER_MAX_NAME_LEN 32+1+4+1
|
||||
#define RS_CONVERT_TEAM_MODULO(num) ((num % 2) ? 1 : 2)
|
||||
|
||||
#define STATIC_OFFSET( X ) X
|
||||
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
namespace rs
|
||||
{
|
||||
class recv_prop
|
||||
{
|
||||
public:
|
||||
int32_t type; //0x0000
|
||||
int32_t offset; //0x0004
|
||||
char pad_0008[24]; //0x0008
|
||||
class recv_table* data_table; //0x0020
|
||||
char* name; //0x0028
|
||||
bool is_inside_array; //0x0030
|
||||
char pad_0031[7]; //0x0031
|
||||
class recv_prop* array_prop; //0x0038
|
||||
void* proxy_fn; //0x0040
|
||||
char pad_0048[12]; //0x0048
|
||||
int32_t flags; //0x0054
|
||||
char pad_0058[4]; //0x0058
|
||||
int32_t num_elements; //0x005C
|
||||
}; //Size: 0x0060
|
||||
|
||||
class recv_table
|
||||
{
|
||||
public:
|
||||
char pad_0000[8]; //0x0000
|
||||
recv_prop** props; //0x0008
|
||||
int32_t num_props; //0x0010
|
||||
char pad_0014[1196]; //0x0014
|
||||
void* decoder; //0x04C0
|
||||
char* name; //0x04C8
|
||||
bool initialized; //0x04D0
|
||||
bool in_main_list; //0x04D1
|
||||
}; //Size: 0x04D2
|
||||
|
||||
class client_class
|
||||
{
|
||||
public:
|
||||
void* create_fn; //0x0000
|
||||
void* create_event_fn; //0x0008
|
||||
char* network_name; //0x0010
|
||||
recv_table* table; //0x0018
|
||||
client_class* next; //0x0020
|
||||
int32_t id; //0x0028
|
||||
char pad_002C[4]; //0x002C
|
||||
char* name; //0x0030
|
||||
}; //Size: 0x0038
|
||||
}
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
#pragma once
|
||||
|
||||
namespace nv::entity
|
||||
{
|
||||
NETVAR_OFFSET_RECEIVER(life_state);
|
||||
NETVAR_OFFSET_RECEIVER(team_num);
|
||||
NETVAR_OFFSET_RECEIVER(team_member_index);
|
||||
NETVAR_OFFSET_RECEIVER(squad_id);
|
||||
NETVAR_OFFSET_RECEIVER(trav_progress);
|
||||
NETVAR_OFFSET_RECEIVER(trav_start_time);
|
||||
NETVAR_OFFSET_RECEIVER(trav_release_time);
|
||||
NETVAR_OFFSET_RECEIVER(identifier_base);
|
||||
NETVAR_OFFSET_RECEIVER(health);
|
||||
NETVAR_OFFSET_RECEIVER(health_max);
|
||||
NETVAR_OFFSET_RECEIVER(armor);
|
||||
NETVAR_OFFSET_RECEIVER(armor_max);
|
||||
NETVAR_OFFSET_RECEIVER(fflags);
|
||||
NETVAR_OFFSET_RECEIVER(bleed_out_state);
|
||||
NETVAR_OFFSET_RECEIVER(latest_primary_weapon);
|
||||
NETVAR_OFFSET_RECEIVER(view_model);
|
||||
NETVAR_OFFSET_RECEIVER(pcollision);
|
||||
|
||||
extern void init();
|
||||
}
|
||||
|
||||
class Entity
|
||||
{
|
||||
public:
|
||||
Entity() = delete;
|
||||
Entity(u64 base)
|
||||
{
|
||||
m_base = base;
|
||||
}
|
||||
|
||||
auto base() const { return m_base; }
|
||||
|
||||
template <typename T>
|
||||
T &get(u32 off) { return *(T *)(m_base + off); }
|
||||
|
||||
DATA_FIELD_NR(renderable, m_base, void *, 0x10);
|
||||
DATA_FIELD_NR(networkable, m_base, void *, 0x18);
|
||||
DATA_FIELD_NR(collision, m_base, Collision, nv::entity::pcollision);
|
||||
|
||||
DATA_FIELD(handle, ehandle, 0x8);
|
||||
DATA_FIELD(mdl_name, char *, 0x30); // m_ModelName
|
||||
DATA_FIELD(life_state, short, nv::entity::life_state); // m_lifeState
|
||||
DATA_FIELD(time_base, float, STATIC_OFFSET(0x2088)); // m_currentFramePlayer.timeBase
|
||||
DATA_FIELD(bone_matrix, matrix3x4a *, 0x0E18);
|
||||
|
||||
DATA_FIELD(name_index, int, 0x38);
|
||||
|
||||
DATA_FIELD(team_num, int, nv::entity::team_num);
|
||||
DATA_FIELD(team_member_index, int, nv::entity::team_member_index);
|
||||
DATA_FIELD(squad_id, int, nv::entity::squad_id);
|
||||
DATA_FIELD(trav_progress, float, nv::entity::trav_progress); // m_traversalProgress
|
||||
DATA_FIELD(trav_start_time, float, nv::entity::trav_start_time); // m_traversalStartTime
|
||||
DATA_FIELD(trav_release_time, float, nv::entity::trav_release_time); // m_traversalReleaseTime
|
||||
|
||||
DATA_FIELD(identifier_base, u64, nv::entity::identifier_base); // m_iSignifierName
|
||||
|
||||
DATA_FIELD(health, int, nv::entity::health); // m_iHealth
|
||||
DATA_FIELD(health_max, int, nv::entity::health_max); // m_iMaxHealth
|
||||
DATA_FIELD(armor, int, nv::entity::armor); // m_shieldHealth
|
||||
DATA_FIELD(armor_max, int, nv::entity::armor_max); // m_shieldHealthMax
|
||||
|
||||
DATA_FIELD(flags, int, nv::entity::fflags); // m_fFlags
|
||||
|
||||
DATA_FIELD(bleed_out_state, int, nv::entity::bleed_out_state); // m_bleedoutState
|
||||
|
||||
DATA_FIELD(latest_primary_weapon, ehandle, nv::entity::latest_primary_weapon); // m_latestPrimaryWeapons
|
||||
DATA_FIELD(view_model, ehandle, nv::entity::view_model); // m_hViewModels
|
||||
|
||||
DATA_FIELD(origin, Vec3, 0x17C);
|
||||
DATA_FIELD(punch_angle, Vec3, STATIC_OFFSET(0x2438)); // m_currentFrameLocalPlayer.m_vecPunchWeapon_Angle
|
||||
DATA_FIELD(last_vis_time, float, STATIC_OFFSET(0x1990));
|
||||
DATA_FIELD(view_angle, Vec3, gctx->offsets.player.view_angle); // CInput::CreateMove
|
||||
DATA_FIELD(view_pos, Vec3, gctx->offsets.player.view_offset);
|
||||
DATA_FIELD(rgfl_coordinate_frame, matrix3x4, STATIC_OFFSET(0x7B0)); // CClientRenderable::GetRgflCoordinateFrame (40 53 48 83 EC 20 48 8D 59 F0 48 8B CB E8 ? ? ? ? 48 8D 83 ? ? ? ? 48 83 C4 20 5B C3)
|
||||
|
||||
inline bool is_alive()
|
||||
{
|
||||
if (life_state() != 0)
|
||||
return false;
|
||||
if (!is_dummie() && bleed_out_state() != 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline u64 identifier_hash()
|
||||
{
|
||||
auto id_base = identifier_base();
|
||||
if (!id_base)
|
||||
return 0;
|
||||
|
||||
return *(u64 *)id_base;
|
||||
}
|
||||
|
||||
inline auto eidx()
|
||||
{
|
||||
return RS_EHANDLE_TO_INDEX(handle());
|
||||
}
|
||||
|
||||
inline bool is_valid()
|
||||
{
|
||||
if (!base())
|
||||
return false;
|
||||
if (!identifier_base())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool is_player()
|
||||
{
|
||||
return (identifier_hash() == decrypt_constant(encrypt_constant(0x726579616c70)));
|
||||
}
|
||||
|
||||
inline bool is_dummie()
|
||||
{
|
||||
return (identifier_hash() == decrypt_constant(encrypt_constant(0x6d6d75645f63706e)));
|
||||
}
|
||||
|
||||
inline bool is_weapon()
|
||||
{
|
||||
return (identifier_hash() == decrypt_constant(encrypt_constant(0x786E6F70616577)));
|
||||
}
|
||||
|
||||
inline bool is_sky_diving() // #STR: "Player_IsSkyDiving"
|
||||
{
|
||||
return *reinterpret_cast<u32*>(base() + STATIC_OFFSET(0x468C)) != 0;
|
||||
}
|
||||
|
||||
inline auto get_level() // #STR: "XP %d too low"
|
||||
{
|
||||
auto opaque1 = *reinterpret_cast<int*>(gctx->game_base + STATIC_OFFSET(0x74916C4));
|
||||
auto opaque2 = reinterpret_cast<int*>(gctx->game_base + STATIC_OFFSET(0x74917C0));
|
||||
|
||||
if(opaque1 < 1)
|
||||
return 1;
|
||||
|
||||
auto num_xp = *reinterpret_cast<int*>(base() + STATIC_OFFSET(0x3694));
|
||||
if(num_xp > 0)
|
||||
{
|
||||
auto v3 = opaque1;
|
||||
auto v4 = opaque1;
|
||||
|
||||
while (num_xp < opaque2[v4])
|
||||
{
|
||||
--v3;
|
||||
if (--v4 < 1)
|
||||
return 1;
|
||||
}
|
||||
return v3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
u64 get_active_weapon();
|
||||
u64 get_view_model();
|
||||
bool is_ally_of(Entity &other);
|
||||
|
||||
auto get_bone_pos(int id)
|
||||
{
|
||||
auto bm = bone_matrix();
|
||||
|
||||
if (bm == nullptr || !MmIsAddressValid(bm))
|
||||
return VEC_EMPTY;
|
||||
|
||||
return Vec3(
|
||||
bm[id][0][3],
|
||||
bm[id][1][3],
|
||||
bm[id][2][3]) +
|
||||
origin();
|
||||
}
|
||||
|
||||
auto get_center_pos()
|
||||
{
|
||||
auto result = VEC_EMPTY;
|
||||
auto pcoll = collision();
|
||||
if(pcoll)
|
||||
{
|
||||
auto vec_mins = pcoll->vec_mins();
|
||||
auto vec_maxs = pcoll->vec_maxs();
|
||||
|
||||
_fp(diver, 2.f);
|
||||
|
||||
result = origin();
|
||||
result.z += (vec_mins.z + vec_maxs.z) / diver;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
protected:
|
||||
u64 m_base;
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "mm.h"
|
||||
#include "surface.h"
|
||||
#include "view_render.h"
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
namespace rs
|
||||
{
|
||||
class Mem_alloc
|
||||
{
|
||||
public:
|
||||
void *alloc(size_t len)
|
||||
{
|
||||
return vfunc::call<0, void *>(this, len);
|
||||
}
|
||||
|
||||
void free(void *p)
|
||||
{
|
||||
return vfunc::call<5, void>(this, p);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
namespace respawn
|
||||
{
|
||||
class Mat_system_surface
|
||||
{
|
||||
public:
|
||||
void get_screen_size(int &wide, int &tall)
|
||||
{
|
||||
return vfunc::call<53, void>(this, &wide, &tall);
|
||||
}
|
||||
|
||||
void draw_set_color(const LColor &clr)
|
||||
{
|
||||
return vfunc::call<14, void>(this, clr.r, clr.g, clr.b, clr.a);
|
||||
}
|
||||
|
||||
void draw_rect_outlined(int x0, int y0, int x1, int y1)
|
||||
{
|
||||
return vfunc::call<19, void>(this, x0, y0, x1, y1);
|
||||
}
|
||||
|
||||
void draw_rect_filled(int x0, int y0, int x1, int y1)
|
||||
{
|
||||
auto addr = gctx->game_base + gctx->offsets.fns.mss_draw_filled_rect;
|
||||
return reinterpret_cast<void(__thiscall*)(void*, int, int, int, int)>(PTR_OF(addr))(
|
||||
this, x0, y0, x1, y1);
|
||||
}
|
||||
|
||||
void draw_line(int x0, int y0, int x1, int y1)
|
||||
{
|
||||
return vfunc::call<20, void>(this, x0, y0, x1, y1);
|
||||
}
|
||||
|
||||
template <typename... A>
|
||||
void draw_text(u16 font, int size, const Point2& pos, const LColor &clr, const char *fmt, A... args)
|
||||
{
|
||||
using fn = void(__thiscall *)(void *, u16, int, int, int, int, int, int, int, const char *, ...);
|
||||
auto fun = reinterpret_cast<fn>((*reinterpret_cast<uptr **>(this))[195]);
|
||||
|
||||
return fun(this, font, size, pos.x, pos.y,
|
||||
clr.r, clr.g, clr.b, clr.a, fmt, args...);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
namespace respawn
|
||||
{
|
||||
class View_render
|
||||
{
|
||||
public:
|
||||
auto get_view_matrix(char index)
|
||||
{
|
||||
return *(d3d::D3DMATRIX **)(BASE_OF(this) + 8 * index + 0x11A350);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
#pragma once
|
||||
|
||||
namespace rs
|
||||
{
|
||||
enum class InKeyStates : int
|
||||
{
|
||||
UNSET = 0,
|
||||
FORCE = 1,
|
||||
TAP = 2,
|
||||
RELEASE = 3,
|
||||
IDLE = 4,
|
||||
HOLDING = 5,
|
||||
};
|
||||
|
||||
class In_state
|
||||
{
|
||||
public:
|
||||
In_state()
|
||||
{
|
||||
_pstate = nullptr;
|
||||
}
|
||||
|
||||
In_state(uptr addr) :
|
||||
In_state()
|
||||
{
|
||||
construct(addr);
|
||||
}
|
||||
|
||||
void construct(uptr addr)
|
||||
{
|
||||
_pstate = reinterpret_cast<InKeyStates *>(addr);
|
||||
}
|
||||
|
||||
auto state() const { return *_pstate; }
|
||||
|
||||
void tap() const
|
||||
{
|
||||
*_pstate = InKeyStates::TAP;
|
||||
}
|
||||
|
||||
void force() const
|
||||
{
|
||||
*_pstate = InKeyStates::FORCE;
|
||||
}
|
||||
|
||||
void toggle(bool val) const
|
||||
{
|
||||
if (val)
|
||||
*_pstate = InKeyStates::HOLDING;
|
||||
else
|
||||
*_pstate = InKeyStates::IDLE;
|
||||
}
|
||||
|
||||
void block() const
|
||||
{
|
||||
*_pstate = InKeyStates::RELEASE;
|
||||
}
|
||||
|
||||
void reset() const
|
||||
{
|
||||
*_pstate = InKeyStates::IDLE;
|
||||
}
|
||||
|
||||
bool active() const
|
||||
{
|
||||
if (*_pstate == InKeyStates::HOLDING || *_pstate == InKeyStates::FORCE ||
|
||||
*_pstate == InKeyStates::TAP)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
InKeyStates *_pstate;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
namespace rs
|
||||
{
|
||||
enum class Buttons
|
||||
{
|
||||
MOUSE_4 = 111,
|
||||
MOUSE_5 = 112,
|
||||
MOUSE_1 = 108,
|
||||
MOUSE_2 = 109,
|
||||
|
||||
KB_F1 = 92,
|
||||
KB_F2 = 93,
|
||||
KB_F3 = 94,
|
||||
KB_F4 = 95,
|
||||
KB_F5 = 96,
|
||||
KB_F6 = 97,
|
||||
KB_F7 = 98,
|
||||
KB_F8 = 99,
|
||||
KB_F9 = 100,
|
||||
KB_F10 = 101,
|
||||
KB_F11 = 102,
|
||||
KB_F12 = 103,
|
||||
|
||||
KB_KEY_C = 13,
|
||||
KB_KEY_V = 32,
|
||||
KB_KEY_SHIFT = 79,
|
||||
|
||||
KB_NUMPAD_1 = 38,
|
||||
KB_NUMPAD_2 = 39,
|
||||
KB_NUMPAD_3 = 40,
|
||||
KB_NUMPAD_4 = 41,
|
||||
KB_NUMPAD_5 = 42,
|
||||
KB_NUMPAD_6 = 43,
|
||||
KB_NUMPAD_7 = 44,
|
||||
KB_NUMPAD_8 = 45,
|
||||
KB_NUMPAD_9 = 46,
|
||||
|
||||
KB_ARROW_DOWN = 90,
|
||||
KB_ARROW_UP = 88,
|
||||
KB_ARROW_LEFT = 89,
|
||||
KB_ARROW_RIGHT = 91,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
Math HEADER dedicated to respawn stuff
|
||||
What does this one have that the main math HEADER doesnt:
|
||||
- can use respawn defs and structs.
|
||||
Keep that in mind when working on this.
|
||||
*/
|
||||
|
||||
namespace rs::math
|
||||
{
|
||||
struct render_points_t
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float w;
|
||||
float h;
|
||||
};
|
||||
|
||||
inline void vec_trans(Vec3 &in, const matrix3x4 &matrix, Vec3 &out)
|
||||
{
|
||||
const auto in_array = in.base();
|
||||
|
||||
out.x = ::math::dot_prod(in_array, matrix[0]) + matrix[0][3];
|
||||
out.y = ::math::dot_prod(in_array, matrix[1]) + matrix[1][3];
|
||||
out.z = ::math::dot_prod(in_array, matrix[2]) + matrix[2][3];
|
||||
}
|
||||
|
||||
LLVM_NOOPT extern bool screen_range_is_within_crosshair(int* begin, int* end) LLVMT(LLVMOBF_INLINE_FP());
|
||||
LLVM_NOOPT extern bool screen_make_bubble_for_combat_ent(Entity& ent, int* obegin, int* oend, float scale) LLVMT(LLVMOBF_INLINE_FP());
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
namespace rs::netvars
|
||||
{
|
||||
extern bool init();
|
||||
extern int32_t find(const char* table, const char* name);
|
||||
extern void dump();
|
||||
}
|
||||
|
||||
LLVM_NOOPT LLVM_INLINE void __netvar_assign(const char *table, const char *prop, u32 *receiver)
|
||||
{
|
||||
auto off = rs::netvars::find(table, prop);
|
||||
if (off == 0)
|
||||
{
|
||||
#if LOGGING_IS_ENABLED == 1
|
||||
msg("failed to find a netvar!");
|
||||
#endif
|
||||
|
||||
__fastfail(0xDAC);
|
||||
}
|
||||
*receiver = off;
|
||||
}
|
||||
|
||||
#define NETVAR_OFFSET_RECEIVER(NAME) inline u32 NAME
|
||||
#define NETVAR_ASSIGN(RECEIVER, TABLE_NAME, PROP_NAME) __netvar_assign(TABLE_NAME, PROP_NAME, RECEIVER)
|
||||
@@ -0,0 +1 @@
|
||||
#pragma once
|
||||
@@ -0,0 +1,74 @@
|
||||
#pragma once
|
||||
|
||||
namespace rotate
|
||||
{
|
||||
template<class T>
|
||||
constexpr T left(T value, int count)
|
||||
{
|
||||
const uint nbits = sizeof(T) * 8;
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
count %= nbits;
|
||||
T high = value >> (nbits - count);
|
||||
if (T(-1) < 0) // signed value
|
||||
high &= ~((T(-1) << count));
|
||||
value <<= count;
|
||||
value |= high;
|
||||
}
|
||||
else
|
||||
{
|
||||
count = -count % nbits;
|
||||
T low = value << (nbits - count);
|
||||
value >>= count;
|
||||
value |= low;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
constexpr T right(T value, int count)
|
||||
{
|
||||
count = -count; // invert it for this op.
|
||||
|
||||
const uint nbits = sizeof(T) * 8;
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
count %= nbits;
|
||||
T high = value >> (nbits - count);
|
||||
if (T(-1) < 0) // signed value
|
||||
high &= ~((T(-1) << count));
|
||||
value <<= count;
|
||||
value |= high;
|
||||
}
|
||||
else
|
||||
{
|
||||
count = -count % nbits;
|
||||
T low = value << (nbits - count);
|
||||
value >>= count;
|
||||
value |= low;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
inline auto encode(void* data, u32 len)
|
||||
{
|
||||
for (u32 i = 0; i < len; i++)
|
||||
{
|
||||
reinterpret_cast<u8*>(data)[i] =
|
||||
left<u8>(reinterpret_cast<u8*>(data)[i], 1);
|
||||
reinterpret_cast<u8*>(data)[i] ^= len;
|
||||
}
|
||||
}
|
||||
|
||||
inline auto decode(void* data, u32 len)
|
||||
{
|
||||
for (u32 i = 0; i < len; i++)
|
||||
{
|
||||
reinterpret_cast<u8*>(data)[i] ^= len;
|
||||
reinterpret_cast<u8*>(data)[i] =
|
||||
right<u8>(reinterpret_cast<u8*>(data)[i], 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#define WINAPI_INLINE LLVM_NOOPT __attribute((noinline)) inline
|
||||
#define SYSV_API_INLINE LLVM_NOOPT __attribute((noinline, sysv_abi)) inline
|
||||
|
||||
namespace stl
|
||||
{
|
||||
inline uptr baseof_libc = 0;
|
||||
inline uptr baseof_libm = 0;
|
||||
|
||||
bool init(uptr libc_base, uptr libm_base);
|
||||
|
||||
namespace prototypes
|
||||
{
|
||||
typedef int (*fn_sprintf)(char *, const char *, ...) __attribute__((sysv_abi));
|
||||
typedef u32 (*fn_sleep)(u32) __attribute__((sysv_abi));
|
||||
}
|
||||
|
||||
namespace fps
|
||||
{
|
||||
inline prototypes::fn_sprintf sprintf = nullptr;
|
||||
inline prototypes::fn_sleep sleep = nullptr;
|
||||
}
|
||||
|
||||
SYSV_API_INLINE auto Xfopen(const char *path, const char *mode)
|
||||
{
|
||||
using fn = void *(*)(const char *, const char *);
|
||||
return reinterpret_cast<fn>(baseof_libc + gctx->linuxcrt_cpp.fopen)(path, mode);
|
||||
}
|
||||
|
||||
SYSV_API_INLINE auto Xfputs(const char *buf, void *fp)
|
||||
{
|
||||
using fn = int (*)(const char *, void *);
|
||||
return reinterpret_cast<fn>(baseof_libc + gctx->linuxcrt_cpp.fputs)(buf, fp);
|
||||
}
|
||||
|
||||
SYSV_API_INLINE auto Xfclose(void *fp)
|
||||
{
|
||||
using fn = int (*)(void *);
|
||||
return reinterpret_cast<fn>(baseof_libc + gctx->linuxcrt_cpp.fclose)(fp);
|
||||
}
|
||||
|
||||
/*
|
||||
Math
|
||||
*/
|
||||
SYSV_API_INLINE auto Xacosf(float val)
|
||||
{
|
||||
using fn = float (*)(float);
|
||||
return reinterpret_cast<fn>(baseof_libm + gctx->linuxcrt_math.acosf)(val);
|
||||
}
|
||||
|
||||
SYSV_API_INLINE auto Xatan2f(float y, float x)
|
||||
{
|
||||
using fn = float (*)(float, float);
|
||||
return reinterpret_cast<fn>(baseof_libm + gctx->linuxcrt_math.atan2f)(y, x);
|
||||
}
|
||||
|
||||
SYSV_API_INLINE auto Xfabsf(float val)
|
||||
{
|
||||
using fn = float (*)(float);
|
||||
return reinterpret_cast<fn>(baseof_libm + gctx->linuxcrt_math.fabsf)(val);
|
||||
}
|
||||
|
||||
SYSV_API_INLINE auto Xsinf(__m128 xx)
|
||||
{
|
||||
using fn = float (*)(__m128);
|
||||
return reinterpret_cast<fn>(baseof_libm + gctx->linuxcrt_math.sinf)(xx);
|
||||
}
|
||||
|
||||
SYSV_API_INLINE auto Xcosf(__m128 xx)
|
||||
{
|
||||
using fn = float (*)(__m128);
|
||||
return reinterpret_cast<fn>(baseof_libm + gctx->linuxcrt_math.cosf)(xx);
|
||||
}
|
||||
|
||||
inline auto file_exists(const char *path)
|
||||
{
|
||||
if (auto handle = Xfopen(path, "r"))
|
||||
{
|
||||
Xfclose(handle);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
LLVM_NOOPT extern void *global_mm_alloc(size_t len);
|
||||
LLVM_NOOPT extern void global_mm_free(void *p);
|
||||
|
||||
template <typename T, typename... Args>
|
||||
T *alloc_type(Args... args)
|
||||
{
|
||||
void *memory = global_mm_alloc(sizeof(T));
|
||||
if (memory == nullptr)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
T *object = new (memory) T(args...);
|
||||
return object;
|
||||
}
|
||||
|
||||
inline uintptr_t search(const uint8_t *data, const uint8_t *end, const uint8_t *needle, size_t needle_len)
|
||||
{
|
||||
if (needle_len > 0)
|
||||
{
|
||||
for (auto *curr = data; curr < end; curr++)
|
||||
{
|
||||
if (curr[0] == needle[0])
|
||||
{
|
||||
if (needle_len == 1)
|
||||
return (uintptr_t)curr;
|
||||
|
||||
auto complen = needle_len - 1;
|
||||
auto comppos = &curr[1];
|
||||
auto needlepos = &needle[1];
|
||||
size_t num_matching = 0;
|
||||
|
||||
for (size_t i = 0; i < complen; i++)
|
||||
{
|
||||
if (comppos[i] == needlepos[i])
|
||||
{
|
||||
num_matching++;
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (num_matching == complen)
|
||||
return (uintptr_t)curr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
#pragma once
|
||||
|
||||
#define CONTAINING_RECORD(address, type, field) \
|
||||
(reinterpret_cast<type*>(reinterpret_cast<char*>(address) - __builtin_offsetof(type, field)))
|
||||
|
||||
namespace stl
|
||||
{
|
||||
// Define the LIST_ENTRY structure
|
||||
typedef struct _LIST_ENTRY
|
||||
{
|
||||
struct _LIST_ENTRY *Flink;
|
||||
struct _LIST_ENTRY *Blink;
|
||||
} LIST_ENTRY, *PLIST_ENTRY;
|
||||
|
||||
LLVM_NOOPT LLVM_INLINE void InitializeListHead(PLIST_ENTRY listHead)
|
||||
{
|
||||
listHead->Flink = listHead->Blink = listHead;
|
||||
}
|
||||
|
||||
LLVM_NOOPT LLVM_INLINE void InsertHeadList(PLIST_ENTRY listHead, PLIST_ENTRY entry)
|
||||
{
|
||||
entry->Flink = listHead->Flink;
|
||||
entry->Blink = listHead;
|
||||
listHead->Flink->Blink = entry;
|
||||
listHead->Flink = entry;
|
||||
}
|
||||
|
||||
LLVM_NOOPT LLVM_INLINE void RemoveEntryList(PLIST_ENTRY entry)
|
||||
{
|
||||
entry->Blink->Flink = entry->Flink;
|
||||
entry->Flink->Blink = entry->Blink;
|
||||
entry->Flink = entry->Blink = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
WARNING: DO NOT USE C++ CLASSES WITH DYNAMIC CONSTRUCTORS, DYNAMIC DATA TYPES ET CETERA.
|
||||
THIS IS INTENDED TO BE A REPLACEMENT FOR C STYLE ARRAYS BUT WITH DYNAMIC WIDTH, NOT A VECTOR REPLACEMENT!
|
||||
*/
|
||||
template <typename storage_type>
|
||||
class linked_list_single
|
||||
{
|
||||
public:
|
||||
linked_list_single() = delete;
|
||||
linked_list_single(fn_mem_alloc alloc_fun, fn_mem_free free_fun)
|
||||
: _mm_fun_alloc(alloc_fun), _mm_fun_free(free_fun)
|
||||
{
|
||||
InitializeListHead(&_head);
|
||||
}
|
||||
|
||||
LLVM_NOOPT void push(const storage_type &data)
|
||||
{
|
||||
list_entry_data<storage_type> *entry = static_cast<list_entry_data<storage_type> *>(_mm_fun_alloc(sizeof(list_entry_data<storage_type>)));
|
||||
if (entry != nullptr)
|
||||
{
|
||||
entry->entry.Flink = _head.Flink;
|
||||
_head.Flink = &(entry->entry);
|
||||
memcpy( &entry->data, &data, sizeof(storage_type));
|
||||
}
|
||||
}
|
||||
|
||||
storage_type pop()
|
||||
{
|
||||
if (_head.Flink == nullptr)
|
||||
return storage_type();
|
||||
|
||||
LIST_ENTRY *entry = _head.Flink;
|
||||
_head.Flink = entry->Flink;
|
||||
|
||||
list_entry_data<storage_type> *entryData = reinterpret_cast<list_entry_data<storage_type> *>(entry);
|
||||
storage_type data = entryData->data;
|
||||
|
||||
_mm_fun_free(entryData);
|
||||
return data;
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
LIST_ENTRY *entry = _head.Flink;
|
||||
while (entry != head())
|
||||
{
|
||||
LIST_ENTRY *nextEntry = entry->Flink;
|
||||
list_entry_data<storage_type> *entryData = reinterpret_cast<list_entry_data<storage_type> *>(entry);
|
||||
_mm_fun_free(entryData);
|
||||
entry = nextEntry;
|
||||
}
|
||||
}
|
||||
|
||||
auto head() { return &_head; }
|
||||
auto link_first() { return head()->Flink; }
|
||||
auto link_is_last(LIST_ENTRY *link) { return link == head(); }
|
||||
auto link_next(LIST_ENTRY **link) { *link = (*(link))->Flink; }
|
||||
|
||||
LLVM_NOOPT storage_type* link_value(LIST_ENTRY *link)
|
||||
{
|
||||
return &(CONTAINING_RECORD(link, list_entry_data<storage_type>, entry)->data);
|
||||
}
|
||||
|
||||
private : template <typename T>
|
||||
struct list_entry_data
|
||||
{
|
||||
LIST_ENTRY entry;
|
||||
T data;
|
||||
};
|
||||
|
||||
fn_mem_alloc _mm_fun_alloc;
|
||||
fn_mem_free _mm_fun_free;
|
||||
LIST_ENTRY _head;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
#pragma once
|
||||
|
||||
namespace stl
|
||||
{
|
||||
using fn_mem_alloc = void*(__fastcall*)(size_t);
|
||||
using fn_mem_free = void(__fastcall*)(void*);
|
||||
}
|
||||
|
||||
LLVM_NOOPT inline size_t strlen(const char *s)
|
||||
{
|
||||
size_t len = 0;
|
||||
while (*s != '\0')
|
||||
{
|
||||
++len;
|
||||
++s;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
LLVM_NOOPT inline uint32_t string_hash_fnv1a(const char *str)
|
||||
{
|
||||
const uint32_t prime = 0x1000193;
|
||||
const uint32_t offset = 0x811c9dc5;
|
||||
uint32_t hash = offset;
|
||||
|
||||
for (const char *p = str; *p; p++)
|
||||
{
|
||||
hash ^= *p;
|
||||
hash *= prime;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
LLVM_NOOPT inline int strcmp(const char *s1, const char *s2)
|
||||
{
|
||||
while (*s1 == *s2++)
|
||||
if (*s1++ == 0)
|
||||
return (0);
|
||||
return (*(unsigned char *)s1 - *(unsigned char *)--s2);
|
||||
}
|
||||
|
||||
LLVM_NOOPT inline int strncmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
if (n == 0)
|
||||
return (0);
|
||||
do
|
||||
{
|
||||
if (*s1 != *s2++)
|
||||
return (*(unsigned char *)s1 - *(unsigned char *)--s2);
|
||||
if (*s1++ == 0)
|
||||
break;
|
||||
} while (--n != 0);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
LLVM_NOOPT inline char *strstr(const char *s, const char *find)
|
||||
{
|
||||
char c, sc;
|
||||
size_t len;
|
||||
if ((c = *find++) != 0)
|
||||
{
|
||||
len = strlen(find);
|
||||
do
|
||||
{
|
||||
do
|
||||
{
|
||||
if ((sc = *s++) == 0)
|
||||
return (NULL);
|
||||
} while (sc != c);
|
||||
} while (strncmp(s, find, len) != 0);
|
||||
s--;
|
||||
}
|
||||
return ((char *)s);
|
||||
}
|
||||
|
||||
LLVM_NOOPT inline int wcscmp(const wchar_t *s1, const wchar_t *s2)
|
||||
{
|
||||
while (*s1 && *s2 && (*s1 == *s2))
|
||||
{
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
return (*s1 - *s2);
|
||||
}
|
||||
|
||||
LLVM_NOOPT inline char *strcpy(char *d, const char *s)
|
||||
{
|
||||
char *saved = d;
|
||||
|
||||
while (*s)
|
||||
{
|
||||
*d++ = *s++;
|
||||
}
|
||||
|
||||
*d = 0;
|
||||
|
||||
return saved;
|
||||
}
|
||||
|
||||
LLVM_NOOPT inline char* find_substr(char* data, const char* needle)
|
||||
{
|
||||
if (!data || !needle)
|
||||
return nullptr;
|
||||
|
||||
size_t data_len = strlen(data);
|
||||
size_t needle_len = strlen(needle);
|
||||
|
||||
for (size_t i = 0; i <= data_len - needle_len; i++)
|
||||
{
|
||||
size_t j;
|
||||
for (j = 0; j < needle_len; j++)
|
||||
{
|
||||
if (data[i + j] != needle[j])
|
||||
break;
|
||||
}
|
||||
|
||||
if (j == needle_len)
|
||||
return &data[i];
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void __guaranteed_stosb(void *dest, unsigned char value, size_t count);
|
||||
void __guaranteed_movsb(void *dest, const void *src, size_t count);
|
||||
|
||||
#define memset(dst, val, len) __guaranteed_stosb((unsigned char *)dst, val, len)
|
||||
#define memcpy(dst, src, len) __guaranteed_movsb((unsigned char *)dst, (unsigned char const *)src, len)
|
||||
|
||||
/*
|
||||
* WARNING: Copies exactly 16 bytes, regardless of the actual valid data range.
|
||||
* This WILL certainly lead to crashes in situations where the memory becomes invalid,
|
||||
* after a certain size has been surpassed.
|
||||
*/
|
||||
LLVM_NOOPT inline void memcpy_16(unsigned char* dst, const unsigned char* src)
|
||||
{
|
||||
__m128i xmm0 = _mm_loadu_si128((__m128i*)src);
|
||||
_mm_storeu_si128((__m128i*)dst, xmm0);
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING: Hashes exactly 16 bytes, regardless of the actual valid data range.
|
||||
* This WILL certainly lead to crashes in situations where the memory becomes invalid,
|
||||
* after a certain size has been surpassed.
|
||||
*/
|
||||
LLVM_NOOPT inline void str2hash_16(uint64_t* out, const char* str)
|
||||
{
|
||||
__m128i rs;
|
||||
memcpy_16(reinterpret_cast<unsigned char*>(&rs), reinterpret_cast<const unsigned char*>(str));
|
||||
|
||||
out[0] = _mm_cvtsi128_si64(rs);
|
||||
out[1] = _mm_cvtsi128_si64(_mm_srli_si128(rs, 8));
|
||||
}
|
||||
|
||||
inline constexpr uint32_t float2dword(const float f)
|
||||
{
|
||||
return __builtin_bit_cast(uint32_t, f);
|
||||
}
|
||||
|
||||
__attribute((always_inline)) inline float dword2float(uint32_t dw)
|
||||
{
|
||||
float rs = 0.f;
|
||||
memcpy(&rs, &dw, 4);
|
||||
return rs;
|
||||
}
|
||||
|
||||
#define _fp(name, val) \
|
||||
constexpr auto __##name = float2dword(val); \
|
||||
auto name = dword2float(__##name);
|
||||
|
||||
#define _fpg(name, val) \
|
||||
inline static constexpr auto __##name = float2dword(val); \
|
||||
inline static auto name = dword2float(__##name);
|
||||
|
||||
#include "stl/linked_list_single.h"
|
||||
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
extern void stream_encode(uint8_t *buffer, size_t length, uint64_t key);
|
||||
extern void stream_decode(uint8_t *buffer, size_t length, uint64_t key);
|
||||
|
||||
#define STRREC_MAX_CONTENT_LENGTH 64
|
||||
|
||||
struct String_record
|
||||
{
|
||||
uint32_t length;
|
||||
uint32_t hash;
|
||||
char content[STRREC_MAX_CONTENT_LENGTH];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct String_table
|
||||
{
|
||||
uint32_t magic;
|
||||
uint32_t table_total_length;
|
||||
uint32_t table_records_count;
|
||||
String_record table[1];
|
||||
} __attribute__((packed));
|
||||
|
||||
extern String_record* str_from_hash(uint32_t hash);
|
||||
|
||||
#define hash2str(HASH) Crypted_string( _encoded_const(HASH) ).decrypt()
|
||||
|
||||
class Crypted_string
|
||||
{
|
||||
public:
|
||||
Crypted_string() = delete;
|
||||
Crypted_string(uint32_t hash);
|
||||
|
||||
const char* decrypt();
|
||||
private:
|
||||
uint32_t m_length;
|
||||
char m_contents[STRREC_MAX_CONTENT_LENGTH];
|
||||
};
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
namespace tools
|
||||
{
|
||||
void replace_slash_with_underscore(const char *path, char *output);
|
||||
char integer2char(int digit);
|
||||
void *vft_cave_setup(size_t table_count, uptr cave_begin, u32 cave_cap, u32 &disp);
|
||||
size_t vft_calc_len(void *ptbl);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
namespace vft
|
||||
{
|
||||
LLVM_NOOPT void *cave_setup(size_t table_count, uptr cave_begin, u32 cave_cap, u32 &disp);
|
||||
LLVM_NOOPT size_t calc_len(void *ptbl);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
namespace vfunc
|
||||
{
|
||||
template <typename Type>
|
||||
__forceinline Type get(void *instance, size_t index)
|
||||
{
|
||||
return (*reinterpret_cast<Type**>(instance))[index];
|
||||
}
|
||||
|
||||
template <size_t Index, typename ReturnType, typename... Args>
|
||||
__forceinline ReturnType call(void *instance, Args... args)
|
||||
{
|
||||
using Fn = ReturnType(__thiscall *)(void *, Args...);
|
||||
auto function = (*reinterpret_cast<Fn **>(instance))[Index];
|
||||
return function(instance, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <u64 length>
|
||||
struct fake_class_t
|
||||
{
|
||||
fake_class_t() = delete;
|
||||
fake_class_t(u64 vta)
|
||||
{
|
||||
vtable_addr = vta;
|
||||
memset(space, 0, length);
|
||||
}
|
||||
|
||||
u64 vtable_addr; // 0x0
|
||||
char space[length]; // 0x8
|
||||
};
|
||||
@@ -0,0 +1,79 @@
|
||||
#pragma once
|
||||
|
||||
class vmthk
|
||||
{
|
||||
public:
|
||||
vmthk() = default;
|
||||
|
||||
void setup(size_t TABLE_COUNT, void *inst, void* storage = nullptr)
|
||||
{
|
||||
memset(this, 0, sizeof(vmthk));
|
||||
|
||||
m_inst = inst;
|
||||
m_table_original = *reinterpret_cast<void ***>(inst);
|
||||
m_count = TABLE_COUNT;
|
||||
|
||||
if (!m_count)
|
||||
return;
|
||||
|
||||
m_len = (m_count + 1 + 1) * sizeof(uptr);
|
||||
if(storage != nullptr)
|
||||
{
|
||||
m_table = reinterpret_cast<void**>(storage);
|
||||
} else {
|
||||
/*
|
||||
This has been stripped because not needed ATM since we use CAVES,
|
||||
and it causes an until yet unnoticed compilation error:
|
||||
r5/src/inc/vmthk.h:23:47: error: use of undeclared identifier 'g'
|
||||
} else {m_table = reinterpret_cast<void **>(g.ix.mm->alloc(m_len)); }
|
||||
^
|
||||
Ideally we put this in a vmthk.cpp or some shit, should we need it again.
|
||||
*/
|
||||
// m_table = reinterpret_cast<void **>(g.ix.mm->alloc(m_len));
|
||||
#if LOGGING_IS_ENABLED == 1
|
||||
LMsg(128, "vmthk::setup() -> null storage not implemented!");
|
||||
#endif
|
||||
__fastfail(_encoded_const(0xDAC1FD00));
|
||||
}
|
||||
|
||||
if (!m_table)
|
||||
return;
|
||||
|
||||
memset(m_table, 0, m_len);
|
||||
|
||||
m_table[0] = m_table_original[-1];
|
||||
memcpy(&m_table[1], m_table_original, m_len - (sizeof(uptr) * 2));
|
||||
}
|
||||
|
||||
const auto &count() const { return m_count; }
|
||||
|
||||
auto table() { return m_table; }
|
||||
auto enable() { *reinterpret_cast<uptr *>(m_inst) = BASE_OF(&m_table[1]); }
|
||||
auto disable() { *reinterpret_cast<void ***>(m_inst) = m_table_original; }
|
||||
|
||||
auto place(size_t idx2, void *handler) -> void *
|
||||
{
|
||||
auto idx = idx2 + 1;
|
||||
if (idx > m_count)
|
||||
return nullptr;
|
||||
|
||||
auto orig = m_table[idx];
|
||||
m_table[idx] = handler;
|
||||
|
||||
return orig;
|
||||
}
|
||||
|
||||
template <typename R>
|
||||
auto original(size_t idx) -> R
|
||||
{
|
||||
return (R)m_table_original[idx];
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
void *m_inst;
|
||||
void **m_table;
|
||||
void **m_table_original;
|
||||
size_t m_count;
|
||||
size_t m_len;
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void read_xmm6(float* out);
|
||||
void read_xmm7(float* out);
|
||||
void read_xmm8(float* out);
|
||||
|
||||
void write_xmm6(float val);
|
||||
void write_xmm7(float val);
|
||||
void write_xmm8(float val);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
#define _XS(X) X
|
||||
#define _XSW(X) X
|
||||
@@ -0,0 +1,35 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
void Input::init()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
LLVM_NOOPT void Input::reset()
|
||||
{
|
||||
memset(_key_states, 0, sizeof(_key_states));
|
||||
memset(_key_states_prev, 0, sizeof(_key_states_prev));
|
||||
}
|
||||
|
||||
LLVM_NOOPT void Input::tick_begin()
|
||||
{
|
||||
// update the key states of the current tick.
|
||||
for (u16 i = 0; i < INPUT_MAX_KEYS_TO_TRACK; i++)
|
||||
_key_states[i] = RS_WAS_BUTTON_DOWN(i);
|
||||
}
|
||||
|
||||
LLVM_NOOPT void Input::tick_end()
|
||||
{
|
||||
// keep track of our previous key states.
|
||||
memcpy(_key_states_prev, _key_states, sizeof(_key_states));
|
||||
}
|
||||
|
||||
LLVM_NOOPT bool Input::is_button_down(rs::Buttons key)
|
||||
{
|
||||
return _key_states[(int)key];
|
||||
}
|
||||
|
||||
LLVM_NOOPT bool Input::was_button_pressed(rs::Buttons key)
|
||||
{
|
||||
return !_key_states_prev[(int)key] && _key_states[(int)key];
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
namespace logger
|
||||
{
|
||||
void log2file(const char *contents)
|
||||
{
|
||||
#if defined(_RI_ENABLE_LOGGING) || defined(DECLARE_AS_DEBUG_BUILD) || defined(_RI_ENABLE_LOGGING_MINIMAL)
|
||||
auto fp = stl::Xfopen(_XS("/home/drof/Documents/log.txt"), _XS("a"));
|
||||
if (fp)
|
||||
{
|
||||
stl::Xfputs(contents, fp);
|
||||
stl::Xfputs("\n", fp);
|
||||
stl::Xfclose(fp);
|
||||
}
|
||||
#else
|
||||
__asm nop;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
Globals g;
|
||||
LoaderContext *gctx = (LoaderContext *)0x0AAAAAAAAAAAAAAAC;
|
||||
|
||||
LLVM_NOOPT bool init_early() LLVMT(LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
gfloats.init();
|
||||
rs::clr::init();
|
||||
|
||||
auto ctx = gctx;
|
||||
memset(&g, 0, sizeof(g));
|
||||
g.ctx = ctx;
|
||||
|
||||
if (!stl::init(ctx->libc_base, ctx->libm_base))
|
||||
return false;
|
||||
|
||||
if(!r5::ac::disarm_stack_walker())
|
||||
return false;
|
||||
|
||||
if(!hooks::init_early())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
LLVM_NOINLINE bool init() LLVMT(LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
auto ctx = gctx;
|
||||
|
||||
g.signon_state = (int *)(ctx->game_base + ctx->offsets.signon_state);
|
||||
g.ent_list = (entity_info_t *)(ctx->game_base + ctx->offsets.entity_list);
|
||||
g.gvars = *(GlobalVars **)(ctx->game_base + ctx->offsets.global_vars);
|
||||
g.gv.rs_controller_checks_enabled = reinterpret_cast<int*>( *(uptr*)(ctx->game_base + ctx->offsets.rs_cvar_gamepad_checks_enabled) + 0x64);
|
||||
g.gv.rs_controller_checks_last = reinterpret_cast<double*>( ctx->game_base + ctx->offsets.rs_gamepad_checks_last );
|
||||
|
||||
g.ix.base_client = (ctx->game_base + ctx->offsets.base_client);
|
||||
g.ix.client_state = (uptr)(ctx->game_base + ctx->offsets.client_state);
|
||||
g.ix.mm = (rs::Mem_alloc *)(BASE_OF(respawn::get_mm_inst()));
|
||||
g.ix.mss = *(respawn::Mat_system_surface **)(ctx->game_base + ctx->offsets.mat_system_surface);
|
||||
g.ix.view_render = (respawn::View_render *)(ctx->game_base + ctx->offsets.view_render);
|
||||
g.ix.mat_kwewed_render_ctx = (uptr)(ctx->game_base + ctx->offsets.kwewed_render_ctx);
|
||||
g.ix.pclient_mode = reinterpret_cast<uptr *>(gctx->game_base + gctx->offsets.client_mode);
|
||||
|
||||
// restore the VFT for init hook, this used to be the loaders job but we do it now.
|
||||
*reinterpret_cast<uptr *>(g.ix.base_client) = gctx->vft_orig_ptrs.base_client;
|
||||
|
||||
if (!respawn::init())
|
||||
return false;
|
||||
math::external::init();
|
||||
|
||||
g.inputs.ui.init();
|
||||
g.inputs.cmove.init();
|
||||
|
||||
g.in_states.duck.construct( gctx->game_base + STATIC_OFFSET(0x73F2E00) );
|
||||
g.in_states.jump.construct( gctx->game_base + STATIC_OFFSET(0x73F2D00) );
|
||||
g.in_states.attack.construct( gctx->game_base + STATIC_OFFSET(0x73F2C20) );
|
||||
|
||||
g.conf.init();
|
||||
|
||||
*g.gv.rs_controller_checks_enabled = 0;
|
||||
|
||||
if(!rs::netvars::init())
|
||||
return false;
|
||||
|
||||
if(!EC::init())
|
||||
return false;
|
||||
|
||||
if (!hooks::init())
|
||||
return false;
|
||||
|
||||
ctx->inited = 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
LLVM_NOOPT __attribute__((naked)) __declspec(dllexport) LLVM_NOINLINE void __fastcall _kb()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
jmp tp_init
|
||||
}
|
||||
}
|
||||
|
||||
LLVM_NOOPT LLVM_NOINLINE void main()
|
||||
{
|
||||
if (!init_early())
|
||||
{
|
||||
__fastfail(_encoded_const(0x1337));
|
||||
}
|
||||
|
||||
if (!init())
|
||||
{
|
||||
__fastfail(_encoded_const(0x1227));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
namespace math
|
||||
{
|
||||
/*
|
||||
* ONLY USE FUNCTIONS WITH SIMPLE CONTROL FLOW
|
||||
* FROM WITHIN THE GAME IMAGE SO THAT WE CAN CONTROL STACK WALKS.
|
||||
*/
|
||||
void external::init()
|
||||
{
|
||||
memset(&pfns, 0, sizeof(funs));
|
||||
|
||||
pfns.ang2vec = reinterpret_cast<void*>(gctx->game_base + gctx->offsets.fns.math_ang2vec);
|
||||
pfns.vec2ang = reinterpret_cast<void*>(gctx->game_base + gctx->offsets.fns.math_vec2ang);
|
||||
}
|
||||
|
||||
__forceinline float remainderf(float x, float y)
|
||||
{
|
||||
int xi = *(int*)&x;
|
||||
int yi = *(int*)&y;
|
||||
int q = (int)(x / y);
|
||||
return x - (float)q * y;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,399 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
#define MENU_FONT_HEIGHT 14
|
||||
#define MENU_FONT_HEIGHT_ADD (MENU_FONT_HEIGHT+2)
|
||||
|
||||
#define STARTUP_DEBUG_PANE_MAX_TIME 45.f
|
||||
#define R5AC_DEBUG_PANE_MAX_TIME 45.f
|
||||
|
||||
namespace menu
|
||||
{
|
||||
state_t state;
|
||||
respawn::Mat_system_surface *gmss = nullptr;
|
||||
|
||||
void checkbox(int &idx, const char *text, bool &pval) LLVMT(LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
auto clr = pval ? LColor(255, 255, 65) : LColor(120, 120, 120);
|
||||
gmss->draw_text(2, MENU_FONT_HEIGHT,
|
||||
{state.render_pos_x, state.render_pos_y + state.height}, clr, text);
|
||||
|
||||
if (state.idx == idx)
|
||||
{
|
||||
if (g.inputs.ui.was_button_pressed(rs::Buttons::KB_ARROW_LEFT))
|
||||
{
|
||||
pval = false;
|
||||
}
|
||||
else if (g.inputs.ui.was_button_pressed(rs::Buttons::KB_ARROW_RIGHT))
|
||||
{
|
||||
pval = true;
|
||||
}
|
||||
}
|
||||
|
||||
state.nitems++;
|
||||
state.height += MENU_FONT_HEIGHT_ADD;
|
||||
idx++;
|
||||
}
|
||||
|
||||
void slider_options(int &idx, const char *text, int &pval, int valmax, char **opts) LLVMT(LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
auto clr = pval > 0 ? LColor(255, 255, 65) : LColor(120, 120, 120);
|
||||
gmss->draw_text(2, MENU_FONT_HEIGHT, {state.render_pos_x, state.render_pos_y + state.height}, clr, _XS("%s [%s]"), text, opts[pval]);
|
||||
|
||||
if (state.idx == idx)
|
||||
{
|
||||
if (g.inputs.ui.was_button_pressed(rs::Buttons::KB_ARROW_LEFT))
|
||||
{
|
||||
if (pval > 0)
|
||||
pval--;
|
||||
}
|
||||
else if (g.inputs.ui.was_button_pressed(rs::Buttons::KB_ARROW_RIGHT))
|
||||
{
|
||||
if (pval < valmax)
|
||||
pval++;
|
||||
}
|
||||
}
|
||||
|
||||
state.nitems++;
|
||||
state.height += MENU_FONT_HEIGHT_ADD;
|
||||
idx++;
|
||||
}
|
||||
|
||||
LLVM_NOOPT void slider_percentage(int &idx, const char *text, int &pval, int step) LLVMT(LLVMOBF_INLINE_FP(),LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
auto clr = pval > 0.f ? LColor(255, 255, 65) : LColor(120, 120, 120);
|
||||
gmss->draw_text(2, MENU_FONT_HEIGHT, {state.render_pos_x, state.render_pos_y + state.height}, clr, _XS("%s (%i%%)"), text, pval);
|
||||
|
||||
if (state.idx == idx)
|
||||
{
|
||||
if (g.inputs.ui.was_button_pressed(rs::Buttons::KB_ARROW_LEFT))
|
||||
{
|
||||
if (pval > 0)
|
||||
pval -= step;
|
||||
|
||||
/* in case STEP made us negative. */
|
||||
if (pval < 0)
|
||||
pval = 0;
|
||||
}
|
||||
else if (g.inputs.ui.was_button_pressed(rs::Buttons::KB_ARROW_RIGHT))
|
||||
{
|
||||
if (pval < 100)
|
||||
pval += step;
|
||||
}
|
||||
}
|
||||
|
||||
state.nitems++;
|
||||
state.height += MENU_FONT_HEIGHT_ADD;
|
||||
idx++;
|
||||
}
|
||||
|
||||
LLVM_NOOPT void slider_float(int &idx, const char *text, float &pval, float maxval, float step, int precision = 0) LLVMT(LLVMOBF_INLINE_FP(),LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
char fmt[64];
|
||||
memset(fmt, 0, sizeof(fmt));
|
||||
switch(precision)
|
||||
{
|
||||
case 1: strcpy(fmt, hash2str(0x37300878)); break;
|
||||
case 2: strcpy(fmt, hash2str(0xbd12c0e3)); break;
|
||||
case 3: strcpy(fmt, hash2str(0x665770b8)); break;
|
||||
case 4: strcpy(fmt, hash2str(0xe45c4108)); break;
|
||||
default: strcpy(fmt, hash2str(0x199d07b)); break;
|
||||
}
|
||||
|
||||
|
||||
auto clr = pval > 0.f ? LColor(255, 255, 65) : LColor(120, 120, 120);
|
||||
gmss->draw_text(2, MENU_FONT_HEIGHT, {state.render_pos_x, state.render_pos_y + state.height}, clr, fmt, text, pval);
|
||||
|
||||
if (state.idx == idx)
|
||||
{
|
||||
if (g.inputs.ui.was_button_pressed(rs::Buttons::KB_ARROW_LEFT))
|
||||
{
|
||||
if (pval > 0.f)
|
||||
pval -= step;
|
||||
|
||||
/* in case STEP made us negative. */
|
||||
if (pval < 0.f)
|
||||
pval = 0.f;
|
||||
}
|
||||
else if (g.inputs.ui.was_button_pressed(rs::Buttons::KB_ARROW_RIGHT))
|
||||
{
|
||||
if (pval < maxval)
|
||||
pval += step;
|
||||
}
|
||||
}
|
||||
|
||||
state.nitems++;
|
||||
state.height += MENU_FONT_HEIGHT_ADD;
|
||||
idx++;
|
||||
}
|
||||
|
||||
void on_update_pos()
|
||||
{
|
||||
state.render_pos_x = state.pos_x + 4;
|
||||
state.render_pos_y = state.pos_y + 4;
|
||||
}
|
||||
|
||||
void init() LLVMT(LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
state.visible = true;
|
||||
state.pos_w = 115;
|
||||
state.pos_h = 2;
|
||||
state.height = 0;
|
||||
state.pos_x = g.screen_dim[0] - state.pos_w - 2;
|
||||
state.pos_y = (g.screen_dim[1] / 12) * 5;
|
||||
|
||||
on_update_pos();
|
||||
}
|
||||
|
||||
LLVM_NOOPT void startup_debug_pane() LLVMT(LLVMOBF_INLINE_FP())
|
||||
{
|
||||
#if !defined(PROD) && defined(DECLARE_AS_DEBUG_BUILD)
|
||||
if(!menu::is_visible() && g.startup_debug_pane_finished)
|
||||
return;
|
||||
|
||||
if(!g.startup_debug_pane_draw_time)
|
||||
{
|
||||
if(Plat_FloatTime() > 0.1f)
|
||||
{
|
||||
g.startup_debug_pane_draw_time = Plat_FloatTime();
|
||||
}
|
||||
} else
|
||||
{
|
||||
if(!menu::is_visible() && (Plat_FloatTime() - g.startup_debug_pane_draw_time) > STARTUP_DEBUG_PANE_MAX_TIME)
|
||||
{
|
||||
g.startup_debug_pane_finished = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int push = 0;
|
||||
|
||||
int start_x = (g.screen_dim[0] / 2) - 200, start_y = 25;
|
||||
|
||||
gmss->draw_text( 2, 14, { start_x, start_y + push }, rs::clr::blue, "Startup!" );
|
||||
push += 15;
|
||||
|
||||
gmss->draw_text( 2, 14, { start_x, start_y + push }, rs::clr::white,
|
||||
"WINAPI_RtlCaptureStackBackTrace: %p", gctx->winapis.capture_stack_back_trace );
|
||||
push += 15;
|
||||
|
||||
|
||||
#if defined(DECLARE_AS_DEBUG_BUILD)
|
||||
gmss->draw_text( 2, 14, { start_x, start_y + push }, rs::clr::white,
|
||||
"GAME_SCN_TEXT: %llx [L%llx]", gctx->game_cs_base, gctx->game_cs_len );
|
||||
push += 15;
|
||||
|
||||
gmss->draw_text( 2, 14, { start_x, start_y + push }, rs::clr::white,
|
||||
"GAME_SCN_RDATA: %llx [L%llx]", gctx->game_rdata_base, gctx->game_rdata_len );
|
||||
push += 15;
|
||||
|
||||
gmss->draw_text( 2, 14, { start_x, start_y + push }, rs::clr::white,
|
||||
"GAME_SCN_DATA: %llx [L%llx]", gctx->game_data_base, gctx->game_data_len );
|
||||
push += 15;
|
||||
#endif
|
||||
|
||||
gmss->draw_text( 2, 14, { start_x, start_y + push }, rs::clr::white,
|
||||
"R5AC_NumStackWalksDisarmed: %i", g.r5ac_num_stack_walks_disarmed );
|
||||
push += 15;
|
||||
|
||||
if (!menu::is_visible())
|
||||
{
|
||||
float time_left = STARTUP_DEBUG_PANE_MAX_TIME - (Plat_FloatTime() - g.startup_debug_pane_draw_time);
|
||||
gmss->draw_text(2, 14, {start_x, start_y + push}, rs::clr::white, "disappearing in %.1f", time_left);
|
||||
push += 15;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
LLVM_NOOPT void respawn_integrity_debug_pane() LLVMT(LLVMOBF_INLINE_FP())
|
||||
{
|
||||
#if !defined(PROD) && defined(DECLARE_AS_DEBUG_BUILD)
|
||||
if(!g.r5ac_debug_pane_draw_time)
|
||||
{
|
||||
if(Plat_FloatTime() > 0.1f)
|
||||
{
|
||||
g.r5ac_debug_pane_draw_time = Plat_FloatTime();
|
||||
}
|
||||
} else
|
||||
{
|
||||
if( !menu::is_visible() && (Plat_FloatTime() - g.r5ac_debug_pane_draw_time) > R5AC_DEBUG_PANE_MAX_TIME )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int push = 0;
|
||||
|
||||
int start_x = (g.screen_dim[0] / 2) + 200, start_y = 25;
|
||||
|
||||
gmss->draw_text( 2, 14, { start_x, start_y + push }, rs::clr::white, "RS_gamepad_checks: %i", *g.gv.rs_controller_checks_enabled );
|
||||
push += 15;
|
||||
|
||||
gmss->draw_text( 2, 14, { start_x, start_y + push }, rs::clr::white, "RS_gamepad_checks_last: %f", *g.gv.rs_controller_checks_last );
|
||||
push += 15;
|
||||
|
||||
gmss->draw_text( 2, 14, { start_x, start_y + push }, rs::clr::white, "R5_AC_swalk_lc: %x", g.r5ac_stack_walk_last_call );
|
||||
push += 15;
|
||||
|
||||
gmss->draw_text( 2, 14, { start_x, start_y + push }, rs::clr::white, "last_disconnect_reason: '%s'", g.last_disconnect_reason );
|
||||
push += 15;
|
||||
|
||||
#if defined(DECLARE_AS_DEBUG_BUILD)
|
||||
if(is_valid_session())
|
||||
{
|
||||
auto me = local_player();
|
||||
if (me.is_valid())
|
||||
{
|
||||
char name[RS_PLAYER_MAX_NAME_LEN];
|
||||
memset(name, 0, sizeof(name));
|
||||
|
||||
respawn::get_name(me, name, sizeof(name));
|
||||
gmss->draw_text(2, 14, {start_x, start_y + push}, rs::clr::white, "local_player_name: '%s'", name);
|
||||
push += 15;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!menu::is_visible())
|
||||
{
|
||||
float time_left = R5AC_DEBUG_PANE_MAX_TIME - (Plat_FloatTime() - g.r5ac_debug_pane_draw_time);
|
||||
gmss->draw_text(2, 14, {start_x, start_y + push}, rs::clr::white, "disappearing in %.1f", time_left);
|
||||
push += 15;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
LLVM_NOOPT void r5i_build_info_pane() LLVMT(LLVMOBF_INLINE_FP(),LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
if(!menu::is_visible())
|
||||
return;
|
||||
|
||||
int push = 0;
|
||||
int start_x = state.pos_x - 250, start_y = 5;
|
||||
|
||||
gmss->draw_text( 2, 14, { start_x, start_y + push }, rs::clr::light_blue, "%s | %s", __DATE__, __TIME__ );
|
||||
push += 15;
|
||||
|
||||
#if defined(PROD)
|
||||
gmss->draw_text(2, 14, {start_x, start_y + push}, rs::clr::light_blue, "Premium build, registered to %s", STRINGIFIED_DEF(_WATERMARKED_USER));
|
||||
push += 15;
|
||||
#endif
|
||||
|
||||
gmss->draw_text( 2, 14, { start_x, start_y + push }, rs::clr::light_blue, hash2str(0xffa91a45), STRINGIFIED_DEF(_COMPILED_AES_SEED_VALUE) );
|
||||
push += 15;
|
||||
}
|
||||
|
||||
LLVM_NOOPT void on_render(respawn::Mat_system_surface *mss) LLVMT(LLVMOBF_INLINE_FP(),LLVMOBF_COMBO_STANDARD)
|
||||
{
|
||||
gmss = mss;
|
||||
|
||||
if (!state.inited)
|
||||
{
|
||||
if(g.screen_dim[0] > 0 && g.screen_dim[1] > 0)
|
||||
{
|
||||
init();
|
||||
state.inited = true;
|
||||
} else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(!g.conf.anon_mode)
|
||||
{
|
||||
respawn_integrity_debug_pane();
|
||||
startup_debug_pane();
|
||||
}
|
||||
|
||||
r5i_build_info_pane();
|
||||
|
||||
if (g.inputs.ui.was_button_pressed(rs::Buttons::KB_NUMPAD_7))
|
||||
{
|
||||
state.visible = !state.visible;
|
||||
}
|
||||
|
||||
if (!state.visible)
|
||||
return;
|
||||
|
||||
if (is_valid_session())
|
||||
{
|
||||
/* only draw background when in game, because i
|
||||
struggle to read the values when in game due to diff terrain. */
|
||||
mss->draw_set_color(LColor(45, 45, 45));
|
||||
mss->draw_rect_filled(state.pos_x,
|
||||
state.render_pos_y,
|
||||
state.pos_x + state.pos_w,
|
||||
state.render_pos_y + state.pos_h + state.height);
|
||||
}
|
||||
|
||||
mss->draw_set_color(LColor(125, 125, 125, 155));
|
||||
mss->draw_rect_filled(state.pos_x,
|
||||
state.render_pos_y + (state.idx * MENU_FONT_HEIGHT_ADD),
|
||||
state.pos_x + state.pos_w,
|
||||
state.render_pos_y + (state.idx * MENU_FONT_HEIGHT_ADD) + MENU_FONT_HEIGHT_ADD);
|
||||
|
||||
if (g.inputs.ui.was_button_pressed(rs::Buttons::KB_ARROW_UP))
|
||||
{
|
||||
if (state.idx > 0)
|
||||
state.idx--;
|
||||
}
|
||||
else if (g.inputs.ui.was_button_pressed(rs::Buttons::KB_ARROW_DOWN))
|
||||
{
|
||||
if (state.idx < state.nitems - 1)
|
||||
state.idx++;
|
||||
}
|
||||
|
||||
auto pos_x = state.render_pos_x;
|
||||
auto pos_y = state.render_pos_y;
|
||||
|
||||
//
|
||||
//
|
||||
|
||||
state.height = 0;
|
||||
state.nitems = 0;
|
||||
|
||||
//
|
||||
//
|
||||
|
||||
int idx = 0;
|
||||
|
||||
#if defined(DECLARE_AS_DEBUG_BUILD)
|
||||
gmss->draw_text(2, MENU_FONT_HEIGHT, {state.render_pos_x, state.render_pos_y + state.height},
|
||||
g.ingame ? rs::clr::green : rs::clr::white, _XS("IG: %i"), g.ingame);
|
||||
state.height += 15;
|
||||
#endif
|
||||
|
||||
checkbox(idx, hash2str(0xa4301260), g.conf.anon_mode);
|
||||
checkbox(idx, hash2str(0x75bc5d87), g.conf.visual);
|
||||
checkbox(idx, hash2str(0x3334d82a), g.conf.visual_far);
|
||||
checkbox(idx, hash2str(0xb1aef1bd), g.conf.visual_outline);
|
||||
|
||||
char psz_rcs_modes[2][16];
|
||||
strcpy(psz_rcs_modes[0], hash2str(0x9d2228ca));
|
||||
strcpy(psz_rcs_modes[1], hash2str(0x69fb5606));
|
||||
|
||||
char *ppsz_rcs_modes[2];
|
||||
ppsz_rcs_modes[0] = psz_rcs_modes[0];
|
||||
ppsz_rcs_modes[1] = psz_rcs_modes[1];
|
||||
checkbox(idx, hash2str(0x7e4b630f), g.conf.rcs);
|
||||
slider_options(idx, hash2str(0x36b16a7e), g.conf.rcs_mode, 1, ppsz_rcs_modes);
|
||||
slider_percentage(idx, hash2str(0xf319857d), g.conf.rcs_strength, 5);
|
||||
|
||||
checkbox(idx, hash2str(0x6226f0e7), g.conf.aim_assist);
|
||||
slider_options(idx, hash2str(0x36b16a7e), g.conf.aim_assist_mode, 1, ppsz_rcs_modes);
|
||||
checkbox(idx, hash2str(0x1f7bc172), g.conf.aim_assist_slow);
|
||||
slider_percentage(idx, hash2str(0x385a66f4), g.conf.aim_assist_strength, 10);
|
||||
checkbox(idx, hash2str(0xd8321dbd), g.conf.aim_assist_rotational);
|
||||
slider_float(idx, hash2str(0x246f545c), g.conf.aim_assist_fov, 25.f, 0.25f, 2);
|
||||
slider_float(idx, hash2str(0xdebc8a9f), g.conf.aim_assist_dead_zone, 6.f, 0.1f, 1);
|
||||
slider_float(idx, hash2str(0xf319857d), g.conf.aim_assist_strength_ror, 0.2f, 0.002, 3);
|
||||
|
||||
#if !defined(PROD)
|
||||
checkbox(idx, _XS("RAO"), g.conf.override_controller_aa);
|
||||
slider_percentage(idx, _XS(" STR"), g.conf.override_controller_aa_value, 10);
|
||||
#endif
|
||||
|
||||
checkbox(idx, hash2str(0x6168876c), g.conf.trigger);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
namespace rs::netvars
|
||||
{
|
||||
struct netvar_record
|
||||
{
|
||||
char name[128 + 1];
|
||||
n32 offset;
|
||||
};
|
||||
|
||||
struct netvar_table
|
||||
{
|
||||
char name[32 + 1];
|
||||
stl::linked_list_single<netvar_record> *contents;
|
||||
};
|
||||
|
||||
stl::linked_list_single<netvar_table> *gtable;
|
||||
|
||||
auto new_table(const char *name)
|
||||
{
|
||||
netvar_table rec;
|
||||
memset(rec.name, 0, sizeof(rec.name));
|
||||
strcpy(rec.name, name);
|
||||
rec.contents = stl::alloc_type<stl::linked_list_single<netvar_record>>(stl::global_mm_alloc, stl::global_mm_free);
|
||||
|
||||
if (rec.contents == nullptr)
|
||||
{
|
||||
#if LOGGING_IS_ENABLED == 1
|
||||
msg("new_table: failed to allocate memory.");
|
||||
#endif
|
||||
__fastfail(0xDAC);
|
||||
}
|
||||
|
||||
gtable->push(rec);
|
||||
return gtable->link_value(gtable->link_first());
|
||||
}
|
||||
|
||||
auto new_netvar(netvar_table *storage, const char *name, n32 offset)
|
||||
{
|
||||
netvar_record rec;
|
||||
memset(&rec, 0, sizeof(rec));
|
||||
|
||||
if (strlen(name) > sizeof(rec.name) - 1)
|
||||
{
|
||||
#if LOGGING_IS_ENABLED == 1
|
||||
msg("new_netvar: name exceeds maximum buffer cap!");
|
||||
#endif
|
||||
__fastfail(0xDAC);
|
||||
}
|
||||
|
||||
strcpy(rec.name, name);
|
||||
rec.offset = offset;
|
||||
storage->contents->push(rec);
|
||||
return storage->contents->link_value(storage->contents->link_first());
|
||||
}
|
||||
|
||||
bool is_prop_garbage(const char *name)
|
||||
{
|
||||
if (strstr(name, _XS("baseclass")) ||
|
||||
strstr(name, _XS("0")) ||
|
||||
strstr(name, _XS("1")) ||
|
||||
strstr(name, _XS("2")))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t search_within_table(stl::linked_list_single<netvar_record> *table, const char *name)
|
||||
{
|
||||
for (auto link = table->link_first(); !table->link_is_last(link); table->link_next(&link))
|
||||
{
|
||||
auto value = table->link_value(link);
|
||||
|
||||
if (!strcmp(value->name, name))
|
||||
return value->offset;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t find(const char *table, const char *name)
|
||||
{
|
||||
for (auto link = gtable->link_first(); !gtable->link_is_last(link); gtable->link_next(&link))
|
||||
{
|
||||
auto value = gtable->link_value(link);
|
||||
|
||||
if (!strcmp(value->name, table))
|
||||
{
|
||||
auto off = search_within_table(value->contents, name);
|
||||
if (off != 0)
|
||||
return off;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void process_prop(netvar_table *storage, rs::recv_prop *prop)
|
||||
{
|
||||
if (!prop->offset)
|
||||
return;
|
||||
if (is_prop_garbage(prop->name))
|
||||
return;
|
||||
new_netvar(storage, prop->name, prop->offset);
|
||||
}
|
||||
|
||||
void process_table(rs::recv_table *table)
|
||||
{
|
||||
auto storage = new_table(table->name);
|
||||
auto head = table->props;
|
||||
|
||||
for (auto i = 0ull; i < table->num_props; i++)
|
||||
{
|
||||
auto *const prop = head[i];
|
||||
|
||||
if (prop == nullptr)
|
||||
continue;
|
||||
|
||||
if (is_prop_garbage(prop->name))
|
||||
continue;
|
||||
|
||||
process_prop(storage, prop);
|
||||
|
||||
if (prop->data_table != nullptr)
|
||||
process_table(prop->data_table);
|
||||
}
|
||||
}
|
||||
|
||||
bool init()
|
||||
{
|
||||
gtable = stl::alloc_type<stl::linked_list_single<netvar_table>>(
|
||||
stl::global_mm_alloc, stl::global_mm_free);
|
||||
|
||||
auto cc_head = *reinterpret_cast<rs::client_class **>(gctx->game_base + gctx->offsets.client_class_head);
|
||||
if (cc_head == nullptr)
|
||||
return false;
|
||||
|
||||
for (auto *client_class = cc_head; client_class != nullptr; client_class = client_class->next)
|
||||
{
|
||||
auto *const table = client_class->table;
|
||||
|
||||
if (table == nullptr)
|
||||
continue;
|
||||
|
||||
process_table(table);
|
||||
}
|
||||
|
||||
/* init the global net vars. */
|
||||
nv::entity::init();
|
||||
nv::collision::init();
|
||||
|
||||
/* after we're done initing, get rid off the global table.*/
|
||||
gtable->clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
namespace r5::ac
|
||||
{
|
||||
bool disarm_stack_walker()
|
||||
{
|
||||
size_t num_handled = 0;
|
||||
uint64_t needle = gctx->winapis.capture_stack_back_trace;
|
||||
if (needle)
|
||||
{
|
||||
uintptr_t offset = 0;
|
||||
auto data = (u8*)gctx->game_data_base;
|
||||
auto end = (u8*)(gctx->game_data_base + gctx->game_data_len);
|
||||
|
||||
while (true)
|
||||
{
|
||||
auto result = stl::search(data + offset, end, (uint8_t *)&needle, sizeof(uintptr_t));
|
||||
if (result != 0)
|
||||
{
|
||||
#if LOGGING_IS_ENABLED == 1
|
||||
LMsg(256, "[R5AC] disarming stack walk at index %i and pointer %p", num_handled, result);
|
||||
#endif
|
||||
*reinterpret_cast<void **>(result) = hk_capture_stack_back_trace;
|
||||
++num_handled;
|
||||
offset = result - (uintptr_t)data + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
break; // No more occurrences found
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g.r5ac_num_stack_walks_disarmed = num_handled;
|
||||
|
||||
return (num_handled > 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
namespace render
|
||||
{
|
||||
void line(const Point2& start, const Point2& end, const LColor& clr)
|
||||
{
|
||||
mss->draw_set_color(clr);
|
||||
mss->draw_line(start.x, start.y, end.x, end.y);
|
||||
}
|
||||
|
||||
void rect(const Point2& start, const Point2& end, const LColor& clr)
|
||||
{
|
||||
mss->draw_set_color(clr);
|
||||
mss->draw_rect_outlined(start.x, start.y, end.x, end.y);
|
||||
}
|
||||
|
||||
void rect_filled(const Point2& start, const Point2& end, const LColor& clr)
|
||||
{
|
||||
mss->draw_set_color(clr);
|
||||
mss->draw_rect_filled(start.x, start.y, end.x, end.y);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
namespace rs::math
|
||||
{
|
||||
bool screen_range_is_within_crosshair(int *begin, int *end)
|
||||
{
|
||||
int cross[2] = {(int)g.screen_dim[0] / 2, (int)g.screen_dim[1] / 2};
|
||||
|
||||
return (cross[0] >= begin[0] && cross[0] < end[0]) &&
|
||||
(cross[1] >= begin[1] && cross[1] < end[1]);
|
||||
}
|
||||
|
||||
bool screen_make_bubble_for_combat_ent(Entity &ent, int *obegin, int *oend, float scale) LLVMT(LLVMOBF_INLINE_FP())
|
||||
{
|
||||
if (scale < 0.01f)
|
||||
scale = 1.f;
|
||||
|
||||
auto rec = EC::get(ent.eidx());
|
||||
if (!EC::is_cached_record_valid(ent, rec))
|
||||
return false;
|
||||
|
||||
if(!rec->rpts_avail)
|
||||
return false;
|
||||
|
||||
auto pos_origin = ent.origin();
|
||||
Vec3 scr_origin = VEC_EMPTY;
|
||||
if (!respawn::w2s(pos_origin, scr_origin))
|
||||
return false;
|
||||
|
||||
int bounds_height = rec->rpts.h;
|
||||
if(!bounds_height) return false;
|
||||
int bounds_width = rec->rpts.w * scale;
|
||||
|
||||
obegin[0] = (int)(scr_origin.x - bounds_width);
|
||||
obegin[1] = (int)(scr_origin.y - bounds_height);
|
||||
|
||||
oend[0] = (int)(scr_origin.x + bounds_width);
|
||||
oend[1] = (int)(scr_origin.y + 5.f);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,297 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
__declspec(noinline) GameModes get_game_mode(Entity &me)
|
||||
{
|
||||
auto mp_gamemode_base = *(u64 *)(gctx->game_base + gctx->offsets.mp_gamemode);
|
||||
if (mp_gamemode_base)
|
||||
{
|
||||
auto gamemode_base = *(u64 *)(mp_gamemode_base + 0x50);
|
||||
if (gamemode_base)
|
||||
{
|
||||
auto gamemode = *(u64 *)gamemode_base;
|
||||
if (gamemode == decrypt_constant(encrypt_constant(0x6c61766976727573)))
|
||||
return GameModes::survival;
|
||||
|
||||
else if (gamemode == decrypt_constant(encrypt_constant(0x6c006d6465657266)))
|
||||
{
|
||||
if (me.squad_id() == -1)
|
||||
return GameModes::tdm;
|
||||
else
|
||||
return GameModes::gunrun;
|
||||
}
|
||||
else if (gamemode == decrypt_constant(encrypt_constant(0x6c6f72746e6f63)))
|
||||
return GameModes::control;
|
||||
}
|
||||
}
|
||||
|
||||
return GameModes::invalid;
|
||||
}
|
||||
|
||||
__attribute((noinline)) bool is_valid_session()
|
||||
{
|
||||
//if(!g.ingame)
|
||||
// return false;
|
||||
|
||||
auto signon_state = *g.signon_state;
|
||||
if (signon_state != 8)
|
||||
return false;
|
||||
|
||||
auto map_name_hash = *(u64 *)(g.ctx->game_base + g.ctx->offsets.map_name);
|
||||
if (map_name_hash == 0 || map_name_hash == decrypt_constant(encrypt_constant(0x7962626f6c5f706d)))
|
||||
return false;
|
||||
|
||||
auto my_base = *(u64 *)(g.ctx->game_base + g.ctx->offsets.game_movement + 0x8);
|
||||
if (!my_base)
|
||||
return false;
|
||||
|
||||
auto me = Entity(my_base);
|
||||
if (!me.is_valid() || !me.is_alive() || !me.is_player())
|
||||
return false;
|
||||
|
||||
g.game_mode = get_game_mode(me);
|
||||
if (g.game_mode == GameModes::invalid)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
If lenient is FALSE, stricter checks will be employed.
|
||||
*/
|
||||
Entity local_player(bool lenient)
|
||||
{
|
||||
auto my_base = *(u64 *)(g.ctx->game_base + g.ctx->offsets.game_movement + 0x8);
|
||||
if (!my_base)
|
||||
return Entity(0);
|
||||
|
||||
auto me = Entity(my_base);
|
||||
if (!me.is_valid())
|
||||
return Entity(0);
|
||||
|
||||
if (!lenient && !me.is_alive())
|
||||
return Entity(0);
|
||||
|
||||
return Entity(my_base);
|
||||
}
|
||||
|
||||
namespace respawn
|
||||
{
|
||||
bool init()
|
||||
{
|
||||
// ...
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void *get_mm_inst()
|
||||
{
|
||||
using fn_get_mm_inst = void *(__fastcall *)();
|
||||
auto get_mm_inst_fn = reinterpret_cast<fn_get_mm_inst>(gctx->game_base + gctx->offsets.fns.get_mem_alloc);
|
||||
|
||||
auto rs = get_mm_inst_fn();
|
||||
return rs;
|
||||
}
|
||||
|
||||
char *get_name_ptr(Entity &ent)
|
||||
{
|
||||
auto name_list = (uptr *)(gctx->game_base + gctx->offsets.name_list);
|
||||
auto name_idx = ent.name_index();
|
||||
if (name_idx > 0 && name_idx < 100)
|
||||
{
|
||||
auto name_ptr = (char *)(name_list[3 * ent.name_index() - 3]);
|
||||
return name_ptr;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char* get_clantag_ptr(Entity& ent)
|
||||
{
|
||||
auto name_list = (uptr *)(gctx->game_base + gctx->offsets.tag_list);
|
||||
auto name_idx = ent.name_index();
|
||||
if (name_idx > 0 && name_idx < 100)
|
||||
{
|
||||
auto name_ptr = (char *)(name_list[3 * ent.name_index() - 3]);
|
||||
return name_ptr;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool get_name(Entity &ent, char *buf, size_t len)
|
||||
{
|
||||
auto name_ptr = get_name_ptr(ent);
|
||||
if (name_ptr)
|
||||
{
|
||||
if (strlen(name_ptr) > 0 && strlen(name_ptr) < (len - 1))
|
||||
{
|
||||
auto clantag_ptr = get_clantag_ptr(ent);
|
||||
if(clantag_ptr != 0)
|
||||
{
|
||||
// if ptr is NOT zero, we got a clan tag to add.
|
||||
strcpy(buf, "[");
|
||||
strcpy(buf + strlen(buf), clantag_ptr);
|
||||
strcpy(buf + strlen(buf), "] ");
|
||||
}
|
||||
|
||||
strcpy(buf + strlen(buf), name_ptr);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
LLVM_NOOPT bool w2s(Vec3 &vIn, Vec3 &vOut) LLVMT( LLVMOBF_INLINE_FP() )
|
||||
{
|
||||
auto pvMatrix = g.ix.view_render->get_view_matrix(0);
|
||||
|
||||
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.screen_dim[0];
|
||||
const auto Cl_height = g.screen_dim[1];
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool setup_render_points(const matrix3x4 &coordination_frame,
|
||||
const Vec3 &mins, const Vec3 &maxs, rs::math::render_points_t &out)
|
||||
{
|
||||
const int num_transformations = 8;
|
||||
|
||||
Vec3 points[num_transformations] = {
|
||||
{mins.x, mins.y, mins.z},
|
||||
{mins.x, maxs.y, mins.z},
|
||||
{maxs.x, maxs.y, mins.z},
|
||||
{maxs.x, mins.y, mins.z},
|
||||
{mins.x, maxs.y, maxs.z},
|
||||
{mins.x, mins.y, maxs.z},
|
||||
{maxs.x, mins.y, maxs.z}};
|
||||
|
||||
Vec3 transformed[num_transformations];
|
||||
|
||||
for (int index = 0; index < num_transformations; index++)
|
||||
{
|
||||
rs::math::vec_trans(points[index], coordination_frame, transformed[index]);
|
||||
}
|
||||
|
||||
Vec3 flb{}, brt{}, blb{}, frt{}, frb{}, brb{}, blt{}, flt{};
|
||||
|
||||
if (!w2s(transformed[3], flb) || !w2s(transformed[5], brt) ||
|
||||
!w2s(transformed[0], blb) || !w2s(transformed[4], frt) ||
|
||||
!w2s(transformed[2], frb) || !w2s(transformed[1], brb) ||
|
||||
!w2s(transformed[6], blt) || !w2s(transformed[7], flt))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Vec3 position_array[num_transformations] = {flb, brt, blb, frt, frb, brb, blt, flt};
|
||||
|
||||
float left = flb.x;
|
||||
float top = flb.y;
|
||||
float right = flb.x;
|
||||
float bottom = flb.y;
|
||||
|
||||
for (auto &index : position_array)
|
||||
{
|
||||
if (left > index.x)
|
||||
{
|
||||
left = index.x;
|
||||
}
|
||||
|
||||
if (right < index.x)
|
||||
{
|
||||
right = index.x;
|
||||
}
|
||||
|
||||
if (top < index.y)
|
||||
{
|
||||
top = index.y;
|
||||
}
|
||||
|
||||
if (bottom > index.y)
|
||||
{
|
||||
bottom = index.y;
|
||||
}
|
||||
}
|
||||
|
||||
out.x = left;
|
||||
out.y = bottom;
|
||||
out.w = (right - left);
|
||||
out.h = (top - bottom);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hijack_playlist_data(void *data)
|
||||
{
|
||||
#if !defined(PROD)
|
||||
if (g.conf.override_controller_aa)
|
||||
{
|
||||
auto pdata = data;
|
||||
auto pstr_assist_adspull_disable = find_substr((char *)pdata, "aimassist_adspull_disabled");
|
||||
if (pstr_assist_adspull_disable)
|
||||
{
|
||||
auto toggle = find_substr(pstr_assist_adspull_disable, "1");
|
||||
if (!toggle)
|
||||
{
|
||||
toggle = find_substr(pstr_assist_adspull_disable, "0");
|
||||
}
|
||||
|
||||
if (toggle)
|
||||
{
|
||||
if (toggle[0] == '1')
|
||||
{
|
||||
toggle[0] = '0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto pstr_assist_magnet_pc = find_substr((char *)pdata, "aimassist_magnet_pc");
|
||||
if (pstr_assist_magnet_pc)
|
||||
{
|
||||
auto value = find_substr(pstr_assist_magnet_pc, "0.");
|
||||
if (value)
|
||||
{
|
||||
if (g.conf.override_controller_aa_value == 100)
|
||||
{
|
||||
value[0] = '1';
|
||||
value[1] = '.';
|
||||
value[2] = '0';
|
||||
} else if(g.conf.override_controller_aa_value > 0)
|
||||
{
|
||||
value[0] = '0';
|
||||
value[1] = '.';
|
||||
int adjusted = g.conf.override_controller_aa_value / 10;
|
||||
value[2] = tools::integer2char(adjusted);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
.text
|
||||
.global __chkstk
|
||||
__chkstk:
|
||||
ret
|
||||
@@ -0,0 +1,71 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
#define ASSIGN_REINTERPRET(DST, VAL) DST = reinterpret_cast<decltype(DST)>(VAL)
|
||||
|
||||
void __guaranteed_stosb(void *dest, unsigned char value, size_t count)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"rep stosb"
|
||||
: "+D"(dest), "+c"(count)
|
||||
: "a"(value)
|
||||
: "memory");
|
||||
}
|
||||
|
||||
void __guaranteed_movsb(void *dest, const void *src, size_t count)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"rep movsb"
|
||||
: "+D"(dest), "+S"(src), "+c"(count)
|
||||
:
|
||||
: "memory");
|
||||
}
|
||||
|
||||
namespace stl
|
||||
{
|
||||
bool init(uptr libc_base, uptr libm_base)
|
||||
{
|
||||
baseof_libc = libc_base;
|
||||
baseof_libm = libm_base;
|
||||
if (!baseof_libc || !baseof_libm)
|
||||
return false;
|
||||
|
||||
fps::sprintf = reinterpret_cast<decltype(fps::sprintf)>(baseof_libc + gctx->linuxcrt_cpp.sprintf);
|
||||
fps::sleep = reinterpret_cast<decltype(fps::sleep)>(baseof_libc + gctx->linuxcrt_cpp.sleep);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void *global_mm_alloc(size_t len)
|
||||
{
|
||||
if (!g.ix.mm)
|
||||
{
|
||||
#if LOGGING_IS_ENABLED == 1
|
||||
msg("mm iface is null!");
|
||||
#endif
|
||||
__fastfail(0x3D2A);
|
||||
}
|
||||
|
||||
auto ptr = g.ix.mm->alloc(len);
|
||||
if (ptr == nullptr)
|
||||
{
|
||||
#if LOGGING_IS_ENABLED == 1
|
||||
msg("mm alloc has failed, returned null!");
|
||||
#endif
|
||||
__fastfail(0x3D4A);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void global_mm_free(void *p)
|
||||
{
|
||||
if (!g.ix.mm)
|
||||
{
|
||||
#if LOGGING_IS_ENABLED == 1
|
||||
msg("mm iface is null!");
|
||||
#endif
|
||||
__fastfail(0x3D2A);
|
||||
}
|
||||
|
||||
g.ix.mm->free(p);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
void stream_decode(uint8_t *buffer, size_t length, uint64_t key)
|
||||
{
|
||||
rotate::decode(buffer, length);
|
||||
|
||||
for (size_t i = 0; i < length; i++)
|
||||
{
|
||||
buffer[i] ^= (key >> (8 * (i % 8))) & 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
void stream_encode(uint8_t *buffer, size_t length, uint64_t key)
|
||||
{
|
||||
for (size_t i = 0; i < length; i++)
|
||||
{
|
||||
buffer[i] ^= (key >> (8 * (i % 8))) & 0xFF;
|
||||
}
|
||||
|
||||
rotate::encode(buffer, length);
|
||||
}
|
||||
|
||||
String_record *str_from_hash(uint32_t hash)
|
||||
{
|
||||
auto table = gctx->strtbl;
|
||||
|
||||
for (uint32_t i = 0; i < table->table_records_count; i++)
|
||||
{
|
||||
auto record = &table->table[i];
|
||||
if (record->hash == hash)
|
||||
{
|
||||
return record;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Crypted_string::Crypted_string(uint32_t hash)
|
||||
{
|
||||
auto in_table_ptr = str_from_hash(hash);
|
||||
if (hash)
|
||||
{
|
||||
m_length = in_table_ptr->length;
|
||||
memcpy(m_contents, in_table_ptr->content, m_length);
|
||||
}
|
||||
}
|
||||
|
||||
const char *Crypted_string::decrypt()
|
||||
{
|
||||
stream_decode((u8 *)this->m_contents, this->m_length, gctx->strtbl_decryption_key );
|
||||
return this->m_contents;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
namespace tools
|
||||
{
|
||||
void replace_slash_with_underscore(const char *path, char *output)
|
||||
{
|
||||
if (path == NULL || output == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while (*path)
|
||||
{
|
||||
if (*path == '/')
|
||||
{
|
||||
*output = '_';
|
||||
}
|
||||
else
|
||||
{
|
||||
*output = *path;
|
||||
}
|
||||
path++;
|
||||
output++;
|
||||
}
|
||||
*output = '\0'; // Add null-terminator to the end of the modified path
|
||||
}
|
||||
|
||||
char integer2char(int digit)
|
||||
{
|
||||
// Ensure the input is a single-digit integer
|
||||
if (digit >= 0 && digit <= 9)
|
||||
{
|
||||
return digit + '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Handle error or return a special character for out-of-range input
|
||||
return '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
namespace vft
|
||||
{
|
||||
void *cave_setup(size_t table_count, uptr cave_begin, u32 cave_cap, u32 &disp)
|
||||
{
|
||||
auto vftable_required_count = table_count + 2; /* plus acts as some sort of padding.*/
|
||||
auto vftable_required_length = (vftable_required_count * sizeof(uptr));
|
||||
#if LOGGING_IS_ENABLED == 1
|
||||
LMsg(256, "vft_cave_setup: required_count:%lld, required_length:0x%04X, disp: 0x%04X",
|
||||
vftable_required_count, vftable_required_length, disp);
|
||||
#endif
|
||||
|
||||
if (vftable_required_count < 1 || vftable_required_length < sizeof(uptr))
|
||||
{
|
||||
#if LOGGING_IS_ENABLED == 1
|
||||
LMsg(256, "vft_cave_setup: illegal vft characteristics!");
|
||||
#endif
|
||||
|
||||
__fastfail(_encoded_const(0xDFDB100));
|
||||
}
|
||||
|
||||
auto space = reinterpret_cast<void *>(cave_begin + disp);
|
||||
|
||||
uptr space_base = BASE_OF(space);
|
||||
uptr space_end = (space_base + vftable_required_length);
|
||||
uptr cave_end = (cave_begin + cave_cap);
|
||||
if (space_end >= cave_end)
|
||||
{
|
||||
#if LOGGING_IS_ENABLED == 1
|
||||
LMsg(256, "vft_cave_setup: no more space left in cave!");
|
||||
#endif
|
||||
|
||||
__fastfail(_encoded_const(0xDFDB102));
|
||||
}
|
||||
|
||||
memset(space, 0, vftable_required_length);
|
||||
disp += vftable_required_length;
|
||||
|
||||
#if LOGGING_IS_ENABLED == 1
|
||||
LMsg(256, "vft_cave_setup: returning cave space at %p (space left after this: %llx)",
|
||||
space, cave_end - (BASE_OF(space) + vftable_required_length));
|
||||
#endif
|
||||
|
||||
return space;
|
||||
}
|
||||
|
||||
size_t calc_len(void *ptbl)
|
||||
{
|
||||
#if LOGGING_IS_ENABLED == 1
|
||||
LMsg(128, "calc_vft_len -> calculating for vftable at %p", ptbl);
|
||||
#endif
|
||||
|
||||
auto tbl = (uptr *)ptbl;
|
||||
size_t result = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
auto handler = tbl[result];
|
||||
|
||||
if (!handler)
|
||||
{
|
||||
#if LOGGING_IS_ENABLED == 1
|
||||
LMsg(128, "calc_vft_len -> abort: handler is zero.");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
/* is the handler within game image at all? */
|
||||
if (handler < gctx->game_base || handler > (gctx->game_base + gctx->game_len))
|
||||
{
|
||||
#if LOGGING_IS_ENABLED == 1
|
||||
LMsg(256, "calc_vft_len -> abort: handler %p is not in game image.", handler);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
/* is the handler within .text section? */
|
||||
if (handler < gctx->game_cs_base || handler > (gctx->game_cs_base + gctx->game_cs_len))
|
||||
{
|
||||
#if LOGGING_IS_ENABLED == 1
|
||||
LMsg(256, "calc_vft_len -> abort: handler %p is not in game code.", handler);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
result++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
.intel_syntax
|
||||
|
||||
.text
|
||||
.global read_xmm7
|
||||
read_xmm7:
|
||||
movaps xmm0, xmm7
|
||||
movss dword ptr [rcx], xmm0
|
||||
ret
|
||||
|
||||
.global write_xmm7
|
||||
write_xmm7:
|
||||
shufps xmm0, xmm0, 0
|
||||
movaps xmm7, xmm0
|
||||
ret
|
||||
|
||||
.global read_xmm6
|
||||
read_xmm6:
|
||||
movaps xmm0, xmm6
|
||||
movss dword ptr [rcx], xmm0
|
||||
ret
|
||||
|
||||
.global write_xmm6
|
||||
write_xmm6:
|
||||
shufps xmm0, xmm0, 0
|
||||
movaps xmm6, xmm0
|
||||
ret
|
||||
|
||||
.global read_xmm8
|
||||
read_xmm8:
|
||||
movaps xmm0, xmm8
|
||||
movss dword ptr [rcx], xmm0
|
||||
ret
|
||||
|
||||
.global write_xmm8
|
||||
write_xmm8:
|
||||
shufps xmm0, xmm0, 0
|
||||
movaps xmm8, xmm0
|
||||
ret
|
||||
|
||||
.global read_xmm15
|
||||
read_xmm15:
|
||||
pextrq rax, xmm15, 1
|
||||
ret
|
||||
|
||||
.global write_xmm15
|
||||
write_xmm15:
|
||||
pinsrq xmm15, rcx, 1
|
||||
ret
|
||||
Reference in New Issue
Block a user