From 8f7931b860ec5acf836ea73a2d927bf061455dc9 Mon Sep 17 00:00:00 2001 From: Spoike Date: Sun, 6 Apr 2014 15:12:19 +0000 Subject: [PATCH] findradius in csqc should not be using server stuff... fix some potential crashes on conflicting cvar/command names. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4634 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/common/pr_bgcmd.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/engine/common/pr_bgcmd.c b/engine/common/pr_bgcmd.c index ee2512fd0..770359637 100644 --- a/engine/common/pr_bgcmd.c +++ b/engine/common/pr_bgcmd.c @@ -874,7 +874,10 @@ void QCBUILTIN PF_cvar_string (pubprogfuncs_t *prinst, struct globalvars_s *pr_g { const char *str = PR_GetStringOfs(prinst, OFS_PARM0); cvar_t *cv = Cvar_Get(str, "", 0, "QC variables"); - RETURN_CSTRING(cv->string); + if (cv) + RETURN_CSTRING(cv->string); + else + G_INT(OFS_RETURN) = 0; } //string(string cvarname) cvar_defstring @@ -882,7 +885,10 @@ void QCBUILTIN PF_cvar_defstring (pubprogfuncs_t *prinst, struct globalvars_s *p { const char *str = PR_GetStringOfs(prinst, OFS_PARM0); cvar_t *cv = Cvar_Get(str, "", 0, "QC variables"); - RETURN_CSTRING(cv->defaultstr); + if (cv) + RETURN_CSTRING(cv->defaultstr); + else + G_INT(OFS_RETURN) = 0; } //string(string cvarname) cvar_description @@ -890,7 +896,10 @@ void QCBUILTIN PF_cvar_description (pubprogfuncs_t *prinst, struct globalvars_s { const char *str = PR_GetStringOfs(prinst, OFS_PARM0); cvar_t *cv = Cvar_Get(str, "", 0, "QC variables"); - RETURN_CSTRING(cv->description); + if (cv) + RETURN_CSTRING(cv->description); + else + G_INT(OFS_RETURN) = 0; } //float(string name) cvar_type @@ -1975,25 +1984,26 @@ findradius (origin, radius) */ void QCBUILTIN PF_findradius (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { + world_t *w = prinst->parms->user; extern cvar_t sv_gameplayfix_blowupfallenzombies; - edict_t *ent, *chain; + wedict_t *ent, *chain; float rad; float *org; vec3_t eorg; int i, j; - chain = (edict_t *)sv.world.edicts; + chain = w->edicts; org = G_VECTOR(OFS_PARM0); rad = G_FLOAT(OFS_PARM1); rad = rad*rad; - for (i=1 ; inum_edicts ; i++) { - ent = EDICT_NUM(svprogfuncs, i); + ent = WEDICT_NUM(prinst, i); if (ent->isfree) continue; - if (ent->v->solid == SOLID_NOT && (progstype != PROG_QW || !((int)ent->v->flags & FL_FINDABLE_NONSOLID)) && !sv_gameplayfix_blowupfallenzombies.value) + if (ent->v->solid == SOLID_NOT && (!((int)ent->v->flags & FL_FINDABLE_NONSOLID)) && !sv_gameplayfix_blowupfallenzombies.value) continue; for (j=0 ; j<3 ; j++) eorg[j] = org[j] - (ent->v->origin[j] + (ent->v->mins[j] + ent->v->maxs[j])*0.5);