diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-08-14 16:40:47 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-08-14 16:40:47 +0300 |
commit | b8b4e4c524331b4deb0a6caa8da004430297c98a (patch) | |
tree | a2fd6f1db45e76f08c0e5c1b4e57bbb86efba57b | |
parent | c28cd5ffb1ca37a3a6d5ee0a73828dcd092db7f1 (diff) | |
download | manaverse-b8b4e4c524331b4deb0a6caa8da004430297c98a.tar.gz manaverse-b8b4e4c524331b4deb0a6caa8da004430297c98a.tar.bz2 manaverse-b8b4e4c524331b4deb0a6caa8da004430297c98a.tar.xz manaverse-b8b4e4c524331b4deb0a6caa8da004430297c98a.zip |
Replace static members usage from pointers to direct classes.
clang-tidy warning: readability-static-accessed-through-instance
45 files changed, 134 insertions, 171 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index 87c63407d..6c1025650 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -420,9 +420,9 @@ impHandler0(quit) { if (Game::instance() == nullptr) return false; - if ((popupManager != nullptr) && popupManager->isPopupMenuVisible()) + if (PopupManager::isPopupMenuVisible()) { - popupManager->closePopupMenu(); + PopupManager::closePopupMenu(); return true; } else if (quitDialog == nullptr) diff --git a/src/actions/chat.cpp b/src/actions/chat.cpp index e1f801c0b..442597849 100644 --- a/src/actions/chat.cpp +++ b/src/actions/chat.cpp @@ -415,7 +415,7 @@ impHandler(guild) if (guild->getServerGuild()) guildHandler->invite(args); else if (guildManager != nullptr) - guildManager->invite(args); + GuildManager::invite(args); #else // TMWA_SUPPORT guildHandler->invite(args); @@ -530,7 +530,7 @@ impHandler(kickGuild) #ifdef TMWA_SUPPORT else if (guildManager != nullptr) { - guildManager->kick(event.args); + GuildManager::kick(event.args); } #endif // TMWA_SUPPORT } diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index 03278c47f..af7fecf23 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -406,12 +406,8 @@ impHandler(commandOutfit) impHandler(commandEmote) { - if (localPlayer != nullptr) - { - localPlayer->emote(CAST_U8(atoi(event.args.c_str()))); - return true; - } - return false; + LocalPlayer::emote(CAST_U8(atoi(event.args.c_str()))); + return true; } impHandler(awayMessage) @@ -428,7 +424,7 @@ impHandler(pseudoAway) { if (localPlayer != nullptr) { - localPlayer->setPseudoAway(event.args); + LocalPlayer::setPseudoAway(event.args); localPlayer->updateStatus(); return true; } @@ -1141,9 +1137,6 @@ impHandler(selectSkillLevel) impHandler(skill) { - if (skillDialog == nullptr) - return false; - StringVect vect; splitToStringVector(vect, event.args, ' '); const int sz = CAST_S32(vect.size()); @@ -1161,7 +1154,7 @@ impHandler(skill) // +++ add here also cast type and offsets if (text.empty()) { - skillDialog->useSkill(skillId, + SkillDialog::useSkill(skillId, AutoTarget_true, level, false, @@ -1172,7 +1165,7 @@ impHandler(skill) } else { - skillDialog->useSkill(skillId, + SkillDialog::useSkill(skillId, AutoTarget_true, level, true, diff --git a/src/actormanager.cpp b/src/actormanager.cpp index 172472072..c864b8c08 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -1071,7 +1071,7 @@ Being *ActorManager::findNearestPvpPlayer() const if (!((mapPvpMode != 0) || (teamId != 0))) continue; - if (!localPlayer->checAttackPermissions(being)) + if (!LocalPlayer::checAttackPermissions(being)) continue; const int dx = being->getTileX() - localPlayer->getTileX(); diff --git a/src/being/being.cpp b/src/being/being.cpp index afea7fc4b..009690a94 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -742,14 +742,14 @@ void Being::takeDamage(Being *restrict const attacker, { if (attacker->mType == ActorType::Player || (amount != 0)) { - chatWindow->battleChatLog(strprintf("%s : Hit you -%d", + ChatWindow::battleChatLog(strprintf("%s : Hit you -%d", attacker->getName().c_str(), amount), ChatMsgType::BY_OTHER); } } else if (attacker == localPlayer && (amount != 0)) { - chatWindow->battleChatLog(strprintf("%s : You hit %s -%d", + ChatWindow::battleChatLog(strprintf("%s : You hit %s -%d", attacker->mName.c_str(), mName.c_str(), amount), diff --git a/src/being/crazymoves.cpp b/src/being/crazymoves.cpp index 463dfd1eb..5fb093d9d 100644 --- a/src/being/crazymoves.cpp +++ b/src/being/crazymoves.cpp @@ -757,7 +757,7 @@ void CrazyMoves::crazyMoveAe() const emoteId = CAST_U8(emo - 'A' + 37); } if (mMoveProgram[settings.crazyMoveState - 1] == 'e') - localPlayer->emote(emoteId); + LocalPlayer::emote(emoteId); else if (PacketLimiter::limitPackets(PacketType::PACKET_CHAT)) petHandler->emote(emoteId); diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 68d39f08f..44cc015d9 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -1838,8 +1838,8 @@ void LocalPlayer::setHome() if (mapItem != nullptr) { const int idx = socialWindow->getPortalIndex(mX, mY); - mapItem->setName(keyboard.getKeyShortString( - outfitWindow->keyName(idx))); + mapItem->setName(KeyboardConfig::getKeyShortString( + OutfitWindow::keyName(idx))); } saveHomes(); } @@ -1879,8 +1879,8 @@ void LocalPlayer::setHome() if (mapItem != nullptr) { const int idx = socialWindow->getPortalIndex(mX, mY); - mapItem->setName(keyboard.getKeyShortString( - outfitWindow->keyName(idx))); + mapItem->setName(KeyboardConfig::getKeyShortString( + OutfitWindow::keyName(idx))); } } else @@ -2134,8 +2134,7 @@ void LocalPlayer::updateCoords() { if (socialWindow != nullptr) socialWindow->updatePortals(); - if (popupManager != nullptr) - popupManager->hideBeingPopup(); + PopupManager::hideBeingPopup(); updateMusic(); } diff --git a/src/client.cpp b/src/client.cpp index 23ca0e608..ef0e5af31 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -616,8 +616,7 @@ void Client::gameClear() delete2(assertListener); - if (ipc != nullptr) - ipc->stop(); + IPC::stop(); eventsManager.shutdown(); WindowManager::deleteWindows(); if (windowContainer != nullptr) @@ -667,7 +666,7 @@ void Client::gameClear() touchManager.clear(); - graphicsManager.deleteRenderers(); + GraphicsManager::deleteRenderers(); if (logger != nullptr) logger->log1("Quitting4"); diff --git a/src/configmanager.cpp b/src/configmanager.cpp index 118a4e76a..804d597ce 100644 --- a/src/configmanager.cpp +++ b/src/configmanager.cpp @@ -88,7 +88,7 @@ void ConfigManager::initServerConfig(const std::string &serverName) configPath.c_str()); } - const bool val = client->isTmw(); + const bool val = Client::isTmw(); setDefaultOption("enableManaMarketBot", val); setDefaultOption("enableRemoteCommands", !val); } diff --git a/src/dirs.cpp b/src/dirs.cpp index ae46f2721..c48e910d1 100644 --- a/src/dirs.cpp +++ b/src/dirs.cpp @@ -464,7 +464,7 @@ void Dirs::initUpdatesDir() // Parse out any "http://" or "https://", and set the updates directory const size_t pos = settings.updateHost.find("://"); - if (pos != settings.updateHost.npos) + if (pos != std::string::npos) { if (pos + 3 < settings.updateHost.length() && !settings.updateHost.empty()) diff --git a/src/dyetool/client.cpp b/src/dyetool/client.cpp index 05a5d365a..18fb9943c 100644 --- a/src/dyetool/client.cpp +++ b/src/dyetool/client.cpp @@ -432,7 +432,7 @@ void Client::gameClear() if (logger != nullptr) logger->log1("Quitting3"); - graphicsManager.deleteRenderers(); + GraphicsManager::deleteRenderers(); if (logger != nullptr) logger->log1("Quitting4"); diff --git a/src/dyetool/client.h b/src/dyetool/client.h index 6a22b6925..57f62c2b9 100644 --- a/src/dyetool/client.h +++ b/src/dyetool/client.h @@ -76,7 +76,7 @@ class Client final : public ActionListener void slowLogic(); - bool isTmw(); + static bool isTmw(); private: void stateGame(); diff --git a/src/dyetool/dyemain.cpp b/src/dyetool/dyemain.cpp index 4caf4b94d..95e038da6 100644 --- a/src/dyetool/dyemain.cpp +++ b/src/dyetool/dyemain.cpp @@ -109,7 +109,7 @@ int main(int argc, char **argv) printf("Error loading image\n"); return 1; } - SDL_Surface *const surface = imageHelper->convertTo32Bit( + SDL_Surface *const surface = ImageHelper::convertTo32Bit( image->getSDLSurface()); ImageWriter::writePNG(surface, dst); SDL_FreeSurface(surface); diff --git a/src/dyetool/gui/viewport.cpp b/src/dyetool/gui/viewport.cpp index 799f6acce..21719286f 100644 --- a/src/dyetool/gui/viewport.cpp +++ b/src/dyetool/gui/viewport.cpp @@ -153,10 +153,10 @@ void Viewport::mousePressed(MouseEvent &event) } // If a popup is active, just remove it - if (popupManager->isPopupMenuVisible()) + if (PopupManager::isPopupMenuVisible()) { mPlayerFollowMouse = false; - popupManager->hidePopupMenu(); + PopupManager::hidePopupMenu(); return; } diff --git a/src/game.cpp b/src/game.cpp index a9e9f26ff..b1687e953 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -340,8 +340,7 @@ static void destroyGuiWindows() whoIsOnline->setAllowUpdate(false); #ifdef TMWA_SUPPORT - if (guildManager != nullptr) - guildManager->clear(); + GuildManager::clear(); #endif // TMWA_SUPPORT delete2(windowMenu); @@ -1060,11 +1059,8 @@ void Game::changeMap(const std::string &mapPath) resetAdjustLevel(); ResourceManager::cleanProtected(); - if (popupManager != nullptr) - { - popupManager->clearPopup(); - popupManager->closePopupMenu(); - } + PopupManager::clearPopup(); + PopupManager::closePopupMenu(); // Clean up floor items, beings and particles if (actorManager != nullptr) @@ -1162,7 +1158,7 @@ void Game::updateHistory(const SDL_Event &event) { bool old = false; - const InputActionT key = keyboard.getKeyIndex(event); + const InputActionT key = KeyboardConfig::getKeyIndex(event); const time_t time = cur_time; int idx = -1; for (int f = 0; f < MAX_LASTKEYS; f ++) diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 8b97b7185..9ad23888b 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -2418,7 +2418,7 @@ void PopupMenu::showSkillTypePopup(const SkillInfo *const info) void PopupMenu::showPopup(int x, int y) { - popupManager->hideItemPopup(); + PopupManager::hideItemPopup(); const int pad2 = 2 * mPadding; mBrowserBox->setPosition(mPadding, mPadding); mScrollArea->setPosition(mPadding, mPadding); diff --git a/src/gui/shortcut/emoteshortcut.cpp b/src/gui/shortcut/emoteshortcut.cpp index fb59da96b..8131a11a2 100644 --- a/src/gui/shortcut/emoteshortcut.cpp +++ b/src/gui/shortcut/emoteshortcut.cpp @@ -77,13 +77,10 @@ void EmoteShortcut::save() const void EmoteShortcut::useEmotePlayer(const size_t index) const { - if (localPlayer == nullptr) - return; - if (index <= CAST_SIZE(SHORTCUT_EMOTES)) { if (mEmotes[index - 1] > 0) - localPlayer->emote(mEmotes[index - 1]); + LocalPlayer::emote(mEmotes[index - 1]); } } @@ -101,7 +98,7 @@ void EmoteShortcut::useEmote(const size_t index) const { case EmoteType::Player: default: - localPlayer->emote(emote); + LocalPlayer::emote(emote); break; case EmoteType::Pet: petHandler->emote(emote); diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 08d2bfb91..c77232591 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -578,10 +578,10 @@ void Viewport::mousePressed(MouseEvent &event) } // If a popup is active, just remove it - if (popupManager->isPopupMenuVisible()) + if (PopupManager::isPopupMenuVisible()) { mPlayerFollowMouse = false; - popupManager->hidePopupMenu(); + PopupManager::hidePopupMenu(); return; } @@ -940,13 +940,13 @@ void Viewport::mouseMoved(MouseEvent &event) || type == ActorType::Mercenary || type == ActorType::Pet)) { - popupManager->hideTextPopup(); + PopupManager::hideTextPopup(); if (mShowBeingPopup && (beingPopup != nullptr)) beingPopup->show(mMouseX, mMouseY, mHoverBeing); } else { - popupManager->hideBeingPopup(); + PopupManager::hideBeingPopup(); } mHoverItem = actorManager->findItem(x / mMap->getTileWidth(), @@ -968,7 +968,7 @@ void Viewport::mouseMoved(MouseEvent &event) { if (!mHoverSign->getComment().empty()) { - popupManager->hideBeingPopup(); + PopupManager::hideBeingPopup(); if (textPopup != nullptr) { textPopup->show(mMouseX, mMouseY, @@ -977,16 +977,19 @@ void Viewport::mouseMoved(MouseEvent &event) } else { - if (popupManager->isTextPopupVisible()) - popupManager->hideTextPopup(); + if (PopupManager::isTextPopupVisible()) + PopupManager::hideTextPopup(); } gui->setCursorType(Cursor::CURSOR_UP); return; } } } - if (!event.isConsumed() && popupManager->isTextPopupVisible()) - popupManager->hideTextPopup(); + if (!event.isConsumed() && + PopupManager::isTextPopupVisible()) + { + PopupManager::hideTextPopup(); + } if (mHoverBeing != nullptr) { diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index e99230216..9f667caba 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -63,10 +63,7 @@ ItemShortcutContainer::ItemShortcutContainer(Widget2 *const widget, mUnEquipedColor(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED)), mUnEquipedColor2(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED_OUTLINE)) { - if (itemShortcut[mNumber] != nullptr) - mMaxItems = itemShortcut[mNumber]->getItemCount(); - else - mMaxItems = 0; + mMaxItems = ItemShortcut::getItemCount(); } ItemShortcutContainer::~ItemShortcutContainer() diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index bf2b2bb83..0f5c5a31a 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -250,8 +250,8 @@ void Popup::mouseMoved(MouseEvent &event A_UNUSED) { if (popupManager != nullptr) { - popupManager->hideBeingPopup(); - popupManager->hideTextPopup(); + PopupManager::hideBeingPopup(); + PopupManager::hideTextPopup(); } mRedraw = true; } diff --git a/src/gui/widgets/tabs/chat/emulateguildtab.cpp b/src/gui/widgets/tabs/chat/emulateguildtab.cpp index 4374f6b2c..4e94bf11d 100644 --- a/src/gui/widgets/tabs/chat/emulateguildtab.cpp +++ b/src/gui/widgets/tabs/chat/emulateguildtab.cpp @@ -56,16 +56,14 @@ EmulateGuildTab::~EmulateGuildTab() bool EmulateGuildTab::handleCommand(const std::string &restrict type, const std::string &restrict args) { - if (guildManager == nullptr) - return false; if (type == "invite") - guildManager->invite(args); + GuildManager::invite(args); else if (type == "leave") - guildManager->leave(); + GuildManager::leave(); else if (type == "kick") - guildManager->kick(args); + GuildManager::kick(args); else if (type == "notice") - guildManager->notice(args); + GuildManager::notice(args); else return false; diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp index 7a37f2d89..bd8097318 100644 --- a/src/gui/widgets/tabs/setup_audio.cpp +++ b/src/gui/widgets/tabs/setup_audio.cpp @@ -72,14 +72,14 @@ Setup_Audio::Setup_Audio(const Widget2 *const widget) : // TRANSLATORS: settings option new SetupItemSlider(_("Sfx volume"), "", "sfxVolume", - this, "sfxVolumeEvent", 0, soundManager.getMaxVolume(), 1, + this, "sfxVolumeEvent", 0, SoundManager::getMaxVolume(), 1, 150, OnTheFly_true, MainConfig_true); // TRANSLATORS: settings option new SetupItemSlider(_("Music volume"), "", "musicVolume", - this, "musicVolumeEvent", 0, soundManager.getMaxVolume(), 1, + this, "musicVolumeEvent", 0, SoundManager::getMaxVolume(), 1, 150, OnTheFly_true, MainConfig_true); diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp index 490205b4b..84cd60521 100644 --- a/src/gui/widgets/tabs/setup_joystick.cpp +++ b/src/gui/widgets/tabs/setup_joystick.cpp @@ -164,8 +164,7 @@ void Setup_Joystick::setTempEnabled(const bool sel) void Setup_Joystick::cancel() { - if (joystick != nullptr) - joystick->setEnabled(mOriginalJoystickEnabled); + Joystick::setEnabled(mOriginalJoystickEnabled); if (mOriginalJoystickEnabled != mJoystickEnabled->isSelected()) setTempEnabled(mOriginalJoystickEnabled); @@ -178,7 +177,7 @@ void Setup_Joystick::apply() if (joystick == nullptr) return; - config.setValue("joystickEnabled", joystick->isEnabled()); + config.setValue("joystickEnabled", Joystick::isEnabled()); config.setValue("useInactiveJoystick", mUseInactiveCheckBox->isSelected()); joystick->setUseInactive(mUseInactiveCheckBox->isSelected()); diff --git a/src/gui/widgets/tabs/socialnavigationtab.h b/src/gui/widgets/tabs/socialnavigationtab.h index 3bd584991..1b049f055 100644 --- a/src/gui/widgets/tabs/socialnavigationtab.h +++ b/src/gui/widgets/tabs/socialnavigationtab.h @@ -136,8 +136,8 @@ class SocialNavigationTab final : public SocialTab ->findPortalByTile(x, y); if (being != nullptr) { - being->setName(keyboard.getKeyShortString( - outfitWindow->keyName(idx))); + being->setName(KeyboardConfig::getKeyShortString( + OutfitWindow::keyName(idx))); } if (specialLayer != nullptr) @@ -146,8 +146,8 @@ class SocialNavigationTab final : public SocialTab ava->getX(), ava->getY()); if (portal != nullptr) { - portal->setName(keyboard.getKeyShortString( - outfitWindow->keyName(idx))); + portal->setName(KeyboardConfig::getKeyShortString( + OutfitWindow::keyName(idx))); } } } diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 5d48cfad3..9d9385f8d 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -958,8 +958,8 @@ void Window::mouseMoved(MouseEvent &event) updateResizeHandler(event); if ((popupManager != nullptr) && !event.isConsumed()) { - popupManager->hideBeingPopup(); - popupManager->hideTextPopup(); + PopupManager::hideBeingPopup(); + PopupManager::hideTextPopup(); } } diff --git a/src/gui/windowmanager.cpp b/src/gui/windowmanager.cpp index 38141720b..978e6ae42 100644 --- a/src/gui/windowmanager.cpp +++ b/src/gui/windowmanager.cpp @@ -322,7 +322,7 @@ void WindowManager::resizeVideo(int actualWidth, #ifndef DYECMD Game *const game = Game::instance(); if (game != nullptr) - game->videoResized(width, height); + Game::videoResized(width, height); #endif // DYECMD if (gui != nullptr) diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index b3f3317a3..b6b635c1c 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -312,7 +312,7 @@ void SocialWindow::action(const ActionEvent &event) if (guildManager == nullptr || !GuildManager::getEnableGuildBot()) guildHandler->inviteResponse(mGuildInvited, true); else - guildManager->inviteResponse(true); + GuildManager::inviteResponse(true); #else // TMWA_SUPPORT guildHandler->inviteResponse(mGuildInvited, true); @@ -332,7 +332,7 @@ void SocialWindow::action(const ActionEvent &event) if (guildManager == nullptr || !GuildManager::getEnableGuildBot()) guildHandler->inviteResponse(mGuildInvited, false); else - guildManager->inviteResponse(false); + GuildManager::inviteResponse(false); #else // TMWA_SUPPORT guildHandler->inviteResponse(mGuildInvited, false); diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index ab0505285..814e2ac76 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -398,7 +398,7 @@ std::string InputManager::getKeyStringLong(const InputActionT index) const { if (key.value >= 0) { - str = keyboard.getKeyName(key.value); + str = KeyboardConfig::getKeyName(key.value); } else if (key.value < -1) { @@ -440,8 +440,8 @@ void InputManager::updateKeyString(const InputFunction &ki, { if (key.value >= 0) { - str = keyboard.getKeyShortString( - keyboard.getKeyName(key.value)); + str = KeyboardConfig::getKeyShortString( + KeyboardConfig::getKeyName(key.value)); } else if (key.value < -1) { diff --git a/src/listeners/playerpostdeathlistener.h b/src/listeners/playerpostdeathlistener.h index c938ea175..2a5f86235 100644 --- a/src/listeners/playerpostdeathlistener.h +++ b/src/listeners/playerpostdeathlistener.h @@ -54,9 +54,7 @@ struct PlayerPostDeathListener final : public ActionListener deathNotice = nullptr; DialogsManager::closeDialogs(); - - if (popupManager != nullptr) - popupManager->closePopupMenu(); + PopupManager::closePopupMenu(); NpcDialog::clearDialogs(); if (localPlayer != nullptr) diff --git a/src/maingui.cpp b/src/maingui.cpp index 9e7efa9c6..205d8c6d1 100644 --- a/src/maingui.cpp +++ b/src/maingui.cpp @@ -132,7 +132,7 @@ int mainGui(int argc, char *argv[]) else { client->testsInit(); - ret = client->testsExec(); + ret = Client::testsExec(); } delete2(client); VirtFs::deinit(); diff --git a/src/net/ea/charserverrecv.cpp b/src/net/ea/charserverrecv.cpp index 7f27a6d2e..d058dfe6d 100644 --- a/src/net/ea/charserverrecv.cpp +++ b/src/net/ea/charserverrecv.cpp @@ -111,20 +111,20 @@ void CharServerRecv::processCharCreateFailed(Net::MessageIn &msg) ShowCenter_true, nullptr, 260); - if (charServerHandler->mCharCreateDialog != nullptr) - charServerHandler->mCharCreateDialog->unlock(); + if (Net::CharServerHandler::mCharCreateDialog != nullptr) + Net::CharServerHandler::mCharCreateDialog->unlock(); BLOCK_END("CharServerRecv::processCharCreateFailed") } void CharServerRecv::processCharDelete(Net::MessageIn &msg A_UNUSED) { BLOCK_START("CharServerRecv::processCharDelete") - delete charServerHandler->mSelectedCharacter; - charServerHandler->mCharacters.remove( - charServerHandler->mSelectedCharacter); - charServerHandler->mSelectedCharacter = nullptr; - charServerHandler->updateCharSelectDialog(); - charServerHandler->unlockCharSelectDialog(); + delete Net::CharServerHandler::mSelectedCharacter; + Net::CharServerHandler::mCharacters.remove( + Net::CharServerHandler::mSelectedCharacter); + Net::CharServerHandler::mSelectedCharacter = nullptr; + Net::CharServerHandler::updateCharSelectDialog(); + Net::CharServerHandler::unlockCharSelectDialog(); CREATEWIDGET(OkDialog, // TRANSLATORS: info message header _("Info"), diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp index 95cb677bd..ce2b3a581 100644 --- a/src/net/eathena/beingrecv.cpp +++ b/src/net/eathena/beingrecv.cpp @@ -470,8 +470,8 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) const int num = socialWindow->getPortalIndex(x, y); if (num >= 0) { - dstBeing->setName(keyboard.getKeyShortString( - outfitWindow->keyName(num))); + dstBeing->setName(KeyboardConfig::getKeyShortString( + OutfitWindow::keyName(num))); } else { @@ -927,8 +927,8 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg) const int num = socialWindow->getPortalIndex(x, y); if (num >= 0) { - dstBeing->setName(keyboard.getKeyShortString( - outfitWindow->keyName(num))); + dstBeing->setName(KeyboardConfig::getKeyShortString( + OutfitWindow::keyName(num))); } else { diff --git a/src/net/eathena/charserverrecv.cpp b/src/net/eathena/charserverrecv.cpp index 13a374533..487e148bd 100644 --- a/src/net/eathena/charserverrecv.cpp +++ b/src/net/eathena/charserverrecv.cpp @@ -224,8 +224,8 @@ void CharServerRecv::processCharLogin(Net::MessageIn &msg) msg.skip(20, "unused 0"); - delete_all(charServerHandler->mCharacters); - charServerHandler->mCharacters.clear(); + delete_all(Net::CharServerHandler::mCharacters); + Net::CharServerHandler::mCharacters.clear(); // Derive number of characters from message length const int count = (msg.getLength() - 24 - offset) @@ -235,7 +235,7 @@ void CharServerRecv::processCharLogin(Net::MessageIn &msg) { Net::Character *const character = new Net::Character; readPlayerData(msg, character); - charServerHandler->mCharacters.push_back(character); + Net::CharServerHandler::mCharacters.push_back(character); if (character->dummy != nullptr) { logger->log("CharServer: Player: %s (%d)", @@ -264,8 +264,7 @@ void CharServerRecv::processCharMapInfo(Net::MessageIn &restrict msg) ServerInfo &server = mapServer; BLOCK_START("CharServerRecv::processCharMapInfo") PlayerInfo::setCharId(msg.readInt32("char id")); - const GameHandler *const gh = static_cast<GameHandler*>(gameHandler); - gh->setMap(msg.readString(16, "map name")); + GameHandler::setMap(msg.readString(16, "map name")); if (config.getBoolValue("usePersistentIP") || settings.persistentIp) { msg.readInt32("map ip address"); @@ -283,15 +282,15 @@ void CharServerRecv::processCharMapInfo(Net::MessageIn &restrict msg) } // Prevent the selected local player from being deleted - localPlayer = charServerHandler->mSelectedCharacter->dummy; - PlayerInfo::setBackend(charServerHandler->mSelectedCharacter->data); + localPlayer = Net::CharServerHandler::mSelectedCharacter->dummy; + PlayerInfo::setBackend(Net::CharServerHandler::mSelectedCharacter->data); PlayerInfo::setStatBase(Attributes::PLAYER_WALK_SPEED, playerHandler->getDefaultWalkSpeed()); - charServerHandler->mSelectedCharacter->dummy = nullptr; + Net::CharServerHandler::mSelectedCharacter->dummy = nullptr; charServerHandler->clear(); - charServerHandler->updateCharSelectDialog(); + Net::CharServerHandler::updateCharSelectDialog(); if (network != nullptr) network->disconnect(); @@ -304,13 +303,12 @@ void CharServerRecv::processChangeMapServer(Net::MessageIn &msg) Network *const network = Network::mInstance; ServerInfo &server = mapServer; BLOCK_START("CharServerRecv::processChangeMapServer") - const GameHandler *const gh = static_cast<GameHandler*>(gameHandler); - if ((gh == nullptr) || (network == nullptr)) + if (network == nullptr) { BLOCK_END("CharServerRecv::processChangeMapServer") return; } - gh->setMap(msg.readString(16, "map name")); + GameHandler::setMap(msg.readString(16, "map name")); const int x = msg.readInt16("x"); const int y = msg.readInt16("y"); if (config.getBoolValue("usePersistentIP") || settings.persistentIp) @@ -372,16 +370,13 @@ void CharServerRecv::processCharCreate(Net::MessageIn &msg) BLOCK_START("CharServerRecv::processCharCreate") Net::Character *const character = new Net::Character; readPlayerData(msg, character); - charServerHandler->mCharacters.push_back(character); + Net::CharServerHandler::mCharacters.push_back(character); - charServerHandler->updateCharSelectDialog(); + Net::CharServerHandler::updateCharSelectDialog(); // Close the character create dialog - if (charServerHandler->mCharCreateDialog != nullptr) - { - charServerHandler->mCharCreateDialog->scheduleDelete(); - charServerHandler->mCharCreateDialog = nullptr; - } + Net::CharServerHandler::mCharCreateDialog->scheduleDelete(); + Net::CharServerHandler::mCharCreateDialog = nullptr; BLOCK_END("CharServerRecv::processCharCreate") } @@ -414,7 +409,7 @@ void CharServerRecv::processCharRename(Net::MessageIn &msg) const int flag = msg.readInt16("flag"); if (flag == 0) { - charServerHandler->mCharSelectDialog->setName( + Net::CharServerHandler::mCharSelectDialog->setName( mRenameId, mNewName); CREATEWIDGET(OkDialog, @@ -478,7 +473,7 @@ void CharServerRecv::processCharChangeSlot(Net::MessageIn &msg) void CharServerRecv::processCharDeleteFailed(Net::MessageIn &msg) { BLOCK_START("CharServerRecv::processCharDeleteFailed") - charServerHandler->unlockCharSelectDialog(); + Net::CharServerHandler::unlockCharSelectDialog(); msg.readUInt8("error"); CREATEWIDGET(OkDialog, // TRANSLATORS: error header @@ -530,8 +525,8 @@ void CharServerRecv::processCharCharacters(Net::MessageIn &msg) { msg.skip(2, "packet len"); - delete_all(charServerHandler->mCharacters); - charServerHandler->mCharacters.clear(); + delete_all(Net::CharServerHandler::mCharacters); + Net::CharServerHandler::mCharacters.clear(); // Derive number of characters from message length const int count = (msg.getLength() - 4) @@ -541,7 +536,7 @@ void CharServerRecv::processCharCharacters(Net::MessageIn &msg) { Net::Character *const character = new Net::Character; readPlayerData(msg, character); - charServerHandler->mCharacters.push_back(character); + Net::CharServerHandler::mCharacters.push_back(character); if (character->dummy != nullptr) { logger->log("CharServer: Player: %s (%d)", diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp index 0557c652b..c2aac194b 100644 --- a/src/net/eathena/generalhandler.cpp +++ b/src/net/eathena/generalhandler.cpp @@ -173,12 +173,12 @@ void GeneralHandler::reload() const static_cast<CharServerHandler*>(mCharServerHandler); charHandler->setCharCreateDialog(nullptr); charHandler->setCharSelectDialog(nullptr); - static_cast<PartyHandler*>(mPartyHandler)->reload(); + PartyHandler::reload(); } void GeneralHandler::reloadPartially() const { - static_cast<PartyHandler*>(mPartyHandler)->reload(); + PartyHandler::reload(); } void GeneralHandler::unload() const diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp index 4c728fb2f..2f5744dec 100644 --- a/src/net/eathena/playerhandler.cpp +++ b/src/net/eathena/playerhandler.cpp @@ -205,10 +205,7 @@ void PlayerHandler::pickUp(const FloorItem *const floorItem) const outMsg.writeBeingId(id, "object id"); } - EAthena::InventoryHandler *const handler = - static_cast<EAthena::InventoryHandler*>(inventoryHandler); - if (handler != nullptr) - handler->pushPickup(floorItem->getId()); + Ea::InventoryHandler::pushPickup(floorItem->getId()); } void PlayerHandler::setDirection(const unsigned char direction) const diff --git a/src/net/tmwa/beingrecv.cpp b/src/net/tmwa/beingrecv.cpp index 40b5630ef..7b37d1438 100644 --- a/src/net/tmwa/beingrecv.cpp +++ b/src/net/tmwa/beingrecv.cpp @@ -896,8 +896,8 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) const int num = socialWindow->getPortalIndex(x, y); if (num >= 0) { - dstBeing->setName(keyboard.getKeyShortString( - outfitWindow->keyName(num))); + dstBeing->setName(KeyboardConfig::getKeyShortString( + OutfitWindow::keyName(num))); } else { diff --git a/src/net/tmwa/charserverrecv.cpp b/src/net/tmwa/charserverrecv.cpp index 0130960e0..0f16effa9 100644 --- a/src/net/tmwa/charserverrecv.cpp +++ b/src/net/tmwa/charserverrecv.cpp @@ -180,8 +180,8 @@ void CharServerRecv::processCharLogin(Net::MessageIn &msg) msg.skip(18, "unused"); - delete_all(charServerHandler->mCharacters); - charServerHandler->mCharacters.clear(); + delete_all(Net::CharServerHandler::mCharacters); + Net::CharServerHandler::mCharacters.clear(); // Derive number of characters from message length const int count = (msg.getLength() - 24) / 106; @@ -190,7 +190,7 @@ void CharServerRecv::processCharLogin(Net::MessageIn &msg) { Net::Character *const character = new Net::Character; readPlayerData(msg, character); - charServerHandler->mCharacters.push_back(character); + Net::CharServerHandler::mCharacters.push_back(character); if (character->dummy != nullptr) { logger->log("CharServer: Player: %s (%d)", @@ -208,8 +208,7 @@ void CharServerRecv::processCharMapInfo(Net::MessageIn &restrict msg) ServerInfo &server = mapServer; BLOCK_START("CharServerRecv::processCharMapInfo") PlayerInfo::setCharId(msg.readInt32("char id?")); - const GameHandler *const gh = static_cast<GameHandler*>(gameHandler); - gh->setMap(msg.readString(16, "map name")); + GameHandler::setMap(msg.readString(16, "map name")); if (config.getBoolValue("usePersistentIP") || settings.persistentIp) { msg.readInt32("ip address"); @@ -222,13 +221,13 @@ void CharServerRecv::processCharMapInfo(Net::MessageIn &restrict msg) server.port = msg.readInt16("port"); // Prevent the selected local player from being deleted - localPlayer = charServerHandler->mSelectedCharacter->dummy; - PlayerInfo::setBackend(charServerHandler->mSelectedCharacter->data); + localPlayer = Net::CharServerHandler::mSelectedCharacter->dummy; + PlayerInfo::setBackend(Net::CharServerHandler::mSelectedCharacter->data); - charServerHandler->mSelectedCharacter->dummy = nullptr; + Net::CharServerHandler::mSelectedCharacter->dummy = nullptr; charServerHandler->clear(); - charServerHandler->updateCharSelectDialog(); + Net::CharServerHandler::updateCharSelectDialog(); if (network != nullptr) network->disconnect(); @@ -241,13 +240,12 @@ void CharServerRecv::processChangeMapServer(Net::MessageIn &msg) Network *const network = Network::mInstance; ServerInfo &server = mapServer; BLOCK_START("CharServerRecv::processChangeMapServer") - GameHandler *const gh = static_cast<GameHandler*>(gameHandler); - if ((gh == nullptr) || (network == nullptr)) + if (network == nullptr) { BLOCK_END("CharServerRecv::processChangeMapServer") return; } - gh->setMap(msg.readString(16, "map name")); + GameHandler::setMap(msg.readString(16, "map name")); const int x = msg.readInt16("x"); const int y = msg.readInt16("y"); if (config.getBoolValue("usePersistentIP") || settings.persistentIp) @@ -276,23 +274,20 @@ void CharServerRecv::processCharCreate(Net::MessageIn &msg) BLOCK_START("CharServerRecv::processCharCreate") Net::Character *const character = new Net::Character; readPlayerData(msg, character); - charServerHandler->mCharacters.push_back(character); + Net::CharServerHandler::mCharacters.push_back(character); - charServerHandler->updateCharSelectDialog(); + Net::CharServerHandler::updateCharSelectDialog(); // Close the character create dialog - if (charServerHandler->mCharCreateDialog != nullptr) - { - charServerHandler->mCharCreateDialog->scheduleDelete(); - charServerHandler->mCharCreateDialog = nullptr; - } + Net::CharServerHandler::mCharCreateDialog->scheduleDelete(); + Net::CharServerHandler::mCharCreateDialog = nullptr; BLOCK_END("CharServerRecv::processCharCreate") } void CharServerRecv::processCharDeleteFailed(Net::MessageIn &msg) { BLOCK_START("CharServerRecv::processCharDeleteFailed") - charServerHandler->unlockCharSelectDialog(); + Net::CharServerHandler::unlockCharSelectDialog(); msg.readUInt8("error"); CREATEWIDGET(OkDialog, // TRANSLATORS: error header diff --git a/src/net/tmwa/chatrecv.cpp b/src/net/tmwa/chatrecv.cpp index 62150a2ad..d0ac861df 100644 --- a/src/net/tmwa/chatrecv.cpp +++ b/src/net/tmwa/chatrecv.cpp @@ -237,7 +237,7 @@ void ChatRecv::processWhisperContinue(const std::string &nick, if (showMsg && (chatWindow != nullptr)) chatWindow->addWhisper(nick, chatMsg); if (chatMsg.find("B1") == 0 || chatMsg.find("S1") == 0) - shopWindow->showList(nick, chatMsg); + ShopWindow::showList(nick, chatMsg); } else if (chatWindow != nullptr) { diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index 6546bf23a..0cbaf1c4c 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -173,12 +173,12 @@ void GeneralHandler::reload() const static_cast<CharServerHandler*>(mCharServerHandler); charHandler->setCharCreateDialog(nullptr); charHandler->setCharSelectDialog(nullptr); - static_cast<PartyHandler*>(mPartyHandler)->reload(); + PartyHandler::reload(); } void GeneralHandler::reloadPartially() const { - static_cast<PartyHandler*>(mPartyHandler)->reload(); + PartyHandler::reload(); } void GeneralHandler::unload() const diff --git a/src/net/tmwa/guildmanager.cpp b/src/net/tmwa/guildmanager.cpp index d3670cdac..168f4cdea 100644 --- a/src/net/tmwa/guildmanager.cpp +++ b/src/net/tmwa/guildmanager.cpp @@ -74,7 +74,7 @@ void GuildManager::init() int val = serverConfig.getValue("enableGuildBot", -1); if (val == -1) { - if (client->isTmw()) + if (Client::isTmw()) val = 1; else val = 0; diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index 70139cd4a..e1d55d47d 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -107,10 +107,7 @@ void PlayerHandler::pickUp(const FloorItem *const floorItem) const createOutPacket(CMSG_ITEM_PICKUP); outMsg.writeBeingId(floorItem->getId(), "object id"); - TmwAthena::InventoryHandler *const handler = - static_cast<TmwAthena::InventoryHandler*>(inventoryHandler); - if (handler != nullptr) - handler->pushPickup(floorItem->getId()); + Ea::InventoryHandler::pushPickup(floorItem->getId()); } void PlayerHandler::setDirection(const unsigned char direction) const diff --git a/src/resources/db/emotedb.cpp b/src/resources/db/emotedb.cpp index f25b14c5a..02018d963 100644 --- a/src/resources/db/emotedb.cpp +++ b/src/resources/db/emotedb.cpp @@ -99,7 +99,7 @@ void EmoteDB::loadXmlFile(const std::string &fileName, const int id = XML::getProperty(emoteNode, "id", -1); // skip hight images - if (id > 19 || (client->isTmw() && id > 13)) + if (id > 19 || (Client::isTmw() && id > 13)) continue; if (id == -1) diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index cc9a2917d..4d0b89b3a 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -814,10 +814,10 @@ bool MapReader::readCsvLayer(XmlNodeConstPtrConst childNode, if (hasAnimations) { - while (oldPos != csv.npos) + while (oldPos != std::string::npos) { const size_t pos = csv.find_first_of(',', oldPos); - if (pos == csv.npos) + if (pos == std::string::npos) return false; const int gid = atoi(csv.substr(oldPos, pos - oldPos).c_str()); @@ -844,10 +844,10 @@ bool MapReader::readCsvLayer(XmlNodeConstPtrConst childNode, } else { - while (oldPos != csv.npos) + while (oldPos != std::string::npos) { const size_t pos = csv.find_first_of(',', oldPos); - if (pos == csv.npos) + if (pos == std::string::npos) return false; const int gid = atoi(csv.substr(oldPos, pos - oldPos).c_str()); diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp index 356ddabaa..c7331df49 100644 --- a/src/test/testlauncher.cpp +++ b/src/test/testlauncher.cpp @@ -373,7 +373,7 @@ int TestLauncher::testTextures() mainGraphics->drawImage(subImage, 0, 0); delete subImage; SDL_Surface *const screen1 = screenshortHelper->getScreenshot(); - SDL_Surface *const screen2 = imageHelper->convertTo32Bit(screen1); + SDL_Surface *const screen2 = ImageHelper::convertTo32Bit(screen1); SDL_FreeSurface(screen1); if (screen2 == nullptr) break; diff --git a/src/utils/translation/translationmanager.cpp b/src/utils/translation/translationmanager.cpp index 72ca23c91..d02ff2c02 100644 --- a/src/utils/translation/translationmanager.cpp +++ b/src/utils/translation/translationmanager.cpp @@ -83,7 +83,7 @@ PoDict *TranslationManager::loadLang(const LangVect &lang, continue; // logger->log("check file: " + subName + *it); - if (parser.checkLang(subName + *it)) + if (PoParser::checkLang(subName + *it)) { name = *it; break; |