From 9627989304c56e7cc646bb85299242e018352c60 Mon Sep 17 00:00:00 2001 From: 8dcc <8dcc.git@gmail.com> Date: Mon, 24 Jul 2023 17:03:22 +0200 Subject: [PATCH] Add chams code No custom colors yet --- src/features/chams.c | 48 +++++++++++++++++++++++++++++++++++++++++ src/features/features.h | 3 +++ src/hooks.c | 5 ++--- 3 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 src/features/chams.c diff --git a/src/features/chams.c b/src/features/chams.c new file mode 100644 index 0000000..dea6afd --- /dev/null +++ b/src/features/chams.c @@ -0,0 +1,48 @@ + +#include "features.h" +#include "../include/globals.h" +#include "../include/cvars.h" +#include "../include/util.h" + +#include + +enum visible_flags { + NONE = 0, + VISIBLE = 1, + NOT_VISIBLE = 2, + /* TODO: HANDS */ +}; + +static visible_flags visible_mode; + +bool chams(void* this_ptr) { + if (!CVAR_ON(chams)) + return false; + + cl_entity_t* ent = i_enginestudio->GetCurrentEntity(); + + if (ent->index == localplayer->index) { + /* TODO: Hand chams (set var, check in gl hook, return true) */ + return false; + } else if (!valid_client(ent) || !is_alive(ent)) { + return false; + } + + /* If we got here it means we are rendering a valid player */ + glDisable(GL_TEXTURE_2D); + + glDisable(GL_DEPTH_TEST); /* Ignore depth (walls between target) */ + visible_mode = NOT_VISIBLE; + i_studiomodelrenderer->StudioRenderFinal(this_ptr); + + glEnable(GL_DEPTH_TEST); /* Don't ignore depth, different color chams */ + visible_mode = VISIBLE; + i_studiomodelrenderer->StudioRenderFinal(this_ptr); + + /* Reset for future calls to glColor4f (from here or somewhere else) */ + visible_mode = NONE; + glEnable(GL_TEXTURE_2D); + + /* StudioRenderModel hook doesn't need to call original */ + return true; +} diff --git a/src/features/features.h b/src/features/features.h index e4ce1fb..ff11684 100644 --- a/src/features/features.h +++ b/src/features/features.h @@ -11,4 +11,7 @@ void bhop(usercmd_t* cmd); void esp(void); void correct_movement(usercmd_t* cmd, vec3_t old_angles); +/* src/features/chams.c */ +bool chams(void* this_ptr); + #endif /* FEATURES_H_ */ diff --git a/src/hooks.c b/src/hooks.c index 3d0fb8c..03cf4a4 100644 --- a/src/hooks.c +++ b/src/hooks.c @@ -55,7 +55,6 @@ int h_HUD_Redraw(float time, int intermission) { } void h_StudioRenderModel(void* this_ptr) { - ORIGINAL(StudioRenderModel, this_ptr); - - printf("Hi from StudioRenderModel!\n"); + if (!chams(this_ptr)) + ORIGINAL(StudioRenderModel, this_ptr); }