@@ -100,9 +100,11 @@ bool ActivityMan::SaveCurrentGame(const std::string& fileName) {
100
100
modifiableScene->GetTerrain ()->SetPresetName (fileName);
101
101
modifiableScene->GetTerrain ()->MigrateToModule (g_PresetMan.GetModuleID (c_UserScriptedSavesModuleName));
102
102
103
- modifiableScene->GetTerrain ()->OverrideDataPath (" Save Mat.png" );
104
- modifiableScene->GetTerrain ()->GetFGSceneLayer ()->OverrideDataPath (" Save FG.png" );
105
- modifiableScene->GetTerrain ()->GetBGSceneLayer ()->OverrideDataPath (" Save BG.png" );
103
+ // See our content files to point to our save game location. This won't actually save a file here- but it allows us to set these up as in-memory ContentFiles on load
104
+ // Meaning that our loading code doesn't need to care about whether it's loading a savegame or a file- it just sees it as an already loaded, cached bitmap
105
+ modifiableScene->GetTerrain ()->GetContentFile ().SetDataPath (g_PresetMan.GetModuleID (c_UserScriptedSavesModuleName) + " /Save Mat.png" );
106
+ modifiableScene->GetTerrain ()->GetFGSceneLayer ()->GetContentFile ().SetDataPath (g_PresetMan.GetModuleID (c_UserScriptedSavesModuleName) + " /Save FG.png" );
107
+ modifiableScene->GetTerrain ()->GetBGSceneLayer ()->GetContentFile ().SetDataPath (g_PresetMan.GetModuleID (c_UserScriptedSavesModuleName) + " /Save BG.png" );
106
108
107
109
std::unique_ptr<std::stringstream> iniStream = std::make_unique<std::stringstream>();
108
110
@@ -293,20 +295,20 @@ bool ActivityMan::LoadAndLaunchGame(const std::string& fileName) {
293
295
get_palette (palette);
294
296
295
297
unzipFileIntoBuffer (" Save Mat.png" );
296
- ContentFile::ManuallyLoadDataBitmap (filePath + " /Save Mat.png" , loadMemPngIntoBitmap (buffer, info.uncompressed_size ));
298
+ ContentFile::ManuallyLoadDataBitmap (g_PresetMan. GetFullModulePath (c_UserScriptedSavesModuleName) + " /Save Mat.png" , loadMemPngIntoBitmap (buffer, info.uncompressed_size ));
297
299
free (buffer);
298
300
299
301
unzipFileIntoBuffer (" Save FG.png" );
300
- ContentFile::ManuallyLoadDataBitmap (filePath + " /Save FG.png" , loadMemPngIntoBitmap (buffer, info.uncompressed_size ));
302
+ ContentFile::ManuallyLoadDataBitmap (g_PresetMan. GetFullModulePath (c_UserScriptedSavesModuleName) + " /Save FG.png" , loadMemPngIntoBitmap (buffer, info.uncompressed_size ));
301
303
free (buffer);
302
304
303
305
unzipFileIntoBuffer (" Save BG.png" );
304
- ContentFile::ManuallyLoadDataBitmap (filePath + " /Save BG.png" , loadMemPngIntoBitmap (buffer, info.uncompressed_size ));
306
+ ContentFile::ManuallyLoadDataBitmap (g_PresetMan. GetFullModulePath (c_UserScriptedSavesModuleName) + " /Save BG.png" , loadMemPngIntoBitmap (buffer, info.uncompressed_size ));
305
307
free (buffer);
306
308
307
309
for (int i = 0 ; i < numberOfTeams; ++i) {
308
310
unzipFileIntoBuffer (std::format (" Save UST%i.png" , i));
309
- ContentFile::ManuallyLoadDataBitmap (filePath + std::format (" /Save UST%i" , i), loadMemPngIntoBitmap (buffer, info.uncompressed_size ));
311
+ ContentFile::ManuallyLoadDataBitmap (g_PresetMan. GetFullModulePath (c_UserScriptedSavesModuleName) + std::format (" /Save UST%i" , i), loadMemPngIntoBitmap (buffer, info.uncompressed_size ));
310
312
free (buffer);
311
313
}
312
314
@@ -323,11 +325,11 @@ bool ActivityMan::LoadAndLaunchGame(const std::string& fileName) {
323
325
g_SceneMan.SetSceneToLoad (originalScenePresetName, placeObjectsIfSceneIsRestarted, placeUnitsIfSceneIsRestarted);
324
326
325
327
// Clear out the cache, we don't need it anymore (and don't want a cache reload to look for this file thinking it really exists)
326
- ContentFile::ManuallyClearDataBitmap (filePath + " /Save Mat.png" );
327
- ContentFile::ManuallyClearDataBitmap (filePath + " /Save FG.png" );
328
- ContentFile::ManuallyClearDataBitmap (filePath + " /Save BG.png" );
328
+ ContentFile::ManuallyClearDataBitmap (g_PresetMan. GetFullModulePath (c_UserScriptedSavesModuleName) + " /Save Mat.png" );
329
+ ContentFile::ManuallyClearDataBitmap (g_PresetMan. GetFullModulePath (c_UserScriptedSavesModuleName) + " /Save FG.png" );
330
+ ContentFile::ManuallyClearDataBitmap (g_PresetMan. GetFullModulePath (c_UserScriptedSavesModuleName) + " /Save BG.png" );
329
331
for (int i = 0 ; i < numberOfTeams; ++i) {
330
- ContentFile::ManuallyClearDataBitmap (filePath + std::format (" /Save UST%i.png" , i));
332
+ ContentFile::ManuallyClearDataBitmap (g_PresetMan. GetFullModulePath (c_UserScriptedSavesModuleName) + std::format (" /Save UST%i.png" , i));
331
333
}
332
334
333
335
g_ConsoleMan.PrintString (" SYSTEM: Game \" " + fileName + " \" loaded!" );
0 commit comments