1 Commits

Author SHA1 Message Date
CraftyBoss 2b099dc14d fix npdm template issues, disable fake heap and stdlib headers, warp to start impl 2024-12-02 00:53:04 -08:00
17 changed files with 1541 additions and 18 deletions
+1 -1
View File
@@ -78,7 +78,7 @@ set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
add_definitions(-DSWITCH -D__SWITCH__ -D__RTLD_6XX__) add_definitions(-DSWITCH -D__SWITCH__ -D__RTLD_6XX__)
set(ARCH "-march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fpic -fvisibility=hidden") set(ARCH "-march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fpic -fvisibility=hidden -nostdlib")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -O3 -ffunction-sections -fdata-sections ${ARCH}" CACHE STRING "C flags") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -O3 -ffunction-sections -fdata-sections ${ARCH}" CACHE STRING "C flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} -Wno-invalid-offsetof -Wno-volatile -fno-exceptions -fno-asynchronous-unwind-tables -fno-unwind-tables" CACHE STRING "C++ flags") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} -Wno-invalid-offsetof -Wno-volatile -fno-exceptions -fno-asynchronous-unwind-tables -fno-unwind-tables" CACHE STRING "C++ flags")
+3 -1
View File
@@ -42,9 +42,11 @@ Permission is hereby granted, free of charge, to any person obtaining a copy
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
#include <limits.h> #include <limits.h>
#include <ctype.h>
#include <float.h> #include <float.h>
// nostdlib hack
#define tolower(c) (((char)c) >= 'A' && ((char)c) <= 'Z' ? ((char)c) + 32 : (char)c)
#ifdef ENABLE_LOCALES #ifdef ENABLE_LOCALES
#include <locale.h> #include <locale.h>
#endif #endif
+6 -2
View File
@@ -19,12 +19,12 @@ public:
virtual CEntityMP1& TypesMatch(int); virtual CEntityMP1& TypesMatch(int);
virtual void Think(float,class CStateManager &); virtual void Think(float,class CStateManager &);
virtual void AcceptScriptMsg(class EScriptObjectMessage,CValueVersionId<uint,uint,ushort,16u,16u>,CStateManager &); virtual void AcceptScriptMsg(EScriptObjectMessage,CValueVersionId<uint,uint,ushort,16u,16u>,CStateManager &);
virtual void SetActive(bool); virtual void SetActive(bool);
virtual void SetOwnerGOC(IMP1EntityBaseGOC &); virtual void SetOwnerGOC(IMP1EntityBaseGOC &);
virtual void OnAreaIdChanged(CStateManager &,CValueVersionId<uint,ushort,ushort,16u,16u>); virtual void OnAreaIdChanged(CStateManager &,CValueVersionId<uint,ushort,ushort,16u,16u>);
void SendScriptMsgs(class EScriptObjectState,CStateManager &,EScriptObjectMessage); void SendScriptMsgs(EScriptObjectState,CStateManager &,EScriptObjectMessage);
void SendActive(CStateManager &,bool); void SendActive(CStateManager &,bool);
void GetAreaIdForPersistence(void); void GetAreaIdForPersistence(void);
void CheckConnectedObject_if(CStateManager const&,EScriptObjectState,EScriptObjectMessage,class CValidEntityPredicate const&); void CheckConnectedObject_if(CStateManager const&,EScriptObjectState,EScriptObjectMessage,class CValidEntityPredicate const&);
@@ -37,6 +37,10 @@ public:
void IsMP1State(SConnection const&,EScriptObjectState,bool); void IsMP1State(SConnection const&,EScriptObjectState,bool);
void Area(void); void Area(void);
void GetArea(void); void GetArea(void);
inline IMP1EntityBaseGOC* GetEntityBaseGOC() {return mEntityBase; }
inline const IMP1EntityBaseGOC* GetEntityBaseGOC() const {return mEntityBase; }
inline int GetUniqueId() const {return mUniqueId; }
}; };
class CEntityGOC : public CGameObjectComponent { class CEntityGOC : public CGameObjectComponent {
+1 -1
View File
@@ -46,7 +46,7 @@ public:
void OnActivationStateChange(CStateManager &,CScriptMsg const&); void OnActivationStateChange(CStateManager &,CScriptMsg const&);
void TranslateAndAcceptScriptMessage(CScriptMsg const&,CStateManager &); void TranslateAndAcceptScriptMessage(CScriptMsg const&,CStateManager &);
void TranslateAndSendScriptMessages(class EScriptObjectState,CStateManager &, class EScriptObjectMessage); void TranslateAndSendScriptMessages(EScriptObjectState,CStateManager &, EScriptObjectMessage);
void TranslateAndSendScriptMessagesForConnection(class SConnection const&,CStateManager &,EScriptObjectMessage); void TranslateAndSendScriptMessagesForConnection(class SConnection const&,CStateManager &,EScriptObjectMessage);
virtual void TranslateScriptMessageToAction(EScriptObjectMessage,bool); virtual void TranslateScriptMessageToAction(EScriptObjectMessage,bool);
+16 -1
View File
@@ -9,7 +9,22 @@
class SScriptStringPoolCache; class SScriptStringPoolCache;
class SScriptLink; class SScriptLink;
class SConnection;
struct SConnectionTarget
{
CGuid mTargetGuid;
TUniqueId mTargetId;
ushort unkShort;
};
struct SConnection {
NScriptMsg::EScriptEvent mEvent;
NScriptMsg::EScriptAction mAction;
SConnectionTarget mConnectionTarget;
rstl::rc_ptr<void*> mEventCriteria;
rstl::rc_ptr<void*> mActionPayload;
char mBitfield;
};
class SGOComponentInstanceData; class SGOComponentInstanceData;
#pragma pack(push, 1) #pragma pack(push, 1)
+10
View File
@@ -188,6 +188,16 @@ private:
CVector2i max; CVector2i max;
}; };
struct CColor4f {
float r;
float g;
float b;
float a;
inline CColor4f() : r(0), g(0), b(0), a(0) {};
inline CColor4f(float r, float g, float b, float a) : r(r), g(g), b(b), a(a) {};
};
class CMath { class CMath {
public: public:
static float CeilingF(float); static float CeilingF(float);
File diff suppressed because it is too large Load Diff
+20 -2
View File
@@ -4,8 +4,26 @@
struct CEntityInfoMP1; struct CEntityInfoMP1;
struct CActorParametersMP1; struct CActorParametersMP1;
struct CAnimResMPT; struct CAnimResMPT {
struct CStaticResMPT; CObjectId mResourceId;
CScale3f mScale;
char gap1C[4];
void* qword20;
const void *pvoid28;
void* qword30;
int stringHash1;
char gap3C[4];
void* qword40;
const void *pvoid48;
void* qword50;
int mStringHash2;
char gap5C[4];
char byte60;
};
struct CStaticResMPT {
CObjectId mResourceId;
CScale3f mScale;
};
struct CAnimatedUvDataMP1; struct CAnimatedUvDataMP1;
enum EMaterialTypesMP1 {}; enum EMaterialTypesMP1 {};
+11
View File
@@ -13,6 +13,17 @@ namespace rstl {
template <typename T> template <typename T>
class less; class less;
template <typename L, typename R>
class pair {
public:
pair() = default;
pair(const L& first, const R& second) : mFirst(first), mSecond(second) {}
bool operator==(const pair& other) const { return mFirst == other.mFirst && mSecond == other.mSecond; }
L mFirst;
R mSecond;
};
// if i had to guess, these allocators probably all use compile time virtualization // if i had to guess, these allocators probably all use compile time virtualization
// to be able to customize how something allocates without needing a reference to an actual allocator class // to be able to customize how something allocates without needing a reference to an actual allocator class
class rmemory_allocator; class rmemory_allocator;
+3 -2
View File
@@ -177,8 +177,9 @@
{ {
"type": "debug_flags", "type": "debug_flags",
"value": { "value": {
"allow_debug": false, "allow_debug": true,
"force_debug": true "force_debug": false,
"force_debug_prod": false
} }
} }
] ]
+1 -1
View File
@@ -75,7 +75,7 @@ namespace RandoConfig {
FsHelper::freeLoadDataBuffer(loadData); FsHelper::freeLoadDataBuffer(loadData);
updateTankCapacity(cJSON_GetNumberValue(cJSON_GetObjectItem(configJson, "EnergyTankCapacity"))); updateTankCapacity(cJSON_GetNumberValue(cJSON_GetObjectItem(configJson, "EnergyTankCapacity")));
// updateStartingRoom(cJSON_GetStringValue(cJSON_GetObjectItem(configJson, "StartingArea"))); updateStartingRoom(cJSON_GetStringValue(cJSON_GetObjectItem(configJson, "StartingArea")));
updateResultsString(cJSON_GetStringValue(cJSON_GetObjectItem(configJson, "ResultsString"))); updateResultsString(cJSON_GetStringValue(cJSON_GetObjectItem(configJson, "ResultsString")));
cJSON_Delete(configJson); cJSON_Delete(configJson);
+20 -2
View File
@@ -3,6 +3,17 @@
#include <logger/Logger.hpp> #include <logger/Logger.hpp>
#include <program/RoomWarper.h> #include <program/RoomWarper.h>
class CWorldTransitionIOWin {
public:
enum class EElevatorDirection {
Up,
Down
};
static void EnableTransition(EElevatorDirection dir);
static void EnableTextTeleport(const rstl::string& txtLbl, const CObjectId& id);
};
namespace { namespace {
struct RegionEntry { struct RegionEntry {
const char* mEnglishName = nullptr; const char* mEnglishName = nullptr;
@@ -28,13 +39,20 @@ namespace {
#include "RegionEntries.h" #include "RegionEntries.h"
CStateManager* RoomWarper::sStateManager = nullptr; CStateManager* RoomWarper::sStateManager = nullptr;
const char* RoomWarper::sTransitionTextLabel = "[42C9296F]_000"; // Tallon Overworld
void RoomWarper::WarpToRoom(const CObjectId& worldId, const CObjectId& areaId) { void RoomWarper::WarpToRoom(const CObjectId& worldId, const CObjectId& areaId, TransitionType transitionType) {
if(sStateManager == nullptr) { if(sStateManager == nullptr) {
Logger::log("State Manager is not Set! Cannot Warp.\n"); Logger::log("State Manager is not Set! Cannot Warp.\n");
return; return;
} }
if(transitionType == TransitionType::Text) {
CWorldTransitionIOWin::EnableTextTeleport(rstl::string_l(sTransitionTextLabel), *CObjectId::Invalid());
} else if(transitionType == TransitionType::Elevator) {
CWorldTransitionIOWin::EnableTransition(CWorldTransitionIOWin::EElevatorDirection::Up);
}
gpGameState->SetCurrentWorldId(worldId); gpGameState->SetCurrentWorldId(worldId);
gpGameState->CurrentWorldState()->SetDesiredAreaAssetId(areaId); gpGameState->CurrentWorldState()->SetDesiredAreaAssetId(areaId);
@@ -44,7 +62,7 @@ void RoomWarper::WarpToRoom(const CObjectId& worldId, const CObjectId& areaId) {
} }
void RoomWarper::WarpToStart() { void RoomWarper::WarpToStart() {
WarpToRoom(RandoConfig::startingWorldId, RandoConfig::startingAreaId); WarpToRoom(RandoConfig::startingWorldId, RandoConfig::startingAreaId, TransitionType::Text);
} }
void RoomWarper::DrawWarpMenu() { void RoomWarper::DrawWarpMenu() {
+11 -1
View File
@@ -6,10 +6,20 @@
class RoomWarper { class RoomWarper {
private: private:
static CStateManager* sStateManager; static CStateManager* sStateManager;
static const char* sTransitionTextLabel;
public: public:
enum class TransitionType {
None,
Text,
Elevator
};
static void SetManager(CStateManager* manager) { sStateManager = manager; } static void SetManager(CStateManager* manager) { sStateManager = manager; }
static void WarpToRoom(const CObjectId& worldId, const CObjectId& areaId); static void SetTransitionLabel(const char* lbl) { sTransitionTextLabel = lbl; }
static void WarpToRoom(const CObjectId& worldId, const CObjectId& areaId, TransitionType transitionType = TransitionType::None);
static void WarpToStart(); static void WarpToStart();
+180
View File
@@ -667,6 +667,171 @@ HOOK_DEFINE_TRAMPOLINE(GameMainLoopHook) {
// CScriptTriggerMP1::CScriptTriggerMP1(CEntityInfoMP1 const&,CVector3f const&,CAABox const&,CDamageInfoMP1 const&,CVector3f const&,uint,bool,bool,bool,bool) .text // CScriptTriggerMP1::CScriptTriggerMP1(CEntityInfoMP1 const&,CVector3f const&,CAABox const&,CDamageInfoMP1 const&,CVector3f const&,uint,bool,bool,bool,bool) .text
struct CScriptSpecialFunctionMP1 : public CActorMP1 {
enum ESpinnerControllerMode {};
enum class ESpecialFunction {
What = 0x0,
PlayerFollowLocator = 0x1,
SpinnerController = 0x2,
ObjectFollowLocator = 0x3,
ChaffTarget = 0x4,
InventoryActivator = 0x5,
MapStation = 0x6,
SaveStation = 0x7,
IntroBossRingController = 0x8,
ViewFrustumTester = 0x9,
ShotSpinnerController = 0xA,
EscapeSequence = 0xB,
BossEnergyBar = 0xC,
EndGame = 0xD,
HUDFadeIn = 0xE,
CinematicSkip = 0xF,
ScriptLayerController = 0x10,
RainSimulator = 0x11,
AreaDamage = 0x12,
ObjectFollowObject = 0x13,
RedundantHintSystem = 0x14,
DropBomb = 0x15,
ScaleActor = 0x16,
MissileStation = 0x17,
Billboard = 0x18,
PlayerInAreaRelay = 0x19,
HUDTarget = 0x1A,
FogFader = 0x1B,
EnterLogbook = 0x1C,
PowerBombStation = 0x1D,
Ending = 0x1E,
FusionRelay = 0x1F,
WeaponSwitch = 0x20,
FogVolume = 0x2F,
RadialDamage = 0x30,
EnvFxDensityController = 0x31,
RumbleEffect = 0x32,
};
void Think(float,CStateManager &);
void ThinkPlayerFollowLocator(float,CStateManager &);
void ThinkSpinnerController(float,CStateManager &,CScriptSpecialFunctionMP1::ESpinnerControllerMode);
void ThinkObjectFollowLocator(float,CStateManager &);
void ThinkObjectFollowObject(float,CStateManager &);
void ThinkChaffTarget(float,CStateManager &);
void ThinkSaveStation(CStateManager &);
void ThinkIntroBossRingController(float,CStateManager &);
void ThinkRainSimulator(CStateManager &);
void ThinkAreaDamagePlayer(float,CStateManager &);
void ThinkScaleObject(float,CStateManager &);
void ThinkPlayerInAreaRelay(float,CStateManager &);
void* qword1E8;
ESpecialFunction mSpecialFunc;
rstl::string mLocatorString;
float mEndingClassification;
float float214;
float float218;
float float21C;
CVector3f mVec;
CColor4f mColor;
};
HOOK_DEFINE_TRAMPOLINE(CheckChoiceMadeHook) {
static bool Callback(void* thiz, int choice) {
Logger::log("Save Game Interface Choice: %d\n", choice);
if(choice == 2) {
RoomWarper::SetTransitionLabel("WarpToStartMsg");
RoomWarper::WarpToStart();
return false;
}
return Orig(thiz, choice);
}
};
// CAnimBitStream::CAnimBitStream(uchar const*,CAnimBitStream::EMode,uint) .text
HOOK_DEFINE_TRAMPOLINE(LogHashValueAndResultHook) {
static int Callback(const char* str, size_t len, uint key) {
int result = Orig(str, len, key);
Logger::log("Generated Hash for string: %s (Value: %02X)\n", str, result);
return result;
}
};
struct CScriptActorRotateMP1 : CEntityMP1
{
CVector3f mRotation;
float mMaxTime;
float mCurrentTime;
rstl::vector<rstl::pair<TUniqueId,CTransform4f>> mActorTransforms;
char mUpdateBitfield;
};
HOOK_DEFINE_TRAMPOLINE(CheckHook) {
static void Callback(CScriptActorRotateMP1* thiz, bool next, CStateManager* stateManager) {
Logger::log("Starting Rotation. Is Next: %s Update Bitfield Values: ", BTOC(next));
MemoryHelper::logBytes(&thiz->mUpdateBitfield, sizeof(char));
Orig(thiz, next, stateManager);
Logger::log("Got %d actor(s) transform.\n", thiz->mActorTransforms.size());
}
};
HOOK_DEFINE_TRAMPOLINE(Check2Hook) {
static bool Callback(CEntityMP1* thiz, const CStateManager& mgr, const SConnection& connection, EScriptObjectState state, EScriptObjectMessage message, bool unkBool) {
bool result = Orig(thiz, mgr, connection, state, message, unkBool);
if(state == EScriptObjectState::Play && message == EScriptObjectMessage::Play) {
Logger::log("Checked Connection: %s for Play State and Message. Result: %s\n", connection.mConnectionTarget.mTargetGuid.AsString().data(), BTOC(result));
Logger::log("Connection Action: %02X Event: %02X\n", connection.mAction, connection.mEvent);
}
return result;
}
};
HOOK_DEFINE_TRAMPOLINE(CustomPickupMP1TranslationToMsgHook) {
static EScriptObjectMessage Callback(CPickupMP1GOC* thiz, NScriptMsg::EScriptAction action, bool unkBool) {
if(action == NScriptMsg::EScriptAction::ActorMP1_Play) {
Logger::log("Translating Action [%02X] to Play.\n", action);
return EScriptObjectMessage::Play;
}
return Orig(thiz, action, unkBool);
}
};
HOOK_DEFINE_TRAMPOLINE(CustomPickupMP1TranslationToActionHook) {
static NScriptMsg::EScriptAction Callback(CPickupMP1GOC* thiz, EScriptObjectMessage msg, bool unkBool) {
if(msg == EScriptObjectMessage::Play) {
Logger::log("Translating Message [%02X] to Play.\n", msg);
return NScriptMsg::EScriptAction::ActorMP1_Play;
}
return Orig(thiz, msg, unkBool);
}
};
HOOK_DEFINE_TRAMPOLINE(LogSendMessageHook) {
static void Callback(CEntityMP1 *thiz, EScriptObjectState state, CStateManager *mgr, EScriptObjectMessage msg) {
auto entityGOC = thiz->GetEntityBaseGOC();
if (entityGOC) {
auto compType = entityGOC->GetComponentType();
if (compType == HUDMemoMP1 || compType == SpawnPointMP1 || compType == TimerMP1)
Logger::log("[%s_%02X] Sending Message with State %s, ignoring %s.\n", getComponentName(compType), thiz->GetUniqueId(), getObjectStateName(state), getObjectMessageName(msg));
}
Orig(thiz, state, mgr, msg);
}
};
HOOK_DEFINE_TRAMPOLINE(LogAcceptMessageHook) {
static void Callback(CEntityMP1 *thiz, EScriptObjectMessage msg, TUniqueId senderId, CStateManager *mgr) {
auto entityGOC = thiz->GetEntityBaseGOC();
if (entityGOC) {
auto compType = entityGOC->GetComponentType();
if (compType == HUDMemoMP1 || compType == SpawnPointMP1 || compType == TimerMP1)
Logger::log("[%s_%02X] Received Message %s from sender %02X.\n", getComponentName(compType), thiz->GetUniqueId(), getObjectMessageName(msg), senderId.value);
}
Orig(thiz, msg, senderId, mgr);
}
};
extern "C" void exl_main(void *x0, void *x1) { extern "C" void exl_main(void *x0, void *x1) {
/* Setup hooking enviroment. */ /* Setup hooking enviroment. */
exl::hook::Initialize(); exl::hook::Initialize();
@@ -689,6 +854,10 @@ extern "C" void exl_main(void *x0, void *x1) {
// rando patches // rando patches
CheckForVariaHook::InstallAtOffset(0xD95F54); CheckForVariaHook::InstallAtOffset(0xD95F54);
// pickup changes
CustomPickupMP1TranslationToMsgHook::InstallAtSymbol("_ZNK13CPickupMP1GOC30TranslateScriptActionToMessageEN10NScriptMsg13EScriptActionEb");
CustomPickupMP1TranslationToActionHook::InstallAtSymbol("_ZNK13CPickupMP1GOC30TranslateScriptMessageToActionE20EScriptObjectMessageb");
// patches for item hint locations on map // patches for item hint locations on map
SwapMaterial1Hook::InstallAtOffset(0xB55D30); SwapMaterial1Hook::InstallAtOffset(0xB55D30);
SwapMaterial2Hook::InstallAtOffset(0xB55D5C); SwapMaterial2Hook::InstallAtOffset(0xB55D5C);
@@ -723,8 +892,19 @@ extern "C" void exl_main(void *x0, void *x1) {
ChangeBaseHealthHook4::InstallAtOffset(0xC8909C); ChangeBaseHealthHook4::InstallAtOffset(0xC8909C);
LowHealthCheckHook::InstallAtOffset(0xC69FFC); LowHealthCheckHook::InstallAtOffset(0xC69FFC);
// Warp to Start
CheckChoiceMadeHook::InstallAtSymbol("_ZN21CSaveGameInterfaceMP118ChoiceMadeInternalEi");
CGameState::mCinematicForceSkippableOverride = true; CGameState::mCinematicForceSkippableOverride = true;
// Misc
LogSendMessageHook::InstallAtSymbol("_ZN10CEntityMP114SendScriptMsgsE18EScriptObjectStateR13CStateManager20EScriptObjectMessage");
LogAcceptMessageHook::InstallAtSymbol("_ZN17CScriptHUDMemoMP115AcceptScriptMsgE20EScriptObjectMessage15CValueVersionIdIjjtLj16ELj16EER13CStateManager");
// LogHashValueAndResultHook::InstallAtSymbol("_ZN8CFnvHash15GetStringHash32EPKcij");
// CheckHook::InstallAtSymbol("_ZN21CScriptActorRotateMP113StartRotationEbR13CStateManager");
// Check2Hook::InstallAtSymbol("_ZNK10CEntityMP115IsMP1ConnectionERK13CStateManagerRK11SConnection18EScriptObjectState20EScriptObjectMessageb");
// VerifyRenderDataUpdateHook::InstallAtOffset(0xB50434); // VerifyRenderDataUpdateHook::InstallAtOffset(0xB50434);
// CheckWillUpdateHook::InstallAtOffset(0xB50420); // CheckWillUpdateHook::InstallAtOffset(0xB50420);
+6
View File
@@ -61,6 +61,12 @@ void runCodePatches() {
// removes call to CMaterialExec::DrawMesh (we call it ourselves in an inline hook) // removes call to CMaterialExec::DrawMesh (we call it ourselves in an inline hook)
p.Seek(0xB55DA4); p.WriteInst(inst::Nop()); p.Seek(0xB55DA4); p.WriteInst(inst::Nop());
p.Seek(0xE64C5C);
p.WriteInst(inst::MovRegister(reg::X20, reg::X13));
// p.Seek(0x4726C4);
// p.BranchLinkInst((void*)CreateGuid);
// changes an unused material index located in a static array used when initializing an SIconInstance for CMappableObjectData // changes an unused material index located in a static array used when initializing an SIconInstance for CMappableObjectData
patch::RandomAccessPatcher rop; patch::RandomAccessPatcher rop;
u64 startOffset = 0x1D27454; u64 startOffset = 0x1D27454;
+1 -1
View File
@@ -5,7 +5,7 @@
#define EXL_MODULE_NAME "mp1r-exlaunch" #define EXL_MODULE_NAME "mp1r-exlaunch"
#define EXL_DEBUG #define EXL_DEBUG
#define EXL_USE_FAKEHEAP //#define EXL_USE_FAKEHEAP
/* /*
#define EXL_SUPPORTS_REBOOTPAYLOAD #define EXL_SUPPORTS_REBOOTPAYLOAD