Skip to content

bugfix(input): Use time-based double tap for unit group centering#2545

Merged
xezon merged 2 commits intoTheSuperHackers:mainfrom
bobtista:bobtista/fix/double-tap-group-select-timing
Apr 11, 2026
Merged

bugfix(input): Use time-based double tap for unit group centering#2545
xezon merged 2 commits intoTheSuperHackers:mainfrom
bobtista:bobtista/fix/double-tap-group-select-timing

Conversation

@bobtista
Copy link
Copy Markdown

@bobtista bobtista commented Apr 6, 2026

Summary

  • Replace frame-based double tap detection with time-based detection for hotkey
    group selection (MSG_META_SELECT_TEAM and MSG_META_ADD_TEAM handlers)
  • Use timeGetTime() instead of TheGameLogic->getFrame() and compare against
    TheGlobalData->m_doubleClickTimeMS instead of a hardcoded 20-frame threshold
  • The double tap window was frame-rate dependent (~667ms at 30 FPS, ~333ms at
    60 FPS), now uses the OS double-click time consistently

Closes #2531

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 6, 2026

Greptile Summary

Replaces frame-based double-tap detection with timeGetTime() in both SelectionXlat.cpp files (Generals and GeneralsMD), comparing against TheGlobalData->m_doubleClickTimeMS (sourced from the OS GetDoubleClickTime()) instead of a hardcoded 20-frame threshold. This makes unit-group camera centering behavior consistent regardless of frame rate.

Confidence Score: 5/5

Safe to merge; the fix is correct, frame-rate independent, and consistent across both game variants.

No bugs found: timeGetTime() is already in scope via PreRTS.h→mmsystem.h, m_doubleClickTimeMS is properly initialized from GetDoubleClickTime(), unsigned subtraction handles 49.7-day wraparound correctly, and the group sentinel (-1) prevents false double-taps on first press. No P0 or P1 issues.

No files require special attention.

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Replaces getFrame()-based double-tap timing with timeGetTime() and m_doubleClickTimeMS in MSG_META_SELECT_TEAM and MSG_META_ADD_TEAM handlers; logic is correct and consistent.
GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Mirrors the same double-tap timing fix for the Zero Hour expansion; changes are symmetric with the Generals file.

Sequence Diagram

sequenceDiagram
    participant User
    participant SelectionXlat
    participant timeGetTime
    participant GlobalData
    participant TacticalView

    User->>SelectionXlat: Press group key (first press)
    SelectionXlat->>timeGetTime: now = timeGetTime()
    SelectionXlat->>SelectionXlat: m_lastGroupSelTime==0 → set to now
    SelectionXlat->>GlobalData: read m_doubleClickTimeMS
    Note over SelectionXlat: group != m_lastGroupSelGroup(-1)<br/>No double tap triggered
    SelectionXlat->>SelectionXlat: Perform selection, update timestamps

    User->>SelectionXlat: Press same group key again
    SelectionXlat->>timeGetTime: now = timeGetTime()
    SelectionXlat->>GlobalData: read m_doubleClickTimeMS
    alt now - m_lastGroupSelTime < m_doubleClickTimeMS AND group matches
        SelectionXlat->>TacticalView: userLookAt(unit position) — center camera
    else Outside window or different group
        SelectionXlat->>SelectionXlat: Normal selection only
    end
    SelectionXlat->>SelectionXlat: Update m_lastGroupSelTime and m_lastGroupSelGroup
Loading

Reviews (1): Last reviewed commit: "fix(input): Use time-based double tap fo..." | Re-trigger Greptile

Copy link
Copy Markdown

@Mauller Mauller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, silly that it gave you less than a second to double click select.

@xezon xezon changed the title fix(input): Use time-based double tap for unit group centering bugfix(input): Use time-based double tap for unit group centering Apr 11, 2026
@xezon xezon added Bug Something is not working right, typically is user facing Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Input labels Apr 11, 2026
@xezon xezon merged commit 73394e5 into TheSuperHackers:main Apr 11, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working right, typically is user facing Gen Relates to Generals Input Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Double tab unit centering is frame based

3 participants