@@ -159,7 +159,7 @@ bool ActivityMan::SaveCurrentGame(const std::string& fileName) {
159
159
delete sceneLayerInfos;
160
160
return ;
161
161
}
162
-
162
+
163
163
std::stringstream* mainStream = static_cast <std::stringstream*>(mainWriter->GetStream ());
164
164
std::stringstream* indexStream = static_cast <std::stringstream*>(indexWriter->GetStream ());
165
165
mainStream->flush ();
@@ -178,40 +178,41 @@ bool ActivityMan::SaveCurrentGame(const std::string& fileName) {
178
178
zipWriteInFileInZip (zippedSaveFile, mainStreamView.data (), mainStreamView.size ());
179
179
zipCloseFileInZip (zippedSaveFile);
180
180
181
- for (const SceneLayerInfo& layerInfo : *sceneLayerInfos)
182
- {
183
- // Save png into a memory buffer
184
- SDL_IOStream* stream = SDL_IOFromDynamicMem ();
185
- SDL_Surface* image = SDL_CreateSurfaceFrom (layerInfo.bitmap ->w , layerInfo.bitmap ->h , SDL_PIXELFORMAT_INDEX8, layerInfo.bitmap ->dat , layerInfo.bitmap ->w );
181
+ std::for_each (std::execution::par_unseq,
182
+ sceneLayerInfos->begin (), sceneLayerInfos->end (),
183
+ [&](const SceneLayerInfo& layerInfo) {
184
+ // Save png into a memory buffer
185
+ SDL_IOStream* stream = SDL_IOFromDynamicMem ();
186
+ SDL_Surface* image = SDL_CreateSurfaceFrom (layerInfo.bitmap ->w , layerInfo.bitmap ->h , SDL_PIXELFORMAT_INDEX8, layerInfo.bitmap ->dat , layerInfo.bitmap ->w );
186
187
187
- SDL_Palette* palette = ContentFile::DefaultPaletteToSDL ();
188
- SDL_SetSurfacePalette (image, palette);
188
+ SDL_Palette* palette = ContentFile::DefaultPaletteToSDL ();
189
+ SDL_SetSurfacePalette (image, palette);
189
190
190
- bool result = IMG_SavePNG_IO (image, stream, false );
191
- SDL_FlushIO (stream);
191
+ bool result = IMG_SavePNG_IO (image, stream, false );
192
+ SDL_FlushIO (stream);
192
193
193
- SDL_DestroyPalette (palette);
194
- SDL_DestroySurface (image);
194
+ SDL_DestroyPalette (palette);
195
+ SDL_DestroySurface (image);
195
196
196
- if (!result) {
197
- g_ConsoleMan.PrintString (" ERROR: Failed to save scenelayers to PNG!" );
198
- continue ;
199
- }
197
+ if (!result) {
198
+ g_ConsoleMan.PrintString (" ERROR: Failed to save scenelayers to PNG!" );
199
+ return ;
200
+ }
200
201
201
- // Actually get the memory
202
- void * buffer = SDL_GetPointerProperty (SDL_GetIOProperties (stream), SDL_PROP_IOSTREAM_DYNAMIC_MEMORY_POINTER, nullptr );
203
- size_t size = static_cast <size_t >(SDL_GetIOSize (stream));
204
- if (!buffer || size < 0 ) {
205
- g_ConsoleMan.PrintString (" ERROR: Failed to save scenelayers to PNG!" );
206
- continue ;
207
- }
202
+ // Actually get the memory
203
+ void * buffer = SDL_GetPointerProperty (SDL_GetIOProperties (stream), SDL_PROP_IOSTREAM_DYNAMIC_MEMORY_POINTER, nullptr );
204
+ size_t size = static_cast <size_t >(SDL_GetIOSize (stream));
205
+ if (!buffer || size < 0 ) {
206
+ g_ConsoleMan.PrintString (" ERROR: Failed to save scenelayers to PNG!" );
207
+ return ;
208
+ }
208
209
209
- zipOpenNewFileInZip (zippedSaveFile, (" Save " + layerInfo.name + " .png" ).c_str (), &zfi, nullptr , 0 , nullptr , 0 , nullptr , MZ_COMPRESS_METHOD_STORE, MZ_COMPRESS_LEVEL_FAST);
210
- zipWriteInFileInZip (zippedSaveFile, static_cast <const char *>(buffer), size);
211
- zipCloseFileInZip (zippedSaveFile);
210
+ zipOpenNewFileInZip (zippedSaveFile, (" Save " + layerInfo.name + " .png" ).c_str (), &zfi, nullptr , 0 , nullptr , 0 , nullptr , MZ_COMPRESS_METHOD_STORE, MZ_COMPRESS_LEVEL_FAST);
211
+ zipWriteInFileInZip (zippedSaveFile, static_cast <const char *>(buffer), size);
212
+ zipCloseFileInZip (zippedSaveFile);
212
213
213
- SDL_CloseIO (stream);
214
- }
214
+ SDL_CloseIO (stream);
215
+ });
215
216
216
217
zipClose (zippedSaveFile, fileName.c_str ());
217
218
@@ -301,8 +302,7 @@ bool ActivityMan::LoadAndLaunchGame(const std::string& fileName) {
301
302
}
302
303
}
303
304
304
- if (!unzipFileIntoBuffer (" Save.ini" ))
305
- {
305
+ if (!unzipFileIntoBuffer (" Save.ini" )) {
306
306
RTEError::ShowMessageBox (" Game loading failed! This save looks invalid or corrupted." );
307
307
return false ;
308
308
}
0 commit comments