diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-03-27 21:41:20 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-03-27 21:41:20 +0300 |
commit | 964ffbb9b6ed5246b14a7d0c0d065f7d38af0912 (patch) | |
tree | edef1b3f31183402e2d0f86ee48c9734c2a03c7e /src | |
parent | 41ac086fcd38fd472b579a495a8e8e7685ae4722 (diff) | |
download | manaplus-964ffbb9b6ed5246b14a7d0c0d065f7d38af0912.tar.gz manaplus-964ffbb9b6ed5246b14a7d0c0d065f7d38af0912.tar.bz2 manaplus-964ffbb9b6ed5246b14a7d0c0d065f7d38af0912.tar.xz manaplus-964ffbb9b6ed5246b14a7d0c0d065f7d38af0912.zip |
Fix some warnings and improve code from gcc 4.6 compilation.
Diffstat (limited to 'src')
31 files changed, 127 insertions, 62 deletions
diff --git a/src/being.cpp b/src/being.cpp index 2f911b1ff..2e2c68283 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -2023,7 +2023,7 @@ void Being::recalcSpritesOrder() // logger->log("preparation end"); int lastRemap = 0; - int cnt = 0; + unsigned cnt = 0; while (cnt < 15 && lastRemap >= 0) { diff --git a/src/client.cpp b/src/client.cpp index 8fa9a1c8c..636b61521 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1207,6 +1207,7 @@ int Client::exec() //++++++ break; + case STATE_START: default: mState = STATE_FORCE_QUIT; break; diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index bd721e8aa..c2cfab2f6 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -104,7 +104,6 @@ public: && botCheckerWindow->mEnabled) { std::set<ActorSprite*> beings = actorSpriteManager->getAll(); - ActorSprites::iterator i = beings.begin(); for (ActorSprites::const_iterator i = beings.begin(); i != beings.end(); ++i) { @@ -391,7 +390,6 @@ void BotCheckerWindow::reset() if (actorSpriteManager) { std::set<ActorSprite*> beings = actorSpriteManager->getAll(); - ActorSprites::iterator i = beings.begin(); for (ActorSprites::const_iterator i = beings.begin(); i != beings.end(); ++i) { diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index bff000ef3..54638f793 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -199,7 +199,7 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) const std::string &eventId = event.getId(); - if (selected != -1) + if (selected >= 0) { if (eventId == "use") { diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 88dbd1b0a..e50310409 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -689,7 +689,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event) mChatInput->isVisible()) { ChatTab *tab = getFocused(); - if (tab && tab->getRows().size() > 0) + if (tab && (unsigned)tab->getRows().size() > 0) { if (!mChatHistoryIndex) { diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 493b5041a..e09d0ce0a 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -116,8 +116,8 @@ void ItemPopup::setItem(const Item *item, bool showImage) ii.getName().c_str(), item->getRefine(), ii.getId())); } mItemName->adjustSize(); - int minWidth = mItemName->getWidth() + 8; - if (getWidth() < minWidth) + unsigned minWidth = mItemName->getWidth() + 8; + if ((unsigned)getWidth() < minWidth) setWidth(minWidth); } } @@ -256,6 +256,10 @@ gcn::Color ItemPopup::getColor(ItemType type) return Theme::getThemeColor(Theme::FEET); case ITEM_EQUIPMENT_AMMO: return Theme::getThemeColor(Theme::AMMO); + case ITEM_EQUIPMENT_CHARM: + return Theme::getThemeColor(Theme::CHARM); + case ITEM_SPRITE_RACE: + case ITEM_SPRITE_HAIR: default: return Theme::getThemeColor(Theme::UNKNOWN_ITEM); } diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp index 9bbbc8549..f01dd01c7 100644 --- a/src/gui/killstats.cpp +++ b/src/gui/killstats.cpp @@ -193,7 +193,7 @@ void KillStats::gainXp(int xp) mLine2->setCaption("Exp: " + toString(PlayerInfo::getAttribute(EXP)) + "/" + toString(xpNextLevel) + " Left: " + toString(xpNextLevel - PlayerInfo::getAttribute(EXP))); - if (AvgExp >= 0.001 && AvgExp <= 0.001) + if (AvgExp >= 0.001f && AvgExp <= 0.001f) { mLine3->setCaption("1% = " + toString(xpNextLevel / 100) + " exp, Avg Mob for 1%: ?"); diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index e5371eaf3..93f84bcf7 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -275,6 +275,10 @@ void Minimap::draw(gcn::Graphics *graphics) type = UserPalette::NPC; break; + case ActorSprite::UNKNOWN: + case ActorSprite::PLAYER: + case ActorSprite::FLOOR_ITEM: + case ActorSprite::PORTAL: default: continue; } diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 183b006d5..4372897cd 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -250,6 +250,9 @@ void PopupMenu::showPopup(int x, int y, Being *being) } break; + case ActorSprite::UNKNOWN: + case ActorSprite::FLOOR_ITEM: + case ActorSprite::PORTAL: default: /* Other beings aren't interesting... */ return; diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index b9f0bc6f5..38124f5c0 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -66,6 +66,7 @@ static std::string serverTypeToString(ServerInfo::Type type) case ServerInfo::MANASERV: return "ManaServ"; default: + case ServerInfo::UNKNOWN: return ""; } } @@ -75,6 +76,7 @@ static unsigned short defaultPortForServerType(ServerInfo::Type type) switch (type) { default: + case ServerInfo::UNKNOWN: case ServerInfo::TMWATHENA: return 6901; case ServerInfo::MANASERV: @@ -490,8 +492,7 @@ void ServerDialog::logic() else if (mDownloadStatus == DOWNLOADING_IN_PROGRESS) { mDescription->setCaption(strprintf(_("Downloading server list..." - "%2.2f%%"), - mDownloadProgress * 100)); + "%2.2f%%"), mDownloadProgress * 100)); } else if (mDownloadStatus == DOWNLOADING_IDLE) { diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h index a49895b53..1eba02b4f 100644 --- a/src/gui/setup_video.h +++ b/src/gui/setup_video.h @@ -64,7 +64,7 @@ class Setup_Video : public SetupTab, public gcn::ActionListener, bool mNPCLogEnabled; bool mPickupChatEnabled; bool mPickupParticleEnabled; - double mOpacity; + float mOpacity; int mFps; int mAltFps; bool mHideShieldSprite; diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 2f61eecb9..8aab63728 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -632,7 +632,8 @@ static int readColorType(const std::string &type) "ARMS", "AMMO", "SERVER_VERSION_NOT_SUPPORTED", - "WARNING" + "WARNING", + "CHARM" }; if (type.empty()) diff --git a/src/gui/theme.h b/src/gui/theme.h index 0e5559d8c..e483bff69 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -182,6 +182,7 @@ class Theme : public Palette, public ConfigListener AMMO, SERVER_VERSION_NOT_SUPPORTED, WARNING, + CHARM, THEME_COLORS_END }; diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 92bd0d80b..4dd5431ee 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -705,6 +705,11 @@ void Viewport::mouseMoved(gcn::MouseEvent &event _UNUSED_) case ActorSprite::MONSTER: gui->setCursorType(Gui::CURSOR_FIGHT); break; + + case ActorSprite::UNKNOWN: + case ActorSprite::PLAYER: + case ActorSprite::FLOOR_ITEM: + case ActorSprite::PORTAL: default: gui->setCursorType(Gui::CURSOR_POINTER); break; diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index c4d9e92a3..9a72bb7fd 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -484,6 +484,7 @@ void WhoIsOnline::logic() chatWindow->updateOnline(mOnlinePlayers); } break; + case UPDATE_COMPLETE: default: break; } diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 8546cbd7e..bc5583148 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -178,7 +178,7 @@ void BrowserBox::addRow(const std::string &row, bool atTop) unsigned int nextChar; const char *hyphen = "~"; int hyphenWidth = font->getWidth(hyphen); - int x = 0; + unsigned x = 0; for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); ++i) { @@ -197,7 +197,7 @@ void BrowserBox::addRow(const std::string &row, bool atTop) if (nextSpacePos <= 0) nextSpacePos = static_cast<int>(row.size()) - 1; - int nextWordWidth = font->getWidth( + unsigned nextWordWidth = font->getWidth( row.substr(nextChar, (nextSpacePos - nextChar))); @@ -335,7 +335,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) int BrowserBox::calcHeight() { - int x = 0, y = 0; + unsigned x = 0, y = 0; int wrappedLines = 0; int link = 0; gcn::Font *font = getFont(); @@ -360,7 +360,7 @@ int BrowserBox::calcHeight() if (row.find("---", 0) == 0) { const int dashWidth = fontWidthMinus; - for (x = 0; x < getWidth(); x++) + for (x = 0; x < (unsigned)getWidth(); x++) { mLineParts.push_back(LinePart(x, y, selColor, "-")); x += dashWidth - 2; diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 40bde104e..2c8db7e85 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -162,6 +162,7 @@ void ChatTab::chatLog(std::string line, Own own, lineColor = "##Y"; break; case BY_OTHER: + case BY_UNKNOWN: tmp.nick += ": "; lineColor = "##C"; break; diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index e0a0da87a..c9f1269aa 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -375,6 +375,8 @@ void ItemContainer::mouseReleased(gcn::MouseEvent &event) case SEL_DRAGGING: mSelectionStatus = SEL_SELECTED; break; + case SEL_NONE: + case SEL_SELECTED: default: return; }; diff --git a/src/gui/widgets/shopitems.cpp b/src/gui/widgets/shopitems.cpp index 6cd0ef39d..764f22a57 100644 --- a/src/gui/widgets/shopitems.cpp +++ b/src/gui/widgets/shopitems.cpp @@ -105,12 +105,12 @@ void ShopItems::clear() mShopItems.clear(); } -ShopItem *ShopItems::findItem(int id, unsigned char color) +ShopItem *ShopItems::findItem(int id, unsigned char color) const { ShopItem *item; - std::vector<ShopItem*>::iterator it = mShopItems.begin(); - std::vector<ShopItem*>::iterator e = mShopItems.end(); + std::vector<ShopItem*>::const_iterator it = mShopItems.begin(); + std::vector<ShopItem*>::const_iterator e = mShopItems.end(); while (it != e) { item = *(it); diff --git a/src/gui/widgets/shopitems.h b/src/gui/widgets/shopitems.h index 2b2dcc5eb..cc444fe85 100644 --- a/src/gui/widgets/shopitems.h +++ b/src/gui/widgets/shopitems.h @@ -110,7 +110,7 @@ class ShopItems : public gcn::ListModel * * @return the item found or 0 */ - ShopItem *findItem(int id, unsigned char color); + ShopItem *findItem(int id, unsigned char color) const; /** The list of items in the shop. */ std::vector<ShopItem*> mShopItems; diff --git a/src/gui/widgets/table.cpp b/src/gui/widgets/table.cpp index 6011e4ceb..00f41a760 100644 --- a/src/gui/widgets/table.cpp +++ b/src/gui/widgets/table.cpp @@ -301,27 +301,31 @@ void GuiTable::draw(gcn::Graphics* graphics) if (first_row < 0) first_row = 0; - int rows_nr = 1 + (getHeight() / getRowHeight()); // May overestimate + unsigned rows_nr = 1 + (getHeight() / getRowHeight()); // May overestimate // by one. - int max_rows_nr = mModel->getRows() - first_row; // clip if neccessary: + unsigned max_rows_nr; + if (mModel->getRows() < first_row) + max_rows_nr = 0; + else + max_rows_nr = mModel->getRows() - first_row; // clip if neccessary: if (max_rows_nr < rows_nr) rows_nr = max_rows_nr; // Now determine the first and last column // Take the easy way out; these are usually bounded and all visible. - int first_column = 0; - int last_column1 = mModel->getColumns(); + unsigned first_column = 0; + unsigned last_column1 = mModel->getColumns(); // Set up everything for drawing int height = getRowHeight(); int y_offset = first_row * height; - for (int r = first_row; r < first_row + rows_nr; ++r) + for (unsigned r = first_row; r < first_row + rows_nr; ++r) { int x_offset = 0; - for (int c = first_column; c + 1 <= last_column1; ++c) + for (unsigned c = first_column; c + 1 <= last_column1; ++c) { gcn::Widget *widget = mModel->getElementAt(r, c); int width = getColumnWidth(c); @@ -340,18 +344,21 @@ void GuiTable::draw(gcn::Graphics* graphics) graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, static_cast<int>(mAlpha * 255.0f))); - if (mLinewiseMode && r == mSelectedRow && c == 0) - { - graphics->fillRectangle(gcn::Rectangle(0, y_offset, - getWidth(), height)); - } - else if (!mLinewiseMode && - c == mSelectedColumn && r == mSelectedRow) + if (mSelectedRow > 0) { - graphics->fillRectangle(gcn::Rectangle(x_offset, y_offset, - width, height)); + if (mLinewiseMode && r == (unsigned)mSelectedRow && c == 0) + { + graphics->fillRectangle(gcn::Rectangle(0, y_offset, + getWidth(), height)); + } + else if (!mLinewiseMode && mSelectedColumn > 0 + && c == (unsigned)mSelectedColumn + && r == (unsigned)mSelectedRow) + { + graphics->fillRectangle(gcn::Rectangle(x_offset, y_offset, + width, height)); + } } - graphics->pushClipArea(bounds); widget->draw(graphics); graphics->popClipArea(); diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 8c33b4787..1b008a087 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -768,14 +768,17 @@ void Window::resetToDefaultSize() int Window::getResizeHandles(gcn::MouseEvent &event) { + if (event.getX() < 0 || event.getY() < 0) + return 0; + int resizeHandles = 0; - const int y = event.getY(); + const unsigned y = event.getY(); if (mGrip && (y > static_cast<int>(mTitleBarHeight) || (y < static_cast<int>(getPadding()) && mTitleBarHeight > getPadding()))) { - const int x = event.getX(); + const unsigned x = event.getX(); if (!getWindowArea().isPointInRect(x, y) && event.getSource() == this) { diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 6f856fc62..f455f1238 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -439,7 +439,7 @@ class Window : public gcn::Window, gcn::WidgetListener * border width, and determines mostly the size of the corner area * where two borders are moved at the same time. */ - static const int resizeBorderWidth = 10; + static const unsigned resizeBorderWidth = 10; GraphicsVertexes *mVertexes; bool mRedraw; }; diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 564c28f78..0533290b3 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -1173,9 +1173,16 @@ bool LocalPlayer::toggleSit() Being::Action newAction; switch (mAction) { - case STAND: newAction = SIT; break; - case SIT: newAction = STAND; break; - default: return true; + case STAND: newAction = SIT; + break; + case SIT: newAction = STAND; + break; + case MOVE: + case ATTACK: + case DEAD: + case HURT: + default: + return true; } Net::getPlayerHandler()->changeAction(newAction); diff --git a/src/map.cpp b/src/map.cpp index a33a87f67..36034cbcb 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -786,6 +786,8 @@ void Map::blockTile(int x, int y, BlockType type) mMetaTiles[tileNum].blockmask |= BLOCKMASK_MONSTER; break; default: + case BLOCKTYPE_NONE: + case NB_BLOCKTYPES: // Do nothing. break; } diff --git a/src/net/net.cpp b/src/net/net.cpp index 89f63cce3..7d530940a 100644 --- a/src/net/net.cpp +++ b/src/net/net.cpp @@ -166,11 +166,9 @@ void connectToServer(const ServerInfo &server) break; #endif case ServerInfo::TMWATHENA: - new TmwAthena::GeneralHandler; - break; - + case ServerInfo::UNKNOWN: default: - // Shouldn't happen... + new TmwAthena::GeneralHandler; break; } diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index 6078dd761..3f8bdab7b 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -707,9 +707,18 @@ void PlayerHandler::changeAction(Being::Action action) char type; switch (action) { - case Being::SIT: type = 2; break; - case Being::STAND: type = 3; break; - default: return; + case Being::SIT: + type = 2; + break; + case Being::STAND: + type = 3; + break; + default: + case Being::MOVE: + case Being::ATTACK: + case Being::DEAD: + case Being::HURT: + return; } MessageOut outMsg(CMSG_PLAYER_CHANGE_ACT); diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp index cd42fd865..b3f8f40d7 100644 --- a/src/particleemitter.cpp +++ b/src/particleemitter.cpp @@ -522,9 +522,9 @@ std::list<Particle *> ParticleEmitter::createParticles(int tick) float angleV = mParticleAngleVertical.value(tick); float power = mParticlePower.value(tick); newParticle->setVelocity( - static_cast<float>(cos(angleH) * cos(angleV) * power), - static_cast<float>(sin(angleH) * cos(angleV) * power), - static_cast<float>(sin(angleV) * power)); + static_cast<float>(cos(angleH) * cos(angleV)) * power, + static_cast<float>(sin(angleH) * cos(angleV)) * power, + static_cast<float>(sin(angleV)) * power); newParticle->setRandomness(mParticleRandomness.value(tick)); newParticle->setGravity(mParticleGravity.value(tick)); diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp index 91fec9947..1273d6bbf 100644 --- a/src/playerrelations.cpp +++ b/src/playerrelations.cpp @@ -259,6 +259,9 @@ unsigned int PlayerRelationsManager::checkPermissionSilently( permissions |= mDefaultPermissions; // widen break; + case PlayerRelation::DISREGARDED: + case PlayerRelation::IGNORED: + case PlayerRelation::ERASED: default: permissions &= mDefaultPermissions; // narrow } diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index c7515fc6b..5c88043ed 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -248,6 +248,20 @@ void ItemDB::load() itemInfo->addTag(mTags["Unusable"]); break; default: + case ITEM_EQUIPMENT_ONE_HAND_WEAPON: + case ITEM_EQUIPMENT_TWO_HANDS_WEAPON: + case ITEM_EQUIPMENT_TORSO: + case ITEM_EQUIPMENT_ARMS: + case ITEM_EQUIPMENT_HEAD: + case ITEM_EQUIPMENT_LEGS: + case ITEM_EQUIPMENT_SHIELD: + case ITEM_EQUIPMENT_RING: + case ITEM_EQUIPMENT_NECKLACE: + case ITEM_EQUIPMENT_FEET: + case ITEM_EQUIPMENT_AMMO: + case ITEM_EQUIPMENT_CHARM: + case ITEM_SPRITE_RACE: + case ITEM_SPRITE_HAIR: itemInfo->addTag(mTags["Equipment"]); break; } diff --git a/src/vector.h b/src/vector.h index 87e9c647a..b2e5f136b 100644 --- a/src/vector.h +++ b/src/vector.h @@ -38,15 +38,15 @@ class Vector * Constructor. */ Vector(): - x(0.0f), - y(0.0f), - z(0.0f) + x(0), + y(0), + z(0) {} /** * Constructor. */ - Vector(float x, float y, float z = 0.0f): + Vector(int x, int y, int z = 0.0f): x(x), y(y), z(z) @@ -67,13 +67,13 @@ class Vector */ bool isNull() const { - return x == 0.0f && y == 0.0f && z == 0.0f; + return x == 0 && y == 0 && z == 0; } /** * Scale vector operator. */ - Vector operator*(float c) const + Vector operator*(int c) const { return Vector(x * c, y * c, @@ -83,7 +83,7 @@ class Vector /** * In-place scale vector operator. */ - Vector &operator*=(float c) + Vector &operator*=(int c) { x *= c; y *= c; @@ -94,7 +94,7 @@ class Vector /** * Scale vector operator. */ - Vector operator/(float c) const + Vector operator/(int c) const { return Vector(x / c, y / c, @@ -104,7 +104,7 @@ class Vector /** * In-place scale vector operator. */ - Vector &operator/=(float c) + Vector &operator/=(int c) { x /= c; y /= c; @@ -189,7 +189,7 @@ class Vector return Vector(x / l, y / l, z / l); } - float x, y, z; + int x, y, z; }; /** |