@@ -63,7 +63,7 @@ void ContentFile::FreeAllLoaded() {
6363int ContentFile::ReadProperty (const std::string_view& propName, Reader& reader) {
6464 StartPropertyList (return Serializable::ReadProperty (propName, reader));
6565
66- MatchForwards (" FilePath" )
66+ MatchForwards (" FilePath" )
6767 MatchProperty (" Path" , { SetDataPath (reader.ReadPropValue ()); });
6868 MatchProperty (" IsMemoryPNG" , { reader >> m_IsMemoryPNG; });
6969
@@ -249,8 +249,8 @@ BITMAP* ContentFile::GetAsBitmap(int conversionMode, bool storeBitmap, const std
249249 SDL_DestroySurface (surface);
250250 s_MemoryPNGs.erase (dataPathToLoad);
251251 }
252- }
253-
252+ }
253+
254254 if (returnBitmap == nullptr ) {
255255 if (!System::PathExistsCaseSensitive (dataPathToLoad)) {
256256 const std::string dataPathWithoutExtension = dataPathToLoad.substr (0 , dataPathToLoad.length () - m_DataPathExtension.length ());
@@ -302,11 +302,19 @@ void ContentFile::GetAsAnimation(std::vector<BITMAP*>& vectorToFill, int frameCo
302302 }
303303 }
304304}
305- SDL_Palette* ContentFile::DefaultPaletteToSDL () {
305+ SDL_Palette* ContentFile::DefaultPaletteToSDL (bool preMask ) {
306306 SDL_Palette* palette = SDL_CreatePalette (256 );
307307 std::array<SDL_Color, 256 > paletteColor;
308308 const PALETTE& defaultPalette = g_FrameMan.GetDefaultPalette ();
309- paletteColor[0 ] = {.r = 0 , .g = 0 , .b = 0 , .a = 0 };
309+ if (preMask) {
310+ paletteColor[0 ] = {.r = 0 , .g = 0 , .b = 0 , .a = 0 };
311+ } else {
312+ paletteColor[0 ] = {.r = defaultPalette[0 ].r ,
313+ .g = defaultPalette[0 ].g ,
314+ .b = defaultPalette[0 ].b ,
315+ .a = 255
316+ };
317+ }
310318 for (size_t i = 1 ; i < paletteColor.size (); ++i) {
311319 paletteColor[i].r = defaultPalette[i].r ;
312320 paletteColor[i].g = defaultPalette[i].g ;
@@ -330,7 +338,7 @@ SDL_Surface* ContentFile::LoadImageAsSurface(int conversionMode, const std::stri
330338 image = newImage;
331339 bitDepth = 8 ;
332340 } else if (bitDepth != 8 || convert8To32) {
333- SDL_Palette* palette = DefaultPaletteToSDL ();
341+ SDL_Palette* palette = DefaultPaletteToSDL (true );
334342 if (SDL_GetPixelFormatDetails (image->format )->bits_per_pixel == 8 ) {
335343 SDL_SetSurfacePalette (image, palette);
336344 SDL_SetSurfaceColorKey (image, true , 0 );
@@ -391,7 +399,7 @@ FMOD::Sound* ContentFile::LoadAndReleaseSound(bool abortGameForInvalidSound, boo
391399 }
392400 if (!System::PathExistsCaseSensitive (m_DataPath)) {
393401 bool foundAltExtension = false ;
394- for (const std::string& altFileExtension: c_SupportedAudioFormats) {
402+ for (const char * altFileExtension: c_SupportedAudioFormats) {
395403 const std::string altDataPathToLoad = m_DataPathWithoutExtension + altFileExtension;
396404 if (System::PathExistsCaseSensitive (altDataPathToLoad)) {
397405 g_ConsoleMan.AddLoadWarningLogExtensionMismatchEntry (m_DataPath, m_FormattedReaderPosition, altFileExtension);
@@ -443,15 +451,14 @@ void ContentFile::ReloadBitmap(const std::string& filePath, int conversionMode)
443451
444452 SDL_Surface* newImage = LoadImageAsSurface (conversionMode, filePath);
445453
446-
447454 BITMAP* newBitmap = create_bitmap_ex (SDL_GetPixelFormatDetails (newImage->format )->bits_per_pixel , newImage->w , newImage->h );
448455
449456 // allegro doesn't (always) align lines to 4byte, so copy line by line. SDL_Surface.pitch is the size in bytes per line + alignment padding.
450457 for (int y = 0 ; y < newImage->h ; y++) {
451- memcpy (newBitmap->line [y], static_cast <unsigned char *>(newImage->pixels ) + y * newImage->pitch , newImage->w * SDL_GetPixelFormatDetails (newImage->format )->bytes_per_pixel );
458+ memcpy (newBitmap->line [y], static_cast <unsigned char *>(newImage->pixels ) + y * newImage->pitch , newImage->w * SDL_GetPixelFormatDetails (newImage->format )->bytes_per_pixel );
452459 }
453460
454- // AddAlphaChannel(newBitmap);
461+ // AddAlphaChannel(newBitmap);
455462 BITMAP swap;
456463
457464 std::memcpy (&swap, loadedBitmap, sizeof (BITMAP));
0 commit comments