Add basic ReHLDS and ReGameDLL support (#417)

* Add ReHLDS API files and its dependencies

Note: This has been stolen from ReAPI AMXX module and modified/adjusted to match AMXX existing includes and to provide as less dependencies as possible as well

* Add the necessary files to get ReHLDS interface

* Split SV_DropClient into pre/post code

* Init ReHLDS API and add SV_DropClient hook

* Add Cvar_DirectSet hook and adjust code with helpers

Note: we don't need to split code here. This is pretty much the naive and straight way, but fairly enough for our case. If it happens we got a lot more hooks, we may consider to use some class to manage better the things.

* Move platform and interface stuff in their own files in public directory

* Make sure to init cvar stuff after ReHLDS

* Add ReGameDLL API files and its dependencies in cstrike module

* Init ReHLDS in cstrike module and adjust code

Note: About cs_uset_set_model(). ReHLDS API doesn't offer a way to know directly the precached models, so instead of looping through all the ressources, the models list is saved one time at map change into a hashmap.

* Init ReGameDLL and adjust code

* Fix linux compilation

* Init ReGameDLL in fakemeta module and adjust code

* Rename /reapi directory to /resdk to avoid confusion

* Retrieve gamerules pointer through InstallGameRules in fakemeta module

* Retrieve gamerules pointer through InstallGameRules in cstrike module

Note: actually gamerules is not used if regamedll is enabled, but it could be used in future natives.

* Fix a typo when ReGameDLL is not enabled

* Fix missing interface check for ReHLDS.

I'm pretty sure I was checking at the very first since I worked first on vanilla version of engine, looks like change has been lost.
This commit is contained in:
Vincent Herbet 2017-03-09 19:59:38 +01:00 committed by GitHub
parent 1c3e8de57a
commit 115916d753
48 changed files with 5298 additions and 379 deletions

View File

@ -93,6 +93,7 @@ binary.sources = [
'../public/memtools/MemoryUtils.cpp',
'../public/memtools/CDetour/detours.cpp',
'../public/memtools/CDetour/asm/asm.c',
'../public/resdk/mod_rehlds_api.cpp',
'CLibrarySys.cpp',
'CGameConfigs.cpp',
'gameconfigs.cpp',

View File

@ -11,67 +11,9 @@
#define _INCLUDE_LIBRARY_SYS_H_
#include "amx.h" // cell
#include <interface.h> // Interface (HLSDK)
#include <amtl/am-utility.h> // AutoPtr
#include <platform_helpers.h>
#include <amtl/os/am-shared-library.h>
#define PLATFORM_WINDOWNS_NAME "windows"
#define PLATFORM_LINUX_NAME "linux"
#define PLATFORM_MAC_NAME "mac"
#if defined(WIN32)
# ifndef PLATFORM_WINDOWS
# define PLATFORM_WINDOWS 1
# endif
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <windows.h>
# include <direct.h>
# include <io.h>
# define PLATFORM_LIB_EXT "dll"
# define PLATFORM_NAME PLATFORM_WINDOWNS_NAME
# define PLATFORM_SEP_CHAR '\\'
# define PLATFORM_SEP_ALTCHAR '/'
# define PLATFORM_EXTERN_C extern "C" __declspec(dllexport)
#elif defined(__linux__) || defined(__APPLE__)
# if defined(__linux__)
# define PLATFORM_LINUX 1
# define PLATFORM_LIB_EXT "so"
# define PLATFORM_NAME PLATFORM_LINUX_NAME
# define PLATFORM_COMPAT_ALT PLATFORM_MAC_NAME
# elif defined(__APPLE__)
# define PLATFORM_APPLE 1
# define PLATFORM_LIB_EXT "dylib"
# define PLATFORM_NAME PLATFORM_MAC_NAME
# define PLATFORM_COMPAT_ALT PLATFORM_LINUX_NAME
# endif
# ifndef PLATFORM_POSIX
# define PLATFORM_POSIX 1
# endif
# include <stdio.h>
# include <sys/types.h>
# include <sys/stat.h>
# include <errno.h>
# include <unistd.h>
# include <dirent.h>
# include <dlfcn.h>
# if defined(PLATFORM_APPLE)
# include <sys/syslimits.h>
# endif
# define PLATFORM_SEP_CHAR '/'
# define PLATFORM_SEP_ALTCHAR '\\'
# define PLATFORM_EXTERN_C extern "C" __attribute__((visibility("default")))
# define WINAPI
#endif
#define PLATFORM_MAX_PATH 260
#if defined PLATFORM_WINDOWS
typedef HANDLE DirHandle;
#elif defined PLATFORM_POSIX
typedef DIR* DirHandle;
#endif
enum FileTimeType
{
FileTime_LastAccess = 0, /* Last access (not available on FAT) */
@ -162,26 +104,4 @@ class LibrarySystem
extern LibrarySystem g_LibSys;
template <typename T>
bool GET_IFACE(const char* library, T*& var, const char* version)
{
const char* path = g_LibSys.PathFormat("%s.%s", library, PLATFORM_LIB_EXT);
ke::AutoPtr<CLibrary> lib(g_LibSys.OpenLibrary(path));
if (lib)
{
CreateInterfaceFn factory = reinterpret_cast<CreateInterfaceFn>(lib->GetSymbolAddress(CREATEINTERFACE_PROCNAME));
if (factory)
{
var = reinterpret_cast<T*>(factory(version, nullptr));
return true;
}
}
var = nullptr;
return false;
}
#endif // _INCLUDE_LIBRARY_SYS_H_

View File

@ -11,10 +11,13 @@
#include "amxmodx.h"
#include <CDetour/detours.h>
#include <auto-string.h>
#include <resdk/mod_rehlds_api.h>
CvarManager g_CvarManager;
DETOUR_DECL_STATIC2(Cvar_DirectSet, void, struct cvar_s*, var, const char*, value)
void (*Cvar_DirectSet_Actual)(struct cvar_s* var, const char *value) = nullptr;
void Cvar_DirectSet_Custom(struct cvar_s *var, const char *value, IRehldsHook_Cvar_DirectSet *chain = nullptr)
{
CvarInfo* info = nullptr;
@ -22,7 +25,7 @@ DETOUR_DECL_STATIC2(Cvar_DirectSet, void, struct cvar_s*, var, const char*, valu
|| strcmp(var->string, value) == 0 // Make sure old and new values are different to not trigger callbacks.
|| !g_CvarManager.CacheLookup(var->name, &info)) // No data in cache, nothing to do.
{
DETOUR_STATIC_CALL(Cvar_DirectSet)(var, value);
chain ? chain->callNext(var, value) : Cvar_DirectSet_Actual(var, value);
return;
}
@ -56,7 +59,7 @@ DETOUR_DECL_STATIC2(Cvar_DirectSet, void, struct cvar_s*, var, const char*, valu
oldValue = var->string;
}
DETOUR_STATIC_CALL(Cvar_DirectSet)(var, value);
chain ? chain->callNext(var, value) : Cvar_DirectSet_Actual(var, value);
if (!info->binds.empty())
{
@ -100,7 +103,18 @@ DETOUR_DECL_STATIC2(Cvar_DirectSet, void, struct cvar_s*, var, const char*, valu
}
}
CvarManager::CvarManager() : m_AmxmodxCvars(0), m_HookDetour(nullptr)
void Cvar_DirectSet(struct cvar_s *var, const char *value)
{
Cvar_DirectSet_Custom(var, value);
}
void Cvar_DirectSet_RH(IRehldsHook_Cvar_DirectSet *chain, cvar_t *var, const char *value)
{
Cvar_DirectSet_Custom(var, value, chain);
}
CvarManager::CvarManager() : m_AmxmodxCvars(0), m_HookDetour(nullptr), m_ReHookEnabled(false)
{
}
@ -116,6 +130,8 @@ void CvarManager::CreateCvarHook(void)
// Cvar_DirectSet(var, value); // <- We want to hook this.
// }
if (!RehldsHookchains)
{
void *functionAddress = nullptr;
if (CommonConfig && CommonConfig->GetMemSig("Cvar_DirectSet", &functionAddress) && functionAddress)
@ -125,7 +141,50 @@ void CvarManager::CreateCvarHook(void)
}
else
{
AMXXLOG_Log("Binding/Hooking cvars have been disabled - check your gamedata files.");
AMXXLOG_Log("Binding/Hooking cvars have been disabled - %s.", RehldsApi ? "update ReHLDS" : "check your gamedata files");
}
}
}
void CvarManager::EnableHook()
{
if (RehldsHookchains)
{
if (!m_ReHookEnabled)
{
RehldsHookchains->Cvar_DirectSet()->registerHook(Cvar_DirectSet_RH);
m_ReHookEnabled = true;
}
}
else if (m_HookDetour)
{
m_HookDetour->EnableDetour();
}
}
void CvarManager::DisableHook()
{
if (RehldsHookchains)
{
if (m_ReHookEnabled)
{
RehldsHookchains->Cvar_DirectSet()->unregisterHook(Cvar_DirectSet_RH);
m_ReHookEnabled = false;
}
}
else if (m_HookDetour)
{
m_HookDetour->DisableDetour();
}
}
void CvarManager::DestroyHook()
{
DisableHook();
if (m_HookDetour)
{
m_HookDetour->Destroy();
}
}
@ -205,9 +264,9 @@ CvarInfo* CvarManager::CreateCvar(const char* name, const char* value, const cha
// Detour is disabled on map change.
// Don't enable it unless there are things to do.
if ((info->bound.hasMin || info->bound.hasMax) && m_HookDetour)
if ((info->bound.hasMin || info->bound.hasMax))
{
m_HookDetour->EnableDetour();
EnableHook();
}
return info;
@ -295,11 +354,8 @@ AutoForward* CvarManager::HookCvarChange(cvar_t* var, AMX* amx, cell param, cons
return nullptr;
}
// Detour is disabled on map change.
if (m_HookDetour)
{
m_HookDetour->EnableDetour();
}
// Hook is disabled on map change.
EnableHook();
AutoForward* forward = new AutoForward(forwardId, *callback);
info->hooks.append(new CvarHook(g_plugins.findPlugin(amx)->getId(), forward));
@ -351,11 +407,8 @@ bool CvarManager::BindCvar(CvarInfo* info, CvarBind::CvarType type, AMX* amx, ce
break;
}
// Detour is disabled on map change.
if (m_HookDetour)
{
m_HookDetour->EnableDetour();
}
// Hook is disabled on map change.
EnableHook();
return true;
}
@ -367,11 +420,8 @@ void CvarManager::SetCvarMin(CvarInfo* info, bool set, float value, int pluginId
if (set)
{
// Detour is disabled on map change.
if (m_HookDetour)
{
m_HookDetour->EnableDetour();
}
// Hook is disabled on map change.
EnableHook();
info->bound.minVal = value;
@ -393,11 +443,8 @@ void CvarManager::SetCvarMax(CvarInfo* info, bool set, float value, int pluginId
if (set)
{
// Detour is disabled on map change.
if (m_HookDetour)
{
m_HookDetour->EnableDetour();
}
// Hook is disabled on map change.
EnableHook();
info->bound.maxVal = value;
@ -584,12 +631,9 @@ void CvarManager::OnPluginUnloaded()
(*cvar)->hooks.clear();
}
// There is no point to enable detour if at next map change
// There is no point to enable hook if at next map change
// no plugins hook cvars.
if (m_HookDetour)
{
m_HookDetour->DisableDetour();
}
DisableHook();
}
void CvarManager::OnAmxxShutdown()
@ -619,8 +663,5 @@ void CvarManager::OnAmxxShutdown()
m_Cache.clear();
if (m_HookDetour)
{
m_HookDetour->Destroy();
}
DestroyHook();
}

View File

@ -142,6 +142,9 @@ class CvarManager
public:
void CreateCvarHook();
void EnableHook();
void DisableHook();
void DestroyHook();
CvarInfo* CreateCvar(const char* name, const char* value, const char* plugin, int pluginId, int flags = 0, const char* helpText = "");
CvarInfo* FindCvar(const char* name);
@ -166,6 +169,7 @@ class CvarManager
CvarsList m_Cvars;
size_t m_AmxmodxCvars;
CDetour* m_HookDetour;
bool m_ReHookEnabled;
};
extern CvarManager g_CvarManager;

View File

@ -32,6 +32,8 @@
#include <engine_strucs.h>
#include <CDetour/detours.h>
#include "CoreConfig.h"
#include <resdk/mod_rehlds_api.h>
#include <amtl/am-utility.h>
plugin_info_t Plugin_info =
{
@ -902,6 +904,31 @@ void C_ClientDisconnect(edict_t *pEntity)
RETURN_META(MRES_IGNORED);
}
CPlayer* SV_DropClient_PreHook(edict_s *client, qboolean crash, const char *buffer, size_t buffer_size)
{
auto pPlayer = client ? GET_PLAYER_POINTER(client) : nullptr;
if (pPlayer)
{
if (pPlayer->initialized)
{
pPlayer->disconnecting = true;
executeForwards(FF_ClientDisconnected, pPlayer->index, TRUE, prepareCharArray(const_cast<char*>(buffer), buffer_size, true), buffer_size - 1);
}
}
return pPlayer;
}
void SV_DropClient_PostHook(CPlayer *pPlayer, qboolean crash, const char *buffer)
{
if (pPlayer)
{
pPlayer->Disconnect();
executeForwards(FF_ClientRemove, pPlayer->index, TRUE, buffer);
}
}
// void SV_DropClient(client_t *cl, qboolean crash, const char *fmt, ...);
DETOUR_DECL_STATIC3_VAR(SV_DropClient, void, client_t*, cl, qboolean, crash, const char*, format)
{
@ -912,24 +939,23 @@ DETOUR_DECL_STATIC3_VAR(SV_DropClient, void, client_t*, cl, qboolean, crash, con
ke::SafeVsprintf(buffer, sizeof(buffer) - 1, format, ap);
va_end(ap);
auto pPlayer = cl->edict ? GET_PLAYER_POINTER(cl->edict) : nullptr;
if (pPlayer)
{
if (pPlayer->initialized)
{
pPlayer->disconnecting = true;
executeForwards(FF_ClientDisconnected, pPlayer->index, TRUE, prepareCharArray(buffer, sizeof(buffer), true), sizeof(buffer) - 1);
}
}
auto pPlayer = SV_DropClient_PreHook(cl->edict, crash, buffer, ARRAY_LENGTH(buffer));
DETOUR_STATIC_CALL(SV_DropClient)(cl, crash, "%s", buffer);
if (pPlayer)
{
pPlayer->Disconnect();
executeForwards(FF_ClientRemove, pPlayer->index, TRUE, buffer);
}
SV_DropClient_PostHook(pPlayer, crash, buffer);
}
void SV_DropClient_RH(IRehldsHook_SV_DropClient *chain, IGameClient *cl, bool crash, const char *format)
{
char buffer[1024];
ke::SafeStrcpy(buffer, sizeof(buffer), format);
auto pPlayer = SV_DropClient_PreHook(cl->GetEdict(), crash, buffer, ARRAY_LENGTH(buffer));
chain->callNext(cl, crash, buffer);
SV_DropClient_PostHook(pPlayer, crash, buffer);
}
void C_ClientPutInServer_Post(edict_t *pEntity)
@ -1602,8 +1628,12 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
ConfigManager.OnAmxxStartup();
g_CvarManager.CreateCvarHook();
if (RehldsApi_Init())
{
RehldsHookchains->SV_DropClient()->registerHook(SV_DropClient_RH);
}
else
{
void *address = nullptr;
if (CommonConfig && CommonConfig->GetMemSig("SV_DropClient", &address) && address)
@ -1612,8 +1642,12 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
}
else
{
AMXXLOG_Log("client_disconnected and client_remove forwards have been disabled - check your gamedata files.");
auto reason = RehldsApi ? "update ReHLDS" : "check your gamedata files";
AMXXLOG_Log("client_disconnected and client_remove forwards have been disabled - %s.", reason);
}
}
g_CvarManager.CreateCvarHook();
GET_IFACE<IFileSystem>("filesystem_stdio", g_FileSystem, FILESYSTEM_INTERFACE_VERSION);
@ -1664,6 +1698,10 @@ C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
{
DropClientDetour->Destroy();
}
else if (RehldsApi)
{
RehldsHookchains->SV_DropClient()->unregisterHook(SV_DropClient_RH);
}
return (TRUE);
}

View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "amxmodx_mm", "amxmodx_mm.vcxproj", "{2BF64D1A-AC89-41B0-9D02-FB8CB610F850}"
EndProject

View File

@ -151,6 +151,7 @@
<ClCompile Include="..\..\public\memtools\CDetour\asm\asm.c" />
<ClCompile Include="..\..\public\memtools\CDetour\detours.cpp" />
<ClCompile Include="..\..\public\memtools\MemoryUtils.cpp" />
<ClCompile Include="..\..\public\resdk\mod_rehlds_api.cpp" />
<ClCompile Include="..\..\third_party\hashing\hashers\crc32.cpp">
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='JITDebug|Win32'">$(IntDir)hashing\</ObjectFileName>
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='JITRelease|Win32'">$(IntDir)hashing\</ObjectFileName>
@ -311,6 +312,10 @@
<ClInclude Include="..\..\public\memtools\CDetour\detourhelpers.h" />
<ClInclude Include="..\..\public\memtools\CDetour\detours.h" />
<ClInclude Include="..\..\public\memtools\MemoryUtils.h" />
<ClInclude Include="..\..\public\resdk\common\hookchains.h" />
<ClInclude Include="..\..\public\resdk\engine\rehlds_api.h" />
<ClInclude Include="..\..\public\resdk\engine\rehlds_interfaces.h" />
<ClInclude Include="..\..\public\resdk\mod_rehlds_api.h" />
<ClInclude Include="..\..\third_party\hashing\hashers\crc32.h" />
<ClInclude Include="..\..\third_party\hashing\hashers\keccak.h" />
<ClInclude Include="..\..\third_party\hashing\hashers\md5.h" />

View File

@ -46,6 +46,15 @@
<Filter Include="Third Party\Hashing\hashers">
<UniqueIdentifier>{fb5fd616-bb2e-42f1-a113-a61eb9ead739}</UniqueIdentifier>
</Filter>
<Filter Include="ReSDK">
<UniqueIdentifier>{5dd87e1c-9be5-43d3-8216-74d36f4f7610}</UniqueIdentifier>
</Filter>
<Filter Include="ReSDK\common">
<UniqueIdentifier>{26cdecf1-06de-459e-9ea0-0bbb4a2b3bf6}</UniqueIdentifier>
</Filter>
<Filter Include="ReSDK\engine">
<UniqueIdentifier>{04fab577-6f56-40d0-8f69-7ce1b8bf3bb9}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\amx.cpp">
@ -291,6 +300,9 @@
<ClCompile Include="..\CoreConfig.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\public\resdk\mod_rehlds_api.cpp">
<Filter>ReSDK</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\amx.h">
@ -503,6 +515,18 @@
<ClInclude Include="..\CFrameAction.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\public\resdk\common\hookchains.h">
<Filter>ReSDK\common</Filter>
</ClInclude>
<ClInclude Include="..\..\public\resdk\engine\rehlds_api.h">
<Filter>ReSDK\engine</Filter>
</ClInclude>
<ClInclude Include="..\..\public\resdk\engine\rehlds_interfaces.h">
<Filter>ReSDK\engine</Filter>
</ClInclude>
<ClInclude Include="..\..\public\resdk\mod_rehlds_api.h">
<Filter>ReSDK</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\version.rc">

View File

@ -19,6 +19,8 @@ binary.sources = [
'../../../public/memtools/MemoryUtils.cpp',
'../../../public/memtools/CDetour/detours.cpp',
'../../../public/memtools/CDetour/asm/asm.c',
'../../../public/resdk/mod_rehlds_api.cpp',
'../../../public/resdk/mod_regamedll_api.cpp',
]
if builder.target_platform == 'windows':

View File

@ -326,7 +326,7 @@ enum CsWeaponClassType
/**
* Weapon infos.
*/
typedef struct
struct WeaponInfoStruct
{
int id;
int cost;
@ -336,8 +336,8 @@ typedef struct
int maxRounds;
int ammoType;
char *entityName;
}
WeaponInfoStruct;
const char *ammoName;
};
/**
* Weapon infos for use with cs_get_weapon_info().

View File

@ -15,6 +15,8 @@
#include "CstrikeUtils.h"
#include "CstrikeHacks.h"
#include "CstrikeItemsInfos.h"
#include <resdk/mod_rehlds_api.h>
#include <resdk/mod_regamedll_api.h>
int ForwardInternalCommand = -1;
int ForwardOnBuy = -1;
@ -64,10 +66,20 @@ server_t *Server;
// Mod global variable
void **GameRules;
void *GameRulesRH;
bool HasReHlds;
bool HasReGameDll;
bool HasRestricteditem_Enabled;
bool InternalCommand_Enabled;
bool GiveDefaultItems_Enabled;
void InitializeHacks()
{
HasReHlds = RehldsApi_Init();
HasReGameDll = RegamedllApi_Init();
CtrlDetours_ClientCommand(true);
CtrlDetours_BuyCommands(true);
CtrlDetours_Natives(true);
@ -88,7 +100,11 @@ void ShutdownHacks()
const char *CMD_ARGV(int i)
{
if (*UseBotArgs)
if (HasReGameDll)
{
return ReGameFuncs->Cmd_Argv(i);
}
else if (*UseBotArgs)
{
if (i < 4)
{
@ -101,9 +117,10 @@ const char *CMD_ARGV(int i)
return g_engfuncs.pfnCmd_Argv(i);
}
DETOUR_DECL_STATIC1(C_ClientCommand, void, edict_t*, pEdict) // void ClientCommand(edict_t *pEntity)
void (*C_ClientCommand_Actual)(edict_t *) = nullptr;
void ClientCommand_Custom(edict_t *pEdict, const char *command, const char *arg1, IReGameHook_InternalCommand *chain = nullptr)
{
auto command = CMD_ARGV(0);
auto client = TypeConversion.edict_to_id(pEdict);
CurrentItemId = CSI_NONE;
@ -117,7 +134,7 @@ DETOUR_DECL_STATIC1(C_ClientCommand, void, edict_t*, pEdict) // void ClientComma
// Handling buy via menu.
if (!strcmp(command, "menuselect"))
{
auto slot = atoi(CMD_ARGV(1));
auto slot = atoi(arg1);
if (slot > 0 && slot < 9)
{
@ -172,7 +189,7 @@ DETOUR_DECL_STATIC1(C_ClientCommand, void, edict_t*, pEdict) // void ClientComma
}
}
if (HasInternalCommandForward && *UseBotArgs && MF_ExecuteForward(ForwardInternalCommand, client, *BotArgs) > 0)
if (HasInternalCommandForward && (HasReGameDll || *UseBotArgs) && MF_ExecuteForward(ForwardInternalCommand, client, CMD_ARGV(0)) > 0)
{
return;
}
@ -185,11 +202,21 @@ DETOUR_DECL_STATIC1(C_ClientCommand, void, edict_t*, pEdict) // void ClientComma
TriggeredFromCommand = CurrentItemId != CSI_NONE;
DETOUR_STATIC_CALL(C_ClientCommand)(pEdict);
chain ? chain->callNext(pEdict, command, arg1) : C_ClientCommand_Actual(pEdict);
TriggeredFromCommand = BlockMoneyUpdate = BlockAmmosUpdate = false;
}
void C_ClientCommand(edict_t* pEdict) // void ClientCommand(edict_t *pEntity)
{
ClientCommand_Custom(pEdict, CMD_ARGV(0), CMD_ARGV(1));
}
void InternalCommand_RH(IReGameHook_InternalCommand* chain, edict_t *pEdict, const char *command, const char *arg1)
{
ClientCommand_Custom(pEdict, CMD_ARGV(0), CMD_ARGV(1), chain);
}
edict_s* OnCreateNamedEntity(int classname)
{
if (NoKnivesMode)
@ -219,6 +246,18 @@ DETOUR_DECL_MEMBER0(GiveDefaultItems, void) // void CBasePlayer::GiveDefaultIte
g_pengfuncsTable->pfnCreateNamedEntity = nullptr;
}
void GiveDefaultItems_RH(IReGameHook_CBasePlayer_GiveDefaultItems *chain, class CBasePlayer *pPlayer)
{
if (NoKnivesMode)
{
g_pengfuncsTable->pfnCreateNamedEntity = OnCreateNamedEntity;
}
chain->callNext(pPlayer);
g_pengfuncsTable->pfnCreateNamedEntity = nullptr;
}
DETOUR_DECL_MEMBER1(CanPlayerBuy, bool, bool, display) // bool CBasePlayer::CanPlayerBuy(bool display)
{
auto canBuy = DETOUR_MEMBER_CALL(CanPlayerBuy)(display);
@ -340,6 +379,35 @@ DETOUR_DECL_MEMBER2(AddAccount, void, int, amount, bool, bTrackChange) // void C
DETOUR_MEMBER_CALL(AddAccount)(amount, bTrackChange);
}
bool CBasePlayer_HasRestrictItem_RH(IReGameHook_CBasePlayer_HasRestrictItem *chain, class CBasePlayer *pPlayer, ItemID item, ItemRestType type)
{
if (type == ITEM_TYPE_BUYING && CurrentItemId != CSI_NONE)
{
auto player = TypeConversion.cbase_to_id(pPlayer);
if (MF_IsPlayerAlive(player) && MF_ExecuteForward(ForwardOnBuy, player, CurrentItemId) > 0)
{
return true;
}
}
return chain->callNext(pPlayer, item, type);
}
bool BuyGunAmmo_RH(IReGameHook_BuyGunAmmo *chain, class CBasePlayer *pPlayer, class CBasePlayerItem *pWeapon, bool blinkMoney)
{
if (CurrentItemId == CSI_PRIAMMO || CurrentItemId == CSI_SECAMMO)
{
auto player = TypeConversion.cbase_to_id(pPlayer);
if (MF_IsPlayerAlive(player) && MF_ExecuteForward(ForwardOnBuy, player, CurrentItemId) > 0)
{
return false;
}
}
return chain->callNext(pPlayer, pWeapon, blinkMoney);
}
void ToggleDetour(CDetour *detour, bool enable)
{
@ -362,6 +430,16 @@ void DestroyDetour(CDetour *&detour)
void CtrlDetours_ClientCommand(bool set)
{
if (set)
{
if (HasReGameDll)
{
if (!InternalCommand_Enabled)
{
ReGameHookchains->InternalCommand()->registerHook(InternalCommand_RH);
InternalCommand_Enabled = true;
}
}
else
{
auto base = reinterpret_cast<void *>(MDLL_ClientCommand);
@ -396,28 +474,54 @@ void CtrlDetours_ClientCommand(bool set)
if (!ClientCommandDetour)
{
MF_Log("ClientCommand is not available - forwards CS_InternalCommand and CS_OnBuy[Attempt] have been disabled");
CtrlDetours_ClientCommand(false);
ToggleHook_ClientCommands(false);
}
else if (!UseBotArgs || !BotArgs)
{
MF_Log("UseBotArgs or BotArgs is not available - forward CS_InternalCommand has been disabled");
}
}
}
else
{
if (HasReGameDll)
{
ReGameHookchains->InternalCommand()->unregisterHook(InternalCommand_RH);
InternalCommand_Enabled = false;
}
else
{
DestroyDetour(ClientCommandDetour);
}
}
}
void ToggleDetour_ClientCommands(bool enable)
void ToggleHook_ClientCommands(bool enable)
{
if (HasReGameDll)
{
CtrlDetours_ClientCommand(enable);
}
else
{
ToggleDetour(ClientCommandDetour, enable);
}
}
void CtrlDetours_BuyCommands(bool set)
{
if (set)
{
if (HasReGameDll)
{
if (!HasRestricteditem_Enabled)
{
ReGameHookchains->CBasePlayer_HasRestrictItem()->registerHook(CBasePlayer_HasRestrictItem_RH);
ReGameHookchains->BuyGunAmmo()->registerHook(BuyGunAmmo_RH);
HasRestricteditem_Enabled = true;
}
}
else
{
void *address = nullptr;
@ -474,9 +578,18 @@ void CtrlDetours_BuyCommands(bool set)
}
MF_Log("Some functions are not available - forwards CS_OnBuy[Attempt] have been disabled");
ToggleDetour_BuyCommands(false);
ToggleHook_BuyCommands(false);
}
}
}
else
{
if (HasReGameDll)
{
ReGameHookchains->CBasePlayer_HasRestrictItem()->unregisterHook(CBasePlayer_HasRestrictItem_RH);
ReGameHookchains->BuyGunAmmo()->unregisterHook(BuyGunAmmo_RH);
HasRestricteditem_Enabled = false;
}
else
{
DestroyDetour(BuyGunAmmoDetour);
@ -485,21 +598,39 @@ void CtrlDetours_BuyCommands(bool set)
DestroyDetour(CanPlayerBuyDetour);
DestroyDetour(CanBuyThisDetour);
}
}
}
void ToggleDetour_BuyCommands(bool enable)
void ToggleHook_BuyCommands(bool enable)
{
if (HasReGameDll)
{
CtrlDetours_BuyCommands(enable);
}
else
{
ToggleDetour(BuyGunAmmoDetour, enable);
ToggleDetour(GiveNamedItemDetour, enable);
ToggleDetour(AddAccountDetour, enable);
ToggleDetour(CanPlayerBuyDetour, enable);
ToggleDetour(CanBuyThisDetour, enable);
}
}
void CtrlDetours_Natives(bool set)
{
if (set)
{
if (HasReGameDll)
{
if (!GiveDefaultItems_Enabled)
{
ReGameHookchains->CBasePlayer_GiveDefaultItems()->registerHook(GiveDefaultItems_RH);
GiveDefaultItems_Enabled = true;
}
}
else
{
void *address = nullptr;
@ -513,15 +644,45 @@ void CtrlDetours_Natives(bool set)
MF_Log("GiveDefaultItems is not available - native cs_set_no_knives has been disabled");
}
}
}
else
{
if (HasReGameDll)
{
ReGameHookchains->CBasePlayer_GiveDefaultItems()->unregisterHook(GiveDefaultItems_RH);
GiveDefaultItems_Enabled = false;
}
else
{
DestroyDetour(GiveDefaultItemsDetour);
}
}
}
void ToggleHook_GiveDefaultItems(bool enable)
{
if (HasReGameDll)
{
CtrlDetours_Natives(enable);
}
else
{
ToggleDetour(GiveDefaultItemsDetour, enable);
}
}
void InitFuncsAddresses()
{
if (HasReGameDll)
{
RemoveEntityHashValue = ReGameFuncs->RemoveEntityHashValue;
CS_CreateNamedEntity = ReGameFuncs->CREATE_NAMED_ENTITY2;
CS_UTIL_FindEntityByString = ReGameFuncs->UTIL_FindEntityByString;
AddEntityHashValue = ReGameFuncs->AddEntityHashValue;
}
else
{
void *address = nullptr;
if (MainConfig->GetMemSig("CreateNamedEntity", &address)) // cs_create_entity()
@ -548,7 +709,7 @@ void InitFuncsAddresses()
{
RemoveEntityHashValue = reinterpret_cast<RemoveEntityHashValueFunc>(address);
}
}
if (!CS_CreateNamedEntity)
{
@ -560,7 +721,12 @@ void InitFuncsAddresses()
MF_Log("UTIL_FindEntByString is not available - native cs_find_ent_by_class() has been disabled");
}
if (!GetWeaponInfo)
if (!AddEntityHashValue || !AddEntityHashValue)
{
MF_Log("AddEntityHashValue or AddEntityHashValue is not available - native cs_set_ent_class() has been disabled");
}
if (!HasReGameDll && !GetWeaponInfo)
{
MF_Log("GetWeaponInfo is not available - native cs_get_weapon_info() and forward CS_OnBuy have been disabled");
CtrlDetours_BuyCommands(false);
@ -584,16 +750,23 @@ void InitClassMembers()
!MoneyDesc.fieldOffset)
{
MF_Log("Invalid or missing entity gamedata files - forwards CS_OnBuy[Attempt] have been disabled");
CtrlDetours_BuyCommands(false);
ToggleHook_BuyCommands(false);
}
}
CGameRules* InstallGameRules(IReGameHook_InstallGameRules *chain)
{
GameRulesRH = chain->callNext();
return static_cast<CGameRules*>(GameRulesRH);
}
void InitGlobalVars()
{
void *address = nullptr;
if (!HasReHlds)
{
#if defined(KE_WINDOWS)
TypeDescription typeDesc;
if (CommonConfig->GetOffset("svs", &typeDesc))
@ -606,14 +779,7 @@ void InitGlobalVars()
{
Server = *reinterpret_cast<decltype(Server)*>(address);
}
if (CommonConfig->GetAddress("g_pGameRules", &address))
{
GameRules = *reinterpret_cast<decltype(GameRules)*>(address);
}
#else
if (CommonConfig->GetMemSig("svs", &address))
{
ServerStatic = reinterpret_cast<decltype(ServerStatic)>(address);
@ -623,14 +789,30 @@ void InitGlobalVars()
{
Server = reinterpret_cast<decltype(Server)>(address);
}
#endif
}
if (HasReGameDll)
{
ReGameHookchains->InstallGameRules()->registerHook(InstallGameRules);
}
else
{
#if defined(KE_WINDOWS)
if (CommonConfig->GetAddress("g_pGameRules", &address))
{
GameRules = *reinterpret_cast<decltype(GameRules)*>(address);
}
#else
if (CommonConfig->GetMemSig("g_pGameRules", &address))
{
GameRules = reinterpret_cast<decltype(GameRules)>(address);
}
#endif
}
if (!HasReHlds)
{
if (!ServerStatic)
{
MF_Log("svs global variable is not available");
@ -640,10 +822,14 @@ void InitGlobalVars()
{
MF_Log("sv global variable is not available");
}
}
if (!HasReGameDll)
{
if (!GameRules)
{
MF_Log("g_pGameRules is not available - Forward CS_OnBuy has been disabled");
CtrlDetours_BuyCommands(false);
}
}
}

View File

@ -19,6 +19,7 @@
#include <CDetour/detours.h>
#include <engine_strucs.h>
#include "CstrikeDatas.h"
#include <resdk/cstrike/regamedll_api.h>
void InitializeHacks();
void InitFuncsAddresses();
@ -30,8 +31,9 @@ void CtrlDetours_ClientCommand(bool set);
void CtrlDetours_BuyCommands(bool set);
void CtrlDetours_Natives(bool set);
void ToggleDetour_ClientCommands(bool enable);
void ToggleDetour_BuyCommands(bool enable);
void ToggleHook_ClientCommands(bool enable);
void ToggleHook_BuyCommands(bool enable);
void ToggleHook_GiveDefaultItems(bool enable);
extern AMX_NATIVE_INFO CstrikeNatives[];
@ -60,10 +62,10 @@ enum class HashType
};
typedef edict_t* (*CreateNamedEntityFunc)(string_t iszClassname);
typedef void* (*UTIL_FindEntityByStringFunc)(void* pStartEntity, const char *szKeyword, const char *szValue);
typedef class CBaseEntity* (*UTIL_FindEntityByStringFunc)(class CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue);
typedef WeaponInfoStruct* (*GetWeaponInfoFunc)(int id);
typedef void (*AddEntityHashValueFunc)(struct entvars_s *pev, const char *value, HashType fieldType);
typedef void (*RemoveEntityHashValueFunc)(struct entvars_s *pev, const char *value, HashType fieldType);
typedef void (*AddEntityHashValueFunc)(entvars_s *pev, const char *value, hash_types_e fieldType);
typedef void (*RemoveEntityHashValueFunc)(entvars_t *pev, const char *value, hash_types_e fieldType);
extern CreateNamedEntityFunc CS_CreateNamedEntity;
extern UTIL_FindEntityByStringFunc CS_UTIL_FindEntityByString;
@ -79,8 +81,12 @@ extern bool NoKnivesMode;
extern server_static_t *ServerStatic;
extern server_t *Server;
extern void **GameRules;
extern void *GameRulesRH;
extern int *UseBotArgs;
extern const char **BotArgs;
extern bool HasReHlds;
extern bool HasReGameDll;
#endif // CSTRIKE_HACKS_H

View File

@ -17,6 +17,7 @@
#include "CstrikeItemsInfos.h"
#include "CstrikeUserMessages.h"
#include <IGameConfigs.h>
#include <resdk/mod_rehlds_api.h>
IGameConfig *MainConfig;
IGameConfig *CommonConfig;
@ -24,6 +25,8 @@ IGameConfigManager *ConfigManager;
HLTypeConversion TypeConversion;
extern StringHashMap<int> ModelsList;
int AmxxCheckGame(const char *game)
{
if (strcasecmp(game, "cstrike") == 0 ||
@ -34,6 +37,30 @@ int AmxxCheckGame(const char *game)
return AMXX_GAME_BAD;
}
void SV_ActivateServer_RH(IRehldsHook_SV_ActivateServer *chain, int runPhysics)
{
chain->callNext(runPhysics);
auto numResources = RehldsData->GetResourcesNum();
if (!numResources)
{
return;
}
ModelsList.clear();
for (auto i = 0; i < numResources; ++i) // Saves all the precached models into a list.
{
auto resource = RehldsData->GetResource(i);
if (resource->type == t_model)
{
ModelsList.insert(resource->szFileName, i);
}
}
}
void OnAmxxAttach()
{
MF_AddNatives(CstrikeNatives);
@ -58,6 +85,11 @@ void OnAmxxAttach()
}
InitializeHacks();
if (HasReHlds)
{
RehldsHookchains->SV_ActivateServer()->registerHook(SV_ActivateServer_RH);
}
}
void OnPluginsLoaded()
@ -74,23 +106,30 @@ void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
// Used to catch WeaponList message at map change.
EnableMessageHooks();
if (!ClientCommandDetour) // All CS_* forwards requires ClientCommand. Unlikely to fail.
if (!HasReGameDll && !ClientCommandDetour) // All CS_* forwards requires ClientCommand. Unlikely to fail.
{
ToggleDetour_ClientCommands(false);
ToggleDetour_BuyCommands(false);
ToggleHook_ClientCommands(false);
ToggleHook_BuyCommands(false);
RETURN_META(MRES_IGNORED);
}
auto haveBotDetours = UseBotArgs && BotArgs;
auto haveBuyDetours = BuyGunAmmoDetour && GiveNamedItemDetour && AddAccountDetour && CanPlayerBuyDetour && CanBuyThisDetour;
auto haveBotHooks = true;
auto haveBuyHooks = true;
HasInternalCommandForward = haveBotDetours && UTIL_CheckForPublic("CS_InternalCommand");
HasOnBuyAttemptForward = haveBuyDetours && UTIL_CheckForPublic("CS_OnBuyAttempt");
HasOnBuyForward = haveBuyDetours && UTIL_CheckForPublic("CS_OnBuy");
if (!HasReGameDll)
{
haveBotHooks = UseBotArgs && BotArgs;
haveBuyHooks = BuyGunAmmoDetour && GiveNamedItemDetour && AddAccountDetour && CanPlayerBuyDetour && CanBuyThisDetour;
}
ToggleDetour_ClientCommands(HasInternalCommandForward || HasOnBuyAttemptForward || HasOnBuyForward);
ToggleDetour_BuyCommands(HasOnBuyForward);
HasInternalCommandForward = haveBotHooks && UTIL_CheckForPublic("CS_InternalCommand");
HasOnBuyAttemptForward = haveBuyHooks && UTIL_CheckForPublic("CS_OnBuyAttempt");
HasOnBuyForward = haveBuyHooks && UTIL_CheckForPublic("CS_OnBuy");
ToggleHook_ClientCommands(HasInternalCommandForward || HasOnBuyAttemptForward || HasOnBuyForward);
ToggleHook_BuyCommands(HasOnBuyForward);
ToggleHook_GiveDefaultItems(false);
RETURN_META(MRES_IGNORED);
}
@ -104,13 +143,15 @@ void OnServerActivate_Post(edict_t *pEdictList, int edictCount, int clientMax)
void OnServerDeactivate()
{
if (!ClientCommandDetour)
if (!HasReGameDll && !ClientCommandDetour)
{
RETURN_META(MRES_IGNORED);
}
ToggleDetour_ClientCommands(false);
ToggleDetour_BuyCommands(false);
GameRulesRH = nullptr;
ToggleHook_ClientCommands(false);
ToggleHook_BuyCommands(false);
RETURN_META(MRES_IGNORED);
}

View File

@ -19,8 +19,10 @@
#include "CstrikeItemsInfos.h"
#include <CDetour/detours.h>
#include <amtl/am-string.h>
#include <resdk/mod_regamedll_api.h>
bool NoKnivesMode = false;
StringHashMap<int> ModelsList;
// native cs_set_user_money(index, money, flash = 1);
static cell AMX_NATIVE_CALL cs_set_user_money(AMX *amx, cell *params)
@ -865,19 +867,18 @@ static cell AMX_NATIVE_CALL cs_set_user_model(AMX *amx, cell *params)
char modelpath[260];
ke::SafeSprintf(modelpath, sizeof(modelpath), "models/player/%s/%s.mdl", newModel, newModel);
for (size_t i = 0; i < HL_MODEL_MAX; ++i)
auto modelIndex = 0;
if (ModelsList.retrieve(modelpath, &modelIndex))
{
if (Server->model_precache[i] && !strcmp(Server->model_precache[i], modelpath))
{
if (pPlayer->v.modelindex != i)
if (pPlayer->v.modelindex != modelIndex)
{
SET_MODEL(pPlayer, STRING(ALLOC_STRING(modelpath)));
}
set_pdata<int>(pPlayer, m_modelIndexPlayer, i);
set_pdata<int>(pPlayer, m_modelIndexPlayer, modelIndex);
return 1;
}
}
MF_Log("Model must be precached using cs_set_user_model with update_index parameter set");
return 0;
@ -1044,7 +1045,7 @@ static cell AMX_NATIVE_CALL cs_get_no_knives(AMX *amx, cell *params)
// native cs_set_no_knives(noknives = 0);
static cell AMX_NATIVE_CALL cs_set_no_knives(AMX *amx, cell *params)
{
if (!GiveDefaultItemsDetour)
if (!HasReGameDll && !GiveDefaultItemsDetour)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Native cs_set_no_knives() is disabled. Check your amxx logs.");
return 0;
@ -1052,14 +1053,7 @@ static cell AMX_NATIVE_CALL cs_set_no_knives(AMX *amx, cell *params)
NoKnivesMode = params[1] != 0;
if (NoKnivesMode)
{
GiveDefaultItemsDetour->EnableDetour();
}
else
{
GiveDefaultItemsDetour->DisableDetour();
}
ToggleHook_GiveDefaultItems(NoKnivesMode);
return 1;
}
@ -1698,7 +1692,7 @@ static cell AMX_NATIVE_CALL cs_find_ent_by_class(AMX* amx, cell* params)
}
int len;
void* pEntity = TypeConversion.id_to_cbase(params[1]);
auto pEntity = (CBaseEntity*)TypeConversion.id_to_cbase(params[1]);
const char* value = MF_GetAmxString(amx, params[2], 0, &len);
int index = TypeConversion.cbase_to_id(CS_UTIL_FindEntityByString(pEntity, "classname", value));
@ -1724,7 +1718,7 @@ static cell AMX_NATIVE_CALL cs_find_ent_by_owner(AMX* amx, cell* params)
CHECK_ENTITY_SIMPLE(owner);
int length;
void* pEntity = TypeConversion.id_to_cbase(params[1]);
auto pEntity = (CBaseEntity*)TypeConversion.id_to_cbase(params[1]);
const char* value = MF_GetAmxString(amx, params[2], 0, &length);
edict_t *pOwner = TypeConversion.id_to_edict(owner);
@ -1763,14 +1757,14 @@ static cell AMX_NATIVE_CALL cs_set_ent_class(AMX* amx, cell* params)
if (pev->classname)
{
RemoveEntityHashValue(pev, STRING(pev->classname), HashType::Classname);
RemoveEntityHashValue(pev, STRING(pev->classname), CLASSNAME);
}
int length;
auto new_classname = MF_GetAmxString(amx, params[2], 0, &length);
pev->classname = ALLOC_STRING(new_classname);
AddEntityHashValue(pev, STRING(pev->classname), HashType::Classname);
AddEntityHashValue(pev, STRING(pev->classname), CLASSNAME);
return 1;
}
@ -1882,7 +1876,7 @@ static cell AMX_NATIVE_CALL cs_get_translated_item_alias(AMX* amx, cell* params)
// native cs_get_weapon_info(weapon_id, CsWeaponInfo:type);
static cell AMX_NATIVE_CALL cs_get_weapon_info(AMX* amx, cell* params)
{
if (GetWeaponInfo <= 0)
if (!HasReGameDll && GetWeaponInfo <= 0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Native cs_get_weapon_info() is disabled. Check your amxx logs.");
return 0;
@ -1893,7 +1887,7 @@ static cell AMX_NATIVE_CALL cs_get_weapon_info(AMX* amx, cell* params)
WeaponInfoStruct *info;
if (weapon_id <= CSW_NONE || weapon_id > CSW_LAST_WEAPON || !(info = GetWeaponInfo(weapon_id)))
if (weapon_id <= CSW_NONE || weapon_id > CSW_LAST_WEAPON || !(info = HasReGameDll ? ReGameApi->GetWeaponInfo(weapon_id) : GetWeaponInfo(weapon_id)))
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id: %d", weapon_id);
return 0;
@ -1925,6 +1919,7 @@ static cell AMX_NATIVE_CALL cs_get_weapon_info(AMX* amx, cell* params)
{
return info->ammoType;
}
// TODO: Ammo name (custom)
}
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid info type: %d", info_type);

View File

@ -18,6 +18,7 @@
#include "CstrikeUtils.h"
#include "CstrikeHacks.h"
#include <amtl/am-vector.h>
#include <resdk/mod_rehlds_api.h>
extern ke::Vector<int> ModelsUpdateQueue;
@ -119,6 +120,11 @@ class CPlayer
g_pengfuncsTable->pfnSetClientKeyValue = SetClientKeyValue;
}
if (HasReHlds)
{
return;
}
if (!ServerStatic)
{
MF_Log("Postponing of model update disabled, check your gamedata files");

View File

@ -144,6 +144,8 @@
<ClCompile Include="..\..\..\..\public\memtools\CDetour\asm\asm.c" />
<ClCompile Include="..\..\..\..\public\memtools\CDetour\detours.cpp" />
<ClCompile Include="..\..\..\..\public\memtools\MemoryUtils.cpp" />
<ClCompile Include="..\..\..\..\public\resdk\mod_regamedll_api.cpp" />
<ClCompile Include="..\..\..\..\public\resdk\mod_rehlds_api.cpp" />
<ClCompile Include="..\CstrikeMain.cpp" />
<ClCompile Include="..\CstrikeHacks.cpp" />
<ClCompile Include="..\CstrikeNatives.cpp" />
@ -158,6 +160,14 @@
<ClInclude Include="..\..\..\..\public\memtools\CDetour\detourhelpers.h" />
<ClInclude Include="..\..\..\..\public\memtools\CDetour\detours.h" />
<ClInclude Include="..\..\..\..\public\memtools\MemoryUtils.h" />
<ClInclude Include="..\..\..\..\public\resdk\common\hookchains.h" />
<ClInclude Include="..\..\..\..\public\resdk\cstrike\regamedll_api.h" />
<ClInclude Include="..\..\..\..\public\resdk\cstrike\regamedll_const.h" />
<ClInclude Include="..\..\..\..\public\resdk\cstrike\regamedll_interfaces.h" />
<ClInclude Include="..\..\..\..\public\resdk\engine\rehlds_api.h" />
<ClInclude Include="..\..\..\..\public\resdk\engine\rehlds_interfaces.h" />
<ClInclude Include="..\..\..\..\public\resdk\mod_regamedll_api.h" />
<ClInclude Include="..\..\..\..\public\resdk\mod_rehlds_api.h" />
<ClInclude Include="..\CstrikeItemsInfos.h" />
<ClInclude Include="..\CstrikeDatas.h" />
<ClInclude Include="..\CstrikeHacks.h" />

View File

@ -27,6 +27,18 @@
<Filter Include="Memtools\CDetour\asm">
<UniqueIdentifier>{4f3c4a13-065a-49b1-83a1-f646a3ec3678}</UniqueIdentifier>
</Filter>
<Filter Include="ReSDK">
<UniqueIdentifier>{7f37b35a-6ac7-4269-81a1-60dab5abbee4}</UniqueIdentifier>
</Filter>
<Filter Include="ReSDK\engine">
<UniqueIdentifier>{bcfa2fd6-45a9-4671-a48e-f9ae4fdd3a9a}</UniqueIdentifier>
</Filter>
<Filter Include="ReSDK\common">
<UniqueIdentifier>{d192d10f-9ccb-4357-a360-875a563b016a}</UniqueIdentifier>
</Filter>
<Filter Include="ReSDK\cstrike">
<UniqueIdentifier>{ba0b72ba-25d8-48c3-af84-c1d4d7436636}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\CstrikeHacks.cpp">
@ -62,6 +74,12 @@
<ClCompile Include="..\CstrikeItemsInfos.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\public\resdk\mod_regamedll_api.cpp">
<Filter>ReSDK</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\public\resdk\mod_rehlds_api.cpp">
<Filter>ReSDK</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\CstrikePlayer.h">
@ -100,6 +118,30 @@
<ClInclude Include="..\CstrikeItemsInfos.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\common\hookchains.h">
<Filter>ReSDK\common</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\cstrike\regamedll_api.h">
<Filter>ReSDK\cstrike</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\cstrike\regamedll_const.h">
<Filter>ReSDK\cstrike</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\cstrike\regamedll_interfaces.h">
<Filter>ReSDK\cstrike</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\engine\rehlds_api.h">
<Filter>ReSDK\engine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\engine\rehlds_interfaces.h">
<Filter>ReSDK\engine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\mod_regamedll_api.h">
<Filter>ReSDK</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\mod_rehlds_api.h">
<Filter>ReSDK</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\..\plugins\include\cstrike.inc">

View File

@ -10,6 +10,7 @@ binary.compiler.defines += [
binary.sources = [
'../../public/sdk/amxxmodule.cpp',
'../../public/memtools/MemoryUtils.cpp',
'../../public/resdk/mod_regamedll_api.cpp',
'dllfunc.cpp',
'engfunc.cpp',
'fakemeta_amxx.cpp',

View File

@ -13,14 +13,24 @@
#include "fakemeta_amxx.h"
#include "sh_stack.h"
#include <resdk/mod_regamedll_api.h>
IGameConfig *CommonConfig;
IGameConfig *GamerulesConfig;
IGameConfigManager *ConfigManager;
bool HasRegameDll;
HLTypeConversion TypeConversion;
void *GameRulesRH;
void **GameRulesAddress;
CGameRules* InstallGameRules(IReGameHook_InstallGameRules *chain)
{
GameRulesRH = chain->callNext();
return static_cast<CGameRules*>(GameRulesRH);
}
void OnAmxxAttach()
{
initialze_offsets();
@ -61,6 +71,12 @@ void OnAmxxAttach()
return;
}
if ((HasRegameDll = RegamedllApi_Init()))
{
ReGameHookchains->InstallGameRules()->registerHook(InstallGameRules);
}
else
{
void *address = nullptr;
if (!CommonConfig->GetAddress("g_pGameRules", &address) || !address)
@ -74,6 +90,7 @@ void OnAmxxAttach()
#else
GameRulesAddress = reinterpret_cast<void**>(address);
#endif
}
}
void OnPluginsLoaded()
@ -135,6 +152,11 @@ void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
void FMH_ServerDeactivate_Post()
{
if (HasRegameDll)
{
GameRulesRH = nullptr;
}
// Reset all call lists here.
// NULL all function tables
RESETE(PrecacheModel);

View File

@ -79,7 +79,9 @@ extern IGameConfig *CommonConfig;
extern IGameConfig *GamerulesConfig;
extern IGameConfigManager *ConfigManager;
extern bool HasRegameDll;
extern HLTypeConversion TypeConversion;
extern void *GameRulesRH;
extern void **GameRulesAddress;
#endif //_FAKEMETA_INCLUDE_H

View File

@ -55,7 +55,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\;..\..\..\public;..\..\..\public\sdk;..\..\..\public\amtl;..\..\third_party;..\..\third_party\hashing;$(METAMOD)\metamod;$(HLSDK)\common;$(HLSDK)\engine;$(HLSDK)\dlls;$(HLSDK)\pm_shared;$(HLSDK)\public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;FAKEMETA_EXPORTS;HAVE_STDINT_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;FAKEMETA_EXPORTS;HAVE_STDINT_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
@ -78,7 +78,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\;..\..\..\public;..\..\..\public\sdk;..\..\..\public\amtl;..\..\third_party;..\..\third_party\hashing;$(METAMOD)\metamod;$(HLSDK)\common;$(HLSDK)\engine;$(HLSDK)\dlls;$(HLSDK)\pm_shared;$(HLSDK)\public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;FAKEMETA_EXPORTS;HAVE_STDINT_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;FAKEMETA_EXPORTS;HAVE_STDINT_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeader>
@ -97,6 +97,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\public\memtools\MemoryUtils.cpp" />
<ClCompile Include="..\..\..\public\resdk\mod_regamedll_api.cpp" />
<ClCompile Include="..\fakemeta_amxx.cpp" />
<ClCompile Include="..\fm_tr.cpp" />
<ClCompile Include="..\fm_tr2.cpp" />
@ -114,6 +115,12 @@
<ItemGroup>
<ClInclude Include="..\..\..\public\HLTypeConversion.h" />
<ClInclude Include="..\..\..\public\memtools\MemoryUtils.h" />
<ClInclude Include="..\..\..\public\resdk\common\hookchains.h" />
<ClInclude Include="..\..\..\public\resdk\cstrike\regamedll_api.h" />
<ClInclude Include="..\..\..\public\resdk\cstrike\regamedll_const.h" />
<ClInclude Include="..\..\..\public\resdk\cstrike\regamedll_interfaces.h" />
<ClInclude Include="..\..\..\public\resdk\mod_regamedll_api.h" />
<ClInclude Include="..\..\..\public\resdk\mod_rehlds_api.h" />
<ClInclude Include="..\fakemeta_amxx.h" />
<ClInclude Include="..\fm_tr.h" />
<ClInclude Include="..\dllfunc.h" />

View File

@ -36,6 +36,15 @@
<Filter Include="Memtools">
<UniqueIdentifier>{e1b28b22-6fde-4e1f-a982-f37dec584571}</UniqueIdentifier>
</Filter>
<Filter Include="ReSDK">
<UniqueIdentifier>{395f243b-8294-49ad-a959-d3d9ca6b79db}</UniqueIdentifier>
</Filter>
<Filter Include="ReSDK\common">
<UniqueIdentifier>{87a7e30d-f917-4853-b5b9-56782049cee6}</UniqueIdentifier>
</Filter>
<Filter Include="ReSDK\cstrike">
<UniqueIdentifier>{0d1c5025-071d-43aa-b19a-2eee0d34a906}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\fakemeta_amxx.cpp">
@ -80,6 +89,9 @@
<ClCompile Include="..\pdata_gamerules.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\public\resdk\mod_regamedll_api.cpp">
<Filter>ReSDK</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\fakemeta_amxx.h">
@ -124,6 +136,24 @@
<ClInclude Include="..\pdata_shared.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\public\resdk\common\hookchains.h">
<Filter>ReSDK\common</Filter>
</ClInclude>
<ClInclude Include="..\..\..\public\resdk\cstrike\regamedll_api.h">
<Filter>ReSDK\cstrike</Filter>
</ClInclude>
<ClInclude Include="..\..\..\public\resdk\cstrike\regamedll_const.h">
<Filter>ReSDK\cstrike</Filter>
</ClInclude>
<ClInclude Include="..\..\..\public\resdk\cstrike\regamedll_interfaces.h">
<Filter>ReSDK\cstrike</Filter>
</ClInclude>
<ClInclude Include="..\..\..\public\resdk\mod_regamedll_api.h">
<Filter>ReSDK</Filter>
</ClInclude>
<ClInclude Include="..\..\..\public\resdk\mod_rehlds_api.h">
<Filter>ReSDK</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\plugins\include\fakemeta.inc">

View File

@ -25,7 +25,7 @@ static cell AMX_NATIVE_CALL get_gamerules_int(AMX *amx, cell *params)
int element = params[3];
CHECK_DATA(data, element, BaseFieldType::Integer);
return PvData::GetInt(*GameRulesAddress, data, element);
return PvData::GetInt(HasRegameDll ? GameRulesRH : *GameRulesAddress, data, element);
}
// native set_gamerules_int(const class[], const member[], any:value, element = 0);
@ -45,7 +45,7 @@ static cell AMX_NATIVE_CALL set_gamerules_int(AMX *amx, cell *params)
return 0;
}
PvData::SetInt(*GameRulesAddress, data, params[3], element);
PvData::SetInt(HasRegameDll ? GameRulesRH : *GameRulesAddress, data, params[3], element);
return 0;
}
@ -62,7 +62,7 @@ static cell AMX_NATIVE_CALL get_gamerules_float(AMX *amx, cell *params)
int element = params[3];
CHECK_DATA(data, element, BaseFieldType::Float);
return PvData::GetFloat(*GameRulesAddress, data, element);
return PvData::GetFloat(HasRegameDll ? GameRulesRH : *GameRulesAddress, data, element);
}
// native set_gamerules_float(const class[], const member[], Float:value, element = 0);
@ -76,7 +76,7 @@ static cell AMX_NATIVE_CALL set_gamerules_float(AMX *amx, cell *params)
int element = params[4];
CHECK_DATA(data, element, BaseFieldType::Float);
PvData::SetFloat(*GameRulesAddress, data, amx_ctof(params[3]), element);
PvData::SetFloat(HasRegameDll ? GameRulesRH : *GameRulesAddress, data, amx_ctof(params[3]), element);
return 1;
}
@ -93,7 +93,7 @@ static cell AMX_NATIVE_CALL get_gamerules_vector(AMX *amx, cell *params)
int element = params[4];
CHECK_DATA(data, element, BaseFieldType::Vector);
PvData::GetVector(*GameRulesAddress, data, MF_GetAmxAddr(amx, params[3]), element);
PvData::GetVector(HasRegameDll ? GameRulesRH : *GameRulesAddress, data, MF_GetAmxAddr(amx, params[3]), element);
return 1;
}
@ -109,7 +109,7 @@ static cell AMX_NATIVE_CALL set_gamerules_vector(AMX *amx, cell *params)
int element = params[4];
CHECK_DATA(data, element, BaseFieldType::Vector);
PvData::GetVector(*GameRulesAddress, data, MF_GetAmxAddr(amx, params[3]), element);
PvData::GetVector(HasRegameDll ? GameRulesRH : *GameRulesAddress, data, MF_GetAmxAddr(amx, params[3]), element);
return 1;
}
@ -126,7 +126,7 @@ static cell AMX_NATIVE_CALL get_gamerules_entity(AMX *amx, cell *params)
int element = params[3];
CHECK_DATA(data, element, BaseFieldType::Entity);
return PvData::GetEntity(*GameRulesAddress, data, element);
return PvData::GetEntity(HasRegameDll ? GameRulesRH : *GameRulesAddress, data, element);
}
// native set_gamerules_entity(const class[], const member[], value, element = 0);
@ -147,7 +147,7 @@ static cell AMX_NATIVE_CALL set_gamerules_entity(AMX *amx, cell *params)
int element = params[4];
CHECK_DATA(data, element, BaseFieldType::Entity);
PvData::SetEntity(*GameRulesAddress, data, params[3], element);
PvData::SetEntity(HasRegameDll ? GameRulesRH : *GameRulesAddress, data, params[3], element);
return 0;
}
@ -167,7 +167,7 @@ static cell AMX_NATIVE_CALL get_gamerules_string(AMX *amx, cell *params)
auto buffer = params[3];
auto maxlen = params[4];
auto string = PvData::GetString(*GameRulesAddress, data, element);
auto string = PvData::GetString(HasRegameDll ? GameRulesRH : *GameRulesAddress, data, element);
if (data.fieldSize)
{
@ -191,7 +191,7 @@ static cell AMX_NATIVE_CALL set_gamerules_string(AMX *amx, cell *params)
int length;
const char *value = MF_GetAmxString(amx, params[3], 0, &length);
return PvData::SetString(*GameRulesAddress, data, value, length, element);
return PvData::SetString(HasRegameDll ? GameRulesRH : *GameRulesAddress, data, value, length, element);
}

View File

@ -64,7 +64,7 @@ enum class BaseFieldType
}
#define CHECK_GAMERULES() \
if (!GameRulesAddress) \
if ((HasRegameDll && !GameRulesRH) || (!HasRegameDll && (!GameRulesAddress || !*GameRulesAddress))) \
{ \
MF_LogError(amx, AMX_ERR_NATIVE, "%s is disabled. Check your AMXX log.", __FUNCTION__); \
return 0; \

View File

@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <amtl/am-string.h>
#include <amtl/am-algorithm.h>
namespace ke {

View File

@ -66,6 +66,12 @@
// This is the packet payload without any header bytes (which are attached for actual sending)
#define NET_MAX_PAYLOAD 3990
typedef enum sv_delta_s
{
sv_packet_nodelta,
sv_packet_delta,
} sv_delta_t;
typedef enum netsrc_s
{
NS_CLIENT,

View File

@ -0,0 +1,44 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
#pragma once
#include "platform_helpers.h"
#include <amtl/os/am-path.h>
#include <amtl/os/am-shared-library.h>
template <typename T>
bool GET_IFACE(const char* library, T*& var, const char* version, bool add_ext = true)
{
char file[PLATFORM_MAX_PATH];
if (add_ext)
ke::path::Format(file, sizeof(file), "%s.%s", library, PLATFORM_LIB_EXT);
else
ke::SafeStrcpy(file, sizeof(file), library);
auto lib = ke::SharedLib::Open(file);
if (!lib || !lib->valid())
{
return false;
}
auto factory = reinterpret_cast<CreateInterfaceFn>(lib->lookup(CREATEINTERFACE_PROCNAME));
if (factory)
{
var = reinterpret_cast<T*>(factory(version, nullptr));
return true;
}
var = nullptr;
return false;
}

70
public/platform_helpers.h Normal file
View File

@ -0,0 +1,70 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
#pragma once
#include <interface.h> // Interface (HLSDK)
#define PLATFORM_WINDOWNS_NAME "windows"
#define PLATFORM_LINUX_NAME "linux"
#define PLATFORM_MAC_NAME "mac"
#if defined(WIN32)
# ifndef PLATFORM_WINDOWS
# define PLATFORM_WINDOWS 1
# endif
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <windows.h>
# include <direct.h>
# include <io.h>
# define PLATFORM_LIB_EXT "dll"
# define PLATFORM_NAME PLATFORM_WINDOWNS_NAME
# define PLATFORM_SEP_CHAR '\\'
# define PLATFORM_SEP_ALTCHAR '/'
# define PLATFORM_EXTERN_C extern "C" __declspec(dllexport)
#elif defined(__linux__) || defined(__APPLE__)
# if defined(__linux__)
# define PLATFORM_LINUX 1
# define PLATFORM_LIB_EXT "so"
# define PLATFORM_NAME PLATFORM_LINUX_NAME
# define PLATFORM_COMPAT_ALT PLATFORM_MAC_NAME
# elif defined(__APPLE__)
# define PLATFORM_APPLE 1
# define PLATFORM_LIB_EXT "dylib"
# define PLATFORM_NAME PLATFORM_MAC_NAME
# define PLATFORM_COMPAT_ALT PLATFORM_LINUX_NAME
# endif
# ifndef PLATFORM_POSIX
# define PLATFORM_POSIX 1
# endif
# include <stdio.h>
# include <sys/types.h>
# include <sys/stat.h>
# include <errno.h>
# include <unistd.h>
# include <dirent.h>
# include <dlfcn.h>
# if defined(PLATFORM_APPLE)
# include <sys/syslimits.h>
# endif
# define PLATFORM_SEP_CHAR '/'
# define PLATFORM_SEP_ALTCHAR '\\'
# define PLATFORM_EXTERN_C extern "C" __attribute__((visibility("default")))
# define WINAPI
#endif
#define PLATFORM_MAX_PATH 260
#if defined PLATFORM_WINDOWS
typedef HANDLE DirHandle;
#elif defined PLATFORM_POSIX
typedef DIR* DirHandle;
#endif

View File

@ -0,0 +1,121 @@
/*
*
* 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
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* 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
* 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
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
template<typename t_ret, typename ...t_args>
class IHookChain {
protected:
virtual ~IHookChain() {}
public:
virtual t_ret callNext(t_args... args) = 0;
virtual t_ret callOriginal(t_args... args) = 0;
};
template<typename t_ret, typename t_class, typename ...t_args>
class IHookChainClass {
protected:
virtual ~IHookChainClass() {}
public:
virtual t_ret callNext(t_class *, t_args... args) = 0;
virtual t_ret callOriginal(t_class *, t_args... args) = 0;
};
template<typename ...t_args>
class IVoidHookChain
{
protected:
virtual ~IVoidHookChain() {}
public:
virtual void callNext(t_args... args) = 0;
virtual void callOriginal(t_args... args) = 0;
};
template<typename t_class, typename ...t_args>
class IVoidHookChainClass
{
protected:
virtual ~IVoidHookChainClass() {}
public:
virtual void callNext(t_class *, t_args... args) = 0;
virtual void callOriginal(t_class *, t_args... args) = 0;
};
// Specifies priorities for hooks call order in the chain.
// For equal priorities first registered hook will be called first.
enum HookChainPriority
{
HC_PRIORITY_UNINTERRUPTABLE = 255, // Hook will be called before other hooks.
HC_PRIORITY_HIGH = 192, // Hook will be called before hooks with default priority.
HC_PRIORITY_DEFAULT = 128, // Default hook call priority.
HC_PRIORITY_MEDIUM = 64, // Hook will be called after hooks with default priority.
HC_PRIORITY_LOW = 0, // Hook will be called after all other hooks.
};
// Hook chain registry(for hooks [un]registration)
template<typename t_ret, typename ...t_args>
class IHookChainRegistry {
public:
typedef t_ret(*hookfunc_t)(IHookChain<t_ret, t_args...>*, t_args...);
virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0;
virtual void unregisterHook(hookfunc_t hook) = 0;
};
// Hook chain registry(for hooks [un]registration)
template<typename t_ret, typename t_class, typename ...t_args>
class IHookChainRegistryClass {
public:
typedef t_ret(*hookfunc_t)(IHookChainClass<t_ret, t_class, t_args...>*, t_class *, t_args...);
virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0;
virtual void unregisterHook(hookfunc_t hook) = 0;
};
// Hook chain registry(for hooks [un]registration)
template<typename ...t_args>
class IVoidHookChainRegistry {
public:
typedef void(*hookfunc_t)(IVoidHookChain<t_args...>*, t_args...);
virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0;
virtual void unregisterHook(hookfunc_t hook) = 0;
};
// Hook chain registry(for hooks [un]registration)
template<typename t_class, typename ...t_args>
class IVoidHookChainRegistryClass {
public:
typedef void(*hookfunc_t)(IVoidHookChainClass<t_class, t_args...>*, t_class *, t_args...);
virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0;
virtual void unregisterHook(hookfunc_t hook) = 0;
};

View File

@ -0,0 +1,482 @@
/*
*
* 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
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* 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
* 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
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
#include <engine_strucs.h>
#include "regamedll_interfaces.h"
#include "regamedll_const.h"
#include "../common/hookchains.h"
#define REGAMEDLL_API_VERSION_MAJOR 5
#define REGAMEDLL_API_VERSION_MINOR 1
// CBasePlayer::Spawn hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_Spawn;
// CBasePlayer::Precache hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_Precache;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_Precache;
// CBasePlayer::ObjectCaps hook
typedef IHookChainClass<int, class CBasePlayer> IReGameHook_CBasePlayer_ObjectCaps;
typedef IHookChainRegistryClass<int, class CBasePlayer> IReGameHookRegistry_CBasePlayer_ObjectCaps;
// CBasePlayer::Classify hook
typedef IHookChainClass<int, class CBasePlayer> IReGameHook_CBasePlayer_Classify;
typedef IHookChainRegistryClass<int, class CBasePlayer> IReGameHookRegistry_CBasePlayer_Classify;
// CBasePlayer::TraceAttack hook
typedef IVoidHookChainClass<class CBasePlayer, struct entvars_s *, float, Vector &, TraceResult *, int> IReGameHook_CBasePlayer_TraceAttack;
typedef IVoidHookChainRegistryClass<class CBasePlayer, struct entvars_s *, float, Vector &, TraceResult *, int> IReGameHookRegistry_CBasePlayer_TraceAttack;
// CBasePlayer::TakeDamage hook
typedef IHookChainClass<BOOL, class CBasePlayer, struct entvars_s *, struct entvars_s *, float&, int> IReGameHook_CBasePlayer_TakeDamage;
typedef IHookChainRegistryClass<BOOL, class CBasePlayer, struct entvars_s *, struct entvars_s *, float&, int> IReGameHookRegistry_CBasePlayer_TakeDamage;
// CBasePlayer::TakeHealth hook
typedef IHookChainClass<BOOL, class CBasePlayer, float, int> IReGameHook_CBasePlayer_TakeHealth;
typedef IHookChainRegistryClass<BOOL, class CBasePlayer, float, int> IReGameHookRegistry_CBasePlayer_TakeHealth;
// CBasePlayer::Killed hook
typedef IVoidHookChainClass<class CBasePlayer, struct entvars_s *, int> IReGameHook_CBasePlayer_Killed;
typedef IVoidHookChainRegistryClass<class CBasePlayer, struct entvars_s *, int> IReGameHookRegistry_CBasePlayer_Killed;
// CBasePlayer::AddPoints hook
typedef IVoidHookChainClass<class CBasePlayer, int, BOOL> IReGameHook_CBasePlayer_AddPoints;
typedef IVoidHookChainRegistryClass<class CBasePlayer, int, BOOL> IReGameHookRegistry_CBasePlayer_AddPoints;
// CBasePlayer::AddPointsToTeam hook
typedef IVoidHookChainClass<class CBasePlayer, int, BOOL> IReGameHook_CBasePlayer_AddPointsToTeam;
typedef IVoidHookChainRegistryClass<class CBasePlayer, int, BOOL> IReGameHookRegistry_CBasePlayer_AddPointsToTeam;
// CBasePlayer::AddPlayerItem hook
typedef IHookChainClass<BOOL, class CBasePlayer, class CBasePlayerItem *> IReGameHook_CBasePlayer_AddPlayerItem;
typedef IHookChainRegistryClass<BOOL, class CBasePlayer, class CBasePlayerItem *> IReGameHookRegistry_CBasePlayer_AddPlayerItem;
// CBasePlayer::RemovePlayerItem hook
typedef IHookChainClass<BOOL, class CBasePlayer, class CBasePlayerItem *> IReGameHook_CBasePlayer_RemovePlayerItem;
typedef IHookChainRegistryClass<BOOL, class CBasePlayer, class CBasePlayerItem *> IReGameHookRegistry_CBasePlayer_RemovePlayerItem;
// CBasePlayer::GiveAmmo hook
typedef IHookChainClass<int, class CBasePlayer, int , char *, int> IReGameHook_CBasePlayer_GiveAmmo;
typedef IHookChainRegistryClass<int, class CBasePlayer, int , char *, int> IReGameHookRegistry_CBasePlayer_GiveAmmo;
// CBasePlayer::ResetMaxSpeed hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_ResetMaxSpeed;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_ResetMaxSpeed;
// CBasePlayer::Jump hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_Jump;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_Jump;
// CBasePlayer::Duck hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_Duck;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_Duck;
// CBasePlayer::PreThink hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_PreThink;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_PreThink;
// CBasePlayer::PostThink hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_PostThink;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_PostThink;
// CBasePlayer::UpdateClientData hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_UpdateClientData;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_UpdateClientData;
// CBasePlayer::ImpulseCommands hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_ImpulseCommands;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_ImpulseCommands;
// CBasePlayer::RoundRespawn hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_RoundRespawn;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_RoundRespawn;
// CBasePlayer::Blind hook
typedef IVoidHookChainClass<class CBasePlayer, float, float, float, int> IReGameHook_CBasePlayer_Blind;
typedef IVoidHookChainRegistryClass<class CBasePlayer, float, float, float, int> IReGameHookRegistry_CBasePlayer_Blind;
// CBasePlayer::Observer_IsValidTarget hook
typedef IHookChainClass<class CBasePlayer *, class CBasePlayer, int, bool> IReGameHook_CBasePlayer_Observer_IsValidTarget;
typedef IHookChainRegistryClass<class CBasePlayer *, class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget;
// CBasePlayer::SetAnimation hook
typedef IVoidHookChainClass<class CBasePlayer, PLAYER_ANIM> IReGameHook_CBasePlayer_SetAnimation;
typedef IVoidHookChainRegistryClass<class CBasePlayer, PLAYER_ANIM> IReGameHookRegistry_CBasePlayer_SetAnimation;
// CBasePlayer::GiveDefaultItems hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_GiveDefaultItems;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_GiveDefaultItems;
// CBasePlayer::GiveNamedItem hook
typedef IHookChainClass<class CBaseEntity *, class CBasePlayer, const char *> IReGameHook_CBasePlayer_GiveNamedItem;
typedef IHookChainRegistryClass<class CBaseEntity *, class CBasePlayer, const char *> IReGameHookRegistry_CBasePlayer_GiveNamedItem;
// CBasePlayer::AddAccount hook
typedef IVoidHookChainClass<class CBasePlayer, int, RewardType, bool> IReGameHook_CBasePlayer_AddAccount;
typedef IVoidHookChainRegistryClass<class CBasePlayer, int, RewardType, bool> IReGameHookRegistry_CBasePlayer_AddAccount;
// CBasePlayer::GiveShield hook
typedef IVoidHookChainClass<class CBasePlayer, bool> IReGameHook_CBasePlayer_GiveShield;
typedef IVoidHookChainRegistryClass<class CBasePlayer, bool> IReGameHookRegistry_CBasePlayer_GiveShield;
// CBasePlayer:SetClientUserInfoModel hook
typedef IVoidHookChainClass<class CBasePlayer, char *, char *> IReGameHook_CBasePlayer_SetClientUserInfoModel;
typedef IVoidHookChainRegistryClass<class CBasePlayer, char *, char *> IReGameHookRegistry_CBasePlayer_SetClientUserInfoModel;
// CBasePlayer:SetClientUserInfoName hook
typedef IHookChainClass<bool, class CBasePlayer, char *, char *> IReGameHook_CBasePlayer_SetClientUserInfoName;
typedef IHookChainRegistryClass<bool, class CBasePlayer, char *, char *> IReGameHookRegistry_CBasePlayer_SetClientUserInfoName;
// CBasePlayer::HasRestrictItem hook
typedef IHookChainClass<bool, class CBasePlayer, ItemID, ItemRestType> IReGameHook_CBasePlayer_HasRestrictItem;
typedef IHookChainRegistryClass<bool, class CBasePlayer, ItemID, ItemRestType> IReGameHookRegistry_CBasePlayer_HasRestrictItem;
// CBasePlayer::DropPlayerItem hook
typedef IVoidHookChainClass<class CBasePlayer, const char *> IReGameHook_CBasePlayer_DropPlayerItem;
typedef IVoidHookChainRegistryClass<class CBasePlayer, const char *> IReGameHookRegistry_CBasePlayer_DropPlayerItem;
// CBasePlayer::DropShield hook
typedef IVoidHookChainClass<class CBasePlayer, bool> IReGameHook_CBasePlayer_DropShield;
typedef IVoidHookChainRegistryClass<class CBasePlayer, bool> IReGameHookRegistry_CBasePlayer_DropShield;
// CBasePlayer::OnSpawnEquip hook
typedef IVoidHookChainClass<class CBasePlayer, bool, bool> IReGameHook_CBasePlayer_OnSpawnEquip;
typedef IVoidHookChainRegistryClass<class CBasePlayer, bool, bool> IReGameHookRegistry_CBasePlayer_OnSpawnEquip;
// CBasePlayer::Radio hook
typedef IVoidHookChainClass<class CBasePlayer, const char *, const char *, short, bool> IReGameHook_CBasePlayer_Radio;
typedef IVoidHookChainRegistryClass<class CBasePlayer, const char *, const char *, short, bool> IReGameHookRegistry_CBasePlayer_Radio;
// CBasePlayer::Disappear hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_Disappear;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_Disappear;
// CBasePlayer::MakeVIP hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_MakeVIP;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_MakeVIP;
// CBasePlayer::MakeBomber hook
typedef IHookChainClass<bool, class CBasePlayer> IReGameHook_CBasePlayer_MakeBomber;
typedef IHookChainRegistryClass<bool, class CBasePlayer> IReGameHookRegistry_CBasePlayer_MakeBomber;
// CBasePlayer::StartObserver hook
typedef IVoidHookChainClass<class CBasePlayer, Vector &, Vector &> IReGameHook_CBasePlayer_StartObserver;
typedef IVoidHookChainRegistryClass<class CBasePlayer, Vector &, Vector &> IReGameHookRegistry_CBasePlayer_StartObserver;
// CBasePlayer::GetIntoGame hook
typedef IHookChainClass<bool, class CBasePlayer> IReGameHook_CBasePlayer_GetIntoGame;
typedef IHookChainRegistryClass<bool, class CBasePlayer> IReGameHookRegistry_CBasePlayer_GetIntoGame;
// CBaseAnimating::ResetSequenceInfo hook
typedef IVoidHookChainClass<class CBaseAnimating> IReGameHook_CBaseAnimating_ResetSequenceInfo;
typedef IVoidHookChainRegistryClass<class CBaseAnimating> IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo;
// GetForceCamera hook
typedef IHookChain<int, class CBasePlayer *> IReGameHook_GetForceCamera;
typedef IHookChainRegistry<int, class CBasePlayer *> IReGameHookRegistry_GetForceCamera;
// PlayerBlind hook
typedef IVoidHookChain<class CBasePlayer *, struct entvars_s *, struct entvars_s *, float, float, int, Vector &> IReGameHook_PlayerBlind;
typedef IVoidHookChainRegistry<class CBasePlayer *, struct entvars_s *, struct entvars_s *, float, float, int, Vector &> IReGameHookRegistry_PlayerBlind;
// RadiusFlash_TraceLine hook
typedef IVoidHookChain<class CBasePlayer *, struct entvars_s *, struct entvars_s *, Vector &, Vector &, TraceResult *> IReGameHook_RadiusFlash_TraceLine;
typedef IVoidHookChainRegistry<class CBasePlayer *, struct entvars_s *, struct entvars_s *, Vector &, Vector &, TraceResult *> IReGameHookRegistry_RadiusFlash_TraceLine;
// RoundEnd hook
typedef IHookChain<bool, int, ScenarioEventEndRound, float> IReGameHook_RoundEnd;
typedef IHookChainRegistry<bool, int, ScenarioEventEndRound, float> IReGameHookRegistry_RoundEnd;
// InstallGameRules hook
typedef IHookChain<class CGameRules *> IReGameHook_InstallGameRules;
typedef IHookChainRegistry<class CGameRules *> IReGameHookRegistry_InstallGameRules;
// PM_Init hook
typedef IVoidHookChain<struct playermove_s *> IReGameHook_PM_Init;
typedef IVoidHookChainRegistry<struct playermove_s *> IReGameHookRegistry_PM_Init;
// PM_Move hook
typedef IVoidHookChain<struct playermove_s *, int> IReGameHook_PM_Move;
typedef IVoidHookChainRegistry<struct playermove_s *, int> IReGameHookRegistry_PM_Move;
// PM_AirMove hook
typedef IVoidHookChain<int> IReGameHook_PM_AirMove;
typedef IVoidHookChainRegistry<int> IReGameHookRegistry_PM_AirMove;
// HandleMenu_ChooseAppearance hook
typedef IVoidHookChain<class CBasePlayer *, int> IReGameHook_HandleMenu_ChooseAppearance;
typedef IVoidHookChainRegistry<class CBasePlayer *, int> IReGameHookRegistry_HandleMenu_ChooseAppearance;
// HandleMenu_ChooseTeam hook
typedef IHookChain<BOOL, class CBasePlayer *, int> IReGameHook_HandleMenu_ChooseTeam;
typedef IHookChainRegistry<BOOL, class CBasePlayer *, int> IReGameHookRegistry_HandleMenu_ChooseTeam;
// ShowMenu hook
typedef IVoidHookChain<class CBasePlayer *, int, int, BOOL, char *> IReGameHook_ShowMenu;
typedef IVoidHookChainRegistry<class CBasePlayer *, int, int, BOOL, char *> IReGameHookRegistry_ShowMenu;
// ShowVGUIMenu hook
typedef IVoidHookChain<class CBasePlayer *, int, int, char *> IReGameHook_ShowVGUIMenu;
typedef IVoidHookChainRegistry<class CBasePlayer *, int, int, char *> IReGameHookRegistry_ShowVGUIMenu;
// BuyGunAmmo hook
typedef IHookChain<bool, class CBasePlayer *, class CBasePlayerItem *, bool> IReGameHook_BuyGunAmmo;
typedef IHookChainRegistry<bool, class CBasePlayer *, class CBasePlayerItem *, bool> IReGameHookRegistry_BuyGunAmmo;
// BuyWeaponByWeaponID hook
typedef IHookChain<class CBaseEntity *, class CBasePlayer *, WeaponIdType> IReGameHook_BuyWeaponByWeaponID;
typedef IHookChainRegistry<class CBaseEntity *, class CBasePlayer *, WeaponIdType> IReGameHookRegistry_BuyWeaponByWeaponID;
// InternalCommand hook
typedef IVoidHookChain<edict_t *, const char *, const char *> IReGameHook_InternalCommand;
typedef IVoidHookChainRegistry<edict_t *, const char *, const char *> IReGameHookRegistry_InternalCommand;
// CHalfLifeMultiplay::FShouldSwitchWeapon hook
typedef IHookChain<BOOL, class CBasePlayer *, class CBasePlayerItem *> IReGameHook_CSGameRules_FShouldSwitchWeapon;
typedef IHookChainRegistry<BOOL, class CBasePlayer *, class CBasePlayerItem *> IReGameHookRegistry_CSGameRules_FShouldSwitchWeapon;
// CHalfLifeMultiplay::GetNextBestWeapon hook
typedef IHookChain<BOOL, class CBasePlayer *, class CBasePlayerItem *> IReGameHook_CSGameRules_GetNextBestWeapon;
typedef IHookChainRegistry<BOOL, class CBasePlayer *, class CBasePlayerItem *> IReGameHookRegistry_CSGameRules_GetNextBestWeapon;
// CHalfLifeMultiplay::FlPlayerFallDamage hook
typedef IHookChain<float, class CBasePlayer *> IReGameHook_CSGameRules_FlPlayerFallDamage;
typedef IHookChainRegistry<float, class CBasePlayer *> IReGameHookRegistry_CSGameRules_FlPlayerFallDamage;
// CHalfLifeMultiplay::FPlayerCanTakeDamage hook
typedef IHookChain<BOOL, class CBasePlayer *, CBaseEntity *> IReGameHook_CSGameRules_FPlayerCanTakeDamage;
typedef IHookChainRegistry<BOOL, class CBasePlayer *, CBaseEntity *> IReGameHookRegistry_CSGameRules_FPlayerCanTakeDamage;
// CHalfLifeMultiplay::PlayerSpawn hook
typedef IVoidHookChain<class CBasePlayer *> IReGameHook_CSGameRules_PlayerSpawn;
typedef IVoidHookChainRegistry<class CBasePlayer *> IReGameHookRegistry_CSGameRules_PlayerSpawn;
// CHalfLifeMultiplay::FPlayerCanRespawn hook
typedef IHookChain<BOOL, class CBasePlayer *> IReGameHook_CSGameRules_FPlayerCanRespawn;
typedef IHookChainRegistry<BOOL, class CBasePlayer *> IReGameHookRegistry_CSGameRules_FPlayerCanRespawn;
// CHalfLifeMultiplay::GetPlayerSpawnSpot hook
typedef IHookChain<struct edict_s *, class CBasePlayer *> IReGameHook_CSGameRules_GetPlayerSpawnSpot;
typedef IHookChainRegistry<struct edict_s *, class CBasePlayer *> IReGameHookRegistry_CSGameRules_GetPlayerSpawnSpot;
// CHalfLifeMultiplay::ClientUserInfoChanged hook
typedef IVoidHookChain<class CBasePlayer *, char *> IReGameHook_CSGameRules_ClientUserInfoChanged;
typedef IVoidHookChainRegistry<class CBasePlayer *, char *> IReGameHookRegistry_CSGameRules_ClientUserInfoChanged;
// CHalfLifeMultiplay::PlayerKilled hook
typedef IVoidHookChain<class CBasePlayer *, struct entvars_s *, struct entvars_s *> IReGameHook_CSGameRules_PlayerKilled;
typedef IVoidHookChainRegistry<class CBasePlayer *, struct entvars_s *, struct entvars_s *> IReGameHookRegistry_CSGameRules_PlayerKilled;
// CHalfLifeMultiplay::DeathNotice hook
typedef IVoidHookChain<class CBasePlayer *, struct entvars_s *, struct entvars_s *> IReGameHook_CSGameRules_DeathNotice;
typedef IVoidHookChainRegistry<class CBasePlayer *, struct entvars_s *, struct entvars_s *> IReGameHookRegistry_CSGameRules_DeathNotice;
// CHalfLifeMultiplay::CanHavePlayerItem hook
typedef IHookChain<BOOL, class CBasePlayer *, class CBasePlayerItem *> IReGameHook_CSGameRules_CanHavePlayerItem;
typedef IHookChainRegistry<BOOL, class CBasePlayer *, class CBasePlayerItem *> IReGameHookRegistry_CSGameRules_CanHavePlayerItem;
// CHalfLifeMultiplay::DeadPlayerWeapons hook
typedef IHookChain<int, class CBasePlayer *> IReGameHook_CSGameRules_DeadPlayerWeapons;
typedef IHookChainRegistry<int, class CBasePlayer *> IReGameHookRegistry_CSGameRules_DeadPlayerWeapons;
// CHalfLifeMultiplay::ServerDeactivate hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_ServerDeactivate;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_ServerDeactivate;
// CHalfLifeMultiplay::CheckMapConditions hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_CheckMapConditions;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_CheckMapConditions;
// CHalfLifeMultiplay::CleanUpMap hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_CleanUpMap;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_CleanUpMap;
// CHalfLifeMultiplay::RestartRound hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_RestartRound;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_RestartRound;
// CHalfLifeMultiplay::CheckWinConditions hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_CheckWinConditions;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_CheckWinConditions;
// CHalfLifeMultiplay::RemoveGuns hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_RemoveGuns;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_RemoveGuns;
// CHalfLifeMultiplay::GiveC4 hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_GiveC4;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_GiveC4;
// CHalfLifeMultiplay::ChangeLevel hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_ChangeLevel;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_ChangeLevel;
// CHalfLifeMultiplay::GoToIntermission hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_GoToIntermission;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_GoToIntermission;
// CHalfLifeMultiplay::BalanceTeams hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_BalanceTeams;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_BalanceTeams;
// CHalfLifeMultiplay::OnRoundFreezeEnd hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_OnRoundFreezeEnd;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_OnRoundFreezeEnd;
// PM_UpdateStepSound hook
typedef IVoidHookChain<> IReGameHook_PM_UpdateStepSound;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_PM_UpdateStepSound;
class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
// CBasePlayer virtual
virtual IReGameHookRegistry_CBasePlayer_Spawn* CBasePlayer_Spawn() = 0;
virtual IReGameHookRegistry_CBasePlayer_Precache* CBasePlayer_Precache() = 0;
virtual IReGameHookRegistry_CBasePlayer_ObjectCaps* CBasePlayer_ObjectCaps() = 0;
virtual IReGameHookRegistry_CBasePlayer_Classify* CBasePlayer_Classify() = 0;
virtual IReGameHookRegistry_CBasePlayer_TraceAttack* CBasePlayer_TraceAttack() = 0;
virtual IReGameHookRegistry_CBasePlayer_TakeDamage* CBasePlayer_TakeDamage() = 0;
virtual IReGameHookRegistry_CBasePlayer_TakeHealth* CBasePlayer_TakeHealth() = 0;
virtual IReGameHookRegistry_CBasePlayer_Killed* CBasePlayer_Killed() = 0;
virtual IReGameHookRegistry_CBasePlayer_AddPoints* CBasePlayer_AddPoints() = 0;
virtual IReGameHookRegistry_CBasePlayer_AddPointsToTeam* CBasePlayer_AddPointsToTeam() = 0;
virtual IReGameHookRegistry_CBasePlayer_AddPlayerItem* CBasePlayer_AddPlayerItem() = 0;
virtual IReGameHookRegistry_CBasePlayer_RemovePlayerItem* CBasePlayer_RemovePlayerItem() = 0;
virtual IReGameHookRegistry_CBasePlayer_GiveAmmo* CBasePlayer_GiveAmmo() = 0;
virtual IReGameHookRegistry_CBasePlayer_ResetMaxSpeed* CBasePlayer_ResetMaxSpeed() = 0;
virtual IReGameHookRegistry_CBasePlayer_Jump* CBasePlayer_Jump() = 0;
virtual IReGameHookRegistry_CBasePlayer_Duck* CBasePlayer_Duck() = 0;
virtual IReGameHookRegistry_CBasePlayer_PreThink* CBasePlayer_PreThink() = 0;
virtual IReGameHookRegistry_CBasePlayer_PostThink* CBasePlayer_PostThink() = 0;
virtual IReGameHookRegistry_CBasePlayer_UpdateClientData* CBasePlayer_UpdateClientData() = 0;
virtual IReGameHookRegistry_CBasePlayer_ImpulseCommands* CBasePlayer_ImpulseCommands() = 0;
virtual IReGameHookRegistry_CBasePlayer_RoundRespawn* CBasePlayer_RoundRespawn() = 0;
virtual IReGameHookRegistry_CBasePlayer_Blind* CBasePlayer_Blind() = 0;
virtual IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget* CBasePlayer_Observer_IsValidTarget() = 0;
virtual IReGameHookRegistry_CBasePlayer_SetAnimation* CBasePlayer_SetAnimation() = 0;
virtual IReGameHookRegistry_CBasePlayer_GiveDefaultItems* CBasePlayer_GiveDefaultItems() = 0;
virtual IReGameHookRegistry_CBasePlayer_GiveNamedItem* CBasePlayer_GiveNamedItem() = 0;
virtual IReGameHookRegistry_CBasePlayer_AddAccount* CBasePlayer_AddAccount() = 0;
virtual IReGameHookRegistry_CBasePlayer_GiveShield* CBasePlayer_GiveShield() = 0;
virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoModel* CBasePlayer_SetClientUserInfoModel() = 0;
virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoName* CBasePlayer_SetClientUserInfoName() = 0;
virtual IReGameHookRegistry_CBasePlayer_HasRestrictItem* CBasePlayer_HasRestrictItem() = 0;
virtual IReGameHookRegistry_CBasePlayer_DropPlayerItem* CBasePlayer_DropPlayerItem() = 0;
virtual IReGameHookRegistry_CBasePlayer_DropShield* CBasePlayer_DropShield() = 0;
virtual IReGameHookRegistry_CBasePlayer_OnSpawnEquip* CBasePlayer_OnSpawnEquip() = 0;
virtual IReGameHookRegistry_CBasePlayer_Radio* CBasePlayer_Radio() = 0;
virtual IReGameHookRegistry_CBasePlayer_Disappear* CBasePlayer_Disappear() = 0;
virtual IReGameHookRegistry_CBasePlayer_MakeVIP* CBasePlayer_MakeVIP() = 0;
virtual IReGameHookRegistry_CBasePlayer_MakeBomber* CBasePlayer_MakeBomber() = 0;
virtual IReGameHookRegistry_CBasePlayer_StartObserver* CBasePlayer_StartObserver() = 0;
virtual IReGameHookRegistry_CBasePlayer_GetIntoGame* CBasePlayer_GetIntoGame() = 0;
virtual IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CBaseAnimating_ResetSequenceInfo() = 0;
virtual IReGameHookRegistry_GetForceCamera* GetForceCamera() = 0;
virtual IReGameHookRegistry_PlayerBlind* PlayerBlind() = 0;
virtual IReGameHookRegistry_RadiusFlash_TraceLine* RadiusFlash_TraceLine() = 0;
virtual IReGameHookRegistry_RoundEnd* RoundEnd() = 0;
virtual IReGameHookRegistry_InstallGameRules* InstallGameRules() = 0;
virtual IReGameHookRegistry_PM_Init* PM_Init() = 0;
virtual IReGameHookRegistry_PM_Move* PM_Move() = 0;
virtual IReGameHookRegistry_PM_AirMove* PM_AirMove() = 0;
virtual IReGameHookRegistry_HandleMenu_ChooseAppearance* HandleMenu_ChooseAppearance() = 0;
virtual IReGameHookRegistry_HandleMenu_ChooseTeam* HandleMenu_ChooseTeam() = 0;
virtual IReGameHookRegistry_ShowMenu* ShowMenu() = 0;
virtual IReGameHookRegistry_ShowVGUIMenu* ShowVGUIMenu() = 0;
virtual IReGameHookRegistry_BuyGunAmmo* BuyGunAmmo() = 0;
virtual IReGameHookRegistry_BuyWeaponByWeaponID* BuyWeaponByWeaponID() = 0;
virtual IReGameHookRegistry_InternalCommand* InternalCommand() = 0;
virtual IReGameHookRegistry_CSGameRules_FShouldSwitchWeapon* CSGameRules_FShouldSwitchWeapon() = 0;
virtual IReGameHookRegistry_CSGameRules_GetNextBestWeapon* CSGameRules_GetNextBestWeapon() = 0;
virtual IReGameHookRegistry_CSGameRules_FlPlayerFallDamage* CSGameRules_FlPlayerFallDamage() = 0;
virtual IReGameHookRegistry_CSGameRules_FPlayerCanTakeDamage* CSGameRules_FPlayerCanTakeDamage() = 0;
virtual IReGameHookRegistry_CSGameRules_PlayerSpawn* CSGameRules_PlayerSpawn() = 0;
virtual IReGameHookRegistry_CSGameRules_FPlayerCanRespawn* CSGameRules_FPlayerCanRespawn() = 0;
virtual IReGameHookRegistry_CSGameRules_GetPlayerSpawnSpot* CSGameRules_GetPlayerSpawnSpot() = 0;
virtual IReGameHookRegistry_CSGameRules_ClientUserInfoChanged* CSGameRules_ClientUserInfoChanged() = 0;
virtual IReGameHookRegistry_CSGameRules_PlayerKilled* CSGameRules_PlayerKilled() = 0;
virtual IReGameHookRegistry_CSGameRules_DeathNotice* CSGameRules_DeathNotice() = 0;
virtual IReGameHookRegistry_CSGameRules_CanHavePlayerItem* CSGameRules_CanHavePlayerItem() = 0;
virtual IReGameHookRegistry_CSGameRules_DeadPlayerWeapons* CSGameRules_DeadPlayerWeapons() = 0;
virtual IReGameHookRegistry_CSGameRules_ServerDeactivate* CSGameRules_ServerDeactivate() = 0;
virtual IReGameHookRegistry_CSGameRules_CheckMapConditions* CSGameRules_CheckMapConditions() = 0;
virtual IReGameHookRegistry_CSGameRules_CleanUpMap* CSGameRules_CleanUpMap() = 0;
virtual IReGameHookRegistry_CSGameRules_RestartRound* CSGameRules_RestartRound() = 0;
virtual IReGameHookRegistry_CSGameRules_CheckWinConditions* CSGameRules_CheckWinConditions() = 0;
virtual IReGameHookRegistry_CSGameRules_RemoveGuns* CSGameRules_RemoveGuns() = 0;
virtual IReGameHookRegistry_CSGameRules_GiveC4* CSGameRules_GiveC4() = 0;
virtual IReGameHookRegistry_CSGameRules_ChangeLevel* CSGameRules_ChangeLevel() = 0;
virtual IReGameHookRegistry_CSGameRules_GoToIntermission* CSGameRules_GoToIntermission() = 0;
virtual IReGameHookRegistry_CSGameRules_BalanceTeams* CSGameRules_BalanceTeams() = 0;
virtual IReGameHookRegistry_CSGameRules_OnRoundFreezeEnd* CSGameRules_OnRoundFreezeEnd() = 0;
virtual IReGameHookRegistry_PM_UpdateStepSound* PM_UpdateStepSound() = 0;
};
struct ReGameFuncs_t {
struct edict_s *(*CREATE_NAMED_ENTITY2)(string_t iClass);
void (*ChangeString)(char *&dest, const char *source);
void (*RadiusDamage)(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType);
void (*ClearMultiDamage)();
void (*ApplyMultiDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker);
void (*AddMultiDamage)(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType);
class CBaseEntity *(*UTIL_FindEntityByString)(class CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue);
void (*AddEntityHashValue)(entvars_t *pev, const char *value, hash_types_e fieldType);
void (*RemoveEntityHashValue)(entvars_t *pev, const char *value, hash_types_e fieldType);
int (*Cmd_Argc)();
const char *(*Cmd_Argv)(int i);
};
class IReGameApi {
public:
virtual ~IReGameApi() {}
virtual int GetMajorVersion() = 0;
virtual int GetMinorVersion() = 0;
virtual const ReGameFuncs_t* GetFuncs() = 0;
virtual IReGameHookchains* GetHookchains() = 0;
virtual class CGameRules* GetGameRules() = 0;
virtual struct WeaponInfoStruct* GetWeaponInfo(int weaponID) = 0;
virtual struct WeaponInfoStruct* GetWeaponInfo(const char* weaponName) = 0;
virtual struct playermove_s* GetPlayerMove() = 0;
virtual struct WeaponSlotInfo* GetWeaponSlot(WeaponIdType weaponID) = 0;
virtual struct WeaponSlotInfo* GetWeaponSlot(const char* weaponName) = 0;
virtual struct ItemInfo* GetItemInfo(WeaponIdType weaponID) = 0;
virtual struct AmmoInfo* GetAmmoInfo(AmmoType ammoID) = 0;
};
#define VRE_GAMEDLL_API_VERSION "VRE_GAMEDLL_API_VERSION001"

View File

@ -0,0 +1,740 @@
/*
*
* 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
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* 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
* 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
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
// custom enum
enum ArmorType
{
ARMOR_NONE, // no armor
ARMOR_KEVLAR, // body vest only
ARMOR_VESTHELM, // vest and helmet
};
enum ArmouryItemPack
{
ARMOURY_MP5NAVY,
ARMOURY_TMP,
ARMOURY_P90,
ARMOURY_MAC10,
ARMOURY_AK47,
ARMOURY_SG552,
ARMOURY_M4A1,
ARMOURY_AUG,
ARMOURY_SCOUT,
ARMOURY_G3SG1,
ARMOURY_AWP,
ARMOURY_M3,
ARMOURY_XM1014,
ARMOURY_M249,
ARMOURY_FLASHBANG,
ARMOURY_HEGRENADE,
ARMOURY_KEVLAR,
ARMOURY_ASSAULT,
ARMOURY_SMOKEGRENADE,
ARMOURY_GLOCK18,
ARMOURY_USP,
ARMOURY_ELITE,
ARMOURY_FIVESEVEN,
ARMOURY_P228,
ARMOURY_DEAGLE,
ARMOURY_FAMAS,
ARMOURY_SG550,
ARMOURY_GALIL,
ARMOURY_UMP45,
ARMOURY_SHIELD
};
struct AmmoInfo
{
const char *pszName;
int iId;
};
struct MULTIDAMAGE
{
CBaseEntity *pEntity;
float amount;
int type;
};
enum ItemRestType
{
ITEM_TYPE_BUYING, // when a player buying items
ITEM_TYPE_TOUCHED, // when the player touches with a weaponbox or armoury_entity
ITEM_TYPE_EQUIPPED // when a entity game_player_equip gives item to player or default item's on player spawn
};
// constant items
#define ITEM_ID_ANTIDOTE 2
#define ITEM_ID_SECURITY 3
enum ItemID
{
ITEM_NONE = -1,
ITEM_SHIELDGUN,
ITEM_P228,
ITEM_GLOCK,
ITEM_SCOUT,
ITEM_HEGRENADE,
ITEM_XM1014,
ITEM_C4,
ITEM_MAC10,
ITEM_AUG,
ITEM_SMOKEGRENADE,
ITEM_ELITE,
ITEM_FIVESEVEN,
ITEM_UMP45,
ITEM_SG550,
ITEM_GALIL,
ITEM_FAMAS,
ITEM_USP,
ITEM_GLOCK18,
ITEM_AWP,
ITEM_MP5N,
ITEM_M249,
ITEM_M3,
ITEM_M4A1,
ITEM_TMP,
ITEM_G3SG1,
ITEM_FLASHBANG,
ITEM_DEAGLE,
ITEM_SG552,
ITEM_AK47,
ITEM_KNIFE,
ITEM_P90,
ITEM_NVG,
ITEM_DEFUSEKIT,
ITEM_KEVLAR,
ITEM_ASSAULT,
ITEM_LONGJUMP,
ITEM_SODACAN,
ITEM_HEALTHKIT,
ITEM_ANTIDOTE,
ITEM_BATTERY
};
// custom enum
enum RewardType
{
RT_NONE,
RT_ROUND_BONUS,
RT_PLAYER_RESET,
RT_PLAYER_JOIN,
RT_PLAYER_SPEC_JOIN,
RT_PLAYER_BOUGHT_SOMETHING,
RT_HOSTAGE_TOOK,
RT_HOSTAGE_RESCUED,
RT_HOSTAGE_DAMAGED,
RT_HOSTAGE_KILLED,
RT_TEAMMATES_KILLED,
RT_ENEMY_KILLED,
RT_INTO_GAME,
RT_VIP_KILLED,
RT_VIP_RESCUED_MYSELF
};
enum PLAYER_ANIM
{
PLAYER_IDLE,
PLAYER_WALK,
PLAYER_JUMP,
PLAYER_SUPERJUMP,
PLAYER_DIE,
PLAYER_ATTACK1,
PLAYER_ATTACK2,
PLAYER_FLINCH,
PLAYER_LARGE_FLINCH,
PLAYER_RELOAD,
PLAYER_HOLDBOMB
};
enum TeamName
{
UNASSIGNED,
TERRORIST,
CT,
SPECTATOR,
};
enum ModelName
{
MODEL_UNASSIGNED,
MODEL_URBAN,
MODEL_TERROR,
MODEL_LEET,
MODEL_ARCTIC,
MODEL_GSG9,
MODEL_GIGN,
MODEL_SAS,
MODEL_GUERILLA,
MODEL_VIP,
MODEL_MILITIA,
MODEL_SPETSNAZ,
MODEL_AUTO
};
enum JoinState
{
JOINED,
SHOWLTEXT,
READINGLTEXT,
SHOWTEAMSELECT,
PICKINGTEAM,
GETINTOGAME
};
enum TrackCommands
{
CMD_SAY = 0,
CMD_SAYTEAM,
CMD_FULLUPDATE,
CMD_VOTE,
CMD_VOTEMAP,
CMD_LISTMAPS,
CMD_LISTPLAYERS,
CMD_NIGHTVISION,
COMMANDS_TO_TRACK,
};
struct RebuyStruct
{
int m_primaryWeapon;
int m_primaryAmmo;
int m_secondaryWeapon;
int m_secondaryAmmo;
int m_heGrenade;
int m_flashbang;
int m_smokeGrenade;
int m_defuser;
int m_nightVision;
ArmorType m_armor;
};
enum ThrowDirection
{
THROW_NONE,
THROW_FORWARD,
THROW_BACKWARD,
THROW_HITVEL,
THROW_BOMB,
THROW_GRENADE,
THROW_HITVEL_MINUS_AIRVEL
};
enum sbar_data
{
SBAR_ID_TARGETTYPE = 1,
SBAR_ID_TARGETNAME,
SBAR_ID_TARGETHEALTH,
SBAR_END
};
enum
{
WINSTATUS_CTS = 1,
WINSTATUS_TERRORISTS,
WINSTATUS_DRAW,
};
// custom enum
// used for EndRoundMessage() logged messages
enum ScenarioEventEndRound
{
ROUND_NONE,
ROUND_TARGET_BOMB,
ROUND_VIP_ESCAPED,
ROUND_VIP_ASSASSINATED,
ROUND_TERRORISTS_ESCAPED,
ROUND_CTS_PREVENT_ESCAPE,
ROUND_ESCAPING_TERRORISTS_NEUTRALIZED,
ROUND_BOMB_DEFUSED,
ROUND_CTS_WIN,
ROUND_TERRORISTS_WIN,
ROUND_END_DRAW,
ROUND_ALL_HOSTAGES_RESCUED,
ROUND_TARGET_SAVED,
ROUND_HOSTAGE_NOT_RESCUED,
ROUND_TERRORISTS_NOT_ESCAPED,
ROUND_VIP_NOT_ESCAPED,
ROUND_GAME_COMMENCE,
ROUND_GAME_RESTART,
ROUND_GAME_OVER
};
enum RewardRules
{
RR_CTS_WIN,
RR_TERRORISTS_WIN,
RR_TARGET_BOMB,
RR_VIP_ESCAPED,
RR_VIP_ASSASSINATED,
RR_TERRORISTS_ESCAPED,
RR_CTS_PREVENT_ESCAPE,
RR_ESCAPING_TERRORISTS_NEUTRALIZED,
RR_BOMB_DEFUSED,
RR_BOMB_PLANTED,
RR_BOMB_EXPLODED,
RR_ALL_HOSTAGES_RESCUED,
RR_TARGET_BOMB_SAVED,
RR_HOSTAGE_NOT_RESCUED,
RR_VIP_NOT_ESCAPED,
RR_LOSER_BONUS_DEFAULT,
RR_LOSER_BONUS_MIN,
RR_LOSER_BONUS_MAX,
RR_LOSER_BONUS_ADD,
RR_RESCUED_HOSTAGE,
RR_TOOK_HOSTAGE_ACC,
RR_TOOK_HOSTAGE,
RR_END
};
// custom enum
enum RewardAccount
{
REWARD_TARGET_BOMB = 3500,
REWARD_VIP_ESCAPED = 3500,
REWARD_VIP_ASSASSINATED = 3250,
REWARD_TERRORISTS_ESCAPED = 3150,
REWARD_CTS_PREVENT_ESCAPE = 3500,
REWARD_ESCAPING_TERRORISTS_NEUTRALIZED = 3250,
REWARD_BOMB_DEFUSED = 3250,
REWARD_BOMB_PLANTED = 800,
REWARD_BOMB_EXPLODED = 3250,
REWARD_CTS_WIN = 3000,
REWARD_TERRORISTS_WIN = 3000,
REWARD_ALL_HOSTAGES_RESCUED = 2500,
// the end round was by the expiration time
REWARD_TARGET_BOMB_SAVED = 3250,
REWARD_HOSTAGE_NOT_RESCUED = 3250,
REWARD_VIP_NOT_ESCAPED = 3250,
// loser bonus
REWARD_LOSER_BONUS_DEFAULT = 1400,
REWARD_LOSER_BONUS_MIN = 1500,
REWARD_LOSER_BONUS_MAX = 3000,
REWARD_LOSER_BONUS_ADD = 500,
REWARD_RESCUED_HOSTAGE = 750,
REWARD_KILLED_ENEMY = 300,
REWARD_KILLED_VIP = 2500,
REWARD_VIP_HAVE_SELF_RESCUED = 2500,
REWARD_TAKEN_HOSTAGE = 1000,
REWARD_TOOK_HOSTAGE_ACC = 100,
REWARD_TOOK_HOSTAGE = 150,
};
// custom enum
enum PaybackForBadThing
{
PAYBACK_FOR_KILLED_TEAMMATES = -3300,
};
// custom enum
enum InfoMapBuyParam
{
BUYING_EVERYONE = 0,
BUYING_ONLY_CTS,
BUYING_ONLY_TERRORISTS,
BUYING_NO_ONE,
};
// weapon respawning return codes
enum
{
GR_NONE = 0,
GR_WEAPON_RESPAWN_YES,
GR_WEAPON_RESPAWN_NO,
GR_AMMO_RESPAWN_YES,
GR_AMMO_RESPAWN_NO,
GR_ITEM_RESPAWN_YES,
GR_ITEM_RESPAWN_NO,
GR_PLR_DROP_GUN_ALL,
GR_PLR_DROP_GUN_ACTIVE,
GR_PLR_DROP_GUN_NO,
GR_PLR_DROP_AMMO_ALL,
GR_PLR_DROP_AMMO_ACTIVE,
GR_PLR_DROP_AMMO_NO,
};
// custom enum
enum
{
SCENARIO_BLOCK_TIME_EXPRIRED = (1 << 0), // flag "a"
SCENARIO_BLOCK_NEED_PLAYERS = (1 << 1), // flag "b"
SCENARIO_BLOCK_VIP_ESCAPE = (1 << 2), // flag "c"
SCENARIO_BLOCK_PRISON_ESCAPE = (1 << 3), // flag "d"
SCENARIO_BLOCK_BOMB = (1 << 4), // flag "e"
SCENARIO_BLOCK_TEAM_EXTERMINATION = (1 << 5), // flag "f"
SCENARIO_BLOCK_HOSTAGE_RESCUE = (1 << 6), // flag "g"
};
// Player relationship return codes
enum
{
GR_NOTTEAMMATE = 0,
GR_TEAMMATE,
GR_ENEMY,
GR_ALLY,
GR_NEUTRAL,
};
enum WeaponIdType
{
WEAPON_NONE,
WEAPON_P228,
WEAPON_GLOCK,
WEAPON_SCOUT,
WEAPON_HEGRENADE,
WEAPON_XM1014,
WEAPON_C4,
WEAPON_MAC10,
WEAPON_AUG,
WEAPON_SMOKEGRENADE,
WEAPON_ELITE,
WEAPON_FIVESEVEN,
WEAPON_UMP45,
WEAPON_SG550,
WEAPON_GALIL,
WEAPON_FAMAS,
WEAPON_USP,
WEAPON_GLOCK18,
WEAPON_AWP,
WEAPON_MP5N,
WEAPON_M249,
WEAPON_M3,
WEAPON_M4A1,
WEAPON_TMP,
WEAPON_G3SG1,
WEAPON_FLASHBANG,
WEAPON_DEAGLE,
WEAPON_SG552,
WEAPON_AK47,
WEAPON_KNIFE,
WEAPON_P90,
WEAPON_SHIELDGUN = 99
};
enum AutoBuyClassType
{
AUTOBUYCLASS_NONE = 0,
AUTOBUYCLASS_PRIMARY = (1 << 0),
AUTOBUYCLASS_SECONDARY = (1 << 1),
AUTOBUYCLASS_AMMO = (1 << 2),
AUTOBUYCLASS_ARMOR = (1 << 3),
AUTOBUYCLASS_DEFUSER = (1 << 4),
AUTOBUYCLASS_PISTOL = (1 << 5),
AUTOBUYCLASS_SMG = (1 << 6),
AUTOBUYCLASS_RIFLE = (1 << 7),
AUTOBUYCLASS_SNIPERRIFLE = (1 << 8),
AUTOBUYCLASS_SHOTGUN = (1 << 9),
AUTOBUYCLASS_MACHINEGUN = (1 << 10),
AUTOBUYCLASS_GRENADE = (1 << 11),
AUTOBUYCLASS_NIGHTVISION = (1 << 12),
AUTOBUYCLASS_SHIELD = (1 << 13),
};
enum AmmoCostType
{
AMMO_338MAG_PRICE = 125,
AMMO_357SIG_PRICE = 50,
AMMO_45ACP_PRICE = 25,
AMMO_50AE_PRICE = 40,
AMMO_556MM_PRICE = 60,
AMMO_57MM_PRICE = 50,
AMMO_762MM_PRICE = 80,
AMMO_9MM_PRICE = 20,
AMMO_BUCKSHOT_PRICE = 65,
};
// custom enum
// the default amount of ammo that comes with each gun when it spawns
enum ClipGiveDefault
{
P228_DEFAULT_GIVE = 13,
GLOCK18_DEFAULT_GIVE = 20,
SCOUT_DEFAULT_GIVE = 10,
HEGRENADE_DEFAULT_GIVE = 1,
XM1014_DEFAULT_GIVE = 7,
C4_DEFAULT_GIVE = 1,
MAC10_DEFAULT_GIVE = 30,
AUG_DEFAULT_GIVE = 30,
SMOKEGRENADE_DEFAULT_GIVE = 1,
ELITE_DEFAULT_GIVE = 30,
FIVESEVEN_DEFAULT_GIVE = 20,
UMP45_DEFAULT_GIVE = 25,
SG550_DEFAULT_GIVE = 30,
GALIL_DEFAULT_GIVE = 35,
FAMAS_DEFAULT_GIVE = 25,
USP_DEFAULT_GIVE = 12,
AWP_DEFAULT_GIVE = 10,
MP5NAVY_DEFAULT_GIVE = 30,
M249_DEFAULT_GIVE = 100,
M3_DEFAULT_GIVE = 8,
M4A1_DEFAULT_GIVE = 30,
TMP_DEFAULT_GIVE = 30,
G3SG1_DEFAULT_GIVE = 20,
FLASHBANG_DEFAULT_GIVE = 1,
DEAGLE_DEFAULT_GIVE = 7,
SG552_DEFAULT_GIVE = 30,
AK47_DEFAULT_GIVE = 30,
/*KNIFE_DEFAULT_GIVE = 1,*/
P90_DEFAULT_GIVE = 50,
};
enum ClipSizeType
{
P228_MAX_CLIP = 13,
GLOCK18_MAX_CLIP = 20,
SCOUT_MAX_CLIP = 10,
XM1014_MAX_CLIP = 7,
MAC10_MAX_CLIP = 30,
AUG_MAX_CLIP = 30,
ELITE_MAX_CLIP = 30,
FIVESEVEN_MAX_CLIP = 20,
UMP45_MAX_CLIP = 25,
SG550_MAX_CLIP = 30,
GALIL_MAX_CLIP = 35,
FAMAS_MAX_CLIP = 25,
USP_MAX_CLIP = 12,
AWP_MAX_CLIP = 10,
MP5N_MAX_CLIP = 30,
M249_MAX_CLIP = 100,
M3_MAX_CLIP = 8,
M4A1_MAX_CLIP = 30,
TMP_MAX_CLIP = 30,
G3SG1_MAX_CLIP = 20,
DEAGLE_MAX_CLIP = 7,
SG552_MAX_CLIP = 30,
AK47_MAX_CLIP = 30,
P90_MAX_CLIP = 50,
};
enum WeightWeapon
{
P228_WEIGHT = 5,
GLOCK18_WEIGHT = 5,
SCOUT_WEIGHT = 30,
HEGRENADE_WEIGHT = 2,
XM1014_WEIGHT = 20,
C4_WEIGHT = 3,
MAC10_WEIGHT = 25,
AUG_WEIGHT = 25,
SMOKEGRENADE_WEIGHT = 1,
ELITE_WEIGHT = 5,
FIVESEVEN_WEIGHT = 5,
UMP45_WEIGHT = 25,
SG550_WEIGHT = 20,
GALIL_WEIGHT = 25,
FAMAS_WEIGHT = 75,
USP_WEIGHT = 5,
AWP_WEIGHT = 30,
MP5NAVY_WEIGHT = 25,
M249_WEIGHT = 25,
M3_WEIGHT = 20,
M4A1_WEIGHT = 25,
TMP_WEIGHT = 25,
G3SG1_WEIGHT = 20,
FLASHBANG_WEIGHT = 1,
DEAGLE_WEIGHT = 7,
SG552_WEIGHT = 25,
AK47_WEIGHT = 25,
P90_WEIGHT = 26,
KNIFE_WEIGHT = 0,
};
enum MaxAmmoType
{
MAX_AMMO_BUCKSHOT = 32,
MAX_AMMO_9MM = 120,
MAX_AMMO_556NATO = 90,
MAX_AMMO_556NATOBOX = 200,
MAX_AMMO_762NATO = 90,
MAX_AMMO_45ACP = 100,
MAX_AMMO_50AE = 35,
MAX_AMMO_338MAGNUM = 30,
MAX_AMMO_57MM = 100,
MAX_AMMO_357SIG = 52,
// custom
MAX_AMMO_SMOKEGRENADE = 1,
MAX_AMMO_HEGRENADE = 1,
MAX_AMMO_FLASHBANG = 2,
};
enum AmmoType
{
AMMO_NONE,
AMMO_338MAGNUM,
AMMO_762NATO,
AMMO_556NATOBOX,
AMMO_556NATO,
AMMO_BUCKSHOT,
AMMO_45ACP,
AMMO_57MM,
AMMO_50AE,
AMMO_357SIG,
AMMO_9MM,
AMMO_FLASHBANG,
AMMO_HEGRENADE,
AMMO_SMOKEGRENADE,
AMMO_C4,
AMMO_MAX_TYPES
};
enum WeaponClassType
{
WEAPONCLASS_NONE,
WEAPONCLASS_KNIFE,
WEAPONCLASS_PISTOL,
WEAPONCLASS_GRENADE,
WEAPONCLASS_SUBMACHINEGUN,
WEAPONCLASS_SHOTGUN,
WEAPONCLASS_MACHINEGUN,
WEAPONCLASS_RIFLE,
WEAPONCLASS_SNIPERRIFLE,
WEAPONCLASS_MAX,
};
enum AmmoBuyAmount
{
AMMO_338MAG_BUY = 10,
AMMO_357SIG_BUY = 13,
AMMO_45ACP_BUY = 12,
AMMO_50AE_BUY = 7,
AMMO_556NATO_BUY = 30,
AMMO_556NATOBOX_BUY = 30,
AMMO_57MM_BUY = 50,
AMMO_762NATO_BUY = 30,
AMMO_9MM_BUY = 30,
AMMO_BUCKSHOT_BUY = 8,
};
enum shieldgun_e
{
SHIELDGUN_IDLE,
SHIELDGUN_SHOOT1,
SHIELDGUN_SHOOT2,
SHIELDGUN_SHOOT_EMPTY,
SHIELDGUN_RELOAD,
SHIELDGUN_DRAW,
SHIELDGUN_DRAWN_IDLE,
SHIELDGUN_UP,
SHIELDGUN_DOWN,
};
// custom
enum shieldgren_e
{
SHIELDREN_IDLE = 4,
SHIELDREN_UP,
SHIELDREN_DOWN
};
enum InventorySlotType
{
NONE_SLOT,
PRIMARY_WEAPON_SLOT,
PISTOL_SLOT,
KNIFE_SLOT,
GRENADE_SLOT,
C4_SLOT,
};
enum Bullet
{
BULLET_NONE,
BULLET_PLAYER_9MM,
BULLET_PLAYER_MP5,
BULLET_PLAYER_357,
BULLET_PLAYER_BUCKSHOT,
BULLET_PLAYER_CROWBAR,
BULLET_MONSTER_9MM,
BULLET_MONSTER_MP5,
BULLET_MONSTER_12MM,
BULLET_PLAYER_45ACP,
BULLET_PLAYER_338MAG,
BULLET_PLAYER_762MM,
BULLET_PLAYER_556MM,
BULLET_PLAYER_50AE,
BULLET_PLAYER_57MM,
BULLET_PLAYER_357SIG,
};
struct WeaponStruct
{
int m_type;
int m_price;
int m_side;
int m_slot;
int m_ammoPrice;
};
struct AutoBuyInfoStruct
{
AutoBuyClassType m_class;
char *m_command;
char *m_classname;
};
struct WeaponAliasInfo
{
char *alias;
WeaponIdType id;
};
struct WeaponBuyAliasInfo
{
char *alias;
WeaponIdType id;
char *failName;
};
struct WeaponClassAliasInfo
{
char *alias;
WeaponClassType id;
};
struct WeaponSlotInfo
{
WeaponIdType id;
InventorySlotType slot;
const char *weaponName;
};
enum hash_types_e { CLASSNAME };

View File

@ -0,0 +1,303 @@
/*
*
* 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
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* 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
* 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
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
#include "regamedll_const.h"
class CBaseEntity;
class CBasePlayer;
// Implementation wrapper
class CCSEntity {
public:
virtual ~CCSEntity() {}
virtual void FireBullets(int iShots, Vector &vecSrc, Vector &vecDirShooting, Vector &vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker);
virtual Vector FireBullets3(Vector &vecSrc, Vector &vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand);
public:
CBaseEntity *m_pContainingEntity;
};
class CCSDelay: public CCSEntity {};
class CCSAnimating: public CCSDelay {};
class CCSPlayerItem: public CCSAnimating {};
class CCSToggle: public CCSAnimating {};
class CCSMonster: public CCSToggle {};
class CCSWeaponBox: public CCSEntity {};
class CCSArmoury: public CCSEntity {};
class CCSPlayer: public CCSMonster {
public:
CCSPlayer() : m_bForceShowMenu(false)
{
m_szModel[0] = '\0';
}
virtual bool IsConnected() const;
virtual void SetAnimation(PLAYER_ANIM playerAnim);
virtual void AddAccount(int amount, RewardType type = RT_NONE, bool bTrackChange = true);
virtual CBaseEntity *GiveNamedItem(const char *pszName);
virtual CBaseEntity *GiveNamedItemEx(const char *pszName);
virtual void GiveDefaultItems();
virtual void GiveShield(bool bDeploy = true);
virtual void DropShield(bool bDeploy = true);
virtual void DropPlayerItem(const char *pszItemName);
virtual void RemoveShield();
virtual void RemoveAllItems(bool bRemoveSuit);
virtual bool RemovePlayerItem(const char* pszItemName);
virtual void SetPlayerModel(bool bHasC4);
virtual void SetPlayerModelEx(const char *modelName);
virtual void SetNewPlayerModel(const char *modelName);
virtual void ClientCommand(const char *cmd, const char *arg1 = nullptr, const char *arg2 = nullptr, const char *arg3 = nullptr);
virtual void SetProgressBarTime(int time);
virtual void SetProgressBarTime2(int time, float timeElapsed);
virtual struct edict_s *EntSelectSpawnPoint();
virtual void SetBombIcon(bool bFlash = false);
virtual void SetScoreAttrib(CBasePlayer *dest);
virtual void SendItemStatus();
virtual void ReloadWeapons(CBasePlayerItem *pWeapon = nullptr, bool bForceReload = false, bool bForceRefill = false);
virtual void Observer_SetMode(int iMode);
virtual bool SelectSpawnSpot(const char *pEntClassName, CBaseEntity* &pSpot);
virtual bool SwitchWeapon(CBasePlayerItem *pWeapon);
virtual void SwitchTeam();
virtual bool JoinTeam(TeamName team);
virtual void StartObserver(Vector& vecPosition, Vector& vecViewAngle);
virtual void TeamChangeUpdate();
virtual void DropSecondary();
virtual void DropPrimary();
virtual bool HasPlayerItem(CBasePlayerItem *pCheckItem);
virtual bool HasNamedPlayerItem(const char *pszItemName);
virtual CBasePlayerItem *GetItemById(WeaponIdType weaponID);
virtual CBasePlayerItem *GetItemByName(const char *itemName);
virtual void Disappear();
virtual void MakeVIP();
virtual bool MakeBomber();
CBasePlayer *BasePlayer() const;
public:
char m_szModel[32];
bool m_bForceShowMenu;
};
class CAPI_Bot: public CCSPlayer {};
class CAPI_CSBot: public CAPI_Bot {};
class CCSShield: public CCSEntity {};
class CCSDeadHEV: public CCSMonster {};
class CCSSprayCan: public CCSEntity {};
class CCSBloodSplat: public CCSEntity {};
class CCSPlayerWeapon: public CCSPlayerItem {};
class CCSWorld: public CCSEntity {};
class CCSDecal: public CCSEntity {};
class CCSCorpse: public CCSEntity {};
class CCSGrenade: public CCSMonster {};
class CCSAirtank: public CCSGrenade {};
class CCSPlayerAmmo: public CCSEntity {};
class CCS9MMAmmo: public CCSPlayerAmmo {};
class CCSBuckShotAmmo: public CCSPlayerAmmo {};
class CCS556NatoAmmo: public CCSPlayerAmmo {};
class CCS556NatoBoxAmmo: public CCSPlayerAmmo {};
class CCS762NatoAmmo: public CCSPlayerAmmo {};
class CCS45ACPAmmo: public CCSPlayerAmmo {};
class CCS50AEAmmo: public CCSPlayerAmmo {};
class CCS338MagnumAmmo: public CCSPlayerAmmo {};
class CCS57MMAmmo: public CCSPlayerAmmo {};
class CCS357SIGAmmo: public CCSPlayerAmmo {};
class CCSFuncWall: public CCSEntity {};
class CCSFuncWallToggle: public CCSFuncWall {};
class CCSFuncConveyor: public CCSFuncWall {};
class CCSFuncIllusionary: public CCSToggle {};
class CCSFuncMonsterClip: public CCSFuncWall {};
class CCSFuncRotating: public CCSEntity {};
class CCSPendulum: public CCSEntity {};
class CCSPointEntity: public CCSEntity {};
class CCSStripWeapons: public CCSPointEntity {};
class CCSInfoIntermission: public CCSPointEntity {};
class CCSRevertSaved: public CCSPointEntity {};
class CCSEnvGlobal: public CCSPointEntity {};
class CCSMultiSource: public CCSPointEntity {};
class CCSButton: public CCSToggle {};
class CCSRotButton: public CCSButton {};
class CCSMomentaryRotButton: public CCSToggle {};
class CCSEnvSpark: public CCSEntity {};
class CCSButtonTarget: public CCSEntity {};
class CCSDoor: public CCSToggle {};
class CCSRotDoor: public CCSDoor {};
class CCSMomentaryDoor: public CCSToggle {};
class CCSGib: public CCSEntity {};
class CCSBubbling: public CCSEntity {};
class CCSBeam: public CCSEntity {};
class CCSLightning: public CCSBeam {};
class CCSLaser: public CCSBeam {};
class CCSGlow: public CCSPointEntity {};
class CCSSprite: public CCSPointEntity {};
class CCSBombGlow: public CCSSprite {};
class CCSGibShooter: public CCSDelay {};
class CCSEnvShooter: public CCSGibShooter {};
class CCSTestEffect: public CCSDelay {};
class CCSBlood: public CCSPointEntity {};
class CCSShake: public CCSPointEntity {};
class CCSFade: public CCSPointEntity {};
class CCSMessage: public CCSPointEntity {};
class CCSEnvFunnel: public CCSDelay {};
class CCSEnvBeverage: public CCSDelay {};
class CCSItemSoda: public CCSEntity {};
class CCSShower: public CCSEntity {};
class CCSEnvExplosion: public CCSMonster {};
class CCSBreakable: public CCSDelay {};
class CCSPushable: public CCSBreakable {};
class CCSFuncTank: public CCSEntity {};
class CCSFuncTankGun: public CCSFuncTank {};
class CCSFuncTankLaser: public CCSFuncTank {};
class CCSFuncTankRocket: public CCSFuncTank {};
class CCSFuncTankMortar: public CCSFuncTank {};
class CCSFuncTankControls: public CCSEntity {};
class CCSRecharge: public CCSToggle {};
class CCSCycler: public CCSMonster {};
class CCSGenericCycler: public CCSCycler {};
class CCSCyclerProbe: public CCSCycler {};
class CCSCyclerSprite: public CCSEntity {};
class CCSWeaponCycler: public CCSPlayerWeapon {};
class CCSWreckage: public CCSMonster {};
class CCSWorldItem: public CCSEntity {};
class CCSItem: public CCSEntity {};
class CCSHealthKit: public CCSItem {};
class CCSWallHealth: public CCSToggle {};
class CCSItemSuit: public CCSItem {};
class CCSItemBattery: public CCSItem {};
class CCSItemAntidote: public CCSItem {};
class CCSItemSecurity: public CCSItem {};
class CCSItemLongJump: public CCSItem {};
class CCSItemKevlar: public CCSItem {};
class CCSItemAssaultSuit: public CCSItem {};
class CCSItemThighPack: public CCSItem {};
class CCSGrenCatch: public CCSEntity {};
class CCSFuncWeaponCheck: public CCSEntity {};
class CCSHostage: public CCSMonster {};
class CCSLight: public CCSPointEntity {};
class CCSEnvLight: public CCSLight {};
class CCSRuleEntity: public CCSEntity {};
class CCSRulePointEntity: public CCSRuleEntity {};
class CCSRuleBrushEntity: public CCSRuleEntity {};
class CCSGameScore: public CCSRulePointEntity {};
class CCSGameEnd: public CCSRulePointEntity {};
class CCSGameText: public CCSRulePointEntity {};
class CCSGameTeamMaster: public CCSRulePointEntity {};
class CCSGameTeamSet: public CCSRulePointEntity {};
class CCSGamePlayerZone: public CCSRuleBrushEntity {};
class CCSGamePlayerHurt: public CCSRulePointEntity {};
class CCSGameCounter: public CCSRulePointEntity {};
class CCSGameCounterSet: public CCSRulePointEntity {};
class CCSGamePlayerEquip: public CCSRulePointEntity {};
class CCSGamePlayerTeam: public CCSRulePointEntity {};
class CCSFuncMortarField: public CCSToggle {};
class CCSMortar: public CCSGrenade {};
class CCSMapInfo: public CCSPointEntity {};
class CCSPathCorner: public CCSPointEntity {};
class CCSPathTrack: public CCSPointEntity {};
class CCSFuncTrackTrain: public CCSEntity {};
class CCSFuncVehicleControls: public CCSEntity {};
class CCSFuncVehicle: public CCSEntity {};
class CCSPlatTrain: public CCSToggle {};
class CCSFuncPlat: public CCSPlatTrain {};
class CCSPlatTrigger: public CCSEntity {};
class CCSFuncPlatRot: public CCSFuncPlat {};
class CCSFuncTrain: public CCSPlatTrain {};
class CCSFuncTrainControls: public CCSEntity {};
class CCSFuncTrackChange: public CCSFuncPlatRot {};
class CCSFuncTrackAuto: public CCSFuncTrackChange {};
class CCSGunTarget: public CCSMonster {};
class CCSAmbientGeneric: public CCSEntity {};
class CCSEnvSound: public CCSPointEntity {};
class CCSSpeaker: public CCSEntity {};
class CCSSoundEnt: public CCSEntity {};
class CCSUSP: public CCSPlayerWeapon {};
class CCSMP5N: public CCSPlayerWeapon {};
class CCSSG552: public CCSPlayerWeapon {};
class CCSAK47: public CCSPlayerWeapon {};
class CCSAUG: public CCSPlayerWeapon {};
class CCSAWP: public CCSPlayerWeapon {};
class CCSC4: public CCSPlayerWeapon {};
class CCSDEAGLE: public CCSPlayerWeapon {};
class CCSFlashbang: public CCSPlayerWeapon {};
class CCSG3SG1: public CCSPlayerWeapon {};
class CCSGLOCK18: public CCSPlayerWeapon {};
class CCSHEGrenade: public CCSPlayerWeapon {};
class CCSKnife: public CCSPlayerWeapon {};
class CCSM249: public CCSPlayerWeapon {};
class CCSM3: public CCSPlayerWeapon {};
class CCSM4A1: public CCSPlayerWeapon {};
class CCSMAC10: public CCSPlayerWeapon {};
class CCSP228: public CCSPlayerWeapon {};
class CCSP90: public CCSPlayerWeapon {};
class CCSSCOUT: public CCSPlayerWeapon {};
class CCSSmokeGrenade: public CCSPlayerWeapon {};
class CCSTMP: public CCSPlayerWeapon {};
class CCSXM1014: public CCSPlayerWeapon {};
class CCSELITE: public CCSPlayerWeapon {};
class CCSFiveSeven: public CCSPlayerWeapon {};
class CCSUMP45: public CCSPlayerWeapon {};
class CCSSG550: public CCSPlayerWeapon {};
class CCSGalil: public CCSPlayerWeapon {};
class CCSFamas: public CCSPlayerWeapon {};
class CCSNullEntity: public CCSEntity {};
class CCSDMStart: public CCSPointEntity {};
class CCSFrictionModifier: public CCSEntity {};
class CCSAutoTrigger: public CCSDelay {};
class CCSTriggerRelay: public CCSDelay {};
class CCSMultiManager: public CCSToggle {};
class CCSRenderFxManager: public CCSEntity {};
class CCSTrigger: public CCSToggle {};
class CCSTriggerHurt: public CCSTrigger {};
class CCSTriggerMonsterJump: public CCSTrigger {};
class CCSTriggerCDAudio: public CCSTrigger {};
class CCSTargetCDAudio: public CCSPointEntity {};
class CCSTriggerMultiple: public CCSTrigger {};
class CCSTriggerOnce: public CCSTriggerMultiple {};
class CCSTriggerCounter: public CCSTrigger {};
class CCSTriggerVolume: public CCSPointEntity {};
class CCSFireAndDie: public CCSDelay {};
class CCSChangeLevel: public CCSTrigger {};
class CCSLadder: public CCSTrigger {};
class CCSTriggerPush: public CCSTrigger {};
class CCSTriggerTeleport: public CCSTrigger {};
class CCSBuyZone: public CCSTrigger {};
class CCSBombTarget: public CCSTrigger {};
class CCSHostageRescue: public CCSTrigger {};
class CCSEscapeZone: public CCSTrigger {};
class CCSVIP_SafetyZone: public CCSTrigger {};
class CCSTriggerSave: public CCSTrigger {};
class CCSTriggerEndSection: public CCSTrigger {};
class CCSTriggerGravity: public CCSTrigger {};
class CCSTriggerChangeTarget: public CCSDelay {};
class CCSTriggerCamera: public CCSDelay {};
class CCSWeather: public CCSTrigger {};
class CCSClientFog: public CCSEntity {};
inline CBasePlayer *CCSPlayer::BasePlayer() const {
return reinterpret_cast<CBasePlayer *>(this->m_pContainingEntity);
}

View File

@ -0,0 +1,61 @@
/*
*
* 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
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* 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
* 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
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
#include <archtypes.h>
class IRehldsFlightRecorder
{
public:
virtual ~IRehldsFlightRecorder() { }
virtual uint16 RegisterMessage(const char* module, const char *message, unsigned int version, bool inOut) = 0;
virtual void StartMessage(uint16 msg, bool entrance) = 0;
virtual void EndMessage(uint16 msg, bool entrance) = 0;
virtual void WriteInt8(int8 v) = 0;
virtual void WriteUInt8(uint8 v) = 0;
virtual void WriteInt16(int16 v) = 0;
virtual void WriteUInt16(uint16 v) = 0;
virtual void WriteInt32(int32 v) = 0;
virtual void WriteUInt32(uint32 v) = 0;
virtual void WriteInt64(int64 v) = 0;
virtual void WriteUInt64(uint64 v) = 0;
virtual void WriteFloat(float v) = 0;
virtual void WriteDouble(double v) = 0;
virtual void WriteString(const char* s) = 0;
virtual void WriteBuffer(const void* data ,unsigned int len) = 0;
};

View File

@ -0,0 +1,47 @@
/*
*
* 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
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* 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
* 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
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
typedef void(*xcommand_t)(void);
typedef struct cmd_function_s
{
struct cmd_function_s *next;
char *name;
xcommand_t function;
int flags;
} cmd_function_t;
typedef enum cmd_source_s
{
src_client = 0, // came in over a net connection as a clc_stringcmd. host_client will be valid during this state.
src_command = 1, // from the command buffer.
} cmd_source_t;
#define FCMD_HUD_COMMAND BIT(0)
#define FCMD_GAME_COMMAND BIT(1)
#define FCMD_WRAPPER_COMMAND BIT(2)

View File

@ -0,0 +1,300 @@
/*
*
* 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
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* 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
* 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
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
#include <engine_strucs.h>
#include <com_model.h>
#include "cmd_rehlds.h"
#include "rehlds_interfaces.h"
#include "FlightRecorder.h"
#include "../common/hookchains.h"
#define REHLDS_API_VERSION_MAJOR 3
#define REHLDS_API_VERSION_MINOR 0
//Steam_NotifyClientConnect hook
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
typedef IHookChainRegistry<qboolean, IGameClient*, const void*, unsigned int> IRehldsHookRegistry_Steam_NotifyClientConnect;
//SV_ConnectClient hook
typedef IVoidHookChain<> IRehldsHook_SV_ConnectClient;
typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_ConnectClient;
//SV_GetIDString hook
typedef IHookChain<char*, USERID_t*> IRehldsHook_SV_GetIDString;
typedef IHookChainRegistry<char*, USERID_t*> IRehldsHookRegistry_SV_GetIDString;
//SV_SendServerinfo hook
typedef IVoidHookChain<sizebuf_t*, IGameClient*> IRehldsHook_SV_SendServerinfo;
typedef IVoidHookChainRegistry<sizebuf_t*, IGameClient*> IRehldsHookRegistry_SV_SendServerinfo;
//SV_CheckProtocol hook
typedef IHookChain<int, netadr_t*, int> IRehldsHook_SV_CheckProtocol;
typedef IHookChainRegistry<int, netadr_t*, int> IRehldsHookRegistry_SV_CheckProtocol;
//SVC_GetChallenge_mod hook
typedef IVoidHookChain<char*, int> IRehldsHook_SVC_GetChallenge_mod;
typedef IVoidHookChainRegistry<char*, int> IRehldsHookRegistry_SVC_GetChallenge_mod;
//SV_CheckKeyInfo hook
typedef IHookChain<int, netadr_t*, char*, uint16*, int*, char*, char*> IRehldsHook_SV_CheckKeyInfo;
typedef IHookChainRegistry<int, netadr_t*, char*, uint16*, int*, char*, char*> IRehldsHookRegistry_SV_CheckKeyInfo;
//SV_CheckIPRestrictions hook
typedef IHookChain<int, netadr_t*, int> IRehldsHook_SV_CheckIPRestrictions;
typedef IHookChainRegistry<int, netadr_t*, int> IRehldsHookRegistry_SV_CheckIPRestrictions;
//SV_FinishCertificateCheck hook
typedef IHookChain<int, netadr_t*, int, char*, char*> IRehldsHook_SV_FinishCertificateCheck;
typedef IHookChainRegistry<int, netadr_t*, int, char*, char*> IRehldsHookRegistry_SV_FinishCertificateCheck;
//Steam_NotifyBotConnect hook
typedef IHookChain<qboolean, IGameClient*> IRehldsHook_Steam_NotifyBotConnect;
typedef IHookChainRegistry<qboolean, IGameClient*> IRehldsHookRegistry_Steam_NotifyBotConnect;
//SerializeSteamId
typedef IVoidHookChain<USERID_t*, USERID_t*> IRehldsHook_SerializeSteamId;
typedef IVoidHookChainRegistry<USERID_t*, USERID_t*> IRehldsHookRegistry_SerializeSteamId;
//SV_CompareUserID hook
typedef IHookChain<qboolean, USERID_t*, USERID_t*> IRehldsHook_SV_CompareUserID;
typedef IHookChainRegistry<qboolean, USERID_t*, USERID_t*> IRehldsHookRegistry_SV_CompareUserID;
//Steam_NotifyClientDisconnect
typedef IVoidHookChain<IGameClient*> IRehldsHook_Steam_NotifyClientDisconnect;
typedef IVoidHookChainRegistry<IGameClient*> IRehldsHookRegistry_Steam_NotifyClientDisconnect;
//PreProcessPacket
typedef IHookChain<bool, uint8*, unsigned int, const netadr_t&> IRehldsHook_PreprocessPacket;
typedef IHookChainRegistry<bool, uint8*, unsigned int, const netadr_t&> IRehldsHookRegistry_PreprocessPacket;
//ValidateCommand
typedef IHookChain<bool, const char*, cmd_source_t, IGameClient*> IRehldsHook_ValidateCommand;
typedef IHookChainRegistry<bool, const char*, cmd_source_t, IGameClient*> IRehldsHookRegistry_ValidateCommand;
//ExecuteServerStringCmd
typedef IVoidHookChain<const char*, cmd_source_t, IGameClient*> IRehldsHook_ExecuteServerStringCmd;
typedef IVoidHookChainRegistry<const char*, cmd_source_t, IGameClient*> IRehldsHookRegistry_ExecuteServerStringCmd;
//ClientConnected
typedef IVoidHookChain<IGameClient*> IRehldsHook_ClientConnected;
typedef IVoidHookChainRegistry<IGameClient*> IRehldsHookRegistry_ClientConnected;
//HandleNetCommand
typedef IVoidHookChain<IGameClient*, int8> IRehldsHook_HandleNetCommand;
typedef IVoidHookChainRegistry<IGameClient*, int8> IRehldsHookRegistry_HandleNetCommand;
//Mod_LoadBrushModel
typedef IVoidHookChain<model_t*, void*> IRehldsHook_Mod_LoadBrushModel;
typedef IVoidHookChainRegistry<model_t*, void*> IRehldsHookRegistry_Mod_LoadBrushModel;
//Mod_LoadStudioModel
typedef IVoidHookChain<model_t*, void*> IRehldsHook_Mod_LoadStudioModel;
typedef IVoidHookChainRegistry<model_t*, void*> IRehldsHookRegistry_Mod_LoadStudioModel;
//SV_EmitEvents hook
typedef IVoidHookChain<IGameClient *, struct packet_entities_s *, sizebuf_t *> IRehldsHook_SV_EmitEvents;
typedef IVoidHookChainRegistry<IGameClient *, struct packet_entities_s *, sizebuf_t *> IRehldsHookRegistry_SV_EmitEvents;
//EV_PlayReliableEvent hook
typedef IVoidHookChain<IGameClient *, int, unsigned short, float, struct event_args_s *> IRehldsHook_EV_PlayReliableEvent;
typedef IVoidHookChainRegistry<IGameClient *, int, unsigned short, float, struct event_args_s *> IRehldsHookRegistry_EV_PlayReliableEvent;
//SV_StartSound hook
typedef IVoidHookChain<int , edict_t *, int, const char *, int, float, int, int> IRehldsHook_SV_StartSound;
typedef IVoidHookChainRegistry<int , edict_t *, int, const char *, int, float, int, int> IRehldsHookRegistry_SV_StartSound;
//PF_Remove_I hook
typedef IVoidHookChain<edict_t *> IRehldsHook_PF_Remove_I;
typedef IVoidHookChainRegistry<edict_t *> IRehldsHookRegistry_PF_Remove_I;
//PF_BuildSoundMsg_I hook
typedef IVoidHookChain<edict_t *, int, const char *, float, float, int, int, int, int, const float *, edict_t *> IRehldsHook_PF_BuildSoundMsg_I;
typedef IVoidHookChainRegistry<edict_t *, int, const char *, float, float, int, int, int, int, const float *, edict_t *> IRehldsHookRegistry_PF_BuildSoundMsg_I;
//SV_WriteFullClientUpdate hook
typedef IVoidHookChain<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> IRehldsHook_SV_WriteFullClientUpdate;
typedef IVoidHookChainRegistry<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> IRehldsHookRegistry_SV_WriteFullClientUpdate;
//SV_CheckConsistencyResponse hook
typedef IHookChain<bool, IGameClient *, resource_t *, uint32> IRehldsHook_SV_CheckConsistencyResponse;
typedef IHookChainRegistry<bool, IGameClient *, resource_t *, uint32> IRehldsHookRegistry_SV_CheckConsistencyResponse;
//SV_DropClient hook
typedef IVoidHookChain<IGameClient*, bool, const char*> IRehldsHook_SV_DropClient;
typedef IVoidHookChainRegistry<IGameClient*, bool, const char*> IRehldsHookRegistry_SV_DropClient;
//SV_ActivateServer hook
typedef IVoidHookChain<int> IRehldsHook_SV_ActivateServer;
typedef IVoidHookChainRegistry<int> IRehldsHookRegistry_SV_ActivateServer;
//SV_WriteVoiceCodec hook
typedef IVoidHookChain<sizebuf_t *> IRehldsHook_SV_WriteVoiceCodec;
typedef IVoidHookChainRegistry<sizebuf_t *> IRehldsHookRegistry_SV_WriteVoiceCodec;
//Steam_GSGetSteamID hook
typedef IHookChain<uint64> IRehldsHook_Steam_GSGetSteamID;
typedef IHookChainRegistry<uint64> IRehldsHookRegistry_Steam_GSGetSteamID;
//SV_TransferConsistencyInfo hook
typedef IHookChain<int> IRehldsHook_SV_TransferConsistencyInfo;
typedef IHookChainRegistry<int> IRehldsHookRegistry_SV_TransferConsistencyInfo;
//Steam_GSBUpdateUserData hook
typedef IHookChain<bool, uint64, const char *, uint32> IRehldsHook_Steam_GSBUpdateUserData;
typedef IHookChainRegistry<bool, uint64, const char *, uint32> IRehldsHookRegistry_Steam_GSBUpdateUserData;
//Cvar_DirectSet hook
typedef IVoidHookChain<struct cvar_s *, const char *> IRehldsHook_Cvar_DirectSet;
typedef IVoidHookChainRegistry<struct cvar_s *, const char *> IRehldsHookRegistry_Cvar_DirectSet;
//SV_EstablishTimeBase hook
typedef IVoidHookChain<IGameClient *, struct usercmd_s *, int, int, int> IRehldsHook_SV_EstablishTimeBase;
typedef IVoidHookChainRegistry<IGameClient *, struct usercmd_s *, int, int, int> IRehldsHookRegistry_SV_EstablishTimeBase;
//SV_Spawn_f hook
typedef IVoidHookChain<> IRehldsHook_SV_Spawn_f;
typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Spawn_f;
//SV_CreatePacketEntities hook
typedef IHookChain<int, enum sv_delta_s, IGameClient *, struct packet_entities_s *, struct sizebuf_s *> IRehldsHook_SV_CreatePacketEntities;
typedef IHookChainRegistry<int, enum sv_delta_s, IGameClient *, struct packet_entities_s *, struct sizebuf_s *> IRehldsHookRegistry_SV_CreatePacketEntities;
//SV_EmitSound2 hook
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;
class IRehldsHookchains {
public:
virtual ~IRehldsHookchains() { }
virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect() = 0;
virtual IRehldsHookRegistry_SV_ConnectClient* SV_ConnectClient() = 0;
virtual IRehldsHookRegistry_SV_GetIDString* SV_GetIDString() = 0;
virtual IRehldsHookRegistry_SV_SendServerinfo* SV_SendServerinfo() = 0;
virtual IRehldsHookRegistry_SV_CheckProtocol* SV_CheckProtocol() = 0;
virtual IRehldsHookRegistry_SVC_GetChallenge_mod* SVC_GetChallenge_mod() = 0;
virtual IRehldsHookRegistry_SV_CheckKeyInfo* SV_CheckKeyInfo() = 0;
virtual IRehldsHookRegistry_SV_CheckIPRestrictions* SV_CheckIPRestrictions() = 0;
virtual IRehldsHookRegistry_SV_FinishCertificateCheck* SV_FinishCertificateCheck() = 0;
virtual IRehldsHookRegistry_Steam_NotifyBotConnect* Steam_NotifyBotConnect() = 0;
virtual IRehldsHookRegistry_SerializeSteamId* SerializeSteamId() = 0;
virtual IRehldsHookRegistry_SV_CompareUserID* SV_CompareUserID() = 0;
virtual IRehldsHookRegistry_Steam_NotifyClientDisconnect* Steam_NotifyClientDisconnect() = 0;
virtual IRehldsHookRegistry_PreprocessPacket* PreprocessPacket() = 0;
virtual IRehldsHookRegistry_ValidateCommand* ValidateCommand() = 0;
virtual IRehldsHookRegistry_ClientConnected* ClientConnected() = 0;
virtual IRehldsHookRegistry_HandleNetCommand* HandleNetCommand() = 0;
virtual IRehldsHookRegistry_Mod_LoadBrushModel* Mod_LoadBrushModel() = 0;
virtual IRehldsHookRegistry_Mod_LoadStudioModel* Mod_LoadStudioModel() = 0;
virtual IRehldsHookRegistry_ExecuteServerStringCmd* ExecuteServerStringCmd() = 0;
virtual IRehldsHookRegistry_SV_EmitEvents* SV_EmitEvents() = 0;
virtual IRehldsHookRegistry_EV_PlayReliableEvent* EV_PlayReliableEvent() = 0;
virtual IRehldsHookRegistry_SV_StartSound* SV_StartSound() = 0;
virtual IRehldsHookRegistry_PF_Remove_I* PF_Remove_I() = 0;
virtual IRehldsHookRegistry_PF_BuildSoundMsg_I* PF_BuildSoundMsg_I() = 0;
virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate() = 0;
virtual IRehldsHookRegistry_SV_CheckConsistencyResponse* SV_CheckConsistencyResponse() = 0;
virtual IRehldsHookRegistry_SV_DropClient* SV_DropClient() = 0;
virtual IRehldsHookRegistry_SV_ActivateServer* SV_ActivateServer() = 0;
virtual IRehldsHookRegistry_SV_WriteVoiceCodec* SV_WriteVoiceCodec() = 0;
virtual IRehldsHookRegistry_Steam_GSGetSteamID* Steam_GSGetSteamID() = 0;
virtual IRehldsHookRegistry_SV_TransferConsistencyInfo* SV_TransferConsistencyInfo() = 0;
virtual IRehldsHookRegistry_Steam_GSBUpdateUserData* Steam_GSBUpdateUserData() = 0;
virtual IRehldsHookRegistry_Cvar_DirectSet* Cvar_DirectSet() = 0;
virtual IRehldsHookRegistry_SV_EstablishTimeBase* SV_EstablishTimeBase() = 0;
virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f() = 0;
virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities() = 0;
virtual IRehldsHookRegistry_SV_EmitSound2* SV_EmitSound2() = 0;
};
struct RehldsFuncs_t {
void(*DropClient)(IGameClient* cl, bool crash, const char* fmt, ...);
void(*RejectConnection)(netadr_t *adr, char *fmt, ...);
qboolean(*SteamNotifyBotConnect)(IGameClient* cl);
sizebuf_t*(*GetNetMessage)();
IGameClient*(*GetHostClient)();
int*(*GetMsgReadCount)();
qboolean(*FilterUser)(USERID_t*);
void(*NET_SendPacket)(unsigned int length, void *data, const netadr_t &to);
void(*TokenizeString)(char* s);
bool(*CheckChallenge)(const netadr_t& adr, int challenge);
void(*SendUserReg)(sizebuf_t* msg);
void(*WriteDeltaDescriptionsToClient)(sizebuf_t* msg);
void(*SetMoveVars)();
void(*WriteMovevarsToClient)(sizebuf_t* msg);
char*(*GetClientFallback)();
int*(*GetAllowCheats)();
bool(*GSBSecure)();
int(*GetBuildNumber)();
double(*GetRealTime)();
int*(*GetMsgBadRead)();
cmd_source_t*(*GetCmdSource)();
void(*Log)(const char* prefix, const char* msg);
DLL_FUNCTIONS *(*GetEntityInterface)();
void(*EV_PlayReliableEvent)(IGameClient *cl, int entindex, unsigned short eventindex, float delay, struct event_args_s *pargs);
int(*SV_LookupSoundIndex)(const char *sample);
void(*MSG_StartBitWriting)(sizebuf_t *buf);
void(*MSG_WriteBits)(uint32 data, int numbits);
void(*MSG_WriteBitVec3Coord)(const float *fa);
void(*MSG_EndBitWriting)(sizebuf_t *buf);
void*(*SZ_GetSpace)(sizebuf_t *buf, int length);
cvar_t*(*GetCvarVars)();
int (*SV_GetChallenge)(const netadr_t& adr);
void (*SV_AddResource)(resourcetype_t type, const char *name, int size, unsigned char flags, int index);
int(*MSG_ReadShort)(void);
int(*MSG_ReadBuf)(int iSize, void *pbuf);
void(*MSG_WriteBuf)(sizebuf_t *sb, int iSize, void *buf);
void(*MSG_WriteByte)(sizebuf_t *sb, int c);
void(*MSG_WriteShort)(sizebuf_t *sb, int c);
void(*MSG_WriteString)(sizebuf_t *sb, const char *s);
void*(*GetPluginApi)(const char *name);
void(*RegisterPluginApi)(const char *name, void *impl);
qboolean(*SV_FileInConsistencyList)(const char *filename, struct consistency_s **ppconsist);
qboolean(*Steam_NotifyClientConnect)(IGameClient *cl, const void *pvSteam2Key, unsigned int ucbSteam2Key);
void(*Steam_NotifyClientDisconnect)(IGameClient* cl);
void(*SV_StartSound)(int recipients, edict_t *entity, int channel, const char *sample, int volume, float attenuation, int flags, int pitch);
bool(*SV_EmitSound2)(edict_t *entity, IGameClient *receiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin);
void(*SV_UpdateUserInfo)(IGameClient *pGameClient);
bool(*StripUnprintableAndSpace)(char *pch);
};
class IRehldsApi {
public:
virtual ~IRehldsApi() { }
virtual int GetMajorVersion() = 0;
virtual int GetMinorVersion() = 0;
virtual const RehldsFuncs_t* GetFuncs() = 0;
virtual IRehldsHookchains* GetHookchains() = 0;
virtual IRehldsServerStatic* GetServerStatic() = 0;
virtual IRehldsServerData* GetServerData() = 0;
virtual IRehldsFlightRecorder* GetFlightRecorder() = 0;
};
#define VREHLDS_HLDS_API_VERSION "VREHLDS_HLDS_API_VERSION001"

View File

@ -0,0 +1,109 @@
/*
*
* 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
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* 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
* 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
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
class INetChan;
class IGameClient;
#include <archtypes.h>
#include <const.h>
class INetChan;
class IGameClient;
class IGameClient {
public:
virtual int GetId() = 0;
virtual bool IsActive() = 0;
virtual void SetActive(bool active) = 0;
virtual bool IsSpawned() = 0;
virtual void SetSpawned(bool spawned) = 0;
virtual INetChan* GetNetChan() = 0;
virtual sizebuf_t* GetDatagram() = 0;
virtual edict_t* GetEdict() = 0;
virtual USERID_t* GetNetworkUserID() = 0;
virtual const char* GetName() = 0;
virtual bool IsConnected() = 0;
virtual void SetConnected(bool connected) = 0;
virtual uint32 GetVoiceStream(int stream_id) = 0;
virtual void SetLastVoiceTime(double time) = 0;
virtual double GetLastVoiceTime() = 0;
virtual bool GetLoopback() = 0;
virtual struct usercmd_s *GetLastCmd() = 0;
};
class INetChan {
public:
virtual const netadr_t* GetRemoteAdr() = 0;
virtual sizebuf_t* GetMessageBuf() = 0;
};
class IRehldsServerStatic {
public:
virtual ~IRehldsServerStatic() { }
virtual int GetMaxClients() = 0;
virtual bool IsLogActive() = 0;
virtual IGameClient* GetClient(int id) = 0;
virtual client_t* GetClient_t(int id) = 0;
virtual int GetIndexOfClient_t(client_t* client) = 0;
};
class IRehldsServerData {
public:
virtual ~IRehldsServerData() { }
virtual const char* GetModelName() = 0;
virtual const char* GetName() = 0;
virtual uint32 GetWorldmapCrc() = 0;
virtual uint8* GetClientDllMd5() = 0;
virtual sizebuf_t* GetDatagram() = 0;
virtual sizebuf_t* GetReliableDatagram() = 0;
virtual void SetModelName(const char* modelname) = 0;
virtual void SetConsistencyNum(int num) = 0;
virtual int GetConsistencyNum() = 0;
virtual int GetResourcesNum() = 0;
virtual int GetDecalNameNum() = 0;
virtual double GetTime() = 0;
virtual void SetResourcesNum(int num) = 0;
virtual struct resource_s *GetResource(int index) = 0;
virtual void SetName(const char* name) = 0;
virtual class ISteamGameServer *GetSteamGameServer() = 0;
virtual struct netadr_s *GetNetFrom() = 0;
};

View File

@ -0,0 +1,121 @@
/*
*
* 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
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* 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
* 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
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
template<typename t_ret, typename ...t_args>
class IHookChain {
protected:
virtual ~IHookChain() {}
public:
virtual t_ret callNext(t_args... args) = 0;
virtual t_ret callOriginal(t_args... args) = 0;
};
template<typename t_ret, typename t_class, typename ...t_args>
class IHookChainClass {
protected:
virtual ~IHookChainClass() {}
public:
virtual t_ret callNext(t_class *, t_args... args) = 0;
virtual t_ret callOriginal(t_class *, t_args... args) = 0;
};
template<typename ...t_args>
class IVoidHookChain
{
protected:
virtual ~IVoidHookChain() {}
public:
virtual void callNext(t_args... args) = 0;
virtual void callOriginal(t_args... args) = 0;
};
template<typename t_class, typename ...t_args>
class IVoidHookChainClass
{
protected:
virtual ~IVoidHookChainClass() {}
public:
virtual void callNext(t_class *, t_args... args) = 0;
virtual void callOriginal(t_class *, t_args... args) = 0;
};
// Specifies priorities for hooks call order in the chain.
// For equal priorities first registered hook will be called first.
enum HookChainPriority
{
HC_PRIORITY_UNINTERRUPTABLE = 255, // Hook will be called before other hooks.
HC_PRIORITY_HIGH = 192, // Hook will be called before hooks with default priority.
HC_PRIORITY_DEFAULT = 128, // Default hook call priority.
HC_PRIORITY_MEDIUM = 64, // Hook will be called after hooks with default priority.
HC_PRIORITY_LOW = 0, // Hook will be called after all other hooks.
};
// Hook chain registry(for hooks [un]registration)
template<typename t_ret, typename ...t_args>
class IHookChainRegistry {
public:
typedef t_ret(*hookfunc_t)(IHookChain<t_ret, t_args...>*, t_args...);
virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0;
virtual void unregisterHook(hookfunc_t hook) = 0;
};
// Hook chain registry(for hooks [un]registration)
template<typename t_ret, typename t_class, typename ...t_args>
class IHookChainRegistryClass {
public:
typedef t_ret(*hookfunc_t)(IHookChainClass<t_ret, t_class, t_args...>*, t_class *, t_args...);
virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0;
virtual void unregisterHook(hookfunc_t hook) = 0;
};
// Hook chain registry(for hooks [un]registration)
template<typename ...t_args>
class IVoidHookChainRegistry {
public:
typedef void(*hookfunc_t)(IVoidHookChain<t_args...>*, t_args...);
virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0;
virtual void unregisterHook(hookfunc_t hook) = 0;
};
// Hook chain registry(for hooks [un]registration)
template<typename t_class, typename ...t_args>
class IVoidHookChainRegistryClass {
public:
typedef void(*hookfunc_t)(IVoidHookChainClass<t_class, t_args...>*, t_class *, t_args...);
virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0;
virtual void unregisterHook(hookfunc_t hook) = 0;
};

View File

@ -0,0 +1,482 @@
/*
*
* 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
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* 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
* 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
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
#include <engine_strucs.h>
#include "regamedll_interfaces.h"
#include "regamedll_const.h"
#include "../common/hookchains.h"
#define REGAMEDLL_API_VERSION_MAJOR 5
#define REGAMEDLL_API_VERSION_MINOR 1
// CBasePlayer::Spawn hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_Spawn;
// CBasePlayer::Precache hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_Precache;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_Precache;
// CBasePlayer::ObjectCaps hook
typedef IHookChainClass<int, class CBasePlayer> IReGameHook_CBasePlayer_ObjectCaps;
typedef IHookChainRegistryClass<int, class CBasePlayer> IReGameHookRegistry_CBasePlayer_ObjectCaps;
// CBasePlayer::Classify hook
typedef IHookChainClass<int, class CBasePlayer> IReGameHook_CBasePlayer_Classify;
typedef IHookChainRegistryClass<int, class CBasePlayer> IReGameHookRegistry_CBasePlayer_Classify;
// CBasePlayer::TraceAttack hook
typedef IVoidHookChainClass<class CBasePlayer, struct entvars_s *, float, Vector &, TraceResult *, int> IReGameHook_CBasePlayer_TraceAttack;
typedef IVoidHookChainRegistryClass<class CBasePlayer, struct entvars_s *, float, Vector &, TraceResult *, int> IReGameHookRegistry_CBasePlayer_TraceAttack;
// CBasePlayer::TakeDamage hook
typedef IHookChainClass<BOOL, class CBasePlayer, struct entvars_s *, struct entvars_s *, float&, int> IReGameHook_CBasePlayer_TakeDamage;
typedef IHookChainRegistryClass<BOOL, class CBasePlayer, struct entvars_s *, struct entvars_s *, float&, int> IReGameHookRegistry_CBasePlayer_TakeDamage;
// CBasePlayer::TakeHealth hook
typedef IHookChainClass<BOOL, class CBasePlayer, float, int> IReGameHook_CBasePlayer_TakeHealth;
typedef IHookChainRegistryClass<BOOL, class CBasePlayer, float, int> IReGameHookRegistry_CBasePlayer_TakeHealth;
// CBasePlayer::Killed hook
typedef IVoidHookChainClass<class CBasePlayer, struct entvars_s *, int> IReGameHook_CBasePlayer_Killed;
typedef IVoidHookChainRegistryClass<class CBasePlayer, struct entvars_s *, int> IReGameHookRegistry_CBasePlayer_Killed;
// CBasePlayer::AddPoints hook
typedef IVoidHookChainClass<class CBasePlayer, int, BOOL> IReGameHook_CBasePlayer_AddPoints;
typedef IVoidHookChainRegistryClass<class CBasePlayer, int, BOOL> IReGameHookRegistry_CBasePlayer_AddPoints;
// CBasePlayer::AddPointsToTeam hook
typedef IVoidHookChainClass<class CBasePlayer, int, BOOL> IReGameHook_CBasePlayer_AddPointsToTeam;
typedef IVoidHookChainRegistryClass<class CBasePlayer, int, BOOL> IReGameHookRegistry_CBasePlayer_AddPointsToTeam;
// CBasePlayer::AddPlayerItem hook
typedef IHookChainClass<BOOL, class CBasePlayer, class CBasePlayerItem *> IReGameHook_CBasePlayer_AddPlayerItem;
typedef IHookChainRegistryClass<BOOL, class CBasePlayer, class CBasePlayerItem *> IReGameHookRegistry_CBasePlayer_AddPlayerItem;
// CBasePlayer::RemovePlayerItem hook
typedef IHookChainClass<BOOL, class CBasePlayer, class CBasePlayerItem *> IReGameHook_CBasePlayer_RemovePlayerItem;
typedef IHookChainRegistryClass<BOOL, class CBasePlayer, class CBasePlayerItem *> IReGameHookRegistry_CBasePlayer_RemovePlayerItem;
// CBasePlayer::GiveAmmo hook
typedef IHookChainClass<int, class CBasePlayer, int , char *, int> IReGameHook_CBasePlayer_GiveAmmo;
typedef IHookChainRegistryClass<int, class CBasePlayer, int , char *, int> IReGameHookRegistry_CBasePlayer_GiveAmmo;
// CBasePlayer::ResetMaxSpeed hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_ResetMaxSpeed;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_ResetMaxSpeed;
// CBasePlayer::Jump hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_Jump;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_Jump;
// CBasePlayer::Duck hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_Duck;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_Duck;
// CBasePlayer::PreThink hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_PreThink;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_PreThink;
// CBasePlayer::PostThink hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_PostThink;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_PostThink;
// CBasePlayer::UpdateClientData hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_UpdateClientData;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_UpdateClientData;
// CBasePlayer::ImpulseCommands hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_ImpulseCommands;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_ImpulseCommands;
// CBasePlayer::RoundRespawn hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_RoundRespawn;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_RoundRespawn;
// CBasePlayer::Blind hook
typedef IVoidHookChainClass<class CBasePlayer, float, float, float, int> IReGameHook_CBasePlayer_Blind;
typedef IVoidHookChainRegistryClass<class CBasePlayer, float, float, float, int> IReGameHookRegistry_CBasePlayer_Blind;
// CBasePlayer::Observer_IsValidTarget hook
typedef IHookChainClass<class CBasePlayer *, class CBasePlayer, int, bool> IReGameHook_CBasePlayer_Observer_IsValidTarget;
typedef IHookChainRegistryClass<class CBasePlayer *, class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget;
// CBasePlayer::SetAnimation hook
typedef IVoidHookChainClass<class CBasePlayer, PLAYER_ANIM> IReGameHook_CBasePlayer_SetAnimation;
typedef IVoidHookChainRegistryClass<class CBasePlayer, PLAYER_ANIM> IReGameHookRegistry_CBasePlayer_SetAnimation;
// CBasePlayer::GiveDefaultItems hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_GiveDefaultItems;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_GiveDefaultItems;
// CBasePlayer::GiveNamedItem hook
typedef IHookChainClass<class CBaseEntity *, class CBasePlayer, const char *> IReGameHook_CBasePlayer_GiveNamedItem;
typedef IHookChainRegistryClass<class CBaseEntity *, class CBasePlayer, const char *> IReGameHookRegistry_CBasePlayer_GiveNamedItem;
// CBasePlayer::AddAccount hook
typedef IVoidHookChainClass<class CBasePlayer, int, RewardType, bool> IReGameHook_CBasePlayer_AddAccount;
typedef IVoidHookChainRegistryClass<class CBasePlayer, int, RewardType, bool> IReGameHookRegistry_CBasePlayer_AddAccount;
// CBasePlayer::GiveShield hook
typedef IVoidHookChainClass<class CBasePlayer, bool> IReGameHook_CBasePlayer_GiveShield;
typedef IVoidHookChainRegistryClass<class CBasePlayer, bool> IReGameHookRegistry_CBasePlayer_GiveShield;
// CBasePlayer:SetClientUserInfoModel hook
typedef IVoidHookChainClass<class CBasePlayer, char *, char *> IReGameHook_CBasePlayer_SetClientUserInfoModel;
typedef IVoidHookChainRegistryClass<class CBasePlayer, char *, char *> IReGameHookRegistry_CBasePlayer_SetClientUserInfoModel;
// CBasePlayer:SetClientUserInfoName hook
typedef IHookChainClass<bool, class CBasePlayer, char *, char *> IReGameHook_CBasePlayer_SetClientUserInfoName;
typedef IHookChainRegistryClass<bool, class CBasePlayer, char *, char *> IReGameHookRegistry_CBasePlayer_SetClientUserInfoName;
// CBasePlayer::HasRestrictItem hook
typedef IHookChainClass<bool, class CBasePlayer, ItemID, ItemRestType> IReGameHook_CBasePlayer_HasRestrictItem;
typedef IHookChainRegistryClass<bool, class CBasePlayer, ItemID, ItemRestType> IReGameHookRegistry_CBasePlayer_HasRestrictItem;
// CBasePlayer::DropPlayerItem hook
typedef IVoidHookChainClass<class CBasePlayer, const char *> IReGameHook_CBasePlayer_DropPlayerItem;
typedef IVoidHookChainRegistryClass<class CBasePlayer, const char *> IReGameHookRegistry_CBasePlayer_DropPlayerItem;
// CBasePlayer::DropShield hook
typedef IVoidHookChainClass<class CBasePlayer, bool> IReGameHook_CBasePlayer_DropShield;
typedef IVoidHookChainRegistryClass<class CBasePlayer, bool> IReGameHookRegistry_CBasePlayer_DropShield;
// CBasePlayer::OnSpawnEquip hook
typedef IVoidHookChainClass<class CBasePlayer, bool, bool> IReGameHook_CBasePlayer_OnSpawnEquip;
typedef IVoidHookChainRegistryClass<class CBasePlayer, bool, bool> IReGameHookRegistry_CBasePlayer_OnSpawnEquip;
// CBasePlayer::Radio hook
typedef IVoidHookChainClass<class CBasePlayer, const char *, const char *, short, bool> IReGameHook_CBasePlayer_Radio;
typedef IVoidHookChainRegistryClass<class CBasePlayer, const char *, const char *, short, bool> IReGameHookRegistry_CBasePlayer_Radio;
// CBasePlayer::Disappear hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_Disappear;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_Disappear;
// CBasePlayer::MakeVIP hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_MakeVIP;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_MakeVIP;
// CBasePlayer::MakeBomber hook
typedef IHookChainClass<bool, class CBasePlayer> IReGameHook_CBasePlayer_MakeBomber;
typedef IHookChainRegistryClass<bool, class CBasePlayer> IReGameHookRegistry_CBasePlayer_MakeBomber;
// CBasePlayer::StartObserver hook
typedef IVoidHookChainClass<class CBasePlayer, Vector &, Vector &> IReGameHook_CBasePlayer_StartObserver;
typedef IVoidHookChainRegistryClass<class CBasePlayer, Vector &, Vector &> IReGameHookRegistry_CBasePlayer_StartObserver;
// CBasePlayer::GetIntoGame hook
typedef IHookChainClass<bool, class CBasePlayer> IReGameHook_CBasePlayer_GetIntoGame;
typedef IHookChainRegistryClass<bool, class CBasePlayer> IReGameHookRegistry_CBasePlayer_GetIntoGame;
// CBaseAnimating::ResetSequenceInfo hook
typedef IVoidHookChainClass<class CBaseAnimating> IReGameHook_CBaseAnimating_ResetSequenceInfo;
typedef IVoidHookChainRegistryClass<class CBaseAnimating> IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo;
// GetForceCamera hook
typedef IHookChain<int, class CBasePlayer *> IReGameHook_GetForceCamera;
typedef IHookChainRegistry<int, class CBasePlayer *> IReGameHookRegistry_GetForceCamera;
// PlayerBlind hook
typedef IVoidHookChain<class CBasePlayer *, struct entvars_s *, struct entvars_s *, float, float, int, Vector &> IReGameHook_PlayerBlind;
typedef IVoidHookChainRegistry<class CBasePlayer *, struct entvars_s *, struct entvars_s *, float, float, int, Vector &> IReGameHookRegistry_PlayerBlind;
// RadiusFlash_TraceLine hook
typedef IVoidHookChain<class CBasePlayer *, struct entvars_s *, struct entvars_s *, Vector &, Vector &, TraceResult *> IReGameHook_RadiusFlash_TraceLine;
typedef IVoidHookChainRegistry<class CBasePlayer *, struct entvars_s *, struct entvars_s *, Vector &, Vector &, TraceResult *> IReGameHookRegistry_RadiusFlash_TraceLine;
// RoundEnd hook
typedef IHookChain<bool, int, ScenarioEventEndRound, float> IReGameHook_RoundEnd;
typedef IHookChainRegistry<bool, int, ScenarioEventEndRound, float> IReGameHookRegistry_RoundEnd;
// InstallGameRules hook
typedef IHookChain<class CGameRules *> IReGameHook_InstallGameRules;
typedef IHookChainRegistry<class CGameRules *> IReGameHookRegistry_InstallGameRules;
// PM_Init hook
typedef IVoidHookChain<struct playermove_s *> IReGameHook_PM_Init;
typedef IVoidHookChainRegistry<struct playermove_s *> IReGameHookRegistry_PM_Init;
// PM_Move hook
typedef IVoidHookChain<struct playermove_s *, int> IReGameHook_PM_Move;
typedef IVoidHookChainRegistry<struct playermove_s *, int> IReGameHookRegistry_PM_Move;
// PM_AirMove hook
typedef IVoidHookChain<int> IReGameHook_PM_AirMove;
typedef IVoidHookChainRegistry<int> IReGameHookRegistry_PM_AirMove;
// HandleMenu_ChooseAppearance hook
typedef IVoidHookChain<class CBasePlayer *, int> IReGameHook_HandleMenu_ChooseAppearance;
typedef IVoidHookChainRegistry<class CBasePlayer *, int> IReGameHookRegistry_HandleMenu_ChooseAppearance;
// HandleMenu_ChooseTeam hook
typedef IHookChain<BOOL, class CBasePlayer *, int> IReGameHook_HandleMenu_ChooseTeam;
typedef IHookChainRegistry<BOOL, class CBasePlayer *, int> IReGameHookRegistry_HandleMenu_ChooseTeam;
// ShowMenu hook
typedef IVoidHookChain<class CBasePlayer *, int, int, BOOL, char *> IReGameHook_ShowMenu;
typedef IVoidHookChainRegistry<class CBasePlayer *, int, int, BOOL, char *> IReGameHookRegistry_ShowMenu;
// ShowVGUIMenu hook
typedef IVoidHookChain<class CBasePlayer *, int, int, char *> IReGameHook_ShowVGUIMenu;
typedef IVoidHookChainRegistry<class CBasePlayer *, int, int, char *> IReGameHookRegistry_ShowVGUIMenu;
// BuyGunAmmo hook
typedef IHookChain<bool, class CBasePlayer *, class CBasePlayerItem *, bool> IReGameHook_BuyGunAmmo;
typedef IHookChainRegistry<bool, class CBasePlayer *, class CBasePlayerItem *, bool> IReGameHookRegistry_BuyGunAmmo;
// BuyWeaponByWeaponID hook
typedef IHookChain<class CBaseEntity *, class CBasePlayer *, WeaponIdType> IReGameHook_BuyWeaponByWeaponID;
typedef IHookChainRegistry<class CBaseEntity *, class CBasePlayer *, WeaponIdType> IReGameHookRegistry_BuyWeaponByWeaponID;
// InternalCommand hook
typedef IVoidHookChain<edict_t *, const char *, const char *> IReGameHook_InternalCommand;
typedef IVoidHookChainRegistry<edict_t *, const char *, const char *> IReGameHookRegistry_InternalCommand;
// CHalfLifeMultiplay::FShouldSwitchWeapon hook
typedef IHookChain<BOOL, class CBasePlayer *, class CBasePlayerItem *> IReGameHook_CSGameRules_FShouldSwitchWeapon;
typedef IHookChainRegistry<BOOL, class CBasePlayer *, class CBasePlayerItem *> IReGameHookRegistry_CSGameRules_FShouldSwitchWeapon;
// CHalfLifeMultiplay::GetNextBestWeapon hook
typedef IHookChain<BOOL, class CBasePlayer *, class CBasePlayerItem *> IReGameHook_CSGameRules_GetNextBestWeapon;
typedef IHookChainRegistry<BOOL, class CBasePlayer *, class CBasePlayerItem *> IReGameHookRegistry_CSGameRules_GetNextBestWeapon;
// CHalfLifeMultiplay::FlPlayerFallDamage hook
typedef IHookChain<float, class CBasePlayer *> IReGameHook_CSGameRules_FlPlayerFallDamage;
typedef IHookChainRegistry<float, class CBasePlayer *> IReGameHookRegistry_CSGameRules_FlPlayerFallDamage;
// CHalfLifeMultiplay::FPlayerCanTakeDamage hook
typedef IHookChain<BOOL, class CBasePlayer *, CBaseEntity *> IReGameHook_CSGameRules_FPlayerCanTakeDamage;
typedef IHookChainRegistry<BOOL, class CBasePlayer *, CBaseEntity *> IReGameHookRegistry_CSGameRules_FPlayerCanTakeDamage;
// CHalfLifeMultiplay::PlayerSpawn hook
typedef IVoidHookChain<class CBasePlayer *> IReGameHook_CSGameRules_PlayerSpawn;
typedef IVoidHookChainRegistry<class CBasePlayer *> IReGameHookRegistry_CSGameRules_PlayerSpawn;
// CHalfLifeMultiplay::FPlayerCanRespawn hook
typedef IHookChain<BOOL, class CBasePlayer *> IReGameHook_CSGameRules_FPlayerCanRespawn;
typedef IHookChainRegistry<BOOL, class CBasePlayer *> IReGameHookRegistry_CSGameRules_FPlayerCanRespawn;
// CHalfLifeMultiplay::GetPlayerSpawnSpot hook
typedef IHookChain<struct edict_s *, class CBasePlayer *> IReGameHook_CSGameRules_GetPlayerSpawnSpot;
typedef IHookChainRegistry<struct edict_s *, class CBasePlayer *> IReGameHookRegistry_CSGameRules_GetPlayerSpawnSpot;
// CHalfLifeMultiplay::ClientUserInfoChanged hook
typedef IVoidHookChain<class CBasePlayer *, char *> IReGameHook_CSGameRules_ClientUserInfoChanged;
typedef IVoidHookChainRegistry<class CBasePlayer *, char *> IReGameHookRegistry_CSGameRules_ClientUserInfoChanged;
// CHalfLifeMultiplay::PlayerKilled hook
typedef IVoidHookChain<class CBasePlayer *, struct entvars_s *, struct entvars_s *> IReGameHook_CSGameRules_PlayerKilled;
typedef IVoidHookChainRegistry<class CBasePlayer *, struct entvars_s *, struct entvars_s *> IReGameHookRegistry_CSGameRules_PlayerKilled;
// CHalfLifeMultiplay::DeathNotice hook
typedef IVoidHookChain<class CBasePlayer *, struct entvars_s *, struct entvars_s *> IReGameHook_CSGameRules_DeathNotice;
typedef IVoidHookChainRegistry<class CBasePlayer *, struct entvars_s *, struct entvars_s *> IReGameHookRegistry_CSGameRules_DeathNotice;
// CHalfLifeMultiplay::CanHavePlayerItem hook
typedef IHookChain<BOOL, class CBasePlayer *, class CBasePlayerItem *> IReGameHook_CSGameRules_CanHavePlayerItem;
typedef IHookChainRegistry<BOOL, class CBasePlayer *, class CBasePlayerItem *> IReGameHookRegistry_CSGameRules_CanHavePlayerItem;
// CHalfLifeMultiplay::DeadPlayerWeapons hook
typedef IHookChain<int, class CBasePlayer *> IReGameHook_CSGameRules_DeadPlayerWeapons;
typedef IHookChainRegistry<int, class CBasePlayer *> IReGameHookRegistry_CSGameRules_DeadPlayerWeapons;
// CHalfLifeMultiplay::ServerDeactivate hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_ServerDeactivate;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_ServerDeactivate;
// CHalfLifeMultiplay::CheckMapConditions hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_CheckMapConditions;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_CheckMapConditions;
// CHalfLifeMultiplay::CleanUpMap hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_CleanUpMap;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_CleanUpMap;
// CHalfLifeMultiplay::RestartRound hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_RestartRound;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_RestartRound;
// CHalfLifeMultiplay::CheckWinConditions hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_CheckWinConditions;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_CheckWinConditions;
// CHalfLifeMultiplay::RemoveGuns hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_RemoveGuns;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_RemoveGuns;
// CHalfLifeMultiplay::GiveC4 hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_GiveC4;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_GiveC4;
// CHalfLifeMultiplay::ChangeLevel hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_ChangeLevel;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_ChangeLevel;
// CHalfLifeMultiplay::GoToIntermission hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_GoToIntermission;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_GoToIntermission;
// CHalfLifeMultiplay::BalanceTeams hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_BalanceTeams;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_BalanceTeams;
// CHalfLifeMultiplay::OnRoundFreezeEnd hook
typedef IVoidHookChain<> IReGameHook_CSGameRules_OnRoundFreezeEnd;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_OnRoundFreezeEnd;
// PM_UpdateStepSound hook
typedef IVoidHookChain<> IReGameHook_PM_UpdateStepSound;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_PM_UpdateStepSound;
class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
// CBasePlayer virtual
virtual IReGameHookRegistry_CBasePlayer_Spawn* CBasePlayer_Spawn() = 0;
virtual IReGameHookRegistry_CBasePlayer_Precache* CBasePlayer_Precache() = 0;
virtual IReGameHookRegistry_CBasePlayer_ObjectCaps* CBasePlayer_ObjectCaps() = 0;
virtual IReGameHookRegistry_CBasePlayer_Classify* CBasePlayer_Classify() = 0;
virtual IReGameHookRegistry_CBasePlayer_TraceAttack* CBasePlayer_TraceAttack() = 0;
virtual IReGameHookRegistry_CBasePlayer_TakeDamage* CBasePlayer_TakeDamage() = 0;
virtual IReGameHookRegistry_CBasePlayer_TakeHealth* CBasePlayer_TakeHealth() = 0;
virtual IReGameHookRegistry_CBasePlayer_Killed* CBasePlayer_Killed() = 0;
virtual IReGameHookRegistry_CBasePlayer_AddPoints* CBasePlayer_AddPoints() = 0;
virtual IReGameHookRegistry_CBasePlayer_AddPointsToTeam* CBasePlayer_AddPointsToTeam() = 0;
virtual IReGameHookRegistry_CBasePlayer_AddPlayerItem* CBasePlayer_AddPlayerItem() = 0;
virtual IReGameHookRegistry_CBasePlayer_RemovePlayerItem* CBasePlayer_RemovePlayerItem() = 0;
virtual IReGameHookRegistry_CBasePlayer_GiveAmmo* CBasePlayer_GiveAmmo() = 0;
virtual IReGameHookRegistry_CBasePlayer_ResetMaxSpeed* CBasePlayer_ResetMaxSpeed() = 0;
virtual IReGameHookRegistry_CBasePlayer_Jump* CBasePlayer_Jump() = 0;
virtual IReGameHookRegistry_CBasePlayer_Duck* CBasePlayer_Duck() = 0;
virtual IReGameHookRegistry_CBasePlayer_PreThink* CBasePlayer_PreThink() = 0;
virtual IReGameHookRegistry_CBasePlayer_PostThink* CBasePlayer_PostThink() = 0;
virtual IReGameHookRegistry_CBasePlayer_UpdateClientData* CBasePlayer_UpdateClientData() = 0;
virtual IReGameHookRegistry_CBasePlayer_ImpulseCommands* CBasePlayer_ImpulseCommands() = 0;
virtual IReGameHookRegistry_CBasePlayer_RoundRespawn* CBasePlayer_RoundRespawn() = 0;
virtual IReGameHookRegistry_CBasePlayer_Blind* CBasePlayer_Blind() = 0;
virtual IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget* CBasePlayer_Observer_IsValidTarget() = 0;
virtual IReGameHookRegistry_CBasePlayer_SetAnimation* CBasePlayer_SetAnimation() = 0;
virtual IReGameHookRegistry_CBasePlayer_GiveDefaultItems* CBasePlayer_GiveDefaultItems() = 0;
virtual IReGameHookRegistry_CBasePlayer_GiveNamedItem* CBasePlayer_GiveNamedItem() = 0;
virtual IReGameHookRegistry_CBasePlayer_AddAccount* CBasePlayer_AddAccount() = 0;
virtual IReGameHookRegistry_CBasePlayer_GiveShield* CBasePlayer_GiveShield() = 0;
virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoModel* CBasePlayer_SetClientUserInfoModel() = 0;
virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoName* CBasePlayer_SetClientUserInfoName() = 0;
virtual IReGameHookRegistry_CBasePlayer_HasRestrictItem* CBasePlayer_HasRestrictItem() = 0;
virtual IReGameHookRegistry_CBasePlayer_DropPlayerItem* CBasePlayer_DropPlayerItem() = 0;
virtual IReGameHookRegistry_CBasePlayer_DropShield* CBasePlayer_DropShield() = 0;
virtual IReGameHookRegistry_CBasePlayer_OnSpawnEquip* CBasePlayer_OnSpawnEquip() = 0;
virtual IReGameHookRegistry_CBasePlayer_Radio* CBasePlayer_Radio() = 0;
virtual IReGameHookRegistry_CBasePlayer_Disappear* CBasePlayer_Disappear() = 0;
virtual IReGameHookRegistry_CBasePlayer_MakeVIP* CBasePlayer_MakeVIP() = 0;
virtual IReGameHookRegistry_CBasePlayer_MakeBomber* CBasePlayer_MakeBomber() = 0;
virtual IReGameHookRegistry_CBasePlayer_StartObserver* CBasePlayer_StartObserver() = 0;
virtual IReGameHookRegistry_CBasePlayer_GetIntoGame* CBasePlayer_GetIntoGame() = 0;
virtual IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CBaseAnimating_ResetSequenceInfo() = 0;
virtual IReGameHookRegistry_GetForceCamera* GetForceCamera() = 0;
virtual IReGameHookRegistry_PlayerBlind* PlayerBlind() = 0;
virtual IReGameHookRegistry_RadiusFlash_TraceLine* RadiusFlash_TraceLine() = 0;
virtual IReGameHookRegistry_RoundEnd* RoundEnd() = 0;
virtual IReGameHookRegistry_InstallGameRules* InstallGameRules() = 0;
virtual IReGameHookRegistry_PM_Init* PM_Init() = 0;
virtual IReGameHookRegistry_PM_Move* PM_Move() = 0;
virtual IReGameHookRegistry_PM_AirMove* PM_AirMove() = 0;
virtual IReGameHookRegistry_HandleMenu_ChooseAppearance* HandleMenu_ChooseAppearance() = 0;
virtual IReGameHookRegistry_HandleMenu_ChooseTeam* HandleMenu_ChooseTeam() = 0;
virtual IReGameHookRegistry_ShowMenu* ShowMenu() = 0;
virtual IReGameHookRegistry_ShowVGUIMenu* ShowVGUIMenu() = 0;
virtual IReGameHookRegistry_BuyGunAmmo* BuyGunAmmo() = 0;
virtual IReGameHookRegistry_BuyWeaponByWeaponID* BuyWeaponByWeaponID() = 0;
virtual IReGameHookRegistry_InternalCommand* InternalCommand() = 0;
virtual IReGameHookRegistry_CSGameRules_FShouldSwitchWeapon* CSGameRules_FShouldSwitchWeapon() = 0;
virtual IReGameHookRegistry_CSGameRules_GetNextBestWeapon* CSGameRules_GetNextBestWeapon() = 0;
virtual IReGameHookRegistry_CSGameRules_FlPlayerFallDamage* CSGameRules_FlPlayerFallDamage() = 0;
virtual IReGameHookRegistry_CSGameRules_FPlayerCanTakeDamage* CSGameRules_FPlayerCanTakeDamage() = 0;
virtual IReGameHookRegistry_CSGameRules_PlayerSpawn* CSGameRules_PlayerSpawn() = 0;
virtual IReGameHookRegistry_CSGameRules_FPlayerCanRespawn* CSGameRules_FPlayerCanRespawn() = 0;
virtual IReGameHookRegistry_CSGameRules_GetPlayerSpawnSpot* CSGameRules_GetPlayerSpawnSpot() = 0;
virtual IReGameHookRegistry_CSGameRules_ClientUserInfoChanged* CSGameRules_ClientUserInfoChanged() = 0;
virtual IReGameHookRegistry_CSGameRules_PlayerKilled* CSGameRules_PlayerKilled() = 0;
virtual IReGameHookRegistry_CSGameRules_DeathNotice* CSGameRules_DeathNotice() = 0;
virtual IReGameHookRegistry_CSGameRules_CanHavePlayerItem* CSGameRules_CanHavePlayerItem() = 0;
virtual IReGameHookRegistry_CSGameRules_DeadPlayerWeapons* CSGameRules_DeadPlayerWeapons() = 0;
virtual IReGameHookRegistry_CSGameRules_ServerDeactivate* CSGameRules_ServerDeactivate() = 0;
virtual IReGameHookRegistry_CSGameRules_CheckMapConditions* CSGameRules_CheckMapConditions() = 0;
virtual IReGameHookRegistry_CSGameRules_CleanUpMap* CSGameRules_CleanUpMap() = 0;
virtual IReGameHookRegistry_CSGameRules_RestartRound* CSGameRules_RestartRound() = 0;
virtual IReGameHookRegistry_CSGameRules_CheckWinConditions* CSGameRules_CheckWinConditions() = 0;
virtual IReGameHookRegistry_CSGameRules_RemoveGuns* CSGameRules_RemoveGuns() = 0;
virtual IReGameHookRegistry_CSGameRules_GiveC4* CSGameRules_GiveC4() = 0;
virtual IReGameHookRegistry_CSGameRules_ChangeLevel* CSGameRules_ChangeLevel() = 0;
virtual IReGameHookRegistry_CSGameRules_GoToIntermission* CSGameRules_GoToIntermission() = 0;
virtual IReGameHookRegistry_CSGameRules_BalanceTeams* CSGameRules_BalanceTeams() = 0;
virtual IReGameHookRegistry_CSGameRules_OnRoundFreezeEnd* CSGameRules_OnRoundFreezeEnd() = 0;
virtual IReGameHookRegistry_PM_UpdateStepSound* PM_UpdateStepSound() = 0;
};
struct ReGameFuncs_t {
struct edict_s *(*CREATE_NAMED_ENTITY2)(string_t iClass);
void (*ChangeString)(char *&dest, const char *source);
void (*RadiusDamage)(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType);
void (*ClearMultiDamage)();
void (*ApplyMultiDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker);
void (*AddMultiDamage)(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType);
class CBaseEntity *(*UTIL_FindEntityByString)(class CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue);
void (*AddEntityHashValue)(entvars_t *pev, const char *value, hash_types_e fieldType);
void (*RemoveEntityHashValue)(entvars_t *pev, const char *value, hash_types_e fieldType);
int (*Cmd_Argc)();
const char *(*Cmd_Argv)(int i);
};
class IReGameApi {
public:
virtual ~IReGameApi() {}
virtual int GetMajorVersion() = 0;
virtual int GetMinorVersion() = 0;
virtual const ReGameFuncs_t* GetFuncs() = 0;
virtual IReGameHookchains* GetHookchains() = 0;
virtual class CGameRules* GetGameRules() = 0;
virtual struct WeaponInfoStruct* GetWeaponInfo(int weaponID) = 0;
virtual struct WeaponInfoStruct* GetWeaponInfo(const char* weaponName) = 0;
virtual struct playermove_s* GetPlayerMove() = 0;
virtual struct WeaponSlotInfo* GetWeaponSlot(WeaponIdType weaponID) = 0;
virtual struct WeaponSlotInfo* GetWeaponSlot(const char* weaponName) = 0;
virtual struct ItemInfo* GetItemInfo(WeaponIdType weaponID) = 0;
virtual struct AmmoInfo* GetAmmoInfo(AmmoType ammoID) = 0;
};
#define VRE_GAMEDLL_API_VERSION "VRE_GAMEDLL_API_VERSION001"

View File

@ -0,0 +1,740 @@
/*
*
* 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
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* 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
* 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
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
// custom enum
enum ArmorType
{
ARMOR_NONE, // no armor
ARMOR_KEVLAR, // body vest only
ARMOR_VESTHELM, // vest and helmet
};
enum ArmouryItemPack
{
ARMOURY_MP5NAVY,
ARMOURY_TMP,
ARMOURY_P90,
ARMOURY_MAC10,
ARMOURY_AK47,
ARMOURY_SG552,
ARMOURY_M4A1,
ARMOURY_AUG,
ARMOURY_SCOUT,
ARMOURY_G3SG1,
ARMOURY_AWP,
ARMOURY_M3,
ARMOURY_XM1014,
ARMOURY_M249,
ARMOURY_FLASHBANG,
ARMOURY_HEGRENADE,
ARMOURY_KEVLAR,
ARMOURY_ASSAULT,
ARMOURY_SMOKEGRENADE,
ARMOURY_GLOCK18,
ARMOURY_USP,
ARMOURY_ELITE,
ARMOURY_FIVESEVEN,
ARMOURY_P228,
ARMOURY_DEAGLE,
ARMOURY_FAMAS,
ARMOURY_SG550,
ARMOURY_GALIL,
ARMOURY_UMP45,
ARMOURY_SHIELD
};
struct AmmoInfo
{
const char *pszName;
int iId;
};
struct MULTIDAMAGE
{
CBaseEntity *pEntity;
float amount;
int type;
};
enum ItemRestType
{
ITEM_TYPE_BUYING, // when a player buying items
ITEM_TYPE_TOUCHED, // when the player touches with a weaponbox or armoury_entity
ITEM_TYPE_EQUIPPED // when a entity game_player_equip gives item to player or default item's on player spawn
};
// constant items
#define ITEM_ID_ANTIDOTE 2
#define ITEM_ID_SECURITY 3
enum ItemID
{
ITEM_NONE = -1,
ITEM_SHIELDGUN,
ITEM_P228,
ITEM_GLOCK,
ITEM_SCOUT,
ITEM_HEGRENADE,
ITEM_XM1014,
ITEM_C4,
ITEM_MAC10,
ITEM_AUG,
ITEM_SMOKEGRENADE,
ITEM_ELITE,
ITEM_FIVESEVEN,
ITEM_UMP45,
ITEM_SG550,
ITEM_GALIL,
ITEM_FAMAS,
ITEM_USP,
ITEM_GLOCK18,
ITEM_AWP,
ITEM_MP5N,
ITEM_M249,
ITEM_M3,
ITEM_M4A1,
ITEM_TMP,
ITEM_G3SG1,
ITEM_FLASHBANG,
ITEM_DEAGLE,
ITEM_SG552,
ITEM_AK47,
ITEM_KNIFE,
ITEM_P90,
ITEM_NVG,
ITEM_DEFUSEKIT,
ITEM_KEVLAR,
ITEM_ASSAULT,
ITEM_LONGJUMP,
ITEM_SODACAN,
ITEM_HEALTHKIT,
ITEM_ANTIDOTE,
ITEM_BATTERY
};
// custom enum
enum RewardType
{
RT_NONE,
RT_ROUND_BONUS,
RT_PLAYER_RESET,
RT_PLAYER_JOIN,
RT_PLAYER_SPEC_JOIN,
RT_PLAYER_BOUGHT_SOMETHING,
RT_HOSTAGE_TOOK,
RT_HOSTAGE_RESCUED,
RT_HOSTAGE_DAMAGED,
RT_HOSTAGE_KILLED,
RT_TEAMMATES_KILLED,
RT_ENEMY_KILLED,
RT_INTO_GAME,
RT_VIP_KILLED,
RT_VIP_RESCUED_MYSELF
};
enum PLAYER_ANIM
{
PLAYER_IDLE,
PLAYER_WALK,
PLAYER_JUMP,
PLAYER_SUPERJUMP,
PLAYER_DIE,
PLAYER_ATTACK1,
PLAYER_ATTACK2,
PLAYER_FLINCH,
PLAYER_LARGE_FLINCH,
PLAYER_RELOAD,
PLAYER_HOLDBOMB
};
enum TeamName
{
UNASSIGNED,
TERRORIST,
CT,
SPECTATOR,
};
enum ModelName
{
MODEL_UNASSIGNED,
MODEL_URBAN,
MODEL_TERROR,
MODEL_LEET,
MODEL_ARCTIC,
MODEL_GSG9,
MODEL_GIGN,
MODEL_SAS,
MODEL_GUERILLA,
MODEL_VIP,
MODEL_MILITIA,
MODEL_SPETSNAZ,
MODEL_AUTO
};
enum JoinState
{
JOINED,
SHOWLTEXT,
READINGLTEXT,
SHOWTEAMSELECT,
PICKINGTEAM,
GETINTOGAME
};
enum TrackCommands
{
CMD_SAY = 0,
CMD_SAYTEAM,
CMD_FULLUPDATE,
CMD_VOTE,
CMD_VOTEMAP,
CMD_LISTMAPS,
CMD_LISTPLAYERS,
CMD_NIGHTVISION,
COMMANDS_TO_TRACK,
};
struct RebuyStruct
{
int m_primaryWeapon;
int m_primaryAmmo;
int m_secondaryWeapon;
int m_secondaryAmmo;
int m_heGrenade;
int m_flashbang;
int m_smokeGrenade;
int m_defuser;
int m_nightVision;
ArmorType m_armor;
};
enum ThrowDirection
{
THROW_NONE,
THROW_FORWARD,
THROW_BACKWARD,
THROW_HITVEL,
THROW_BOMB,
THROW_GRENADE,
THROW_HITVEL_MINUS_AIRVEL
};
enum sbar_data
{
SBAR_ID_TARGETTYPE = 1,
SBAR_ID_TARGETNAME,
SBAR_ID_TARGETHEALTH,
SBAR_END
};
enum
{
WINSTATUS_CTS = 1,
WINSTATUS_TERRORISTS,
WINSTATUS_DRAW,
};
// custom enum
// used for EndRoundMessage() logged messages
enum ScenarioEventEndRound
{
ROUND_NONE,
ROUND_TARGET_BOMB,
ROUND_VIP_ESCAPED,
ROUND_VIP_ASSASSINATED,
ROUND_TERRORISTS_ESCAPED,
ROUND_CTS_PREVENT_ESCAPE,
ROUND_ESCAPING_TERRORISTS_NEUTRALIZED,
ROUND_BOMB_DEFUSED,
ROUND_CTS_WIN,
ROUND_TERRORISTS_WIN,
ROUND_END_DRAW,
ROUND_ALL_HOSTAGES_RESCUED,
ROUND_TARGET_SAVED,
ROUND_HOSTAGE_NOT_RESCUED,
ROUND_TERRORISTS_NOT_ESCAPED,
ROUND_VIP_NOT_ESCAPED,
ROUND_GAME_COMMENCE,
ROUND_GAME_RESTART,
ROUND_GAME_OVER
};
enum RewardRules
{
RR_CTS_WIN,
RR_TERRORISTS_WIN,
RR_TARGET_BOMB,
RR_VIP_ESCAPED,
RR_VIP_ASSASSINATED,
RR_TERRORISTS_ESCAPED,
RR_CTS_PREVENT_ESCAPE,
RR_ESCAPING_TERRORISTS_NEUTRALIZED,
RR_BOMB_DEFUSED,
RR_BOMB_PLANTED,
RR_BOMB_EXPLODED,
RR_ALL_HOSTAGES_RESCUED,
RR_TARGET_BOMB_SAVED,
RR_HOSTAGE_NOT_RESCUED,
RR_VIP_NOT_ESCAPED,
RR_LOSER_BONUS_DEFAULT,
RR_LOSER_BONUS_MIN,
RR_LOSER_BONUS_MAX,
RR_LOSER_BONUS_ADD,
RR_RESCUED_HOSTAGE,
RR_TOOK_HOSTAGE_ACC,
RR_TOOK_HOSTAGE,
RR_END
};
// custom enum
enum RewardAccount
{
REWARD_TARGET_BOMB = 3500,
REWARD_VIP_ESCAPED = 3500,
REWARD_VIP_ASSASSINATED = 3250,
REWARD_TERRORISTS_ESCAPED = 3150,
REWARD_CTS_PREVENT_ESCAPE = 3500,
REWARD_ESCAPING_TERRORISTS_NEUTRALIZED = 3250,
REWARD_BOMB_DEFUSED = 3250,
REWARD_BOMB_PLANTED = 800,
REWARD_BOMB_EXPLODED = 3250,
REWARD_CTS_WIN = 3000,
REWARD_TERRORISTS_WIN = 3000,
REWARD_ALL_HOSTAGES_RESCUED = 2500,
// the end round was by the expiration time
REWARD_TARGET_BOMB_SAVED = 3250,
REWARD_HOSTAGE_NOT_RESCUED = 3250,
REWARD_VIP_NOT_ESCAPED = 3250,
// loser bonus
REWARD_LOSER_BONUS_DEFAULT = 1400,
REWARD_LOSER_BONUS_MIN = 1500,
REWARD_LOSER_BONUS_MAX = 3000,
REWARD_LOSER_BONUS_ADD = 500,
REWARD_RESCUED_HOSTAGE = 750,
REWARD_KILLED_ENEMY = 300,
REWARD_KILLED_VIP = 2500,
REWARD_VIP_HAVE_SELF_RESCUED = 2500,
REWARD_TAKEN_HOSTAGE = 1000,
REWARD_TOOK_HOSTAGE_ACC = 100,
REWARD_TOOK_HOSTAGE = 150,
};
// custom enum
enum PaybackForBadThing
{
PAYBACK_FOR_KILLED_TEAMMATES = -3300,
};
// custom enum
enum InfoMapBuyParam
{
BUYING_EVERYONE = 0,
BUYING_ONLY_CTS,
BUYING_ONLY_TERRORISTS,
BUYING_NO_ONE,
};
// weapon respawning return codes
enum
{
GR_NONE = 0,
GR_WEAPON_RESPAWN_YES,
GR_WEAPON_RESPAWN_NO,
GR_AMMO_RESPAWN_YES,
GR_AMMO_RESPAWN_NO,
GR_ITEM_RESPAWN_YES,
GR_ITEM_RESPAWN_NO,
GR_PLR_DROP_GUN_ALL,
GR_PLR_DROP_GUN_ACTIVE,
GR_PLR_DROP_GUN_NO,
GR_PLR_DROP_AMMO_ALL,
GR_PLR_DROP_AMMO_ACTIVE,
GR_PLR_DROP_AMMO_NO,
};
// custom enum
enum
{
SCENARIO_BLOCK_TIME_EXPRIRED = (1 << 0), // flag "a"
SCENARIO_BLOCK_NEED_PLAYERS = (1 << 1), // flag "b"
SCENARIO_BLOCK_VIP_ESCAPE = (1 << 2), // flag "c"
SCENARIO_BLOCK_PRISON_ESCAPE = (1 << 3), // flag "d"
SCENARIO_BLOCK_BOMB = (1 << 4), // flag "e"
SCENARIO_BLOCK_TEAM_EXTERMINATION = (1 << 5), // flag "f"
SCENARIO_BLOCK_HOSTAGE_RESCUE = (1 << 6), // flag "g"
};
// Player relationship return codes
enum
{
GR_NOTTEAMMATE = 0,
GR_TEAMMATE,
GR_ENEMY,
GR_ALLY,
GR_NEUTRAL,
};
enum WeaponIdType
{
WEAPON_NONE,
WEAPON_P228,
WEAPON_GLOCK,
WEAPON_SCOUT,
WEAPON_HEGRENADE,
WEAPON_XM1014,
WEAPON_C4,
WEAPON_MAC10,
WEAPON_AUG,
WEAPON_SMOKEGRENADE,
WEAPON_ELITE,
WEAPON_FIVESEVEN,
WEAPON_UMP45,
WEAPON_SG550,
WEAPON_GALIL,
WEAPON_FAMAS,
WEAPON_USP,
WEAPON_GLOCK18,
WEAPON_AWP,
WEAPON_MP5N,
WEAPON_M249,
WEAPON_M3,
WEAPON_M4A1,
WEAPON_TMP,
WEAPON_G3SG1,
WEAPON_FLASHBANG,
WEAPON_DEAGLE,
WEAPON_SG552,
WEAPON_AK47,
WEAPON_KNIFE,
WEAPON_P90,
WEAPON_SHIELDGUN = 99
};
enum AutoBuyClassType
{
AUTOBUYCLASS_NONE = 0,
AUTOBUYCLASS_PRIMARY = (1 << 0),
AUTOBUYCLASS_SECONDARY = (1 << 1),
AUTOBUYCLASS_AMMO = (1 << 2),
AUTOBUYCLASS_ARMOR = (1 << 3),
AUTOBUYCLASS_DEFUSER = (1 << 4),
AUTOBUYCLASS_PISTOL = (1 << 5),
AUTOBUYCLASS_SMG = (1 << 6),
AUTOBUYCLASS_RIFLE = (1 << 7),
AUTOBUYCLASS_SNIPERRIFLE = (1 << 8),
AUTOBUYCLASS_SHOTGUN = (1 << 9),
AUTOBUYCLASS_MACHINEGUN = (1 << 10),
AUTOBUYCLASS_GRENADE = (1 << 11),
AUTOBUYCLASS_NIGHTVISION = (1 << 12),
AUTOBUYCLASS_SHIELD = (1 << 13),
};
enum AmmoCostType
{
AMMO_338MAG_PRICE = 125,
AMMO_357SIG_PRICE = 50,
AMMO_45ACP_PRICE = 25,
AMMO_50AE_PRICE = 40,
AMMO_556MM_PRICE = 60,
AMMO_57MM_PRICE = 50,
AMMO_762MM_PRICE = 80,
AMMO_9MM_PRICE = 20,
AMMO_BUCKSHOT_PRICE = 65,
};
// custom enum
// the default amount of ammo that comes with each gun when it spawns
enum ClipGiveDefault
{
P228_DEFAULT_GIVE = 13,
GLOCK18_DEFAULT_GIVE = 20,
SCOUT_DEFAULT_GIVE = 10,
HEGRENADE_DEFAULT_GIVE = 1,
XM1014_DEFAULT_GIVE = 7,
C4_DEFAULT_GIVE = 1,
MAC10_DEFAULT_GIVE = 30,
AUG_DEFAULT_GIVE = 30,
SMOKEGRENADE_DEFAULT_GIVE = 1,
ELITE_DEFAULT_GIVE = 30,
FIVESEVEN_DEFAULT_GIVE = 20,
UMP45_DEFAULT_GIVE = 25,
SG550_DEFAULT_GIVE = 30,
GALIL_DEFAULT_GIVE = 35,
FAMAS_DEFAULT_GIVE = 25,
USP_DEFAULT_GIVE = 12,
AWP_DEFAULT_GIVE = 10,
MP5NAVY_DEFAULT_GIVE = 30,
M249_DEFAULT_GIVE = 100,
M3_DEFAULT_GIVE = 8,
M4A1_DEFAULT_GIVE = 30,
TMP_DEFAULT_GIVE = 30,
G3SG1_DEFAULT_GIVE = 20,
FLASHBANG_DEFAULT_GIVE = 1,
DEAGLE_DEFAULT_GIVE = 7,
SG552_DEFAULT_GIVE = 30,
AK47_DEFAULT_GIVE = 30,
/*KNIFE_DEFAULT_GIVE = 1,*/
P90_DEFAULT_GIVE = 50,
};
enum ClipSizeType
{
P228_MAX_CLIP = 13,
GLOCK18_MAX_CLIP = 20,
SCOUT_MAX_CLIP = 10,
XM1014_MAX_CLIP = 7,
MAC10_MAX_CLIP = 30,
AUG_MAX_CLIP = 30,
ELITE_MAX_CLIP = 30,
FIVESEVEN_MAX_CLIP = 20,
UMP45_MAX_CLIP = 25,
SG550_MAX_CLIP = 30,
GALIL_MAX_CLIP = 35,
FAMAS_MAX_CLIP = 25,
USP_MAX_CLIP = 12,
AWP_MAX_CLIP = 10,
MP5N_MAX_CLIP = 30,
M249_MAX_CLIP = 100,
M3_MAX_CLIP = 8,
M4A1_MAX_CLIP = 30,
TMP_MAX_CLIP = 30,
G3SG1_MAX_CLIP = 20,
DEAGLE_MAX_CLIP = 7,
SG552_MAX_CLIP = 30,
AK47_MAX_CLIP = 30,
P90_MAX_CLIP = 50,
};
enum WeightWeapon
{
P228_WEIGHT = 5,
GLOCK18_WEIGHT = 5,
SCOUT_WEIGHT = 30,
HEGRENADE_WEIGHT = 2,
XM1014_WEIGHT = 20,
C4_WEIGHT = 3,
MAC10_WEIGHT = 25,
AUG_WEIGHT = 25,
SMOKEGRENADE_WEIGHT = 1,
ELITE_WEIGHT = 5,
FIVESEVEN_WEIGHT = 5,
UMP45_WEIGHT = 25,
SG550_WEIGHT = 20,
GALIL_WEIGHT = 25,
FAMAS_WEIGHT = 75,
USP_WEIGHT = 5,
AWP_WEIGHT = 30,
MP5NAVY_WEIGHT = 25,
M249_WEIGHT = 25,
M3_WEIGHT = 20,
M4A1_WEIGHT = 25,
TMP_WEIGHT = 25,
G3SG1_WEIGHT = 20,
FLASHBANG_WEIGHT = 1,
DEAGLE_WEIGHT = 7,
SG552_WEIGHT = 25,
AK47_WEIGHT = 25,
P90_WEIGHT = 26,
KNIFE_WEIGHT = 0,
};
enum MaxAmmoType
{
MAX_AMMO_BUCKSHOT = 32,
MAX_AMMO_9MM = 120,
MAX_AMMO_556NATO = 90,
MAX_AMMO_556NATOBOX = 200,
MAX_AMMO_762NATO = 90,
MAX_AMMO_45ACP = 100,
MAX_AMMO_50AE = 35,
MAX_AMMO_338MAGNUM = 30,
MAX_AMMO_57MM = 100,
MAX_AMMO_357SIG = 52,
// custom
MAX_AMMO_SMOKEGRENADE = 1,
MAX_AMMO_HEGRENADE = 1,
MAX_AMMO_FLASHBANG = 2,
};
enum AmmoType
{
AMMO_NONE,
AMMO_338MAGNUM,
AMMO_762NATO,
AMMO_556NATOBOX,
AMMO_556NATO,
AMMO_BUCKSHOT,
AMMO_45ACP,
AMMO_57MM,
AMMO_50AE,
AMMO_357SIG,
AMMO_9MM,
AMMO_FLASHBANG,
AMMO_HEGRENADE,
AMMO_SMOKEGRENADE,
AMMO_C4,
AMMO_MAX_TYPES
};
enum WeaponClassType
{
WEAPONCLASS_NONE,
WEAPONCLASS_KNIFE,
WEAPONCLASS_PISTOL,
WEAPONCLASS_GRENADE,
WEAPONCLASS_SUBMACHINEGUN,
WEAPONCLASS_SHOTGUN,
WEAPONCLASS_MACHINEGUN,
WEAPONCLASS_RIFLE,
WEAPONCLASS_SNIPERRIFLE,
WEAPONCLASS_MAX,
};
enum AmmoBuyAmount
{
AMMO_338MAG_BUY = 10,
AMMO_357SIG_BUY = 13,
AMMO_45ACP_BUY = 12,
AMMO_50AE_BUY = 7,
AMMO_556NATO_BUY = 30,
AMMO_556NATOBOX_BUY = 30,
AMMO_57MM_BUY = 50,
AMMO_762NATO_BUY = 30,
AMMO_9MM_BUY = 30,
AMMO_BUCKSHOT_BUY = 8,
};
enum shieldgun_e
{
SHIELDGUN_IDLE,
SHIELDGUN_SHOOT1,
SHIELDGUN_SHOOT2,
SHIELDGUN_SHOOT_EMPTY,
SHIELDGUN_RELOAD,
SHIELDGUN_DRAW,
SHIELDGUN_DRAWN_IDLE,
SHIELDGUN_UP,
SHIELDGUN_DOWN,
};
// custom
enum shieldgren_e
{
SHIELDREN_IDLE = 4,
SHIELDREN_UP,
SHIELDREN_DOWN
};
enum InventorySlotType
{
NONE_SLOT,
PRIMARY_WEAPON_SLOT,
PISTOL_SLOT,
KNIFE_SLOT,
GRENADE_SLOT,
C4_SLOT,
};
enum Bullet
{
BULLET_NONE,
BULLET_PLAYER_9MM,
BULLET_PLAYER_MP5,
BULLET_PLAYER_357,
BULLET_PLAYER_BUCKSHOT,
BULLET_PLAYER_CROWBAR,
BULLET_MONSTER_9MM,
BULLET_MONSTER_MP5,
BULLET_MONSTER_12MM,
BULLET_PLAYER_45ACP,
BULLET_PLAYER_338MAG,
BULLET_PLAYER_762MM,
BULLET_PLAYER_556MM,
BULLET_PLAYER_50AE,
BULLET_PLAYER_57MM,
BULLET_PLAYER_357SIG,
};
struct WeaponStruct
{
int m_type;
int m_price;
int m_side;
int m_slot;
int m_ammoPrice;
};
struct AutoBuyInfoStruct
{
AutoBuyClassType m_class;
char *m_command;
char *m_classname;
};
struct WeaponAliasInfo
{
char *alias;
WeaponIdType id;
};
struct WeaponBuyAliasInfo
{
char *alias;
WeaponIdType id;
char *failName;
};
struct WeaponClassAliasInfo
{
char *alias;
WeaponClassType id;
};
struct WeaponSlotInfo
{
WeaponIdType id;
InventorySlotType slot;
const char *weaponName;
};
enum hash_types_e { CLASSNAME };

View File

@ -0,0 +1,303 @@
/*
*
* 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
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* 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
* 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
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
#include "regamedll_const.h"
class CBaseEntity;
class CBasePlayer;
// Implementation wrapper
class CCSEntity {
public:
virtual ~CCSEntity() {}
virtual void FireBullets(int iShots, Vector &vecSrc, Vector &vecDirShooting, Vector &vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker);
virtual Vector FireBullets3(Vector &vecSrc, Vector &vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand);
public:
CBaseEntity *m_pContainingEntity;
};
class CCSDelay: public CCSEntity {};
class CCSAnimating: public CCSDelay {};
class CCSPlayerItem: public CCSAnimating {};
class CCSToggle: public CCSAnimating {};
class CCSMonster: public CCSToggle {};
class CCSWeaponBox: public CCSEntity {};
class CCSArmoury: public CCSEntity {};
class CCSPlayer: public CCSMonster {
public:
CCSPlayer() : m_bForceShowMenu(false)
{
m_szModel[0] = '\0';
}
virtual bool IsConnected() const;
virtual void SetAnimation(PLAYER_ANIM playerAnim);
virtual void AddAccount(int amount, RewardType type = RT_NONE, bool bTrackChange = true);
virtual CBaseEntity *GiveNamedItem(const char *pszName);
virtual CBaseEntity *GiveNamedItemEx(const char *pszName);
virtual void GiveDefaultItems();
virtual void GiveShield(bool bDeploy = true);
virtual void DropShield(bool bDeploy = true);
virtual void DropPlayerItem(const char *pszItemName);
virtual void RemoveShield();
virtual void RemoveAllItems(bool bRemoveSuit);
virtual bool RemovePlayerItem(const char* pszItemName);
virtual void SetPlayerModel(bool bHasC4);
virtual void SetPlayerModelEx(const char *modelName);
virtual void SetNewPlayerModel(const char *modelName);
virtual void ClientCommand(const char *cmd, const char *arg1 = nullptr, const char *arg2 = nullptr, const char *arg3 = nullptr);
virtual void SetProgressBarTime(int time);
virtual void SetProgressBarTime2(int time, float timeElapsed);
virtual struct edict_s *EntSelectSpawnPoint();
virtual void SetBombIcon(bool bFlash = false);
virtual void SetScoreAttrib(CBasePlayer *dest);
virtual void SendItemStatus();
virtual void ReloadWeapons(CBasePlayerItem *pWeapon = nullptr, bool bForceReload = false, bool bForceRefill = false);
virtual void Observer_SetMode(int iMode);
virtual bool SelectSpawnSpot(const char *pEntClassName, CBaseEntity* &pSpot);
virtual bool SwitchWeapon(CBasePlayerItem *pWeapon);
virtual void SwitchTeam();
virtual bool JoinTeam(TeamName team);
virtual void StartObserver(Vector& vecPosition, Vector& vecViewAngle);
virtual void TeamChangeUpdate();
virtual void DropSecondary();
virtual void DropPrimary();
virtual bool HasPlayerItem(CBasePlayerItem *pCheckItem);
virtual bool HasNamedPlayerItem(const char *pszItemName);
virtual CBasePlayerItem *GetItemById(WeaponIdType weaponID);
virtual CBasePlayerItem *GetItemByName(const char *itemName);
virtual void Disappear();
virtual void MakeVIP();
virtual bool MakeBomber();
CBasePlayer *BasePlayer() const;
public:
char m_szModel[32];
bool m_bForceShowMenu;
};
class CAPI_Bot: public CCSPlayer {};
class CAPI_CSBot: public CAPI_Bot {};
class CCSShield: public CCSEntity {};
class CCSDeadHEV: public CCSMonster {};
class CCSSprayCan: public CCSEntity {};
class CCSBloodSplat: public CCSEntity {};
class CCSPlayerWeapon: public CCSPlayerItem {};
class CCSWorld: public CCSEntity {};
class CCSDecal: public CCSEntity {};
class CCSCorpse: public CCSEntity {};
class CCSGrenade: public CCSMonster {};
class CCSAirtank: public CCSGrenade {};
class CCSPlayerAmmo: public CCSEntity {};
class CCS9MMAmmo: public CCSPlayerAmmo {};
class CCSBuckShotAmmo: public CCSPlayerAmmo {};
class CCS556NatoAmmo: public CCSPlayerAmmo {};
class CCS556NatoBoxAmmo: public CCSPlayerAmmo {};
class CCS762NatoAmmo: public CCSPlayerAmmo {};
class CCS45ACPAmmo: public CCSPlayerAmmo {};
class CCS50AEAmmo: public CCSPlayerAmmo {};
class CCS338MagnumAmmo: public CCSPlayerAmmo {};
class CCS57MMAmmo: public CCSPlayerAmmo {};
class CCS357SIGAmmo: public CCSPlayerAmmo {};
class CCSFuncWall: public CCSEntity {};
class CCSFuncWallToggle: public CCSFuncWall {};
class CCSFuncConveyor: public CCSFuncWall {};
class CCSFuncIllusionary: public CCSToggle {};
class CCSFuncMonsterClip: public CCSFuncWall {};
class CCSFuncRotating: public CCSEntity {};
class CCSPendulum: public CCSEntity {};
class CCSPointEntity: public CCSEntity {};
class CCSStripWeapons: public CCSPointEntity {};
class CCSInfoIntermission: public CCSPointEntity {};
class CCSRevertSaved: public CCSPointEntity {};
class CCSEnvGlobal: public CCSPointEntity {};
class CCSMultiSource: public CCSPointEntity {};
class CCSButton: public CCSToggle {};
class CCSRotButton: public CCSButton {};
class CCSMomentaryRotButton: public CCSToggle {};
class CCSEnvSpark: public CCSEntity {};
class CCSButtonTarget: public CCSEntity {};
class CCSDoor: public CCSToggle {};
class CCSRotDoor: public CCSDoor {};
class CCSMomentaryDoor: public CCSToggle {};
class CCSGib: public CCSEntity {};
class CCSBubbling: public CCSEntity {};
class CCSBeam: public CCSEntity {};
class CCSLightning: public CCSBeam {};
class CCSLaser: public CCSBeam {};
class CCSGlow: public CCSPointEntity {};
class CCSSprite: public CCSPointEntity {};
class CCSBombGlow: public CCSSprite {};
class CCSGibShooter: public CCSDelay {};
class CCSEnvShooter: public CCSGibShooter {};
class CCSTestEffect: public CCSDelay {};
class CCSBlood: public CCSPointEntity {};
class CCSShake: public CCSPointEntity {};
class CCSFade: public CCSPointEntity {};
class CCSMessage: public CCSPointEntity {};
class CCSEnvFunnel: public CCSDelay {};
class CCSEnvBeverage: public CCSDelay {};
class CCSItemSoda: public CCSEntity {};
class CCSShower: public CCSEntity {};
class CCSEnvExplosion: public CCSMonster {};
class CCSBreakable: public CCSDelay {};
class CCSPushable: public CCSBreakable {};
class CCSFuncTank: public CCSEntity {};
class CCSFuncTankGun: public CCSFuncTank {};
class CCSFuncTankLaser: public CCSFuncTank {};
class CCSFuncTankRocket: public CCSFuncTank {};
class CCSFuncTankMortar: public CCSFuncTank {};
class CCSFuncTankControls: public CCSEntity {};
class CCSRecharge: public CCSToggle {};
class CCSCycler: public CCSMonster {};
class CCSGenericCycler: public CCSCycler {};
class CCSCyclerProbe: public CCSCycler {};
class CCSCyclerSprite: public CCSEntity {};
class CCSWeaponCycler: public CCSPlayerWeapon {};
class CCSWreckage: public CCSMonster {};
class CCSWorldItem: public CCSEntity {};
class CCSItem: public CCSEntity {};
class CCSHealthKit: public CCSItem {};
class CCSWallHealth: public CCSToggle {};
class CCSItemSuit: public CCSItem {};
class CCSItemBattery: public CCSItem {};
class CCSItemAntidote: public CCSItem {};
class CCSItemSecurity: public CCSItem {};
class CCSItemLongJump: public CCSItem {};
class CCSItemKevlar: public CCSItem {};
class CCSItemAssaultSuit: public CCSItem {};
class CCSItemThighPack: public CCSItem {};
class CCSGrenCatch: public CCSEntity {};
class CCSFuncWeaponCheck: public CCSEntity {};
class CCSHostage: public CCSMonster {};
class CCSLight: public CCSPointEntity {};
class CCSEnvLight: public CCSLight {};
class CCSRuleEntity: public CCSEntity {};
class CCSRulePointEntity: public CCSRuleEntity {};
class CCSRuleBrushEntity: public CCSRuleEntity {};
class CCSGameScore: public CCSRulePointEntity {};
class CCSGameEnd: public CCSRulePointEntity {};
class CCSGameText: public CCSRulePointEntity {};
class CCSGameTeamMaster: public CCSRulePointEntity {};
class CCSGameTeamSet: public CCSRulePointEntity {};
class CCSGamePlayerZone: public CCSRuleBrushEntity {};
class CCSGamePlayerHurt: public CCSRulePointEntity {};
class CCSGameCounter: public CCSRulePointEntity {};
class CCSGameCounterSet: public CCSRulePointEntity {};
class CCSGamePlayerEquip: public CCSRulePointEntity {};
class CCSGamePlayerTeam: public CCSRulePointEntity {};
class CCSFuncMortarField: public CCSToggle {};
class CCSMortar: public CCSGrenade {};
class CCSMapInfo: public CCSPointEntity {};
class CCSPathCorner: public CCSPointEntity {};
class CCSPathTrack: public CCSPointEntity {};
class CCSFuncTrackTrain: public CCSEntity {};
class CCSFuncVehicleControls: public CCSEntity {};
class CCSFuncVehicle: public CCSEntity {};
class CCSPlatTrain: public CCSToggle {};
class CCSFuncPlat: public CCSPlatTrain {};
class CCSPlatTrigger: public CCSEntity {};
class CCSFuncPlatRot: public CCSFuncPlat {};
class CCSFuncTrain: public CCSPlatTrain {};
class CCSFuncTrainControls: public CCSEntity {};
class CCSFuncTrackChange: public CCSFuncPlatRot {};
class CCSFuncTrackAuto: public CCSFuncTrackChange {};
class CCSGunTarget: public CCSMonster {};
class CCSAmbientGeneric: public CCSEntity {};
class CCSEnvSound: public CCSPointEntity {};
class CCSSpeaker: public CCSEntity {};
class CCSSoundEnt: public CCSEntity {};
class CCSUSP: public CCSPlayerWeapon {};
class CCSMP5N: public CCSPlayerWeapon {};
class CCSSG552: public CCSPlayerWeapon {};
class CCSAK47: public CCSPlayerWeapon {};
class CCSAUG: public CCSPlayerWeapon {};
class CCSAWP: public CCSPlayerWeapon {};
class CCSC4: public CCSPlayerWeapon {};
class CCSDEAGLE: public CCSPlayerWeapon {};
class CCSFlashbang: public CCSPlayerWeapon {};
class CCSG3SG1: public CCSPlayerWeapon {};
class CCSGLOCK18: public CCSPlayerWeapon {};
class CCSHEGrenade: public CCSPlayerWeapon {};
class CCSKnife: public CCSPlayerWeapon {};
class CCSM249: public CCSPlayerWeapon {};
class CCSM3: public CCSPlayerWeapon {};
class CCSM4A1: public CCSPlayerWeapon {};
class CCSMAC10: public CCSPlayerWeapon {};
class CCSP228: public CCSPlayerWeapon {};
class CCSP90: public CCSPlayerWeapon {};
class CCSSCOUT: public CCSPlayerWeapon {};
class CCSSmokeGrenade: public CCSPlayerWeapon {};
class CCSTMP: public CCSPlayerWeapon {};
class CCSXM1014: public CCSPlayerWeapon {};
class CCSELITE: public CCSPlayerWeapon {};
class CCSFiveSeven: public CCSPlayerWeapon {};
class CCSUMP45: public CCSPlayerWeapon {};
class CCSSG550: public CCSPlayerWeapon {};
class CCSGalil: public CCSPlayerWeapon {};
class CCSFamas: public CCSPlayerWeapon {};
class CCSNullEntity: public CCSEntity {};
class CCSDMStart: public CCSPointEntity {};
class CCSFrictionModifier: public CCSEntity {};
class CCSAutoTrigger: public CCSDelay {};
class CCSTriggerRelay: public CCSDelay {};
class CCSMultiManager: public CCSToggle {};
class CCSRenderFxManager: public CCSEntity {};
class CCSTrigger: public CCSToggle {};
class CCSTriggerHurt: public CCSTrigger {};
class CCSTriggerMonsterJump: public CCSTrigger {};
class CCSTriggerCDAudio: public CCSTrigger {};
class CCSTargetCDAudio: public CCSPointEntity {};
class CCSTriggerMultiple: public CCSTrigger {};
class CCSTriggerOnce: public CCSTriggerMultiple {};
class CCSTriggerCounter: public CCSTrigger {};
class CCSTriggerVolume: public CCSPointEntity {};
class CCSFireAndDie: public CCSDelay {};
class CCSChangeLevel: public CCSTrigger {};
class CCSLadder: public CCSTrigger {};
class CCSTriggerPush: public CCSTrigger {};
class CCSTriggerTeleport: public CCSTrigger {};
class CCSBuyZone: public CCSTrigger {};
class CCSBombTarget: public CCSTrigger {};
class CCSHostageRescue: public CCSTrigger {};
class CCSEscapeZone: public CCSTrigger {};
class CCSVIP_SafetyZone: public CCSTrigger {};
class CCSTriggerSave: public CCSTrigger {};
class CCSTriggerEndSection: public CCSTrigger {};
class CCSTriggerGravity: public CCSTrigger {};
class CCSTriggerChangeTarget: public CCSDelay {};
class CCSTriggerCamera: public CCSDelay {};
class CCSWeather: public CCSTrigger {};
class CCSClientFog: public CCSEntity {};
inline CBasePlayer *CCSPlayer::BasePlayer() const {
return reinterpret_cast<CBasePlayer *>(this->m_pContainingEntity);
}

View File

@ -0,0 +1,61 @@
/*
*
* 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
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* 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
* 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
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
#include <archtypes.h>
class IRehldsFlightRecorder
{
public:
virtual ~IRehldsFlightRecorder() { }
virtual uint16 RegisterMessage(const char* module, const char *message, unsigned int version, bool inOut) = 0;
virtual void StartMessage(uint16 msg, bool entrance) = 0;
virtual void EndMessage(uint16 msg, bool entrance) = 0;
virtual void WriteInt8(int8 v) = 0;
virtual void WriteUInt8(uint8 v) = 0;
virtual void WriteInt16(int16 v) = 0;
virtual void WriteUInt16(uint16 v) = 0;
virtual void WriteInt32(int32 v) = 0;
virtual void WriteUInt32(uint32 v) = 0;
virtual void WriteInt64(int64 v) = 0;
virtual void WriteUInt64(uint64 v) = 0;
virtual void WriteFloat(float v) = 0;
virtual void WriteDouble(double v) = 0;
virtual void WriteString(const char* s) = 0;
virtual void WriteBuffer(const void* data ,unsigned int len) = 0;
};

View File

@ -0,0 +1,47 @@
/*
*
* 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
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* 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
* 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
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
typedef void(*xcommand_t)(void);
typedef struct cmd_function_s
{
struct cmd_function_s *next;
char *name;
xcommand_t function;
int flags;
} cmd_function_t;
typedef enum cmd_source_s
{
src_client = 0, // came in over a net connection as a clc_stringcmd. host_client will be valid during this state.
src_command = 1, // from the command buffer.
} cmd_source_t;
#define FCMD_HUD_COMMAND BIT(0)
#define FCMD_GAME_COMMAND BIT(1)
#define FCMD_WRAPPER_COMMAND BIT(2)

View File

@ -0,0 +1,300 @@
/*
*
* 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
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* 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
* 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
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
#include <engine_strucs.h>
#include <com_model.h>
#include "cmd_rehlds.h"
#include "rehlds_interfaces.h"
#include "FlightRecorder.h"
#include "../common/hookchains.h"
#define REHLDS_API_VERSION_MAJOR 3
#define REHLDS_API_VERSION_MINOR 0
//Steam_NotifyClientConnect hook
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
typedef IHookChainRegistry<qboolean, IGameClient*, const void*, unsigned int> IRehldsHookRegistry_Steam_NotifyClientConnect;
//SV_ConnectClient hook
typedef IVoidHookChain<> IRehldsHook_SV_ConnectClient;
typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_ConnectClient;
//SV_GetIDString hook
typedef IHookChain<char*, USERID_t*> IRehldsHook_SV_GetIDString;
typedef IHookChainRegistry<char*, USERID_t*> IRehldsHookRegistry_SV_GetIDString;
//SV_SendServerinfo hook
typedef IVoidHookChain<sizebuf_t*, IGameClient*> IRehldsHook_SV_SendServerinfo;
typedef IVoidHookChainRegistry<sizebuf_t*, IGameClient*> IRehldsHookRegistry_SV_SendServerinfo;
//SV_CheckProtocol hook
typedef IHookChain<int, netadr_t*, int> IRehldsHook_SV_CheckProtocol;
typedef IHookChainRegistry<int, netadr_t*, int> IRehldsHookRegistry_SV_CheckProtocol;
//SVC_GetChallenge_mod hook
typedef IVoidHookChain<char*, int> IRehldsHook_SVC_GetChallenge_mod;
typedef IVoidHookChainRegistry<char*, int> IRehldsHookRegistry_SVC_GetChallenge_mod;
//SV_CheckKeyInfo hook
typedef IHookChain<int, netadr_t*, char*, uint16*, int*, char*, char*> IRehldsHook_SV_CheckKeyInfo;
typedef IHookChainRegistry<int, netadr_t*, char*, uint16*, int*, char*, char*> IRehldsHookRegistry_SV_CheckKeyInfo;
//SV_CheckIPRestrictions hook
typedef IHookChain<int, netadr_t*, int> IRehldsHook_SV_CheckIPRestrictions;
typedef IHookChainRegistry<int, netadr_t*, int> IRehldsHookRegistry_SV_CheckIPRestrictions;
//SV_FinishCertificateCheck hook
typedef IHookChain<int, netadr_t*, int, char*, char*> IRehldsHook_SV_FinishCertificateCheck;
typedef IHookChainRegistry<int, netadr_t*, int, char*, char*> IRehldsHookRegistry_SV_FinishCertificateCheck;
//Steam_NotifyBotConnect hook
typedef IHookChain<qboolean, IGameClient*> IRehldsHook_Steam_NotifyBotConnect;
typedef IHookChainRegistry<qboolean, IGameClient*> IRehldsHookRegistry_Steam_NotifyBotConnect;
//SerializeSteamId
typedef IVoidHookChain<USERID_t*, USERID_t*> IRehldsHook_SerializeSteamId;
typedef IVoidHookChainRegistry<USERID_t*, USERID_t*> IRehldsHookRegistry_SerializeSteamId;
//SV_CompareUserID hook
typedef IHookChain<qboolean, USERID_t*, USERID_t*> IRehldsHook_SV_CompareUserID;
typedef IHookChainRegistry<qboolean, USERID_t*, USERID_t*> IRehldsHookRegistry_SV_CompareUserID;
//Steam_NotifyClientDisconnect
typedef IVoidHookChain<IGameClient*> IRehldsHook_Steam_NotifyClientDisconnect;
typedef IVoidHookChainRegistry<IGameClient*> IRehldsHookRegistry_Steam_NotifyClientDisconnect;
//PreProcessPacket
typedef IHookChain<bool, uint8*, unsigned int, const netadr_t&> IRehldsHook_PreprocessPacket;
typedef IHookChainRegistry<bool, uint8*, unsigned int, const netadr_t&> IRehldsHookRegistry_PreprocessPacket;
//ValidateCommand
typedef IHookChain<bool, const char*, cmd_source_t, IGameClient*> IRehldsHook_ValidateCommand;
typedef IHookChainRegistry<bool, const char*, cmd_source_t, IGameClient*> IRehldsHookRegistry_ValidateCommand;
//ExecuteServerStringCmd
typedef IVoidHookChain<const char*, cmd_source_t, IGameClient*> IRehldsHook_ExecuteServerStringCmd;
typedef IVoidHookChainRegistry<const char*, cmd_source_t, IGameClient*> IRehldsHookRegistry_ExecuteServerStringCmd;
//ClientConnected
typedef IVoidHookChain<IGameClient*> IRehldsHook_ClientConnected;
typedef IVoidHookChainRegistry<IGameClient*> IRehldsHookRegistry_ClientConnected;
//HandleNetCommand
typedef IVoidHookChain<IGameClient*, int8> IRehldsHook_HandleNetCommand;
typedef IVoidHookChainRegistry<IGameClient*, int8> IRehldsHookRegistry_HandleNetCommand;
//Mod_LoadBrushModel
typedef IVoidHookChain<model_t*, void*> IRehldsHook_Mod_LoadBrushModel;
typedef IVoidHookChainRegistry<model_t*, void*> IRehldsHookRegistry_Mod_LoadBrushModel;
//Mod_LoadStudioModel
typedef IVoidHookChain<model_t*, void*> IRehldsHook_Mod_LoadStudioModel;
typedef IVoidHookChainRegistry<model_t*, void*> IRehldsHookRegistry_Mod_LoadStudioModel;
//SV_EmitEvents hook
typedef IVoidHookChain<IGameClient *, struct packet_entities_s *, sizebuf_t *> IRehldsHook_SV_EmitEvents;
typedef IVoidHookChainRegistry<IGameClient *, struct packet_entities_s *, sizebuf_t *> IRehldsHookRegistry_SV_EmitEvents;
//EV_PlayReliableEvent hook
typedef IVoidHookChain<IGameClient *, int, unsigned short, float, struct event_args_s *> IRehldsHook_EV_PlayReliableEvent;
typedef IVoidHookChainRegistry<IGameClient *, int, unsigned short, float, struct event_args_s *> IRehldsHookRegistry_EV_PlayReliableEvent;
//SV_StartSound hook
typedef IVoidHookChain<int , edict_t *, int, const char *, int, float, int, int> IRehldsHook_SV_StartSound;
typedef IVoidHookChainRegistry<int , edict_t *, int, const char *, int, float, int, int> IRehldsHookRegistry_SV_StartSound;
//PF_Remove_I hook
typedef IVoidHookChain<edict_t *> IRehldsHook_PF_Remove_I;
typedef IVoidHookChainRegistry<edict_t *> IRehldsHookRegistry_PF_Remove_I;
//PF_BuildSoundMsg_I hook
typedef IVoidHookChain<edict_t *, int, const char *, float, float, int, int, int, int, const float *, edict_t *> IRehldsHook_PF_BuildSoundMsg_I;
typedef IVoidHookChainRegistry<edict_t *, int, const char *, float, float, int, int, int, int, const float *, edict_t *> IRehldsHookRegistry_PF_BuildSoundMsg_I;
//SV_WriteFullClientUpdate hook
typedef IVoidHookChain<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> IRehldsHook_SV_WriteFullClientUpdate;
typedef IVoidHookChainRegistry<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> IRehldsHookRegistry_SV_WriteFullClientUpdate;
//SV_CheckConsistencyResponse hook
typedef IHookChain<bool, IGameClient *, resource_t *, uint32> IRehldsHook_SV_CheckConsistencyResponse;
typedef IHookChainRegistry<bool, IGameClient *, resource_t *, uint32> IRehldsHookRegistry_SV_CheckConsistencyResponse;
//SV_DropClient hook
typedef IVoidHookChain<IGameClient*, bool, const char*> IRehldsHook_SV_DropClient;
typedef IVoidHookChainRegistry<IGameClient*, bool, const char*> IRehldsHookRegistry_SV_DropClient;
//SV_ActivateServer hook
typedef IVoidHookChain<int> IRehldsHook_SV_ActivateServer;
typedef IVoidHookChainRegistry<int> IRehldsHookRegistry_SV_ActivateServer;
//SV_WriteVoiceCodec hook
typedef IVoidHookChain<sizebuf_t *> IRehldsHook_SV_WriteVoiceCodec;
typedef IVoidHookChainRegistry<sizebuf_t *> IRehldsHookRegistry_SV_WriteVoiceCodec;
//Steam_GSGetSteamID hook
typedef IHookChain<uint64> IRehldsHook_Steam_GSGetSteamID;
typedef IHookChainRegistry<uint64> IRehldsHookRegistry_Steam_GSGetSteamID;
//SV_TransferConsistencyInfo hook
typedef IHookChain<int> IRehldsHook_SV_TransferConsistencyInfo;
typedef IHookChainRegistry<int> IRehldsHookRegistry_SV_TransferConsistencyInfo;
//Steam_GSBUpdateUserData hook
typedef IHookChain<bool, uint64, const char *, uint32> IRehldsHook_Steam_GSBUpdateUserData;
typedef IHookChainRegistry<bool, uint64, const char *, uint32> IRehldsHookRegistry_Steam_GSBUpdateUserData;
//Cvar_DirectSet hook
typedef IVoidHookChain<struct cvar_s *, const char *> IRehldsHook_Cvar_DirectSet;
typedef IVoidHookChainRegistry<struct cvar_s *, const char *> IRehldsHookRegistry_Cvar_DirectSet;
//SV_EstablishTimeBase hook
typedef IVoidHookChain<IGameClient *, struct usercmd_s *, int, int, int> IRehldsHook_SV_EstablishTimeBase;
typedef IVoidHookChainRegistry<IGameClient *, struct usercmd_s *, int, int, int> IRehldsHookRegistry_SV_EstablishTimeBase;
//SV_Spawn_f hook
typedef IVoidHookChain<> IRehldsHook_SV_Spawn_f;
typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Spawn_f;
//SV_CreatePacketEntities hook
typedef IHookChain<int, enum sv_delta_s, IGameClient *, struct packet_entities_s *, struct sizebuf_s *> IRehldsHook_SV_CreatePacketEntities;
typedef IHookChainRegistry<int, enum sv_delta_s, IGameClient *, struct packet_entities_s *, struct sizebuf_s *> IRehldsHookRegistry_SV_CreatePacketEntities;
//SV_EmitSound2 hook
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;
class IRehldsHookchains {
public:
virtual ~IRehldsHookchains() { }
virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect() = 0;
virtual IRehldsHookRegistry_SV_ConnectClient* SV_ConnectClient() = 0;
virtual IRehldsHookRegistry_SV_GetIDString* SV_GetIDString() = 0;
virtual IRehldsHookRegistry_SV_SendServerinfo* SV_SendServerinfo() = 0;
virtual IRehldsHookRegistry_SV_CheckProtocol* SV_CheckProtocol() = 0;
virtual IRehldsHookRegistry_SVC_GetChallenge_mod* SVC_GetChallenge_mod() = 0;
virtual IRehldsHookRegistry_SV_CheckKeyInfo* SV_CheckKeyInfo() = 0;
virtual IRehldsHookRegistry_SV_CheckIPRestrictions* SV_CheckIPRestrictions() = 0;
virtual IRehldsHookRegistry_SV_FinishCertificateCheck* SV_FinishCertificateCheck() = 0;
virtual IRehldsHookRegistry_Steam_NotifyBotConnect* Steam_NotifyBotConnect() = 0;
virtual IRehldsHookRegistry_SerializeSteamId* SerializeSteamId() = 0;
virtual IRehldsHookRegistry_SV_CompareUserID* SV_CompareUserID() = 0;
virtual IRehldsHookRegistry_Steam_NotifyClientDisconnect* Steam_NotifyClientDisconnect() = 0;
virtual IRehldsHookRegistry_PreprocessPacket* PreprocessPacket() = 0;
virtual IRehldsHookRegistry_ValidateCommand* ValidateCommand() = 0;
virtual IRehldsHookRegistry_ClientConnected* ClientConnected() = 0;
virtual IRehldsHookRegistry_HandleNetCommand* HandleNetCommand() = 0;
virtual IRehldsHookRegistry_Mod_LoadBrushModel* Mod_LoadBrushModel() = 0;
virtual IRehldsHookRegistry_Mod_LoadStudioModel* Mod_LoadStudioModel() = 0;
virtual IRehldsHookRegistry_ExecuteServerStringCmd* ExecuteServerStringCmd() = 0;
virtual IRehldsHookRegistry_SV_EmitEvents* SV_EmitEvents() = 0;
virtual IRehldsHookRegistry_EV_PlayReliableEvent* EV_PlayReliableEvent() = 0;
virtual IRehldsHookRegistry_SV_StartSound* SV_StartSound() = 0;
virtual IRehldsHookRegistry_PF_Remove_I* PF_Remove_I() = 0;
virtual IRehldsHookRegistry_PF_BuildSoundMsg_I* PF_BuildSoundMsg_I() = 0;
virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate() = 0;
virtual IRehldsHookRegistry_SV_CheckConsistencyResponse* SV_CheckConsistencyResponse() = 0;
virtual IRehldsHookRegistry_SV_DropClient* SV_DropClient() = 0;
virtual IRehldsHookRegistry_SV_ActivateServer* SV_ActivateServer() = 0;
virtual IRehldsHookRegistry_SV_WriteVoiceCodec* SV_WriteVoiceCodec() = 0;
virtual IRehldsHookRegistry_Steam_GSGetSteamID* Steam_GSGetSteamID() = 0;
virtual IRehldsHookRegistry_SV_TransferConsistencyInfo* SV_TransferConsistencyInfo() = 0;
virtual IRehldsHookRegistry_Steam_GSBUpdateUserData* Steam_GSBUpdateUserData() = 0;
virtual IRehldsHookRegistry_Cvar_DirectSet* Cvar_DirectSet() = 0;
virtual IRehldsHookRegistry_SV_EstablishTimeBase* SV_EstablishTimeBase() = 0;
virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f() = 0;
virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities() = 0;
virtual IRehldsHookRegistry_SV_EmitSound2* SV_EmitSound2() = 0;
};
struct RehldsFuncs_t {
void(*DropClient)(IGameClient* cl, bool crash, const char* fmt, ...);
void(*RejectConnection)(netadr_t *adr, char *fmt, ...);
qboolean(*SteamNotifyBotConnect)(IGameClient* cl);
sizebuf_t*(*GetNetMessage)();
IGameClient*(*GetHostClient)();
int*(*GetMsgReadCount)();
qboolean(*FilterUser)(USERID_t*);
void(*NET_SendPacket)(unsigned int length, void *data, const netadr_t &to);
void(*TokenizeString)(char* s);
bool(*CheckChallenge)(const netadr_t& adr, int challenge);
void(*SendUserReg)(sizebuf_t* msg);
void(*WriteDeltaDescriptionsToClient)(sizebuf_t* msg);
void(*SetMoveVars)();
void(*WriteMovevarsToClient)(sizebuf_t* msg);
char*(*GetClientFallback)();
int*(*GetAllowCheats)();
bool(*GSBSecure)();
int(*GetBuildNumber)();
double(*GetRealTime)();
int*(*GetMsgBadRead)();
cmd_source_t*(*GetCmdSource)();
void(*Log)(const char* prefix, const char* msg);
DLL_FUNCTIONS *(*GetEntityInterface)();
void(*EV_PlayReliableEvent)(IGameClient *cl, int entindex, unsigned short eventindex, float delay, struct event_args_s *pargs);
int(*SV_LookupSoundIndex)(const char *sample);
void(*MSG_StartBitWriting)(sizebuf_t *buf);
void(*MSG_WriteBits)(uint32 data, int numbits);
void(*MSG_WriteBitVec3Coord)(const float *fa);
void(*MSG_EndBitWriting)(sizebuf_t *buf);
void*(*SZ_GetSpace)(sizebuf_t *buf, int length);
cvar_t*(*GetCvarVars)();
int (*SV_GetChallenge)(const netadr_t& adr);
void (*SV_AddResource)(resourcetype_t type, const char *name, int size, unsigned char flags, int index);
int(*MSG_ReadShort)(void);
int(*MSG_ReadBuf)(int iSize, void *pbuf);
void(*MSG_WriteBuf)(sizebuf_t *sb, int iSize, void *buf);
void(*MSG_WriteByte)(sizebuf_t *sb, int c);
void(*MSG_WriteShort)(sizebuf_t *sb, int c);
void(*MSG_WriteString)(sizebuf_t *sb, const char *s);
void*(*GetPluginApi)(const char *name);
void(*RegisterPluginApi)(const char *name, void *impl);
qboolean(*SV_FileInConsistencyList)(const char *filename, struct consistency_s **ppconsist);
qboolean(*Steam_NotifyClientConnect)(IGameClient *cl, const void *pvSteam2Key, unsigned int ucbSteam2Key);
void(*Steam_NotifyClientDisconnect)(IGameClient* cl);
void(*SV_StartSound)(int recipients, edict_t *entity, int channel, const char *sample, int volume, float attenuation, int flags, int pitch);
bool(*SV_EmitSound2)(edict_t *entity, IGameClient *receiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin);
void(*SV_UpdateUserInfo)(IGameClient *pGameClient);
bool(*StripUnprintableAndSpace)(char *pch);
};
class IRehldsApi {
public:
virtual ~IRehldsApi() { }
virtual int GetMajorVersion() = 0;
virtual int GetMinorVersion() = 0;
virtual const RehldsFuncs_t* GetFuncs() = 0;
virtual IRehldsHookchains* GetHookchains() = 0;
virtual IRehldsServerStatic* GetServerStatic() = 0;
virtual IRehldsServerData* GetServerData() = 0;
virtual IRehldsFlightRecorder* GetFlightRecorder() = 0;
};
#define VREHLDS_HLDS_API_VERSION "VREHLDS_HLDS_API_VERSION001"

View File

@ -0,0 +1,109 @@
/*
*
* 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
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* 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
* 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
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
class INetChan;
class IGameClient;
#include <archtypes.h>
#include <const.h>
class INetChan;
class IGameClient;
class IGameClient {
public:
virtual int GetId() = 0;
virtual bool IsActive() = 0;
virtual void SetActive(bool active) = 0;
virtual bool IsSpawned() = 0;
virtual void SetSpawned(bool spawned) = 0;
virtual INetChan* GetNetChan() = 0;
virtual sizebuf_t* GetDatagram() = 0;
virtual edict_t* GetEdict() = 0;
virtual USERID_t* GetNetworkUserID() = 0;
virtual const char* GetName() = 0;
virtual bool IsConnected() = 0;
virtual void SetConnected(bool connected) = 0;
virtual uint32 GetVoiceStream(int stream_id) = 0;
virtual void SetLastVoiceTime(double time) = 0;
virtual double GetLastVoiceTime() = 0;
virtual bool GetLoopback() = 0;
virtual struct usercmd_s *GetLastCmd() = 0;
};
class INetChan {
public:
virtual const netadr_t* GetRemoteAdr() = 0;
virtual sizebuf_t* GetMessageBuf() = 0;
};
class IRehldsServerStatic {
public:
virtual ~IRehldsServerStatic() { }
virtual int GetMaxClients() = 0;
virtual bool IsLogActive() = 0;
virtual IGameClient* GetClient(int id) = 0;
virtual client_t* GetClient_t(int id) = 0;
virtual int GetIndexOfClient_t(client_t* client) = 0;
};
class IRehldsServerData {
public:
virtual ~IRehldsServerData() { }
virtual const char* GetModelName() = 0;
virtual const char* GetName() = 0;
virtual uint32 GetWorldmapCrc() = 0;
virtual uint8* GetClientDllMd5() = 0;
virtual sizebuf_t* GetDatagram() = 0;
virtual sizebuf_t* GetReliableDatagram() = 0;
virtual void SetModelName(const char* modelname) = 0;
virtual void SetConsistencyNum(int num) = 0;
virtual int GetConsistencyNum() = 0;
virtual int GetResourcesNum() = 0;
virtual int GetDecalNameNum() = 0;
virtual double GetTime() = 0;
virtual void SetResourcesNum(int num) = 0;
virtual struct resource_s *GetResource(int index) = 0;
virtual void SetName(const char* name) = 0;
virtual class ISteamGameServer *GetSteamGameServer() = 0;
virtual struct netadr_s *GetNetFrom() = 0;
};

View File

@ -0,0 +1,29 @@
#include "mod_regamedll_api.h"
IReGameApi* ReGameApi;
const ReGameFuncs_t* ReGameFuncs;
IReGameHookchains * ReGameHookchains;
bool RegamedllApi_Init()
{
auto library = GET_GAME_INFO(PLID, GINFO_DLL_FULLPATH);
if (!library || !GET_IFACE<IReGameApi>(library, ReGameApi, VRE_GAMEDLL_API_VERSION, false) || !ReGameApi)
{
return false;
}
auto majorVersion = ReGameApi->GetMajorVersion();
auto minorVersion = ReGameApi->GetMinorVersion();
if (majorVersion != REGAMEDLL_API_VERSION_MAJOR || minorVersion < REGAMEDLL_API_VERSION_MINOR)
{
return false;
}
ReGameFuncs = ReGameApi->GetFuncs();
ReGameHookchains = ReGameApi->GetHookchains();
return true;
}

View File

@ -0,0 +1,11 @@
#pragma once
#include <interface_helpers.h>
#include <resdk/cstrike/regamedll_api.h>
extern IReGameApi* ReGameApi;
extern const ReGameFuncs_t* ReGameFuncs;
extern IReGameHookchains* ReGameHookchains;
extern bool RegamedllApi_Init();

View File

@ -0,0 +1,37 @@
#include "mod_rehlds_api.h"
IRehldsApi* RehldsApi;
const RehldsFuncs_t* RehldsFuncs;
IRehldsServerData* RehldsData;
IRehldsHookchains* RehldsHookchains;
IRehldsServerStatic* RehldsSvs;
bool RehldsApi_Init()
{
#if defined(PLATFORM_WINDOWS)
auto library = "swds";
#elif defined(PLATFORM_POSIX)
auto library = "engine_i486";
#endif
if (!GET_IFACE<IRehldsApi>(library, RehldsApi, VREHLDS_HLDS_API_VERSION) || !RehldsApi)
{
return false;
}
auto majorVersion = RehldsApi->GetMajorVersion();
auto minorVersion = RehldsApi->GetMinorVersion();
if (majorVersion != REHLDS_API_VERSION_MAJOR || minorVersion < REHLDS_API_VERSION_MINOR)
{
return false;
}
RehldsFuncs = RehldsApi->GetFuncs();
RehldsData = RehldsApi->GetServerData();
RehldsHookchains = RehldsApi->GetHookchains();
RehldsSvs = RehldsApi->GetServerStatic();
return true;
}

View File

@ -0,0 +1,12 @@
#pragma once
#include <interface_helpers.h>
#include "engine/rehlds_api.h"
extern IRehldsApi* RehldsApi;
extern const RehldsFuncs_t* RehldsFuncs;
extern IRehldsServerData* RehldsData;
extern IRehldsHookchains* RehldsHookchains;
extern IRehldsServerStatic* RehldsSvs;
extern bool RehldsApi_Init();