summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-05 20:58:21 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-05 20:58:21 +0300
commita87db81b6b7551a248e31e2850577aefda092538 (patch)
treef47c20512183113face758cf58ec71369c82806c /src/net
parent92c019dad798f1a84c5d3e8e8331a885f6458133 (diff)
downloadmanaverse-a87db81b6b7551a248e31e2850577aefda092538.tar.gz
manaverse-a87db81b6b7551a248e31e2850577aefda092538.tar.bz2
manaverse-a87db81b6b7551a248e31e2850577aefda092538.tar.xz
manaverse-a87db81b6b7551a248e31e2850577aefda092538.zip
Replace most bools usage in playerinfo to strong typed bools.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/playerhandler.cpp12
-rw-r--r--src/net/ea/playerhandler.h2
-rw-r--r--src/net/ea/tradehandler.cpp10
-rw-r--r--src/net/eathena/homunculushandler.cpp4
-rw-r--r--src/net/eathena/homunculushandler.h2
-rw-r--r--src/net/eathena/mercenaryhandler.cpp4
-rw-r--r--src/net/eathena/mercenaryhandler.h2
-rw-r--r--src/net/eathena/playerhandler.cpp19
-rw-r--r--src/net/eathena/playerhandler.h4
-rw-r--r--src/net/eathena/tradehandler.cpp2
-rw-r--r--src/net/homunculushandler.h4
-rw-r--r--src/net/mercenaryhandler.h4
-rw-r--r--src/net/playerhandler.h6
-rw-r--r--src/net/tmwa/homunculushandler.cpp2
-rw-r--r--src/net/tmwa/homunculushandler.h2
-rw-r--r--src/net/tmwa/mercenaryhandler.cpp2
-rw-r--r--src/net/tmwa/mercenaryhandler.h2
-rw-r--r--src/net/tmwa/playerhandler.cpp20
-rw-r--r--src/net/tmwa/playerhandler.h4
-rw-r--r--src/net/tmwa/tradehandler.cpp2
20 files changed, 61 insertions, 48 deletions
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");