diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-07-18 01:51:36 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-07-18 01:51:36 +0300 |
commit | f0e95132f27ceb901fbd779fafc798a1f67a06a6 (patch) | |
tree | 52ee9ab21f4e01c2c8ae70b86841b0138349645d /src | |
parent | 7e0a97d2521b9ce57003176e82a0b5564aa003c2 (diff) | |
download | manaplus-f0e95132f27ceb901fbd779fafc798a1f67a06a6.tar.gz manaplus-f0e95132f27ceb901fbd779fafc798a1f67a06a6.tar.bz2 manaplus-f0e95132f27ceb901fbd779fafc798a1f67a06a6.tar.xz manaplus-f0e95132f27ceb901fbd779fafc798a1f67a06a6.zip |
Another warning fixes.
Diffstat (limited to 'src')
30 files changed, 66 insertions, 72 deletions
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 41a7aa215..4368643c5 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -310,7 +310,7 @@ unsigned int AnimatedSprite::getCurrentFrame() const unsigned int AnimatedSprite::getFrameCount() const { if (mAnimation) - return mAnimation->getLength(); + return static_cast<unsigned int>(mAnimation->getLength()); else return 0; } diff --git a/src/being.cpp b/src/being.cpp index 6f0ac307b..33f4e102a 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -500,7 +500,7 @@ void Being::setSpeech(const std::string &text, int time) return; if (!time && mSpeech.size() < 200) - time = SPEECH_TIME - 300 + (3 * mSpeech.size()); + time = static_cast<int>(SPEECH_TIME - 300 + (3 * mSpeech.size())); if (time < SPEECH_MIN_TIME) time = SPEECH_MIN_TIME; @@ -2051,7 +2051,7 @@ void Being::drawSprites(Graphics* graphics, int posX, int posY) const void Being::drawSpritesSDL(Graphics* graphics, int posX, int posY) const { - const unsigned sz = size(); + const size_t sz = size(); for (unsigned f = 0; f < sz; f ++) { const int rSprite = mSpriteHide[mSpriteRemap[f]]; @@ -2523,7 +2523,7 @@ Equipment *Being::getEquipment() void Being::undressItemById(int id) { - int sz = mSpriteIDs.size(); + size_t sz = mSpriteIDs.size(); for (int f = 0; f < sz; f ++) { @@ -2691,7 +2691,7 @@ BeingEquipBackend::BeingEquipBackend(Being *being): memset(mEquipment, 0, sizeof(mEquipment)); if (being) { - int sz = being->mSpriteIDs.size(); + size_t sz = being->mSpriteIDs.size(); for (int f = 0; f < sz; f ++) { diff --git a/src/client.cpp b/src/client.cpp index 3bd59d7d0..cfff614ef 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -136,9 +136,6 @@ */ static const int MAX_TICK_VALUE = 10000; -static const int defaultSfxVolume = 100; -static const int defaultMusicVolume = 60; - // TODO: Get rid fo these globals std::string errorMessage; ErrorListener errorListener; diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 8ed68ae20..75f4a5331 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -1074,7 +1074,7 @@ void CommandHandler::handleCacheInfo(const std::string &args A_UNUSED, { if (!cache[f].empty()) { - all += cache[f].size(); + all += static_cast<int>(cache[f].size()); str += strprintf("%d: %u, ", f, static_cast<unsigned int>(cache[f].size())); } diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp index fa5b4b202..98ee8c6df 100644 --- a/src/compoundsprite.cpp +++ b/src/compoundsprite.cpp @@ -229,7 +229,7 @@ int CompoundSprite::getNumberOfLayers() const if (mImage || mAlphaImage) return 1; else - return size(); + return static_cast<int>(size()); } unsigned int CompoundSprite::getCurrentFrame() const diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index b71b812d2..ad766091c 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -283,7 +283,7 @@ void CharCreateDialog::action(const gcn::ActionEvent &event) Net::getCharHandler()->newCharacter(getName(), characterSlot, mFemale->isSelected(), mHairStyle, mHairColor, - static_cast<uint16_t>(mRace), atts); + static_cast<unsigned char>(mRace), atts); } else { diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index fc30fbc04..f3255af97 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -1058,8 +1058,8 @@ void ChatWindow::addWhisper(const std::string &nick, { std::string msg = mes; std::string nick2; - int idx = mes.find(":"); - if (idx > 0) + size_t idx = mes.find(":"); + if (idx != std::string::npos && idx > 0) { nick2 = msg.substr(0, idx); msg = msg.substr(idx + 1); diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp index 95b6fc666..d8ba0232e 100644 --- a/src/gui/logindialog.cpp +++ b/src/gui/logindialog.cpp @@ -48,11 +48,6 @@ #include "debug.h" -static const int MAX_SERVER_LIST_SIZE = 15; -static const int LOGIN_DIALOG_WIDTH = 300; -static const int LOGIN_DIALOG_HEIGHT = 140; -static const int FIELD_WIDTH = LOGIN_DIALOG_WIDTH - 70; - std::string LoginDialog::savedPassword(""); std::string LoginDialog::savedPasswordKey(""); diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index e1310ef2e..19a912173 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -339,7 +339,7 @@ void SDLFont::doClean() for (int f = 0; f < CACHES_NUMBER; f ++) { std::list<SDLTextChunk> *cache = &mCache[f]; - const unsigned size = cache->size(); + const size_t size = cache->size(); #ifdef DEBUG_FONT_COUNTERS logger->log("ptr: %d, size: %d", f, size); #endif diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index 154594e60..be68518e3 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -313,7 +313,7 @@ void UpdaterWindow::loadNews() { firstLine = false; std::string str = line; - unsigned i = str.find("##9 Latest client version: ##6"); + size_t i = str.find("##9 Latest client version: ##6"); if (!i) { line = strtok(nullptr, "\n"); diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index 438318fdc..8e130d887 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -191,7 +191,7 @@ void WhoIsOnline::updateWindow(std::vector<OnlinePlayer*> &friends, std::vector<OnlinePlayer*> &neutral, std::vector<OnlinePlayer*> &disregard, std::vector<OnlinePlayer*> enemy, - int numOnline) + size_t numOnline) { //Set window caption setCaption(_("Who Is Online - ") + toString(numOnline)); @@ -245,7 +245,7 @@ void WhoIsOnline::updateWindow(std::vector<OnlinePlayer*> &friends, void WhoIsOnline::loadList(std::vector<OnlinePlayer*> &list) { mBrowserBox->clearRows(); - int numOnline = list.size(); + size_t numOnline = list.size(); std::vector<OnlinePlayer*> friends; std::vector<OnlinePlayer*> neutral; std::vector<OnlinePlayer*> disregard; diff --git a/src/gui/whoisonline.h b/src/gui/whoisonline.h index 94b30bfc2..4f70b24f9 100644 --- a/src/gui/whoisonline.h +++ b/src/gui/whoisonline.h @@ -170,7 +170,7 @@ private: std::vector<OnlinePlayer*> &neutral, std::vector<OnlinePlayer*> &disregard, std::vector<OnlinePlayer*> enemy, - int numOnline); + size_t numOnline); enum DownloadStatus { diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index 453e62a50..990937e06 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -349,9 +349,9 @@ void LayoutArray::reflow(int nx, int ny, int nw, int nh) { int dx = x, dy = y, dw = 0, dh = 0; align(dx, dw, 0, *cell, &widths[gridX], - widths.size() - gridX); + static_cast<int>(widths.size() - gridX)); align(dy, dh, 1, *cell, &heights[gridY], - heights.size() - gridY); + static_cast<int>(heights.size() - gridY)); cell->reflow(dx, dy, dw, dh); } x += widths[gridX] + mSpacing; diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index b40a7dcb1..cd5b4bf99 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -177,7 +177,8 @@ void TextBox::keyPressed(gcn::KeyEvent& keyEvent) } else { - mCaretColumn = mTextRows[mCaretRow].size(); + mCaretColumn = static_cast<int>( + mTextRows[mCaretRow].size()); } } break; @@ -192,11 +193,12 @@ void TextBox::keyPressed(gcn::KeyEvent& keyEvent) if (mCaretRow >= static_cast<int>(mTextRows.size())) { - mCaretRow = mTextRows.size() - 1; + mCaretRow = static_cast<int>(mTextRows.size()) - 1; if (mCaretRow < 0) mCaretRow = 0; - mCaretColumn = mTextRows[mCaretRow].size(); + mCaretColumn = static_cast<int>( + mTextRows[mCaretRow].size()); } else { @@ -223,7 +225,7 @@ void TextBox::keyPressed(gcn::KeyEvent& keyEvent) } case Input::KEY_GUI_END: { - mCaretColumn = mTextRows[mCaretRow].size(); + mCaretColumn = static_cast<int>(mTextRows[mCaretRow].size()); break; } @@ -250,7 +252,8 @@ void TextBox::keyPressed(gcn::KeyEvent& keyEvent) } else if (mCaretColumn == 0 && mCaretRow != 0 && mEditable) { - mCaretColumn = mTextRows[mCaretRow - 1].size(); + mCaretColumn = static_cast<int>( + mTextRows[mCaretRow - 1].size()); mTextRows[mCaretRow - 1] += mTextRows[mCaretRow]; mTextRows.erase(mTextRows.begin() + mCaretRow); --mCaretRow; @@ -303,7 +306,7 @@ void TextBox::keyPressed(gcn::KeyEvent& keyEvent) mCaretRow += rowsPerPage; if (mCaretRow >= static_cast<int>(mTextRows.size())) - mCaretRow = mTextRows.size() - 1; + mCaretRow = static_cast<int>(mTextRows.size()) - 1; } break; } diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 3d106f9a2..f0df5eb57 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -279,7 +279,7 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent) break; case 5: // Ctrl+e - mCaretPosition = mText.size(); + mCaretPosition = static_cast<int>(mText.size()); consumed = true; break; diff --git a/src/guichan/defaultfont.cpp b/src/guichan/defaultfont.cpp index feeb91001..8d0b23623 100644 --- a/src/guichan/defaultfont.cpp +++ b/src/guichan/defaultfont.cpp @@ -64,7 +64,7 @@ namespace gcn int DefaultFont::getWidth(const std::string& text) const { - return 8*text.size(); + return static_cast<int>(8 * text.size()); } int DefaultFont::drawGlyph(Graphics* graphics, @@ -88,7 +88,7 @@ namespace gcn int DefaultFont::getStringIndexAt(const std::string& text, int x) const { if (x > static_cast<int>(text.size() * 8)) - return text.size(); + return static_cast<int>(text.size()); return x / 8; } diff --git a/src/guichan/focushandler.cpp b/src/guichan/focushandler.cpp index 839c35cc1..393c08880 100644 --- a/src/guichan/focushandler.cpp +++ b/src/guichan/focushandler.cpp @@ -235,7 +235,7 @@ namespace gcn -- i; if (focusedWidget <= 0) - focusedWidget = mWidgets.size() - 1; + focusedWidget = static_cast<int>(mWidgets.size() - 1); if (focusedWidget == focused) return; @@ -433,7 +433,7 @@ namespace gcn -- i; if (focusedWidget <= 0) - focusedWidget = mWidgets.size() - 1; + focusedWidget = static_cast<int>(mWidgets.size() - 1); if (focusedWidget == focused) return; diff --git a/src/guichan/font.cpp b/src/guichan/font.cpp index 598b1610b..6fec94121 100644 --- a/src/guichan/font.cpp +++ b/src/guichan/font.cpp @@ -62,6 +62,6 @@ namespace gcn return i; } - return text.size(); + return static_cast<int>(text.size()); } } diff --git a/src/guichan/include/guichan/platform.hpp b/src/guichan/include/guichan/platform.hpp index 9a18191d2..9e3d1338a 100644 --- a/src/guichan/include/guichan/platform.hpp +++ b/src/guichan/include/guichan/platform.hpp @@ -73,8 +73,8 @@ #define GCN_EXTENSION_DECLSPEC #endif -#ifndef NULL -#define NULL 0 -#endif +//#ifndef NULL +//#define NULL 0 +//#endif #endif // end GCN_PLATFORM_HPP diff --git a/src/guichan/widgets/textbox.cpp b/src/guichan/widgets/textbox.cpp index 0103cdb99..6b03a1cb5 100644 --- a/src/guichan/widgets/textbox.cpp +++ b/src/guichan/widgets/textbox.cpp @@ -100,9 +100,9 @@ namespace gcn pos = text.find("\n", lastPos); if (pos != std::string::npos) - length = pos - lastPos; + length = static_cast<int>(pos - lastPos); else - length = text.size() - lastPos; + length = static_cast<int>(text.size() - lastPos); std::string sub = text.substr(lastPos, length); mTextRows.push_back(sub); lastPos = pos + 1; @@ -133,7 +133,8 @@ namespace gcn for (size_t i = 0; i < mTextRows.size(); i++) { // Move the text one pixel so we can have a caret before a letter. - graphics->drawText(mTextRows[i], 1, i * getFont()->getHeight()); + graphics->drawText(mTextRows[i], 1, + static_cast<int>(i * getFont()->getHeight())); } } @@ -150,7 +151,7 @@ namespace gcn mCaretRow = mouseEvent.getY() / getFont()->getHeight(); if (mCaretRow >= static_cast<int>(mTextRows.size())) - mCaretRow = mTextRows.size() - 1; + mCaretRow = static_cast<int>(mTextRows.size() - 1); mCaretColumn = getFont()->getStringIndexAt( mTextRows[mCaretRow], mouseEvent.getX()); @@ -177,7 +178,7 @@ namespace gcn } setWidth(width + 1); - setHeight(getFont()->getHeight() * mTextRows.size()); + setHeight(static_cast<int>(getFont()->getHeight() * mTextRows.size())); } void TextBox::setCaretPosition(unsigned int position) @@ -197,8 +198,8 @@ namespace gcn } // position beyond end of text - mCaretRow = mTextRows.size() - 1; - mCaretColumn = mTextRows[mCaretRow].size(); + mCaretRow = static_cast<int>(mTextRows.size() - 1); + mCaretColumn = static_cast<int>(mTextRows[mCaretRow].size()); } unsigned int TextBox::getCaretPosition() const @@ -206,7 +207,7 @@ namespace gcn int pos = 0, row; for (row = 0; row < mCaretRow; row++) - pos += mTextRows[row].size(); + pos += static_cast<int>(mTextRows[row].size()); return pos + mCaretColumn; } @@ -222,7 +223,7 @@ namespace gcn mCaretRow = row; if (mCaretRow >= static_cast<int>(mTextRows.size())) - mCaretRow = mTextRows.size() - 1; + mCaretRow = static_cast<int>(mTextRows.size() - 1); if (mCaretRow < 0) mCaretRow = 0; @@ -240,7 +241,7 @@ namespace gcn mCaretColumn = column; if (mCaretColumn > static_cast<int>(mTextRows[mCaretRow].size())) - mCaretColumn = mTextRows[mCaretRow].size(); + mCaretColumn = static_cast<int>(mTextRows[mCaretRow].size()); if (mCaretColumn < 0) mCaretColumn = 0; @@ -268,7 +269,7 @@ namespace gcn unsigned int TextBox::getNumberOfRows() const { - return mTextRows.size(); + return static_cast<int>(mTextRows.size()); } std::string TextBox::getText() const diff --git a/src/guichan/widgets/textfield.cpp b/src/guichan/widgets/textfield.cpp index b23722cc4..b74d2333f 100644 --- a/src/guichan/widgets/textfield.cpp +++ b/src/guichan/widgets/textfield.cpp @@ -83,7 +83,7 @@ namespace gcn void TextField::setText(const std::string& text) { if (text.size() < mCaretPosition) - mCaretPosition = text.size(); + mCaretPosition = static_cast<int>(text.size()); mText = text; } @@ -151,7 +151,7 @@ namespace gcn void TextField::setCaretPosition(unsigned int position) { if (position > mText.size()) - mCaretPosition = mText.size(); + mCaretPosition = static_cast<int>(mText.size()); else mCaretPosition = position; diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp index 9f07d1fe9..02612ff42 100644 --- a/src/inputmanager.cpp +++ b/src/inputmanager.cpp @@ -259,8 +259,8 @@ bool InputManager::hasConflicts(int &key1, int &key2) && mKey[i].values[i2].value == mKey[j].values[j2].value && mKey[i].values[i2].type == mKey[j].values[j2].type) { - key1 = i; - key2 = j; + key1 = static_cast<int>(i); + key2 = static_cast<int>(j); return true; } } @@ -377,7 +377,7 @@ void InputManager::addActionKey(int action, int type, int val) || (key.values[i].type == type && key.values[i].value == val)) { - idx = i; + idx = static_cast<int>(i); break; } } @@ -614,7 +614,7 @@ void InputManager::updateKeyActionMap(KeyToActionMap &actionMap, { const KeyItem &ki = key.values[i2]; if (ki.type == type && ki.value != -1) - actionMap[ki.value].push_back(i); + actionMap[ki.value].push_back(static_cast<int>(i)); } } if (keyData[i].configField && (keyData[i].grp & Input::GRP_GUICHAN)) @@ -623,7 +623,7 @@ void InputManager::updateKeyActionMap(KeyToActionMap &actionMap, { const KeyItem &ki = key.values[i2]; if (ki.type == type && ki.value != -1) - idMap[ki.value] = i; + idMap[ki.value] = static_cast<int>(i); } } if (keyData[i].configField && (keyData[i].grp & Input::GRP_REPEAT)) @@ -678,7 +678,7 @@ int InputManager::getKeyIndex(int value, int grp, int type) const && (grp & keyData[i].grp) != 0 && key.values[i2].type == type) { - return i; + return static_cast<int>(i); } } } diff --git a/src/inventory.cpp b/src/inventory.cpp index 4b9a22739..9aff286ff 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -46,7 +46,8 @@ struct SlotUsed : public std::unary_function<Item*, bool> Inventory::Inventory(int type, int size): mType(type), - mSize(size == -1 ? Net::getInventoryHandler()->getSize(type) + mSize(size == -1 ? static_cast<unsigned>( + Net::getInventoryHandler()->getSize(type)) : static_cast<unsigned>(size)), mUsed(0) { diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp index ce6aedb59..62b37f34e 100644 --- a/src/itemshortcut.cpp +++ b/src/itemshortcut.cpp @@ -75,7 +75,8 @@ void ItemShortcut::load(bool oldConfig) for (int i = 0; i < SHORTCUT_ITEMS; i++) { int itemId = cfg->getValue(name + toString(i), -1); - unsigned char itemColor = cfg->getValue(color + toString(i), 1); + unsigned char itemColor = static_cast<unsigned char>( + cfg->getValue(color + toString(i), 1)); mItems[i] = itemId; mItemColors[i] = itemColor; diff --git a/src/localplayer.cpp b/src/localplayer.cpp index b998a5ee2..231cfba4a 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -80,10 +80,6 @@ #include "debug.h" -// This is the minimal delay between to permitted -// setDestination() calls using the keyboard. -// TODO: This can fine tuned later on when running is added... -const short walkingKeyboardDelay = 1000; const short awayLimitTimer = 60; LocalPlayer *player_node = nullptr; diff --git a/src/map.cpp b/src/map.cpp index 9f4805239..1b25bee02 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1364,7 +1364,7 @@ void Map::indexTilesets() return; } - const int size = s->getFirstGid() + s->size(); + const int size = static_cast<int>(s->getFirstGid()) + s->size(); mIndexedTilesetsSize = size; mIndexedTilesets = new Tileset*[size]; std::fill_n(mIndexedTilesets, size, static_cast<Tileset*>(nullptr)); @@ -1377,7 +1377,7 @@ void Map::indexTilesets() if (s) { const int start = s->getFirstGid(); - const int end = start + s->size(); + const int end = stati_cast<int>(start + s->size()); for (int f = start; f < end; f ++) { if (f < size) diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index 2b9a21500..4828ca388 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -47,7 +47,7 @@ void ColorDB::load() ColorListsIterator it = mColorLists.find("hair"); if (it != mColorLists.end()) - mHairColorsSize = (*it).second.size(); + mHairColorsSize = static_cast<int>((*it).second.size()); else mHairColorsSize = 0; } diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index 95c03f141..9ab011c92 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -88,7 +88,7 @@ void SimpleAnimation::setFrame(int frame) if (frame < 0) frame = 0; if (static_cast<unsigned>(frame) >= mAnimation->getLength()) - frame = mAnimation->getLength() - 1; + frame = static_cast<int>(mAnimation->getLength()) - 1; mAnimationPhase = frame; mCurrentFrame = &mAnimation->mFrames[mAnimationPhase]; } @@ -127,7 +127,7 @@ int SimpleAnimation::getLength() const if (!mAnimation) return 0; - return mAnimation->getLength(); + return static_cast<int>(mAnimation->getLength()); } Image *SimpleAnimation::getCurrentImage() const diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp index 1d2289600..b5dc63449 100644 --- a/src/utils/copynpaste.cpp +++ b/src/utils/copynpaste.cpp @@ -457,7 +457,7 @@ bool runxsel(std::string& text, const char *p1, const char *p2) // parent close(fd[0]); - const int len = strlen(text.c_str()); + const int len = static_cast<int>(strlen(text.c_str())); if (write(fd[1], text.c_str(), len) != len) { close(fd[1]); diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp index 1a2ec1b5c..081b642c0 100644 --- a/src/utils/paths.cpp +++ b/src/utils/paths.cpp @@ -118,7 +118,7 @@ std::string getSelfName() std::string getSelfName() { char buf[257]; - int sz = readlink("/proc/self/exe", buf, 256); + ssize_t sz = readlink("/proc/self/exe", buf, 256); if (sz > 0 && sz < 256) { buf[sz] = 0; |