forked from teamnwah/openmw-tes3coop
[General] Cleanup Player packets
This commit is contained in:
parent
901fe72471
commit
e44fcdc0b3
26 changed files with 189 additions and 229 deletions
|
@ -40,7 +40,7 @@ void Books::addBook(const std::string &bookId)
|
||||||
|
|
||||||
std::string Books::getBookId(unsigned i) const
|
std::string Books::getBookId(unsigned i) const
|
||||||
{
|
{
|
||||||
if (i >= player->bookChanges.count)
|
if (i >= player->bookChanges.books.size())
|
||||||
return "invalid";
|
return "invalid";
|
||||||
|
|
||||||
return player->bookChanges.books.at(i).bookId;
|
return player->bookChanges.books.at(i).bookId;
|
||||||
|
@ -48,7 +48,7 @@ std::string Books::getBookId(unsigned i) const
|
||||||
|
|
||||||
unsigned Books::getChanges() const
|
unsigned Books::getChanges() const
|
||||||
{
|
{
|
||||||
return player->bookChanges.count;
|
return player->bookChanges.books.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Books::reset()
|
void Books::reset()
|
||||||
|
|
|
@ -59,5 +59,5 @@ std::string Dialogue::getTopicId(unsigned int i) const
|
||||||
|
|
||||||
unsigned int Dialogue::getChanges() const
|
unsigned int Dialogue::getChanges() const
|
||||||
{
|
{
|
||||||
return player->topicChanges.count;
|
return player->topicChanges.topics.size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ void Inventory::InitializeInventoryChanges()
|
||||||
|
|
||||||
int Inventory::getChangesSize() const
|
int Inventory::getChangesSize() const
|
||||||
{
|
{
|
||||||
return netActor->getNetCreature()->inventoryChanges.count;
|
return netActor->getNetCreature()->inventoryChanges.items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inventory::equipItem(unsigned short slot, const std::string& refId, unsigned int count, int charge)
|
void Inventory::equipItem(unsigned short slot, const std::string& refId, unsigned int count, int charge)
|
||||||
|
|
|
@ -1091,7 +1091,6 @@ void LocalPlayer::sendInventory()
|
||||||
inventoryChanges.items.push_back(item);
|
inventoryChanges.items.push_back(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
inventoryChanges.count = (unsigned int) inventoryChanges.items.size();
|
|
||||||
inventoryChanges.action = InventoryChanges::SET;
|
inventoryChanges.action = InventoryChanges::SET;
|
||||||
getNetworking()->getPlayerPacket(ID_PLAYER_INVENTORY)->setPlayer(this);
|
getNetworking()->getPlayerPacket(ID_PLAYER_INVENTORY)->setPlayer(this);
|
||||||
getNetworking()->getPlayerPacket(ID_PLAYER_INVENTORY)->Send();
|
getNetworking()->getPlayerPacket(ID_PLAYER_INVENTORY)->Send();
|
||||||
|
|
|
@ -84,7 +84,6 @@ namespace mwmp
|
||||||
struct AttributeChanges
|
struct AttributeChanges
|
||||||
{
|
{
|
||||||
std::vector<int> attributeIndexes;
|
std::vector<int> attributeIndexes;
|
||||||
unsigned int count;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Track only the indexes of the skills that have been changed,
|
// Track only the indexes of the skills that have been changed,
|
||||||
|
@ -92,19 +91,16 @@ namespace mwmp
|
||||||
struct SkillChanges
|
struct SkillChanges
|
||||||
{
|
{
|
||||||
std::vector<int> skillIndexes;
|
std::vector<int> skillIndexes;
|
||||||
unsigned int count;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct JournalChanges
|
struct JournalChanges
|
||||||
{
|
{
|
||||||
std::vector<JournalItem> journalItems;
|
std::vector<JournalItem> journalItems;
|
||||||
unsigned int count;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FactionChanges
|
struct FactionChanges
|
||||||
{
|
{
|
||||||
std::vector<Faction> factions;
|
std::vector<Faction> factions;
|
||||||
unsigned int count;
|
|
||||||
|
|
||||||
enum FACTION_ACTION
|
enum FACTION_ACTION
|
||||||
{
|
{
|
||||||
|
@ -119,31 +115,27 @@ namespace mwmp
|
||||||
struct TopicChanges
|
struct TopicChanges
|
||||||
{
|
{
|
||||||
std::vector<Topic> topics;
|
std::vector<Topic> topics;
|
||||||
unsigned int count;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct KillChanges
|
struct KillChanges
|
||||||
{
|
{
|
||||||
std::vector<Kill> kills;
|
std::vector<Kill> kills;
|
||||||
unsigned int count;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BookChanges
|
struct BookChanges
|
||||||
{
|
{
|
||||||
std::vector<Book> books;
|
std::vector<Book> books;
|
||||||
unsigned int count;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MapChanges
|
struct MapChanges
|
||||||
{
|
{
|
||||||
std::vector<ESM::Cell> cellsExplored;
|
std::vector<ESM::Cell> cellsExplored;
|
||||||
unsigned int count;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SpellbookChanges
|
struct SpellbookChanges
|
||||||
{
|
{
|
||||||
std::vector<ESM::Spell> spells;
|
std::vector<ESM::Spell> spells;
|
||||||
unsigned int count;
|
|
||||||
enum ACTION_TYPE
|
enum ACTION_TYPE
|
||||||
{
|
{
|
||||||
SET = 0,
|
SET = 0,
|
||||||
|
@ -156,7 +148,6 @@ namespace mwmp
|
||||||
struct CellStateChanges
|
struct CellStateChanges
|
||||||
{
|
{
|
||||||
std::vector<CellState> cellStates;
|
std::vector<CellState> cellStates;
|
||||||
unsigned int count;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum RESURRECT_TYPE
|
enum RESURRECT_TYPE
|
||||||
|
@ -225,9 +216,7 @@ namespace mwmp
|
||||||
BasePlayer(RakNet::RakNetGUID guid) : guid(guid)
|
BasePlayer(RakNet::RakNetGUID guid) : guid(guid)
|
||||||
{
|
{
|
||||||
inventoryChanges.action = 0;
|
inventoryChanges.action = 0;
|
||||||
inventoryChanges.count = 0;
|
|
||||||
spellbookChanges.action = 0;
|
spellbookChanges.action = 0;
|
||||||
spellbookChanges.count = 0;
|
|
||||||
useCreatureName = false;
|
useCreatureName = false;
|
||||||
isWerewolf = false;
|
isWerewolf = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ namespace mwmp
|
||||||
struct InventoryChanges
|
struct InventoryChanges
|
||||||
{
|
{
|
||||||
std::vector<Item> items;
|
std::vector<Item> items;
|
||||||
unsigned int count;
|
|
||||||
enum ACTION_TYPE
|
enum ACTION_TYPE
|
||||||
{
|
{
|
||||||
SET = 0,
|
SET = 0,
|
||||||
|
|
|
@ -42,9 +42,9 @@ void BasePacket::SetSendStream(RakNet::BitStream *bitStream)
|
||||||
|
|
||||||
void BasePacket::SetStreams(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
|
void BasePacket::SetStreams(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
|
||||||
{
|
{
|
||||||
if (inStream != 0)
|
if (inStream != nullptr)
|
||||||
bsRead = inStream;
|
bsRead = inStream;
|
||||||
if (outStream != 0)
|
if (outStream != nullptr)
|
||||||
bsSend = outStream;
|
bsSend = outStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace mwmp
|
||||||
bs->Read(data);
|
bs->Read(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RW(std::string &str, bool write, bool compress = 0)
|
void RW(std::string &str, bool write, bool compress = false)
|
||||||
{
|
{
|
||||||
if (write)
|
if (write)
|
||||||
{
|
{
|
||||||
|
@ -101,10 +101,10 @@ namespace mwmp
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
unsigned char packetID;
|
uint8_t packetID;
|
||||||
PacketReliability reliability;
|
PacketReliability reliability;
|
||||||
PacketPriority priority;
|
PacketPriority priority;
|
||||||
int orderChannel;
|
char orderChannel;
|
||||||
RakNet::BitStream *bsRead, *bsSend, *bs;
|
RakNet::BitStream *bsRead, *bsSend, *bs;
|
||||||
RakNet::RakPeerInterface *peer;
|
RakNet::RakPeerInterface *peer;
|
||||||
RakNet::RakNetGUID guid;
|
RakNet::RakNetGUID guid;
|
||||||
|
|
|
@ -24,7 +24,7 @@ void PacketGUIWindow::Packet(RakNet::BitStream *bs, bool send)
|
||||||
|
|
||||||
int32_t size;
|
int32_t size;
|
||||||
if (send)
|
if (send)
|
||||||
size = player->guiWindow.widgets.size();
|
size = static_cast<int32_t>(player->guiWindow.widgets.size());
|
||||||
RW(size, send);
|
RW(size, send);
|
||||||
|
|
||||||
if(!send)
|
if(!send)
|
||||||
|
|
|
@ -16,43 +16,40 @@ void PacketPlayerActiveSkills::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
PlayerPacket::Packet(bs, send);
|
PlayerPacket::Packet(bs, send);
|
||||||
|
|
||||||
unsigned long spells = 0;
|
uint32_t spellCount = 0;
|
||||||
|
|
||||||
if (send)
|
if (send)
|
||||||
spells = player->activeSpells.mSpells.size();
|
spellCount = static_cast<uint32_t>(player->activeSpells.mSpells.size());
|
||||||
|
|
||||||
RW(spells, send);
|
RW(spellCount, send);
|
||||||
|
|
||||||
|
auto fnRWSpell = [this, &send](ESM::ActiveSpells::TContainer::value_type &spell) {
|
||||||
|
RW(spell.first, send);
|
||||||
|
RW(spell.second.mTimeStamp, send);
|
||||||
|
uint32_t effectsCount;
|
||||||
|
|
||||||
if(send)
|
if(send)
|
||||||
for (ESM::ActiveSpells::TContainer::const_iterator spell = player->activeSpells.mSpells.begin();
|
effectsCount = static_cast<uint32_t>(spell.second.mEffects.size());
|
||||||
spell != player->activeSpells.mSpells.end(); ++spell)
|
|
||||||
|
RW(effectsCount, send);
|
||||||
|
|
||||||
|
if(!send)
|
||||||
|
spell.second.mEffects.resize(effectsCount);
|
||||||
|
|
||||||
|
for (auto &&effect : spell.second.mEffects)
|
||||||
|
RW(effect, send);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (send)
|
||||||
|
for (auto && spell : player->activeSpells.mSpells)
|
||||||
{
|
{
|
||||||
RW(spell->first, true);
|
fnRWSpell(spell);
|
||||||
RW(spell->second.mTimeStamp, true);
|
|
||||||
unsigned long effects = spell->second.mEffects.size();
|
|
||||||
RW(effects, true);
|
|
||||||
|
|
||||||
for (std::vector<ESM::ActiveEffect>::const_iterator effect = spell->second.mEffects.begin();
|
|
||||||
effect != spell->second.mEffects.end(); ++effect)
|
|
||||||
RW(effect, true);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
for (unsigned int i = 0; i < spells; i++)
|
for (unsigned int i = 0; i < spellCount; i++)
|
||||||
{
|
{
|
||||||
ESM::ActiveSpells::TContainer::value_type spell;
|
ESM::ActiveSpells::TContainer::value_type spell;
|
||||||
|
fnRWSpell(spell);
|
||||||
RW(spell.first, false);
|
|
||||||
RW(spell.second.mTimeStamp, false);
|
|
||||||
unsigned long effects;
|
|
||||||
RW(effects, false);
|
|
||||||
|
|
||||||
ESM::ActiveEffect effect;
|
|
||||||
for (unsigned int j = 0; j < effects; j++)
|
|
||||||
{
|
|
||||||
RW(effect, false);
|
|
||||||
spell.second.mEffects.push_back(effect);
|
|
||||||
}
|
|
||||||
player->activeSpells.mSpells.insert(spell);
|
player->activeSpells.mSpells.insert(spell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,23 +13,23 @@ void PacketPlayerAttribute::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
PlayerPacket::Packet(bs, send);
|
PlayerPacket::Packet(bs, send);
|
||||||
|
|
||||||
|
unsigned count;
|
||||||
if (send)
|
if (send)
|
||||||
player->attributeChanges.count = (unsigned int)(player->attributeChanges.attributeIndexes.size());
|
count = (unsigned int)(player->attributeChanges.attributeIndexes.size());
|
||||||
else
|
|
||||||
player->attributeChanges.attributeIndexes.clear();
|
|
||||||
|
|
||||||
RW(player->attributeChanges.count, send);
|
RW(count, send);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < player->attributeChanges.count; i++)
|
if(!send)
|
||||||
{
|
{
|
||||||
int attributeId;
|
player->attributeChanges.attributeIndexes.clear();
|
||||||
|
player->attributeChanges.attributeIndexes.resize(count);
|
||||||
|
}
|
||||||
|
|
||||||
if (send)
|
for (auto &&attributeIndex : player->attributeChanges.attributeIndexes)
|
||||||
attributeId = player->attributeChanges.attributeIndexes.at(i);
|
{
|
||||||
|
RW(attributeIndex, send);
|
||||||
|
|
||||||
RW(attributeId, send);
|
RW(player->creatureStats.mAttributes[attributeIndex], send);
|
||||||
|
RW(player->npcStats.mSkillIncrease[attributeIndex], send);
|
||||||
RW(player->creatureStats.mAttributes[attributeId], send);
|
|
||||||
RW(player->npcStats.mSkillIncrease[attributeId], send);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,23 +13,21 @@ void PacketPlayerBook::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
PlayerPacket::Packet(bs, send);
|
PlayerPacket::Packet(bs, send);
|
||||||
|
|
||||||
if (send)
|
uint32_t count;
|
||||||
player->bookChanges.count = (unsigned int)(player->bookChanges.books.size());
|
|
||||||
else
|
|
||||||
player->bookChanges.books.clear();
|
|
||||||
|
|
||||||
RW(player->bookChanges.count, send);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < player->bookChanges.count; i++)
|
|
||||||
{
|
|
||||||
Book book;
|
|
||||||
|
|
||||||
if (send)
|
if (send)
|
||||||
book = player->bookChanges.books.at(i);
|
count = static_cast<uint32_t>(player->bookChanges.books.size());
|
||||||
|
|
||||||
RW(book.bookId, send, 1);
|
RW(count, send);
|
||||||
|
|
||||||
if(!send)
|
if(!send)
|
||||||
player->bookChanges.books.push_back(book);
|
{
|
||||||
|
player->bookChanges.books.clear();
|
||||||
|
player->bookChanges.books.resize(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto &&book : player->bookChanges.books)
|
||||||
|
{
|
||||||
|
RW(book.bookId, send, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,25 +13,24 @@ void mwmp::PacketPlayerCellState::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
PlayerPacket::Packet(bs, send);
|
PlayerPacket::Packet(bs, send);
|
||||||
|
|
||||||
if (send)
|
uint32_t count;
|
||||||
player->cellStateChanges.count = (unsigned int)(player->cellStateChanges.cellStates.size());
|
|
||||||
else
|
|
||||||
player->cellStateChanges.cellStates.clear();
|
|
||||||
|
|
||||||
RW(player->cellStateChanges.count, send);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < player->cellStateChanges.count; i++)
|
|
||||||
{
|
|
||||||
CellState cellState;
|
|
||||||
|
|
||||||
if (send)
|
if (send)
|
||||||
cellState = player->cellStateChanges.cellStates.at(i);
|
count = static_cast<uint32_t>(player->cellStateChanges.cellStates.size());
|
||||||
|
|
||||||
RW(cellState.type, send);
|
|
||||||
RW(cellState.cell.mData, send, 1);
|
RW(count, send);
|
||||||
RW(cellState.cell.mName, send, 1);
|
|
||||||
|
|
||||||
if(!send)
|
if(!send)
|
||||||
player->cellStateChanges.cellStates.push_back(cellState);
|
{
|
||||||
|
player->cellStateChanges.cellStates.clear();
|
||||||
|
player->cellStateChanges.cellStates.resize(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto &&cellState : player->cellStateChanges.cellStates)
|
||||||
|
{
|
||||||
|
RW(cellState.type, send);
|
||||||
|
RW(cellState.cell.mData, send, true);
|
||||||
|
RW(cellState.cell.mName, send, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ void mwmp::PacketPlayerClass::Packet(RakNet::BitStream *bs, bool send)
|
||||||
|
|
||||||
if (player->charClass.mId.empty()) // custom class
|
if (player->charClass.mId.empty()) // custom class
|
||||||
{
|
{
|
||||||
RW(player->charClass.mName, send, 1);
|
RW(player->charClass.mName, send, true);
|
||||||
RW(player->charClass.mDescription, send, 1);
|
RW(player->charClass.mDescription, send, true);
|
||||||
RW(player->charClass.mData, send, 1);
|
RW(player->charClass.mData, send, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace mwmp
|
||||||
{
|
{
|
||||||
PlayerPacket::Packet(bs, send);
|
PlayerPacket::Packet(bs, send);
|
||||||
|
|
||||||
RW(player->deathReason, send, 1);
|
RW(player->deathReason, send, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,10 @@ void PacketPlayerEquipment::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
PlayerPacket::Packet(bs, send);
|
PlayerPacket::Packet(bs, send);
|
||||||
|
|
||||||
for (int i = 0; i < 19; i++)
|
for (auto &equipedItem : player->equipedItems)
|
||||||
{
|
{
|
||||||
RW(player->equipedItems[i].refId, send, 1);
|
RW(equipedItem.refId, send, true);
|
||||||
RW(player->equipedItems[i].count, send);
|
RW(equipedItem.count, send);
|
||||||
RW(player->equipedItems[i].charge, send);
|
RW(equipedItem.charge, send);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,21 +15,22 @@ void PacketPlayerFaction::Packet(RakNet::BitStream *bs, bool send)
|
||||||
|
|
||||||
RW(player->factionChanges.action, send);
|
RW(player->factionChanges.action, send);
|
||||||
|
|
||||||
|
uint32_t count;
|
||||||
|
|
||||||
if (send)
|
if (send)
|
||||||
player->factionChanges.count = (unsigned int)(player->factionChanges.factions.size());
|
count = static_cast<uint32_t>(player->factionChanges.factions.size());
|
||||||
else
|
|
||||||
player->factionChanges.factions.clear();
|
|
||||||
|
|
||||||
RW(player->factionChanges.count, send);
|
RW(count, send);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < player->factionChanges.count; i++)
|
if(!send)
|
||||||
{
|
{
|
||||||
Faction faction;
|
player->factionChanges.factions.clear();
|
||||||
|
player->factionChanges.factions.resize(count);
|
||||||
|
}
|
||||||
|
|
||||||
if (send)
|
for (auto &&faction : player->factionChanges.factions)
|
||||||
faction = player->factionChanges.factions.at(i);
|
{
|
||||||
|
RW(faction.factionId, send, true);
|
||||||
RW(faction.factionId, send, 1);
|
|
||||||
|
|
||||||
if (player->factionChanges.action == FactionChanges::RANK)
|
if (player->factionChanges.action == FactionChanges::RANK)
|
||||||
RW(faction.rank, send);
|
RW(faction.rank, send);
|
||||||
|
@ -39,8 +40,5 @@ void PacketPlayerFaction::Packet(RakNet::BitStream *bs, bool send)
|
||||||
|
|
||||||
if (player->factionChanges.action == FactionChanges::REPUTATION)
|
if (player->factionChanges.action == FactionChanges::REPUTATION)
|
||||||
RW(faction.reputation, send);
|
RW(faction.reputation, send);
|
||||||
|
|
||||||
if (!send)
|
|
||||||
player->factionChanges.factions.push_back(faction);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,25 +19,23 @@ void PacketPlayerInventory::Packet(RakNet::BitStream *bs, bool send)
|
||||||
|
|
||||||
RW(player->inventoryChanges.action, send);
|
RW(player->inventoryChanges.action, send);
|
||||||
|
|
||||||
if (send)
|
uint32_t count;
|
||||||
player->inventoryChanges.count = (unsigned int) (player->inventoryChanges.items.size());
|
|
||||||
else
|
|
||||||
player->inventoryChanges.items.clear();
|
|
||||||
|
|
||||||
RW(player->inventoryChanges.count, send);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < player->inventoryChanges.count; i++)
|
|
||||||
{
|
|
||||||
Item item;
|
|
||||||
|
|
||||||
if (send)
|
if (send)
|
||||||
item = player->inventoryChanges.items.at(i);
|
count = static_cast<uint32_t>(player->inventoryChanges.items.size());
|
||||||
|
|
||||||
RW(item.refId, send, 1);
|
RW(count, send);
|
||||||
RW(item.count, send);
|
|
||||||
RW(item.charge, send);
|
|
||||||
|
|
||||||
if(!send)
|
if(!send)
|
||||||
player->inventoryChanges.items.push_back(item);
|
{
|
||||||
|
player->inventoryChanges.items.clear();
|
||||||
|
player->inventoryChanges.items.resize(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto &&item : player->inventoryChanges.items)
|
||||||
|
{
|
||||||
|
RW(item.refId, send, true);
|
||||||
|
RW(item.count, send);
|
||||||
|
RW(item.charge, send);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,6 @@ void PacketPlayerJail::Packet(RakNet::BitStream *bs, bool send)
|
||||||
RW(player->jailDays, send);
|
RW(player->jailDays, send);
|
||||||
RW(player->ignoreJailTeleportation, send);
|
RW(player->ignoreJailTeleportation, send);
|
||||||
RW(player->ignoreJailSkillIncreases, send);
|
RW(player->ignoreJailSkillIncreases, send);
|
||||||
RW(player->jailProgressText, send, 1);
|
RW(player->jailProgressText, send, true);
|
||||||
RW(player->jailEndText, send, 1);
|
RW(player->jailEndText, send, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,30 +13,26 @@ void PacketPlayerJournal::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
PlayerPacket::Packet(bs, send);
|
PlayerPacket::Packet(bs, send);
|
||||||
|
|
||||||
|
uint32_t count;
|
||||||
|
|
||||||
if (send)
|
if (send)
|
||||||
player->journalChanges.count = (unsigned int)(player->journalChanges.journalItems.size());
|
count = static_cast<uint32_t>(player->journalChanges.journalItems.size());
|
||||||
else
|
|
||||||
player->journalChanges.journalItems.clear();
|
|
||||||
|
|
||||||
RW(player->journalChanges.count, send);
|
RW(count, send);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < player->journalChanges.count; i++)
|
if(!send)
|
||||||
{
|
{
|
||||||
JournalItem journalItem;
|
player->journalChanges.journalItems.clear();
|
||||||
|
player->journalChanges.journalItems.resize(count);
|
||||||
if (send)
|
}
|
||||||
journalItem = player->journalChanges.journalItems.at(i);
|
|
||||||
|
|
||||||
|
for (auto &&journalItem : player->journalChanges.journalItems)
|
||||||
|
{
|
||||||
RW(journalItem.type, send);
|
RW(journalItem.type, send);
|
||||||
RW(journalItem.quest, send, 1);
|
RW(journalItem.quest, send, true);
|
||||||
RW(journalItem.index, send);
|
RW(journalItem.index, send);
|
||||||
|
|
||||||
if (journalItem.type == JournalItem::ENTRY)
|
if (journalItem.type == JournalItem::ENTRY)
|
||||||
{
|
RW(journalItem.actorRefId, send, true);
|
||||||
RW(journalItem.actorRefId, send, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!send)
|
|
||||||
player->journalChanges.journalItems.push_back(journalItem);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,24 +10,22 @@ void mwmp::PacketPlayerKillCount::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
PlayerPacket::Packet(bs, send);
|
PlayerPacket::Packet(bs, send);
|
||||||
|
|
||||||
if (send)
|
uint32_t count;
|
||||||
player->killChanges.count = (unsigned int)(player->killChanges.kills.size());
|
|
||||||
else
|
|
||||||
player->killChanges.kills.clear();
|
|
||||||
|
|
||||||
RW(player->killChanges.count, send);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < player->killChanges.count; i++)
|
|
||||||
{
|
|
||||||
Kill kill;
|
|
||||||
|
|
||||||
if (send)
|
if (send)
|
||||||
kill = player->killChanges.kills.at(i);
|
count = static_cast<uint32_t>(player->killChanges.kills.size());
|
||||||
|
|
||||||
RW(kill.refId, send, 1);
|
RW(count, send);
|
||||||
RW(kill.number, send);
|
|
||||||
|
|
||||||
if(!send)
|
if(!send)
|
||||||
player->killChanges.kills.push_back(kill);
|
{
|
||||||
|
player->killChanges.kills.clear();
|
||||||
|
player->killChanges.kills.resize(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto &&kill : player->killChanges.kills)
|
||||||
|
{
|
||||||
|
RW(kill.refId, send, true);
|
||||||
|
RW(kill.number, send);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,24 +13,22 @@ void PacketPlayerMap::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
PlayerPacket::Packet(bs, send);
|
PlayerPacket::Packet(bs, send);
|
||||||
|
|
||||||
if (send)
|
uint32_t count;
|
||||||
player->mapChanges.count = (unsigned int)(player->mapChanges.cellsExplored.size());
|
|
||||||
else
|
|
||||||
player->mapChanges.cellsExplored.clear();
|
|
||||||
|
|
||||||
RW(player->mapChanges.count, send);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < player->mapChanges.count; i++)
|
|
||||||
{
|
|
||||||
ESM::Cell cellExplored;
|
|
||||||
|
|
||||||
if (send)
|
if (send)
|
||||||
cellExplored = player->mapChanges.cellsExplored.at(i);
|
count = static_cast<uint32_t>(player->mapChanges.cellsExplored.size());
|
||||||
|
|
||||||
RW(cellExplored.mData, send, 1);
|
RW(count, send);
|
||||||
RW(cellExplored.mName, send, 1);
|
|
||||||
|
|
||||||
if(!send)
|
if(!send)
|
||||||
player->mapChanges.cellsExplored.push_back(cellExplored);
|
{
|
||||||
|
player->mapChanges.cellsExplored.clear();
|
||||||
|
player->mapChanges.cellsExplored.resize(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto &&cellExplored : player->mapChanges.cellsExplored)
|
||||||
|
{
|
||||||
|
RW(cellExplored.mData, send, true);
|
||||||
|
RW(cellExplored.mName, send, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,10 @@ void PacketPlayerPosition::Packet(RakNet::BitStream *bs, bool send)
|
||||||
dir = (player->direction.pos[0] >= 0 ? (unsigned char)(player->direction.pos[0]) : (unsigned char) 0x3) << 2; // pack direction
|
dir = (player->direction.pos[0] >= 0 ? (unsigned char)(player->direction.pos[0]) : (unsigned char) 0x3) << 2; // pack direction
|
||||||
dir += (player->direction.pos[1] >= 0 ? (unsigned char)(player->direction.pos[1]) : (unsigned char) 0x3);
|
dir += (player->direction.pos[1] >= 0 ? (unsigned char)(player->direction.pos[1]) : (unsigned char) 0x3);
|
||||||
}
|
}
|
||||||
RW(rot[0], send, 1);
|
RW(rot[0], send, true);
|
||||||
RW(rot[1], send, 1);
|
RW(rot[1], send, true);
|
||||||
|
|
||||||
RW(player->position.pos, send, 1);
|
RW(player->position.pos, send, true);
|
||||||
RW(dir, send);
|
RW(dir, send);
|
||||||
|
|
||||||
if (!send)
|
if (!send)
|
||||||
|
|
|
@ -18,20 +18,21 @@ void PacketPlayerSkill::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
PlayerPacket::Packet(bs, send);
|
PlayerPacket::Packet(bs, send);
|
||||||
|
|
||||||
|
uint32_t count;
|
||||||
|
|
||||||
if (send)
|
if (send)
|
||||||
player->skillChanges.count = (unsigned int)(player->skillChanges.skillIndexes.size());
|
count = static_cast<uint32_t>(player->skillChanges.skillIndexes.size());
|
||||||
else
|
|
||||||
player->skillChanges.skillIndexes.clear();
|
|
||||||
|
|
||||||
RW(player->skillChanges.count, send);
|
RW(count, send);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < player->skillChanges.count; i++)
|
if(!send)
|
||||||
{
|
{
|
||||||
int skillId;
|
player->skillChanges.skillIndexes.clear();
|
||||||
|
player->skillChanges.skillIndexes.resize(count);
|
||||||
if (send)
|
}
|
||||||
skillId = player->skillChanges.skillIndexes.at(i);
|
|
||||||
|
|
||||||
|
for (auto && skillId : player->skillChanges.skillIndexes)
|
||||||
|
{
|
||||||
RW(skillId, send);
|
RW(skillId, send);
|
||||||
RW(player->npcStats.mSkills[skillId], send);
|
RW(player->npcStats.mSkills[skillId], send);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,58 +15,56 @@ void PacketPlayerSpellbook::Packet(RakNet::BitStream *bs, bool send)
|
||||||
|
|
||||||
RW(player->spellbookChanges.action, send);
|
RW(player->spellbookChanges.action, send);
|
||||||
|
|
||||||
|
uint32_t changesCount;
|
||||||
|
|
||||||
if (send)
|
if (send)
|
||||||
player->spellbookChanges.count = (unsigned int) (player->spellbookChanges.spells.size());
|
changesCount = static_cast<uint32_t>(player->spellbookChanges.spells.size());
|
||||||
else
|
|
||||||
player->spellbookChanges.spells.clear();
|
|
||||||
|
|
||||||
RW(player->spellbookChanges.count, send);
|
RW(changesCount, send);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < player->spellbookChanges.count; i++)
|
if(!send)
|
||||||
{
|
{
|
||||||
ESM::Spell spell;
|
player->spellbookChanges.spells.clear();
|
||||||
|
player->spellbookChanges.spells.resize(changesCount);
|
||||||
|
}
|
||||||
|
|
||||||
if (send)
|
for (auto &&spell : player->spellbookChanges.spells)
|
||||||
spell = player->spellbookChanges.spells.at(i);
|
{
|
||||||
|
|
||||||
RW(spell.mId, send, 1);
|
RW(spell.mId, send, true);
|
||||||
|
|
||||||
if(spell.mId.find("$dynamic") != string::npos)
|
if(spell.mId.find("$dynamic") != string::npos)
|
||||||
{
|
{
|
||||||
RW(spell.mName, send, 1);
|
RW(spell.mName, send, true);
|
||||||
|
|
||||||
RW(spell.mData.mType, send, 1);
|
RW(spell.mData.mType, send, true);
|
||||||
RW(spell.mData.mCost, send, 1);
|
RW(spell.mData.mCost, send, true);
|
||||||
RW(spell.mData.mFlags, send, 1);
|
RW(spell.mData.mFlags, send, true);
|
||||||
|
|
||||||
int effectCount = 0;
|
uint32_t effectCount;
|
||||||
if (send)
|
if (send)
|
||||||
effectCount = spell.mEffects.mList.size();
|
effectCount = static_cast<uint32_t>(spell.mEffects.mList.size());
|
||||||
|
|
||||||
RW(effectCount, send, 1);
|
RW(effectCount, send, true);
|
||||||
|
|
||||||
for (unsigned int j = 0; j < effectCount; j++)
|
if (!send)
|
||||||
{
|
{
|
||||||
ESM::ENAMstruct effect;
|
spell.mEffects.mList.resize(effectCount);
|
||||||
if (send)
|
}
|
||||||
effect = spell.mEffects.mList.at(j);
|
|
||||||
|
|
||||||
RW(effect.mEffectID, send, 1);
|
for (auto &&effect : spell.mEffects.mList)
|
||||||
RW(effect.mSkill, send, 1);
|
{
|
||||||
RW(effect.mAttribute, send, 1);
|
|
||||||
RW(effect.mRange, send, 1);
|
|
||||||
RW(effect.mArea, send, 1);
|
|
||||||
RW(effect.mDuration, send, 1);
|
|
||||||
RW(effect.mMagnMin, send, 1);
|
|
||||||
RW(effect.mMagnMax, send, 1);
|
|
||||||
|
|
||||||
if(!send)
|
RW(effect.mEffectID, send, true);
|
||||||
spell.mEffects.mList.push_back(effect);
|
RW(effect.mSkill, send, true);
|
||||||
|
RW(effect.mAttribute, send, true);
|
||||||
|
RW(effect.mRange, send, true);
|
||||||
|
RW(effect.mArea, send, true);
|
||||||
|
RW(effect.mDuration, send, true);
|
||||||
|
RW(effect.mMagnMin, send, true);
|
||||||
|
RW(effect.mMagnMax, send, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!send)
|
|
||||||
player->spellbookChanges.spells.push_back(spell);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,23 +13,15 @@ void PacketPlayerTopic::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
PlayerPacket::Packet(bs, send);
|
PlayerPacket::Packet(bs, send);
|
||||||
|
|
||||||
|
uint32_t count;
|
||||||
|
|
||||||
if (send)
|
if (send)
|
||||||
player->topicChanges.count = (unsigned int)(player->topicChanges.topics.size());
|
count = static_cast<uint32_t>(player->topicChanges.topics.size());
|
||||||
else
|
|
||||||
player->topicChanges.topics.clear();
|
|
||||||
|
|
||||||
RW(player->topicChanges.count, send);
|
RW(count, send);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < player->topicChanges.count; i++)
|
for (auto &&topic : player->topicChanges.topics)
|
||||||
{
|
{
|
||||||
Topic topic;
|
RW(topic.topicId, send, true);
|
||||||
|
|
||||||
if (send)
|
|
||||||
topic = player->topicChanges.topics.at(i);
|
|
||||||
|
|
||||||
RW(topic.topicId, send, 1);
|
|
||||||
|
|
||||||
if (!send)
|
|
||||||
player->topicChanges.topics.push_back(topic);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue