From 8670d3a5410714e25eff297164c00e4bfd10ee16 Mon Sep 17 00:00:00 2001 From: wootguy Date: Sat, 9 Nov 2024 07:07:42 -0800 Subject: [PATCH] expose rehlds hooks kind of a pain to use because the rehlds and hlsdk headers conflict. Include rehlds.h before anything else. Example hook usage: https://github.com/rehlds/revoice/blob/master/revoice/src/revoice_main.cpp#L252 --- CMakeLists.txt | 4 ++++ dlls/CMakeLists.txt | 4 ---- dlls/game.cpp | 2 +- dlls/rehlds.cpp | 34 ++-------------------------------- dlls/rehlds.h | 36 +++++++++++++++++++++++++++++++++++- 5 files changed, 42 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b407d56..27fad34e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,10 @@ include_directories(${CMAKE_SOURCE_DIR}/dlls/weapon) include_directories(${CMAKE_SOURCE_DIR}/dlls/net) include_directories(${CMAKE_SOURCE_DIR}/dlls/) +include_directories(${CMAKE_SOURCE_DIR}/rehlds) +include_directories(${CMAKE_SOURCE_DIR}/rehlds/rehlds/public) +include_directories(${CMAKE_SOURCE_DIR}/rehlds/rehlds/common) + project(sevenkewp) if (BUILD_SERVER) diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 2f8aa51e..b4c5958a 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -607,10 +607,6 @@ set(ALL_SRC # don't compile individual entity files set_source_files_properties(${ENT_SRC} PROPERTIES HEADER_FILE_ONLY TRUE) -include_directories(${CMAKE_SOURCE_DIR}/rehlds) -include_directories(${CMAKE_SOURCE_DIR}/rehlds/rehlds/public) -include_directories(${CMAKE_SOURCE_DIR}/rehlds/rehlds/common) - add_library(${SERVER_DLL_NAME} SHARED ${ALL_SRC}) target_include_directories(${SERVER_DLL_NAME} PRIVATE monster) diff --git a/dlls/game.cpp b/dlls/game.cpp index 42bafe2b..6ed3209c 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#include "rehlds.h" #include "extdll.h" #include "eiface.h" #include "util.h" @@ -20,7 +21,6 @@ #include "CBaseMonster.h" #include "skill.h" #include "PluginManager.h" -#include "rehlds.h" cvar_t displaysoundlist = {"displaysoundlist","0", 0, 0, 0}; diff --git a/dlls/rehlds.cpp b/dlls/rehlds.cpp index c140114f..d798057a 100644 --- a/dlls/rehlds.cpp +++ b/dlls/rehlds.cpp @@ -1,27 +1,5 @@ -typedef enum server_state_e -{ - ss_dead = 0, - ss_loading = 1, - ss_active = 2, -} server_state_t; - -typedef float vec_t; -typedef vec_t vec3_t[3]; - -typedef struct cache_user_s -{ - void* data; -} cache_user_t; - -using cvar_callback_t = void (*)(const char* pszNewValue); - -#define EXT_FUNC -#define SYNCTYPE_T - -#include "rehlds/public/interface.h" -#include "rehlds/public/rehlds/custom.h" -#include "rehlds/public/FileSystem.h" -#include "rehlds/public/rehlds/rehlds_api.h" +#include "rehlds.h" +#include "util.h" IRehldsApi* g_RehldsApi; const RehldsFuncs_t* g_RehldsFuncs; @@ -29,14 +7,6 @@ IRehldsServerData* g_RehldsData; IRehldsHookchains* g_RehldsHookchains; IRehldsServerStatic* g_RehldsSvs; -#include "rehlds.h" - -extern void DEBUG_MSG(ALERT_TYPE target, const char* format, ...); -#define ALERT(...) DEBUG_MSG(__VA_ARGS__) -extern char* UTIL_VarArgs(const char* format, ...); - -extern enginefuncs_t g_engfuncs; - bool RehldsApi_Init() { #ifdef WIN32 diff --git a/dlls/rehlds.h b/dlls/rehlds.h index 2493d764..e5026227 100644 --- a/dlls/rehlds.h +++ b/dlls/rehlds.h @@ -1,4 +1,38 @@ #pragma once +// handle conflicts between rehlds and hlsdk headers +#ifndef CACHE_USER +typedef enum server_state_e +{ + ss_dead = 0, + ss_loading = 1, + ss_active = 2, +} server_state_t; -bool RehldsApi_Init(); \ No newline at end of file +using cvar_callback_t = void (*)(const char* pszNewValue); + +typedef struct cache_user_s +{ + void* data; +} cache_user_t; + +#define CACHE_USER +#define SYNCTYPE_T +#define DID_VEC3_T_DEFINE +#define EXT_FUNC +#define EIFACE_H +#endif + +#include "extdll.h" +#include "rehlds/public/rehlds/custom.h" +#include "rehlds/public/interface.h" +#include "rehlds/public/FileSystem.h" +#include "rehlds/public/rehlds/rehlds_api.h" + +bool RehldsApi_Init(); + +EXPORT extern IRehldsApi* g_RehldsApi; +EXPORT extern const RehldsFuncs_t* g_RehldsFuncs; +EXPORT extern IRehldsServerData* g_RehldsData; +EXPORT extern IRehldsHookchains* g_RehldsHookchains; +EXPORT extern IRehldsServerStatic* g_RehldsSvs; \ No newline at end of file