mirror of
https://github.com/rehlds/rehlds.git
synced 2024-12-29 08:05:50 +03:00
Refactor & Fix pr_cmds.cpp (#437)
* Use sizeof in PF_stuffcmd_I * Undef IGETINDEX_CHECK_FIELD after usage * Move index variables to loops * Use __func__ whenever possible, addition to #353
This commit is contained in:
parent
7efc256c7c
commit
52c6d0f855
@ -828,7 +828,7 @@ void EXT_FUNC PF_stuffcmd_I(edict_t *pEdict, const char *szFmt, ...)
|
|||||||
Q_vsnprintf(szOut, sizeof(szOut), szFmt, argptr);
|
Q_vsnprintf(szOut, sizeof(szOut), szFmt, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
szOut[1023] = 0;
|
szOut[sizeof(szOut) - 1] = 0;
|
||||||
if (entnum < 1 || entnum > g_psvs.maxclients)
|
if (entnum < 1 || entnum > g_psvs.maxclients)
|
||||||
{
|
{
|
||||||
Con_Printf("\n!!!\n\nStuffCmd: Some entity tried to stuff '%s' to console "
|
Con_Printf("\n!!!\n\nStuffCmd: Some entity tried to stuff '%s' to console "
|
||||||
@ -977,6 +977,8 @@ int EXT_FUNC iGetIndex(const char *pszField)
|
|||||||
IGETINDEX_CHECK_FIELD(noise3);
|
IGETINDEX_CHECK_FIELD(noise3);
|
||||||
IGETINDEX_CHECK_FIELD(globalname);
|
IGETINDEX_CHECK_FIELD(globalname);
|
||||||
|
|
||||||
|
#undef IGETINDEX_CHECK_FIELD
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1017,8 +1019,6 @@ qboolean EXT_FUNC PR_IsEmptyString(const char *s)
|
|||||||
|
|
||||||
int EXT_FUNC PF_precache_sound_I(const char *s)
|
int EXT_FUNC PF_precache_sound_I(const char *s)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!s)
|
if (!s)
|
||||||
Host_Error("%s: NULL pointer", __func__);
|
Host_Error("%s: NULL pointer", __func__);
|
||||||
|
|
||||||
@ -1032,7 +1032,7 @@ int EXT_FUNC PF_precache_sound_I(const char *s)
|
|||||||
{
|
{
|
||||||
g_psv.sound_precache_hashedlookup_built = 0;
|
g_psv.sound_precache_hashedlookup_built = 0;
|
||||||
|
|
||||||
for (i = 0; i < MAX_SOUNDS; i++)
|
for (int i = 0; i < MAX_SOUNDS; i++)
|
||||||
{
|
{
|
||||||
if (!g_psv.sound_precache[i])
|
if (!g_psv.sound_precache[i])
|
||||||
{
|
{
|
||||||
@ -1055,7 +1055,7 @@ int EXT_FUNC PF_precache_sound_I(const char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// precaching not enabled. check if already exists.
|
// precaching not enabled. check if already exists.
|
||||||
for (i = 0; i < MAX_SOUNDS; i++)
|
for (int i = 0; i < MAX_SOUNDS; i++)
|
||||||
{
|
{
|
||||||
if (g_psv.sound_precache[i] && !Q_stricmp(g_psv.sound_precache[i], s))
|
if (g_psv.sound_precache[i] && !Q_stricmp(g_psv.sound_precache[i], s))
|
||||||
return i;
|
return i;
|
||||||
@ -1739,7 +1739,6 @@ void EXT_FUNC PF_aim_I(edict_t *ent, float speed, float *rgflReturn)
|
|||||||
vec3_t dir;
|
vec3_t dir;
|
||||||
vec3_t end;
|
vec3_t end;
|
||||||
vec3_t bestdir;
|
vec3_t bestdir;
|
||||||
int j;
|
|
||||||
trace_t tr;
|
trace_t tr;
|
||||||
float dist;
|
float dist;
|
||||||
float bestdist;
|
float bestdist;
|
||||||
@ -1788,7 +1787,7 @@ void EXT_FUNC PF_aim_I(edict_t *ent, float speed, float *rgflReturn)
|
|||||||
if (ent->v.team > 0 && ent->v.team == check->v.team)
|
if (ent->v.team > 0 && ent->v.team == check->v.team)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (j = 0; j < 3; j++)
|
for (int j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
end[j] = (check->v.maxs[j] + check->v.mins[j]) * 0.75 + check->v.origin[j] + ent->v.view_ofs[j] * 0.0;
|
end[j] = (check->v.maxs[j] + check->v.mins[j]) * 0.75 + check->v.origin[j] + ent->v.view_ofs[j] * 0.0;
|
||||||
}
|
}
|
||||||
@ -2560,7 +2559,7 @@ const char* EXT_FUNC PF_GetPhysicsInfoString(const edict_t *pClient)
|
|||||||
int entnum = NUM_FOR_EDICT(pClient);
|
int entnum = NUM_FOR_EDICT(pClient);
|
||||||
if (entnum < 1 || entnum > g_psvs.maxclients)
|
if (entnum < 1 || entnum > g_psvs.maxclients)
|
||||||
{
|
{
|
||||||
Con_Printf("tried to PF_GetPhysicsInfoString a non-client\n");
|
Con_Printf("tried to %s a non-client\n", __func__);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2573,7 +2572,7 @@ const char* EXT_FUNC PF_GetPhysicsKeyValue(const edict_t *pClient, const char *k
|
|||||||
int entnum = NUM_FOR_EDICT(pClient);
|
int entnum = NUM_FOR_EDICT(pClient);
|
||||||
if (entnum < 1 || entnum > g_psvs.maxclients)
|
if (entnum < 1 || entnum > g_psvs.maxclients)
|
||||||
{
|
{
|
||||||
Con_Printf("tried to PF_GetPhysicsKeyValue a non-client\n");
|
Con_Printf("tried to %s a non-client\n", __func__);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2585,7 +2584,7 @@ void EXT_FUNC PF_SetPhysicsKeyValue(const edict_t *pClient, const char *key, con
|
|||||||
{
|
{
|
||||||
int entnum = NUM_FOR_EDICT(pClient);
|
int entnum = NUM_FOR_EDICT(pClient);
|
||||||
if (entnum < 1 || entnum > g_psvs.maxclients)
|
if (entnum < 1 || entnum > g_psvs.maxclients)
|
||||||
Con_Printf("tried to PF_SetPhysicsKeyValue a non-client\n");
|
Con_Printf("tried to %s a non-client\n", __func__);
|
||||||
|
|
||||||
client_t* client = &g_psvs.clients[entnum - 1];
|
client_t* client = &g_psvs.clients[entnum - 1];
|
||||||
Info_SetValueForKey(client->physinfo, key, value, MAX_INFO_STRING);
|
Info_SetValueForKey(client->physinfo, key, value, MAX_INFO_STRING);
|
||||||
@ -2605,7 +2604,7 @@ int EXT_FUNC PF_CanSkipPlayer(const edict_t *pClient)
|
|||||||
int entnum = NUM_FOR_EDICT(pClient);
|
int entnum = NUM_FOR_EDICT(pClient);
|
||||||
if (entnum < 1 || entnum > g_psvs.maxclients)
|
if (entnum < 1 || entnum > g_psvs.maxclients)
|
||||||
{
|
{
|
||||||
Con_Printf("tried to PF_CanSkipPlayer a non-client\n");
|
Con_Printf("tried to %s a non-client\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2698,7 +2697,7 @@ void EXT_FUNC PF_GetPlayerStats(const edict_t *pClient, int *ping, int *packet_l
|
|||||||
int c = NUM_FOR_EDICT(pClient);
|
int c = NUM_FOR_EDICT(pClient);
|
||||||
if (c < 1 || c > g_psvs.maxclients)
|
if (c < 1 || c > g_psvs.maxclients)
|
||||||
{
|
{
|
||||||
Con_Printf("tried to PF_GetPlayerStats a non-client\n");
|
Con_Printf("tried to %s a non-client\n", __func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2767,7 +2766,7 @@ void EXT_FUNC QueryClientCvarValue(const edict_t *player, const char *cvarName)
|
|||||||
if (gNewDLLFunctions.pfnCvarValue)
|
if (gNewDLLFunctions.pfnCvarValue)
|
||||||
gNewDLLFunctions.pfnCvarValue(player, "Bad Player");
|
gNewDLLFunctions.pfnCvarValue(player, "Bad Player");
|
||||||
|
|
||||||
Con_Printf("tried to QueryClientCvarValue a non-client\n");
|
Con_Printf("tried to %s a non-client\n", __func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
client_t *client = &g_psvs.clients[entnum - 1];
|
client_t *client = &g_psvs.clients[entnum - 1];
|
||||||
@ -2783,7 +2782,11 @@ void EXT_FUNC QueryClientCvarValue2(const edict_t *player, const char *cvarName,
|
|||||||
if (gNewDLLFunctions.pfnCvarValue2)
|
if (gNewDLLFunctions.pfnCvarValue2)
|
||||||
gNewDLLFunctions.pfnCvarValue2(player, requestID, cvarName, "Bad Player");
|
gNewDLLFunctions.pfnCvarValue2(player, requestID, cvarName, "Bad Player");
|
||||||
|
|
||||||
|
#ifdef REHLDS_FIXES
|
||||||
|
Con_Printf("tried to %s a non-client\n", __func__);
|
||||||
|
#else
|
||||||
Con_Printf("tried to QueryClientCvarValue a non-client\n");
|
Con_Printf("tried to QueryClientCvarValue a non-client\n");
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
client_t *client = &g_psvs.clients[entnum - 1];
|
client_t *client = &g_psvs.clients[entnum - 1];
|
||||||
|
Loading…
Reference in New Issue
Block a user