|
| 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 | +} |
0 commit comments