Skip to content

bugfix(commandxlat): Re-enable right mouse click move commands during camera scrolling#2847

Open
xezon wants to merge 1 commit into
TheSuperHackers:mainfrom
xezon:xezon/fix-scroll-click
Open

bugfix(commandxlat): Re-enable right mouse click move commands during camera scrolling#2847
xezon wants to merge 1 commit into
TheSuperHackers:mainfrom
xezon:xezon/fix-scroll-click

Conversation

@xezon

@xezon xezon commented Jun 30, 2026

Copy link
Copy Markdown

This change re-enables right mouse click move commands during camera scrolling.

@xezon xezon requested a review from Stubbjax June 30, 2026 17:43
@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 ThisProject The issue was introduced by this project, or this task is specific to this project Input labels Jun 30, 2026
@greptile-apps

greptile-apps Bot commented Jun 30, 2026

Copy link
Copy Markdown

Greptile Summary

This PR re-enables right mouse button move commands in CommandXlat during camera scrolling by removing the 3D camera-position check from that path, while preserving the camera-position check in SelectionXlat (which guards against accidental deselection during scrolls). It is a follow-up to #2826.

  • Mouse::isClick is refactored into two overloads: a simpler 2D/time-only version (new) and a 3D version that delegates to it then additionally checks camera delta. The two overloads cover different use cases — move commands vs. unit deselection.
  • CommandXlat drops its m_rightMouseDownCameraPos/m_rightMouseUpCameraPos members entirely and now calls the 2D-only overload, allowing right-click move orders even while the camera is scrolling.
  • SelectionXlat is unchanged in its camera-tracking logic and continues to use the 3D overload, so dragging the camera does not accidentally deselect units.

Confidence Score: 5/5

The change is narrowly scoped: it removes the camera-position guard from right-click command dispatch in CommandXlat only, deliberately retaining it in SelectionXlat to protect unit deselection. The refactored isClick overloads are logically equivalent to the original, and the parameter-type reordering means the compiler will catch any missed call sites.

All three call sites are updated to match the new signatures. The 3D overload correctly delegates to the 2D check before applying the camera-delta test, preserving the original logic for SelectionXlat. No missing updates, no stale state, and the two code paths are now cleanly separated by intent.

No files require special attention. The split between CommandXlat (2D-only) and SelectionXlat (3D) is intentional and correctly implemented.

Important Files Changed

Filename Overview
Core/GameEngine/Source/GameClient/Input/Mouse.cpp Refactors isClick into two overloads: a 2D/time-only version and a 3D camera-delta version that delegates to it. Logic is equivalent to the old combined check, cleanly split by concern.
Core/GameEngine/Include/GameClient/Mouse.h Declares both isClick overloads; parameter order change from old signature is handled consistently across all callers. Uses #pragma once correctly.
Core/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp Removes camera-position capture from right mouse down/up handlers; switches isClick calls to the 2D-only overload; comment updated from three to two exclusion conditions.
Core/GameEngine/Include/GameClient/CommandXlat.h Removes m_rightMouseDownCameraPos and m_rightMouseUpCameraPos members; no other structural changes.
Core/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Switches argument order in isClick call to match the updated signature; camera position tracking and 3D overload intentionally retained to guard against accidental deselection during scrolling.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant User
    participant CommandXlat
    participant SelectionXlat
    participant Mouse
    participant TheTacticalView

    Note over User: Right Mouse Button Down
    User->>CommandXlat: MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN
    CommandXlat->>CommandXlat: store m_rightMouseDownAnchor, m_rightMouseDownTimeMs
    Note right of CommandXlat: Camera pos no longer stored (PR change)

    User->>SelectionXlat: MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN
    SelectionXlat->>TheTacticalView: getPosition()
    SelectionXlat->>SelectionXlat: store m_rightMouseDownAnchor, m_rightMouseDownTimeMs, m_rightMouseDownCameraPos

    Note over User: Right Mouse Button Up
    User->>CommandXlat: MSG_RAW_MOUSE_RIGHT_BUTTON_UP
    CommandXlat->>Mouse: isClick(timeMs0, timeMs1, anchor0, anchor1)
    Note right of Mouse: 2D+time check only (no camera check)
    Mouse-->>CommandXlat: TRUE (click valid even during scroll)
    CommandXlat->>CommandXlat: issue move / attack command

    User->>SelectionXlat: MSG_RAW_MOUSE_RIGHT_BUTTON_UP
    SelectionXlat->>TheTacticalView: getPosition()
    SelectionXlat->>Mouse: isClick(timeMs0, timeMs1, anchor0, anchor1, camPos0, camPos1)
    Note right of Mouse: 2D+time check AND 3D camera delta check
    Mouse-->>SelectionXlat: FALSE if camera moved too far
    SelectionXlat->>SelectionXlat: skip deselect (camera scrolled)
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant User
    participant CommandXlat
    participant SelectionXlat
    participant Mouse
    participant TheTacticalView

    Note over User: Right Mouse Button Down
    User->>CommandXlat: MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN
    CommandXlat->>CommandXlat: store m_rightMouseDownAnchor, m_rightMouseDownTimeMs
    Note right of CommandXlat: Camera pos no longer stored (PR change)

    User->>SelectionXlat: MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN
    SelectionXlat->>TheTacticalView: getPosition()
    SelectionXlat->>SelectionXlat: store m_rightMouseDownAnchor, m_rightMouseDownTimeMs, m_rightMouseDownCameraPos

    Note over User: Right Mouse Button Up
    User->>CommandXlat: MSG_RAW_MOUSE_RIGHT_BUTTON_UP
    CommandXlat->>Mouse: isClick(timeMs0, timeMs1, anchor0, anchor1)
    Note right of Mouse: 2D+time check only (no camera check)
    Mouse-->>CommandXlat: TRUE (click valid even during scroll)
    CommandXlat->>CommandXlat: issue move / attack command

    User->>SelectionXlat: MSG_RAW_MOUSE_RIGHT_BUTTON_UP
    SelectionXlat->>TheTacticalView: getPosition()
    SelectionXlat->>Mouse: isClick(timeMs0, timeMs1, anchor0, anchor1, camPos0, camPos1)
    Note right of Mouse: 2D+time check AND 3D camera delta check
    Mouse-->>SelectionXlat: FALSE if camera moved too far
    SelectionXlat->>SelectionXlat: skip deselect (camera scrolled)
Loading

Reviews (1): Last reviewed commit: "bugfix(commandxlat): Re-enable right mou..." | Re-trigger Greptile

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 ThisProject The issue was introduced by this project, or this task is specific to this project ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant