Skip to content

Commit 42b7135

Browse files
authored
Prevent Maria from spawning OOB in certain rooms (#1187)
1 parent 03b3131 commit 42b7135

File tree

6 files changed

+62
-0
lines changed

6 files changed

+62
-0
lines changed

Common/Settings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
visit(MainMenuFix, true) \
107107
visit(MainMenuInstantLoadOptions, true) \
108108
visit(MainMenuTitlePerLang, true) \
109+
visit(MariaSpawnFix, true) \
109110
visit(MemoScreenFix, true) \
110111
visit(MenuSoundsFix, true) \
111112
visit(MothDrawOrderFix, true) \
@@ -269,6 +270,7 @@
269270
visit(LimitPerFrameFPS) \
270271
visit(LoadModulesFromMemory) \
271272
visit(LockResolution) \
273+
visit(MariaSpawnFix) \
272274
visit(MusicBoxVolume) \
273275
visit(NormalFontHeight) \
274276
visit(NormalFontWidth) \

Patches/MariaSpawnFix.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Copyright (C) 2025 Murugo
3+
*
4+
* This software is provided 'as-is', without any express or implied warranty. In no event will the
5+
* authors be held liable for any damages arising from the use of this software.
6+
* Permission is granted to anyone to use this software for any purpose, including commercial
7+
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
8+
*
9+
* 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
10+
* original software. If you use this software in a product, an acknowledgment in the product
11+
* documentation would be appreciated but is not required.
12+
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
13+
* being the original software.
14+
* 3. This notice may not be removed or altered from any source distribution.
15+
*/
16+
17+
#define WIN32_LEAN_AND_MEAN
18+
#include <Windows.h>
19+
#include "Patches.h"
20+
#include "Common\Utils.h"
21+
#include "Logging\Logging.h"
22+
23+
// Prevents Maria from spawning out of bounds in certain rooms after reuniting with her outside of
24+
// Pete's Bowl-O-Rama or in the basement of the Otherworld Hospital.
25+
void RunMariaSpawnFix()
26+
{
27+
// If enabled, when loading the next room, the game will set Maria's position to her last saved
28+
// position from the current save file.
29+
static WORD* UseSavedPos = nullptr;
30+
31+
if (!UseSavedPos)
32+
{
33+
RUNONCE();
34+
35+
constexpr BYTE SearchBytes[]{ 0x33, 0xC9, 0xB8, 0x21, 0x00, 0x00, 0x00, 0xBA };
36+
UseSavedPos = (WORD*)ReadSearchedAddresses(0x0052D9FB, 0x0052DD2B, 0x0052D64B, SearchBytes, sizeof(SearchBytes), -0x21, __FUNCTION__);
37+
if (!UseSavedPos)
38+
{
39+
Logging::Log() << __FUNCTION__ << " Error: failed to find memory address!";
40+
return;
41+
}
42+
}
43+
44+
if (GetCutsceneID() == CS_BOWL_MARIA_JAMES || GetCutsceneID() == CS_HSP_ALT_MARIA_BASEMENT ||
45+
(GetRoomID() == R_HSP_ALT_BASEMENT && GetEventIndex() == EVENT_GAME_FMV))
46+
{
47+
*UseSavedPos = 0;
48+
}
49+
}

Patches/Patches.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,7 @@ void RunHotelWater();
766766
void RunInfiniteRumbleFix();
767767
void RunInnerFlashlightGlow(DWORD Height);
768768
void RunLightingTransition();
769+
void RunMariaSpawnFix();
769770
void RunPlayFlashlightSounds();
770771
void RunPlayLyingFigureSounds();
771772
void RunQuickSaveTweaks();

Wrappers/d3d8/IDirect3DDevice8.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,6 +2782,12 @@ HRESULT m_IDirect3DDevice8::BeginScene()
27822782
RunChainsawSoundFix();
27832783
}
27842784

2785+
// Prevent Maria from spawning out of bounds in certain rooms
2786+
if (MariaSpawnFix)
2787+
{
2788+
RunMariaSpawnFix();
2789+
}
2790+
27852791
NeedToGrabScreenForWater = true;
27862792
RoachesDrawingCounter = 0;
27872793
}

sh2-enhce.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ copy /Y "$(ProjectDir)Resources\SH2EEsetup.exe" "$(TargetDir)" &gt;nul</Command>
230230
<ClCompile Include="Patches\MapTranscription.cpp" />
231231
<ClCompile Include="Patches\DelayedFadeIn.cpp" />
232232
<ClCompile Include="Patches\FmvSubtitles.cpp" />
233+
<ClCompile Include="Patches\MariaSpawnFix.cpp" />
233234
<ClCompile Include="Patches\MusicBoxVolume.cpp" />
234235
<ClCompile Include="Patches\OptionsMenuTweaks.cpp" />
235236
<ClCompile Include="Patches\PuzzleAlignmentFixes.cpp" />

sh2-enhce.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,9 @@
491491
<ClCompile Include="Patches\DogRoomEnhanced.cpp">
492492
<Filter>Patches</Filter>
493493
</ClCompile>
494+
<ClCompile Include="Patches\MariaSpawnFix.cpp">
495+
<Filter>Patches</Filter>
496+
</ClCompile>
494497
</ItemGroup>
495498
<ItemGroup>
496499
<ClInclude Include="Common\Settings.h">

0 commit comments

Comments
 (0)