summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-06-20 17:42:33 +0300
committerAndrei Karas <akaras@inbox.ru>2014-06-20 21:11:13 +0300
commit8963c582f2d2f2879b69821337a5c396f9712a06 (patch)
tree9cc8f89e3116bb09ad3f4a30f7552fad6e83fe57 /src
parent65f5f9343a75a5adabdf840db93106cda71c703f (diff)
downloadplus-8963c582f2d2f2879b69821337a5c396f9712a06.tar.gz
plus-8963c582f2d2f2879b69821337a5c396f9712a06.tar.bz2
plus-8963c582f2d2f2879b69821337a5c396f9712a06.tar.xz
plus-8963c582f2d2f2879b69821337a5c396f9712a06.zip
Fix code style.
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp6
-rw-r--r--src/client.h10
-rw-r--r--src/commandhandler.cpp2
-rw-r--r--src/commandhandler.h2
-rw-r--r--src/graphicsmanager.cpp2
-rw-r--r--src/graphicsmanager.h4
-rw-r--r--src/graphicsvertexes.cpp7
-rw-r--r--src/gui/widgets/sliderlist.cpp1
-rw-r--r--src/gui/windows/chatwindow.cpp2
-rw-r--r--src/net/messagein.cpp3
-rw-r--r--src/render/mgldefines.h8
-rw-r--r--src/render/modernopenglgraphics.cpp34
-rw-r--r--src/render/shaders/shader.cpp2
-rw-r--r--src/render/shaders/shader.h8
-rw-r--r--src/render/shaders/shaderprogram.cpp2
-rw-r--r--src/render/shaders/shaderprogram.h6
-rw-r--r--src/render/shaders/shadersmanager.cpp1
-rw-r--r--src/render/shaders/shadersmanager.h6
-rw-r--r--src/test/testlauncher.cpp6
-rw-r--r--src/utils/stringutils.cpp4
20 files changed, 62 insertions, 54 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 2692f296c..52d18477f 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -698,7 +698,7 @@ void Client::gameClear()
TranslationManager::close();
}
-int Client::testsExec() const
+int Client::testsExec()
{
#ifdef USE_OPENGL
if (settings.options.test.empty())
@@ -1671,7 +1671,7 @@ void Client::initFeatures()
features.setDefaultValues(getFeaturesDefaults());
}
-void Client::initTradeFilter() const
+void Client::initTradeFilter()
{
const std::string tradeListName =
settings.serverConfigDir + "/tradefilter.txt";
@@ -1704,7 +1704,7 @@ void Client::initTradeFilter() const
}
}
-bool Client::isTmw() const
+bool Client::isTmw()
{
const std::string &name = settings.serverName;
if (name == "server.themanaworld.org"
diff --git a/src/client.h b/src/client.h
index 4a5d5016d..6dff50877 100644
--- a/src/client.h
+++ b/src/client.h
@@ -81,7 +81,7 @@ public:
int gameExec();
- int testsExec() const;
+ static int testsExec();
void setState(const State state)
{ mState = state; }
@@ -89,13 +89,13 @@ public:
State getState() const A_WARN_UNUSED
{ return mState; }
- bool isTmw() const A_WARN_UNUSED;
+ static bool isTmw() A_WARN_UNUSED;
void optionChanged(const std::string &name) override final;
void action(const ActionEvent &event) override final;
- void initTradeFilter() const;
+ static void initTradeFilter();
void moveButtons(const int width);
@@ -108,9 +108,9 @@ private:
void initConfigListeners();
- void initGraphics();
+ static void initGraphics();
- void updateEnv();
+ static void updateEnv();
static void initFeatures();
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index d3c0b248a..b594d8bda 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -65,7 +65,7 @@ void CommandHandler::addChatCommands(std::list<std::string> &arr)
}
void CommandHandler::handleCommands(const std::string &command,
- ChatTab *const tab)
+ ChatTab *const tab) const
{
// here need add splitting commands
handleCommand(command, tab);
diff --git a/src/commandhandler.h b/src/commandhandler.h
index b2b74d77d..7bcb00fdc 100644
--- a/src/commandhandler.h
+++ b/src/commandhandler.h
@@ -66,7 +66,7 @@ class CommandHandler final
ChatTab *const tab = localChatTab) const;
void handleCommands(const std::string &command,
- ChatTab *const tab = localChatTab);
+ ChatTab *const tab = localChatTab) const;
void invokeCommand(const std::string &type,
const std::string &args,
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 1d9914592..358793daa 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -63,8 +63,6 @@
#include "resources/surfaceimagehelper.h"
#endif
-#include "render/shaders/shadersmanager.h"
-
#include "utils/delete2.h"
#include "utils/sdlhelper.h"
#include "utils/stringutils.h"
diff --git a/src/graphicsmanager.h b/src/graphicsmanager.h
index d71fdc8a0..c50645942 100644
--- a/src/graphicsmanager.h
+++ b/src/graphicsmanager.h
@@ -163,10 +163,10 @@ class GraphicsManager final
std::string getGLVersion() const
{ return mGlVersionString; }
- GLenum getLastErrorCached() const
+ static GLenum getLastErrorCached()
{ return mLastError; }
- void resetCachedError()
+ static void resetCachedError()
{ mLastError = GL_NO_ERROR; }
#endif
diff --git a/src/graphicsvertexes.cpp b/src/graphicsvertexes.cpp
index 102512274..778f6ff30 100644
--- a/src/graphicsvertexes.cpp
+++ b/src/graphicsvertexes.cpp
@@ -20,8 +20,6 @@
#include "graphicsvertexes.h"
-#include "logger.h"
-
#include "render/graphics.h"
#include "utils/dtor.h"
@@ -54,7 +52,8 @@ OpenGLGraphicsVertexes::OpenGLGraphicsVertexes() :
mFloatTexPool(),
mIntVertPool(),
mShortVertPool(),
- mIntTexPool()
+ mIntTexPool(),
+ mVbo()
{
mFloatTexPool.reserve(30);
mIntVertPool.reserve(30);
@@ -99,7 +98,7 @@ void OpenGLGraphicsVertexes::clear()
}
mIntTexPool.clear();
- const int sz = mVbo.size();
+ const int sz = static_cast<int>(mVbo.size());
if (sz > 0)
{
mainGraphics->removeArray(sz, &mVbo[0]);
diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp
index f925dcb10..ca642ee69 100644
--- a/src/gui/widgets/sliderlist.cpp
+++ b/src/gui/widgets/sliderlist.cpp
@@ -40,6 +40,7 @@ SliderList::SliderList(const Widget2 *const widget,
Container(widget),
ActionListener(),
MouseListener(),
+ mButtons(),
mLabel(new Label(this)),
mListModel(listModel),
mPrevEventId(),
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index d1d9370a1..776ad9501 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -897,7 +897,7 @@ void ChatWindow::keyPressed(KeyEvent &event)
bool ChatWindow::addCurrentToHistory()
{
- const std::string str = mChatInput->getText();
+ const std::string &str = mChatInput->getText();
if (str.empty())
return false;
FOR_EACH (HistoryIterator, it, mHistory)
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index cbdcd127c..ffda37e9c 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -92,7 +92,6 @@ uint8_t MessageIn::fromServerDirection(const uint8_t serverDir)
void MessageIn::readCoordinates(uint16_t &restrict x, uint16_t &restrict y,
uint8_t &restrict direction)
{
- uint8_t serverDir = 0;
if (mPos + 3 <= mLength)
{
const char *const data = mData + static_cast<size_t>(mPos);
@@ -101,7 +100,7 @@ void MessageIn::readCoordinates(uint16_t &restrict x, uint16_t &restrict y,
temp = MAKEWORD(data[2] & 0x00f0, data[1] & 0x003f);
y = static_cast<uint16_t>(temp >> 4);
- serverDir = static_cast<uint8_t>(data[2] & 0x000f);
+ const uint8_t serverDir = static_cast<uint8_t>(data[2] & 0x000f);
direction = fromServerDirection(serverDir);
DEBUGLOG(std::string("readCoordinates: ").append(toString(
diff --git a/src/render/mgldefines.h b/src/render/mgldefines.h
index 524d8eca4..109744b91 100644
--- a/src/render/mgldefines.h
+++ b/src/render/mgldefines.h
@@ -83,6 +83,14 @@
#define GL_DYNAMIC_DRAW 0x88E8
#endif
+#ifndef GL_COMPILE_STATUS
+#define GL_FRAGMENT_SHADER 0x8B30
+#define GL_VERTEX_SHADER 0x8B31
+#define GL_COMPILE_STATUS 0x8B81
+#define GL_LINK_STATUS 0x8B82
+#define GL_INFO_LOG_LENGTH 0x8B84
+#endif
+
#endif // USE_OPENGL
#endif // RENDER_MGLDEFINES_H
diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp
index 96ce5e1ef..ce7f86f56 100644
--- a/src/render/modernopenglgraphics.cpp
+++ b/src/render/modernopenglgraphics.cpp
@@ -154,10 +154,10 @@ void ModernOpenGLGraphics::postInit()
mglGenVertexArrays(1, &mVao);
mglBindVertexArray(mVao);
mglGenBuffers(1, &mVbo);
- //logger->log("gen vbo buffer: %u", mVbo);
+// logger->log("gen vbo buffer: %u", mVbo);
bindArrayBuffer(mVbo);
mglGenBuffers(1, &mEbo);
- //logger->log("gen ebo buffer: %u", mEbo);
+// logger->log("gen ebo buffer: %u", mEbo);
bindElementBuffer(mEbo);
logger->log("Compiling shaders");
@@ -274,7 +274,7 @@ void ModernOpenGLGraphics::drawQuad(const Image *const image A_UNUSED,
x2, y2, texX2, texY2
};
- //logger->log("allocate: %d, %ld", mVboCached, sizeof(vertices));
+// logger->log("allocate: %d, %ld", mVboCached, sizeof(vertices));
mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
@@ -303,7 +303,7 @@ void ModernOpenGLGraphics::drawRescaledQuad(const Image *const image A_UNUSED,
x2, y2, texX2, texY2
};
- //logger->log("allocate: %d, %ld", mVboCached, sizeof(vertices));
+// logger->log("allocate: %d, %ld", mVboCached, sizeof(vertices));
mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
@@ -352,8 +352,8 @@ void ModernOpenGLGraphics::testDraw()
800, 600, 800, 600
};
- //logger->log("allocate: %d, %ld", mVboCached, sizeof(vertices));
- //logger->log("allocate ebo: %d, %ld", mEboCached, sizeof(elements));
+// logger->log("allocate: %d, %ld", mVboCached, sizeof(vertices));
+// logger->log("allocate ebo: %d, %ld", mEboCached, sizeof(elements));
mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
vertices, GL_STREAM_DRAW);
// mglBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elements),
@@ -572,7 +572,7 @@ inline void ModernOpenGLGraphics::drawVertexes(const
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
#endif
- //logger->log("draw from array: %u", *ivbo);
+// logger->log("draw from array: %u", *ivbo);
glDrawArrays(GL_TRIANGLES, 0, *ivp / 4);
}
}
@@ -946,7 +946,7 @@ void ModernOpenGLGraphics::drawPoint(int x, int y)
{
x + clipArea.xOffset, y + clipArea.yOffset, 0, 0
};
- //logger->log("allocate: %d, %ld", mVboCached, sizeof(vertices));
+// logger->log("allocate: %d, %ld", mVboCached, sizeof(vertices));
mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
@@ -965,7 +965,7 @@ void ModernOpenGLGraphics::drawLine(int x1, int y1, int x2, int y2)
x1 + clipArea.xOffset, y1 + clipArea.yOffset, 0, 0,
x2 + clipArea.xOffset, y2 + clipArea.yOffset, 0, 0
};
- //logger->log("allocate: %d, %ld", mVboCached, sizeof(vertices));
+// logger->log("allocate: %d, %ld", mVboCached, sizeof(vertices));
mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
@@ -991,7 +991,7 @@ void ModernOpenGLGraphics::drawRectangle(const Rect& rect)
x2, y1, 0, 0
};
- //logger->log("allocate: %d, %ld", mVboCached, sizeof(vertices));
+// logger->log("allocate: %d, %ld", mVboCached, sizeof(vertices));
mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
@@ -1017,7 +1017,7 @@ void ModernOpenGLGraphics::fillRectangle(const Rect& rect)
x2, y2, 0, 0
};
- //logger->log("allocate: %d, %ld", mVboCached, sizeof(vertices));
+// logger->log("allocate: %d, %ld", mVboCached, sizeof(vertices));
mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
@@ -1148,7 +1148,7 @@ void ModernOpenGLGraphics::removeArray(const uint32_t sz,
{
if (arr[f] == mVboCached)
mVboCached = 0;
- //logger->log("delete buffers: %u", arr[f]);
+// logger->log("delete buffers: %u", arr[f]);
}
}
@@ -1157,7 +1157,7 @@ void ModernOpenGLGraphics::bindArrayBuffer(const GLuint vbo)
if (mVboCached != vbo)
{
mVboCached = vbo;
- //logger->log("bind array: %u", vbo);
+// logger->log("bind array: %u", vbo);
mglBindBuffer(GL_ARRAY_BUFFER, vbo);
/*
if (mglIsBuffer(vbo) != GL_TRUE)
@@ -1280,7 +1280,7 @@ void ModernOpenGLGraphics::finalize(ImageVertexes *const vert)
std::vector<GLuint> &vbos = ogl.mVbo;
std::vector<GLuint>::const_iterator ivbo;
- const int sz = intTexPool.size();
+ const int sz = static_cast<int>(intTexPool.size());
vbos.resize(sz);
mglGenBuffers(sz, &vbos[0]);
/*
@@ -1311,7 +1311,7 @@ void ModernOpenGLGraphics::finalize(ImageVertexes *const vert)
void ModernOpenGLGraphics::drawTriangleArray(const int size)
{
- //logger->log("allocate: %d, %ld", mVboCached, size * sizeof(GLint));
+// logger->log("allocate: %d, %ld", mVboCached, size * sizeof(GLint));
mglBufferData(GL_ARRAY_BUFFER, size * sizeof(GLint),
mIntArray, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
@@ -1323,7 +1323,7 @@ void ModernOpenGLGraphics::drawTriangleArray(const int size)
void ModernOpenGLGraphics::drawTriangleArray(const GLint *const array,
const int size)
{
- //logger->log("allocate: %d, %ld", mVboCached, size * sizeof(GLint));
+// logger->log("allocate: %d, %ld", mVboCached, size * sizeof(GLint));
mglBufferData(GL_ARRAY_BUFFER, size * sizeof(GLint),
array, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
@@ -1334,7 +1334,7 @@ void ModernOpenGLGraphics::drawTriangleArray(const GLint *const array,
void ModernOpenGLGraphics::drawLineArrays(const int size)
{
- //logger->log("allocate: %d, %ld", mVboCached, size * sizeof(GLint));
+// logger->log("allocate: %d, %ld", mVboCached, size * sizeof(GLint));
mglBufferData(GL_ARRAY_BUFFER, size * sizeof(GLint),
mIntArray, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
diff --git a/src/render/shaders/shader.cpp b/src/render/shaders/shader.cpp
index 9a0d317a5..242a9fbdc 100644
--- a/src/render/shaders/shader.cpp
+++ b/src/render/shaders/shader.cpp
@@ -24,6 +24,8 @@
#include "render/mgl.h"
+#include "debug.h"
+
Shader::Shader(const unsigned int id) :
Resource(),
mShaderId(id)
diff --git a/src/render/shaders/shader.h b/src/render/shaders/shader.h
index adcc29702..c5bd2d490 100644
--- a/src/render/shaders/shader.h
+++ b/src/render/shaders/shader.h
@@ -18,8 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef RENDER_SHADER_H
-#define RENDER_SHADER_H
+#ifndef RENDER_SHADERS_SHADER_H
+#define RENDER_SHADERS_SHADER_H
#ifdef USE_OPENGL
@@ -28,7 +28,7 @@
class Shader final : public Resource
{
public:
- Shader(const unsigned int id);
+ explicit Shader(const unsigned int id);
~Shader();
@@ -42,4 +42,4 @@ class Shader final : public Resource
};
#endif // USE_OPENGL
-#endif // RENDER_SHADER_H
+#endif // RENDER_SHADERS_SHADER_H
diff --git a/src/render/shaders/shaderprogram.cpp b/src/render/shaders/shaderprogram.cpp
index 7d79e5cb9..fd2db9ba8 100644
--- a/src/render/shaders/shaderprogram.cpp
+++ b/src/render/shaders/shaderprogram.cpp
@@ -26,6 +26,8 @@
#include "render/shaders/shader.h"
+#include "debug.h"
+
ShaderProgram::ShaderProgram(const unsigned int id,
Shader *const vertex,
Shader *const fragment) :
diff --git a/src/render/shaders/shaderprogram.h b/src/render/shaders/shaderprogram.h
index a0781d684..5289567aa 100644
--- a/src/render/shaders/shaderprogram.h
+++ b/src/render/shaders/shaderprogram.h
@@ -18,8 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef RENDER_SHADERPROGRAM_H
-#define RENDER_SHADERPROGRAM_H
+#ifndef RENDER_SHADERS_SHADERPROGRAM_H
+#define RENDER_SHADERS_SHADERPROGRAM_H
#ifdef USE_OPENGL
@@ -48,4 +48,4 @@ class ShaderProgram final : public Resource
};
#endif // USE_OPENGL
-#endif // RENDER_SHADERPROGRAM_H
+#endif // RENDER_SHADERS_SHADERPROGRAM_H
diff --git a/src/render/shaders/shadersmanager.cpp b/src/render/shaders/shadersmanager.cpp
index 2c37f56d5..efaa97c77 100644
--- a/src/render/shaders/shadersmanager.cpp
+++ b/src/render/shaders/shadersmanager.cpp
@@ -24,7 +24,6 @@
#include "configuration.h"
#include "logger.h"
-#include "settings.h"
#include "render/mgl.h"
diff --git a/src/render/shaders/shadersmanager.h b/src/render/shaders/shadersmanager.h
index 50e714aba..841f3f072 100644
--- a/src/render/shaders/shadersmanager.h
+++ b/src/render/shaders/shadersmanager.h
@@ -18,8 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef RENDER_SHADERSMANAGER_H
-#define RENDER_SHADERSMANAGER_H
+#ifndef RENDER_SHADERS_SHADERSMANAGER_H
+#define RENDER_SHADERS_SHADERSMANAGER_H
#ifdef USE_OPENGL
@@ -46,4 +46,4 @@ class ShadersManager final
extern ShadersManager shaders;
#endif // USE_OPENGL
-#endif // RENDER_SHADERSMANAGER_H
+#endif // RENDER_SHADERS_SHADERSMANAGER_H
diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp
index 22a77eb0e..abc22fc75 100644
--- a/src/test/testlauncher.cpp
+++ b/src/test/testlauncher.cpp
@@ -184,7 +184,7 @@ int TestLauncher::testFps()
file << mTest << std::endl;
file << tFps << std::endl;
- printf("fps: %u\n", tFps);
+ printf("fps: %d\n", tFps);
sleep(1);
return 0;
}
@@ -216,7 +216,7 @@ int TestLauncher::testFps2()
file << mTest << std::endl;
file << tFps << std::endl;
- printf("fps: %u\n", tFps);
+ printf("fps: %d\n", tFps);
sleep(1);
return 0;
}
@@ -263,7 +263,7 @@ int TestLauncher::testFps3()
file << mTest << std::endl;
file << tFps << std::endl;
- printf("fps: %u\n", tFps);
+ printf("fps: %d\n", tFps);
sleep(1);
return 0;
}
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index af4cafd35..31d68a418 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -203,8 +203,8 @@ size_t findI(std::string text, const StringVect &list)
return std::string::npos;
}
-int base = 94;
-int start = 33;
+unsigned int base = 94;
+unsigned int start = 33;
const std::string encodeStr(unsigned int value, const unsigned int size)
{