From c002344993d07c52d24bcc4acb4a90a7fd834589 Mon Sep 17 00:00:00 2001 From: Jenny White Date: Sat, 28 Apr 2018 18:12:58 +0300 Subject: [PATCH] Several fixes for various compile options --- CMakeLists.txt | 6 ++ include/CMakeLists.txt | 1 - include/hacks/CMakeLists.txt | 12 ++- include/hooks/CMakeLists.txt | 8 +- include/hooks/hookedmethods.hpp | 2 + include/visual/CMakeLists.txt | 3 +- include/visual/drawex.hpp | 6 +- include/{ => visual}/fidgetspinner.hpp | 0 include/visual/glez.h | 108 ------------------------- include/visual/xoverlay.h | 48 ----------- src/CMakeLists.txt | 1 - src/hack.cpp | 6 +- src/hacks/CMakeLists.txt | 12 ++- src/hooks/CMakeLists.txt | 12 ++- src/hooks/PaintTraverse.cpp | 5 ++ src/visual/CMakeLists.txt | 3 +- src/visual/drawex.cpp | 12 +-- src/{ => visual}/fidgetspinner.cpp | 2 +- 18 files changed, 61 insertions(+), 186 deletions(-) rename include/{ => visual}/fidgetspinner.hpp (100%) delete mode 100755 include/visual/glez.h delete mode 100755 include/visual/xoverlay.h rename src/{ => visual}/fidgetspinner.cpp (98%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2db3c6b7..69e8f11e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,10 @@ set(EnableTextmodeStdin 0 CACHE BOOL "Textmode Stdin -> Console bridge (EXPERIME set(EnableWarnings 1 CACHE BOOL "Enable compile warnings") set(EnableNullGraphics 0 CACHE BOOL "Enable experimental textmode hooks (CRASHES)") +if(NOT EnableVisuals) + set(EnableGUI 0) +endif() + find_package(Git REQUIRED) find_package(OpenSSL REQUIRED) @@ -49,10 +53,12 @@ endif() if(EnableVisuals) find_package(glez REQUIRED) + get_target_property(glez_INCLUDE_DIRS glez INTERFACE_INCLUDE_DIRECTORIES) find_package(SDL2 REQUIRED) find_package(GLEW REQUIRED) if(ExternalDrawing) find_package(xoverlay REQUIRED) + get_target_property(xoverlay_INCLUDE_DIRS xoverlay INTERFACE_INCLUDE_DIRECTORIES) target_include_directories(cathook PRIVATE "${xoverlay_INCLUDE_DIRS}") target_link_libraries(cathook xoverlay) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 1089e432..fb289fd6 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -14,7 +14,6 @@ target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/entitycache.hpp" "${CMAKE_CURRENT_LIST_DIR}/entityhitboxcache.hpp" "${CMAKE_CURRENT_LIST_DIR}/enums.hpp" - "${CMAKE_CURRENT_LIST_DIR}/fidgetspinner.hpp" "${CMAKE_CURRENT_LIST_DIR}/gameinfo.hpp" "${CMAKE_CURRENT_LIST_DIR}/globals.h" "${CMAKE_CURRENT_LIST_DIR}/hack.hpp" diff --git a/include/hacks/CMakeLists.txt b/include/hacks/CMakeLists.txt index d00a113d..e4abc6b0 100644 --- a/include/hacks/CMakeLists.txt +++ b/include/hacks/CMakeLists.txt @@ -16,7 +16,6 @@ target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/AutoTaunt.hpp" "${CMAKE_CURRENT_LIST_DIR}/Bunnyhop.hpp" "${CMAKE_CURRENT_LIST_DIR}/CatBot.hpp" - "${CMAKE_CURRENT_LIST_DIR}/ESP.hpp" "${CMAKE_CURRENT_LIST_DIR}/FollowBot.hpp" "${CMAKE_CURRENT_LIST_DIR}/hacklist.hpp" "${CMAKE_CURRENT_LIST_DIR}/HealArrows.hpp" @@ -25,14 +24,19 @@ target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/LagExploit.hpp" "${CMAKE_CURRENT_LIST_DIR}/Misc.hpp" "${CMAKE_CURRENT_LIST_DIR}/Noisemaker.hpp" - "${CMAKE_CURRENT_LIST_DIR}/Radar.hpp" - "${CMAKE_CURRENT_LIST_DIR}/SkinChanger.hpp" "${CMAKE_CURRENT_LIST_DIR}/Spam.hpp" - "${CMAKE_CURRENT_LIST_DIR}/SpyAlert.hpp" "${CMAKE_CURRENT_LIST_DIR}/Trigger.hpp" "${CMAKE_CURRENT_LIST_DIR}/UberSpam.hpp" "${CMAKE_CURRENT_LIST_DIR}/Walkbot.hpp") +if(EnableVisuals) +target_sources(cathook PRIVATE + "${CMAKE_CURRENT_LIST_DIR}/ESP.hpp" + "${CMAKE_CURRENT_LIST_DIR}/Radar.hpp" + "${CMAKE_CURRENT_LIST_DIR}/SkinChanger.hpp" + "${CMAKE_CURRENT_LIST_DIR}/SpyAlert.hpp") +endif() + target_include_directories(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}") add_subdirectory(ac) \ No newline at end of file diff --git a/include/hooks/CMakeLists.txt b/include/hooks/CMakeLists.txt index 1b023837..cb48678f 100644 --- a/include/hooks/CMakeLists.txt +++ b/include/hooks/CMakeLists.txt @@ -1,7 +1,11 @@ target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/CreateMove.hpp" "${CMAKE_CURRENT_LIST_DIR}/hookedmethods.hpp" - "${CMAKE_CURRENT_LIST_DIR}/others.hpp" - "${CMAKE_CURRENT_LIST_DIR}/PaintTraverse.hpp") + "${CMAKE_CURRENT_LIST_DIR}/others.hpp") + +if(EnableVisuals) + target_sources(cathook PRIVATE + "${CMAKE_CURRENT_LIST_DIR}/PaintTraverse.hpp") +endif() target_include_directories(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}") \ No newline at end of file diff --git a/include/hooks/hookedmethods.hpp b/include/hooks/hookedmethods.hpp index fcb003c3..15513884 100644 --- a/include/hooks/hookedmethods.hpp +++ b/include/hooks/hookedmethods.hpp @@ -49,6 +49,7 @@ CUserCmd *GetUserCmd_hook(IInput *, int); void DrawModelExecute_hook(IVModelRender *_this, const DrawModelState_t &state, const ModelRenderInfo_t &info, matrix3x4_t *matrix); +#if ENABLE_VISUALS void Paint_hook(IEngineVGui *_this, PaintMode_t mode); /* SDL HOOKS */ @@ -65,6 +66,7 @@ void SDL_GL_SwapWindow_hook(SDL_Window *window); void DoSDLHooking(); void DoSDLUnhooking(); +#endif #include "CreateMove.hpp" #include "PaintTraverse.hpp" diff --git a/include/visual/CMakeLists.txt b/include/visual/CMakeLists.txt index 36598235..ef6ce432 100644 --- a/include/visual/CMakeLists.txt +++ b/include/visual/CMakeLists.txt @@ -6,8 +6,7 @@ target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/drawmgr.hpp" "${CMAKE_CURRENT_LIST_DIR}/EffectChams.hpp" "${CMAKE_CURRENT_LIST_DIR}/EffectGlow.hpp" - "${CMAKE_CURRENT_LIST_DIR}/glez.h" - "${CMAKE_CURRENT_LIST_DIR}/xoverlay.h") + "${CMAKE_CURRENT_LIST_DIR}/fidgetspinner.hpp") if(EnableGUI) add_subdirectory(menu) diff --git a/include/visual/drawex.hpp b/include/visual/drawex.hpp index c2bb45a4..f23a70c9 100755 --- a/include/visual/drawex.hpp +++ b/include/visual/drawex.hpp @@ -10,8 +10,10 @@ #include extern "C" { -#include "visual/glez.h" -#include "visual/xoverlay.h" +#include +#if EXTERNAL_DRAWING +#include +#endif } #define draw_api drawex::api diff --git a/include/fidgetspinner.hpp b/include/visual/fidgetspinner.hpp similarity index 100% rename from include/fidgetspinner.hpp rename to include/visual/fidgetspinner.hpp diff --git a/include/visual/glez.h b/include/visual/glez.h deleted file mode 100755 index 01c160be..00000000 --- a/include/visual/glez.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * glez.h - * - * Created on: Dec 7, 2017 - * Author: nullifiedcat - */ - -#pragma once - -/* Types */ - -typedef struct glez_vec4_s -{ - union { - float data[4]; - struct - { - float r; - float g; - float b; - float a; - }; - struct - { - float x; - float y; - float z; - float w; - }; - }; -} glez_vec4_t, glez_rgba_t; - -typedef unsigned int glez_texture_t; -typedef unsigned int glez_font_t; - -/* State functions */ - -void glez_init(int width, int height); - -void glez_shutdown(); - -void glez_begin(); - -void glez_end(); - -void glez_resize(int width, int height); - -/* Helper functions */ - -static inline glez_rgba_t glez_rgba(unsigned char r, unsigned char g, - unsigned char b, unsigned char a) -{ - glez_rgba_t result; - result.r = (float) r / 255.0f; - result.g = (float) g / 255.0f; - result.b = (float) b / 255.0f; - result.a = (float) a / 255.0f; - return result; -} - -/* Font-related functions */ - -#define GLEZ_FONT_COUNT 64 -#define GLEZ_FONT_INVALID ((glez_font_t) 0xFFFFFFFF) - -glez_font_t glez_font_load(const char *path, float size); - -void glez_font_unload(glez_font_t handle); - -void glez_font_string_size(glez_font_t font, const char *string, float *out_x, - float *out_y); - -/* Texture-related functions */ - -#define GLEZ_TEXTURE_COUNT 64 -#define GLEZ_TEXTURE_INVALID ((glez_texture_t) 0xFFFFFFFF) - -glez_texture_t glez_texture_load_png_rgba(const char *path); - -void glez_texture_unload(glez_texture_t handle); - -void glez_texture_size(glez_texture_t handle, int *width, int *height); - -/* Drawing functions */ - -void glez_line(float x, float y, float dx, float dy, glez_rgba_t color, - float thickness); - -void glez_rect(float x, float y, float w, float h, glez_rgba_t color); - -void glez_rect_outline(float x, float y, float w, float h, glez_rgba_t color, - float thickness); - -void glez_rect_textured(float x, float y, float w, float h, glez_rgba_t color, - glez_texture_t texture, float tx, float ty, float tw, - float th, float angle); - -void glez_string(float x, float y, const char *string, glez_font_t font, - glez_rgba_t color, float *out_x, float *out_y); - -void glez_string_with_outline(float x, float y, const char *string, - glez_font_t font, glez_rgba_t color, - glez_rgba_t outline_color, float outline_width, - int adjust_outline_alpha, float *out_x, - float *out_y); - -void glez_circle(float x, float y, float radius, glez_rgba_t color, - float thickness, int steps); diff --git a/include/visual/xoverlay.h b/include/visual/xoverlay.h deleted file mode 100755 index 0c1d2cc0..00000000 --- a/include/visual/xoverlay.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * overlay.hpp - * - * Created on: Nov 8, 2017 - * Author: nullifiedcat - */ - -#pragma once - -#include -#include - -struct xoverlay_library -{ - Display *display; - Window window; - Colormap colormap; - GC gc; - XGCValues gcvalues; - XFontStruct font; - int screen; - - int width; - int height; - - struct - { - int x; - int y; - } mouse; - - char init; - char drawing; - char mapped; -}; - -extern struct xoverlay_library xoverlay_library; - -int xoverlay_init(); -void xoverlay_destroy(); - -void xoverlay_show(); - -void xoverlay_hide(); - -void xoverlay_draw_begin(); - -void xoverlay_draw_end(); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b7667b47..4b38b43f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,7 +9,6 @@ target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/entitycache.cpp" "${CMAKE_CURRENT_LIST_DIR}/entityhitboxcache.cpp" "${CMAKE_CURRENT_LIST_DIR}/entry.cpp" - "${CMAKE_CURRENT_LIST_DIR}/fidgetspinner.cpp" "${CMAKE_CURRENT_LIST_DIR}/globals.cpp" "${CMAKE_CURRENT_LIST_DIR}/hack.cpp" "${CMAKE_CURRENT_LIST_DIR}/headshake.cpp" diff --git a/src/hack.cpp b/src/hack.cpp index 3d6b2787..dacdca80 100644 --- a/src/hack.cpp +++ b/src/hack.cpp @@ -367,13 +367,13 @@ free(logname);*/ hooks::modelrender.HookMethod((void *) DrawModelExecute_hook, offsets::DrawModelExecute()); hooks::modelrender.Apply(); -#endif -#endif hooks::enginevgui.Set(g_IEngineVGui); hooks::enginevgui.HookMethod( (void *) Paint_hook, offsets::PlatformOffset(14, offsets::undefined, offsets::undefined)); hooks::enginevgui.Apply(); +#endif +#endif hooks::steamfriends.Set(g_ISteamFriends); hooks::steamfriends.HookMethod((void *) GetFriendPersonaName_hook, offsets::GetFriendPersonaName()); @@ -469,7 +469,9 @@ void hack::Shutdown() return; hack::shutdown = true; playerlist::Save(); +#if ENABLE_VISUALS DoSDLUnhooking(); +#endif logging::Info("Unregistering convars.."); ConVar_Unregister(); logging::Info("Shutting down killsay..."); diff --git a/src/hacks/CMakeLists.txt b/src/hacks/CMakeLists.txt index ab30a10d..f8477efe 100644 --- a/src/hacks/CMakeLists.txt +++ b/src/hacks/CMakeLists.txt @@ -17,7 +17,6 @@ target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/AutoTaunt.cpp" "${CMAKE_CURRENT_LIST_DIR}/Bunnyhop.cpp" "${CMAKE_CURRENT_LIST_DIR}/CatBot.cpp" - "${CMAKE_CURRENT_LIST_DIR}/ESP.cpp" "${CMAKE_CURRENT_LIST_DIR}/FollowBot.cpp" "${CMAKE_CURRENT_LIST_DIR}/HealArrows.cpp" "${CMAKE_CURRENT_LIST_DIR}/KillSay.cpp" @@ -25,12 +24,17 @@ target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/LagExploit.cpp" "${CMAKE_CURRENT_LIST_DIR}/Misc.cpp" "${CMAKE_CURRENT_LIST_DIR}/Noisemaker.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Radar.cpp" - "${CMAKE_CURRENT_LIST_DIR}/SkinChanger.cpp" "${CMAKE_CURRENT_LIST_DIR}/Spam.cpp" - "${CMAKE_CURRENT_LIST_DIR}/SpyAlert.cpp" "${CMAKE_CURRENT_LIST_DIR}/Trigger.cpp" "${CMAKE_CURRENT_LIST_DIR}/UberSpam.cpp" "${CMAKE_CURRENT_LIST_DIR}/Walkbot.cpp") +if(EnableVisuals) + target_sources(cathook PRIVATE + "${CMAKE_CURRENT_LIST_DIR}/ESP.cpp" + "${CMAKE_CURRENT_LIST_DIR}/Radar.cpp" + "${CMAKE_CURRENT_LIST_DIR}/SkinChanger.cpp" + "${CMAKE_CURRENT_LIST_DIR}/SpyAlert.cpp") +endif() + add_subdirectory(ac) \ No newline at end of file diff --git a/src/hooks/CMakeLists.txt b/src/hooks/CMakeLists.txt index 13adec8b..7b815ce0 100644 --- a/src/hooks/CMakeLists.txt +++ b/src/hooks/CMakeLists.txt @@ -1,7 +1,11 @@ target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/CreateMove.cpp" "${CMAKE_CURRENT_LIST_DIR}/nographics.cpp" - "${CMAKE_CURRENT_LIST_DIR}/others.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Paint.cpp" - "${CMAKE_CURRENT_LIST_DIR}/PaintTraverse.cpp" - "${CMAKE_CURRENT_LIST_DIR}/sdl.cpp") \ No newline at end of file + "${CMAKE_CURRENT_LIST_DIR}/others.cpp") + +if(EnableVisuals) + target_sources(cathook PRIVATE + "${CMAKE_CURRENT_LIST_DIR}/Paint.cpp" + "${CMAKE_CURRENT_LIST_DIR}/PaintTraverse.cpp" + "${CMAKE_CURRENT_LIST_DIR}/sdl.cpp") +endif() \ No newline at end of file diff --git a/src/hooks/PaintTraverse.cpp b/src/hooks/PaintTraverse.cpp index b9a9a22a..dbb5e442 100644 --- a/src/hooks/PaintTraverse.cpp +++ b/src/hooks/PaintTraverse.cpp @@ -6,7 +6,10 @@ */ #include "common.hpp" + +#if ENABLE_GUI #include "GUI.h" +#endif CatVar clean_screenshots(CV_SWITCH, "clean_screenshots", "1", "Clean screenshots", @@ -159,7 +162,9 @@ void PaintTraverse_hook(void *_this, unsigned int vp, bool fr, bool ar) if (clean_screenshots && g_IEngine->IsTakingScreenshot()) return; +#if ENABLE_GUI g_pGUI->Update(); +#endif PROF_SECTION(PT_active); draw::UpdateWTS(); } diff --git a/src/visual/CMakeLists.txt b/src/visual/CMakeLists.txt index 1268674b..580c2e88 100644 --- a/src/visual/CMakeLists.txt +++ b/src/visual/CMakeLists.txt @@ -5,7 +5,8 @@ target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/drawing.cpp" "${CMAKE_CURRENT_LIST_DIR}/drawmgr.cpp" "${CMAKE_CURRENT_LIST_DIR}/EffectChams.cpp" - "${CMAKE_CURRENT_LIST_DIR}/EffectGlow.cpp") + "${CMAKE_CURRENT_LIST_DIR}/EffectGlow.cpp" + "${CMAKE_CURRENT_LIST_DIR}/fidgetspinner.cpp") if(EnableGUI) add_subdirectory(menu) diff --git a/src/visual/drawex.cpp b/src/visual/drawex.cpp index 3212309b..7b5ccfde 100755 --- a/src/visual/drawex.cpp +++ b/src/visual/drawex.cpp @@ -13,11 +13,11 @@ #include #include +#if EXTERNAL_DRAWING extern "C" { -#include "visual/xoverlay.h" +#include } - -#define DRAW_XOVERLAY 0 +#endif SDL_GLContext context = nullptr; @@ -62,7 +62,7 @@ bool ready() void initialize() { -#if DRAW_XOVERLAY +#if EXTERNAL_DRAWING int status = xoverlay_init(); xoverlay_draw_begin(); glez_init(xoverlay_library.width, xoverlay_library.height); @@ -156,7 +156,7 @@ void get_string_size(const char *string, font_handle_t &font, float *x, void draw_begin() { PROF_SECTION(DRAWEX_draw_begin); -#if DRAW_XOVERLAY +#if EXTERNAL_DRAWING xoverlay_draw_begin(); #else SDL_GL_MakeCurrent(sdl_current_window, context); @@ -169,7 +169,7 @@ void draw_end() PROF_SECTION(DRAWEX_draw_end); glez_end(); SDL_GL_MakeCurrent(sdl_current_window, nullptr); -#if DRAW_XOVERLAY +#if EXTERNAL_DRAWING xoverlay_draw_end(); #endif } diff --git a/src/fidgetspinner.cpp b/src/visual/fidgetspinner.cpp similarity index 98% rename from src/fidgetspinner.cpp rename to src/visual/fidgetspinner.cpp index a91ef863..4d013b3f 100644 --- a/src/fidgetspinner.cpp +++ b/src/visual/fidgetspinner.cpp @@ -5,7 +5,7 @@ * Author: nullifiedcat */ -#include "fidgetspinner.hpp" +#include "visual/fidgetspinner.hpp" #include "common.hpp" #include