Skip to content

Commit a3e4b81

Browse files
authored
Make cPlanetModel actually usable (#113)
* Improve terrain-related class fields, add `cTerrainSphereDecal` * Add `cTerrainSphereDecal` to `Terrain.h` * Minor field renames * Fix includes in `cTerrainSphereDecal.h` * Minor field fix for `cTerrainDecal` (68h is some float value) Also rename some fields in `cPlanetModel`. * Rename fields of `TerrainModification` (a.k.a. `cRelevel`) * Describe most `cPlanetModel` fieldss, fix alignment
1 parent 9281e1b commit a3e4b81

9 files changed

Lines changed: 106 additions & 34 deletions

File tree

‎Spore ModAPI/SourceCode/Simulator/SimulatorSystem.cpp‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ namespace Simulator
6666
: mnRefCount(0)
6767
, mLastGameMode(0xFFFFFFFF)
6868
, mCurrentGameMode(0xFFFFFFFF)
69-
, field_14(0xFFFFFFFF)
70-
, field_18(0)
69+
, mCurrentTransition(0xFFFFFFFF)
70+
, mCurrentTransitionPhase(0)
7171
{}
7272
cStrategy::~cStrategy() {}
7373

@@ -102,7 +102,7 @@ namespace Simulator
102102
return mCurrentGameMode;
103103
}
104104
bool cStrategy::func24h(uint32_t mode) {
105-
return mode == GetCurrentGameMode() && mode == GetLastGameMode() && field_14 == 0xFFFFFFFF;
105+
return mode == GetCurrentGameMode() && mode == GetLastGameMode() && mCurrentTransition == 0xFFFFFFFF;
106106
}
107107

108108
void cStrategy::OnLoad(const cSavedGameHeader& savedGame) {}
@@ -111,22 +111,22 @@ namespace Simulator
111111
void cStrategy::PostUpdate(int deltaTime, int deltaGameTime) {}
112112

113113
void cStrategy::func40h(uint32_t mode) {
114-
field_18 = 1;
115-
if (field_14 == 0xFFFFFFFF) field_14 = mode;
114+
mCurrentTransitionPhase = 1;
115+
if (mCurrentTransition == 0xFFFFFFFF) mCurrentTransition = mode;
116116
}
117117
void cStrategy::func44h(uint32_t mode) {
118-
field_18 = 2;
119-
if (field_14 == 0xFFFFFFFF) field_14 = mode;
118+
mCurrentTransitionPhase = 2;
119+
if (mCurrentTransition == 0xFFFFFFFF) mCurrentTransition = mode;
120120
}
121121
void cStrategy::func48h() {
122-
mLastGameMode = field_14;
123-
field_14 = 0xFFFFFFFF;
124-
field_18 = 0;
122+
mLastGameMode = mCurrentTransition;
123+
mCurrentTransition = 0xFFFFFFFF;
124+
mCurrentTransitionPhase = 0;
125125
}
126126
void cStrategy::func4Ch() {
127-
mCurrentGameMode = field_14;
128-
field_14 = 0xFFFFFFFF;
129-
field_18 = 0;
127+
mCurrentGameMode = mCurrentTransition;
128+
mCurrentTransition = 0xFFFFFFFF;
129+
mCurrentTransitionPhase = 0;
130130
}
131131
}
132132
#endif

‎Spore ModAPI/Spore ModAPI.vcxproj‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@
331331
<ClInclude Include="Spore\Editors\cSPEditorVerbIcon.h" />
332332
<ClInclude Include="Spore\Editors\cSPEditorVerbIconTray.h" />
333333
<ClInclude Include="Spore\Graphics\cCubeMapCoord.h" />
334+
<ClInclude Include="Spore\Graphics\cCubeMapIndex.h" />
334335
<ClInclude Include="Spore\IO\IniFile.h" />
335336
<ClInclude Include="Spore\IO\StreamCompressionZLib.h" />
336337
<ClInclude Include="Spore\Swarm\cDecal.h" />

‎Spore ModAPI/Spore ModAPI.vcxproj.filters‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,6 +2304,9 @@
23042304
<ClInclude Include="Spore\Graphics\cCubeMapCoord.h">
23052305
<Filter>Header Files</Filter>
23062306
</ClInclude>
2307+
<ClInclude Include="Spore\Graphics\cCubeMapIndex.h">
2308+
<Filter>Header Files</Filter>
2309+
</ClInclude>
23072310
</ItemGroup>
23082311
<ItemGroup>
23092312
<ClCompile Include="SourceCode\Allocator.cpp">
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
3+
#include <Spore\Internal.h>
4+
5+
namespace Graphics
6+
{
7+
struct cCubeMapIndex
8+
{
9+
/* 00h */ int mCol;
10+
/* 04h */ int mRow;
11+
/* 08h */ int mFace;
12+
};
13+
ASSERT_SIZE(cCubeMapIndex, 0x0C);
14+
}

‎Spore ModAPI/Spore/Simulator/SubSystem/PlanetModel.h‎

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
****************************************************************************/
1919
#pragma once
2020

21+
#include <Spore\Graphics\cCubeMapIndex.h>
2122
#include <Spore\Simulator\SubSystem\cStrategy.h>
2223
#include <Spore\Simulator\cCity.h>
23-
#include <Spore\Terrain\ITerrain.h>
24+
#include <Spore\Terrain\cTerrainSphere.h>
2425
#include <Spore\MathUtils.h>
2526

2627
/// Access the active Simulator planet manager.
@@ -29,13 +30,52 @@
2930
namespace Simulator
3031
{
3132
using namespace Math;
33+
34+
struct cPoliticalZone
35+
{
36+
uint32_t mPoliticalID;
37+
Vector3 mCenter;
38+
bool mCityZone;
39+
bool mVisible;
40+
cCity* mCity;
41+
};
3242

3343
//sizeof 0x13208
3444
class cPlanetModel
3545
: public App::IMessageListener
3646
, public cStrategy
3747
{
3848
public:
49+
struct cLandTradeRoute
50+
{
51+
cCity* city1;
52+
cCity* city2;
53+
eastl::vector<Vector3> path;
54+
};
55+
56+
struct cBoundaryPointInfo
57+
{
58+
Vector3 mDisplacedPoint;
59+
int8_t mZoneIdxs[4];
60+
bool mVisited[4];
61+
};
62+
63+
struct cCubeCornerHash
64+
{
65+
size_t operator()(const Graphics::cCubeMapIndex& c) const
66+
{
67+
return c.mFace * 0xfd + c.mCol * 0x25 + c.mRow;
68+
}
69+
};
70+
71+
struct cCubeMapIndexEqual
72+
{
73+
bool operator()(const Graphics::cCubeMapIndex& a, const Graphics::cCubeMapIndex& b) const
74+
{
75+
return (a.mFace == b.mFace) && (a.mCol == b.mCol) && (a.mRow == b.mRow);
76+
}
77+
};
78+
3979
//TODO PLACEHOLDER
4080

4181
// B7DC40 Get water level?
@@ -63,19 +103,30 @@ namespace Simulator
63103

64104
public:
65105
//TODO
66-
/* 1Ch */ int field_1C; // not initialized
67-
// one of these is cTerrainSphere*?
68-
/* 20h */ ITerrainPtr mpTerrain;
69-
/* 24h */ Terrain::ITerrain* mpTerrain2;
70-
/* 28h */ float field_28;
106+
/* 20h */ cTerrainSpherePtr mpSphere;
107+
/* 24h */ ITerrainPtr mpTerrain;
108+
/* 28h */ float mWaterFraction;
71109
/* 2Ch */ ResourceKey mPlanetKey;
72-
/* 38h */ eastl::string16 field_38;
110+
/* 38h */ eastl::string16 mPlanetName;
73111
/* 48h */ bool mbAddedMessageListeners;
74-
/* 4Ch */ void* mpPlanetAStarInfo;
75-
76-
/* 7Ch */ void* mpPlanetObstacles;
112+
/* 4Ch */ uint32_t* mContinentMap;
113+
/* 50h */ eastl::vector<uint32_t> mContinentAreas;
114+
/* 64h */ eastl::vector<bool> mContinentAboveWater;
115+
/* 78h */ bool mContinentMapDirty;
116+
/* 7Ch */ uint8_t* mObstacleBitMap;
117+
/* 80h */ eastl::vector<cPoliticalZone> mPoliticalZones;
118+
/* 94h */ eastl::vector<int8_t> mPoliticalZoneIdxMap;
119+
/* A8h */ void* mPlanetRibbonGfx; // cPlanetRibbonGfx
120+
/* ACh */ eastl::vector<eastl::pair<cCity*, cCity*>> mSeaTradeRoutes;
121+
/* C0h */ eastl::vector<eastl::pair<cCity*, cCity*>> mAirTradeRoutes;
122+
/* D4h */ eastl::vector<cLandTradeRoute> mLandTradeRoutes;
123+
/* E8h */ bool mSeaTradeRoutesDirty;
124+
/* E9h */ bool mAirTradeRoutesDirty;
125+
/* EAh */ bool mLandTradeRoutesDirty;
126+
/* ECh */ uint32_t mGameMode;
127+
// eastl::fixed_hash_map<Graphics::cCubeMapIndex, cBoundaryPointInfo, 2048, 512, true, cCubeCornerHash, cCubeMapIndexEqual, false> mPoliticalBoundaryPoints;
128+
// Graphics::cCubeMapIndex mPoliticalBoundaryStartCorner[15];
77129

78-
/* A8h */ void* mpPlanetRibbonGfx;
79130
//PLACEHODER more things
80131
};
81132

‎Spore ModAPI/Spore/Simulator/SubSystem/cStrategy.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ namespace Simulator
8484
// NOTE: These 2 mode values can sometimes appear swapped when changing modes.
8585
/* 0Ch */ uint32_t mLastGameMode; // -1
8686
/* 10h */ uint32_t mCurrentGameMode; // -1
87-
/* 14h */ uint32_t field_14; // -1
88-
/* 18h */ int field_18;
87+
/* 14h */ uint32_t mCurrentTransition; // -1
88+
/* 18h */ int mCurrentTransitionPhase;
8989
};
9090
ASSERT_SIZE(cStrategy, 0x1C);
9191
}

‎Spore ModAPI/Spore/Terrain/cTerrainDecal.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ namespace Terrain
77
struct cTerrainDecal
88
: public Swarm::cDecal
99
{
10-
/* 68h */ Swarm::DecalType mType = Swarm::DecalType::kDecalTypeTerrain;
10+
/* 68h */ float field_68;
11+
// /* 68h */ Swarm::DecalType mType = Swarm::DecalType::kDecalTypeTerrain;
1112
};
1213
ASSERT_SIZE(cTerrainDecal, 0x6C);
1314
}

‎Spore ModAPI/Spore/Terrain/cTerrainSphere.h‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#include <Spore\Terrain\TerrainShaderData.h>
3535
#include <Spore\Terrain\cTerrainSphereQuad.h>
3636

37+
#define cTerrainSpherePtr eastl::intrusive_ptr<Terrain::cTerrainSphere>
38+
3739
namespace Terrain
3840
{
3941
enum TerrainGameMode
@@ -138,11 +140,11 @@ namespace Terrain
138140

139141
struct TerrainModification
140142
{
141-
/* 00h */ Transform transform;
142-
/* 38h */ char field_38[0x60]; // floats
143-
/* 98h */ ResourceKey key;
144-
/* A4h */ int field_A4;
145-
/* A8h */ uint32_t modid;
143+
/* 00h */ Transform mTransform;
144+
/* 38h */ Math::Rectangle mBounds[6];
145+
/* 98h */ ResourceKey mKey;
146+
/* A4h */ uint32_t mFlagsAndBits;
147+
/* A8h */ uint32_t mModId;
146148
};
147149
ASSERT_SIZE(TerrainModification, 0xAC);
148150

@@ -188,7 +190,7 @@ namespace Terrain
188190
/* 20Ch */ cTerrainStateMgr* mpTerrainStateMgr;
189191
/* 210h */ cWeatherManagerPtr mpWeatherManager;
190192
/* 214h */ int field_214;
191-
/* 218h */ eastl::vector<int> mpDecalList[4];
193+
/* 218h */ eastl::vector<cTerrainSphereDecal*> mpDecalList[4];
192194
/* 268h */ eastl::vector<int> mDecalIdFreeList[4];
193195
/* 2B8h */ eastl::vector<int> mpDecalSegList;
194196
/* 2CCh */ eastl::vector<int> mDecalSegListIdFreeList;

‎Spore ModAPI/Spore/Terrain/cTerrainSphereDecal.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ namespace Terrain
9999
}
100100

101101
public:
102-
/* 74h */ int field_74; // -1
102+
/* 74h */ int field_74; // -1, index?
103103
/* 78h */ cTerrainSphere* mpParentSphere;
104104
/* 7Ch */ cTerrainMapSet* mpTerrainMapSet;
105105
/* 80h */ eastl::vector<FaceInfo> mFaceArray;

0 commit comments

Comments
 (0)