[General] Minor improvements for player packets

Add compression, remove useless loop iterations
pull/249/merge
Koncord 8 years ago
parent ad873e16b8
commit 556bf18535

@ -31,9 +31,7 @@ void PacketActorCellChange::Packet(RakNet::BitStream *bs, bool send)
for (unsigned int i = 0; i < actorList->count; i++)
{
if (send)
{
actor = actorList->baseActors.at(i);
}
RW(actor.refNumIndex, send);
RW(actor.mpNum, send);
@ -45,8 +43,6 @@ void PacketActorCellChange::Packet(RakNet::BitStream *bs, bool send)
RW(actor.direction, send, 1);
if (!send)
{
actorList->baseActors.push_back(actor);
}
}
}

@ -16,15 +16,15 @@ void PacketPlayerAttack::Packet(RakNet::BitStream *bs, bool send)
{
PlayerPacket::Packet(bs, send);
RW(player->attack.target.refId, send);
RW(player->attack.target.refId, send, 1);
RW(player->attack.target.refNumIndex, send);
RW(player->attack.target.mpNum, send);
RW(player->attack.target.guid, send);
RW(player->attack.spellId, send);
RW(player->attack.spellId, send, 1);
RW(player->attack.type, send);
RW(player->attack.success, send);
RW(player->attack.damage, send);
RW(player->attack.damage, send, 0); // never compress damage
RW(player->attack.pressed, send);
RW(player->attack.knockdown, send);

@ -16,6 +16,5 @@ void PacketPlayerAttribute::Packet(RakNet::BitStream *bs, bool send)
{
PlayerPacket::Packet(bs, send);
for (int i = 0; i < AttributeCount; ++i)
RW(player->creatureStats.mAttributes[i], send);
RW(player->creatureStats.mAttributes, send);
}

@ -16,16 +16,16 @@ void PacketPlayerBaseInfo::Packet(RakNet::BitStream *bs, bool send)
{
PlayerPacket::Packet(bs, send);
RW(player->npc.mName, send);
RW(player->npc.mModel, send);
RW(player->npc.mRace, send);
RW(player->npc.mHair, send);
RW(player->npc.mHead, send);
RW(player->npc.mName, send, 1);
RW(player->npc.mModel, send, 1);
RW(player->npc.mRace, send, 1);
RW(player->npc.mHair, send), 1;
RW(player->npc.mHead, send), 1;
RW(player->npc.mFlags, send);
RW(player->birthsign, send);
RW(player->birthsign, send, 1);
RW(player->creatureModel, send);
RW(player->creatureModel, send, 1);
RW(player->useCreatureName, send);
}

@ -17,8 +17,6 @@ void mwmp::PacketPlayerCellChange::Packet(RakNet::BitStream *bs, bool send)
{
PlayerPacket::Packet(bs, send);
RW(player->cell.mData.mFlags, send);
RW(player->cell.mData.mX, send);
RW(player->cell.mData.mY, send);
RW(player->cell.mName, send);
RW(player->cell.mData, send, 1);
RW(player->cell.mName, send, 1);
}

@ -25,19 +25,13 @@ void mwmp::PacketPlayerCellState::Packet(RakNet::BitStream *bs, bool send)
CellState cellState;
if (send)
{
cellState = player->cellStateChanges.cellStates.at(i);
}
RW(cellState.type, send);
RW(cellState.cell.mData.mFlags, send);
RW(cellState.cell.mData.mX, send);
RW(cellState.cell.mData.mY, send);
RW(cellState.cell.mName, send);
RW(cellState.cell.mData, send, 1);
RW(cellState.cell.mName, send, 1);
if (!send)
{
player->cellStateChanges.cellStates.push_back(cellState);
}
}
}

@ -17,8 +17,8 @@ void mwmp::PacketPlayerClass::Packet(RakNet::BitStream *bs, bool send)
RW(player->charClass.mId, send);
if (player->charClass.mId.empty()) // custom class
{
RW(player->charClass.mName, send);
RW(player->charClass.mDescription, send);
RW(player->charClass.mData, send);
RW(player->charClass.mName, send, 1);
RW(player->charClass.mDescription, send, 1);
RW(player->charClass.mData, send, 1);
}
}

@ -23,7 +23,7 @@ namespace mwmp
PlayerPacket::Packet(bs, send);
RW(player->creatureStats.mDead, send);
RW(player->deathReason, send);
RW(player->deathReason, send, 1);
}
};
}

@ -18,7 +18,7 @@ void PacketPlayerEquipment::Packet(RakNet::BitStream *bs, bool send)
for (int i = 0; i < 19; i++)
{
RW(player->equipedItems[i].refId, send);
RW(player->equipedItems[i].refId, send, 1);
RW(player->equipedItems[i].count, send);
RW(player->equipedItems[i].charge, send);
}

@ -27,7 +27,7 @@ void PacketPlayerFaction::Packet(RakNet::BitStream *bs, bool send)
if (send)
faction = player->factionChanges.factions.at(i);
RW(faction.factionId, send);
RW(faction.factionId, send, 1);
RW(faction.rank, send);
RW(faction.isExpelled, send);

@ -31,17 +31,13 @@ void PacketPlayerInventory::Packet(RakNet::BitStream *bs, bool send)
Item item;
if (send)
{
item = player->inventoryChanges.items.at(i);
}
RW(item.refId, send);
RW(item.refId, send, 1);
RW(item.count, send);
RW(item.charge, send);
if (!send)
{
player->inventoryChanges.items.push_back(item);
}
}
}

@ -28,18 +28,16 @@ void PacketPlayerJournal::Packet(RakNet::BitStream *bs, bool send)
journalItem = player->journalChanges.journalItems.at(i);
RW(journalItem.type, send);
RW(journalItem.quest, send);
RW(journalItem.quest, send, 1);
RW(journalItem.index, send);
if (journalItem.type == JournalItem::ENTRY)
{
RW(journalItem.actorRefId, send);
RW(journalItem.actorRefId, send, 1);
RW(journalItem.actorRefNumIndex, send);
RW(journalItem.actorMpNum, send);
RW(journalItem.actorCell.mData.mFlags, send);
RW(journalItem.actorCell.mData.mX, send);
RW(journalItem.actorCell.mData.mY, send);
RW(journalItem.actorCell.mName, send);
RW(journalItem.actorCell.mData, send, 1);
RW(journalItem.actorCell.mName, send, 1);
}
if (!send)

@ -18,11 +18,10 @@ void PacketPlayerSkill::Packet(RakNet::BitStream *bs, bool send)
{
PlayerPacket::Packet(bs, send);
for (int i = 0; i < SkillCount; ++i)
RW(player->npcStats.mSkills[i], send);
RW(player->npcStats.mSkills, send);
for (int i = 0; i < AttributeCount; ++i)
RW(player->npcStats.mSkillIncrease[i], send);
RW(player->npcStats.mSkillIncrease, send);
RW(player->npcStats.mLevelProgress, send);
}

@ -27,16 +27,12 @@ void PacketPlayerSpellbook::Packet(RakNet::BitStream *bs, bool send)
ESM::Spell spell;
if (send)
{
spell = player->spellbookChanges.spells.at(i);
}
RW(spell.mId, send);
RW(spell.mId, send, 1);
if (!send)
{
player->spellbookChanges.spells.push_back(spell);
}
}
}

@ -27,7 +27,7 @@ void PacketPlayerTopic::Packet(RakNet::BitStream *bs, bool send)
if (send)
topic = player->topicChanges.topics.at(i);
RW(topic.topicId, send);
RW(topic.topicId, send, 1);
if (!send)
player->topicChanges.topics.push_back(topic);

Loading…
Cancel
Save