Skip to content

Commit

Permalink
Merge branch 'dreamstalker:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
metita authored Mar 13, 2024
2 parents c2fd324 + 05f4a27 commit 3623ea1
Show file tree
Hide file tree
Showing 27 changed files with 753 additions and 217 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ You can try playing on one of many servers that are using ReHLDS: [Game Tracker]
</ul>

## How can use it?
ReHLDS is fully compatible with latest official HLDS downloaded by steamcmd. All you have to do is to download rehlds binaries and replace original swds.dll/engine_i486.so. For windows you can also copy a swds.pdb file with a debug information.
<br /><b>Warning!</b> ReHLDS is not compatible with an old 5xxx or below platforms downloaded by hldsupdatetool.
ReHLDS is fully compatible with the official pre-anniversary edition of HLDS (engine version <= 8684) downloaded by steamcmd. All you have to do is to download rehlds binaries and replace original swds.dll/engine_i486.so. For windows you can also copy a swds.pdb file with a debug information.

<b>Warning!</b> ReHLDS is not compatible with an old 5xxx or below platforms downloaded by hldsupdatetool.

#### Downloading HLDS via steamcmd

```
app_set_config 90 mod cstrike
app_update 90 -beta steam_legacy validate
```

## Downloads
* [Release builds](https://github.com/dreamstalker/rehlds/releases)
Expand All @@ -31,37 +39,41 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
<details>
<summary>Click to expand</summary>
<ul>
<li>listipcfgfile <filename> // File for permanent ip bans. Default: listip.cfg
<li>syserror_logfile <filename> // File for the system error log. Default: sys_error.log
<li>sv_auto_precache_sounds_in_models <1|0> // Automatically precache sounds attached to models. Deault: 0
<li>sv_delayed_spray_upload <1|0> // Upload custom sprays after entering the game instead of when connecting. It increases upload speed. Default: 0
<li>sv_echo_unknown_cmd <1|0> // Echo in the console when trying execute an unknown command. Default: 0
<li>sv_rcon_condebug <1|0> // Print rcon debug in the console. Default: 1
<li>sv_force_ent_intersection <1|0> // In a 3-rd party plugins used to force colliding of SOLID_SLIDEBOX entities. Default: 0
<li>sv_rehlds_force_dlmax <1|0> // Force a client's cl_dlmax cvar to 1024. It avoids an excessive packets fragmentation. Default: 0
<li>sv_rehlds_hull_centering <1|0> // Use center of hull instead of corner. Default: 0
<li>listipcfgfile &lt;filename&gt; // File for permanent ip bans. Default: listip.cfg
<li>syserror_logfile &lt;filename&gt; // File for the system error log. Default: sys_error.log
<li>sv_auto_precache_sounds_in_models &lt;1|0&gt; // Automatically precache sounds attached to models. Deault: 0
<li>sv_delayed_spray_upload &lt;1|0&gt; // Upload custom sprays after entering the game instead of when connecting. It increases upload speed. Default: 0
<li>sv_echo_unknown_cmd &lt;1|0&gt; // Echo in the console when trying execute an unknown command. Default: 0
<li>sv_rcon_condebug &lt;1|0&gt; // Print rcon debug in the console. Default: 1
<li>sv_force_ent_intersection &lt;1|0&gt; // In a 3-rd party plugins used to force colliding of SOLID_SLIDEBOX entities. Default: 0
<li>sv_rehlds_force_dlmax &lt;1|0&gt; // Force a client's cl_dlmax cvar to 1024. It avoids an excessive packets fragmentation. Default: 0
<li>sv_rehlds_hull_centering &lt;1|0&gt; // Use center of hull instead of corner. Default: 0
<li>sv_rehlds_movecmdrate_max_avg // Max average level of 'move' cmds for ban. Default: 400
<li>sv_rehlds_movecmdrate_avg_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_movecmdrate_max_burst // Max burst level of 'move' cmds for ban. Default: 2500
<li>sv_rehlds_movecmdrate_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_send_mapcycle <1|0> // Send mapcycle.txt in serverinfo message (HLDS behavior, but it is unused on the client). Default: 0
<li>sv_rehlds_send_mapcycle &lt;1|0&gt; // Send mapcycle.txt in serverinfo message (HLDS behavior, but it is unused on the client). Default: 0
<li>sv_rehlds_stringcmdrate_max_avg // Max average level of 'string' cmds for ban. Default: 80
<li>sv_rehlds_stringcmdrate_avg_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_stringcmdrate_max_burst // Max burst level of 'string' cmds for ban. Default: 400
<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 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_rehlds_local_gametime &lt;1|0&gt; // 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_usercmd_custom_random_seed // When enabled server will populate an additional random seed independent of the client. Default: 0
<li>sv_tags &lt;comma-delimited string list of tags&gt; // Sets a string defining the "gametags" for this server, this is optional, but if it is set it allows users/scripts to filter in the matchmaking/server-browser interfaces based on the value. Default: ""
</ul>
</details>

## Commands
<ul>
<li>rescount // Prints the total count of precached resources in the server console
<li>reslist &lt;sound | model | decal | generic | event&gt; // Separately prints the details of the precached resources for sounds, models, decals, generic and events in server console. Useful for managing resources and dealing with the goldsource precache limits.
<li>rcon_adduser &lt;ipaddress/CIDR&gt; // Add a new IP address or CIDR range to RCON user list (This command adds a new IP address to the RCON user list. The specified IP or CIDR range is granted privileged access to server console. Without any Rcon users, access is allowed to anyone with a valid password)</li>
<li>rcon_deluser &lt;ipaddress&gt; {removeAll} // Remove an IP address or CIDR range from RCON user list</li>
<li>rcon_users // List all IP addresses and CIDR ranges in RCON user list</li>
</ul>

## Build instructions
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
14 changes: 5 additions & 9 deletions rehlds/engine/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ void Cbuf_Execute(void)
}

// execute the command line
Cmd_ExecuteString(line, src_command);
if (line[0])
Cmd_ExecuteString(line, src_command);

if (cmd_wait)
{
Expand Down Expand Up @@ -406,17 +407,12 @@ void Cmd_Exec_f(void)
else
{
char *pszDataPtr = configContents;
while (true)
while (pszDataPtr && *pszDataPtr)
{
Cbuf_Execute(); // TODO: This doesn't obey the rule to first execute commands from the file, and then the others in the buffer
pszDataPtr = COM_ParseLine(pszDataPtr); // TODO: COM_ParseLine can be const char*

if (com_token[0] == 0)
{
break;
}

Cbuf_InsertTextLines(com_token);
if (com_token[0])
Cbuf_InsertTextLines(com_token);
}
}

Expand Down
32 changes: 30 additions & 2 deletions rehlds/engine/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,9 @@ void MSG_WriteBitData(void *src, int length)

void MSG_WriteBitAngle(float fAngle, int numbits)
{
if (numbits >= 32)
if (numbits > 22)
{
Sys_Error("%s: Can't write bit angle with 32 bits precision\n", __func__);
Sys_Error("%s: Can't write bit angle with more than 22 bits precision\n", __func__);
}

uint32 shift = (1 << numbits);
Expand Down Expand Up @@ -1978,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 Down
2 changes: 2 additions & 0 deletions rehlds/engine/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,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
49 changes: 47 additions & 2 deletions rehlds/engine/cvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
All cvar names are case insensitive! Values not.
*/

cvar_t *cvar_vars;
cvar_t *cvar_vars = NULL;
cvarhook_t *cvar_hooks = NULL;
char cvar_null_string[] = "";

void Cvar_Init(void)
Expand Down Expand Up @@ -319,15 +320,26 @@ void Cvar_DirectSet(struct cvar_s *var, const char *value)

void Cvar_Set(const char *var_name, const char *value)
{
cvar_t *var = Cvar_FindVar(var_name);
cvar_t *var;
cvarhook_t *pHook;

var = Cvar_FindVar(var_name);
if (!var)
{
Con_DPrintf("%s: variable \"%s\" not found\n", __func__, var_name);
return;
}

Cvar_DirectSet(var, value);

for (pHook = cvar_hooks; pHook; pHook = pHook->next)
{
if (pHook->cvar == var)
{
pHook->hook(var);
break;
}
}
}

void Cvar_SetValue(const char *var_name, float value)
Expand Down Expand Up @@ -730,3 +742,36 @@ void Cvar_CmdInit(void)
{
Cmd_AddCommand("cvarlist", Cmd_CvarList_f);
}

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

if (!pHook || !pHook->hook)
return FALSE;

if (pHook->cvar || pHook->next)
return FALSE;

cvar = Cvar_FindVar(var_name);
if (!cvar)
return FALSE;

cvarhook_t *pCur = cvar_hooks;
pHook->cvar = cvar;

if (pCur)
{
while (pCur->next)
pCur = pCur->next;

pCur->next = pHook;
}
else
{
// First in chain is null, assign pHook to it
cvar_hooks = pHook;
}

return TRUE;
}
2 changes: 0 additions & 2 deletions rehlds/engine/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ typedef struct ipfilter_s
} compare;
float banEndTime;
float banTime;
#ifdef REHLDS_FIXES
int cidr;
#endif // REHLDS_FIXES
} ipfilter_t;

typedef struct userfilter_s
Expand Down
Loading

0 comments on commit 3623ea1

Please sign in to comment.