From e72f26151bca6c5a73d0377e385c0f7dd7cab3aa Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 9 Sep 2011 00:47:31 +0300 Subject: Add to inventory filter by letters from item names. --- src/game.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index 5a372a6bd..aaa9694bf 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -785,7 +785,8 @@ void Game::handleInput() && !chatWindow->isInputFocused() && !setupWindow->isVisible() && !player_node->getAwayMode() - && !NpcDialog::isAnyInputFocused()) + && !NpcDialog::isAnyInputFocused() + && !InventoryWindow::isAnyInputFocused()) { bool wearOutfit = false; bool copyOutfit = false; @@ -848,8 +849,11 @@ void Game::handleInput() } if (keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT)) { - if (chatWindow->requestChatFocus()) - used = true; + if (!InventoryWindow::isAnyInputFocused()) + { + if (chatWindow->requestChatFocus()) + used = true; + } } if (dialog) { @@ -861,7 +865,8 @@ void Game::handleInput() } if ((!chatWindow->isInputFocused() && - !NpcDialog::isAnyInputFocused()) + !NpcDialog::isAnyInputFocused() && + !InventoryWindow::isAnyInputFocused()) || (event.key.keysym.mod & KMOD_ALT)) { if (keyboard.isKeyActive(keyboard.KEY_PREV_CHAT_TAB)) @@ -948,7 +953,8 @@ void Game::handleInput() && mValidSpeed && !setupWindow->isVisible() && !player_node->getAwayMode() - && !NpcDialog::isAnyInputFocused()) + && !NpcDialog::isAnyInputFocused() + && !InventoryWindow::isAnyInputFocused()) { switch (tKey) { @@ -1085,7 +1091,8 @@ void Game::handleInput() && !chatWindow->isInputFocused() && !NpcDialog::isAnyInputFocused() && !player_node->getAwayMode() - && !keyboard.isKeyActive(keyboard.KEY_TARGET)) + && !keyboard.isKeyActive(keyboard.KEY_TARGET) + && !InventoryWindow::isAnyInputFocused()) { const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); -- cgit v1.2.3-70-g09d2 From 4484b433abc8f07bcf7d4d22fd946e00b66b078d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 9 Sep 2011 19:43:40 +0300 Subject: Fix first part of shadow variables/methods errors. --- src/client.cpp | 30 +++++----- src/game.cpp | 12 ++-- src/graphics.h | 2 +- src/gui/changeemaildialog.cpp | 18 +++--- src/gui/changeemaildialog.h | 2 +- src/gui/changepassworddialog.cpp | 20 +++---- src/gui/changepassworddialog.h | 2 +- src/gui/charselectdialog.cpp | 10 ++-- src/gui/charselectdialog.h | 2 +- src/gui/chatwindow.cpp | 4 +- src/gui/palette.h | 13 +++-- src/gui/popupmenu.cpp | 8 +-- src/gui/setup_video.cpp | 30 +++++----- src/gui/spellpopup.cpp | 8 +-- src/gui/statuspopup.cpp | 6 +- src/gui/textpopup.cpp | 6 +- src/gui/widgets/avatarlistbox.cpp | 3 +- src/gui/widgets/browserbox.cpp | 14 ++--- src/gui/widgets/popup.cpp | 10 ++-- src/gui/widgets/progressbar.h | 4 +- src/gui/widgets/window.cpp | 84 +++++++++++++-------------- src/gui/windowmenu.cpp | 8 +-- src/guichan/cliprectangle.cpp | 16 ++--- src/guichan/include/guichan/cliprectangle.hpp | 32 +++++----- src/guichan/include/guichan/inputevent.hpp | 8 +-- src/guichan/include/guichan/keyevent.hpp | 20 +++---- src/guichan/include/guichan/mouseevent.hpp | 16 ++--- src/guichan/inputevent.cpp | 16 ++--- src/guichan/keyevent.cpp | 20 +++---- src/guichan/mouseevent.cpp | 16 ++--- src/map.h | 6 +- src/position.h | 4 +- src/resources/ambientlayer.cpp | 8 +-- src/resources/colordb.h | 8 +-- src/resources/itemdb.h | 8 +-- src/resources/spritedef.h | 6 +- src/vector.h | 8 +-- 37 files changed, 242 insertions(+), 246 deletions(-) (limited to 'src/game.cpp') diff --git a/src/client.cpp b/src/client.cpp index 472c862e6..b9e9735c9 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -140,11 +140,11 @@ Configuration config; /**< XML file configuration reader */ Configuration serverConfig; /**< XML file server configuration reader */ Configuration branding; /**< XML branding information reader */ Configuration paths; /**< XML default paths information reader */ -Logger *logger; /**< Log object */ -ChatLogger *chatLogger; /**< Chat log object */ +Logger *logger = 0; /**< Log object */ +ChatLogger *chatLogger = 0; /**< Chat log object */ KeyboardConfig keyboard; -UserPalette *userPalette; -Graphics *graphics; +UserPalette *userPalette = 0; +Graphics *mainGraphics = 0; Sound sound; @@ -440,20 +440,20 @@ Client::Client(const Options &options): switch(useOpenGL) { case 0: - graphics = new Graphics; + mainGraphics = new Graphics; break; case 1: default: - graphics = new OpenGLGraphics; + mainGraphics = new OpenGLGraphics; break; case 2: - graphics = new OpenGL1Graphics; + mainGraphics = new OpenGL1Graphics; break; }; #else // Create the graphics context - graphics = new Graphics; + mainGraphics = new Graphics; #endif runCounters = config.getBoolValue("packetcounters"); @@ -465,7 +465,7 @@ Client::Client(const Options &options): const bool hwaccel = config.getBoolValue("hwaccel"); // Try to set the desired video mode - if (!graphics->setVideoMode(width, height, bpp, fullscreen, hwaccel)) + if (!mainGraphics->setVideoMode(width, height, bpp, fullscreen, hwaccel)) { logger->log(strprintf("Couldn't set %dx%dx%d video mode: %s", width, height, bpp, SDL_GetError())); @@ -482,7 +482,7 @@ Client::Client(const Options &options): config.setValueInt("screenwidth", oldWidth); config.setValueInt("screenheight", oldHeight); config.setValue("screen", oldFullscreen); - if (!graphics->setVideoMode(oldWidth, oldHeight, bpp, + if (!mainGraphics->setVideoMode(oldWidth, oldHeight, bpp, oldFullscreen, hwaccel)) { logger->error(strprintf("Couldn't restore %dx%dx%d " @@ -493,7 +493,7 @@ Client::Client(const Options &options): } // Initialize for drawing - graphics->_beginDraw(); + mainGraphics->_beginDraw(); Theme::selectSkin(); // Theme::prepareThemePath(); @@ -507,7 +507,7 @@ Client::Client(const Options &options): // Initialize the drop shortcuts. dropShortcut = new DropShortcut; - gui = new Gui(graphics); + gui = new Gui(mainGraphics); // Initialize sound engine try @@ -645,8 +645,8 @@ Client::~Client() logger->log1("Quitting3"); - delete graphics; - graphics = 0; + delete mainGraphics; + mainGraphics = 0; logger->log1("Quitting4"); @@ -760,7 +760,7 @@ int Client::exec() frame_count++; if (gui) gui->draw(); - graphics->updateScreen(); + mainGraphics->updateScreen(); // logger->log("active"); } else diff --git a/src/game.cpp b/src/game.cpp index aaa9694bf..a0635f42f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -371,8 +371,8 @@ Game::Game(): // Create the viewport viewport = new Viewport; - viewport->setDimension(gcn::Rectangle(0, 0, graphics->mWidth, - graphics->mHeight)); + viewport->setDimension(gcn::Rectangle(0, 0, mainGraphics->mWidth, + mainGraphics->mHeight)); gcn::Container *top = static_cast(gui->getTop()); top->add(viewport); @@ -459,14 +459,14 @@ static bool saveScreenshot() if (!config.getBoolValue("showip")) { - graphics->setSecure(true); + mainGraphics->setSecure(true); gui->draw(); - screenshot = graphics->getScreenshot(); - graphics->setSecure(false); + screenshot = mainGraphics->getScreenshot(); + mainGraphics->setSecure(false); } else { - screenshot = graphics->getScreenshot(); + screenshot = mainGraphics->getScreenshot(); } if (!screenshot) diff --git a/src/graphics.h b/src/graphics.h index 53b4b7c72..f3e0bd05d 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -292,6 +292,6 @@ class Graphics : public gcn::SDLGraphics bool mSecure; }; -extern Graphics *graphics; +extern Graphics *mainGraphics; #endif diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index c24624bc2..69af649e2 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -44,10 +44,10 @@ #include "debug.h" -ChangeEmailDialog::ChangeEmailDialog(LoginData *loginData): +ChangeEmailDialog::ChangeEmailDialog(LoginData *data): Window(_("Change Email Address"), true), mWrongDataNoticeListener(new WrongDataNoticeListener), - mLoginData(loginData) + mLoginData(data) { gcn::Label *accountLabel = new Label(strprintf(_("Account: %s"), mLoginData->username.c_str())); @@ -120,7 +120,7 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) logger->log("ChangeEmailDialog::Email change, Username is %s", username.c_str()); - std::stringstream errorMessage; + std::stringstream errorMsg; int error = 0; unsigned int min = Net::getLoginHandler()->getMinPasswordLength(); @@ -129,21 +129,21 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) if (newFirstEmail.length() < min) { // First email address too short - errorMessage << strprintf(_("The new email address needs to be at " - "least %d characters long."), min); + errorMsg << strprintf(_("The new email address needs to be at " + "least %d characters long."), min); error = 1; } else if (newFirstEmail.length() > max - 1 ) { // First email address too long - errorMessage << strprintf(_("The new email address needs to be " - "less than %d characters long."), max); + errorMsg << strprintf(_("The new email address needs to be " + "less than %d characters long."), max); error = 1; } else if (newFirstEmail != newSecondEmail) { // Second Pass mismatch - errorMessage << _("The email address entries mismatch."); + errorMsg << _("The email address entries mismatch."); error = 2; } @@ -154,7 +154,7 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) else if (error == 2) mWrongDataNoticeListener->setTarget(this->mSecondEmailField); - OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str()); + OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str()); if (dlg) dlg->addActionListener(mWrongDataNoticeListener); } diff --git a/src/gui/changeemaildialog.h b/src/gui/changeemaildialog.h index e130a9074..fccb5cb1c 100644 --- a/src/gui/changeemaildialog.h +++ b/src/gui/changeemaildialog.h @@ -46,7 +46,7 @@ class ChangeEmailDialog : public Window, public gcn::ActionListener * * @see Window::Window */ - ChangeEmailDialog(LoginData *loginData); + ChangeEmailDialog(LoginData *data); /** * Destructor. diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index 30012ae52..56db37ebb 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -46,10 +46,10 @@ #include "debug.h" -ChangePasswordDialog::ChangePasswordDialog(LoginData *loginData): +ChangePasswordDialog::ChangePasswordDialog(LoginData *data): Window(_("Change Password"), true), mWrongDataNoticeListener(new WrongDataNoticeListener), - mLoginData(loginData) + mLoginData(data) { gcn::Label *accountLabel = new Label( strprintf(_("Account: %s"), mLoginData->username.c_str())); @@ -101,7 +101,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) logger->log("ChangePasswordDialog::Password change, Username is %s", username.c_str()); - std::stringstream errorMessage; + std::stringstream errorMsg; int error = 0; unsigned int min = Net::getLoginHandler()->getMinPasswordLength(); @@ -111,27 +111,27 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) if (oldPassword.empty()) { // No old password - errorMessage << _("Enter the old password first."); + errorMsg << _("Enter the old password first."); error = 1; } else if (newFirstPass.length() < min) { // First password too short - errorMessage << strprintf(_("The new password needs to be at least" - " %d characters long."), min); + errorMsg << strprintf(_("The new password needs to be at least" + " %d characters long."), min); error = 2; } else if (newFirstPass.length() > max - 1 ) { // First password too long - errorMessage << strprintf(_("The new password needs to be less " - "than %d characters long."), max); + errorMsg << strprintf(_("The new password needs to be less " + "than %d characters long."), max); error = 2; } else if (newFirstPass != newSecondPass) { // Second Pass mismatch - errorMessage << _("The new password entries mismatch."); + errorMsg << _("The new password entries mismatch."); error = 3; } @@ -144,7 +144,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) else if (error == 3) mWrongDataNoticeListener->setTarget(this->mSecondPassField); - OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str()); + OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str()); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/changepassworddialog.h b/src/gui/changepassworddialog.h index 3b0626922..fca8b4946 100644 --- a/src/gui/changepassworddialog.h +++ b/src/gui/changepassworddialog.h @@ -46,7 +46,7 @@ class ChangePasswordDialog : public Window, public gcn::ActionListener * * @see Window::Window */ - ChangePasswordDialog(LoginData *loginData); + ChangePasswordDialog(LoginData *data); /** * Destructor diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 75468d1ab..f926a90aa 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -121,20 +121,20 @@ class CharacterDisplay : public Container Button *mDelete; }; -CharSelectDialog::CharSelectDialog(LoginData *loginData): +CharSelectDialog::CharSelectDialog(LoginData *data): Window(_("Account and Character Management")), mLocked(false), mUnregisterButton(0), mChangeEmailButton(0), mCharacterEntries(0), - mLoginData(loginData), + mLoginData(data), mCharHandler(Net::getCharHandler()), mDeleteDialog(0), mDeleteIndex(-1) { setCloseButton(false); - mAccountNameLabel = new Label(loginData->username); + mAccountNameLabel = new Label(mLoginData->username); mSwitchLoginButton = new Button(_("Switch Login"), "switch", this); mChangePasswordButton = new Button(_("Change Password"), "change_password", this); @@ -373,7 +373,7 @@ void CharSelectDialog::setLocked(bool locked) } bool CharSelectDialog::selectByName(const std::string &name, - SelectAction action) + SelectAction selAction) { if (mLocked) return false; @@ -387,7 +387,7 @@ bool CharSelectDialog::selectByName(const std::string &name, { if (mCharacterEntries[i]) mCharacterEntries[i]->requestFocus(); - if (action == Choose) + if (selAction == Choose) attemptCharacterSelect(i); return true; } diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h index bcbbb7679..0dfe90733 100644 --- a/src/gui/charselectdialog.h +++ b/src/gui/charselectdialog.h @@ -60,7 +60,7 @@ class CharSelectDialog : public Window, public gcn::ActionListener, /** * Constructor. */ - CharSelectDialog(LoginData *loginData); + CharSelectDialog(LoginData *data); ~CharSelectDialog(); diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 639125739..1b9877363 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -666,8 +666,8 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event) { int newX = std::max(0, getX() + event.getX() - mDragOffsetX); int newY = std::max(0, getY() + event.getY() - mDragOffsetY); - newX = std::min(graphics->mWidth - getWidth(), newX); - newY = std::min(graphics->mHeight - getHeight(), newY); + newX = std::min(mainGraphics->mWidth - getWidth(), newX); + newY = std::min(mainGraphics->mHeight - getHeight(), newY); setPosition(newX, newY); } } diff --git a/src/gui/palette.h b/src/gui/palette.h index 1cebe236f..645260280 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -182,13 +182,14 @@ class Palette int delay; int committedDelay; - void set(int type, gcn::Color& color, GradientType grad, int delay) + void set(int type0, gcn::Color& color0, GradientType grad0, + int delay0) { - ColorElem::type = type; - ColorElem::color = color; - ColorElem::testColor = color; - ColorElem::grad = grad; - ColorElem::delay = delay; + ColorElem::type = type0; + ColorElem::color = color0; + ColorElem::testColor = color0; + ColorElem::grad = grad0; + ColorElem::delay = delay0; ColorElem::gradientIndex = rand(); } diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index a329488ce..7e43c9954 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -2029,10 +2029,10 @@ void PopupMenu::showUndressPopup(int x, int y, Being *being, Item *item) void PopupMenu::showPopup(int x, int y) { setContentSize(mBrowserBox->getWidth() + 8, mBrowserBox->getHeight() + 8); - if (graphics->mWidth < (x + getWidth() + 5)) - x = graphics->mWidth - getWidth(); - if (graphics->mHeight < (y + getHeight() + 5)) - y = graphics->mHeight - getHeight(); + if (mainGraphics->mWidth < (x + getWidth() + 5)) + x = mainGraphics->mWidth - getWidth(); + if (mainGraphics->mHeight < (y + getHeight() + 5)) + y = mainGraphics->mHeight - getHeight(); setPosition(x, y); setVisible(true); requestMoveToTop(); diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 0bfab1438..7bbcd9a2c 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -59,7 +59,7 @@ #include "debug.h" -extern Graphics *graphics; +extern Graphics *mainGraphics; /** * The list model for mode list. @@ -157,8 +157,8 @@ ModeListModel::ModeListModel() addCustomMode("1280x1024"); addCustomMode("1400x900"); addCustomMode("1500x990"); - addCustomMode(toString(graphics->mWidth) + "x" - + toString(graphics->mHeight)); + addCustomMode(toString(mainGraphics->mWidth) + "x" + + toString(mainGraphics->mHeight)); std::sort(mVideoModes.begin(), mVideoModes.end(), modeSorter); mVideoModes.push_back("custom"); @@ -348,8 +348,8 @@ Setup_Video::Setup_Video(): mFpsCheckBox->setSelected(mFps > 0); // Pre-select the current video mode. - std::string videoMode = toString(graphics->mWidth) + "x" - + toString(graphics->mHeight); + std::string videoMode = toString(mainGraphics->mWidth) + "x" + + toString(mainGraphics->mHeight); mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); mModeList->setActionEventId("videomode"); @@ -473,10 +473,10 @@ void Setup_Video::apply() if (!config.getIntValue("opengl")) { #endif - if (!graphics->setFullscreen(fullscreen)) + if (!mainGraphics->setFullscreen(fullscreen)) { fullscreen = !fullscreen; - if (!graphics->setFullscreen(fullscreen)) + if (!mainGraphics->setFullscreen(fullscreen)) { std::stringstream errorMessage; if (fullscreen) @@ -564,11 +564,11 @@ void Setup_Video::cancel() config.setValue("screen", mFullScreenEnabled); // Set back to the current video mode. - std::string videoMode = toString(graphics->mWidth) + "x" - + toString(graphics->mHeight); + std::string videoMode = toString(mainGraphics->mWidth) + "x" + + toString(mainGraphics->mHeight); mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); - config.setValue("screenwidth", graphics->mWidth); - config.setValue("screenheight", graphics->mHeight); + config.setValue("screenwidth", mainGraphics->mWidth); + config.setValue("screenheight", mainGraphics->mHeight); config.setValue("customcursor", mCustomCursorEnabled); config.setValue("particleeffects", mParticleEffectsEnabled); @@ -612,9 +612,9 @@ void Setup_Video::action(const gcn::ActionEvent &event) return; // TODO: Find out why the drawing area doesn't resize without a restart. - if (width != graphics->mWidth || height != graphics->mHeight) + if (width != mainGraphics->mWidth || height != mainGraphics->mHeight) { - if (width < graphics->mWidth || height < graphics->mHeight) + if (width < mainGraphics->mWidth || height < mainGraphics->mHeight) new OkDialog(_("Screen Resolution Changed"), _("Restart your client for the change to take effect.") + std::string("\n") + @@ -625,8 +625,8 @@ void Setup_Video::action(const gcn::ActionEvent &event) } config.setValue("oldscreen", config.getBoolValue("screen")); - config.setValue("oldscreenwidth", graphics->mWidth); - config.setValue("oldscreenheight", graphics->mHeight); + config.setValue("oldscreenwidth", mainGraphics->mWidth); + config.setValue("oldscreenheight", mainGraphics->mHeight); config.setValue("screenwidth", width); config.setValue("screenheight", height); } diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp index a918e037d..f87e691de 100644 --- a/src/gui/spellpopup.cpp +++ b/src/gui/spellpopup.cpp @@ -80,14 +80,14 @@ void SpellPopup::view(int x, int y) int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->mWidth) + if (posX + getWidth() > mainGraphics->mWidth) { - if (graphics->mWidth > getWidth()) - posX = graphics->mWidth - getWidth(); + if (mainGraphics->mWidth > getWidth()) + posX = mainGraphics->mWidth - getWidth(); else posX = 0; } - if (posY + getHeight() > graphics->mHeight) + if (posY + getHeight() > mainGraphics->mHeight) { if (y > getHeight() + distance) posY = y - getHeight() - distance; diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp index bb7a295ab..9214f1406 100644 --- a/src/gui/statuspopup.cpp +++ b/src/gui/statuspopup.cpp @@ -169,9 +169,9 @@ void StatusPopup::view(int x, int y) int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->mWidth) - posX = graphics->mWidth - getWidth(); - if (posY + getHeight() > graphics->mHeight) + if (posX + getWidth() > mainGraphics->mWidth) + posX = mainGraphics->mWidth - getWidth(); + if (posY + getHeight() > mainGraphics->mHeight) posY = y - getHeight() - distance; update(); diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp index 1ff601154..65c712461 100644 --- a/src/gui/textpopup.cpp +++ b/src/gui/textpopup.cpp @@ -96,9 +96,9 @@ void TextPopup::show(int x, int y, const std::string &str1, int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->mWidth) - posX = graphics->mWidth - getWidth(); - if (posY + getHeight() > graphics->mHeight) + if (posX + getWidth() > mainGraphics->mWidth) + posX = mainGraphics->mWidth - getWidth(); + if (posY + getHeight() > mainGraphics->mHeight) posY = y - getHeight() - distance; setPosition(posX, posY); diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index d4764cba5..29fca7662 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -373,7 +373,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) default: { Map *map = viewport->getMap(); - Avatar *ava = model->getAvatarAt(selected); + ava = model->getAvatarAt(selected); if (map && ava) { MapItem *mapItem = map->findPortalXY( @@ -384,7 +384,6 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) } } } - else if (event.getButton() == gcn::MouseEvent::MIDDLE) { if (ava->getType() == AVATAR_PLAYER && chatWindow) diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 65a25363d..c20eb4622 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -210,23 +210,23 @@ void BrowserBox::addRow(const std::string &row, bool atTop) for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); ++i) { - std::string row = *i; - for (unsigned int j = 0; j < row.size(); j++) + std::string tempRow = *i; + for (unsigned int j = 0; j < tempRow.size(); j++) { - std::string character = row.substr(j, 1); + std::string character = tempRow.substr(j, 1); x += font->getWidth(character); nextChar = j + 1; // Wraping between words (at blank spaces) - if ((nextChar < row.size()) && (row.at(nextChar) == ' ')) + if (nextChar < tempRow.size() && tempRow.at(nextChar) == ' ') { int nextSpacePos = static_cast( - row.find(" ", (nextChar + 1))); + tempRow.find(" ", (nextChar + 1))); if (nextSpacePos <= 0) - nextSpacePos = static_cast(row.size()) - 1; + nextSpacePos = static_cast(tempRow.size()) - 1; unsigned nextWordWidth = font->getWidth( - row.substr(nextChar, + tempRow.substr(nextChar, (nextSpacePos - nextChar))); if ((x + nextWordWidth + 10) > (unsigned)getWidth()) diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 38088770b..ebfdbe303 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -44,8 +44,8 @@ Popup::Popup(const std::string &name, const std::string &skin): mPopupName(name), mMinWidth(100), mMinHeight(40), - mMaxWidth(graphics->mWidth), - mMaxHeight(graphics->mHeight), + mMaxWidth(mainGraphics->mWidth), + mMaxHeight(mainGraphics->mHeight), mVertexes(new GraphicsVertexes()), mRedraw(true) { @@ -190,9 +190,9 @@ void Popup::position(int x, int y) int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->mWidth) - posX = graphics->mWidth - getWidth(); - if (posY + getHeight() > graphics->mHeight) + if (posX + getWidth() > mainGraphics->mWidth) + posX = mainGraphics->mWidth - getWidth(); + if (posY + getHeight() > mainGraphics->mHeight) posY = y - getHeight() - distance; setPosition(posX, posY); diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index 52a26ddac..36ed96bd2 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -94,8 +94,8 @@ class ProgressBar : public gcn::Widget, public gcn::WidgetListener /** * Sets the text shown on the progress bar. */ - void setText(const std::string &text) - { mText = text; } + void setText(const std::string &str) + { mText = str; } /** * Returns the text shown on the progress bar. diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 9709f4c8a..05509ab39 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -63,8 +63,8 @@ Window::Window(const std::string &caption, bool modal, Window *parent, mStickyButtonLock(false), mMinWinWidth(100), mMinWinHeight(40), - mMaxWinWidth(graphics->mWidth), - mMaxWinHeight(graphics->mHeight), + mMaxWinWidth(mainGraphics->mWidth), + mMaxWinHeight(mainGraphics->mHeight), mVertexes(new GraphicsVertexes()), mRedraw(true) { @@ -244,39 +244,39 @@ void Window::setLocationRelativeTo(ImageRect::ImagePosition position, } else if (position == ImageRect::UPPER_CENTER) { - offsetX += (graphics->mWidth - getWidth()) / 2; + offsetX += (mainGraphics->mWidth - getWidth()) / 2; } else if (position == ImageRect::UPPER_RIGHT) { - offsetX += graphics->mWidth - getWidth(); + offsetX += mainGraphics->mWidth - getWidth(); } else if (position == ImageRect::LEFT) { - offsetY += (graphics->mHeight - getHeight()) / 2; + offsetY += (mainGraphics->mHeight - getHeight()) / 2; } else if (position == ImageRect::CENTER) { - offsetX += (graphics->mWidth - getWidth()) / 2; - offsetY += (graphics->mHeight - getHeight()) / 2; + offsetX += (mainGraphics->mWidth - getWidth()) / 2; + offsetY += (mainGraphics->mHeight - getHeight()) / 2; } else if (position == ImageRect::RIGHT) { - offsetX += graphics->mWidth - getWidth(); - offsetY += (graphics->mHeight - getHeight()) / 2; + offsetX += mainGraphics->mWidth - getWidth(); + offsetY += (mainGraphics->mHeight - getHeight()) / 2; } else if (position == ImageRect::LOWER_LEFT) { - offsetY += graphics->mHeight - getHeight(); + offsetY += mainGraphics->mHeight - getHeight(); } else if (position == ImageRect::LOWER_CENTER) { - offsetX += (graphics->mWidth - getWidth()) / 2; - offsetY += graphics->mHeight - getHeight(); + offsetX += (mainGraphics->mWidth - getWidth()) / 2; + offsetY += mainGraphics->mHeight - getHeight(); } else if (position == ImageRect::LOWER_RIGHT) { - offsetX += graphics->mWidth - getWidth(); - offsetY += graphics->mHeight - getHeight(); + offsetX += mainGraphics->mWidth - getWidth(); + offsetY += mainGraphics->mHeight - getHeight(); } setPosition(offsetX, offsetY); @@ -579,8 +579,8 @@ void Window::mouseDragged(gcn::MouseEvent &event) { int newX = std::max(0, getX()); int newY = std::max(0, getY()); - newX = std::min(graphics->mWidth - getWidth(), newX); - newY = std::min(graphics->mHeight - getHeight(), newY); + newX = std::min(mainGraphics->mWidth - getWidth(), newX); + newY = std::min(mainGraphics->mHeight - getHeight(), newY); setPosition(newX, newY); } @@ -621,14 +621,10 @@ void Window::mouseDragged(gcn::MouseEvent &event) newDim.height += newDim.y; newDim.y = 0; } - if (newDim.x + newDim.width > graphics->mWidth) - { - newDim.width = graphics->mWidth - newDim.x; - } - if (newDim.y + newDim.height > graphics->mHeight) - { - newDim.height = graphics->mHeight - newDim.y; - } + if (newDim.x + newDim.width > mainGraphics->mWidth) + newDim.width = mainGraphics->mWidth - newDim.x; + if (newDim.y + newDim.height > mainGraphics->mHeight) + newDim.height = mainGraphics->mHeight - newDim.y; // Update mouse offset when dragging bottom or right border if (mouseResize & BOTTOM) @@ -790,39 +786,39 @@ void Window::setDefaultSize(int defaultWidth, int defaultHeight, } else if (position == ImageRect::UPPER_CENTER) { - x = (graphics->mWidth - defaultWidth) / 2; + x = (mainGraphics->mWidth - defaultWidth) / 2; } else if (position == ImageRect::UPPER_RIGHT) { - x = graphics->mWidth - defaultWidth; + x = mainGraphics->mWidth - defaultWidth; } else if (position == ImageRect::LEFT) { - y = (graphics->mHeight - defaultHeight) / 2; + y = (mainGraphics->mHeight - defaultHeight) / 2; } else if (position == ImageRect::CENTER) { - x = (graphics->mWidth - defaultWidth) / 2; - y = (graphics->mHeight - defaultHeight) / 2; + x = (mainGraphics->mWidth - defaultWidth) / 2; + y = (mainGraphics->mHeight - defaultHeight) / 2; } else if (position == ImageRect::RIGHT) { - x = graphics->mWidth - defaultWidth; - y = (graphics->mHeight - defaultHeight) / 2; + x = mainGraphics->mWidth - defaultWidth; + y = (mainGraphics->mHeight - defaultHeight) / 2; } else if (position == ImageRect::LOWER_LEFT) { - y = graphics->mHeight - defaultHeight; + y = mainGraphics->mHeight - defaultHeight; } else if (position == ImageRect::LOWER_CENTER) { - x = (graphics->mWidth - defaultWidth) / 2; - y = graphics->mHeight - defaultHeight; + x = (mainGraphics->mWidth - defaultWidth) / 2; + y = mainGraphics->mHeight - defaultHeight; } else if (position == ImageRect::LOWER_RIGHT) { - x = graphics->mWidth - defaultWidth; - y = graphics->mHeight - defaultHeight; + x = mainGraphics->mWidth - defaultWidth; + y = mainGraphics->mHeight - defaultHeight; } mDefaultX = x - offsetX; @@ -994,11 +990,11 @@ void Window::checkIfIsOffScreen(bool partially, bool entirely) // Look if the window is partially off-screen limits... if (partially) { - if (winDimension.x + winDimension.width > graphics->mWidth) - winDimension.x = graphics->mWidth - winDimension.width; + if (winDimension.x + winDimension.width > mainGraphics->mWidth) + winDimension.x = mainGraphics->mWidth - winDimension.width; - if (winDimension.y + winDimension.height > graphics->mHeight) - winDimension.y = graphics->mHeight - winDimension.height; + if (winDimension.y + winDimension.height > mainGraphics->mHeight) + winDimension.y = mainGraphics->mHeight - winDimension.height; setDimension(winDimension); return; @@ -1006,11 +1002,11 @@ void Window::checkIfIsOffScreen(bool partially, bool entirely) if (entirely) { - if (winDimension.x > graphics->mWidth) - winDimension.x = graphics->mWidth - winDimension.width; + if (winDimension.x > mainGraphics->mWidth) + winDimension.x = mainGraphics->mWidth - winDimension.width; - if (winDimension.y > graphics->mHeight) - winDimension.y = graphics->mHeight - winDimension.height; + if (winDimension.y > mainGraphics->mHeight) + winDimension.y = mainGraphics->mHeight - winDimension.height; } setDimension(winDimension); } diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 8431cece1..eaec791ee 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -99,9 +99,9 @@ WindowMenu::WindowMenu(): KeyboardConfig::KEY_WINDOW_DIDYOUKNOW); addButton(N_("SET"), _("Setup"), x, h, KeyboardConfig::KEY_WINDOW_SETUP); - if (graphics) + if (mainGraphics) { - setDimension(gcn::Rectangle(graphics->mWidth - x - 3, + setDimension(gcn::Rectangle(mainGraphics->mWidth - x - 3, 3, x - 3, h)); } @@ -345,9 +345,9 @@ void WindowMenu::updateButtons() h = btn->getHeight(); } } - if (graphics) + if (mainGraphics) { - setDimension(gcn::Rectangle(graphics->mWidth - x - 3, + setDimension(gcn::Rectangle(mainGraphics->mWidth - x - 3, 3, x - 3, h)); } } diff --git a/src/guichan/cliprectangle.cpp b/src/guichan/cliprectangle.cpp index feaa47729..6effb48c8 100644 --- a/src/guichan/cliprectangle.cpp +++ b/src/guichan/cliprectangle.cpp @@ -61,15 +61,15 @@ namespace gcn yOffset = 0; } - ClipRectangle::ClipRectangle(int x, int y, int width, int height, - int xOffset, int yOffset) + ClipRectangle::ClipRectangle(int x0, int y0, int width0, int height0, + int xOffset0, int yOffset0) { - this->x = x; - this->y = y; - this->width = width; - this->height = height; - this->xOffset = xOffset; - this->yOffset = yOffset; + x = x0; + y = y0; + width = width0; + height = height0; + xOffset = xOffset0; + yOffset = yOffset0; } const ClipRectangle& ClipRectangle::operator=(const Rectangle& other) diff --git a/src/guichan/include/guichan/cliprectangle.hpp b/src/guichan/include/guichan/cliprectangle.hpp index 792c40bb9..b5aa5e4af 100644 --- a/src/guichan/include/guichan/cliprectangle.hpp +++ b/src/guichan/include/guichan/cliprectangle.hpp @@ -67,23 +67,23 @@ namespace gcn /** * Constructor. * - * @param x The rectangle x coordinate. - * @param y The rectangle y coordinate. - * @param width The rectangle width. - * @param height The rectangle height. - * @param xOffset The offset of the x coordinate. Used to for - * calculating the actual screen coordinate from - * the relative screen coordinate. - * @param yOffset The offset of the y coordinate. Used to for - * calculating the actual screen coordinate from - * the relative screen coordinate. + * @param x0 The rectangle x coordinate. + * @param y0 The rectangle y coordinate. + * @param width0 The rectangle width. + * @param height0 The rectangle height. + * @param xOffset0 The offset of the x coordinate. Used to for + * calculating the actual screen coordinate from + * the relative screen coordinate. + * @param yOffset0 The offset of the y coordinate. Used to for + * calculating the actual screen coordinate from + * the relative screen coordinate. */ - ClipRectangle(int x, - int y, - int width, - int height, - int xOffset, - int yOffset); + ClipRectangle(int x0, + int y0, + int width0, + int height0, + int xOffset0, + int yOffset0); /** * Copy constructor. Copies x, y, width and height diff --git a/src/guichan/include/guichan/inputevent.hpp b/src/guichan/include/guichan/inputevent.hpp index 8594d3dae..f252341cf 100644 --- a/src/guichan/include/guichan/inputevent.hpp +++ b/src/guichan/include/guichan/inputevent.hpp @@ -69,10 +69,10 @@ namespace gcn * @param isMetaPressed True if meta is pressed, false otherwise. */ InputEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed); + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed); /** * Checks if shift is pressed. diff --git a/src/guichan/include/guichan/keyevent.hpp b/src/guichan/include/guichan/keyevent.hpp index f42601235..5c10238c5 100644 --- a/src/guichan/include/guichan/keyevent.hpp +++ b/src/guichan/include/guichan/keyevent.hpp @@ -71,22 +71,22 @@ namespace gcn * Constructor. * * @param source The source widget of the event. - * @param isShiftPressed True if shift is pressed, false otherwise. - * @param isControlPressed True if control is pressed, false otherwise. - * @param isAltPressed True if alt is pressed, false otherwise. - * @param isMetaPressed True if meta is pressed, false otherwise. + * @param shiftPressed True if shift is pressed, false otherwise. + * @param controlPressed True if control is pressed, false otherwise. + * @param altPressed True if alt is pressed, false otherwise. + * @param metaPressed True if meta is pressed, false otherwise. * @param type The type of the event. A value from KeyEventType. - * @param isNumericPad True if the event occured on the numeric pad, + * @param numericPad True if the event occured on the numeric pad, * false otherwise. * @param key The key of the event. */ KeyEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed, + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed, unsigned int type, - bool isNumericPad, + bool numericPad, const Key& key); /** diff --git a/src/guichan/include/guichan/mouseevent.hpp b/src/guichan/include/guichan/mouseevent.hpp index 280d373e6..6f6dc828c 100644 --- a/src/guichan/include/guichan/mouseevent.hpp +++ b/src/guichan/include/guichan/mouseevent.hpp @@ -66,10 +66,10 @@ namespace gcn * Constructor. * * @param source The source widget of the mouse event. - * @param isShiftPressed True if shift is pressed, false otherwise. - * @param isControlPressed True if control is pressed, false otherwise. - * @param isAltPressed True if alt is pressed, false otherwise. - * @param isMetaPressed True if meta is pressed, false otherwise. + * @param shiftPressed True if shift is pressed, false otherwise. + * @param controlPressed True if control is pressed, false otherwise. + * @param altPressed True if alt is pressed, false otherwise. + * @param metaPressed True if meta is pressed, false otherwise. * @param type The type of the mouse event. * @param button The button of the mouse event. * @param x The x coordinate of the event relative to the source widget. @@ -78,10 +78,10 @@ namespace gcn * It's set to zero if another button is used. */ MouseEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed, + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed, unsigned int type, unsigned int button, int x, diff --git a/src/guichan/inputevent.cpp b/src/guichan/inputevent.cpp index 7a3bdb06d..a135b15b8 100644 --- a/src/guichan/inputevent.cpp +++ b/src/guichan/inputevent.cpp @@ -52,15 +52,15 @@ namespace gcn { InputEvent::InputEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed) + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed) :Event(source), - mShiftPressed(isShiftPressed), - mControlPressed(isControlPressed), - mAltPressed(isAltPressed), - mMetaPressed(isMetaPressed), + mShiftPressed(shiftPressed), + mControlPressed(controlPressed), + mAltPressed(altPressed), + mMetaPressed(metaPressed), mIsConsumed(false) { diff --git a/src/guichan/keyevent.cpp b/src/guichan/keyevent.cpp index 1bc8fe9d2..f9c14bb59 100644 --- a/src/guichan/keyevent.cpp +++ b/src/guichan/keyevent.cpp @@ -52,20 +52,20 @@ namespace gcn { KeyEvent::KeyEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed, + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed, unsigned int type, - bool isNumericPad, + bool numericPad, const Key& key) :InputEvent(source, - isShiftPressed, - isControlPressed, - isAltPressed, - isMetaPressed), + shiftPressed, + controlPressed, + altPressed, + metaPressed), mType(type), - mIsNumericPad(isNumericPad), + mIsNumericPad(numericPad), mKey(key) { diff --git a/src/guichan/mouseevent.cpp b/src/guichan/mouseevent.cpp index e5046ed15..5ff544a04 100644 --- a/src/guichan/mouseevent.cpp +++ b/src/guichan/mouseevent.cpp @@ -52,20 +52,20 @@ namespace gcn { MouseEvent::MouseEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed, + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed, unsigned int type, unsigned int button, int x, int y, int clickCount) :InputEvent(source, - isShiftPressed, - isControlPressed, - isAltPressed, - isMetaPressed), + shiftPressed, + controlPressed, + altPressed, + metaPressed), mType(type), mButton(button), mX(x), diff --git a/src/map.h b/src/map.h index c92a3c60f..e9a9df593 100644 --- a/src/map.h +++ b/src/map.h @@ -96,10 +96,10 @@ struct MetaTile class MapObject { public: - MapObject(int type, std::string data) + MapObject(int type0, std::string data0) { - this->type = type; - this->data = data; + type = type0; + data = data0; } int type; diff --git a/src/position.h b/src/position.h index 1d3070e1b..973a774f0 100644 --- a/src/position.h +++ b/src/position.h @@ -31,8 +31,8 @@ */ struct Position { - Position(int x, int y): - x(x), y(y) + Position(int x0, int y0): + x(x0), y(y0) { } int x; diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp index 10d70c2c7..319bc5b8c 100644 --- a/src/resources/ambientlayer.cpp +++ b/src/resources/ambientlayer.cpp @@ -41,16 +41,16 @@ AmbientLayer::AmbientLayer(Image *img, float parallax, if (keepRatio && !mImage->useOpenGL() /*&& defaultScreenWidth != 0 && defaultScreenHeight != 0*/ - && graphics->mWidth != defaultScreenWidth - && graphics->mHeight != defaultScreenHeight) + && mainGraphics->mWidth != defaultScreenWidth + && mainGraphics->mHeight != defaultScreenHeight) { // Rescale the overlay to keep the ratio as if we were on // the default resolution... Image *rescaledOverlay = ResourceManager::getInstance()-> getRescaled(mImage, static_cast(mImage->mBounds.w) - / defaultScreenWidth * graphics->mWidth, + / defaultScreenWidth * mainGraphics->mWidth, static_cast(mImage->mBounds.h) - / defaultScreenHeight * graphics->mHeight); + / defaultScreenHeight * mainGraphics->mHeight); if (rescaledOverlay) mImage = rescaledOverlay; diff --git a/src/resources/colordb.h b/src/resources/colordb.h index ce128578e..83bff57da 100644 --- a/src/resources/colordb.h +++ b/src/resources/colordb.h @@ -38,11 +38,11 @@ namespace ColorDB color("") { } - ItemColor(int id, std::string name, std::string color) + ItemColor(int id0, std::string name0, std::string color0) { - this->id = id; - this->name = name; - this->color = color; + this->id = id0; + this->name = name0; + this->color = color0; } int id; diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h index 267f60eef..c20961eff 100644 --- a/src/resources/itemdb.h +++ b/src/resources/itemdb.h @@ -68,10 +68,10 @@ namespace ItemDB struct Stat { - Stat(const std::string &tag, - const std::string &format): - tag(tag), - format(format) + Stat(const std::string &tag0, + const std::string &format0) : + tag(tag0), + format(format0) {} std::string tag; diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index 8fa64e7b9..ccad62b1b 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -43,10 +43,10 @@ struct SpriteReference sprite(""), variant(0) {} - SpriteReference(std::string sprite, int variant) + SpriteReference(std::string sprite0, int variant0) { - this->sprite = sprite; - this->variant = variant; + sprite = sprite0; + variant = variant0; } std::string sprite; diff --git a/src/vector.h b/src/vector.h index 87e9c647a..0f10bae96 100644 --- a/src/vector.h +++ b/src/vector.h @@ -46,10 +46,10 @@ class Vector /** * Constructor. */ - Vector(float x, float y, float z = 0.0f): - x(x), - y(y), - z(z) + Vector(float x0, float y0, float z0 = 0.0f): + x(x0), + y(y0), + z(z0) {} /** -- cgit v1.2.3-70-g09d2 From 703a3c4df3732e3e88559147001260f3355d42d6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 9 Sep 2011 22:10:53 +0300 Subject: Continue fix for shadow variables/methods errors. --- src/actorspritemanager.cpp | 7 +++--- src/actorspritemanager.h | 4 +-- src/client.cpp | 52 +++++++++++++++++++-------------------- src/client.h | 4 +-- src/commandhandler.cpp | 6 ++--- src/game.cpp | 4 +-- src/gui/chatwindow.cpp | 8 +++--- src/gui/chatwindow.h | 4 +-- src/gui/inventorywindow.cpp | 11 +++------ src/gui/itemamountwindow.cpp | 4 +-- src/gui/logindialog.cpp | 8 +++--- src/gui/logindialog.h | 2 +- src/gui/ministatuswindow.cpp | 4 +-- src/gui/ministatuswindow.h | 2 +- src/gui/popupmenu.cpp | 15 ++++++----- src/gui/register.cpp | 22 ++++++++--------- src/gui/sdlfont.cpp | 4 +-- src/gui/serverdialog.cpp | 10 ++++---- src/gui/setup_video.cpp | 16 ++++++------ src/gui/shopwindow.cpp | 2 +- src/gui/socialwindow.cpp | 6 ++--- src/gui/textcommandeditor.cpp | 4 +-- src/gui/tradewindow.cpp | 4 +-- src/gui/unregisterdialog.cpp | 16 ++++++------ src/gui/viewport.cpp | 2 +- src/gui/widgets/avatarlistbox.cpp | 2 +- src/gui/widgets/mouseevent.h | 10 ++++---- src/gui/windowmenu.cpp | 4 +-- src/gui/windowmenu.h | 2 +- src/localplayer.cpp | 6 ++--- src/map.cpp | 10 ++++---- src/net/ea/buysellhandler.cpp | 12 ++++----- src/net/ea/chathandler.cpp | 20 +++++++-------- src/net/ea/inventoryhandler.h | 16 ++++++------ src/net/manaserv/chathandler.cpp | 2 +- src/net/tmwa/adminhandler.cpp | 2 +- src/net/tmwa/adminhandler.h | 2 +- src/net/tmwa/beinghandler.cpp | 12 ++++----- src/party.cpp | 4 +-- src/resources/beinginfo.h | 10 ++++---- 40 files changed, 166 insertions(+), 169 deletions(-) (limited to 'src/game.cpp') diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 1104f034a..3acb63dc3 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -257,7 +257,6 @@ void ActorSpriteManager::undelete(ActorSprite *actor) for (it = mDeleteActors.begin(), it_end = mDeleteActors.end(); it != it_end; ++it) { - ActorSprite *actor = *it; if (*it == actor) { mDeleteActors.erase(*it); @@ -906,15 +905,15 @@ bool ActorSpriteManager::validateBeing(Being *aroundBeing, Being* being, || player_node->isReachable(being, maxCost)); } -void ActorSpriteManager::healTarget(LocalPlayer* player_node) +void ActorSpriteManager::healTarget() { if (!player_node) return; - heal(player_node, player_node->getTarget()); + heal(player_node->getTarget()); } -void ActorSpriteManager::heal(LocalPlayer* player_node, Being* target) +void ActorSpriteManager::heal(Being* target) { if (!player_node || !chatWindow || !player_node->isAlive() || !Net::getPlayerHandler()->canUseMagic()) diff --git a/src/actorspritemanager.h b/src/actorspritemanager.h index 91503e1c3..bd2ae79fb 100644 --- a/src/actorspritemanager.h +++ b/src/actorspritemanager.h @@ -164,9 +164,9 @@ class ActorSpriteManager: public ConfigListener // void HealAllTargets(Being *aroundBeing, int maxdist, // Being::Type type) const; - void healTarget(LocalPlayer* player_node); + void healTarget(); - void heal(LocalPlayer* player_node, Being* target); + void heal(Being* target); void itenplz(); diff --git a/src/client.cpp b/src/client.cpp index b9e9735c9..be1c00197 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -196,16 +196,16 @@ Uint32 nextSecond(Uint32 interval, void *param A_UNUSED) * @return the elapsed time in milliseconds * between two tick values. */ -int get_elapsed_time(int start_time) +int get_elapsed_time(int startTime) { - if (start_time <= tick_time) + if (startTime <= tick_time) { - return (tick_time - start_time) * MILLISECONDS_IN_A_TICK; + return (tick_time - startTime) * MILLISECONDS_IN_A_TICK; } else { - return (tick_time + (MAX_TICK_VALUE - start_time)) - * MILLISECONDS_IN_A_TICK; + return (tick_time + (MAX_TICK_VALUE - startTime)) + * MILLISECONDS_IN_A_TICK; } } @@ -845,10 +845,10 @@ int Client::exec() if (mState != mOldState) { { - Mana::Event event(EVENT_STATECHANGE); - event.setInt("oldState", mOldState); - event.setInt("newState", mState); - Mana::Event::trigger(CHANNEL_CLIENT, event); + Mana::Event evt(EVENT_STATECHANGE); + evt.setInt("oldState", mOldState); + evt.setInt("newState", mState); + Mana::Event::trigger(CHANNEL_CLIENT, evt); } if (mOldState == STATE_GAME) @@ -1046,10 +1046,10 @@ int Client::exec() if (!BeingInfo::unknown) BeingInfo::unknown = new BeingInfo; - Mana::Event event(EVENT_STATECHANGE); - event.setInt("newState", STATE_LOAD_DATA); - event.setInt("oldState", mOldState); - Mana::Event::trigger(CHANNEL_CLIENT, event); + Mana::Event evt(EVENT_STATECHANGE); + evt.setInt("newState", STATE_LOAD_DATA); + evt.setInt("oldState", mOldState); + Mana::Event::trigger(CHANNEL_CLIENT, evt); // Load XML databases ColorDB::load(); @@ -1733,27 +1733,27 @@ void Client::initScreenshotDir() } } -void Client::accountLogin(LoginData *loginData) +void Client::accountLogin(LoginData *data) { - if (!loginData) + if (!data) return; - logger->log("Username is %s", loginData->username.c_str()); + logger->log("Username is %s", data->username.c_str()); // Send login infos - if (loginData->registerLogin) - Net::getLoginHandler()->registerAccount(loginData); + if (data->registerLogin) + Net::getLoginHandler()->registerAccount(data); else - Net::getLoginHandler()->loginAccount(loginData); + Net::getLoginHandler()->loginAccount(data); // Clear the password, avoids auto login when returning to login - loginData->password = ""; + data->password = ""; // TODO This is not the best place to save the config, but at least better // than the login gui window - if (loginData->remember) - serverConfig.setValue("username", loginData->username); - serverConfig.setValue("remember", loginData->remember); + if (data->remember) + serverConfig.setValue("username", data->username); + serverConfig.setValue("remember", data->remember); } bool Client::copyFile(std::string &configPath, std::string &oldConfigPath) @@ -1805,7 +1805,7 @@ void Client::storeSafeParameters() int width; int height; std::string font; - std::string boldFont; + std::string bFont; std::string particleFont; std::string helpFont; std::string secureFont; @@ -1833,7 +1833,7 @@ void Client::storeSafeParameters() height = config.getIntValue("screenheight"); font = config.getStringValue("font"); - boldFont = config.getStringValue("boldFont"); + bFont = config.getStringValue("boldFont"); particleFont = config.getStringValue("particleFont"); helpFont = config.getStringValue("helpFont"); secureFont = config.getStringValue("secureFont"); @@ -1878,7 +1878,7 @@ void Client::storeSafeParameters() config.setValue("screenwidth", width); config.setValue("screenheight", height); config.setValue("font", font); - config.setValue("boldFont", boldFont); + config.setValue("boldFont", bFont); config.setValue("particleFont", particleFont); config.setValue("helpFont", helpFont); config.setValue("secureFont", secureFont); diff --git a/src/client.h b/src/client.h index 3edf12674..4409cf8db 100644 --- a/src/client.h +++ b/src/client.h @@ -78,7 +78,7 @@ extern LoginData loginData; /** * Returns elapsed time. (Warning: supposes the delay is always < 100 seconds) */ -int get_elapsed_time(int start_time); +int get_elapsed_time(int startTime); /** * All client states. @@ -291,7 +291,7 @@ private: bool copyFile(std::string &configPath, std::string &oldConfigPath); bool createConfig(std::string &configPath); - void accountLogin(LoginData *loginData); + void accountLogin(LoginData *data); void storeSafeParameters(); diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index dc962a17d..d16a7db27 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -397,7 +397,7 @@ void CommandHandler::handleMsg(const std::string &args, ChatTab *tab) if (tempNick.compare(playerName) == 0 || args.empty()) return; - chatWindow->whisper(recvnick, msg, BY_PLAYER); + chatWindow->addWhisper(recvnick, msg, BY_PLAYER); } else tab->chatLog(_("Cannot send empty whispers!"), BY_SERVER); @@ -851,11 +851,11 @@ void CommandHandler::handleHeal(const std::string &args, ChatTab *tab A_UNUSED) Being *being = actorSpriteManager->findBeingByName( args, Being::PLAYER); if (being) - actorSpriteManager->heal(player_node, being); + actorSpriteManager->heal(being); } else { - actorSpriteManager->heal(player_node, player_node); + actorSpriteManager->heal(player_node); } } diff --git a/src/game.cpp b/src/game.cpp index a0635f42f..3c7579d78 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -972,7 +972,7 @@ void Game::handleInput() break; case KeyboardConfig::KEY_MAGIC_INMA1: - actorSpriteManager->healTarget(player_node); + actorSpriteManager->healTarget(); setValidSpeed(); break; @@ -1094,7 +1094,7 @@ void Game::handleInput() && !keyboard.isKeyActive(keyboard.KEY_TARGET) && !InventoryWindow::isAnyInputFocused()) { - const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); +// const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); if (setupWindow->isVisible()) { diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index c52511189..f3e4b88b8 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -907,9 +907,9 @@ void ChatWindow::addItemText(const std::string &item) addInputText(text.str()); } -void ChatWindow::setVisible(bool isVisible) +void ChatWindow::setVisible(bool visible) { - Window::setVisible(isVisible); + Window::setVisible(visible); /* * For whatever reason, if setVisible is called, the mTmpVisible effect @@ -918,8 +918,8 @@ void ChatWindow::setVisible(bool isVisible) mTmpVisible = false; } -void ChatWindow::whisper(const std::string &nick, - const std::string &mes, Own own) +void ChatWindow::addWhisper(const std::string &nick, + const std::string &mes, Own own) { if (mes.empty() || !player_node) return; diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h index 97e366701..1ad468a3b 100644 --- a/src/gui/chatwindow.h +++ b/src/gui/chatwindow.h @@ -222,8 +222,8 @@ class ChatWindow : public Window, void doPresent(); - void whisper(const std::string &nick, const std::string &mes, - Own own = BY_OTHER); + void addWhisper(const std::string &nick, const std::string &mes, + Own own = BY_OTHER); ChatTab *addWhisperTab(const std::string &nick, bool switchTo = false); diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index da1c45782..c6afaaf1d 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -362,17 +362,12 @@ void InventoryWindow::action(const gcn::ActionEvent &event) else if (event.getId() == "split") { ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit, this, item, - (item->getQuantity() - 1)); + (item->getQuantity() - 1)); } else if (event.getId() == "retrieve") { - Item *item = mItems->getSelectedItem(); - - if (!item) - return; - - ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove, this, - item); + ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove, + this, item); } } diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp index 059f3d785..9bd3f3ab3 100644 --- a/src/gui/itemamountwindow.cpp +++ b/src/gui/itemamountwindow.cpp @@ -53,11 +53,11 @@ class ItemsModal : public gcn::ListModel public: ItemsModal() { - std::map info = ItemDB::getItemInfos(); + std::map items = ItemDB::getItemInfos(); std::list tempStrings; for (std::map::const_iterator - i = info.begin(), i_end = info.end(); + i = items.begin(), i_end = items.end(); i != i_end; ++i) { if (i->first < 0) diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp index ab5dc7401..adf499f75 100644 --- a/src/gui/logindialog.cpp +++ b/src/gui/logindialog.cpp @@ -81,10 +81,10 @@ public: } }; -LoginDialog::LoginDialog(LoginData *loginData, std::string serverName, +LoginDialog::LoginDialog(LoginData *data, std::string serverName, std::string *updateHost): Window(_("Login")), - mLoginData(loginData), + mLoginData(data), mUpdateHost(updateHost), mServerName(serverName) { @@ -94,7 +94,7 @@ LoginDialog::LoginDialog(LoginData *loginData, std::string serverName, gcn::Label *userLabel = new Label(_("Name:")); gcn::Label *passLabel = new Label(_("Password:")); mCustomUpdateHost = new CheckBox(_("Custom update host"), - loginData->updateType & LoginData::Upd_Custom, this, "customhost"); + mLoginData->updateType & LoginData::Upd_Custom, this, "customhost"); mUpdateHostText = new TextField(serverConfig.getValue( "customUpdateHost", "")); @@ -112,7 +112,7 @@ LoginDialog::LoginDialog(LoginData *loginData, std::string serverName, mUpdateTypeModel = new UpdateTypeModel(); mUpdateTypeDropDown = new DropDown(mUpdateTypeModel); mUpdateTypeDropDown->setActionEventId("updatetype"); - mUpdateTypeDropDown->setSelected((loginData->updateType + mUpdateTypeDropDown->setSelected((mLoginData->updateType | LoginData::Upd_Custom) ^ LoginData::Upd_Custom); if (!mCustomUpdateHost->isSelected()) diff --git a/src/gui/logindialog.h b/src/gui/logindialog.h index e464c6f24..0696bc680 100644 --- a/src/gui/logindialog.h +++ b/src/gui/logindialog.h @@ -49,7 +49,7 @@ class LoginDialog : public Window, public gcn::ActionListener, * * @see Window::Window */ - LoginDialog(LoginData *loginData, std::string serverName, + LoginDialog(LoginData *data, std::string serverName, std::string *updateHost); ~LoginDialog(); diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index b325bcef6..e3f441b60 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -400,12 +400,12 @@ void MiniStatusWindow::mouseExited(gcn::MouseEvent &event) mStatusPopup->hide(); } -void MiniStatusWindow::showBar(std::string name, bool isVisible) +void MiniStatusWindow::showBar(std::string name, bool visible) { ProgressBar *bar = mBarNames[name]; if (!bar) return; - bar->setVisible(isVisible); + bar->setVisible(visible); updateBars(); saveBars(); } diff --git a/src/gui/ministatuswindow.h b/src/gui/ministatuswindow.h index 91aebcfac..5e1b442dc 100644 --- a/src/gui/ministatuswindow.h +++ b/src/gui/ministatuswindow.h @@ -80,7 +80,7 @@ class MiniStatusWindow : public Popup, void mouseExited(gcn::MouseEvent &event); - void showBar(std::string name, bool isVisible); + void showBar(std::string name, bool visible); void updateBars(); diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 7e43c9954..e43ab35bc 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -879,7 +879,7 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "heal" && being && being->getType() != Being::MONSTER) { - actorSpriteManager->heal(player_node, being); + actorSpriteManager->heal(being); } else if (link == "unignore" && being && being->getType() == ActorSprite::PLAYER) @@ -1591,12 +1591,15 @@ void PopupMenu::handleLink(const std::string &link, } else if (!link.compare(0, 7, "player_")) { - mBeingId = atoi(link.substr(7).c_str()); - Being *being = actorSpriteManager->findBeing(mBeingId); - if (being) + if (actorSpriteManager) { - showPopup(getX(), getY(), being); - return; + mBeingId = atoi(link.substr(7).c_str()); + being = actorSpriteManager->findBeing(mBeingId); + if (being) + { + showPopup(getX(), getY(), being); + return; + } } } else if (!link.compare(0, 12, "hide button_")) diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 913c958f2..e2c718359 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -62,21 +62,21 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event) mTarget->requestFocus(); } -RegisterDialog::RegisterDialog(LoginData *loginData): +RegisterDialog::RegisterDialog(LoginData *data): Window(_("Register")), mEmailField(0), mMaleButton(0), mFemaleButton(0), mWrongDataNoticeListener(new WrongDataNoticeListener), - mLoginData(loginData) + mLoginData(data) { int optionalActions = Net::getLoginHandler()->supportedOptionalActions(); gcn::Label *userLabel = new Label(_("Name:")); gcn::Label *passwordLabel = new Label(_("Password:")); gcn::Label *confirmLabel = new Label(_("Confirm:")); - mUserField = new TextField(loginData->username); - mPasswordField = new PasswordField(loginData->password); + mUserField = new TextField(mLoginData->username); + mPasswordField = new PasswordField(mLoginData->password); mConfirmField = new PasswordField; mRegisterButton = new Button(_("Register"), "register", this); mCancelButton = new Button(_("Cancel"), "cancel", this); @@ -161,7 +161,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) const std::string user = mUserField->getText(); logger->log("RegisterDialog::register Username is %s", user.c_str()); - std::string errorMessage; + std::string errorMsg; int error = 0; unsigned int minUser = Net::getLoginHandler()->getMinUserNameLength(); @@ -172,7 +172,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) if (user.length() < minUser) { // Name too short - errorMessage = strprintf + errorMsg = strprintf (_("The username needs to be at least %d characters long."), minUser); error = 1; @@ -180,7 +180,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) else if (user.length() > maxUser - 1 ) { // Name too long - errorMessage = strprintf + errorMsg = strprintf (_("The username needs to be less than %d characters long."), maxUser); error = 1; @@ -188,7 +188,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) else if (mPasswordField->getText().length() < minPass) { // Pass too short - errorMessage = strprintf + errorMsg = strprintf (_("The password needs to be at least %d characters long."), minPass); error = 2; @@ -196,7 +196,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) else if (mPasswordField->getText().length() > maxPass - 1 ) { // Pass too long - errorMessage = strprintf + errorMsg = strprintf (_("The password needs to be less than %d characters long."), maxPass); error = 2; @@ -204,7 +204,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) else if (mPasswordField->getText() != mConfirmField->getText()) { // Password does not match with the confirmation one - errorMessage = _("Passwords do not match."); + errorMsg = _("Passwords do not match."); error = 2; } @@ -225,7 +225,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) mWrongDataNoticeListener->setTarget(this->mPasswordField); } - OkDialog *dlg = new OkDialog(_("Error"), errorMessage); + OkDialog *dlg = new OkDialog(_("Error"), errorMsg); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index 8dd7f929d..b196ae4e4 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -48,8 +48,8 @@ char *strBuf; class SDLTextChunk { public: - SDLTextChunk(const std::string &text, const gcn::Color &color) : - img(0), text(text), color(color) + SDLTextChunk(const std::string &text0, const gcn::Color &color0) : + img(0), text(text0), color(color0) { } diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 763c190d6..f9d6ebfd0 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -548,7 +548,7 @@ void ServerDialog::mouseClicked(gcn::MouseEvent &mouseEvent) void ServerDialog::logic() { { - MutexLocker lock(&mMutex); + MutexLocker tempLock(&mMutex); if (mDownloadStatus == DOWNLOADING_COMPLETE) { mDownloadStatus = DOWNLOADING_OVER; @@ -636,11 +636,11 @@ void ServerDialog::loadServers(bool addNew) return; } - int version = XML::getProperty(rootNode, "version", 0); - if (version != 1) + int ver = XML::getProperty(rootNode, "version", 0); + if (ver != 1) { logger->log("Error: unsupported online server list version: %d", - version); + ver); return; } @@ -703,7 +703,7 @@ void ServerDialog::loadServers(bool addNew) server.version.first = gui->getFont()->getWidth(version); server.version.second = version; - MutexLocker lock(&mMutex); + MutexLocker tempLock(&mMutex); // Add the server to the local list if it's not already present bool found = false; for (unsigned int i = 0; i < mServers.size(); i++) diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 7bbcd9a2c..bc210075a 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -478,20 +478,20 @@ void Setup_Video::apply() fullscreen = !fullscreen; if (!mainGraphics->setFullscreen(fullscreen)) { - std::stringstream errorMessage; + std::stringstream errorMsg; if (fullscreen) { - errorMessage << _("Failed to switch to windowed mode " - "and restoration of old mode also " - "failed!") << std::endl; + errorMsg << _("Failed to switch to windowed mode " + "and restoration of old mode also " + "failed!") << std::endl; } else { - errorMessage << _("Failed to switch to fullscreen mode" - " and restoration of old mode also " - "failed!") << std::endl; + errorMsg << _("Failed to switch to fullscreen mode" + " and restoration of old mode also " + "failed!") << std::endl; } - logger->error(errorMessage.str()); + logger->error(errorMsg.str()); } } #if defined(WIN32) || defined(__APPLE__) diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index 5cf1573bb..c62c3254c 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -596,7 +596,7 @@ void ShopWindow::sendMessage(const std::string &nick, if (config.getBoolValue("hideShopMessages")) Net::getChatHandler()->privateMessage(nick, data); else if (chatWindow) - chatWindow->whisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, BY_PLAYER); //here was true } diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 7feca8bf4..886894564 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -962,7 +962,7 @@ public: { name = *i; } - Avatar *ava = new Avatar(name); + ava = new Avatar(name); ava->setOnline(true); ava->setLevel(level); ava->setType(MapItem::PRIORITY); @@ -997,7 +997,7 @@ public: { name = *i; } - Avatar *ava = new Avatar(name); + ava = new Avatar(name); ava->setOnline(true); ava->setLevel(level); ava->setType(MapItem::ATTACK); @@ -1032,7 +1032,7 @@ public: { name = *i; } - Avatar *ava = new Avatar(name); + ava = new Avatar(name); ava->setOnline(false); ava->setLevel(level); ava->setType(MapItem::IGNORE_); diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index 9d759c4a2..1e18da57a 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -61,11 +61,11 @@ class IconsModal : public gcn::ListModel public: IconsModal() { - std::map info = ItemDB::getItemInfos(); + std::map items = ItemDB::getItemInfos(); std::list tempStrings; for (std::map::const_iterator - i = info.begin(), i_end = info.end(); + i = items.begin(), i_end = items.end(); i != i_end; ++i) { if (i->first < 0) diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index 3c19ee9c2..d0ae67746 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -443,10 +443,10 @@ void TradeWindow::initTrade(std::string nick) bool TradeWindow::checkItem(Item *item) { - Item *tradeItem = mMyInventory->findItem( + Item *tItem = mMyInventory->findItem( item->getId(), item->getColor()); - if (tradeItem && (tradeItem->getQuantity() > 1 + if (tItem && (tItem->getQuantity() > 1 || item->getQuantity() > 1)) { if (localChatTab) diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index 568e0613e..e875000c4 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -46,10 +46,10 @@ #include "debug.h" -UnRegisterDialog::UnRegisterDialog(LoginData *loginData): +UnRegisterDialog::UnRegisterDialog(LoginData *data): Window(_("Unregister"), true), mWrongDataNoticeListener(new WrongDataNoticeListener), - mLoginData(loginData) + mLoginData(data) { gcn::Label *userLabel = new Label(strprintf(_("Name: %s"), mLoginData-> username.c_str())); @@ -108,7 +108,7 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event) logger->log("UnregisterDialog::unregistered, Username is %s", username.c_str()); - std::stringstream errorMessage; + std::stringstream errorMsg; bool error = false; unsigned int min = Net::getLoginHandler()->getMinPasswordLength(); @@ -118,15 +118,15 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event) if (password.length() < min) { // Pass too short - errorMessage << strprintf(_("The password needs to be at least %d " - "characters long."), min); + errorMsg << strprintf(_("The password needs to be at least %d " + "characters long."), min); error = true; } else if (password.length() > max - 1) { // Pass too long - errorMessage << strprintf(_("The password needs to be less than " - "%d characters long."), max); + errorMsg << strprintf(_("The password needs to be less than " + "%d characters long."), max); error = true; } @@ -134,7 +134,7 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event) { mWrongDataNoticeListener->setTarget(this->mPasswordField); - OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str()); + OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str()); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 073697459..461dd581d 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -489,7 +489,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) if (actorSpriteManager) { if (player_node != mHoverBeing || mSelfMouseHeal) - actorSpriteManager->heal(player_node, mHoverBeing); + actorSpriteManager->heal(mHoverBeing); } } else if (player_node->withinAttackRange(mHoverBeing) || diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 29fca7662..18dc48417 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -330,7 +330,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) Being* being = actorSpriteManager->findBeingByName(ava->getName(), Being::PLAYER); if (being) - actorSpriteManager->heal(player_node, being); + actorSpriteManager->heal(being); } else { diff --git a/src/gui/widgets/mouseevent.h b/src/gui/widgets/mouseevent.h index 5e9a46cfd..9484be0a5 100644 --- a/src/gui/widgets/mouseevent.h +++ b/src/gui/widgets/mouseevent.h @@ -28,12 +28,12 @@ class MouseEvent : public gcn::MouseEvent { public: - MouseEvent(gcn::Widget* source, bool isShiftPressed, - bool isControlPressed, bool isAltPressed, - bool isMetaPressed, unsigned int type, unsigned int button, + MouseEvent(gcn::Widget* source, bool shiftPressed, + bool controlPressed, bool altPressed, + bool metaPressed, unsigned int type, unsigned int button, int x, int y, int clickCount) : - gcn::MouseEvent(source, isShiftPressed, isControlPressed, - isAltPressed, isMetaPressed, type, button, x, y, + gcn::MouseEvent(source, shiftPressed, controlPressed, + altPressed, metaPressed, type, button, x, y, clickCount) { } diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index eaec791ee..487035350 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -315,13 +315,13 @@ void WindowMenu::mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED) mTextPopup->hide(); } -void WindowMenu::showButton(std::string name, bool isVisible) +void WindowMenu::showButton(std::string name, bool visible) { Button *btn = dynamic_cast(mButtonNames[name]); if (!btn) return; - btn->setVisible(isVisible); + btn->setVisible(visible); updateButtons(); saveButtons(); } diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index 6572fe470..739a302ba 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -72,7 +72,7 @@ class WindowMenu : public Container, std::vector &getButtons() { return mButtons; } - void showButton(std::string name, bool isVisible); + void showButton(std::string name, bool visible); void loadButtons(); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index fdbc4b0b7..b19b1b9af 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -3674,9 +3674,9 @@ void LocalPlayer::followMoveTo(Being *being, int x1, int y1, int x2, int y2) { if (actorSpriteManager) { - Being *being = actorSpriteManager->findBeingByName( - mPlayerFollowed, Being::PLAYER); - setTarget(being); + Being *b = actorSpriteManager->findBeingByName( + mPlayerFollowed, Being::PLAYER); + setTarget(b); } } moveToTarget(); diff --git a/src/map.cpp b/src/map.cpp index e5b3632b6..86d1171f0 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -114,10 +114,10 @@ void TileAnimation::update(int ticks) } } -MapLayer::MapLayer(int x, int y, int width, int height, bool isFringeLayer): +MapLayer::MapLayer(int x, int y, int width, int height, bool fringeLayer): mX(x), mY(y), mWidth(width), mHeight(height), - mIsFringeLayer(isFringeLayer), + mIsFringeLayer(fringeLayer), mHighlightAttackRange(config.getBoolValue("highlightAttackRange")) { const int size = mWidth * mHeight; @@ -1592,9 +1592,9 @@ void Map::addParticleEffect(const std::string &effectFile, particleEffects.push_back(newEffect); } -void Map::initializeParticleEffects(Particle *particleEngine) +void Map::initializeParticleEffects(Particle *engine) { - if (!particleEngine) + if (!engine) return; Particle *p; @@ -1605,7 +1605,7 @@ void Map::initializeParticleEffects(Particle *particleEngine) i = particleEffects.begin(); i != particleEffects.end(); ++i) { - p = particleEngine->addEffect(i->file, i->x, i->y); + p = engine->addEffect(i->file, i->x, i->y); if (p && i->w > 0 && i->h > 0) p->adjustEmitterSize(i->w, i->h); } diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp index 685562d6f..f38d17a59 100644 --- a/src/net/ea/buysellhandler.cpp +++ b/src/net/ea/buysellhandler.cpp @@ -70,7 +70,7 @@ void BuySellHandler::requestSellList(std::string nick) else { if (chatWindow) - chatWindow->whisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, BY_PLAYER); } } @@ -89,7 +89,7 @@ void BuySellHandler::requestBuyList(std::string nick) else { if (chatWindow) - chatWindow->whisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, BY_PLAYER); } } @@ -102,12 +102,12 @@ void BuySellHandler::sendBuyRequest(std::string nick, ShopItem* item, return; } std::string data = strprintf("!buyitem %d %d %d", - item->getId(), item->getPrice(), amount); + item->getId(), item->getPrice(), amount); if (config.getBoolValue("hideShopMessages")) Net::getChatHandler()->privateMessage(nick, data); else - chatWindow->whisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, BY_PLAYER); } void BuySellHandler::sendSellRequest(std::string nick, ShopItem* item, @@ -120,12 +120,12 @@ void BuySellHandler::sendSellRequest(std::string nick, ShopItem* item, } std::string data = strprintf("!sellitem %d %d %d", - item->getId(), item->getPrice(), amount); + item->getId(), item->getPrice(), amount); if (config.getBoolValue("hideShopMessages")) Net::getChatHandler()->privateMessage(nick, data); else - chatWindow->whisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, BY_PLAYER); } void BuySellHandler::processNpcBuySellChoice(Net::MessageIn &msg) diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 5737cc2b2..c18b1bb9a 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -125,7 +125,7 @@ void ChatHandler::processWhisperResponse(Net::MessageIn &msg) case 0x01: if (chatWindow) { - chatWindow->whisper(nick, + chatWindow->addWhisper(nick, strprintf(_("Whisper could not be " "sent, %s is offline."), nick.c_str()), BY_SERVER); } @@ -133,7 +133,7 @@ void ChatHandler::processWhisperResponse(Net::MessageIn &msg) case 0x02: if (chatWindow) { - chatWindow->whisper(nick, + chatWindow->addWhisper(nick, strprintf(_("Whisper could not " "be sent, ignored by %s."), nick.c_str()), BY_SERVER); @@ -183,7 +183,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) if (tradeBot) { if (showMsg && chatWindow) - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); shopWindow->giveList(nick, ShopWindow::SELL); } @@ -193,7 +193,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) if (tradeBot) { if (showMsg && chatWindow) - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); shopWindow->giveList(nick, ShopWindow::BUY); } @@ -201,7 +201,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) else if (chatMsg.find("!buyitem ") == 0) { if (showMsg && chatWindow) - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); if (tradeBot) { shopWindow->processRequest(nick, chatMsg, @@ -211,7 +211,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) else if (chatMsg.find("!sellitem ") == 0) { if (showMsg && chatWindow) - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); if (tradeBot) { shopWindow->processRequest(nick, chatMsg, @@ -223,7 +223,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) { chatMsg = chatMsg.erase(0, 2); if (showMsg && chatWindow) - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); if (chatMsg.find("B1") == 0 || chatMsg.find("S1") == 0) { @@ -232,12 +232,12 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) } else if (chatWindow) { - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); } } else if (chatWindow) { - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); } } else @@ -246,7 +246,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) || (chatMsg.find("!selllist") != 0 && chatMsg.find("!buylist") != 0))) { - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); } } } diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h index 4be4ddaa6..cb1e84673 100644 --- a/src/net/ea/inventoryhandler.h +++ b/src/net/ea/inventoryhandler.h @@ -114,15 +114,15 @@ class InventoryItem int refine; bool equip; - InventoryItem(int slot, int id, int quantity, int refine, - unsigned char color, bool equip) + InventoryItem(int slot0, int id0, int quantity0, int refine0, + unsigned char color0, bool equip0) { - this->slot = slot; - this->id = id; - this->quantity = quantity; - this->refine = refine; - this->color = color; - this->equip = equip; + slot = slot0; + id = id0; + quantity = quantity0; + refine = refine0; + color = color0; + equip = equip0; } }; diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp index 85323b11a..16552018e 100644 --- a/src/net/manaserv/chathandler.cpp +++ b/src/net/manaserv/chathandler.cpp @@ -231,7 +231,7 @@ void ChatHandler::handlePrivateMessage(Net::MessageIn &msg) std::string userNick = msg.readString(); std::string chatMsg = msg.readString(); - chatWindow->whisper(userNick, chatMsg); + chatWindow->addWhisper(userNick, chatMsg); } void ChatHandler::handleAnnouncement(Net::MessageIn &msg) diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp index a332b04fa..5d5034938 100644 --- a/src/net/tmwa/adminhandler.cpp +++ b/src/net/tmwa/adminhandler.cpp @@ -89,7 +89,7 @@ void AdminHandler::localAnnounce(const std::string &text) outMsg.writeString(text, static_cast(text.length())); } -void AdminHandler::hide(bool hide A_UNUSED) +void AdminHandler::hide(bool h A_UNUSED) { MessageOut outMsg(CMSG_ADMIN_HIDE); outMsg.writeInt32(0); //unused diff --git a/src/net/tmwa/adminhandler.h b/src/net/tmwa/adminhandler.h index 79f41dece..53fd4831f 100644 --- a/src/net/tmwa/adminhandler.h +++ b/src/net/tmwa/adminhandler.h @@ -50,7 +50,7 @@ class AdminHandler : public MessageHandler, public Ea::AdminHandler void localAnnounce(const std::string &text); - void hide(bool hide); + void hide(bool h); void kick(int playerId); }; diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index c087ab43d..845c30f19 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -445,7 +445,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) Being *dstBeing; int hairStyle, hairColor; unsigned char colors[9]; - Uint8 dir; + // An update about a player, potentially including movement. int id = msg.readInt32(); @@ -469,7 +469,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) return; } - dir = dstBeing->getDirectionDelayed(); + Uint8 dir = dstBeing->getDirectionDelayed(); if (dir) { if (dir != dstBeing->getDirection()) @@ -568,10 +568,10 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) if (srcX != dstX || srcY != dstY) { - int dir = dstBeing->calcDirection(dstX, dstY); + int d = dstBeing->calcDirection(dstX, dstY); - if (dir && dstBeing->getDirection() != dir) - dstBeing->setDirectionDelayed(static_cast(dir)); + if (d && dstBeing->getDirection() != d) + dstBeing->setDirectionDelayed(static_cast(d)); } if (player_node->getCurrentAction() != Being::STAND) @@ -584,7 +584,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) } else { - Uint8 dir; +// Uint8 dir; Uint16 x, y; msg.readCoordinates(x, y, dir); dstBeing->setTileCoords(x, y); diff --git a/src/party.cpp b/src/party.cpp index 9becee1cd..9da1a235d 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -119,9 +119,9 @@ void Party::removeMember(PartyMember *member) if ((*itr)->mId == member->mId && (*itr)->getName() == member->getName()) { - PartyMember *member = (*itr); + PartyMember *m = (*itr); mMembers.erase(itr); - delete member; + delete m; deleted = true; break; } diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index a61483940..b93c11ba6 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -38,12 +38,12 @@ struct Attack std::string particleEffect; std::string missileParticle; - Attack(std::string action, std::string particleEffect, - std::string missileParticle) + Attack(std::string action0, std::string particleEffect0, + std::string missileParticle0) { - this->action = action; - this->particleEffect = particleEffect; - this->missileParticle = missileParticle; + action = action0; + particleEffect = particleEffect0; + missileParticle = missileParticle0; } }; -- cgit v1.2.3-70-g09d2 From c38e43cee40cfd7cad2a92ea704aa26c23523b67 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 11 Sep 2011 16:07:26 +0300 Subject: Add own theme xml configuration for each shortcuts based window. --- src/game.cpp | 8 ++++---- src/gui/shortcutwindow.cpp | 7 +++++-- src/gui/shortcutwindow.h | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index 3c7579d78..6eda01640 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -216,7 +216,7 @@ static void createGuiWindows() minimap = new Minimap; helpWindow = new HelpWindow; debugWindow = new DebugWindow; - itemShortcutWindow = new ShortcutWindow("ItemShortcut"); + itemShortcutWindow = new ShortcutWindow("ItemShortcut", "items.xml"); for (int f = 0; f < SHORTCUT_TABS; f ++) { itemShortcutWindow->addTab(toString(f + 1), @@ -230,13 +230,13 @@ static void createGuiWindows() } emoteShortcutWindow = new ShortcutWindow("EmoteShortcut", - new EmoteShortcutContainer); + new EmoteShortcutContainer, "emotes.xml"); outfitWindow = new OutfitWindow(); specialsWindow = new SpecialsWindow(); dropShortcutWindow = new ShortcutWindow("DropShortcut", - new DropShortcutContainer); + new DropShortcutContainer, "drops.xml"); - spellShortcutWindow = new ShortcutWindow("SpellShortcut", + spellShortcutWindow = new ShortcutWindow("SpellShortcut", "spells.xml", 265, 328); for (int f = 0; f < SPELL_SHORTCUT_TABS; f ++) { diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp index cf491c9f0..df21488a5 100644 --- a/src/gui/shortcutwindow.cpp +++ b/src/gui/shortcutwindow.cpp @@ -52,8 +52,9 @@ class ShortcutTab : public Tab ShortcutWindow::ShortcutWindow(const std::string &title, ShortcutContainer *content, + std::string skinFile, int width, int height) : - Window("Window", false, 0, "shortcuts.xml") + Window("Window", false, 0, skinFile) { setWindowName(title); // no title presented, title bar is padding so window can be moved. @@ -97,7 +98,9 @@ ShortcutWindow::ShortcutWindow(const std::string &title, loadWindowState(); } -ShortcutWindow::ShortcutWindow(const std::string &title, int width, int height) +ShortcutWindow::ShortcutWindow(const std::string &title, std::string skinFile, + int width, int height) : + Window("Window", false, 0, skinFile) { setWindowName(title); // no title presented, title bar is padding so window can be moved. diff --git a/src/gui/shortcutwindow.h b/src/gui/shortcutwindow.h index 4301b72d1..1c91835e8 100644 --- a/src/gui/shortcutwindow.h +++ b/src/gui/shortcutwindow.h @@ -41,9 +41,10 @@ class ShortcutWindow : public Window * Constructor. */ ShortcutWindow(const std::string &title, ShortcutContainer *content, + std::string skinFile = "", int width = 0, int height = 0); - ShortcutWindow(const std::string &title, + ShortcutWindow(const std::string &title, std::string skinFile = "", int width = 0, int height = 0); /** -- cgit v1.2.3-70-g09d2 From 6bd4fff31e0b44b8b71876250c626fe8c15b4105 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 12 Sep 2011 18:29:12 +0300 Subject: Add missing checks to some files and style fixes. --- src/client.cpp | 8 +- src/configuration.cpp | 2 +- src/configuration.h | 3 + src/dropshortcut.cpp | 12 +- src/emoteshortcut.cpp | 11 -- src/event.cpp | 6 +- src/flooritem.cpp | 14 +-- src/flooritem.h | 1 + src/game.cpp | 326 ++++++++++++++++++++++++++++++++----------------- src/graphics.cpp | 13 +- src/guild.cpp | 19 +-- src/guildmanager.cpp | 5 +- src/item.cpp | 7 +- src/keyboardconfig.cpp | 2 +- src/localplayer.cpp | 102 ++++++---------- src/logger.cpp | 2 - 16 files changed, 300 insertions(+), 233 deletions(-) (limited to 'src/game.cpp') diff --git a/src/client.cpp b/src/client.cpp index bdba75aa8..47d0e9a21 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1044,10 +1044,10 @@ int Client::exec() if (!BeingInfo::unknown) BeingInfo::unknown = new BeingInfo; - Mana::Event evt(EVENT_STATECHANGE); - evt.setInt("newState", STATE_LOAD_DATA); - evt.setInt("oldState", mOldState); - Mana::Event::trigger(CHANNEL_CLIENT, evt); + Mana::Event evt2(EVENT_STATECHANGE); + evt2.setInt("newState", STATE_LOAD_DATA); + evt2.setInt("oldState", mOldState); + Mana::Event::trigger(CHANNEL_CLIENT, evt2); // Load XML databases ColorDB::load(); diff --git a/src/configuration.cpp b/src/configuration.cpp index 94c0dce37..a0167b9b0 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -585,4 +585,4 @@ void Configuration::removeListener( const std::string &key, ConfigListener *listener) { mListenerMap[key].remove(listener); -} \ No newline at end of file +} diff --git a/src/configuration.h b/src/configuration.h index 2e694002d..1f03b7387 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -179,6 +179,9 @@ class ConfigurationObject ConfigurationList *list = &(mContainerOptions[name]); CONT container = empty; + if (!manager) + return container; + for (ConfigurationList::const_iterator it = list->begin(); it != list->end(); it++) { diff --git a/src/dropshortcut.cpp b/src/dropshortcut.cpp index 48eed92bc..79f895490 100644 --- a/src/dropshortcut.cpp +++ b/src/dropshortcut.cpp @@ -150,6 +150,10 @@ void DropShortcut::dropItems(int cnt) bool DropShortcut::dropItem(int cnt) { + const Inventory *inv = PlayerInfo::getInventory(); + if (!inv) + return false; + int itemId = 0; unsigned char itemColor = 1; while (mLastDropIndex < DROP_SHORTCUT_ITEMS && itemId < 1) @@ -160,7 +164,7 @@ bool DropShortcut::dropItem(int cnt) } if (itemId > 0) { - Item *item = PlayerInfo::getInventory()->findItem(itemId, itemColor); + Item *item = inv->findItem(itemId, itemColor); if (item && item->getQuantity() > 0) { Net::getInventoryHandler()->dropItem(item, cnt); @@ -180,8 +184,7 @@ bool DropShortcut::dropItem(int cnt) } if (itemId > 0) { - Item *item = PlayerInfo::getInventory()->findItem( - itemId, itemColor); + Item *item = inv->findItem(itemId, itemColor); if (item && item->getQuantity() > 0) { Net::getInventoryHandler()->dropItem(item, cnt); @@ -210,6 +213,9 @@ void DropShortcut::setItemSelected(Item *item) void DropShortcut::setItem(int index) { + if (index < 0 || index >= DROP_SHORTCUT_ITEMS) + return; + mItems[index] = mItemSelected; mItemColors[index] = mItemColorSelected; save(); diff --git a/src/emoteshortcut.cpp b/src/emoteshortcut.cpp index 00d7264a4..352c373b5 100644 --- a/src/emoteshortcut.cpp +++ b/src/emoteshortcut.cpp @@ -34,7 +34,6 @@ EmoteShortcut *emoteShortcut; EmoteShortcut::EmoteShortcut(): mEmoteSelected(0) { -// load(); for (int i = 0; i < SHORTCUT_EMOTES; i++) mEmotes[i] = 0; } @@ -57,16 +56,6 @@ void EmoteShortcut::load() j ++; } } - -/* - for (int i = 0; i < SHORTCUT_EMOTES; i++) - { - unsigned char emoteId = static_cast( - serverConfig.getValue("emoteshortcut" + toString(i), i + 1)); - mEmotes[i] = emoteId; -// mEmotes[i] = i + 1; - } -*/ } void EmoteShortcut::save() diff --git a/src/event.cpp b/src/event.cpp index 5a1d673b2..6913e8660 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -56,7 +56,7 @@ int Event::getInt(const std::string &key) const throw (BadEvent) if (it == mData.end()) throw BAD_KEY; - if (it->second->getType() != VariableData::DATA_INT) + if (!it->second || it->second->getType() != VariableData::DATA_INT) throw BAD_VALUE; return static_cast(it->second)->getData(); @@ -78,7 +78,7 @@ const std::string &Event::getString(const std::string &key) if (it == mData.end()) throw BAD_KEY; - if (it->second->getType() != VariableData::DATA_STRING) + if (!! it->second || it->second->getType() != VariableData::DATA_STRING) throw BAD_VALUE; return static_cast(it->second)->getData(); @@ -99,7 +99,7 @@ double Event::getFloat(const std::string &key) const throw (BadEvent) if (it == mData.end()) throw BAD_KEY; - if (it->second->getType() != VariableData::DATA_FLOAT) + if (!it->second || it->second->getType() != VariableData::DATA_FLOAT) throw BAD_VALUE; return static_cast(it->second)->getData(); diff --git a/src/flooritem.cpp b/src/flooritem.cpp index 63112511e..9b11bdc9c 100644 --- a/src/flooritem.cpp +++ b/src/flooritem.cpp @@ -50,14 +50,13 @@ FloorItem::FloorItem(int id, mX(x), mY(y), mMap(map), -// mAlpha(1.0f), + mDropTime(cur_time), mAmount(amount), mPickupCount(0), mColor(color), - mShowMsg(true) + mShowMsg(true), + mHighlight(config.getBoolValue("floorItemsHighlight")) { - mDropTime = cur_time; - setMap(map); if (map) { @@ -99,9 +98,8 @@ bool FloorItem::draw(Graphics *graphics, int offsetX, int offsetY) const const int x = mX * mMap->getTileWidth() + offsetX; const int y = mY * mMap->getTileHeight() + offsetY; gcn::Font *font = 0; - const bool highl = config.getBoolValue("floorItemsHighlight"); - if (highl) + if (mHighlight) { int curTime = cur_time; font = gui->getFont(); @@ -118,7 +116,7 @@ bool FloorItem::draw(Graphics *graphics, int offsetX, int offsetY) const { graphics->setColor(gcn::Color(200, 80, 20, 80 + 10 * (curTime - mDropTime - 18))); - graphics->fillRectangle(gcn::Rectangle( + graphics->fillRectangle(gcn::Rectangle( x, y, dx, dy)); } else if (curTime > mDropTime && curTime < mDropTime + 20) @@ -133,7 +131,7 @@ bool FloorItem::draw(Graphics *graphics, int offsetX, int offsetY) const const bool res = ActorSprite::draw(graphics, offsetX, offsetY); - if (highl) + if (mHighlight) { if (font && mAmount > 1) { diff --git a/src/flooritem.h b/src/flooritem.h index dd1db1b35..fb929268a 100644 --- a/src/flooritem.h +++ b/src/flooritem.h @@ -100,6 +100,7 @@ class FloorItem : public ActorSprite unsigned mPickupCount; unsigned char mColor; bool mShowMsg; + bool mHighlight; }; #endif diff --git a/src/game.cpp b/src/game.cpp index 6eda01640..4762055fa 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -383,12 +383,14 @@ Game::Game(): windowMenu = new WindowMenu; // mWindowMenu = windowMenu; - windowContainer->add(windowMenu); + if (windowContainer) + windowContainer->add(windowMenu); initEngines(); // Initialize beings - actorSpriteManager->setPlayer(player_node); + if (actorSpriteManager) + actorSpriteManager->setPlayer(player_node); /* * To prevent the server from sending data before the client @@ -551,14 +553,12 @@ void Game::logic() // Handle network stuff if (!Net::getGameHandler()->isConnected()) { - if (Client::getState() == STATE_CHANGE_MAP) return; // Not a problem here if (Client::getState() != STATE_ERROR) errorMessage = _("The connection to the server was lost."); - if (!disconnectedDialog) { if (viewport) @@ -830,7 +830,7 @@ void Game::handleInput() } } - if (!chatWindow->isInputFocused() + if ((!chatWindow || !chatWindow->isInputFocused()) && !gui->getFocusHandler()->getModalFocused() && !player_node->getAwayMode()) { @@ -847,7 +847,8 @@ void Game::handleInput() else if (dialog) dialog->action(gcn::ActionEvent(NULL, "ok")); } - if (keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT)) + if (chatWindow && keyboard.isKeyActive( + keyboard.KEY_TOGGLE_CHAT)) { if (!InventoryWindow::isAnyInputFocused()) { @@ -864,10 +865,10 @@ void Game::handleInput() } } - if ((!chatWindow->isInputFocused() && + if (chatWindow && ((!chatWindow->isInputFocused() && !NpcDialog::isAnyInputFocused() && !InventoryWindow::isAnyInputFocused()) - || (event.key.keysym.mod & KMOD_ALT)) + || (event.key.keysym.mod & KMOD_ALT))) { if (keyboard.isKeyActive(keyboard.KEY_PREV_CHAT_TAB)) { @@ -900,14 +901,14 @@ void Game::handleInput() switch (tKey) { case KeyboardConfig::KEY_SCROLL_CHAT_UP: - if (chatWindow->isVisible()) + if (chatWindow && chatWindow->isVisible()) { chatWindow->scroll(-DEFAULT_CHAT_WINDOW_SCROLL); used = true; } break; case KeyboardConfig::KEY_SCROLL_CHAT_DOWN: - if (chatWindow->isVisible()) + if (chatWindow && chatWindow->isVisible()) { chatWindow->scroll(DEFAULT_CHAT_WINDOW_SCROLL); used = true; @@ -916,21 +917,23 @@ void Game::handleInput() break; case KeyboardConfig::KEY_WINDOW_HELP: // In-game Help - if (helpWindow->isVisible()) - helpWindow->setVisible(false); - else + if (helpWindow) { - helpWindow->loadHelp("index"); - helpWindow->requestMoveToTop(); + if (helpWindow->isVisible()) + { + helpWindow->setVisible(false); + } + else + { + helpWindow->loadHelp("index"); + helpWindow->requestMoveToTop(); + } } used = true; break; - - - // Quitting confirmation dialog case KeyboardConfig::KEY_QUIT: - if (!chatWindow->isInputFocused()) + if (!chatWindow || !chatWindow->isInputFocused()) { if (viewport && viewport->isPopupMenuVisible()) { @@ -948,31 +951,38 @@ void Game::handleInput() break; } - if (keyboard.isEnabled() && !chatWindow->isInputFocused() + if (keyboard.isEnabled() && (!chatWindow + || !chatWindow->isInputFocused()) && !gui->getFocusHandler()->getModalFocused() && mValidSpeed - && !setupWindow->isVisible() - && !player_node->getAwayMode() + && (!setupWindow || !setupWindow->isVisible()) + && (!player_node || !player_node->getAwayMode()) && !NpcDialog::isAnyInputFocused() && !InventoryWindow::isAnyInputFocused()) { switch (tKey) { case KeyboardConfig::KEY_QUICK_DROP: - dropShortcut->dropFirst(); + if (dropShortcut) + dropShortcut->dropFirst(); break; case KeyboardConfig::KEY_QUICK_DROPN: - dropShortcut->dropItems(); + if (dropShortcut) + dropShortcut->dropItems(); break; case KeyboardConfig::KEY_SWITCH_QUICK_DROP: - if (!player_node->getDisableGameModifiers()) - player_node->changeQuickDropCounter(); + if (player_node) + { + if (!player_node->getDisableGameModifiers()) + player_node->changeQuickDropCounter(); + } break; case KeyboardConfig::KEY_MAGIC_INMA1: - actorSpriteManager->healTarget(); + if (actorSpriteManager) + actorSpriteManager->healTarget(); setValidSpeed(); break; @@ -986,85 +996,125 @@ void Game::handleInput() break; case KeyboardConfig::KEY_CRAZY_MOVES: - player_node->crazyMove(); + if (player_node) + player_node->crazyMove(); break; case KeyboardConfig::KEY_CHANGE_CRAZY_MOVES_TYPE: - if (!player_node->getDisableGameModifiers()) - player_node->changeCrazyMoveType(); + if (player_node) + { + if (!player_node->getDisableGameModifiers()) + player_node->changeCrazyMoveType(); + } break; case KeyboardConfig::KEY_CHANGE_PICKUP_TYPE: - if (!player_node->getDisableGameModifiers()) - player_node->changePickUpType(); + if (player_node) + { + if (!player_node->getDisableGameModifiers()) + player_node->changePickUpType(); + } break; case KeyboardConfig::KEY_MOVE_TO_TARGET: - if (!keyboard.isKeyActive(keyboard.KEY_TARGET_ATTACK) - && !keyboard.isKeyActive(keyboard.KEY_ATTACK)) + if (player_node) { - player_node->moveToTarget(); + if (!keyboard.isKeyActive( + keyboard.KEY_TARGET_ATTACK) + && !keyboard.isKeyActive(keyboard.KEY_ATTACK)) + { + player_node->moveToTarget(); + } } break; case KeyboardConfig::KEY_MOVE_TO_HOME: - if (!keyboard.isKeyActive(keyboard.KEY_TARGET_ATTACK) - && !keyboard.isKeyActive(keyboard.KEY_ATTACK)) + if (player_node) { - player_node->moveToHome(); + if (!keyboard.isKeyActive( + keyboard.KEY_TARGET_ATTACK) + && !keyboard.isKeyActive(keyboard.KEY_ATTACK)) + { + player_node->moveToHome(); + } + setValidSpeed(); } - setValidSpeed(); break; case KeyboardConfig::KEY_SET_HOME: - player_node->setHome(); + if (player_node) + player_node->setHome(); break; case KeyboardConfig::KEY_INVERT_DIRECTION: - if (!player_node->getDisableGameModifiers()) - player_node->invertDirection(); + if (player_node) + { + if (!player_node->getDisableGameModifiers()) + player_node->invertDirection(); + } break; case KeyboardConfig::KEY_CHANGE_ATTACK_WEAPON_TYPE: - if (!player_node->getDisableGameModifiers()) - player_node->changeAttackWeaponType(); + if (player_node) + { + if (!player_node->getDisableGameModifiers()) + player_node->changeAttackWeaponType(); + } break; case KeyboardConfig::KEY_CHANGE_ATTACK_TYPE: - if (!player_node->getDisableGameModifiers()) - player_node->changeAttackType(); + if (player_node) + { + if (!player_node->getDisableGameModifiers()) + player_node->changeAttackType(); + } break; case KeyboardConfig::KEY_CHANGE_FOLLOW_MODE: - if (!player_node->getDisableGameModifiers()) - player_node->changeFollowMode(); + if (player_node) + { + if (!player_node->getDisableGameModifiers()) + player_node->changeFollowMode(); + } break; case KeyboardConfig::KEY_CHANGE_IMITATION_MODE: - if (!player_node->getDisableGameModifiers()) - player_node->changeImitationMode(); + if (player_node) + { + if (!player_node->getDisableGameModifiers()) + player_node->changeImitationMode(); + } break; case KeyboardConfig::KEY_MAGIC_ATTACK: - player_node->magicAttack(); + if (player_node) + player_node->magicAttack(); break; case KeyboardConfig::KEY_SWITCH_MAGIC_ATTACK: - if (!player_node->getDisableGameModifiers()) - player_node->switchMagicAttack(); + if (player_node) + { + if (!player_node->getDisableGameModifiers()) + player_node->switchMagicAttack(); + } break; case KeyboardConfig::KEY_CHANGE_MOVE_TO_TARGET: - if (!player_node->getDisableGameModifiers()) - player_node->changeMoveToTargetType(); + if (player_node) + { + if (!player_node->getDisableGameModifiers()) + player_node->changeMoveToTargetType(); + } break; case KeyboardConfig::KEY_COPY_EQUIPED_OUTFIT: - outfitWindow->copyFromEquiped(); + if (outfitWindow) + outfitWindow->copyFromEquiped(); break; case KeyboardConfig::KEY_DISABLE_GAME_MODIFIERS: - player_node->switchGameModifiers(); + if (player_node) + player_node->switchGameModifiers(); break; case KeyboardConfig::KEY_CHANGE_AUDIO: @@ -1072,14 +1122,20 @@ void Game::handleInput() break; case KeyboardConfig::KEY_AWAY: - player_node->changeAwayMode(); - setValidSpeed(); + if (player_node) + { + player_node->changeAwayMode(); + setValidSpeed(); + } break; case KeyboardConfig::KEY_CAMERA: - if (!player_node->getDisableGameModifiers()) - viewport->toggleCameraMode(); - setValidSpeed(); + if (player_node && viewport) + { + if (!player_node->getDisableGameModifiers()) + viewport->toggleCameraMode(); + setValidSpeed(); + } break; default: @@ -1088,15 +1144,15 @@ void Game::handleInput() } if (keyboard.isEnabled() - && !chatWindow->isInputFocused() + && (!chatWindow || !chatWindow->isInputFocused()) && !NpcDialog::isAnyInputFocused() - && !player_node->getAwayMode() + && (!player_node || !player_node->getAwayMode()) && !keyboard.isKeyActive(keyboard.KEY_TARGET) && !InventoryWindow::isAnyInputFocused()) { // const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); - if (setupWindow->isVisible()) + if (setupWindow && setupWindow->isVisible()) { if (tKey == KeyboardConfig::KEY_WINDOW_SETUP) { @@ -1107,7 +1163,8 @@ void Game::handleInput() else { // Do not activate shortcuts if tradewindow is visible - if (itemShortcutWindow && !tradeWindow->isVisible() + if (itemShortcutWindow && tradeWindow + && !tradeWindow->isVisible() && !setupWindow->isVisible()) { int num = itemShortcutWindow->getTabIndex(); @@ -1131,34 +1188,51 @@ void Game::handleInput() switch (tKey) { case KeyboardConfig::KEY_PICKUP: - player_node->pickUpItems(); + if (player_node) + player_node->pickUpItems(); used = true; break; case KeyboardConfig::KEY_SIT: // Player sit action - if (keyboard.isKeyActive(keyboard.KEY_EMOTE)) - player_node->updateSit(); - else - player_node->toggleSit(); + if (player_node) + { + if (keyboard.isKeyActive(keyboard.KEY_EMOTE)) + player_node->updateSit(); + else + player_node->toggleSit(); + } used = true; break; case KeyboardConfig::KEY_HIDE_WINDOWS: // Hide certain windows - if (!chatWindow->isInputFocused()) + if (!chatWindow || !chatWindow->isInputFocused()) { - statusWindow->setVisible(false); - inventoryWindow->setVisible(false); - shopWindow->setVisible(false); - skillDialog->setVisible(false); - setupWindow->setVisible(false); - equipmentWindow->setVisible(false); - helpWindow->setVisible(false); - debugWindow->setVisible(false); - outfitWindow->setVisible(false); - dropShortcutWindow->setVisible(false); - spellShortcutWindow->setVisible(false); - botCheckerWindow->setVisible(false); - socialWindow->setVisible(false); + if (statusWindow) + statusWindow->setVisible(false); + if (inventoryWindow) + inventoryWindow->setVisible(false); + if (shopWindow) + shopWindow->setVisible(false); + if (skillDialog) + skillDialog->setVisible(false); + if (setupWindow) + setupWindow->setVisible(false); + if (equipmentWindow) + equipmentWindow->setVisible(false); + if (helpWindow) + helpWindow->setVisible(false); + if (debugWindow) + debugWindow->setVisible(false); + if (outfitWindow) + outfitWindow->setVisible(false); + if (dropShortcutWindow) + dropShortcutWindow->setVisible(false); + if (spellShortcutWindow) + spellShortcutWindow->setVisible(false); + if (botCheckerWindow) + botCheckerWindow->setVisible(false); + if (socialWindow) + socialWindow->setVisible(false); } break; case KeyboardConfig::KEY_WINDOW_STATUS: @@ -1222,7 +1296,8 @@ void Game::handleInput() break; case KeyboardConfig::KEY_PATHFIND: // Find path to mouse (debug purpose) - if (!player_node->getDisableGameModifiers()) + if (!player_node || !player_node-> + getDisableGameModifiers()) { if (viewport) viewport->toggleDebugPath(); @@ -1239,16 +1314,22 @@ void Game::handleInput() unsigned int deflt = player_relations.getDefault(); if (deflt & PlayerRelation::TRADE) { - localChatTab->chatLog( - _("Ignoring incoming trade requests"), - BY_SERVER); + if (localChatTab) + { + localChatTab->chatLog( + _("Ignoring incoming trade requests"), + BY_SERVER); + } deflt &= ~PlayerRelation::TRADE; } else { - localChatTab->chatLog( - _("Accepting incoming trade requests"), - BY_SERVER); + if (localChatTab) + { + localChatTab->chatLog( + _("Accepting incoming trade requests"), + BY_SERVER); + } deflt |= PlayerRelation::TRADE; } @@ -1284,10 +1365,11 @@ void Game::handleInput() if (event.active.gain) { // window restore Client::setIsMinimized(false); - if (player_node && !player_node->getAwayMode()) + if (!player_node && !player_node->getAwayMode()) { fpsLimit = config.getIntValue("fpslimit"); - player_node->setHalfAway(false); + if (player_node) + player_node->setHalfAway(false); } } else @@ -1309,12 +1391,20 @@ void Game::handleInput() if (event.active.state & SDL_APPMOUSEFOCUS) Client::setMouseFocused(event.active.gain); - if (player_node->getAwayMode()) + if (player_node) { - if (Client::getInputFocused() || Client::getMouseFocused()) - fpsLimit = config.getIntValue("fpslimit"); - else - fpsLimit = config.getIntValue("altfpslimit"); + if (player_node->getAwayMode()) + { + if (Client::getInputFocused() || Client::getMouseFocused()) + fpsLimit = config.getIntValue("fpslimit"); + else + fpsLimit = config.getIntValue("altfpslimit"); + Client::setFramerate(fpsLimit); + } + } + else + { + fpsLimit = config.getIntValue("fpslimit"); Client::setFramerate(fpsLimit); } } @@ -1329,7 +1419,8 @@ void Game::handleInput() { try { - guiInput->pushInput(event); + if (guiInput) + guiInput->pushInput(event); } catch (const gcn::Exception &e) { @@ -1341,12 +1432,12 @@ void Game::handleInput() } // End while // If the user is configuring the keys then don't respond. - if (!keyboard.isEnabled() || player_node->getAwayMode()) + if (!player_node || !keyboard.isEnabled() || player_node->getAwayMode()) return; if (keyboard.isKeyActive(keyboard.KEY_WEAR_OUTFIT) || keyboard.isKeyActive(keyboard.KEY_COPY_OUTFIT) - || setupWindow->isVisible()) + || (setupWindow && setupWindow->isVisible())) { return; } @@ -1355,7 +1446,7 @@ void Game::handleInput() if (player_node->isAlive() && (!Being::isTalking() || keyboard.getKeyIndex(event.key.keysym.sym) == KeyboardConfig::KEY_TALK) - && !chatWindow->isInputFocused() && !quitDialog) + && chatWindow && !chatWindow->isInputFocused() && !quitDialog) { // Get the state of the keyboard keys keyboard.refreshActiveKeys(); @@ -1602,19 +1693,24 @@ void Game::changeMap(const std::string &mapPath) resetAdjustLevel(); // Clean up floor items, beings and particles - actorSpriteManager->clear(); + if (actorSpriteManager) + actorSpriteManager->clear(); // Close the popup menu on map change so that invalid options can't be // executed. - viewport->closePopupMenu(); - viewport->cleanHoverItems(); + if (viewport) + { + viewport->closePopupMenu(); + viewport->cleanHoverItems(); + } // Unset the map of the player so that its particles are cleared before // being deleted in the next step if (player_node) player_node->setMap(0); - particleEngine->clear(); + if (particleEngine) + particleEngine->clear(); mMapName = mapPath; @@ -1647,10 +1743,14 @@ void Game::changeMap(const std::string &mapPath) socialWindow->setMap(newMap); // Notify the minimap and actorSpriteManager about the map change - minimap->setMap(newMap); - actorSpriteManager->setMap(newMap); - particleEngine->setMap(newMap); - viewport->setMap(newMap); + if (minimap) + minimap->setMap(newMap); + if (actorSpriteManager) + actorSpriteManager->setMap(newMap); + if (particleEngine) + particleEngine->setMap(newMap); + if (viewport) + viewport->setMap(newMap); // Initialize map-based particle effects if (newMap) @@ -1683,7 +1783,7 @@ void Game::changeMap(const std::string &mapPath) void Game::updateHistory(SDL_Event &event) { - if (!player_node->getAttackType()) + if (!player_node || !player_node->getAttackType()) return; bool old = false; @@ -1738,7 +1838,7 @@ void Game::checkKeys() const int timeRange = 120; const int cntInTime = 130; - if (!player_node->getAttackType()) + if (!player_node || !player_node->getAttackType()) return; for (int f = 0; f < MAX_LASTKEYS; f ++) diff --git a/src/graphics.cpp b/src/graphics.cpp index 37fd72c08..efa1058a6 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -97,13 +97,14 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel) logger->log1("Using video driver: unknown"); mDoubleBuffer = ((mTarget->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF); - logger->log("Double buffer mode: %s", - mDoubleBuffer ? "yes" : "no"); + logger->log("Double buffer mode: %s", mDoubleBuffer ? "yes" : "no"); if (mTarget->format) logger->log("Bits per pixel: %d", mTarget->format->BytesPerPixel); const SDL_VideoInfo *vi = SDL_GetVideoInfo(); + if (!vi) + return false; logger->log("Possible to create hardware surfaces: %s", ((vi->hw_available) ? "yes" : "no")); @@ -259,7 +260,8 @@ void Graphics::drawImagePattern(Image *image, int x, int y, int w, int h) const int iw = image->mBounds.w; const int ih = image->mBounds.h; - if (iw == 0 || ih == 0) return; + if (iw == 0 || ih == 0) + return; for (int py = 0; py < h; py += ih) // Y position on pattern plane { @@ -346,8 +348,6 @@ void Graphics::drawImageRect(int x, int y, int w, int h, Image *bottom, Image *left, Image *center) { -// pushClipArea(gcn::Rectangle(x, y, w, h)); - const bool drawMain = center && topLeft && topRight && bottomLeft && bottomRight; @@ -390,8 +390,6 @@ void Graphics::drawImageRect(int x, int y, int w, int h, x + w - bottomRight->getWidth(), y + h - bottomRight->getHeight()); } - -// popClipArea(); } void Graphics::drawImageRect(int x, int y, int w, int h, @@ -601,6 +599,7 @@ void Graphics::calcTile(ImageVertexes *vert, int x, int y) void Graphics::drawTile(ImageVertexes *vert) { + // vert and img must be != 0 Image *img = vert->image; DoubleRects *rects = &vert->sdl; DoubleRects::const_iterator it = rects->begin(); diff --git a/src/guild.cpp b/src/guild.cpp index a2d9149eb..5d129e11e 100644 --- a/src/guild.cpp +++ b/src/guild.cpp @@ -124,7 +124,7 @@ GuildMember *Guild::getMember(int id) const itr_end = mMembers.end(); while (itr != itr_end) { - if ((*itr)->mId == id) + if ((*itr) && (*itr)->mId == id) return (*itr); ++itr; } @@ -138,7 +138,7 @@ GuildMember *Guild::getMember(int accountId, int charId) const itr_end = mMembers.end(); while (itr != itr_end) { - if ((*itr)->mId == accountId && (*itr)->mCharId == charId) + if ((*itr) && (*itr)->mId == accountId && (*itr)->mCharId == charId) return (*itr); ++itr; } @@ -152,7 +152,7 @@ GuildMember *Guild::getMember(const std::string &name) const itr_end = mMembers.end(); while (itr != itr_end) { - if ((*itr)->getName() == name) + if ((*itr) && (*itr)->getName() == name) return (*itr); ++itr; } @@ -189,7 +189,7 @@ void Guild::removeMember(int id) itr_end = mMembers.end(); while (itr != itr_end) { - if ((*itr)->mId == id) + if ((*itr) && (*itr)->mId == id) { GuildMember *member = *itr; mMembers.erase(itr); @@ -212,7 +212,7 @@ void Guild::removeMember(const std::string &name) itr_end = mMembers.end(); while (itr != itr_end) { - if ((*itr)->getName() == name) + if ((*itr) && (*itr)->getName() == name) { GuildMember *member = *itr; mMembers.erase(itr); @@ -262,7 +262,7 @@ bool Guild::isMember(GuildMember *member) const itr_end = mMembers.end(); while (itr != itr_end) { - if ((*itr)->mId == member->mId && + if ((*itr) && (*itr)->mId == member->mId && (*itr)->getName() == member->getName()) { return true; @@ -279,7 +279,7 @@ bool Guild::isMember(int id) const itr_end = mMembers.end(); while (itr != itr_end) { - if ((*itr)->mId == id) + if ((*itr) && (*itr)->mId == id) return true; ++itr; } @@ -293,7 +293,7 @@ bool Guild::isMember(const std::string &name) const itr_end = mMembers.end(); while (itr != itr_end) { - if ((*itr)->getName() == name) + if ((*itr) && (*itr)->getName() == name) return true; ++itr; } @@ -309,7 +309,8 @@ void Guild::getNames(std::vector &names) const while (it != it_end) { - names.push_back((*it)->getName()); + if (*it) + names.push_back((*it)->getName()); ++it; } } diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp index c5d8f8bb6..4620de742 100644 --- a/src/guildmanager.cpp +++ b/src/guildmanager.cpp @@ -96,7 +96,7 @@ void GuildManager::reload() if (socialWindow) { Guild *guild = Guild::getGuild(1); - if (guild) + if (guild && socialWindow) socialWindow->removeTab(guild); } delete mTab; @@ -120,7 +120,8 @@ void GuildManager::chat(std::string msg) void GuildManager::getNames(std::vector &names) { Guild *guild = createGuild(); - guild->getNames(names); + if (guild) + guild->getNames(names); } void GuildManager::requestGuildInfo() diff --git a/src/item.cpp b/src/item.cpp index d76eaf401..45a10f837 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -72,14 +72,9 @@ void Item::setId(int id, unsigned char color) ResourceManager *resman = ResourceManager::getInstance(); const ItemInfo &info = getInfo(); mTags = info.getTags(); -// logger->log("tag0=" + toString(mTags[1])); - -// for (int f = 0; f < mTags->size(); f ++) -// logger->log("tag: %d", (*mTags)[f]); SpriteDisplay display = info.getDisplay(); - std::string imagePath = paths.getStringValue("itemIcons") - + display.image; + std::string imagePath = paths.getStringValue("itemIcons") + display.image; std::string dye = combineDye2(imagePath, info.getDyeColorsString(color)); mImage = resman->getImage(dye); mDrawImage = resman->getImage(dye); diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index bf58c518a..ea9f9b90b 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -477,4 +477,4 @@ std::string KeyboardConfig::getKeyShortString(const std::string &key) const else if (key == "unknown key") return "u key"; return key; -} \ No newline at end of file +} diff --git a/src/localplayer.cpp b/src/localplayer.cpp index ff93cdbf1..8105f3291 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -93,6 +93,8 @@ LocalPlayer *player_node = NULL; extern std::list beingInfoCache; extern OkDialog *weightNotice; extern int weightNoticeTime; +extern MiniStatusWindow *miniStatusWindow; +extern SkillDialog *skillDialog; LocalPlayer::LocalPlayer(int id, int subtype): Being(id, PLAYER, subtype, 0), @@ -138,7 +140,10 @@ LocalPlayer::LocalPlayer(int id, int subtype): mUpdateName = true; mTextColor = &Theme::getThemeColor(Theme::PLAYER); - mNameColor = &userPalette->getColor(UserPalette::SELF); + if (userPalette) + mNameColor = &userPalette->getColor(UserPalette::SELF); + else + mNameColor = 0; mLastTargetX = 0; mLastTargetY = 0; @@ -345,8 +350,11 @@ void LocalPlayer::logic() if (mEnableAdvert && !mBlockAdvert && mAdvertTime < cur_time) { Uint8 smile = FLAG_SPECIAL; - if (mTradebot && shopWindow && !shopWindow->isShopEmpty()) + if (mTradebot && shopWindow && shopWindow + && !shopWindow->isShopEmpty()) + { smile += FLAG_SHOP; + } if (mAwayMode) smile += FLAG_AWAY; @@ -391,8 +399,6 @@ void LocalPlayer::setGMLevel(int level) Position LocalPlayer::getNextWalkPosition(unsigned char dir) { - // check for mMap? - // Compute where the next tile will be set. int dx = 0, dy = 0; if (dir & Being::UP) @@ -1040,13 +1046,13 @@ void LocalPlayer::setDestination(int x, int y) else if (mInvertDirection == 1) { Uint8 newDir = 0; - if (mDirection&UP) + if (mDirection & UP) newDir |= DOWN; - if (mDirection&LEFT) + if (mDirection & LEFT) newDir |= RIGHT; - if (mDirection&DOWN) + if (mDirection & DOWN) newDir |= UP; - if (mDirection&RIGHT) + if (mDirection & RIGHT) newDir |= LEFT; Net::getPlayerHandler()->setDestination(x, y, newDir); @@ -1116,8 +1122,8 @@ void LocalPlayer::setWalkingDir(unsigned char dir) startWalking(dir); } #ifdef MANASERV_SUPPORT - else if (mAction == MOVE - && (Net::getNetworkType() == ServerInfo::MANASERV)) + else if (mAction == MOVE && (Net::getNetworkType() + == ServerInfo::MANASERV)) { nextTile(dir); } @@ -1427,7 +1433,7 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount, msg = N_("Unknown problem picking up item."); break; } - if (config.getBoolValue("showpickupchat")) + if (localChatTab && config.getBoolValue("showpickupchat")) localChatTab->chatLog(_(msg), BY_SERVER); if (mMap && config.getBoolValue("showpickupparticle")) @@ -1545,9 +1551,6 @@ void LocalPlayer::setGotoTarget(Being *target) } } -extern MiniStatusWindow *miniStatusWindow; -extern SkillDialog *skillDialog; - void LocalPlayer::handleStatusEffect(StatusEffect *effect, int effectId) { Being::handleStatusEffect(effect, effectId); @@ -1762,9 +1765,12 @@ void LocalPlayer::moveToTarget(unsigned int dist) if (mTarget) { - debugPath = mMap->findPath(static_cast(playerPos.x - 16) / 32, + if (mMap) + { + debugPath = mMap->findPath(static_cast(playerPos.x - 16) / 32, static_cast(playerPos.y - 32) / 32, mTarget->getTileX(), mTarget->getTileY(), getWalkMask(), 0); + } if (debugPath.size() < dist) return; @@ -1812,7 +1818,7 @@ void LocalPlayer::moveToHome() { moveTo(mCrossX, mCrossY); } - else + else if (mMap) { std::map::const_iterator iter = mHomes.find(mMap->getProperty("_realfilename")); @@ -1929,20 +1935,24 @@ void LocalPlayer::changeEquipmentBeforeAttack(Being* target) if (dx * dx + dy * dy < 8) allowSword = true; + const Inventory *inv = PlayerInfo::getInventory(); + if (!inv) + return; + //if attack distance for sword if (allowSword) { //finding sword - item = PlayerInfo::getInventory()->findItem(571, 0); + item = inv->findItem(571, 0); if (!item) - item = PlayerInfo::getInventory()->findItem(570, 0); + item = inv->findItem(570, 0); if (!item) - item = PlayerInfo::getInventory()->findItem(579, 0); + item = inv->findItem(579, 0); if (!item) - item = PlayerInfo::getInventory()->findItem(536, 0); + item = inv->findItem(536, 0); //no swords if (!item) @@ -1950,21 +1960,17 @@ void LocalPlayer::changeEquipmentBeforeAttack(Being* target) //if sword not equiped if (!item->isEquipped()) - { Net::getInventoryHandler()->equipItem(item); - } //if need equip shield too if (mAttackWeaponType == 3) { //finding shield - item = PlayerInfo::getInventory()->findItem(601, 0); + item = inv->findItem(601, 0); if (!item) - item = PlayerInfo::getInventory()->findItem(602, 0); + item = inv->findItem(602, 0); if (item && !item->isEquipped()) - { Net::getInventoryHandler()->equipItem(item); - } } } @@ -1972,29 +1978,22 @@ void LocalPlayer::changeEquipmentBeforeAttack(Being* target) else { //finding bow - item = PlayerInfo::getInventory()->findItem(545, 0); + item = inv->findItem(545, 0); if (!item) - item = PlayerInfo::getInventory()->findItem(530, 0); + item = inv->findItem(530, 0); //no bow if (!item) return; if (!item->isEquipped()) - { Net::getInventoryHandler()->equipItem(item); - } } - } - void LocalPlayer::crazyMove() { -// if (!allowAction()) -// return; - bool oldDisableCrazyMove = mDisableCrazyMove; mDisableCrazyMove = true; switch(mCrazyMoveType) @@ -2251,7 +2250,7 @@ void LocalPlayer::crazyMove7() void LocalPlayer::crazyMove8() { - if (mAction == MOVE) + if (mAction == MOVE || !mMap) return; int idx = 0; int dist = 1; @@ -2379,7 +2378,7 @@ void LocalPlayer::crazyMoveA() if (mAction == MOVE) return; - if (mMoveProgram.length() == 0) + if (mMoveProgram.empty()) return; if (mCrazyMoveState >= mMoveProgram.length()) @@ -2609,11 +2608,8 @@ void LocalPlayer::crazyMoveA() mCrazyMoveState ++; } -// mCrazyMoveState ++; if (mCrazyMoveState >= mMoveProgram.length()) mCrazyMoveState = 0; - -// debugMsg("mCrazyMoveState: " + toString(mCrazyMoveState)); } bool LocalPlayer::isReachable(int x, int y, int maxCost) @@ -2858,8 +2854,6 @@ void LocalPlayer::specialMove(unsigned char direction) } else { -// if (direction != 0 && getInvertDirection() == 4) -// crazyMove(); setWalkingDir(direction); } @@ -2980,7 +2974,6 @@ void LocalPlayer::setMap(Map *map) Being::setMap(map); updateNavigateList(); -// updateCoords(); } void LocalPlayer::setHome() @@ -3012,8 +3005,6 @@ void LocalPlayer::setHome() mMap->updatePortalTile("", MapItem::EMPTY, static_cast(pos.x), static_cast(pos.y)); -// if (specialLayer) -// specialLayer->setTile(pos.x, pos.y, MapItem::EMPTY); mHomes.erase(key); socialWindow->removePortal(static_cast(pos.x), static_cast(pos.y)); @@ -3031,8 +3022,6 @@ void LocalPlayer::setHome() mHomes[key] = pos; mMap->updatePortalTile("home", MapItem::HOME, getTileX(), getTileY()); -// if (specialLayer) -// specialLayer->setTile(getTileX(), getTileY(), MapItem::HOME); socialWindow->addPortal(getTileX(), getTileY()); } MapItem *mapItem = specialLayer->getTile(getTileX(), getTileY()); @@ -3048,8 +3037,6 @@ void LocalPlayer::setHome() { MapItem *mapItem = specialLayer->getTile(getTileX(), getTileY()); int type = 0; -// if (!mapItem) -// return; std::map::iterator iter = mHomes.find(key); if (iter != mHomes.end() && getTileX() == pos.x && getTileY() == pos.y) @@ -3060,8 +3047,6 @@ void LocalPlayer::setHome() if (!mapItem || mapItem->getType() == MapItem::EMPTY) { -// if (mAction == SIT) -// type = MapItem::HOME; if (mDirection & UP) type = MapItem::ARROW_UP; else if (mDirection & LEFT) @@ -3076,7 +3061,6 @@ void LocalPlayer::setHome() type = MapItem::EMPTY; } mMap->updatePortalTile("", type, getTileX(), getTileY()); -// mapItem = specialLayer->getTile(getTileX(), getTileY()); if (type != MapItem::EMPTY) { @@ -3350,8 +3334,7 @@ void LocalPlayer::updateCoords() if (mShowNavigePath) { - if (getTileX() != mOldTileX || getTileY() != mOldTileY) -// if (playerPos.x != mOldX || playerPos.y != mOldY) + if (mMap && (getTileX() != mOldTileX || getTileY() != mOldTileY)) { SpecialLayer *tmpLayer = mMap->getTempLayer(); if (!tmpLayer) @@ -3575,17 +3558,9 @@ void LocalPlayer::imitateOutfit(Being *player, int sprite) if (mImitationMode == 1 && !player_imitated.empty() && player->getName() == player_imitated) { -// logger->log("have equip %d", sprite); -// std::string filename = ItemDB::get( -// player->getId()).getSprite(mGender); -// logger->log("LocalPlayer::imitateOutfit sprite: " + toString(sprite)); -// logger->log("LocalPlayer::imitateOutfit sprite: " + toString(player->getNumberOfLayers())); -// logger->log("LocalPlayer::imitateOutfit spritecount: " + toString(player->getSpritesCount())); if (sprite < 0 || sprite >= player->getNumberOfLayers()) -// if (sprite < 0 || sprite >= 20) return; -// logger->log("after check"); AnimatedSprite *equipmentSprite = dynamic_cast(player ->getSprite(sprite)); @@ -3635,7 +3610,8 @@ void LocalPlayer::imitateOutfit(Being *player, int sprite) void LocalPlayer::followMoveTo(Being *being, int x, int y) { - if (!mPlayerFollowed.empty() && being->getName() == mPlayerFollowed) + if (being && !mPlayerFollowed.empty() + && being->getName() == mPlayerFollowed) { mPickUpTarget = 0; setDestination(x, y); diff --git a/src/logger.cpp b/src/logger.cpp index 6790d622a..2ec5c331e 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -51,9 +51,7 @@ Logger::Logger(): Logger::~Logger() { if (mLogFile.is_open()) - { mLogFile.close(); - } } void Logger::setLogFile(const std::string &logFilename) -- cgit v1.2.3-70-g09d2 From 3fac30d570918a853a236c75fe985a2d732e7f75 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 13 Sep 2011 22:56:19 +0300 Subject: Fix fps switching after game window set active. --- src/game.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index 4762055fa..d82f13913 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1391,16 +1391,13 @@ void Game::handleInput() if (event.active.state & SDL_APPMOUSEFOCUS) Client::setMouseFocused(event.active.gain); - if (player_node) + if (player_node && player_node->getAwayMode()) { - if (player_node->getAwayMode()) - { - if (Client::getInputFocused() || Client::getMouseFocused()) - fpsLimit = config.getIntValue("fpslimit"); - else - fpsLimit = config.getIntValue("altfpslimit"); - Client::setFramerate(fpsLimit); - } + if (Client::getInputFocused() || Client::getMouseFocused()) + fpsLimit = config.getIntValue("fpslimit"); + else + fpsLimit = config.getIntValue("altfpslimit"); + Client::setFramerate(fpsLimit); } else { -- cgit v1.2.3-70-g09d2