Skip to content

Commit

Permalink
Merge pull request BSVino#35 from TomyLobo/fix-unstick
Browse files Browse the repository at this point in the history
Fix da_auto_unstick
  • Loading branch information
TomyLobo committed Mar 30, 2016
2 parents 8e076b7 + 5b858c8 commit 5e41123
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions mp/src/game/server/sdk/sdk_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@ CSDKPlayer::CSDKPlayer()
m_flCurrentTime = gpGlobals->curtime;

m_iszCharacter = NULL_STRING;

m_flStuckTime = -1;
}


Expand Down
1 change: 1 addition & 0 deletions mp/src/game/server/sdk/sdk_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ class CSDKPlayer : public CBaseMultiplayerPlayer

int m_iKills;
int m_iDeaths;
float m_flStuckTime;

CNetworkHandle(CSDKPlayer, m_hKiller);
CNetworkHandle(CBaseEntity, m_hInflictor);
Expand Down
16 changes: 8 additions & 8 deletions mp/src/game/shared/sdk/sdk_gamemovement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,16 @@ class CSDKGameMovement : public CGameMovement
bool ResolveStanding( void );
void TracePlayerBBoxWithStep( const Vector &vStart, const Vector &vEnd, unsigned int fMask, int collisionGroup, trace_t &trace );
public:
// A reference to the player whose movement is currently being considered.
// If additional per-player data is needed, put it into CSDKPlayer and refer to it via m_pSDKPlayer.
// Do not put it directly into CSDKGameMovement, because there isn't an instance of that per player.
CSDKPlayer *m_pSDKPlayer;

#ifdef STUCK_DEBUG
float m_flStuckCheck;

void AddBotTag(const char* tag);
#endif

float m_flStuckTime;
};

#define ROLL_TIME 0.65f
Expand All @@ -160,7 +161,6 @@ CSDKGameMovement::CSDKGameMovement()
#ifdef STUCK_DEBUG
m_flStuckCheck = 0;
#endif
m_flStuckTime = -1;
}

CSDKGameMovement::~CSDKGameMovement()
Expand Down Expand Up @@ -611,19 +611,19 @@ void CSDKGameMovement::PlayerMove (void)
#ifndef CLIENT_DLL
if (da_auto_unstick.GetBool() && m_pSDKPlayer->IsAlive() && PlayerIsStuck() && m_pSDKPlayer->GetMoveType() != MOVETYPE_NOCLIP)
{
if (m_flStuckTime < 0)
m_flStuckTime = gpGlobals->curtime;
else if (gpGlobals->curtime - m_flStuckTime > 3)
if (m_pSDKPlayer->m_flStuckTime < 0)
m_pSDKPlayer->m_flStuckTime = gpGlobals->curtime;
else if (gpGlobals->curtime - m_pSDKPlayer->m_flStuckTime > 3)
{
// Im hopelessly stuck. Respawn me.
CBaseEntity* spawn = SDKGameRules()->GetPlayerSpawnSpot(m_pSDKPlayer);
mv->SetAbsOrigin(spawn->GetAbsOrigin());
mv->m_vecVelocity = Vector(0, 0, 0);
m_flStuckTime = -1;
m_pSDKPlayer->m_flStuckTime = -1;
}
}
else
m_flStuckTime = -1;
m_pSDKPlayer->m_flStuckTime = -1;
#endif

#ifdef STUCK_DEBUG
Expand Down

0 comments on commit 5e41123

Please sign in to comment.