Skip to content

Commit 8d3fdfd

Browse files
committed
please god, make these the final fixes. Perhaps this was a mistake :(
1 parent ad309ad commit 8d3fdfd

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

Source/Entities/MovableObject.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,10 @@ int MovableObject::Create(const MovableObject& reference) {
267267
m_ObjectValueMap = reference.m_ObjectValueMap;
268268

269269
// If we're currently performing a game save or load we want to persist our existing IDs
270-
if (g_MovableMan.ShouldPersistUniqueIDs()) {
271-
m_UniqueID = reference.m_UniqueID == 0 ? g_MovableMan.GetNextUniqueID() : reference.m_UniqueID;
270+
if (g_MovableMan.ShouldPersistUniqueIDs() && reference.m_UniqueID != 0) {
271+
m_UniqueID = reference.m_UniqueID;
272272
m_AgeTimer = reference.m_AgeTimer;
273+
const_cast<MovableObject&>(reference).m_UniqueID = 0; // fuck it, stop it deregistering us
273274
} else {
274275
// Otherwise we're copying from a preset normally and ought to create a new object
275276
m_UniqueID = g_MovableMan.GetNextUniqueID();

Source/Managers/ActivityMan.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ bool ActivityMan::SaveCurrentGame(const std::string& fileName) {
128128
}
129129
}
130130

131-
writer->NewPropertyWithValue("MaxUniqueID", currentMaxID);
132-
writer->NewPropertyWithValue("CurrentSimTicks", g_TimerMan.GetSimTickCount());
133131
writer->NewPropertyWithValue("OriginalScenePresetName", scene->GetPresetName());
134132
writer->NewPropertyWithValue("PlaceObjectsIfSceneIsRestarted", g_SceneMan.GetPlaceObjectsOnLoad());
135133
writer->NewPropertyWithValue("PlaceUnitsIfSceneIsRestarted", g_SceneMan.GetPlaceUnitsOnLoad());
136134
writer->NewPropertyWithValue("Scene", modifiableScene.get());
135+
writer->NewPropertyWithValue("MaxUniqueID", currentMaxID);
136+
writer->NewPropertyWithValue("CurrentSimTicks", g_TimerMan.GetSimTickCount());
137137

138138
auto saveWriterData = [](Writer* writerToSave) {
139139
writerToSave->EndWrite();
@@ -181,11 +181,7 @@ bool ActivityMan::LoadAndLaunchGame(const std::string& fileName) {
181181
bool placeUnitsIfSceneIsRestarted = true;
182182
while (reader.NextProperty()) {
183183
std::string propName = reader.ReadPropName();
184-
if (propName == "MaxUniqueID") {
185-
reader >> maxUniqueID;
186-
} else if (propName == "CurrentSimTicks") {
187-
reader >> simTimeTicks;
188-
} else if (propName == "Activity") {
184+
if (propName == "Activity") {
189185
reader >> activity.get();
190186
} else if (propName == "OriginalScenePresetName") {
191187
reader >> originalScenePresetName;
@@ -195,7 +191,11 @@ bool ActivityMan::LoadAndLaunchGame(const std::string& fileName) {
195191
reader >> placeUnitsIfSceneIsRestarted;
196192
} else if (propName == "Scene") {
197193
reader >> scene.get();
198-
}
194+
} else if (propName == "MaxUniqueID") {
195+
reader >> maxUniqueID;
196+
} else if (propName == "CurrentSimTicks") {
197+
reader >> simTimeTicks;
198+
}
199199
}
200200

201201
g_MovableMan.SetShouldPersistUniqueIDs(true);

0 commit comments

Comments
 (0)