2222// locking. Was originally called in CGame::Init().
2323static bool sgeLockOff = (sge_Lock_OFF(), true );
2424
25- static Uint16 tilesetIdxForMapType (MapType mapType, bool want32bit);
25+ static unsigned tilesetIdxForMapType (MapType mapType, bool want32bit);
2626
2727namespace {
2828const TerrainDesc* getTerrainDesc (const bobMAP& map, Uint8 rawTextureId)
@@ -1512,7 +1512,7 @@ float CSurface::absf(float a)
15121512}
15131513
15141514// / Map a MapType to the 8-bit or 32-bit tileset bmpArray slot
1515- static Uint16 tilesetIdxForMapType (MapType mapType, bool want32bit)
1515+ static unsigned tilesetIdxForMapType (MapType mapType, bool want32bit)
15161516{
15171517 switch (mapType)
15181518 {
@@ -1538,8 +1538,8 @@ static void rotatePaletteRange(SDL_Palette* pal, uint8_t firstClr, int colorCoun
15381538
15391539void CSurface::UpdatePaletteAnimations (MapType mapType)
15401540{
1541- const Uint16 tilesetIdx8 = tilesetIdxForMapType (mapType, false );
1542- auto animIt = global::paletteAnimations.find (tilesetIdx8);
1541+ const auto tilesetIdx8 = tilesetIdxForMapType (mapType, false );
1542+ auto animIt = global::paletteAnimations.find (static_cast <Uint16>( tilesetIdx8) );
15431543 if (animIt == global::paletteAnimations.end () || animIt->second .empty ())
15441544 return ;
15451545
@@ -1552,15 +1552,15 @@ void CSurface::UpdatePaletteAnimations(MapType mapType)
15521552 (global::s2 && global::s2->getMapObj ()) ? global::s2->getMapObj ()->getSurfacePalette () : nullptr ;
15531553
15541554 // 32-bit tileset surface for blitting after palette updates
1555- const Uint16 tilesetIdx32 = tilesetIdxForMapType (mapType, true );
1556- auto * surf32 = global::bmpArray[tilesetIdx32].surface . get () ;
1555+ const auto tilesetIdx32 = tilesetIdxForMapType (mapType, true );
1556+ auto & surf32 = * global::bmpArray[tilesetIdx32].surface ;
15571557
1558- const Uint32 now = SDL_GetTicks ();
1558+ const unsigned now = SDL_GetTicks ();
15591559 bool anyUpdate = false ;
15601560
15611561 for (auto & [palAnimIdx, anim] : animMap)
15621562 {
1563- if (!anim. isActive || anim.rate == 0 )
1563+ if (anim.rate == 0 )
15641564 continue ;
15651565
15661566 const int colorCount = anim.lastClr - anim.firstClr + 1 ;
@@ -1570,12 +1570,12 @@ void CSurface::UpdatePaletteAnimations(MapType mapType)
15701570 // Time per step: (8192/30) / rate seconds, converted to ms
15711571 const float intervalMs = (8192 .0f / 30 .0f ) * 1000 .0f / anim.rate ;
15721572
1573- const uint32_t elapsed = now - anim.lastUpdateTime ;
1574- if (elapsed < static_cast <uint32_t >(intervalMs))
1573+ const unsigned elapsed = now - anim.lastUpdateTime ;
1574+ if (elapsed < static_cast <unsigned >(intervalMs))
15751575 continue ;
15761576
15771577 int steps = static_cast <int >(elapsed / intervalMs);
1578- anim.lastUpdateTime += static_cast <uint32_t >(steps * intervalMs);
1578+ anim.lastUpdateTime += static_cast <unsigned >(steps * intervalMs);
15791579
15801580 int newOffset = anim.moveUp ? (anim.currentOffset + steps) % colorCount :
15811581 (anim.currentOffset - steps + colorCount * steps) % colorCount;
@@ -1595,16 +1595,13 @@ void CSurface::UpdatePaletteAnimations(MapType mapType)
15951595 return ;
15961596
15971597 // Blit 8-bit tileset to 32-bit so the rotated palette takes effect in 32bpp mode
1598- if (surf32 && surf8)
1599- {
1600- if (SDL_MUSTLOCK (surf32))
1601- SDL_LockSurface (surf32);
1602- if (SDL_MUSTLOCK (surf8))
1603- SDL_LockSurface (surf8);
1604- SDL_BlitSurface (surf8, nullptr , surf32, nullptr );
1605- if (SDL_MUSTLOCK (surf8))
1606- SDL_UnlockSurface (surf8);
1607- if (SDL_MUSTLOCK (surf32))
1608- SDL_UnlockSurface (surf32);
1609- }
1598+ if (SDL_MUSTLOCK (&surf32))
1599+ SDL_LockSurface (&surf32);
1600+ if (SDL_MUSTLOCK (surf8))
1601+ SDL_LockSurface (surf8);
1602+ SDL_BlitSurface (surf8, nullptr , &surf32, nullptr );
1603+ if (SDL_MUSTLOCK (surf8))
1604+ SDL_UnlockSurface (surf8);
1605+ if (SDL_MUSTLOCK (&surf32))
1606+ SDL_UnlockSurface (&surf32);
16101607}
0 commit comments