SDK Known Issues List Fixed

From Valve Developer Community
Revision as of 21:50, 12 August 2006 by Bloodykenny (talk | contribs) (new page for storing SDK known issues that have been fixed now)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This page is intended to store important SDK bugs/known issues that existed in previous released but have now been fixed. If your mod is based on an older SDK release, you may still be experiencing some of these bugs.

vphysics patch from Jay at Valve

Note.pngNote:This issue was fixed in the 2006-08-04 SDK Update

In addition to the vphysics bug/feature listed below where ShouldCollide can cause it to engage Physical Mayhem, an additional requirement for vphysics is this - again quoted from Jay. Need to figure out where in the code to patch in some docs on this - in the meantime:

Calling UTIL_Remove() or delete on an entity during a callback may corrupt vphysics.

The following patch uses an assert to document this requirement from the closed-source side of things:

--- mod/src/dlls/physics.cpp    2005/10/16 16:26:25     1.4
+++ mod/src/dlls/physics.cpp    2006/05/29 17:39:03
@@ -141,6 +141,7 @@

        // IPhysicsCollisionSolver
        int             ShouldCollide( IPhysicsObject *pObj0, IPhysicsObject *pObj1, void *pGameData0, void *pGameData1 );
+       int             ShouldCollide_Default(IPhysicsObject *pObj0, IPhysicsObject *pObj1, void *pGameData0, void *pGameData1);
        int             ShouldSolvePenetration( IPhysicsObject *pObj0, IPhysicsObject *pObj1, void *pGameData0, void *pGameData1, float dt );
        bool    ShouldFreezeObject( IPhysicsObject *pObject ) { return true; }
        int             AdditionalCollisionChecksThisTick( int currentChecksDone )
@@ -482,6 +483,21 @@
 }

 int CCollisionEvent::ShouldCollide( IPhysicsObject *pObj0, IPhysicsObject *pObj1, void *pGameData0, void *pGameData1 )
+{
+       int x0 = ShouldCollide_Default(pObj0, pObj1, pGameData0, pGameData1);
+#if !defined(NDEBUG)
+       int x1 = ShouldCollide_Default(pObj1, pObj0, pGameData1, pGameData0);
+       if ( x0 != x1 )
+       {
+               Assert(0 && "ShouldCollide must return the same value regardless of the order of the two objects that are passed in");
+               ShouldCollide_Default(pObj0, pObj1, pGameData0, pGameData1);
+               ShouldCollide_Default(pObj1, pObj0, pGameData1, pGameData0);
+       }
+#endif
+       return x0;
+}
+
+int CCollisionEvent::ShouldCollide_Default( IPhysicsObject *pObj0, IPhysicsObject *pObj1, void *pGameData0, void *pGameData1 )
 {
        CallbackContext check(this);

Here's another for Jay. I haven't tested this yet, but what's the worst that it could do? :)

--- ./mod/src/game_shared/physics_main_shared.cpp       2005/02/18 04:45:54     1.1.1.1
+++ ./mod/src/game_shared/physics_main_shared.cpp       2005/11/04 02:01:53
@@ -371,6 +371,8 @@
        return link;
 }

+static touchlink_t *g_pNextLink = NULL;
+
 //-----------------------------------------------------------------------------
 // Purpose:
 // Input  : *link -
@@ -380,6 +382,10 @@
 {
        if ( link )
        {
+        if ( link == g_pNextLink )
+        {
+            g_pNextLink = link->nextLink;
+        }
                --linksallocated;
        }
        g_EdictTouchLinks.Free( link );
@@ -442,7 +448,9 @@
 //-----------------------------------------------------------------------------
 void CBaseEntity::PhysicsCheckForEntityUntouch( void )
 {
-       touchlink_t *link, *nextLink;
+       Assert( g_pNextLink == NULL );
+
+    touchlink_t *link;

        touchlink_t *root = ( touchlink_t * )GetDataObject( TOUCHLINK );
        if ( root )
@@ -453,7 +461,7 @@
                link = root->nextLink;
                while ( link != root )
                {
-                       nextLink = link->nextLink;
+                       g_pNextLink = link->nextLink;

                        // these touchlinks are not polled.  The ents are touching due to an outside
                        // system that will add/delete them as necessary (vphysics in this case)
@@ -476,7 +484,7 @@
                                }
                        }

-                       link = nextLink;
+                       link = g_pNextLink;
                }

                g_bCleanupDatObject = saveCleanup;
@@ -489,6 +497,8 @@
                }
        }

+    g_pNextLink = NULL;
+
        SetCheckUntouch( false );
 }