summaryrefslogtreecommitdiff
path: root/src/net/ea/playerhandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-11 19:28:57 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-11 19:28:57 +0300
commit87c59212f8590a8dd72fac3e320fcb2ada781355 (patch)
tree198d627c44f1164140659827a5c782d30bec375b /src/net/ea/playerhandler.cpp
parent02e91411eb9961e95f856bd717d6ca0d8ec0e435 (diff)
downloadplus-87c59212f8590a8dd72fac3e320fcb2ada781355.tar.gz
plus-87c59212f8590a8dd72fac3e320fcb2ada781355.tar.bz2
plus-87c59212f8590a8dd72fac3e320fcb2ada781355.tar.xz
plus-87c59212f8590a8dd72fac3e320fcb2ada781355.zip
Move player attributes into separate file.
Diffstat (limited to 'src/net/ea/playerhandler.cpp')
-rw-r--r--src/net/ea/playerhandler.cpp53
1 files changed, 27 insertions, 26 deletions
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 475df2db0..1b324e376 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -29,6 +29,7 @@
#include "notifymanager.h"
#include "units.h"
+#include "being/attributes.h"
#include "being/localplayer.h"
#include "gui/viewport.h"
@@ -233,13 +234,13 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
case 0x0000:
player_node->setWalkSpeed(Vector(static_cast<float>(
value), static_cast<float>(value), 0));
- PlayerInfo::setStatBase(PlayerInfo::WALK_SPEED, value);
- PlayerInfo::setStatMod(PlayerInfo::WALK_SPEED, 0);
+ PlayerInfo::setStatBase(Attributes::WALK_SPEED, value);
+ PlayerInfo::setStatMod(Attributes::WALK_SPEED, 0);
break;
case 0x0004:
break; // manner
case 0x0005:
- PlayerInfo::setAttribute(PlayerInfo::HP, value);
+ PlayerInfo::setAttribute(Attributes::HP, value);
if (player_node->isInParty() && Party::getParty(1))
{
PartyMember *const m = Party::getParty(1)
@@ -247,12 +248,12 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
if (m)
{
m->setHp(value);
- m->setMaxHp(PlayerInfo::getAttribute(PlayerInfo::MAX_HP));
+ m->setMaxHp(PlayerInfo::getAttribute(Attributes::MAX_HP));
}
}
break;
case 0x0006:
- PlayerInfo::setAttribute(PlayerInfo::MAX_HP, value);
+ PlayerInfo::setAttribute(Attributes::MAX_HP, value);
if (player_node->isInParty() && Party::getParty(1))
{
@@ -260,22 +261,22 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
player_node->getId());
if (m)
{
- m->setHp(PlayerInfo::getAttribute(PlayerInfo::HP));
+ m->setHp(PlayerInfo::getAttribute(Attributes::HP));
m->setMaxHp(value);
}
}
break;
case 0x0007:
- PlayerInfo::setAttribute(PlayerInfo::MP, value);
+ PlayerInfo::setAttribute(Attributes::MP, value);
break;
case 0x0008:
- PlayerInfo::setAttribute(PlayerInfo::MAX_MP, value);
+ PlayerInfo::setAttribute(Attributes::MAX_MP, value);
break;
case 0x0009:
- PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, value);
+ PlayerInfo::setAttribute(Attributes::CHAR_POINTS, value);
break;
case 0x000b:
- PlayerInfo::setAttribute(PlayerInfo::LEVEL, value);
+ PlayerInfo::setAttribute(Attributes::LEVEL, value);
if (player_node)
{
player_node->setLevel(value);
@@ -283,7 +284,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
}
break;
case 0x000c:
- PlayerInfo::setAttribute(PlayerInfo::SKILL_POINTS, value);
+ PlayerInfo::setAttribute(Attributes::SKILL_POINTS, value);
if (skillDialog)
skillDialog->update();
break;
@@ -291,9 +292,9 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
if (!weightNotice && config.getBoolValue("weightMsg"))
{
const int max = PlayerInfo::getAttribute(
- PlayerInfo::MAX_WEIGHT) / 2;
+ Attributes::MAX_WEIGHT) / 2;
const int total = PlayerInfo::getAttribute(
- PlayerInfo::TOTAL_WEIGHT);
+ Attributes::TOTAL_WEIGHT);
if (value >= max && total < max)
{
weightNoticeTime = cur_time + 5;
@@ -319,10 +320,10 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
&weightListener);
}
}
- PlayerInfo::setAttribute(PlayerInfo::TOTAL_WEIGHT, value);
+ PlayerInfo::setAttribute(Attributes::TOTAL_WEIGHT, value);
break;
case 0x0019:
- PlayerInfo::setAttribute(PlayerInfo::MAX_WEIGHT, value);
+ PlayerInfo::setAttribute(Attributes::MAX_WEIGHT, value);
break;
case 0x0029:
@@ -372,8 +373,8 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
case 0x0035:
player_node->setAttackSpeed(value);
- PlayerInfo::setStatBase(PlayerInfo::ATTACK_DELAY, value);
- PlayerInfo::setStatMod(PlayerInfo::ATTACK_DELAY, 0);
+ PlayerInfo::setStatBase(Attributes::ATTACK_DELAY, value);
+ PlayerInfo::setStatMod(Attributes::ATTACK_DELAY, 0);
PlayerInfo::updateAttrs();
break;
@@ -391,7 +392,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
break;
}
- if (PlayerInfo::getAttribute(PlayerInfo::HP) == 0 && !deathNotice)
+ if (PlayerInfo::getAttribute(Attributes::HP) == 0 && !deathNotice)
{
// TRANSLATORS: message header
deathNotice = new OkDialog(_("Message"),
@@ -413,7 +414,7 @@ void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg)
switch (type)
{
case 0x0001:
- PlayerInfo::setAttribute(PlayerInfo::EXP, msg.readInt32());
+ PlayerInfo::setAttribute(Attributes::EXP, msg.readInt32());
break;
case 0x0002:
PlayerInfo::setStatExperience(EA_JOB, msg.readInt32(),
@@ -421,7 +422,7 @@ void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg)
break;
case 0x0014:
{
- const int oldMoney = PlayerInfo::getAttribute(PlayerInfo::MONEY);
+ const int oldMoney = PlayerInfo::getAttribute(Attributes::MONEY);
const int newMoney = msg.readInt32();
if (newMoney > oldMoney)
{
@@ -434,11 +435,11 @@ void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg)
Units::formatCurrency(oldMoney - newMoney).c_str());
}
- PlayerInfo::setAttribute(PlayerInfo::MONEY, newMoney);
+ PlayerInfo::setAttribute(Attributes::MONEY, newMoney);
break;
}
case 0x0016:
- PlayerInfo::setAttribute(PlayerInfo::EXP_NEEDED, msg.readInt32());
+ PlayerInfo::setAttribute(Attributes::EXP_NEEDED, msg.readInt32());
break;
case 0x0017:
PlayerInfo::setStatExperience(EA_JOB,
@@ -460,7 +461,7 @@ void PlayerHandler::processPlayerStatUpdate3(Net::MessageIn &msg)
PlayerInfo::setStatBase(type, base, false);
PlayerInfo::setStatMod(type, bonus);
- if (type == EA_ATK || type == PlayerInfo::ATTACK_DELAY)
+ if (type == EA_ATK || type == Attributes::ATTACK_DELAY)
PlayerInfo::updateAttrs();
BLOCK_END("PlayerHandler::processPlayerStatUpdate3")
}
@@ -475,9 +476,9 @@ void PlayerHandler::processPlayerStatUpdate4(Net::MessageIn &msg)
if (ok != 1)
{
const int oldValue = PlayerInfo::getStatBase(type);
- const int points = PlayerInfo::getAttribute(PlayerInfo::CHAR_POINTS)
+ const int points = PlayerInfo::getAttribute(Attributes::CHAR_POINTS)
+ oldValue - value;
- PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, points);
+ PlayerInfo::setAttribute(Attributes::CHAR_POINTS, points);
NotifyManager::notify(NotifyManager::SKILL_RAISE_ERROR);
}
@@ -488,7 +489,7 @@ void PlayerHandler::processPlayerStatUpdate4(Net::MessageIn &msg)
void PlayerHandler::processPlayerStatUpdate5(Net::MessageIn &msg)
{
BLOCK_START("PlayerHandler::processPlayerStatUpdate5")
- PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, msg.readInt16());
+ PlayerInfo::setAttribute(Attributes::CHAR_POINTS, msg.readInt16());
int val = msg.readInt8();
PlayerInfo::setStatBase(EA_STR, val);