Skip to content

Commit 4718d05

Browse files
committed
fix(input): Replicate double-click fast drive timing fix to Generals
1 parent 315bb68 commit 4718d05

File tree

2 files changed

+55
-7
lines changed

2 files changed

+55
-7
lines changed

Generals/Code/GameEngine/Include/GameLogic/Module/ParticleUplinkCannonUpdate.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,12 @@ class ParticleUplinkCannonUpdate : public UpdateModule, public SpecialPowerUpdat
225225
UnsignedInt m_nextDamagePulseFrame;
226226
UnsignedInt m_startAttackFrame;
227227
UnsignedInt m_startDecayFrame;
228-
UnsignedInt m_lastDrivingClickFrame;
229-
UnsignedInt m_2ndLastDrivingClickFrame;
228+
#if RETAIL_COMPATIBLE_XFER_SAVE
229+
UnsignedInt m_lastDrivingClickFrame; // Frame number for retail compatibility
230+
UnsignedInt m_2ndLastDrivingClickFrame; // Frame number for retail compatibility
231+
#endif
232+
UnsignedInt m_lastDrivingClickTimeMsec; // Real-time milliseconds
233+
UnsignedInt m_2ndLastDrivingClickTimeMsec; // Real-time milliseconds
230234

231235
Bool m_upBonesCached;
232236
Bool m_defaultInfoCached;

Generals/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,12 @@ ParticleUplinkCannonUpdate::ParticleUplinkCannonUpdate( Thing *thing, const Modu
183183
m_nextDamagePulseFrame = 0;
184184
m_startAttackFrame = 0;
185185
m_startDecayFrame = 0;
186+
#if RETAIL_COMPATIBLE_XFER_SAVE
186187
m_lastDrivingClickFrame = 0;
187188
m_2ndLastDrivingClickFrame = 0;
189+
#endif
190+
m_lastDrivingClickTimeMsec = 0;
191+
m_2ndLastDrivingClickTimeMsec = 0;
188192
m_clientShroudedLastFrame = FALSE;
189193

190194
for( Int i = 0; i < MAX_OUTER_NODES; i++ )
@@ -324,8 +328,12 @@ void ParticleUplinkCannonUpdate::setSpecialPowerOverridableDestination( const Co
324328
{
325329
m_overrideTargetDestination = *loc;
326330
m_manualTargetMode = true;
331+
#if RETAIL_COMPATIBLE_XFER_SAVE
327332
m_2ndLastDrivingClickFrame = m_lastDrivingClickFrame;
328333
m_lastDrivingClickFrame = TheGameLogic->getFrame();
334+
#endif
335+
m_2ndLastDrivingClickTimeMsec = m_lastDrivingClickTimeMsec;
336+
m_lastDrivingClickTimeMsec = timeGetTime();
329337
}
330338
}
331339

@@ -517,7 +525,11 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()
517525
else
518526
{
519527
Real speed = data->m_manualDrivingSpeed;
528+
#if !RETAIL_COMPATIBLE_CRC
529+
if( m_lastDrivingClickTimeMsec != 0 && m_2ndLastDrivingClickTimeMsec != 0 && m_lastDrivingClickTimeMsec - m_2ndLastDrivingClickTimeMsec < data->m_doubleClickToFastDriveDelay )
530+
#else
520531
if( m_lastDrivingClickFrame - m_2ndLastDrivingClickFrame < data->m_doubleClickToFastDriveDelay )
532+
#endif
521533
{
522534
//Because we double clicked, use the faster driving speed.
523535
speed = data->m_manualFastDrivingSpeed;
@@ -1308,7 +1320,11 @@ void ParticleUplinkCannonUpdate::crc( Xfer *xfer )
13081320
// ------------------------------------------------------------------------------------------------
13091321
/** Xfer method
13101322
* Version Info:
1311-
* 1: Initial version */
1323+
* 1: Initial version
1324+
* 2: Added m_startDecayFrame
1325+
* 3: Added m_orbitToTargetLaserRadius
1326+
* 4: Changed m_lastDrivingClickFrame and m_2ndLastDrivingClickFrame to m_lastDrivingClickTimeMsec and m_2ndLastDrivingClickTimeMsec (frames to milliseconds)
1327+
*/
13121328
// ------------------------------------------------------------------------------------------------
13131329
void ParticleUplinkCannonUpdate::xfer( Xfer *xfer )
13141330
{
@@ -1414,13 +1430,41 @@ void ParticleUplinkCannonUpdate::xfer( Xfer *xfer )
14141430
m_startDecayFrame = m_startAttackFrame + data->m_totalFiringFrames;
14151431
}
14161432

1417-
// the time of last manual target click
1433+
// the time of last manual target click (milliseconds)
1434+
#if RETAIL_COMPATIBLE_XFER_SAVE
1435+
// Retail builds stay at version 2 for compatibility, so always use old frame format
14181436
xfer->xferUnsignedInt( & m_lastDrivingClickFrame );
1419-
1420-
// the time of the 2nd last manual target click
14211437
xfer->xferUnsignedInt( &m_2ndLastDrivingClickFrame );
1422-
1438+
#if !RETAIL_COMPATIBLE_CRC
1439+
if( xfer->getXferMode() == XFER_LOAD )
1440+
{
1441+
// Can't convert frames to milliseconds accurately, so set to 0
1442+
m_lastDrivingClickTimeMsec = 0;
1443+
m_2ndLastDrivingClickTimeMsec = 0;
1444+
}
1445+
#endif
1446+
#else
14231447
if( version >= 4 )
1448+
{
1449+
xfer->xferUnsignedInt( & m_lastDrivingClickTimeMsec );
1450+
xfer->xferUnsignedInt( &m_2ndLastDrivingClickTimeMsec );
1451+
}
1452+
else
1453+
{
1454+
// Old versions stored frame numbers, which we can't meaningfully convert to milliseconds
1455+
UnsignedInt oldLastDrivingClickFrame = 0;
1456+
UnsignedInt old2ndLastDrivingClickFrame = 0;
1457+
xfer->xferUnsignedInt( &oldLastDrivingClickFrame );
1458+
xfer->xferUnsignedInt( &old2ndLastDrivingClickFrame );
1459+
if( xfer->getXferMode() == XFER_LOAD )
1460+
{
1461+
m_lastDrivingClickTimeMsec = 0;
1462+
m_2ndLastDrivingClickTimeMsec = 0;
1463+
}
1464+
}
1465+
#endif
1466+
1467+
if( version >= 3 )
14241468
{
14251469
m_orbitToTargetLaserRadius.xfer( xfer );
14261470
}

0 commit comments

Comments
 (0)