@@ -185,8 +185,8 @@ namespace SavedGames
185185 };
186186
187187
188- template <typename T>
189- bool AppendToStorage (IStorage* pStorage)
188+ template <typename T> requires std::is_trivially_copyable_v<T>
189+ bool WriteToStorage (IStorage* pStorage)
190190 {
191191 IStreamPtr pStream = nullptr ;
192192 bool ret = false ;
@@ -210,7 +210,7 @@ namespace SavedGames
210210 }
211211
212212
213- template <typename T>
213+ template <typename T> requires std::is_trivially_copyable_v<T>
214214 std::optional<T> ReadFromStorage (IStorage* pStorage)
215215 {
216216 IStreamPtr pStream = nullptr ;
@@ -223,7 +223,7 @@ namespace SavedGames
223223 &pStream
224224 );
225225
226- T info;
226+ T info {} ;
227227
228228 if (SUCCEEDED (hr) && pStream != nullptr )
229229 {
@@ -280,10 +280,10 @@ DEFINE_HOOK(0x67D2E3, SaveGame_AdditionalInfoForClient, 0x6)
280280 GET_STACK (IStorage*, pStorage, STACK_OFFSET (0x4A0 , -0x490 ));
281281 using namespace SavedGames ;
282282
283- if (pStorage)
283+ if (pStorage && SessionClass::IsCampaign () )
284284 {
285- if (SessionClass::IsCampaign () && Spawner::GetConfig ()->CustomMissionID )
286- AppendToStorage <CustomMissionID>(pStorage);
285+ if (Spawner::GetConfig ()->CustomMissionID )
286+ WriteToStorage <CustomMissionID>(pStorage);
287287 }
288288
289289 return 0 ;
@@ -304,7 +304,7 @@ DEFINE_HOOK(0x67E4DC, LoadGame_AdditionalInfoForClient, 0x7)
304304 if (auto id = ReadFromStorage<CustomMissionID>(pStorage))
305305 {
306306 int num = id->Number ;
307- Debug::Log (" [Spawner] sav file CustomMissionID = %d\n " , num);
307+ Debug::Log (" sav file CustomMissionID = %d\n " , num);
308308 Spawner::GetConfig ()->CustomMissionID = num;
309309 ScenarioClass::Instance->EndOfGame = true ;
310310 }
0 commit comments