From: havoc Date: Sun, 3 Feb 2008 11:12:42 +0000 (+0000) Subject: fix Black's PRVM_EDICT_NUM_ERROR return type change which did not work X-Git-Tag: xonotic-v0.1.0preview~2450 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=17c4cc7228e9fc5f7c6cd60f12470668fea71646;p=xonotic%2Fdarkplaces.git fix Black's PRVM_EDICT_NUM_ERROR return type change which did not work (0 is not the same as NULL, compilers get upset about that) one other minor correction of the same kind git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8066 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_collision.c b/cl_collision.c index 45acfefa..f7a838ec 100644 --- a/cl_collision.c +++ b/cl_collision.c @@ -295,7 +295,7 @@ trace_t CL_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const // figure out whether this is a point trace for comparisons pointtrace = VectorCompare(clipmins, clipmaxs); // precalculate passedict's owner edict pointer for comparisons - traceowner = passedict ? PRVM_PROG_TO_EDICT(passedict->fields.client->owner) : 0; + traceowner = passedict ? PRVM_PROG_TO_EDICT(passedict->fields.client->owner) : NULL; // collide against network entities if (hitnetworkbrushmodels) diff --git a/csprogs.c b/csprogs.c index c6b38b15..0e5bba3e 100644 --- a/csprogs.c +++ b/csprogs.c @@ -577,7 +577,9 @@ void CSQC_ReadEntities (void) // make sure no one gets wrong ideas prog->globals.client->self = 0; PRVM_ExecuteProgram(prog->funcoffsets.CSQC_Ent_Spawn, "QC function CSQC_Ent_Spawn is missing"); - cl.csqc_server2csqcentitynumber[realentnum] = PRVM_EDICT( PRVM_G_INT( OFS_RETURN ) ); + entnum = PRVM_G_INT(OFS_RETURN); + PRVM_CHECKEDICTNUM(entnum); + cl.csqc_server2csqcentitynumber[realentnum] = entnum; } } else { diff --git a/progsvm.h b/progsvm.h index e5dd2d00..e46eed01 100644 --- a/progsvm.h +++ b/progsvm.h @@ -516,9 +516,9 @@ void PRVM_ED_ParseGlobals (const char *data); void PRVM_ED_LoadFromFile (const char *data); -unsigned PRVM_EDICT_NUM_ERROR(int n, char *filename, int fileline); -#define PRVM_EDICT(n) (((unsigned)(n) < (unsigned int)prog->max_edicts) ? n : PRVM_EDICT_NUM_ERROR(n, __FILE__, __LINE__)) -#define PRVM_EDICT_NUM(n) (prog->edicts + PRVM_EDICT(n)) +prvm_edict_t *PRVM_EDICT_NUM_ERROR(unsigned int n, char *filename, int fileline); +#define PRVM_CHECKEDICTNUM(n) (((unsigned)(n) < (unsigned int)prog->max_edicts) ? NULL : PRVM_EDICT_NUM_ERROR((n), __FILE__, __LINE__)) +#define PRVM_EDICT_NUM(n) (PRVM_CHECKEDICTNUM(n), prog->edicts + (n)) //int NUM_FOR_EDICT_ERROR(prvm_edict_t *e); #define PRVM_NUM_FOR_EDICT(e) ((int)((prvm_edict_t *)(e) - prog->edicts)) diff --git a/prvm_edict.c b/prvm_edict.c index 600e8495..08aca4e5 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -2107,10 +2107,10 @@ void _PRVM_FreeAll(const char *filename, int fileline) } // LordHavoc: turned PRVM_EDICT_NUM into a #define for speed reasons -unsigned PRVM_EDICT_NUM_ERROR(int n, char *filename, int fileline) +prvm_edict_t *PRVM_EDICT_NUM_ERROR(unsigned int n, char *filename, int fileline) { PRVM_ERROR ("PRVM_EDICT_NUM: %s: bad number %i (called at %s:%i)", PRVM_NAME, n, filename, fileline); - return 0; + return NULL; } /*