Skip to content

Commit

Permalink
expose rehlds hooks
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wootguy committed Nov 9, 2024
1 parent 15626b9 commit 8670d3a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 38 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions dlls/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* without written permission from Valve LLC.
*
****/
#include "rehlds.h"
#include "extdll.h"
#include "eiface.h"
#include "util.h"
Expand All @@ -20,7 +21,6 @@
#include "CBaseMonster.h"
#include "skill.h"
#include "PluginManager.h"
#include "rehlds.h"

cvar_t displaysoundlist = {"displaysoundlist","0", 0, 0, 0};

Expand Down
34 changes: 2 additions & 32 deletions dlls/rehlds.cpp
Original file line number Diff line number Diff line change
@@ -1,42 +1,12 @@
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;
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
Expand Down
36 changes: 35 additions & 1 deletion dlls/rehlds.h
Original file line number Diff line number Diff line change
@@ -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();
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;

0 comments on commit 8670d3a

Please sign in to comment.