Skip to content

Commit 261a09e

Browse files
Large fixes + names update (#100)
* Update SimulatorEnums.h * change cCreatureModeStrategy pickup structs * add kCreatureFlagIsEpic flag * revert GetSelectableMembers to return cSpatialObjectPtr * annotate and edit vars * field_7BC ->mbEnableAmbientEffects * annotate some vars * add additional operators and funcs to Math::Color * rename and annotate cTerrainStateMgr vars * overhaul EditorRequest * GameBundle related vars * add ScheduleTaskWithArgs to IMessageManager * fix cGameBundleGroundContainer * rename EditorUI vars * make ScheduleTaskWithArgs less strict with input types * add Teleport & CreateGroundBundles helper funcs + fix headers for prev commit, re-add some addresses * remove outdated comment * fix typos * add info to CitizenAction enum * annotate and rename vars * add single arg instantiators to ResourceKey and ResourceID * annotate community plan vars * add Vec * Vec and Vec / Vec operators to Vector2-4 * fix various typos, annotate vars * Update AddressesSimulator.cpp * annotate CreatureModeStrategy Pickup struct * Update cCreatureBase.h * add DamageType enum * fix some issues * add App::RenderType * add .find() to vector<eastl::type> * patch various function addresses * annotate and rename vars, add to PaletteItem::ItemType enum * Add march2017 address for cBundleManager::RemoveBundles() --------- Co-authored-by: Rosalie Wanders <rosalie@mailbox.org>
1 parent 4dea572 commit 261a09e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+612
-200
lines changed

EASTL-3.02.01/include/EASTL/vector.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ namespace eastl
333333

334334
bool validate() const EA_NOEXCEPT;
335335
int validate_iterator(const_iterator i) const EA_NOEXCEPT;
336+
int find(const value_type& value) const EA_NOEXCEPT;
337+
int find(const value_type& value, const bool reverse) const EA_NOEXCEPT;
336338

337339
#if EASTL_RESET_ENABLED
338340
void reset() EA_NOEXCEPT; // This function name is deprecated; use reset_lose_memory instead.
@@ -1356,6 +1358,34 @@ namespace eastl
13561358
mpEnd = mpBegin;
13571359
}
13581360

1361+
template <typename T, typename Allocator>
1362+
inline int vector<T, Allocator>::find(const value_type& value) const EA_NOEXCEPT
1363+
{
1364+
const value_type* p = data();
1365+
const value_type* e = p + size();
1366+
for (; p != e; ++p)
1367+
if (*p == value)
1368+
return int(p - data());
1369+
return -1;
1370+
}
1371+
1372+
template <typename T, typename Allocator>
1373+
inline int vector<T, Allocator>::find(const value_type& value, const bool reverse) const EA_NOEXCEPT
1374+
{
1375+
const value_type* p = data();
1376+
const value_type* e = p + size();
1377+
if (!reverse) {
1378+
for (; p != e; ++p)
1379+
if (*p == value)
1380+
return int(p - data());
1381+
}
1382+
else {
1383+
while (p != b)
1384+
if (*--p == value)
1385+
return int(p - b);
1386+
}
1387+
return -1;
1388+
}
13591389

13601390
#if EASTL_RESET_ENABLED
13611391
// This function name is deprecated; use reset_lose_memory instead.

Spore ModAPI/SourceCode/DLL/AddressesAnim.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ namespace Anim
1313
{
1414
DefineAddress(Get, SelectAddress(0x67CC70, 0x67CAE0));
1515
}
16+
17+
namespace Addresses(IAnimWorld)
18+
{
19+
DefineAddress(LoadCreature, SelectAddress(0xA0B1C0, 0xA0B1C0));
20+
}
1621
}
1722

1823
#endif

Spore ModAPI/SourceCode/DLL/AddressesSimulator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ namespace Simulator
845845
namespace Addresses(cScenarioPowerup)
846846
{
847847
DefineAddress(ReactToPowerup, SelectAddress(0xF23FD0, 0xF23BF0));
848-
//TODO DefineAddress(ApplyBoost, SelectAddress(0xF20670, 0xF20290));
848+
DefineAddress(ApplyBoost, SelectAddress(0xF20670, 0xF20290));
849849
DefineAddress(ActivateMedKit, SelectAddress(0xF229C0, 0xF225E0));
850850
DefineAddress(ActivateEnergyKit, SelectAddress(0xF22BE0, 0xF22800));
851851
DefineAddress(ActivateSpeedBoost, SelectAddress(0xF232B0, 0xF22ED0));
@@ -1189,6 +1189,7 @@ namespace Simulator
11891189
namespace Addresses(cBundleManager) {
11901190
DefineAddress(Get, SelectAddress(0xB3D210, 0xB3D3B0));
11911191
DefineAddress(CreateBundles, SelectAddress(0xAC7810, 0xAC79F0));
1192+
DefineAddress(RemoveBundles, SelectAddress(0xAC7A70, 0x00ac7c50));
11921193
}
11931194

11941195
namespace Addresses(cTribeInputStrategy) {

Spore ModAPI/SourceCode/Editors/EditorRequest.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,39 @@ namespace Editors
66
{
77
EditorRequest::EditorRequest()
88
: mRefCount()
9-
, editorID(-1)
10-
, creationKey()
11-
, activeModeID(GameModeManager.GetActiveModeID())
12-
, field_20()
13-
, editableTests()
14-
, sporepediaCanSwitch()
15-
, disableNameEdit()
16-
, allowSporepedia()
17-
, hasSaveButton()
18-
, hasCreateNewButton()
19-
, hasExitButton(true)
20-
, hasPublishButton()
21-
, hasCancelButton(true)
9+
, mEditorName(-1)
10+
, mModelKey()
11+
, mCallingGameModeID(GameModeManager.GetActiveModeID())
12+
, mbIsFirstTimeInEditor()
13+
, mEditableTests()
14+
, mbSporepediaCanSwitch()
15+
, mbDisableNameEdit()
16+
, mbAllowSporepedia()
17+
, mShowSaveButton()
18+
, mShowNewButton()
19+
, mShowExitButton(true)
20+
, mShowPublishButton()
21+
, mShowCancelButton(true)
2222
, field_3C()
2323
, field_3D(true)
2424
, field_40()
2525
, field_50()
2626
, field_60()
2727
, field_64()
28-
, field_65()
28+
, mShowPlayButton()
2929
, field_66()
3030
, field_68()
3131
, field_6C()
3232
, field_6D(true)
3333
, field_6E(true)
3434
, field_6F()
35-
, field_70()
35+
, mConsequenceTraits()
3636
, field_84()
3737
, field_88()
3838
, field_8C()
3939
, field_90()
40-
, field_94(nullptr)
41-
, next(nullptr)
40+
, mpCollectableItems(nullptr)
41+
, mpNext(nullptr)
4242
{
4343
}
4444

Spore ModAPI/SourceCode/Simulator/SimulatorMisc.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,23 @@ namespace Simulator
247247
Args(float amount, cGameBundleContainer* container, int bundleType),
248248
Args(amount, container, bundleType));
249249

250+
251+
auto_METHOD(cBundleManager, float, RemoveBundles,
252+
Args(float amount, cGameBundleContainer* container, cGameBundle* bundle),
253+
Args(amount, container, bundle));
254+
255+
256+
cGameBundle* cBundleManager::CreateGroundBundles(float amount, int bundleType, const Vector3& position, const Quaternion& orientation) {
257+
cGameBundle* bundles = CreateBundles(amount, mpGroundContainer.get(), bundleType);
258+
if (bundles) bundles->Teleport(position, orientation);
259+
return bundles;
260+
}
261+
262+
263+
float cBundleManager::RemoveGroundBundles(float amount, cGameBundle* bundle) {
264+
return RemoveBundles(amount, mpGroundContainer.get(), bundle);
265+
}
266+
250267
/// GamePlantManager ///
251268

252269
auto_STATIC_METHOD_(cGamePlantManager, cGamePlantManager*, Get);

Spore ModAPI/SourceCode/Simulator/cSpatialObject.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,13 @@ namespace Simulator
5050
// Apply the yaw rotation while maintaining the original pitch and roll
5151
return (yawRotation * GetOrientation());
5252
}
53+
54+
void cSpatialObject::Teleport(const Math::Vector3& position) {
55+
this->Teleport(position, mOrientation);
56+
}
57+
void cSpatialObject::Teleport(const cSpatialObjectPtr& refobj) {
58+
this->Teleport(refobj->GetPosition(), refobj->GetOrientation());
59+
}
60+
5361
}
5462
#endif

Spore ModAPI/SourceCode/Terrain/Terrain.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,14 @@ namespace Terrain
136136
, mpTextureCliff()
137137
, mpAtmospherePackedCurves()
138138
, mpAboveColorRamp()
139-
, field_38()
140-
, field_3C()
141-
, field_40()
142-
, field_44()
143-
, field_48()
139+
, mpAboveDetailNoise()
140+
, mpPlanetColorRampsDead()
141+
, mpPlanetColorRampsLiving()
142+
, mpPlanetColorRampsIce()
143+
, mpPlanetColorRampsLava()
144144
, field_4C()
145-
, field_50()
146-
, field_54()
145+
, mpJetStream()
146+
, mpPCAWater()
147147
{
148148

149149
}
@@ -175,7 +175,7 @@ namespace Terrain
175175
, field_61C()
176176
, field_620()
177177
, field_624()
178-
, field_7BC()
178+
, mbEnableAmbientEffects()
179179
{
180180
memset(field_628, 0, sizeof(field_628));
181181
memset(field_7C0, 0, sizeof(field_7C0));

Spore ModAPI/Spore/Anim/IAnimWorld.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,9 @@ namespace Anim
5050
/* 54h */ virtual bool func54h() = 0;
5151
/* 58h */ virtual bool func58h() = 0;
5252
};
53+
54+
namespace Addresses(IAnimWorld)
55+
{
56+
DeclareAddress(LoadCreature);
57+
}
5358
}

Spore ModAPI/Spore/App/IGameModeManager.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ namespace App
125125

126126
///
127127
/// Sets the active game mode to nullptr. The IGameMode::OnExit() method will be called on the active context,
128-
/// and the messages 0x212D3E7 and 0x22D1ADC will be generated.
128+
/// and the messages kMsgOnModeExit and kMsgOnModeEnter will be generated.
129129
/// @returns True if there was an active context, false otherwise.
130130
///
131131
/* 1Ch */ virtual bool ClearActiveMode() = 0;
@@ -148,7 +148,7 @@ namespace App
148148
///
149149
/// Sets the active game mode to be the one with the specified ID. If there's already an active mode,
150150
/// the method IGameMode::OnExit(). The method IGameMode::OnEnter() will be called on
151-
/// the mode with the specified ID. A message with ID 0x22D1ADC will be generated.
151+
/// the mode with the specified ID. A message with ID kMsgOnModeEnter will be generated.
152152
/// @param modeID The ID of the game mode to set as active.
153153
/// @returns True if the mode was found and set active, false otherwise.
154154
///
@@ -187,7 +187,7 @@ namespace App
187187
///
188188
/// Sets the active game mode to be the one at the specified index. If there's already an active mode,
189189
/// the method IGameMode::OnExit() will be called on it. The method IGameMode::OnEnter() will be called on
190-
/// the mode at the specified index. A message with ID 0x22D1ADC will be generated.
190+
/// the mode at the specified index. A message with ID kMsgOnModeEnter will be generated.
191191
/// @param index The index of the game mode to set as active.
192192
/// @returns True if the mode was found and set active, false otherwise.
193193
///
@@ -205,7 +205,7 @@ namespace App
205205
///
206206
/// Sets the active game mode to be the one with the specified name. If there's already an active mode,
207207
/// the method IGameMode::OnExit() will be called on it. The method IGameMode::OnEnter() will be called on
208-
/// the moed at the specified index. A message with ID 0x22D1ADC will be generated.
208+
/// the moed at the specified index. A message with ID kMsgOnModeEnter will be generated.
209209
/// @param pName The name of the game mode to set as active.
210210
/// @returns True if the mode was found and set active, false otherwise.
211211
///

Spore ModAPI/Spore/App/IMessageManager.h

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ namespace App
259259
/// kMsgAppUpdate message. Every frame uses a Clock object to compare the elapsed time since
260260
/// this task as scheduled. The listener is removed once the task has finished executing.
261261
///
262-
/// @param function A void function with no parameters, that will be executed every frame.
262+
/// @param function A void function with no parameters, that will be executed after the scheduled time.
263263
/// @param scheduleTime The time that has to pass, in seconds, since the task is scheduled for it to be executed.
264264
inline ScheduledTaskListenerPtr ScheduleTask(const VoidFunction_T& function, float scheduleTime) {
265265
auto listener = new ScheduledTaskListener(function, scheduleTime, 0.0f);
@@ -268,6 +268,14 @@ namespace App
268268
return listener;
269269
}
270270

271+
/// @param function A void function with parameters, that will be executed after the scheduled time.
272+
/// @param scheduleTime The time that has to pass, in seconds, since the task is scheduled for it to be executed.
273+
template <typename Func, typename... Args>
274+
inline ScheduledTaskListenerPtr ScheduleTaskWithArgs(Func&& function, float scheduleTime, Args&&... args) {
275+
auto boundFunction = [=]() { function(args...); };
276+
return ScheduleTask(boundFunction, scheduleTime);
277+
}
278+
271279
///
272280
/// Executes a class method after a certain time (measured in seconds) has passed from ths call. The method
273281
/// is executed only once, and the time starts counting since this ScheduleTask method has been called.
@@ -280,7 +288,7 @@ namespace App
280288
/// this task as scheduled. The listener is removed once the task has finished executing.
281289
///
282290
/// @param object The object to which the method will be called.
283-
/// @param method A void method with no parameters, that will be executed every frame.
291+
/// @param method A void method with no parameters, that will be executed after the scheduled time.
284292
/// @param scheduleTime The time that has to pass, in seconds, since the task is scheduled for it to be executed.
285293
template <class T>
286294
inline ScheduledTaskListenerPtr ScheduleTask(T* object, VoidMethod_T<T> method, float scheduleTime) {
@@ -289,6 +297,27 @@ namespace App
289297
}, scheduleTime);
290298
}
291299

300+
/// @param object The object to which the method will be called.
301+
/// @param function A void function with parameters, that will be executed after the scheduled time.
302+
/// @param scheduleTime The time that has to pass, in seconds, since the task is scheduled for it to be executed.
303+
template <class ObjT, class MethodT, class... MethodArgs, class... CallArgs>
304+
inline ScheduledTaskListenerPtr ScheduleTaskWithArgs(
305+
ObjT* object,
306+
void (MethodT::* method)(MethodArgs...),
307+
float scheduleTime,
308+
CallArgs&&... args)
309+
{
310+
static_assert(std::is_base_of_v<MethodT, ObjT>,
311+
"Object must derive from method's class");
312+
313+
// Own the data safely for delayed execution
314+
auto boundFunction = [object, method, args...]() {
315+
(static_cast<MethodT*>(object)->*method)(args...);
316+
};
317+
318+
return ScheduleTask(boundFunction, scheduleTime);
319+
}
320+
292321
///
293322
/// Executes a function after a certain time (measured in seconds) has passed from this call,
294323
/// and then keeps repeating it after a certain period (defined by the repeatRate parameter) parameter. The function is executed only
@@ -366,7 +395,7 @@ namespace Simulator
366395
/// kMsgAppUpdate message. Every frame uses a cGonzagoTimer object to compare the elapsed time since
367396
/// this task as scheduled. The listener is removed once the task has finished executing.
368397
///
369-
/// @param function A void function with no parameters, that will be executed every frame.
398+
/// @param function A void function with no parameters, that will be executed after the scheduled time.
370399
/// @param scheduleTime The time that has to pass, in seconds, since the task is scheduled for it to be executed.
371400
inline SimScheduledTaskListenerPtr ScheduleTask(const App::VoidFunction_T& function, float scheduleTime) {
372401
auto listener = new ScheduledTaskListener(function, scheduleTime, 0.0f);
@@ -375,6 +404,14 @@ namespace Simulator
375404
return listener;
376405
}
377406

407+
/// @param function A void function with parameters, that will be executed after the scheduled time.
408+
/// @param scheduleTime The time that has to pass, in seconds, since the task is scheduled for it to be executed.
409+
template <typename Func, typename... Args>
410+
inline SimScheduledTaskListenerPtr ScheduleTaskWithArgs(Func&& function, float scheduleTime, Args&&... args) {
411+
auto boundFunction = [=]() { function(args...); };
412+
return ScheduleTask(boundFunction, scheduleTime);
413+
}
414+
378415
///
379416
/// Executes a class method after a certain time (measured in seconds) has passed from ths call. The method
380417
/// is executed only once, and the time starts counting since this ScheduleTask method has been called.
@@ -387,7 +424,7 @@ namespace Simulator
387424
/// this task as scheduled. The listener is removed once the task has finished executing.
388425
///
389426
/// @param object The object to which the method will be called.
390-
/// @param method A void method with no parameters, that will be executed every frame.
427+
/// @param method A void method with no parameters, that will be executed after the scheduled time.
391428
/// @param scheduleTime The time that has to pass, in seconds, since the task is scheduled for it to be executed.
392429
template <class T>
393430
inline SimScheduledTaskListenerPtr ScheduleTask(T* object, App::VoidMethod_T<T> method, float scheduleTime) {
@@ -396,6 +433,27 @@ namespace Simulator
396433
}, scheduleTime);
397434
}
398435

436+
/// @param object The object to which the method will be called.
437+
/// @param method A void method with parameters, that will be executed after the scheduled time.
438+
/// @param scheduleTime The time that has to pass, in seconds, since the task is scheduled for it to be executed.
439+
template <class ObjT, class MethodT, class... MethodArgs, class... CallArgs>
440+
inline SimScheduledTaskListenerPtr ScheduleTaskWithArgs(
441+
ObjT* object,
442+
void (MethodT::* method)(MethodArgs...),
443+
float scheduleTime,
444+
CallArgs&&... args)
445+
{
446+
static_assert(std::is_base_of_v<MethodT, ObjT>,
447+
"Object must derive from method's class");
448+
449+
// Own the data safely for delayed execution
450+
auto boundFunction = [object, method, args...]() {
451+
(static_cast<MethodT*>(object)->*method)(args...);
452+
};
453+
454+
return ScheduleTask(boundFunction, scheduleTime);
455+
}
456+
399457
///
400458
/// Executes a function after a certain time (measured in seconds) has passed from this call,
401459
/// and then keeps repeating it after a certain period (defined by the repeatRate parameter) parameter. The function is executed only

0 commit comments

Comments
 (0)