Skip to content

Commit bedd3a9

Browse files
committed
fix(input): Replicate double-click fast drive timing fix to Generals
1 parent 51d9bbf commit bedd3a9

File tree

2 files changed

+57
-8
lines changed

2 files changed

+57
-8
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_lastDrivingClickTimeMsec;
229-
UnsignedInt m_2ndLastDrivingClickTimeMsec;
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: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ ParticleUplinkCannonUpdate::ParticleUplinkCannonUpdate( Thing *thing, const Modu
183183
m_nextDamagePulseFrame = 0;
184184
m_startAttackFrame = 0;
185185
m_startDecayFrame = 0;
186+
#if RETAIL_COMPATIBLE_XFER_SAVE
187+
m_lastDrivingClickFrame = 0;
188+
m_2ndLastDrivingClickFrame = 0;
189+
#endif
186190
m_lastDrivingClickTimeMsec = 0;
187191
m_2ndLastDrivingClickTimeMsec = 0;
188192
m_clientShroudedLastFrame = FALSE;
@@ -324,6 +328,10 @@ void ParticleUplinkCannonUpdate::setSpecialPowerOverridableDestination( const Co
324328
{
325329
m_overrideTargetDestination = *loc;
326330
m_manualTargetMode = true;
331+
#if RETAIL_COMPATIBLE_XFER_SAVE
332+
m_2ndLastDrivingClickFrame = m_lastDrivingClickFrame;
333+
m_lastDrivingClickFrame = TheGameLogic->getFrame();
334+
#endif
327335
m_2ndLastDrivingClickTimeMsec = m_lastDrivingClickTimeMsec;
328336
m_lastDrivingClickTimeMsec = timeGetTime();
329337
}
@@ -517,7 +525,11 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()
517525
else
518526
{
519527
Real speed = data->m_manualDrivingSpeed;
528+
#if !RETAIL_COMPATIBLE_CRC
520529
if( m_lastDrivingClickTimeMsec != 0 && m_2ndLastDrivingClickTimeMsec != 0 && m_lastDrivingClickTimeMsec - m_2ndLastDrivingClickTimeMsec < data->m_doubleClickToFastDriveDelay )
530+
#else
531+
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,12 @@ 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: Changed m_lastDrivingClickFrame and m_2ndLastDrivingClickFrame to m_lastDrivingClickTimeMsec and m_2ndLastDrivingClickTimeMsec (frames to milliseconds)
1326+
* 4: Added m_orbitToTargetLaserRadius
1327+
* 5: (non-retail) Changed m_lastDrivingClickFrame and m_2ndLastDrivingClickFrame to m_lastDrivingClickTimeMsec and m_2ndLastDrivingClickTimeMsec
1328+
*/
13121329
// ------------------------------------------------------------------------------------------------
13131330
void ParticleUplinkCannonUpdate::xfer( Xfer *xfer )
13141331
{
@@ -1318,7 +1335,7 @@ void ParticleUplinkCannonUpdate::xfer( Xfer *xfer )
13181335
#if RETAIL_COMPATIBLE_XFER_SAVE
13191336
const XferVersion currentVersion = 2;
13201337
#else
1321-
const XferVersion currentVersion = 4;
1338+
const XferVersion currentVersion = 5;
13221339
#endif
13231340
XferVersion version = currentVersion;
13241341
xfer->xferVersion( &version, currentVersion );
@@ -1415,10 +1432,38 @@ void ParticleUplinkCannonUpdate::xfer( Xfer *xfer )
14151432
}
14161433

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

14231468
if( version >= 4 )
14241469
{

0 commit comments

Comments
 (0)