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 );
delete pStk;
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 );
});
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):
* see CBotReturn::Compile & CBotExpression::Compile
* TypeCompatible( valueType, varType, opType )
* TypeCompatible( valueType, varType, opType )
* \param type1
* \param type2
* \param op

View File

@ -148,9 +148,7 @@ bool CBotProgram::Start(const std::string& name)
{
Stop();
auto it = std::find_if(m_functions.begin(), m_functions.end(), [&name](CBotFunction* x) {
return x->GetName() == name;
});
auto it = std::find_if(m_functions.begin(), m_functions.end(), [&name](CBotFunction* x) { return x->GetName() == name; });
if (it == m_functions.end())
{
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)
{
auto it = std::find_if(m_functions.begin(), m_functions.end(), [&name](CBotFunction* x) {
return x->GetName() == name;
});
auto it = std::find_if(m_functions.begin(), m_functions.end(), [&name](CBotFunction* x) { return x->GetName() == name; });
if (it == m_functions.end()) return false;
(*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)
{
std::string mode;
CBotFileAccessHandler::OpenMode openMode = CBotFileAccessHandler::OpenMode::Read;
// must be a character string
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 )
{
// recover mode
mode = pVar->GetValString();
if ( mode != "r" && mode != "w" && mode != "a" ) { Exception = CBotErrBadParam; return false; }
std::string mode = pVar->GetValString();
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
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
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;
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);
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++;
g_files[fileHandle] = std::move(file);
// save the file handle
pVar = pThis->GetItem("handle");
pVar->SetValInt(fileHandle);
// save the file handle
pVar = pThis->GetItem("handle");
pVar->SetValInt(fileHandle);
}
return true;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -49,20 +49,20 @@ namespace Gfx
struct VertexAttribute
{
//! true enables vertex attribute
bool enabled;
bool enabled = false;
//! true means normalized value (integer types only)
bool normalized;
bool normalized = false;
//! Number of elements in the vertex 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 type;
Type type = Type::UBYTE;
//! Offset to the vertex attribute
int offset;
int offset = 0;
//! Stride of vertex attribute
int stride;
int stride = 0;
//! 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
{
//! Vertex coordinate
VertexAttribute vertex;
VertexAttribute vertex{};
//! Color
VertexAttribute color;
VertexAttribute color{};
//! Normal
VertexAttribute normal;
VertexAttribute normal{};
//! Texture coordinate 1
VertexAttribute tex1;
VertexAttribute tex1{};
//! Texture coordinate 2
VertexAttribute tex2;
VertexAttribute tex2{};
};
/**

View File

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

View File

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

View File

@ -2065,7 +2065,7 @@ unsigned int CGL33Device::UploadVertexData(DynamicBuffer& buffer, const void* da
if (ptr != nullptr)
{
memcpy(ptr, data, size);
glUnmapBuffer(GL_ARRAY_BUFFER);
}
// 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
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#include "math/half.h"

View File

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