Skip to content

Commit e13efd4

Browse files
authored
bugfix(network): Fix Network stalling state (#1650)
1 parent 9174d63 commit e13efd4

File tree

2 files changed

+20
-6
lines changed
  • GeneralsMD/Code/GameEngine/Source/GameNetwork
  • Generals/Code/GameEngine/Source/GameNetwork

2 files changed

+20
-6
lines changed

Generals/Code/GameEngine/Source/GameNetwork/Network.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ class Network : public NetworkInterface
207207
__int64 m_nextFrameTime; ///< When did we execute the last frame? For slugging the GameLogic...
208208

209209
Bool m_frameDataReady; ///< Is the frame data for the next frame ready to be executed by TheGameLogic?
210+
Bool m_isStalling;
210211

211212
// CRC info
212213
Bool m_checkCRCsThisFrame;
@@ -269,6 +270,7 @@ Network::Network()
269270
m_checkCRCsThisFrame = FALSE;
270271
m_didSelfSlug = FALSE;
271272
m_frameDataReady = FALSE;
273+
m_isStalling = FALSE;
272274
m_sawCRCMismatch = FALSE;
273275
//
274276

@@ -334,6 +336,7 @@ void Network::init()
334336
m_lastExecutionFrame = m_runAhead - 1; // subtract 1 since we're starting on frame 0
335337
m_lastFrameCompleted = m_runAhead - 1; // subtract 1 since we're starting on frame 0
336338
m_frameDataReady = FALSE;
339+
m_isStalling = FALSE;
337340
m_didSelfSlug = FALSE;
338341

339342
m_localStatus = NETLOCALSTATUS_PREGAME;
@@ -692,6 +695,7 @@ void Network::update( void )
692695
// 4. If all commands are there, put that frame's commands on TheCommandList.
693696
//
694697
m_frameDataReady = FALSE;
698+
m_isStalling = FALSE;
695699

696700
#if defined(RTS_DEBUG)
697701
if (m_networkOn == FALSE) {
@@ -723,6 +727,11 @@ void Network::update( void )
723727
m_frameDataReady = TRUE; // Tell the GameEngine to run the commands for the new frame.
724728
}
725729
}
730+
else {
731+
__int64 curTime;
732+
QueryPerformanceCounter((LARGE_INTEGER *)&curTime);
733+
m_isStalling = curTime >= m_nextFrameTime;
734+
}
726735
}
727736

728737
void Network::liteupdate() {
@@ -812,9 +821,7 @@ Bool Network::isFrameDataReady() {
812821

813822
Bool Network::isStalling()
814823
{
815-
__int64 curTime;
816-
QueryPerformanceCounter((LARGE_INTEGER *)&curTime);
817-
return curTime >= m_nextFrameTime;
824+
return m_isStalling;
818825
}
819826

820827
/**

GeneralsMD/Code/GameEngine/Source/GameNetwork/Network.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ class Network : public NetworkInterface
207207
__int64 m_nextFrameTime; ///< When did we execute the last frame? For slugging the GameLogic...
208208

209209
Bool m_frameDataReady; ///< Is the frame data for the next frame ready to be executed by TheGameLogic?
210+
Bool m_isStalling;
210211

211212
// CRC info
212213
Bool m_checkCRCsThisFrame;
@@ -269,6 +270,7 @@ Network::Network()
269270
m_checkCRCsThisFrame = FALSE;
270271
m_didSelfSlug = FALSE;
271272
m_frameDataReady = FALSE;
273+
m_isStalling = FALSE;
272274
m_sawCRCMismatch = FALSE;
273275
//
274276

@@ -334,6 +336,7 @@ void Network::init()
334336
m_lastExecutionFrame = m_runAhead - 1; // subtract 1 since we're starting on frame 0
335337
m_lastFrameCompleted = m_runAhead - 1; // subtract 1 since we're starting on frame 0
336338
m_frameDataReady = FALSE;
339+
m_isStalling = FALSE;
337340
m_didSelfSlug = FALSE;
338341

339342
m_localStatus = NETLOCALSTATUS_PREGAME;
@@ -692,6 +695,7 @@ void Network::update( void )
692695
// 4. If all commands are there, put that frame's commands on TheCommandList.
693696
//
694697
m_frameDataReady = FALSE;
698+
m_isStalling = FALSE;
695699

696700
#if defined(RTS_DEBUG)
697701
if (m_networkOn == FALSE) {
@@ -723,6 +727,11 @@ void Network::update( void )
723727
m_frameDataReady = TRUE; // Tell the GameEngine to run the commands for the new frame.
724728
}
725729
}
730+
else {
731+
__int64 curTime;
732+
QueryPerformanceCounter((LARGE_INTEGER *)&curTime);
733+
m_isStalling = curTime >= m_nextFrameTime;
734+
}
726735
}
727736

728737
void Network::liteupdate() {
@@ -812,9 +821,7 @@ Bool Network::isFrameDataReady() {
812821

813822
Bool Network::isStalling()
814823
{
815-
__int64 curTime;
816-
QueryPerformanceCounter((LARGE_INTEGER *)&curTime);
817-
return curTime >= m_nextFrameTime;
824+
return m_isStalling;
818825
}
819826

820827
/**

0 commit comments

Comments
 (0)