diff --git a/Generals/Code/GameEngine/Include/GameLogic/Module/ParticleUplinkCannonUpdate.h b/Generals/Code/GameEngine/Include/GameLogic/Module/ParticleUplinkCannonUpdate.h index f313a06f55..4ed3bda71c 100644 --- a/Generals/Code/GameEngine/Include/GameLogic/Module/ParticleUplinkCannonUpdate.h +++ b/Generals/Code/GameEngine/Include/GameLogic/Module/ParticleUplinkCannonUpdate.h @@ -225,8 +225,13 @@ class ParticleUplinkCannonUpdate : public UpdateModule, public SpecialPowerUpdat UnsignedInt m_nextDamagePulseFrame; UnsignedInt m_startAttackFrame; UnsignedInt m_startDecayFrame; - UnsignedInt m_lastDrivingClickFrame; - UnsignedInt m_2ndLastDrivingClickFrame; +#if RETAIL_COMPATIBLE_CRC || RETAIL_COMPATIBLE_XFER_SAVE + UnsignedInt m_lastDrivingClickFrame; // Frame number for retail compatibility + UnsignedInt m_2ndLastDrivingClickFrame; // Frame number for retail compatibility +#else + UnsignedInt m_lastDrivingClickTimeMsec; // Real-time milliseconds + UnsignedInt m_2ndLastDrivingClickTimeMsec; // Real-time milliseconds +#endif Bool m_upBonesCached; Bool m_defaultInfoCached; diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp index ad7614d1f1..7c8141b3b1 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp @@ -183,8 +183,13 @@ ParticleUplinkCannonUpdate::ParticleUplinkCannonUpdate( Thing *thing, const Modu m_nextDamagePulseFrame = 0; m_startAttackFrame = 0; m_startDecayFrame = 0; +#if RETAIL_COMPATIBLE_CRC || RETAIL_COMPATIBLE_XFER_SAVE m_lastDrivingClickFrame = 0; m_2ndLastDrivingClickFrame = 0; +#else + m_lastDrivingClickTimeMsec = 0; + m_2ndLastDrivingClickTimeMsec = 0; +#endif m_clientShroudedLastFrame = FALSE; for( Int i = 0; i < MAX_OUTER_NODES; i++ ) @@ -324,8 +329,13 @@ void ParticleUplinkCannonUpdate::setSpecialPowerOverridableDestination( const Co { m_overrideTargetDestination = *loc; m_manualTargetMode = true; +#if RETAIL_COMPATIBLE_CRC || RETAIL_COMPATIBLE_XFER_SAVE m_2ndLastDrivingClickFrame = m_lastDrivingClickFrame; m_lastDrivingClickFrame = TheGameLogic->getFrame(); +#else + m_2ndLastDrivingClickTimeMsec = m_lastDrivingClickTimeMsec; + m_lastDrivingClickTimeMsec = timeGetTime(); +#endif } } @@ -517,7 +527,14 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update() else { Real speed = data->m_manualDrivingSpeed; - if( m_lastDrivingClickFrame - m_2ndLastDrivingClickFrame < data->m_doubleClickToFastDriveDelay ) +#if RETAIL_COMPATIBLE_CRC + DEBUG_ASSERTCRASH(m_lastDrivingClickFrame >= m_2ndLastDrivingClickFrame, ("m_lastDrivingClickFrame should always be >= m_2ndLastDrivingClickFrame")); + const Bool useFasterSpeed = m_lastDrivingClickFrame - m_2ndLastDrivingClickFrame < data->m_doubleClickToFastDriveDelay; +#else + DEBUG_ASSERTCRASH(m_lastDrivingClickTimeMsec >= m_2ndLastDrivingClickTimeMsec, ("m_lastDrivingClickTimeMsec should always be >= m_2ndLastDrivingClickTimeMsec")); + const Bool useFasterSpeed = m_lastDrivingClickTimeMsec - m_2ndLastDrivingClickTimeMsec < data->m_doubleClickToFastDriveDelay; +#endif + if( useFasterSpeed ) { //Because we double clicked, use the faster driving speed. speed = data->m_manualFastDrivingSpeed; @@ -1308,7 +1325,12 @@ void ParticleUplinkCannonUpdate::crc( Xfer *xfer ) // ------------------------------------------------------------------------------------------------ /** Xfer method * Version Info: - * 1: Initial version */ + * 1: Initial version + * 2: Added m_startDecayFrame + * 3: Added m_manualTargetMode + * 4: Added m_orbitToTargetLaserRadius + * 5: Changed m_lastDrivingClickFrame and m_2ndLastDrivingClickFrame to m_lastDrivingClickTimeMsec and m_2ndLastDrivingClickTimeMsec (frames to milliseconds) + */ // ------------------------------------------------------------------------------------------------ void ParticleUplinkCannonUpdate::xfer( Xfer *xfer ) { @@ -1316,9 +1338,9 @@ void ParticleUplinkCannonUpdate::xfer( Xfer *xfer ) // version #if RETAIL_COMPATIBLE_XFER_SAVE - const XferVersion currentVersion = 2; + const XferVersion currentVersion = 3; #else - const XferVersion currentVersion = 4; + const XferVersion currentVersion = 5; #endif XferVersion version = currentVersion; xfer->xferVersion( &version, currentVersion ); @@ -1415,10 +1437,35 @@ void ParticleUplinkCannonUpdate::xfer( Xfer *xfer ) } // the time of last manual target click - xfer->xferUnsignedInt( & m_lastDrivingClickFrame ); - - // the time of the 2nd last manual target click +#if RETAIL_COMPATIBLE_CRC || RETAIL_COMPATIBLE_XFER_SAVE + // Retail builds stay at version 3 for compatibility, so always use old frame format + xfer->xferUnsignedInt( &m_lastDrivingClickFrame ); xfer->xferUnsignedInt( &m_2ndLastDrivingClickFrame ); +#else + if( version >= 5 ) + { + xfer->xferUnsignedInt( &m_lastDrivingClickTimeMsec ); + xfer->xferUnsignedInt( &m_2ndLastDrivingClickTimeMsec ); + } + else + { + // Old versions stored frame numbers, which we can't meaningfully convert to milliseconds + UnsignedInt oldLastDrivingClickFrame = 0; + UnsignedInt old2ndLastDrivingClickFrame = 0; + xfer->xferUnsignedInt( &oldLastDrivingClickFrame ); + xfer->xferUnsignedInt( &old2ndLastDrivingClickFrame ); + if( xfer->getXferMode() == XFER_LOAD ) + { + m_lastDrivingClickTimeMsec = 0; + m_2ndLastDrivingClickTimeMsec = 0; + } + } +#endif + + if( version >= 3 ) + { + xfer->xferBool( &m_manualTargetMode ); + } if( version >= 4 ) { diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ParticleUplinkCannonUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ParticleUplinkCannonUpdate.h index 015813b9a7..a75261b948 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ParticleUplinkCannonUpdate.h +++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ParticleUplinkCannonUpdate.h @@ -227,8 +227,13 @@ class ParticleUplinkCannonUpdate : public SpecialPowerUpdateModule UnsignedInt m_nextDamagePulseFrame; UnsignedInt m_startAttackFrame; UnsignedInt m_startDecayFrame; - UnsignedInt m_lastDrivingClickFrame; - UnsignedInt m_2ndLastDrivingClickFrame; +#if RETAIL_COMPATIBLE_CRC || RETAIL_COMPATIBLE_XFER_SAVE + UnsignedInt m_lastDrivingClickFrame; // Frame number for retail compatibility + UnsignedInt m_2ndLastDrivingClickFrame; // Frame number for retail compatibility +#else + UnsignedInt m_lastDrivingClickTimeMsec; // Real-time milliseconds + UnsignedInt m_2ndLastDrivingClickTimeMsec; // Real-time milliseconds +#endif UnsignedInt m_nextDestWaypointID; Bool m_upBonesCached; diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp index d2d1d07928..7ee4251c81 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp @@ -184,8 +184,13 @@ ParticleUplinkCannonUpdate::ParticleUplinkCannonUpdate( Thing *thing, const Modu m_nextDamagePulseFrame = 0; m_startAttackFrame = 0; m_startDecayFrame = 0; +#if RETAIL_COMPATIBLE_CRC || RETAIL_COMPATIBLE_XFER_SAVE m_lastDrivingClickFrame = 0; m_2ndLastDrivingClickFrame = 0; +#else + m_lastDrivingClickTimeMsec = 0; + m_2ndLastDrivingClickTimeMsec = 0; +#endif m_clientShroudedLastFrame = FALSE; for( Int i = 0; i < MAX_OUTER_NODES; i++ ) @@ -374,8 +379,13 @@ void ParticleUplinkCannonUpdate::setSpecialPowerOverridableDestination( const Co { m_overrideTargetDestination = *loc; m_manualTargetMode = TRUE; +#if RETAIL_COMPATIBLE_CRC || RETAIL_COMPATIBLE_XFER_SAVE m_2ndLastDrivingClickFrame = m_lastDrivingClickFrame; m_lastDrivingClickFrame = TheGameLogic->getFrame(); +#else + m_2ndLastDrivingClickTimeMsec = m_lastDrivingClickTimeMsec; + m_lastDrivingClickTimeMsec = timeGetTime(); +#endif } } @@ -567,7 +577,14 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update() else { Real speed = data->m_manualDrivingSpeed; - if( m_scriptedWaypointMode || m_lastDrivingClickFrame - m_2ndLastDrivingClickFrame < data->m_doubleClickToFastDriveDelay ) +#if RETAIL_COMPATIBLE_CRC + DEBUG_ASSERTCRASH(m_lastDrivingClickFrame >= m_2ndLastDrivingClickFrame, ("m_lastDrivingClickFrame should always be >= m_2ndLastDrivingClickFrame")); + const Bool useFasterSpeed = m_scriptedWaypointMode || (m_lastDrivingClickFrame - m_2ndLastDrivingClickFrame < data->m_doubleClickToFastDriveDelay); +#else + DEBUG_ASSERTCRASH(m_lastDrivingClickTimeMsec >= m_2ndLastDrivingClickTimeMsec, ("m_lastDrivingClickTimeMsec should always be >= m_2ndLastDrivingClickTimeMsec")); + const Bool useFasterSpeed = m_scriptedWaypointMode || (m_lastDrivingClickTimeMsec - m_2ndLastDrivingClickTimeMsec < data->m_doubleClickToFastDriveDelay); +#endif + if( useFasterSpeed ) { //Because we double clicked, use the faster driving speed. speed = data->m_manualFastDrivingSpeed; @@ -1392,7 +1409,12 @@ void ParticleUplinkCannonUpdate::crc( Xfer *xfer ) // ------------------------------------------------------------------------------------------------ /** Xfer method * Version Info: - * 1: Initial version */ + * 1: Initial version + * 2: Added m_startDecayFrame + * 3: Added m_manualTargetMode, m_scriptedWaypointMode, m_nextDestWaypointID + * 4: Added m_orbitToTargetLaserRadius + * 5: Changed m_lastDrivingClickFrame and m_2ndLastDrivingClickFrame to m_lastDrivingClickTimeMsec and m_2ndLastDrivingClickTimeMsec (frames to milliseconds) + */ // ------------------------------------------------------------------------------------------------ void ParticleUplinkCannonUpdate::xfer( Xfer *xfer ) { @@ -1402,7 +1424,7 @@ void ParticleUplinkCannonUpdate::xfer( Xfer *xfer ) #if RETAIL_COMPATIBLE_XFER_SAVE const XferVersion currentVersion = 3; #else - const XferVersion currentVersion = 4; + const XferVersion currentVersion = 5; #endif XferVersion version = currentVersion; xfer->xferVersion( &version, currentVersion ); @@ -1499,10 +1521,30 @@ void ParticleUplinkCannonUpdate::xfer( Xfer *xfer ) } // the time of last manual target click - xfer->xferUnsignedInt( & m_lastDrivingClickFrame ); - - // the time of the 2nd last manual target click +#if RETAIL_COMPATIBLE_CRC || RETAIL_COMPATIBLE_XFER_SAVE + // Retail builds stay at version 3 for compatibility, so always use old frame format + xfer->xferUnsignedInt( &m_lastDrivingClickFrame ); xfer->xferUnsignedInt( &m_2ndLastDrivingClickFrame ); +#else + if( version >= 5 ) + { + xfer->xferUnsignedInt( &m_lastDrivingClickTimeMsec ); + xfer->xferUnsignedInt( &m_2ndLastDrivingClickTimeMsec ); + } + else + { + // Old versions stored frame numbers, which we can't meaningfully convert to milliseconds + UnsignedInt oldLastDrivingClickFrame = 0; + UnsignedInt old2ndLastDrivingClickFrame = 0; + xfer->xferUnsignedInt( &oldLastDrivingClickFrame ); + xfer->xferUnsignedInt( &old2ndLastDrivingClickFrame ); + if( xfer->getXferMode() == XFER_LOAD ) + { + m_lastDrivingClickTimeMsec = 0; + m_2ndLastDrivingClickTimeMsec = 0; + } + } +#endif if( version >= 3 ) {