Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed a bug where GHost++ would occasionally generate broken replays …

…(anytime a "pretick" or w3gs_incoming_action2 was generated)

git-svn-id: http://ghostplusplus.googlecode.com/svn/trunk@408 a7494f72-a4b0-11dd-a887-7ffe1a420f8d
  • Loading branch information...
commit dbb998449766082234b4df259c200463db449b51 1 parent d188e6a
hogantp authored
Showing with 41 additions and 10 deletions.
  1. +12 −8 ghost/game_base.cpp
  2. +24 −0 ghost/replay.cpp
  3. +5 −2 ghost/replay.h
View
20 ghost/game_base.cpp
@@ -1265,19 +1265,12 @@ void CBaseGame :: SendAllActions( )
Send( *i, m_Protocol->SEND_W3GS_INCOMING_ACTION( queue<CIncomingAction *>( ), 0 ) );
}
}
- }
-
- // add actions to replay
- if( m_Replay )
- {
- if( UsingGProxy )
+ if( m_Replay )
{
for( unsigned char i = 0; i < m_GProxyEmptyActions; i++ )
m_Replay->AddTimeSlot( 0, queue<CIncomingAction *>( ) );
}
-
- m_Replay->AddTimeSlot( m_Latency, m_Actions );
}
// Warcraft III doesn't seem to respond to empty actions
@@ -1315,6 +1308,9 @@ void CBaseGame :: SendAllActions( )
SendAll( m_Protocol->SEND_W3GS_INCOMING_ACTION2( SubActions ) );
+ if( m_Replay )
+ m_Replay->AddTimeSlot2( SubActions );
+
while( !SubActions.empty( ) )
{
delete SubActions.front( );
@@ -1330,6 +1326,9 @@ void CBaseGame :: SendAllActions( )
SendAll( m_Protocol->SEND_W3GS_INCOMING_ACTION( SubActions, m_Latency ) );
+ if( m_Replay )
+ m_Replay->AddTimeSlot( m_Latency, SubActions );
+
while( !SubActions.empty( ) )
{
delete SubActions.front( );
@@ -1337,8 +1336,13 @@ void CBaseGame :: SendAllActions( )
}
}
else
+ {
SendAll( m_Protocol->SEND_W3GS_INCOMING_ACTION( m_Actions, m_Latency ) );
+ if( m_Replay )
+ m_Replay->AddTimeSlot( m_Latency, m_Actions );
+ }
+
uint32_t ActualSendInterval = GetTicks( ) - m_LastActionSentTicks;
uint32_t ExpectedSendInterval = m_Latency - m_LastActionLateBy;
m_LastActionLateBy = ActualSendInterval - ExpectedSendInterval;
View
24 ghost/replay.cpp
@@ -65,6 +65,30 @@ void CReplay :: AddLeaveGameDuringLoading( uint32_t reason, unsigned char PID, u
m_LoadingBlocks.push( Block );
}
+void CReplay :: AddTimeSlot2( queue<CIncomingAction *> actions )
+{
+ BYTEARRAY Block;
+ Block.push_back( REPLAY_TIMESLOT2 );
+ UTIL_AppendByteArray( Block, (uint16_t)0, false );
+ UTIL_AppendByteArray( Block, (uint16_t)0, false );
+
+ while( !actions.empty( ) )
+ {
+ CIncomingAction *Action = actions.front( );
+ actions.pop( );
+ Block.push_back( Action->GetPID( ) );
+ UTIL_AppendByteArray( Block, (uint16_t)Action->GetAction( )->size( ), false );
+ UTIL_AppendByteArrayFast( Block, *Action->GetAction( ) );
+ }
+
+ // assign length
+
+ BYTEARRAY LengthBytes = UTIL_CreateByteArray( (uint16_t)( Block.size( ) - 3 ), false );
+ Block[1] = LengthBytes[0];
+ Block[2] = LengthBytes[1];
+ m_Blocks.push( Block );
+}
+
void CReplay :: AddTimeSlot( uint16_t timeIncrement, queue<CIncomingAction *> actions )
{
BYTEARRAY Block;
View
7 ghost/replay.h
@@ -37,9 +37,11 @@ class CReplay : public CPacked
REPLAY_FIRSTSTARTBLOCK = 0x1A,
REPLAY_SECONDSTARTBLOCK = 0x1B,
REPLAY_THIRDSTARTBLOCK = 0x1C,
- REPLAY_TIMESLOT = 0x1F,
+ REPLAY_TIMESLOT2 = 0x1E, // corresponds to W3GS_INCOMING_ACTION2
+ REPLAY_TIMESLOT = 0x1F, // corresponds to W3GS_INCOMING_ACTION
REPLAY_CHATMESSAGE = 0x20,
- REPLAY_CHECKSUM = 0x22
+ REPLAY_CHECKSUM = 0x22, // corresponds to W3GS_OUTGOING_KEEPALIVE
+ REPLAY_DESYNC = 0x23
};
private:
@@ -88,6 +90,7 @@ class CReplay : public CPacked
void AddLeaveGame( uint32_t reason, unsigned char PID, uint32_t result );
void AddLeaveGameDuringLoading( uint32_t reason, unsigned char PID, uint32_t result );
+ void AddTimeSlot2( queue<CIncomingAction *> actions );
void AddTimeSlot( uint16_t timeIncrement, queue<CIncomingAction *> actions );
void AddChatMessage( unsigned char PID, unsigned char flags, uint32_t chatMode, string message );
void AddCheckSum( uint32_t checkSum );
Please sign in to comment.
Something went wrong with that request. Please try again.