mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-16 16:48:13 +03:00
Merge branch 'dreamstalker:master' into master
This commit is contained in:
commit
85294e2e5d
@ -47,4 +47,16 @@ struct cvar_listener_t
|
|||||||
const char *name;
|
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
|
#endif // CVARDEF_H
|
||||||
|
@ -1978,6 +1978,34 @@ NOXREF int COM_ExpandFilename(char *filename)
|
|||||||
return *filename != 0;
|
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)
|
int EXT_FUNC COM_FileSize(const char *filename)
|
||||||
{
|
{
|
||||||
FileHandle_t fp;
|
FileHandle_t fp;
|
||||||
|
@ -187,6 +187,8 @@ void COM_CreatePath(char *path);
|
|||||||
NOXREF void COM_CopyFile(char *netpath, char *cachepath);
|
NOXREF void COM_CopyFile(char *netpath, char *cachepath);
|
||||||
NOXREF int COM_ExpandFilename(char *filename);
|
NOXREF int COM_ExpandFilename(char *filename);
|
||||||
int COM_FileSize(const 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);
|
unsigned char *COM_LoadFile(const char *path, int usehunk, int *pLength);
|
||||||
void COM_FreeFile(void *buffer);
|
void COM_FreeFile(void *buffer);
|
||||||
void COM_CopyFileChunk(FileHandle_t dst, FileHandle_t src, int nSize);
|
void COM_CopyFileChunk(FileHandle_t dst, FileHandle_t src, int nSize);
|
||||||
|
@ -32,7 +32,8 @@
|
|||||||
All cvar names are case insensitive! Values not.
|
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[] = "";
|
char cvar_null_string[] = "";
|
||||||
|
|
||||||
void Cvar_Init(void)
|
void Cvar_Init(void)
|
||||||
@ -319,8 +320,10 @@ void Cvar_DirectSet(struct cvar_s *var, const char *value)
|
|||||||
|
|
||||||
void Cvar_Set(const char *var_name, 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)
|
if (!var)
|
||||||
{
|
{
|
||||||
Con_DPrintf("%s: variable \"%s\" not found\n", __func__, var_name);
|
Con_DPrintf("%s: variable \"%s\" not found\n", __func__, var_name);
|
||||||
@ -328,6 +331,15 @@ void Cvar_Set(const char *var_name, const char *value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Cvar_DirectSet(var, value);
|
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)
|
void Cvar_SetValue(const char *var_name, float value)
|
||||||
@ -730,3 +742,36 @@ void Cvar_CmdInit(void)
|
|||||||
{
|
{
|
||||||
Cmd_AddCommand("cvarlist", Cmd_CvarList_f);
|
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;
|
||||||
|
}
|
||||||
|
@ -57,7 +57,11 @@ cvar_t deathmatch = { "deathmatch", "0", FCVAR_SERVER, 0.0f, NULL };
|
|||||||
cvar_t coop = { "coop", "0", FCVAR_SERVER, 0.0f, NULL };
|
cvar_t coop = { "coop", "0", FCVAR_SERVER, 0.0f, NULL };
|
||||||
|
|
||||||
cvar_t sys_ticrate = { "sys_ticrate", "100.0", 0, 0.0f, NULL };
|
cvar_t sys_ticrate = { "sys_ticrate", "100.0", 0, 0.0f, NULL };
|
||||||
|
|
||||||
|
void sys_timescale_hook_callback(cvar_t *cvar);
|
||||||
|
cvarhook_t sys_timescale_hook = { sys_timescale_hook_callback, NULL, NULL };
|
||||||
cvar_t sys_timescale = { "sys_timescale", "1.0", 0, 0.0f, NULL };
|
cvar_t sys_timescale = { "sys_timescale", "1.0", 0, 0.0f, NULL };
|
||||||
|
|
||||||
cvar_t fps_max = { "fps_max", "100.0", FCVAR_ARCHIVE, 0.0f, NULL };
|
cvar_t fps_max = { "fps_max", "100.0", FCVAR_ARCHIVE, 0.0f, NULL };
|
||||||
cvar_t host_killtime = { "host_killtime", "0.0", 0, 0.0f, NULL };
|
cvar_t host_killtime = { "host_killtime", "0.0", 0, 0.0f, NULL };
|
||||||
cvar_t sv_stats = { "sv_stats", "1", 0, 0.0f, NULL };
|
cvar_t sv_stats = { "sv_stats", "1", 0, 0.0f, NULL };
|
||||||
@ -143,6 +147,9 @@ void Host_InitLocal(void)
|
|||||||
Host_InitCommands();
|
Host_InitCommands();
|
||||||
Cvar_RegisterVariable(&host_killtime);
|
Cvar_RegisterVariable(&host_killtime);
|
||||||
Cvar_RegisterVariable(&sys_ticrate);
|
Cvar_RegisterVariable(&sys_ticrate);
|
||||||
|
Cvar_RegisterVariable(&sys_timescale);
|
||||||
|
Cvar_HookVariable(sys_timescale.name, &sys_timescale_hook);
|
||||||
|
|
||||||
Cvar_RegisterVariable(&fps_max);
|
Cvar_RegisterVariable(&fps_max);
|
||||||
Cvar_RegisterVariable(&fps_override);
|
Cvar_RegisterVariable(&fps_override);
|
||||||
Cvar_RegisterVariable(&host_name);
|
Cvar_RegisterVariable(&host_name);
|
||||||
@ -355,7 +362,7 @@ void SV_ClientPrintf(const char *fmt, ...)
|
|||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
char string[1024];
|
char string[1024];
|
||||||
|
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
Q_vsnprintf(string, ARRAYSIZE(string) - 1, fmt, va);
|
Q_vsnprintf(string, ARRAYSIZE(string) - 1, fmt, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
@ -367,7 +374,7 @@ void SV_ClientPrintf(const char *fmt, ...)
|
|||||||
void EXT_FUNC SV_ClientPrintf_internal(const char *Dest)
|
void EXT_FUNC SV_ClientPrintf_internal(const char *Dest)
|
||||||
{
|
{
|
||||||
char string[1024];
|
char string[1024];
|
||||||
|
|
||||||
Q_strlcpy(string, Dest, min(strlen(Dest) + 1, sizeof(string)));
|
Q_strlcpy(string, Dest, min(strlen(Dest) + 1, sizeof(string)));
|
||||||
MSG_WriteByte(&host_client->netchan.message, svc_print);
|
MSG_WriteByte(&host_client->netchan.message, svc_print);
|
||||||
MSG_WriteString(&host_client->netchan.message, string);
|
MSG_WriteString(&host_client->netchan.message, string);
|
||||||
@ -1275,3 +1282,23 @@ void Host_Shutdown(void)
|
|||||||
g_psv.time = 0.0f;
|
g_psv.time = 0.0f;
|
||||||
g_pcl.time = 0.0f;
|
g_pcl.time = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sys_timescale_hook_callback(cvar_t *cvar)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
client_t *client = NULL;
|
||||||
|
|
||||||
|
if (!Host_IsServerActive())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < g_psvs.maxclients; i++)
|
||||||
|
{
|
||||||
|
client = &g_psvs.clients[i];
|
||||||
|
|
||||||
|
if (!client->fakeclient && (client->active || client->spawned || client->connected))
|
||||||
|
{
|
||||||
|
MSG_WriteByte(&client->netchan.message, svc_timescale);
|
||||||
|
MSG_WriteFloat(&client->netchan.message, max(0.1f, sys_timescale.value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -205,11 +205,19 @@ void Host_Motd_f(void)
|
|||||||
char *next;
|
char *next;
|
||||||
|
|
||||||
pFileList = motdfile.string;
|
pFileList = motdfile.string;
|
||||||
if (*pFileList == '/' || Q_strstr(pFileList, ":") || Q_strstr(pFileList, "..") || Q_strstr(pFileList, "\\"))
|
if (!COM_IsValidPath(pFileList) || COM_IsAbsolutePath(pFileList))
|
||||||
{
|
{
|
||||||
Con_Printf("Unable to open %s (contains illegal characters)\n", pFileList);
|
Con_Printf("Unable to open %s (contains illegal characters)\n", pFileList);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *pchExtension = COM_FileExtension(pFileList);
|
||||||
|
if (Q_stricmp(pchExtension, "txt") != 0)
|
||||||
|
{
|
||||||
|
Con_Printf("Invalid motdfile name %s (wrong file extension, must be .txt)\n", pFileList);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pFile = FS_Open(pFileList, "rb");
|
pFile = FS_Open(pFileList, "rb");
|
||||||
if (!pFile)
|
if (!pFile)
|
||||||
{
|
{
|
||||||
@ -753,6 +761,111 @@ void Host_Status_Formatted_f(void)
|
|||||||
Host_Status_Printf(conprint, log, "%i users\n", nClients);
|
Host_Status_Printf(conprint, log, "%i users\n", nClients);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sets client to godmode
|
||||||
|
void Host_God_f(void)
|
||||||
|
{
|
||||||
|
if (cmd_source == src_command)
|
||||||
|
{
|
||||||
|
Cmd_ForwardToServer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sv_cheats.value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE;
|
||||||
|
if (!((int)sv_player->v.flags & FL_GODMODE))
|
||||||
|
SV_ClientPrintf("godmode OFF\n");
|
||||||
|
else
|
||||||
|
SV_ClientPrintf("godmode ON\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sets client to notarget mode
|
||||||
|
void Host_Notarget_f(void)
|
||||||
|
{
|
||||||
|
if (cmd_source == src_command)
|
||||||
|
{
|
||||||
|
Cmd_ForwardToServer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sv_cheats.value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET;
|
||||||
|
if (!((int)sv_player->v.flags & FL_NOTARGET))
|
||||||
|
SV_ClientPrintf("notarget OFF\n");
|
||||||
|
else
|
||||||
|
SV_ClientPrintf("notarget ON\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Searches along the direction ray in steps of "step" to see if
|
||||||
|
// the entity position is passible
|
||||||
|
// Used for putting the player in valid space when toggling off noclip mode
|
||||||
|
int FindPassableSpace(edict_t *pEdict, vec_t *direction, float step)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < 100; i++)
|
||||||
|
{
|
||||||
|
VectorMA(pEdict->v.origin, step, direction, pEdict->v.origin);
|
||||||
|
|
||||||
|
if (!SV_TestEntityPosition(pEdict))
|
||||||
|
{
|
||||||
|
// Store old origin
|
||||||
|
VectorCopy(pEdict->v.origin, pEdict->v.oldorigin);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Host_Noclip_f(void)
|
||||||
|
{
|
||||||
|
if (cmd_source == src_command)
|
||||||
|
{
|
||||||
|
Cmd_ForwardToServer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sv_cheats.value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (sv_player->v.movetype != MOVETYPE_NOCLIP)
|
||||||
|
{
|
||||||
|
sv_player->v.movetype = MOVETYPE_NOCLIP;
|
||||||
|
SV_ClientPrintf("noclip ON\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sv_player->v.movetype = MOVETYPE_WALK;
|
||||||
|
|
||||||
|
// Store old origin
|
||||||
|
VectorCopy(sv_player->v.origin, sv_player->v.oldorigin);
|
||||||
|
|
||||||
|
SV_ClientPrintf("noclip OFF\n");
|
||||||
|
|
||||||
|
if (SV_TestEntityPosition(sv_player))
|
||||||
|
{
|
||||||
|
vec3_t forward, right, up;
|
||||||
|
AngleVectors(sv_player->v.v_angle, forward, right, up);
|
||||||
|
|
||||||
|
if (!FindPassableSpace(sv_player, forward, 1.0)
|
||||||
|
&& !FindPassableSpace(sv_player, right, 1.0)
|
||||||
|
&& !FindPassableSpace(sv_player, right, -1.0) // left
|
||||||
|
&& !FindPassableSpace(sv_player, up, 1.0) // up
|
||||||
|
&& !FindPassableSpace(sv_player, up, -1.0) // down
|
||||||
|
&& !FindPassableSpace(sv_player, forward, -1.0)) // back
|
||||||
|
{
|
||||||
|
Con_DPrintf("Can't find the world\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
VectorCopy(sv_player->v.oldorigin, sv_player->v.origin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Host_Ping_f(void)
|
void Host_Ping_f(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -3138,11 +3251,12 @@ void Host_InitCommands(void)
|
|||||||
Cmd_AddCommand("setinfo", Host_SetInfo_f);
|
Cmd_AddCommand("setinfo", Host_SetInfo_f);
|
||||||
Cmd_AddCommand("fullinfo", Host_FullInfo_f);
|
Cmd_AddCommand("fullinfo", Host_FullInfo_f);
|
||||||
|
|
||||||
#ifndef SWDS
|
|
||||||
Cmd_AddCommand("god", Host_God_f);
|
Cmd_AddCommand("god", Host_God_f);
|
||||||
Cmd_AddCommand("notarget", Host_Notarget_f);
|
Cmd_AddCommand("notarget", Host_Notarget_f);
|
||||||
Cmd_AddCommand("fly", Host_Fly_f);
|
|
||||||
Cmd_AddCommand("noclip", Host_Noclip_f);
|
Cmd_AddCommand("noclip", Host_Noclip_f);
|
||||||
|
|
||||||
|
#ifndef SWDS
|
||||||
|
Cmd_AddCommand("fly", Host_Fly_f);
|
||||||
Cmd_AddCommand("viewmodel", Host_Viewmodel_f);
|
Cmd_AddCommand("viewmodel", Host_Viewmodel_f);
|
||||||
Cmd_AddCommand("viewframe", Host_Viewframe_f);
|
Cmd_AddCommand("viewframe", Host_Viewframe_f);
|
||||||
Cmd_AddCommand("viewnext", Host_Viewnext_f);
|
Cmd_AddCommand("viewnext", Host_Viewnext_f);
|
||||||
|
@ -418,3 +418,12 @@ qboolean VectorCompare(const vec_t *v1, const vec_t *v2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // #if !defined(REHLDS_SSE)
|
#endif // #if !defined(REHLDS_SSE)
|
||||||
|
|
||||||
|
qboolean BoundsIntersect(const vec3_t mins1, const vec3_t maxs1, const vec3_t mins2, const vec3_t maxs2)
|
||||||
|
{
|
||||||
|
if (mins1[0] > maxs2[0] || mins1[1] > maxs2[1] || mins1[2] > maxs2[2])
|
||||||
|
return FALSE;
|
||||||
|
if (maxs1[0] < mins2[0] || maxs1[1] < mins2[1] || maxs1[2] < mins2[2])
|
||||||
|
return FALSE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
@ -171,3 +171,4 @@ void R_ConcatTransforms(float in1[3][4], float in2[3][4], float out[3][4]);
|
|||||||
NOBODY void FloorDivMod(double numer, double denom, int *quotient, int *rem);
|
NOBODY void FloorDivMod(double numer, double denom, int *quotient, int *rem);
|
||||||
NOBODY int GreatestCommonDivisor(int i1, int i2);
|
NOBODY int GreatestCommonDivisor(int i1, int i2);
|
||||||
NOBODY fixed16_t Invert24To16(fixed16_t val);
|
NOBODY fixed16_t Invert24To16(fixed16_t val);
|
||||||
|
qboolean BoundsIntersect(const vec3_t mins1, const vec3_t maxs1, const vec3_t mins2, const vec3_t maxs2);
|
||||||
|
@ -651,7 +651,7 @@ void NET_AdjustLag()
|
|||||||
}
|
}
|
||||||
lasttime = realtime;
|
lasttime = realtime;
|
||||||
|
|
||||||
if (allow_cheats || fakelag.value == 0.0)
|
if (sv_cheats.value || fakelag.value == 0.0)
|
||||||
{
|
{
|
||||||
if (fakelag.value != gFakeLag)
|
if (fakelag.value != gFakeLag)
|
||||||
{
|
{
|
||||||
@ -689,7 +689,7 @@ qboolean NET_LagPacket(qboolean newdata, netsrc_t sock, netadr_t *from, sizebuf_
|
|||||||
{
|
{
|
||||||
if (fakeloss.value != 0.0)
|
if (fakeloss.value != 0.0)
|
||||||
{
|
{
|
||||||
if (allow_cheats)
|
if (sv_cheats.value)
|
||||||
{
|
{
|
||||||
static int losscount[NS_MAX] = {};
|
static int losscount[NS_MAX] = {};
|
||||||
++losscount[sock];
|
++losscount[sock];
|
||||||
|
@ -1447,6 +1447,9 @@ int EXT_FUNC PF_precache_model_I_internal(const char *s)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_MODELS; i++)
|
for (int i = 0; i < MAX_MODELS; i++)
|
||||||
{
|
{
|
||||||
|
if (!g_psv.model_precache[i])
|
||||||
|
continue;
|
||||||
|
|
||||||
// use case-sensitive names to increase performance
|
// use case-sensitive names to increase performance
|
||||||
#ifdef REHLDS_FIXES
|
#ifdef REHLDS_FIXES
|
||||||
if (!Q_strcmp(g_psv.model_precache[i], s))
|
if (!Q_strcmp(g_psv.model_precache[i], s))
|
||||||
@ -1545,7 +1548,7 @@ int EXT_FUNC PF_precache_generic_I_internal(const char *s)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_GENERIC; i++)
|
for (int i = 0; i < MAX_GENERIC; i++)
|
||||||
{
|
{
|
||||||
if (!Q_stricmp(g_psv.generic_precache[i], s))
|
if (g_psv.generic_precache[i] && !Q_stricmp(g_psv.generic_precache[i], s))
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
Host_Error("%s: '%s' Precache can only be done in spawn functions", __func__, s);
|
Host_Error("%s: '%s' Precache can only be done in spawn functions", __func__, s);
|
||||||
|
@ -349,7 +349,6 @@ extern cvar_t sv_proxies;
|
|||||||
extern cvar_t sv_outofdatetime;
|
extern cvar_t sv_outofdatetime;
|
||||||
extern cvar_t mapchangecfgfile;
|
extern cvar_t mapchangecfgfile;
|
||||||
|
|
||||||
extern qboolean allow_cheats;
|
|
||||||
extern cvar_t mp_logecho;
|
extern cvar_t mp_logecho;
|
||||||
extern cvar_t mp_logfile;
|
extern cvar_t mp_logfile;
|
||||||
extern cvar_t sv_allow_download;
|
extern cvar_t sv_allow_download;
|
||||||
|
@ -100,7 +100,6 @@ redirect_t sv_redirected;
|
|||||||
netadr_t sv_redirectto;
|
netadr_t sv_redirectto;
|
||||||
|
|
||||||
GameType_e g_eGameType = GT_Unitialized;
|
GameType_e g_eGameType = GT_Unitialized;
|
||||||
qboolean allow_cheats;
|
|
||||||
|
|
||||||
char *gNullString = "";
|
char *gNullString = "";
|
||||||
int SV_UPDATE_BACKUP = SINGLEPLAYER_BACKUP;
|
int SV_UPDATE_BACKUP = SINGLEPLAYER_BACKUP;
|
||||||
@ -130,6 +129,12 @@ cvar_t sv_waterfriction = { "sv_waterfriction", "1", FCVAR_SERVER, 0.0f, NULL };
|
|||||||
cvar_t sv_zmax = { "sv_zmax", "4096", FCVAR_SPONLY, 0.0f, NULL };
|
cvar_t sv_zmax = { "sv_zmax", "4096", FCVAR_SPONLY, 0.0f, NULL };
|
||||||
cvar_t sv_wateramp = { "sv_wateramp", "0", 0, 0.0f, NULL };
|
cvar_t sv_wateramp = { "sv_wateramp", "0", 0, 0.0f, NULL };
|
||||||
|
|
||||||
|
void sv_cheats_hook_callback(cvar_t *cvar);
|
||||||
|
void mapcyclefile_hook_callback(cvar_t *cvar);
|
||||||
|
|
||||||
|
cvarhook_t sv_cheats_hook = { sv_cheats_hook_callback, NULL, NULL };
|
||||||
|
cvarhook_t mapcyclefile_hook = { mapcyclefile_hook_callback, NULL, NULL };
|
||||||
|
|
||||||
cvar_t sv_skyname = { "sv_skyname", "desert", 0, 0.0f, NULL };
|
cvar_t sv_skyname = { "sv_skyname", "desert", 0, 0.0f, NULL };
|
||||||
cvar_t mapcyclefile = { "mapcyclefile", "mapcycle.txt", 0, 0.0f, NULL };
|
cvar_t mapcyclefile = { "mapcyclefile", "mapcycle.txt", 0, 0.0f, NULL };
|
||||||
cvar_t motdfile = { "motdfile", "motd.txt", 0, 0.0f, NULL };
|
cvar_t motdfile = { "motdfile", "motd.txt", 0, 0.0f, NULL };
|
||||||
@ -1173,7 +1178,7 @@ void SV_SendServerinfo_internal(sizebuf_t *msg, client_t *client)
|
|||||||
|
|
||||||
MSG_WriteByte(msg, svc_sendextrainfo);
|
MSG_WriteByte(msg, svc_sendextrainfo);
|
||||||
MSG_WriteString(msg, com_clientfallback);
|
MSG_WriteString(msg, com_clientfallback);
|
||||||
MSG_WriteByte(msg, allow_cheats);
|
MSG_WriteByte(msg, sv_cheats.value != 0);
|
||||||
|
|
||||||
SV_WriteDeltaDescriptionsToClient(msg);
|
SV_WriteDeltaDescriptionsToClient(msg);
|
||||||
SV_SetMoveVars();
|
SV_SetMoveVars();
|
||||||
@ -6257,7 +6262,6 @@ int SV_SpawnServer(qboolean bIsDemo, char *server, char *startspot)
|
|||||||
gGlobalVariables.serverflags = g_psvs.serverflags;
|
gGlobalVariables.serverflags = g_psvs.serverflags;
|
||||||
gGlobalVariables.mapname = (size_t)g_psv.name - (size_t)pr_strings;
|
gGlobalVariables.mapname = (size_t)g_psv.name - (size_t)pr_strings;
|
||||||
gGlobalVariables.startspot = (size_t)g_psv.startspot - (size_t)pr_strings;
|
gGlobalVariables.startspot = (size_t)g_psv.startspot - (size_t)pr_strings;
|
||||||
allow_cheats = sv_cheats.value;
|
|
||||||
SV_SetMoveVars();
|
SV_SetMoveVars();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -6576,6 +6580,42 @@ void EXT_FUNC SV_SerializeSteamid(USERID_t* id, USERID_t* serialized)
|
|||||||
*serialized = *id;
|
*serialized = *id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sv_cheats_hook_callback(cvar_t *cvar)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
client_t *client = NULL;
|
||||||
|
|
||||||
|
if (!Host_IsServerActive())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < g_psvs.maxclients; i++)
|
||||||
|
{
|
||||||
|
client = &g_psvs.clients[i];
|
||||||
|
|
||||||
|
if (!client->fakeclient && (client->active || client->spawned || client->connected))
|
||||||
|
{
|
||||||
|
MSG_WriteByte(&client->netchan.message, svc_sendextrainfo);
|
||||||
|
MSG_WriteString(&client->netchan.message, "");
|
||||||
|
MSG_WriteByte(&client->netchan.message, sv_cheats.value != 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void mapcyclefile_hook_callback(cvar_t *cvar)
|
||||||
|
{
|
||||||
|
char buf[MAX_PATH + 4];
|
||||||
|
|
||||||
|
if (!Q_strcmp(COM_FileExtension(cvar->string), "txt"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Q_snprintf(buf, sizeof(buf) - 3, "%s.txt", cvar->string);
|
||||||
|
|
||||||
|
if (!Q_strcmp(COM_FileExtension(buf), "txt"))
|
||||||
|
Cvar_DirectSet(cvar, buf);
|
||||||
|
else
|
||||||
|
Cvar_DirectSet(cvar, "mapcycle.txt");
|
||||||
|
}
|
||||||
|
|
||||||
void SV_BanId_f(void)
|
void SV_BanId_f(void)
|
||||||
{
|
{
|
||||||
char szreason[256];
|
char szreason[256];
|
||||||
@ -8014,6 +8054,7 @@ void SV_Init(void)
|
|||||||
Cvar_RegisterVariable(&sv_skyname);
|
Cvar_RegisterVariable(&sv_skyname);
|
||||||
Cvar_RegisterVariable(&sv_maxvelocity);
|
Cvar_RegisterVariable(&sv_maxvelocity);
|
||||||
Cvar_RegisterVariable(&sv_cheats);
|
Cvar_RegisterVariable(&sv_cheats);
|
||||||
|
Cvar_HookVariable(sv_cheats.name, &sv_cheats_hook);
|
||||||
if (COM_CheckParm("-dev"))
|
if (COM_CheckParm("-dev"))
|
||||||
Cvar_SetValue("sv_cheats", 1.0);
|
Cvar_SetValue("sv_cheats", 1.0);
|
||||||
Cvar_RegisterVariable(&sv_spectatormaxspeed);
|
Cvar_RegisterVariable(&sv_spectatormaxspeed);
|
||||||
@ -8025,6 +8066,7 @@ void SV_Init(void)
|
|||||||
Cvar_RegisterVariable(&sv_logbans);
|
Cvar_RegisterVariable(&sv_logbans);
|
||||||
Cvar_RegisterVariable(&hpk_maxsize);
|
Cvar_RegisterVariable(&hpk_maxsize);
|
||||||
Cvar_RegisterVariable(&mapcyclefile);
|
Cvar_RegisterVariable(&mapcyclefile);
|
||||||
|
Cvar_HookVariable(mapcyclefile.name, &mapcyclefile_hook);
|
||||||
Cvar_RegisterVariable(&motdfile);
|
Cvar_RegisterVariable(&motdfile);
|
||||||
Cvar_RegisterVariable(&servercfgfile);
|
Cvar_RegisterVariable(&servercfgfile);
|
||||||
Cvar_RegisterVariable(&mapchangecfgfile);
|
Cvar_RegisterVariable(&mapchangecfgfile);
|
||||||
|
@ -42,7 +42,7 @@ edict_t *sv_player;
|
|||||||
qboolean nofind;
|
qboolean nofind;
|
||||||
|
|
||||||
#if defined(SWDS) && defined(REHLDS_FIXES)
|
#if defined(SWDS) && defined(REHLDS_FIXES)
|
||||||
const char *clcommands[] = { "status", "name", "kill", "pause", "spawn", "new", "sendres", "dropclient", "kick", "ping", "dlfile", "setinfo", "sendents", "fullupdate", "setpause", "unpause", NULL };
|
const char *clcommands[] = { "status", "name", "kill", "pause", "spawn", "new", "sendres", "dropclient", "kick", "ping", "dlfile", "setinfo", "sendents", "fullupdate", "setpause", "unpause", "noclip", "god", "notarget", NULL };
|
||||||
#else
|
#else
|
||||||
const char *clcommands[23] = { "status", "god", "notarget", "fly", "name", "noclip", "kill", "pause", "spawn", "new", "sendres", "dropclient", "kick", "ping", "dlfile", "nextdl", "setinfo", "showinfo", "sendents", "fullupdate", "setpause", "unpause", NULL };
|
const char *clcommands[23] = { "status", "god", "notarget", "fly", "name", "noclip", "kill", "pause", "spawn", "new", "sendres", "dropclient", "kick", "ping", "dlfile", "nextdl", "setinfo", "showinfo", "sendents", "fullupdate", "setpause", "unpause", NULL };
|
||||||
#endif
|
#endif
|
||||||
@ -525,7 +525,6 @@ void SV_AddLinksToPM_(areanode_t *node, float *pmove_mins, float *pmove_maxs)
|
|||||||
edict_t *check;
|
edict_t *check;
|
||||||
int e;
|
int e;
|
||||||
physent_t *ve;
|
physent_t *ve;
|
||||||
int i;
|
|
||||||
link_t *next;
|
link_t *next;
|
||||||
float *fmax;
|
float *fmax;
|
||||||
float *fmin;
|
float *fmin;
|
||||||
@ -588,13 +587,7 @@ void SV_AddLinksToPM_(areanode_t *node, float *pmove_mins, float *pmove_maxs)
|
|||||||
if (check->v.flags & FL_CLIENT)
|
if (check->v.flags & FL_CLIENT)
|
||||||
SV_GetTrueMinMax(e - 1, &fmin, &fmax);
|
SV_GetTrueMinMax(e - 1, &fmin, &fmax);
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
if (!BoundsIntersect(pmove_mins, pmove_maxs, fmin, fmax))
|
||||||
{
|
|
||||||
if (fmin[i] > pmove_maxs[i] || fmax[i] < pmove_mins[i])
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i != 3)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (check->v.solid || check->v.skin != -16)
|
if (check->v.solid || check->v.skin != -16)
|
||||||
|
@ -359,12 +359,7 @@ void SV_TouchLinks(edict_t *ent, areanode_t *node)
|
|||||||
if (touch->v.solid != SOLID_TRIGGER)
|
if (touch->v.solid != SOLID_TRIGGER)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ent->v.absmin[0] > touch->v.absmax[0]
|
if (!BoundsIntersect(ent->v.absmin, ent->v.absmax, touch->v.absmin, touch->v.absmax))
|
||||||
|| ent->v.absmin[1] > touch->v.absmax[1]
|
|
||||||
|| ent->v.absmin[2] > touch->v.absmax[2]
|
|
||||||
|| ent->v.absmax[0] < touch->v.absmin[0]
|
|
||||||
|| ent->v.absmax[1] < touch->v.absmin[1]
|
|
||||||
|| ent->v.absmax[2] < touch->v.absmin[2])
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// check brush triggers accuracy
|
// check brush triggers accuracy
|
||||||
@ -647,12 +642,7 @@ int SV_LinkContents(areanode_t *node, const vec_t *pos)
|
|||||||
if (Mod_GetType(touch->v.modelindex) != mod_brush)
|
if (Mod_GetType(touch->v.modelindex) != mod_brush)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (pos[0] > touch->v.absmax[0]
|
if (!BoundsIntersect(pos, pos, touch->v.absmin, touch->v.absmax))
|
||||||
|| pos[1] > touch->v.absmax[1]
|
|
||||||
|| pos[2] > touch->v.absmax[2]
|
|
||||||
|| pos[0] < touch->v.absmin[0]
|
|
||||||
|| pos[1] < touch->v.absmin[1]
|
|
||||||
|| pos[2] < touch->v.absmin[2])
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int contents = touch->v.skin;
|
int contents = touch->v.skin;
|
||||||
@ -1190,13 +1180,15 @@ void SV_ClipToLinks(areanode_t *node, moveclip_t *clip)
|
|||||||
if (touch->v.solid == SOLID_TRIGGER)
|
if (touch->v.solid == SOLID_TRIGGER)
|
||||||
Sys_Error("%s: Trigger in clipping list", __func__);
|
Sys_Error("%s: Trigger in clipping list", __func__);
|
||||||
|
|
||||||
|
#ifndef REHLDS_OPT_PEDANTIC
|
||||||
if (gNewDLLFunctions.pfnShouldCollide && !gNewDLLFunctions.pfnShouldCollide(touch, clip->passedict))
|
if (gNewDLLFunctions.pfnShouldCollide && !gNewDLLFunctions.pfnShouldCollide(touch, clip->passedict))
|
||||||
#ifdef REHLDS_FIXES
|
#ifdef REHLDS_FIXES
|
||||||
// https://github.com/dreamstalker/rehlds/issues/46
|
// https://github.com/dreamstalker/rehlds/issues/46
|
||||||
continue;
|
continue;
|
||||||
#else
|
#else
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif // REHLDS_FIXES
|
||||||
|
#endif // REHLDS_OPT_PEDANTIC
|
||||||
|
|
||||||
// monsterclip filter
|
// monsterclip filter
|
||||||
if (touch->v.solid == SOLID_BSP)
|
if (touch->v.solid == SOLID_BSP)
|
||||||
@ -1214,12 +1206,7 @@ void SV_ClipToLinks(areanode_t *node, moveclip_t *clip)
|
|||||||
if (clip->ignoretrans && touch->v.rendermode != kRenderNormal && !(touch->v.flags & FL_WORLDBRUSH))
|
if (clip->ignoretrans && touch->v.rendermode != kRenderNormal && !(touch->v.flags & FL_WORLDBRUSH))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (clip->boxmins[0] > touch->v.absmax[0]
|
if (!BoundsIntersect(clip->boxmins, clip->boxmaxs, touch->v.absmin, touch->v.absmax))
|
||||||
|| clip->boxmins[1] > touch->v.absmax[1]
|
|
||||||
|| clip->boxmins[2] > touch->v.absmax[2]
|
|
||||||
|| clip->boxmaxs[0] < touch->v.absmin[0]
|
|
||||||
|| clip->boxmaxs[1] < touch->v.absmin[1]
|
|
||||||
|| clip->boxmaxs[2] < touch->v.absmin[2])
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (touch->v.solid != SOLID_SLIDEBOX
|
if (touch->v.solid != SOLID_SLIDEBOX
|
||||||
@ -1248,6 +1235,16 @@ void SV_ClipToLinks(areanode_t *node, moveclip_t *clip)
|
|||||||
continue; // don't clip against owner
|
continue; // don't clip against owner
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef REHLDS_OPT_PEDANTIC
|
||||||
|
if (gNewDLLFunctions.pfnShouldCollide && !gNewDLLFunctions.pfnShouldCollide(touch, clip->passedict))
|
||||||
|
#ifdef REHLDS_FIXES
|
||||||
|
// https://github.com/dreamstalker/rehlds/issues/46
|
||||||
|
continue;
|
||||||
|
#else
|
||||||
|
return;
|
||||||
|
#endif // REHLDS_FIXES
|
||||||
|
#endif // REHLDS_OPT_PEDANTIC
|
||||||
|
|
||||||
trace_t trace;
|
trace_t trace;
|
||||||
if (touch->v.flags & FL_MONSTER)
|
if (touch->v.flags & FL_MONSTER)
|
||||||
trace = SV_ClipMoveToEntity(touch, clip->start, clip->mins2, clip->maxs2, clip->end);
|
trace = SV_ClipMoveToEntity(touch, clip->start, clip->mins2, clip->maxs2, clip->end);
|
||||||
@ -1298,12 +1295,7 @@ void SV_ClipToWorldbrush(areanode_t *node, moveclip_t *clip)
|
|||||||
if (!(touch->v.flags & FL_WORLDBRUSH))
|
if (!(touch->v.flags & FL_WORLDBRUSH))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (clip->boxmins[0] > touch->v.absmax[0]
|
if (!BoundsIntersect(clip->boxmins, clip->boxmaxs, touch->v.absmin, touch->v.absmax))
|
||||||
|| clip->boxmins[1] > touch->v.absmax[1]
|
|
||||||
|| clip->boxmins[2] > touch->v.absmax[2]
|
|
||||||
|| clip->boxmaxs[0] < touch->v.absmin[0]
|
|
||||||
|| clip->boxmaxs[1] < touch->v.absmin[1]
|
|
||||||
|| clip->boxmaxs[2] < touch->v.absmin[2])
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (clip->trace.allsolid)
|
if (clip->trace.allsolid)
|
||||||
|
@ -679,7 +679,7 @@ void Cache_Force_Flush()
|
|||||||
|
|
||||||
void Cache_Flush()
|
void Cache_Flush()
|
||||||
{
|
{
|
||||||
if (g_pcl.maxclients <= 1 || allow_cheats)
|
if (g_pcl.maxclients <= 1 || sv_cheats.value)
|
||||||
{
|
{
|
||||||
Cache_Force_Flush();
|
Cache_Force_Flush();
|
||||||
}
|
}
|
||||||
|
@ -463,6 +463,7 @@
|
|||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\version\msvc\version.vcxproj">
|
<ProjectReference Include="..\version\msvc\version.vcxproj">
|
||||||
<Project>{6973dca5-253c-4d84-b51e-187e035eae06}</Project>
|
<Project>{6973dca5-253c-4d84-b51e-187e035eae06}</Project>
|
||||||
|
<Private>false</Private>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
|
@ -52,7 +52,9 @@ char* EXT_FUNC GetClientFallback_api() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int* EXT_FUNC GetAllowCheats_api() {
|
int* EXT_FUNC GetAllowCheats_api() {
|
||||||
return &allow_cheats;
|
static int sv_cheats_stub = 0;
|
||||||
|
Con_Printf("WARNING! allow_cheats marked as deprecated! Use sv_cheats cvar directly!\n");
|
||||||
|
return &sv_cheats_stub;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EXT_FUNC GSBSecure_api() {
|
bool EXT_FUNC GSBSecure_api() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user