remove use of loops in protocol
This commit is contained in:
@@ -331,8 +331,8 @@ DataBuffer PlayerListPacket::Serialize(bool packetID) const {
|
||||
|
||||
WritePacketID(data, packetID);
|
||||
data << static_cast<std::uint8_t>(m_Players.size());
|
||||
for (auto pair : m_Players) {
|
||||
data << pair.first << pair.second.name << pair.second.team;
|
||||
for (auto [playerID, playerInfo] : m_Players) {
|
||||
data << playerID << playerInfo.name << playerInfo.team;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@@ -488,20 +488,18 @@ DataBuffer SendMobsPacket::Serialize(bool packetID) const {
|
||||
|
||||
WritePacketID(data, packetID);
|
||||
data << static_cast<std::uint8_t>(m_MobSends.size());
|
||||
for (const MobSend& mobSend : m_MobSends) {
|
||||
data << mobSend;
|
||||
}
|
||||
|
||||
data.WriteSome(reinterpret_cast<const std::uint8_t*>(m_MobSends.data()), m_MobSends.size() * sizeof(m_MobSends));
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void SendMobsPacket::Deserialize(DataBuffer& data) {
|
||||
std::uint8_t mobSendCount;
|
||||
data >> mobSendCount;
|
||||
protocol::MobSend mobSend;
|
||||
for (int i = 0; i < mobSendCount; i++) {
|
||||
data >> mobSend;
|
||||
m_MobSends.push_back(mobSend);
|
||||
}
|
||||
|
||||
m_MobSends.resize(mobSendCount);
|
||||
data.ReadSome(reinterpret_cast<std::uint8_t*>(m_MobSends.data()), mobSendCount * sizeof(MobSend));
|
||||
}
|
||||
|
||||
DataBuffer UpgradeTowerPacket::Serialize(bool packetID) const {
|
||||
@@ -533,9 +531,8 @@ DataBuffer UpdateMobStatesPacket::Serialize(bool packetID) const {
|
||||
|
||||
WritePacketID(data, packetID);
|
||||
data << static_cast<std::uint64_t>(m_MobStates.size());
|
||||
for (auto mobState : m_MobStates) {
|
||||
data << mobState;
|
||||
}
|
||||
|
||||
data.WriteSome(reinterpret_cast<const std::uint8_t*>(m_MobStates.data()), m_MobStates.size() * sizeof(MobState));
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -543,9 +540,8 @@ void UpdateMobStatesPacket::Deserialize(DataBuffer& data) {
|
||||
std::uint64_t mobCount;
|
||||
data >> mobCount;
|
||||
m_MobStates.resize(mobCount);
|
||||
for (std::uint64_t mobIndex = 0; mobIndex < mobCount; mobIndex++) {
|
||||
data >> m_MobStates[mobIndex];
|
||||
}
|
||||
|
||||
data.ReadSome(reinterpret_cast<std::uint8_t*>(m_MobStates.data()), mobCount * sizeof(MobState));
|
||||
}
|
||||
|
||||
DataBuffer PlayerBuyItemPacket::Serialize(bool packetID) const {
|
||||
|
||||
Reference in New Issue
Block a user