Skip to content

Commit 0621bef

Browse files
authored
Merge branch 'dreamstalker:master' into master
2 parents c1d81f0 + f955b07 commit 0621bef

File tree

14 files changed

+87
-34
lines changed

14 files changed

+87
-34
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ jobs:
277277
github.event.action == 'published' &&
278278
startsWith(github.ref, 'refs/tags/')
279279
run: |
280-
7z a -tzip rehlds-bin-${{ env.APP_VERSION }}.zip bin/linux32/ hlsdk/
280+
7z a -tzip rehlds-bin-${{ env.APP_VERSION }}.zip bin/ hlsdk/
281281
7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -aoa rehlds-dbg-${{ env.APP_VERSION }}.7z debug/
282282
283283
- name: Publish artifacts

rehlds/HLTV/Core/src/BSPModel.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ byte *BSPModel::LeafPVS(mleaf_t *leaf)
170170

171171
byte *BSPModel::DecompressVis(unsigned char *in)
172172
{
173-
static unsigned char decompressed[MODEL_MAX_PVS];
173+
static unsigned char decompressed[MAX_MAP_LEAFS / 8];
174174
if (in == nullptr) {
175175
return m_novis;
176176
}

rehlds/HLTV/Core/src/BSPModel.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include "l_studio.h"
3434
#include "edict.h"
35+
#include "bspfile.h"
3536

3637
// values for model_t's needload
3738
#define NL_PRESENT 0
@@ -87,9 +88,7 @@ class BSPModel: public IBSPModel {
8788

8889
protected:
8990
model_t m_model;
90-
91-
enum { MODEL_MAX_PVS = 1024 };
92-
byte m_novis[MODEL_MAX_PVS];
91+
byte m_novis[MAX_MAP_LEAFS / 8];
9392
byte *m_base;
9493

9594
int m_visframecount;

rehlds/engine/cmodel.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@
3131
unsigned char *gPAS;
3232
unsigned char *gPVS;
3333
int gPVSRowBytes;
34-
unsigned char mod_novis[MODEL_MAX_PVS];
34+
unsigned char mod_novis[MAX_MAP_LEAFS / 8];
3535

3636
void Mod_Init(void)
3737
{
3838
SW_Mod_Init();
39-
Q_memset(mod_novis, 255, MODEL_MAX_PVS);
39+
Q_memset(mod_novis, 0xFF, MAX_MAP_LEAFS / 8);
4040
}
4141

4242
unsigned char *Mod_DecompressVis(unsigned char *in, model_t *model)
4343
{
44-
static unsigned char decompressed[MODEL_MAX_PVS];
44+
static unsigned char decompressed[MAX_MAP_LEAFS / 8];
4545

4646
if (in == NULL)
4747
{

rehlds/engine/cmodel.h

-5
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,10 @@
2929
#pragma once
3030

3131
#include "maintypes.h"
32-
#include "model.h"
33-
34-
// Looks like no more than 8096 visibility leafs per world model
35-
const int MODEL_MAX_PVS = 1024;
3632

3733
extern unsigned char *gPAS;
3834
extern unsigned char *gPVS;
3935
extern int gPVSRowBytes;
40-
extern unsigned char mod_novis[MODEL_MAX_PVS];
4136

4237
void Mod_Init(void);
4338
unsigned char *Mod_DecompressVis(unsigned char *in, model_t *model);

rehlds/engine/r_studio.cpp

+22-4
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,15 @@ void EXT_FUNC AnimationAutomove(const edict_t *pEdict, float flTime)
881881
void EXT_FUNC GetBonePosition(const edict_t *pEdict, int iBone, float *rgflOrigin, float *rgflAngles)
882882
{
883883
pstudiohdr = (studiohdr_t *)Mod_Extradata(g_psv.models[pEdict->v.modelindex]);
884+
885+
#ifdef REHLDS_FIXES
886+
if (!pstudiohdr)
887+
return;
888+
889+
if (iBone < 0 || iBone >= pstudiohdr->numbones)
890+
return; // invalid bone
891+
#endif
892+
884893
g_pSvBlendingAPI->SV_StudioSetupBones(
885894
g_psv.models[pEdict->v.modelindex],
886895
pEdict->v.frame,
@@ -906,14 +915,23 @@ void EXT_FUNC GetAttachment(const edict_t *pEdict, int iAttachment, float *rgflO
906915
mstudioattachment_t *pattachment;
907916
vec3_t angles;
908917

909-
angles[0] = -pEdict->v.angles[0];
910-
angles[1] = pEdict->v.angles[1];
911-
angles[2] = pEdict->v.angles[2];
912-
913918
pstudiohdr = (studiohdr_t *)Mod_Extradata(g_psv.models[pEdict->v.modelindex]);
919+
920+
#ifdef REHLDS_FIXES
921+
if (!pstudiohdr)
922+
return;
923+
924+
if (iAttachment < 0 || iAttachment >= pstudiohdr->numattachments)
925+
return; // invalid attachment
926+
#endif
927+
914928
pattachment = (mstudioattachment_t *)((char *)pstudiohdr + pstudiohdr->attachmentindex);
915929
pattachment += iAttachment;
916930

931+
angles[0] = -pEdict->v.angles[0];
932+
angles[1] = pEdict->v.angles[1];
933+
angles[2] = pEdict->v.angles[2];
934+
917935
g_pSvBlendingAPI->SV_StudioSetupBones(
918936
g_psv.models[pEdict->v.modelindex],
919937
pEdict->v.frame,

rehlds/engine/server.h

-5
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,6 @@ enum GameType_e
408408

409409
extern GameType_e g_eGameType;
410410

411-
extern int fatbytes;
412411
extern int giNextUserMsg;
413412
extern int hashstrings_collisions;
414413

@@ -421,10 +420,6 @@ extern delta_t *g_pweapondelta;
421420
extern delta_t *g_pusercmddelta;
422421
#endif
423422

424-
extern unsigned char fatpvs[1024];
425-
extern int fatpasbytes;
426-
extern unsigned char fatpas[1024];
427-
428423
extern int gPacketSuppressed;
429424

430425
extern char localinfo[MAX_LOCALINFO];

rehlds/engine/sv_main.cpp

+27-10
Original file line numberDiff line numberDiff line change
@@ -683,22 +683,22 @@ qboolean SV_BuildSoundMsg(edict_t *entity, int channel, const char *sample, int
683683

684684
if (volume < 0 || volume > 255)
685685
{
686-
Con_Printf("%s: volume = %i", __func__, volume);
686+
Con_Printf("%s: volume = %i\n", __func__, volume);
687687
volume = (volume < 0) ? 0 : 255;
688688
}
689689
if (attenuation < 0.0f || attenuation > 4.0f)
690690
{
691-
Con_Printf("%s: attenuation = %f", __func__, attenuation);
691+
Con_Printf("%s: attenuation = %f\n", __func__, attenuation);
692692
attenuation = (attenuation < 0.0f) ? 0.0f : 4.0f;
693693
}
694694
if (channel < 0 || channel > 7)
695695
{
696-
Con_Printf("%s: channel = %i", __func__, channel);
696+
Con_Printf("%s: channel = %i\n", __func__, channel);
697697
channel = (channel < 0) ? CHAN_AUTO : CHAN_NETWORKVOICE_BASE;
698698
}
699699
if (pitch < 0 || pitch > 255)
700700
{
701-
Con_Printf("%s: pitch = %i", __func__, pitch);
701+
Con_Printf("%s: pitch = %i\n", __func__, pitch);
702702
pitch = (pitch < 0) ? 0 : 255;
703703
}
704704

@@ -710,7 +710,7 @@ qboolean SV_BuildSoundMsg(edict_t *entity, int channel, const char *sample, int
710710
sound_num = Q_atoi(sample + 1);
711711
if (sound_num >= CVOXFILESENTENCEMAX)
712712
{
713-
Con_Printf("%s: invalid sentence number: %s", __func__, sample + 1);
713+
Con_Printf("%s: invalid sentence number: %s\n", __func__, sample + 1);
714714
return FALSE;
715715
}
716716
}
@@ -1115,8 +1115,18 @@ void SV_SendServerinfo_internal(sizebuf_t *msg, client_t *client)
11151115
else
11161116
MSG_WriteByte(msg, 0);
11171117

1118-
COM_FileBase(com_gamedir, message);
1119-
MSG_WriteString(msg, message);
1118+
const char *pszGameDir = message;
1119+
1120+
#ifdef REHLDS_FIXES
1121+
// Give the client a chance to connect in to the server with different game
1122+
const char *gd = Info_ValueForKey(client->userinfo, "_gd");
1123+
if (gd[0])
1124+
pszGameDir = gd;
1125+
else
1126+
#endif
1127+
COM_FileBase(com_gamedir, message);
1128+
1129+
MSG_WriteString(msg, pszGameDir);
11201130
MSG_WriteString(msg, Cvar_VariableString("hostname"));
11211131
MSG_WriteString(msg, g_psv.modelname);
11221132

@@ -4033,9 +4043,10 @@ void SV_EmitEvents_internal(client_t *cl, packet_entities_t *pack, sizebuf_t *ms
40334043
}
40344044

40354045
int fatbytes;
4036-
unsigned char fatpvs[1024];
4046+
unsigned char fatpvs[MAX_MAP_LEAFS / 8];
4047+
40374048
int fatpasbytes;
4038-
unsigned char fatpas[1024];
4049+
unsigned char fatpas[MAX_MAP_LEAFS / 8];
40394050

40404051
void SV_AddToFatPVS(vec_t *org, mnode_t *node)
40414052
{
@@ -4077,6 +4088,9 @@ unsigned char* EXT_FUNC SV_FatPVS(float *org)
40774088
#endif // REHLDS_FIXES
40784089
fatbytes = (g_psv.worldmodel->numleafs + 31) >> 3;
40794090

4091+
if (fatbytes >= (MAX_MAP_LEAFS / 8))
4092+
Sys_Error("%s: MAX_MAP_LEAFS limit exceeded\n", __func__);
4093+
40804094
Q_memset(fatpvs, 0, fatbytes);
40814095
SV_AddToFatPVS(org, g_psv.worldmodel->nodes);
40824096
return fatpvs;
@@ -4134,6 +4148,9 @@ unsigned char* EXT_FUNC SV_FatPAS(float *org)
41344148
#endif // REHLDS_FIXES
41354149
fatpasbytes = (g_psv.worldmodel->numleafs + 31) >> 3;
41364150

4151+
if (fatpasbytes >= (MAX_MAP_LEAFS / 8))
4152+
Sys_Error("%s: MAX_MAP_LEAFS limit exceeded\n", __func__);
4153+
41374154
Q_memset(fatpas, 0, fatpasbytes);
41384155
SV_AddToFatPAS(org, g_psv.worldmodel->nodes);
41394156
return fatpas;
@@ -6158,7 +6175,7 @@ int SV_SpawnServer(qboolean bIsDemo, char *server, char *startspot)
61586175
if (g_psvs.maxclients <= 1)
61596176
{
61606177
int row = (g_psv.worldmodel->numleafs + 7) / 8;
6161-
if (row < 0 || row > MODEL_MAX_PVS)
6178+
if (row < 0 || row > (MAX_MAP_LEAFS / 8))
61626179
{
61636180
Sys_Error("%s: oversized g_psv.worldmodel->numleafs: %i", __func__, g_psv.worldmodel->numleafs);
61646181
}

rehlds/engine/sv_user.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,14 @@ void SV_CopyEdictToPhysent(physent_t *pe, int e, edict_t *check)
511511
pe->vuser4[2] = check->v.vuser4[2];
512512
}
513513

514+
bool EXT_FUNC SV_AllowPhysent_mod(edict_t* check, edict_t* sv_player) {
515+
return true;
516+
}
517+
518+
bool SV_AllowPhysent(edict_t* check, edict_t* sv_player) {
519+
return g_RehldsHookchains.m_SV_AllowPhysent.callChain(SV_AllowPhysent_mod, check, sv_player);
520+
}
521+
514522
void SV_AddLinksToPM_(areanode_t *node, float *pmove_mins, float *pmove_maxs)
515523
{
516524
struct link_s *l;
@@ -547,6 +555,11 @@ void SV_AddLinksToPM_(areanode_t *node, float *pmove_mins, float *pmove_maxs)
547555
if (check->v.solid != SOLID_BSP && check->v.solid != SOLID_BBOX && check->v.solid != SOLID_SLIDEBOX && check->v.solid != SOLID_NOT)
548556
continue;
549557

558+
// Apply our own custom checks
559+
if (!SV_AllowPhysent(check, sv_player)) {
560+
continue;
561+
}
562+
550563
e = NUM_FOR_EDICT(check);
551564
ve = &pmove->visents[pmove->numvisent];
552565
pmove->numvisent = pmove->numvisent + 1;

rehlds/public/rehlds/bspfile.h

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define HLBSP_VERSION 30 // half-life regular version
3333

3434
#define MAX_MAP_HULLS 4
35+
#define MAX_MAP_LEAFS 32767 // signed short limit
3536

3637
#define CONTENTS_ORIGIN -7 // removed at csg time
3738
#define CONTENTS_CLIP -8 // changed to contents_solid

rehlds/public/rehlds/rehlds_api.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#include "pr_dlls.h"
3838

3939
#define REHLDS_API_VERSION_MAJOR 3
40-
#define REHLDS_API_VERSION_MINOR 12
40+
#define REHLDS_API_VERSION_MINOR 13
4141

4242
//Steam_NotifyClientConnect hook
4343
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
@@ -255,6 +255,10 @@ typedef IVoidHookChainRegistry<resourcetype_t, const char *, int, unsigned char,
255255
typedef IVoidHookChain<const char *> IRehldsHook_SV_ClientPrintf;
256256
typedef IVoidHookChainRegistry<const char *> IRehldsHookRegistry_SV_ClientPrintf;
257257

258+
//SV_AllowPhysent hook
259+
typedef IHookChain<bool, edict_t*, edict_t*> IRehldsHook_SV_AllowPhysent;
260+
typedef IHookChainRegistry<bool, edict_t*, edict_t*> IRehldsHookRegistry_SV_AllowPhysent;
261+
258262
class IRehldsHookchains {
259263
public:
260264
virtual ~IRehldsHookchains() { }
@@ -313,6 +317,7 @@ class IRehldsHookchains {
313317
virtual IRehldsHookRegistry_EV_Precache* EV_Precache() = 0;
314318
virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource() = 0;
315319
virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf() = 0;
320+
virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent() = 0;
316321
};
317322

318323
struct RehldsFuncs_t {

rehlds/rehlds/rehlds_api_impl.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,10 @@ IRehldsHookRegistry_SV_ClientPrintf* CRehldsHookchains::SV_ClientPrintf(){
879879
return &m_SV_ClientPrintf;
880880
}
881881

882+
IRehldsHookRegistry_SV_AllowPhysent* CRehldsHookchains::SV_AllowPhysent() {
883+
return &m_SV_AllowPhysent;
884+
}
885+
882886
int EXT_FUNC CRehldsApi::GetMajorVersion()
883887
{
884888
return REHLDS_API_VERSION_MAJOR;

rehlds/rehlds/rehlds_api_impl.h

+6
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ typedef IVoidHookChainRegistryImpl<resourcetype_t, const char*, int, unsigned ch
250250
typedef IVoidHookChainImpl<const char*> CRehldsHook_SV_ClientPrintf;
251251
typedef IVoidHookChainRegistryImpl<const char*> CRehldsHookRegistry_SV_ClientPrintf;
252252

253+
//SV_AllowPhysent hook
254+
typedef IHookChainImpl<bool, edict_t*, edict_t*> CRehldsHook_SV_AllowPhysent;
255+
typedef IHookChainRegistryImpl<bool, edict_t*, edict_t*> CRehldsHookRegistry_SV_AllowPhysent;
256+
253257
class CRehldsHookchains : public IRehldsHookchains {
254258
public:
255259
CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect;
@@ -306,6 +310,7 @@ class CRehldsHookchains : public IRehldsHookchains {
306310
CRehldsHookRegistry_EV_Precache m_EV_Precache;
307311
CRehldsHookRegistry_SV_AddResource m_SV_AddResource;
308312
CRehldsHookRegistry_SV_ClientPrintf m_SV_ClientPrintf;
313+
CRehldsHookRegistry_SV_AllowPhysent m_SV_AllowPhysent;
309314

310315
public:
311316
EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
@@ -362,6 +367,7 @@ class CRehldsHookchains : public IRehldsHookchains {
362367
EXT_FUNC virtual IRehldsHookRegistry_EV_Precache* EV_Precache();
363368
EXT_FUNC virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource();
364369
EXT_FUNC virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf();
370+
EXT_FUNC virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent();
365371
};
366372

367373
extern CRehldsHookchains g_RehldsHookchains;

rehlds/version/version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
#pragma once
77

88
#define VERSION_MAJOR 3
9-
#define VERSION_MINOR 12
9+
#define VERSION_MINOR 13
1010
#define VERSION_MAINTENANCE 0

0 commit comments

Comments
 (0)