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();
@ -762,7 +762,7 @@ public:
void QuadsBegin() override;
void QuadsEnd() override;
void TextQuadsBegin() override;
void TextQuadsEnd(int TextureSize, int TextTextureIndex, int TextOutlineTextureIndex, float* pOutlineTextColor) override;
void TextQuadsEnd(int TextureSize, int TextTextureIndex, int TextOutlineTextureIndex, float *pOutlineTextColor) override;
void QuadsEndKeepVertices() override;
void QuadsDrawCurrentVertices(bool KeepVertices = true) override;
void QuadsSetRotation(float Angle) override;
@ -804,13 +804,13 @@ public:
void RenderTileLayer(int BufferContainerIndex, float *pColor, char **pOffsets, unsigned int *IndicedVertexDrawNum, size_t NumIndicesOffet) override;
void RenderBorderTiles(int BufferContainerIndex, float *pColor, char *pIndexBufferOffset, float *pOffset, float *pDir, int JumpIndex, unsigned int DrawNum) override;
void RenderBorderTileLines(int BufferContainerIndex, float *pColor, char *pIndexBufferOffset, float *pOffset, float *pDir, unsigned int IndexDrawNum, unsigned int RedrawNum) override;
void RenderQuadLayer(int BufferContainerIndex, SQuadRenderInfo* pQuadInfo, int QuadNum) override;
void RenderText(int BufferContainerIndex, int TextQuadNum, int TextureSize, int TextureTextIndex, int TextureTextOutlineIndex, float* pTextColor, float* pTextoutlineColor) override;
void RenderQuadLayer(int BufferContainerIndex, SQuadRenderInfo *pQuadInfo, int QuadNum) override;
void RenderText(int BufferContainerIndex, int TextQuadNum, int TextureSize, int TextureTextIndex, int TextureTextOutlineIndex, float *pTextColor, float *pTextoutlineColor) override;
// opengl 3.3 functions
int CreateBufferObject(size_t UploadDataSize, void* pUploadData) override;
void RecreateBufferObject(int BufferIndex, size_t UploadDataSize, void* pUploadData) override;
void UpdateBufferObject(int BufferIndex, size_t UploadDataSize, void* pUploadData, void* pOffset) override;
int CreateBufferObject(size_t UploadDataSize, void *pUploadData) override;
void RecreateBufferObject(int BufferIndex, size_t UploadDataSize, void *pUploadData) override;
void UpdateBufferObject(int BufferIndex, size_t UploadDataSize, void *pUploadData, void *pOffset) override;
void CopyBufferObject(int WriteBufferIndex, int ReadBufferIndex, size_t WriteOffset, size_t ReadOffset, size_t CopyDataSize) override;
void DeleteBufferObject(int BufferIndex) override;

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;
}
}
}
@ -157,7 +157,7 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit
pEntities = "race";
EntitiesModType = MAP_IMAGE_MOD_TYPE_RACE;
}
else if (GameClient()->m_GameInfo.m_EntitiesBW)
else if(GameClient()->m_GameInfo.m_EntitiesBW)
{
pEntities = "blockworlds";
EntitiesModType = MAP_IMAGE_MOD_TYPE_BLOCKWORLDS;
@ -176,7 +176,7 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit
if(!m_EntitiesIsLoaded[EntitiesModType])
{
m_EntitiesIsLoaded[EntitiesModType] = true;
bool WasUnknwon = EntitiesModType == MAP_IMAGE_MOD_TYPE_UNKNOWN;
char aPath[64];
@ -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);
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;
@ -250,11 +250,11 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit
{
if(TileIndex == TILE_SWITCHTIMEDOPEN)
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);
}
}
@ -298,14 +298,14 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit
m_TransparentTexture = Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, pBuildImgData, ImgInfo.m_Format, TextureLoadFlag, aPath);
}
m_EntitiesTextures[EntitiesModType][n] = m_TransparentTexture;
}
}
}
free(pBuildImgData);
}
}
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);
@ -57,7 +58,7 @@ public:
// DDRace
IGraphics::CTextureHandle GetEntities(EMapImageEntityLayerType EntityLayerType);
IGraphics::CTextureHandle GetSpeedupArrow();
IGraphics::CTextureHandle GetOverlayBottom();
IGraphics::CTextureHandle GetOverlayTop();
IGraphics::CTextureHandle GetOverlayCenter();
@ -75,7 +76,7 @@ private:
IGraphics::CTextureHandle m_OverlayCenterTexture;
IGraphics::CTextureHandle m_TransparentTexture;
int m_TextureScale;
void InitOverlayTextures();
IGraphics::CTextureHandle UploadEntityLayerText(int TextureSize, int MaxWidth, int YOffset);
void UpdateEntityLayerText(void* pTexBuffer, int ImageColorChannelCount, int TexWidth, int TexHeight, int TextureSize, int MaxWidth, int YOffset, int NumbersPower, int MaxNumber = -1);

View file

@ -587,18 +587,18 @@ void CMapLayers::OnMapLoad()
{
if(IsGameLayer)
{
Index = ((CTile*)pTiles)[y*pTMap->m_Width+x].m_Index;
Flags = ((CTile*)pTiles)[y*pTMap->m_Width+x].m_Flags;
Index = ((CTile *)pTiles)[y * pTMap->m_Width + x].m_Index;
Flags = ((CTile *)pTiles)[y * pTMap->m_Width + x].m_Flags;
}
if(IsFrontLayer)
{
Index = ((CTile*)pTiles)[y*pTMap->m_Width+x].m_Index;
Flags = ((CTile*)pTiles)[y*pTMap->m_Width+x].m_Flags;
Index = ((CTile *)pTiles)[y * pTMap->m_Width + x].m_Index;
Flags = ((CTile *)pTiles)[y * pTMap->m_Width + x].m_Flags;
}
if(IsSwitchLayer)
{
Flags = 0;
Index = ((CSwitchTile*)pTiles)[y*pTMap->m_Width+x].m_Type;
Index = ((CSwitchTile *)pTiles)[y * pTMap->m_Width + x].m_Type;
if(CurOverlay == 0)
{
Flags = ((CSwitchTile*)pTiles)[y*pTMap->m_Width+x].m_Flags;
@ -624,8 +624,8 @@ void CMapLayers::OnMapLoad()
{
Index = ((CSpeedupTile*)pTiles)[y*pTMap->m_Width+x].m_Type;
Flags = 0;
AngleRotate = ((CSpeedupTile*)pTiles)[y*pTMap->m_Width + x].m_Angle;
if(((CSpeedupTile*)pTiles)[y*pTMap->m_Width+x].m_Force == 0)
AngleRotate = ((CSpeedupTile *)pTiles)[y * pTMap->m_Width + x].m_Angle;
if(((CSpeedupTile *)pTiles)[y * pTMap->m_Width + x].m_Force == 0)
Index = 0;
else if(CurOverlay == 1)
Index = ((CSpeedupTile*)pTiles)[y*pTMap->m_Width+x].m_Force;
@ -634,7 +634,7 @@ void CMapLayers::OnMapLoad()
}
if(IsTuneLayer)
{
Index = ((CTuneTile*)pTiles)[y*pTMap->m_Width+x].m_Type;
Index = ((CTuneTile *)pTiles)[y * pTMap->m_Width + x].m_Type;
Flags = 0;
}
} else

View file

@ -1548,20 +1548,20 @@ void CLayerSpeedup::BrushDraw(CLayer *pBrush, float wx, float wy)
}
else
{
m_pSpeedupTile[fy*m_Width+fx].m_Force = 0;
m_pSpeedupTile[fy*m_Width+fx].m_MaxSpeed = 0;
m_pSpeedupTile[fy*m_Width+fx].m_Angle = 0;
m_pSpeedupTile[fy*m_Width+fx].m_Type = 0;
m_pTiles[fy*m_Width+fx].m_Index = 0;
m_pSpeedupTile[fy * m_Width + fx].m_Force = 0;
m_pSpeedupTile[fy * m_Width + fx].m_MaxSpeed = 0;
m_pSpeedupTile[fy * m_Width + fx].m_Angle = 0;
m_pSpeedupTile[fy * m_Width + fx].m_Type = 0;
m_pTiles[fy * m_Width + fx].m_Index = 0;
}
}
else
{
m_pSpeedupTile[fy*m_Width+fx].m_Force = 0;
m_pSpeedupTile[fy*m_Width+fx].m_MaxSpeed = 0;
m_pSpeedupTile[fy*m_Width+fx].m_Angle = 0;
m_pSpeedupTile[fy*m_Width+fx].m_Type = 0;
m_pTiles[fy*m_Width+fx].m_Index = 0;
m_pSpeedupTile[fy * m_Width + fx].m_Force = 0;
m_pSpeedupTile[fy * m_Width + fx].m_MaxSpeed = 0;
m_pSpeedupTile[fy * m_Width + fx].m_Angle = 0;
m_pSpeedupTile[fy * m_Width + fx].m_Type = 0;
m_pTiles[fy * m_Width + fx].m_Index = 0;
}
}
FlagModified(sx, sy, l->m_Width, l->m_Height);