Skip to content

Commit

Permalink
Merge pull request #2 from dreamstalker/master
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
aleeperezz16 authored Nov 28, 2023
2 parents 5c6f219 + 0af97d9 commit ef3707a
Show file tree
Hide file tree
Showing 35 changed files with 685 additions and 135 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
jobs:
windows:
name: 'Windows'
runs-on: windows-latest
runs-on: windows-2019

env:
solution: 'msvc/ReHLDS.sln'
Expand All @@ -25,12 +25,12 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.0.2
uses: microsoft/setup-msbuild@v1.1.3

- name: Build and Run unittests
run: |
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
move msvc\${{ env.buildRelease }}\director.pdb publish\debug\director.pdb
- name: Deploy artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3.1.1
with:
name: win32
path: publish/*
Expand All @@ -92,7 +92,7 @@ jobs:

steps:
- name: Deploying windows artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: win32

Expand Down Expand Up @@ -155,7 +155,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

Expand Down Expand Up @@ -228,7 +228,7 @@ jobs:
shell: bash

- name: Deploy artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3.1.1
id: upload-job
with:
name: linux32
Expand All @@ -247,12 +247,12 @@ jobs:

steps:
- name: Deploying linux artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: linux32

- name: Deploying windows artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: win32

Expand All @@ -277,7 +277,7 @@ jobs:
github.event.action == 'published' &&
startsWith(github.ref, 'refs/tags/')
run: |
7z a -tzip rehlds-bin-${{ env.APP_VERSION }}.zip bin/linux32/ hlsdk/
7z a -tzip rehlds-bin-${{ env.APP_VERSION }}.zip bin/ hlsdk/
7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -aoa rehlds-dbg-${{ env.APP_VERSION }}.7z debug/
- name: Publish artifacts
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
<li>sv_rehlds_stringcmdrate_burst_punish // Time in minutes for which the player will be banned (0 - Permanent, use a negative number for a kick). Default: 5
<li>sv_rehlds_userinfo_transmitted_fields // Userinfo fields only with these keys will be transmitted to clients via network. If not set then all fields will be transmitted (except prefixed with underscore). Each key must be prefixed by backslash, for example "\name\model\*sid\*hltv\bottomcolor\topcolor". See [wiki](https://github.com/dreamstalker/rehlds/wiki/Userinfo-keys) to collect sufficient set of keys for your server. Default: ""
<li>sv_rehlds_attachedentities_playeranimationspeed_fix // Fixes bug with gait animation speed increase when player has some attached entities (aiments). Can cause animation lags when cl_updaterate is low. Default: 0
<li>sv_rehlds_maxclients_from_single_ip // Limit number of connections from the single ip address. Default: 5
<li>sv_rehlds_maxclients_from_single_ip // Limit number of connections at the same time from single IP address, not confuse to already connected players. Default: 5
<li>sv_rehlds_local_gametime <1|0> // A feature of local gametime which decrease "lags" if you run same map for a long time. Default: 0
<li>sv_use_entity_file // Use custom entity file for a map. Path to an entity file will be "maps/[map name].ent". 0 - use original entities. 1 - use .ent files from maps directory. 2 - use .ent files from maps directory and create new .ent file if not exist.
<li>sv_rcon_allowexternal <1|0> // Usage of Rcon from externals IPs. Default: 1
Expand Down
2 changes: 1 addition & 1 deletion rehlds/HLTV/Core/src/BSPModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 2 additions & 3 deletions rehlds/HLTV/Core/src/BSPModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include "l_studio.h"
#include "edict.h"
#include "bspfile.h"

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

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;
Expand Down
12 changes: 12 additions & 0 deletions rehlds/common/cvardef.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,16 @@ struct cvar_listener_t
const char *name;
};

typedef void (*pfnCvar_HookVariable_t) (cvar_t *pCvar);

struct cvarhook_t
{
pfnCvar_HookVariable_t hook;

cvar_t *cvar;
cvarhook_t *next;
};

qboolean Cvar_HookVariable(const char *var_name, cvarhook_t *pHook);

#endif // CVARDEF_H
6 changes: 3 additions & 3 deletions rehlds/engine/cmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
5 changes: 0 additions & 5 deletions rehlds/engine/cmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
102 changes: 84 additions & 18 deletions rehlds/engine/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1446,31 +1446,64 @@ char *COM_FileExtension(char *in)
#endif // #ifdef REHLDS_FIXES
}

// Fills "out" with the file name without path and extension.
// Fills "out" with the file name without path and extension
void COM_FileBase(const char *in, char *out)
{
const char *start, *end;
int len;
COM_FileBase_s(in, out, -1);
}

*out = 0;
// Extracts the base name of a file (no path, no extension, assumes '/' as path separator)
const char *COM_FileBase_s(const char *in, char *out, int size)
{
if (!in || !in[0])
{
*out = '\0';
return NULL;
}

len = Q_strlen(in);
int len = Q_strlen(in);
if (len <= 0)
return;
return NULL;

start = in + len - 1;
end = in + len;
while (start >= in && *start != '/' && *start != '\\')
// scan backward for '.'
int end = len - 1;
while (end && in[end] != '.' && !PATHSEPARATOR(in[end]))
end--;

// no '.', copy to end
if (in[end] != '.')
{
if (*start == '.')
end = start;
end = len - 1;
}
else
{
// Found ',', copy to left of '.'
end--;
}

// Scan backward for '/'
int start = len - 1;
while (start >= 0 && !PATHSEPARATOR(in[start]))
start--;

if (start < 0 || !PATHSEPARATOR(in[start]))
{
start = 0;
}
else
{
start++;
}
start++;

len = end - start;
Q_strncpy(out, start, len);
out[len] = 0;
// Length of new sting
int maxcopy = end - start + 1;
if (size >= 0 && maxcopy >= size)
return NULL;

// Copy partial string
Q_strncpy(out, &in[start], maxcopy);
out[maxcopy] = '\0';
return out;
}

void COM_DefaultExtension(char *path, char *extension)
Expand Down Expand Up @@ -1945,6 +1978,34 @@ NOXREF int COM_ExpandFilename(char *filename)
return *filename != 0;
}

// small helper function shared by lots of modules
qboolean COM_IsAbsolutePath(const char *pStr)
{
if (strchr(pStr, ':') || pStr[0] == '/' || pStr[0] == '\\')
return FALSE;

return TRUE;
}

qboolean COM_IsValidPath(const char *pszFilename)
{
if (!pszFilename)
return FALSE;

if (Q_strlen(pszFilename) <= 0 ||
Q_strstr(pszFilename, "\\\\") || // to protect network paths
Q_strstr(pszFilename, ":") || // to protect absolute paths
Q_strstr(pszFilename, "..") || // to protect relative paths
Q_strstr(pszFilename, "~") ||
Q_strstr(pszFilename, "\n") || // CFileSystem_Stdio::FS_fopen doesn't allow this
Q_strstr(pszFilename, "\r")) // CFileSystem_Stdio::FS_fopen doesn't allow this
{
return FALSE;
}

return TRUE;
}

int EXT_FUNC COM_FileSize(const char *filename)
{
FileHandle_t fp;
Expand All @@ -1962,7 +2023,10 @@ int EXT_FUNC COM_FileSize(const char *filename)

unsigned char* EXT_FUNC COM_LoadFile(const char *path, int usehunk, int *pLength)
{
char base[33];
if (!path || !path[0])
return NULL;

char base[MAX_PATH];
unsigned char *buf = NULL;

#ifndef SWDS
Expand All @@ -1982,8 +2046,10 @@ unsigned char* EXT_FUNC COM_LoadFile(const char *path, int usehunk, int *pLength
}

int len = FS_Size(hFile);
COM_FileBase(path, base);
base[32] = 0;
if (!COM_FileBase_s(path, base, sizeof(base)))
Sys_Error("%s: Bad path length: %s", __func__, path);

base[32] = '\0';

switch (usehunk)
{
Expand Down
3 changes: 3 additions & 0 deletions rehlds/engine/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ NOXREF char *COM_SkipPath(char *pathname);
void COM_StripExtension(char *in, char *out);
char *COM_FileExtension(char *in);
void COM_FileBase(const char *in, char *out);
const char *COM_FileBase_s(const char *in, char *out, int size);
void COM_DefaultExtension(char *path, char *extension);
void COM_UngetToken(void);
char *COM_Parse(char *data);
Expand All @@ -186,6 +187,8 @@ void COM_CreatePath(char *path);
NOXREF void COM_CopyFile(char *netpath, char *cachepath);
NOXREF int COM_ExpandFilename(char *filename);
int COM_FileSize(const char *filename);
qboolean COM_IsAbsolutePath(const char *pStr);
qboolean COM_IsValidPath(const char *pszFilename);
unsigned char *COM_LoadFile(const char *path, int usehunk, int *pLength);
void COM_FreeFile(void *buffer);
void COM_CopyFileChunk(FileHandle_t dst, FileHandle_t src, int nSize);
Expand Down
Loading

0 comments on commit ef3707a

Please sign in to comment.