Skip to content

Commit 4a44ef5

Browse files
committed
- Improve flags in App::Property.
- Add basic support for ObstacleManager and cObstacle. - Fix cJob functions.
1 parent 8498464 commit 4a44ef5

15 files changed

Lines changed: 276 additions & 86 deletions

File tree

Spore ModAPI/SourceCode/App/App.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <Spore\App\ConfigManager.h>
1010
#include <Spore\App\IStateManager.h>
1111
#include <Spore\App\cAppSystem.h>
12+
#include <Spore\App\cJob.h>
13+
#include <Spore\App\JobManager.h>
1214
#endif
1315
#include <Spore\App\CommandLine.h>
1416

@@ -105,6 +107,33 @@ namespace App
105107

106108
auto_METHOD_VOID(cCreatureModeStrategy, ExecuteAction, Args(uint32_t actionID, void* actionData), Args(actionID, actionData));
107109

110+
/// cJob ///
111+
112+
auto_STATIC_METHOD_(IJobManager, IJobManager*, Get);
113+
114+
auto_METHOD_(cJob, int, AddRef);
115+
auto_METHOD_(cJob, int, Release);
116+
117+
void cJob::SetMethodCallback(cJobCallback callback, void* object) {
118+
this->mCallback = callback;
119+
this->mpCallbackObject = object;
120+
}
121+
122+
auto_METHOD_VOID(cJob, AddDependency, Args(cJob* other), Args(other));
123+
auto_METHOD_VOID(cJob, AddWeakDependency, Args(cJob* other), Args(other));
124+
125+
auto_METHOD_VOID_(cJob, Wait);
126+
auto_METHOD_VOID(cJob, Cancel, Args(bool wait), Args(wait));
127+
auto_METHOD_VOID_(cJob, Resume);
128+
129+
auto_METHOD_VOID(cJob, Continuation, Args(cJobVoidCallback callback, void* object), Args(callback, object));
130+
131+
auto_METHOD_(cJob, int, GetStatus);
132+
133+
void cJob::SetThreadAffinity(uint32_t affinity) {
134+
this->mThreadAffinity = affinity;
135+
}
136+
108137
#endif
109138

110139

Spore ModAPI/SourceCode/DLL/AddressesSimulator.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
#include <Spore\Simulator\SubSystem\BundleManager.h>
111111
#include <Spore\Simulator\SubSystem\GamePlantManager.h>
112112
#include <Spore\Simulator\SubSystem\UIAssetDiscoveryManager.h>
113+
#include <Spore\Simulator\SubSystem\ObstacleManager.h>
113114
#include <Spore\Simulator\NounClassFactories.h>
114115

115116
namespace Addresses(Simulator)
@@ -1176,6 +1177,10 @@ namespace Simulator
11761177
namespace Addresses(cUIAssetDiscoveryManager) {
11771178
DefineAddress(Get, SelectAddress(0xB3D450, 0xB3D5F0));
11781179
}
1180+
1181+
namespace Addresses(cObstacleManager) {
1182+
DefineAddress(Get, SelectAddress(0xB3D320, 0xB3D4C0));
1183+
}
11791184
}
11801185

11811186
#ifdef SDK_TO_GHIDRA

Spore ModAPI/SourceCode/Simulator/SimulatorMisc.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <Spore\Simulator\SubSystem\UIAssetDiscoveryManager.h>
1212
#include <Spore\Simulator\SubSystem\CinematicManager.h>
1313
#include <Spore\Simulator\SubSystem\GamePlantManager.h>
14+
#include <Spore\Simulator\SubSystem\ObstacleManager.h>
1415
#include <Spore\Simulator\cDefaultToolProjectile.h>
1516
#include <Spore\Simulator\cArtilleryProjectile.h>
1617
#include <Spore\Simulator\cCulturalProjectile.h>
@@ -229,6 +230,10 @@ namespace Simulator
229230
/// UIAssetDiscoveryManager ///
230231

231232
auto_STATIC_METHOD_(cUIAssetDiscoveryManager, cUIAssetDiscoveryManager*, Get);
233+
234+
/// ObstacleManager ///
235+
236+
auto_STATIC_METHOD_(cObstacleManager, cObstacleManager*, Get);
232237
}
233238

234239
#endif

Spore ModAPI/Spore ModAPI.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,13 @@
329329
<ClInclude Include="Spore\App\Thumbnail_cImportExport.h" />
330330
<ClInclude Include="Spore\Resource\FakeRecord.h" />
331331
<ClInclude Include="Spore\Simulator\cBaseSimulatorInputStrategy.h" />
332+
<ClInclude Include="Spore\Simulator\cObstacle.h" />
332333
<ClInclude Include="Spore\Simulator\cTribeInputStrategy.h" />
333334
<ClInclude Include="Spore\Simulator\cTribeToolData.h" />
334335
<ClInclude Include="Spore\Simulator\SubSystem\BundleManager.h" />
335336
<ClInclude Include="Spore\Simulator\SubSystem\CinematicManager.h" />
336337
<ClInclude Include="Spore\Simulator\SubSystem\GamePlantManager.h" />
338+
<ClInclude Include="Spore\Simulator\SubSystem\ObstacleManager.h" />
337339
<ClInclude Include="Spore\Simulator\SubSystem\UIAssetDiscoveryManager.h" />
338340
<ClInclude Include="Spore\Simulator\UIStateMachine.h" />
339341
<ClInclude Include="Spore\BasicIncludes.h" />

Spore ModAPI/Spore ModAPI.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,6 +2229,12 @@
22292229
<ClInclude Include="Spore\UI\AssetBrowserAssetGridUI.h">
22302230
<Filter>Header Files</Filter>
22312231
</ClInclude>
2232+
<ClInclude Include="Spore\Simulator\cObstacle.h">
2233+
<Filter>Header Files</Filter>
2234+
</ClInclude>
2235+
<ClInclude Include="Spore\Simulator\SubSystem\ObstacleManager.h">
2236+
<Filter>Header Files</Filter>
2237+
</ClInclude>
22322238
</ItemGroup>
22332239
<ItemGroup>
22342240
<ClCompile Include="SourceCode\Allocator.cpp">

Spore ModAPI/Spore/App/Property.h

Lines changed: 71 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,17 @@ namespace App
105105
public:
106106
enum PropertyFlags
107107
{
108-
kPropertyFlagNotDirect = 0x10,
109-
kPropertyFlagArray = 0x30
108+
/// If set, when the property object is destroyed, it will try to cleanup memory
109+
kPropertyFlagCleanup = 4,
110+
/// If set, the data is stored in a separate buffer, pointed at by the fields in PropertyArray
111+
kPropertyFlagPointer = 0x10,
112+
/// If set, the property will not deallocate memory pointed by it; if not set, the pointer memory will be deleted when the property is destroyed
113+
kPropertyFlagSkipDealloc = 0x20,
114+
115+
/// Combination of flags for array properties that must copy their origin data, and must clean it up on delete
116+
kPropertyFlagArrayByCopy = kPropertyFlagPointer | kPropertyFlagCleanup,
117+
/// Combination of flags for array properties whose data is a reference to memory managed by other code, and must not copy nor delete that memory
118+
kPropertyFlagArrayByReference = kPropertyFlagPointer | kPropertyFlagSkipDealloc,
110119
};
111120

112121
public:
@@ -392,120 +401,135 @@ namespace App
392401
/// This will be an array bool property of 'nValueCount' values.
393402
/// @param pValues The array with the values.
394403
/// @param nValueCount How many values the array has.
404+
/// @param flags Set of flags for the property; by default, it makes the array a reference to the given memory
395405
///
396-
Property& SetArrayBool(const bool* pValues, size_t nValueCount);
406+
Property& SetArrayBool(const bool* pValues, size_t nValueCount, int flags = kPropertyFlagArrayByReference);
397407

398408
///
399409
/// Sets the value of this Property to an array of int32_t values.
400410
/// This will be an array int32 property of 'nValueCount' values.
401411
/// @param pValues The array with the values.
402412
/// @param nValueCount How many values the array has.
413+
/// @param flags Set of flags for the property; by default, it makes the array a reference to the given memory
403414
///
404-
Property& SetArrayInt32(const int32_t* pValues, size_t nValueCount);
415+
Property& SetArrayInt32(const int32_t* pValues, size_t nValueCount, int flags = kPropertyFlagArrayByReference);
405416

406417
///
407418
/// Sets the value of this Property to an array of uint32_t values.
408419
/// This will be an array uint32 property of 'nValueCount' values.
409420
/// @param pValues The array with the values.
410421
/// @param nValueCount How many values the array has.
422+
/// @param flags Set of flags for the property; by default, it makes the array a reference to the given memory
411423
///
412-
Property& SetArrayUInt32(const uint32_t* pValues, size_t nValueCount);
424+
Property& SetArrayUInt32(const uint32_t* pValues, size_t nValueCount, int flags = kPropertyFlagArrayByReference);
413425

414426
///
415427
/// Sets the value of this Property to an array of float values.
416428
/// This will be an array float property of 'nValueCount' values.
417429
/// @param pValues The array with the values.
418430
/// @param nValueCount How many values the array has.
431+
/// @param flags Set of flags for the property; by default, it makes the array a reference to the given memory
419432
///
420-
Property& SetArrayFloat(const float* pValues, size_t nValueCount);
433+
Property& SetArrayFloat(const float* pValues, size_t nValueCount, int flags = kPropertyFlagArrayByReference);
421434

422435
///
423436
/// Sets the value of this Property to an array of ResourceKey values.
424437
/// This will be an array key property of 'nValueCount' values.
425438
/// @param pValues The array with the values.
426439
/// @param nValueCount How many values the array has.
440+
/// @param flags Set of flags for the property; by default, it makes the array a reference to the given memory
427441
///
428-
Property& SetArrayKey(const ResourceKey* pValues, size_t nValueCount);
442+
Property& SetArrayKey(const ResourceKey* pValues, size_t nValueCount, int flags = kPropertyFlagArrayByReference);
429443

430444
///
431445
/// Sets the value of this Property to the an array of eastl::string8 values.
432446
/// This will be an array eastl::string8 property of 'nValueCount' values.
433447
/// @param pValues The array with the values.
434448
/// @param nValueCount How many values the array has.
449+
/// @param flags Set of flags for the property; by default, it makes the array a reference to the given memory
435450
///
436-
Property& SetArrayString8(const eastl::string8* pValues, size_t nValueCount);
451+
Property& SetArrayString8(const eastl::string8* pValues, size_t nValueCount, int flags = kPropertyFlagArrayByReference);
437452

438453
///
439454
/// Sets the value of this Property to an array of eastl::string16 values.
440455
/// This will be an array eastl::string16 property of 'nValueCount' values.
441456
/// @param pValues The array with the values.
442457
/// @param nValueCount How many values the array has.
458+
/// @param flags Set of flags for the property; by default, it makes the array a reference to the given memory
443459
///
444-
Property& SetArrayString16(const eastl::string16* pValues, size_t nValueCount);
460+
Property& SetArrayString16(const eastl::string16* pValues, size_t nValueCount, int flags = kPropertyFlagArrayByReference);
445461

446462
///
447463
/// Sets the value of this Property to an array of BoundingBox values.
448464
/// This will be an array bbox property of 'nValueCount' values.
449465
/// @param pValues The array with the values.
450466
/// @param nValueCount How many values the array has.
467+
/// @param flags Set of flags for the property; by default, it makes the array a reference to the given memory
451468
///
452-
Property& SetArrayBBox(const BoundingBox* pValues, size_t nValueCount);
469+
Property& SetArrayBBox(const BoundingBox* pValues, size_t nValueCount, int flags = kPropertyFlagArrayByReference);
453470

454471
///
455472
/// Sets the value of this Property to an array of Transform values.
456473
/// This will be an array transform property of 'nValueCount' values.
457474
/// @param pValues The array with the values.
458475
/// @param nValueCount How many values the array has.
476+
/// @param flags Set of flags for the property; by default, it makes the array a reference to the given memory
459477
///
460-
Property& SetArrayTransform(const Transform* pValues, size_t nValueCount);
478+
Property& SetArrayTransform(const Transform* pValues, size_t nValueCount, int flags = kPropertyFlagArrayByReference);
461479

462480
///
463481
/// Sets the value of this Property to an array of LocalizedString values.
464482
/// This will be an array text property of 'nValueCount' values.
465483
/// @param pValues The array with the values.
466484
/// @param nValueCount How many values the array has.
485+
/// @param flags Set of flags for the property; by default, it makes the array a reference to the given memory
467486
///
468-
Property& SetArrayText(const LocalizedString* pValues, size_t nValueCount);
487+
Property& SetArrayText(const LocalizedString* pValues, size_t nValueCount, int flags = kPropertyFlagArrayByReference);
469488

470489
///
471490
/// Sets the value of this Property to an array of Math::Vector2 values.
472491
/// This will be an array vector2 property of 'nValueCount' values.
473492
/// @param pValues The array with the values.
474493
/// @param nValueCount How many values the array has.
494+
/// @param flags Set of flags for the property; by default, it makes the array a reference to the given memory
475495
///
476-
Property& SetArrayVector2(const Vector2* pValues, size_t nValueCount);
496+
Property& SetArrayVector2(const Vector2* pValues, size_t nValueCount, int flags = kPropertyFlagArrayByReference);
477497

478498
///
479499
/// Sets the value of this Property to an array of Math::Vector3 values.
480500
/// This will be an array vector3 property of 'nValueCount' values.
481501
/// @param pValues The array with the values.
482502
/// @param nValueCount How many values the array has.
503+
/// @param flags Set of flags for the property; by default, it makes the array a reference to the given memory
483504
///
484-
Property& SetArrayVector3(const Vector3* pValues, size_t nValueCount);
505+
Property& SetArrayVector3(const Vector3* pValues, size_t nValueCount, int flags = kPropertyFlagArrayByReference);
485506

486507
///
487508
/// Sets the value of this Property to an array of Math::Vector4 values.
488509
/// This will be an array vector4 property of 'nValueCount' values.
489510
/// @param pValues The array with the values.
490511
/// @param nValueCount How many values the array has.
512+
/// @param flags Set of flags for the property; by default, it makes the array a reference to the given memory
491513
///
492-
Property& SetArrayVector4(const Vector4* pValues, size_t nValueCount);
514+
Property& SetArrayVector4(const Vector4* pValues, size_t nValueCount, int flags = kPropertyFlagArrayByReference);
493515

494516
///
495517
/// Sets the value of this Property to an array of Math::ColorRGB values.
496518
/// This will be an array colorRGB property of 'nValueCount' values.
497519
/// @param pValues The array with the values.
498520
/// @param nValueCount How many values the array has.
521+
/// @param flags Set of flags for the property; by default, it makes the array a reference to the given memory
499522
///
500-
Property& SetArrayColorRGB(const ColorRGB* pValues, size_t nValueCount);
523+
Property& SetArrayColorRGB(const ColorRGB* pValues, size_t nValueCount, int flags = kPropertyFlagArrayByReference);
501524

502525
///
503526
/// Sets the value of this Property to an array of Math::ColorRGBA values.
504527
/// This will be an array colorRGBA property of 'nValueCount' values.
505528
/// @param pValues The array with the values.
506529
/// @param nValueCount How many values the array has.
530+
/// @param flags Set of flags for the property; by default, it makes the array a reference to the given memory
507531
///
508-
Property& SetArrayColorRGBA(const ColorRGBA* pValues, size_t nValueCount);
532+
Property& SetArrayColorRGBA(const ColorRGBA* pValues, size_t nValueCount, int flags = kPropertyFlagArrayByReference);
509533

510534
///@}
511535

@@ -1179,64 +1203,64 @@ namespace App
11791203
//TODO Bounding boxes?
11801204

11811205

1182-
inline Property& Property::SetArrayBool(const bool* pValues, size_t nValueCount) {
1183-
Set(PropertyType::Bool, kPropertyFlagArray, (void*) pValues, sizeof(bool), nValueCount);
1206+
inline Property& Property::SetArrayBool(const bool* pValues, size_t nValueCount, int flags) {
1207+
Set(PropertyType::Bool, flags, (void*) pValues, sizeof(bool), nValueCount);
11841208
return *this;
11851209
}
1186-
inline Property& Property::SetArrayInt32(const int32_t* pValues, size_t nValueCount) {
1187-
Set(PropertyType::Int32, kPropertyFlagArray, (void*)pValues, sizeof(int32_t), nValueCount);
1210+
inline Property& Property::SetArrayInt32(const int32_t* pValues, size_t nValueCount, int flags) {
1211+
Set(PropertyType::Int32, flags, (void*)pValues, sizeof(int32_t), nValueCount);
11881212
return *this;
11891213
}
1190-
inline Property& Property::SetArrayUInt32(const uint32_t* pValues, size_t nValueCount) {
1191-
Set(PropertyType::UInt32, kPropertyFlagArray, (void*)pValues, sizeof(uint32_t), nValueCount);
1214+
inline Property& Property::SetArrayUInt32(const uint32_t* pValues, size_t nValueCount, int flags) {
1215+
Set(PropertyType::UInt32, flags, (void*)pValues, sizeof(uint32_t), nValueCount);
11921216
return *this;
11931217
}
1194-
inline Property& Property::SetArrayFloat(const float* pValues, size_t nValueCount) {
1195-
Set(PropertyType::Float, kPropertyFlagArray, (void*)pValues, sizeof(float), nValueCount);
1218+
inline Property& Property::SetArrayFloat(const float* pValues, size_t nValueCount, int flags) {
1219+
Set(PropertyType::Float, flags, (void*)pValues, sizeof(float), nValueCount);
11961220
return *this;
11971221
}
1198-
inline Property& Property::SetArrayKey(const ResourceKey* pValues, size_t nValueCount) {
1199-
Set(PropertyType::Key, kPropertyFlagArray, (void*)pValues, sizeof(ResourceKey), nValueCount);
1222+
inline Property& Property::SetArrayKey(const ResourceKey* pValues, size_t nValueCount, int flags) {
1223+
Set(PropertyType::Key, flags, (void*)pValues, sizeof(ResourceKey), nValueCount);
12001224
return *this;
12011225
}
1202-
inline Property& Property::SetArrayString8(const eastl::string8* pValues, size_t nValueCount) {
1203-
Set(PropertyType::String8, kPropertyFlagArray, (void*)pValues, sizeof(eastl::string8), nValueCount);
1226+
inline Property& Property::SetArrayString8(const eastl::string8* pValues, size_t nValueCount, int flags) {
1227+
Set(PropertyType::String8, flags, (void*)pValues, sizeof(eastl::string8), nValueCount);
12041228
return *this;
12051229
}
1206-
inline Property& Property::SetArrayString16(const eastl::string16* pValues, size_t nValueCount) {
1207-
Set(PropertyType::String16, kPropertyFlagArray, (void*)pValues, sizeof(eastl::string16), nValueCount);
1230+
inline Property& Property::SetArrayString16(const eastl::string16* pValues, size_t nValueCount, int flags) {
1231+
Set(PropertyType::String16, flags, (void*)pValues, sizeof(eastl::string16), nValueCount);
12081232
return *this;
12091233
}
1210-
inline Property& Property::SetArrayBBox(const BoundingBox* pValues, size_t nValueCount) {
1211-
Set(PropertyType::BBox, kPropertyFlagArray, (void*)pValues, sizeof(BoundingBox), nValueCount);
1234+
inline Property& Property::SetArrayBBox(const BoundingBox* pValues, size_t nValueCount, int flags) {
1235+
Set(PropertyType::BBox, flags, (void*)pValues, sizeof(BoundingBox), nValueCount);
12121236
return *this;
12131237
}
1214-
inline Property& Property::SetArrayTransform(const Transform* pValues, size_t nValueCount) {
1215-
Set(PropertyType::Transform, kPropertyFlagArray, (void*)pValues, sizeof(Transform), nValueCount);
1238+
inline Property& Property::SetArrayTransform(const Transform* pValues, size_t nValueCount, int flags) {
1239+
Set(PropertyType::Transform, flags, (void*)pValues, sizeof(Transform), nValueCount);
12161240
return *this;
12171241
}
1218-
inline Property& Property::SetArrayText(const LocalizedString* pValues, size_t nValueCount) {
1219-
Set(PropertyType::Text, kPropertyFlagArray, (void*)pValues, sizeof(LocalizedString), nValueCount);
1242+
inline Property& Property::SetArrayText(const LocalizedString* pValues, size_t nValueCount, int flags) {
1243+
Set(PropertyType::Text, flags, (void*)pValues, sizeof(LocalizedString), nValueCount);
12201244
return *this;
12211245
}
1222-
inline Property& Property::SetArrayVector2(const Vector2* pValues, size_t nValueCount) {
1223-
Set(PropertyType::Vector2, kPropertyFlagArray, (void*)pValues, sizeof(Vector2), nValueCount);
1246+
inline Property& Property::SetArrayVector2(const Vector2* pValues, size_t nValueCount, int flags) {
1247+
Set(PropertyType::Vector2, flags, (void*)pValues, sizeof(Vector2), nValueCount);
12241248
return *this;
12251249
}
1226-
inline Property& Property::SetArrayVector3(const Vector3* pValues, size_t nValueCount) {
1227-
Set(PropertyType::Vector3, kPropertyFlagArray, (void*)pValues, sizeof(Vector3), nValueCount);
1250+
inline Property& Property::SetArrayVector3(const Vector3* pValues, size_t nValueCount, int flags) {
1251+
Set(PropertyType::Vector3, flags, (void*)pValues, sizeof(Vector3), nValueCount);
12281252
return *this;
12291253
}
1230-
inline Property& Property::SetArrayVector4(const Vector4* pValues, size_t nValueCount) {
1231-
Set(PropertyType::Vector4, kPropertyFlagArray, (void*)pValues, sizeof(Vector4), nValueCount);
1254+
inline Property& Property::SetArrayVector4(const Vector4* pValues, size_t nValueCount, int flags) {
1255+
Set(PropertyType::Vector4, flags, (void*)pValues, sizeof(Vector4), nValueCount);
12321256
return *this;
12331257
}
1234-
inline Property& Property::SetArrayColorRGB(const ColorRGB* pValues, size_t nValueCount) {
1235-
Set(PropertyType::ColorRGB, kPropertyFlagArray, (void*)pValues, sizeof(ColorRGB), nValueCount);
1258+
inline Property& Property::SetArrayColorRGB(const ColorRGB* pValues, size_t nValueCount, int flags) {
1259+
Set(PropertyType::ColorRGB, flags, (void*)pValues, sizeof(ColorRGB), nValueCount);
12361260
return *this;
12371261
}
1238-
inline Property& Property::SetArrayColorRGBA(const ColorRGBA* pValues, size_t nValueCount) {
1239-
Set(PropertyType::ColorRGBA, kPropertyFlagArray, (void*)pValues, sizeof(ColorRGBA), nValueCount);
1262+
inline Property& Property::SetArrayColorRGBA(const ColorRGBA* pValues, size_t nValueCount, int flags) {
1263+
Set(PropertyType::ColorRGBA, flags, (void*)pValues, sizeof(ColorRGBA), nValueCount);
12401264
return *this;
12411265
}
12421266

Spore ModAPI/Spore/App/ScenarioMode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ namespace App
7070
/* 1Ch */ int mpScenarioUI; // Simulator::ScenarioModeUI ?
7171
/* 20h */ GameInput mInput;
7272
/* 68h */ int field_68;
73-
/* 6Ch */ int field_6C; // another UI?
73+
/* 6Ch */ int mpScenarioDisplayStrategy; // another UI?
7474
/* 70h */ int field_70;
7575
/* 74h */ cScenarioDataPtr mpData;
7676
/* 78h */ cScenarioPlayModePtr mpPlayMode;

0 commit comments

Comments
 (0)