diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-04-30 19:54:08 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-04-30 19:54:08 +0300 |
commit | ef7e7319305f040a47c483b71f2e78da7a1d6149 (patch) | |
tree | 14ac10427d7c94288fcb198db5277455754589ae /src | |
parent | 12389c8441c748996962412201af9e21d66f9e55 (diff) | |
download | ManaVerse-ef7e7319305f040a47c483b71f2e78da7a1d6149.tar.gz ManaVerse-ef7e7319305f040a47c483b71f2e78da7a1d6149.tar.bz2 ManaVerse-ef7e7319305f040a47c483b71f2e78da7a1d6149.tar.xz ManaVerse-ef7e7319305f040a47c483b71f2e78da7a1d6149.zip |
Fix code style in other files.
Diffstat (limited to 'src')
-rw-r--r-- | src/animatedsprite.cpp | 3 | ||||
-rw-r--r-- | src/chatlogger.cpp | 4 | ||||
-rw-r--r-- | src/client.cpp | 4 | ||||
-rw-r--r-- | src/commands.cpp | 9 | ||||
-rw-r--r-- | src/dragdrop.h | 6 | ||||
-rw-r--r-- | src/emoteshortcut.cpp | 3 | ||||
-rw-r--r-- | src/eventsmanager.cpp | 4 | ||||
-rw-r--r-- | src/graphicsmanager.cpp | 15 | ||||
-rw-r--r-- | src/notifications.h | 10 | ||||
-rw-r--r-- | src/particle/particleemitter.cpp | 8 | ||||
-rw-r--r-- | src/simpleanimation.h | 4 | ||||
-rw-r--r-- | src/test/testlauncher.cpp | 2 | ||||
-rw-r--r-- | src/units.cpp | 2 |
13 files changed, 45 insertions, 29 deletions
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 930d7d61e..e1ca0a27d 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -226,8 +226,7 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) if (frame->type == Frame::LABEL && mFrame->nextAction == frame->nextAction) { -// mFrameTime = 0; - mFrameIndex = i; + mFrameIndex = static_cast<unsigned int>(i); if (mFrameIndex >= mAnimation->getLength()) mFrameIndex = 0; diff --git a/src/chatlogger.cpp b/src/chatlogger.cpp index 2bfe4933b..52c57dcf0 100644 --- a/src/chatlogger.cpp +++ b/src/chatlogger.cpp @@ -133,8 +133,8 @@ std::string ChatLogger::getDir() const std::string ChatLogger::secureName(std::string &name) { - const unsigned int sz = name.length(); - for (unsigned int f = 0; f < sz; f ++) + const size_t sz = name.length(); + for (size_t f = 0; f < sz; f ++) { const unsigned char ch = name[f]; if ((ch < '0' || ch > '9') diff --git a/src/client.cpp b/src/client.cpp index 9b5f2c956..ce4cd081b 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1286,7 +1286,7 @@ int Client::gameExec() mSearchHash = Net::Download::adlerBuffer( const_cast<char*>(mCurrentServer.hostname.c_str()), - mCurrentServer.hostname.size()); + static_cast<int>(mCurrentServer.hostname.size())); if (mOptions.username.empty() || mOptions.password.empty()) { @@ -2198,7 +2198,7 @@ void Client::initUpdatesDir() if (mUpdateHost.length() < 2) return; - const int sz = mUpdateHost.size(); + const size_t sz = mUpdateHost.size(); // Remove any trailing slash at the end of the update host if (mUpdateHost.at(sz - 1) == '/') mUpdateHost.resize(sz - 1); diff --git a/src/commands.cpp b/src/commands.cpp index 3d476f8c6..ef1e2faac 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1241,14 +1241,17 @@ impHandler0(createItems) if (id <= 500) continue; - const int colors = info->getColorsSize(); + int colors = info->getColorsSize(); + if (colors >= 255) + colors = 254; + if (!colors || serverVersion < 1) { dialog->addItem(id, 1, 100, 0); } else { - for (int f = 0; f < colors; f ++) + for (unsigned char f = 0; f < colors; f ++) { if (!info->getColor(f).empty()) dialog->addItem(id, f, 100, 0); @@ -1309,7 +1312,7 @@ static int uploadUpdate(void *ptr, if (chatWindow && (!tab || chatWindow->isTabPresent(tab))) { std::string str = Net::Download::getUploadResponse(); - const int sz = str.size(); + const size_t sz = str.size(); if (sz > 0) { if (str[sz - 1] == '\n') diff --git a/src/dragdrop.h b/src/dragdrop.h index 3623d548c..157b1aec8 100644 --- a/src/dragdrop.h +++ b/src/dragdrop.h @@ -60,7 +60,7 @@ class DragDrop final mItem(item ? item->getId() : 0), mSelItem(0), mTag(-1), - mItemColor(item ? item->getColor() : 1), + mItemColor(item ? item->getColor() : static_cast<uint8_t>(1U)), mSelItemColor(1) { if (mItemImage) @@ -78,7 +78,7 @@ class DragDrop final int getItem() const { return mItem; } - int getItemColor() const + uint8_t getItemColor() const { return mItemColor; } Image *getItemImage() @@ -218,7 +218,7 @@ class DragDrop final int getSelected() const { return mSelItem; } - int getSelectedColor() const + uint8_t getSelectedColor() const { return mSelItemColor; } bool isSelected() const diff --git a/src/emoteshortcut.cpp b/src/emoteshortcut.cpp index 34e68b9f8..7ec54e47f 100644 --- a/src/emoteshortcut.cpp +++ b/src/emoteshortcut.cpp @@ -45,7 +45,8 @@ EmoteShortcut::~EmoteShortcut() void EmoteShortcut::load() { - for (unsigned char i = 0, j = 0, sz = EmoteDB::getLast(); + for (unsigned char i = 0, j = 0, + sz = static_cast<unsigned char>(EmoteDB::getLast()); i <= sz && j < SHORTCUT_EMOTES; i++) { diff --git a/src/eventsmanager.cpp b/src/eventsmanager.cpp index 3062ac3d2..9ae04d308 100644 --- a/src/eventsmanager.cpp +++ b/src/eventsmanager.cpp @@ -297,8 +297,8 @@ void EventsManager::logEvent(const SDL_Event &event) { const char *const text = event.text.text; logger->log("event: SDL_TEXTINPUT: %s", text); - const int sz = strlen(event.text.text); - for (int f = 0; f < sz; f ++) + const size_t sz = strlen(event.text.text); + for (size_t f = 0; f < sz; f ++) logger->log("dec: %d", text[f]); break; } diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp index 30d50340a..0770332d9 100644 --- a/src/graphicsmanager.cpp +++ b/src/graphicsmanager.cpp @@ -408,18 +408,15 @@ void GraphicsManager::setVideoMode() } } +#ifdef USE_SDL2 SDL_Window *GraphicsManager::createWindow(const int w, const int h, - const int bpp, const int flags) + const int bpp A_UNUSED, + const int flags) { -#ifdef USE_SDL2 return SDL_CreateWindow("ManaPlus", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, flags); -#else - return SDL_SetVideoMode(w, h, bpp, flags); -#endif } -#ifdef USE_SDL2 SDL_Renderer *GraphicsManager::createRenderer(SDL_Window *const window, const int flags) { @@ -428,6 +425,12 @@ SDL_Renderer *GraphicsManager::createRenderer(SDL_Window *const window, SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); return renderer; } +#else +SDL_Window *GraphicsManager::createWindow(const int w, const int h, + const int bpp, const int flags) +{ + return SDL_SetVideoMode(w, h, bpp, flags); +} #endif #ifdef USE_OPENGL diff --git a/src/notifications.h b/src/notifications.h index 18a689287..0c08c0430 100644 --- a/src/notifications.h +++ b/src/notifications.h @@ -41,6 +41,16 @@ namespace NotifyManager struct NotificationInfo final { + NotificationInfo(const char *const sound0, + const char *const text0, + const NotifyFlags flags0) : + sound(sound0), + text(text0), + flags(flags0) + { } + + A_DELETE_COPY(NotificationInfo) + const char *sound; const char *text; const NotifyFlags flags; diff --git a/src/particle/particleemitter.cpp b/src/particle/particleemitter.cpp index 54c3623c4..39550f03d 100644 --- a/src/particle/particleemitter.cpp +++ b/src/particle/particleemitter.cpp @@ -611,11 +611,11 @@ std::list<Particle *> ParticleEmitter::createParticles(const int tick) newParticle->moveTo(position); const float angleH = mParticleAngleHorizontal.value(tick); - const float cosAngleH = cos(angleH); - const float sinAngleH = sin(angleH); + const float cosAngleH = static_cast<float>(cos(angleH)); + const float sinAngleH = static_cast<float>(sin(angleH)); const float angleV = mParticleAngleVertical.value(tick); - const float cosAngleV = cos(angleV); - const float sinAngleV = sin(angleV); + const float cosAngleV = static_cast<float>(cos(angleV)); + const float sinAngleV = static_cast<float>(sin(angleV)); const float power = mParticlePower.value(tick); newParticle->setVelocity(cosAngleH * cosAngleV * power, sinAngleH * cosAngleV * power, diff --git a/src/simpleanimation.h b/src/simpleanimation.h index f5f971059..74af7f819 100644 --- a/src/simpleanimation.h +++ b/src/simpleanimation.h @@ -50,8 +50,8 @@ class SimpleAnimation final /** * Creates a simple animation that creates its animation from XML Data. */ - explicit SimpleAnimation(const XmlNodePtr animationNode, - const std::string& dyePalettes); + SimpleAnimation(const XmlNodePtr animationNode, + const std::string& dyePalettes); A_DELETE_COPY(SimpleAnimation) diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp index 584bdb5cb..09c7ef2ed 100644 --- a/src/test/testlauncher.cpp +++ b/src/test/testlauncher.cpp @@ -303,6 +303,6 @@ int TestLauncher::calcFps(const timeval *const start, const timeval *const end, if (mtime == 0) return 100000; - return static_cast<long>(calls) * 1000 / mtime; + return static_cast<int>(static_cast<long>(calls) * 1000 / mtime); } #endif diff --git a/src/units.cpp b/src/units.cpp index f095d7bbf..ec4084126 100644 --- a/src/units.cpp +++ b/src/units.cpp @@ -207,7 +207,7 @@ static std::string formatUnit(const int value, const int type) else { double amount = ud.conversion * value; - const unsigned int sz = ud.levels.size(); + const unsigned int sz = static_cast<unsigned int>(ud.levels.size()); // If only the first level is needed, act like mix if false if (ud.mix && !ud.levels.empty() && ud.levels[1].count < amount) |