bugfix(input): Prevent command execution when attempting to exit command context while moving the camera#1501
Conversation
| Bool isClick = TheMouse->isClick(&m_deselectFeedbackAnchor, &pixel, m_lastClick, currentTime); | ||
|
|
||
| if (isClick && | ||
| cameraPos.length() > TheMouse->m_dragTolerance3D) |
There was a problem hiding this comment.
Mouse.ini:
DragTolerance = 25 ; How many pixels should we allow before it is a drag?
DragTolerance3D = 25 ; How many feet in worldspace should we allow before it is a drag?
DragToleranceMS = 250 ; if the mouse is held down for this long, we consider it a drag, not a click.
This is the only user of m_dragTolerance3D. So we can remove that field as well?
Perhaps the cameraPos.length() > TheMouse->m_dragTolerance3D was meant to be inside isClick function? It looks to be intentional, so I wonder if there is something to it we are missing.
There was a problem hiding this comment.
The field can indeed be removed. I left it for posterity in case it could be used for something else.
It is a reasonable expectation that right-clicking cancels the active context command regardless of camera movement. It otherwise introduces a seemingly arbitrary behavioural inconsistency (especially as it is dependent on the player's camera scroll speed set in the game options). A player might right-click while moving the camera (or immediately after pressing spacebar or a hotkey to zoom to a location), not realise their command is still active, and then accidentally bomb themselves or a useless location.
I think it probably was meant to be inside isClick, but I cannot come up with any valid cases for keeping the condition.
There was a problem hiding this comment.
Also, judging by the descriptions, it appears to be redundant to DragTolerance.
|
Can we come up with a more intuitive change description? Even I have trouble understand what this means. |
Do you mean the description or title? The description is more technical / developer-focused. Perhaps we can come up with one based on the repro steps.
The change essentially ensures that right-clicking consistently exits the active command context - when the user has selected an ability to use and the game is awaiting input for a location / target. |
|
Replacing "context" with "command context" helps readability a bit but otherwise I have no better idea. I expect most readers will not understand this. "Prevent command execution when attempting to exit command context while moving the camera" |
…and context while moving the camera (TheSuperHackers#1501)
…and context while moving the camera (TheSuperHackers#1501)
This change resolves a bug where right-clicking to cancel a context command such as a super weapon will actually trigger it if the camera is moving with a high enough scroll speed. This occurs because
MSG_RAW_MOUSE_RIGHT_BUTTON_UPis not consumed for clicks determined to be invalid due to camera movement, allowing the message to be processed inCommandXlatwhere the same condition is not present.An alternative approach would be to add the same camera movement condition to
CommandXlat, but it feels counterintuitive to be unable to cancel context commands while the camera is moving with a high enough scroll speed. There are no apparent consequences to removing the condition.