From 2e149095848de1e6c81bce7dfb13b65379b6bf3d Mon Sep 17 00:00:00 2001 From: Michael Fadely Date: Thu, 25 Jun 2020 14:30:50 -0600 Subject: [PATCH] update mod loader, small cleanup --- sadx-mod-loader | 2 +- sadx-test-spawn/mod.cpp | 43 ++++++++++++++++++---------------------- sadx-test-spawn/stdafx.h | 2 +- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/sadx-mod-loader b/sadx-mod-loader index eb829f4..2fe5d95 160000 --- a/sadx-mod-loader +++ b/sadx-mod-loader @@ -1 +1 @@ -Subproject commit eb829f49da5107d6604186c1b995d939b3f07321 +Subproject commit 2fe5d955c692d8f37329665c5b8676b0bb243720 diff --git a/sadx-test-spawn/mod.cpp b/sadx-test-spawn/mod.cpp index e37959c..64e21da 100644 --- a/sadx-test-spawn/mod.cpp +++ b/sadx-test-spawn/mod.cpp @@ -1,11 +1,5 @@ #include "stdafx.h" -#include -#include // for CommandLineToArgvW -#include -#include -#include - static const auto loc_40C318 = reinterpret_cast(0x0040C318); __declspec(naked) void ForceTrialMode() @@ -107,16 +101,16 @@ static void Obj_Icecap_r(ObjectMaster* o) extern "C" { __declspec(dllexport) ModInfo SADXModInfo = { - ModLoaderVer, - nullptr, - nullptr, - 0, - nullptr, - 0, - nullptr, - 0, - nullptr, - 0 + /* Version: */ ModLoaderVer, + /* Init: */ nullptr, + /* Patches: */ nullptr, + /* PatchCount: */ 0, + /* Jumps: */ nullptr, + /* JumpCount: */ 0, + /* Calls: */ nullptr, + /* CallCount: */ 0, + /* Pointers: */ nullptr, + /* PointerCount: */ 0 }; __declspec(dllexport) void __cdecl Init(const char* path, const HelperFunctions& helperFunctions) @@ -127,9 +121,9 @@ extern "C" bool level_set = false; bool act_set = false; - // Prevents CurrentCharacter from being overwritten. There could be other side effects, - // but there are none that I've noticed thus far. - WriteData<5>((void*)0x00415007, 0x90i8); + // NOP. Prevents CurrentCharacter from being overwritten. There could be other side + // effects, but there are none that we've noticed thus far. + WriteData<5>(reinterpret_cast(0x00415007), 0x90u); for (int i = 1; i < argc; i++) { @@ -180,13 +174,14 @@ extern "C" if (CurrentLevel == LevelIDs_IceCap) { - WriteData<2>(reinterpret_cast(0x004149EC), 0x90i8); - WriteData<2>(reinterpret_cast(0x0041497F), 0x90i8); - WriteData<2>(reinterpret_cast(0x00414A70), 0x90i8); + // NOPs to disable several checks for LevelIDs_IceCap which prevent + // correct player positioning and orienting. + WriteData<2>(reinterpret_cast(0x004149EC), 0x90u); + WriteData<2>(reinterpret_cast(0x0041497F), 0x90u); + WriteData<2>(reinterpret_cast(0x00414A70), 0x90u); using LevelObjectFunc = void(__cdecl*)(ObjectMaster* this_); - auto* level_objects = reinterpret_cast(0x0090BF38); - level_objects[LevelIDs_IceCap] = Obj_Icecap_r; + LevelObjects[LevelIDs_IceCap] = Obj_Icecap_r; } const float x = std::stof(argv[++i]); diff --git a/sadx-test-spawn/stdafx.h b/sadx-test-spawn/stdafx.h index bb19ca8..5390203 100644 --- a/sadx-test-spawn/stdafx.h +++ b/sadx-test-spawn/stdafx.h @@ -1,7 +1,7 @@ #pragma once #include -#include // for CommandLineToArgvW +#include // for CommandLineToArgvW #include #include #include