[General] Reduce packets size and add integrity checks

0.6.3
Koncord 7 years ago committed by Koncord
parent fa2bf0663e
commit f9ff5f10df

@ -233,15 +233,15 @@ namespace mwmp
// Track only the indexes of the attributes that have been changed,
// with the attribute values themselves being stored in creatureStats.mAttributes
std::vector<int> attributeIndexChanges;
std::vector<uint8_t> attributeIndexChanges;
// Track only the indexes of the skills that have been changed,
// with the skill values themselves being stored in npcStats.mSkills
std::vector<int> skillIndexChanges;
std::vector<uint8_t> skillIndexChanges;
// Track only the indexes of the dynamic states that have been changed,
// with the dynamicStats themselves being stored in creatureStats.mDynamic
std::vector<int> statsDynamicIndexChanges;
std::vector<uint8_t> statsDynamicIndexChanges;
// Track only the indexes of the equipment items that have been changed,
// with the items themselves being stored in equipmentItems

@ -39,6 +39,12 @@ void PacketPlayerAttribute::Packet(RakNet::BitStream *bs, bool send)
{
RW(attributeIndex, send);
if (attributeIndex >= 8)
{
packetValid = false;
return;
}
RW(player->creatureStats.mAttributes[attributeIndex], send);
RW(player->npcStats.mSkillIncrease[attributeIndex], send);
}

@ -38,6 +38,11 @@ void PacketPlayerSkill::Packet(RakNet::BitStream *bs, bool send)
for (auto &&skillId : player->skillIndexChanges)
{
RW(skillId, send);
if (skillId >= 27)
{
packetValid = false;
return;
}
RW(player->npcStats.mSkills[skillId], send);
}
}

@ -37,7 +37,11 @@ void PacketPlayerStatsDynamic::Packet(RakNet::BitStream *bs, bool send)
for (auto &&statsDynamicIndex : player->statsDynamicIndexChanges)
{
RW(statsDynamicIndex, send);
if (statsDynamicIndex >= 3)
{
packetValid = false;
return;
}
RW(player->creatureStats.mDynamic[statsDynamicIndex], send);
}
}

Loading…
Cancel
Save