SDK Known Issues List: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(dm_powerhouse lamps lay on the ground)
m (add list cat)
 
(63 intermediate revisions by 20 users not shown)
Line 1: Line 1:
{{Note|This page is for the SDK code. For the SDK tools, see [[Source SDK Known Issues]]. For the HL2 core, see the [[Core Known Issues List]].}}
{{Note|This page is for the SDK code. For the SDK tools, see [[Source SDK Known Issues]]. For the HL2 core, see the [[Core Known Issues List]] or the [http://tinyurl.com/ndfsc HL2 Bugzilla].}} The patches listed here are in unidiff format.
== First pass at compiling server_hl2mp-2005.vcproj under Linux ==
 
=== Preconditions ===
Setup the SDK as desribed in http://developer.valvesoftware.com/wiki/Compiling_under_Linux but obtained with "Modify Half-Life 2 Multiplayer" instead of "Source code only (advanced users only)". Obtained and compiled as of Sunday, February the 15th, 2009. Using Debian Lenny.
 
=== Issues ===
 
==== ../dlls/lightglow.cpp:57: error: 'SendProxy_Angles' was not declared in this scope ====
Ambiguous function pointer. One probable fix could be to add '0, ' before the inclined call and add an 'extern ' declaration of the inclined function.
 
==== /usr/include/c++/3.4/limits:292:22: macro "max" requires 2 arguments, but only 1 given ====
In file included from /usr/include/c++/3.4/memory:61, from /usr/include/c++/3.4/string:48, from ../dlls/../public/stdstring.h:26, from ../dlls/ai_playerally.h:18, from ../dlls/npc_talker.h:34, from ../dlls/npc_talker.cpp:10
Maybe fixed by commenting out #include <set> in ../dlls/npc_talker.h
 
==== ../game_shared/gamestats/ep1_gamestats.h:14:27: tier1/UtlDict.h: No such file or directory ====
In file included from ../dlls/../game_shared/gamestats/ep1_gamestats.cpp:7. Probably because public is not part of the path. Probably also because of case sensitivity.
Fix:
ln -s ../public/tier1 tier1
ln ../public/tier1/utlbuffer.h tier1/UtlBuffer.h
ln ../public/tier1/utldict.h tier1/UtlDict.h
 
==== ../dlls/episodic/grenade_hopwire.h:14:20: sprite.h: No such file or directory ====
In file included from ../dlls/episodic/grenade_hopwire.cpp:8
Fix:
 
ln ../game_shared/Sprite.h ../game_shared/sprite.h
 
The compile completed after these issues in the first pass.


== Issues only with SDK 2006-08-04 ==
== Issues only with SDK 2006-08-04 ==


=== dm_powerhouse lamps lay on the ground ===
=== Assert whenever Gravity Gun is holding a crate/barrel that explodes ===
This was first reported on the [http://forums.steampowered.com/forums/showthread.php?postid=5119212&perpage=1 Steam Forums HL2 bug list], including [http://img391.imageshack.us/my.php?image=dmpowerhouse0000dt1.jpg this screenshot].
See bugzilla [http://developer.valvesoftware.com/cgi-bin/bugzilla/show_bug.cgi?id=13].
 
=== Assert: no supported muzzle flash for the type specified ===
This is apparently a bug in the HL2 model so looks like there's nothing to be done but comment out the assert.
 
<pre>
--- src/cl_dll/c_te_legacytempents.cpp      26 Aug 2006 21:24:22 -0000      1.5
+++ src/cl_dll/c_te_legacytempents.cpp      27 Aug 2006 19:31:35 -0000
@@ -1676,7 +1676,7 @@
 
        default:
                // There's no supported muzzle flash for the type specified!
-              Assert(0);
+              // Assert(0);
                break;
        }


Since updating the SDK the bug now occurs in my mod.  I'm currently scouring the code to track this down.
</pre>


=== IsFrameLocking assert ===
=== Assert( i >= 0 && i < GetNumSeq() ) ===
If you commented out the <code>AssertOnce( pModelCache->IsFrameLocking() );</code> asserts, uncommented them.  According to Jay at Valve the core is allowed to delete a GetModelPtr() pointer at any time unless you're inside the lock, therefore all of these fixes below are potential crashers.
Once again this is apparently a bug in the HL2 model so looks like there's nothing to be done but comment out the assert.


<pre>
<pre>
--- src/cl_dll/c_baseanimating.cpp 26 Aug 2006 21:24:20 -0000 1.8
--- src/public/studio.cpp 26 Aug 2006 21:24:47 -0000     1.3
+++ src/cl_dll/c_baseanimating.cpp 2 Sep 2006 19:04:00 -0000
+++ src/public/studio.cpp 27 Aug 2006 19:44:53 -0000
@@ -3333,6 +3333,8 @@
@@ -783,7 +783,7 @@
 
  void C_BaseAnimating::GetRenderBounds( Vector& theMins, Vector& theMaxs )
  mstudioseqdesc_t &CStudioHdr::pSeqdesc( int i ) const
  {
  {
+   MDLCACHE_CRITICAL_SECTION();
-      Assert( i >= 0 && i < GetNumSeq() );
+
+       // Assert( i >= 0 && i < GetNumSeq() );
if ( IsRagdoll() )
 
{
        if (m_pVModel == NULL)
m_pRagdoll->GetRagdollBounds( theMins, theMaxs );
        {
@@ -3919,6 +3921,8 @@
 
</pre>
 
 
=== dm_powerhouse lamps lay on the ground ===
This was first reported on the [http://forums.steampowered.com/forums/showthread.php?postid=5119212&perpage=1 Steam Forums HL2 bug list], including [http://img391.imageshack.us/my.php?image=dmpowerhouse0000dt1.jpg this screenshot].
 
Since updating the SDK the bug now occurs in my mod.
 
It's been obvious for a long time that the dm_powerhouse map was broken (see [[#dm_powerhouse_lights_never_slow_down]]).  Looks like Valve was attempting to out-think broken maps, but only made things worse.  See the [[#dm_powerhouse_lights_never_slow_down]] KI for the real dm_powerhouse bug fix.  Meanwhile here's the bugfix to undo the latest SDK breakage:
<pre>
--- src/dlls/physconstraint.cpp 26 Aug 2006 21:24:31 -0000      1.4
+++ src/dlls/physconstraint.cpp 2 Sep 2006 22:50:09 -0000
@@ -437,8 +437,6 @@
                if ( Q_strlen(STRING(m_nameAttach1)) )
                {
                        Warning("Bogus constraint %s (attaches %s to %s)\n", GetDebugName(), STRING(m_nameAttach1), STRING(m_nameAttach2));
-                      info.pObjects[0] = info.pObjects[1] = NULL;
-                      return;
                }
                info.pObjects[0] = g_PhysWorldObject;
                info.massScale[0] = info.massScale[1] = 1.0f; // no mass scale on world constraint
@@ -448,8 +446,6 @@
                if ( Q_strlen(STRING(m_nameAttach2)) )
                {
                        Warning("Bogus constraint %s (attaches %s to %s)\n", GetDebugName(), STRING(m_nameAttach1), STRING(m_nameAttach2));
-                      info.pObjects[0] = info.pObjects[1] = NULL;
-                      return;
                }
                info.pObjects[1] = info.pObjects[0];
                info.pObjects[0] = g_PhysWorldObject;          // Try to make the world object consistently object0 for ease of implementation
</pre>
 
=== IsFrameLocking assert ===
If you commented out the <code>AssertOnce( pModelCache->IsFrameLocking() );</code> asserts, uncommented them.  According to Jay at Valve the core is allowed to delete a GetModelPtr() pointer at any time unless you're inside the lock, therefore all of these fixes below are potential crashers.
 
<pre>
--- mod/src/cl_dll/prediction.cpp      3 Sep 2006 01:31:56 -0000      1.5
+++ mod/src/cl_dll/prediction.cpp      16 Sep 2006 18:56:39 -0000
@@ -212,6 +212,8 @@
void CPrediction::ShutdownPredictables( void )
  {
  {
VPROF( "C_BaseAnimating::TestCollision" );
#if !defined( NO_ENTITY_PREDICTION )
+    MDLCACHE_CRITICAL_SECTION();
+    MDLCACHE_CRITICAL_SECTION();
+
+
CStudioHdr *pStudioHdr = GetModelPtr();
        // Transfer intermediate data from other predictables
if (!pStudioHdr)
        int c = predictables->GetPredictableCount();
return false;
        int i;
@@ -4028,6 +4032,7 @@
</pre>
if ( m_bClientSideAnimation )
 
return;
and...
 
<pre>
--- src/game_shared/baseplayer_shared.cpp      26 Aug 2006 21:24:36 -0000      1.28
+++ src/game_shared/baseplayer_shared.cpp      4 Sep 2006 18:53:21 -0000
@@ -749,6 +749,8 @@
//-----------------------------------------------------------------------------
bool CBasePlayer::Weapon_Switch( CBaseCombatWeapon *pWeapon, int viewmodelindex /*=0*/ )
{
+    MDLCACHE_CRITICAL_SECTION();
+
        CBaseCombatWeapon *pLastWeapon = GetActiveWeapon();
        if ( BaseClass::Weapon_Switch( pWeapon, viewmodelindex ))
   
   
+    MDLCACHE_CRITICAL_SECTION();
CStudioHdr *hdr = GetModelPtr();
if ( !hdr )
return;
@@ -4103,6 +4108,11 @@
}
}
   
   
+float C_BaseAnimating::GetSequenceGroundSpeed(int iSequence) {
 
+    MDLCACHE_CRITICAL_SECTION();
--- src/cl_dll/c_baseanimating.cpp 2 Sep 2006 23:11:26 -0000 1.9
+    return GetSequenceGroundSpeed(GetModelPtr(), iSequence);
+++ src/cl_dll/c_baseanimating.cpp 3 Sep 2006 01:00:52 -0000
+}
@@ -3919,6 +3919,8 @@
+
{
//-----------------------------------------------------------------------------
  VPROF( "C_BaseAnimating::TestCollision" );
// Purpose:  
//
@@ -4274,6 +4284,11 @@
  return (::GetSequenceFlags( pStudioHdr, iSequence ) & STUDIO_LOOPING) != 0;
}
   
   
+bool C_BaseAnimating::IsSequenceLooping(int iSequence) {
+    MDLCACHE_CRITICAL_SECTION();
+    MDLCACHE_CRITICAL_SECTION();
+    return IsSequenceLooping(GetModelPtr(), iSequence);
+}
+
+
float C_BaseAnimating::SequenceDuration( CStudioHdr *pStudioHdr, int iSequence )
CStudioHdr *pStudioHdr = GetModelPtr();
{
  if (!pStudioHdr)
  if ( !pStudioHdr )
return false;
@@ -4291,6 +4306,11 @@
 
 
--- src/cl_dll/prediction.cpp 26 Aug 2006 21:24:24 -0000 1.4
+++ src/cl_dll/prediction.cpp 3 Sep 2006 01:00:52 -0000
@@ -19,6 +19,7 @@
#include "in_buttons.h"
#include "con_nprint.h"
#include "hud_pdump.h"
+#include "datacache/imdlcache.h"
   
   
  }
  #ifdef HL2_CLIENT_DLL
#include "c_basehlplayer.h"
@@ -1484,6 +1484,9 @@
//}
   
   
+float C_BaseAnimating::SequenceDuration(int iSequence) {
Assert( i >= 1 );
+
+    MDLCACHE_CRITICAL_SECTION();
+    MDLCACHE_CRITICAL_SECTION();
+    return SequenceDuration(GetModelPtr(), iSequence);
+}
+
+
int C_BaseAnimating::FindTransitionSequence( int iCurrentSequence, int iGoalSequence, int *piDir )
while ( true )
{
{
CStudioHdr *hdr = GetModelPtr();
// Incoming_acknowledged is the last usercmd the server acknowledged having acted upon
@@ -4502,6 +4522,11 @@
 
return -1; // Error
 
}
--- src/dlls/player_command.cpp 26 Aug 2006 21:24:31 -0000 1.5
+++ src/dlls/player_command.cpp 3 Sep 2006 01:00:54 -0000
@@ -14,6 +14,7 @@
#include "movehelper_server.h"
#include "iservervehicle.h"
#include "tier0/vprof.h"
+#include "datacache/imdlcache.h"
   
   
+int C_BaseAnimating::LookupPoseParameter(const char *szName) {
  // memdbgon must be the last include file in a .cpp file!!!
+    MDLCACHE_CRITICAL_SECTION();
  #include "tier0/memdbgon.h"
+    return LookupPoseParameter(GetModelPtr(), szName);
@@ -306,6 +307,8 @@
+}
  //-----------------------------------------------------------------------------
+
  void CPlayerMove::RunCommand ( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *moveHelper )
  //=========================================================
  //=========================================================
float C_BaseAnimating::SetPoseParameter( CStudioHdr *pStudioHdr, const char *szName, float flValue )
@@ -4509,6 +4534,11 @@
return SetPoseParameter( pStudioHdr, LookupPoseParameter( pStudioHdr, szName ), flValue );
  }
   
+float C_BaseAnimating::SetPoseParameter(const char *szName, float flValue) {
+    MDLCACHE_CRITICAL_SECTION();
+    return SetPoseParameter(GetModelPtr(), szName, flValue);
+}
+
float C_BaseAnimating::SetPoseParameter( CStudioHdr *pStudioHdr, int iParameter, float flValue )
  {
  {
if ( !pStudioHdr )
@@ -4527,6 +4557,12 @@
return flValue;
}
+float C_BaseAnimating::SetPoseParameter(int iParameter, float flValue) {
+    MDLCACHE_CRITICAL_SECTION();
+    MDLCACHE_CRITICAL_SECTION();
+    return SetPoseParameter(GetModelPtr(), iParameter, flValue);
+}
+
+
+
  StartCommand( player, ucmd );
//-----------------------------------------------------------------------------
// Purpose:
// Input  : *label -
 
 
 
 
--- src/cl_dll/c_baseanimating.h 26 Aug 2006 21:24:20 -0000 1.2
+++ src/cl_dll/c_baseanimating.h 2 Sep 2006 19:04:00 -0000
@@ -166,12 +166,12 @@
  int LookupRandomAttachment( const char *pAttachmentNameSubstring );
   
   
  int LookupPoseParameter( CStudioHdr *pStudioHdr, const char *szName );
  // Set globals appropriately
- inline int LookupPoseParameter( const char *szName ) { return LookupPoseParameter(GetModelPtr(), szName); }
+ int    LookupPoseParameter(const char *szName);
float SetPoseParameter( CStudioHdr *pStudioHdr, const char *szName, float flValue );
- inline float SetPoseParameter( const char *szName, float flValue ) { return SetPoseParameter( GetModelPtr(), szName, flValue ); }
+ float  SetPoseParameter(const char *szName, float flValue);
float SetPoseParameter( CStudioHdr *pStudioHdr, int iParameter, float flValue );
- inline float SetPoseParameter( int iParameter, float flValue ) { return SetPoseParameter( GetModelPtr(), iParameter, flValue ); }
+ float  SetPoseParameter(int iParameter, float flValue);
float GetPoseParameter( int iPoseParameter );
@@ -254,9 +254,9 @@
void SetSequence(int nSequence);
inline void ResetSequence(int nSequence);
float GetSequenceGroundSpeed( CStudioHdr *pStudioHdr, int iSequence );
- inline float GetSequenceGroundSpeed( int iSequence ) { return GetSequenceGroundSpeed(GetModelPtr(), iSequence); }
+ float                          GetSequenceGroundSpeed(int iSequence);
bool IsSequenceLooping( CStudioHdr *pStudioHdr, int iSequence );
- inline bool IsSequenceLooping( int iSequence ) { return IsSequenceLooping(GetModelPtr(),iSequence); }
+    bool                            IsSequenceLooping(int iSequence);
float GetSequenceMoveDist( CStudioHdr *pStudioHdr, int iSequence );
void GetSequenceLinearMotion( int iSequence, Vector *pVec );
void GetBlendedLinearVelocity( Vector *pVec );
@@ -351,7 +351,7 @@
void ResetSequenceInfo( void );
float SequenceDuration( void );
float SequenceDuration( CStudioHdr *pStudioHdr, int iSequence );
- inline float SequenceDuration( int iSequence ) { return SequenceDuration(GetModelPtr(), iSequence); }
+    float                          SequenceDuration(int iSequence);
int FindTransitionSequence( int iCurrentSequence, int iGoalSequence, int *piDir );
virtual void GetRagdollPreSequence( matrix3x4_t *preBones, float flTime );




 
--- src/dlls/hl2mp_dll/hl2mp_player.cpp 26 Aug 2006 21:24:35 -0000 1.43
 
+++ src/dlls/hl2mp_dll/hl2mp_player.cpp 3 Sep 2006 01:00:54 -0000
--- src/cl_dll/c_baseanimatingoverlay.cpp 26 Aug 2006 21:24:20 -0000 1.6
@@ -18,6 +18,7 @@
+++ src/cl_dll/c_baseanimatingoverlay.cpp 2 Sep 2006 19:04:00 -0000
#include "weapon_hl2mpbase.h"
@@ -176,6 +176,8 @@
#include "grenade_satchel.h"
#include "eventqueue.h"
+#include "datacache/imdlcache.h"
#include "engine/IEngineSound.h"
#include "SoundEmitterSystem/isoundemittersystembase.h"
@@ -504,6 +505,8 @@
  {
  {
  BaseClass::GetRenderBounds( theMins, theMaxs );
  if ( IsAlive() )
{
+        MDLCACHE_CRITICAL_SECTION();
+
SetSequence ( -1 );
SetActivity( ACT_INVALID );
   
   
+    MDLCACHE_CRITICAL_SECTION();
+
if ( !IsRagdoll() )
{
CStudioHdr *pStudioHdr = GetModelPtr();




--- src/game_shared/basecombatweapon_shared.cpp 26 Aug 2006 21:24:35 -0000 1.9
+++ src/game_shared/basecombatweapon_shared.cpp 3 Sep 2006 01:00:54 -0000
@@ -1287,6 +1287,7 @@
float flSequenceDuration = 0;
if ( GetActivity() == ACT_VM_HOLSTER )
{
+        MDLCACHE_CRITICAL_SECTION();
flSequenceDuration = SequenceDuration();
}




--- src/dlls/BaseAnimatingOverlay.cpp 26 Aug 2006 21:24:26 -0000 1.6
+++ src/dlls/BaseAnimatingOverlay.cpp 2 Sep 2006 19:04:01 -0000
@@ -12,6 +12,7 @@
#include "bone_setup.h"
#include "ai_basenpc.h"
#include "npcevent.h"
+#include "datacache/imdlcache.h"
   
   
#include "saverestore_utlvector.h"
</pre>
#include "dt_utlvector_send.h"
@@ -359,6 +360,7 @@
{
  animevent_t event;
+    MDLCACHE_CRITICAL_SECTION();
CStudioHdr *pstudiohdr = pOwner->GetModelPtr( );
if ( !pstudiohdr )
@@ -634,6 +636,7 @@
m_AnimOverlay[i].m_flBlendOut = 0.0f;
m_AnimOverlay[i].m_bSequenceFinished = false;
m_AnimOverlay[i].m_flLastEventCheck = 0;
+        MDLCACHE_CRITICAL_SECTION();
m_AnimOverlay[i].m_bLooping = ((GetSequenceFlags( GetModelPtr(), sequence ) & STUDIO_LOOPING) != 0);
if (ai_sequence_debug.GetBool() == true && m_debugOverlays & OVERLAY_NPC_SELECTED_BIT)
{


=== AI_Activity.cpp assert on startup ===
Just before the "// Multiplayer" line, add the following:
<pre>
ADD_ACTIVITY_TO_SR( ACT_MP_STAND_IDLE_PORTALGUN );
ADD_ACTIVITY_TO_SR( ACT_MP_RUN_IDLE_PORTALGUN );
ADD_ACTIVITY_TO_SR( ACT_MP_CROUCH_IDLE_PORTALGUN );
ADD_ACTIVITY_TO_SR( ACT_MP_WALK_CROUCH_PORTALGUN );
ADD_ACTIVITY_TO_SR( ACT_MP_GESTURE_RANGE_ATTACK_PORTALGUN );
ADD_ACTIVITY_TO_SR( ACT_MP_GESTURE_RELOAD_PORTALGUN );
ADD_ACTIVITY_TO_SR( ACT_MP_JUMP_PORTALGUN );
</pre>
===  Will not compile on Linux ===


This was partially moved to [[Source SDK Known Issues#Linux_Support]]


Here's a better fix for the Linux build breaking without -O.  Apparently using always_inline without -O intentionally breaks on GCC.  There's no real need for this though - you're better off letting the compiler optimize at will anyway.


--- src/dlls/baseanimating.cpp 26 Aug 2006 21:24:28 -0000 1.4
<pre>
+++ src/dlls/baseanimating.cpp 2 Sep 2006 19:04:01 -0000
--- src/public/tier0/platform.26 Aug 2006 21:24:48 -0000     1.5
@@ -437,6 +437,8 @@
+++ src/public/tier0/platform.h  28 Aug 2006 03:20:52 -0000
  //=========================================================
@@ -310,7 +310,7 @@
  void CBaseAnimating::StudioFrameAdvance()
  #else
  {
        #define STDCALL
+    MDLCACHE_CRITICAL_SECTION();
        #define FASTCALL
+
-      #define  FORCEINLINE                    __attribute__ ((always_inline))
CStudioHdr *pStudioHdr = GetModelPtr();
+       #define  FORCEINLINE                    inline
   
        // GCC 3.4.1 has a bug in supporting forced inline of templated functions
if ( !pStudioHdr || !pStudioHdr->SequencesAvailable() )
        // this macro lets us not force inlining in that case
@@ -573,6 +575,7 @@
        #define FORCEINLINE_TEMPLATE
//=========================================================
</pre>
int CBaseAnimating::SelectWeightedSequence ( Activity activity )
 
{
And some other issues...
+ MDLCACHE_CRITICAL_SECTION();
 
Assert( activity != ACT_INVALID );
<pre>
Assert( GetModelPtr() );
--- src/dlls/episodic/grenade_hopwire.h 2006-08-05 10:58:48.278875000 -0500
return ::SelectWeightedSequence( GetModelPtr(), activity, GetSequence() );
+++ src/dlls/episodic/grenade_hopwire.h 2006-08-13 23:09:41.000000000 -0500
@@ -819,6 +822,8 @@
@@ -11,7 +11,7 @@
SetSequence( 0 );
#endif
}
 
   
  #include "basegrenade_shared.h"
+   MDLCACHE_CRITICAL_SECTION();
-#include "sprite.h"
+
+#include "Sprite.h"
CStudioHdr *pStudioHdr = GetModelPtr();
 
m_flGroundSpeed = GetSequenceGroundSpeed( pStudioHdr, GetSequence() );
extern ConVar hopwire_trap;
m_bSequenceLoops = ((GetSequenceFlags( pStudioHdr, GetSequence() ) & STUDIO_LOOPING) != 0);
</pre>
@@ -854,6 +859,7 @@
 
  //=========================================================
<pre>
void CBaseAnimating::SetSequence( int nSequence )
--- src/game_shared/gamestats/ep1_gamestats.cpp  2006-08-05 10:59:06.075750000 -0500
  {
+++ src/game_shared/gamestats/ep1_gamestats.cpp  2006-08-13 16:10:42.000000000 -0500
+    MDLCACHE_CRITICAL_SECTION(); // this lock is only needed in debug mode right now, but I put it here for debug/release because the risk of making it debug-only is later the code below changes and suddenly your assert isn't correct in release mode
@@ -5,7 +5,7 @@
Assert( GetModelPtr( ) && nSequence < GetModelPtr( )->GetNumSeq() );
  //=============================================================================
m_nSequence = nSequence;
 
}
  #include "gamestats/ep1_gamestats.h"
@@ -882,6 +888,11 @@
-#include "tier1/UtlBuffer.h"
return Studio_Duration( pStudioHdr, iSequence, GetPoseParameterArray() );
+#include "tier1/utlbuffer.h"
}
 
  static int g_nParseVersion = -1;
+float CBaseAnimating::SequenceDuration(int iSequence) {
 
+    MDLCACHE_CRITICAL_SECTION();
@@ -194,4 +194,4 @@
+    return SequenceDuration(GetModelPtr(), iSequence);
                m_nDXLevel = (int)buf.GetShort();
+}
        }
+
        return bret;
  float CBaseAnimating::GetSequenceCycleRate( CStudioHdr *pStudioHdr, int iSequence )
-}
{
\ No newline at end of file
float t = SequenceDuration( pStudioHdr, iSequence );
@@ -896,6 +907,11 @@
}
}
+float CBaseAnimating::GetSequenceCycleRate(int iSequence) {
+    MDLCACHE_CRITICAL_SECTION();
+    return GetSequenceCycleRate(GetModelPtr(),iSequence);
+}
+
float CBaseAnimating::GetLastVisibleCycle( CStudioHdr *pStudioHdr, int iSequence )
{
@@ -930,6 +946,11 @@
}
}
+float CBaseAnimating::GetSequenceGroundSpeed(int iSequence) {
+    MDLCACHE_CRITICAL_SECTION();
+    return GetSequenceGroundSpeed(GetModelPtr(), iSequence);
+}
+
float CBaseAnimating::GetIdealSpeed( ) const
{
return m_flGroundSpeed;
@@ -981,6 +1002,8 @@
animevent_t event;
+    MDLCACHE_CRITICAL_SECTION();
+
CStudioHdr *pstudiohdr = GetModelPtr( );
if ( !pstudiohdr )
@@ -1084,6 +1107,11 @@
return SetPoseParameter( pStudioHdr, LookupPoseParameter( pStudioHdr, szName ), flValue );
}
+float CBaseAnimating::SetPoseParameter(const char *szName, float flValue) {
+    MDLCACHE_CRITICAL_SECTION();
+    return SetPoseParameter(GetModelPtr(), szName, flValue);
+}
+}
+
</pre>
float CBaseAnimating::SetPoseParameter( CStudioHdr *pStudioHdr, int iParameter, float flValue )
 
{
<pre>
if ( !pStudioHdr )
--- src/game_shared/gamestats/ep1_gamestats.h    2006-08-05 10:59:06.091375000 -0500
@@ -1101,6 +1129,11 @@
+++ src/game_shared/gamestats/ep1_gamestats.h    2006-08-13 16:10:52.000000000 -0500
return flValue;
@@ -11,7 +11,7 @@
}
  #endif
+float CBaseAnimating::SetPoseParameter(int iParameter, float flValue) {
+    MDLCACHE_CRITICAL_SECTION();
+    return SetPoseParameter(GetModelPtr(), iParameter, flValue);
+}
+
//=========================================================
//=========================================================
float CBaseAnimating::GetPoseParameter( const char *szName )
@@ -1174,6 +1207,11 @@
return -1; // Error
}
+int CBaseAnimating::LookupPoseParameter(const char *szName) {
+   MDLCACHE_CRITICAL_SECTION();
+   return LookupPoseParameter(GetModelPtr(), szName);
+}
+
//=========================================================
//=========================================================
bool CBaseAnimating::HasPoseParameter( int iSequence, const char *szName )
@@ -1288,6 +1326,8 @@
void CBaseAnimating::GetBoneTransform( int iBone, matrix3x4_t &pBoneToWorld )
{
+ MDLCACHE_CRITICAL_SECTION();
+
CStudioHdr *pStudioHdr = GetModelPtr( );
if (!pStudioHdr)
@@ -1750,6 +1790,8 @@
//-----------------------------------------------------------------------------
bool CBaseAnimating::GetAttachment( int iAttachment, matrix3x4_t &attachmentToWorld )
{
+ MDLCACHE_CRITICAL_SECTION();
+
CStudioHdr *pStudioHdr = GetModelPtr( );
if (!pStudioHdr)
{
@@ -2384,6 +2426,8 @@
  //-----------------------------------------------------------------------------
CBoneCache *CBaseAnimating::GetBoneCache( void )
{
+ MDLCACHE_CRITICAL_SECTION();
+
CStudioHdr *pStudioHdr = GetModelPtr( );
Assert(pStudioHdr);
 


class CUtlBuffer;
-#include "tier1/UtlDict.h"
+#include "tier1/utldict.h"


#define GAMESTATS_FILE_VERSION_OLD            001
#define GAMESTATS_FILE_VERSION_OLD2            002
</pre>


--- src/dlls/baseanimating.h 26 Aug 2006 21:24:28 -0000 1.2
That's all the compile bugs I encounteredGranted I was using my mod as a basis, so there might be other compile bugs I didn't see thanks to other fixes in my mod. If anyone else can confirm that's the complete list of fixes for a fresh SDK checkout, please do so.
+++ src/dlls/baseanimating.h 2 Sep 2006 19:04:01 -0000
@@ -88,12 +88,12 @@
inline bool SequenceLoops( void ) { return m_bSequenceLoops; }
inline float SequenceDuration( void ) { return SequenceDuration( m_nSequence ); }
float SequenceDuration( CStudioHdr *pStudioHdr, int iSequence );
- inline float SequenceDuration( int iSequence ) { return SequenceDuration(GetModelPtr(), iSequence); }
+ float  SequenceDuration(int iSequence);
float GetSequenceCycleRate( CStudioHdr *pStudioHdr, int iSequence );
- inline float GetSequenceCycleRate( int iSequence ) { return GetSequenceCycleRate(GetModelPtr(),iSequence); }
+ float  GetSequenceCycleRate(int iSequence);
float GetLastVisibleCycle( CStudioHdr *pStudioHdr, int iSequence );
float GetSequenceGroundSpeed( CStudioHdr *pStudioHdr, int iSequence );
- inline float GetSequenceGroundSpeed( int iSequence ) { return GetSequenceGroundSpeed(GetModelPtr(), iSequence); }
+ float  GetSequenceGroundSpeed(int iSequence);
void ResetActivityIndexes ( void );
void    ResetEventIndexes ( void );
int SelectWeightedSequence ( Activity activity );
@@ -132,12 +132,12 @@
virtual void HandleAnimEvent( animevent_t *pEvent );
   
int LookupPoseParameter( CStudioHdr *pStudioHdr, const char *szName );
- inline int LookupPoseParameter( const char *szName ) { return LookupPoseParameter(GetModelPtr(), szName); }
+ int LookupPoseParameter(const char *szName);
   
float SetPoseParameter( CStudioHdr *pStudioHdr, const char *szName, float flValue );
- inline float SetPoseParameter( const char *szName, float flValue ) { return SetPoseParameter( GetModelPtr(), szName, flValue ); }
+ float  SetPoseParameter( const char *szName, float flValue );
float SetPoseParameter( CStudioHdr *pStudioHdr, int iParameter, float flValue );
- inline float SetPoseParameter( int iParameter, float flValue ) { return SetPoseParameter( GetModelPtr(), iParameter, flValue ); }
+ float  SetPoseParameter( int iParameter, float flValue );
float GetPoseParameter( const char *szName );
float GetPoseParameter( int iParameter );


===  Will not link fully on Linux ===


The lack of mathlib results in "undefined symbol: _Z9AngleDiffff" at runtime.  There used to be a file called public/mathlib.cpp that exported that symbol, however that file is now complete gone and seemingly has no replacement.  (There is a mathlib.lib which is of course useless for non-MSVC.)


Update: this was apparently an oversight - Valve intended to switch everything to libs...


--- src/dlls/hl2mp_dll/hl2mp_player.cpp 26 Aug 2006 21:24:35 -0000 1.43
'''Fix:'''
+++ src/dlls/hl2mp_dll/hl2mp_player.cpp 2 Sep 2006 19:04:01 -0000
Download these [http://www.fileplanet.com/hosteddl.aspx?/hst/b/l/bloodyk0/linuxlibs.zip linuxlibs] that [[User:Mdurand | Mike Durand]] provided (careful not to overwrite your existing Makefile), and apply [http://developer.valvesoftware.com/cgi-bin/bugzilla/attachment.cgi?id=1&action=view this patch].
@@ -18,6 +18,7 @@
#include "weapon_hl2mpbase.h"
#include "grenade_satchel.h"
#include "eventqueue.h"
+#include "datacache/imdlcache.h"
#include "engine/IEngineSound.h"
#include "SoundEmitterSystem/isoundemittersystembase.h"
@@ -297,6 +298,7 @@
{
if ( HL2MPRules()->IsTeamplay() == false )
{
+            MDLCACHE_CRITICAL_SECTION();
if ( GetModelPtr() == NULL )
{
const char *szModelName = NULL;


=== GameInfo.txt issues ===


This was moved to [[Source SDK Known Issues#SDK_Launcher_Issues]]


=== Animations are jittery ===
Open <code>cl_dll/c_baseentity.cpp</code> and remove the following code:
<pre>if ( !IsSelfAnimating() )
{
        m_flAnimTime = engine->GetLastTimeStamp();     
}</pre>


--- src/game_shared/hl2mp/hl2mp_player_shared.cpp 26 Aug 2006 21:24:38 -0000 1.7
=== HL2Gamerules() ===
+++ src/game_shared/hl2mp/hl2mp_player_shared.cpp 2 Sep 2006 19:04:01 -0000
When you are running a multiplayer mod, a call to <code>HL2Gamerules()</code>, without checking if the object valid, will probably crash. This happens because the function tries to static_cast <code>g_pGamerules</code> to the class <code>CHalfLife2</code>. However the gamerules of multiplay_gamerules.cpp or hl2dm_gamerules.cpp is used. As a result the casting fails and any calls to it crash. To fix this, you need to add a check to every call to this function.
@@ -6,6 +6,7 @@
//
//=============================================================================//
#include "cbase.h"
+#include "datacache/imdlcache.h"
#ifdef CLIENT_DLL
#include "c_hl2mp_player.h"
@@ -257,6 +258,7 @@
m_angRender = GetOuter()->GetLocalAngles();
ComputePoseParam_BodyYaw();
+    MDLCACHE_CRITICAL_SECTION();
ComputePoseParam_BodyPitch(GetOuter()->GetModelPtr());
ComputePoseParam_BodyLookYaw();
</pre>
 
=== AI_Activity.cpp assert on startup ===
Just before the "// Multiplayer" line, add the following:


=== Bullet impact sounds do not play to clients ===
In the <code>PlayImpactSound</code> function in <code>cl_dll/fx_impact.cpp</code>, replace:
<pre>
<pre>
ADD_ACTIVITY_TO_SR( ACT_MP_STAND_IDLE_PORTALGUN );
C_BaseEntity::EmitSound( filter, NULL, pbulletImpactSoundName, pdata->soundhandles.bulletImpact, &vecOrigin );
ADD_ACTIVITY_TO_SR( ACT_MP_RUN_IDLE_PORTALGUN );
ADD_ACTIVITY_TO_SR( ACT_MP_CROUCH_IDLE_PORTALGUN );
ADD_ACTIVITY_TO_SR( ACT_MP_WALK_CROUCH_PORTALGUN );
ADD_ACTIVITY_TO_SR( ACT_MP_GESTURE_RANGE_ATTACK_PORTALGUN );
ADD_ACTIVITY_TO_SR( ACT_MP_GESTURE_RELOAD_PORTALGUN );
ADD_ACTIVITY_TO_SR( ACT_MP_JUMP_PORTALGUN );
</pre>
</pre>
with:
<pre>
C_BaseEntity::EmitSound( filter, NULL, pbulletImpactSoundName, &vecOrigin );
</pre>
This can also be observed as hearing the <code>WateryDeath.Warn</code> soundscript entry played while shooting at models with the "Weapon" surfaceprop when hosting a listen server in a map using level-specific soundscripts.


=== Will not compile on Linux ===
=== use of non-standard _stricmp in portable code block ===
 
This was partially moved to [[Source SDK Known Issues#Linux_Support]]


Here's a better fix for the Linux build breaking without -O. Apparently using always_inline without -O intentionally breaks on GCC.  There's no real need for this though - you're better off letting the compiler optimize at will anyway.
Can someone confirm whether this patch works with a fresh SDK?  I've removed Valve's inappropriate Makefile defines (see -Wall section) which may be what revealed this, or it might just be another Linux compilation DOA.
:This stuffs up vc2003 again, and chucks up 1000's of warnings if you #ifdef WIN32 or #ifdef LINUX - only use this fix if you are in need of it! --[[User:Amckern|Amckern]] 23:22, 2 Oct 2006 (PDT)


<pre>
<pre>
--- src/public/tier0/platform.h 26 Aug 2006 21:24:48 -0000      1.5
--- public/tier1/strtools.h     26 Aug 2006 21:30:57 -0000      1.1
+++ src/public/tier0/platform.h 28 Aug 2006 03:20:52 -0000
+++ public/tier1/strtools.h     27 Aug 2006 03:33:54 -0000
@@ -310,7 +310,7 @@
@@ -98,7 +98,7 @@
  #else
  inline char*  V_strrchr  ( const char *s,    char c            ) { return strrchr( s, c );      }
        #define STDCALL
  inline int    V_strcmp  ( const char *s1,    const char *s2    ) { return strcmp( s1, s2 );    }
        #define FASTCALL
  inline int    V_wcscmp  ( const wchar_t *s1, const wchar_t *s2  ) { return wcscmp( s1, s2 );    }
-       #define FORCEINLINE                    __attribute__ ((always_inline))
-inline int    V_stricmp ( const char *s1,    const char *s2    ) { return _stricmp( s1, s2 );  }
+      #define FORCEINLINE                    inline
+inline int    V_stricmp  ( const char *s1,    const char *s2    ) { return strcasecmp( s1, s2 ); }
        // GCC 3.4.1 has a bug in supporting forced inline of templated functions
  inline char*  V_strstr  ( const char *s1,    const char *search ) { return strstr( s1, search ); }
        // this macro lets us not force inlining in that case
inline char*  V_strupr  ( char *start )                          { return strupr( start );      }
        #define FORCEINLINE_TEMPLATE
  inline char*  V_strlower ( char *start )                          { return strlwr( start );      }
</pre>
</pre>


And some other issues...
== Missing activity ACT_HL2MP_GESTURE_RELOAD_CROSSBOW ==
This error happens because Valve never made crossbow reload animations for
the playermodels, but told it to use ACT_HL2MP_GESTURE_RELOAD_CROSSBOW in
the acttable anyway.
 
<pre>--- sourcecode/trunk/game_shared/hl2mp/weapon_crossbow.cpp (revision 336)
+++ sourcecode/trunk/game_shared/hl2mp/weapon_crossbow.cpp (revision 357)
@@ -485,5 +485,5 @@
{ ACT_HL2MP_WALK_CROUCH,          ACT_HL2MP_WALK_CROUCH_CROSSBOW,          false },
{ ACT_HL2MP_GESTURE_RANGE_ATTACK, ACT_HL2MP_GESTURE_RANGE_ATTACK_CROSSBOW, false },
- { ACT_HL2MP_GESTURE_RELOAD,      ACT_HL2MP_GESTURE_RELOAD_CROSSBOW,      false },
+ { ACT_HL2MP_GESTURE_RELOAD,      ACT_HL2MP_GESTURE_RELOAD_AR2,            false },
{ ACT_HL2MP_JUMP,                ACT_HL2MP_JUMP_CROSSBOW,                false },
};</pre>
 
== "Extra App ID set to 211, but no SteamAppID" while debugging ==
This issue happens when mounting multiple GCFs. The fix is to mount appid's in the negative. ie: -320 instead of 320.


== Bot physics/hitbox not accurate ==
<pre>
<pre>
--- src/dlls/hl2_dll/info_darknessmode_lightsource.cpp   2006-08-05 10:58:51.013250000 -0500
--- src/dlls/sdk/sdk_bot_temp.cpp       3 Sep 2006 02:18:03 -0000      1.3
+++ src/dlls/hl2_dll/info_darknessmode_lightsource.cpp   2006-08-13 23:36:01.000000000 -0500
+++ src/dlls/sdk/sdk_bot_temp.cpp       3 Sep 2006 02:36:29 -0000
@@ -61,7 +61,7 @@
@@ -52,6 +52,13 @@


                        if ( g_debug_darkness.GetBool() )
        QAngle                  m_ForwardAngle;
                        {
        QAngle                  m_LastAngles;
-                              SetThink( DebugThink );
+
+                               SetThink( &DebugThink );
+   virtual void PhysicsSimulate() {
                                SetNextThink( gpGlobals->curtime );
+        BaseClass::PhysicsSimulate();
                        }
+
                }
+        // Since this isn't called for bots.. call it here
@@ -364,7 +364,7 @@
+        UpdateVPhysicsPosition(m_vNewVPhysicsPosition, m_vNewVPhysicsVelocity, gpGlobals->frametime);
                {
+    }
                        if ( bDebug )
};
                        {
-                              pLightSource->SetThink( CInfoDarknessLightSource::DebugThink );
+                               pLightSource->SetThink( &CInfoDarknessLightSource::DebugThink );
                                pLightSource->SetNextThink( gpGlobals->curtime );
                        }
                        else


--- src/dlls/episodic/grenade_hopwire.h 2006-08-05 10:58:48.278875000 -0500
LINK_ENTITY_TO_CLASS( sdk_bot, CSDKBot );
+++ src/dlls/episodic/grenade_hopwire.h 2006-08-13 23:09:41.000000000 -0500
</pre>
@@ -11,7 +11,7 @@
#endif


#include "basegrenade_shared.h"
Bot physics/hitbox not accurate: '''happens also on HL2MP mod''' with bots. Any fix for this?
-#include "sprite.h"
+#include "Sprite.h"


  extern ConVar hopwire_trap;
== Invalid Combine Ball vphysics ==
This is an old bug, but still exists in the new SDK. This might be the last of the vphysics bugs?


<pre>
--- dlls/hl2_dll/prop_combine_ball.h    2006-08-27 18:22:56.255500000 -0500
+++ dlls/hl2_dll/prop_combine_ball.h    2006-08-27 18:22:56.255500000 -0500
@@ -119,6 +119,8 @@


--- src/game_shared/gamestats/ep1_gamestats.cpp  2006-08-05 10:59:06.075750000 -0500
        // Pow!
+++ src/game_shared/gamestats/ep1_gamestats.cpp  2006-08-13 16:10:42.000000000 -0500
        void DoExplosion( );
@@ -5,7 +5,7 @@
+       void DoExplosion_internal();
//=============================================================================
+   int OnTakeDamage(const CTakeDamageInfo &info);


#include "gamestats/ep1_gamestats.h"
        void StartAnimating( void );
-#include "tier1/UtlBuffer.h"
        void StopAnimating( void );
+#include "tier1/utlbuffer.h"


static int g_nParseVersion = -1;


@@ -194,4 +194,4 @@
                m_nDXLevel = (int)buf.GetShort();
        }
        return bret;
-}
\ No newline at end of file
+}


--- src/game_shared/gamestats/ep1_gamestats.h    2006-08-05 10:59:06.091375000 -0500
--- dlls/hl2_dll/prop_combine_ball.cpp  2006-08-27 18:24:17.364875000 -0500
+++ src/game_shared/gamestats/ep1_gamestats.h    2006-08-13 16:10:52.000000000 -0500
+++ dlls/hl2_dll/prop_combine_ball.cpp  2006-08-27 18:24:17.364875000 -0500
@@ -11,7 +11,7 @@
@@ -974,7 +974,18 @@
  #endif
  //------------------------------------------------------------------------------
 
// Pow!
  class CUtlBuffer;
  //------------------------------------------------------------------------------
-#include "tier1/UtlDict.h"
-void CPropCombineBall::DoExplosion( )
+#include "tier1/utldict.h"
+void CPropCombineBall::DoExplosion() {
 
+    // don't call DoExplosion() directly since we might be in a vphysics callback
  #define GAMESTATS_FILE_VERSION_OLD            001
+    TakeDamage(CTakeDamageInfo(this, this, 1, DMG_PREVENT_PHYSICS_FORCE));
#define GAMESTATS_FILE_VERSION_OLD2            002
+}
+
+int CPropCombineBall::OnTakeDamage(const CTakeDamageInfo &info) {
+   // now we're safely no longer in a vphysics callback
+    DoExplosion_internal();
+    return 0;
+}
+
+void CPropCombineBall::DoExplosion_internal()
  {
        // Tell the respawner to make a new one
        if ( GetSpawner() )
</pre>
</pre>


That's all the compile bugs I encountered.  Granted I was using my mod as a basis, so there might be other compile bugs I didn't see thanks to other fixes in my mod. If anyone else can confirm that's the complete list of fixes for a fresh SDK checkout, please do so.
== Wasted entitygroundcontact ==
It also seems that the code lets every client on the server calculate the minimum and maximum height of each animating entity and sends it to the server, while the server doesn't really need it. Each client calculates the same so it's waste of bandwidth.


===  Will not link fully on Linux ===
It's better to test these changes very good because it's possible it may break something.


The lack of mathlib results in "undefined symbol: _Z9AngleDiffff" at runtime.  There used to be a file called public/mathlib.cpp that exported that symbol, however that file is now complete gone and seemingly has no replacement.  (There is a mathlib.lib which is of course useless for non-MSVC.) It's not clear what Valve intended here.
Note: Why not instead of compleatly removing it, having only 1 player to calculate it ? (if its a listen server then its the local player, if its a dedicated one what about the player who has been on the most :P/any random player ?) --[[User:Filip|Filip]] 06:43, 6 December 2012 (PST)


'''Partial Fix'''
==== game_shared/usercmd.cpp ====
 
Remove:
* Add back the src/public/mathlib.cpp file that the new SDK deleted.
<pre>#if defined( HL2_CLIENT_DLL )
* Add back the src/public/mathlib.cpp file that the new SDK deleted.
if ( to->entitygroundcontact.Count() != 0 )
* Add the "..\game_shared\choreoevent.cpp" block back to the hl_sdk.vcproj.
* Add the "..\game_shared\chorescene.cpp" block back to the hl_sdk.vcproj.
 
Unfortunately then you end up missing a function called <code>void VectorRotate( const Vector &in1, const QAngle &in2, Vector &out )</code> which never existed in the SDK.  I could try to reverse engineer it, but for the moment I'm too tired of dealing with Valve's breakage.
 
Probably the real solution would be for Valve to ship some .a files containing these symbols, if for some reason they want to hide the source code to mathlib.cpp and friends.
 
=== GameInfo.txt issues ===
 
This was moved to [[Source SDK Known Issues#SDK_Launcher_Issues]]
 
=== Animations are jittery ===
Open <code>cl_dll/c_baseentity.cpp</code> and replace the following code:
<pre>if ( !IsSelfAnimating() )  
{
        m_flAnimTime = engine->GetLastTimeStamp();     
}</pre>
with this:
<pre>if ( !IsSelfAnimating() && !IsNPC() && !IsPlayer() )
{
{
m_flAnimTime = engine->GetLastTimeStamp();
buf->WriteOneBit( 1 );
}</pre>
buf->WriteShort( to->entitygroundcontact.Count() );
 
int i;
=== HL2Gamerules() ===
for (i = 0; i < to->entitygroundcontact.Count(); i++)
When you are running a multiplayer mod, a call to <code>HL2Gamerules()</code>, without checking if the object valid, will probably crash. This happens because the function tries to static_cast <code>g_pGamerules</code> to the class <code>CHalfLife2</code>. However the gamerules of multiplay_gamerules.cpp or hl2dm_gamerules.cpp is used. As a result the casting fails and any calls to it crash. To fix this, you need to add a check to every call to this function.
{
 
buf->WriteUBitLong( to->entitygroundcontact[i].entindex, MAX_EDICT_BITS );
=== Bullet impact sounds do not play to clients ===
buf->WriteBitCoord( to->entitygroundcontact[i].minheight );
In the <code>PlayImpactSound</code> function in <code>cl_dll/fx_impact.cpp</code>, replace:
buf->WriteBitCoord( to->entitygroundcontact[i].maxheight );
<pre>
}
C_BaseEntity::EmitSound( filter, NULL, pbulletImpactSoundName, pdata->soundhandles.bulletImpact, &vecOrigin );
to->entitygroundcontact.RemoveAll();
</pre>
}
with:
else
<pre>
{
C_BaseEntity::EmitSound( filter, NULL, pbulletImpactSoundName, &vecOrigin );
buf->WriteOneBit( 0 );
</pre>
}
This can also be observed as hearing the <code>WateryDeath.Warn</code> soundscript entry played while shooting at models with the "Weapon" surfaceprop when hosting a listen server in a map using level-specific soundscripts.
#endif</pre>
<pre>#if defined( HL2_DLL )
if ( buf->ReadOneBit() )
{
// DM: Fix negative entitygroundcontact crash, from the VDC
int count = buf->ReadShort();
        if ( count < 0 || count > 140 ) {
            Msg( "Ignoring strange entitygroundcontact count: %d\n", count );
            return; // why can this be less than 0, Valve? change to ReadWord()???
        }
move->entitygroundcontact.SetCount( count );


=== use of non-standard _stricmp in portable code block ===
int i;
 
for (i = 0; i < move->entitygroundcontact.Count(); i++)
Can someone confirm whether this patch works with a fresh SDK?  I've removed Valve's inappropriate Makefile defines (see -Wall section) which may be what revealed this, or it might just be another Linux compilation DOA.
{
move->entitygroundcontact[i].entindex = buf->ReadUBitLong( MAX_EDICT_BITS );
move->entitygroundcontact[i].minheight = buf->ReadBitCoord( );
move->entitygroundcontact[i].maxheight = buf->ReadBitCoord( );
}
}
#endif</pre>


<pre>
==== game_shared/usercmd.h ====
--- public/tier1/strtools.h     26 Aug 2006 21:30:57 -0000      1.1
Remove:
+++ public/tier1/strtools.h    27 Aug 2006 03:33:54 -0000
<pre>class CEntityGroundContact
@@ -98,7 +98,7 @@
{
inline char*  V_strrchr (const char *s, char c)                                      { return strrchr( s, c ); }
public:
inline int             V_strcmp (const char *s1, const char *s2)                      { return strcmp( s1, s2 ); }
int entindex;
inline int            V_wcscmp (const wchar_t *s1, const wchar_t *s2)        { return wcscmp( s1, s2 ); }
float minheight;
-inline int            V_stricmp( const char *s1, const char *s2 )                    { return _stricmp( s1, s2 ); }
float maxheight;
+inline int            V_stricmp( const char *s1, const char *s2 )                     { return strcasecmp( s1, s2 ); }
};</pre>
inline char*  V_strstr( const char *s1, const char *search )          { return strstr( s1, search ); }
<pre>#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
inline char*  V_strupr (char *start)                                                         { return strupr( start ); }
entitygroundcontact.RemoveAll();
inline char*  V_strlower (char *start)                                                       { return strlwr( start ); }
#endif</pre>
</pre>
<pre>#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
entitygroundcontact = src.entitygroundcontact;
#endif</pre>
<pre>#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
CUtlVector< CEntityGroundContact > entitygroundcontact;
#endif</pre>


== "Extra App ID set to 211, but no SteamAppID" while debugging ==
==== dlls/player_command.cpp ====
This issue happens when mounting multiple GCFs. The fix is to run the mod via start_mod.bat and let Visual Studio attach to hl2.exe.
Remove:
<pre>#if defined (HL2_DLL)
// pull out backchannel data and move this out


== Invalid Combine Ball vphysics ==
int i;
This is an old bug, but still exists in the new SDK. This might be the last of the vphysics bugs?
for (i = 0; i < cmd->entitygroundcontact.Count(); i++)
{
int entindex = cmd->entitygroundcontact[i].entindex;
CBaseEntity *pEntity = CBaseEntity::Instance( engine->PEntityOfEntIndex( entindex) );
if (pEntity)
{
CBaseAnimating *pAnimating = pEntity->GetBaseAnimating();
if (pAnimating)
{
pAnimating->SetIKGroundContactInfo( cmd->entitygroundcontact[i].minheight, cmd->entitygroundcontact[i].maxheight );
}
}
}


<pre>
#endif</pre>
--- dlls/hl2_dll/prop_combine_ball.h    2006-08-27 18:22:56.255500000 -0500
+++ dlls/hl2_dll/prop_combine_ball.h    2006-08-27 18:22:56.255500000 -0500
@@ -119,6 +119,8 @@


        // Pow!
==== cl_dll/input.h ====
        void DoExplosion( );
Remove:<pre>#if defined( HL2_CLIENT_DLL )  
+      void DoExplosion_internal();
        CUtlVector< CEntityGroundContact > m_EntityGroundContact;  
+    int OnTakeDamage(const CTakeDamageInfo &info);
#endif</pre>
 
==== cl_dll/in_main.cpp ====
Comment out the entire function <code>CInput::AddIKGroundContactInfo</code>


         void StartAnimating( void );
== Resizing game window glitches HUD elements ==
         void StopAnimating( void );
'''Fix:'''
<pre>
--- mod/src/cl_dll/game_controls/vgui_TeamFortressViewport.cpp  21 Feb 2006 01:58:36 -0000      1.6
+++ mod/src/cl_dll/game_controls/vgui_TeamFortressViewport.cpp  16 Jul 2006 20:52:44 -0000
@@ -152,6 +152,9 @@
         m_pBackGround->SetZPos( -20 ); // send it to the back
         m_pBackGround->SetVisible( false );
        CreateDefaultPanels();
+
+      // reload again... this fixes the ammo display etc
+      ReloadScheme( NULL );
}
</pre>


== Mod fails to compile with gcc 4.x ==
{{Note|Even if you apply these fixes, gcc 4 still won't work. However both of these fixes seem reasonable on 3.x as well.}}


'''Fix:''' First pass problem is a code bug - not sure if this would've shown up in gcc 3.x if Valve didn't use the horribly evil -w option, but it certainly looks like invalid code to reference a friend function without a declaration.


--- dlls/hl2_dll/prop_combine_ball.cpp  2006-08-27 18:24:17.364875000 -0500
<pre>
+++ dlls/hl2_dll/prop_combine_ball.cpp  2006-08-27 18:24:17.364875000 -0500
--- mod/src/dlls/baseentity.h  2005/08/29 00:14:40    1.3
@@ -974,7 +974,18 @@
+++ mod/src/dlls/baseentity.2006/06/07 02:17:03
  //------------------------------------------------------------------------------
@@ -325,6 +325,9 @@
// Pow!
  #define CREATE_PREDICTED_ENTITY( className )   \
//------------------------------------------------------------------------------
        CBaseEntity::CreatePredictedEntityByName( className, __FUNCTION__, __LINE__ );
-void CPropCombineBall::DoExplosion( )
 
+void CPropCombineBall::DoExplosion() {
+void SendProxy_Origin( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID );
+   // don't call DoExplosion() directly since we might be in a vphysics callback
+void SendProxy_Angles( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID );
+   TakeDamage(CTakeDamageInfo(this, this, 1, DMG_PREVENT_PHYSICS_FORCE));
+}
+
+
+int CPropCombineBall::OnTakeDamage(const CTakeDamageInfo &info) {
//
+    // now we're safely no longer in a vphysics callback
// Base Entity.  All entity types derive from this
+    DoExplosion_internal();
  //
+    return 0;
</pre>
+}
+
+void CPropCombineBall::DoExplosion_internal()
  {
        // Tell the respawner to make a new one
        if ( GetSpawner() )
</pre>


== Usercmd sends unneeded extra data ==
Looks like the only other issue was this asm change.  Apparently gcc did something slightly backwards incompatible in 4.x.
The [[usercmd]] sends data many times per sec and some of it don't really seem needed.


=== Impulse commands ===
<pre>
Usercmd sends the impulse commands also every time. Unless the impulse commands change VERY often, this is a bandwidth waste.
--- src/public/mathlib.cpp      18 Feb 2005 04:45:56 -0000      1.1.1.1
It's better to change this to a normal command.
+++ src/public/mathlib.cpp      11 Jun 2006 19:45:34 -0000
@@ -436,7 +436,6 @@
                "movss %%xmm0, %0 \n\t"
                : "=m" (x)
                : "m" (rroot)
-              : "%xmm0"
        );
#else
#error
</pre>


==== cl_dll/in_main.cpp ====
== Case changes in player names cause chat truncation ==
Remove:
<pre>
<pre>static int in_impulse = 0;</pre>
--- mod/src/cl_dll/hl2mp/hl2mp_hud_chat.cpp    2006/02/21 01:58:38    1.3
<pre>void IN_Impulse (void)
+++ mod/src/cl_dll/hl2mp/hl2mp_hud_chat.cpp    2006/03/28 03:11:13
{
@@ -422,8 +422,9 @@
in_impulse = atoi( engine->Cmd_Argv(1) );
        else
}</pre>
                line->InsertColorChange( Color( g_ColorYellow[0], g_ColorYellow[1], g_ColorYellow[2], 255 ) );
<pre>// Latch and clear impulse
cmd->impulse = in_impulse;
in_impulse = 0;</pre>
<pre>static ConCommand impulse("impulse", IN_Impulse);</pre>


==== cl_dll/prediction.cpp ====
-      char *buf = static_cast<char *>( stackalloc( strlen( pmsg ) + 1  ) );
Remove:
-      wchar_t *wbuf = static_cast<wchar_t *>( stackalloc( (strlen( pmsg ) + 1 ) * sizeof(wchar_t) ) );
<pre>move->m_nImpulseCommand = ucmd->impulse;</pre>
+      char buf[4096];
+      wchar_t wbuf[4096];
+      Assert(strlen(pmsg) < sizeof(buf)); // otherwise message truncation will occur
        if ( buf )
        {
                float *flColor = GetClientColor( iPlayerIndex );
@@ -435,10 +436,10 @@
                buf[ min( iNameLength, MAX_PLAYER_NAME_LENGTH+31) ] = 0;
                line->InsertColorChange( Color( flColor[0], flColor[1], flColor[2], 255 ) );
                line->InsertString( buf );
-              Q_strncpy( buf, pmsg + iNameLength, strlen( pmsg ));
+              Q_strncpy(buf, pmsg + iNameLength, sizeof(buf));
                buf[ strlen( pmsg + iNameLength ) ] = '\0';
                line->InsertColorChange( Color( g_ColorYellow[0], g_ColorYellow[1], g_ColorYellow[2], 255 ) );
-              vgui::localize()->ConvertANSIToUnicode( buf, wbuf, strlen(pmsg)*sizeof(wchar_t));
+              vgui::localize()->ConvertANSIToUnicode( buf, wbuf, sizeof(wbuf));
                line->InsertString( wbuf );
                line->SetVisible( true );
                line->SetNameLength( iNameLength );


==== dlls/player.cpp ====
--- mod/src/tier1/stringpool.cpp       2005/02/18 04:45:59    1.1.1.1
Remove:
+++ mod/src/tier1/stringpool.cpp        2006/03/28 03:25:05
<pre>DEFINE_FIELD( m_nImpulse, FIELD_INTEGER ),</pre>
@@ -22,7 +22,7 @@
<pre>ucmd->impulse = 0;</pre>
<pre>cmd.impulse = ucmd->impulse; </pre>
(The last line is in the file twice)


bool StrLess( const char * const &pszLeft, const char * const &pszRight )
{
-      return ( Q_stricmp( pszLeft, pszRight) < 0 );
+      return ( Q_strcmp( pszLeft, pszRight) < 0 );
}


Change <code>void CBasePlayer::ImpulseCommands( )</code> to <code>void CBasePlayer::ImpulseCommands( int iImpulse ) </code>. Don't forget the header too.
//-----------------------------------------------------------------------------
 
--- mod/src/cl_dll/sdk/sdk_hud_chat.cpp 2006/02/21 01:58:38 1.3
Add the following code to the top:
+++ mod/src/cl_dll/sdk/sdk_hud_chat.cpp 2006/03/28 03:34:35
<pre>// DM: If we are frozen, don't accept impulse-commands
@@ -422,8 +422,9 @@
if ( GetFlags() & FL_FROZEN )
else
return;</pre>
line->InsertColorChange( Color( g_ColorYellow[0], g_ColorYellow[1], g_ColorYellow[2], 255 ) );
I guess the comment speaks for itself.
 
- char *buf = static_cast<char *>( stackalloc( strlen( pmsg ) + 1  ) );
Remove in that function also:
- wchar_t *wbuf = static_cast<wchar_t *>( stackalloc( (strlen( pmsg ) + 1 ) * sizeof(wchar_t) ) );
<pre>int iImpulse = (int)m_nImpulse; </pre>
+ char buf[4096];
<pre>m_nImpulse = 0;</pre>
+ wchar_t wbuf[4096];
 
+    assert(strlen(pmsg) < sizeof(buf)); // otherwise message truncation will occur
Then look for the function <code>CBasePlayer::ClientCommand()</code> and add the following:
if ( buf )
<pre>else if( stricmp( cmd, "impulse" ) == 0 && engine->Cmd_Argc() == 2 )  
{
{
float *flColor = GetClientColor( iPlayerIndex );
ImpulseCommands( atoi(engine->Cmd_Argv( 1 )) );  
@@ -435,10 +436,10 @@
return true;
buf[ min( iNameLength, MAX_PLAYER_NAME_LENGTH+31) ] = 0;
}</pre>
line->InsertColorChange( Color( flColor[0], flColor[1], flColor[2], 255 ) );
 
line->InsertString( buf );
Don't forget the HL2DM equivalents.
- Q_strncpy( buf, pmsg + iNameLength, strlen( pmsg ));
 
+ Q_strncpy(buf, pmsg + iNameLength, sizeof(buf));
==== dlls/player.h ====
buf[ strlen( pmsg + iNameLength ) ] = '\0';
Remove:
line->InsertColorChange( Color( g_ColorYellow[0], g_ColorYellow[1], g_ColorYellow[2], 255 ) );
<pre>int            GetImpulse( void ) const { return m_nImpulse; } </pre>
- vgui::localize()->ConvertANSIToUnicode( buf, wbuf, strlen(pmsg)*sizeof(wchar_t));
<pre>int                                            m_nImpulse; </pre>
+ vgui::localize()->ConvertANSIToUnicode( buf, wbuf, sizeof(wbuf));
 
line->InsertString( wbuf );
==== dlls/player_command.cpp ====
line->SetVisible( true );
Remove:
line->SetNameLength( iNameLength );
<pre>move->m_nImpulseCommand        = ucmd->impulse;</pre>
</pre>
<pre>if ( ucmd->impulse )
{
// Discard impulse commands unless the vehicle allows them.
// FIXME: UsingStandardWeapons seems like a bad filter for this. The flashlight is an impulse command, for example.
if ( !pVehicle || player->UsingStandardWeaponsInVehicle() )
{
player->m_nImpulse = ucmd->impulse;
}
}</pre>


==== game_shared/igamemovement.h ====
{{note|I've never actually tested the patch to sdk_hud_chat.cpp, but the code is identical to hl2mp_hud_chat.cpp so it should work.}}
Remove:
<pre>int                            m_nImpulseCommand;      // Impulse command issued. </pre>


==== game_shared/usercmd.cpp ====
== dm_powerhouse lights never slow down ==
Remove:
'''Workaround:''' Really this should be fixed in the map, but good luck waiting on that to happen.  In the mean time here's a code patch for any such mapping errors:
<pre>if ( to->impulse != from->impulse )
{
                buf->WriteOneBit( 1 );
            buf->WriteUBitLong( to->impulse, 8 );
        }
        else
        {
                buf->WriteOneBit( 0 );
        } </pre>


<pre>if ( buf->ReadOneBit() )  
<pre>
        {
--- mod/src/dlls/physconstraint.cpp    2005/03/26 17:44:28    1.2
                move->impulse = buf->ReadUBitLong( 8 );  
+++ mod/src/dlls/physconstraint.cpp    2006/03/06 02:45:47
        } </pre>
@@ -727,6 +727,16 @@
==== cl_dll/c_baseplayer.cpp ====
                for ( int i = 0; i < 2; i++ )
Remove:
                {
<pre>DEFINE_PRED_FIELD( m_nImpulse, FIELD_INTEGER, FTYPEDESC_INSENDTABLE ), </pre>
                        info.pObjects[i]->WorldToLocal( &ballsocket.constraintPosition[i], GetAbsOrigin() );
<pre>DEFINE_FIELD( m_nImpulse, FIELD_INTEGER ), </pre>
+            // HACKHACK - the mapper forgot to put in some sane physics damping (dm_powerhouse)
+            float damping, adamping;
+            info.pObjects[i]->GetDamping(&damping, &adamping);
+            if (damping < .2f) {
+                damping = .2f;
+            }
+            if (adamping < .2f) {
+                adamping = .2f;
+            }
+            info.pObjects[i]->SetDamping(&damping, &damping);
                }
                GetBreakParams( ballsocket.constraint, info );
                ballsocket.constraint.torqueLimit = 0;
</pre>


==== cl_dll/c_baseplayer.h ====
== Wall Boosting Exploit ==
Remove:
<pre>int                            m_nImpulse;</pre>


=== entitygroundcontact ===
Hi, everyone would of no doubt noticed that running against a wall(strafing and moving forward works best) makes you run really fast. If anyone has played kreedz climbing yet(I used to code for it) you might of noticed moving against walls is jerky. I think when I was adding some things to the movement I made the server and client disagree on what speed the player is moving at. Has anyone sound why players in source do this? where the boost might be clamped to normal levels? If so I'd love to know, and it would be good to know for bg2 as well, people who play it complain a lot of it  
It also seems that the code lets every client on the server calculate the minimum and maximum height of each animating entity and sends it to the server, while the server doesn't really need it. Each client calculates the same so it's waste of bandwidth.
as well(just the boost, not client prediction jerks).


It's better to test these changes very good because it's possible it may break something.
'''Fix Provided by [[User:Omega|Tony "omega" Sergi]]'''


==== game_shared/usercmd.cpp ====
mod/game_shared/gamemovement.cpp
Remove:
Line 1374
<pre>#if defined( HL2_CLIENT_DLL )
 
if ( to->entitygroundcontact.Count() != 0 )
<pre>
{
void CGameMovement::Accelerate( Vector& wishdir, float wishspeed, float
buf->WriteOneBit( 1 );
accel )
buf->WriteShort( to->entitygroundcontact.Count() );
{
int i;
int i;
for (i = 0; i < to->entitygroundcontact.Count(); i++)
float addspeed, accelspeed, currentspeed;
{
 
buf->WriteUBitLong( to->entitygroundcontact[i].entindex, MAX_EDICT_BITS );
// This gets overridden because some games (CSPort) want to allow dead (observer) players
buf->WriteBitCoord( to->entitygroundcontact[i].minheight );
// to be able to move around.
buf->WriteBitCoord( to->entitygroundcontact[i].maxheight );
if ( !CanAccelerate() )
}
return;
to->entitygroundcontact.RemoveAll();
}
else
{
buf->WriteOneBit( 0 );
}
#endif</pre>
<pre>#if defined( HL2_DLL )
if ( buf->ReadOneBit() )
{
// DM: Fix negative entitygroundcontact crash, from the VDC
int count = buf->ReadShort();
        if ( count < 0 || count > 140 ) {
            Msg( "Ignoring strange entitygroundcontact count: %d\n", count );
            return; // why can this be less than 0, Valve? change to ReadWord()???
        }
move->entitygroundcontact.SetCount( count );


int i;
//omega; WALLSTRAFE FIX
for (i = 0; i < move->entitygroundcontact.Count(); i++)
{
move->entitygroundcontact[i].entindex = buf->ReadUBitLong( MAX_EDICT_BITS );
move->entitygroundcontact[i].minheight = buf->ReadBitCoord( );
move->entitygroundcontact[i].maxheight = buf->ReadBitCoord( );
}
}
#endif</pre>


==== game_shared/usercmd.h ====
// See if we are changing direction a bit
Remove:
// currentspeed = mv->m_vecVelocity.Dot(wishdir);
<pre>class CEntityGroundContact
{
public:
int entindex;
float minheight;
float maxheight;
};</pre>
<pre>#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
entitygroundcontact.RemoveAll();
#endif</pre>
<pre>#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
entitygroundcontact = src.entitygroundcontact;
#endif</pre>
<pre>#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
CUtlVector< CEntityGroundContact > entitygroundcontact;
#endif</pre>


==== dlls/player_command.cpp ====
currentspeed = sqrt( DotProduct(mv->m_vecVelocity, mv->m_vecVelocity) );
Remove:
//omega; END WALLSTRAFE FIX
<pre>#if defined (HL2_DLL)
// pull out backchannel data and move this out


int i;
// Reduce wishspeed by the amount of veer.
for (i = 0; i < cmd->entitygroundcontact.Count(); i++)
</pre>
{
int entindex =  cmd->entitygroundcontact[i].entindex;
CBaseEntity *pEntity = CBaseEntity::Instance( engine->PEntityOfEntIndex( entindex) );
if (pEntity)
{
CBaseAnimating *pAnimating = pEntity->GetBaseAnimating();
if (pAnimating)
{
pAnimating->SetIKGroundContactInfo( cmd->entitygroundcontact[i].minheight, cmd->entitygroundcontact[i].maxheight );
}
}
}
 
#endif</pre>
 
==== cl_dll/input.h ====
Remove:<pre>#if defined( HL2_CLIENT_DLL )
        CUtlVector< CEntityGroundContact > m_EntityGroundContact;
#endif</pre>
 
==== cl_dll/in_main.cpp ====
Comment out the entire function <code>CInput::AddIKGroundContactInfo</code>






== GNU crasher for maps with broken ladders ==
'''Fix:''' Valve's code is invalid but compiles on MSVC due to its D.W.I.M. philosophy.  The following patch is required:


== Resizing game window glitches HUD elements ==
'''Fix:'''
<pre>
<pre>
--- mod/src/cl_dll/game_controls/vgui_TeamFortressViewport.cpp 21 Feb 2006 01:58:36 -0000      1.6
--- mod/src/game_shared/func_ladder.cpp 2005/06/11 22:14:32    1.2
+++ mod/src/cl_dll/game_controls/vgui_TeamFortressViewport.cpp 16 Jul 2006 20:52:44 -0000
+++ mod/src/game_shared/func_ladder.cpp 2006/02/12 19:43:25
@@ -152,6 +152,9 @@
@@ -87,7 +87,7 @@
        m_pBackGround->SetZPos( -20 ); // send it to the back
                                m_vecPlayerMountPositionBottom.GetZ(),
        m_pBackGround->SetVisible( false );
                                bottomtrace.m_pEnt
        CreateDefaultPanels();
                                        ?
+
-                                      UTIL_VarArgs( "%s/%s", bottomtrace.m_pEnt->GetClassname(), bottomtrace.m_pEnt->GetEntityName() )
+      // reload again... this fixes the ammo display etc
+                                      UTIL_VarArgs( "%s/%s", bottomtrace.m_pEnt->GetClassname(), STRING(bottomtrace.m_pEnt->GetEntityName()) )
+       ReloadScheme( NULL );
                                        :
}
                                        "NULL" );
</pre>
                }
 
@@ -99,7 +99,7 @@
== Mod fails to compile with gcc 4.x ==
                                m_vecPlayerMountPositionTop.GetZ(),
Note even if you apply these fixes, gcc 4 still won't work.  However both of these fixes seem reasonable on 3.x as well.
                                toptrace.m_pEnt
 
                                        ?
'''Fix:''' First pass problem is a code bug - not sure if this would've shown up in gcc 3.x if Valve didn't use the horribly evil -w option, but it certainly looks like invalid code to reference a friend function without a declaration.
-                                      UTIL_VarArgs( "%s/%s", toptrace.m_pEnt->GetClassname(), toptrace.m_pEnt->GetEntityName() )
+                                       UTIL_VarArgs( "%s/%s", toptrace.m_pEnt->GetClassname(), STRING(toptrace.m_pEnt->GetEntityName()) )
                                        :
                                        "NULL" );
                }
</pre>
 
== sdkshaders: fix for spaces in path ==
Issue: Any attempt to compile the SDK shaders for a mod with spaces in the path name results in failure:


<pre>
(ie: "C:\Program Files\Steam\SteamApps\SourceMods\MODNAME\src\src\sdkshaders")  
--- mod/src/dlls/baseentity.h  2005/08/29 00:14:40    1.3
+++ mod/src/dlls/baseentity.h  2006/06/07 02:17:03
@@ -325,6 +325,9 @@
#define CREATE_PREDICTED_ENTITY( className )  \
        CBaseEntity::CreatePredictedEntityByName( className, __FUNCTION__, __LINE__ );


+void SendProxy_Origin( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID );
This is due to the fact that the perl scripts and bat files have not been properly modified to handle spaces in the path.
+void SendProxy_Angles( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID );
+
//
// Base Entity. All entity types derive from this
//
</pre>


Looks like the only other issue was this asm change.  Apparently gcc did something slightly backwards incompatible in 4.x.


<pre>
'''Fix:''' [[User:Visualphoenix|Ray "VisualPhoenix" Barbiero]] has provided the following patches:
--- src/public/mathlib.cpp      18 Feb 2005 04:45:56 -0000      1.1.1.1
 
+++ src/public/mathlib.cpp      11 Jun 2006 19:45:34 -0000
{{note|These patches have been tested on paths with and without spaces.}}
@@ -436,7 +436,6 @@
                "movss %%xmm0, %0 \n\t"
                : "=m" (x)
                : "m" (rroot)
-              : "%xmm0"
        );
#else
#error
</pre>


== Case changes in player names cause chat truncation ==
=== updateshaders.pl ===
<pre>
<pre>
--- mod/src/cl_dll/hl2mp/hl2mp_hud_chat.cpp    2006/02/21 01:58:38    1.3
--- mod/src/devtools/bin/updateshaders.pl 2005-07-14 09:58:54.000000000 -0500
+++ mod/src/cl_dll/hl2mp/hl2mp_hud_chat.cpp    2006/03/28 03:11:13
+++ mod/src/devtools/bin/updateshaders.pl 2005-10-11 23:42:36.000000000 -0500
@@ -422,8 +422,9 @@
@@ -105,7 +105,7 @@
        else
{
                line->InsertColorChange( Color( g_ColorYellow[0], g_ColorYellow[1], g_ColorYellow[2], 255 ) );
$xboxswitch = "-xbox ";
 
}
-       char *buf = static_cast<char *>( stackalloc( strlen( pmsg ) + 1  ) );
- print MAKEFILE "\t$g_SourceDir\\devtools\\bin\\perl.exe $g_SourceDir\\devtools\\bin\\" . $shadertype . "_prep.pl $xboxswitch -shaderoutputdir $shaderoutputdir -source \"$g_SourceDir\" $shadername\n";
-       wchar_t *wbuf = static_cast<wchar_t *>( stackalloc( (strlen( pmsg ) + 1 ) * sizeof(wchar_t) ) );
+ print MAKEFILE "\t\"$g_SourceDir\\devtools\\bin\\perl.exe\" \"$g_SourceDir\\devtools\\bin\\" . $shadertype . "_prep.pl\" $xboxswitch -shaderoutputdir $shaderoutputdir -source \"$g_SourceDir\" $shadername\n";
+       char buf[4096];
my $filename;
+      wchar_t wbuf[4096];
if( $shadertype eq "fxc" )
+      Assert(strlen(pmsg) < sizeof(buf)); // otherwise message truncation will occur
{
        if ( buf )
@@ -199,14 +199,14 @@
        {
# We only generate inc files for fxc and vsh files.
                float *flColor = GetClientColor( iPlayerIndex );
if( $g_xbox )
@@ -435,10 +436,10 @@
{
                buf[ min( iNameLength, MAX_PLAYER_NAME_LENGTH+31) ] = 0;
- print MAKEFILE " $shadertype" . "tmp_xbox\\" . $shaderbase . "\.inc";
                line->InsertColorChange( Color( flColor[0], flColor[1], flColor[2], 255 ) );
+ print MAKEFILE " \"$shadertype" . "tmp_xbox\\" . $shaderbase . "\.inc\"";
                line->InsertString( buf );
}
-               Q_strncpy( buf, pmsg + iNameLength, strlen( pmsg ));
else
+               Q_strncpy(buf, pmsg + iNameLength, sizeof(buf));
{
                buf[ strlen( pmsg + iNameLength ) ] = '\0';
- print MAKEFILE " $shadertype" . "tmp9\\" . $shaderbase . "\.inc";
                line->InsertColorChange( Color( g_ColorYellow[0], g_ColorYellow[1], g_ColorYellow[2], 255 ) );
+ print MAKEFILE " \"$shadertype" . "tmp9\\" . $shaderbase . "\.inc\"";
-              vgui::localize()->ConvertANSIToUnicode( buf, wbuf, strlen(pmsg)*sizeof(wchar_t));
}
+              vgui::localize()->ConvertANSIToUnicode( buf, wbuf, sizeof(wbuf));
}
                line->InsertString( wbuf );
- print MAKEFILE " $shaderoutputdir\\$shadertype\\$shaderbase\.vcs";
                line->SetVisible( true );
+ print MAKEFILE " \"$shaderoutputdir\\$shadertype\\$shaderbase\.vcs\"";
                line->SetNameLength( iNameLength );
 
--- mod/src/tier1/stringpool.cpp        2005/02/18 04:45:59    1.1.1.1
+++ mod/src/tier1/stringpool.cpp        2006/03/28 03:25:05
@@ -22,7 +22,7 @@
 
bool StrLess( const char * const &pszLeft, const char * const &pszRight )
{
-       return ( Q_stricmp( pszLeft, pszRight) < 0 );
+       return ( Q_strcmp( pszLeft, pszRight) < 0 );
  }
  }
print MAKEFILE "\n\n";
@@ -221,11 +221,11 @@
# We only generate inc files for fxc and vsh files.
if( $g_xbox )
{
- print MAKEFILE "\tdel /f /q $shadertype" . "tmp_xbox\\" . $shaderbase . "\.inc\n";
+ print MAKEFILE "\tdel /f /q \"$shadertype" . "tmp_xbox\\" . $shaderbase . "\.inc\"\n";
}
else
{
- print MAKEFILE "\tdel /f /q $shadertype" . "tmp9\\" . $shaderbase . "\.inc\n";
+ print MAKEFILE "\tdel /f /q \"$shadertype" . "tmp9\\" . $shaderbase . "\.inc\"\n";
}
}
print MAKEFILE "\tdel /f /q \"$shaderoutputdir\\$shadertype\\$shaderbase\.vcs\"\n";
</pre>


//-----------------------------------------------------------------------------
=== buildshaders.bat ===
--- mod/src/cl_dll/sdk/sdk_hud_chat.cpp 2006/02/21 01:58:38 1.3
+++ mod/src/cl_dll/sdk/sdk_hud_chat.cpp 2006/03/28 03:34:35
@@ -422,8 +422,9 @@
else
line->InsertColorChange( Color( g_ColorYellow[0], g_ColorYellow[1], g_ColorYellow[2], 255 ) );
- char *buf = static_cast<char *>( stackalloc( strlen( pmsg ) + 1  ) );
- wchar_t *wbuf = static_cast<wchar_t *>( stackalloc( (strlen( pmsg ) + 1 ) * sizeof(wchar_t) ) );
+ char buf[4096];
+ wchar_t wbuf[4096];
+    assert(strlen(pmsg) < sizeof(buf)); // otherwise message truncation will occur
if ( buf )
{
float *flColor = GetClientColor( iPlayerIndex );
@@ -435,10 +436,10 @@
buf[ min( iNameLength, MAX_PLAYER_NAME_LENGTH+31) ] = 0;
line->InsertColorChange( Color( flColor[0], flColor[1], flColor[2], 255 ) );
line->InsertString( buf );
- Q_strncpy( buf, pmsg + iNameLength, strlen( pmsg ));
+ Q_strncpy(buf, pmsg + iNameLength, sizeof(buf));
buf[ strlen( pmsg + iNameLength ) ] = '\0';
line->InsertColorChange( Color( g_ColorYellow[0], g_ColorYellow[1], g_ColorYellow[2], 255 ) );
- vgui::localize()->ConvertANSIToUnicode( buf, wbuf, strlen(pmsg)*sizeof(wchar_t));
+ vgui::localize()->ConvertANSIToUnicode( buf, wbuf, sizeof(wbuf));
line->InsertString( wbuf );
line->SetVisible( true );
line->SetNameLength( iNameLength );
</pre>
 
{{note|I've never actually tested the patch to sdk_hud_chat.cpp, but the code is identical to hl2mp_hud_chat.cpp so it should work.}}
 
== dm_powerhouse lights never slow down ==
'''Workaround:''' Really this should be fixed in the map, but good luck waiting on that to happen.  In the mean time here's a code patch for any such mapping errors:
 
<pre>
<pre>
--- mod/src/dlls/physconstraint.cpp    2005/03/26 17:44:28    1.2
--- mod/src/materialsystem/stdshaders/buildshaders.bat 2005-07-14 10:00:36.000000000 -0500
+++ mod/src/dlls/physconstraint.cpp    2006/03/06 02:45:47
+++ mod/src/materialsystem/stdshaders/buildshaders.bat 2005-10-11 23:01:08.000000000 -0500
@@ -727,6 +727,16 @@
@@ -36,7 +36,7 @@
                for ( int i = 0; i < 2; i++ )
REM ****************
                {
:set_xbox_args
                        info.pObjects[i]->WorldToLocal( &ballsocket.constraintPosition[i], GetAbsOrigin() );
set xbox_args=-xbox
+            // HACKHACK - the mapper forgot to put in some sane physics damping (dm_powerhouse)
-set targetdir=%vproject%\shaders_xbox
+            float damping, adamping;
+set targetdir="%vproject%\shaders_xbox"
+            info.pObjects[i]->GetDamping(&damping, &adamping);
goto build_shaders
+           if (damping < .2f) {
+               damping = .2f;
+            }
@@ -45,8 +45,8 @@
+            if (adamping < .2f) {
REM ****************
+                adamping = .2f;
:set_mod_args
+           }
+           info.pObjects[i]->SetDamping(&damping, &damping);
-if not exist %sourcesdk%\bin\shadercompile.exe goto NoShaderCompile
                }
-set ChangeToDir=%sourcesdk%\bin
                GetBreakParams( ballsocket.constraint, info );
+if not exist "%sourcesdk%\bin\shadercompile.exe" goto NoShaderCompile
                ballsocket.constraint.torqueLimit = 0;
+set ChangeToDir="%sourcesdk%\bin"
if /i "%4" NEQ "-source" goto NoSourceDirSpecified
set SrcDirBase=%~5
@@ -75,7 +75,7 @@
:NoShaderCompile
echo -
-echo - ERROR: shadercompile.exe doesn't exist in %sourcesdk%\bin
+echo - ERROR: shadercompile.exe doesn't exist in "%sourcesdk%\bin"
echo -
goto end
@@ -129,7 +129,7 @@
REM ****************
REM Execute distributed process on work/build list
REM ****************
-"%SrcDirBase%\devtools\bin\perl" "%SrcDirBase%\materialsystem\stdshaders\runvmpi.pl" %xbox_args% -changetodir "%ChangeToDir%" %SDKArgs%
+"%SrcDirBase%\devtools\bin\perl" "%SrcDirBase%\materialsystem\stdshaders\runvmpi.pl" %xbox_args% -changetodir %ChangeToDir% %SDKArgs%
REM ****************
REM Copy the generated files to the output dir.
</pre>
</pre>


== Wall Boosting Exploit ==
=== runvmpi.pl ===
 
<pre>
Hi, everyone would of no doubt noticed that running against a wall(strafing and moving forward works best) makes you run really fast. If anyone has played kreedz climbing yet(I used to code for it) you might of noticed moving against walls is jerky. I think when I was adding some things to the movement I made the server and client disagree on what speed the player is moving at. Has anyone sound why players in source do this? where the boost might be clamped to normal levels? If so I'd love to know, and it would be good to know for bg2 as well, people who play it complain a lot of it
--- mod/src/materialsystem/stdshaders/runvmpi.pl 2005-07-14 10:00:34.000000000 -0500
as well(just the boost, not client prediction jerks).
+++ mod/src/materialsystem/stdshaders/runvmpi.pl 2005-10-11 22:34:02.000000000 -0500
@@ -41,7 +41,7 @@
$shaderpath =~ s,/,\\,g;
chdir $changeToDir;
-$cmdToRun = "shadercompile.exe $noMPI $xboxFlag -shaderpath $shaderpath -mpi_workercount 32 -allowdebug $gameFlag";
+$cmdToRun = "shadercompile.exe $noMPI $xboxFlag -shaderpath \"$shaderpath\" -mpi_workercount 32 -allowdebug $gameFlag";
system $cmdToRun;
# other options..
</pre>
 
=== build_sample_shaders.bat ===
<pre>
--- mod/src/sdkshaders/build_sample_shaders.bat 2005-07-14 09:57:02.000000000 -0500
+++ mod/src/sdkshaders/build_sample_shaders.bat 2005-10-11 23:38:18.000000000 -0500
@@ -9,7 +9,7 @@
rem **** Call the batch files to build our stuff.
-call ..\materialsystem\stdshaders\buildshaders.bat sdk_shaders -game "%__GameDir%" -source ..
+call ..\materialsystem\stdshaders\buildshaders.bat sdk_shaders -game "%__GameDir%" -source .\..
goto end
</pre>


'''Fix Provided by [[User:Omega|Tony "omega" Sergi]]'''


mod/game_shared/gamemovement.cpp
Line 1374


<pre>
== Getting the SDK to work under -Wall -Werror ==
void CGameMovement::Accelerate( Vector& wishdir, float wishspeed, float
If you're a professional programmer with any familiarity with GNU then the first thing you probably did was attempt to compile the SDK with -Wall -Werror, and were then disappointed by all the violations in Valve's code out of the box.  Here's a list of fixes to make this work.  (This list is by no means complete - I fixed many problems before I realized this would be something worth wiki-ing.)
accel )
{
int i;
float addspeed, accelspeed, currentspeed;


// This gets overridden because some games (CSPort) want to allow dead (observer) players
I just noticed Valve uses -fpermissive!  *barf*!  So, if anyone out there had already noticed that, I now have a work in progress to fix all the scary hacks that -fpermissive would normally error on... coming soon. --[[User:Bloodykenny|Bloodykenny]] 20:46, 25 Oct 2005 (PDT)
// to be able to move around.
if ( !CanAccelerate() )
return;


//omega; WALLSTRAFE FIX
=== offsetof errors ===
These are due to [http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16618 a bug in gcc].  It was fixed in 3.4.2, and gcc 3.4.4 is now known to work fine and fixes the issue.


// See if we are changing direction a bit
=== Downcast explicitly ===
// currentspeed = mv->m_vecVelocity.Dot(wishdir);


currentspeed = sqrt( DotProduct(mv->m_vecVelocity, mv->m_vecVelocity) );
One should always [http://www.camtp.uni-mb.si/books/Thinking-in-C++/Chapter08.html#Index572 downcast] explicitly.  This squelches useful warnings, and self-documents your intent to downcast.
//omega; END WALLSTRAFE FIX
 
// Reduce wishspeed by the amount of veer.
</pre>


<pre>
--- mod/src/public/tier0/fasttimer.h    2005/06/11 22:14:36    1.2
+++ mod/src/public/tier0/fasttimer.h    2005/09/14 00:25:19
@@ -253,7 +253,7 @@
inline void CCycleCount::Init( float initTimeMsec )
{
        if ( g_ClockSpeedMillisecondsMultiplier > 0 )
-              m_Int64 = initTimeMsec / g_ClockSpeedMillisecondsMultiplier;
+              m_Int64 = int64(initTimeMsec / g_ClockSpeedMillisecondsMultiplier);
        else
                m_Int64 = 0;
}
</pre>


=== Poor abused templates ===
* This code fixes some badly used Memory Templates, and provides compatibility with Unix based systems.
<pre>
--- mod/src/public/tier1/utlmemory.h    2005/02/18 04:45:58    1.1.1.1
+++ mod/src/public/tier1/utlmemory.h    2005/09/14 00:24:15
@@ -293,7 +293,7 @@
{
        Assert( num > 0 );


== GNU crasher for maps with broken ladders ==
-      if (IsExternallyAllocated())
'''Fix:''' Valve's code is invalid but compiles on MSVC due to its D.W.I.M. philosophy.  The following patch is required:
+    if (CUtlMemory<T>::IsExternallyAllocated())
        {
                // Can't grow a buffer whose memory was externally allocated
                Assert(0);
@@ -349,7 +349,7 @@
        if (m_nAllocationCount >= num)
                return;


<pre>
-      if (IsExternallyAllocated())
--- mod/src/game_shared/func_ladder.cpp 2005/06/11 22:14:32    1.2
+    if (CUtlMemory<T>::IsExternallyAllocated())
+++ mod/src/game_shared/func_ladder.cpp 2006/02/12 19:43:25
        {
@@ -87,7 +87,7 @@
                // Can't grow a buffer whose memory was externally allocated
                                m_vecPlayerMountPositionBottom.GetZ(),
                Assert(0);
                                bottomtrace.m_pEnt
@@ -376,7 +376,7 @@
                                        ?
template< class T >
-                                       UTIL_VarArgs( "%s/%s", bottomtrace.m_pEnt->GetClassname(), bottomtrace.m_pEnt->GetEntityName() )
void CUtlMemory<T>::Purge()
+                                       UTIL_VarArgs( "%s/%s", bottomtrace.m_pEnt->GetClassname(), STRING(bottomtrace.m_pEnt->GetEntityName()) )
{
                                        :
-       if (!IsExternallyAllocated())
                                        "NULL" );
+   if (!CUtlMemory<T>::IsExternallyAllocated())
                 }
        {
@@ -99,7 +99,7 @@
                if (m_pMemory)
                                m_vecPlayerMountPositionTop.GetZ(),
                 {
                                toptrace.m_pEnt
@@ -495,7 +495,7 @@
                                        ?
{
-                                      UTIL_VarArgs( "%s/%s", toptrace.m_pEnt->GetClassname(), toptrace.m_pEnt->GetEntityName() )
        Assert( num > 0 );
+                                      UTIL_VarArgs( "%s/%s", toptrace.m_pEnt->GetClassname(), STRING(toptrace.m_pEnt->GetEntityName()) )
                                        :
                                        "NULL" );
                }
</pre>


== sdkshaders: fix for spaces in path ==
-      if (IsExternallyAllocated())
Issue: Any attempt to compile the SDK shaders for a mod with spaces in the path name results in failure:  
+    if (CUtlMemory<T>::IsExternallyAllocated())
        {
                // Can't grow a buffer whose memory was externally allocated
                Assert(0);
@@ -551,7 +551,7 @@
        if (CUtlMemory<T>::m_nAllocationCount >= num)
                return;


(ie: "C:\Program Files\Steam\SteamApps\SourceMods\MODNAME\src\src\sdkshaders")  
-      if (IsExternallyAllocated())
 
+    if (CUtlMemory<T>::IsExternallyAllocated())
This is due to the fact that the perl scripts and bat files have not been properly modified to handle spaces in the path.
        {
                // Can't grow a buffer whose memory was externally allocated
                Assert(0);
@@ -579,7 +579,7 @@
template< class T, int nAlignment >
void CUtlMemoryAligned<T, nAlignment>::Purge()
{
-      if (!IsExternallyAllocated())
+    if (!CUtlMemory<T>::IsExternallyAllocated())
        {
                if (m_pMemoryBase)
                {
</pre>


=== Missing EOF linefeeds ===


'''Fix:''' [[User:Visualphoenix|Ray "VisualPhoenix" Barbiero]] has provided the following patches:
First you'll need to `cvs rm -f mod/src/dlls/worker_scientist.h` since that file is blank, unused, and will make the script below not run. :)


{{note|These patches have been tested on paths with and without spaces.}}
Then run:


=== updateshaders.pl ===
<pre>
<pre>
--- mod/src/devtools/bin/updateshaders.pl 2005-07-14 09:58:54.000000000 -0500
#!/usr/bin/perl -w
+++ mod/src/devtools/bin/updateshaders.pl 2005-10-11 23:42:36.000000000 -0500
 
@@ -105,7 +105,7 @@
use strict;
{
foreach (`find mod -name *.cpp -or -name *.h`) {
$xboxswitch = "-xbox ";
    chomp;
}
    open(F, "+<", $_) or die "$! on $_";
- print MAKEFILE "\t$g_SourceDir\\devtools\\bin\\perl.exe $g_SourceDir\\devtools\\bin\\" . $shadertype . "_prep.pl $xboxswitch -shaderoutputdir $shaderoutputdir -source \"$g_SourceDir\" $shadername\n";
    seek(F, -1, 2) or die "$! on $_";
+ print MAKEFILE "\t\"$g_SourceDir\\devtools\\bin\\perl.exe\" \"$g_SourceDir\\devtools\\bin\\" . $shadertype . "_prep.pl\" $xboxswitch -shaderoutputdir $shaderoutputdir -source \"$g_SourceDir\" $shadername\n";
    my $c;
my $filename;
    read(F, $c, 1) or die "$! on $_";
if( $shadertype eq "fxc" )
    if ($c ne "\n") {
{
        print "$_\n";
@@ -199,14 +199,14 @@
        print(F "\n");
# We only generate inc files for fxc and vsh files.
    }
if( $g_xbox )
}
{
</pre>
- print MAKEFILE " $shadertype" . "tmp_xbox\\" . $shaderbase . "\.inc";
 
+ print MAKEFILE " \"$shadertype" . "tmp_xbox\\" . $shaderbase . "\.inc\"";
=== Garbage after #endifs ===
}
 
else
A common mistake in the SDK, obviously trivial to fix, but here for your conveniance:
{
 
- print MAKEFILE " $shadertype" . "tmp9\\" . $shaderbase . "\.inc";
<pre>
+ print MAKEFILE " \"$shadertype" . "tmp9\\" . $shaderbase . "\.inc\"";
diff -w -u -r1.3 ai_basenpc.cpp
}
--- dlls/ai_basenpc.cpp 2005/06/11 22:14:26    1.3
}
+++ dlls/ai_basenpc.cpp 2005/09/10 18:16:13
- print MAKEFILE " $shaderoutputdir\\$shadertype\\$shaderbase\.vcs";
@@ -8450,7 +8450,7 @@
+ print MAKEFILE " \"$shaderoutputdir\\$shadertype\\$shaderbase\.vcs\"";
 
        return shotDir;
  }
  }
  print MAKEFILE "\n\n";
-#endif HL2_DLL
+#endif // HL2_DLL
@@ -221,11 +221,11 @@
 
# We only generate inc files for fxc and vsh files.
  //-----------------------------------------------------------------------------
if( $g_xbox )
 
{
 
- print MAKEFILE "\tdel /f /q $shadertype" . "tmp_xbox\\" . $shaderbase . "\.inc\n";
 
+ print MAKEFILE "\tdel /f /q \"$shadertype" . "tmp_xbox\\" . $shaderbase . "\.inc\"\n";
diff -w -u -r1.1.1.1 npc_BaseZombie.cpp
}
--- dlls/hl2_dll/npc_BaseZombie.cpp    2005/02/18 04:45:52    1.1.1.1
else
+++ dlls/hl2_dll/npc_BaseZombie.cpp    2005/09/10 20:57:40
{
@@ -1582,7 +1582,7 @@
- print MAKEFILE "\tdel /f /q $shadertype" . "tmp9\\" . $shaderbase . "\.inc\n";
 
+ print MAKEFILE "\tdel /f /q \"$shadertype" . "tmp9\\" . $shaderbase . "\.inc\"\n";
#ifdef DEBUG_ZOMBIES
}
                        DevMsg("Wandering\n");
}
-#endif+
print MAKEFILE "\tdel /f /q \"$shaderoutputdir\\$shadertype\\$shaderbase\.vcs\"\n";
+#endif
</pre>
 
                        // Just lost track of our enemy.
                        // Wander around a bit so we don't look like a dingus.
 
 
 
diff -w -u -r1.2 memalloc.h
--- public/tier0/memalloc.h    2005/02/19 18:24:26    1.2
+++ public/tier0/memalloc.h    2005/09/10 05:12:39
@@ -133,6 +133,6 @@
#define MEM_ALLOC_CREDIT_CLASS()
#define MEM_ALLOC_CLASSNAME(type) NULL
 
-#endif !STEAM && NO_MALLOC_OVERRIDE
+#endif // !STEAM && NO_MALLOC_OVERRIDE
 
#endif /* TIER0_MEMALLOC_H */
 
 


=== buildshaders.bat ===
<pre>
--- mod/src/materialsystem/stdshaders/buildshaders.bat 2005-07-14 10:00:36.000000000 -0500
+++ mod/src/materialsystem/stdshaders/buildshaders.bat 2005-10-11 23:01:08.000000000 -0500
@@ -36,7 +36,7 @@
REM ****************
:set_xbox_args
set xbox_args=-xbox
-set targetdir=%vproject%\shaders_xbox
+set targetdir="%vproject%\shaders_xbox"
goto build_shaders
@@ -45,8 +45,8 @@
REM ****************
:set_mod_args
-if not exist %sourcesdk%\bin\shadercompile.exe goto NoShaderCompile
-set ChangeToDir=%sourcesdk%\bin
+if not exist "%sourcesdk%\bin\shadercompile.exe" goto NoShaderCompile
+set ChangeToDir="%sourcesdk%\bin"
if /i "%4" NEQ "-source" goto NoSourceDirSpecified
set SrcDirBase=%~5
@@ -75,7 +75,7 @@
:NoShaderCompile
echo -
-echo - ERROR: shadercompile.exe doesn't exist in %sourcesdk%\bin
+echo - ERROR: shadercompile.exe doesn't exist in "%sourcesdk%\bin"
echo -
goto end
@@ -129,7 +129,7 @@
REM ****************
REM Execute distributed process on work/build list
REM ****************
-"%SrcDirBase%\devtools\bin\perl" "%SrcDirBase%\materialsystem\stdshaders\runvmpi.pl" %xbox_args% -changetodir "%ChangeToDir%" %SDKArgs%
+"%SrcDirBase%\devtools\bin\perl" "%SrcDirBase%\materialsystem\stdshaders\runvmpi.pl" %xbox_args% -changetodir %ChangeToDir% %SDKArgs%
REM ****************
REM Copy the generated files to the output dir.
</pre>
</pre>


=== runvmpi.pl ===
<pre>
--- mod/src/materialsystem/stdshaders/runvmpi.pl 2005-07-14 10:00:34.000000000 -0500
+++ mod/src/materialsystem/stdshaders/runvmpi.pl 2005-10-11 22:34:02.000000000 -0500
@@ -41,7 +41,7 @@
$shaderpath =~ s,/,\\,g;
chdir $changeToDir;
-$cmdToRun = "shadercompile.exe $noMPI $xboxFlag -shaderpath $shaderpath -mpi_workercount 32 -allowdebug $gameFlag";
+$cmdToRun = "shadercompile.exe $noMPI $xboxFlag -shaderpath \"$shaderpath\" -mpi_workercount 32 -allowdebug $gameFlag";
system $cmdToRun;
# other options..
</pre>


=== build_sample_shaders.bat ===
=== snprintf strangeness ===
 
There are several conflicting snprintf defines and other snprintf porting bugs in the SDK, which need to be fixed for Werror compatibility:
 
<pre>
<pre>
--- mod/src/sdkshaders/build_sample_shaders.bat 2005-07-14 09:57:02.000000000 -0500
diff -w -u -r1.1.1.1 interface.h
+++ mod/src/sdkshaders/build_sample_shaders.bat 2005-10-11 23:38:18.000000000 -0500
--- public/tier1/interface.h    2005/02/18 04:45:58    1.1.1.1
@@ -9,7 +9,7 @@
+++ public/tier1/interface.h    2005/09/10 06:09:25
@@ -33,8 +33,6 @@
   
 
  rem **** Call the batch files to build our stuff.
  #define HMODULE void *
-call ..\materialsystem\stdshaders\buildshaders.bat sdk_shaders -game "%__GameDir%" -source ..
  #define GetProcAddress dlsym
+call ..\materialsystem\stdshaders\buildshaders.bat sdk_shaders -game "%__GameDir%" -source .\..
-
  goto end
-#define _snprintf snprintf
</pre>
  #endif


// TODO: move interface.cpp into tier0 library.




== Getting the SDK to work under -Wall -Werror ==
If you're a professional programmer with any familiarity with GNU then the first thing you probably did was attempt to compile the SDK with -Wall -Werror, and were then disappointed by all the violations in Valve's code out of the box.  Here's a list of fixes to make this work.  (This list is by no means complete - I fixed many problems before I realized this would be something worth wiki-ing.)


I just noticed Valve uses -fpermissive!  *barf*!  So, if anyone out there had already noticed that, I now have a work in progress to fix all the scary hacks that -fpermissive would normally error on... coming soon. --[[User:Bloodykenny|Bloodykenny]] 20:46, 25 Oct 2005 (PDT)
diff -w -u -r1.1.1.1 interface.cpp
--- tier1/interface.cpp 2005/02/18 04:45:59    1.1.1.1
+++ tier1/interface.cpp 2005/09/10 21:18:20
@@ -191,7 +191,7 @@
                Q_snprintf( str, sizeof(str), "%s.dll", szAbsoluteModuleName );
                hDLL = LoadLibrary( str );
#elif _LINUX
-              _snprintf( str, sizeof(str), "%s_i486.so", szAbsoluteModuleName );
+              Q_snprintf( str, sizeof(str), "%s_i486.so", szAbsoluteModuleName );
                hDLL = dlopen(str, RTLD_NOW);
#endif
</pre>


=== offsetof errors ===
=== Broken comments ===
These are due to [http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16618 a bug in gcc].  It was fixed in 3.4.2, and gcc 3.4.4 is now known to work fine and fixes the issue.


=== Downcast explicitly ===
Ending a // comment with \ is just begging for trouble...


One should always [http://www.camtp.uni-mb.si/books/Thinking-in-C++/Chapter08.html#Index572 downcast] explicitly.  This squelches useful warnings, and self-documents your intent to downcast.
<pre>
diff -w -u -r1.1.1.1 collisionutils.cpp
--- public/collisionutils.cpp  2005/02/18 04:45:56    1.1.1.1
+++ public/collisionutils.cpp  2005/09/10 23:59:09
@@ -2299,7 +2299,7 @@


<pre>
         return true;
--- mod/src/public/tier0/fasttimer.h    2005/06/11 22:14:36    1.2
+++ mod/src/public/tier0/fasttimer.h    2005/09/14 00:25:19
@@ -253,7 +253,7 @@
inline void CCycleCount::Init( float initTimeMsec )
{
         if ( g_ClockSpeedMillisecondsMultiplier > 0 )
-              m_Int64 = initTimeMsec / g_ClockSpeedMillisecondsMultiplier;
+              m_Int64 = int64(initTimeMsec / g_ClockSpeedMillisecondsMultiplier);
        else
                m_Int64 = 0;
  }
  }
</pre>
-
 
+/*
=== Poor abused templates ===
//--------------------------------------------------------------------------
* This code fixes some badly used Memory Templates, and provides compatibility with Unix based systems.
// Purpose:
<pre>
//
--- mod/src/public/tier1/utlmemory.h    2005/02/18 04:45:58    1.1.1.1
@@ -2314,7 +2314,7 @@
+++ mod/src/public/tier1/utlmemory.h    2005/09/14 00:24:15
  //    0-----2
@@ -293,7 +293,7 @@
//
  {
//--------------------------------------------------------------------------
        Assert( num > 0 );
-
+*/
//-----------------------------------------------------------------------------
// Purpose: find the minima and maxima of the 3 given values
//-----------------------------------------------------------------------------
</pre>
 
=== First big pass at -Wall and consistent code ===
Convert stricmp, _alloca etc to Q_stricmp, stackalloc versions.  Fix basetype declarations like 0 to 0.0f when appropriate.  Comply with STL min/max.  Comply with POSIX/BSD naming inline (and appropriate #ifdefing) in all cases where a cross-platform compatibility utility function does not yet exist.


-       if (IsExternallyAllocated())
You'll need to remove the inappropriate -D defines in the Makefile for the str/printf/alloc things.  Those are now fixed by using the correct functions in the code to begin with, however I don't have a patch for the Makefile included in the file below.
+    if (CUtlMemory<T>::IsExternallyAllocated())
        {
                // Can't grow a buffer whose memory was externally allocated
                Assert(0);
@@ -349,7 +349,7 @@
        if (m_nAllocationCount >= num)
                return;


-       if (IsExternallyAllocated())
I have uploaded this file for BloodKenny at -
+    if (CUtlMemory<T>::IsExternallyAllocated())
        {
                // Can't grow a buffer whose memory was externally allocated
                Assert(0);
@@ -376,7 +376,7 @@
template< class T >
void CUtlMemory<T>::Purge()
{
-      if (!IsExternallyAllocated())
+    if (!CUtlMemory<T>::IsExternallyAllocated())
        {
                if (m_pMemory)
                {
@@ -495,7 +495,7 @@
{
        Assert( num > 0 );


-      if (IsExternallyAllocated())
http://www.nigredostudios.com/temp/patch_hl2_sdk_wall_sanity.txt
+    if (CUtlMemory<T>::IsExternallyAllocated())
        {
                // Can't grow a buffer whose memory was externally allocated
                Assert(0);
@@ -551,7 +551,7 @@
        if (CUtlMemory<T>::m_nAllocationCount >= num)
                return;


-       if (IsExternallyAllocated())
Right click save as - amckern
+    if (CUtlMemory<T>::IsExternallyAllocated())
 
        {
Second pass - fix unreliable and error/warning prone min/max/clamp macros with STL calls and normal templatization:
                // Can't grow a buffer whose memory was externally allocated
                Assert(0);
@@ -579,7 +579,7 @@
template< class T, int nAlignment >
void CUtlMemoryAligned<T, nAlignment>::Purge()
{
-      if (!IsExternallyAllocated())
+    if (!CUtlMemory<T>::IsExternallyAllocated())
        {
                if (m_pMemoryBase)
                {
</pre>


=== Missing EOF linefeeds ===
http://aoa.gamemod.net/patch-warning-minmax.txt


First you'll need to `cvs rm -f mod/src/dlls/worker_scientist.h` since that file is blank, unused, and will make the script below not run. :)
== Server: Host_Error: SV_PackEntity: SendTable_Encode returned false (ent %d). ==
Here %d will be replaced by whatever the entity number is that caused the error.  No single entity is allowed to write more than 2KB to the network stream.  This error happens when an entity overflows that buffer.


Then run:
'''Fix:'''  If you need an entity to occasionally transmit more than 2K of data, you will need to split it up into multiple entities, each transmitting part of the data.  You should ensure of course that no entity -consistently- transmits 2K of data, as it would bog down your network.  Some entities might want to send a large amount on map initialization etc, however.  Another possible workaround for some situations (may not always be possible), is to update data a little bit each frame, so that no one frame has a big change.


<pre>
== Server: The client's health variable is pointlessly sent across the wire twice. ==
#!/usr/bin/perl -w


use strict;
'''Fix:''' [[Diff And Patch]]
foreach (`find mod -name *.cpp -or -name *.h`) {
    chomp;
    open(F, "+<", $_) or die "$! on $_";
    seek(F, -1, 2) or die "$! on $_";
    my $c;
    read(F, $c, 1) or die "$! on $_";
    if ($c ne "\n") {
        print "$_\n";
        print(F "\n");
    }
}
</pre>


=== Garbage after #endifs ===
* There is no line 1888 within c_baseplayer.cpp in the stock MP, or SP SDK's - do i just tack the code onto the end (The BaseClass::SetGroundEntity(ground); is also not there) --[[User:Amckern|Amckern]] 22:46, 5 Nov 2005 (PST)


A common mistake in the SDK, obviously trivial to fix, but here for your conveniance:
Ah, sorry.  That patch was against an already-modified file, not a fresh SDK.  The SetGroundEntity is part of my mod. :)  Yes tack it onto the end.  After you do so, post the diff back here!  --[[User:Bloodykenny|Bloodykenny]] 09:25, 12 Nov 2005 (PST)


<pre>
<pre>
diff -w -u -r1.3 ai_basenpc.cpp
--- mod/src/cl_dll/c_baseplayer.cpp     2005/06/30 05:54:09     1.6
--- dlls/ai_basenpc.cpp 2005/06/11 22:14:26     1.3
+++ mod/src/cl_dll/c_baseplayer.cpp     2005/07/16 21:33:33
+++ dlls/ai_basenpc.cpp 2005/09/10 18:16:13
@@ -1888,3 +1888,7 @@
@@ -8450,7 +8450,7 @@
    BaseClass::SetGroundEntity(ground);
}


        return shotDir;
+
}
+int C_BasePlayer::GetHealth() const {
-#endif HL2_DLL
+    return g_PR->GetHealth(entindex());
+#endif // HL2_DLL
+}


//-----------------------------------------------------------------------------




--- mod/src/cl_dll/c_baseplayer.h      2005/07/11 03:28:41    1.9
+++ mod/src/cl_dll/c_baseplayer.h      2005/07/16 21:05:31
@@ -103,7 +103,7 @@


diff -w -u -r1.1.1.1 npc_BaseZombie.cpp
        // Data handlers
--- dlls/hl2_dll/npc_BaseZombie.cpp    2005/02/18 04:45:52    1.1.1.1
        virtual bool    IsPlayer( void ) const { return true; };
+++ dlls/hl2_dll/npc_BaseZombie.cpp    2005/09/10 20:57:40
-       virtual int            GetHealth() const { return m_iHealth; };
@@ -1582,7 +1582,7 @@
+       virtual int            GetHealth() const;


#ifdef DEBUG_ZOMBIES
        // observer mode
                        DevMsg("Wandering\n");
        virtual int                    GetObserverMode() const;
-#endif+
+#endif


                        // Just lost track of our enemy.
                        // Wander around a bit so we don't look like a dingus.




--- mod/src/dlls/player.cpp    2005/07/12 07:38:04    1.33
+++ mod/src/dlls/player.cpp    2005/07/22 00:45:48
@@ -58,6 +58,8 @@
#include "nav_mesh.h"
#include "env_zoom.h"


diff -w -u -r1.2 memalloc.h
+#include "player_resource.h"
--- public/tier0/memalloc.h     2005/02/19 18:24:26    1.2
+
+++ public/tier0/memalloc.h     2005/09/10 05:12:39
#ifdef HL2_DLL
@@ -133,6 +133,6 @@
#include "combine_mine.h"
#define MEM_ALLOC_CREDIT_CLASS()
#include "weapon_physcannon.h"
#define MEM_ALLOC_CLASSNAME(type) NULL
@@ -4295,6 +4297,9 @@
 
        m_lastx = m_lasty = 0;
-#endif !STEAM && NO_MALLOC_OVERRIDE
+#endif // !STEAM && NO_MALLOC_OVERRIDE


#endif /* TIER0_MEMALLOC_H */
        m_lastNavArea = NULL;
+
+    // update now so that our new health gets sent with the respawn notice
+    g_pPlayerResource->SetPlayerHealth(entindex(), m_iHealth);


        /// @todo Do this once per round instead of once per player
        if (TheNavMesh)




</pre>


--- mod/src/dlls/player_resource.cpp    2005/06/19 02:54:04    1.5
+++ mod/src/dlls/player_resource.cpp    2005/07/22 00:44:35
@@ -85,6 +85,13 @@
}


=== snprintf strangeness ===
//-----------------------------------------------------------------------------
 
+// Purpose: Sets health value for a particular client (used to set on spawn so the data will be sent synchronously)
There are several conflicting snprintf defines and other snprintf porting bugs in the SDK, which need to be fixed for Werror compatibility:
+//-----------------------------------------------------------------------------
+void CPlayerResource::SetPlayerHealth(int entindex, int health) {
+    m_iHealth.Set(entindex, health);
+}
+
+//-----------------------------------------------------------------------------
// Purpose: The Player resource is always transmitted to clients
//-----------------------------------------------------------------------------
int CPlayerResource::UpdateTransmitState()


<pre>
diff -w -u -r1.1.1.1 interface.h
--- public/tier1/interface.h    2005/02/18 04:45:58    1.1.1.1
+++ public/tier1/interface.h    2005/09/10 06:09:25
@@ -33,8 +33,6 @@


#define HMODULE void *
#define GetProcAddress dlsym
-
-#define _snprintf snprintf
#endif


// TODO: move interface.cpp into tier0 library.
--- mod/src/dlls/player_resource.h      2005/06/18 21:16:29    1.3
+++ mod/src/dlls/player_resource.h      2005/07/22 00:42:57
@@ -26,6 +26,8 @@
        virtual void UpdatePlayerData( void );
        virtual int  UpdateTransmitState(void);


 
+   void SetPlayerHealth(int entindex, int health);
 
+
diff -w -u -r1.1.1.1 interface.cpp
  protected:
--- tier1/interface.cpp 2005/02/18 04:45:59    1.1.1.1
        // Data for each player that's propagated to all clients
+++ tier1/interface.cpp 2005/09/10 21:18:20
        // Stored in individual arrays so they can be sent down via datatables
@@ -191,7 +191,7 @@
                Q_snprintf( str, sizeof(str), "%s.dll", szAbsoluteModuleName );
                hDLL = LoadLibrary( str );
  #elif _LINUX
-              _snprintf( str, sizeof(str), "%s_i486.so", szAbsoluteModuleName );
+              Q_snprintf( str, sizeof(str), "%s_i486.so", szAbsoluteModuleName );
                hDLL = dlopen(str, RTLD_NOW);
#endif
</pre>
</pre>


=== Broken comments ===
Then you can remove the SendPropInt and RecvPropInt for CBasePlayer::m_iHealth...
 
Ending a // comment with \ is just begging for trouble...


<pre>
<pre>
diff -w -u -r1.1.1.1 collisionutils.cpp
--- src/cl_dll/c_baseplayer.cpp 26 Aug 2006 21:24:21 -0000 1.14
--- public/collisionutils.cpp   2005/02/18 04:45:56    1.1.1.1
+++ src/cl_dll/c_baseplayer.cpp 4 Sep 2006 18:33:46 -0000
+++ public/collisionutils.cpp   2005/09/10 23:59:09
@@ -222,7 +222,7 @@
@@ -2299,7 +2299,7 @@
RecvPropEHandle( RECVINFO(m_hVehicle) ),
RecvPropEHandle( RECVINFO(m_hUseEntity) ),
- RecvPropInt (RECVINFO(m_iHealth)),
+ // RecvPropInt (RECVINFO(m_iHealth)),
RecvPropInt (RECVINFO(m_lifeState)),
RecvPropFloat (RECVINFO(m_flMaxspeed)),
@@ -284,7 +284,7 @@
DEFINE_PRED_FIELD( m_hVehicle, FIELD_EHANDLE, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD_TOL( m_flMaxspeed, FIELD_FLOAT, FTYPEDESC_INSENDTABLE, 0.5f ),
- DEFINE_PRED_FIELD( m_iHealth, FIELD_INTEGER, FTYPEDESC_INSENDTABLE ),
+ // DEFINE_PRED_FIELD( m_iHealth, FIELD_INTEGER, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_fOnTarget, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_nNextThinkTick, FIELD_INTEGER, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_lifeState, FIELD_CHARACTER, FTYPEDESC_INSENDTABLE ),


        return true;
}
-
+/*
//--------------------------------------------------------------------------
// Purpose:
//
@@ -2314,7 +2314,7 @@
//    0-----2
//
//--------------------------------------------------------------------------
-
+*/
//-----------------------------------------------------------------------------
// Purpose: find the minima and maxima of the 3 given values
//-----------------------------------------------------------------------------
</pre>


=== First big pass at -Wall and consistent code ===
--- src/cl_dll/c_baseplayer.h 26 Aug 2006 21:24:21 -0000 1.19
Convert stricmp, _alloca etc to Q_stricmp, stackalloc versions. Fix basetype declarations like 0 to 0.0f when appropriate.  Comply with STL min/max. Comply with POSIX/BSD naming inline (and appropriate #ifdefing) in all cases where a cross-platform compatibility utility function does not yet exist.
+++ src/cl_dll/c_baseplayer.h 4 Sep 2006 18:33:46 -0000
@@ -377,7 +377,7 @@
EHANDLE m_hUseEntity;
float m_flMaxspeed;
- int m_iHealth;
+ void m_iHealth(); // hide the base class m_iHealth to ensure it's not used
CInterpolatedVar< Vector > m_iv_vecViewOffset;


You'll need to remove the inappropriate -D defines in the Makefile for the str/printf/alloc things.  Those are now fixed by using the correct functions in the code to begin with, however I don't have a patch for the Makefile included in the file below.


I have uploaded this file for BloodKenny at -
--- src/dlls/player.cpp 3 Sep 2006 23:29:16 -0000 1.76
+++ src/dlls/player.cpp 4 Sep 2006 18:33:47 -0000
@@ -7298,7 +7298,7 @@
SendPropDataTable(SENDINFO_DT(pl), &REFERENCE_SEND_TABLE(DT_PlayerState), SendProxy_DataTableToDataTable),
SendPropEHandle(SENDINFO(m_hVehicle)),
SendPropEHandle(SENDINFO(m_hUseEntity)),
- SendPropInt (SENDINFO(m_iHealth), 10 ),
+ // SendPropInt (SENDINFO(m_iHealth), 10 ),
SendPropInt (SENDINFO(m_lifeState), 3, SPROP_UNSIGNED ),
SendPropFloat (SENDINFO(m_flMaxspeed), 12, SPROP_ROUNDDOWN, 0.0f, 2048.0f ),  // CL
SendPropInt (SENDINFO(m_fFlags), PLAYER_FLAG_BITS, SPROP_UNSIGNED|SPROP_CHANGES_OFTEN, SendProxy_CropFlagsToPlayerFlagBitsLength ),


http://www.nigredostudios.com/temp/patch_hl2_sdk_wall_sanity.txt


http://www.noballs.org/downloads/patch_hl2_sdk_wall_sanity.txt
--- src/game_shared/gamemovement.cpp 26 Aug 2006 21:24:36 -0000 1.21
+++ src/game_shared/gamemovement.cpp 4 Sep 2006 18:33:47 -0000
@@ -490,7 +490,7 @@
bool CGameMovement::IsDead( void ) const
{
- return ( player->m_iHealth <= 0 ) ? true : false;
+ return ( player->GetHealth() <= 0 ) ? true : false;
}
//-----------------------------------------------------------------------------
</pre>


http://www.ammahls.com/downloads/patch_hl2_sdk_wall_sanity.txt
== Server: The client's team membership is pointlessly sent across the wire twice. ==


Right click save as - amckern
Similar to the above KI, but for another variable.  Also this fixes an SDK crasher, but according to Yahn at Valve, Steam will be fixed soon to not do that.


Second pass - fix unreliable and error/warning prone min/max/clamp macros with STL calls and normal templatization:
'''Fix:''' [[Diff And Patch]]


http://aoa.gamemod.net/patch-warning-minmax.txt
<pre>
--- mod/src/dlls/team.cpp      2005/06/11 22:14:30    1.2
+++ mod/src/dlls/team.cpp      2006/05/29 18:58:52    1.3
@@ -19,6 +19,7 @@
//-----------------------------------------------------------------------------
void SendProxy_PlayerList( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID )
{
+    Assert(0);
        CTeam *pTeam = (CTeam*)pData;


        // If this assertion fails, then SendProxyArrayLength_PlayerArray must have failed.
@@ -31,8 +32,11 @@


int SendProxyArrayLength_PlayerArray( const void *pStruct, int objectID )
{
-      CTeam *pTeam = (CTeam*)pStruct;
-      return pTeam->m_aPlayers.Count();
+    // The RecvPropArray2 in general was seemingly broken in the May 25th-ish core engine update.
+    // The CTeam in particular was certainly broken at that time, however, thankfully it doesn't
+    // serve any important purpose.
+    // For backwards compatibility with old client, we disable it, rather than remove it entirely.
+    return 0;
}
</pre>


== Server: Host_Error: SV_PackEntity: SendTable_Encode returned false (ent %d). ==
== Server: weapon_citizensuitcase Assert on startup ==
Here %d will be replaced by whatever the entity number is that caused the error.  No single entity is allowed to write more than 2KB to the network stream.  This error happens when an entity overflows that buffer.
 
'''Fix:'''  If you need an entity to occasionally transmit more than 2K of data, you will need to split it up into multiple entities, each transmitting part of the data.  You should ensure of course that no entity -consistently- transmits 2K of data, as it would bog down your network.  Some entities might want to send a large amount on map initialization etc, however.  Another possible workaround for some situations (may not always be possible), is to update data a little bit each frame, so that no one frame has a big change.
 
== Server: The client's health variable is pointlessly sent across the wire twice. ==


'''Fix:''' [[Diff And Patch]]
'''Fix:''' Install copy of the SP SDK, then copy the scripts/ directory over


* There is no line 1888 within c_baseplayer.cpp in the stock MP, or SP SDK's - do i just tack the code onto the end (The BaseClass::SetGroundEntity(ground); is also not there) --[[User:Amckern|Amckern]] 22:46, 5 Nov 2005 (PST)
== Server: Some bullet weapons set to do 0 damage. ==


Ah, sorry.  That patch was against an already-modified file, not a fresh SDK.  The SetGroundEntity is part of my mod. :)  Yes tack it onto the end. After you do so, post the diff back here!  --[[User:Bloodykenny|Bloodykenny]] 09:25, 12 Nov 2005 (PST)
'''Fix:''' Need to edit their AddAmmoType which are strangely set to 0 for some reason.  


<pre>
== Server: Some projectile weapons set to do 0 damage. ==
--- mod/src/cl_dll/c_baseplayer.cpp    2005/06/30 05:54:09    1.6
+++ mod/src/cl_dll/c_baseplayer.cpp    2005/07/16 21:33:33
@@ -1888,3 +1888,7 @@
    BaseClass::SetGroundEntity(ground);
}


+
'''Fix:''' Need to edit their source files and set a damage.
+int C_BasePlayer::GetHealth() const {
+    return g_PR->GetHealth(entindex());
+}


== Client: --- Missing Vgui material vgui/steam/games/icon_cz ==


'''Fix:''' These files are used in the currently inaccessible Friends IM client. Create 4 vmts in their places of any design to remove the error.


--- mod/src/cl_dll/c_baseplayer.h      2005/07/11 03:28:41    1.9
* materials\VGUI\steam\games\icon_cs.vmt
+++ mod/src/cl_dll/c_baseplayer.h      2005/07/16 21:05:31
* materials\VGUI\steam\games\icon_dod.vmt
@@ -103,7 +103,7 @@
* materials\VGUI\steam\games\icon_hl2mp.vmt
* materials\VGUI\servers\icon_secure_deny.vmt


        // Data handlers
Here's a patch to create files for the first three. (I don't see the icon_secure_deny.vmt error, so didn't create anything for it.)
        virtual bool    IsPlayer( void ) const { return true; };
-      virtual int            GetHealth() const { return m_iHealth; };
+      virtual int            GetHealth() const;


        // observer mode
<pre>
        virtual int                    GetObserverMode() const;
--- materials/VGUI/steam/games/icon_cs.vmt      1969-12-31 18:00:00.000000000 -0600
 
+++ materials/VGUI/steam/games/icon_cs.vmt      2005-07-28 01:54:17.000000000 -0500
 
@@ -0,0 +1 @@
 
+"UnlitGeneric" {}
--- mod/src/dlls/player.cpp     2005/07/12 07:38:04    1.33
--- materials/VGUI/steam/games/icon_dod.vmt    1969-12-31 18:00:00.000000000 -0600
+++ mod/src/dlls/player.cpp    2005/07/22 00:45:48
+++ materials/VGUI/steam/games/icon_dod.vmt     2005-07-28 01:54:19.000000000 -0500
@@ -58,6 +58,8 @@
@@ -0,0 +1 @@
#include "nav_mesh.h"
+"UnlitGeneric" {}
#include "env_zoom.h"
--- materials/VGUI/steam/games/icon_hl2mp.vmt  1969-12-31 18:00:00.000000000 -0600
+++ materials/VGUI/steam/games/icon_hl2mp.vmt  2005-07-28 01:54:15.000000000 -0500
@@ -0,0 +1 @@
+"UnlitGeneric" {}
</pre>


+#include "player_resource.h"
'''Fix2:''' Add clear to your rc file in cfg (extract from gcf if non-existant)
+
#ifdef HL2_DLL
#include "combine_mine.h"
#include "weapon_physcannon.h"
@@ -4295,6 +4297,9 @@
        m_lastx = m_lasty = 0;


        m_lastNavArea = NULL;
== Server: The crossbow causes an assertion failure. ==
+
+    // update now so that our new health gets sent with the respawn notice
+    g_pPlayerResource->SetPlayerHealth(entindex(), m_iHealth);


        /// @todo Do this once per round instead of once per player
'''Fix:''' Comment out ai_activity.cpp line 53. This doesn't appear to be something that can be fixed in code?
        if (TheNavMesh)


== Server? Client?: RL explosion invisible ==


Per http://www.chatbear.com/board.plm?a=viewthread&t=970,1107153392,30132&id=786504&b=4991&v=flatold


--- mod/src/dlls/player_resource.cpp    2005/06/19 02:54:04     1.5
The patch to c_te_explosion.cpp was rolled into the 2006-08-04 SDK update, however it does not fix the issue. The issue still exists. My current speculation is that this is a bug in core or in the maps, but hard to say which.
+++ mod/src/dlls/player_resource.cpp    2005/07/22 00:44:35
@@ -85,6 +85,13 @@
}


//-----------------------------------------------------------------------------
== sv_gravity is not associated with physics gravity==
+// Purpose: Sets health value for a particular client (used to set on spawn so the data will be sent synchronously)
When gravity is changed, the physics gravity isn't updated
+//-----------------------------------------------------------------------------
+void CPlayerResource::SetPlayerHealth(int entindex, int health) {
+    m_iHealth.Set(entindex, health);
+}
+
+//-----------------------------------------------------------------------------
// Purpose: The Player resource is always transmitted to clients
//-----------------------------------------------------------------------------
int CPlayerResource::UpdateTransmitState()


 
'''Fix:'''
 
In movevars_shared.cpp:
--- mod/src/dlls/player_resource.h      2005/06/18 21:16:29    1.3
inline void UpdatePhysicsGravity(float gravity)
+++ mod/src/dlls/player_resource.h      2005/07/22 00:42:57
  {
@@ -26,6 +26,8 @@
if(physenv)
        virtual void UpdatePlayerData( void );
physenv->SetGravity(Vector(0,0,-gravity));
        virtual int UpdateTransmitState(void);
  }
 
  static void GravityChanged_Callback( ConVar *var, const char *pOldString )
+    void SetPlayerHealth(int entindex, int health);
+
protected:
        // Data for each player that's propagated to all clients
        // Stored in individual arrays so they can be sent down via datatables
</pre>
 
Then you can remove the SendPropInt and RecvPropInt for CBasePlayer::m_iHealth.  (However, I don't have a patch for that yet since it's not a backwards-compatible change.  Will post a patch once I've done so, if no on else beats me to it.)
 
== Server: The client's team membership is pointlessly sent across the wire twice. ==
 
Similar to the above KI, but for another variable. Also this fixes an SDK crasher, but according to Yahn at Valve, Steam will be fixed soon to not do that.
 
'''Fix:''' [[Diff And Patch]]
 
<pre>
--- mod/src/dlls/team.cpp      2005/06/11 22:14:30    1.2
+++ mod/src/dlls/team.cpp      2006/05/29 18:58:52    1.3
@@ -19,6 +19,7 @@
//-----------------------------------------------------------------------------
  void SendProxy_PlayerList( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID )
  {
  {
+    Assert(0);
#ifndef CLIENT_DLL
        CTeam *pTeam = (CTeam*)pData;
UpdatePhysicsGravity(var->GetFloat());
 
if(gpGlobals->mapname!=NULL_STRING)
        // If this assertion fails, then SendProxyArrayLength_PlayerArray must have failed.
{
@@ -31,8 +32,11 @@
IGameEvent *event = gameeventmanager->CreateEvent( "gravity_change" );
 
if ( event )
  int SendProxyArrayLength_PlayerArray( const void *pStruct, int objectID )
{
event->SetFloat( "newgravity", var->GetFloat() );
gameeventmanager->FireEvent( event );
}
}
#endif
}
  #ifdef CLIENT_DLL
class CGravityChange : public IGameEventListener2, public CAutoGameSystem
  {
  {
-       CTeam *pTeam = (CTeam*)pStruct;
public:
-      return pTeam->m_aPlayers.Count();
bool Init()
+    // The RecvPropArray2 in general was seemingly broken in the May 25th-ish core engine update.
{
+    // The CTeam in particular was certainly broken at that time, however, thankfully it doesn't
gameeventmanager->AddListener(this,"gravity_change",false);
+    // serve any important purpose.
return true;
+    // For backwards compatibility with old client, we disable it, rather than remove it entirely.
}
+    return 0;
void FireGameEvent( IGameEvent *event )
}
{
</pre>
UpdatePhysicsGravity(event->GetFloat("newgravity"));
}
};
static CGravityChange s_GravityChange;
#endif
ConVar sv_gravity ( "sv_gravity",DEFAULT_GRAVITY_STRING, FCVAR_NOTIFY | FCVAR_REPLICATED, "World gravity.", GravityChanged_Callback );
In your mod's events file (GameEvents.res/ModEvents.res):
"gravity_change"
{
"newgravity" "float"
}
{{TODO|Diff this}}


== Server: weapon_citizensuitcase Assert on startup ==
== Server: util.cpp (531) : Assertion Failed: !"UTIL_GetLocalPlayer" ==
Occurs when taking damage to yourself from tossing a table straight up into the air.


'''Fix:''' Install copy of the SP SDK, then copy the scripts/ directory over
'''Fix:'''
The following patch fixes the Assert, and appears to be more functionally correct as well. Validation from Valve that the patch is correct would be appreciated. [[Diff And Patch]]
<pre>
Index: mod/src/dlls/player.h
===================================================================
--- mod/src/dlls/player.h 2005/02/19 22:20:29 1.2
+++ mod/src/dlls/player.h 2005/02/24 00:35:30
@@ -459,6 +459,7 @@
    // mass/size limit set to zero for none
    static bool CanPickupObject( CBaseEntity *pObject, float massLimit, float sizeLimit );
    virtual void PickupObject( CBaseEntity *pObject, bool bLimitMassAndSize = true ) {}
+    virtual bool IsHoldingEntity( CBaseEntity *pEnt );
    virtual void ForceDropOfCarriedPhysObjects( CBaseEntity *pOnlyIfHoldindThis = NULL ) {}
    virtual float GetHeldObjectMass( IPhysicsObject *pHeldObject );


== Server: Some bullet weapons set to do 0 damage. ==
Index: mod/src/dlls/player.cpp
===================================================================
--- mod/src/dlls/player.cpp 2005/02/21 00:05:42 1.3
+++ mod/src/dlls/player.cpp 2005/02/24 00:35:33
@@ -7447,3 +7447,7 @@
    return cmd;
}


'''Fix:''' Need to edit their AddAmmoType which are strangely set to 0 for some reason.
+bool CBasePlayer::IsHoldingEntity( CBaseEntity *pEnt )
 
+{
== Server: Some projectile weapons set to do 0 damage. ==
+    return PlayerPickupControllerIsHoldingEntity( m_hUseEntity, pEnt );
 
+}
'''Fix:''' Need to edit their source files and set a damage.
 
== Client: --- Missing Vgui material vgui/steam/games/icon_cz ==
 
'''Fix:''' These files are used in the currently inaccessible Friends IM client. Create 4 vmts in their places of any design to remove the error.
 
* materials\VGUI\steam\games\icon_cs.vmt
* materials\VGUI\steam\games\icon_dod.vmt
* materials\VGUI\steam\games\icon_hl2mp.vmt
* materials\VGUI\servers\icon_secure_deny.vmt
 
Here's a patch to create files for the first three. (I don't see the icon_secure_deny.vmt error, so didn't create anything for it.)


Index: mod/src/dlls/physics_impact_damage.cpp
===================================================================
--- mod/src/dlls/physics_impact_damage.cpp 2005/02/18 04:45:50 1.1.1.1
+++ mod/src/dlls/physics_impact_damage.cpp 2005/02/24 00:42:24
@@ -417,12 +417,22 @@
    else if ( pEvent->pObjects[index>GetGameFlags() & FVPHYSICS_PLAYER_HELD )
    {
    // if the player is holding the object, use it's real mass (player holding reduced the mass)
-    CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
-    if ( pPlayer )
-    {
+    CBasePlayer* pPlayer = NULL;
+    {for (int i = 1; i <= gpGlobals->maxClients; i++) {
+        CBasePlayer *temp_player = UTIL_PlayerByIndex(i);
+        if (temp_player
+            && temp_player->edict()
+            && temp_player->IsHoldingEntity(pEvent->pEntities[index])
+        ) {
+            pPlayer = temp_player;
+            break;
+        }
+    }}
+    Assert(pPlayer && "object with FVPHYSICS_PLAYER_HELD but no player holding it");
+    if (pPlayer) {
    float mass = pPlayer->GetHeldObjectMass( pEvent->pObjects[index] );
-    if ( mass > 0 )
-    {
+        Assert((mass > 0) && "player was holding object so mass should be non-zero");
+        if (mass > 0) {
            invMass = 1.0f / mass;
        }
    }
</pre>
{{note|Instead of iterating all players, why not consider adding a m_pHolder var and GetHolder and SetHolder functions to CBaseEntity}}
(You could, though it's unlikely to impact performance much since this is not a frequently called function. [[User:Bloodykenny|Bloodykenny]] 17:55, 19 Jul 2005 (PDT))
== Assert !"UTIL_GetLocalPlayer" when using combine ball ==
'''Fix:''' [[Diff And Patch]]
<pre>
<pre>
--- materials/VGUI/steam/games/icon_cs.vmt      1969-12-31 18:00:00.000000000 -0600
diff -u -r1.1.1.1 prop_combine_ball.cpp
+++ materials/VGUI/steam/games/icon_cs.vmt      2005-07-28 01:54:17.000000000 -0500
--- mod/src/dlls/hl2_dll/prop_combine_ball.cpp 2005/02/18 04:45:52 1.1.1.1
@@ -0,0 +1 @@
+++ mod/src/dlls/hl2_dll/prop_combine_ball.cpp 2005/02/24 01:34:21
+"UnlitGeneric" {}
@@ -788,9 +788,9 @@  
--- materials/VGUI/steam/games/icon_dod.vmt    1969-12-31 18:00:00.000000000 -0600
    pPhysicsObject->GetPosition( &vecPosition, NULL );
+++ materials/VGUI/steam/games/icon_dod.vmt    2005-07-28 01:54:19.000000000 -0500
    pPhysicsObject->GetVelocity( &vecVelocity, NULL );
@@ -0,0 +1 @@
 
+"UnlitGeneric" {}
-   CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
--- materials/VGUI/steam/games/icon_hl2mp.vmt  1969-12-31 18:00:00.000000000 -0600
-   if ( pPlayer )
+++ materials/VGUI/steam/games/icon_hl2mp.vmt  2005-07-28 01:54:15.000000000 -0500
+    if (gpGlobals->maxClients == 1)
@@ -0,0 +1 @@
    {
+"UnlitGeneric" {}
+   CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
    Vector vecDelta;
    VectorSubtract( pPlayer->GetAbsOrigin(), vecPosition, vecDelta );
    VectorNormalize( vecDelta );
</pre>
</pre>


'''Fix2:''' Add clear to your rc file in cfg (extract from gcf if non-existant)
== Server/Client: Negative entitygroundcontact crash. ==


== Server: The crossbow causes an assertion failure. ==
The implications of this SDK bug are not at all clear, but in debug mode you'll get an assert, and in release mode it will presumably segfault.  The patch assumes anything negative or really large is bogus and dumps it.


'''Fix:''' Comment out ai_activity.cpp line 53. This doesn't appear to be something that can be fixed in code?
I'm starting to wonder if maybe this is another symptom of the Physics Mayhem bugs. --[[User:Bloodykenny|Bloodykenny]] 17:24, 4 Nov 2005 (PST)


== Server? Client?: RL explosion invisible ==
'''Fix:''' [[Diff And Patch]]
 
Per http://www.chatbear.com/board.plm?a=viewthread&t=970,1107153392,30132&id=786504&b=4991&v=flatold
 
'''Fix:''' in c_te_explosion.cpp


<pre>
<pre>
--- mod/src/cl_dll/c_te_explosion.cpp Mon Mar 24 00:46:49 2003
--- mod/src/game_shared/usercmd.cpp 2005/02/18 04:45:54 1.1.1.1
+++ mod/src/cl_dll/c_te_explosion.cpp Mon Mar 24 00:48:38 2003
+++ mod/src/game_shared/usercmd.cpp 2005/03/23 02:24:00
@@ -241,15 +241,18 @@
@@ -290,7 +290,12 @@
const Vector* normal = NULL, unsigned char materialType = 'C' )
#if defined( HL2_DLL )
{
    if ( buf->ReadOneBit() )
// Major hack to access singleton object for doing this event (simulate receiving network message)
    {
+ Assert( pos );
-        move->entitygroundcontact.SetCount( buf->ReadShort() );
+
+       int count = buf->ReadShort();
+ __g_C_TEExplosion.m_vecOrigin = *pos;
+       if ((count < 0) || (count > 140)) {
__g_C_TEExplosion.m_nModelIndex = modelindex;
+            Msg("Ignoring strange entitygroundcontact count: %d\n", count);
__g_C_TEExplosion.m_fScale = scale;
+            return; // why can this be less than 0, Valve? change to ReadWord()???
__g_C_TEExplosion.m_nFrameRate = framerate;
+        }
__g_C_TEExplosion.m_nFlags = flags;
+    move->entitygroundcontact.SetCount( count );
- __g_C_TEExplosion.m_vecNormal = *normal;
+ __g_C_TEExplosion.m_vecNormal = normal ? *normal : Vector( 0, 0, 1 );
__g_C_TEExplosion.m_chMaterialType = materialType;
__g_C_TEExplosion.m_nRadius = radius;
__g_C_TEExplosion.m_nMagnitude = magnitude;


__g_C_TEExplosion.PostDataUpdate( DATA_UPDATE_CREATED );
    int i;
 
    for (i = 0; i < move->entitygroundcontact.Count(); i++)
}
</pre>
</pre>


== sv_gravity is not associated with physics gravity==
== Client: Spinning around quickly with the Stun Baton as your active weapon causes the screen to flash white ==
When gravity is changed, the physics gravity isn't updated
 
It's worth noting that recent updates to HL2DM have fixed this.  However there has not yet been an SDK code update to show what the fix is.  Basically Valve seems to have made the glow fade out completely in between swings.
 
'''Fix:''' Fix unknown
 
== Assert on line 866 of mod/src/game_shared/basecombatweapon_shared.cpp ==
 
'''Fix:''' I haven't been able to determine exactly why this is an assert. It's just "Assert(0);" with no accompanying explanation, but commenting it out results in no problems it seems. [[Diff And Patch]]


'''Fix:'''
<pre>
In movevars_shared.cpp:
--- mod/src/game_shared/basecombatweapon_shared.cpp    2005/02/18 04:45:53    1.1
inline void UpdatePhysicsGravity(float gravity)
+++ mod/src/game_shared/basecombatweapon_shared.cpp     2005/03/04 03:45:36    1.2
{
@@ -863,7 +863,7 @@
if(physenv)
        CBaseViewModel *vm = pOwner->GetViewModel( m_nViewModelIndex );
physenv->SetGravity(Vector(0,0,-gravity));
        if ( vm == NULL )
}
        {
static void GravityChanged_Callback( ConVar *var, const char *pOldString )
-               Assert( false );
{
+              //Assert( false );
#ifndef CLIENT_DLL
                return false;
UpdatePhysicsGravity(var->GetFloat());
        }
if(gpGlobals->mapname!=NULL_STRING)
</pre>
{
 
IGameEvent *event = gameeventmanager->CreateEvent( "gravity_change" );
== Client: The mod can appear to have frozen on initial startup ==
if ( event )
Originally posted by MattC here: http://www.chatbear.com/board.plm?a=viewthread&b=4991&t=234,1117553034,6915&s=0&id=868372
{
 
event->SetFloat( "newgravity", var->GetFloat() );
'''Fix:''' Issue a "progress_enable" command just before "map <mapname>".
gameeventmanager->FireEvent( event );
 
}
<pre>
}
engine->ClientCmd("progress_enable");
#endif
 
}
engine->ClientCmd("map test");
#ifdef CLIENT_DLL
</pre>
class CGravityChange : public IGameEventListener2, public CAutoGameSystem
{
public:
bool Init()
{
gameeventmanager->AddListener(this,"gravity_change",false);
return true;
}
void FireGameEvent( IGameEvent *event )
{
UpdatePhysicsGravity(event->GetFloat("newgravity"));
}
};
static CGravityChange s_GravityChange;
#endif
ConVar sv_gravity ( "sv_gravity",DEFAULT_GRAVITY_STRING, FCVAR_NOTIFY | FCVAR_REPLICATED, "World gravity.", GravityChanged_Callback );
In your mod's events file (GameEvents.res/ModEvents.res):
"gravity_change"
{
"newgravity" "float"
}
{{TODO|Diff this}}


== Server: util.cpp (531) : Assertion Failed: !"UTIL_GetLocalPlayer" ==
This should fix local servers. For connecting to a remote multiplayer server, the only issue appears to be that you can't switch to another window and then switch back to HL2.  Doing so causes HL2 to never render progress info until load is fully complete.  That seems to be an HL2 core bug unrelated (though very similar in appearance) to the fix above.
Occurs when taking damage to yourself from tossing a table straight up into the air.  


'''Fix:'''
== USE_VCR_MODE linker errors ==
The following patch fixes the Assert, and appears to be more functionally correct as well. Validation from Valve that the patch is correct would be appreciated. [[Diff And Patch]]
This is because Valve wants to be able to somehow replay all of the things that happen in a mod and get back the exact same output. I'm still confused as to how that would work, or what the value really is, but anyway, if you need things like threading, you'll hit these errors.
<pre>
Index: mod/src/dlls/player.h
===================================================================
--- mod/src/dlls/player.h 2005/02/19 22:20:29 1.2
+++ mod/src/dlls/player.h 2005/02/24 00:35:30
@@ -459,6 +459,7 @@
    // mass/size limit set to zero for none
    static bool CanPickupObject( CBaseEntity *pObject, float massLimit, float sizeLimit );
    virtual void PickupObject( CBaseEntity *pObject, bool bLimitMassAndSize = true ) {}
+    virtual bool IsHoldingEntity( CBaseEntity *pEnt );
    virtual void ForceDropOfCarriedPhysObjects( CBaseEntity *pOnlyIfHoldindThis = NULL ) {}
    virtual float GetHeldObjectMass( IPhysicsObject *pHeldObject );


Index: mod/src/dlls/player.cpp
My mod needed threading and commenting these out has never caused any issue. Though apparently it means my mod can't use VCR mode.
===================================================================
--- mod/src/dlls/player.cpp 2005/02/21 00:05:42 1.3
+++ mod/src/dlls/player.cpp 2005/02/24 00:35:33
@@ -7447,3 +7447,7 @@
    return cmd;
}


+bool CBasePlayer::IsHoldingEntity( CBaseEntity *pEnt )
'''Fix:''' Comment out the appropriate lines in protected_things.h, for whatever VCR thing was failing.  Note, don't just block out the whole file - the string part at the top is actually useful.
+{
+    return PlayerPickupControllerIsHoldingEntity( m_hUseEntity, pEnt );
+}


Index: mod/src/dlls/physics_impact_damage.cpp
== Lighting in Compile (RAD) ==
===================================================================
There is currently a rather severe lighting bug during RAD. Visible symptoms include: black models while in shadows cast by light_environment; large, unlit sections in "outdoor" type areas.
--- mod/src/dlls/physics_impact_damage.cpp 2005/02/18 04:45:50 1.1.1.1
 
+++ mod/src/dlls/physics_impact_damage.cpp 2005/02/24 00:42:24
'''Fix:''' Pending.
@@ -417,12 +417,22 @@
 
    else if ( pEvent->pObjects[index>GetGameFlags() & FVPHYSICS_PLAYER_HELD )
 
    {
 
    // if the player is holding the object, use it's real mass (player holding reduced the mass)
== Complaints about tv_delaymapchange in NON SRCTV Mods ==
-    CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
{{Note|This issue is fixed in the August 2006 SDK update}}
-    if ( pPlayer )
Issue: Console reports an issue about tv_delaymapchange when loading a mod with no SRCTV Support.
-    {
 
+    CBasePlayer* pPlayer = NULL;
=== mod/game_shared/multiplay_gamerules.cpp ===
+    {for (int i = 1; i <= gpGlobals->maxClients; i++) {
Undone! you don't have to remove it, instead, add FCVAR_REPLICATED like all the other cvar's.
+        CBasePlayer *temp_player = UTIL_PlayerByIndex(i);
It's doing it because it's a shared ConVar in both dll's and not being replicated. --[[User:Omega|omega]]
+        if (temp_player
 
+            && temp_player->edict()
Instead, change to this:
+            && temp_player->IsHoldingEntity(pEvent->pEntities[index])
<pre>
+        ) {
Line 47
+            pPlayer = temp_player;
ConVar mp_timelimit( "mp_timelimit",
+            break;
  "0",
+        }
  FCVAR_NOTIFY|FCVAR_REPLICATED,
+    }}
  "game time per map in minutes" );
+    Assert(pPlayer && "object with FVPHYSICS_PLAYER_HELD but no player holding it");
+    if (pPlayer) {
    float mass = pPlayer->GetHeldObjectMass( pEvent->pObjects[index] );
-    if ( mass > 0 )
-    {
+        Assert((mass > 0) && "player was holding object so mass should be non-zero");
+        if (mass > 0) {
            invMass = 1.0f / mass;
        }
    }
</pre>


{{note|Instead of iterating all players, why not consider adding a m_pHolder var and GetHolder and SetHolder functions to CBaseEntity}}
ConVar tv_delaymapchange( "tv_delaymapchange",
 
  "0",
(You could, though it's unlikely to impact performance much since this is not a frequently called function. [[User:Bloodykenny|Bloodykenny]] 17:55, 19 Jul 2005 (PDT))
-   0,
+   FCVAR_NOTIFY|FCVAR_REPLICATED,
  "Delays map change until broadcast is complete" );
 
</pre>


== Assert !"UTIL_GetLocalPlayer" when using combine ball ==
== Physics models show up darker under switchable lights ==


'''Fix:''' [[Diff And Patch]]
Switchable lights are not taken into account for visibility of physics models when Source starts a map. So whenever a physics model is mostly lit by switchable lights, it will show up much darker when the map starts.
<pre>
diff -u -r1.1.1.1 prop_combine_ball.cpp
--- mod/src/dlls/hl2_dll/prop_combine_ball.cpp 2005/02/18 04:45:52 1.1.1.1
+++ mod/src/dlls/hl2_dll/prop_combine_ball.cpp 2005/02/24 01:34:21
@@ -788,9 +788,9 @@
    pPhysicsObject->GetPosition( &vecPosition, NULL );
    pPhysicsObject->GetVelocity( &vecVelocity, NULL );


-    CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
If the switchable lights are turned off and on again, or if a physics model is moved, then the visibility of this physics model is automatically fixed. But if the map is saved and reloaded, all physics models under switchable lights become darker again.
-    if ( pPlayer )
 
+    if (gpGlobals->maxClients == 1)
{{note|A switchable light is a light with a targetname, that can be triggered to turn on/off.}}
    {  
 
+    CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
'''Fix:''' Fix unknown
    Vector vecDelta;
    VectorSubtract( pPlayer->GetAbsOrigin(), vecPosition, vecDelta );
    VectorNormalize( vecDelta );
</pre>


== Server/Client: Negative entitygroundcontact crash. ==


The implications of this SDK bug are not at all clear, but in debug mode you'll get an assert, and in release mode it will presumably segfault.  The patch assumes anything negative or really large is bogus and dumps it.


I'm starting to wonder if maybe this is another symptom of the Physics Mayhem bugs. --[[User:Bloodykenny|Bloodykenny]] 17:24, 4 Nov 2005 (PST)
== Sticky Player Collisions / No lagcompensation ==
{{note|In the SDK-code of August 06, there is no StartLagCompensation() call.}}
I've been chasing a fix for this for months for Dystopia, when two players collide with each other there's massive prediction errors and to the player it looks like they're jerking back and forth. It can mean real trouble when two players attempt to get through a doorway or something, and it sucks if you're trying to do a good melee system.


'''Fix:''' [[Diff And Patch]]
Anyways, I found out the cause of this problem is on the server, when it runs a players movement code, it first unlags all the other players on the server, presumably to help predict player vs. player collisions. The problem is, because two players have different pings, there's no authoritative point of impact for the collision, so the jerking around you see is caused by this unlagging. Now down to the fix, which is really simple:


player_command.cpp Line 42
<pre>
<pre>
--- mod/src/game_shared/usercmd.cpp 2005/02/18 04:45:54 1.1.1.1
// Move other players back to history positions based on local player's lag
+++ mod/src/game_shared/usercmd.cpp 2005/03/23 02:24:00
- lagcompensation->StartLagCompensation( player, cmd );
@@ -290,7 +290,12 @@
#if defined( HL2_DLL )
    if ( buf->ReadOneBit() )
    {
-        move->entitygroundcontact.SetCount( buf->ReadShort() );
+        int count = buf->ReadShort();
+        if ((count < 0) || (count > 140)) {
+            Msg("Ignoring strange entitygroundcontact count: %d\n", count);
+            return; // why can this be less than 0, Valve? change to ReadWord()???
+        }
+    move->entitygroundcontact.SetCount( count );
 
    int i;
    for (i = 0; i < move->entitygroundcontact.Count(); i++)
</pre>
</pre>


== Client: Spinning around quickly with the Stun Baton as your active weapon causes the screen to flash white ==
player_command.cpp Line 52
<pre>
// Restore other players to current positions
- lagcompensation->FinishLagCompensation( player );
</pre>
 
player_command.cpp Line 348
// Let server invoke any needed impact functions
moveHelper->ProcessImpacts();
+ // Only do unlag for post think/post frame, which is mainly weapons stuff! - Teddy
+ lagcompensation->StartLagCompensation( player, '''u'''cmd );
RunPostThink( player );
+ lagcompensation->FinishLagCompensation( player );
FinishCommand( player );
 
Pretty simple huh? You only need unlag for weapons really, and all the weapon hitscan code is run from the weapon's ItemPostFrame which is what the RunPostThink() runs. Let me know if it works for you! --[[User:Teddy|Teddy]] 20:05, 12 Jun 2006 (PDT)
 
I added this fix to the latest version of the SDK (as of January, 2007) and I did not notice any difference. I believe this issue may have already been addressed in the latest SDK so this fix is uneccessary if you are running the latest SDK code. [User: Minh]


It's worth noting that recent updates to HL2DM have fixed this.  However there has not yet been an SDK code update to show what the fix is.  Basically Valve seems to have made the glow fade out completely in between swings.
== Minor/misc code neatenings/fixings ==


'''Fix:''' Fix unknown
(This section is for issues in the codebase that you've spotted to be potentially dangerous but aren't actually causing obvious bugs/issues... every little improvement to the quality of the codebase helps, right?)


== Assert on line 866 of mod/src/game_shared/basecombatweapon_shared.cpp ==
/src/cl_dll/game_controls/spectatorgui.cpp(508): The memset is setting twice as much memory as it should be to 0x0 because sizeof(playerName) already accounts for the fact that the elements are wchar_t type. '''Fix:''' Remove the "* sizeof( wchar_t)".


'''Fix:''' I haven't been able to determine exactly why this is an assert. It's just "Assert(0);" with no accompanying explanation, but commenting it out results in no problems it seems. [[Diff And Patch]]
== filter_damage_type doesn't work ==
Open <code>dlls/filters.cpp</code> and replace


<pre>
<pre>
--- mod/src/game_shared/basecombatweapon_shared.cpp    2005/02/18 04:45:53    1.1
return info.GetDamageType() == m_iDamageType;
+++ mod/src/game_shared/basecombatweapon_shared.cpp    2005/03/04 03:45:36    1.2
@@ -863,7 +863,7 @@
        CBaseViewModel *vm = pOwner->GetViewModel( m_nViewModelIndex );
        if ( vm == NULL )
        {
-              Assert( false );
+              //Assert( false );
                return false;
        }
</pre>
</pre>


== Client: The mod can appear to have frozen on initial startup ==
with
Originally posted by MattC here: http://www.chatbear.com/board.plm?a=viewthread&b=4991&t=234,1117553034,6915&s=0&id=868372
 
'''Fix:''' Issue a "progress_enable" command just before "map <mapname>".


<pre>
<pre>
engine->ClientCmd("progress_enable");
return ( (info.GetDamageType() & m_iDamageType ) ? true : false );
 
engine->ClientCmd("map test");
</pre>
</pre>


This should fix local servers.  For connecting to a remote multiplayer server, the only issue appears to be that you can't switch to another window and then switch back to HL2.  Doing so causes HL2 to never render progress info until load is fully complete.  That seems to be an HL2 core bug unrelated (though very similar in appearance) to the fix above.
== Floating SLAM's ==
When attaching a SLAM at a movable object, it doesn't explode when the object moves and so give a "floating SLAM".


== USE_VCR_MODE linker errors ==
'''Fix:'''
This is because Valve wants to be able to somehow replay all of the things that happen in a mod and get back the exact same output.  I'm still confused as to how that would work, or what the value really is, but anyway, if you need things like threading, you'll hit these errors.
<pre>
 
--- mod/src/dlls/hl2_dll/grenade_tripmine.h 18 Feb 2005 04:45:51 -0000 1.1.1.1
My mod needed threading and commenting these out has never caused any issue.  Though apparently it means my mod can't use VCR mode.
+++ mod/src/dlls/hl2_dll/grenade_tripmine.h 22 Jul 2006 22:32:28 -0000
 
@@ -36,6 +36,8 @@
'''Fix:''' Comment out the appropriate lines in protect_things.h, for whatever VCR thing was failing. Note, don't just block out the whole file - the string part at the top is actually useful.
void MakeBeam( void );
 
void KillBeam( void );
 
 
+   void AttachToEntity(const CBaseEntity* const ent);
 
+
 
public:
== Lighting in Compile (RAD) ==
EHANDLE m_hOwner;
There is currently a rather severe lighting bug during RAD. Visible symptoms include: black models while in shadows cast by light_environment; large, unlit sections in "outdoor" type areas.
   
 
@@ -49,6 +51,10 @@
'''Fix:''' Pending.
Vector m_posOwner;
 
Vector m_angleOwner;
== Using the Sheild Scanner npc_cscanner is not possible unless you name the map with d3_c17 as a prefix ==
   
I was expecting the flag for strider scout scanner to be the sheild scanner version of the npc_cscanner, but it seems that the flag is there, but currently in the default hl2 code it does nothing.
+   const CBaseEntity* m_pAttachedObject;
 
+   Vector m_vecOldPosAttachedObject;
So I replaced in the Scanner constructor function the code that compares the first 6 letters of a map name to d3_c17 with
+   QAngle m_vecOldAngAttachedObject;
 
+
npc_scanner.cpp Line 588
DECLARE_DATADESC();
 
};
<pre>
DevMsg("CNPC_CScanner::Spawn: Invalid spotlight width %.1f (max %.1f).\n", m_flSpotlightGoalWidth, MAX_BEAM_WIDTH );
--- mod/src/dlls/hl2mp_dll/grenade_tripmine.cpp 18 Feb 2005 04:45:51 -0000 1.1.1.1
m_flSpotlightGoalWidth = MAX_BEAM_WIDTH;  
+++ mod/src/dlls/hl2mp_dll/grenade_tripmine.cpp 22 Jul 2006 22:32:28 -0000
}
@@ -91,6 +91,8 @@
 
m_vecEnd = GetAbsOrigin() + m_vecDir * 2048;
+if( IsStriderScout() )
+ {
AddEffects( EF_NOSHADOW );
+ // Streetwar scanners are claw scanners
+
+ m_bIsClawScanner = true;
+    m_pAttachedObject = NULL;
+ }
}
+ else
+ {
+ m_bIsClawScanner = false;
@@ -224,7 +226,27 @@
+ }
return;
 
}
Precache();
 
- SetNextThink( gpGlobals->curtime + 0.05f );
if( m_bIsClawScanner )
+    // Detonate if the parent object moves
</pre>
+    if (
 
+        m_pAttachedObject
== Complaints about tv_delaymapchange in NON SRCTV Mods ==
+        && (
{{Note|This issue is fixed in the August 2006 SDK update}}
+              !VectorsAreEqual(m_vecOldPosAttachedObject, m_pAttachedObject->GetAbsOrigin(), 1.0f)
Issue: Console reports an issue about tv_delaymapchange when loading a mod with no SRCTV Support.
+            || !QAnglesAreEqual(m_vecOldAngAttachedObject, m_pAttachedObject->GetAbsAngles(), 1.0f)
 
+        )
=== mod/game_shared/multiplay_gamerules.cpp ===
+    ) {
Undone! you don't have to remove it, instead, add FCVAR_REPLICATED like all the other cvar's.
+        m_iHealth = 0;
It's doing it because it's a shared ConVar in both dll's and not being replicated. --[[User:Omega|omega]]
+        Event_Killed(CTakeDamageInfo((CBaseEntity*)m_hOwner, this, 100, GIB_NORMAL));
 
+        return;
Instead, change to this:
+    }
<pre>
+
Line 47
+ SetNextThink(gpGlobals->curtime + 0.05f);
ConVar mp_timelimit( "mp_timelimit",
+}
  "0",
+
  FCVAR_NOTIFY|FCVAR_REPLICATED,
+void CTripmineGrenade::AttachToEntity(const CBaseEntity* const ent) {
  "game time per map in minutes" );
+    Assert(m_pAttachedObject == NULL);
 
+    m_pAttachedObject = ent;
ConVar tv_delaymapchange( "tv_delaymapchange",
+    m_vecOldPosAttachedObject = ent->GetAbsOrigin();
  "0",
+    m_vecOldAngAttachedObject = ent->GetAbsAngles();
-   0,
}
+   FCVAR_NOTIFY|FCVAR_REPLICATED,
  "Delays map change until broadcast is complete" );
 
</pre>
 
== Physics models show up darker under switchable lights ==
 
Switchable lights are not taken into account for visibility of physics models when Source starts a map. So whenever a physics model is mostly lit by switchable lights, it will show up much darker when the map starts.
 
If the switchable lights are turned off and on again, or if a physics model is moved, then the visibility of this physics model is automatically fixed. But if the map is saved and reloaded, all physics models under switchable lights become darker again.
 
{{note|A switchable light is a light with a targetname, that can be triggered to turn on/off.}}
 
'''Fix:''' Fix unknown
 
 
 
== Sticky Player Collisions ==
I've been chasing a fix for this for months for Dystopia, when two players collide with each other there's massive prediction errors and to the player it looks like they're jerking back and forth. It can mean real trouble when two players attempt to get through a doorway or something, and it sucks if you're trying to do a good melee system.
 
Anyways, I found out the cause of this problem is on the server, when it runs a players movement code, it first unlags all the other players on the server, presumably to help predict player vs. player collisions. The problem is, because two players have different pings, there's no authoritative point of impact for the collision, so the jerking around you see is caused by this unlagging. Now down to the fix, which is really simple:
 
player_command.cpp Line 42
<pre>
// Move other players back to history positions based on local player's lag
- lagcompensation->StartLagCompensation( player, cmd );
</pre>
 
player_command.cpp Line 52
<pre>
// Restore other players to current positions
- lagcompensation->FinishLagCompensation( player );
</pre>
 
player_command.cpp Line 348
// Let server invoke any needed impact functions
moveHelper->ProcessImpacts();
   
   
  + // Only do unlag for post think/post frame, which is mainly weapons stuff! - Teddy
  int CTripmineGrenade::OnTakeDamage_Alive( const CTakeDamageInfo &info )
+ lagcompensation->StartLagCompensation( player, '''u'''cmd );
--- mod/src/dlls/hl2mp_dll/grenade_tripmine.h 18 Feb 2005 04:45:51 -0000 1.1.1.1
  RunPostThink( player );
+++ mod/src/dlls/hl2mp_dll/grenade_tripmine.h 22 Jul 2006 22:32:28 -0000
  + lagcompensation->FinishLagCompensation( player );
@@ -36,6 +36,8 @@
void MakeBeam( void );
  void KillBeam( void );
   
+   void AttachToEntity(const CBaseEntity* const ent);
+
public:
EHANDLE m_hOwner;
@@ -49,6 +51,10 @@
Vector m_posOwner;
Vector m_angleOwner;
   
   
  FinishCommand( player );
+    const CBaseEntity* m_pAttachedObject;
 
+    Vector m_vecOldPosAttachedObject;
Pretty simple huh? You only need unlag for weapons really, and all the weapon hitscan code is run from the weapon's ItemPostFrame which is what the RunPostThink() runs. Let me know if it works for you! --[[User:Teddy|Teddy]] 20:05, 12 Jun 2006 (PDT)
+    QAngle m_vecOldAngAttachedObject;
 
+
 
  DECLARE_DATADESC();
== Minor/misc code neatenings/fixings ==
};
 
(This section is for issues in the codebase that you've spotted to be potentially dangerous but aren't actually causing obvious bugs/issues... every little improvement to the quality of the codebase helps, right?)
--- mod/src/game_shared/hl2mp/weapon_slam.cpp 17 Jun 2006 17:51:06 -0000 1.6
 
+++ mod/src/game_shared/hl2mp/weapon_slam.cpp 22 Jul 2006 22:32:28 -0000
/src/cl_dll/game_controls/spectatorgui.cpp(498): The memset is setting twice as much memory as it should be to 0x0 because sizeof(playerName) already accounts for the fact that the elements are wchar_t type. '''Fix:''' Remove the "* sizeof( wchar_t)".
@@ -371,6 +371,7 @@
 
CBaseEntity *pEnt = CBaseEntity::Create( "npc_tripmine", tr.endpos + tr.plane.normal * 3, angles, NULL );
 
CTripmineGrenade *pMine = (CTripmineGrenade *)pEnt;
+            pMine->AttachToEntity(pEntity);
pMine->m_hOwner = GetOwner();
            pMine->SetDamage(pOwner->get_damage(AOA_SLAM));
#endif
</pre>


== filter_damage_type doesn't work ==
== Assertion Failed in utlbuffer.cpp ==
Open <code>dlls/filters.cpp</code> and replace
'''[ISSUE]''' An assertion is thrown from the following location in <code>utlbuffer.cpp</code>:
<source lang=cpp highlight=4>
CUtlBuffer::CUtlBuffer( const void *pBuffer, int nSize, int nFlags ) :
m_Memory( (unsigned char*)pBuffer, nSize ), m_Error(0)
{
        Assert( nSize != 0 );


<pre>
...
return info.GetDamageType() == m_iDamageType;
}
</pre>
</source>


with


<pre>
'''[FIX]''' Change the source to:
return ( (info.GetDamageType() & m_iDamageType ) ? true : false );
<source lang=cpp highlight=4>
</pre>
CUtlBuffer::CUtlBuffer( const void *pBuffer, int nSize, int nFlags ) :
m_Memory( (unsigned char*)pBuffer, nSize ), m_Error(0)
{
        Assert( nSize >= 0 );


== Floating SLAM's ==
...
When attaching a SLAM at a movable object, it doesn't explode when the object moves and so give a "floating SLAM".
}
</source>
 
 
However, there appears to be a separate issue with dependencies in the VS project. For example, selecting <code>Build Solution</code> may not reflect the above changes when running the project. For a temporary workaround, select <code>Rebuild Solution</code> and then <code>Build Solution</code>. The expected behavior is that rebuilding will produce a linker error about <code>tier1.lib</code>, but building afterwards will succeed.
 
 
'''[TODO]''' Investigate VS project dependencies to come up with a fix that avoids having to rebuild the solution.
 
== Constant physprops->GetSurfaceData( ) on Linux ==
The physprops->GetSurfaceData( ) for a trace returns always CHAR_TEX_CONCRETE on Linux with SDK 2007. The surface type is correctly detected on Windows though.
This should be fixed in 2009 according to: [http://store.steampowered.com/news/4015/].
 
== Cannot re-ignite entities ==
There's a glich in SDK that does not call Extinguish() on entity once fire goes out, because it always returns NULL pointer, this causes inability to ignite same entity again. To fix this without changing header go to EntityFlame.cpp line 286.
{{Warning|Not only can you re-ignite entities in latest SDK version, but the game will crash if this edit is applied.}}
Replace this


'''Fix:'''
<pre>
<pre>
--- mod/src/dlls/hl2_dll/grenade_tripmine.h 18 Feb 2005 04:45:51 -0000 1.1.1.1
if ( m_hEntAttached )
+++ mod/src/dlls/hl2_dll/grenade_tripmine.h 22 Jul 2006 22:32:28 -0000
{
@@ -36,6 +36,8 @@
CBaseCombatCharacter *pAttachedCC = m_hEntAttached->MyCombatCharacterPointer();
void MakeBeam( void );
 
void KillBeam( void );
if( pAttachedCC )
{
+    void AttachToEntity(const CBaseEntity* const ent);
// Notify the NPC that it's no longer burning!
+
pAttachedCC->Extinguish();
public:
}
EHANDLE m_hOwner;
}
</pre>
@@ -49,6 +51,10 @@
 
Vector m_posOwner;
with this
Vector m_angleOwner;
 
<pre>
+    const CBaseEntity* m_pAttachedObject;
if ( m_hEntAttached )
+    Vector m_vecOldPosAttachedObject;
{
+    QAngle m_vecOldAngAttachedObject;
//Cannot directly cast networked variables
+
CBaseEntity *temp = m_hEntAttached;
DECLARE_DATADESC();
CBaseCombatCharacter *pAttachedCC = (CBaseCombatCharacter *)temp;
};
 
if( pAttachedCC )
--- mod/src/dlls/hl2mp_dll/grenade_tripmine.cpp 18 Feb 2005 04:45:51 -0000 1.1.1.1
{
+++ mod/src/dlls/hl2mp_dll/grenade_tripmine.cpp 22 Jul 2006 22:32:28 -0000
// Notify the NPC that it's no longer burning!
@@ -91,6 +91,8 @@
pAttachedCC->Extinguish();
m_vecEnd = GetAbsOrigin() + m_vecDir * 2048;
}
}
AddEffects( EF_NOSHADOW );
+
+    m_pAttachedObject = NULL;
}
@@ -224,7 +226,27 @@
return;
}
- SetNextThink( gpGlobals->curtime + 0.05f );
+    // Detonate if the parent object moves
+    if (
+        m_pAttachedObject
+        && (
+              !VectorsAreEqual(m_vecOldPosAttachedObject, m_pAttachedObject->GetAbsOrigin(), 1.0f)
+            || !QAnglesAreEqual(m_vecOldAngAttachedObject, m_pAttachedObject->GetAbsAngles(), 1.0f)
+        )
+    ) {
+        m_iHealth = 0;
+        Event_Killed(CTakeDamageInfo((CBaseEntity*)m_hOwner, this, 100, GIB_NORMAL));
+        return;
+    }
+
+ SetNextThink(gpGlobals->curtime + 0.05f);
+}
+
+void CTripmineGrenade::AttachToEntity(const CBaseEntity* const ent) {
+    Assert(m_pAttachedObject == NULL);
+    m_pAttachedObject = ent;
+    m_vecOldPosAttachedObject = ent->GetAbsOrigin();
+    m_vecOldAngAttachedObject = ent->GetAbsAngles();
}
int CTripmineGrenade::OnTakeDamage_Alive( const CTakeDamageInfo &info )
--- mod/src/dlls/hl2mp_dll/grenade_tripmine.h 18 Feb 2005 04:45:51 -0000 1.1.1.1
+++ mod/src/dlls/hl2mp_dll/grenade_tripmine.h 22 Jul 2006 22:32:28 -0000
@@ -36,6 +36,8 @@
void MakeBeam( void );
void KillBeam( void );
+    void AttachToEntity(const CBaseEntity* const ent);
+
public:
EHANDLE m_hOwner;
@@ -49,6 +51,10 @@
Vector m_posOwner;
Vector m_angleOwner;
+    const CBaseEntity* m_pAttachedObject;
+    Vector m_vecOldPosAttachedObject;
+    QAngle m_vecOldAngAttachedObject;
+
DECLARE_DATADESC();
};
--- mod/src/game_shared/hl2mp/weapon_slam.cpp 17 Jun 2006 17:51:06 -0000 1.6
+++ mod/src/game_shared/hl2mp/weapon_slam.cpp 22 Jul 2006 22:32:28 -0000
@@ -371,6 +371,7 @@
CBaseEntity *pEnt = CBaseEntity::Create( "npc_tripmine", tr.endpos + tr.plane.normal * 3, angles, NULL );
CTripmineGrenade *pMine = (CTripmineGrenade *)pEnt;
+            pMine->AttachToEntity(pEntity);
pMine->m_hOwner = GetOwner();
            pMine->SetDamage(pOwner->get_damage(AOA_SLAM));
#endif
</pre>
</pre>


Line 2,079: Line 1,850:


[[Category:Debugging]] [[Category:Feedback]] [[Category:Programming]] [[Category:Source SDK FAQ]]
[[Category:Debugging]] [[Category:Feedback]] [[Category:Programming]] [[Category:Source SDK FAQ]]
[[Category:Lists]]

Latest revision as of 12:08, 20 May 2023

Note.pngNote:This page is for the SDK code. For the SDK tools, see Source SDK Known Issues. For the HL2 core, see the Core Known Issues List or the HL2 Bugzilla.

The patches listed here are in unidiff format.

First pass at compiling server_hl2mp-2005.vcproj under Linux

Preconditions

Setup the SDK as desribed in http://developer.valvesoftware.com/wiki/Compiling_under_Linux but obtained with "Modify Half-Life 2 Multiplayer" instead of "Source code only (advanced users only)". Obtained and compiled as of Sunday, February the 15th, 2009. Using Debian Lenny.

Issues

../dlls/lightglow.cpp:57: error: 'SendProxy_Angles' was not declared in this scope

Ambiguous function pointer. One probable fix could be to add '0, ' before the inclined call and add an 'extern ' declaration of the inclined function.

/usr/include/c++/3.4/limits:292:22: macro "max" requires 2 arguments, but only 1 given

In file included from /usr/include/c++/3.4/memory:61, from /usr/include/c++/3.4/string:48, from ../dlls/../public/stdstring.h:26, from ../dlls/ai_playerally.h:18, from ../dlls/npc_talker.h:34, from ../dlls/npc_talker.cpp:10 Maybe fixed by commenting out #include <set> in ../dlls/npc_talker.h

../game_shared/gamestats/ep1_gamestats.h:14:27: tier1/UtlDict.h: No such file or directory

In file included from ../dlls/../game_shared/gamestats/ep1_gamestats.cpp:7. Probably because public is not part of the path. Probably also because of case sensitivity. Fix:

ln -s ../public/tier1 tier1
ln ../public/tier1/utlbuffer.h tier1/UtlBuffer.h
ln ../public/tier1/utldict.h tier1/UtlDict.h

../dlls/episodic/grenade_hopwire.h:14:20: sprite.h: No such file or directory

In file included from ../dlls/episodic/grenade_hopwire.cpp:8 Fix:

ln ../game_shared/Sprite.h ../game_shared/sprite.h

The compile completed after these issues in the first pass.

Issues only with SDK 2006-08-04

Assert whenever Gravity Gun is holding a crate/barrel that explodes

See bugzilla [1].

Assert: no supported muzzle flash for the type specified

This is apparently a bug in the HL2 model so looks like there's nothing to be done but comment out the assert.

--- src/cl_dll/c_te_legacytempents.cpp      26 Aug 2006 21:24:22 -0000      1.5
+++ src/cl_dll/c_te_legacytempents.cpp      27 Aug 2006 19:31:35 -0000
@@ -1676,7 +1676,7 @@

        default:
                // There's no supported muzzle flash for the type specified!
-               Assert(0);
+               // Assert(0);
                break;
        }

Assert( i >= 0 && i < GetNumSeq() )

Once again this is apparently a bug in the HL2 model so looks like there's nothing to be done but comment out the assert.

--- src/public/studio.cpp 26 Aug 2006 21:24:47 -0000      1.3
+++ src/public/studio.cpp 27 Aug 2006 19:44:53 -0000
@@ -783,7 +783,7 @@

 mstudioseqdesc_t &CStudioHdr::pSeqdesc( int i ) const
 {
-       Assert( i >= 0 && i < GetNumSeq() );
+       // Assert( i >= 0 && i < GetNumSeq() );

        if (m_pVModel == NULL)
        {


dm_powerhouse lamps lay on the ground

This was first reported on the Steam Forums HL2 bug list, including this screenshot.

Since updating the SDK the bug now occurs in my mod.

It's been obvious for a long time that the dm_powerhouse map was broken (see #dm_powerhouse_lights_never_slow_down). Looks like Valve was attempting to out-think broken maps, but only made things worse. See the #dm_powerhouse_lights_never_slow_down KI for the real dm_powerhouse bug fix. Meanwhile here's the bugfix to undo the latest SDK breakage:

--- src/dlls/physconstraint.cpp 26 Aug 2006 21:24:31 -0000      1.4
+++ src/dlls/physconstraint.cpp 2 Sep 2006 22:50:09 -0000
@@ -437,8 +437,6 @@
                if ( Q_strlen(STRING(m_nameAttach1)) )
                {
                        Warning("Bogus constraint %s (attaches %s to %s)\n", GetDebugName(), STRING(m_nameAttach1), STRING(m_nameAttach2));
-                       info.pObjects[0] = info.pObjects[1] = NULL;
-                       return;
                }
                info.pObjects[0] = g_PhysWorldObject;
                info.massScale[0] = info.massScale[1] = 1.0f; // no mass scale on world constraint
@@ -448,8 +446,6 @@
                if ( Q_strlen(STRING(m_nameAttach2)) )
                {
                        Warning("Bogus constraint %s (attaches %s to %s)\n", GetDebugName(), STRING(m_nameAttach1), STRING(m_nameAttach2));
-                       info.pObjects[0] = info.pObjects[1] = NULL;
-                       return;
                }
                info.pObjects[1] = info.pObjects[0];
                info.pObjects[0] = g_PhysWorldObject;           // Try to make the world object consistently object0 for ease of implementation

IsFrameLocking assert

If you commented out the AssertOnce( pModelCache->IsFrameLocking() ); asserts, uncommented them. According to Jay at Valve the core is allowed to delete a GetModelPtr() pointer at any time unless you're inside the lock, therefore all of these fixes below are potential crashers.

--- mod/src/cl_dll/prediction.cpp       3 Sep 2006 01:31:56 -0000       1.5
+++ mod/src/cl_dll/prediction.cpp       16 Sep 2006 18:56:39 -0000
@@ -212,6 +212,8 @@
 void CPrediction::ShutdownPredictables( void )
 {
 #if !defined( NO_ENTITY_PREDICTION )
+    MDLCACHE_CRITICAL_SECTION();
+
        // Transfer intermediate data from other predictables
        int c = predictables->GetPredictableCount();
        int i;

and...

--- src/game_shared/baseplayer_shared.cpp       26 Aug 2006 21:24:36 -0000      1.28
+++ src/game_shared/baseplayer_shared.cpp       4 Sep 2006 18:53:21 -0000
@@ -749,6 +749,8 @@
 //-----------------------------------------------------------------------------
 bool CBasePlayer::Weapon_Switch( CBaseCombatWeapon *pWeapon, int viewmodelindex /*=0*/ )
 {
+    MDLCACHE_CRITICAL_SECTION();
+ 
        CBaseCombatWeapon *pLastWeapon = GetActiveWeapon();
 
        if ( BaseClass::Weapon_Switch( pWeapon, viewmodelindex ))
 
 

--- src/cl_dll/c_baseanimating.cpp	2 Sep 2006 23:11:26 -0000	1.9
+++ src/cl_dll/c_baseanimating.cpp	3 Sep 2006 01:00:52 -0000
@@ -3919,6 +3919,8 @@
 {
 	VPROF( "C_BaseAnimating::TestCollision" );
 
+    MDLCACHE_CRITICAL_SECTION();
+
 	CStudioHdr *pStudioHdr = GetModelPtr();
 	if (!pStudioHdr)
 		return false;


--- src/cl_dll/prediction.cpp	26 Aug 2006 21:24:24 -0000	1.4
+++ src/cl_dll/prediction.cpp	3 Sep 2006 01:00:52 -0000
@@ -19,6 +19,7 @@
 #include "in_buttons.h"
 #include "con_nprint.h"
 #include "hud_pdump.h"
+#include "datacache/imdlcache.h"
 
 #ifdef HL2_CLIENT_DLL
 #include "c_basehlplayer.h"
@@ -1484,6 +1484,9 @@
 	//}
 
 	Assert( i >= 1 );
+
+    MDLCACHE_CRITICAL_SECTION();
+
 	while ( true )
 	{
 		// Incoming_acknowledged is the last usercmd the server acknowledged having acted upon


--- src/dlls/player_command.cpp	26 Aug 2006 21:24:31 -0000	1.5
+++ src/dlls/player_command.cpp	3 Sep 2006 01:00:54 -0000
@@ -14,6 +14,7 @@
 #include "movehelper_server.h"
 #include "iservervehicle.h"
 #include "tier0/vprof.h"
+#include "datacache/imdlcache.h"
 
 // memdbgon must be the last include file in a .cpp file!!!
 #include "tier0/memdbgon.h"
@@ -306,6 +307,8 @@
 //-----------------------------------------------------------------------------
 void CPlayerMove::RunCommand ( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *moveHelper )
 {
+    MDLCACHE_CRITICAL_SECTION();
+
 	StartCommand( player, ucmd );
 
 	// Set globals appropriately


--- src/dlls/hl2mp_dll/hl2mp_player.cpp	26 Aug 2006 21:24:35 -0000	1.43
+++ src/dlls/hl2mp_dll/hl2mp_player.cpp	3 Sep 2006 01:00:54 -0000
@@ -18,6 +18,7 @@
 #include "weapon_hl2mpbase.h"
 #include "grenade_satchel.h"
 #include "eventqueue.h"
+#include "datacache/imdlcache.h"
 
 #include "engine/IEngineSound.h"
 #include "SoundEmitterSystem/isoundemittersystembase.h"
@@ -504,6 +505,8 @@
 {
 	if ( IsAlive() )
 	{
+        MDLCACHE_CRITICAL_SECTION();
+
 		SetSequence ( -1 );
 		SetActivity( ACT_INVALID );
 


--- src/game_shared/basecombatweapon_shared.cpp	26 Aug 2006 21:24:35 -0000	1.9
+++ src/game_shared/basecombatweapon_shared.cpp	3 Sep 2006 01:00:54 -0000
@@ -1287,6 +1287,7 @@
 	float flSequenceDuration = 0;
 	if ( GetActivity() == ACT_VM_HOLSTER )
 	{
+        MDLCACHE_CRITICAL_SECTION();
 		flSequenceDuration = SequenceDuration();
 	}


 

AI_Activity.cpp assert on startup

Just before the "// Multiplayer" line, add the following:

	ADD_ACTIVITY_TO_SR( ACT_MP_STAND_IDLE_PORTALGUN );
	ADD_ACTIVITY_TO_SR( ACT_MP_RUN_IDLE_PORTALGUN );
	ADD_ACTIVITY_TO_SR( ACT_MP_CROUCH_IDLE_PORTALGUN );
	ADD_ACTIVITY_TO_SR( ACT_MP_WALK_CROUCH_PORTALGUN );
	ADD_ACTIVITY_TO_SR( ACT_MP_GESTURE_RANGE_ATTACK_PORTALGUN );
	ADD_ACTIVITY_TO_SR( ACT_MP_GESTURE_RELOAD_PORTALGUN );
	ADD_ACTIVITY_TO_SR( ACT_MP_JUMP_PORTALGUN );

Will not compile on Linux

This was partially moved to Source SDK Known Issues#Linux_Support

Here's a better fix for the Linux build breaking without -O. Apparently using always_inline without -O intentionally breaks on GCC. There's no real need for this though - you're better off letting the compiler optimize at will anyway.

--- src/public/tier0/platform.h  26 Aug 2006 21:24:48 -0000      1.5
+++ src/public/tier0/platform.h  28 Aug 2006 03:20:52 -0000
@@ -310,7 +310,7 @@
 #else
        #define  STDCALL
        #define  FASTCALL
-       #define  FORCEINLINE                    __attribute__ ((always_inline))
+       #define  FORCEINLINE                    inline
        // GCC 3.4.1 has a bug in supporting forced inline of templated functions
        // this macro lets us not force inlining in that case
        #define  FORCEINLINE_TEMPLATE

And some other issues...

--- src/dlls/episodic/grenade_hopwire.h 2006-08-05 10:58:48.278875000 -0500
+++ src/dlls/episodic/grenade_hopwire.h 2006-08-13 23:09:41.000000000 -0500
@@ -11,7 +11,7 @@
 #endif

 #include "basegrenade_shared.h"
-#include "sprite.h"
+#include "Sprite.h"

 extern ConVar hopwire_trap;
--- src/game_shared/gamestats/ep1_gamestats.cpp  2006-08-05 10:59:06.075750000 -0500
+++ src/game_shared/gamestats/ep1_gamestats.cpp  2006-08-13 16:10:42.000000000 -0500
@@ -5,7 +5,7 @@
 //=============================================================================

 #include "gamestats/ep1_gamestats.h"
-#include "tier1/UtlBuffer.h"
+#include "tier1/utlbuffer.h"

 static int g_nParseVersion = -1;

@@ -194,4 +194,4 @@
                m_nDXLevel = (int)buf.GetShort();
        }
        return bret;
-}
\ No newline at end of file
+}
--- src/game_shared/gamestats/ep1_gamestats.h    2006-08-05 10:59:06.091375000 -0500
+++ src/game_shared/gamestats/ep1_gamestats.h    2006-08-13 16:10:52.000000000 -0500
@@ -11,7 +11,7 @@
 #endif

 class CUtlBuffer;
-#include "tier1/UtlDict.h"
+#include "tier1/utldict.h"

 #define GAMESTATS_FILE_VERSION_OLD             001
 #define GAMESTATS_FILE_VERSION_OLD2            002

That's all the compile bugs I encountered. Granted I was using my mod as a basis, so there might be other compile bugs I didn't see thanks to other fixes in my mod. If anyone else can confirm that's the complete list of fixes for a fresh SDK checkout, please do so.

Will not link fully on Linux

The lack of mathlib results in "undefined symbol: _Z9AngleDiffff" at runtime. There used to be a file called public/mathlib.cpp that exported that symbol, however that file is now complete gone and seemingly has no replacement. (There is a mathlib.lib which is of course useless for non-MSVC.)

Update: this was apparently an oversight - Valve intended to switch everything to libs...

Fix: Download these linuxlibs that Mike Durand provided (careful not to overwrite your existing Makefile), and apply this patch.

GameInfo.txt issues

This was moved to Source SDK Known Issues#SDK_Launcher_Issues

Animations are jittery

Open cl_dll/c_baseentity.cpp and remove the following code:

if ( !IsSelfAnimating() ) 
{ 
        m_flAnimTime = engine->GetLastTimeStamp();       
}

HL2Gamerules()

When you are running a multiplayer mod, a call to HL2Gamerules(), without checking if the object valid, will probably crash. This happens because the function tries to static_cast g_pGamerules to the class CHalfLife2. However the gamerules of multiplay_gamerules.cpp or hl2dm_gamerules.cpp is used. As a result the casting fails and any calls to it crash. To fix this, you need to add a check to every call to this function.

Bullet impact sounds do not play to clients

In the PlayImpactSound function in cl_dll/fx_impact.cpp, replace:

C_BaseEntity::EmitSound( filter, NULL, pbulletImpactSoundName, pdata->soundhandles.bulletImpact, &vecOrigin );

with:

C_BaseEntity::EmitSound( filter, NULL, pbulletImpactSoundName, &vecOrigin );

This can also be observed as hearing the WateryDeath.Warn soundscript entry played while shooting at models with the "Weapon" surfaceprop when hosting a listen server in a map using level-specific soundscripts.

use of non-standard _stricmp in portable code block

Can someone confirm whether this patch works with a fresh SDK? I've removed Valve's inappropriate Makefile defines (see -Wall section) which may be what revealed this, or it might just be another Linux compilation DOA.

This stuffs up vc2003 again, and chucks up 1000's of warnings if you #ifdef WIN32 or #ifdef LINUX - only use this fix if you are in need of it! --Amckern 23:22, 2 Oct 2006 (PDT)
--- public/tier1/strtools.h     26 Aug 2006 21:30:57 -0000      1.1
+++ public/tier1/strtools.h     27 Aug 2006 03:33:54 -0000
@@ -98,7 +98,7 @@
 inline char*   V_strrchr  ( const char *s,     char c             ) { return strrchr( s, c );      }
 inline int     V_strcmp   ( const char *s1,    const char *s2     ) { return strcmp( s1, s2 );     }
 inline int     V_wcscmp   ( const wchar_t *s1, const wchar_t *s2  ) { return wcscmp( s1, s2 );     }
-inline int     V_stricmp  ( const char *s1,    const char *s2     ) { return _stricmp( s1, s2 );   }
+inline int     V_stricmp  ( const char *s1,    const char *s2     ) { return strcasecmp( s1, s2 ); }
 inline char*   V_strstr   ( const char *s1,    const char *search ) { return strstr( s1, search ); }
 inline char*   V_strupr   ( char *start )                           { return strupr( start );      }
 inline char*   V_strlower ( char *start )                           { return strlwr( start );      }

Missing activity ACT_HL2MP_GESTURE_RELOAD_CROSSBOW

This error happens because Valve never made crossbow reload animations for the playermodels, but told it to use ACT_HL2MP_GESTURE_RELOAD_CROSSBOW in the acttable anyway.

--- sourcecode/trunk/game_shared/hl2mp/weapon_crossbow.cpp (revision 336)
+++ sourcecode/trunk/game_shared/hl2mp/weapon_crossbow.cpp (revision 357)
@@ -485,5 +485,5 @@
 	{ ACT_HL2MP_WALK_CROUCH,          ACT_HL2MP_WALK_CROUCH_CROSSBOW,          false },
 	{ ACT_HL2MP_GESTURE_RANGE_ATTACK, ACT_HL2MP_GESTURE_RANGE_ATTACK_CROSSBOW, false },
-	{ ACT_HL2MP_GESTURE_RELOAD,       ACT_HL2MP_GESTURE_RELOAD_CROSSBOW,       false },
+	{ ACT_HL2MP_GESTURE_RELOAD,       ACT_HL2MP_GESTURE_RELOAD_AR2,            false },
 	{ ACT_HL2MP_JUMP,                 ACT_HL2MP_JUMP_CROSSBOW,                 false },
 };

"Extra App ID set to 211, but no SteamAppID" while debugging

This issue happens when mounting multiple GCFs. The fix is to mount appid's in the negative. ie: -320 instead of 320.

Bot physics/hitbox not accurate

--- src/dlls/sdk/sdk_bot_temp.cpp       3 Sep 2006 02:18:03 -0000       1.3
+++ src/dlls/sdk/sdk_bot_temp.cpp       3 Sep 2006 02:36:29 -0000
@@ -52,6 +52,13 @@

        QAngle                  m_ForwardAngle;
        QAngle                  m_LastAngles;
+
+    virtual void PhysicsSimulate() {
+        BaseClass::PhysicsSimulate();
+
+        // Since this isn't called for bots.. call it here
+        UpdateVPhysicsPosition(m_vNewVPhysicsPosition, m_vNewVPhysicsVelocity, gpGlobals->frametime);
+    }
 };

 LINK_ENTITY_TO_CLASS( sdk_bot, CSDKBot );

Bot physics/hitbox not accurate: happens also on HL2MP mod with bots. Any fix for this?

Invalid Combine Ball vphysics

This is an old bug, but still exists in the new SDK. This might be the last of the vphysics bugs?

--- dlls/hl2_dll/prop_combine_ball.h    2006-08-27 18:22:56.255500000 -0500
+++ dlls/hl2_dll/prop_combine_ball.h    2006-08-27 18:22:56.255500000 -0500
@@ -119,6 +119,8 @@

        // Pow!
        void DoExplosion( );
+       void DoExplosion_internal();
+    int OnTakeDamage(const CTakeDamageInfo &info);

        void StartAnimating( void );
        void StopAnimating( void );



--- dlls/hl2_dll/prop_combine_ball.cpp  2006-08-27 18:24:17.364875000 -0500
+++ dlls/hl2_dll/prop_combine_ball.cpp  2006-08-27 18:24:17.364875000 -0500
@@ -974,7 +974,18 @@
 //------------------------------------------------------------------------------
 // Pow!
 //------------------------------------------------------------------------------
-void CPropCombineBall::DoExplosion( )
+void CPropCombineBall::DoExplosion() {
+    // don't call DoExplosion() directly since we might be in a vphysics callback
+    TakeDamage(CTakeDamageInfo(this, this, 1, DMG_PREVENT_PHYSICS_FORCE));
+}
+
+int CPropCombineBall::OnTakeDamage(const CTakeDamageInfo &info) {
+    // now we're safely no longer in a vphysics callback
+    DoExplosion_internal();
+    return 0;
+}
+
+void CPropCombineBall::DoExplosion_internal()
 {
        // Tell the respawner to make a new one
        if ( GetSpawner() )

Wasted entitygroundcontact

It also seems that the code lets every client on the server calculate the minimum and maximum height of each animating entity and sends it to the server, while the server doesn't really need it. Each client calculates the same so it's waste of bandwidth.

It's better to test these changes very good because it's possible it may break something.

Note: Why not instead of compleatly removing it, having only 1 player to calculate it ? (if its a listen server then its the local player, if its a dedicated one what about the player who has been on the most :P/any random player ?) --Filip 06:43, 6 December 2012 (PST)

game_shared/usercmd.cpp

Remove:

#if defined( HL2_CLIENT_DLL )
	if ( to->entitygroundcontact.Count() != 0 )
	{
		buf->WriteOneBit( 1 );
		buf->WriteShort( to->entitygroundcontact.Count() );
		int i;
		for (i = 0; i < to->entitygroundcontact.Count(); i++)
		{
			buf->WriteUBitLong( to->entitygroundcontact[i].entindex, MAX_EDICT_BITS );
			buf->WriteBitCoord( to->entitygroundcontact[i].minheight );
			buf->WriteBitCoord( to->entitygroundcontact[i].maxheight );
		}
		to->entitygroundcontact.RemoveAll();
	}
	else
	{
		buf->WriteOneBit( 0 );
	}
#endif
#if defined( HL2_DLL )
	if ( buf->ReadOneBit() )
	{
		// DM: Fix negative entitygroundcontact crash, from the VDC
		int count = buf->ReadShort();
        if ( count < 0 || count > 140 ) {
            Msg( "Ignoring strange entitygroundcontact count: %d\n", count );
            return; // why can this be less than 0, Valve? change to ReadWord()???
        }
		move->entitygroundcontact.SetCount( count );

		int i;
		for (i = 0; i < move->entitygroundcontact.Count(); i++)
		{
			move->entitygroundcontact[i].entindex = buf->ReadUBitLong( MAX_EDICT_BITS );
			move->entitygroundcontact[i].minheight = buf->ReadBitCoord( );
			move->entitygroundcontact[i].maxheight = buf->ReadBitCoord( );
		}
	}
#endif

game_shared/usercmd.h

Remove:

class CEntityGroundContact
{
public:
	int					entindex;
	float				minheight;
	float				maxheight;
};
#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
		entitygroundcontact.RemoveAll();
#endif
#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
		entitygroundcontact			= src.entitygroundcontact;
#endif
#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
	CUtlVector< CEntityGroundContact > entitygroundcontact;
#endif

dlls/player_command.cpp

Remove:

#if defined (HL2_DLL)
	// pull out backchannel data and move this out

	int i;
	for (i = 0; i < cmd->entitygroundcontact.Count(); i++)
	{
		int entindex =  cmd->entitygroundcontact[i].entindex;
		CBaseEntity *pEntity = CBaseEntity::Instance( engine->PEntityOfEntIndex( entindex) );
		if (pEntity)
		{
			CBaseAnimating *pAnimating = pEntity->GetBaseAnimating();
			if (pAnimating)
			{
				pAnimating->SetIKGroundContactInfo( cmd->entitygroundcontact[i].minheight, cmd->entitygroundcontact[i].maxheight );
			}
		}
	}

#endif

cl_dll/input.h

Remove:

#if defined( HL2_CLIENT_DLL ) 
        CUtlVector< CEntityGroundContact > m_EntityGroundContact; 
#endif

cl_dll/in_main.cpp

Comment out the entire function CInput::AddIKGroundContactInfo

Resizing game window glitches HUD elements

Fix:

--- mod/src/cl_dll/game_controls/vgui_TeamFortressViewport.cpp  21 Feb 2006 01:58:36 -0000      1.6
+++ mod/src/cl_dll/game_controls/vgui_TeamFortressViewport.cpp  16 Jul 2006 20:52:44 -0000
@@ -152,6 +152,9 @@
        m_pBackGround->SetZPos( -20 ); // send it to the back
        m_pBackGround->SetVisible( false );
        CreateDefaultPanels();
+
+       // reload again... this fixes the ammo display etc
+       ReloadScheme( NULL );
 }

Mod fails to compile with gcc 4.x

Note.pngNote:Even if you apply these fixes, gcc 4 still won't work. However both of these fixes seem reasonable on 3.x as well.

Fix: First pass problem is a code bug - not sure if this would've shown up in gcc 3.x if Valve didn't use the horribly evil -w option, but it certainly looks like invalid code to reference a friend function without a declaration.

--- mod/src/dlls/baseentity.h   2005/08/29 00:14:40     1.3
+++ mod/src/dlls/baseentity.h   2006/06/07 02:17:03
@@ -325,6 +325,9 @@
 #define CREATE_PREDICTED_ENTITY( className )   \
        CBaseEntity::CreatePredictedEntityByName( className, __FUNCTION__, __LINE__ );

+void SendProxy_Origin( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID );
+void SendProxy_Angles( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID );
+
 //
 // Base Entity.  All entity types derive from this
 //

Looks like the only other issue was this asm change. Apparently gcc did something slightly backwards incompatible in 4.x.

--- src/public/mathlib.cpp      18 Feb 2005 04:45:56 -0000      1.1.1.1
+++ src/public/mathlib.cpp      11 Jun 2006 19:45:34 -0000
@@ -436,7 +436,6 @@
                "movss %%xmm0, %0 \n\t"
                : "=m" (x)
                : "m" (rroot)
-               : "%xmm0"
        );
 #else
 #error

Case changes in player names cause chat truncation

--- mod/src/cl_dll/hl2mp/hl2mp_hud_chat.cpp     2006/02/21 01:58:38     1.3
+++ mod/src/cl_dll/hl2mp/hl2mp_hud_chat.cpp     2006/03/28 03:11:13
@@ -422,8 +422,9 @@
        else
                line->InsertColorChange( Color( g_ColorYellow[0], g_ColorYellow[1], g_ColorYellow[2], 255 ) );

-       char *buf = static_cast<char *>( stackalloc( strlen( pmsg ) + 1  ) );
-       wchar_t *wbuf = static_cast<wchar_t *>( stackalloc( (strlen( pmsg ) + 1 ) * sizeof(wchar_t) ) );
+       char buf[4096];
+       wchar_t wbuf[4096];
+       Assert(strlen(pmsg) < sizeof(buf)); // otherwise message truncation will occur
        if ( buf )
        {
                float *flColor = GetClientColor( iPlayerIndex );
@@ -435,10 +436,10 @@
                buf[ min( iNameLength, MAX_PLAYER_NAME_LENGTH+31) ] = 0;
                line->InsertColorChange( Color( flColor[0], flColor[1], flColor[2], 255 ) );
                line->InsertString( buf );
-               Q_strncpy( buf, pmsg + iNameLength, strlen( pmsg ));
+               Q_strncpy(buf, pmsg + iNameLength, sizeof(buf));
                buf[ strlen( pmsg + iNameLength ) ] = '\0';
                line->InsertColorChange( Color( g_ColorYellow[0], g_ColorYellow[1], g_ColorYellow[2], 255 ) );
-               vgui::localize()->ConvertANSIToUnicode( buf, wbuf, strlen(pmsg)*sizeof(wchar_t));
+               vgui::localize()->ConvertANSIToUnicode( buf, wbuf, sizeof(wbuf));
                line->InsertString( wbuf );
                line->SetVisible( true );
                line->SetNameLength( iNameLength );

--- mod/src/tier1/stringpool.cpp        2005/02/18 04:45:59     1.1.1.1
+++ mod/src/tier1/stringpool.cpp        2006/03/28 03:25:05
@@ -22,7 +22,7 @@

 bool StrLess( const char * const &pszLeft, const char * const &pszRight )
 {
-       return ( Q_stricmp( pszLeft, pszRight) < 0 );
+       return ( Q_strcmp( pszLeft, pszRight) < 0 );
 }

 //-----------------------------------------------------------------------------
--- mod/src/cl_dll/sdk/sdk_hud_chat.cpp	2006/02/21 01:58:38	1.3
+++ mod/src/cl_dll/sdk/sdk_hud_chat.cpp	2006/03/28 03:34:35
@@ -422,8 +422,9 @@
 	else
 		line->InsertColorChange( Color( g_ColorYellow[0], g_ColorYellow[1], g_ColorYellow[2], 255 ) );
 
-	char *buf = static_cast<char *>( stackalloc( strlen( pmsg ) + 1  ) );
-	wchar_t *wbuf = static_cast<wchar_t *>( stackalloc( (strlen( pmsg ) + 1 ) * sizeof(wchar_t) ) );
+	char buf[4096];
+	wchar_t wbuf[4096];
+    assert(strlen(pmsg) < sizeof(buf)); // otherwise message truncation will occur
 	if ( buf )
 	{
 		float *flColor = GetClientColor( iPlayerIndex );
@@ -435,10 +436,10 @@
 		buf[ min( iNameLength, MAX_PLAYER_NAME_LENGTH+31) ] = 0;
 		line->InsertColorChange( Color( flColor[0], flColor[1], flColor[2], 255 ) );
 		line->InsertString( buf );
-		Q_strncpy( buf, pmsg + iNameLength, strlen( pmsg ));
+		Q_strncpy(buf, pmsg + iNameLength, sizeof(buf));
 		buf[ strlen( pmsg + iNameLength ) ] = '\0';
 		line->InsertColorChange( Color( g_ColorYellow[0], g_ColorYellow[1], g_ColorYellow[2], 255 ) );
-		vgui::localize()->ConvertANSIToUnicode( buf, wbuf, strlen(pmsg)*sizeof(wchar_t));
+		vgui::localize()->ConvertANSIToUnicode( buf, wbuf, sizeof(wbuf));
 		line->InsertString( wbuf );
 		line->SetVisible( true );
 		line->SetNameLength( iNameLength );
Note.pngNote:I've never actually tested the patch to sdk_hud_chat.cpp, but the code is identical to hl2mp_hud_chat.cpp so it should work.

dm_powerhouse lights never slow down

Workaround: Really this should be fixed in the map, but good luck waiting on that to happen. In the mean time here's a code patch for any such mapping errors:

--- mod/src/dlls/physconstraint.cpp     2005/03/26 17:44:28     1.2
+++ mod/src/dlls/physconstraint.cpp     2006/03/06 02:45:47
@@ -727,6 +727,16 @@
                for ( int i = 0; i < 2; i++ )
                {
                        info.pObjects[i]->WorldToLocal( &ballsocket.constraintPosition[i], GetAbsOrigin() );
+            // HACKHACK - the mapper forgot to put in some sane physics damping (dm_powerhouse)
+            float damping, adamping;
+            info.pObjects[i]->GetDamping(&damping, &adamping);
+            if (damping < .2f) {
+                damping = .2f;
+            }
+            if (adamping < .2f) {
+                adamping = .2f;
+            }
+            info.pObjects[i]->SetDamping(&damping, &damping);
                }
                GetBreakParams( ballsocket.constraint, info );
                ballsocket.constraint.torqueLimit = 0;

Wall Boosting Exploit

Hi, everyone would of no doubt noticed that running against a wall(strafing and moving forward works best) makes you run really fast. If anyone has played kreedz climbing yet(I used to code for it) you might of noticed moving against walls is jerky. I think when I was adding some things to the movement I made the server and client disagree on what speed the player is moving at. Has anyone sound why players in source do this? where the boost might be clamped to normal levels? If so I'd love to know, and it would be good to know for bg2 as well, people who play it complain a lot of it as well(just the boost, not client prediction jerks).

Fix Provided by Tony "omega" Sergi

mod/game_shared/gamemovement.cpp Line 1374

void CGameMovement::Accelerate( Vector& wishdir, float wishspeed, float
accel )
{
	int i;
	float addspeed, accelspeed, currentspeed;

	// This gets overridden because some games (CSPort) want to allow dead (observer) players
	// to be able to move around.
	if ( !CanAccelerate() )
		return;

	//omega; WALLSTRAFE FIX

	// See if we are changing direction a bit
	//	currentspeed = mv->m_vecVelocity.Dot(wishdir);

	currentspeed = sqrt( DotProduct(mv->m_vecVelocity, mv->m_vecVelocity) );
	//omega; END WALLSTRAFE FIX

	// Reduce wishspeed by the amount of veer.


GNU crasher for maps with broken ladders

Fix: Valve's code is invalid but compiles on MSVC due to its D.W.I.M. philosophy. The following patch is required:

--- mod/src/game_shared/func_ladder.cpp 2005/06/11 22:14:32     1.2
+++ mod/src/game_shared/func_ladder.cpp 2006/02/12 19:43:25
@@ -87,7 +87,7 @@
                                m_vecPlayerMountPositionBottom.GetZ(),
                                bottomtrace.m_pEnt
                                        ?
-                                       UTIL_VarArgs( "%s/%s", bottomtrace.m_pEnt->GetClassname(), bottomtrace.m_pEnt->GetEntityName() )
+                                       UTIL_VarArgs( "%s/%s", bottomtrace.m_pEnt->GetClassname(), STRING(bottomtrace.m_pEnt->GetEntityName()) )
                                        :
                                        "NULL" );
                }
@@ -99,7 +99,7 @@
                                m_vecPlayerMountPositionTop.GetZ(),
                                toptrace.m_pEnt
                                        ?
-                                       UTIL_VarArgs( "%s/%s", toptrace.m_pEnt->GetClassname(), toptrace.m_pEnt->GetEntityName() )
+                                       UTIL_VarArgs( "%s/%s", toptrace.m_pEnt->GetClassname(), STRING(toptrace.m_pEnt->GetEntityName()) )
                                        :
                                        "NULL" );
                }

sdkshaders: fix for spaces in path

Issue: Any attempt to compile the SDK shaders for a mod with spaces in the path name results in failure:

(ie: "C:\Program Files\Steam\SteamApps\SourceMods\MODNAME\src\src\sdkshaders")

This is due to the fact that the perl scripts and bat files have not been properly modified to handle spaces in the path.


Fix: Ray "VisualPhoenix" Barbiero has provided the following patches:

Note.pngNote:These patches have been tested on paths with and without spaces.

updateshaders.pl

--- mod/src/devtools/bin/updateshaders.pl	2005-07-14 09:58:54.000000000 -0500
+++ mod/src/devtools/bin/updateshaders.pl	2005-10-11 23:42:36.000000000 -0500
@@ -105,7 +105,7 @@
 	{
 		$xboxswitch = "-xbox ";
 	}
-	print MAKEFILE "\t$g_SourceDir\\devtools\\bin\\perl.exe $g_SourceDir\\devtools\\bin\\" . $shadertype . "_prep.pl $xboxswitch -shaderoutputdir $shaderoutputdir -source \"$g_SourceDir\" $shadername\n";
+	print MAKEFILE "\t\"$g_SourceDir\\devtools\\bin\\perl.exe\" \"$g_SourceDir\\devtools\\bin\\" . $shadertype . "_prep.pl\" $xboxswitch -shaderoutputdir $shaderoutputdir -source \"$g_SourceDir\" $shadername\n";
 	my $filename;
 	if( $shadertype eq "fxc" )
 	{
@@ -199,14 +199,14 @@
 		# We only generate inc files for fxc and vsh files.
 		if( $g_xbox )
 		{
-			print MAKEFILE " $shadertype" . "tmp_xbox\\" . $shaderbase . "\.inc";
+			print MAKEFILE " \"$shadertype" . "tmp_xbox\\" . $shaderbase . "\.inc\"";
 		}
 		else
 		{
-			print MAKEFILE " $shadertype" . "tmp9\\" . $shaderbase . "\.inc";
+			print MAKEFILE " \"$shadertype" . "tmp9\\" . $shaderbase . "\.inc\"";
 		}
 	}
-	print MAKEFILE " $shaderoutputdir\\$shadertype\\$shaderbase\.vcs";
+	print MAKEFILE " \"$shaderoutputdir\\$shadertype\\$shaderbase\.vcs\"";
 }
 print MAKEFILE "\n\n";
 
@@ -221,11 +221,11 @@
 		# We only generate inc files for fxc and vsh files.
 		if( $g_xbox )
 		{
-			print MAKEFILE "\tdel /f /q $shadertype" . "tmp_xbox\\" . $shaderbase . "\.inc\n";
+			print MAKEFILE "\tdel /f /q \"$shadertype" . "tmp_xbox\\" . $shaderbase . "\.inc\"\n";
 		}
 		else
 		{
-			print MAKEFILE "\tdel /f /q $shadertype" . "tmp9\\" . $shaderbase . "\.inc\n";
+			print MAKEFILE "\tdel /f /q \"$shadertype" . "tmp9\\" . $shaderbase . "\.inc\"\n";
 		}
 	}
 	print MAKEFILE "\tdel /f /q \"$shaderoutputdir\\$shadertype\\$shaderbase\.vcs\"\n";

buildshaders.bat

--- mod/src/materialsystem/stdshaders/buildshaders.bat	2005-07-14 10:00:36.000000000 -0500
+++ mod/src/materialsystem/stdshaders/buildshaders.bat	2005-10-11 23:01:08.000000000 -0500
@@ -36,7 +36,7 @@
 REM ****************
 :set_xbox_args
 set xbox_args=-xbox
-set targetdir=%vproject%\shaders_xbox
+set targetdir="%vproject%\shaders_xbox"
 goto build_shaders
 
 
@@ -45,8 +45,8 @@
 REM ****************
 :set_mod_args
 
-if not exist %sourcesdk%\bin\shadercompile.exe goto NoShaderCompile
-set ChangeToDir=%sourcesdk%\bin
+if not exist "%sourcesdk%\bin\shadercompile.exe" goto NoShaderCompile
+set ChangeToDir="%sourcesdk%\bin"
 
 if /i "%4" NEQ "-source" goto NoSourceDirSpecified
 set SrcDirBase=%~5
@@ -75,7 +75,7 @@
 
 :NoShaderCompile
 echo -
-echo - ERROR: shadercompile.exe doesn't exist in %sourcesdk%\bin
+echo - ERROR: shadercompile.exe doesn't exist in "%sourcesdk%\bin"
 echo -
 goto end
 
@@ -129,7 +129,7 @@
 REM ****************
 REM Execute distributed process on work/build list
 REM ****************
-"%SrcDirBase%\devtools\bin\perl" "%SrcDirBase%\materialsystem\stdshaders\runvmpi.pl" %xbox_args% -changetodir "%ChangeToDir%" %SDKArgs%
+"%SrcDirBase%\devtools\bin\perl" "%SrcDirBase%\materialsystem\stdshaders\runvmpi.pl" %xbox_args% -changetodir %ChangeToDir% %SDKArgs%
 
 REM ****************
 REM Copy the generated files to the output dir.

runvmpi.pl

--- mod/src/materialsystem/stdshaders/runvmpi.pl	2005-07-14 10:00:34.000000000 -0500
+++ mod/src/materialsystem/stdshaders/runvmpi.pl	2005-10-11 22:34:02.000000000 -0500
@@ -41,7 +41,7 @@
 $shaderpath =~ s,/,\\,g;
 chdir $changeToDir;
 
-$cmdToRun = "shadercompile.exe $noMPI $xboxFlag -shaderpath $shaderpath -mpi_workercount 32 -allowdebug $gameFlag";
+$cmdToRun = "shadercompile.exe $noMPI $xboxFlag -shaderpath \"$shaderpath\" -mpi_workercount 32 -allowdebug $gameFlag";
 system $cmdToRun;
 
 # other options..

build_sample_shaders.bat

--- mod/src/sdkshaders/build_sample_shaders.bat	2005-07-14 09:57:02.000000000 -0500
+++ mod/src/sdkshaders/build_sample_shaders.bat	2005-10-11 23:38:18.000000000 -0500
@@ -9,7 +9,7 @@
 
 
 rem **** Call the batch files to build our stuff.
-call ..\materialsystem\stdshaders\buildshaders.bat sdk_shaders -game "%__GameDir%" -source ..
+call ..\materialsystem\stdshaders\buildshaders.bat sdk_shaders -game "%__GameDir%" -source .\..
 goto end


Getting the SDK to work under -Wall -Werror

If you're a professional programmer with any familiarity with GNU then the first thing you probably did was attempt to compile the SDK with -Wall -Werror, and were then disappointed by all the violations in Valve's code out of the box. Here's a list of fixes to make this work. (This list is by no means complete - I fixed many problems before I realized this would be something worth wiki-ing.)

I just noticed Valve uses -fpermissive! *barf*! So, if anyone out there had already noticed that, I now have a work in progress to fix all the scary hacks that -fpermissive would normally error on... coming soon. --Bloodykenny 20:46, 25 Oct 2005 (PDT)

offsetof errors

These are due to a bug in gcc. It was fixed in 3.4.2, and gcc 3.4.4 is now known to work fine and fixes the issue.

Downcast explicitly

One should always downcast explicitly. This squelches useful warnings, and self-documents your intent to downcast.

--- mod/src/public/tier0/fasttimer.h    2005/06/11 22:14:36     1.2
+++ mod/src/public/tier0/fasttimer.h    2005/09/14 00:25:19
@@ -253,7 +253,7 @@
 inline void CCycleCount::Init( float initTimeMsec )
 {
        if ( g_ClockSpeedMillisecondsMultiplier > 0 )
-               m_Int64 = initTimeMsec / g_ClockSpeedMillisecondsMultiplier;
+               m_Int64 = int64(initTimeMsec / g_ClockSpeedMillisecondsMultiplier);
        else
                m_Int64 = 0;
 }

Poor abused templates

  • This code fixes some badly used Memory Templates, and provides compatibility with Unix based systems.
--- mod/src/public/tier1/utlmemory.h    2005/02/18 04:45:58     1.1.1.1
+++ mod/src/public/tier1/utlmemory.h    2005/09/14 00:24:15
@@ -293,7 +293,7 @@
 {
        Assert( num > 0 );

-       if (IsExternallyAllocated())
+    if (CUtlMemory<T>::IsExternallyAllocated())
        {
                // Can't grow a buffer whose memory was externally allocated
                Assert(0);
@@ -349,7 +349,7 @@
        if (m_nAllocationCount >= num)
                return;

-       if (IsExternallyAllocated())
+    if (CUtlMemory<T>::IsExternallyAllocated())
        {
                // Can't grow a buffer whose memory was externally allocated
                Assert(0);
@@ -376,7 +376,7 @@
 template< class T >
 void CUtlMemory<T>::Purge()
 {
-       if (!IsExternallyAllocated())
+    if (!CUtlMemory<T>::IsExternallyAllocated())
        {
                if (m_pMemory)
                {
@@ -495,7 +495,7 @@
 {
        Assert( num > 0 );

-       if (IsExternallyAllocated())
+    if (CUtlMemory<T>::IsExternallyAllocated())
        {
                // Can't grow a buffer whose memory was externally allocated
                Assert(0);
@@ -551,7 +551,7 @@
        if (CUtlMemory<T>::m_nAllocationCount >= num)
                return;

-       if (IsExternallyAllocated())
+    if (CUtlMemory<T>::IsExternallyAllocated())
        {
                // Can't grow a buffer whose memory was externally allocated
                Assert(0);
@@ -579,7 +579,7 @@
 template< class T, int nAlignment >
 void CUtlMemoryAligned<T, nAlignment>::Purge()
 {
-       if (!IsExternallyAllocated())
+    if (!CUtlMemory<T>::IsExternallyAllocated())
        {
                if (m_pMemoryBase)
                {

Missing EOF linefeeds

First you'll need to `cvs rm -f mod/src/dlls/worker_scientist.h` since that file is blank, unused, and will make the script below not run. :)

Then run:

#!/usr/bin/perl -w

use strict;
foreach (`find mod -name *.cpp -or -name *.h`) {
    chomp;
    open(F, "+<", $_) or die "$! on $_";
    seek(F, -1, 2) or die "$! on $_";
    my $c;
    read(F, $c, 1) or die "$! on $_";
    if ($c ne "\n") {
        print "$_\n";
        print(F "\n");
    }
}

Garbage after #endifs

A common mistake in the SDK, obviously trivial to fix, but here for your conveniance:

diff -w -u -r1.3 ai_basenpc.cpp
--- dlls/ai_basenpc.cpp 2005/06/11 22:14:26     1.3
+++ dlls/ai_basenpc.cpp 2005/09/10 18:16:13
@@ -8450,7 +8450,7 @@

        return shotDir;
 }
-#endif HL2_DLL
+#endif // HL2_DLL

 //-----------------------------------------------------------------------------



diff -w -u -r1.1.1.1 npc_BaseZombie.cpp
--- dlls/hl2_dll/npc_BaseZombie.cpp     2005/02/18 04:45:52     1.1.1.1
+++ dlls/hl2_dll/npc_BaseZombie.cpp     2005/09/10 20:57:40
@@ -1582,7 +1582,7 @@

 #ifdef DEBUG_ZOMBIES
                        DevMsg("Wandering\n");
-#endif+
+#endif

                        // Just lost track of our enemy.
                        // Wander around a bit so we don't look like a dingus.



diff -w -u -r1.2 memalloc.h
--- public/tier0/memalloc.h     2005/02/19 18:24:26     1.2
+++ public/tier0/memalloc.h     2005/09/10 05:12:39
@@ -133,6 +133,6 @@
 #define MEM_ALLOC_CREDIT_CLASS()
 #define MEM_ALLOC_CLASSNAME(type) NULL

-#endif !STEAM && NO_MALLOC_OVERRIDE
+#endif // !STEAM && NO_MALLOC_OVERRIDE

 #endif /* TIER0_MEMALLOC_H */




snprintf strangeness

There are several conflicting snprintf defines and other snprintf porting bugs in the SDK, which need to be fixed for Werror compatibility:

diff -w -u -r1.1.1.1 interface.h
--- public/tier1/interface.h    2005/02/18 04:45:58     1.1.1.1
+++ public/tier1/interface.h    2005/09/10 06:09:25
@@ -33,8 +33,6 @@

 #define HMODULE void *
 #define GetProcAddress dlsym
-
-#define _snprintf snprintf
 #endif

 // TODO: move interface.cpp into tier0 library.



diff -w -u -r1.1.1.1 interface.cpp
--- tier1/interface.cpp 2005/02/18 04:45:59     1.1.1.1
+++ tier1/interface.cpp 2005/09/10 21:18:20
@@ -191,7 +191,7 @@
                Q_snprintf( str, sizeof(str), "%s.dll", szAbsoluteModuleName );
                hDLL = LoadLibrary( str );
 #elif _LINUX
-               _snprintf( str, sizeof(str), "%s_i486.so", szAbsoluteModuleName );
+               Q_snprintf( str, sizeof(str), "%s_i486.so", szAbsoluteModuleName );
                 hDLL = dlopen(str, RTLD_NOW);
 #endif

Broken comments

Ending a // comment with \ is just begging for trouble...

diff -w -u -r1.1.1.1 collisionutils.cpp
--- public/collisionutils.cpp   2005/02/18 04:45:56     1.1.1.1
+++ public/collisionutils.cpp   2005/09/10 23:59:09
@@ -2299,7 +2299,7 @@

        return true;
 }
-
+/*
 //--------------------------------------------------------------------------
 // Purpose:
 //
@@ -2314,7 +2314,7 @@
 //    0-----2
 //
 //--------------------------------------------------------------------------
-
+*/
 //-----------------------------------------------------------------------------
 // Purpose: find the minima and maxima of the 3 given values
 //-----------------------------------------------------------------------------

First big pass at -Wall and consistent code

Convert stricmp, _alloca etc to Q_stricmp, stackalloc versions. Fix basetype declarations like 0 to 0.0f when appropriate. Comply with STL min/max. Comply with POSIX/BSD naming inline (and appropriate #ifdefing) in all cases where a cross-platform compatibility utility function does not yet exist.

You'll need to remove the inappropriate -D defines in the Makefile for the str/printf/alloc things. Those are now fixed by using the correct functions in the code to begin with, however I don't have a patch for the Makefile included in the file below.

I have uploaded this file for BloodKenny at -

http://www.nigredostudios.com/temp/patch_hl2_sdk_wall_sanity.txt

Right click save as - amckern

Second pass - fix unreliable and error/warning prone min/max/clamp macros with STL calls and normal templatization:

http://aoa.gamemod.net/patch-warning-minmax.txt

Server: Host_Error: SV_PackEntity: SendTable_Encode returned false (ent %d).

Here %d will be replaced by whatever the entity number is that caused the error. No single entity is allowed to write more than 2KB to the network stream. This error happens when an entity overflows that buffer.

Fix: If you need an entity to occasionally transmit more than 2K of data, you will need to split it up into multiple entities, each transmitting part of the data. You should ensure of course that no entity -consistently- transmits 2K of data, as it would bog down your network. Some entities might want to send a large amount on map initialization etc, however. Another possible workaround for some situations (may not always be possible), is to update data a little bit each frame, so that no one frame has a big change.

Server: The client's health variable is pointlessly sent across the wire twice.

Fix: Diff And Patch

  • There is no line 1888 within c_baseplayer.cpp in the stock MP, or SP SDK's - do i just tack the code onto the end (The BaseClass::SetGroundEntity(ground); is also not there) --Amckern 22:46, 5 Nov 2005 (PST)

Ah, sorry. That patch was against an already-modified file, not a fresh SDK. The SetGroundEntity is part of my mod. :) Yes tack it onto the end. After you do so, post the diff back here! --Bloodykenny 09:25, 12 Nov 2005 (PST)

--- mod/src/cl_dll/c_baseplayer.cpp     2005/06/30 05:54:09     1.6
+++ mod/src/cl_dll/c_baseplayer.cpp     2005/07/16 21:33:33
@@ -1888,3 +1888,7 @@
    BaseClass::SetGroundEntity(ground);
}

+
+int C_BasePlayer::GetHealth() const {
+    return g_PR->GetHealth(entindex());
+}



--- mod/src/cl_dll/c_baseplayer.h       2005/07/11 03:28:41     1.9
+++ mod/src/cl_dll/c_baseplayer.h       2005/07/16 21:05:31
@@ -103,7 +103,7 @@

        // Data handlers
        virtual bool    IsPlayer( void ) const { return true; };
-       virtual int             GetHealth() const { return m_iHealth; };
+       virtual int             GetHealth() const;

        // observer mode
        virtual int                     GetObserverMode() const;



--- mod/src/dlls/player.cpp     2005/07/12 07:38:04     1.33
+++ mod/src/dlls/player.cpp     2005/07/22 00:45:48
@@ -58,6 +58,8 @@
 #include "nav_mesh.h"
 #include "env_zoom.h"

+#include "player_resource.h"
+
 #ifdef HL2_DLL
 #include "combine_mine.h"
 #include "weapon_physcannon.h"
@@ -4295,6 +4297,9 @@
        m_lastx = m_lasty = 0;

        m_lastNavArea = NULL;
+
+    // update now so that our new health gets sent with the respawn notice
+    g_pPlayerResource->SetPlayerHealth(entindex(), m_iHealth);

        /// @todo Do this once per round instead of once per player
        if (TheNavMesh)



--- mod/src/dlls/player_resource.cpp    2005/06/19 02:54:04     1.5
+++ mod/src/dlls/player_resource.cpp    2005/07/22 00:44:35
@@ -85,6 +85,13 @@
 }

 //-----------------------------------------------------------------------------
+// Purpose: Sets health value for a particular client (used to set on spawn so the data will be sent synchronously)
+//-----------------------------------------------------------------------------
+void CPlayerResource::SetPlayerHealth(int entindex, int health) {
+    m_iHealth.Set(entindex, health);
+}
+
+//-----------------------------------------------------------------------------
 // Purpose: The Player resource is always transmitted to clients
 //-----------------------------------------------------------------------------
 int CPlayerResource::UpdateTransmitState()



--- mod/src/dlls/player_resource.h      2005/06/18 21:16:29     1.3
+++ mod/src/dlls/player_resource.h      2005/07/22 00:42:57
@@ -26,6 +26,8 @@
        virtual void UpdatePlayerData( void );
        virtual int  UpdateTransmitState(void);

+    void SetPlayerHealth(int entindex, int health);
+
 protected:
        // Data for each player that's propagated to all clients
        // Stored in individual arrays so they can be sent down via datatables

Then you can remove the SendPropInt and RecvPropInt for CBasePlayer::m_iHealth...

--- src/cl_dll/c_baseplayer.cpp	26 Aug 2006 21:24:21 -0000	1.14
+++ src/cl_dll/c_baseplayer.cpp	4 Sep 2006 18:33:46 -0000
@@ -222,7 +222,7 @@
 		RecvPropEHandle( RECVINFO(m_hVehicle) ),
 		RecvPropEHandle( RECVINFO(m_hUseEntity) ),
 
-		RecvPropInt		(RECVINFO(m_iHealth)),
+		// RecvPropInt		(RECVINFO(m_iHealth)),
 		RecvPropInt		(RECVINFO(m_lifeState)),
 
 		RecvPropFloat	(RECVINFO(m_flMaxspeed)),
@@ -284,7 +284,7 @@
 
 	DEFINE_PRED_FIELD( m_hVehicle, FIELD_EHANDLE, FTYPEDESC_INSENDTABLE ),
 	DEFINE_PRED_FIELD_TOL( m_flMaxspeed, FIELD_FLOAT, FTYPEDESC_INSENDTABLE, 0.5f ),
-	DEFINE_PRED_FIELD( m_iHealth, FIELD_INTEGER, FTYPEDESC_INSENDTABLE ),
+	// DEFINE_PRED_FIELD( m_iHealth, FIELD_INTEGER, FTYPEDESC_INSENDTABLE ),
 	DEFINE_PRED_FIELD( m_fOnTarget, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE ),
 	DEFINE_PRED_FIELD( m_nNextThinkTick, FIELD_INTEGER, FTYPEDESC_INSENDTABLE ),
 	DEFINE_PRED_FIELD( m_lifeState, FIELD_CHARACTER, FTYPEDESC_INSENDTABLE ),


--- src/cl_dll/c_baseplayer.h	26 Aug 2006 21:24:21 -0000	1.19
+++ src/cl_dll/c_baseplayer.h	4 Sep 2006 18:33:46 -0000
@@ -377,7 +377,7 @@
 	EHANDLE			m_hUseEntity;
 	
 	float			m_flMaxspeed;
-	int				m_iHealth;
+	void			m_iHealth(); // hide the base class m_iHealth to ensure it's not used
 
 	CInterpolatedVar< Vector >	m_iv_vecViewOffset;
 


--- src/dlls/player.cpp	3 Sep 2006 23:29:16 -0000	1.76
+++ src/dlls/player.cpp	4 Sep 2006 18:33:47 -0000
@@ -7298,7 +7298,7 @@
 		SendPropDataTable(SENDINFO_DT(pl), &REFERENCE_SEND_TABLE(DT_PlayerState), SendProxy_DataTableToDataTable),
 		SendPropEHandle(SENDINFO(m_hVehicle)),
 		SendPropEHandle(SENDINFO(m_hUseEntity)),
-		SendPropInt		(SENDINFO(m_iHealth), 10 ),
+		// SendPropInt		(SENDINFO(m_iHealth), 10 ),
 		SendPropInt		(SENDINFO(m_lifeState), 3, SPROP_UNSIGNED ),
 		SendPropFloat	(SENDINFO(m_flMaxspeed), 12, SPROP_ROUNDDOWN, 0.0f, 2048.0f ),  // CL
 		SendPropInt		(SENDINFO(m_fFlags), PLAYER_FLAG_BITS, SPROP_UNSIGNED|SPROP_CHANGES_OFTEN, SendProxy_CropFlagsToPlayerFlagBitsLength ),


--- src/game_shared/gamemovement.cpp	26 Aug 2006 21:24:36 -0000	1.21
+++ src/game_shared/gamemovement.cpp	4 Sep 2006 18:33:47 -0000
@@ -490,7 +490,7 @@
 
 bool CGameMovement::IsDead( void ) const
 {
-	return ( player->m_iHealth <= 0 ) ? true : false;
+	return ( player->GetHealth() <= 0 ) ? true : false;
 }
 
 //-----------------------------------------------------------------------------

Server: The client's team membership is pointlessly sent across the wire twice.

Similar to the above KI, but for another variable. Also this fixes an SDK crasher, but according to Yahn at Valve, Steam will be fixed soon to not do that.

Fix: Diff And Patch

--- mod/src/dlls/team.cpp       2005/06/11 22:14:30     1.2
+++ mod/src/dlls/team.cpp       2006/05/29 18:58:52     1.3
@@ -19,6 +19,7 @@
 //-----------------------------------------------------------------------------
 void SendProxy_PlayerList( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID )
 {
+    Assert(0);
        CTeam *pTeam = (CTeam*)pData;

        // If this assertion fails, then SendProxyArrayLength_PlayerArray must have failed.
@@ -31,8 +32,11 @@

 int SendProxyArrayLength_PlayerArray( const void *pStruct, int objectID )
 {
-       CTeam *pTeam = (CTeam*)pStruct;
-       return pTeam->m_aPlayers.Count();
+    // The RecvPropArray2 in general was seemingly broken in the May 25th-ish core engine update.
+    // The CTeam in particular was certainly broken at that time, however, thankfully it doesn't
+    // serve any important purpose.
+    // For backwards compatibility with old client, we disable it, rather than remove it entirely.
+    return 0;
 }

Server: weapon_citizensuitcase Assert on startup

Fix: Install copy of the SP SDK, then copy the scripts/ directory over

Server: Some bullet weapons set to do 0 damage.

Fix: Need to edit their AddAmmoType which are strangely set to 0 for some reason.

Server: Some projectile weapons set to do 0 damage.

Fix: Need to edit their source files and set a damage.

Client: --- Missing Vgui material vgui/steam/games/icon_cz

Fix: These files are used in the currently inaccessible Friends IM client. Create 4 vmts in their places of any design to remove the error.

  • materials\VGUI\steam\games\icon_cs.vmt
  • materials\VGUI\steam\games\icon_dod.vmt
  • materials\VGUI\steam\games\icon_hl2mp.vmt
  • materials\VGUI\servers\icon_secure_deny.vmt

Here's a patch to create files for the first three. (I don't see the icon_secure_deny.vmt error, so didn't create anything for it.)

--- materials/VGUI/steam/games/icon_cs.vmt      1969-12-31 18:00:00.000000000 -0600
+++ materials/VGUI/steam/games/icon_cs.vmt      2005-07-28 01:54:17.000000000 -0500
@@ -0,0 +1 @@
+"UnlitGeneric" {}
--- materials/VGUI/steam/games/icon_dod.vmt     1969-12-31 18:00:00.000000000 -0600
+++ materials/VGUI/steam/games/icon_dod.vmt     2005-07-28 01:54:19.000000000 -0500
@@ -0,0 +1 @@
+"UnlitGeneric" {}
--- materials/VGUI/steam/games/icon_hl2mp.vmt   1969-12-31 18:00:00.000000000 -0600
+++ materials/VGUI/steam/games/icon_hl2mp.vmt   2005-07-28 01:54:15.000000000 -0500
@@ -0,0 +1 @@
+"UnlitGeneric" {}

Fix2: Add clear to your rc file in cfg (extract from gcf if non-existant)

Server: The crossbow causes an assertion failure.

Fix: Comment out ai_activity.cpp line 53. This doesn't appear to be something that can be fixed in code?

Server? Client?: RL explosion invisible

Per http://www.chatbear.com/board.plm?a=viewthread&t=970,1107153392,30132&id=786504&b=4991&v=flatold

The patch to c_te_explosion.cpp was rolled into the 2006-08-04 SDK update, however it does not fix the issue. The issue still exists. My current speculation is that this is a bug in core or in the maps, but hard to say which.

sv_gravity is not associated with physics gravity

When gravity is changed, the physics gravity isn't updated

Fix: In movevars_shared.cpp:

inline void UpdatePhysicsGravity(float gravity)
{
	if(physenv)
		physenv->SetGravity(Vector(0,0,-gravity));
}
static void GravityChanged_Callback( ConVar *var, const char *pOldString )
{
#ifndef CLIENT_DLL
	UpdatePhysicsGravity(var->GetFloat());
	if(gpGlobals->mapname!=NULL_STRING)
	{
		IGameEvent *event = gameeventmanager->CreateEvent( "gravity_change" );
		if ( event )
		{
			event->SetFloat( "newgravity", var->GetFloat() );
			gameeventmanager->FireEvent( event );
		}
	}
#endif
}
#ifdef CLIENT_DLL
class CGravityChange : public IGameEventListener2, public CAutoGameSystem
{
public:
	bool Init()
	{
		gameeventmanager->AddListener(this,"gravity_change",false);
		return true;
	}
	void FireGameEvent( IGameEvent *event )
	{
		UpdatePhysicsGravity(event->GetFloat("newgravity"));
	}
};
static CGravityChange s_GravityChange;
#endif
ConVar	sv_gravity		( "sv_gravity",DEFAULT_GRAVITY_STRING, FCVAR_NOTIFY | FCVAR_REPLICATED, "World gravity.", GravityChanged_Callback );

In your mod's events file (GameEvents.res/ModEvents.res):

	"gravity_change"
	{
		"newgravity"	"float"
	}
Todo: Diff this

Server: util.cpp (531) : Assertion Failed: !"UTIL_GetLocalPlayer"

Occurs when taking damage to yourself from tossing a table straight up into the air.

Fix: The following patch fixes the Assert, and appears to be more functionally correct as well. Validation from Valve that the patch is correct would be appreciated. Diff And Patch

Index: mod/src/dlls/player.h
===================================================================
--- mod/src/dlls/player.h 2005/02/19 22:20:29 1.2
+++ mod/src/dlls/player.h 2005/02/24 00:35:30
@@ -459,6 +459,7 @@
     // mass/size limit set to zero for none
     static bool CanPickupObject( CBaseEntity *pObject, float massLimit, float sizeLimit );
     virtual void PickupObject( CBaseEntity *pObject, bool bLimitMassAndSize = true ) {}
+    virtual bool IsHoldingEntity( CBaseEntity *pEnt );
     virtual void ForceDropOfCarriedPhysObjects( CBaseEntity *pOnlyIfHoldindThis = NULL ) {}
     virtual float GetHeldObjectMass( IPhysicsObject *pHeldObject );

Index: mod/src/dlls/player.cpp
===================================================================
--- mod/src/dlls/player.cpp 2005/02/21 00:05:42 1.3
+++ mod/src/dlls/player.cpp 2005/02/24 00:35:33
@@ -7447,3 +7447,7 @@
     return cmd;
 }

+bool CBasePlayer::IsHoldingEntity( CBaseEntity *pEnt )
+{
+    return PlayerPickupControllerIsHoldingEntity( m_hUseEntity, pEnt );
+}

Index: mod/src/dlls/physics_impact_damage.cpp
===================================================================
--- mod/src/dlls/physics_impact_damage.cpp 2005/02/18 04:45:50 1.1.1.1
+++ mod/src/dlls/physics_impact_damage.cpp 2005/02/24 00:42:24
@@ -417,12 +417,22 @@
     else if ( pEvent->pObjects[index>GetGameFlags() & FVPHYSICS_PLAYER_HELD )
     {
     // if the player is holding the object, use it's real mass (player holding reduced the mass)
-    CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
-    if ( pPlayer )
-    {
+    CBasePlayer* pPlayer = NULL;
+    {for (int i = 1; i <= gpGlobals->maxClients; i++) {
+        CBasePlayer *temp_player = UTIL_PlayerByIndex(i);
+        if (temp_player
+            && temp_player->edict()
+            && temp_player->IsHoldingEntity(pEvent->pEntities[index])
+        ) {
+            pPlayer = temp_player;
+            break;
+        }
+    }}
+    Assert(pPlayer && "object with FVPHYSICS_PLAYER_HELD but no player holding it");
+    if (pPlayer) {
     float mass = pPlayer->GetHeldObjectMass( pEvent->pObjects[index] );
-    if ( mass > 0 )
-    {
+        Assert((mass > 0) && "player was holding object so mass should be non-zero");
+        if (mass > 0) {
             invMass = 1.0f / mass;
         }
     }
Note.pngNote:Instead of iterating all players, why not consider adding a m_pHolder var and GetHolder and SetHolder functions to CBaseEntity

(You could, though it's unlikely to impact performance much since this is not a frequently called function. Bloodykenny 17:55, 19 Jul 2005 (PDT))

Assert !"UTIL_GetLocalPlayer" when using combine ball

Fix: Diff And Patch

diff -u -r1.1.1.1 prop_combine_ball.cpp 
--- mod/src/dlls/hl2_dll/prop_combine_ball.cpp 2005/02/18 04:45:52 1.1.1.1 
+++ mod/src/dlls/hl2_dll/prop_combine_ball.cpp 2005/02/24 01:34:21 
@@ -788,9 +788,9 @@ 
     pPhysicsObject->GetPosition( &vecPosition, NULL ); 
     pPhysicsObject->GetVelocity( &vecVelocity, NULL ); 

-    CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); 
-    if ( pPlayer ) 
+    if (gpGlobals->maxClients == 1) 
     { 
+    CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); 
     Vector vecDelta; 
     VectorSubtract( pPlayer->GetAbsOrigin(), vecPosition, vecDelta ); 
     VectorNormalize( vecDelta );

Server/Client: Negative entitygroundcontact crash.

The implications of this SDK bug are not at all clear, but in debug mode you'll get an assert, and in release mode it will presumably segfault. The patch assumes anything negative or really large is bogus and dumps it.

I'm starting to wonder if maybe this is another symptom of the Physics Mayhem bugs. --Bloodykenny 17:24, 4 Nov 2005 (PST)

Fix: Diff And Patch

--- mod/src/game_shared/usercmd.cpp 2005/02/18 04:45:54 1.1.1.1
+++ mod/src/game_shared/usercmd.cpp 2005/03/23 02:24:00
@@ -290,7 +290,12 @@
 #if defined( HL2_DLL )
     if ( buf->ReadOneBit() )
     {
-        move->entitygroundcontact.SetCount( buf->ReadShort() );
+        int count = buf->ReadShort();
+        if ((count < 0) || (count > 140)) {
+            Msg("Ignoring strange entitygroundcontact count: %d\n", count);
+            return; // why can this be less than 0, Valve? change to ReadWord()???
+        }
+    move->entitygroundcontact.SetCount( count );

     int i;
     for (i = 0; i < move->entitygroundcontact.Count(); i++)

Client: Spinning around quickly with the Stun Baton as your active weapon causes the screen to flash white

It's worth noting that recent updates to HL2DM have fixed this. However there has not yet been an SDK code update to show what the fix is. Basically Valve seems to have made the glow fade out completely in between swings.

Fix: Fix unknown

Assert on line 866 of mod/src/game_shared/basecombatweapon_shared.cpp

Fix: I haven't been able to determine exactly why this is an assert. It's just "Assert(0);" with no accompanying explanation, but commenting it out results in no problems it seems. Diff And Patch

--- mod/src/game_shared/basecombatweapon_shared.cpp     2005/02/18 04:45:53     1.1
+++ mod/src/game_shared/basecombatweapon_shared.cpp     2005/03/04 03:45:36     1.2
@@ -863,7 +863,7 @@
        CBaseViewModel *vm = pOwner->GetViewModel( m_nViewModelIndex );
        if ( vm == NULL )
        {
-               Assert( false );
+               //Assert( false );
                return false;
        }

Client: The mod can appear to have frozen on initial startup

Originally posted by MattC here: http://www.chatbear.com/board.plm?a=viewthread&b=4991&t=234,1117553034,6915&s=0&id=868372

Fix: Issue a "progress_enable" command just before "map <mapname>".

engine->ClientCmd("progress_enable");

engine->ClientCmd("map test");

This should fix local servers. For connecting to a remote multiplayer server, the only issue appears to be that you can't switch to another window and then switch back to HL2. Doing so causes HL2 to never render progress info until load is fully complete. That seems to be an HL2 core bug unrelated (though very similar in appearance) to the fix above.

USE_VCR_MODE linker errors

This is because Valve wants to be able to somehow replay all of the things that happen in a mod and get back the exact same output. I'm still confused as to how that would work, or what the value really is, but anyway, if you need things like threading, you'll hit these errors.

My mod needed threading and commenting these out has never caused any issue. Though apparently it means my mod can't use VCR mode.

Fix: Comment out the appropriate lines in protected_things.h, for whatever VCR thing was failing. Note, don't just block out the whole file - the string part at the top is actually useful.

Lighting in Compile (RAD)

There is currently a rather severe lighting bug during RAD. Visible symptoms include: black models while in shadows cast by light_environment; large, unlit sections in "outdoor" type areas.

Fix: Pending.


Complaints about tv_delaymapchange in NON SRCTV Mods

Note.pngNote:This issue is fixed in the August 2006 SDK update

Issue: Console reports an issue about tv_delaymapchange when loading a mod with no SRCTV Support.

mod/game_shared/multiplay_gamerules.cpp

Undone! you don't have to remove it, instead, add FCVAR_REPLICATED like all the other cvar's. It's doing it because it's a shared ConVar in both dll's and not being replicated. --omega

Instead, change to this:

Line 47
ConVar	mp_timelimit( "mp_timelimit",
					  "0",
					  FCVAR_NOTIFY|FCVAR_REPLICATED,
					  "game time per map in minutes" );

ConVar	tv_delaymapchange( "tv_delaymapchange",
					  "0",
-					  0,
+					  FCVAR_NOTIFY|FCVAR_REPLICATED,
					  "Delays map change until broadcast is complete" );
					  

Physics models show up darker under switchable lights

Switchable lights are not taken into account for visibility of physics models when Source starts a map. So whenever a physics model is mostly lit by switchable lights, it will show up much darker when the map starts.

If the switchable lights are turned off and on again, or if a physics model is moved, then the visibility of this physics model is automatically fixed. But if the map is saved and reloaded, all physics models under switchable lights become darker again.

Note.pngNote:A switchable light is a light with a targetname, that can be triggered to turn on/off.

Fix: Fix unknown


Sticky Player Collisions / No lagcompensation

Note.pngNote:In the SDK-code of August 06, there is no StartLagCompensation() call.

I've been chasing a fix for this for months for Dystopia, when two players collide with each other there's massive prediction errors and to the player it looks like they're jerking back and forth. It can mean real trouble when two players attempt to get through a doorway or something, and it sucks if you're trying to do a good melee system.

Anyways, I found out the cause of this problem is on the server, when it runs a players movement code, it first unlags all the other players on the server, presumably to help predict player vs. player collisions. The problem is, because two players have different pings, there's no authoritative point of impact for the collision, so the jerking around you see is caused by this unlagging. Now down to the fix, which is really simple:

player_command.cpp Line 42

	// Move other players back to history positions based on local player's lag
-	lagcompensation->StartLagCompensation( player, cmd );

player_command.cpp Line 52

	// Restore other players to current positions
-	lagcompensation->FinishLagCompensation( player );

player_command.cpp Line 348

	// Let server invoke any needed impact functions
	moveHelper->ProcessImpacts();

+	// Only do unlag for post think/post frame, which is mainly weapons stuff! - Teddy
+	lagcompensation->StartLagCompensation( player, ucmd );
	RunPostThink( player );
+	lagcompensation->FinishLagCompensation( player );

	FinishCommand( player );

Pretty simple huh? You only need unlag for weapons really, and all the weapon hitscan code is run from the weapon's ItemPostFrame which is what the RunPostThink() runs. Let me know if it works for you! --Teddy 20:05, 12 Jun 2006 (PDT)

I added this fix to the latest version of the SDK (as of January, 2007) and I did not notice any difference. I believe this issue may have already been addressed in the latest SDK so this fix is uneccessary if you are running the latest SDK code. [User: Minh]

Minor/misc code neatenings/fixings

(This section is for issues in the codebase that you've spotted to be potentially dangerous but aren't actually causing obvious bugs/issues... every little improvement to the quality of the codebase helps, right?)

/src/cl_dll/game_controls/spectatorgui.cpp(508): The memset is setting twice as much memory as it should be to 0x0 because sizeof(playerName) already accounts for the fact that the elements are wchar_t type. Fix: Remove the "* sizeof( wchar_t)".

filter_damage_type doesn't work

Open dlls/filters.cpp and replace

return info.GetDamageType() == m_iDamageType;

with

return ( (info.GetDamageType() & m_iDamageType ) ? true : false );

Floating SLAM's

When attaching a SLAM at a movable object, it doesn't explode when the object moves and so give a "floating SLAM".

Fix:

--- mod/src/dlls/hl2_dll/grenade_tripmine.h	18 Feb 2005 04:45:51 -0000	1.1.1.1
+++ mod/src/dlls/hl2_dll/grenade_tripmine.h	22 Jul 2006 22:32:28 -0000
@@ -36,6 +36,8 @@
 	void MakeBeam( void );
 	void KillBeam( void );
 
+    void AttachToEntity(const CBaseEntity* const ent);
+
 public:
 	EHANDLE		m_hOwner;
 
@@ -49,6 +51,10 @@
 	Vector		m_posOwner;
 	Vector		m_angleOwner;
 
+    const CBaseEntity* m_pAttachedObject;
+    Vector m_vecOldPosAttachedObject;
+    QAngle m_vecOldAngAttachedObject;
+
 	DECLARE_DATADESC();
 };
 
--- mod/src/dlls/hl2mp_dll/grenade_tripmine.cpp	18 Feb 2005 04:45:51 -0000	1.1.1.1
+++ mod/src/dlls/hl2mp_dll/grenade_tripmine.cpp	22 Jul 2006 22:32:28 -0000
@@ -91,6 +91,8 @@
 	m_vecEnd = GetAbsOrigin() + m_vecDir * 2048;
 
 	AddEffects( EF_NOSHADOW );
+
+    m_pAttachedObject = NULL;
 }
 
 
@@ -224,7 +226,27 @@
 		return;
 	}
 
-	SetNextThink( gpGlobals->curtime + 0.05f );
+    // Detonate if the parent object moves
+    if (
+        m_pAttachedObject
+        && (
+               !VectorsAreEqual(m_vecOldPosAttachedObject, m_pAttachedObject->GetAbsOrigin(), 1.0f)
+            || !QAnglesAreEqual(m_vecOldAngAttachedObject, m_pAttachedObject->GetAbsAngles(), 1.0f)
+        )
+    ) {
+        m_iHealth = 0;
+        Event_Killed(CTakeDamageInfo((CBaseEntity*)m_hOwner, this, 100, GIB_NORMAL));
+        return;
+    }
+
+	SetNextThink(gpGlobals->curtime + 0.05f);
+}
+
+void CTripmineGrenade::AttachToEntity(const CBaseEntity* const ent) {
+    Assert(m_pAttachedObject == NULL);
+    m_pAttachedObject = ent;
+    m_vecOldPosAttachedObject = ent->GetAbsOrigin();
+    m_vecOldAngAttachedObject = ent->GetAbsAngles();
 }
 
 int CTripmineGrenade::OnTakeDamage_Alive( const CTakeDamageInfo &info )
--- mod/src/dlls/hl2mp_dll/grenade_tripmine.h	18 Feb 2005 04:45:51 -0000	1.1.1.1
+++ mod/src/dlls/hl2mp_dll/grenade_tripmine.h	22 Jul 2006 22:32:28 -0000
@@ -36,6 +36,8 @@
 	void MakeBeam( void );
 	void KillBeam( void );
 
+    void AttachToEntity(const CBaseEntity* const ent);
+
 public:
 	EHANDLE		m_hOwner;
 
@@ -49,6 +51,10 @@
 	Vector		m_posOwner;
 	Vector		m_angleOwner;
 
+    const CBaseEntity* m_pAttachedObject;
+    Vector m_vecOldPosAttachedObject;
+    QAngle m_vecOldAngAttachedObject;
+
 	DECLARE_DATADESC();
 };
 
--- mod/src/game_shared/hl2mp/weapon_slam.cpp	17 Jun 2006 17:51:06 -0000	1.6
+++ mod/src/game_shared/hl2mp/weapon_slam.cpp	22 Jul 2006 22:32:28 -0000
@@ -371,6 +371,7 @@
 			CBaseEntity *pEnt = CBaseEntity::Create( "npc_tripmine", tr.endpos + tr.plane.normal * 3, angles, NULL );
 
 			CTripmineGrenade *pMine = (CTripmineGrenade *)pEnt;
+            pMine->AttachToEntity(pEntity);
 			pMine->m_hOwner = GetOwner();
             pMine->SetDamage(pOwner->get_damage(AOA_SLAM));
 #endif

Assertion Failed in utlbuffer.cpp

[ISSUE] An assertion is thrown from the following location in utlbuffer.cpp:

CUtlBuffer::CUtlBuffer( const void *pBuffer, int nSize, int nFlags ) :
	m_Memory( (unsigned char*)pBuffer, nSize ), m_Error(0)
{
        Assert( nSize != 0 );

	...
}


[FIX] Change the source to:

CUtlBuffer::CUtlBuffer( const void *pBuffer, int nSize, int nFlags ) :
	m_Memory( (unsigned char*)pBuffer, nSize ), m_Error(0)
{
        Assert( nSize >= 0 );

	...
}


However, there appears to be a separate issue with dependencies in the VS project. For example, selecting Build Solution may not reflect the above changes when running the project. For a temporary workaround, select Rebuild Solution and then Build Solution. The expected behavior is that rebuilding will produce a linker error about tier1.lib, but building afterwards will succeed.


[TODO] Investigate VS project dependencies to come up with a fix that avoids having to rebuild the solution.

Constant physprops->GetSurfaceData( ) on Linux

The physprops->GetSurfaceData( ) for a trace returns always CHAR_TEX_CONCRETE on Linux with SDK 2007. The surface type is correctly detected on Windows though. This should be fixed in 2009 according to: [2].

Cannot re-ignite entities

There's a glich in SDK that does not call Extinguish() on entity once fire goes out, because it always returns NULL pointer, this causes inability to ignite same entity again. To fix this without changing header go to EntityFlame.cpp line 286.

Warning.pngWarning:Not only can you re-ignite entities in latest SDK version, but the game will crash if this edit is applied.

Replace this

if ( m_hEntAttached )
		{
			CBaseCombatCharacter *pAttachedCC = m_hEntAttached->MyCombatCharacterPointer();

			if( pAttachedCC )
			{
				// Notify the NPC that it's no longer burning!
				pAttachedCC->Extinguish();
			}
		}

with this

		if ( m_hEntAttached )
		{
			//Cannot directly cast networked variables
			CBaseEntity *temp = m_hEntAttached;
			CBaseCombatCharacter *pAttachedCC = (CBaseCombatCharacter *)temp;

			if( pAttachedCC )
			{
				// Notify the NPC that it's no longer burning!
				pAttachedCC->Extinguish();
			}
		}

Other info and links

See also Core Known Issues List for the list of issues in the closed-source HL2 Core engine.

See also SDK Known Issues List Fixed for the list of SDK Known Issues fixed in new SDK revisions.

See also this nice general HL2 bug list on the steam forums. Many of the issues seem imbedded down inside the closed-source side of things, so they are outside the scope of this SDK Known Issues list.

There's also this Patch HL2 petition where users sign their name to beg Valve to fix the aforementioned bugs.

SDK Known Issues specific to memory leaks are on the Memory Leak Fixes page.