]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
some work on SV_TestEntityPosition and entity unsticking, now only checks against...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 8 Mar 2006 01:13:29 +0000 (01:13 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 8 Mar 2006 01:13:29 +0000 (01:13 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6081 d7cf8633-e32d-0410-b094-e92efae38249

sv_phys.c
world.c
world.h

index 1e58ea8b8b0b97b76d8080cca7f9d8c8ac09a149..4e17bc92d5907a43bc7f4660aab542b3d8a98df9 100644 (file)
--- 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 8195fa762c9c9e0d46c73167786818dc1f2adf46..680269c6f06ac6542bb3b8e630addc99b696994a 100644 (file)
--- 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 fd79b93ee36412519658bc296ba8c180693c09a1..e01b831c0ca8b00f89c26b2ee484ba9bc7ed1f22 100644 (file)
--- 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);