From: havoc Date: Wed, 8 Mar 2006 01:13:29 +0000 (+0000) Subject: some work on SV_TestEntityPosition and entity unsticking, now only checks against... X-Git-Tag: xonotic-v0.1.0preview~4235 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e80a362bdb11a1192b828defe4ecc6953a4b8dbe;p=xonotic%2Fdarkplaces.git some work on SV_TestEntityPosition and entity unsticking, now only checks against bmodels git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6081 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/sv_phys.c b/sv_phys.c index 1e58ea8b..4e17bc92 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -72,6 +72,18 @@ void SV_Phys_Init (void) Cvar_RegisterVariable(&sv_sound_land); } +/* +============ +SV_TestEntityPosition + +returns true if the entity is in solid currently +============ +*/ +static int SV_TestEntityPosition (prvm_edict_t *ent, int movemode) +{ + return SV_Move (ent->fields.server->origin, ent->fields.server->mins, ent->fields.server->maxs, ent->fields.server->origin, movemode, ent).startsolid; +} + /* ================ SV_CheckAllEnts @@ -94,7 +106,7 @@ void SV_CheckAllEnts (void) || check->fields.server->movetype == MOVETYPE_NOCLIP) continue; - if (SV_TestEntityPosition (check)) + if (SV_TestEntityPosition (check, MOVE_NORMAL)) Con_Print("entity in invalid position\n"); } } @@ -819,7 +831,7 @@ void SV_CheckStuck (prvm_edict_t *ent) int i, j, z; vec3_t org; - if (!SV_TestEntityPosition(ent)) + if (!SV_TestEntityPosition(ent, MOVE_NORMAL)) { VectorCopy (ent->fields.server->origin, ent->fields.server->oldorigin); return; @@ -827,7 +839,7 @@ void SV_CheckStuck (prvm_edict_t *ent) VectorCopy (ent->fields.server->origin, org); VectorCopy (ent->fields.server->oldorigin, ent->fields.server->origin); - if (!SV_TestEntityPosition(ent)) + if (!SV_TestEntityPosition(ent, MOVE_NORMAL)) { Con_DPrintf("Unstuck entity %i (classname \"%s\").\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(ent->fields.server->classname)); SV_LinkEdict (ent, true); @@ -841,7 +853,7 @@ void SV_CheckStuck (prvm_edict_t *ent) ent->fields.server->origin[0] = org[0] + i; ent->fields.server->origin[1] = org[1] + j; ent->fields.server->origin[2] = org[2] + z; - if (!SV_TestEntityPosition(ent)) + if (!SV_TestEntityPosition(ent, MOVE_NORMAL)) { Con_DPrintf("Unstuck entity %i (classname \"%s\").\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(ent->fields.server->classname)); SV_LinkEdict (ent, true); @@ -853,11 +865,15 @@ void SV_CheckStuck (prvm_edict_t *ent) Con_DPrintf("Stuck entity %i (classname \"%s\").\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(ent->fields.server->classname)); } -void SV_UnstickEntity (prvm_edict_t *ent) +static void SV_UnstickEntity (prvm_edict_t *ent) { int i, j, z; vec3_t org; + // if not stuck in a bmodel, just return + if (!SV_TestEntityPosition(ent, MOVE_NOMONSTERS)) + return; + VectorCopy (ent->fields.server->origin, org); for (z=0 ; z< 18 ; z += 6) @@ -867,7 +883,7 @@ void SV_UnstickEntity (prvm_edict_t *ent) ent->fields.server->origin[0] = org[0] + i; ent->fields.server->origin[1] = org[1] + j; ent->fields.server->origin[2] = org[2] + z; - if (!SV_TestEntityPosition(ent)) + if (!SV_TestEntityPosition(ent, MOVE_NOMONSTERS)) { Con_DPrintf("Unstuck entity %i (classname \"%s\").\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(ent->fields.server->classname)); SV_LinkEdict (ent, true); diff --git a/world.c b/world.c index 8195fa76..680269c6 100644 --- a/world.c +++ b/world.c @@ -395,27 +395,6 @@ void SV_LinkEdict (prvm_edict_t *ent, qboolean touch_triggers) -/* -=============================================================================== - -POINT TESTING IN HULLS - -=============================================================================== -*/ - -/* -============ -SV_TestEntityPosition - -This could be a lot more efficient... -============ -*/ -int SV_TestEntityPosition (prvm_edict_t *ent) -{ - return SV_Move (ent->fields.server->origin, ent->fields.server->mins, ent->fields.server->maxs, ent->fields.server->origin, MOVE_NORMAL, ent).startsolid; -} - - /* =============================================================================== diff --git a/world.h b/world.h index fd79b93e..e01b831c 100644 --- a/world.h +++ b/world.h @@ -43,9 +43,6 @@ void SV_UnlinkEdict (prvm_edict_t *ent); // if touchtriggers, calls prog functions for the intersected triggers void SV_LinkEdict (prvm_edict_t *ent, qboolean touch_triggers); -// returns true if the entity is in solid currently -int SV_TestEntityPosition (prvm_edict_t *ent); - // returns list of entities touching a box int SV_EntitiesInBox(vec3_t mins, vec3_t maxs, int maxlist, prvm_edict_t **list);