Difference between revisions of "Source 2007 Template Fixes"

From Valve Developer Community
Jump to: navigation, search
m (Updated the Steam Shutdown procedure.)
Line 98: Line 98:
 
2. Search for CServerGameDLL::DLLShutdown
 
2. Search for CServerGameDLL::DLLShutdown
  
3. At the end of this function, add this line above the DisconnectTier3Libraries() function call:  
+
3. At the end of this function, add these lines above the DisconnectTier3Libraries() function call:  
  
 
<source lang=cpp>
 
<source lang=cpp>
+ SteamAPI_Shutdown();
+
+ SteamClient()->ReleaseUser( GetHSteamPipe(), GetHSteamUser() );
 +
+ SteamClient()->BReleaseSteamPipe( GetHSteamPipe() );
  
 
DisconnectTier3Libraries();
 
DisconnectTier3Libraries();

Revision as of 13:59, 8 September 2012

This is a collection of fixes that only effect the Source 2007 Template.

Missing prediction table entry on the client-side player

A prediction table in game/client/sdk/c_sdk_player.cpp is missing an entry for shared player data, causing some values such as the amount of stamina to appear jittery.

--- game\client\sdk\c_sdk_player.cpp	2010-03-28 17:00:41.000000000 -0600
+++ game\client\sdk\c_sdk_player.cpp	2011-07-14 19:06:20.000000000 -0600
@@ -149,12 +149,13 @@
 #if defined( SDK_USE_SPRINTING )
 	DEFINE_PRED_FIELD( m_bIsSprinting, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE ),
 #endif
 END_PREDICTION_DATA()
 
 BEGIN_PREDICTION_DATA( C_SDKPlayer )
+	DEFINE_PRED_TYPEDESCRIPTION( m_Shared, CSDKPlayerShared ),
 	DEFINE_PRED_FIELD( m_flCycle, FIELD_FLOAT, FTYPEDESC_OVERRIDE | FTYPEDESC_PRIVATE | FTYPEDESC_NOERRORCHECK ),
 	DEFINE_PRED_FIELD( m_iShotsFired, FIELD_INTEGER, FTYPEDESC_INSENDTABLE ),   
 END_PREDICTION_DATA()
 
 LINK_ENTITY_TO_CLASS( player, C_SDKPlayer );

SDK sprinting

With the previous prediction patch, we need to apply the sprint penalty in prediction. The initial SetMaxSpeed is also called with the wrong value.

--- game\shared\sdk\sdk_player_shared.cpp	2010-03-28 17:00:44.000000000 -0600
+++ game\shared\sdk\sdk_player_shared.cpp	2011-07-14 18:52:55.000000000 -0600
@@ -213,13 +213,13 @@
 }
 
 bool CSDKPlayer::IsSprinting( void )
 {
 	float flVelSqr = GetAbsVelocity().LengthSqr();
 
-	return m_Shared.m_bIsSprinting && ( flVelSqr > 0.5f );
+	return m_Shared.IsSprinting() && ( flVelSqr > 0.5f );
 }
 #endif // SDK_USE_SPRINTING
 
 bool CSDKPlayer::CanAttack( void )
 {
 #if defined ( SDK_USE_SPRINTING )
@@ -424,24 +424,20 @@
 
 #endif
 
 #if defined ( SDK_USE_SPRINTING )
 void CSDKPlayerShared::SetSprinting( bool bSprinting )
 {
-	if ( bSprinting && !m_bIsSprinting )
+	if ( bSprinting && !IsSprinting())
 	{
 		StartSprinting();
 
-		// only one penalty per key press
-		if ( m_bGaveSprintPenalty == false )
-		{
-			m_flStamina -= INITIAL_SPRINT_STAMINA_PENALTY;
-			m_bGaveSprintPenalty = true;
-		}
+		// always apply this penalty as we're predicting m_bSprinting
+		m_flStamina -= INITIAL_SPRINT_STAMINA_PENALTY;
 	}
-	else if ( !bSprinting && m_bIsSprinting )
+	else if ( !bSprinting && IsSprinting() )
 	{
 		StopSprinting();
 	}
 }
 
 // this is reset when we let go of the sprint key
@@ -568,13 +564,13 @@
 {
 #if !defined ( SDK_USE_PLAYERCLASSES )
 	m_Shared.m_flRunSpeed = SDK_DEFAULT_PLAYER_RUNSPEED;
 	m_Shared.m_flSprintSpeed = SDK_DEFAULT_PLAYER_SPRINTSPEED;
 	m_Shared.m_flProneSpeed = SDK_DEFAULT_PLAYER_PRONESPEED;
 	// Set the absolute max to sprint speed
-	SetMaxSpeed( m_Shared.m_flSprintSpeed ); 
+	SetMaxSpeed( m_Shared.m_flRunSpeed ); 
 	return;
 #endif
 #if defined ( SDK_USE_PLAYERCLASSES )
 		int playerclass = m_Shared.PlayerClass();
 
 		//Tony; error checkings.

Game freezing on exit instead of closing

There's a problem in the Source 2007 (and maybe later versions, I'm not sure) which makes the game unable to be closed by normal means, the only way being finalizing the process in the Task Manager. Luckily for us, there is a simple fix for this.

1. Open the src/game/server/gameinterface.cpp

2. Search for CServerGameDLL::DLLShutdown

3. At the end of this function, add these lines above the DisconnectTier3Libraries() function call:

+	SteamClient()->ReleaseUser( GetHSteamPipe(), GetHSteamUser() );
+	SteamClient()->BReleaseSteamPipe( GetHSteamPipe() );

	DisconnectTier3Libraries();
	DisconnectTier2Libraries();
	ConVar_Unregister();
	DisconnectTier1Libraries();