While your solution works, here's another (cleaner IMHO) solution: if ( !pRagdoll->IsValid() ) { Msg("Bad ragdoll for %s\n", pstudiohdr->name ); delete pRagdoll; pRagdoll = NULL; } else { pRagdoll->SetInitialBonePosition( pstudiohdr, pDesiredBonePosition ); }
I'm not a big fan of multiple return statements =) On Thu, 24 Feb 2005 13:41:51 -0500, Patrick Flanagan <[EMAIL PROTECTED]> wrote: > I've been running my DM mod, and I noticed that periodically the > clients would crash but the server would remain up. I happened to > catch one in the debugger, and it looks like this is problem is in > CreateRagdoll in ragdoll.cpp: > > CRagdoll *CreateRagdoll( > C_BaseEntity *ent, > studiohdr_t *pstudiohdr, > const Vector &forceVector, > int forceBone, > const CBoneAccessor &pPrevBones, > const CBoneAccessor &pBoneToWorld, > const CBoneAccessor &pDesiredBonePosition, > float dt ) > { > CRagdoll *pRagdoll = new CRagdoll; > pRagdoll->Init( ent, pstudiohdr, forceVector, forceBone, pPrevBones, > pBoneToWorld, dt ); > > if ( !pRagdoll->IsValid() ) > { > Msg("Bad ragdoll for %s\n", pstudiohdr->name ); > delete pRagdoll; > pRagdoll = NULL; > > } > > pRagdoll->SetInitialBonePosition( pstudiohdr, pDesiredBonePosition ); > > return pRagdoll; > } > > I'm not sure under what circumstances the ragdoll is not valid, but > apparently this was happening periodically. So when the ragdoll was > not valid, it would delete that pointer and then immediately call > SetInitialBonePosition on it. Nice. > > I changed the if block to: > > if ( !pRagdoll->IsValid() ) > { > Msg("Bad ragdoll for %s\n", pstudiohdr->name ); > delete pRagdoll; > pRagdoll = NULL; > return pRagdoll; > } > > and haven't seen this crash since. > > Patrick > > _______________________________________________ > To unsubscribe, edit your list preferences, or view the list archives, please > visit: > http://list.valvesoftware.com/mailman/listinfo/hlcoders > > _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders