Skip to content

Commit 6b72e1e

Browse files
committed
Correct changelog, avoid out-of-bounds array access.
In updating to changelog to actually include an example of the effects of mixing up screen and player indices, I realized that there was no protection against out-of-bounds array accesses in these functions, so I fixed that.
1 parent 2182180 commit 6b72e1e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3939

4040
- Fixed an issue where palette index 255 was incorrectly showing as black.
4141

42-
- Fixed instances of `CameraMan:GetScrollTarget()` and `CameraMan:SetScrollTarget()` supplying a player index instead of a screen index.
42+
- Fixed instances of `CameraMan:GetScrollTarget()` and `CameraMan:SetScrollTarget()` supplying a player index instead of a screen index. This could prevent the functions from working properly, or at all, when playing as a player other than 1, potentially screwing up camera effects.
4343

4444
- Fixed a bug in Decision Day that could cause an error when trying to set the camera's scroll target, in addition to the previous issue.
4545

Source/Managers/CameraMan.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,16 @@ void CameraMan::SetScroll(const Vector& center, int screenId) {
6464
}
6565

6666
Vector CameraMan::GetScrollTarget(int screenId) const {
67+
if (screenId < 0 || screenId >= c_MaxScreenCount)
68+
// Would it be preferable to just set screenId to 0?
69+
return Vector();
6770
return g_NetworkClient.IsConnectedAndRegistered() ? g_NetworkClient.GetFrameTarget() : m_Screens[screenId].ScrollTarget;
6871
}
6972

7073
void CameraMan::SetScrollTarget(const Vector& targetCenter, float speed, int screenId) {
74+
if (screenId < 0 || screenId >= c_MaxScreenCount)
75+
return;
76+
7177
Screen& screen = m_Screens[screenId];
7278

7379
// See if it would make sense to automatically wrap.

0 commit comments

Comments
 (0)