diff --git a/Spore ModAPI/SourceCode/DLL/AddressesSimulator.cpp b/Spore ModAPI/SourceCode/DLL/AddressesSimulator.cpp index 15e53674..b080126d 100644 --- a/Spore ModAPI/SourceCode/DLL/AddressesSimulator.cpp +++ b/Spore ModAPI/SourceCode/DLL/AddressesSimulator.cpp @@ -103,6 +103,7 @@ #include #include #include +#include #include namespace Addresses(Simulator) @@ -1105,6 +1106,15 @@ namespace Simulator namespace Addresses(cSpatialObject) { DefineAddress(SetModelKey, SelectAddress(0xC87B30, 0xC889A0)); } + + namespace Addresses(CinematicAction) { + DefineAddress(StartVignetteFunction_ptr, SelectAddress(0xAD3D50, 0xAD3EF0)); + } + + namespace Addresses(cCinematicManager) { + DefineAddress(Get, SelectAddress(0xB3D430, 0xB3D5D0)); + DefineAddress(PlayCinematic, SelectAddress(0xAE0480, 0xAE08B0)); + } } #ifdef SDK_TO_GHIDRA diff --git a/Spore ModAPI/SourceCode/Simulator/SimulatorMisc.cpp b/Spore ModAPI/SourceCode/Simulator/SimulatorMisc.cpp index 259f05c1..a2091435 100644 --- a/Spore ModAPI/SourceCode/Simulator/SimulatorMisc.cpp +++ b/Spore ModAPI/SourceCode/Simulator/SimulatorMisc.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -156,5 +157,17 @@ namespace Simulator auto_METHOD_VOID(cPlanetaryArtifact, LoadFromItem, Args(SpaceInventoryItemType itemType, const ResourceKey& itemKey, int count, bool arg), Args(itemType, itemKey, count, arg)); + + //// CinematicManager //// + + auto_STATIC_METHOD_(cCinematicManager, cCinematicManager*, Get); + + auto_METHOD_VOID(cCinematicManager, PlayCinematic, + Args(const char* cinematicName, int arg0, int arg1, int arg2, int arg3, int arg4), + Args(cinematicName, arg0, arg1, arg2, arg3, arg4)); + + CinematicActionFunction_t CinematicAction::GetStartVignetteFunction() { + return (CinematicActionFunction_t)(GetAddress(CinematicAction, StartVignetteFunction_ptr)); + } } #endif \ No newline at end of file diff --git a/Spore ModAPI/Spore ModAPI.vcxproj b/Spore ModAPI/Spore ModAPI.vcxproj index b2beea33..a4ed439d 100644 --- a/Spore ModAPI/Spore ModAPI.vcxproj +++ b/Spore ModAPI/Spore ModAPI.vcxproj @@ -327,6 +327,7 @@ + diff --git a/Spore ModAPI/Spore ModAPI.vcxproj.filters b/Spore ModAPI/Spore ModAPI.vcxproj.filters index d43c4393..13b5f31e 100644 --- a/Spore ModAPI/Spore ModAPI.vcxproj.filters +++ b/Spore ModAPI/Spore ModAPI.vcxproj.filters @@ -2193,6 +2193,9 @@ Header Files + + Header Files + diff --git a/Spore ModAPI/Spore/ResourceKey.h b/Spore ModAPI/Spore/ResourceKey.h index 936033d5..59fbb3e5 100644 --- a/Spore ModAPI/Spore/ResourceKey.h +++ b/Spore ModAPI/Spore/ResourceKey.h @@ -81,6 +81,8 @@ ASSERT_SIZE(ResourceKey, 0xC); #define type_id(id) ResourceKey(0, id, 0) #define group_id(id) ResourceKey(0, 0, id) +#define WILDCARD_KEY ResourceKey(ResourceKey::kWildcardID, ResourceKey::kWildcardID, ResourceKey::kWildcardID) + inline ResourceKey::ResourceKey() #ifndef SDK_TO_GHIDRA : instanceID(0) @@ -125,7 +127,7 @@ inline bool ResourceKey::operator >(const ResourceKey &b) const inline bool ResourceKey::operator <(const ResourceKey &b) const { - return groupID > b.groupID; + return groupID < b.groupID; } namespace eastl diff --git a/Spore ModAPI/Spore/Simulator.h b/Spore ModAPI/Spore/Simulator.h index 2fb0fed6..e2516d4e 100644 --- a/Spore ModAPI/Spore/Simulator.h +++ b/Spore ModAPI/Spore/Simulator.h @@ -37,6 +37,7 @@ #include #include #include +#include #include #include diff --git a/Spore ModAPI/Spore/Simulator/SimulatorMessages.h b/Spore ModAPI/Spore/Simulator/SimulatorMessages.h index d3a09353..2a16f4b6 100644 --- a/Spore ModAPI/Spore/Simulator/SimulatorMessages.h +++ b/Spore ModAPI/Spore/Simulator/SimulatorMessages.h @@ -23,6 +23,7 @@ #include #include #include +#include namespace Simulator { @@ -100,6 +101,9 @@ namespace Simulator /// Sent when the ownership of some star changes. No parameters. kMsgStarOwnershipChanged = 0x55BD8F7, + + /// Simulator::DoCinematicActionMessage ; sent to execute a single action within a cinematic stage + kMsgDoCinematicAction = 0x4470A41, }; class IMessageParameters @@ -261,4 +265,17 @@ namespace Simulator return params[0].uint32; } }; + + /// Sent to execute a single action within a cinematic stage + class DoCinematicActionMessage : App::StandardMessage + { + public: + static const uint32_t ID = kMsgDoCinematicAction; + + DoCinematicActionMessage(CinematicAction* action); + + inline CinematicAction* GetActionData() { + return (CinematicAction*)params[0].object; + } + }; } \ No newline at end of file diff --git a/Spore ModAPI/Spore/Simulator/StarID.h b/Spore ModAPI/Spore/Simulator/StarID.h index f73b2802..e6f6731c 100644 --- a/Spore ModAPI/Spore/Simulator/StarID.h +++ b/Spore ModAPI/Spore/Simulator/StarID.h @@ -1,7 +1,9 @@ #pragma once #include +#include #include +#include namespace Simulator { @@ -43,6 +45,13 @@ namespace Simulator inline unsigned int GetStarIndex() const { return internalValue & 0x00000FFF; } + +#ifndef SDK_TO_GHIDRA + bool StarID::operator ==(const StarID& b) const; + bool StarID::operator !=(const StarID& b) const; + bool StarID::operator <(const StarID& b) const; + bool StarID::operator >(const StarID& b) const; +#endif }; ASSERT_SIZE(StarID, 4); @@ -85,6 +94,63 @@ namespace Simulator inline unsigned int GetPlanetIndex() const { return internalValue & 0xFF000000 >> 24; } + +#ifndef SDK_TO_GHIDRA + bool PlanetID::operator ==(const PlanetID& b) const; + bool PlanetID::operator !=(const PlanetID& b) const; + bool PlanetID::operator <(const PlanetID& b) const; + bool PlanetID::operator >(const PlanetID& b) const; +#endif }; ASSERT_SIZE(PlanetID, 4); -} \ No newline at end of file + +#ifndef SDK_TO_GHIDRA + inline bool StarID::operator ==(const StarID& b) const + { + return internalValue == b.internalValue; + } + inline bool StarID::operator !=(const StarID& b) const + { + return internalValue != b.internalValue; + } + inline bool StarID::operator >(const StarID& b) const + { + return internalValue > b.internalValue; + } + inline bool StarID::operator <(const StarID& b) const + { + return internalValue < b.internalValue; + } + + inline bool PlanetID::operator ==(const PlanetID& b) const + { + return internalValue == b.internalValue; + } + inline bool PlanetID::operator !=(const PlanetID& b) const + { + return internalValue != b.internalValue; + } + inline bool PlanetID::operator >(const PlanetID& b) const + { + return internalValue > b.internalValue; + } + inline bool PlanetID::operator <(const PlanetID& b) const + { + return internalValue < b.internalValue; + } +#endif +} + +#ifndef SDK_TO_GHIDRA +namespace eastl +{ + template <> struct hash + { + size_t operator()(const Simulator::StarID& val) const { return hash()(val.internalValue); } + }; + template <> struct hash + { + size_t operator()(const Simulator::PlanetID& val) const { return hash()(val.internalValue); } + }; +} +#endif \ No newline at end of file diff --git a/Spore ModAPI/Spore/Simulator/SubSystem/CinematicManager.h b/Spore ModAPI/Spore/Simulator/SubSystem/CinematicManager.h new file mode 100644 index 00000000..3bbb6696 --- /dev/null +++ b/Spore ModAPI/Spore/Simulator/SubSystem/CinematicManager.h @@ -0,0 +1,127 @@ +#pragma once + +#include +#include +#include +#include + +/// Accesses the current instance of Simulator::cCinematicManager +#define CinematicManager (*Simulator::cCinematicManager::Get()) + +namespace Simulator +{ + class CinematicActionUnkBase + { + public: + virtual ~CinematicActionUnkBase() = 0; + virtual int AddRef() = 0; + virtual int Release() = 0; + }; + + typedef bool(*CinematicActionFunction_t)(Object* actionData, bool); + + class CinematicAction + : public RefCountTemplate + , public CinematicActionUnkBase + { + public: + virtual ~CinematicAction(); + virtual int AddRef() override; + virtual int Release() override; + + static CinematicActionFunction_t GetStartVignetteFunction(); + + public: + /// For instance, CinematicVignetteAction + /* 0Ch */ ObjectPtr mActionData; + /* 10h */ CinematicActionFunction_t mFunction; + }; + ASSERT_SIZE(CinematicAction, 0x14); + + namespace Addresses(CinematicAction) { + DeclareAddress(StartVignetteFunction_ptr); // 0xAD3D50 0xAD3EF0 + } + + + class cCinematicManager + : public App::IMessageListener + , public cStrategy + { + public: + static cCinematicManager* Get(); + + /* 10h */ virtual void AddCommand(const char* commandName, ArgScript::ICommand* command); + + void PlayCinematic(const char* cinematicName, int arg0, int arg1, int arg2, int arg3, int arg4); + + public: + /* 20h */ char padding_20[0x3c8 - 0x20]; + }; + ASSERT_SIZE(cCinematicManager, 0x3C8); + + namespace Addresses(cCinematicManager) { + DeclareAddress(Get); // 0xB3D430 0xB3D5D0 + DeclareAddress(PlayCinematic); // 0xAE0480 0xAE08B0 + } + + + + class CinematicVignetteAction + : public Object + , public DefaultRefCounted + { + public: + enum class PositionType + { + None = 0, + Unk1 = 1, + Effect = 2, + ActorNest = 3, + ActorHut = 4, + ActorTribe = 5, + ActorCity = 6, + Object = 7, + Actor = 8, + NearestWater = 9, + NearestLand = 10 + }; + + enum class OffsetMultiplier { + /// Uses the foot radius of the actor as an offset multiplier + FootprintRadius = 0, + /// Uses the max width of the target object as an offset multiplier + TargetWidth = 1, + /// Uses the height of the target object as an offset multiplier + TargetHeight = 2, + None = 3, + }; + + static const uint32_t TYPE = 0x55113D6; + + virtual int AddRef() override; + virtual int Release() override; + virtual void* Cast(uint32_t type) const override; + + public: + /// Actor name + /* 0Ch */ uint32_t mActorId; + /// Vignette identifier + /* 10h */ uint32_t mVignetteId; + /// Vignette identifier + /* 14h */ ResourceKey mVignetteKey; + /// Relative position (if no options specified, then relative to the actor) + /* 20h */ Math::Vector3 mPosition; + /* 2Ch */ Math::Vector3 mFacingOffset; + /// If not None, relative to a position + /* 38h */ PositionType mRelativePosType; // Unk1 + /* 3Ch */ uint32_t mRelativePosId; + /// If not None, face a position with an optional offset mFacingOffset + /* 40h */ PositionType mFacingType; // None + /* 44h */ uint32_t mFacingId; + /// state does not wait for routing to finish + /* 48h */ bool mNoWait; + /* 4Ch */ OffsetMultiplier mOffsetMultiplier; // None + /* 50h */ uint32_t field_50; // -1 + }; + ASSERT_SIZE(CinematicVignetteAction, 0x54); +} \ No newline at end of file diff --git a/Spore ModAPI/Spore/Simulator/cScenarioData.h b/Spore ModAPI/Spore/Simulator/cScenarioData.h index db12692f..79fe9789 100644 --- a/Spore ModAPI/Spore/Simulator/cScenarioData.h +++ b/Spore ModAPI/Spore/Simulator/cScenarioData.h @@ -89,7 +89,7 @@ namespace Simulator /* 24h */ int field_24; /* 28h */ int field_28; /* 2Ch */ bool field_2C; - /* 30h */ int field_30; + /* 30h */ TexturePtr field_30; /* 34h */ int field_34; /* 38h */ TexturePtr mThumbnail; /* 3Ch */ TexturePtr mLargeThumbnail; diff --git a/Spore ModAPI/Spore/Terrain/ITerrainResourceManager.h b/Spore ModAPI/Spore/Terrain/ITerrainResourceManager.h index 4e0e15b5..e503ad80 100644 --- a/Spore ModAPI/Spore/Terrain/ITerrainResourceManager.h +++ b/Spore ModAPI/Spore/Terrain/ITerrainResourceManager.h @@ -14,9 +14,12 @@ namespace Terrain public: virtual ~ITerrainResourceManager(); + /// Returns the property list assigned to the given planet; if the planet still doesn't have + /// a property list, it will select one from the game available planets and copy it. + /// @param planetKey /* 04h */ virtual App::PropertyList* GetPropertyList(const ResourceKey& planetKey) = 0; /// returns wta and planetinfo? - /* 08h */ virtual void func08h(const ResourceKey& key, int* dst) = 0; + /* 08h */ virtual void LoadPlanetInfo(const ResourceKey& key, eastl::tuple& dst) = 0; /* 0Ch */ virtual void func0Ch(const ResourceKey& key) = 0; // removes player effects and models? /// Creates a property list and saves it to a file with key `outputKey`,