diff --git a/Generals/Code/GameEngine/Include/GameLogic/Module/ParticleUplinkCannonUpdate.h b/Generals/Code/GameEngine/Include/GameLogic/Module/ParticleUplinkCannonUpdate.h index 9101cd2a58..8a5d9ada50 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 XferVersion m_xferVersion; diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp index 70860c672b..5179e37747 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp @@ -148,7 +148,11 @@ ParticleUplinkCannonUpdateModuleData::ParticleUplinkCannonUpdateModuleData() { "ManualDrivingSpeed", INI::parseReal, NULL, offsetof( ParticleUplinkCannonUpdateModuleData, m_manualDrivingSpeed ) }, { "ManualFastDrivingSpeed", INI::parseReal, NULL, offsetof( ParticleUplinkCannonUpdateModuleData, m_manualFastDrivingSpeed ) }, +#if RETAIL_COMPATIBLE_CRC || RETAIL_COMPATIBLE_XFER_SAVE { "DoubleClickToFastDriveDelay", INI::parseDurationUnsignedInt, NULL, offsetof( ParticleUplinkCannonUpdateModuleData, m_doubleClickToFastDriveDelay ) }, +#else + { "DoubleClickToFastDriveDelay", INI::parseUnsignedInt, NULL, offsetof( ParticleUplinkCannonUpdateModuleData, m_doubleClickToFastDriveDelay ) }, +#endif { 0, 0, 0, 0 } }; @@ -184,8 +188,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++ ) @@ -325,8 +334,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 } } @@ -518,7 +532,14 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update() else { Real speed = data->m_manualDrivingSpeed; - if( m_lastDrivingClickFrame - m_2ndLastDrivingClickFrame < data->m_doubleClickToFastDriveDelay ) +#if RETAIL_COMPATIBLE_CRC || RETAIL_COMPATIBLE_XFER_SAVE + 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; @@ -1311,6 +1332,7 @@ void ParticleUplinkCannonUpdate::crc( Xfer *xfer ) * Version Info: * 1: Initial version * 2: Serialize decay frames + * 3: TheSuperHackers @tweak Serialize manual target mode * 4: TheSuperHackers @tweak Serialize orbit to target laser radius */ // ------------------------------------------------------------------------------------------------ @@ -1319,7 +1341,7 @@ void ParticleUplinkCannonUpdate::xfer( Xfer *xfer ) const ParticleUplinkCannonUpdateModuleData *data = getParticleUplinkCannonUpdateModuleData(); // version -#if RETAIL_COMPATIBLE_XFER_SAVE +#if RETAIL_COMPATIBLE_CRC || RETAIL_COMPATIBLE_XFER_SAVE const XferVersion currentVersion = 2; #else const XferVersion currentVersion = 4; @@ -1420,10 +1442,21 @@ 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 + xfer->xferUnsignedInt( &m_lastDrivingClickFrame ); xfer->xferUnsignedInt( &m_2ndLastDrivingClickFrame ); +#else + // TheSuperHackers @info timeGetTime values are machine-relative and meaningless on load. + // Write/read dummy values to maintain file format compatibility. + UnsignedInt dummyClickTime = 0; + xfer->xferUnsignedInt( &dummyClickTime ); + xfer->xferUnsignedInt( &dummyClickTime ); + + if( version >= 3 ) + { + xfer->xferBool( &m_manualTargetMode ); + } +#endif if( version >= 4 ) { diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ParticleUplinkCannonUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ParticleUplinkCannonUpdate.h index a022329ba1..fed305aa1f 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; XferVersion m_xferVersion; diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp index bb41f47e12..702c30d54d 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp @@ -147,7 +147,11 @@ ParticleUplinkCannonUpdateModuleData::ParticleUplinkCannonUpdateModuleData() { "ManualDrivingSpeed", INI::parseReal, NULL, offsetof( ParticleUplinkCannonUpdateModuleData, m_manualDrivingSpeed ) }, { "ManualFastDrivingSpeed", INI::parseReal, NULL, offsetof( ParticleUplinkCannonUpdateModuleData, m_manualFastDrivingSpeed ) }, +#if RETAIL_COMPATIBLE_CRC || RETAIL_COMPATIBLE_XFER_SAVE { "DoubleClickToFastDriveDelay", INI::parseDurationUnsignedInt, NULL, offsetof( ParticleUplinkCannonUpdateModuleData, m_doubleClickToFastDriveDelay ) }, +#else + { "DoubleClickToFastDriveDelay", INI::parseUnsignedInt, NULL, offsetof( ParticleUplinkCannonUpdateModuleData, m_doubleClickToFastDriveDelay ) }, +#endif { 0, 0, 0, 0 } }; @@ -185,8 +189,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++ ) @@ -375,8 +384,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 } } @@ -568,7 +582,14 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update() else { Real speed = data->m_manualDrivingSpeed; - if( m_scriptedWaypointMode || m_lastDrivingClickFrame - m_2ndLastDrivingClickFrame < data->m_doubleClickToFastDriveDelay ) +#if RETAIL_COMPATIBLE_CRC || RETAIL_COMPATIBLE_XFER_SAVE + 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; @@ -1404,7 +1425,7 @@ void ParticleUplinkCannonUpdate::xfer( Xfer *xfer ) const ParticleUplinkCannonUpdateModuleData *data = getParticleUplinkCannonUpdateModuleData(); // version -#if RETAIL_COMPATIBLE_XFER_SAVE +#if RETAIL_COMPATIBLE_CRC || RETAIL_COMPATIBLE_XFER_SAVE const XferVersion currentVersion = 3; #else const XferVersion currentVersion = 4; @@ -1505,10 +1526,16 @@ 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 + xfer->xferUnsignedInt( &m_lastDrivingClickFrame ); xfer->xferUnsignedInt( &m_2ndLastDrivingClickFrame ); +#else + // TheSuperHackers @info timeGetTime values are machine-relative and meaningless on load. + // Write/read dummy values to maintain file format compatibility. + UnsignedInt dummyClickTime = 0; + xfer->xferUnsignedInt( &dummyClickTime ); + xfer->xferUnsignedInt( &dummyClickTime ); +#endif if( version >= 3 ) {