Skip to content

Commit

Permalink
3rdParty: update Spore-ModAPI to v2.5.307
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Jan 24, 2024
1 parent 3d95343 commit 8ad69b6
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 8 deletions.
2 changes: 1 addition & 1 deletion 3rdParty/BuildSporeModAPI.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set SPOREMODAPI_CUR_DIR=%~dp0

msbuild "%SPOREMODAPI_CUR_DIR%\Spore-ModAPI\Spore ModAPI" ^
/p:Configuration="Release DLL" ^
/p:SDK_BUILD_VER=306 ^
/p:SDK_BUILD_VER=307 ^
/p:EXECUTABLE_TYPE=10 ^
/p:Platform=Win32 ^
/m
4 changes: 2 additions & 2 deletions 3rdParty/Spore-ModAPI/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = [email protected]:emd4600/Spore-ModAPI.git
branch = master
commit = 2acd9498cc262f2c1860381d999802da01a44ee3
parent = b403863775c22022a64a405c7a295962b5c7eb99
commit = 4ad8633b87129ff96fd2ffa3aed758593f541f31
parent = 3d9534382b570a45022048ef5793bd7724e19b44
method = merge
cmdver = 0.4.6
18 changes: 18 additions & 0 deletions 3rdParty/Spore-ModAPI/EASTL-3.02.01/include/EASTL/fixed_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,24 @@ namespace eastl
}



/// Spore equivalent of fixed_map; only reading is supported, adding elements might crash.
template <typename Key,
typename T,
size_t nodeCount>
class sp_fixed_map : public map<Key, T>
{
public:
typedef hash_map<Key, T> base_type;
typedef typename base_type::node_type node_type;
typedef typename base_type::size_type size_type;

public:
/* 1Ch */ int mPoolAllocator[4]; // actually part of mAllocator
char mPoolBuffer[(nodeCount + 1) * sizeof(node_type)];
};


} // namespace eastl


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ else if (returnTypeSize == 8) {
}
else if ("void".equals(signature.getReturnType().getName())) {
returnStorage = VariableStorage.VOID_STORAGE;
}
else if ("float".equals(signature.getReturnType().getName())) {
returnStorage = new VariableStorage(currentProgram, currentProgram.getRegister("st0"));
}
else {
returnStorage = new VariableStorage(currentProgram, currentProgram.getRegister("eax"));
Expand Down
2 changes: 1 addition & 1 deletion 3rdParty/Spore-ModAPI/SDKtoGhidra/eastl_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ namespace eastl
float mfMaxLoadFactor;
float mfGrowthFactor;
int mnNextResize;
/* 1Ch */ int mPoolAllocator[5];
/* 1Ch */ int mPoolAllocator[6];
/* 34h */ void* mBucketBuffer[bucketCount + 1];
//WARNING this does not work if T has alignment 8, because the struct will also get the alignment (but it shouldn't)
int mPoolBuffer0[bucketCount + 1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ namespace Addresses(Simulator)
DefineAddress(IsNotStarOrBinaryStar, SelectAddress(0xC8A840, 0xC8B6B0));

DefineAddress(LaunchDefaultToolProjectile, SelectAddress(0x1054F40, 0x1054390));

DefineAddress(sCreatureGameUnlockCategoriesCount, SelectAddress(0x1587278, 0x1583298));

#ifndef SDK_TO_GHIDRA
DefineAddress(LightingWorld_ptr, SelectAddress(0x1682CD4, 0x167EA54));
Expand Down Expand Up @@ -1029,6 +1031,13 @@ namespace Simulator
DefineAddress(LoadConfig, SelectAddress(0x599100, 0x599440));
DefineAddress(AddUnlockableItem, SelectAddress(0x598A70, 0x598DB0));
DefineAddress(AddUnlockableItemFromProp, SelectAddress(0x598B50, 0x598E90));
DefineAddress(sub_597BC0, SelectAddress(0x597BC0, 0x597F00));
DefineAddress(sub_597390, SelectAddress(0x597390, 0x5976D0));
}

namespace Addresses(CreatureGamePartUnlocking)
{
DefineAddress(sub_D3B460, , SelectAddress(0xD3B460, 0xD3BF50));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,14 @@ namespace Simulator
auto_METHOD(cCollectableItems, bool, AddUnlockableItemFromProp,
Args(struct ResourceKey key, uint32_t categoryID, int row, int column, int pageIndex),
Args(key, categoryID, row, column, pageIndex));

auto_METHOD_VOID(cCollectableItems, sub_597390,
Args(eastl::vector<int>& dst, struct cCollectableItemID itemID, int unk),
Args(dst, itemID, unk));


eastl::fixed_vector<eastl::pair<uint32_t, int>, 16>& GetCreatureGameUnlockCategoriesCount() {
return *(eastl::fixed_vector<eastl::pair<uint32_t, int>, 16>*)(GetAddress(Simulator, sCreatureGameUnlockCategoriesCount));
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,10 @@ inline T* simulator_new()
{
return object_cast<T>(GameNounManager.CreateInstance(T::NOUN_ID));
}

namespace Simulator
{
inline cPlayer* GetPlayer() {
return GameNounManager.GetPlayer();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <EASTL\vector.h>
#include <EASTL\hash_map.h>
#include <EASTL\list.h>
#include <EASTL\fixed_map.h>
#include <EASTL\fixed_vector.h>
#include <EASTL\fixed_hash_set.h>
#include <EASTL\fixed_hash_map.h>

Expand All @@ -24,6 +26,8 @@ namespace Simulator
uint32_t instanceID;
uint32_t groupID;
};

constexpr cCollectableItemID COLLECTABLE_ITEM_NULL_ID = { -1, -1 };
}

#ifndef SDK_TO_GHIDRA
Expand All @@ -39,11 +43,36 @@ namespace eastl

namespace Simulator
{
typedef eastl::fixed_vector<cCollectableItemID, 5> cCollectableItemsRowVector;

typedef uint64_t cCollectableItemsRowID;

inline cCollectableItemsRowID GetCollectableItemsRowID(uint32_t categoryID, int pageIndex, int row) {
return ((uint64_t)categoryID) << 32 | (pageIndex << 16) | row;
}

struct UnkHashtableItem {
int field_0;
int field_4;
};
ASSERT_SIZE(UnkHashtableItem, 8);
typedef eastl::sp_fixed_hash_map<Simulator::cCollectableItemID, UnkHashtableItem, 4> UnkHastable;
ASSERT_SIZE(UnkHastable, 0xDC);

typedef eastl::sp_fixed_hash_map<int, UnkHastable, 8> UnkHashMap;
ASSERT_SIZE(UnkHashMap, 0x888);

class cCollectableItems
: public ISimulatorSerializable
, public DefaultRefCounted
{
public:
static const uint32_t TYPE = 0x3A3AA3A;

using Object::AddRef;
using Object::Release;
using Object::Cast;

void LoadConfig(uint32_t configGroupID, uint32_t configInstanceID, uint32_t itemsGroupID);

void AddUnlockableItem(uint32_t instanceID, uint32_t groupID, int itemUnlockLevel, uint32_t categoryID, int row, int column, int pageIndex, float itemUnlockFindPercentage, uint32_t itemUnlockEffect);
Expand All @@ -57,22 +86,28 @@ namespace Simulator
/// @param pageIndex
bool AddUnlockableItemFromProp(struct ResourceKey key, uint32_t categoryID, int row, int column, int pageIndex);


void sub_597BC0(UnkHashMap& dst, int, const ResourceKey& speciesKey);

void sub_597390(eastl::vector<int>& dst, struct cCollectableItemID itemID, int);

public:
struct UnlockableItem
{
/* 00h */ int itemUnlockLevel;
/* 04h */ float itemUnlockFindPercentage;
/* 08h */ uint32_t categoryID;
/* 0Ch */ int row;
/* 10h */ int column;
/* 0Ch */ int column;
/* 10h */ int row;
/* 14h */ int pageIndex;
/* 18h */ uint32_t itemUnlockEffect;
};
ASSERT_SIZE(UnlockableItem, 0x1C);

#ifndef SDK_TO_GHIDRA
/* 0Ch */ bool field_C; // true
/* 10h */ char field_10[0x147C]; // some fixed_ structure of vector<pair<int, int>>?
/// Stores a progression of unlockable items (for instance, all the mouths in the same row)
/* 10h */ eastl::sp_fixed_map<cCollectableItemsRowID, cCollectableItemsRowVector, 64> mUnlockableRows;
/* 148Ch */ eastl::sp_fixed_hash_map<cCollectableItemID, UnlockableItem, 256> mUnlockableItems;
/// Some flags
/* 4D00h */ eastl::sp_fixed_hash_map<cCollectableItemID, uint8_t, 256> mItemStatusInfos;
Expand Down Expand Up @@ -107,9 +142,28 @@ namespace Simulator
DeclareAddress(LoadConfig); // 0x599100 0x599440
DeclareAddress(AddUnlockableItem); // 0x598A70 0x598DB0
DeclareAddress(AddUnlockableItemFromProp); // 0x598B50 0x598E90

DeclareAddress(sub_597BC0); // 0x597BC0 0x597F00
DeclareAddress(sub_597390); // 0x597390 0x5976D0
}


class CreatureGamePartUnlocking
{
public:
struct cCollectableItemID sub_D3B460(UnkHashMap&, bool, int, int);
};

namespace Addresses(CreatureGamePartUnlocking)
{
DeclareAddress(sub_D3B460); // 0xD3B460 0xD3BF50
}


eastl::fixed_vector<eastl::pair<uint32_t, int>, 16>& GetCreatureGameUnlockCategoriesCount();
}

// eastl::fixed_vector<eastl::pair<>
namespace Addresses(Simulator)
{
DeclareAddress(sCreatureGameUnlockCategoriesCount); // 0x1587278 0x1583298
}

0 comments on commit 8ad69b6

Please sign in to comment.