Fix some style issues via scripts/fix_style.py, size_t

This commit is contained in:
heinrich5991 2020-09-11 00:42:42 +02:00
parent 1e1c16f83a
commit aa46ca6bf9
7 changed files with 65 additions and 64 deletions

View file

@ -555,12 +555,12 @@ int CGraphics_Threaded::LoadPNG(CImageInfo *pImg, const char *pFilename, int Sto
return 1;
}
void CGraphics_Threaded::CopyTextureBufferSub(uint8_t* pDestBuffer, uint8_t* pSourceBuffer, size_t FullWidth, size_t FullHeight, size_t ColorChannelCount, size_t SubOffsetX, size_t SubOffsetY, size_t SubCopyWidth, size_t SubCopyHeight)
void CGraphics_Threaded::CopyTextureBufferSub(uint8_t *pDestBuffer, uint8_t *pSourceBuffer, int FullWidth, int FullHeight, int ColorChannelCount, int SubOffsetX, int SubOffsetY, int SubCopyWidth, int SubCopyHeight)
{
for(size_t Y = 0; Y < SubCopyHeight; ++Y)
for(int Y = 0; Y < SubCopyHeight; ++Y)
{
size_t ImgOffset = ((SubOffsetY + Y) * FullWidth * ColorChannelCount) + (SubOffsetX * ColorChannelCount);
size_t CopySize = SubCopyWidth * ColorChannelCount;
int ImgOffset = ((SubOffsetY + Y) * FullWidth * ColorChannelCount) + (SubOffsetX * ColorChannelCount);
int CopySize = SubCopyWidth * ColorChannelCount;
mem_copy(&pDestBuffer[ImgOffset], &pSourceBuffer[ImgOffset], CopySize);
}
}

View file

@ -751,7 +751,7 @@ public:
IGraphics::CTextureHandle LoadTexture(const char *pFilename, int StorageType, int StoreFormat, int Flags) override;
int LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType) override;
void CopyTextureBufferSub(uint8_t* pDestBuffer, uint8_t* pSourceBuffer, size_t FullWidth, size_t FullHeight, size_t ColorChannelCount, size_t SubOffsetX, size_t SubOffsetY, size_t SubCopyWidth, size_t SubCopyHeight) override;
void CopyTextureBufferSub(uint8_t *pDestBuffer, uint8_t *pSourceBuffer, int FullWidth, int FullHeight, int ColorChannelCount, int SubOffsetX, int SubOffsetY, int SubCopyWidth, int SubCopyHeight) override;
void ScreenshotDirect();

View file

@ -194,7 +194,7 @@ public:
virtual int LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType) = 0;
// destination and source buffer require to have the same width and height
virtual void CopyTextureBufferSub(uint8_t* pDestBuffer, uint8_t* pSourceBuffer, size_t FullWidth, size_t FullHeight, size_t ColorChannelCount, size_t SubOffsetX, size_t SubOffsetY, size_t SubCopyWidth, size_t SubCopyHeight) = 0;
virtual void CopyTextureBufferSub(uint8_t *pDestBuffer, uint8_t *pSourceBuffer, int FullWidth, int FullHeight, int ColorChannelCount, int SubOffsetX, int SubOffsetY, int SubCopyWidth, int SubCopyHeight) = 0;
virtual int UnloadTexture(CTextureHandle Index) = 0;
virtual CTextureHandle LoadTextureRaw(int Width, int Height, int Format, const void *pData, int StoreFormat, int Flags, const char *pTexName = NULL) = 0;

View file

@ -59,7 +59,7 @@ void CMapImages::OnMapLoadImpl(class CLayers *pLayers, IMap *pMap)
CMapItemLayerTilemap *pTLayer = (CMapItemLayerTilemap *)pLayer;
if(pTLayer->m_Image != -1 && pTLayer->m_Image < (int)(sizeof(m_aTextures) / sizeof(m_aTextures[0])))
{
m_aTextureUsedByTileOrQuadLayerFlag[(size_t)pTLayer->m_Image] |= 1;
m_aTextureUsedByTileOrQuadLayerFlag[pTLayer->m_Image] |= 1;
}
}
else if(pLayer->m_Type == LAYERTYPE_QUADS)
@ -67,7 +67,7 @@ void CMapImages::OnMapLoadImpl(class CLayers *pLayers, IMap *pMap)
CMapItemLayerQuads *pQLayer = (CMapItemLayerQuads *)pLayer;
if(pQLayer->m_Image != -1 && pQLayer->m_Image < (int)(sizeof(m_aTextures) / sizeof(m_aTextures[0])))
{
m_aTextureUsedByTileOrQuadLayerFlag[(size_t)pQLayer->m_Image] |= 2;
m_aTextureUsedByTileOrQuadLayerFlag[pQLayer->m_Image] |= 2;
}
}
}
@ -193,7 +193,7 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit
CImageInfo ImgInfo;
if(Graphics()->LoadPNG(&ImgInfo, aPath, IStorage::TYPE_ALL) && ImgInfo.m_Width > 0 && ImgInfo.m_Height > 0)
{
size_t ColorChannelCount = 0;
int ColorChannelCount = 0;
if(ImgInfo.m_Format == CImageInfo::FORMAT_ALPHA)
ColorChannelCount = 1;
else if(ImgInfo.m_Format == CImageInfo::FORMAT_RGB)
@ -201,48 +201,48 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit
else if(ImgInfo.m_Format == CImageInfo::FORMAT_RGBA)
ColorChannelCount = 4;
size_t BuildImageSize = ColorChannelCount * (size_t)ImgInfo.m_Width * (size_t)ImgInfo.m_Height;
int BuildImageSize = ColorChannelCount * ImgInfo.m_Width * ImgInfo.m_Height;
uint8_t *pTmpImgData = (uint8_t *)ImgInfo.m_pData;
uint8_t *pBuildImgData = (uint8_t *)malloc(BuildImageSize);
// build game layer
for(size_t n = 0; n < MAP_IMAGE_ENTITY_LAYER_TYPE_COUNT; ++n)
for(int n = 0; n < MAP_IMAGE_ENTITY_LAYER_TYPE_COUNT; ++n)
{
bool BuildThisLayer = true;
if(n == (size_t)MAP_IMAGE_ENTITY_LAYER_TYPE_FRONT && !GameTypeHasFrontLayer)
if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_FRONT && !GameTypeHasFrontLayer)
BuildThisLayer = false;
else if(n == (size_t)MAP_IMAGE_ENTITY_LAYER_TYPE_SPEEDUP && !GameTypeHasSpeedupLayer)
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_SPEEDUP && !GameTypeHasSpeedupLayer)
BuildThisLayer = false;
else if(n == (size_t)MAP_IMAGE_ENTITY_LAYER_TYPE_SWITCH && !GameTypeHasSwitchLayer)
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_SWITCH && !GameTypeHasSwitchLayer)
BuildThisLayer = false;
else if(n == (size_t)MAP_IMAGE_ENTITY_LAYER_TYPE_TELE && !GameTypeHasTeleLayer)
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_TELE && !GameTypeHasTeleLayer)
BuildThisLayer = false;
else if(n == (size_t)MAP_IMAGE_ENTITY_LAYER_TYPE_TUNE && !GameTypeHasTuneLayer)
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_TUNE && !GameTypeHasTuneLayer)
BuildThisLayer = false;
dbg_assert(m_EntitiesTextures[EntitiesModType][n] == -1, "This should not happen.");
dbg_assert(m_EntitiesTextures[EntitiesModType][n] == -1, "entities texture already loaded when it should not be");
if(BuildThisLayer)
{
// set everything transparent
mem_zero(pBuildImgData, BuildImageSize);
for(size_t i = 0; i < 256; ++i)
for(int i = 0; i < 256; ++i)
{
bool ValidTile = i != 0;
size_t TileIndex = i;
int TileIndex = i;
if(EntitiesModType == MAP_IMAGE_MOD_TYPE_DDNET || EntitiesModType == MAP_IMAGE_MOD_TYPE_DDRACE)
{
if(EntitiesModType == MAP_IMAGE_MOD_TYPE_DDNET || TileIndex != TILE_BOOST)
{
if(n == (size_t)MAP_IMAGE_ENTITY_LAYER_TYPE_GAME && !IsValidGameTile((int)TileIndex))
if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_GAME && !IsValidGameTile((int)TileIndex))
ValidTile = false;
else if(n == (size_t)MAP_IMAGE_ENTITY_LAYER_TYPE_FRONT && !IsValidFrontTile((int)TileIndex))
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_FRONT && !IsValidFrontTile((int)TileIndex))
ValidTile = false;
else if(n == (size_t)MAP_IMAGE_ENTITY_LAYER_TYPE_SPEEDUP && !IsValidSpeedupTile((int)TileIndex))
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_SPEEDUP && !IsValidSpeedupTile((int)TileIndex))
ValidTile = false;
else if(n == (size_t)MAP_IMAGE_ENTITY_LAYER_TYPE_SWITCH)
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_SWITCH)
{
if(!IsValidSwitchTile((int)TileIndex))
ValidTile = false;
@ -252,9 +252,9 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit
TileIndex = 8;
}
}
else if(n == (size_t)MAP_IMAGE_ENTITY_LAYER_TYPE_TELE && !IsValidTeleTile((int)TileIndex))
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_TELE && !IsValidTeleTile((int)TileIndex))
ValidTile = false;
else if(n == (size_t)MAP_IMAGE_ENTITY_LAYER_TYPE_TUNE && !IsValidTuneTile((int)TileIndex))
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_TUNE && !IsValidTuneTile((int)TileIndex))
ValidTile = false;
}
}
@ -275,14 +275,14 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit
ValidTile = false;
}*/
size_t X = TileIndex % 16;
size_t Y = TileIndex / 16;
int X = TileIndex % 16;
int Y = TileIndex / 16;
size_t CopyWidth = (size_t)ImgInfo.m_Width / 16;
size_t CopyHeight = (size_t)ImgInfo.m_Height / 16;
int CopyWidth = ImgInfo.m_Width / 16;
int CopyHeight = ImgInfo.m_Height / 16;
if(ValidTile)
{
Graphics()->CopyTextureBufferSub(pBuildImgData, pTmpImgData, (size_t)ImgInfo.m_Width, (size_t)ImgInfo.m_Height, ColorChannelCount, X * CopyWidth, Y * CopyHeight, CopyWidth, CopyHeight);
Graphics()->CopyTextureBufferSub(pBuildImgData, pTmpImgData, ImgInfo.m_Width, ImgInfo.m_Height, ColorChannelCount, X * CopyWidth, Y * CopyHeight, CopyWidth, CopyHeight);
}
}
@ -305,7 +305,7 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit
}
}
return m_EntitiesTextures[EntitiesModType][(size_t)EntityLayerType];
return m_EntitiesTextures[EntitiesModType][EntityLayerType];
}
IGraphics::CTextureHandle CMapImages::GetSpeedupArrow()

View file

@ -42,6 +42,7 @@ class CMapImages : public CComponent
bool HasSwitchLayer();
bool HasTeleLayer();
bool HasTuneLayer();
public:
CMapImages();
CMapImages(int ImageSize);