forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 134
fix(input): Fix double-click fast drive timing in ParticleUplinkCannon #2012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bobtista
wants to merge
7
commits into
TheSuperHackers:main
Choose a base branch
from
bobtista:bobtista/fix-particle-uplink-double-click-timing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+116
−17
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d27516c
fix(input): Convert double-click fast drive timing from frames to rea…
bobtista 2e261bd
refactor(input): Extract double-click condition to variable in Partic…
bobtista 9a758f4
style: Fix spacing inconsistency in ParticleUplinkCannon xfer function
bobtista 1cc6468
refactor: Make millisecond variables conditional in ParticleUplinkCan…
bobtista c63aab5
fix(input): Fix double-click fast drive timing in ParticleUplinkCannon
bobtista d3e0024
Replicate to generals
bobtista c01dbb2
refactor(input): Remove unnecessary null checks from double-click tim…
bobtista File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
bobtista marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 | ||
Caball009 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be |
||
| 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 ) | ||
| { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.