mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 06:28:19 +00:00
fix code pattern mistakes and warnings
This commit is contained in:
parent
b328457e81
commit
463944b143
|
@ -521,7 +521,8 @@ void CCommandProcessorFragment_OpenGL3_3::SetState(const CCommandBuffer::SState
|
|||
glBindTexture(GL_TEXTURE_2D, m_aTextures[State.m_Texture].m_Tex);
|
||||
glBindSampler(Slot, m_aTextures[State.m_Texture].m_Sampler);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
Slot = 0;
|
||||
glBindTexture(GL_TEXTURE_2D, m_aTextures[State.m_Texture].m_Tex);
|
||||
glBindSampler(Slot, m_aTextures[State.m_Texture].m_Sampler);
|
||||
|
@ -547,7 +548,8 @@ void CCommandProcessorFragment_OpenGL3_3::SetState(const CCommandBuffer::SState
|
|||
m_TextureSlotBoundToUnit[Slot].m_LastWrapMode = State.m_WrapMode;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
if(pProgram->m_LocIsTextured != -1) pProgram->SetUniform(pProgram->m_LocIsTextured, (int)0);
|
||||
}
|
||||
|
||||
|
@ -798,7 +800,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Shutdown(const SCommand_Shutdown *
|
|||
DestroyTexture(i);
|
||||
}
|
||||
|
||||
for(int i = 0; i < m_VisualObjects.size(); ++i)
|
||||
for(size_t i = 0; i < m_VisualObjects.size(); ++i)
|
||||
{
|
||||
DestroyVisualObjects(i);
|
||||
}
|
||||
|
@ -1073,7 +1075,8 @@ bool CCommandProcessorFragment_OpenGL3_3::RunCommand(const CCommandBuffer::SComm
|
|||
bool CCommandProcessorFragment_OpenGL3_3::IsAndUpdateTextureSlotBound(int IDX, int Slot)
|
||||
{
|
||||
if(m_TextureSlotBoundToUnit[IDX].m_TextureSlot == Slot) return true;
|
||||
else {
|
||||
else
|
||||
{
|
||||
//the texture slot uses this index now
|
||||
m_TextureSlotBoundToUnit[IDX].m_TextureSlot = Slot;
|
||||
m_TextureSlotBoundToUnit[IDX].m_LastWrapMode = -1;
|
||||
|
@ -1108,7 +1111,7 @@ void CCommandProcessorFragment_OpenGL3_3::AppendIndices(unsigned int NewIndicesC
|
|||
unsigned int AddCount = NewIndicesCount - m_CurrentIndicesInBuffer;
|
||||
unsigned int* Indices = new unsigned int[AddCount];
|
||||
int Primq = (m_CurrentIndicesInBuffer/6) * 4;
|
||||
for(int i = 0; i < AddCount; i+=6)
|
||||
for(unsigned int i = 0; i < AddCount; i+=6)
|
||||
{
|
||||
Indices[i] = Primq;
|
||||
Indices[i+1] = Primq + 1;
|
||||
|
@ -1142,7 +1145,7 @@ void CCommandProcessorFragment_OpenGL3_3::AppendIndices(unsigned int NewIndicesC
|
|||
void CCommandProcessorFragment_OpenGL3_3::Cmd_DestroyVertexArray(const CCommandBuffer::SCommand_DestroyVisual *pCommand)
|
||||
{
|
||||
int Index = pCommand->m_VisualObjectIDX;
|
||||
if(Index >= m_VisualObjects.size())
|
||||
if((size_t)Index >= m_VisualObjects.size())
|
||||
return;
|
||||
|
||||
DestroyVisualObjects(Index);
|
||||
|
@ -1152,7 +1155,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderBorderTile(const CCommandBuf
|
|||
{
|
||||
int Index = pCommand->m_VisualObjectIDX;
|
||||
//if space not there return
|
||||
if(Index >= m_VisualObjects.size())
|
||||
if((size_t)Index >= m_VisualObjects.size())
|
||||
return;
|
||||
|
||||
SVisualObject& VisualObject = m_VisualObjects[Index];
|
||||
|
@ -1183,7 +1186,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderBorderTileLine(const CComman
|
|||
{
|
||||
int Index = pCommand->m_VisualObjectIDX;
|
||||
//if space not there return
|
||||
if(Index >= m_VisualObjects.size())
|
||||
if((size_t)Index >= m_VisualObjects.size())
|
||||
return;
|
||||
|
||||
SVisualObject& VisualObject = m_VisualObjects[Index];
|
||||
|
@ -1211,7 +1214,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderVertexArray(const CCommandBu
|
|||
{
|
||||
int Index = pCommand->m_VisualObjectIDX;
|
||||
//if space not there return
|
||||
if(Index >= m_VisualObjects.size())
|
||||
if((size_t)Index >= m_VisualObjects.size())
|
||||
return;
|
||||
|
||||
SVisualObject& VisualObject = m_VisualObjects[Index];
|
||||
|
@ -1249,7 +1252,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_CreateVertBuffer(const CCommandBuf
|
|||
{
|
||||
int Index = pCommand->m_VisualObjectIDX;
|
||||
//create necessary space
|
||||
if(Index >= m_VisualObjects.size())
|
||||
if((size_t)Index >= m_VisualObjects.size())
|
||||
{
|
||||
for(int i = m_VisualObjects.size(); i < Index + 1; ++i)
|
||||
{
|
||||
|
@ -1274,7 +1277,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_AppendVertBuffer(const CCommandBuf
|
|||
int Index = pCommand->m_VisualObjectIDX;
|
||||
|
||||
//if space not there return
|
||||
if(Index >= m_VisualObjects.size())
|
||||
if((size_t)Index >= m_VisualObjects.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1302,7 +1305,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_CreateVertArray(const CCommandBuff
|
|||
{
|
||||
int Index = pCommand->m_VisualObjectIDX;
|
||||
//if space not there return
|
||||
if(Index >= m_VisualObjects.size())
|
||||
if((size_t)Index >= m_VisualObjects.size())
|
||||
return;
|
||||
|
||||
if(pCommand->m_RequiredIndicesCount > m_CurrentIndicesInBuffer)
|
||||
|
@ -1691,7 +1694,9 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt
|
|||
CmdBuffer.AddCommand(CmdOpenGL);
|
||||
RunBuffer(&CmdBuffer);
|
||||
WaitForIdle();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CCommandProcessorFragment_OpenGL::SCommand_Init CmdOpenGL;
|
||||
CmdOpenGL.m_pTextureMemoryUsage = &m_TextureMemoryUsage;
|
||||
CmdBuffer.AddCommand(CmdOpenGL);
|
||||
|
|
|
@ -565,7 +565,8 @@ void CGraphics_Threaded::QuadsSetRotation(float Angle)
|
|||
m_Rotation = Angle;
|
||||
}
|
||||
|
||||
inline void clampf(float& Value, float Min, float Max){
|
||||
inline void clampf(float& Value, float Min, float Max)
|
||||
{
|
||||
if(Value > Max) Value = Max;
|
||||
else if(Value < Min) Value = Min;
|
||||
}
|
||||
|
@ -1023,7 +1024,9 @@ int CGraphics_Threaded::CreateVisualObjects(float* pVertices, unsigned char* pTe
|
|||
{
|
||||
index = m_VertexArrayIndices.size();
|
||||
m_VertexArrayIndices.push_back(index);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
index = m_FirstFreeVertexArrayIndex;
|
||||
m_FirstFreeVertexArrayIndex = m_VertexArrayIndices[index];
|
||||
m_VertexArrayIndices[index] = index;
|
||||
|
|
|
@ -4,18 +4,20 @@
|
|||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
bool CGLSL::LoadShader(const char* pFile, int Type) {
|
||||
bool CGLSL::LoadShader(const char* pFile, int Type)
|
||||
{
|
||||
if (m_IsLoaded) return true;
|
||||
IOHANDLE f;
|
||||
f = io_open(pFile, IOFLAG_READ);
|
||||
|
||||
std::vector<std::string> Lines;
|
||||
char buff[500];
|
||||
if (f) {
|
||||
if (f)
|
||||
{
|
||||
CLineReader LineReader;
|
||||
LineReader.Init(f);
|
||||
char* ReadLine = NULL;
|
||||
while ((ReadLine = LineReader.Get())) {
|
||||
while ((ReadLine = LineReader.Get()))
|
||||
{
|
||||
Lines.push_back(ReadLine);
|
||||
Lines.back().append("\r\n");
|
||||
}
|
||||
|
@ -23,7 +25,8 @@ bool CGLSL::LoadShader(const char* pFile, int Type) {
|
|||
|
||||
const char** ShaderCode = new const char*[Lines.size()];
|
||||
|
||||
for (int i = 0; i < Lines.size(); ++i) {
|
||||
for (size_t i = 0; i < Lines.size(); ++i)
|
||||
{
|
||||
ShaderCode[i] = Lines[i].c_str();
|
||||
}
|
||||
|
||||
|
@ -37,7 +40,8 @@ bool CGLSL::LoadShader(const char* pFile, int Type) {
|
|||
int CompilationStatus;
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &CompilationStatus);
|
||||
|
||||
if (CompilationStatus == GL_FALSE) {
|
||||
if (CompilationStatus == GL_FALSE)
|
||||
{
|
||||
char buff[3000];
|
||||
|
||||
GLint maxLength = 0;
|
||||
|
@ -60,24 +64,29 @@ bool CGLSL::LoadShader(const char* pFile, int Type) {
|
|||
|
||||
}
|
||||
|
||||
void CGLSL::DeleteShader() {
|
||||
void CGLSL::DeleteShader()
|
||||
{
|
||||
if (!IsLoaded()) return;
|
||||
m_IsLoaded = false;
|
||||
glDeleteShader(m_ShaderID);
|
||||
}
|
||||
|
||||
bool CGLSL::IsLoaded() {
|
||||
bool CGLSL::IsLoaded()
|
||||
{
|
||||
return m_IsLoaded;
|
||||
}
|
||||
|
||||
GLuint CGLSL::GetShaderID() {
|
||||
GLuint CGLSL::GetShaderID()
|
||||
{
|
||||
return m_ShaderID;
|
||||
}
|
||||
|
||||
CGLSL::CGLSL(){
|
||||
CGLSL::CGLSL()
|
||||
{
|
||||
m_IsLoaded = false;
|
||||
}
|
||||
|
||||
CGLSL::~CGLSL(){
|
||||
CGLSL::~CGLSL()
|
||||
{
|
||||
DeleteShader();
|
||||
}
|
|
@ -57,7 +57,8 @@ void CGLSLProgram::LinkProgram()
|
|||
DetachAllShaders();
|
||||
}
|
||||
|
||||
void CGLSLProgram::DetachAllShaders(){
|
||||
void CGLSLProgram::DetachAllShaders()
|
||||
{
|
||||
GLuint aShaders[100];
|
||||
GLsizei ReturnedCount = 0;
|
||||
while(1)
|
||||
|
|
|
@ -772,7 +772,8 @@ public:
|
|||
MinSize = 8;
|
||||
FontSize = MinSize;
|
||||
|
||||
while(!FoundMaxFontSize){
|
||||
while(!FoundMaxFontSize)
|
||||
{
|
||||
int WidthOfText = 0;
|
||||
|
||||
while(pCurrent < pEnd)
|
||||
|
@ -828,7 +829,7 @@ public:
|
|||
int MaxSize = (MaxWidth - WidthLastChars);
|
||||
if (MaxSize > 0)
|
||||
{
|
||||
int SlotW = (MaxSize < pBitmap->width ? MaxSize : pBitmap->width);
|
||||
int SlotW = ((unsigned int)MaxSize < pBitmap->width ? MaxSize : pBitmap->width);
|
||||
int SlotH = pBitmap->rows;
|
||||
int SlotSize = SlotW*SlotH;
|
||||
|
||||
|
|
|
@ -335,11 +335,13 @@ bool CMapLayers::STileLayerVisuals::Init(unsigned int Width, unsigned int Height
|
|||
m_TilesOfLayer[i] = new CMapLayers::STileLayerVisuals::STileVisual[Width];
|
||||
}
|
||||
|
||||
if(Width > 2) {
|
||||
if(Width > 2)
|
||||
{
|
||||
m_BorderTop = new CMapLayers::STileLayerVisuals::STileVisual[Width-2];
|
||||
m_BorderBottom = new CMapLayers::STileLayerVisuals::STileVisual[Width-2];
|
||||
}
|
||||
if(Height > 2) {
|
||||
if(Height > 2)
|
||||
{
|
||||
m_BorderLeft = new CMapLayers::STileLayerVisuals::STileVisual[Height-2];
|
||||
m_BorderRight = new CMapLayers::STileLayerVisuals::STileVisual[Height-2];
|
||||
}
|
||||
|
@ -348,7 +350,8 @@ bool CMapLayers::STileLayerVisuals::Init(unsigned int Width, unsigned int Height
|
|||
|
||||
CMapLayers::STileLayerVisuals::~STileLayerVisuals()
|
||||
{
|
||||
if(m_TilesOfLayer) {
|
||||
if(m_TilesOfLayer)
|
||||
{
|
||||
for(unsigned int i = 0; i < m_Height; ++i)
|
||||
{
|
||||
delete[] m_TilesOfLayer[i];
|
||||
|
@ -485,7 +488,7 @@ void CMapLayers::OnMapLoad()
|
|||
|
||||
|
||||
int DataIndex = 0;
|
||||
int TileSize = 0;
|
||||
unsigned int TileSize = 0;
|
||||
int OverlayCount = 0;
|
||||
if (IsFrontLayer)
|
||||
{
|
||||
|
@ -830,17 +833,17 @@ void CMapLayers::RenderTileLayer(int LayerIndex, vec4* pColor, CMapItemLayerTile
|
|||
if(DrawLayer)
|
||||
{
|
||||
//create the indice buffers we want to draw -- reuse them
|
||||
static std::vector<char*> IndexOffsets;
|
||||
static std::vector<unsigned int> DrawCounts;
|
||||
static unsigned long long maxRes = (IndexOffsets.max_size() > DrawCounts.max_size() ? DrawCounts.max_size() : IndexOffsets.max_size());
|
||||
static std::vector<char*> s_IndexOffsets;
|
||||
static std::vector<unsigned int> s_DrawCounts;
|
||||
static unsigned long long s_MaxRes = (s_IndexOffsets.max_size() > s_DrawCounts.max_size() ? s_DrawCounts.max_size() : s_IndexOffsets.max_size());
|
||||
|
||||
IndexOffsets.clear();
|
||||
DrawCounts.clear();
|
||||
s_IndexOffsets.clear();
|
||||
s_DrawCounts.clear();
|
||||
|
||||
unsigned long long Reserve = absolute(Y1 - Y0) + 1;
|
||||
if(Reserve > maxRes) Reserve = maxRes;
|
||||
IndexOffsets.reserve(Reserve);
|
||||
DrawCounts.reserve(Reserve);
|
||||
if(Reserve > s_MaxRes) Reserve = s_MaxRes;
|
||||
s_IndexOffsets.reserve(Reserve);
|
||||
s_DrawCounts.reserve(Reserve);
|
||||
|
||||
for(int y = Y0; y <= Y1; ++y)
|
||||
{
|
||||
|
@ -850,9 +853,10 @@ void CMapLayers::RenderTileLayer(int LayerIndex, vec4* pColor, CMapItemLayerTile
|
|||
|
||||
unsigned int NumVertices = (Visuals.m_TilesOfLayer[y][X1].m_TilesHandledCount - Visuals.m_TilesOfLayer[y][X0].m_TilesHandledCount) * 6lu + (Visuals.m_TilesOfLayer[y][X1].m_Draw ? 6lu : 0lu);
|
||||
|
||||
if(NumVertices) {
|
||||
IndexOffsets.push_back(Visuals.m_TilesOfLayer[y][X0].m_IndexBufferByteOffset);
|
||||
DrawCounts.push_back(NumVertices);
|
||||
if(NumVertices)
|
||||
{
|
||||
s_IndexOffsets.push_back(Visuals.m_TilesOfLayer[y][X0].m_IndexBufferByteOffset);
|
||||
s_DrawCounts.push_back(NumVertices);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -861,9 +865,10 @@ void CMapLayers::RenderTileLayer(int LayerIndex, vec4* pColor, CMapItemLayerTile
|
|||
pColor->z *= b;
|
||||
pColor->w *= a;
|
||||
|
||||
int DrawCount = IndexOffsets.size();
|
||||
if(DrawCount != 0) {
|
||||
Graphics()->DrawVisualObject(Visuals.m_VisualObjectsIndex, (float*)pColor, &IndexOffsets[0], &DrawCounts[0], DrawCount);
|
||||
int DrawCount = s_IndexOffsets.size();
|
||||
if(DrawCount != 0)
|
||||
{
|
||||
Graphics()->DrawVisualObject(Visuals.m_VisualObjectsIndex, (float*)pColor, &s_IndexOffsets[0], &s_DrawCounts[0], DrawCount);
|
||||
}
|
||||
}
|
||||
if(DrawBorder) DrawTileBorder(LayerIndex, pColor, pTileLayer, pGroup, BorderX0, BorderY0, BorderX1, BorderY1);
|
||||
|
@ -1150,7 +1155,7 @@ int CMapLayers::TileLayersOfGroup(CMapItemGroup* pGroup)
|
|||
{
|
||||
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
||||
int DataIndex = 0;
|
||||
int TileSize = 0;
|
||||
unsigned int TileSize = 0;
|
||||
int TileLayerAndOverlayCount = 0;
|
||||
if (IsFrontLayer)
|
||||
{
|
||||
|
@ -1330,7 +1335,7 @@ void CMapLayers::OnRender()
|
|||
{
|
||||
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
||||
int DataIndex = 0;
|
||||
int TileSize = 0;
|
||||
unsigned int TileSize = 0;
|
||||
int TileLayerAndOverlayCount = 0;
|
||||
if (IsFrontLayer)
|
||||
{
|
||||
|
@ -1491,7 +1496,9 @@ void CMapLayers::OnRender()
|
|||
Graphics()->BlendNormal();
|
||||
RenderTools()->RenderTilemap(pFrontTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT,
|
||||
EnvelopeEval, this, pTMap->m_ColorEnv, pTMap->m_ColorEnvOffset);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Graphics()->BlendNormal();
|
||||
RenderTileLayer(TileLayerCounter-1, &Color, pTMap, pGroup);
|
||||
}
|
||||
|
@ -1515,7 +1522,9 @@ void CMapLayers::OnRender()
|
|||
Graphics()->BlendNormal();
|
||||
RenderTools()->RenderSwitchmap(pSwitchTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT);
|
||||
RenderTools()->RenderSwitchOverlay(pSwitchTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, g_Config.m_ClOverlayEntities/100.0f);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Graphics()->BlendNormal();
|
||||
RenderTileLayer(TileLayerCounter-3, &Color, pTMap, pGroup);
|
||||
if(g_Config.m_ClTextEntities)
|
||||
|
@ -1546,7 +1555,9 @@ void CMapLayers::OnRender()
|
|||
Graphics()->BlendNormal();
|
||||
RenderTools()->RenderTelemap(pTeleTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT);
|
||||
RenderTools()->RenderTeleOverlay(pTeleTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, g_Config.m_ClOverlayEntities/100.0f);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Graphics()->BlendNormal();
|
||||
RenderTileLayer(TileLayerCounter-2, &Color, pTMap, pGroup);
|
||||
if(g_Config.m_ClTextEntities)
|
||||
|
@ -1575,7 +1586,9 @@ void CMapLayers::OnRender()
|
|||
Graphics()->BlendNormal();
|
||||
RenderTools()->RenderSpeedupmap(pSpeedupTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT);
|
||||
RenderTools()->RenderSpeedupOverlay(pSpeedupTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, g_Config.m_ClOverlayEntities/100.0f);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Graphics()->BlendNormal();
|
||||
// draw arrow
|
||||
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_SPEEDUP_ARROW].m_Id);
|
||||
|
@ -1608,7 +1621,9 @@ void CMapLayers::OnRender()
|
|||
Graphics()->BlendNormal();
|
||||
RenderTools()->RenderTunemap(pTuneTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT);
|
||||
//RenderTools()->RenderTuneOverlay(pTuneTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, g_Config.m_ClOverlayEntities/100.0f);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Graphics()->BlendNormal();
|
||||
RenderTileLayer(TileLayerCounter-1, &Color, pTMap, pGroup);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue