Skip to content

Commit

Permalink
Add CinematicManager, DoCinematicActionMessage, CinematicVignetteAction
Browse files Browse the repository at this point in the history
  • Loading branch information
emd4600 committed Sep 28, 2024
1 parent 002e314 commit 7ece943
Show file tree
Hide file tree
Showing 11 changed files with 247 additions and 4 deletions.
10 changes: 10 additions & 0 deletions Spore ModAPI/SourceCode/DLL/AddressesSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
#include <Spore\Simulator\SubSystem\AnimalSpeciesManager.h>
#include <Spore\Simulator\SubSystem\PlantSpeciesManager.h>
#include <Spore\Simulator\SubSystem\GamePersistenceManager.h>
#include <Spore\Simulator\SubSystem\CinematicManager.h>
#include <Spore\Simulator\NounClassFactories.h>

namespace Addresses(Simulator)
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions Spore ModAPI/SourceCode/Simulator/SimulatorMisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <Spore\Simulator\cSpeciesProfile.h>
#include <Spore\Simulator\cIdentityColorable.h>
#include <Spore\Simulator\SubSystem\GamePersistenceManager.h>
#include <Spore\Simulator\SubSystem\CinematicManager.h>
#include <Spore\Simulator\cDefaultToolProjectile.h>
#include <Spore\Simulator\cArtilleryProjectile.h>
#include <Spore\Simulator\cCulturalProjectile.h>
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions Spore ModAPI/Spore ModAPI.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@
<ClInclude Include="Spore\App\IDGenerator.h" />
<ClInclude Include="Spore\App\JobManager.h" />
<ClInclude Include="Spore\App\Thumbnail_cImportExport.h" />
<ClInclude Include="Spore\Simulator\SubSystem\CinematicManager.h" />
<ClInclude Include="Spore\Simulator\UIStateMachine.h" />
<ClInclude Include="Spore\BasicIncludes.h" />
<ClInclude Include="Spore\Cell.h" />
Expand Down
3 changes: 3 additions & 0 deletions Spore ModAPI/Spore ModAPI.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -2193,6 +2193,9 @@
<ClInclude Include="Spore\Simulator\UIStateMachine.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Spore\Simulator\SubSystem\CinematicManager.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="SourceCode\Allocator.cpp">
Expand Down
4 changes: 3 additions & 1 deletion Spore ModAPI/Spore/ResourceKey.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Spore ModAPI/Spore/Simulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <Spore\Simulator\SubSystem\SpaceGfx.h>
#include <Spore\Simulator\SubSystem\SpaceTrading.h>
#include <Spore\Simulator\SubSystem\TerraformingManager.h>
#include <Spore\Simulator\SubSystem\CinematicManager.h>

#include <Spore\Simulator\cGameData.h>
#include <Spore\Simulator\cGonzagoSimulator.h>
Expand Down
17 changes: 17 additions & 0 deletions Spore ModAPI/Spore/Simulator/SimulatorMessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <Spore\ResourceKey.h>
#include <Spore\App\StandardMessage.h>
#include <Spore\Simulator\cMission.h>
#include <Spore\Simulator\SubSystem\CinematicManager.h>

namespace Simulator
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
};
}
68 changes: 67 additions & 1 deletion Spore ModAPI/Spore/Simulator/StarID.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#pragma once

#include <cstdint>
#include <EASTL\functional.h>
#include <Spore\Internal.h>
#include <Spore\Hash.h>

namespace Simulator
{
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}

#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<Simulator::StarID>
{
size_t operator()(const Simulator::StarID& val) const { return hash<uint32_t>()(val.internalValue); }
};
template <> struct hash<Simulator::PlanetID>
{
size_t operator()(const Simulator::PlanetID& val) const { return hash<uint32_t>()(val.internalValue); }
};
}
#endif
127 changes: 127 additions & 0 deletions Spore ModAPI/Spore/Simulator/SubSystem/CinematicManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#pragma once

#include <Spore\App\IMessageListener.h>
#include <Spore\ArgScript\ICommand.h>
#include <Spore\Simulator\SubSystem\cStrategy.h>
#include <Spore\MathUtils.h>

/// 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);
}
2 changes: 1 addition & 1 deletion Spore ModAPI/Spore/Simulator/cScenarioData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion Spore ModAPI/Spore/Terrain/ITerrainResourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<float, float, float, float, float>& 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`,
Expand Down

0 comments on commit 7ece943

Please sign in to comment.