]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
improved entity unsticking code, it now uses a trace from the offset
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 18 Apr 2007 10:20:09 +0000 (10:20 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 18 Apr 2007 10:20:09 +0000 (10:20 +0000)
position back to the original position, and uses the impact point, this
makes it correct significantly less than before

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7130 d7cf8633-e32d-0410-b094-e92efae38249

sv_phys.c
todo

index 476882453082e8757cfc6129167524ffdc4477e5..60ab8f24cb13f5b2ed97c627129853057e3d0726 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -459,9 +459,12 @@ SV_TestEntityPosition
 returns true if the entity is in solid currently
 ============
 */
-static int SV_TestEntityPosition (prvm_edict_t *ent)
+static int SV_TestEntityPosition (prvm_edict_t *ent, vec3_t offset)
 {
-       trace_t trace = SV_Move (ent->fields.server->origin, ent->fields.server->mins, ent->fields.server->maxs, ent->fields.server->origin, MOVE_NOMONSTERS, ent, SUPERCONTENTS_SOLID);
+       vec3_t org;
+       trace_t trace;
+       VectorAdd(ent->fields.server->origin, offset, org);
+       trace = SV_Move (org, ent->fields.server->mins, ent->fields.server->maxs, ent->fields.server->origin, MOVE_NOMONSTERS, ent, SUPERCONTENTS_SOLID);
        if (trace.startsupercontents & SUPERCONTENTS_SOLID)
                return true;
        else
@@ -471,10 +474,11 @@ static int SV_TestEntityPosition (prvm_edict_t *ent)
                        // q1bsp/hlbsp use hulls and if the entity does not exactly match
                        // a hull size it is incorrectly tested, so this code tries to
                        // 'fix' it slightly...
+                       // FIXME: this breaks entities larger than the hull size
                        int i;
                        vec3_t v, m1, m2, s;
-                       VectorAdd(ent->fields.server->origin, ent->fields.server->mins, m1);
-                       VectorAdd(ent->fields.server->origin, ent->fields.server->maxs, m2);
+                       VectorAdd(org, ent->fields.server->mins, m1);
+                       VectorAdd(org, ent->fields.server->maxs, m2);
                        VectorSubtract(m2, m1, s);
 #define EPSILON (1.0f / 32.0f)
                        if (s[0] >= EPSILON*2) {m1[0] += EPSILON;m2[0] -= EPSILON;}
@@ -489,8 +493,11 @@ static int SV_TestEntityPosition (prvm_edict_t *ent)
                                        return true;
                        }
                }
-               return false;
        }
+       // if the trace found a better position for the entity, move it there
+       if (VectorDistance2(trace.endpos, ent->fields.server->origin) >= 0.0001)
+               VectorCopy(trace.endpos, ent->fields.server->origin);
+       return false;
 }
 
 /*
@@ -515,7 +522,7 @@ void SV_CheckAllEnts (void)
                 || check->fields.server->movetype == MOVETYPE_NOCLIP)
                        continue;
 
-               if (SV_TestEntityPosition (check))
+               if (SV_TestEntityPosition (check, vec3_origin))
                        Con_Print("entity in invalid position\n");
        }
 }
@@ -1344,20 +1351,17 @@ clipping hull.
 void SV_CheckStuck (prvm_edict_t *ent)
 {
        int i;
-       vec3_t org;
+       vec3_t offset;
 
-       if (!SV_TestEntityPosition(ent))
+       if (!SV_TestEntityPosition(ent, vec3_origin))
        {
                VectorCopy (ent->fields.server->origin, ent->fields.server->oldorigin);
                return;
        }
 
-       VectorCopy (ent->fields.server->origin, org);
-
        for (i = 0;i < (int)(sizeof(unstickoffsets) / sizeof(unstickoffsets[0]));i += 3)
        {
-               VectorAdd(org, unstickoffsets + i, ent->fields.server->origin);
-               if (!SV_TestEntityPosition(ent))
+               if (!SV_TestEntityPosition(ent, unstickoffsets + i))
                {
                        Con_DPrintf("Unstuck player entity %i (classname \"%s\") with offset %f %f %f.\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(ent->fields.server->classname), unstickoffsets[i+0], unstickoffsets[i+1], unstickoffsets[i+2]);
                        SV_LinkEdict (ent, true);
@@ -1365,33 +1369,28 @@ void SV_CheckStuck (prvm_edict_t *ent)
                }
        }
 
-       VectorCopy (ent->fields.server->oldorigin, ent->fields.server->origin);
-       if (!SV_TestEntityPosition(ent))
+       VectorSubtract(ent->fields.server->oldorigin, ent->fields.server->origin, offset);
+       if (!SV_TestEntityPosition(ent, offset))
        {
                Con_DPrintf("Unstuck player entity %i (classname \"%s\") by restoring oldorigin.\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(ent->fields.server->classname));
                SV_LinkEdict (ent, true);
                return;
        }
 
-       VectorCopy (org, ent->fields.server->origin);
        Con_DPrintf("Stuck player entity %i (classname \"%s\").\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(ent->fields.server->classname));
 }
 
 static void SV_UnstickEntity (prvm_edict_t *ent)
 {
        int i;
-       vec3_t org;
 
        // if not stuck in a bmodel, just return
-       if (!SV_TestEntityPosition(ent))
+       if (!SV_TestEntityPosition(ent, vec3_origin))
                return;
 
-       VectorCopy (ent->fields.server->origin, org);
-
        for (i = 0;i < (int)(sizeof(unstickoffsets) / sizeof(unstickoffsets[0]));i += 3)
        {
-               VectorAdd(org, unstickoffsets + i, ent->fields.server->origin);
-               if (!SV_TestEntityPosition(ent))
+               if (!SV_TestEntityPosition(ent, unstickoffsets + i))
                {
                        Con_DPrintf("Unstuck entity %i (classname \"%s\") with offset %f %f %f.\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(ent->fields.server->classname), unstickoffsets[i+0], unstickoffsets[i+1], unstickoffsets[i+2]);
                        SV_LinkEdict (ent, true);
@@ -1399,7 +1398,6 @@ static void SV_UnstickEntity (prvm_edict_t *ent)
                }
        }
 
-       VectorCopy (org, ent->fields.server->origin);
        if (developer.integer >= 100)
                Con_Printf("Stuck entity %i (classname \"%s\").\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(ent->fields.server->classname));
 }
diff --git a/todo b/todo
index 3c77068dfc8c478a4d053b7b0dec30b9375572b7..40283dfa5d5cb46a07539ff4cdbfe5440055f022 100644 (file)
--- a/todo
+++ b/todo
 0 bug darkplaces server: SV_PushMove's call to SV_ClipMoveToEntity should do a trace, not just a point test, to support hollow pusher models (Urre)
 0 bug darkplaces server: player entered the game is printed twice, test with +map start
 0 bug darkplaces server: savegames do not save precaches, which means that automatic precaching frequently results in invalid modelindex values when reloading the savegame, and this bug also exists in many quake mods that randomly choose multiple variants of a monster, each with separate precaches, resulting in a different precache order when reloading the savegame
-0 bug darkplaces server: when server quits, it does not notify the master that it is quitting, it should send out a couple forced heartbeats and dpmaster should be modified to remove servers that do not respond to queries within a reason time (jitspoe, div0)
 0 bug darkplaces wgl client: during video mode setup, sometimes another application's window becomes permanently top most, not darkplaces' fullscreen window, why? (tZork)
 0 bug darkplaces windows sound: freezing on exit sometimes when freeing sound buffer during sound shutdown (Black)
 0 bug darkplaces windows sound: surround sound fails in windows client, falls back to stereo (greenmarine)
+0 bug dpmaster: if server does not reply to queries in a reasonable period of time it should be removed from the list, this is necessary for the server to be removed when it shuts down and sends out two heartbeats to let the master know that it is shutting down, and isn't there to reply to queries (jitspoe, div0)
 0 bug dpmaster: if server does not reply within 5 seconds to a query it should be removed (jitspoe, div0)
 0 bug dpmod: LinkDoors seems to ignore .origin on door entities when comparing if they overlap
 0 bug dpmod: allow selection of weapons with secondary ammo but no primary ammo, and switch away if trying to fire primary ammo you don't have (romi)
@@ -638,6 +638,7 @@ d bug darkplaces server: stats[TOTAL_MONSTERS] should be networked as a stat
 d bug darkplaces server: stepping while jumping is setting FL_GROUND (allowing the quake2 doublejump bug)
 d bug darkplaces server: sv_jumpstep should be defaulted to off because it makes it possible to reach places one should not be able to reach in quake, it can be turned on by particular games if desired (div0, SavageX, Kazashi)
 d bug darkplaces server: the lava+func_trains room of r1m5 is leaving items floating in the air - r1m5 is Towers of Wrath, in episode of Dissolution of Eternity, aka rogue (maichal)
+d bug darkplaces server: when server quits, it does not notify the master that it is quitting, it should send out a couple forced heartbeats and assume the master server will remove it because it does not respond (jitspoe, div0)
 d bug darkplaces server: when trying to load a map that is missing the model is still precached permanently, causing 'not found' warnings every time r_restart/vid_restart are used
 d bug darkplaces sound: sound is sometimes coming from the wrong side apparently (lcatlnx)
 d bug darkplaces sound: spatialization bug occurs in The Ascension of Vigil, making all player and monster sounds far to the right (RenegadeC)