[colobot] 22/100: Fix code style issues
Didier Raboud
odyx at moszumanska.debian.org
Thu Jun 1 18:10:15 UTC 2017
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch debian/master
in repository colobot.
commit 88c6818cfdd64cca6c2633942ba02a0c63907413
Author: krzys-h <krzys_h at interia.pl>
Date: Sat Nov 26 13:48:12 2016 +0100
Fix code style issues
---
src/CBot/CBotClass.cpp | 3 ++-
src/CBot/CBotInstr/CBotInstrUtils.h | 2 +-
src/CBot/CBotProgram.cpp | 8 ++------
src/CBot/stdlib/FileFunctions.cpp | 34 +++++++++++++++-------------------
src/app/app.cpp | 6 ++++--
src/common/system/system.cpp | 4 ++--
src/graphics/core/type.cpp | 34 +++++++++++++++++-----------------
src/graphics/core/type.h | 34 +++++++++++++++++-----------------
src/graphics/core/vertex.h | 24 ++++++++++++------------
src/graphics/engine/text.cpp | 30 +++++++++++++++---------------
src/graphics/opengl/gl14device.h | 10 +++++-----
src/graphics/opengl/gl33device.cpp | 2 +-
src/math/half.cpp | 34 +++++++++++++++++-----------------
src/math/half.h | 36 +++++++++++++++++++-----------------
14 files changed, 129 insertions(+), 132 deletions(-)
diff --git a/src/CBot/CBotClass.cpp b/src/CBot/CBotClass.cpp
index d93d7f5..579dda0 100644
--- a/src/CBot/CBotClass.cpp
+++ b/src/CBot/CBotClass.cpp
@@ -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, ¶ms](CBotFunction* x) {
+ std::list<CBotFunction*>::iterator pfIter = std::find_if(m_pMethod.begin(), m_pMethod.end(), [&pp, ¶ms](CBotFunction* x)
+ {
return x->GetName() == pp && x->CheckParam( params );
});
assert(pfIter != m_pMethod.end());
diff --git a/src/CBot/CBotInstr/CBotInstrUtils.h b/src/CBot/CBotInstr/CBotInstrUtils.h
index b530288..0177e09 100644
--- a/src/CBot/CBotInstr/CBotInstrUtils.h
+++ b/src/CBot/CBotInstr/CBotInstrUtils.h
@@ -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
diff --git a/src/CBot/CBotProgram.cpp b/src/CBot/CBotProgram.cpp
index 65d373a..fdb36eb 100644
--- a/src/CBot/CBotProgram.cpp
+++ b/src/CBot/CBotProgram.cpp
@@ -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);
diff --git a/src/CBot/stdlib/FileFunctions.cpp b/src/CBot/stdlib/FileFunctions.cpp
index 4f2f613..57d778a 100644
--- a/src/CBot/stdlib/FileFunctions.cpp
+++ b/src/CBot/stdlib/FileFunctions.cpp
@@ -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;
}
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 4ab6440..806a17c 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -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)
diff --git a/src/common/system/system.cpp b/src/common/system/system.cpp
index ce594ea..ff4ad7c 100644
--- a/src/common/system/system.cpp
+++ b/src/common/system/system.cpp
@@ -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>
diff --git a/src/graphics/core/type.cpp b/src/graphics/core/type.cpp
index ddcd343..38dc9f5 100644
--- a/src/graphics/core/type.cpp
+++ b/src/graphics/core/type.cpp
@@ -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
diff --git a/src/graphics/core/type.h b/src/graphics/core/type.h
index 4a49f58..2d49345 100644
--- a/src/graphics/core/type.h
+++ b/src/graphics/core/type.h
@@ -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
diff --git a/src/graphics/core/vertex.h b/src/graphics/core/vertex.h
index 11f1ea4..254c8d3 100644
--- a/src/graphics/core/vertex.h
+++ b/src/graphics/core/vertex.h
@@ -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{};
};
/**
diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp
index aece13e..53bd7f6 100644
--- a/src/graphics/engine/text.cpp
+++ b/src/graphics/engine/text.cpp
@@ -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:
diff --git a/src/graphics/opengl/gl14device.h b/src/graphics/opengl/gl14device.h
index e0dba14..4106b84 100644
--- a/src/graphics/opengl/gl14device.h
+++ b/src/graphics/opengl/gl14device.h
@@ -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;
};
diff --git a/src/graphics/opengl/gl33device.cpp b/src/graphics/opengl/gl33device.cpp
index 3d5ae71..3ea93e4 100644
--- a/src/graphics/opengl/gl33device.cpp
+++ b/src/graphics/opengl/gl33device.cpp
@@ -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
diff --git a/src/math/half.cpp b/src/math/half.cpp
index 4508218..d1339a4 100644
--- a/src/math/half.cpp
+++ b/src/math/half.cpp
@@ -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"
diff --git a/src/math/half.h b/src/math/half.h
index a5e44f4..a9d80d9 100644
--- a/src/math/half.h
+++ b/src/math/half.h
@@ -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
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list