WIP temporary Werror to get rid of undefined macros

This commit is contained in:
Jenny White 2018-04-28 11:58:38 +03:00
parent eae51762ff
commit 851a635ab1
19 changed files with 37 additions and 43 deletions

View File

@ -14,6 +14,10 @@ set(EnableGUI 1 CACHE BOOL "Enable GUI")
set(EnableIPC 1 CACHE BOOL "Enable IPC") set(EnableIPC 1 CACHE BOOL "Enable IPC")
set(DataPath "/opt/cathook/data" CACHE STRING "Data location") set(DataPath "/opt/cathook/data" CACHE STRING "Data location")
set(VACBypass 0 CACHE BOOL "Textmode VAC bypass") set(VACBypass 0 CACHE BOOL "Textmode VAC bypass")
set(Textmode 0 CACHE BOOL "Various textmode-only features for bots")
set(EnableTextmodeStdin 0 CACHE BOOL "Textmode Stdin -> Console bridge (EXPERIMENTAL)")
set(EnableWarnings 1 CACHE BOOL "Enable compile warnings")
set(EnableNullGraphics 0 CACHE BOOL "Enable experimental textmode hooks (CRASHES)")
find_package(Git REQUIRED) find_package(Git REQUIRED)
find_package(SDL2 REQUIRED) find_package(SDL2 REQUIRED)
@ -57,7 +61,7 @@ target_compile_definitions(cathook PRIVATE
GNUC=1 GNUC=1
NO_MALLOC_OVERRIDE=1) NO_MALLOC_OVERRIDE=1)
target_include_directories(cathook PRIVATE target_include_directories(cathook SYSTEM PRIVATE
"source-sdk-2013-headers/mp/src/mathlib" "source-sdk-2013-headers/mp/src/mathlib"
"source-sdk-2013-headers/mp/src/public" "source-sdk-2013-headers/mp/src/public"
"source-sdk-2013-headers/mp/src/common" "source-sdk-2013-headers/mp/src/common"
@ -74,6 +78,10 @@ target_include_directories(cathook PRIVATE
"${xoverlay_INCLUDE_DIRS}" "${xoverlay_INCLUDE_DIRS}"
"${SimpleIPC_INCLUDE_DIRS}") "${SimpleIPC_INCLUDE_DIRS}")
if(EnableWarnings)
target_compile_options(cathook PRIVATE -Wundef -Werror)
endif()
add_subdirectory(include) add_subdirectory(include)
add_subdirectory(src) add_subdirectory(src)

View File

@ -11,3 +11,6 @@
#define ENABLE_IPC @EnableIPC@ #define ENABLE_IPC @EnableIPC@
#define DATA_PATH "@DataPath@" #define DATA_PATH "@DataPath@"
#define ENABLE_VAC_BYPASS @VACBypass@ #define ENABLE_VAC_BYPASS @VACBypass@
#define ENABLE_TEXTMODE_STDIN @EnableTextmodeStdin@
#define ENABLE_NULL_GRAPHICS @EnableNullGraphics@
#define TEXTMODE @Textmode@

View File

@ -11,9 +11,9 @@ public:
uintptr_t dwFindPattern(uintptr_t dwAddress, uintptr_t dwLength, uintptr_t dwFindPattern(uintptr_t dwAddress, uintptr_t dwLength,
const char *szPattern); const char *szPattern);
void *GetModuleHandleSafe(const char *pszModuleName); void *GetModuleHandleSafe(const char *pszModuleName);
uintptr_t GetClientSignature(char *chPattern); uintptr_t GetClientSignature(const char *chPattern);
uintptr_t GetEngineSignature(char *chPattern); uintptr_t GetEngineSignature(const char *chPattern);
uintptr_t GetVstdSignature(char *chPattern); uintptr_t GetVstdSignature(const char *chPattern);
}; };
extern CSignature gSignatures; extern CSignature gSignatures;

View File

@ -7,6 +7,8 @@
#pragma once #pragma once
#include "config.h"
class INetMessage; class INetMessage;
class CViewSetup; class CViewSetup;
class bf_read; class bf_read;
@ -14,7 +16,7 @@ class SDL_Window;
class CatVar; class CatVar;
extern CatVar disconnect_reason; extern CatVar disconnect_reason;
#if ENABLE_VISUALS == 1 #if ENABLE_VISUALS
extern int spectator_target; extern int spectator_target;
#endif #endif
@ -29,7 +31,7 @@ void LevelInit_hook(void *, const char *);
void LevelShutdown_hook(void *); void LevelShutdown_hook(void *);
int RandomInt_hook(void *, int, int); int RandomInt_hook(void *, int, int);
#if ENABLE_NULL_GRAPHICS == 1 #if ENABLE_NULL_GRAPHICS
typedef ITexture *(*FindTexture_t)(void *, const char *, const char *, bool, typedef ITexture *(*FindTexture_t)(void *, const char *, const char *, bool,
int); int);
typedef IMaterial *(*FindMaterialEx_t)(void *, const char *, const char *, int, typedef IMaterial *(*FindMaterialEx_t)(void *, const char *, const char *, int,

View File

@ -1,4 +1,3 @@
#if TEXTMODE_VAC != 1
namespace colorsint namespace colorsint
{ {
constexpr int Create(int r, int g, int b, int a) constexpr int Create(int r, int g, int b, int a)
@ -50,8 +49,7 @@ void FString(unsigned long font, int x, int y, int color, int shadow,
void DrawRect(int x, int y, int w, int h, int color); void DrawRect(int x, int y, int w, int h, int color);
void DrawLine(int x, int y, int dx, int dy, int color); void DrawLine(int x, int y, int dx, int dy, int color);
void OutlineRect(int x, int y, int w, int h, int color); void OutlineRect(int x, int y, int w, int h, int color);
void GetStringLength(unsigned long font, char *string, int &length, void GetStringLength(unsigned long font, const char *string, int &length,
int &height); int &height);
std::pair<int, int> GetStringLength(unsigned long font, std::string string); std::pair<int, int> GetStringLength(unsigned long font, std::string string);
} }
#endif

View File

@ -9,6 +9,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "config.h"
struct link_map; struct link_map;
typedef void *(*fn_CreateInterface_t)(const char *, int *); typedef void *(*fn_CreateInterface_t)(const char *, int *);
@ -43,7 +44,7 @@ SharedObject &vstdlib();
SharedObject &tier0(); SharedObject &tier0();
SharedObject &inputsystem(); SharedObject &inputsystem();
SharedObject &materialsystem(); SharedObject &materialsystem();
#if ENABLE_VISUALS == 1 #if ENABLE_VISUALS
SharedObject &vguimatsurface(); SharedObject &vguimatsurface();
SharedObject &vgui2(); SharedObject &vgui2();
SharedObject &studiorender(); SharedObject &studiorender();

View File

@ -1,4 +1,4 @@
#pragma once #pragma once
#define GIT_COMMIT_HASH "@GIT_COMMIT_HASH@" #define GIT_COMMIT_HASH @GIT_COMMIT_HASH@
#define GIT_COMMIT_DATE "@GIT_COMMIT_DATE@" #define GIT_COMMIT_DATE @GIT_COMMIT_DATE@

View File

@ -67,10 +67,8 @@ uintptr_t CSignature::dwFindPattern(uintptr_t dwAddress, uintptr_t dwLength,
firstMatch = pCur; firstMatch = pCur;
if (!pat[2]) if (!pat[2])
return firstMatch; return firstMatch;
if (*(uintptr_t *) pat == '\?\?' || *(uint8_t *) pat != '\?') if (*pat == '\?')
pat += 3; pat += 3;
else
pat += 2;
} }
else else
{ {
@ -94,7 +92,7 @@ void *CSignature::GetModuleHandleSafe(const char *pszModuleName)
return moduleHandle; return moduleHandle;
} }
//=================================================================================== //===================================================================================
uintptr_t CSignature::GetClientSignature(char *chPattern) uintptr_t CSignature::GetClientSignature(const char *chPattern)
{ {
// we need to do this becuase (i assume that) under the hood, dlopen only // we need to do this becuase (i assume that) under the hood, dlopen only
// loads up the sections that it needs into memory, meaning that we cannot // loads up the sections that it needs into memory, meaning that we cannot
@ -121,7 +119,7 @@ uintptr_t CSignature::GetClientSignature(char *chPattern)
(uintptr_t)(module) + moduleMap->l_addr; (uintptr_t)(module) + moduleMap->l_addr;
} }
//=================================================================================== //===================================================================================
uintptr_t CSignature::GetEngineSignature(char *chPattern) uintptr_t CSignature::GetEngineSignature(const char *chPattern)
{ {
// we need to do this becuase (i assume that) under the hood, dlopen only // we need to do this becuase (i assume that) under the hood, dlopen only
// loads up the sections that it needs into memory, meaning that we cannot // loads up the sections that it needs into memory, meaning that we cannot
@ -148,7 +146,7 @@ uintptr_t CSignature::GetEngineSignature(char *chPattern)
(uintptr_t)(module) + moduleMap->l_addr; (uintptr_t)(module) + moduleMap->l_addr;
} }
//=================================================================================== //===================================================================================
uintptr_t CSignature::GetVstdSignature(char *chPattern) uintptr_t CSignature::GetVstdSignature(const char *chPattern)
{ {
// we need to do this becuase (i assume that) under the hood, dlopen only // we need to do this becuase (i assume that) under the hood, dlopen only
// loads up the sections that it needs into memory, meaning that we cannot // loads up the sections that it needs into memory, meaning that we cannot

View File

@ -243,7 +243,7 @@ void WorldTick()
void DrawTick() void DrawTick()
{ {
#if TEXTMODE_VAC != 1 #if ENABLE_VISUALS
if (!followbot || !draw_crumb) if (!followbot || !draw_crumb)
return; return;
if (breadcrumbs.size() < 2) if (breadcrumbs.size() < 2)

View File

@ -398,7 +398,7 @@ void def_attribute_modifier::Set(int id, float value)
logging::Info("Woah there, that's too many! Remove some."); logging::Info("Woah there, that's too many! Remove some.");
return; return;
} }
modifiers.push_back(attribute_s{ id, value }); modifiers.push_back(attribute_s{ (uint16_t)id, value });
logging::Info("Added new attribute: %i %.2f (%i)", id, value, logging::Info("Added new attribute: %i %.2f (%i)", id, value,
modifiers.size()); modifiers.size());
} }

View File

@ -65,7 +65,7 @@ void Paint_hook(IEngineVGui *_this, PaintMode_t mode)
hack::command_stack().pop(); hack::command_stack().pop();
} }
} }
#if TEXTMODE_STDIN == 1 #if ENABLE_TEXTMODE_STDIN == 1
static auto last_stdin = std::chrono::system_clock::from_time_t(0); static auto last_stdin = std::chrono::system_clock::from_time_t(0);
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>( auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now() - last_stdin) std::chrono::system_clock::now() - last_stdin)

View File

@ -10,7 +10,6 @@
#include "common.hpp" #include "common.hpp"
#include "sdk.hpp" #include "sdk.hpp"
#if TEXTMODE_VAC != 1
class IMemAlloc; class IMemAlloc;
IMemAlloc *g_pMemAlloc = 0; IMemAlloc *g_pMemAlloc = 0;
@ -256,4 +255,3 @@ void CBaseContainer::Update()
} }
CBaseWidget::Update(); CBaseWidget::Update();
} }
#endif

View File

@ -9,7 +9,6 @@
#include "common.hpp" #include "common.hpp"
#include "GUI.h" #include "GUI.h"
#if TEXTMODE_VAC != 1
void CBaseWidget::DrawBounds(int x, int y) void CBaseWidget::DrawBounds(int x, int y)
{ {
if (m_KeyValues->IsEmpty("bounds_color")) if (m_KeyValues->IsEmpty("bounds_color"))
@ -68,4 +67,3 @@ std::pair<int, int> CBaseWidget::AbsolutePosition()
} }
return result; return result;
} }
#endif

View File

@ -9,7 +9,6 @@
#include "common.hpp" #include "common.hpp"
#include "menu/GUI.h" #include "menu/GUI.h"
#if TEXTMODE_VAC != 1
void CBaseWindow::MoveChildren() void CBaseWindow::MoveChildren()
{ {
@ -63,4 +62,3 @@ void CBaseWindow::Draw(int x, int y)
NCGUIColor()); NCGUIColor());
CBaseContainer::Draw(x, y); CBaseContainer::Draw(x, y);
} }
#endif

View File

@ -11,7 +11,6 @@
#include "sdk.hpp" #include "sdk.hpp"
#include "GUI.h" #include "GUI.h"
#if TEXTMODE_VAC != 1
std::string WordWrap(std::string &in, int max, unsigned long font) std::string WordWrap(std::string &in, int max, unsigned long font)
{ {
std::stringstream result, line, wordstream, next; std::stringstream result, line, wordstream, next;
@ -134,4 +133,3 @@ void CTextLabel::Draw(int x, int y)
else else
draw::String(fonts::MENU, x, y, colorsint::white, 1, GetText()); draw::String(fonts::MENU, x, y, colorsint::white, 1, GetText());
} }
#endif

View File

@ -11,7 +11,6 @@
#include "common.hpp" #include "common.hpp"
#include "sdk.hpp" #include "sdk.hpp"
#if TEXTMODE_VAC != 1
#undef RootWindow #undef RootWindow
void GUIVisibleCallback(IConVar *var, const char *pOldValue, float flOldValue) void GUIVisibleCallback(IConVar *var, const char *pOldValue, float flOldValue)
@ -239,4 +238,3 @@ bool CatGUI::ConsumesKey(ButtonCode_t key)
} }
CatGUI *g_pGUI = 0; CatGUI *g_pGUI = 0;
#endif

View File

@ -6,8 +6,7 @@
*/ */
#include "menu/IWidget.h" #include "menu/IWidget.h"
#if TEXTMODE_VAC != 1
IWidget::~IWidget() IWidget::~IWidget()
{ {
} }
#endif

View File

@ -1,6 +1,5 @@
#include "common.hpp" #include "common.hpp"
#if TEXTMODE_VAC != 1
namespace fonts namespace fonts
{ {
unsigned long MENU = 0; unsigned long MENU = 0;
@ -74,7 +73,7 @@ void draw::OutlineRect(int x, int y, int w, int h, int color)
g_ISurface->DrawOutlinedRect(x, y, x + w, y + h); g_ISurface->DrawOutlinedRect(x, y, x + w, y + h);
} }
void draw::GetStringLength(unsigned long font, char *string, int &length, void draw::GetStringLength(unsigned long font, const char *string, int &length,
int &height) int &height)
{ {
wchar_t buf[512]; wchar_t buf[512];
@ -186,4 +185,3 @@ std::pair<int, int> draw::GetStringLength(unsigned long font,
draw::GetStringLength(font, (char *) string.c_str(), l, h); draw::GetStringLength(font, (char *) string.c_str(), l, h);
return std::make_pair(l, h); return std::make_pair(l, h);
} }
#endif

View File

@ -7,9 +7,6 @@
#include "common.hpp" #include "common.hpp"
#include <fcntl.h>
#include <unistd.h>
bool *allowSecureServers{ nullptr }; bool *allowSecureServers{ nullptr };
// valve pls no ban // valve pls no ban
@ -42,19 +39,19 @@ CatCommand fixvac("fixvac", "Lemme in to secure servers",
[]() { *allowSecureServers = true; }); []() { *allowSecureServers = true; });
InitRoutine init([]() { InitRoutine init([]() {
#if TEXTMODE_STDIN == 1 #if ENABLE_TEXTMODE_STDIN
logging::Info("[TEXTMODE] Setting up input handling"); logging::Info("[TEXTMODE] Setting up input handling");
int flags = fcntl(0, F_GETFL, 0); int flags = fcntl(0, F_GETFL, 0);
flags |= O_NONBLOCK; flags |= O_NONBLOCK;
fcntl(0, F_SETFL, flags); fcntl(0, F_SETFL, flags);
logging::Info("[TEXTMODE] stdin is now non-blocking"); logging::Info("[TEXTMODE] stdin is now non-blocking");
#endif #endif
#if TEXTMODE_VAC == 1 #if ENABLE_VAC_BYPASS
EXPOSED_Epic_VACBypass_1337_DoNotSteal_xXx_$1_xXx_MLG(); EXPOSED_Epic_VACBypass_1337_DoNotSteal_xXx_$1_xXx_MLG();
#endif #endif
}); });
#if TEXTMODE_STDIN == 1 #if ENABLE_TEXTMODE_STDIN
void UpdateInput() void UpdateInput()
{ {
char buffer[256]; char buffer[256];