@ -312,8 +312,8 @@ void DrawMissilePrivate(const Surface &out, const Missile &missile, Point target
return ;
}
int nCel = missile . _miAnimFrame ;
const int frames = LoadLE32 ( missile . _miAnimData ) ;
if ( nCel < 1 | | frames > 50 | | nCel > frames ) {
const u int32_ t frames = LoadLE32 ( missile . _miAnimData ) ;
if ( nCel < 1 | | frames > 50 | | nCel > static_cast < int > ( frames ) ) {
Log ( " Draw Missile 2: frame {} of {}, missile type=={} " , nCel , frames , missile . _mitype ) ;
return ;
}
@ -352,7 +352,7 @@ void DrawMissile(const Surface &out, Point tilePosition, Point targetBufferPosit
*/
void DrawMonster ( const Surface & out , Point tilePosition , Point targetBufferPosition , const Monster & monster )
{
if ( monster . AnimInfo . pCelSprite = = nullptr ) {
if ( ! monster . AnimInfo . celSprite ) {
Log ( " Draw Monster \" {} \" : NULL Cel Buffer " , monster . mName ) ;
return ;
}
@ -419,7 +419,7 @@ void DrawMonster(const Surface &out, Point tilePosition, Point targetBufferPosit
} ;
int nCel = monster . AnimInfo . GetFrameToUseForRendering ( ) ;
const uint32_t frames = LoadLE32 ( monster . AnimInfo . pC elSprite- > Data ( ) ) ;
const uint32_t frames = LoadLE32 ( monster . AnimInfo . c elSprite- > Data ( ) ) ;
if ( nCel < 1 | | frames > 50 | | nCel > static_cast < int > ( frames ) ) {
Log (
" Draw Monster \" {} \" {}: facing {}, frame {} of {} " ,
@ -431,7 +431,7 @@ void DrawMonster(const Surface &out, Point tilePosition, Point targetBufferPosit
return ;
}
const auto & cel = * monster . AnimInfo . pC elSprite;
const auto & cel = * monster . AnimInfo . c elSprite;
if ( ! IsTileLit ( tilePosition ) ) {
Cl2DrawTRN ( out , targetBufferPosition . x , targetBufferPosition . y , cel , nCel , GetInfravisionTRN ( ) ) ;
@ -455,7 +455,7 @@ void DrawMonster(const Surface &out, Point tilePosition, Point targetBufferPosit
*/
void DrawPlayerIconHelper ( const Surface & out , int pnum , missile_graphic_id missileGraphicId , Point position , bool lighting )
{
position . x + = CalculateWidth2 ( Players [ pnum ] . AnimInfo . pC elSprite- > Width ( ) ) - MissileSpriteData [ missileGraphicId ] . animWidth2 ;
position . x + = CalculateWidth2 ( Players [ pnum ] . AnimInfo . c elSprite- > Width ( ) ) - MissileSpriteData [ missileGraphicId ] . animWidth2 ;
int width = MissileSpriteData [ missileGraphicId ] . animWidth ;
const byte * pCelBuff = MissileSpriteData [ missileGraphicId ] . GetFirstFrame ( ) ;
@ -509,22 +509,22 @@ void DrawPlayer(const Surface &out, int pnum, Point tilePosition, Point targetBu
auto & player = Players [ pnum ] ;
const auto * pCelS prite = player . AnimInfo . pC elSprite;
std : : optional < CelSprite > s prite = player . AnimInfo . c elSprite;
int nCel = player . AnimInfo . GetFrameToUseForRendering ( ) ;
if ( player . pP reviewCelSprite ! = nullptr ) {
pCelS prite = player . pP reviewCelSprite ;
if ( player . previewCelSprite ) {
s prite = player . previewCelSprite ;
nCel = 1 ;
}
if ( pCelSprite = = nullptr ) {
if ( ! sprite ) {
Log ( " Drawing player {} \" {} \" : NULL CelSprite " , pnum , player . _pName ) ;
return ;
}
targetBufferPosition - = { CalculateWidth2 ( pCelSprite = = nullptr ? 96 : pCelS prite- > Width ( ) ) , 0 } ;
targetBufferPosition - = { CalculateWidth2 ( sprite ? s prite- > Width ( ) : 96 ) , 0 } ;
int frames = SDL_SwapLE32 ( * reinterpret_cast < const DWORD * > ( pCelS prite- > Data ( ) ) ) ;
int frames = SDL_SwapLE32 ( * reinterpret_cast < const DWORD * > ( s prite- > Data ( ) ) ) ;
if ( nCel < 1 | | frames > 50 | | nCel > frames ) {
const char * szMode = " unknown action " ;
if ( player . _pmode < = PM_QUIT )
@ -541,16 +541,16 @@ void DrawPlayer(const Surface &out, int pnum, Point tilePosition, Point targetBu
}
if ( pnum = = pcursplr )
Cl2DrawOutline ( out , 165 , targetBufferPosition . x , targetBufferPosition . y , * pCelS prite, nCel ) ;
Cl2DrawOutline ( out , 165 , targetBufferPosition . x , targetBufferPosition . y , * s prite, nCel ) ;
if ( pnum = = MyPlayerId ) {
Cl2Draw ( out , targetBufferPosition . x , targetBufferPosition . y , * pCelS prite, nCel ) ;
Cl2Draw ( out , targetBufferPosition . x , targetBufferPosition . y , * s prite, nCel ) ;
DrawPlayerIcons ( out , pnum , targetBufferPosition , true ) ;
return ;
}
if ( ! IsTileLit ( tilePosition ) | | ( Players [ MyPlayerId ] . _pInfraFlag & & LightTableIndex > 8 ) ) {
Cl2DrawTRN ( out , targetBufferPosition . x , targetBufferPosition . y , * pCelS prite, nCel , GetInfravisionTRN ( ) ) ;
Cl2DrawTRN ( out , targetBufferPosition . x , targetBufferPosition . y , * s prite, nCel , GetInfravisionTRN ( ) ) ;
DrawPlayerIcons ( out , pnum , targetBufferPosition , true ) ;
return ;
}
@ -561,7 +561,7 @@ void DrawPlayer(const Surface &out, int pnum, Point tilePosition, Point targetBu
else
LightTableIndex - = 5 ;
Cl2DrawLight ( out , targetBufferPosition . x , targetBufferPosition . y , * pCelS prite, nCel ) ;
Cl2DrawLight ( out , targetBufferPosition . x , targetBufferPosition . y , * s prite, nCel ) ;
DrawPlayerIcons ( out , pnum , targetBufferPosition , false ) ;
LightTableIndex = l ;
@ -581,7 +581,7 @@ void DrawDeadPlayer(const Surface &out, Point tilePosition, Point targetBufferPo
auto & player = Players [ i ] ;
if ( player . plractive & & player . _pHitPoints = = 0 & & player . plrlevel = = ( BYTE ) currlevel & & player . position . tile = = tilePosition ) {
dFlags [ tilePosition . x ] [ tilePosition . y ] | = DungeonFlag : : DeadPlayer ;
const Displacement center { CalculateWidth2 ( player . AnimInfo . pCelSprite = = nullptr ? 96 : player . AnimInfo . pC elSprite- > Width ( ) ) , 0 } ;
const Displacement center { CalculateWidth2 ( player . AnimInfo . celSprite ? player . AnimInfo . c elSprite- > Width ( ) : 96 ) , 0 } ;
const Point playerRenderPosition { targetBufferPosition + player . position . offset - center } ;
DrawPlayer ( out , i , tilePosition , playerRenderPosition ) ;
}
@ -713,15 +713,15 @@ void DrawItem(const Surface &out, Point tilePosition, Point targetBufferPosition
if ( item . _iPostDraw = = pre )
return ;
const auto * cel = item . AnimInfo . pC elSprite;
if ( cel = = nullptr ) {
std : : optional < CelSprite > cel = item . AnimInfo . c elSprite;
if ( ! cel ) {
Log ( " Draw Item \" {} \" 1: NULL CelSprite " , item . _iIName ) ;
return ;
}
int nCel = item . AnimInfo . GetFrameToUseForRendering ( ) ;
int frames = SDL_SwapLE32 ( * ( DWORD * ) cel - > Data ( ) ) ;
if ( nCel < 1 | | frames > 50 | | nCel > frames ) {
const uint32_t frames = LoadLE32 ( cel - > Data ( ) ) ;
if ( nCel < 1 | | frames > 50 | | nCel > static_cast < int > ( frames ) ) {
Log ( " Draw \" {} \" Item 1: frame {} of {}, item type=={} " , item . _iIName , nCel , frames , ItemTypeToString ( item . _itype ) ) ;
return ;
}
@ -750,11 +750,12 @@ void DrawMonsterHelper(const Surface &out, Point tilePosition, Point targetBuffe
auto & towner = Towners [ mi ] ;
int px = targetBufferPosition . x - CalculateWidth2 ( towner . _tAnimWidth ) ;
const Point position { px , targetBufferPosition . y } ;
CelSprite sprite { towner . _tAnimData , towner . _tAnimWidth } ;
if ( mi = = pcursmonst ) {
CelBlitOutlineTo ( out , 166 , position , CelSprite ( towne r. _tAn imDa ta , town er . _tAnimWidth ) , towner . _tAnimFrame ) ;
CelBlitOutlineTo ( out , 166 , position , sp rite, towner . _tAnimFrame ) ;
}
assert ( towner . _tAnimData ) ;
CelClippedDrawTo ( out , position , CelSprite ( towne r. _tAn imDa ta , town er . _tAnimWidth ) , towner . _tAnimFrame ) ;
CelClippedDrawTo ( out , position , sp rite, towner . _tAnimFrame ) ;
return ;
}
@ -776,7 +777,7 @@ void DrawMonsterHelper(const Surface &out, Point tilePosition, Point targetBuffe
return ;
}
const CelSprite & cel = * monster . AnimInfo . pC elSprite;
CelSprite cel = * monster . AnimInfo . c elSprite;
Displacement offset = monster . position . offset ;
if ( monster . IsWalking ( ) ) {