Fix code style issues

dev-buzzingcars
krzys-h 2016-11-26 13:48:12 +01:00
parent be9dba4788
commit 88c6818cfd
14 changed files with 129 additions and 132 deletions

View File

@ -610,7 +610,8 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
CBotDefParam* params = CBotDefParam::Compile(p, pStk ); CBotDefParam* params = CBotDefParam::Compile(p, pStk );
delete pStk; delete pStk;
p = ppp; p = ppp;
std::list<CBotFunction*>::iterator pfIter = std::find_if(m_pMethod.begin(), m_pMethod.end(), [&pp, &params](CBotFunction* x) { std::list<CBotFunction*>::iterator pfIter = std::find_if(m_pMethod.begin(), m_pMethod.end(), [&pp, &params](CBotFunction* x)
{
return x->GetName() == pp && x->CheckParam( params ); return x->GetName() == pp && x->CheckParam( params );
}); });
assert(pfIter != m_pMethod.end()); assert(pfIter != m_pMethod.end());

View File

@ -45,7 +45,7 @@ CBotInstr* CompileParams(CBotToken* &p, CBotCStack* pStack, CBotVar** ppVars);
* For assignment or compound assignment operations (it's reversed): * For assignment or compound assignment operations (it's reversed):
* see CBotReturn::Compile & CBotExpression::Compile * see CBotReturn::Compile & CBotExpression::Compile
* TypeCompatible( valueType, varType, opType ) * TypeCompatible( valueType, varType, opType )
* \param type1 * \param type1
* \param type2 * \param type2
* \param op * \param op

View File

@ -148,9 +148,7 @@ bool CBotProgram::Start(const std::string& name)
{ {
Stop(); Stop();
auto it = std::find_if(m_functions.begin(), m_functions.end(), [&name](CBotFunction* x) { auto it = std::find_if(m_functions.begin(), m_functions.end(), [&name](CBotFunction* x) { return x->GetName() == name; });
return x->GetName() == name;
});
if (it == m_functions.end()) if (it == m_functions.end())
{ {
m_error = CBotErrNoRun; m_error = CBotErrNoRun;
@ -166,9 +164,7 @@ bool CBotProgram::Start(const std::string& name)
bool CBotProgram::GetPosition(const std::string& name, int& start, int& stop, CBotGet modestart, CBotGet modestop) bool CBotProgram::GetPosition(const std::string& name, int& start, int& stop, CBotGet modestart, CBotGet modestop)
{ {
auto it = std::find_if(m_functions.begin(), m_functions.end(), [&name](CBotFunction* x) { auto it = std::find_if(m_functions.begin(), m_functions.end(), [&name](CBotFunction* x) { return x->GetName() == name; });
return x->GetName() == name;
});
if (it == m_functions.end()) return false; if (it == m_functions.end()) return false;
(*it)->GetPosition(start, stop, modestart, modestop); (*it)->GetPosition(start, stop, modestart, modestop);

View File

@ -38,7 +38,7 @@ int g_nextFileId = 1;
bool FileClassOpenFile(CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) bool FileClassOpenFile(CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{ {
std::string mode; CBotFileAccessHandler::OpenMode openMode = CBotFileAccessHandler::OpenMode::Read;
// must be a character string // must be a character string
if ( pVar->GetType() != CBotTypString ) { Exception = CBotErrBadString; return false; } if ( pVar->GetType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
@ -50,8 +50,11 @@ bool FileClassOpenFile(CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exc
if ( pVar != nullptr ) if ( pVar != nullptr )
{ {
// recover mode // recover mode
mode = pVar->GetValString(); std::string mode = pVar->GetValString();
if ( mode != "r" && mode != "w" && mode != "a" ) { Exception = CBotErrBadParam; return false; } if ( mode == "r" ) openMode = CBotFileAccessHandler::OpenMode::Read;
else if ( mode == "w" ) openMode = CBotFileAccessHandler::OpenMode::Write;
else if ( mode == "a" ) openMode = CBotFileAccessHandler::OpenMode::Append;
else { Exception = CBotErrBadParam; return false; }
// no third parameter // no third parameter
if ( pVar->GetNext() != nullptr ) { Exception = CBotErrOverParam; return false; } if ( pVar->GetNext() != nullptr ) { Exception = CBotErrOverParam; return false; }
@ -66,27 +69,20 @@ bool FileClassOpenFile(CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exc
// which must not be initialized // which must not be initialized
if ( pVar->IsDefined()) { Exception = CBotErrFileOpen; return false; } if ( pVar->IsDefined()) { Exception = CBotErrFileOpen; return false; }
if ( !mode.empty() ) // opens the requested file
{ assert(g_fileHandler != nullptr);
// opens the requested file
assert(g_fileHandler != nullptr);
CBotFileAccessHandler::OpenMode openMode; std::unique_ptr<CBotFile> file = g_fileHandler->OpenFile(filename, openMode);
if ( mode == "r" ) openMode = CBotFileAccessHandler::OpenMode::Read;
else if ( mode == "w" ) openMode = CBotFileAccessHandler::OpenMode::Write;
else if ( mode == "a" ) openMode = CBotFileAccessHandler::OpenMode::Append;
std::unique_ptr<CBotFile> file = g_fileHandler->OpenFile(filename, openMode); if (!file->Opened()) { Exception = CBotErrFileOpen; return false; }
if (!file->Opened()) { Exception = CBotErrFileOpen; return false; } int fileHandle = g_nextFileId++;
g_files[fileHandle] = std::move(file);
int fileHandle = g_nextFileId++; // save the file handle
g_files[fileHandle] = std::move(file); pVar = pThis->GetItem("handle");
pVar->SetValInt(fileHandle);
// save the file handle
pVar = pThis->GetItem("handle");
pVar->SetValInt(fileHandle);
}
return true; return true;
} }

View File

@ -674,7 +674,8 @@ bool CApplication::Create()
// Create the robot application. // Create the robot application.
m_controller = MakeUnique<CController>(); m_controller = MakeUnique<CController>();
CThread musicLoadThread([this]() { CThread musicLoadThread([this]()
{
GetLogger()->Debug("Cache sounds...\n"); GetLogger()->Debug("Cache sounds...\n");
SystemTimeStamp* musicLoadStart = m_systemUtils->CreateTimeStamp(); SystemTimeStamp* musicLoadStart = m_systemUtils->CreateTimeStamp();
m_systemUtils->GetCurrentTimeStamp(musicLoadStart); m_systemUtils->GetCurrentTimeStamp(musicLoadStart);
@ -685,7 +686,8 @@ bool CApplication::Create()
m_systemUtils->GetCurrentTimeStamp(musicLoadEnd); m_systemUtils->GetCurrentTimeStamp(musicLoadEnd);
float musicLoadTime = m_systemUtils->TimeStampDiff(musicLoadStart, musicLoadEnd, STU_MSEC); float musicLoadTime = m_systemUtils->TimeStampDiff(musicLoadStart, musicLoadEnd, STU_MSEC);
GetLogger()->Debug("Sound loading took %.2f ms\n", musicLoadTime); GetLogger()->Debug("Sound loading took %.2f ms\n", musicLoadTime);
}, "Sound loading thread"); },
"Sound loading thread");
musicLoadThread.Start(); musicLoadThread.Start();
if (m_runSceneCategory == LevelCategory::Max) if (m_runSceneCategory == LevelCategory::Max)

View File

@ -22,6 +22,8 @@
#include "common/config.h" #include "common/config.h"
#include "common/make_unique.h"
#if defined(PLATFORM_WINDOWS) #if defined(PLATFORM_WINDOWS)
#include "common/system/system_windows.h" #include "common/system/system_windows.h"
#elif defined(PLATFORM_LINUX) #elif defined(PLATFORM_LINUX)
@ -32,8 +34,6 @@
#include "common/system/system_other.h" #include "common/system/system_other.h"
#endif #endif
#include "common/make_unique.h"
#include <cassert> #include <cassert>
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>

View File

@ -1,21 +1,21 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses * along with this program. If not, see http://gnu.org/licenses
*/ */
/** /**
* \file graphics/core/type.cpp * \file graphics/core/type.cpp

View File

@ -1,21 +1,21 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses * along with this program. If not, see http://gnu.org/licenses
*/ */
/** /**
* \file graphics/core/type.h * \file graphics/core/type.h

View File

@ -49,20 +49,20 @@ namespace Gfx
struct VertexAttribute struct VertexAttribute
{ {
//! true enables vertex attribute //! true enables vertex attribute
bool enabled; bool enabled = false;
//! true means normalized value (integer types only) //! true means normalized value (integer types only)
bool normalized; bool normalized = false;
//! Number of elements in the vertex attribute. //! Number of elements in the vertex attribute.
//! Valid values are 1, 2, 3, and 4. Depends on specific attribute. //! Valid values are 1, 2, 3, and 4. Depends on specific attribute.
unsigned char size; unsigned char size = 0;
//! Type of values in vertex attribute //! Type of values in vertex attribute
Type type; Type type = Type::UBYTE;
//! Offset to the vertex attribute //! Offset to the vertex attribute
int offset; int offset = 0;
//! Stride of vertex attribute //! Stride of vertex attribute
int stride; int stride = 0;
//! Default values used when attribute is disabled //! Default values used when attribute is disabled
float values[4]; float values[4] = {0.0f, 0.0f, 0.0f, 0.0f};
}; };
/** /**
@ -81,15 +81,15 @@ struct VertexAttribute
struct VertexFormat struct VertexFormat
{ {
//! Vertex coordinate //! Vertex coordinate
VertexAttribute vertex; VertexAttribute vertex{};
//! Color //! Color
VertexAttribute color; VertexAttribute color{};
//! Normal //! Normal
VertexAttribute normal; VertexAttribute normal{};
//! Texture coordinate 1 //! Texture coordinate 1
VertexAttribute tex1; VertexAttribute tex1{};
//! Texture coordinate 2 //! Texture coordinate 2
VertexAttribute tex2; VertexAttribute tex2{};
}; };
/** /**

View File

@ -643,37 +643,37 @@ UTF8Char CText::TranslateSpecialChar(int specialChar)
case CHAR_NEWLINE: case CHAR_NEWLINE:
// Unicode: U+21B2 // Unicode: U+21B2
ch.c1 = 0xE2; ch.c1 = static_cast<char>(0xE2);
ch.c2 = 0x86; ch.c2 = static_cast<char>(0x86);
ch.c3 = 0xB2; ch.c3 = static_cast<char>(0xB2);
break; break;
case CHAR_DOT: case CHAR_DOT:
// Unicode: U+23C5 // Unicode: U+23C5
ch.c1 = 0xE2; ch.c1 = static_cast<char>(0xE2);
ch.c2 = 0x8F; ch.c2 = static_cast<char>(0x8F);
ch.c3 = 0x85; ch.c3 = static_cast<char>(0x85);
break; break;
case CHAR_SQUARE: case CHAR_SQUARE:
// Unicode: U+25FD // Unicode: U+25FD
ch.c1 = 0xE2; ch.c1 = static_cast<char>(0xE2);
ch.c2 = 0x97; ch.c2 = static_cast<char>(0x97);
ch.c3 = 0xBD; ch.c3 = static_cast<char>(0xBD);
break; break;
case CHAR_SKIP_RIGHT: case CHAR_SKIP_RIGHT:
// Unicode: U+25B6 // Unicode: U+25B6
ch.c1 = 0xE2; ch.c1 = static_cast<char>(0xE2);
ch.c2 = 0x96; ch.c2 = static_cast<char>(0x96);
ch.c3 = 0xB6; ch.c3 = static_cast<char>(0xB6);
break; break;
case CHAR_SKIP_LEFT: case CHAR_SKIP_LEFT:
// Unicode: U+25C0 // Unicode: U+25C0
ch.c1 = 0xE2; ch.c1 = static_cast<char>(0xE2);
ch.c2 = 0x97; ch.c2 = static_cast<char>(0x97);
ch.c3 = 0x80; ch.c3 = static_cast<char>(0x80);
break; break;
default: default:

View File

@ -298,11 +298,11 @@ private:
//! Pointers to OpenGL functions //! Pointers to OpenGL functions
PFNGLGENBUFFERSPROC m_glGenBuffers; PFNGLGENBUFFERSPROC m_glGenBuffers = nullptr;
PFNGLDELETEBUFFERSPROC m_glDeleteBuffers; PFNGLDELETEBUFFERSPROC m_glDeleteBuffers = nullptr;
PFNGLBINDBUFFERPROC m_glBindBuffer; PFNGLBINDBUFFERPROC m_glBindBuffer = nullptr;
PFNGLBUFFERDATAPROC m_glBufferData; PFNGLBUFFERDATAPROC m_glBufferData = nullptr;
PFNGLBUFFERSUBDATAPROC m_glBufferSubData; PFNGLBUFFERSUBDATAPROC m_glBufferSubData = nullptr;
}; };

View File

@ -2065,7 +2065,7 @@ unsigned int CGL33Device::UploadVertexData(DynamicBuffer& buffer, const void* da
if (ptr != nullptr) if (ptr != nullptr)
{ {
memcpy(ptr, data, size); memcpy(ptr, data, size);
glUnmapBuffer(GL_ARRAY_BUFFER); glUnmapBuffer(GL_ARRAY_BUFFER);
} }
// mapping failed, we must upload data with glBufferSubData // mapping failed, we must upload data with glBufferSubData

View File

@ -1,21 +1,21 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses * along with this program. If not, see http://gnu.org/licenses
*/ */
#include "math/half.h" #include "math/half.h"

View File

@ -1,21 +1,21 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses * along with this program. If not, see http://gnu.org/licenses
*/ */
/** /**
* \file math/half.h * \file math/half.h
@ -36,6 +36,7 @@ uint16_t FloatToHalf(float value);
//! Converts half-float binary representation to float //! Converts half-float binary representation to float
float HaltToFloat(uint16_t value); float HaltToFloat(uint16_t value);
//@colobot-lint-exclude ClassNamingRule
/** /**
* \struct half * \struct half
* \brief half-precision floating point type * \brief half-precision floating point type
@ -99,5 +100,6 @@ struct half
return HaltToFloat(bits); return HaltToFloat(bits);
} }
}; };
//@end-colobot-lint-exclude
} // namespace Math } // namespace Math