Merge branch 'master' into zipbomb_exploit

This commit is contained in:
Dmitry Novikov 2024-03-11 23:28:24 +07:00 committed by GitHub
commit cb752a94ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 395 additions and 157 deletions

View File

@ -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: |
@ -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/*
@ -92,7 +92,7 @@ jobs:
steps:
- name: Deploying windows artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: win32
@ -155,7 +155,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
@ -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
@ -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

View File

@ -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)
@ -31,20 +39,20 @@ 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
@ -52,13 +60,14 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
<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_net_incoming_decompression <1|0> // When enabled server will decompress of incoming compressed file transfer payloads. Default: 1
<li>sv_net_incoming_decompression_max_ratio <0|100> // Sets the max allowed ratio between compressed and uncompressed data for file transfer. (A ratio close to 90 indicates large uncompressed data with low entropy) Default: 80.0
<li>sv_net_incoming_decompression_max_size <16|65536> // Sets the max allowed size for decompressed file transfer data. Default: 65536 bytes
<li>sv_net_incoming_decompression_punish // Time in minutes for which the player will be banned for malformed/abnormal bzip2 fragments (0 - Permanent, use a negative number for a kick). Default: -1
<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>
@ -66,6 +75,9 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
<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

View File

@ -235,6 +235,7 @@ void Cbuf_Execute(void)
}
// execute the command line
if (line[0])
Cmd_ExecuteString(line, src_command);
if (cmd_wait)
@ -406,16 +407,11 @@ 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;
}
if (com_token[0])
Cbuf_InsertTextLines(com_token);
}
}

View File

@ -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);

View File

@ -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

View File

@ -1197,7 +1197,11 @@ int Host_Init(quakeparms_t *parms)
else
{
Cvar_RegisterVariable(&suitvolume);
#ifdef REHLDS_FIXES
Cvar_RegisterVariable(&r_cachestudio);
#endif
}
Cbuf_InsertText("exec valve.rc\n");
Hunk_AllocName(0, "-HOST_HUNKLEVEL-");
host_hunklevel = Hunk_LowMark();

View File

@ -610,7 +610,6 @@ void Host_Status_f(void)
Host_Status_Printf(conprint, log, "players : %i active (%i max)\n\n", nClients, g_psvs.maxclients);
Host_Status_Printf(conprint, log, "# name userid uniqueid frag time ping loss adr\n");
int count = 1;
client = g_psvs.clients;
for (j = 0; j < g_psvs.maxclients; j++, client++)
{
@ -634,7 +633,7 @@ void Host_Status_f(void)
val = SV_GetClientIDString(client);
else val = "BOT";
Host_Status_Printf(conprint, log, "#%2i %8s %i %s", count++, va("\"%s\"", client->name), client->userid, val);
Host_Status_Printf(conprint, log, "#%2i %8s %i %s", j + 1, va("\"%s\"", client->name), client->userid, val);
if (client->proxy)
{
const char *userInfo = Info_ValueForKey(client->userinfo, "hspecs");
@ -724,7 +723,6 @@ void Host_Status_Formatted_f(void)
Host_Status_Printf(conprint, log, "players : %i active (%i max)\n\n", nClients, g_psvs.maxclients);
Host_Status_Printf(conprint, log, "%-2.2s\t%-9.9s\t%-7.7s\t%-20.20s\t%-4.4s\t%-8.8s\t%-4.4s\t%-4.4s\t%-21.21s\n","# ","name","userid ","uniqueid ","frag","time ","ping","loss","adr");
int count = 1;
char *szRemoteAddr;
client = g_psvs.clients;
for (j = 0; j < g_psvs.maxclients; j++, client++)
@ -755,7 +753,7 @@ void Host_Status_Formatted_f(void)
#endif // REHLDS_FIXES
szIDString = SV_GetClientIDString(client);
Host_Status_Printf(conprint, log, "%-2.2s\t%-9.9s\t%-7.7s\t%-20.20s\t%-4.4s\t%-8.8s\t%-4.4s\t%-4.4s\t%-21.21s\n",
va("%-2i", count++),va("\"%s\"", client->name),va("%-7i", client->userid),szIDString,
va("%-2i", j + 1),va("\"%s\"", client->name),va("%-7i", client->userid),szIDString,
va("%-4i", (int)client->edict->v.frags),sz,va("%-4i", SV_CalcPing(client)),va("%-4i", (int)client->packet_loss),szRemoteAddr);
}
Host_Status_Printf(conprint, log, "%i users\n", nClients);

View File

@ -1802,7 +1802,14 @@ void EXT_FUNC PF_aim_I(edict_t *ent, float speed, float *rgflReturn)
bestdir[1] = dir[1];
bestdir[2] = dir[2];
bestdir[0] = dir[0];
if (sv_allow_autoaim.value)
{
bestdist = sv_aim.value;
}
else
{
bestdist = 0.0f;
}
for (int i = 1; i < g_psv.num_edicts; i++)
{

View File

@ -283,6 +283,7 @@ extern rehlds_server_t g_rehlds_sv;
extern cvar_t sv_lan;
extern cvar_t sv_lan_rate;
extern cvar_t sv_aim;
extern cvar_t sv_allow_autoaim;
extern cvar_t sv_skycolor_r;
extern cvar_t sv_skycolor_g;
@ -365,6 +366,7 @@ extern cvar_t sv_visiblemaxplayers;
extern cvar_t sv_downloadurl;
extern cvar_t sv_allow_dlfile;
extern cvar_t sv_version;
extern cvar_t sv_tags;
#ifdef REHLDS_FIXES
extern cvar_t sv_echo_unknown_cmd;
extern cvar_t sv_auto_precache_sounds_in_models;
@ -586,6 +588,9 @@ void SV_ClearEntities(void);
int RegUserMsg(const char *pszName, int iSize);
qboolean StringToFilter(const char *s, ipfilter_t *f);
USERID_t *SV_StringToUserID(const char *str);
bool CanBeWrittenWithoutCIDR(const ipfilter_t &f);
void FilterToString(const ipfilter_t &f, char *s);
bool IsFilterIncludesAnotherFilter(const ipfilter_t &f, const ipfilter_t &f2);
void SV_BanId_f(void);
void Host_Kick_f(void);
void SV_RemoveId_f(void);

View File

@ -114,6 +114,7 @@ int giNextUserMsg = 64;
cvar_t sv_lan = { "sv_lan", "0", 0, 0.0f, NULL };
cvar_t sv_lan_rate = { "sv_lan_rate", "20000.0", 0, 0.0f, NULL };
cvar_t sv_aim = { "sv_aim", "1", FCVAR_SERVER | FCVAR_ARCHIVE , 0.0f, NULL };
cvar_t sv_allow_autoaim = { "sv_allow_autoaim", "1", FCVAR_SERVER | FCVAR_ARCHIVE, 0.0f, NULL };
cvar_t sv_skycolor_r = { "sv_skycolor_r", "0", 0, 0.0f, NULL };
cvar_t sv_skycolor_g = { "sv_skycolor_g", "0", 0, 0.0f, NULL };
@ -192,6 +193,8 @@ cvar_t sv_version = { "sv_version", "", FCVAR_SERVER, 0.0f, NULL };
cvar_t sv_version = {"sv_version", "", 0, 0.0f, NULL};
#endif
cvar_t sv_tags = { "sv_tags", "", 0, 0.0f, NULL };
cvar_t sv_rcon_minfailures = { "sv_rcon_minfailures", "5", 0, 0.0f, NULL };
cvar_t sv_rcon_maxfailures = { "sv_rcon_maxfailures", "10", 0, 0.0f, NULL };
cvar_t sv_rcon_minfailuretime = { "sv_rcon_minfailuretime", "30", 0, 0.0f, NULL };
@ -3273,6 +3276,159 @@ void SV_ResetRcon_f(void)
Q_memset(g_rgRconFailures, 0, sizeof(g_rgRconFailures));
}
const int MAX_RCON_USERS = 128;
ipfilter_t rconusers[MAX_RCON_USERS];
int numrconusers = 0;
qboolean SV_CheckRconAllowed(const netadr_t *adr)
{
if (numrconusers <= 0)
return TRUE; // Rcon user list empty so assume allowed it for all
for (int i = numrconusers - 1; i >= 0; i--)
{
ipfilter_t *curFilter = &rconusers[i];
if (curFilter->compare.u32 == 0xFFFFFFFF || (*(uint32*)adr->ip & curFilter->mask) == curFilter->compare.u32)
return TRUE;
}
return FALSE;
}
void SV_RconAddUser_f(void)
{
if (Cmd_Argc() != 2)
{
Con_Printf("Usage: rcon_adduser <ipaddress/CIDR>\n"
"ipaddress A.B.C.D/24 is equivalent to A.B.C.0 and A.B.C\n");
return;
}
ipfilter_t tempFilter;
if (!StringToFilter(Cmd_Argv(1), &tempFilter))
{
Con_Printf("Invalid IP address!\nUsage: rcon_adduser <ipaddress>\n");
return;
}
int i = 0;
for (; i < numrconusers; i++)
{
if (rconusers[i].mask == tempFilter.mask && rconusers[i].compare.u32 == tempFilter.compare.u32)
{
rconusers[i].cidr = tempFilter.cidr;
return;
}
}
if (numrconusers >= MAX_RCON_USERS)
{
Con_Printf("IP rcon users is full\n");
return;
}
numrconusers++;
rconusers[i].compare = tempFilter.compare;
rconusers[i].mask = tempFilter.mask;
rconusers[i].cidr = tempFilter.cidr;
}
void SV_RconDelUser_f(void)
{
int argCount = Cmd_Argc();
if (argCount != 2 && argCount != 3)
{
Con_Printf("Usage: rcon_deluser <ipaddress> {removeAll}\n"
"removeip <ipaddress/CIDR> {removeAll}\n"
"Use removeAll to delete all Rcon ip users which ipaddress or ipaddress/CIDR includes\n");
return;
}
ipfilter_t f;
if (!StringToFilter(Cmd_Argv(1), &f))
{
Con_Printf("Invalid IP address\n"
"Usage: rcon_deluser <ipaddress> {removeAll}\n"
" rcon_deluser <ipaddress/CIDR> {removeAll}\n"
"Use removeAll to delete all Rcon ip users which ipaddress or ipaddress/CIDR includes\n");
return;
}
bool found = false;
for (int i = 0; i < numrconusers; i++)
{
if ((argCount == 2 && rconusers[i].mask == f.mask && rconusers[i].compare.u32 == f.compare.u32) ||
(argCount == 3 && IsFilterIncludesAnotherFilter(f, rconusers[i])))
{
if (i + 1 < numrconusers)
Q_memmove(&rconusers[i], &rconusers[i + 1], (numrconusers - (i + 1)) * sizeof(ipfilter_t));
numrconusers--;
rconusers[numrconusers].banTime = 0.0f;
rconusers[numrconusers].banEndTime = 0.0f;
rconusers[numrconusers].compare.u32 = 0;
rconusers[numrconusers].mask = 0;
found = true;
--i;
if (argCount == 2)
break;
}
}
if (found)
Con_Printf("Rcon user IP removed.\n");
else
{
Con_Printf("rcon_deluser: couldn't find %s.\n", Cmd_Argv(1));
}
}
void SV_RconUsers_f(void)
{
if (numrconusers <= 0)
{
Con_Printf("Rcon user IP list: empty\n");
return;
}
bool isNew = Cmd_Argc() == 2;
bool searchByFilter = isNew && isdigit(Cmd_Argv(1)[0]);
ipfilter_t filter;
if (searchByFilter)
{
if (!StringToFilter(Cmd_Argv(1), &filter))
return;
Con_Printf("Rcon user IP list for %s:\n", Cmd_Argv(1));
}
else
{
Con_Printf("Rcon user IP list:\n");
}
for (int i = 0; i < numrconusers; i++)
{
uint8 *b = rconusers[i].compare.octets;
if (isNew)
{
if (!searchByFilter || IsFilterIncludesAnotherFilter(filter, rconusers[i]))
{
char strFilter[32];
FilterToString(rconusers[i], strFilter);
Con_Printf("%-18s\n", strFilter);
}
}
else if (CanBeWrittenWithoutCIDR(rconusers[i]))
{
Con_Printf("%3i.%3i.%3i.%3i\n", b[0], b[1], b[2], b[3]);
}
}
}
void SV_AddFailedRcon(netadr_t *adr)
{
int i;
@ -3401,10 +3557,21 @@ qboolean SV_CheckRconFailure(netadr_t *adr)
return FALSE;
}
#define RCON_RESULT_SUCCESS 0 // allow the rcon
#define RCON_RESULT_BADPASSWORD 1 // reject it, bad password
#define RCON_RESULT_BADCHALLENGE 2 // bad challenge
#define RCON_RESULT_BANNING 3 // decline it, banning for rcon hacking attempts
#define RCON_RESULT_NOSETPASSWORD 4 // rcon password is not set
#define RCON_RESULT_NOPRIVILEGE 5 // user attempt with valid password but is not privileged
int SV_Rcon_Validate(void)
{
if (Cmd_Argc() < 3 || Q_strlen(rcon_password.string) == 0)
return 1;
if (Cmd_Argc() < 3)
return RCON_RESULT_BADPASSWORD;
// Must have a password set to allow any rconning
if (Q_strlen(rcon_password.string) == 0)
return RCON_RESULT_NOSETPASSWORD;
if (sv_rcon_banpenalty.value < 0.0f)
Cvar_SetValue("sv_rcon_banpenalty", 0.0);
@ -3413,78 +3580,105 @@ int SV_Rcon_Validate(void)
{
Con_Printf("Banning %s for rcon hacking attempts\n", NET_AdrToString(net_from));
Cbuf_AddText(va("addip %i %s\n", (int)sv_rcon_banpenalty.value, NET_BaseAdrToString(net_from)));
return 3;
return RCON_RESULT_BANNING;
}
if (!SV_CheckChallenge(&net_from, Q_atoi(Cmd_Argv(1))))
return 2;
return RCON_RESULT_BADCHALLENGE; // The client is spoofing...
// If the pw does not match, then disallow command
if (Q_strcmp(Cmd_Argv(2), rcon_password.string))
{
SV_AddFailedRcon(&net_from);
return 1;
}
return 0;
return RCON_RESULT_BADPASSWORD;
}
if (!SV_CheckRconAllowed(&net_from))
{
Con_Printf("Banning %s for rcon attempts without privileged\n", NET_AdrToString(net_from));
Cbuf_AddText(va("addip %i %s\n", (int)sv_rcon_banpenalty.value, NET_BaseAdrToString(net_from)));
return RCON_RESULT_NOPRIVILEGE;
}
// Otherwise it's ok
return RCON_RESULT_SUCCESS;
}
// A client issued an rcom command
// Shift down the remaining args and redirect all Con_Printf
void SV_Rcon(netadr_t *net_from_)
{
char remaining[512];
char rcon_buff[1024];
int invalid;
char remaining[1024];
char rcon_buff[512];
int len;
int invalid = SV_Rcon_Validate();
int len = net_message.cursize - Q_strlen("rcon");
if (len <= 0 || len >= sizeof(remaining))
// Verify this user has access rights
invalid = SV_Rcon_Validate();
len = net_message.cursize - Q_strlen("rcon");
if (len <= 0 || len >= sizeof(rcon_buff))
return;
Q_memcpy(remaining, &net_message.data[Q_strlen("rcon")], len);
remaining[len] = 0;
Q_memcpy(rcon_buff, &net_message.data[Q_strlen("rcon")], len);
rcon_buff[len] = 0;
#ifdef REHLDS_FIXES
if (sv_rcon_condebug.value > 0.0f)
#endif
{
if (invalid)
if (invalid != RCON_RESULT_SUCCESS)
{
Con_Printf("Bad Rcon from %s:\n%s\n", NET_AdrToString(*net_from_), remaining);
Log_Printf("Bad Rcon: \"%s\" from \"%s\"\n", remaining, NET_AdrToString(*net_from_));
Con_Printf("Bad Rcon from %s:\n%s\n", NET_AdrToString(*net_from_), rcon_buff);
Log_Printf("Bad Rcon: \"%s\" from \"%s\"\n", rcon_buff, NET_AdrToString(*net_from_));
}
else
{
Con_Printf("Rcon from %s:\n%s\n", NET_AdrToString(*net_from_), remaining);
Log_Printf("Rcon: \"%s\" from \"%s\"\n", remaining, NET_AdrToString(*net_from_));
Con_Printf("Rcon from %s:\n%s\n", NET_AdrToString(*net_from_), rcon_buff);
Log_Printf("Rcon: \"%s\" from \"%s\"\n", rcon_buff, NET_AdrToString(*net_from_));
}
}
SV_BeginRedirect(RD_PACKET, net_from_);
if (invalid)
switch (invalid)
{
if (invalid == 2)
Con_Printf("Bad rcon_password.\n");
else if (Q_strlen(rcon_password.string) == 0)
Con_Printf("Bad rcon_password.\nNo password set for this server.\n");
else
Con_Printf("Bad rcon_password.\n");
case RCON_RESULT_SUCCESS:
{
char *data;
data = COM_Parse(rcon_buff);
data = COM_Parse(data);
data = COM_Parse(data);
SV_EndRedirect();
return;
if (data)
{
Q_strncpy(remaining, data, sizeof(remaining) - 1);
remaining[sizeof(remaining) - 1] = 0;
Cmd_ExecuteString(remaining, src_command);
}
char *data = COM_Parse(COM_Parse(COM_Parse(remaining)));
if (!data)
else
{
Con_Printf("Empty rcon\n");
#ifdef REHLDS_FIXES
//missing SV_EndRedirect()
SV_EndRedirect();
#endif // REHLDS_FIXES
return;
}
Q_strncpy(rcon_buff, data, sizeof(rcon_buff) - 1);
rcon_buff[sizeof(rcon_buff) - 1] = 0;
Cmd_ExecuteString(rcon_buff, src_command);
break;
}
case RCON_RESULT_BANNING:
case RCON_RESULT_BADPASSWORD:
Con_Printf("Bad rcon_password.\n");
break;
case RCON_RESULT_NOPRIVILEGE:
Con_Printf("Bad rcon_password.\nNo privilege.\n");
break;
case RCON_RESULT_NOSETPASSWORD:
Con_Printf("Bad rcon_password.\nNo password set for this server.\n");
break;
case RCON_RESULT_BADCHALLENGE:
Con_Printf("Bad rcon_password.\nBad challenge.\n");
break;
}
SV_EndRedirect();
}
@ -4697,16 +4891,38 @@ void SV_WriteEntitiesToClient(client_t *client, sizebuf_t *msg)
auto &entityState = curPack->entities[i];
if (entityState.number > MAX_CLIENTS)
{
if (sv_rehlds_attachedentities_playeranimationspeed_fix.string[0] == '1'
&& entityState.movetype == MOVETYPE_FOLLOW
&& 1 <= entityState.aiment && entityState.aiment <= MAX_CLIENTS)
if (entityState.movetype == MOVETYPE_FOLLOW)
{
if (entityState.aiment > 0 && entityState.aiment < g_psv.num_edicts)
{
if (sv_rehlds_attachedentities_playeranimationspeed_fix.string[0] == '1' &&
entityState.aiment <= MAX_CLIENTS)
{
attachedEntCount[entityState.aiment]++;
}
// Prevent crash "Cache_UnlinkLRU: NULL link" on client-side
// if aiment with sprite model will be to render as a studio model
edict_t *ent = &g_psv.edicts[entityState.aiment];
if (ent->v.modelindex >= 0 && ent->v.modelindex < MAX_MODELS
&& (!g_psv.models[ent->v.modelindex]
|| g_psv.models[ent->v.modelindex]->type != mod_studio))
{
entityState.aiment = 0;
entityState.movetype = MOVETYPE_NONE;
}
}
else
{
entityState.aiment = 0;
entityState.movetype = MOVETYPE_NONE;
}
}
// Prevent spam "Non-sprite set to glow!" in console on client-side
if (entityState.rendermode == kRenderGlow
&& (entityState.modelindex >= 0 && entityState.modelindex < MAX_MODELS)
&& g_psv.models[entityState.modelindex]
&& g_psv.models[entityState.modelindex]->type != mod_sprite)
{
entityState.rendermode = kRenderNormal;
@ -6355,7 +6571,6 @@ int EXT_FUNC RegUserMsg(const char *pszName, int iSize)
return pNewMsg->iMsg;
}
#ifdef REHLDS_FIXES
uint32_t CIDRToMask(int cidr)
{
return htonl(0xFFFFFFFFull << (32 - cidr));
@ -6505,44 +6720,6 @@ qboolean StringToFilter(const char *s, ipfilter_t *f)
return true;
}
#else // REHLDS_FIXES
qboolean StringToFilter(const char *s, ipfilter_t *f)
{
char num[128];
unsigned char b[4] = { 0, 0, 0, 0 };
unsigned char m[4] = { 0, 0, 0, 0 };
const char* cc = s;
int i = 0;
while (1)
{
if (*cc < '0' || *cc > '9')
break;
int j = 0;
while (*cc >= '0' && *cc <= '9')
num[j++] = *(cc++);
num[j] = 0;
b[i] = Q_atoi(num);
if (b[i])
m[i] = -1;
if (*cc)
{
++cc;
++i;
if (i < 4)
continue;
}
f->mask = *(uint32 *)m;
f->compare.u32 = *(uint32 *)b;
return TRUE;
}
Con_Printf("Bad filter address: %s\n", cc);
return FALSE;
}
#endif // REHLDS_FIXES
USERID_t *SV_StringToUserID(const char *str)
{
@ -7980,6 +8157,11 @@ void SV_Init(void)
Cmd_AddCommand("listid", SV_ListId_f);
Cmd_AddCommand("writeid", SV_WriteId_f);
Cmd_AddCommand("resetrcon", SV_ResetRcon_f);
#ifdef REHLDS_FIXES
Cmd_AddCommand("rcon_adduser", SV_RconAddUser_f);
Cmd_AddCommand("rcon_deluser", SV_RconDelUser_f);
Cmd_AddCommand("rcon_users", SV_RconUsers_f);
#endif
Cmd_AddCommand("logaddress", SV_SetLogAddress_f);
Cmd_AddCommand("logaddress_add", SV_AddLogAddress_f);
Cmd_AddCommand("logaddress_del", SV_DelLogAddress_f);
@ -8024,6 +8206,9 @@ void SV_Init(void)
Cvar_RegisterVariable(&sv_visiblemaxplayers);
Cvar_RegisterVariable(&sv_password);
Cvar_RegisterVariable(&sv_aim);
#ifdef REHLDS_FIXES
Cvar_RegisterVariable(&sv_allow_autoaim);
#endif
Cvar_RegisterVariable(&violence_hblood);
Cvar_RegisterVariable(&violence_ablood);
Cvar_RegisterVariable(&violence_hgibs);
@ -8091,6 +8276,7 @@ void SV_Init(void)
Cvar_RegisterVariable(&sv_version);
Cvar_RegisterVariable(&sv_allow_dlfile);
#ifdef REHLDS_FIXES
Cvar_RegisterVariable(&sv_tags);
Cvar_RegisterVariable(&sv_force_ent_intersection);
Cvar_RegisterVariable(&sv_echo_unknown_cmd);
Cvar_RegisterVariable(&sv_auto_precache_sounds_in_models);

View File

@ -232,6 +232,10 @@ CSteam3Server::CSteam3Server() :
m_CallbackLogonFailure(this, &CSteam3Server::OnLogonFailure),
m_SteamIDGS(1, 0, k_EUniverseInvalid, k_EAccountTypeInvalid)
{
#ifdef REHLDS_FIXES
m_GameTagsData[0] = '\0';
#endif
m_bHasActivePlayers = false;
m_bWantToBeSecure = false;
m_bLanOnly = false;
@ -499,6 +503,21 @@ void CSteam3Server::RunFrame()
}
}
void CSteam3Server::UpdateGameTags()
{
#ifdef REHLDS_FIXES
if (!m_GameTagsData[0] && !sv_tags.string[0])
return;
if (m_GameTagsData[0] && !Q_stricmp(m_GameTagsData, sv_tags.string))
return;
Q_strlcpy(m_GameTagsData, sv_tags.string);
Q_strlwr(m_GameTagsData);
CRehldsPlatformHolder::get()->SteamGameServer()->SetGameTags(m_GameTagsData);
#endif
}
void CSteam3Server::SendUpdatedServerDetails()
{
int botCount = 0;
@ -521,6 +540,8 @@ void CSteam3Server::SendUpdatedServerDetails()
CRehldsPlatformHolder::get()->SteamGameServer()->SetBotPlayerCount(botCount);
CRehldsPlatformHolder::get()->SteamGameServer()->SetServerName(Cvar_VariableString("hostname"));
CRehldsPlatformHolder::get()->SteamGameServer()->SetMapName(g_psv.name);
UpdateGameTags();
}
void CSteam3Client::Shutdown()

View File

@ -54,6 +54,8 @@ protected:
bool InitModule();
};
#define MAX_STEAM_TAGS_LENGTH 128 // Steam doesn't send tags string more than 128 bytes
class CSteam3Server: public CSteam3
{
public:
@ -71,6 +73,10 @@ protected:
bool m_bLanOnly;
CSteamID m_SteamIDGS;
#ifdef REHLDS_FIXES
char m_GameTagsData[MAX_STEAM_TAGS_LENGTH];
#endif
public:
NOBODY void SetServerType();
@ -96,6 +102,7 @@ public:
void NotifyOfLevelChange(bool bForce);
void RunFrame();
void SendUpdatedServerDetails();
void UpdateGameTags();
};
class CSteam3Client: public CSteam3

View File

@ -1150,46 +1150,47 @@ void EXT_FUNC EngineFprintf(void *pfile, const char *szFmt, ...)
void EXT_FUNC AlertMessage(ALERT_TYPE atype, const char *szFmt, ...)
{
char szOut[2048];
va_list argptr;
static char szOut[1024];
va_start(argptr, szFmt);
if (atype == at_logged && g_psvs.maxclients > 1)
{
va_start(argptr, szFmt);
Q_vsnprintf(szOut, sizeof(szOut), szFmt, argptr);
va_end(argptr);
Log_Printf("%s", szOut);
return;
}
else if (developer.value != 0.0f)
{
if (!developer.value)
return;
if (atype == at_aiconsole && developer.value < 2)
return;
va_start(argptr, szFmt);
Q_vsnprintf(szOut, sizeof(szOut), szFmt, argptr);
va_end(argptr);
switch (atype)
{
case at_notice:
Q_strcpy(szOut, "NOTE: ");
Con_Printf("NOTE: %s", szOut);
break;
case at_console:
szOut[0] = 0;
break;
case at_aiconsole:
if (developer.value < 2.0f)
return;
szOut[0] = 0;
Con_Printf("%s", szOut);
break;
case at_warning:
Q_strcpy(szOut, "WARNING: ");
Con_Printf("WARNING: %s", szOut);
break;
case at_error:
Q_strcpy(szOut, "ERROR: ");
break;
case at_logged:
Con_Printf("ERROR: %s", szOut);
break;
default:
break;
}
int iLen = Q_strlen(szOut);
Q_vsnprintf(&szOut[iLen], sizeof(szOut) - iLen, szFmt, argptr);
Con_Printf("%s", szOut);
}
va_end(argptr);
}
NOXREF void Sys_SplitPath(const char *path, char *drive, char *dir, char *fname, char *ext)

View File

@ -109,10 +109,10 @@ qboolean TEX_InitFromWad(char *path)
#endif // REHLDS_FIXES
texfile = FS_Open(wadPath, "rb");
texfiles[nTexFiles++] = texfile;
if (!texfile)
Sys_Error("%s: couldn't open %s\n", __func__, wadPath);
texfiles[nTexFiles++] = texfile;
Con_DPrintf("Using WAD File: %s\n", wadPath);
SafeRead(texfile, &header, 12);
if (Q_strncmp(header.identification, "WAD2", 4) && Q_strncmp(header.identification, "WAD3", 4))
@ -147,8 +147,9 @@ void TEX_CleanupWadInfo(void)
for (int i = 0; i < nTexFiles; i++)
{
if (texfiles[i])
FS_Close(texfiles[i]);
texfiles[i] = 0;
texfiles[i] = NULL;
}
nTexLumps = 0;

View File

@ -15,5 +15,7 @@ void check_size() {
void checkSizesStatic() {
CHECK_TYPE_SIZE(client_t, 0x5018, 0x4EF4);
CHECK_TYPE_SIZE(userfilter_t, 0x20, 0x18);
#ifndef REHLDS_FIXES
CHECK_TYPE_SIZE(CSteam3Server, 0x90, 0xA8);
#endif
}