Add handling of skill increases

coverity_scan^2
David Cernat 8 years ago
parent 15a4602482
commit 6650b74498

@ -424,26 +424,26 @@ void StatsFunctions::SetSkillProgress(unsigned short pid, unsigned short skill,
player->NpcStats()->mSkills[skill].mProgress = value;
}
int StatsFunctions::GetSkillIncrease(unsigned short pid, unsigned int pos) noexcept
int StatsFunctions::GetSkillIncrease(unsigned short pid, unsigned int attribute) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (pos > 7)
if (attribute > Attribute::Length)
return 0;
return player->NpcStats()->mSkillIncrease[pos];
return player->NpcStats()->mSkillIncrease[attribute];
}
void StatsFunctions::SetSkillIncrease(unsigned short pid, unsigned int pos, int value) noexcept // TODO: need packet for transmit it
void StatsFunctions::SetSkillIncrease(unsigned short pid, unsigned int attribute, int value) noexcept // TODO: need packet for transmit it
{
Player *player;
GET_PLAYER(pid, player,);
if (pos > 7)
if (attribute > Attribute::Length)
return;
player->NpcStats()->mSkillIncrease[pos] = value;
player->NpcStats()->mSkillIncrease[attribute] = value;
}
void StatsFunctions::SetCharGenStage(unsigned short pid, int start, int end) noexcept

@ -134,6 +134,13 @@ void LocalPlayer::updateSkills(bool forceUpdate)
else if (ptrNpcStats.getSkill(i).getProgress() != NpcStats()->mSkills[i].mProgress)
{
ptrNpcStats.getSkill(i).writeState(NpcStats()->mSkills[i]);
}
}
for (int i = 0; i < 8; i++)
{
if (ptrNpcStats.getSkillIncrease(i) != NpcStats()->mSkillIncrease[i]) {
NpcStats()->mSkillIncrease[i] = ptrNpcStats.getSkillIncrease(i);
}
}
@ -301,6 +308,11 @@ void LocalPlayer::setSkills()
ptrNpcStats->setSkill(i, skillValue);
}
for (int i = 0; i < 8; ++i)
{
ptrNpcStats->setSkillIncrease(i, NpcStats()->mSkillIncrease[i]);
}
ptrNpcStats->setLevelProgress(NpcStats()->mLevelProgress);
}

@ -16,6 +16,6 @@ void PacketAttribute::Packet(RakNet::BitStream *bs, BasePlayer *player, bool sen
{
BasePacket::Packet(bs, player, send);
for (int i = 0; i < AttributesCount; ++i)
for (int i = 0; i < AttributeCount; ++i)
RW(player->CreatureStats()->mAttributes[i], send);
}

@ -12,7 +12,7 @@ namespace mwmp
class PacketAttribute : public BasePacket
{
public:
const static int AttributesCount = 8;
const static int AttributeCount = 8;
PacketAttribute(RakNet::RakPeerInterface *peer);
virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send);

@ -18,8 +18,11 @@ void PacketSkill::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
for (int i = 0; i < StatsCount; ++i)
for (int i = 0; i < SkillCount; ++i)
RW(player->NpcStats()->mSkills[i], send);
for (int i = 0; i < AttributeCount; ++i)
RW(player->NpcStats()->mSkillIncrease[i], send);
RW(player->NpcStats()->mLevelProgress, send);
}

@ -13,7 +13,8 @@ namespace mwmp
class PacketSkill : public BasePacket
{
public:
const static int StatsCount = 27;
const static int SkillCount = 27;
const static int AttributeCount = 8;
PacketSkill(RakNet::RakPeerInterface *peer);
virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send);

Loading…
Cancel
Save