diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-05 20:58:21 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-05 20:58:21 +0300 |
commit | a87db81b6b7551a248e31e2850577aefda092538 (patch) | |
tree | f47c20512183113face758cf58ec71369c82806c | |
parent | 92c019dad798f1a84c5d3e8e8331a885f6458133 (diff) | |
download | mv-a87db81b6b7551a248e31e2850577aefda092538.tar.gz mv-a87db81b6b7551a248e31e2850577aefda092538.tar.bz2 mv-a87db81b6b7551a248e31e2850577aefda092538.tar.xz mv-a87db81b6b7551a248e31e2850577aefda092538.zip |
Replace most bools usage in playerinfo to strong typed bools.
34 files changed, 164 insertions, 137 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index f9b0c0550..d80949865 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -457,7 +457,7 @@ impHandler(dropItemIdAll) Item *const item = inv->findItem(atoi(event.args.c_str()), 1); if (item && !PlayerInfo::isItemProtected(item->getId())) - PlayerInfo::dropItem(item, item->getQuantity(), true); + PlayerInfo::dropItem(item, item->getQuantity(), Sfx_true); return true; } @@ -465,7 +465,7 @@ impHandler(dropItemInvAll) { Item *const item = getItemByInvIndex(event, InventoryType::INVENTORY); if (item && !PlayerInfo::isItemProtected(item->getId())) - PlayerInfo::dropItem(item, item->getQuantity(), true); + PlayerInfo::dropItem(item, item->getQuantity(), Sfx_true); return true; } @@ -1452,7 +1452,7 @@ impHandler(useItem) { // +++ ignoring item color for now const Item *const item = inv->findItem(itemId, 1); - PlayerInfo::useEquipItem(item, true); + PlayerInfo::useEquipItem(item, Sfx_true); } } else if (itemId < SKILL_MIN_ID && spellManager) @@ -1469,7 +1469,7 @@ impHandler(useItem) impHandler(useItemInv) { Item *const item = getItemByInvIndex(event, InventoryType::INVENTORY); - PlayerInfo::useEquipItem(item, true); + PlayerInfo::useEquipItem(item, Sfx_true); return true; } diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index ba7f4d794..e3adafc6d 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -157,7 +157,7 @@ LocalPlayer::LocalPlayer(const int id, const uint16_t subtype) : mUpdateName(true), mBlockAdvert(false), mTargetDeadPlayers(config.getBoolValue("targetDeadPlayers")), - mServerAttack(config.getBoolValue("serverAttack")), + mServerAttack(fromBool(config.getBoolValue("serverAttack"), Keep)), mEnableAdvert(config.getBoolValue("enableAdvert")), mTradebot(config.getBoolValue("tradebot")), mTargetOnlyReachable(config.getBoolValue("targetOnlyReachable")), @@ -488,7 +488,7 @@ bool LocalPlayer::pickUp(FloorItem *const item) { if (actorManager && actorManager->checkForPickup(item)) { - PlayerInfo::pickUpItem(item, true); + PlayerInfo::pickUpItem(item, Sfx_true); mPickUpTarget = nullptr; } } @@ -795,7 +795,7 @@ void LocalPlayer::stopAttack(const bool keepAttack) if (!PacketLimiter::limitPackets(PACKET_STOPATTACK)) return; - if (mServerAttack && mAction == BeingAction::ATTACK) + if (mServerAttack == Keep_true && mAction == BeingAction::ATTACK) playerHandler->stopAttack(); untarget(); @@ -1039,7 +1039,7 @@ void LocalPlayer::optionChanged(const std::string &value) else if (value == "drawPath") mDrawPath = config.getBoolValue("drawPath"); else if (value == "serverAttack") - mServerAttack = config.getBoolValue("serverAttack"); + mServerAttack = fromBool(config.getBoolValue("serverAttack"), Keep); else if (value == "attackMoving") mAttackMoving = config.getBoolValue("attackMoving"); else if (value == "attackNext") @@ -1327,7 +1327,7 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const // if sword not equiped if (item->isEquipped() == Equipped_false) - PlayerInfo::equipItem(item, true); + PlayerInfo::equipItem(item, Sfx_true); // if need equip shield too if (settings.attackWeaponType == 3) @@ -1341,7 +1341,7 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const break; } if (item && item->isEquipped() == Equipped_false) - PlayerInfo::equipItem(item, true); + PlayerInfo::equipItem(item, Sfx_true); } } // big distance. allowed only bow @@ -1361,7 +1361,7 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const return; if (item->isEquipped() == Equipped_false) - PlayerInfo::equipItem(item, true); + PlayerInfo::equipItem(item, Sfx_true); } } @@ -2076,7 +2076,7 @@ void LocalPlayer::targetMoved() const /* if (mKeepAttacking) { - if (mTarget && mServerAttack) + if (mTarget && mServerAttack == Keep_true) { logger->log("LocalPlayer::targetMoved0"); if (!PacketLimiter::limitPackets(PACKET_ATTACK)) @@ -2312,7 +2312,7 @@ void LocalPlayer::imitateOutfit(const Being *const player, const Item *const item = inv->findItemBySprite(path, player->getGender(), player->getSubType()); if (item && item->isEquipped() == Equipped_false) - PlayerInfo::equipItem(item, false); + PlayerInfo::equipItem(item, Sfx_false); } else { @@ -2327,7 +2327,7 @@ void LocalPlayer::imitateOutfit(const Being *const player, if (item) { // logger->log("unequiping"); - PlayerInfo::unequipItem(item, false); + PlayerInfo::unequipItem(item, Sfx_false); } } } diff --git a/src/being/localplayer.h b/src/being/localplayer.h index 02c092f69..a4f26dcff 100644 --- a/src/being/localplayer.h +++ b/src/being/localplayer.h @@ -25,6 +25,8 @@ #include "being/being.h" +#include "enums/simpletypes.h" + #include "enums/being/pickup.h" #include "gui/userpalette.h" @@ -486,7 +488,7 @@ class LocalPlayer final : public Being, bool mUpdateName; bool mBlockAdvert; bool mTargetDeadPlayers; - bool mServerAttack; + Keep mServerAttack; bool mEnableAdvert; bool mTradebot; bool mTargetOnlyReachable; diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp index 687ab5382..8ed30492f 100644 --- a/src/being/playerinfo.cpp +++ b/src/being/playerinfo.cpp @@ -66,7 +66,7 @@ Equipment *mEquipment = nullptr; int mPetBeingId = 0; GuildPositionFlags::Type mGuildPositionFlags = GuildPositionFlags::None; -bool mTrading = false; +Trading mTrading = Trading_false; bool mVending = false; int mLevelProgress = 0; std::set<int> mProtectedItems; @@ -95,11 +95,13 @@ int getAttribute(const int id) return 0; } -void setAttribute(const int id, const int value, const bool notify) +void setAttribute(const int id, + const int value, + const Notify notify) { const int old = mData.mAttributes[id]; mData.mAttributes[id] = value; - if (notify) + if (notify == Notify_true) triggerAttr(id, old); } @@ -128,11 +130,11 @@ int getStatBase(const int id) return 0; } -void setStatBase(const int id, const int value, const bool notify) +void setStatBase(const int id, const int value, const Notify notify) { const int old = mData.mStats[id].base; mData.mStats[id].base = value; - if (notify) + if (notify == Notify_true) triggerStat(id, old, 0); } @@ -145,11 +147,11 @@ int getStatMod(const int id) return 0; } -void setStatMod(const int id, const int value, const bool notify) +void setStatMod(const int id, const int value, const Notify notify) { const int old = mData.mStats[id].mod; mData.mStats[id].mod = value; - if (notify) + if (notify == Notify_true) triggerStat(id, old, 0); } @@ -179,8 +181,10 @@ const std::pair<int, int> getStatExperience(const int id) return std::pair<int, int>(a, b); } -void setStatExperience(const int id, const int have, - const int need, const bool notify) +void setStatExperience(const int id, + const int have, + const int need, + const Notify notify) { Stat &stat = mData.mStats[id]; @@ -188,7 +192,7 @@ void setStatExperience(const int id, const int have, const int oldExpNeed = stat.expNeed; stat.exp = have; stat.expNeed = need; - if (notify) + if (notify == Notify_true) triggerStat(id, oldExp, oldExpNeed); } @@ -238,28 +242,28 @@ void setEquipmentBackend(Equipment::Backend *const backend) mEquipment->setBackend(backend); } -void equipItem(const Item *const item, const bool sfx) +void equipItem(const Item *const item, const Sfx sfx) { - if (sfx) + if (sfx == Sfx_true) ItemSoundManager::playSfx(item, ItemSoundEvent::EQUIP); inventoryHandler->equipItem(item); } -void unequipItem(const Item *const item, const bool sfx) +void unequipItem(const Item *const item, const Sfx sfx) { - if (sfx) + if (sfx == Sfx_true) ItemSoundManager::playSfx(item, ItemSoundEvent::UNEQUIP); inventoryHandler->unequipItem(item); } -void useItem(const Item *const item, const bool sfx) +void useItem(const Item *const item, const Sfx sfx) { - if (sfx) + if (sfx == Sfx_true) ItemSoundManager::playSfx(item, ItemSoundEvent::USE); inventoryHandler->useItem(item); } -void useEquipItem(const Item *const item, const bool sfx) +void useEquipItem(const Item *const item, const Sfx sfx) { if (item) { @@ -267,13 +271,13 @@ void useEquipItem(const Item *const item, const bool sfx) { if (item->isEquipped() == Equipped_true) { - if (sfx) + if (sfx == Sfx_true) ItemSoundManager::playSfx(item, ItemSoundEvent::UNEQUIP); inventoryHandler->unequipItem(item); } else { - if (sfx) + if (sfx == Sfx_true) ItemSoundManager::playSfx(item, ItemSoundEvent::EQUIP); inventoryHandler->equipItem(item); } @@ -283,14 +287,14 @@ void useEquipItem(const Item *const item, const bool sfx) if (mProtectedItems.find(item->getId()) == mProtectedItems.end()) { inventoryHandler->useItem(item); - if (sfx) + if (sfx == Sfx_true) ItemSoundManager::playSfx(item, ItemSoundEvent::USE); } } } } -void useEquipItem2(const Item *const item, const bool sfx) +void useEquipItem2(const Item *const item, const Sfx sfx) { if (item) { @@ -298,13 +302,13 @@ void useEquipItem2(const Item *const item, const bool sfx) { if (item->isEquipped() == Equipped_true) { - if (sfx) + if (sfx == Sfx_true) ItemSoundManager::playSfx(item, ItemSoundEvent::UNEQUIP); inventoryHandler->unequipItem(item); } else { - if (sfx) + if (sfx == Sfx_true) ItemSoundManager::playSfx(item, ItemSoundEvent::EQUIP); inventoryHandler->equipItem(item); } @@ -313,7 +317,7 @@ void useEquipItem2(const Item *const item, const bool sfx) { if (mProtectedItems.find(item->getId()) == mProtectedItems.end()) { - if (sfx) + if (sfx == Sfx_true) ItemSoundManager::playSfx(item, ItemSoundEvent::USE); inventoryHandler->useItem(item); } @@ -321,19 +325,19 @@ void useEquipItem2(const Item *const item, const bool sfx) } } -void dropItem(const Item *const item, const int amount, const bool sfx) +void dropItem(const Item *const item, const int amount, const Sfx sfx) { if (item && mProtectedItems.find(item->getId()) == mProtectedItems.end()) { - if (sfx) + if (sfx == Sfx_true) ItemSoundManager::playSfx(item, ItemSoundEvent::DROP); inventoryHandler->dropItem(item, amount); } } -void pickUpItem(const FloorItem *const item, const bool sfx) +void pickUpItem(const FloorItem *const item, const Sfx sfx) { - if (sfx) + if (sfx == Sfx_true) ItemSoundManager::playSfx(item, ItemSoundEvent::PICKUP); playerHandler->pickUp(item); } @@ -359,12 +363,12 @@ void logic() { } -bool isTrading() +Trading isTrading() { return mTrading; } -void setTrading(const bool trading) +void setTrading(const Trading trading) { mTrading = trading; } @@ -375,14 +379,14 @@ void updateAttrs() if (attackDelay) { setStatBase(Attributes::ATTACK_SPEED, - getStatBase(Attributes::ATK) * 1000 / attackDelay, false); + getStatBase(Attributes::ATK) * 1000 / attackDelay, Notify_false); setStatMod(Attributes::ATTACK_SPEED, - getStatMod(Attributes::ATK) * 1000 / attackDelay, true); + getStatMod(Attributes::ATK) * 1000 / attackDelay, Notify_true); } else { - setStatBase(Attributes::ATTACK_SPEED, 0, false); - setStatMod(Attributes::ATTACK_SPEED, 0, true); + setStatBase(Attributes::ATTACK_SPEED, 0, Notify_false); + setStatMod(Attributes::ATTACK_SPEED, 0, Notify_true); } } @@ -569,7 +573,7 @@ void updateMoveAI() homunculusHandler->moveToMaster(); } -void updateAttackAi(const int targetId, const bool keep) +void updateAttackAi(const int targetId, const Keep keep) { if (mMercenary) mercenaryHandler->attack(targetId, keep); diff --git a/src/being/playerinfo.h b/src/being/playerinfo.h index d780c7da7..e405dbe06 100644 --- a/src/being/playerinfo.h +++ b/src/being/playerinfo.h @@ -25,6 +25,7 @@ #include "equipment.h" #include "enums/guildpositionflags.h" +#include "enums/simpletypes.h" #include "enums/state.h" #include <map> @@ -75,7 +76,6 @@ struct PetInfo; /** * A database like namespace which holds global info about the localplayer * - * NOTE: 'bool notify' is used to determine if a event is to be triggered. */ namespace PlayerInfo { @@ -90,7 +90,7 @@ namespace PlayerInfo * Changes the value of the given attribute. */ void setAttribute(const int id, const int value, - const bool notify = true); + const Notify notify = Notify_true); int getSkillLevel(const int id) A_WARN_UNUSED; @@ -107,7 +107,7 @@ namespace PlayerInfo * Changes the base value of the given stat. */ void setStatBase(const int id, const int value, - const bool notify = true); + const Notify notify = Notify_true); /** * Returns the modifier for the given stat. @@ -118,7 +118,7 @@ namespace PlayerInfo * Changes the modifier for the given stat. */ void setStatMod(const int id, const int value, - const bool notify = true); + const Notify notify = Notify_true); /** * Returns the current effective value of the given stat. Effective is base @@ -129,7 +129,7 @@ namespace PlayerInfo /** * Changes the level of the given stat. */ - void setStatLevel(int id, int value, bool notify = true); + void setStatLevel(int id, int value, Notify notify = Notify_true); /** * Returns the experience of the given stat. @@ -139,8 +139,10 @@ namespace PlayerInfo /** * Changes the experience of the given stat. */ - void setStatExperience(const int id, const int have, - const int need, const bool notify = true); + void setStatExperience(const int id, + const int have, + const int need, + const Notify notify = Notify_true); // --- Inventory / Equipment -------------------------------------------------- @@ -192,12 +194,12 @@ namespace PlayerInfo * Returns true if the player is involved in a trade at the moment, false * otherwise. */ - bool isTrading(); + Trading isTrading(); /** * Sets whether the player is currently involved in trade or not. */ - void setTrading(const bool trading); + void setTrading(const Trading trading); void updateAttrs(); @@ -222,19 +224,19 @@ namespace PlayerInfo void setEquipmentBackend(Equipment::Backend *const backend); - void equipItem(const Item *const item, const bool sfx); + void equipItem(const Item *const item, const Sfx sfx); - void unequipItem(const Item *const item, const bool sfx); + void unequipItem(const Item *const item, const Sfx sfx); - void useItem(const Item *const item, const bool sfx); + void useItem(const Item *const item, const Sfx sfx); - void useEquipItem(const Item *const item, const bool sfx); + void useEquipItem(const Item *const item, const Sfx sfx); - void useEquipItem2(const Item *const item, const bool sfx); + void useEquipItem2(const Item *const item, const Sfx sfx); - void dropItem(const Item *const item, const int amount, const bool sfx); + void dropItem(const Item *const item, const int amount, const Sfx sfx); - void pickUpItem(const FloorItem *const item, const bool sfx); + void pickUpItem(const FloorItem *const item, const Sfx sfx); void protectItem(const int id); @@ -269,7 +271,7 @@ namespace PlayerInfo void updateMoveAI(); - void updateAttackAi(const int targetId, const bool keep); + void updateAttackAi(const int targetId, const Keep keep); std::string getRoomName(); diff --git a/src/dropshortcut.cpp b/src/dropshortcut.cpp index 66a58c6bd..1c860f7d4 100644 --- a/src/dropshortcut.cpp +++ b/src/dropshortcut.cpp @@ -73,12 +73,12 @@ void DropShortcut::dropFirst() const const int cnt = settings.quickDropCounter; if (localPlayer->isServerBuggy()) { - PlayerInfo::dropItem(item, cnt, true); + PlayerInfo::dropItem(item, cnt, Sfx_true); } else { for (int i = 0; i < cnt; i++) - PlayerInfo::dropItem(item, 1, false); + PlayerInfo::dropItem(item, 1, Sfx_false); } } } @@ -134,7 +134,7 @@ bool DropShortcut::dropItem(const int cnt) const Item *const item = inv->findItem(itemId, itemColor); if (item && item->getQuantity() > 0) { - PlayerInfo::dropItem(item, cnt, true); + PlayerInfo::dropItem(item, cnt, Sfx_true); return true; } } @@ -157,7 +157,7 @@ bool DropShortcut::dropItem(const int cnt) const Item *const item = inv->findItem(itemId, itemColor); if (item && item->getQuantity() > 0) { - PlayerInfo::dropItem(item, cnt, true); + PlayerInfo::dropItem(item, cnt, Sfx_true); return true; } } diff --git a/src/enums/simpletypes.h b/src/enums/simpletypes.h index c32f22413..cd9c51a58 100644 --- a/src/enums/simpletypes.h +++ b/src/enums/simpletypes.h @@ -54,5 +54,9 @@ defBoolEnum(Equipm); defBoolEnum(Equipped); defBoolEnum(Modal); defBoolEnum(ShowCenter); +defBoolEnum(Notify); +defBoolEnum(Trading); +defBoolEnum(Sfx); +defBoolEnum(Keep); #endif // ENUMS_SIMPLETYPES_H diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index cc2d34991..44cb01bc1 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -292,7 +292,7 @@ void EquipmentWindow::action(const ActionEvent &event) return; const Item *const item = mEquipment->getEquipment(mSelected); - PlayerInfo::unequipItem(item, true); + PlayerInfo::unequipItem(item, Sfx_true); setSelected(-1); } else if (!eventId.find("tab_")) @@ -325,7 +325,7 @@ void EquipmentWindow::action(const ActionEvent &event) if (item->isEquipment() == Equipm_true) { if (item->isEquipped() == Equipped_false) - PlayerInfo::equipItem(item, true); + PlayerInfo::equipItem(item, Sfx_true); } } } @@ -469,7 +469,7 @@ void EquipmentWindow::mouseReleased(MouseEvent &event) if (item->isEquipment() == Equipm_true) { if (item->isEquipped() == Equipped_false) - PlayerInfo::equipItem(item, true); + PlayerInfo::equipItem(item, Sfx_true); } } else if (dragDrop.getSource() == DRAGDROP_SOURCE_EQUIPMENT) @@ -493,7 +493,7 @@ void EquipmentWindow::mouseReleased(MouseEvent &event) } if (item->isEquipped() == Equipped_true) - PlayerInfo::unequipItem(item, true); + PlayerInfo::unequipItem(item, Sfx_true); } } dragDrop.clear(); diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 65e89bbb3..c87fe3ebc 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -461,11 +461,11 @@ void InventoryWindow::action(const ActionEvent &event) if (eventId == "use") { - PlayerInfo::useEquipItem(item, true); + PlayerInfo::useEquipItem(item, Sfx_true); } if (eventId == "equip") { - PlayerInfo::useEquipItem2(item, true); + PlayerInfo::useEquipItem2(item, Sfx_true); } else if (eventId == "drop") { @@ -491,7 +491,7 @@ void InventoryWindow::action(const ActionEvent &event) if (inputManager.isActionActive(static_cast<int>( InputAction::STOP_ATTACK))) { - PlayerInfo::dropItem(item, item->getQuantity(), true); + PlayerInfo::dropItem(item, item->getQuantity(), Sfx_true); } else { @@ -647,7 +647,7 @@ void InventoryWindow::mouseClicked(MouseEvent &event) } else { - PlayerInfo::useEquipItem(item, true); + PlayerInfo::useEquipItem(item, Sfx_true); } } else diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index 2c6280ca7..c3eb60b89 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -65,7 +65,7 @@ void ItemAmountWindow::finish(const Item *const item, tradeWindow->tradeItem(item, amount); break; case ItemDrop: - PlayerInfo::dropItem(item, amount, true); + PlayerInfo::dropItem(item, amount, Sfx_true); break; case ItemSplit: inventoryHandler->splitItem(item, amount); diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp index 7080ee133..896136bb3 100644 --- a/src/gui/windows/outfitwindow.cpp +++ b/src/gui/windows/outfitwindow.cpp @@ -282,7 +282,7 @@ void OutfitWindow::wearOutfit(const int outfit, const bool unwearEmpty, { if (item->isEquipment() == Equipm_true) { - PlayerInfo::equipItem(item, false); + PlayerInfo::equipItem(item, Sfx_false); isEmpty = false; } } @@ -525,7 +525,7 @@ void OutfitWindow::unequipNotInOutfit(const int outfit) const } } if (!found) - PlayerInfo::unequipItem(item, false); + PlayerInfo::unequipItem(item, Sfx_false); } } } diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index 529b8131e..ca82c03c1 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -865,9 +865,11 @@ void ShopWindow::showList(const std::string &nick, std::string data) void ShopWindow::processRequest(const std::string &nick, std::string data, const int mode) { - if (!localPlayer || !mTradeNick.empty() || PlayerInfo::isTrading() - || !actorManager - || !actorManager->findBeingByName(nick, ActorType::Player)) + if (!localPlayer || + !mTradeNick.empty() || + PlayerInfo::isTrading() == Trading_true || + !actorManager || + !actorManager->findBeingByName(nick, ActorType::Player)) { return; } diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index 7dadbb18c..dfa5b1339 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -394,7 +394,7 @@ void TradeWindow::action(const ActionEvent &event) { setVisible(false); reset(); - PlayerInfo::setTrading(false); + PlayerInfo::setTrading(Trading_false); tradeHandler->cancel(); } else if (eventId == "ok") diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp index 10a05824d..05035c5d0 100644 --- a/src/itemshortcut.cpp +++ b/src/itemshortcut.cpp @@ -131,7 +131,7 @@ void ItemShortcut::useItem(const int index) const { const Item *const item = inv->findItem(itemId, itemColor); if (item && item->getQuantity()) - PlayerInfo::useEquipItem(item, true); + PlayerInfo::useEquipItem(item, Sfx_true); } else if (itemId < SKILL_MIN_ID && spellManager) { @@ -159,7 +159,7 @@ void ItemShortcut::equipItem(const int index) const if (item->isEquipment() == Equipm_true) { if (item->isEquipped() == Equipped_false) - PlayerInfo::equipItem(item, true); + PlayerInfo::equipItem(item, Sfx_true); } } } @@ -179,7 +179,7 @@ void ItemShortcut::unequipItem(const int index) const if (item->isEquipment() == Equipm_true) { if (item->isEquipped() == Equipped_true) - PlayerInfo::unequipItem(item, true); + PlayerInfo::unequipItem(item, Sfx_true); } } } diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 121a6284c..0003a0a7e 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -171,7 +171,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) return; } - playerHandler->setStat(msg, type, value, NoStat, true); + playerHandler->setStat(msg, type, value, NoStat, Notify_true); BLOCK_END("PlayerHandler::processPlayerStatUpdate1") } @@ -180,7 +180,7 @@ void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg) BLOCK_START("PlayerHandler::processPlayerStatUpdate2") const int type = msg.readInt16("type"); const int value = msg.readInt32("value"); - playerHandler->setStat(msg, type, value, NoStat, true); + playerHandler->setStat(msg, type, value, NoStat, Notify_true); BLOCK_END("PlayerHandler::processPlayerStatUpdate2") } @@ -191,7 +191,7 @@ void PlayerHandler::processPlayerStatUpdate3(Net::MessageIn &msg) const int base = msg.readInt32("base"); const int bonus = msg.readInt32("bonus"); - playerHandler->setStat(msg, type, base, bonus, false); + playerHandler->setStat(msg, type, base, bonus, Notify_false); BLOCK_END("PlayerHandler::processPlayerStatUpdate3") } @@ -211,7 +211,7 @@ void PlayerHandler::processPlayerStatUpdate4(Net::MessageIn &msg) NotifyManager::notify(NotifyTypes::SKILL_RAISE_ERROR); } - playerHandler->setStat(msg, type, value, NoStat, true); + playerHandler->setStat(msg, type, value, NoStat, Notify_true); BLOCK_END("PlayerHandler::processPlayerStatUpdate4") } @@ -221,7 +221,7 @@ void PlayerHandler::processPlayerStatUpdate6(Net::MessageIn &msg) const int type = msg.readInt16("type"); const int value = msg.readUInt8("value"); if (statusWindow) - playerHandler->setStat(msg, type, value, NoStat, true); + playerHandler->setStat(msg, type, value, NoStat, Notify_true); BLOCK_END("PlayerHandler::processPlayerStatUpdate6") } @@ -258,7 +258,7 @@ void PlayerHandler::setStat(Net::MessageIn &msg, const int type, const int base, const int mod, - const bool notify) const + const Notify notify) const { switch (type) { diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h index 3e32fbf1a..760f52af7 100644 --- a/src/net/ea/playerhandler.h +++ b/src/net/ea/playerhandler.h @@ -59,7 +59,7 @@ class PlayerHandler notfinal : public Net::PlayerHandler const int type, const int base, const int mod, - const bool notify) const override; + const Notify notify) const override; static const int NoStat = INT_MAX; diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp index 5bdf42775..9c6f8f387 100644 --- a/src/net/ea/tradehandler.cpp +++ b/src/net/ea/tradehandler.cpp @@ -103,7 +103,7 @@ void TradeHandler::processTradeResponseContinue(const uint8_t type) tradeWindow->setVisible(false); // tradeWindow->clear(); } - PlayerInfo::setTrading(false); + PlayerInfo::setTrading(Trading_false); break; case 5: NotifyManager::notify(NotifyTypes::TRADE_CANCELLED_BUSY, @@ -135,7 +135,7 @@ void TradeHandler::processTradeCancel(Net::MessageIn &msg A_UNUSED) tradeWindow->setVisible(false); tradeWindow->reset(); } - PlayerInfo::setTrading(false); + PlayerInfo::setTrading(Trading_false); } void TradeHandler::processTradeComplete(Net::MessageIn &msg A_UNUSED) @@ -146,7 +146,7 @@ void TradeHandler::processTradeComplete(Net::MessageIn &msg A_UNUSED) tradeWindow->setVisible(false); tradeWindow->reset(); } - PlayerInfo::setTrading(false); + PlayerInfo::setTrading(Trading_false); } void TradeHandler::processTradeRequestContinue(const std::string &partner) @@ -154,14 +154,14 @@ void TradeHandler::processTradeRequestContinue(const std::string &partner) if (player_relations.hasPermission(partner, PlayerRelation::TRADE)) { - if (PlayerInfo::isTrading() || confirmDlg) + if (PlayerInfo::isTrading() == Trading_true || confirmDlg) { tradeHandler->respond(false); return; } tradePartnerName = partner; - PlayerInfo::setTrading(true); + PlayerInfo::setTrading(Trading_true); if (tradeWindow) { if (tradePartnerName.empty() || tradeWindow->getAutoTradeNick() diff --git a/src/net/eathena/homunculushandler.cpp b/src/net/eathena/homunculushandler.cpp index 13ba7ebe8..e3f83cd39 100644 --- a/src/net/eathena/homunculushandler.cpp +++ b/src/net/eathena/homunculushandler.cpp @@ -262,7 +262,7 @@ void HomunculusHandler::move(const int x, const int y) const 0U, "position"); } -void HomunculusHandler::attack(const int targetId, const bool keep) const +void HomunculusHandler::attack(const int targetId, const Keep keep) const { const int id = PlayerInfo::getHomunculusId(); if (!id) @@ -270,7 +270,7 @@ void HomunculusHandler::attack(const int targetId, const bool keep) const createOutPacket(CMSG_HOMMERC_ATTACK); outMsg.writeInt32(id, "homunculus id"); outMsg.writeInt32(targetId, "target id"); - outMsg.writeInt8(static_cast<int8_t>(keep ? 1 : 0), "keep"); + outMsg.writeInt8(static_cast<int8_t>(keep == Keep_true ? 1 : 0), "keep"); } void HomunculusHandler::feed() const diff --git a/src/net/eathena/homunculushandler.h b/src/net/eathena/homunculushandler.h index db992b5b3..5b288eeb6 100644 --- a/src/net/eathena/homunculushandler.h +++ b/src/net/eathena/homunculushandler.h @@ -45,7 +45,7 @@ class HomunculusHandler final : public MessageHandler, void move(const int x, const int y) const override final; - void attack(const int targetId, const bool keep) const override final; + void attack(const int targetId, const Keep keep) const override final; void feed() const override final; diff --git a/src/net/eathena/mercenaryhandler.cpp b/src/net/eathena/mercenaryhandler.cpp index e93edcc0b..1bc35a72f 100644 --- a/src/net/eathena/mercenaryhandler.cpp +++ b/src/net/eathena/mercenaryhandler.cpp @@ -207,7 +207,7 @@ void MercenaryHandler::move(const int x, const int y) const 0U, "position"); } -void MercenaryHandler::attack(const int targetId, const bool keep) const +void MercenaryHandler::attack(const int targetId, const Keep keep) const { const int id = PlayerInfo::getMercenaryId(); if (!id) @@ -215,7 +215,7 @@ void MercenaryHandler::attack(const int targetId, const bool keep) const createOutPacket(CMSG_HOMMERC_ATTACK); outMsg.writeInt32(id, "mercenary id"); outMsg.writeInt32(targetId, "target id"); - outMsg.writeInt8(static_cast<int8_t>(keep ? 1 : 0), "keep"); + outMsg.writeInt8(static_cast<int8_t>(keep == Keep_true ? 1 : 0), "keep"); } void MercenaryHandler::talk(const std::string &restrict text) const diff --git a/src/net/eathena/mercenaryhandler.h b/src/net/eathena/mercenaryhandler.h index c1a784c3b..a24f414ff 100644 --- a/src/net/eathena/mercenaryhandler.h +++ b/src/net/eathena/mercenaryhandler.h @@ -45,7 +45,7 @@ class MercenaryHandler final : public MessageHandler, void move(const int x, const int y) const override final; - void attack(const int targetId, const bool keep) const override final; + void attack(const int targetId, const Keep keep) const override final; void talk(const std::string &restrict text) const override final; diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp index b866dcb5c..a2bb8b83e 100644 --- a/src/net/eathena/playerhandler.cpp +++ b/src/net/eathena/playerhandler.cpp @@ -205,11 +205,11 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) } } -void PlayerHandler::attack(const int id, const bool keep) const +void PlayerHandler::attack(const int id, const Keep keep) const { createOutPacket(CMSG_PLAYER_CHANGE_ACT); outMsg.writeInt32(id, "target id"); - if (keep) + if (keep == Keep_true) outMsg.writeInt8(7, "action"); else outMsg.writeInt8(0, "action"); @@ -446,26 +446,29 @@ void PlayerHandler::processPlayerStatUpdate5(Net::MessageIn &msg) msg.readUInt8("luk cost"); } - PlayerInfo::setStatBase(Attributes::ATK, msg.readInt16("left atk"), false); + PlayerInfo::setStatBase(Attributes::ATK, + msg.readInt16("left atk"), Notify_false); PlayerInfo::setStatMod(Attributes::ATK, msg.readInt16("right atk")); PlayerInfo::updateAttrs(); val = msg.readInt16("right matk"); - PlayerInfo::setStatBase(Attributes::MATK, val, false); + PlayerInfo::setStatBase(Attributes::MATK, val, Notify_false); val = msg.readInt16("left matk"); PlayerInfo::setStatMod(Attributes::MATK, val); - PlayerInfo::setStatBase(Attributes::DEF, msg.readInt16("left def"), false); + PlayerInfo::setStatBase(Attributes::DEF, + msg.readInt16("left def"), Notify_false); PlayerInfo::setStatMod(Attributes::DEF, msg.readInt16("right def")); PlayerInfo::setStatBase(Attributes::MDEF, - msg.readInt16("left mdef"), false); + msg.readInt16("left mdef"), Notify_false); PlayerInfo::setStatMod(Attributes::MDEF, msg.readInt16("right mdef")); PlayerInfo::setStatBase(Attributes::HIT, msg.readInt16("hit")); - PlayerInfo::setStatBase(Attributes::FLEE, msg.readInt16("flee"), false); + PlayerInfo::setStatBase(Attributes::FLEE, + msg.readInt16("flee"), Notify_false); PlayerInfo::setStatMod(Attributes::FLEE, msg.readInt16("flee2/10")); PlayerInfo::setStatBase(Attributes::CRIT, msg.readInt16("crit/10")); @@ -577,7 +580,7 @@ void PlayerHandler::setStat(Net::MessageIn &msg, const int type, const int base, const int mod, - const bool notify) const + const Notify notify) const { Ea::PlayerHandler::setStat(msg, type, base, mod, notify); } diff --git a/src/net/eathena/playerhandler.h b/src/net/eathena/playerhandler.h index bc2dab173..6d7d6a9e1 100644 --- a/src/net/eathena/playerhandler.h +++ b/src/net/eathena/playerhandler.h @@ -39,7 +39,7 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler void handleMessage(Net::MessageIn &msg) override final; - void attack(const int id, const bool keep) const override final; + void attack(const int id, const Keep keep) const override final; void stopAttack() const override final; void emote(const uint8_t emoteId) const override final; @@ -74,7 +74,7 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler const int type, const int base, const int mod, - const bool notify) const override final; + const Notify notify) const override final; static void processPlayerShortcuts(Net::MessageIn &msg); diff --git a/src/net/eathena/tradehandler.cpp b/src/net/eathena/tradehandler.cpp index a7a9c3300..5b1c92ac1 100644 --- a/src/net/eathena/tradehandler.cpp +++ b/src/net/eathena/tradehandler.cpp @@ -122,7 +122,7 @@ void TradeHandler::request(const Being *const being) const void TradeHandler::respond(const bool accept) const { if (!accept) - PlayerInfo::setTrading(false); + PlayerInfo::setTrading(Trading_false); createOutPacket(CMSG_TRADE_RESPONSE); outMsg.writeInt8(static_cast<int8_t>(accept ? 3 : 4), "accept"); diff --git a/src/net/homunculushandler.h b/src/net/homunculushandler.h index e587a02e8..1d27afd1a 100644 --- a/src/net/homunculushandler.h +++ b/src/net/homunculushandler.h @@ -23,6 +23,8 @@ #ifdef EATHENA_SUPPORT +#include "enums/simpletypes.h" + #include <string> #include "localconsts.h" @@ -42,7 +44,7 @@ class HomunculusHandler notfinal virtual void move(const int x, const int y) const = 0; - virtual void attack(const int targetId, const bool keep) const = 0; + virtual void attack(const int targetId, const Keep keep) const = 0; virtual void feed() const = 0; diff --git a/src/net/mercenaryhandler.h b/src/net/mercenaryhandler.h index 40a92bbd7..104d7e8d2 100644 --- a/src/net/mercenaryhandler.h +++ b/src/net/mercenaryhandler.h @@ -23,6 +23,8 @@ #ifdef EATHENA_SUPPORT +#include "enums/simpletypes.h" + #include <string> #include "localconsts.h" @@ -44,7 +46,7 @@ class MercenaryHandler notfinal virtual void move(const int x, const int y) const = 0; - virtual void attack(const int targetId, const bool keep) const = 0; + virtual void attack(const int targetId, const Keep keep) const = 0; virtual void talk(const std::string &restrict text) const = 0; diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h index 2cdfdf062..af4b09958 100644 --- a/src/net/playerhandler.h +++ b/src/net/playerhandler.h @@ -25,6 +25,8 @@ #include "flooritem.h" +#include "enums/simpletypes.h" + #include "enums/being/beingaction.h" #include "net/messagein.h" @@ -38,7 +40,7 @@ class PlayerHandler notfinal virtual ~PlayerHandler() { } - virtual void attack(const int id, const bool keep) const = 0; + virtual void attack(const int id, const Keep keep) const = 0; virtual void stopAttack() const = 0; @@ -101,7 +103,7 @@ class PlayerHandler notfinal const int type, const int base, const int mod, - const bool notify) const = 0; + const Notify notify) const = 0; }; } // namespace Net diff --git a/src/net/tmwa/homunculushandler.cpp b/src/net/tmwa/homunculushandler.cpp index b851aef20..8ffbb6ed4 100644 --- a/src/net/tmwa/homunculushandler.cpp +++ b/src/net/tmwa/homunculushandler.cpp @@ -55,7 +55,7 @@ void HomunculusHandler::move(const int x A_UNUSED, const int y A_UNUSED) const } void HomunculusHandler::attack(const int targetId A_UNUSED, - const bool keep A_UNUSED) const + const Keep keep A_UNUSED) const { } diff --git a/src/net/tmwa/homunculushandler.h b/src/net/tmwa/homunculushandler.h index 5b4272161..9aec1eed6 100644 --- a/src/net/tmwa/homunculushandler.h +++ b/src/net/tmwa/homunculushandler.h @@ -46,7 +46,7 @@ class HomunculusHandler final : public MessageHandler, void move(const int x, const int y) const override final; - void attack(const int targetId, const bool keep) const override final; + void attack(const int targetId, const Keep keep) const override final; void feed() const override final; diff --git a/src/net/tmwa/mercenaryhandler.cpp b/src/net/tmwa/mercenaryhandler.cpp index 2dc3e388f..aa71c7f69 100644 --- a/src/net/tmwa/mercenaryhandler.cpp +++ b/src/net/tmwa/mercenaryhandler.cpp @@ -59,7 +59,7 @@ void MercenaryHandler::move(const int x A_UNUSED, const int y A_UNUSED) const } void MercenaryHandler::attack(const int targetId A_UNUSED, - const bool keep A_UNUSED) const + const Keep keep A_UNUSED) const { } diff --git a/src/net/tmwa/mercenaryhandler.h b/src/net/tmwa/mercenaryhandler.h index 1d5a40b8a..f2fe3ecae 100644 --- a/src/net/tmwa/mercenaryhandler.h +++ b/src/net/tmwa/mercenaryhandler.h @@ -48,7 +48,7 @@ class MercenaryHandler final : public MessageHandler, void move(const int x, const int y) const override final; - void attack(const int targetId, const bool keep) const override final; + void attack(const int targetId, const Keep keep) const override final; void talk(const std::string &restrict text) const override final; diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index cc11aa8ba..c78382f27 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -124,11 +124,11 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) BLOCK_END("PlayerHandler::handleMessage") } -void PlayerHandler::attack(const int id, const bool keep) const +void PlayerHandler::attack(const int id, const Keep keep) const { createOutPacket(CMSG_PLAYER_CHANGE_ACT); outMsg.writeInt32(id, "target id"); - if (keep) + if (keep == Keep_true) outMsg.writeInt8(7, "action"); else outMsg.writeInt8(0, "action"); @@ -327,25 +327,29 @@ void PlayerHandler::processPlayerStatUpdate5(Net::MessageIn &msg) msg.readUInt8("luk cost"); } - PlayerInfo::setStatBase(Attributes::ATK, msg.readInt16("atk"), false); + PlayerInfo::setStatBase(Attributes::ATK, + msg.readInt16("atk"), Notify_false); PlayerInfo::setStatMod(Attributes::ATK, msg.readInt16("atk+")); PlayerInfo::updateAttrs(); val = msg.readInt16("matk"); - PlayerInfo::setStatBase(Attributes::MATK, val, false); + PlayerInfo::setStatBase(Attributes::MATK, val, Notify_false); val = msg.readInt16("matk+"); PlayerInfo::setStatMod(Attributes::MATK, val); - PlayerInfo::setStatBase(Attributes::DEF, msg.readInt16("def"), false); + PlayerInfo::setStatBase(Attributes::DEF, + msg.readInt16("def"), Notify_false); PlayerInfo::setStatMod(Attributes::DEF, msg.readInt16("def+")); - PlayerInfo::setStatBase(Attributes::MDEF, msg.readInt16("mdef"), false); + PlayerInfo::setStatBase(Attributes::MDEF, + msg.readInt16("mdef"), Notify_false); PlayerInfo::setStatMod(Attributes::MDEF, msg.readInt16("mdef+")); PlayerInfo::setStatBase(Attributes::HIT, msg.readInt16("hit")); - PlayerInfo::setStatBase(Attributes::FLEE, msg.readInt16("flee"), false); + PlayerInfo::setStatBase(Attributes::FLEE, + msg.readInt16("flee"), Notify_false); PlayerInfo::setStatMod(Attributes::FLEE, msg.readInt16("flee+")); PlayerInfo::setStatBase(Attributes::CRIT, msg.readInt16("crit")); @@ -403,7 +407,7 @@ void PlayerHandler::setStat(Net::MessageIn &msg, const int type, const int base, const int mod, - const bool notify) const + const Notify notify) const { if (type == 500) { diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h index 062e00db6..f0162c8f2 100644 --- a/src/net/tmwa/playerhandler.h +++ b/src/net/tmwa/playerhandler.h @@ -39,7 +39,7 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler void handleMessage(Net::MessageIn &msg) override final; - void attack(const int id, const bool keep) const override final; + void attack(const int id, const Keep keep) const override final; void stopAttack() const override final; void emote(const uint8_t emoteId) const override final; @@ -83,7 +83,7 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler const int type, const int base, const int mod, - const bool notify) const override final; + const Notify notify) const override final; static void processPlayerStatUpdate5(Net::MessageIn &msg); diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp index f734a2e43..5962ff89a 100644 --- a/src/net/tmwa/tradehandler.cpp +++ b/src/net/tmwa/tradehandler.cpp @@ -124,7 +124,7 @@ void TradeHandler::request(const Being *const being) const void TradeHandler::respond(const bool accept) const { if (!accept) - PlayerInfo::setTrading(false); + PlayerInfo::setTrading(Trading_false); createOutPacket(CMSG_TRADE_RESPONSE); outMsg.writeInt8(static_cast<int8_t>(accept ? 3 : 4), "accept"); |