Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 12209a2

Browse files
committed
Fix incorrect mouse bounds during splitscreen when the mouse player is not Player 1
1 parent 780c69c commit 12209a2

File tree

2 files changed

+32
-29
lines changed

2 files changed

+32
-29
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
433433

434434
- Console error spam will no longer cripple performance over time.
435435

436+
- Fixed incorrect mouse bounds during splitscreen when the mouse player was not Player 1.
437+
436438
</details>
437439

438440

Managers/UInputMan.cpp

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -372,42 +372,43 @@ namespace RTE {
372372
void UInputMan::ForceMouseWithinBox(int x, int y, int width, int height, int whichPlayer) const {
373373
// Only mess with the mouse if the original mouse position is not above the screen and may be grabbing the title bar of the game window
374374
if (!m_DisableMouseMoving && !m_TrapMousePos && (whichPlayer == Players::NoPlayer || m_ControlScheme.at(whichPlayer).GetDevice() == InputDevice::DEVICE_MOUSE_KEYB)) {
375-
position_mouse(Limit(mouse_x, x + width * g_FrameMan.GetResMultiplier(), x), Limit(mouse_y, y + height * g_FrameMan.GetResMultiplier(), y));
375+
position_mouse(Limit(mouse_x, x + width, x), Limit(mouse_y, y + height, y));
376376
}
377377
}
378378

379379
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
380380

381381
void UInputMan::ForceMouseWithinPlayerScreen(int whichPlayer) const {
382-
if (whichPlayer < Players::PlayerOne || whichPlayer >= Players::PlayerFour) {
383-
return;
384-
}
385-
unsigned int screenWidth = g_FrameMan.GetPlayerFrameBufferWidth(whichPlayer);
386-
unsigned int screenHeight = g_FrameMan.GetPlayerFrameBufferHeight(whichPlayer);
387-
388-
if (g_FrameMan.GetScreenCount() > 1) {
389-
switch (whichPlayer) {
390-
case Players::PlayerOne:
391-
ForceMouseWithinBox(0, 0, screenWidth, screenHeight, whichPlayer);
392-
break;
393-
case Players::PlayerTwo:
394-
if ((g_FrameMan.GetVSplit() && !g_FrameMan.GetHSplit()) || (g_FrameMan.GetVSplit() && g_FrameMan.GetHSplit())) {
395-
ForceMouseWithinBox(g_FrameMan.GetResX() / 2, 0, screenWidth, screenHeight, whichPlayer);
396-
} else {
397-
ForceMouseWithinBox(0, g_FrameMan.GetResY() / 2, screenWidth, screenHeight, whichPlayer);
398-
}
399-
break;
400-
case Players::PlayerThree:
401-
ForceMouseWithinBox(0, g_FrameMan.GetResY() / 2, screenWidth, screenHeight, whichPlayer);
402-
break;
403-
case Players::PlayerFour:
404-
ForceMouseWithinBox(g_FrameMan.GetResX() / 2, g_FrameMan.GetResY() / 2, screenWidth, screenHeight, whichPlayer);
405-
break;
406-
default:
407-
RTEAbort("Undefined player value passed in. See Players enumeration for defined values.")
382+
if (whichPlayer >= Players::PlayerOne && whichPlayer < Players::MaxPlayerCount) {
383+
int screenWidth = g_FrameMan.GetPlayerFrameBufferWidth(whichPlayer) * g_FrameMan.GetResMultiplier();
384+
int screenHeight = g_FrameMan.GetPlayerFrameBufferHeight(whichPlayer) * g_FrameMan.GetResMultiplier();
385+
int screenCount = g_FrameMan.GetScreenCount();
386+
387+
if (screenCount > 1) {
388+
switch (g_ActivityMan.GetActivity()->ScreenOfPlayer(whichPlayer)) {
389+
case 0:
390+
ForceMouseWithinBox(0, 0, screenWidth, screenHeight, whichPlayer);
391+
break;
392+
case 1:
393+
if (screenCount >= 2 && g_FrameMan.GetVSplit()) {
394+
ForceMouseWithinBox(screenWidth, 0, screenWidth, screenHeight, whichPlayer);
395+
} else {
396+
ForceMouseWithinBox(0, screenHeight, screenWidth, screenHeight, whichPlayer);
397+
}
398+
break;
399+
case 2:
400+
ForceMouseWithinBox(0, screenHeight, screenWidth, screenHeight, whichPlayer);
401+
break;
402+
case 3:
403+
ForceMouseWithinBox(screenWidth, screenHeight, screenWidth, screenHeight, whichPlayer);
404+
break;
405+
default:
406+
// ScreenOfPlayer will return -1 for inactive player so do nothing.
407+
break;
408+
}
409+
} else {
410+
ForceMouseWithinBox(0, 0, screenWidth, screenHeight, whichPlayer);
408411
}
409-
} else {
410-
ForceMouseWithinBox(0, 0, screenWidth, screenHeight, whichPlayer);
411412
}
412413
}
413414

0 commit comments

Comments
 (0)