mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-01 01:25:38 +03:00
Merge pull request #97 from s1lentq/master
ReHLDS API: Implemented SV_ActivateServer hook
This commit is contained in:
commit
056b02ad5e
@ -19,6 +19,18 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// Max # of clients allowed in a server.
|
||||
#define MAX_CLIENTS 32
|
||||
|
||||
// How many bits to use to encode an edict.
|
||||
#define MAX_EDICT_BITS 11 // # of bits needed to represent max edicts
|
||||
// Max # of edicts in a level (2048)
|
||||
#define MAX_EDICTS (1<<MAX_EDICT_BITS)
|
||||
|
||||
// How many data slots to use when in multiplayer (must be power of 2)
|
||||
#define MULTIPLAYER_BACKUP 64
|
||||
// Same for single player
|
||||
#define SINGLEPLAYER_BACKUP 8
|
||||
//
|
||||
// Constants shared by the engine and dlls
|
||||
// This header file included by engine files and DLL files.
|
||||
|
39
rehlds/common/qlimits.h
Normal file
39
rehlds/common/qlimits.h
Normal file
@ -0,0 +1,39 @@
|
||||
//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ==========
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#ifndef QLIMITS_H
|
||||
#define QLIMITS_H
|
||||
|
||||
#if defined( _WIN32 )
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// DATA STRUCTURE INFO
|
||||
|
||||
#define MAX_NUM_ARGVS 50
|
||||
|
||||
// SYSTEM INFO
|
||||
#define MAX_QPATH 64 // max length of a game pathname
|
||||
#define MAX_OSPATH 260 // max length of a filesystem pathname
|
||||
|
||||
#define ON_EPSILON 0.1 // point on plane side epsilon
|
||||
|
||||
#define MAX_LIGHTSTYLE_INDEX_BITS 6
|
||||
#define MAX_LIGHTSTYLES (1<<MAX_LIGHTSTYLE_INDEX_BITS)
|
||||
|
||||
// Resource counts;
|
||||
#define MAX_MODEL_INDEX_BITS 9 // sent as a short
|
||||
#define MAX_MODELS (1<<MAX_MODEL_INDEX_BITS)
|
||||
#define MAX_SOUND_INDEX_BITS 9
|
||||
#define MAX_SOUNDS (1<<MAX_SOUND_INDEX_BITS)
|
||||
|
||||
#define MAX_GENERIC_INDEX_BITS 9
|
||||
#define MAX_GENERIC (1<<MAX_GENERIC_INDEX_BITS)
|
||||
#define MAX_DECAL_INDEX_BITS 9
|
||||
#define MAX_BASE_DECALS (1<<MAX_DECAL_INDEX_BITS)
|
||||
|
||||
#endif // QLIMITS_H
|
@ -30,6 +30,9 @@
|
||||
/* <19039> ../common/quakedef.h:29 */
|
||||
typedef int BOOL; /* size: 4 */
|
||||
|
||||
// user message
|
||||
#define MAX_USER_MSG_DATA 192
|
||||
|
||||
/* <627f> ../common/quakedef.h:137 */
|
||||
//moved to com_model.h
|
||||
//typedef struct cache_user_s
|
||||
|
@ -32,6 +32,7 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#define MAX_CONSISTENCY_LIST 512
|
||||
|
||||
/* <7508> ../engine/consistency.h:9 */
|
||||
typedef struct consistency_s
|
||||
|
@ -34,6 +34,13 @@
|
||||
|
||||
#include "userid.h"
|
||||
|
||||
#ifdef REHLDS_FIXES
|
||||
#define MAX_IPFILTERS 4096
|
||||
#define MAX_USERFILTERS 4096
|
||||
#else
|
||||
#define MAX_IPFILTERS 32768
|
||||
#define MAX_USERFILTERS 32768
|
||||
#endif // REHLDS_FIXES
|
||||
|
||||
/* <a05ba> ../engine/filter.h:12 */
|
||||
typedef struct ipfilter_s
|
||||
|
@ -42,6 +42,11 @@
|
||||
|
||||
#define INFO_MAX_BUFFER_VALUES 4
|
||||
|
||||
#ifdef REHLDS_FIXES
|
||||
#define MAX_LOCALINFO 4096
|
||||
#else
|
||||
#define MAX_LOCALINFO MAX_INFO_STRING * 128
|
||||
#endif // REHLDS_FIXES
|
||||
|
||||
const char *Info_ValueForKey(const char *s, const char *key);
|
||||
void Info_RemoveKey(char *s, const char *key);
|
||||
|
@ -43,7 +43,11 @@
|
||||
// MAX_CHALLENGES is made large to prevent a denial
|
||||
// of service attack that could cycle all of them
|
||||
// out before legitimate users connected
|
||||
#define MAX_CHALLENGES 1024
|
||||
#ifdef REHLDS_OPT_PEDANTIC
|
||||
#define MAX_CHALLENGES 64
|
||||
#else
|
||||
#define MAX_CHALLENGES 1024
|
||||
#endif // REHLDS_OPT_PEDANTIC
|
||||
|
||||
// Client connection is initiated by requesting a challenge value
|
||||
// the server sends this value back
|
||||
|
@ -2163,12 +2163,14 @@ void EXT_FUNC PF_MessageEnd_I(void)
|
||||
if (pUserMsg->iSize == -1)
|
||||
{
|
||||
MsgIsVarLength = 1;
|
||||
if (gMsgBuffer.cursize > 192)
|
||||
|
||||
// Limit packet sizes
|
||||
if (gMsgBuffer.cursize > MAX_USER_MSG_DATA)
|
||||
Host_Error(
|
||||
"PF_MessageEnd_I: Refusing to send user message %s of %i bytes to client, user message size limit is %i bytes\n",
|
||||
pUserMsg->szName,
|
||||
gMsgBuffer.cursize,
|
||||
192
|
||||
MAX_USER_MSG_DATA
|
||||
);
|
||||
}
|
||||
else
|
||||
|
@ -35,18 +35,9 @@
|
||||
#include "maintypes.h"
|
||||
|
||||
// TODO: I think this defines must be in /common/
|
||||
#define MAX_CLIENTS 32
|
||||
#define MAX_EDICTS 900
|
||||
#define NUM_EDICTS 900
|
||||
#define MAX_NAME 32
|
||||
#define MAX_LIGHTSTYLES 64
|
||||
#define MAX_PACKET_ENTITIES 256
|
||||
#define MAX_RESOURCE_LIST 1280
|
||||
#define MAX_CONSISTENCY_LIST 512
|
||||
#ifdef REHLDS_OPT_PEDANTIC
|
||||
#define MAX_CHALLENGES 64
|
||||
#else
|
||||
#define MAX_CHALLENGES 1024
|
||||
#endif
|
||||
|
||||
#include "custom_int.h"
|
||||
#include "crc.h"
|
||||
@ -470,7 +461,7 @@ extern cvar_t lservercfgfile;
|
||||
extern cvar_t logsdir;
|
||||
extern cvar_t bannedcfgfile;
|
||||
|
||||
extern decalname_t sv_decalnames[512];
|
||||
extern decalname_t sv_decalnames[MAX_BASE_DECALS];
|
||||
extern int sv_decalnamecount;
|
||||
|
||||
extern UserMsg *sv_gpNewUserMsgs;
|
||||
@ -572,12 +563,12 @@ extern unsigned char fatpas[1024];
|
||||
|
||||
extern int gPacketSuppressed;
|
||||
|
||||
extern char localinfo[MAX_INFO_STRING * 128];
|
||||
extern char localmodels[512][5];
|
||||
extern char localinfo[MAX_LOCALINFO];
|
||||
extern char localmodels[MAX_MODELS][5];
|
||||
|
||||
extern ipfilter_t ipfilters[32768];
|
||||
extern ipfilter_t ipfilters[MAX_IPFILTERS];
|
||||
extern int numipfilters;
|
||||
extern userfilter_t userfilters[32768];
|
||||
extern userfilter_t userfilters[MAX_USERFILTERS];
|
||||
extern int numuserfilters;
|
||||
|
||||
extern challenge_t g_rg_sv_challenges[MAX_CHALLENGES];
|
||||
@ -730,6 +721,7 @@ void SV_BuildReconnect(sizebuf_t *msg);
|
||||
NOXREF void SV_ReconnectAllClients(void);
|
||||
void SetCStrikeFlags(void);
|
||||
void SV_ActivateServer(int runPhysics);
|
||||
void SV_ActivateServer_internal(int runPhysics);
|
||||
void SV_ServerShutdown(void);
|
||||
int SV_SpawnServer(qboolean bIsDemo, char *server, char *startspot);
|
||||
void SV_LoadEntities(void);
|
||||
|
@ -61,7 +61,7 @@ server_t g_psv;
|
||||
|
||||
rehlds_server_t g_rehlds_sv;
|
||||
|
||||
decalname_t sv_decalnames[512];
|
||||
decalname_t sv_decalnames[MAX_BASE_DECALS];
|
||||
int sv_decalnamecount;
|
||||
|
||||
UserMsg *sv_gpNewUserMsgs;
|
||||
@ -79,12 +79,12 @@ delta_t *g_peventdelta;
|
||||
|
||||
int gPacketSuppressed;
|
||||
|
||||
char localinfo[MAX_INFO_STRING * 128];
|
||||
char localmodels[512][5];
|
||||
char localinfo[MAX_LOCALINFO];
|
||||
char localmodels[MAX_MODELS][5];
|
||||
|
||||
ipfilter_t ipfilters[32768];
|
||||
ipfilter_t ipfilters[MAX_IPFILTERS];
|
||||
int numipfilters;
|
||||
userfilter_t userfilters[32768];
|
||||
userfilter_t userfilters[MAX_USERFILTERS];
|
||||
int numuserfilters;
|
||||
|
||||
|
||||
@ -117,8 +117,8 @@ qboolean allow_cheats;
|
||||
#ifndef HOOK_ENGINE
|
||||
|
||||
char *gNullString = "";
|
||||
int SV_UPDATE_BACKUP = 8;
|
||||
int SV_UPDATE_MASK = 7;
|
||||
int SV_UPDATE_BACKUP = SINGLEPLAYER_BACKUP;
|
||||
int SV_UPDATE_MASK = (SINGLEPLAYER_BACKUP - 1);
|
||||
int giNextUserMsg = 64;
|
||||
|
||||
cvar_t sv_lan = { "sv_lan", "0", 0, 0.0f, NULL };
|
||||
@ -847,7 +847,7 @@ qboolean SV_BuildSoundMsg(edict_t *entity, int channel, const char *sample, int
|
||||
if (field_mask & SND_FL_ATTENUATION)
|
||||
MSG_WriteBits((uint32)(attenuation * 64.0f), 8);
|
||||
MSG_WriteBits(channel, 3);
|
||||
MSG_WriteBits(ent, 11);
|
||||
MSG_WriteBits(ent, MAX_EDICT_BITS);
|
||||
MSG_WriteBits(sound_num, (field_mask & SND_FL_LARGE_INDEX) ? 16 : 8);
|
||||
MSG_WriteBitVec3Coord(origin);
|
||||
if (field_mask & SND_FL_PITCH)
|
||||
@ -2531,7 +2531,7 @@ void SV_ResetModInfo(void)
|
||||
Q_memset(&gmodinfo, 0, sizeof(modinfo_t));
|
||||
gmodinfo.version = 1;
|
||||
gmodinfo.svonly = TRUE;
|
||||
gmodinfo.num_edicts = MAX_EDICTS;
|
||||
gmodinfo.num_edicts = NUM_EDICTS;
|
||||
|
||||
Q_snprintf(szDllListFile, sizeof(szDllListFile), "%s", "liblist.gam");
|
||||
hLibListFile = FS_Open(szDllListFile, "rb");
|
||||
@ -5328,8 +5328,13 @@ void SetCStrikeFlags(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* <a9f01> ../engine/sv_main.c:7107 */
|
||||
void SV_ActivateServer(int runPhysics)
|
||||
{
|
||||
g_RehldsHookchains.m_SV_ActivateServer.callChain(SV_ActivateServer_internal, runPhysics);
|
||||
}
|
||||
|
||||
/* <a9f01> ../engine/sv_main.c:7107 */
|
||||
void EXT_FUNC SV_ActivateServer_internal(int runPhysics)
|
||||
{
|
||||
int i;
|
||||
unsigned char data[NET_MAX_PAYLOAD];
|
||||
@ -5511,8 +5516,8 @@ int SV_SpawnServer(qboolean bIsDemo, char *server, char *startspot)
|
||||
for (i = 0; i < g_psvs.maxclientslimit; i++, cl++)
|
||||
SV_ClearFrames(&cl->frames);
|
||||
|
||||
SV_UPDATE_BACKUP = g_psvs.maxclients != 1 ? 64 : 8;
|
||||
SV_UPDATE_MASK = g_psvs.maxclients != 1 ? 63 : 7;
|
||||
SV_UPDATE_BACKUP = (g_psvs.maxclients == 1) ? SINGLEPLAYER_BACKUP : MULTIPLAYER_BACKUP;
|
||||
SV_UPDATE_MASK = (SV_UPDATE_BACKUP - 1);
|
||||
|
||||
SV_AllocClientFrames();
|
||||
Q_memset(&g_psv, 0, sizeof(server_t));
|
||||
@ -7075,9 +7080,9 @@ void SV_Init(void)
|
||||
Cvar_RegisterVariable(&sv_allow_dlfile);
|
||||
Cvar_RegisterVariable(&sv_force_ent_intersection);
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(localmodels); i++)
|
||||
for (int i = 0; i < MAX_MODELS; i++)
|
||||
{
|
||||
Q_snprintf(localmodels[i], 5u, "*%i", i);
|
||||
Q_snprintf(localmodels[i], sizeof(localmodels[i]), "*%i", i);
|
||||
}
|
||||
|
||||
g_psvs.isSecure = FALSE;
|
||||
|
@ -76,7 +76,7 @@ qboolean g_bPrintingKeepAliveDots;
|
||||
qboolean gHasMMXTechnology;
|
||||
#endif // _WIN32
|
||||
//volatile int sys_checksum;
|
||||
//char *argv[50];
|
||||
//char *argv[MAX_NUM_ARGVS];
|
||||
qboolean con_debuglog;
|
||||
|
||||
#ifdef REHLDS_FIXES
|
||||
|
@ -343,6 +343,7 @@
|
||||
<ClInclude Include="..\common\pmtrace.h" />
|
||||
<ClInclude Include="..\common\port.h" />
|
||||
<ClInclude Include="..\common\qfont.h" />
|
||||
<ClInclude Include="..\common\qlimits.h" />
|
||||
<ClInclude Include="..\common\quakedef.h" />
|
||||
<ClInclude Include="..\common\ref_params.h" />
|
||||
<ClInclude Include="..\common\r_efx.h" />
|
||||
|
@ -1065,6 +1065,9 @@
|
||||
<ClInclude Include="..\rehlds\rehlds_security.h">
|
||||
<Filter>rehlds</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\qlimits.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\linux\appversion.sh">
|
||||
|
@ -28,6 +28,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "const.h"
|
||||
#include "qlimits.h"
|
||||
|
||||
#ifdef REHLDS_FIXES
|
||||
#define COM_TOKEN_LEN 2048
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "const.h"
|
||||
|
||||
#define MAX_QPATH 64 // Must match value in quakedefs.h
|
||||
#define MAX_RESOURCE_LIST 1280
|
||||
|
||||
/////////////////
|
||||
// Customization
|
||||
|
@ -149,6 +149,10 @@ typedef IHookChainRegistry<bool, IGameClient *, resource_t *, uint32> IRehldsHoo
|
||||
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;
|
||||
|
||||
class IRehldsHookchains {
|
||||
public:
|
||||
virtual ~IRehldsHookchains() { }
|
||||
@ -181,6 +185,7 @@ public:
|
||||
virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate() = 0;
|
||||
virtual IRehldsHookRegistry_SV_CheckConsistencyResponce* SV_CheckConsistencyResponce() = 0;
|
||||
virtual IRehldsHookRegistry_SV_DropClient* SV_DropClient() = 0;
|
||||
virtual IRehldsHookRegistry_SV_ActivateServer* SV_ActivateServer() = 0;
|
||||
};
|
||||
|
||||
struct RehldsFuncs_t {
|
||||
|
@ -115,4 +115,6 @@ public:
|
||||
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;
|
||||
};
|
||||
|
@ -268,6 +268,10 @@ IRehldsHookRegistry_SV_DropClient* CRehldsHookchains::SV_DropClient() {
|
||||
return &m_SV_DropClient;
|
||||
}
|
||||
|
||||
IRehldsHookRegistry_SV_ActivateServer* CRehldsHookchains::SV_ActivateServer() {
|
||||
return &m_SV_ActivateServer;
|
||||
}
|
||||
|
||||
int EXT_FUNC CRehldsApi::GetMajorVersion()
|
||||
{
|
||||
return REHLDS_API_VERSION_MAJOR;
|
||||
|
@ -143,6 +143,10 @@ typedef IHookChainRegistryImpl<bool, IGameClient *, resource_t *, uint32> CRehld
|
||||
typedef IVoidHookChainImpl<IGameClient*, bool, const char*> CRehldsHook_SV_DropClient;
|
||||
typedef IVoidHookChainRegistryImpl<IGameClient*, bool, const char*> CRehldsHookRegistry_SV_DropClient;
|
||||
|
||||
//SV_ActivateServer hook
|
||||
typedef IVoidHookChainImpl<int> CRehldsHook_SV_ActivateServer;
|
||||
typedef IVoidHookChainRegistryImpl<int> CRehldsHookRegistry_SV_ActivateServer;
|
||||
|
||||
class CRehldsHookchains : public IRehldsHookchains {
|
||||
public:
|
||||
CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect;
|
||||
@ -173,6 +177,7 @@ public:
|
||||
CRehldsHookRegistry_SV_WriteFullClientUpdate m_SV_WriteFullClientUpdate;
|
||||
CRehldsHookRegistry_SV_CheckConsistencyResponce m_SV_CheckConsistencyResponce;
|
||||
CRehldsHookRegistry_SV_DropClient m_SV_DropClient;
|
||||
CRehldsHookRegistry_SV_ActivateServer m_SV_ActivateServer;
|
||||
|
||||
public:
|
||||
virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
|
||||
@ -203,6 +208,7 @@ public:
|
||||
virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate();
|
||||
virtual IRehldsHookRegistry_SV_CheckConsistencyResponce* SV_CheckConsistencyResponce();
|
||||
virtual IRehldsHookRegistry_SV_DropClient* SV_DropClient();
|
||||
virtual IRehldsHookRegistry_SV_ActivateServer* SV_ActivateServer();
|
||||
};
|
||||
|
||||
extern CRehldsHookchains g_RehldsHookchains;
|
||||
|
@ -199,6 +199,14 @@ int EXT_FUNC CRehldsServerData::GetConsistencyNum() {
|
||||
return g_psv.num_consistency;
|
||||
}
|
||||
|
||||
int EXT_FUNC CRehldsServerData::GetResourcesNum() {
|
||||
return g_psv.num_resources;
|
||||
}
|
||||
|
||||
int EXT_FUNC CRehldsServerData::GetDecalNameNum() {
|
||||
return sv_decalnamecount;
|
||||
}
|
||||
|
||||
void Rehlds_Interfaces_FreeClients()
|
||||
{
|
||||
if (g_GameClients == NULL)
|
||||
|
@ -101,6 +101,8 @@ public:
|
||||
virtual void SetModelName(const char* modelname);
|
||||
virtual void SetConsistencyNum(int num);
|
||||
virtual int GetConsistencyNum();
|
||||
virtual int GetResourcesNum();
|
||||
virtual int GetDecalNameNum();
|
||||
};
|
||||
|
||||
extern CGameClient** g_GameClients;
|
||||
|
Loading…
Reference in New Issue
Block a user