mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-14 07:38:04 +03:00
Merge branch 'dreamstalker:master' into test-overflowfix-szgetspace
This commit is contained in:
commit
d36790b005
@ -170,7 +170,7 @@ byte *BSPModel::LeafPVS(mleaf_t *leaf)
|
||||
|
||||
byte *BSPModel::DecompressVis(unsigned char *in)
|
||||
{
|
||||
static unsigned char decompressed[MODEL_MAX_PVS];
|
||||
static unsigned char decompressed[MAX_MAP_LEAFS / 8];
|
||||
if (in == nullptr) {
|
||||
return m_novis;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include "l_studio.h"
|
||||
#include "edict.h"
|
||||
#include "bspfile.h"
|
||||
|
||||
// values for model_t's needload
|
||||
#define NL_PRESENT 0
|
||||
@ -87,9 +88,7 @@ private:
|
||||
|
||||
protected:
|
||||
model_t m_model;
|
||||
|
||||
enum { MODEL_MAX_PVS = 1024 };
|
||||
byte m_novis[MODEL_MAX_PVS];
|
||||
byte m_novis[MAX_MAP_LEAFS / 8];
|
||||
byte *m_base;
|
||||
|
||||
int m_visframecount;
|
||||
|
@ -31,17 +31,17 @@
|
||||
unsigned char *gPAS;
|
||||
unsigned char *gPVS;
|
||||
int gPVSRowBytes;
|
||||
unsigned char mod_novis[MODEL_MAX_PVS];
|
||||
unsigned char mod_novis[MAX_MAP_LEAFS / 8];
|
||||
|
||||
void Mod_Init(void)
|
||||
{
|
||||
SW_Mod_Init();
|
||||
Q_memset(mod_novis, 255, MODEL_MAX_PVS);
|
||||
Q_memset(mod_novis, 0xFF, MAX_MAP_LEAFS / 8);
|
||||
}
|
||||
|
||||
unsigned char *Mod_DecompressVis(unsigned char *in, model_t *model)
|
||||
{
|
||||
static unsigned char decompressed[MODEL_MAX_PVS];
|
||||
static unsigned char decompressed[MAX_MAP_LEAFS / 8];
|
||||
|
||||
if (in == NULL)
|
||||
{
|
||||
|
@ -29,15 +29,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "maintypes.h"
|
||||
#include "model.h"
|
||||
|
||||
// Looks like no more than 8096 visibility leafs per world model
|
||||
const int MODEL_MAX_PVS = 1024;
|
||||
|
||||
extern unsigned char *gPAS;
|
||||
extern unsigned char *gPVS;
|
||||
extern int gPVSRowBytes;
|
||||
extern unsigned char mod_novis[MODEL_MAX_PVS];
|
||||
|
||||
void Mod_Init(void);
|
||||
unsigned char *Mod_DecompressVis(unsigned char *in, model_t *model);
|
||||
|
@ -405,7 +405,6 @@ enum GameType_e
|
||||
|
||||
extern GameType_e g_eGameType;
|
||||
|
||||
extern int fatbytes;
|
||||
extern int giNextUserMsg;
|
||||
extern int hashstrings_collisions;
|
||||
|
||||
@ -418,10 +417,6 @@ extern delta_t *g_pweapondelta;
|
||||
extern delta_t *g_pusercmddelta;
|
||||
#endif
|
||||
|
||||
extern unsigned char fatpvs[1024];
|
||||
extern int fatpasbytes;
|
||||
extern unsigned char fatpas[1024];
|
||||
|
||||
extern int gPacketSuppressed;
|
||||
|
||||
extern char localinfo[MAX_LOCALINFO];
|
||||
|
@ -4030,9 +4030,10 @@ void SV_EmitEvents_internal(client_t *cl, packet_entities_t *pack, sizebuf_t *ms
|
||||
}
|
||||
|
||||
int fatbytes;
|
||||
unsigned char fatpvs[1024];
|
||||
unsigned char fatpvs[MAX_MAP_LEAFS / 8];
|
||||
|
||||
int fatpasbytes;
|
||||
unsigned char fatpas[1024];
|
||||
unsigned char fatpas[MAX_MAP_LEAFS / 8];
|
||||
|
||||
void SV_AddToFatPVS(vec_t *org, mnode_t *node)
|
||||
{
|
||||
@ -4074,6 +4075,9 @@ unsigned char* EXT_FUNC SV_FatPVS(float *org)
|
||||
#endif // REHLDS_FIXES
|
||||
fatbytes = (g_psv.worldmodel->numleafs + 31) >> 3;
|
||||
|
||||
if (fatbytes >= (MAX_MAP_LEAFS / 8))
|
||||
Sys_Error("%s: MAX_MAP_LEAFS limit exceeded\n", __func__);
|
||||
|
||||
Q_memset(fatpvs, 0, fatbytes);
|
||||
SV_AddToFatPVS(org, g_psv.worldmodel->nodes);
|
||||
return fatpvs;
|
||||
@ -4131,6 +4135,9 @@ unsigned char* EXT_FUNC SV_FatPAS(float *org)
|
||||
#endif // REHLDS_FIXES
|
||||
fatpasbytes = (g_psv.worldmodel->numleafs + 31) >> 3;
|
||||
|
||||
if (fatpasbytes >= (MAX_MAP_LEAFS / 8))
|
||||
Sys_Error("%s: MAX_MAP_LEAFS limit exceeded\n", __func__);
|
||||
|
||||
Q_memset(fatpas, 0, fatpasbytes);
|
||||
SV_AddToFatPAS(org, g_psv.worldmodel->nodes);
|
||||
return fatpas;
|
||||
@ -6155,7 +6162,7 @@ int SV_SpawnServer(qboolean bIsDemo, char *server, char *startspot)
|
||||
if (g_psvs.maxclients <= 1)
|
||||
{
|
||||
int row = (g_psv.worldmodel->numleafs + 7) / 8;
|
||||
if (row < 0 || row > MODEL_MAX_PVS)
|
||||
if (row < 0 || row > (MAX_MAP_LEAFS / 8))
|
||||
{
|
||||
Sys_Error("%s: oversized g_psv.worldmodel->numleafs: %i", __func__, g_psv.worldmodel->numleafs);
|
||||
}
|
||||
|
@ -511,6 +511,14 @@ void SV_CopyEdictToPhysent(physent_t *pe, int e, edict_t *check)
|
||||
pe->vuser4[2] = check->v.vuser4[2];
|
||||
}
|
||||
|
||||
bool EXT_FUNC SV_AllowPhysent_mod(edict_t* check, edict_t* sv_player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SV_AllowPhysent(edict_t* check, edict_t* sv_player) {
|
||||
return g_RehldsHookchains.m_SV_AllowPhysent.callChain(SV_AllowPhysent_mod, check, sv_player);
|
||||
}
|
||||
|
||||
void SV_AddLinksToPM_(areanode_t *node, float *pmove_mins, float *pmove_maxs)
|
||||
{
|
||||
struct link_s *l;
|
||||
@ -547,6 +555,11 @@ void SV_AddLinksToPM_(areanode_t *node, float *pmove_mins, float *pmove_maxs)
|
||||
if (check->v.solid != SOLID_BSP && check->v.solid != SOLID_BBOX && check->v.solid != SOLID_SLIDEBOX && check->v.solid != SOLID_NOT)
|
||||
continue;
|
||||
|
||||
// Apply our own custom checks
|
||||
if (!SV_AllowPhysent(check, sv_player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
e = NUM_FOR_EDICT(check);
|
||||
ve = &pmove->visents[pmove->numvisent];
|
||||
pmove->numvisent = pmove->numvisent + 1;
|
||||
|
@ -32,6 +32,7 @@
|
||||
#define HLBSP_VERSION 30 // half-life regular version
|
||||
|
||||
#define MAX_MAP_HULLS 4
|
||||
#define MAX_MAP_LEAFS 32767 // signed short limit
|
||||
|
||||
#define CONTENTS_ORIGIN -7 // removed at csg time
|
||||
#define CONTENTS_CLIP -8 // changed to contents_solid
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include "pr_dlls.h"
|
||||
|
||||
#define REHLDS_API_VERSION_MAJOR 3
|
||||
#define REHLDS_API_VERSION_MINOR 12
|
||||
#define REHLDS_API_VERSION_MINOR 13
|
||||
|
||||
//Steam_NotifyClientConnect hook
|
||||
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
|
||||
@ -255,6 +255,10 @@ typedef IVoidHookChainRegistry<resourcetype_t, const char *, int, unsigned char,
|
||||
typedef IVoidHookChain<const char *> IRehldsHook_SV_ClientPrintf;
|
||||
typedef IVoidHookChainRegistry<const char *> IRehldsHookRegistry_SV_ClientPrintf;
|
||||
|
||||
//SV_AllowPhysent hook
|
||||
typedef IHookChain<bool, edict_t*, edict_t*> IRehldsHook_SV_AllowPhysent;
|
||||
typedef IHookChainRegistry<bool, edict_t*, edict_t*> IRehldsHookRegistry_SV_AllowPhysent;
|
||||
|
||||
class IRehldsHookchains {
|
||||
public:
|
||||
virtual ~IRehldsHookchains() { }
|
||||
@ -313,6 +317,7 @@ public:
|
||||
virtual IRehldsHookRegistry_EV_Precache* EV_Precache() = 0;
|
||||
virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource() = 0;
|
||||
virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf() = 0;
|
||||
virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent() = 0;
|
||||
};
|
||||
|
||||
struct RehldsFuncs_t {
|
||||
|
@ -879,6 +879,10 @@ IRehldsHookRegistry_SV_ClientPrintf* CRehldsHookchains::SV_ClientPrintf(){
|
||||
return &m_SV_ClientPrintf;
|
||||
}
|
||||
|
||||
IRehldsHookRegistry_SV_AllowPhysent* CRehldsHookchains::SV_AllowPhysent() {
|
||||
return &m_SV_AllowPhysent;
|
||||
}
|
||||
|
||||
int EXT_FUNC CRehldsApi::GetMajorVersion()
|
||||
{
|
||||
return REHLDS_API_VERSION_MAJOR;
|
||||
|
@ -250,6 +250,10 @@ typedef IVoidHookChainRegistryImpl<resourcetype_t, const char*, int, unsigned ch
|
||||
typedef IVoidHookChainImpl<const char*> CRehldsHook_SV_ClientPrintf;
|
||||
typedef IVoidHookChainRegistryImpl<const char*> CRehldsHookRegistry_SV_ClientPrintf;
|
||||
|
||||
//SV_AllowPhysent hook
|
||||
typedef IHookChainImpl<bool, edict_t*, edict_t*> CRehldsHook_SV_AllowPhysent;
|
||||
typedef IHookChainRegistryImpl<bool, edict_t*, edict_t*> CRehldsHookRegistry_SV_AllowPhysent;
|
||||
|
||||
class CRehldsHookchains : public IRehldsHookchains {
|
||||
public:
|
||||
CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect;
|
||||
@ -306,6 +310,7 @@ public:
|
||||
CRehldsHookRegistry_EV_Precache m_EV_Precache;
|
||||
CRehldsHookRegistry_SV_AddResource m_SV_AddResource;
|
||||
CRehldsHookRegistry_SV_ClientPrintf m_SV_ClientPrintf;
|
||||
CRehldsHookRegistry_SV_AllowPhysent m_SV_AllowPhysent;
|
||||
|
||||
public:
|
||||
EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
|
||||
@ -362,6 +367,7 @@ public:
|
||||
EXT_FUNC virtual IRehldsHookRegistry_EV_Precache* EV_Precache();
|
||||
EXT_FUNC virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource();
|
||||
EXT_FUNC virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf();
|
||||
EXT_FUNC virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent();
|
||||
};
|
||||
|
||||
extern CRehldsHookchains g_RehldsHookchains;
|
||||
|
@ -6,5 +6,5 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_MAJOR 3
|
||||
#define VERSION_MINOR 12
|
||||
#define VERSION_MINOR 13
|
||||
#define VERSION_MAINTENANCE 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user