mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-14 23:58:10 +03:00
ReHLDS API: Updated 3.3 (#506)
ReHLDS API: Add AddExtDll, RemoveExtDll, AddCvarListener, RemoveCvarListener, GetEntityInit, CreateFakeClient Bump minor API version
This commit is contained in:
parent
1cea370869
commit
9b75935be0
@ -1,3 +1,3 @@
|
|||||||
majorVersion=3
|
majorVersion=3
|
||||||
minorVersion=0
|
minorVersion=3
|
||||||
maintenanceVersion=0
|
maintenanceVersion=0
|
||||||
|
@ -125,7 +125,7 @@ void setupToolchain(NativeBinarySpec b) {
|
|||||||
}
|
}
|
||||||
b.lib LazyNativeDepSet.create(dep_bzip2, 'bzip2', b.buildType.name, true)
|
b.lib LazyNativeDepSet.create(dep_bzip2, 'bzip2', b.buildType.name, true)
|
||||||
|
|
||||||
cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'DEDICATED', 'SWDS', 'REHLDS_SELF', 'REHLDS_OPT_PEDANTIC', 'REHLDS_FLIGHT_REC'
|
cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'DEDICATED', 'SWDS', 'REHLDS_SELF', 'REHLDS_OPT_PEDANTIC', 'REHLDS_FLIGHT_REC', 'REHLDS_API'
|
||||||
|
|
||||||
if (cfg instanceof MsvcToolchainConfig) {
|
if (cfg instanceof MsvcToolchainConfig) {
|
||||||
cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig(
|
cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig(
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/***
|
/***
|
||||||
*
|
*
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||||
*
|
*
|
||||||
* This product contains software technology licensed from Id
|
* This product contains software technology licensed from Id
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
* Use, distribution, and modification of this source code and/or resulting
|
||||||
@ -36,4 +36,15 @@ typedef struct cvar_s
|
|||||||
struct cvar_s *next;
|
struct cvar_s *next;
|
||||||
} cvar_t;
|
} cvar_t;
|
||||||
|
|
||||||
|
using cvar_callback_t = void (*)(const char *pszNewValue);
|
||||||
|
|
||||||
|
struct cvar_listener_t
|
||||||
|
{
|
||||||
|
cvar_listener_t(const char *var_name, cvar_callback_t handler) :
|
||||||
|
func(handler), name(var_name) {}
|
||||||
|
|
||||||
|
cvar_callback_t func;
|
||||||
|
const char *name;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // CVARDEF_H
|
#endif // CVARDEF_H
|
||||||
|
@ -174,6 +174,15 @@ NOXREF const char *Cvar_CompleteVariable(const char *search, int forward)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Cvar_FireListeners(const char *var_name, const char *value)
|
||||||
|
{
|
||||||
|
for (auto var : g_CvarsListeners) {
|
||||||
|
if (Q_strcmp(var->name, var_name) == 0) {
|
||||||
|
var->func(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EXT_FUNC Cvar_DirectSet_internal(struct cvar_s *var, const char *value)
|
void EXT_FUNC Cvar_DirectSet_internal(struct cvar_s *var, const char *value)
|
||||||
{
|
{
|
||||||
if (!var || !value)
|
if (!var || !value)
|
||||||
@ -239,7 +248,6 @@ void EXT_FUNC Cvar_DirectSet_internal(struct cvar_s *var, const char *value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
qboolean changed = Q_strcmp(var->string, pszValue);
|
qboolean changed = Q_strcmp(var->string, pszValue);
|
||||||
|
|
||||||
if (var->flags & FCVAR_USERINFO)
|
if (var->flags & FCVAR_USERINFO)
|
||||||
{
|
{
|
||||||
if (g_pcls.state == ca_dedicated)
|
if (g_pcls.state == ca_dedicated)
|
||||||
@ -296,6 +304,12 @@ void EXT_FUNC Cvar_DirectSet_internal(struct cvar_s *var, const char *value)
|
|||||||
var->string = (char *)Z_Malloc(Q_strlen(pszValue) + 1);
|
var->string = (char *)Z_Malloc(Q_strlen(pszValue) + 1);
|
||||||
Q_strcpy(var->string, pszValue);
|
Q_strcpy(var->string, pszValue);
|
||||||
var->value = (float)Q_atof(var->string);
|
var->value = (float)Q_atof(var->string);
|
||||||
|
|
||||||
|
#ifdef REHLDS_API
|
||||||
|
if (changed) {
|
||||||
|
Cvar_FireListeners(var->name, pszValue);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cvar_DirectSet(struct cvar_s *var, const char *value)
|
void Cvar_DirectSet(struct cvar_s *var, const char *value)
|
||||||
|
@ -1549,7 +1549,7 @@ int EXT_FUNC PF_IsMapValid_I(const char *mapname)
|
|||||||
if (!mapname || Q_strlen(mapname) == 0)
|
if (!mapname || Q_strlen(mapname) == 0)
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Q_snprintf(cBuf, sizeof(cBuf), "maps/%.32s.bsp", mapname);
|
Q_snprintf(cBuf, sizeof(cBuf), "maps/%.32s.bsp", mapname);
|
||||||
return FS_FileExists(cBuf);
|
return FS_FileExists(cBuf);
|
||||||
}
|
}
|
||||||
@ -1943,7 +1943,12 @@ void EXT_FUNC PF_crosshairangle_I(const edict_t *clientent, float pitch, float y
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
edict_t* EXT_FUNC PF_CreateFakeClient_I(const char *netname)
|
edict_t *EXT_FUNC PF_CreateFakeClient_I(const char *netname)
|
||||||
|
{
|
||||||
|
return g_RehldsHookchains.m_CreateFakeClient.callChain(CreateFakeClient_internal, netname);
|
||||||
|
}
|
||||||
|
|
||||||
|
edict_t *EXT_FUNC CreateFakeClient_internal(const char *netname)
|
||||||
{
|
{
|
||||||
client_t *fakeclient;
|
client_t *fakeclient;
|
||||||
edict_t *ent;
|
edict_t *ent;
|
||||||
|
@ -172,6 +172,7 @@ void PF_changepitch_I(edict_t *ent);
|
|||||||
void PF_setview_I(const edict_t *clientent, const edict_t *viewent);
|
void PF_setview_I(const edict_t *clientent, const edict_t *viewent);
|
||||||
void PF_crosshairangle_I(const edict_t *clientent, float pitch, float yaw);
|
void PF_crosshairangle_I(const edict_t *clientent, float pitch, float yaw);
|
||||||
edict_t *PF_CreateFakeClient_I(const char *netname);
|
edict_t *PF_CreateFakeClient_I(const char *netname);
|
||||||
|
edict_t *CreateFakeClient_internal(const char *netname);
|
||||||
void PF_RunPlayerMove_I(edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, unsigned char impulse, unsigned char msec);
|
void PF_RunPlayerMove_I(edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, unsigned char impulse, unsigned char msec);
|
||||||
sizebuf_t *WriteDest_Parm(int dest);
|
sizebuf_t *WriteDest_Parm(int dest);
|
||||||
void PF_MessageBegin_I(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed);
|
void PF_MessageBegin_I(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed);
|
||||||
|
@ -4344,7 +4344,7 @@ int SV_CreatePacketEntities_internal(sv_delta_t type, client_t *client, packet_e
|
|||||||
else
|
else
|
||||||
newindex = 9999;
|
newindex = 9999;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef REHLDS_FIXES
|
#ifdef REHLDS_FIXES
|
||||||
if (oldnum < oldmax && from)
|
if (oldnum < oldmax && from)
|
||||||
#else
|
#else
|
||||||
|
@ -59,7 +59,7 @@ int giStateInfo;
|
|||||||
DLL_FUNCTIONS gEntityInterface;
|
DLL_FUNCTIONS gEntityInterface;
|
||||||
NEW_DLL_FUNCTIONS gNewDLLFunctions;
|
NEW_DLL_FUNCTIONS gNewDLLFunctions;
|
||||||
|
|
||||||
extensiondll_t g_rgextdll[50];
|
extensiondll_t g_rgextdll[MAX_EXTENSION_DLL];
|
||||||
|
|
||||||
int g_iextdllMac;
|
int g_iextdllMac;
|
||||||
modinfo_t gmodinfo;
|
modinfo_t gmodinfo;
|
||||||
@ -789,7 +789,7 @@ const char* EXT_FUNC NameForFunction(uint32 function)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ENTITYINIT GetEntityInit(char *pClassName)
|
ENTITYINIT EXT_FUNC GetEntityInit(char *pClassName)
|
||||||
{
|
{
|
||||||
return (ENTITYINIT)GetDispatch(pClassName);
|
return (ENTITYINIT)GetDispatch(pClassName);
|
||||||
}
|
}
|
||||||
@ -1089,7 +1089,7 @@ void LoadThisDll(const char *szDllFilename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pfnGiveFnptrsToDll(&g_engfuncsExportedToDlls, &gGlobalVariables);
|
pfnGiveFnptrsToDll(&g_engfuncsExportedToDlls, &gGlobalVariables);
|
||||||
if (g_iextdllMac == 50)
|
if (g_iextdllMac == MAX_EXTENSION_DLL)
|
||||||
{
|
{
|
||||||
Con_Printf("Too many DLLs, ignoring remainder\n");
|
Con_Printf("Too many DLLs, ignoring remainder\n");
|
||||||
goto IgnoreThisDLL;
|
goto IgnoreThisDLL;
|
||||||
|
@ -441,7 +441,6 @@
|
|||||||
<ClInclude Include="..\engine\pmove.h" />
|
<ClInclude Include="..\engine\pmove.h" />
|
||||||
<ClInclude Include="..\engine\pmovetst.h" />
|
<ClInclude Include="..\engine\pmovetst.h" />
|
||||||
<ClInclude Include="..\engine\pr_cmds.h" />
|
<ClInclude Include="..\engine\pr_cmds.h" />
|
||||||
<ClInclude Include="..\engine\pr_dlls.h" />
|
|
||||||
<ClInclude Include="..\engine\pr_edict.h" />
|
<ClInclude Include="..\engine\pr_edict.h" />
|
||||||
<ClInclude Include="..\engine\server.h" />
|
<ClInclude Include="..\engine\server.h" />
|
||||||
<ClInclude Include="..\engine\server_static.h" />
|
<ClInclude Include="..\engine\server_static.h" />
|
||||||
@ -512,6 +511,7 @@
|
|||||||
<ClInclude Include="..\public\rehlds\studio.h" />
|
<ClInclude Include="..\public\rehlds\studio.h" />
|
||||||
<ClInclude Include="..\public\rehlds\sys_shared.h" />
|
<ClInclude Include="..\public\rehlds\sys_shared.h" />
|
||||||
<ClInclude Include="..\public\rehlds\userid_rehlds.h" />
|
<ClInclude Include="..\public\rehlds\userid_rehlds.h" />
|
||||||
|
<ClInclude Include="..\public\rehlds\pr_dlls.h" />
|
||||||
<ClInclude Include="..\public\savegame_version.h" />
|
<ClInclude Include="..\public\savegame_version.h" />
|
||||||
<ClInclude Include="..\public\steam\isteamapps.h" />
|
<ClInclude Include="..\public\steam\isteamapps.h" />
|
||||||
<ClInclude Include="..\public\steam\isteambilling.h" />
|
<ClInclude Include="..\public\steam\isteambilling.h" />
|
||||||
@ -767,7 +767,7 @@
|
|||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>REHLDS_OPT_PEDANTIC;REHLDS_SELF;HOOK_ENGINE;REHLDS_FIXES;REHLDS_CHECKS;HAVE_OPT_STRTOOLS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>REHLDS_API;REHLDS_OPT_PEDANTIC;REHLDS_SELF;HOOK_ENGINE;REHLDS_FIXES;REHLDS_CHECKS;HAVE_OPT_STRTOOLS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<FloatingPointModel>Precise</FloatingPointModel>
|
<FloatingPointModel>Precise</FloatingPointModel>
|
||||||
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
@ -805,7 +805,7 @@
|
|||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;REHLDS_FIXES;REHLDS_SELF;REHLDS_CHECKS;HAVE_OPT_STRTOOLS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>REHLDS_API;REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;REHLDS_FIXES;REHLDS_SELF;REHLDS_CHECKS;HAVE_OPT_STRTOOLS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<FloatingPointModel>Precise</FloatingPointModel>
|
<FloatingPointModel>Precise</FloatingPointModel>
|
||||||
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
@ -953,7 +953,7 @@
|
|||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;HAVE_OPT_STRTOOLS;REHLDS_SELF;REHLDS_UNIT_TESTS;_BUILD_FROM_IDE;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>REHLDS_API;REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;HAVE_OPT_STRTOOLS;REHLDS_SELF;REHLDS_UNIT_TESTS;_BUILD_FROM_IDE;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
|
||||||
@ -989,7 +989,7 @@
|
|||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;REHLDS_FIXES;HAVE_OPT_STRTOOLS;REHLDS_SELF;REHLDS_UNIT_TESTS;_BUILD_FROM_IDE;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>REHLDS_API;REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;REHLDS_FIXES;HAVE_OPT_STRTOOLS;REHLDS_SELF;REHLDS_UNIT_TESTS;_BUILD_FROM_IDE;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
|
||||||
@ -1026,7 +1026,7 @@
|
|||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>REHLDS_OPT_PEDANTIC;REHLDS_SELF;HOOK_ENGINE;REHLDS_CHECKS;HAVE_OPT_STRTOOLS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>REHLDS_API;REHLDS_OPT_PEDANTIC;REHLDS_SELF;HOOK_ENGINE;REHLDS_CHECKS;HAVE_OPT_STRTOOLS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
@ -1149,7 +1149,7 @@
|
|||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>REHLDS_FLIGHT_REC;REHLDS_FIXES;REHLDS_OPT_PEDANTIC;REHLDS_SELF;REHLDS_CHECKS;HAVE_OPT_STRTOOLS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>REHLDS_API;REHLDS_FLIGHT_REC;REHLDS_FIXES;REHLDS_OPT_PEDANTIC;REHLDS_SELF;REHLDS_CHECKS;HAVE_OPT_STRTOOLS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
@ -577,9 +577,6 @@
|
|||||||
<ClInclude Include="..\engine\filter.h">
|
<ClInclude Include="..\engine\filter.h">
|
||||||
<Filter>engine\server</Filter>
|
<Filter>engine\server</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\engine\pr_dlls.h">
|
|
||||||
<Filter>engine\common</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\engine\sys_dll2.h">
|
<ClInclude Include="..\engine\sys_dll2.h">
|
||||||
<Filter>engine\server</Filter>
|
<Filter>engine\server</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@ -844,6 +841,9 @@
|
|||||||
<ClInclude Include="..\public\rehlds\rehlds_api.h">
|
<ClInclude Include="..\public\rehlds\rehlds_api.h">
|
||||||
<Filter>public\rehlds</Filter>
|
<Filter>public\rehlds</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\public\rehlds\pr_dlls.h">
|
||||||
|
<Filter>public\rehlds</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\rehlds\hookchains_impl.h">
|
<ClInclude Include="..\rehlds\hookchains_impl.h">
|
||||||
<Filter>rehlds</Filter>
|
<Filter>rehlds</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -1,49 +1,51 @@
|
|||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License as published by the
|
* under the terms of the GNU General Public License as published by the
|
||||||
* Free Software Foundation; either version 2 of the License, or (at
|
* Free Software Foundation; either version 2 of the License, or (at
|
||||||
* your option) any later version.
|
* your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but
|
* This program is distributed in the hope that it will be useful, but
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* General Public License for more details.
|
* General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software Foundation,
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
* In addition, as a special exception, the author gives permission to
|
* In addition, as a special exception, the author gives permission to
|
||||||
* link the code of this program with the Half-Life Game Engine ("HL
|
* link the code of this program with the Half-Life Game Engine ("HL
|
||||||
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||||
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||||
* respects for all of the code used other than the HL Engine and MODs
|
* respects for all of the code used other than the HL Engine and MODs
|
||||||
* from Valve. If you modify this file, you may extend this exception
|
* from Valve. If you modify this file, you may extend this exception
|
||||||
* to your version of the file, but you are not obligated to do so. If
|
* to your version of the file, but you are not obligated to do so. If
|
||||||
* you do not wish to do so, delete this exception statement from your
|
* you do not wish to do so, delete this exception statement from your
|
||||||
* version.
|
* version.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "maintypes.h"
|
#include "maintypes.h"
|
||||||
#include "eiface.h"
|
#include "eiface.h"
|
||||||
|
|
||||||
typedef struct functiontable_s
|
const int MAX_EXTENSION_DLL = 50;
|
||||||
{
|
|
||||||
uint32 pFunction;
|
typedef struct functiontable_s
|
||||||
char *pFunctionName;
|
{
|
||||||
} functiontable_t;
|
uint32 pFunction;
|
||||||
|
char *pFunctionName;
|
||||||
typedef struct extensiondll_s
|
} functiontable_t;
|
||||||
{
|
|
||||||
void *lDLLHandle;
|
typedef struct extensiondll_s
|
||||||
functiontable_t *functionTable;
|
{
|
||||||
int functionCount;
|
void *lDLLHandle;
|
||||||
} extensiondll_t;
|
functiontable_t *functionTable;
|
||||||
|
int functionCount;
|
||||||
typedef void(*ENTITYINIT)(struct entvars_s *);
|
} extensiondll_t;
|
||||||
typedef void(*DISPATCHFUNCTION)(struct entvars_s *, void *);
|
|
||||||
typedef void(*FIELDIOFUNCTION)(SAVERESTOREDATA *, const char *, void *, TYPEDESCRIPTION *, int);
|
typedef void(*ENTITYINIT)(struct entvars_s *);
|
||||||
|
typedef void(*DISPATCHFUNCTION)(struct entvars_s *, void *);
|
||||||
|
typedef void(*FIELDIOFUNCTION)(SAVERESTOREDATA *, const char *, void *, TYPEDESCRIPTION *, int);
|
@ -34,9 +34,10 @@
|
|||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
#include "ObjectList.h"
|
#include "ObjectList.h"
|
||||||
|
#include "pr_dlls.h"
|
||||||
|
|
||||||
#define REHLDS_API_VERSION_MAJOR 3
|
#define REHLDS_API_VERSION_MAJOR 3
|
||||||
#define REHLDS_API_VERSION_MINOR 2
|
#define REHLDS_API_VERSION_MINOR 3
|
||||||
|
|
||||||
//Steam_NotifyClientConnect hook
|
//Steam_NotifyClientConnect hook
|
||||||
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
|
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
|
||||||
@ -190,6 +191,10 @@ typedef IHookChainRegistry<int, enum sv_delta_s, IGameClient *, struct packet_en
|
|||||||
typedef IHookChain<bool, edict_t *, IGameClient *, int, const char*, float, float, int, int, int, const float*> IRehldsHook_SV_EmitSound2;
|
typedef IHookChain<bool, edict_t *, IGameClient *, int, const char*, float, float, int, int, int, const float*> IRehldsHook_SV_EmitSound2;
|
||||||
typedef IHookChainRegistry<bool, edict_t *, IGameClient *, int, const char*, float, float, int, int, int, const float*> IRehldsHookRegistry_SV_EmitSound2;
|
typedef IHookChainRegistry<bool, edict_t *, IGameClient *, int, const char*, float, float, int, int, int, const float*> IRehldsHookRegistry_SV_EmitSound2;
|
||||||
|
|
||||||
|
//CreateFakeClient hook
|
||||||
|
typedef IHookChain<edict_t *, const char *> IRehldsHook_CreateFakeClient;
|
||||||
|
typedef IHookChainRegistry<edict_t *, const char *> IRehldsHookRegistry_CreateFakeClient;
|
||||||
|
|
||||||
class IRehldsHookchains {
|
class IRehldsHookchains {
|
||||||
public:
|
public:
|
||||||
virtual ~IRehldsHookchains() { }
|
virtual ~IRehldsHookchains() { }
|
||||||
@ -232,6 +237,7 @@ public:
|
|||||||
virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f() = 0;
|
virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f() = 0;
|
||||||
virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities() = 0;
|
virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities() = 0;
|
||||||
virtual IRehldsHookRegistry_SV_EmitSound2* SV_EmitSound2() = 0;
|
virtual IRehldsHookRegistry_SV_EmitSound2* SV_EmitSound2() = 0;
|
||||||
|
virtual IRehldsHookRegistry_CreateFakeClient* CreateFakeClient() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RehldsFuncs_t {
|
struct RehldsFuncs_t {
|
||||||
@ -285,6 +291,11 @@ struct RehldsFuncs_t {
|
|||||||
bool(*StripUnprintableAndSpace)(char *pch);
|
bool(*StripUnprintableAndSpace)(char *pch);
|
||||||
void(*Cmd_RemoveCmd)(const char *cmd_name);
|
void(*Cmd_RemoveCmd)(const char *cmd_name);
|
||||||
void(*GetCommandMatches)(const char *string, ObjectList *pMatchList);
|
void(*GetCommandMatches)(const char *string, ObjectList *pMatchList);
|
||||||
|
bool(*AddExtDll)(void *hModule);
|
||||||
|
void(*AddCvarListener)(const char *var_name, cvar_callback_t func);
|
||||||
|
void(*RemoveExtDll)(void *hModule);
|
||||||
|
void(*RemoveCvarListener)(const char *var_name, cvar_callback_t func);
|
||||||
|
ENTITYINIT(*GetEntityInit)(char *pszClassName);
|
||||||
};
|
};
|
||||||
|
|
||||||
class IRehldsApi {
|
class IRehldsApi {
|
||||||
|
@ -34,6 +34,7 @@ struct plugin_api_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::vector<plugin_api_t *> g_PluginApis;
|
std::vector<plugin_api_t *> g_PluginApis;
|
||||||
|
std::vector<cvar_listener_t *> g_CvarsListeners;
|
||||||
|
|
||||||
plugin_api_t* FindPluginApiByName(const char *name) {
|
plugin_api_t* FindPluginApiByName(const char *name) {
|
||||||
for (auto pl : g_PluginApis) {
|
for (auto pl : g_PluginApis) {
|
||||||
@ -181,10 +182,84 @@ void EXT_FUNC GetCommandMatches_api(const char *string, ObjectList *pMatchList)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EXT_FUNC AddExtDll_api(void *hModule)
|
||||||
|
{
|
||||||
|
if (!hModule) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_iextdllMac >= MAX_EXTENSION_DLL) {
|
||||||
|
Con_Printf("Too many DLLs, ignoring remainder\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pextdll = &g_rgextdll[g_iextdllMac++];
|
||||||
|
Q_memset(pextdll, 0, sizeof(*pextdll));
|
||||||
|
pextdll->lDLLHandle = hModule;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EXT_FUNC RemoveExtDll_api(void *hModule)
|
||||||
|
{
|
||||||
|
if (!hModule) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto i = 0; i < g_iextdllMac; i++)
|
||||||
|
{
|
||||||
|
if (g_rgextdll[i].lDLLHandle == hModule)
|
||||||
|
{
|
||||||
|
g_iextdllMac--;
|
||||||
|
if (g_iextdllMac != i)
|
||||||
|
{
|
||||||
|
Q_memmove(&g_rgextdll[i], &g_rgextdll[i + 1], (g_iextdllMac - i) * sizeof(g_rgextdll[0]));
|
||||||
|
i = g_iextdllMac;
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_memset(&g_rgextdll[i], 0, sizeof(g_rgextdll[0]));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EXT_FUNC AddCvarListener_api(const char *var_name, cvar_callback_t func)
|
||||||
|
{
|
||||||
|
cvar_t *var = Cvar_FindVar(var_name);
|
||||||
|
if (!var) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto cvars : g_CvarsListeners) {
|
||||||
|
if (!Q_strcmp(cvars->name, var_name)) {
|
||||||
|
if (cvars->func == func) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cvar_listener_t *list = new cvar_listener_t(var_name, func);
|
||||||
|
g_CvarsListeners.push_back(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EXT_FUNC RemoveCvarListener_api(const char *var_name, cvar_callback_t func)
|
||||||
|
{
|
||||||
|
auto iter = g_CvarsListeners.begin();
|
||||||
|
while (iter != g_CvarsListeners.end())
|
||||||
|
{
|
||||||
|
if (Q_strcmp((*iter)->name, var_name) != 0 || (*iter)->func != func) {
|
||||||
|
iter++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete (*iter);
|
||||||
|
iter = g_CvarsListeners.erase(iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CRehldsServerStatic g_RehldsServerStatic;
|
CRehldsServerStatic g_RehldsServerStatic;
|
||||||
CRehldsServerData g_RehldsServerData;
|
CRehldsServerData g_RehldsServerData;
|
||||||
CRehldsHookchains g_RehldsHookchains;
|
CRehldsHookchains g_RehldsHookchains;
|
||||||
RehldsFuncs_t g_RehldsApiFuncs =
|
RehldsFuncs_t g_RehldsApiFuncs =
|
||||||
{
|
{
|
||||||
&SV_DropClient_api,
|
&SV_DropClient_api,
|
||||||
&SV_RejectConnection,
|
&SV_RejectConnection,
|
||||||
@ -235,7 +310,12 @@ RehldsFuncs_t g_RehldsApiFuncs =
|
|||||||
&SV_UpdateUserInfo_api,
|
&SV_UpdateUserInfo_api,
|
||||||
&StripUnprintableAndSpace_api,
|
&StripUnprintableAndSpace_api,
|
||||||
&Cmd_RemoveCmd,
|
&Cmd_RemoveCmd,
|
||||||
&GetCommandMatches_api
|
&GetCommandMatches_api,
|
||||||
|
&AddExtDll_api,
|
||||||
|
&AddCvarListener_api,
|
||||||
|
&RemoveExtDll_api,
|
||||||
|
&RemoveCvarListener_api,
|
||||||
|
&GetEntityInit
|
||||||
};
|
};
|
||||||
|
|
||||||
bool EXT_FUNC SV_EmitSound2_internal(edict_t *entity, IGameClient *pReceiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin)
|
bool EXT_FUNC SV_EmitSound2_internal(edict_t *entity, IGameClient *pReceiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin)
|
||||||
@ -486,6 +566,10 @@ IRehldsHookRegistry_SV_EmitSound2* CRehldsHookchains::SV_EmitSound2() {
|
|||||||
return &m_SV_EmitSound2;
|
return &m_SV_EmitSound2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IRehldsHookRegistry_CreateFakeClient* CRehldsHookchains::CreateFakeClient() {
|
||||||
|
return &m_CreateFakeClient;
|
||||||
|
}
|
||||||
|
|
||||||
int EXT_FUNC CRehldsApi::GetMajorVersion()
|
int EXT_FUNC CRehldsApi::GetMajorVersion()
|
||||||
{
|
{
|
||||||
return REHLDS_API_VERSION_MAJOR;
|
return REHLDS_API_VERSION_MAJOR;
|
||||||
|
@ -183,6 +183,10 @@ typedef IHookChainRegistryImpl<int, sv_delta_t, IGameClient *, packet_entities_t
|
|||||||
typedef IHookChainImpl<bool, edict_t *, IGameClient *, int, const char*, float, float, int, int, int, const float*> CRehldsHook_SV_EmitSound2;
|
typedef IHookChainImpl<bool, edict_t *, IGameClient *, int, const char*, float, float, int, int, int, const float*> CRehldsHook_SV_EmitSound2;
|
||||||
typedef IHookChainRegistryImpl<bool, edict_t *, IGameClient *, int, const char*, float, float, int, int, int, const float*> CRehldsHookRegistry_SV_EmitSound2;
|
typedef IHookChainRegistryImpl<bool, edict_t *, IGameClient *, int, const char*, float, float, int, int, int, const float*> CRehldsHookRegistry_SV_EmitSound2;
|
||||||
|
|
||||||
|
//CreateFakeClient hook
|
||||||
|
typedef IHookChainImpl<edict_t *, const char *> CRehldsHook_CreateFakeClient;
|
||||||
|
typedef IHookChainRegistryImpl<edict_t *, const char *> CRehldsHookRegistry_CreateFakeClient;
|
||||||
|
|
||||||
class CRehldsHookchains : public IRehldsHookchains {
|
class CRehldsHookchains : public IRehldsHookchains {
|
||||||
public:
|
public:
|
||||||
CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect;
|
CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect;
|
||||||
@ -223,6 +227,7 @@ public:
|
|||||||
CRehldsHookRegistry_SV_Spawn_f m_SV_Spawn_f;
|
CRehldsHookRegistry_SV_Spawn_f m_SV_Spawn_f;
|
||||||
CRehldsHookRegistry_SV_CreatePacketEntities m_SV_CreatePacketEntities;
|
CRehldsHookRegistry_SV_CreatePacketEntities m_SV_CreatePacketEntities;
|
||||||
CRehldsHookRegistry_SV_EmitSound2 m_SV_EmitSound2;
|
CRehldsHookRegistry_SV_EmitSound2 m_SV_EmitSound2;
|
||||||
|
CRehldsHookRegistry_CreateFakeClient m_CreateFakeClient;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
|
virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
|
||||||
@ -263,6 +268,7 @@ public:
|
|||||||
virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f();
|
virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f();
|
||||||
virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities();
|
virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities();
|
||||||
virtual IRehldsHookRegistry_SV_EmitSound2* SV_EmitSound2();
|
virtual IRehldsHookRegistry_SV_EmitSound2* SV_EmitSound2();
|
||||||
|
virtual IRehldsHookRegistry_CreateFakeClient* CreateFakeClient();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CRehldsHookchains g_RehldsHookchains;
|
extern CRehldsHookchains g_RehldsHookchains;
|
||||||
@ -285,5 +291,6 @@ public:
|
|||||||
extern sizebuf_t* GetNetMessage_api();
|
extern sizebuf_t* GetNetMessage_api();
|
||||||
extern IGameClient* GetHostClient_api();
|
extern IGameClient* GetHostClient_api();
|
||||||
extern int* GetMsgReadCount_api();
|
extern int* GetMsgReadCount_api();
|
||||||
|
extern std::vector<cvar_listener_t *> g_CvarsListeners;
|
||||||
|
|
||||||
bool SV_EmitSound2_api(edict_t *entity, IGameClient *receiver, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch, int emitFlags, const float *pOrigin);
|
bool SV_EmitSound2_api(edict_t *entity, IGameClient *receiver, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch, int emitFlags, const float *pOrigin);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user