diff --git a/CMakeLists.txt b/CMakeLists.txt index e085bfe7..b36bdb29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,7 +179,7 @@ file(ARCHIVE_EXTRACT INPUT ${PROJECT_BINARY_DIR}/navmeshes.zip DESTINATION ${PRO file(REMOVE ${PROJECT_BINARY_DIR}/navmeshes.zip) # Copy vanity files on first build -set(VANITY_FILES "CREDITS.md" "INFO.md" "TESTAMENT.md" "NPC.xml") +set(VANITY_FILES "CREDITS.md" "INFO.md" "TESTAMENT.md" "root.xml" "dev-tribute.xml" "atm.xml") foreach(file ${VANITY_FILES}) configure_file("${CMAKE_SOURCE_DIR}/vanity/${file}" "${CMAKE_BINARY_DIR}/vanity/${file}" COPYONLY) diff --git a/dChatServer/ChatIgnoreList.cpp b/dChatServer/ChatIgnoreList.cpp index d77eeeed..f0c55eb0 100644 --- a/dChatServer/ChatIgnoreList.cpp +++ b/dChatServer/ChatIgnoreList.cpp @@ -59,7 +59,7 @@ void ChatIgnoreList::GetIgnoreList(Packet* packet) { bitStream.Write(LUWString(ignoredPlayer.playerName, 36)); } - Game::server->Send(&bitStream, packet->systemAddress, false); + Game::server->Send(bitStream, packet->systemAddress, false); } void ChatIgnoreList::AddIgnore(Packet* packet) { @@ -131,7 +131,7 @@ void ChatIgnoreList::AddIgnore(Packet* packet) { bitStream.Write(playerNameSend); bitStream.Write(ignoredPlayerId); - Game::server->Send(&bitStream, packet->systemAddress, false); + Game::server->Send(bitStream, packet->systemAddress, false); } void ChatIgnoreList::RemoveIgnore(Packet* packet) { @@ -167,5 +167,5 @@ void ChatIgnoreList::RemoveIgnore(Packet* packet) { LUWString playerNameSend(removedIgnoreStr, 33); bitStream.Write(playerNameSend); - Game::server->Send(&bitStream, packet->systemAddress, false); + Game::server->Send(bitStream, packet->systemAddress, false); } diff --git a/dChatServer/ChatServer.cpp b/dChatServer/ChatServer.cpp index 44957042..9ba70026 100644 --- a/dChatServer/ChatServer.cpp +++ b/dChatServer/ChatServer.cpp @@ -211,7 +211,7 @@ void HandlePacket(Packet* packet) { case eChatInternalMessageType::ANNOUNCEMENT: { //we just forward this packet to every connected server CINSTREAM; - Game::server->Send(&inStream, packet->systemAddress, true); //send to everyone except origin + Game::server->Send(inStream, packet->systemAddress, true); //send to everyone except origin break; } diff --git a/dChatServer/PlayerContainer.cpp b/dChatServer/PlayerContainer.cpp index dbbaeb9e..4e4d1be5 100644 --- a/dChatServer/PlayerContainer.cpp +++ b/dChatServer/PlayerContainer.cpp @@ -150,7 +150,7 @@ void PlayerContainer::BroadcastMuteUpdate(LWOOBJID player, time_t time) { bitStream.Write(player); bitStream.Write(time); - Game::server->Send(&bitStream, UNASSIGNED_SYSTEM_ADDRESS, true); + Game::server->Send(bitStream, UNASSIGNED_SYSTEM_ADDRESS, true); } TeamData* PlayerContainer::CreateLocalTeam(std::vector members) { @@ -365,7 +365,7 @@ void PlayerContainer::UpdateTeamsOnWorld(TeamData* team, bool deleteTeam) { } } - Game::server->Send(&bitStream, UNASSIGNED_SYSTEM_ADDRESS, true); + Game::server->Send(bitStream, UNASSIGNED_SYSTEM_ADDRESS, true); } std::u16string PlayerContainer::GetName(LWOOBJID playerID) { diff --git a/dCommon/AMFDeserialize.cpp b/dCommon/AMFDeserialize.cpp index 4675b31b..b551dbda 100644 --- a/dCommon/AMFDeserialize.cpp +++ b/dCommon/AMFDeserialize.cpp @@ -9,12 +9,11 @@ * AMF3 Deserializer written by EmosewaMC */ -std::unique_ptr AMFDeserialize::Read(RakNet::BitStream* inStream) { - if (!inStream) return nullptr; +std::unique_ptr AMFDeserialize::Read(RakNet::BitStream& inStream) { std::unique_ptr returnValue = nullptr; // Read in the value type from the bitStream eAmf marker; - inStream->Read(marker); + inStream.Read(marker); // Based on the typing, create the value associated with that and return the base value class switch (marker) { case eAmf::Undefined: { @@ -79,13 +78,13 @@ std::unique_ptr AMFDeserialize::Read(RakNet::BitStream* inStream) return returnValue; } -uint32_t AMFDeserialize::ReadU29(RakNet::BitStream* inStream) { +uint32_t AMFDeserialize::ReadU29(RakNet::BitStream& inStream) { bool byteFlag = true; uint32_t actualNumber{}; uint8_t numberOfBytesRead{}; while (byteFlag && numberOfBytesRead < 4) { uint8_t byte{}; - inStream->Read(byte); + inStream.Read(byte); // Parse the byte if (numberOfBytesRead < 3) { byteFlag = byte & static_cast(1 << 7); @@ -101,7 +100,7 @@ uint32_t AMFDeserialize::ReadU29(RakNet::BitStream* inStream) { return actualNumber; } -const std::string AMFDeserialize::ReadString(RakNet::BitStream* inStream) { +const std::string AMFDeserialize::ReadString(RakNet::BitStream& inStream) { auto length = ReadU29(inStream); // Check if this is a reference bool isReference = length % 2 == 1; @@ -109,7 +108,7 @@ const std::string AMFDeserialize::ReadString(RakNet::BitStream* inStream) { length = length >> 1; if (isReference) { std::string value(length, 0); - inStream->Read(&value[0], length); + inStream.Read(&value[0], length); // Empty strings are never sent by reference if (!value.empty()) accessedElements.push_back(value); return value; @@ -119,13 +118,13 @@ const std::string AMFDeserialize::ReadString(RakNet::BitStream* inStream) { } } -std::unique_ptr AMFDeserialize::ReadAmfDouble(RakNet::BitStream* inStream) { +std::unique_ptr AMFDeserialize::ReadAmfDouble(RakNet::BitStream& inStream) { double value; - inStream->Read(value); + inStream.Read(value); return std::make_unique(value); } -std::unique_ptr AMFDeserialize::ReadAmfArray(RakNet::BitStream* inStream) { +std::unique_ptr AMFDeserialize::ReadAmfArray(RakNet::BitStream& inStream) { auto arrayValue = std::make_unique(); // Read size of dense array @@ -144,10 +143,10 @@ std::unique_ptr AMFDeserialize::ReadAmfArray(RakNet::BitStream* i return arrayValue; } -std::unique_ptr AMFDeserialize::ReadAmfString(RakNet::BitStream* inStream) { +std::unique_ptr AMFDeserialize::ReadAmfString(RakNet::BitStream& inStream) { return std::make_unique(ReadString(inStream)); } -std::unique_ptr AMFDeserialize::ReadAmfInteger(RakNet::BitStream* inStream) { +std::unique_ptr AMFDeserialize::ReadAmfInteger(RakNet::BitStream& inStream) { return std::make_unique(ReadU29(inStream)); // NOTE: NARROWING CONVERSION FROM UINT TO INT. IS THIS INTENDED? } diff --git a/dCommon/AMFDeserialize.h b/dCommon/AMFDeserialize.h index 5971a961..dc8a21a8 100644 --- a/dCommon/AMFDeserialize.h +++ b/dCommon/AMFDeserialize.h @@ -15,7 +15,7 @@ public: * @param inStream inStream to read value from. * @return Returns an AMFValue with all the information from the bitStream in it. */ - std::unique_ptr Read(RakNet::BitStream* inStream); + std::unique_ptr Read(RakNet::BitStream& inStream); private: /** * @brief Private method to read a U29 integer from a bitstream @@ -23,7 +23,7 @@ private: * @param inStream bitstream to read data from * @return The number as an unsigned 29 bit integer */ - static uint32_t ReadU29(RakNet::BitStream* inStream); + static uint32_t ReadU29(RakNet::BitStream& inStream); /** * @brief Reads a string from a bitstream @@ -31,7 +31,7 @@ private: * @param inStream bitStream to read data from * @return The read string */ - const std::string ReadString(RakNet::BitStream* inStream); + const std::string ReadString(RakNet::BitStream& inStream); /** * @brief Read an AMFDouble value from a bitStream @@ -39,7 +39,7 @@ private: * @param inStream bitStream to read data from * @return Double value represented as an AMFValue */ - static std::unique_ptr ReadAmfDouble(RakNet::BitStream* inStream); + static std::unique_ptr ReadAmfDouble(RakNet::BitStream& inStream); /** * @brief Read an AMFArray from a bitStream @@ -47,7 +47,7 @@ private: * @param inStream bitStream to read data from * @return Array value represented as an AMFValue */ - std::unique_ptr ReadAmfArray(RakNet::BitStream* inStream); + std::unique_ptr ReadAmfArray(RakNet::BitStream& inStream); /** * @brief Read an AMFString from a bitStream @@ -55,7 +55,7 @@ private: * @param inStream bitStream to read data from * @return String value represented as an AMFValue */ - std::unique_ptr ReadAmfString(RakNet::BitStream* inStream); + std::unique_ptr ReadAmfString(RakNet::BitStream& inStream); /** * @brief Read an AMFInteger from a bitStream @@ -63,7 +63,7 @@ private: * @param inStream bitStream to read data from * @return Integer value represented as an AMFValue */ - static std::unique_ptr ReadAmfInteger(RakNet::BitStream* inStream); + static std::unique_ptr ReadAmfInteger(RakNet::BitStream& inStream); /** * List of strings read so far saved to be read by reference. diff --git a/dCommon/AmfSerialize.cpp b/dCommon/AmfSerialize.cpp index 3072b8e1..e11ae1de 100644 --- a/dCommon/AmfSerialize.cpp +++ b/dCommon/AmfSerialize.cpp @@ -53,7 +53,7 @@ void RakNet::BitStream::Write(AMFBaseValue& value) { * A private function to write an value to a RakNet::BitStream * RakNet writes in the correct byte order - do not reverse this. */ -void WriteUInt29(RakNet::BitStream* bs, uint32_t v) { +void WriteUInt29(RakNet::BitStream& bs, uint32_t v) { unsigned char b4 = static_cast(v); if (v < 0x00200000) { b4 = b4 & 0x7F; @@ -65,10 +65,10 @@ void WriteUInt29(RakNet::BitStream* bs, uint32_t v) { unsigned char b2; v = v >> 7; b2 = static_cast(v) | 0x80; - bs->Write(b2); + bs.Write(b2); } - bs->Write(b3); + bs.Write(b3); } } else { unsigned char b1; @@ -82,19 +82,19 @@ void WriteUInt29(RakNet::BitStream* bs, uint32_t v) { v = v >> 7; b1 = static_cast(v) | 0x80; - bs->Write(b1); - bs->Write(b2); - bs->Write(b3); + bs.Write(b1); + bs.Write(b2); + bs.Write(b3); } - bs->Write(b4); + bs.Write(b4); } /** * Writes a flag number to a RakNet::BitStream * RakNet writes in the correct byte order - do not reverse this. */ -void WriteFlagNumber(RakNet::BitStream* bs, uint32_t v) { +void WriteFlagNumber(RakNet::BitStream& bs, uint32_t v) { v = (v << 1) | 0x01; WriteUInt29(bs, v); } @@ -104,9 +104,9 @@ void WriteFlagNumber(RakNet::BitStream* bs, uint32_t v) { * * RakNet writes in the correct byte order - do not reverse this. */ -void WriteAMFString(RakNet::BitStream* bs, const std::string& str) { +void WriteAMFString(RakNet::BitStream& bs, const std::string& str) { WriteFlagNumber(bs, static_cast(str.size())); - bs->Write(str.c_str(), static_cast(str.size())); + bs.Write(str.c_str(), static_cast(str.size())); } /** @@ -114,8 +114,8 @@ void WriteAMFString(RakNet::BitStream* bs, const std::string& str) { * * RakNet writes in the correct byte order - do not reverse this. */ -void WriteAMFU16(RakNet::BitStream* bs, uint16_t value) { - bs->Write(value); +void WriteAMFU16(RakNet::BitStream& bs, uint16_t value) { + bs.Write(value); } /** @@ -123,8 +123,8 @@ void WriteAMFU16(RakNet::BitStream* bs, uint16_t value) { * * RakNet writes in the correct byte order - do not reverse this. */ -void WriteAMFU32(RakNet::BitStream* bs, uint32_t value) { - bs->Write(value); +void WriteAMFU32(RakNet::BitStream& bs, uint32_t value) { + bs.Write(value); } /** @@ -132,40 +132,40 @@ void WriteAMFU32(RakNet::BitStream* bs, uint32_t value) { * * RakNet writes in the correct byte order - do not reverse this. */ -void WriteAMFU64(RakNet::BitStream* bs, uint64_t value) { - bs->Write(value); +void WriteAMFU64(RakNet::BitStream& bs, uint64_t value) { + bs.Write(value); } // Writes an AMFIntegerValue to BitStream template<> void RakNet::BitStream::Write(AMFIntValue& value) { - WriteUInt29(this, value.GetValue()); + WriteUInt29(*this, value.GetValue()); } // Writes an AMFDoubleValue to BitStream template<> void RakNet::BitStream::Write(AMFDoubleValue& value) { double d = value.GetValue(); - WriteAMFU64(this, *reinterpret_cast(&d)); + WriteAMFU64(*this, *reinterpret_cast(&d)); } // Writes an AMFStringValue to BitStream template<> void RakNet::BitStream::Write(AMFStringValue& value) { - WriteAMFString(this, value.GetValue()); + WriteAMFString(*this, value.GetValue()); } // Writes an AMFArrayValue to BitStream template<> void RakNet::BitStream::Write(AMFArrayValue& value) { uint32_t denseSize = value.GetDense().size(); - WriteFlagNumber(this, denseSize); + WriteFlagNumber(*this, denseSize); auto it = value.GetAssociative().begin(); auto end = value.GetAssociative().end(); while (it != end) { - WriteAMFString(this, it->first); + WriteAMFString(*this, it->first); this->Write(*it->second); it++; } diff --git a/dCommon/GeneralUtils.cpp b/dCommon/GeneralUtils.cpp index 3e3e2f9c..27ebfb2c 100644 --- a/dCommon/GeneralUtils.cpp +++ b/dCommon/GeneralUtils.cpp @@ -278,14 +278,14 @@ std::vector GeneralUtils::SplitString(const std::string& str, char return vector; } -std::u16string GeneralUtils::ReadWString(RakNet::BitStream* inStream) { +std::u16string GeneralUtils::ReadWString(RakNet::BitStream& inStream) { uint32_t length; - inStream->Read(length); + inStream.Read(length); std::u16string string; for (auto i = 0; i < length; i++) { uint16_t c; - inStream->Read(c); + inStream.Read(c); string.push_back(c); } diff --git a/dCommon/GeneralUtils.h b/dCommon/GeneralUtils.h index f81f8a7f..cba3f3d5 100644 --- a/dCommon/GeneralUtils.h +++ b/dCommon/GeneralUtils.h @@ -116,7 +116,7 @@ namespace GeneralUtils { bool ReplaceInString(std::string& str, const std::string& from, const std::string& to); - std::u16string ReadWString(RakNet::BitStream* inStream); + std::u16string ReadWString(RakNet::BitStream& inStream); std::vector SplitString(std::wstring& str, wchar_t delimiter); diff --git a/dCommon/LDFFormat.h b/dCommon/LDFFormat.h index 3a4f2ea7..2cd9156c 100644 --- a/dCommon/LDFFormat.h +++ b/dCommon/LDFFormat.h @@ -31,7 +31,7 @@ public: virtual ~LDFBaseData() {} - virtual void WriteToPacket(RakNet::BitStream* packet) = 0; + virtual void WriteToPacket(RakNet::BitStream& packet) = 0; virtual const std::u16string& GetKey() = 0; @@ -62,17 +62,17 @@ private: T value; //! Writes the key to the packet - void WriteKey(RakNet::BitStream* packet) { - packet->Write(this->key.length() * sizeof(uint16_t)); + void WriteKey(RakNet::BitStream& packet) { + packet.Write(this->key.length() * sizeof(uint16_t)); for (uint32_t i = 0; i < this->key.length(); ++i) { - packet->Write(this->key[i]); + packet.Write(this->key[i]); } } //! Writes the value to the packet - void WriteValue(RakNet::BitStream* packet) { - packet->Write(this->GetValueType()); - packet->Write(this->value); + void WriteValue(RakNet::BitStream& packet) { + packet.Write(this->GetValueType()); + packet.Write(this->value); } public: @@ -108,7 +108,7 @@ public: /*! \param packet The packet */ - void WriteToPacket(RakNet::BitStream* packet) override { + void WriteToPacket(RakNet::BitStream& packet) override { this->WriteKey(packet); this->WriteValue(packet); } @@ -178,31 +178,31 @@ template<> inline eLDFType LDFData::GetValueType(void) { return LDF // The specialized version for std::u16string (UTF-16) template<> -inline void LDFData::WriteValue(RakNet::BitStream* packet) { - packet->Write(this->GetValueType()); +inline void LDFData::WriteValue(RakNet::BitStream& packet) { + packet.Write(this->GetValueType()); - packet->Write(this->value.length()); + packet.Write(this->value.length()); for (uint32_t i = 0; i < this->value.length(); ++i) { - packet->Write(this->value[i]); + packet.Write(this->value[i]); } } // The specialized version for bool template<> -inline void LDFData::WriteValue(RakNet::BitStream* packet) { - packet->Write(this->GetValueType()); +inline void LDFData::WriteValue(RakNet::BitStream& packet) { + packet.Write(this->GetValueType()); - packet->Write(this->value); + packet.Write(this->value); } // The specialized version for std::string (UTF-8) template<> -inline void LDFData::WriteValue(RakNet::BitStream* packet) { - packet->Write(this->GetValueType()); +inline void LDFData::WriteValue(RakNet::BitStream& packet) { + packet.Write(this->GetValueType()); - packet->Write(this->value.length()); + packet.Write(this->value.length()); for (uint32_t i = 0; i < this->value.length(); ++i) { - packet->Write(this->value[i]); + packet.Write(this->value[i]); } } diff --git a/dCommon/dEnums/dCommonVars.h b/dCommon/dEnums/dCommonVars.h index d871e267..7cdbfdb6 100644 --- a/dCommon/dEnums/dCommonVars.h +++ b/dCommon/dEnums/dCommonVars.h @@ -34,8 +34,8 @@ constexpr uint32_t lowFrameDelta = FRAMES_TO_MS(lowFramerate); #define CINSTREAM RakNet::BitStream inStream(packet->data, packet->length, false); #define CINSTREAM_SKIP_HEADER CINSTREAM if (inStream.GetNumberOfUnreadBits() >= BYTES_TO_BITS(HEADER_SIZE)) inStream.IgnoreBytes(HEADER_SIZE); else inStream.IgnoreBits(inStream.GetNumberOfUnreadBits()); #define CMSGHEADER BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::GAME_MSG); -#define SEND_PACKET Game::server->Send(&bitStream, sysAddr, false); -#define SEND_PACKET_BROADCAST Game::server->Send(&bitStream, UNASSIGNED_SYSTEM_ADDRESS, true); +#define SEND_PACKET Game::server->Send(bitStream, sysAddr, false); +#define SEND_PACKET_BROADCAST Game::server->Send(bitStream, UNASSIGNED_SYSTEM_ADDRESS, true); //=========== TYPEDEFS ========== diff --git a/dCommon/dEnums/eReplicaComponentType.h b/dCommon/dEnums/eReplicaComponentType.h index 83acbf89..2b991dfb 100644 --- a/dCommon/dEnums/eReplicaComponentType.h +++ b/dCommon/dEnums/eReplicaComponentType.h @@ -106,7 +106,7 @@ enum class eReplicaComponentType : uint32_t { INTERACTION_MANAGER, DONATION_VENDOR, COMBAT_MEDIATOR, - COMMENDATION_VENDOR, + ACHIEVEMENT_VENDOR, GATE_RUSH_CONTROL, RAIL_ACTIVATOR, ROLLER, diff --git a/dCommon/dEnums/eVendorTransactionResult.h b/dCommon/dEnums/eVendorTransactionResult.h new file mode 100644 index 00000000..e61ee0ee --- /dev/null +++ b/dCommon/dEnums/eVendorTransactionResult.h @@ -0,0 +1,15 @@ +#ifndef __EVENDORTRANSACTIONRESULT__ +#define __EVENDORTRANSACTIONRESULT__ + +#include + +enum class eVendorTransactionResult : uint32_t { + SELL_SUCCESS = 0, + SELL_FAIL, + PURCHASE_SUCCESS, + PURCHASE_FAIL, + DONATION_FAIL, + DONATION_FULL +}; + +#endif // !__EVENDORTRANSACTIONRESULT__ diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.cpp b/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.cpp index 8862b1db..97dcde9f 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.cpp +++ b/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.cpp @@ -79,7 +79,6 @@ void CDMissionsTable::LoadValuesFromDatabase() { entries.push_back(entry); tableData.nextRow(); } - tableData.finalize(); Default.id = -1; @@ -118,3 +117,12 @@ const CDMissions& CDMissionsTable::GetByMissionID(uint32_t missionID, bool& foun return Default; } +const std::set CDMissionsTable::GetMissionsForReward(LOT lot) { + std::set toReturn {}; + for (const auto& entry : GetEntries()) { + if (lot == entry.reward_item1 || lot == entry.reward_item2 || lot == entry.reward_item3 || lot == entry.reward_item4) { + toReturn.insert(entry.id); + } + } + return toReturn; +} diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.h b/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.h index 6ba7b19e..5067f2e2 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.h +++ b/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.h @@ -70,6 +70,9 @@ public: const CDMissions& GetByMissionID(uint32_t missionID, bool& found) const; + const std::set GetMissionsForReward(LOT lot); + + static CDMissions Default; }; diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 269b4cc4..55b2b85f 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -82,6 +82,7 @@ #include "CollectibleComponent.h" #include "ItemComponent.h" #include "GhostComponent.h" +#include "AchievementVendorComponent.h" // Table includes #include "CDComponentsRegistryTable.h" @@ -615,6 +616,8 @@ void Entity::Initialize() { AddComponent(); } else if ((compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::DONATION_VENDOR, -1) != -1)) { AddComponent(); + } else if ((compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::ACHIEVEMENT_VENDOR, -1) != -1)) { + AddComponent(); } if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROPERTY_VENDOR, -1) != -1) { @@ -896,34 +899,34 @@ void Entity::SetGMLevel(eGameMasterLevel value) { } } -void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacketType packetType) { +void Entity::WriteBaseReplicaData(RakNet::BitStream& outBitStream, eReplicaPacketType packetType) { if (packetType == eReplicaPacketType::CONSTRUCTION) { - outBitStream->Write(m_ObjectID); - outBitStream->Write(m_TemplateID); + outBitStream.Write(m_ObjectID); + outBitStream.Write(m_TemplateID); if (IsPlayer()) { std::string name = m_Character != nullptr ? m_Character->GetName() : "Invalid"; - outBitStream->Write(uint8_t(name.size())); + outBitStream.Write(uint8_t(name.size())); for (size_t i = 0; i < name.size(); ++i) { - outBitStream->Write(name[i]); + outBitStream.Write(name[i]); } } else { const auto& name = GetVar(u"npcName"); - outBitStream->Write(uint8_t(name.size())); + outBitStream.Write(uint8_t(name.size())); for (size_t i = 0; i < name.size(); ++i) { - outBitStream->Write(name[i]); + outBitStream.Write(name[i]); } } - outBitStream->Write(0); //Time since created on server + outBitStream.Write(0); //Time since created on server const auto& syncLDF = GetVar>(u"syncLDF"); // Only sync for models. if (m_Settings.size() > 0 && (GetComponent() && !GetComponent())) { - outBitStream->Write1(); //ldf data + outBitStream.Write1(); //ldf data RakNet::BitStream settingStream; int32_t numberOfValidKeys = m_Settings.size(); @@ -940,13 +943,13 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke for (LDFBaseData* data : m_Settings) { if (data && data->GetValueType() != eLDFType::LDF_TYPE_UNKNOWN) { - data->WriteToPacket(&settingStream); + data->WriteToPacket(settingStream); } } - outBitStream->Write(settingStream.GetNumberOfBytesUsed() + 1); - outBitStream->Write(0); //no compression used - outBitStream->Write(settingStream); + outBitStream.Write(settingStream.GetNumberOfBytesUsed() + 1); + outBitStream.Write(0); //no compression used + outBitStream.Write(settingStream); } else if (!syncLDF.empty()) { std::vector ldfData; @@ -954,79 +957,79 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke ldfData.push_back(GetVarData(data)); } - outBitStream->Write1(); //ldf data + outBitStream.Write1(); //ldf data RakNet::BitStream settingStream; settingStream.Write(ldfData.size()); for (LDFBaseData* data : ldfData) { if (data) { - data->WriteToPacket(&settingStream); + data->WriteToPacket(settingStream); } } - outBitStream->Write(settingStream.GetNumberOfBytesUsed() + 1); - outBitStream->Write(0); //no compression used - outBitStream->Write(settingStream); + outBitStream.Write(settingStream.GetNumberOfBytesUsed() + 1); + outBitStream.Write(0); //no compression used + outBitStream.Write(settingStream); } else { - outBitStream->Write0(); //No ldf data + outBitStream.Write0(); //No ldf data } TriggerComponent* triggerComponent; if (TryGetComponent(eReplicaComponentType::TRIGGER, triggerComponent)) { // has trigger component, check to see if we have events to handle auto* trigger = triggerComponent->GetTrigger(); - outBitStream->Write(trigger && trigger->events.size() > 0); + outBitStream.Write(trigger && trigger->events.size() > 0); } else { // no trigger componenet, so definitely no triggers - outBitStream->Write0(); + outBitStream.Write0(); } if (m_ParentEntity != nullptr || m_SpawnerID != 0) { - outBitStream->Write1(); - if (m_ParentEntity != nullptr) outBitStream->Write(GeneralUtils::SetBit(m_ParentEntity->GetObjectID(), static_cast(eObjectBits::CLIENT))); - else if (m_Spawner != nullptr && m_Spawner->m_Info.isNetwork) outBitStream->Write(m_SpawnerID); - else outBitStream->Write(GeneralUtils::SetBit(m_SpawnerID, static_cast(eObjectBits::CLIENT))); - } else outBitStream->Write0(); + outBitStream.Write1(); + if (m_ParentEntity != nullptr) outBitStream.Write(GeneralUtils::SetBit(m_ParentEntity->GetObjectID(), static_cast(eObjectBits::CLIENT))); + else if (m_Spawner != nullptr && m_Spawner->m_Info.isNetwork) outBitStream.Write(m_SpawnerID); + else outBitStream.Write(GeneralUtils::SetBit(m_SpawnerID, static_cast(eObjectBits::CLIENT))); + } else outBitStream.Write0(); - outBitStream->Write(m_HasSpawnerNodeID); - if (m_HasSpawnerNodeID) outBitStream->Write(m_SpawnerNodeID); + outBitStream.Write(m_HasSpawnerNodeID); + if (m_HasSpawnerNodeID) outBitStream.Write(m_SpawnerNodeID); - //outBitStream->Write0(); //Spawner node id + //outBitStream.Write0(); //Spawner node id - if (m_Scale == 1.0f || m_Scale == 0.0f) outBitStream->Write0(); + if (m_Scale == 1.0f || m_Scale == 0.0f) outBitStream.Write0(); else { - outBitStream->Write1(); - outBitStream->Write(m_Scale); + outBitStream.Write1(); + outBitStream.Write(m_Scale); } - outBitStream->Write0(); //ObjectWorldState + outBitStream.Write0(); //ObjectWorldState if (m_GMLevel != eGameMasterLevel::CIVILIAN) { - outBitStream->Write1(); - outBitStream->Write(m_GMLevel); - } else outBitStream->Write0(); //No GM Level + outBitStream.Write1(); + outBitStream.Write(m_GMLevel); + } else outBitStream.Write0(); //No GM Level } // Only serialize parent / child info should the info be dirty (changed) or if this is the construction of the entity. - outBitStream->Write(m_IsParentChildDirty || packetType == eReplicaPacketType::CONSTRUCTION); + outBitStream.Write(m_IsParentChildDirty || packetType == eReplicaPacketType::CONSTRUCTION); if (m_IsParentChildDirty || packetType == eReplicaPacketType::CONSTRUCTION) { m_IsParentChildDirty = false; - outBitStream->Write(m_ParentEntity != nullptr); + outBitStream.Write(m_ParentEntity != nullptr); if (m_ParentEntity) { - outBitStream->Write(m_ParentEntity->GetObjectID()); - outBitStream->Write0(); + outBitStream.Write(m_ParentEntity->GetObjectID()); + outBitStream.Write0(); } - outBitStream->Write(m_ChildEntities.size() > 0); + outBitStream.Write(m_ChildEntities.size() > 0); if (m_ChildEntities.size() > 0) { - outBitStream->Write(m_ChildEntities.size()); + outBitStream.Write(m_ChildEntities.size()); for (Entity* child : m_ChildEntities) { - outBitStream->Write(child->GetObjectID()); + outBitStream.Write(child->GetObjectID()); } } } } -void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType packetType) { +void Entity::WriteComponents(RakNet::BitStream& outBitStream, eReplicaPacketType packetType) { /** * This has to be done in a specific order. @@ -1114,7 +1117,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType possessorComponent->Serialize(outBitStream, bIsInitialUpdate); } else { // Should never happen, but just to be safe - outBitStream->Write0(); + outBitStream.Write0(); } LevelProgressionComponent* levelProgressionComponent; @@ -1122,7 +1125,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType levelProgressionComponent->Serialize(outBitStream, bIsInitialUpdate); } else { // Should never happen, but just to be safe - outBitStream->Write0(); + outBitStream.Write0(); } PlayerForcedMovementComponent* playerForcedMovementComponent; @@ -1130,7 +1133,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType playerForcedMovementComponent->Serialize(outBitStream, bIsInitialUpdate); } else { // Should never happen, but just to be safe - outBitStream->Write0(); + outBitStream.Write0(); } characterComponent->Serialize(outBitStream, bIsInitialUpdate); @@ -1191,6 +1194,11 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType donationVendorComponent->Serialize(outBitStream, bIsInitialUpdate); } + AchievementVendorComponent* achievementVendorComponent; + if (TryGetComponent(eReplicaComponentType::ACHIEVEMENT_VENDOR, achievementVendorComponent)) { + achievementVendorComponent->Serialize(outBitStream, bIsInitialUpdate); + } + BouncerComponent* bouncerComponent; if (TryGetComponent(eReplicaComponentType::BOUNCER, bouncerComponent)) { bouncerComponent->Serialize(outBitStream, bIsInitialUpdate); @@ -1242,7 +1250,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType // BBB Component, unused currently // Need to to write0 so that is serialized correctly // TODO: Implement BBB Component - outBitStream->Write0(); + outBitStream.Write0(); } void Entity::UpdateXMLDoc(tinyxml2::XMLDocument* doc) { @@ -2189,3 +2197,9 @@ void Entity::SetRespawnRot(const NiQuaternion& rotation) { auto* characterComponent = GetComponent(); if (characterComponent) characterComponent->SetRespawnRot(rotation); } + +void Entity::SetScale(const float scale) { + if (scale == m_Scale) return; + m_Scale = scale; + Game::entityManager->SerializeEntity(this); +} \ No newline at end of file diff --git a/dGame/Entity.h b/dGame/Entity.h index 6546e458..711e0b63 100644 --- a/dGame/Entity.h +++ b/dGame/Entity.h @@ -171,8 +171,8 @@ public: std::unordered_map& GetComponents() { return m_Components; } // TODO: Remove - void WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacketType packetType); - void WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType packetType); + void WriteBaseReplicaData(RakNet::BitStream& outBitStream, eReplicaPacketType packetType); + void WriteComponents(RakNet::BitStream& outBitStream, eReplicaPacketType packetType); void UpdateXMLDoc(tinyxml2::XMLDocument* doc); void Update(float deltaTime); @@ -295,6 +295,8 @@ public: void ProcessPositionUpdate(PositionUpdate& update); + void SetScale(const float scale); + protected: LWOOBJID m_ObjectID; diff --git a/dGame/EntityManager.cpp b/dGame/EntityManager.cpp index 9cd9df43..4d648bbd 100644 --- a/dGame/EntityManager.cpp +++ b/dGame/EntityManager.cpp @@ -178,18 +178,18 @@ void EntityManager::SerializeEntities() { stream.Write(ID_REPLICA_MANAGER_SERIALIZE); stream.Write(entity->GetNetworkId()); - entity->WriteBaseReplicaData(&stream, eReplicaPacketType::SERIALIZATION); - entity->WriteComponents(&stream, eReplicaPacketType::SERIALIZATION); + entity->WriteBaseReplicaData(stream, eReplicaPacketType::SERIALIZATION); + entity->WriteComponents(stream, eReplicaPacketType::SERIALIZATION); if (entity->GetIsGhostingCandidate()) { for (auto* player : PlayerManager::GetAllPlayers()) { auto* ghostComponent = player->GetComponent(); if (ghostComponent && ghostComponent->IsObserved(toSerialize)) { - Game::server->Send(&stream, player->GetSystemAddress(), false); + Game::server->Send(stream, player->GetSystemAddress(), false); } } } else { - Game::server->Send(&stream, UNASSIGNED_SYSTEM_ADDRESS, true); + Game::server->Send(stream, UNASSIGNED_SYSTEM_ADDRESS, true); } } m_EntitiesToSerialize.clear(); @@ -359,16 +359,16 @@ void EntityManager::ConstructEntity(Entity* entity, const SystemAddress& sysAddr stream.Write(true); stream.Write(entity->GetNetworkId()); - entity->WriteBaseReplicaData(&stream, eReplicaPacketType::CONSTRUCTION); - entity->WriteComponents(&stream, eReplicaPacketType::CONSTRUCTION); + entity->WriteBaseReplicaData(stream, eReplicaPacketType::CONSTRUCTION); + entity->WriteComponents(stream, eReplicaPacketType::CONSTRUCTION); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) { if (skipChecks) { - Game::server->Send(&stream, UNASSIGNED_SYSTEM_ADDRESS, true); + Game::server->Send(stream, UNASSIGNED_SYSTEM_ADDRESS, true); } else { for (auto* player : PlayerManager::GetAllPlayers()) { if (player->GetPlayerReadyForUpdates()) { - Game::server->Send(&stream, player->GetSystemAddress(), false); + Game::server->Send(stream, player->GetSystemAddress(), false); } else { auto* ghostComponent = player->GetComponent(); if (ghostComponent) ghostComponent->AddLimboConstruction(entity->GetObjectID()); @@ -376,7 +376,7 @@ void EntityManager::ConstructEntity(Entity* entity, const SystemAddress& sysAddr } } } else { - Game::server->Send(&stream, sysAddr, false); + Game::server->Send(stream, sysAddr, false); } if (entity->IsPlayer()) { @@ -407,7 +407,7 @@ void EntityManager::DestructEntity(Entity* entity, const SystemAddress& sysAddr) stream.Write(ID_REPLICA_MANAGER_DESTRUCTION); stream.Write(entity->GetNetworkId()); - Game::server->Send(&stream, sysAddr, sysAddr == UNASSIGNED_SYSTEM_ADDRESS); + Game::server->Send(stream, sysAddr, sysAddr == UNASSIGNED_SYSTEM_ADDRESS); for (auto* player : PlayerManager::GetAllPlayers()) { if (!player->GetPlayerReadyForUpdates()) { diff --git a/dGame/LeaderboardManager.cpp b/dGame/LeaderboardManager.cpp index ba9055a7..347bd68e 100644 --- a/dGame/LeaderboardManager.cpp +++ b/dGame/LeaderboardManager.cpp @@ -43,9 +43,9 @@ inline void WriteLeaderboardRow(std::ostringstream& leaderboard, const uint32_t& leaderboard << "\nResult[0].Row[" << index << "]." << data->GetString(); } -void Leaderboard::Serialize(RakNet::BitStream* bitStream) const { - bitStream->Write(gameID); - bitStream->Write(infoType); +void Leaderboard::Serialize(RakNet::BitStream& bitStream) const { + bitStream.Write(gameID); + bitStream.Write(infoType); std::ostringstream leaderboard; @@ -64,12 +64,12 @@ void Leaderboard::Serialize(RakNet::BitStream* bitStream) const { // Serialize the thing to a BitStream uint32_t leaderboardSize = leaderboard.tellp(); - bitStream->Write(leaderboardSize); + bitStream.Write(leaderboardSize); // Doing this all in 1 call so there is no possbility of a dangling pointer. - bitStream->WriteAlignedBytes(reinterpret_cast(GeneralUtils::ASCIIToUTF16(leaderboard.str()).c_str()), leaderboardSize * sizeof(char16_t)); - if (leaderboardSize > 0) bitStream->Write(0); - bitStream->Write0(); - bitStream->Write0(); + bitStream.WriteAlignedBytes(reinterpret_cast(GeneralUtils::ASCIIToUTF16(leaderboard.str()).c_str()), leaderboardSize * sizeof(char16_t)); + if (leaderboardSize > 0) bitStream.Write(0); + bitStream.Write0(); + bitStream.Write0(); } void Leaderboard::QueryToLdf(std::unique_ptr& rows) { diff --git a/dGame/LeaderboardManager.h b/dGame/LeaderboardManager.h index 89537ba0..527ae02d 100644 --- a/dGame/LeaderboardManager.h +++ b/dGame/LeaderboardManager.h @@ -88,7 +88,7 @@ public: * * Expensive! Leaderboards are very string intensive so be wary of performatnce calling this method. */ - void Serialize(RakNet::BitStream* bitStream) const; + void Serialize(RakNet::BitStream& bitStream) const; /** * Builds the leaderboard from the database based on the associated gameID diff --git a/dGame/dBehaviors/AirMovementBehavior.cpp b/dGame/dBehaviors/AirMovementBehavior.cpp index 8a3f894c..46d18680 100644 --- a/dGame/dBehaviors/AirMovementBehavior.cpp +++ b/dGame/dBehaviors/AirMovementBehavior.cpp @@ -5,35 +5,35 @@ #include "Game.h" #include "Logger.h" -void AirMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void AirMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { uint32_t handle{}; - if (!bitStream->Read(handle)) { - LOG("Unable to read handle from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(handle)) { + LOG("Unable to read handle from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; } context->RegisterSyncBehavior(handle, this, branch, this->m_Timeout); } -void AirMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void AirMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { const auto handle = context->GetUniqueSkillId(); - bitStream->Write(handle); + bitStream.Write(handle); } -void AirMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void AirMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { uint32_t behaviorId{}; - if (!bitStream->Read(behaviorId)) { - LOG("Unable to read behaviorId from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(behaviorId)) { + LOG("Unable to read behaviorId from bitStream, aborting Sync! %i", bitStream.GetNumberOfUnreadBits()); return; } LWOOBJID target{}; - if (!bitStream->Read(target)) { - LOG("Unable to read target from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(target)) { + LOG("Unable to read target from bitStream, aborting Sync! %i", bitStream.GetNumberOfUnreadBits()); return; } diff --git a/dGame/dBehaviors/AirMovementBehavior.h b/dGame/dBehaviors/AirMovementBehavior.h index 9d51ef03..0edb1a76 100644 --- a/dGame/dBehaviors/AirMovementBehavior.h +++ b/dGame/dBehaviors/AirMovementBehavior.h @@ -6,11 +6,11 @@ class AirMovementBehavior final : public Behavior public: explicit AirMovementBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {} - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; private: diff --git a/dGame/dBehaviors/AndBehavior.cpp b/dGame/dBehaviors/AndBehavior.cpp index 57493248..ad986e37 100644 --- a/dGame/dBehaviors/AndBehavior.cpp +++ b/dGame/dBehaviors/AndBehavior.cpp @@ -3,13 +3,13 @@ #include "Game.h" #include "Logger.h" -void AndBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void AndBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { for (auto* behavior : this->m_behaviors) { behavior->Handle(context, bitStream, branch); } } -void AndBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void AndBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { for (auto* behavior : this->m_behaviors) { behavior->Calculate(context, bitStream, branch); } diff --git a/dGame/dBehaviors/AndBehavior.h b/dGame/dBehaviors/AndBehavior.h index 0ef7c0fd..76bd3956 100644 --- a/dGame/dBehaviors/AndBehavior.h +++ b/dGame/dBehaviors/AndBehavior.h @@ -15,9 +15,9 @@ public: explicit AndBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; diff --git a/dGame/dBehaviors/ApplyBuffBehavior.cpp b/dGame/dBehaviors/ApplyBuffBehavior.cpp index 26b3da84..9ee48375 100644 --- a/dGame/dBehaviors/ApplyBuffBehavior.cpp +++ b/dGame/dBehaviors/ApplyBuffBehavior.cpp @@ -5,7 +5,7 @@ #include "BuffComponent.h" -void ApplyBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ApplyBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* entity = Game::entityManager->GetEntity(branch.target == LWOOBJID_EMPTY ? context->originator : branch.target); if (entity == nullptr) return; @@ -30,7 +30,7 @@ void ApplyBuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext b buffComponent->RemoveBuff(m_BuffId); } -void ApplyBuffBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ApplyBuffBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/ApplyBuffBehavior.h b/dGame/dBehaviors/ApplyBuffBehavior.h index e01a238e..4acc6550 100644 --- a/dGame/dBehaviors/ApplyBuffBehavior.h +++ b/dGame/dBehaviors/ApplyBuffBehavior.h @@ -24,11 +24,11 @@ public: explicit ApplyBuffBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; private: diff --git a/dGame/dBehaviors/AreaOfEffectBehavior.cpp b/dGame/dBehaviors/AreaOfEffectBehavior.cpp index 2a7e9754..ce41785f 100644 --- a/dGame/dBehaviors/AreaOfEffectBehavior.cpp +++ b/dGame/dBehaviors/AreaOfEffectBehavior.cpp @@ -12,11 +12,11 @@ #include "Game.h" #include "Logger.h" -void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { uint32_t targetCount{}; - if (!bitStream->Read(targetCount)) { - LOG("Unable to read targetCount from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(targetCount)) { + LOG("Unable to read targetCount from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; } @@ -40,7 +40,7 @@ void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* b for (auto i = 0u; i < targetCount; ++i) { LWOOBJID target{}; - if (!bitStream->Read(target)) { + if (!bitStream.Read(target)) { LOG("failed to read in target %i from bitStream, aborting target Handle!", i); }; targets.push_back(target); @@ -54,7 +54,7 @@ void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* b PlayFx(u"cast", context->originator); } -void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* caster = Game::entityManager->GetEntity(context->caster); if (!caster) return; @@ -83,7 +83,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream // resize if we have more than max targets allows if (targets.size() > this->m_maxTargets) targets.resize(this->m_maxTargets); - bitStream->Write(targets.size()); + bitStream.Write(targets.size()); if (targets.size() == 0) { PlayFx(u"miss", context->originator); @@ -92,7 +92,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream context->foundTarget = true; // write all the targets to the bitstream for (auto* target : targets) { - bitStream->Write(target->GetObjectID()); + bitStream.Write(target->GetObjectID()); } // then cast all the actions diff --git a/dGame/dBehaviors/AreaOfEffectBehavior.h b/dGame/dBehaviors/AreaOfEffectBehavior.h index f0fbb18d..5ce20003 100644 --- a/dGame/dBehaviors/AreaOfEffectBehavior.h +++ b/dGame/dBehaviors/AreaOfEffectBehavior.h @@ -6,8 +6,8 @@ class AreaOfEffectBehavior final : public Behavior { public: explicit AreaOfEffectBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {} - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; private: Behavior* m_action; diff --git a/dGame/dBehaviors/AttackDelayBehavior.cpp b/dGame/dBehaviors/AttackDelayBehavior.cpp index 1bf1048a..105a1327 100644 --- a/dGame/dBehaviors/AttackDelayBehavior.cpp +++ b/dGame/dBehaviors/AttackDelayBehavior.cpp @@ -4,11 +4,11 @@ #include "Game.h" #include "Logger.h" -void AttackDelayBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void AttackDelayBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { uint32_t handle{}; - if (!bitStream->Read(handle)) { - LOG("Unable to read handle from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(handle)) { + LOG("Unable to read handle from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -17,10 +17,10 @@ void AttackDelayBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi } } -void AttackDelayBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void AttackDelayBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { const auto handle = context->GetUniqueSkillId(); - bitStream->Write(handle); + bitStream.Write(handle); context->foundTarget = true; @@ -31,11 +31,11 @@ void AttackDelayBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* } } -void AttackDelayBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void AttackDelayBehavior::Sync(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { this->m_action->Handle(context, bitStream, branch); } -void AttackDelayBehavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void AttackDelayBehavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { PlayFx(u"cast", context->originator); this->m_action->Calculate(context, bitStream, branch); diff --git a/dGame/dBehaviors/AttackDelayBehavior.h b/dGame/dBehaviors/AttackDelayBehavior.h index 64271ba5..173b0a0d 100644 --- a/dGame/dBehaviors/AttackDelayBehavior.h +++ b/dGame/dBehaviors/AttackDelayBehavior.h @@ -19,13 +19,13 @@ public: explicit AttackDelayBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void SyncCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/BasicAttackBehavior.cpp b/dGame/dBehaviors/BasicAttackBehavior.cpp index 914e67a5..3d45d9a7 100644 --- a/dGame/dBehaviors/BasicAttackBehavior.cpp +++ b/dGame/dBehaviors/BasicAttackBehavior.cpp @@ -9,7 +9,7 @@ #include "BehaviorContext.h" #include "eBasicAttackSuccessTypes.h" -void BasicAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void BasicAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { if (context->unmanaged) { auto* entity = Game::entityManager->GetEntity(branch.target); @@ -30,22 +30,22 @@ void BasicAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi return; } - bitStream->AlignReadToByteBoundary(); + bitStream.AlignReadToByteBoundary(); uint16_t allocatedBits{}; - if (!bitStream->Read(allocatedBits) || allocatedBits == 0) { + if (!bitStream.Read(allocatedBits) || allocatedBits == 0) { LOG_DEBUG("No allocated bits"); return; } LOG_DEBUG("Number of allocated bits %i", allocatedBits); - const auto baseAddress = bitStream->GetReadOffset(); + const auto baseAddress = bitStream.GetReadOffset(); DoHandleBehavior(context, bitStream, branch); - bitStream->SetReadOffset(baseAddress + allocatedBits); + bitStream.SetReadOffset(baseAddress + allocatedBits); } -void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* targetEntity = Game::entityManager->GetEntity(branch.target); if (!targetEntity) { LOG("Target targetEntity %llu not found.", branch.target); @@ -62,7 +62,7 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit bool isImmune{}; bool isSuccess{}; - if (!bitStream->Read(isBlocked)) { + if (!bitStream.Read(isBlocked)) { LOG("Unable to read isBlocked"); return; } @@ -74,7 +74,7 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit return; } - if (!bitStream->Read(isImmune)) { + if (!bitStream.Read(isImmune)) { LOG("Unable to read isImmune"); return; } @@ -85,20 +85,20 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit return; } - if (!bitStream->Read(isSuccess)) { + if (!bitStream.Read(isSuccess)) { LOG("failed to read success from bitstream"); return; } if (isSuccess) { uint32_t armorDamageDealt{}; - if (!bitStream->Read(armorDamageDealt)) { + if (!bitStream.Read(armorDamageDealt)) { LOG("Unable to read armorDamageDealt"); return; } uint32_t healthDamageDealt{}; - if (!bitStream->Read(healthDamageDealt)) { + if (!bitStream.Read(healthDamageDealt)) { LOG("Unable to read healthDamageDealt"); return; } @@ -111,7 +111,7 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit } bool died{}; - if (!bitStream->Read(died)) { + if (!bitStream.Read(died)) { LOG("Unable to read died"); return; } @@ -122,7 +122,7 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit } uint8_t successState{}; - if (!bitStream->Read(successState)) { + if (!bitStream.Read(successState)) { LOG("Unable to read success state"); return; } @@ -144,26 +144,26 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit } } -void BasicAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { - bitStream->AlignWriteToByteBoundary(); +void BasicAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { + bitStream.AlignWriteToByteBoundary(); - const auto allocatedAddress = bitStream->GetWriteOffset(); + const auto allocatedAddress = bitStream.GetWriteOffset(); - bitStream->Write(0); + bitStream.Write(0); - const auto startAddress = bitStream->GetWriteOffset(); + const auto startAddress = bitStream.GetWriteOffset(); DoBehaviorCalculation(context, bitStream, branch); - const auto endAddress = bitStream->GetWriteOffset(); + const auto endAddress = bitStream.GetWriteOffset(); const uint16_t allocate = endAddress - startAddress; - bitStream->SetWriteOffset(allocatedAddress); - bitStream->Write(allocate); - bitStream->SetWriteOffset(startAddress + allocate); + bitStream.SetWriteOffset(allocatedAddress); + bitStream.Write(allocate); + bitStream.SetWriteOffset(startAddress + allocate); } -void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* targetEntity = Game::entityManager->GetEntity(branch.target); if (!targetEntity) { LOG("Target entity %llu is null!", branch.target); @@ -178,7 +178,7 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet const bool isBlocking = destroyableComponent->GetAttacksToBlock() > 0; - bitStream->Write(isBlocking); + bitStream.Write(isBlocking); if (isBlocking) { destroyableComponent->SetAttacksToBlock(destroyableComponent->GetAttacksToBlock() - 1); @@ -188,7 +188,7 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet } const bool isImmune = destroyableComponent->IsImmune() || destroyableComponent->IsCooldownImmune(); - bitStream->Write(isImmune); + bitStream.Write(isImmune); if (isImmune) { LOG_DEBUG("Target targetEntity %llu is immune!", branch.target); @@ -210,7 +210,7 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet const uint32_t healthDamageDealt = previousHealth - destroyableComponent->GetHealth(); isSuccess = armorDamageDealt > 0 || healthDamageDealt > 0 || (armorDamageDealt + healthDamageDealt) > 0; - bitStream->Write(isSuccess); + bitStream.Write(isSuccess); //Handle player damage cooldown if (isSuccess && targetEntity->IsPlayer() && !this->m_DontApplyImmune) { @@ -225,12 +225,12 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet successState = this->m_OnFailArmor->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY ? eBasicAttackSuccessTypes::FAILIMMUNE : eBasicAttackSuccessTypes::FAILARMOR; } - bitStream->Write(armorDamageDealt); - bitStream->Write(healthDamageDealt); - bitStream->Write(targetEntity->GetIsDead()); + bitStream.Write(armorDamageDealt); + bitStream.Write(healthDamageDealt); + bitStream.Write(targetEntity->GetIsDead()); } - bitStream->Write(successState); + bitStream.Write(successState); switch (static_cast(successState)) { case eBasicAttackSuccessTypes::SUCCESS: diff --git a/dGame/dBehaviors/BasicAttackBehavior.h b/dGame/dBehaviors/BasicAttackBehavior.h index 6525c343..3cde23fd 100644 --- a/dGame/dBehaviors/BasicAttackBehavior.h +++ b/dGame/dBehaviors/BasicAttackBehavior.h @@ -12,7 +12,7 @@ public: * is then offset to after the allocated bits for this stream. * */ - void DoHandleBehavior(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch); + void DoHandleBehavior(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch); /** * @brief Handles a client initialized Basic Attack Behavior cast to be deserialized and verified on the server. @@ -22,14 +22,14 @@ public: * and will fail gracefully if an overread is detected. * @param branch The context of this specific branch of the Skill Behavior. Changes based on which branch you are going down. */ - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; /** * @brief Writes a 16bit short to the bitStream and when the actual behavior calculation finishes with all of its branches, the number * of bits used is then written to where the 16bit short initially was. * */ - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; /** * @brief Calculates a server initialized Basic Attack Behavior cast to be serialized to the client @@ -38,7 +38,7 @@ public: * @param bitStream The bitStream to serialize to. * @param branch The context of this specific branch of the Skill Behavior. Changes based on which branch you are going down. */ - void DoBehaviorCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch); + void DoBehaviorCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch); /** * @brief Loads this Behaviors parameters from the database. For this behavior specifically: diff --git a/dGame/dBehaviors/Behavior.cpp b/dGame/dBehaviors/Behavior.cpp index 64bb03f5..36607a66 100644 --- a/dGame/dBehaviors/Behavior.cpp +++ b/dGame/dBehaviors/Behavior.cpp @@ -487,10 +487,10 @@ std::map Behavior::GetParameterNames() const { void Behavior::Load() { } -void Behavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void Behavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { } -void Behavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void Behavior::Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { } void Behavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) { @@ -502,10 +502,10 @@ void Behavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWO void Behavior::End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) { } -void Behavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void Behavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { } -void Behavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void Behavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { } Behavior::~Behavior() { diff --git a/dGame/dBehaviors/Behavior.h b/dGame/dBehaviors/Behavior.h index ca1c23e5..af7fd206 100644 --- a/dGame/dBehaviors/Behavior.h +++ b/dGame/dBehaviors/Behavior.h @@ -68,9 +68,9 @@ public: virtual void Load(); // Player side - virtual void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch); + virtual void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch); - virtual void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch); + virtual void Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch); virtual void UnCast(BehaviorContext* context, BehaviorBranchContext branch); @@ -79,9 +79,9 @@ public: virtual void End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second); // Npc side - virtual void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch); + virtual void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch); - virtual void SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch); + virtual void SyncCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch); /* * Creations/destruction diff --git a/dGame/dBehaviors/BehaviorContext.cpp b/dGame/dBehaviors/BehaviorContext.cpp index e4f3011c..5ca335b1 100644 --- a/dGame/dBehaviors/BehaviorContext.cpp +++ b/dGame/dBehaviors/BehaviorContext.cpp @@ -105,7 +105,7 @@ void BehaviorContext::ExecuteUpdates() { this->scheduledUpdates.clear(); } -void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream* bitStream) { +void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream& bitStream) { BehaviorSyncEntry entry; auto found = false; @@ -243,27 +243,25 @@ bool BehaviorContext::CalculateUpdate(const float deltaTime) { echo.uiBehaviorHandle = entry.handle; echo.uiSkillHandle = this->skillUId; - auto* bitStream = new RakNet::BitStream(); + RakNet::BitStream bitStream{}; // Calculate sync entry.behavior->SyncCalculation(this, bitStream, entry.branchContext); if (!clientInitalized) { - echo.sBitStream.assign(reinterpret_cast(bitStream->GetData()), bitStream->GetNumberOfBytesUsed()); + echo.sBitStream.assign(reinterpret_cast(bitStream.GetData()), bitStream.GetNumberOfBytesUsed()); // Write message RakNet::BitStream message; BitStreamUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG); message.Write(this->originator); - echo.Serialize(&message); + echo.Serialize(message); - Game::server->Send(&message, UNASSIGNED_SYSTEM_ADDRESS, true); + Game::server->Send(message, UNASSIGNED_SYSTEM_ADDRESS, true); } ExecuteUpdates(); - - delete bitStream; } std::vector valid; diff --git a/dGame/dBehaviors/BehaviorContext.h b/dGame/dBehaviors/BehaviorContext.h index 333dc9a8..3e6c0b1d 100644 --- a/dGame/dBehaviors/BehaviorContext.h +++ b/dGame/dBehaviors/BehaviorContext.h @@ -93,7 +93,7 @@ struct BehaviorContext void ExecuteUpdates(); - void SyncBehavior(uint32_t syncId, RakNet::BitStream* bitStream); + void SyncBehavior(uint32_t syncId, RakNet::BitStream& bitStream); void Update(float deltaTime); diff --git a/dGame/dBehaviors/BlockBehavior.cpp b/dGame/dBehaviors/BlockBehavior.cpp index 88c6bb0b..0d3e164b 100644 --- a/dGame/dBehaviors/BlockBehavior.cpp +++ b/dGame/dBehaviors/BlockBehavior.cpp @@ -7,7 +7,7 @@ #include "Logger.h" #include "DestroyableComponent.h" -void BlockBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void BlockBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { const auto target = context->originator; auto* entity = Game::entityManager->GetEntity(target); @@ -33,7 +33,7 @@ void BlockBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea } } -void BlockBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void BlockBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/BlockBehavior.h b/dGame/dBehaviors/BlockBehavior.h index e0d639ed..9f4d696d 100644 --- a/dGame/dBehaviors/BlockBehavior.h +++ b/dGame/dBehaviors/BlockBehavior.h @@ -13,9 +13,9 @@ public: explicit BlockBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; diff --git a/dGame/dBehaviors/BuffBehavior.cpp b/dGame/dBehaviors/BuffBehavior.cpp index 7ac8b352..e20bf820 100644 --- a/dGame/dBehaviors/BuffBehavior.cpp +++ b/dGame/dBehaviors/BuffBehavior.cpp @@ -7,7 +7,7 @@ #include "Logger.h" #include "DestroyableComponent.h" -void BuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void BuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { const auto target = branch.target != LWOOBJID_EMPTY ? branch.target : context->originator; auto* entity = Game::entityManager->GetEntity(target); diff --git a/dGame/dBehaviors/BuffBehavior.h b/dGame/dBehaviors/BuffBehavior.h index b7c805b3..d057758a 100644 --- a/dGame/dBehaviors/BuffBehavior.h +++ b/dGame/dBehaviors/BuffBehavior.h @@ -16,7 +16,7 @@ public: explicit BuffBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; diff --git a/dGame/dBehaviors/CarBoostBehavior.cpp b/dGame/dBehaviors/CarBoostBehavior.cpp index eb22cb09..fdbcba71 100644 --- a/dGame/dBehaviors/CarBoostBehavior.cpp +++ b/dGame/dBehaviors/CarBoostBehavior.cpp @@ -8,7 +8,7 @@ #include "Logger.h" #include "PossessableComponent.h" -void CarBoostBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void CarBoostBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { GameMessages::SendVehicleAddPassiveBoostAction(branch.target, UNASSIGNED_SYSTEM_ADDRESS); auto* entity = Game::entityManager->GetEntity(context->originator); diff --git a/dGame/dBehaviors/CarBoostBehavior.h b/dGame/dBehaviors/CarBoostBehavior.h index 3f4265b9..5e629421 100644 --- a/dGame/dBehaviors/CarBoostBehavior.h +++ b/dGame/dBehaviors/CarBoostBehavior.h @@ -17,7 +17,7 @@ public: explicit CarBoostBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/ChainBehavior.cpp b/dGame/dBehaviors/ChainBehavior.cpp index 4a20c151..feb27988 100644 --- a/dGame/dBehaviors/ChainBehavior.cpp +++ b/dGame/dBehaviors/ChainBehavior.cpp @@ -3,11 +3,11 @@ #include "Game.h" #include "Logger.h" -void ChainBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void ChainBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { uint32_t chainIndex{}; - if (!bitStream->Read(chainIndex)) { - LOG("Unable to read chainIndex from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(chainIndex)) { + LOG("Unable to read chainIndex from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; } @@ -16,12 +16,12 @@ void ChainBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea if (chainIndex < this->m_behaviors.size()) { this->m_behaviors.at(chainIndex)->Handle(context, bitStream, branch); } else { - LOG("chainIndex out of bounds, aborting handle of chain %i bits unread %i", chainIndex, bitStream->GetNumberOfUnreadBits()); + LOG("chainIndex out of bounds, aborting handle of chain %i bits unread %i", chainIndex, bitStream.GetNumberOfUnreadBits()); } } -void ChainBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { - bitStream->Write(1); +void ChainBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { + bitStream.Write(1); this->m_behaviors.at(0)->Calculate(context, bitStream, branch); } diff --git a/dGame/dBehaviors/ChainBehavior.h b/dGame/dBehaviors/ChainBehavior.h index c31d5358..174326df 100644 --- a/dGame/dBehaviors/ChainBehavior.h +++ b/dGame/dBehaviors/ChainBehavior.h @@ -16,9 +16,9 @@ public: explicit ChainBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/ChangeIdleFlagsBehavior.cpp b/dGame/dBehaviors/ChangeIdleFlagsBehavior.cpp index 06a79fa7..b7c6b80a 100644 --- a/dGame/dBehaviors/ChangeIdleFlagsBehavior.cpp +++ b/dGame/dBehaviors/ChangeIdleFlagsBehavior.cpp @@ -3,7 +3,7 @@ #include "BehaviorContext.h" #include "BehaviorBranchContext.h" -void ChangeIdleFlagsBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ChangeIdleFlagsBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { const auto target = branch.target != LWOOBJID_EMPTY ? branch.target : context->originator; if (!target) return; @@ -16,7 +16,7 @@ void ChangeIdleFlagsBehavior::Handle(BehaviorContext* context, RakNet::BitStream } } -void ChangeIdleFlagsBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ChangeIdleFlagsBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/ChangeIdleFlagsBehavior.h b/dGame/dBehaviors/ChangeIdleFlagsBehavior.h index 91f802f4..e40af3cc 100644 --- a/dGame/dBehaviors/ChangeIdleFlagsBehavior.h +++ b/dGame/dBehaviors/ChangeIdleFlagsBehavior.h @@ -11,8 +11,8 @@ public: */ explicit ChangeIdleFlagsBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {} - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override; void End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override; void Load() override; diff --git a/dGame/dBehaviors/ChangeOrientationBehavior.cpp b/dGame/dBehaviors/ChangeOrientationBehavior.cpp index 445c76df..f8a34fb8 100644 --- a/dGame/dBehaviors/ChangeOrientationBehavior.cpp +++ b/dGame/dBehaviors/ChangeOrientationBehavior.cpp @@ -3,7 +3,7 @@ #include "BehaviorContext.h" #include "EntityManager.h" -void ChangeOrientationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ChangeOrientationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Entity* sourceEntity; if (this->m_orientCaster) sourceEntity = Game::entityManager->GetEntity(context->originator); else sourceEntity = Game::entityManager->GetEntity(branch.target); diff --git a/dGame/dBehaviors/ChangeOrientationBehavior.h b/dGame/dBehaviors/ChangeOrientationBehavior.h index 22c92bb8..62c47d5c 100644 --- a/dGame/dBehaviors/ChangeOrientationBehavior.h +++ b/dGame/dBehaviors/ChangeOrientationBehavior.h @@ -5,7 +5,7 @@ class ChangeOrientationBehavior final : public Behavior { public: explicit ChangeOrientationBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {} - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; private: bool m_orientCaster; diff --git a/dGame/dBehaviors/ChargeUpBehavior.cpp b/dGame/dBehaviors/ChargeUpBehavior.cpp index cf737e19..dd6293db 100644 --- a/dGame/dBehaviors/ChargeUpBehavior.cpp +++ b/dGame/dBehaviors/ChargeUpBehavior.cpp @@ -4,10 +4,10 @@ #include "Game.h" #include "Logger.h" -void ChargeUpBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void ChargeUpBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { uint32_t handle{}; - if (!bitStream->Read(handle)) { + if (!bitStream.Read(handle)) { LOG("Unable to read handle from bitStream, aborting Handle! variable_type"); return; }; @@ -15,10 +15,10 @@ void ChargeUpBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt context->RegisterSyncBehavior(handle, this, branch, this->m_MaxDuration); } -void ChargeUpBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ChargeUpBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { } -void ChargeUpBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void ChargeUpBehavior::Sync(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { this->m_action->Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/ChargeUpBehavior.h b/dGame/dBehaviors/ChargeUpBehavior.h index ceb40f6c..2ded1eb6 100644 --- a/dGame/dBehaviors/ChargeUpBehavior.h +++ b/dGame/dBehaviors/ChargeUpBehavior.h @@ -6,11 +6,11 @@ class ChargeUpBehavior final : public Behavior public: explicit ChargeUpBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {} - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; private: diff --git a/dGame/dBehaviors/ClearTargetBehavior.cpp b/dGame/dBehaviors/ClearTargetBehavior.cpp index ec0c0db6..40ae9b01 100644 --- a/dGame/dBehaviors/ClearTargetBehavior.cpp +++ b/dGame/dBehaviors/ClearTargetBehavior.cpp @@ -3,13 +3,13 @@ #include "BehaviorContext.h" -void ClearTargetBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ClearTargetBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { branch.target = LWOOBJID_EMPTY; this->m_action->Handle(context, bitStream, branch); } -void ClearTargetBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ClearTargetBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { branch.target = LWOOBJID_EMPTY; this->m_action->Calculate(context, bitStream, branch); diff --git a/dGame/dBehaviors/ClearTargetBehavior.h b/dGame/dBehaviors/ClearTargetBehavior.h index 0ed57fb4..d950c8f5 100644 --- a/dGame/dBehaviors/ClearTargetBehavior.h +++ b/dGame/dBehaviors/ClearTargetBehavior.h @@ -14,9 +14,9 @@ public: explicit ClearTargetBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/ConsumeItemBehavior.cpp b/dGame/dBehaviors/ConsumeItemBehavior.cpp index c3b76fcb..440a641b 100644 --- a/dGame/dBehaviors/ConsumeItemBehavior.cpp +++ b/dGame/dBehaviors/ConsumeItemBehavior.cpp @@ -3,7 +3,7 @@ #include "BehaviorBranchContext.h" #include "InventoryComponent.h" -void ConsumeItemBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ConsumeItemBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto action_to_cast = m_ActionNotConsumed; if (this->m_ConsumeLOT != -1) { auto caster = Game::entityManager->GetEntity(context->caster); @@ -19,7 +19,7 @@ void ConsumeItemBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi if(action_to_cast) action_to_cast->Handle(context, bitStream, branch); } -void ConsumeItemBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ConsumeItemBehavior::Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/ConsumeItemBehavior.h b/dGame/dBehaviors/ConsumeItemBehavior.h index f3eeb330..c2fe357c 100644 --- a/dGame/dBehaviors/ConsumeItemBehavior.h +++ b/dGame/dBehaviors/ConsumeItemBehavior.h @@ -5,8 +5,8 @@ class ConsumeItemBehavior final : public Behavior { public: explicit ConsumeItemBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {} - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; - void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; + void Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; private: diff --git a/dGame/dBehaviors/DamageAbsorptionBehavior.cpp b/dGame/dBehaviors/DamageAbsorptionBehavior.cpp index 880550e3..f657c8fd 100644 --- a/dGame/dBehaviors/DamageAbsorptionBehavior.cpp +++ b/dGame/dBehaviors/DamageAbsorptionBehavior.cpp @@ -7,7 +7,7 @@ #include "Logger.h" #include "DestroyableComponent.h" -void DamageAbsorptionBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void DamageAbsorptionBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { @@ -29,7 +29,7 @@ void DamageAbsorptionBehavior::Handle(BehaviorContext* context, RakNet::BitStrea context->RegisterTimerBehavior(this, branch, target->GetObjectID()); } -void DamageAbsorptionBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void DamageAbsorptionBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/DamageAbsorptionBehavior.h b/dGame/dBehaviors/DamageAbsorptionBehavior.h index 1b865e87..6e26bda1 100644 --- a/dGame/dBehaviors/DamageAbsorptionBehavior.h +++ b/dGame/dBehaviors/DamageAbsorptionBehavior.h @@ -13,9 +13,9 @@ public: explicit DamageAbsorptionBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override; diff --git a/dGame/dBehaviors/DamageReductionBehavior.cpp b/dGame/dBehaviors/DamageReductionBehavior.cpp index bf32360e..62b70a52 100644 --- a/dGame/dBehaviors/DamageReductionBehavior.cpp +++ b/dGame/dBehaviors/DamageReductionBehavior.cpp @@ -7,7 +7,7 @@ #include "Logger.h" #include "DestroyableComponent.h" -void DamageReductionBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void DamageReductionBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { @@ -27,7 +27,7 @@ void DamageReductionBehavior::Handle(BehaviorContext* context, RakNet::BitStream context->RegisterTimerBehavior(this, branch, target->GetObjectID()); } -void DamageReductionBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void DamageReductionBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/DamageReductionBehavior.h b/dGame/dBehaviors/DamageReductionBehavior.h index bddd31fb..7a9aa4f5 100644 --- a/dGame/dBehaviors/DamageReductionBehavior.h +++ b/dGame/dBehaviors/DamageReductionBehavior.h @@ -13,9 +13,9 @@ public: explicit DamageReductionBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override; diff --git a/dGame/dBehaviors/DarkInspirationBehavior.cpp b/dGame/dBehaviors/DarkInspirationBehavior.cpp index 27a7c634..367f9d5a 100644 --- a/dGame/dBehaviors/DarkInspirationBehavior.cpp +++ b/dGame/dBehaviors/DarkInspirationBehavior.cpp @@ -6,7 +6,7 @@ #include "EntityManager.h" #include "BehaviorContext.h" -void DarkInspirationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void DarkInspirationBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { @@ -25,7 +25,7 @@ void DarkInspirationBehavior::Handle(BehaviorContext* context, RakNet::BitStream } } -void DarkInspirationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void DarkInspirationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { diff --git a/dGame/dBehaviors/DarkInspirationBehavior.h b/dGame/dBehaviors/DarkInspirationBehavior.h index f8298742..5fe02c5e 100644 --- a/dGame/dBehaviors/DarkInspirationBehavior.h +++ b/dGame/dBehaviors/DarkInspirationBehavior.h @@ -11,9 +11,9 @@ public: explicit DarkInspirationBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; private: diff --git a/dGame/dBehaviors/DurationBehavior.cpp b/dGame/dBehaviors/DurationBehavior.cpp index c0bc5585..3544dc52 100644 --- a/dGame/dBehaviors/DurationBehavior.cpp +++ b/dGame/dBehaviors/DurationBehavior.cpp @@ -2,13 +2,13 @@ #include "BehaviorBranchContext.h" #include "BehaviorContext.h" -void DurationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void DurationBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { branch.duration = this->m_duration; this->m_action->Handle(context, bitStream, branch); } -void DurationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void DurationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { branch.duration = this->m_duration; this->m_action->Calculate(context, bitStream, branch); diff --git a/dGame/dBehaviors/DurationBehavior.h b/dGame/dBehaviors/DurationBehavior.h index 164754b1..5ea6abb9 100644 --- a/dGame/dBehaviors/DurationBehavior.h +++ b/dGame/dBehaviors/DurationBehavior.h @@ -11,9 +11,9 @@ public: explicit DurationBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; private: diff --git a/dGame/dBehaviors/EndBehavior.cpp b/dGame/dBehaviors/EndBehavior.cpp index c67f3215..804a31b7 100644 --- a/dGame/dBehaviors/EndBehavior.cpp +++ b/dGame/dBehaviors/EndBehavior.cpp @@ -3,11 +3,11 @@ #include "BehaviorContext.h" #include "BehaviorBranchContext.h" -void EndBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void EndBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { context->InvokeEnd(this->m_startBehavior); } -void EndBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void EndBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { context->InvokeEnd(this->m_startBehavior); } diff --git a/dGame/dBehaviors/EndBehavior.h b/dGame/dBehaviors/EndBehavior.h index e1c06068..26a6f2d5 100644 --- a/dGame/dBehaviors/EndBehavior.h +++ b/dGame/dBehaviors/EndBehavior.h @@ -13,9 +13,9 @@ public: explicit EndBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/FallSpeedBehavior.cpp b/dGame/dBehaviors/FallSpeedBehavior.cpp index dfbdec2a..9a376cec 100644 --- a/dGame/dBehaviors/FallSpeedBehavior.cpp +++ b/dGame/dBehaviors/FallSpeedBehavior.cpp @@ -5,7 +5,7 @@ #include "BehaviorBranchContext.h" -void FallSpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void FallSpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { // make sure required parameter has non-default value if (m_PercentSlowed == 0.0f) return; auto* target = Game::entityManager->GetEntity(branch.target); @@ -23,7 +23,7 @@ void FallSpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS } } -void FallSpeedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void FallSpeedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/FallSpeedBehavior.h b/dGame/dBehaviors/FallSpeedBehavior.h index 01f0143f..f53c17e2 100644 --- a/dGame/dBehaviors/FallSpeedBehavior.h +++ b/dGame/dBehaviors/FallSpeedBehavior.h @@ -6,8 +6,8 @@ class FallSpeedBehavior final : public Behavior public: explicit FallSpeedBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {} - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override; void End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; diff --git a/dGame/dBehaviors/ForceMovementBehavior.cpp b/dGame/dBehaviors/ForceMovementBehavior.cpp index 2ba3f2e1..83c6fabc 100644 --- a/dGame/dBehaviors/ForceMovementBehavior.cpp +++ b/dGame/dBehaviors/ForceMovementBehavior.cpp @@ -6,29 +6,29 @@ #include "Game.h" #include "Logger.h" -void ForceMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void ForceMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { if (this->m_hitAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitEnemyAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitFactionAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY) { return; } uint32_t handle{}; - if (!bitStream->Read(handle)) { - LOG("Unable to read handle from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(handle)) { + LOG("Unable to read handle from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; } context->RegisterSyncBehavior(handle, this, branch, this->m_Duration); } -void ForceMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ForceMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { uint32_t next{}; - if (!bitStream->Read(next)) { - LOG("Unable to read target from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(next)) { + LOG("Unable to read target from bitStream, aborting Sync! %i", bitStream.GetNumberOfUnreadBits()); return; } LWOOBJID target{}; - if (!bitStream->Read(target)) { - LOG("Unable to read target from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(target)) { + LOG("Unable to read target from bitStream, aborting Sync! %i", bitStream.GetNumberOfUnreadBits()); return; } @@ -37,7 +37,7 @@ void ForceMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bi behavior->Handle(context, bitStream, branch); } -void ForceMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ForceMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { if (this->m_hitAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitEnemyAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitFactionAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY) { return; } @@ -56,7 +56,7 @@ void ForceMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStrea } const auto skillHandle = context->GetUniqueSkillId(); - bitStream->Write(skillHandle); + bitStream.Write(skillHandle); context->SyncCalculation(skillHandle, this->m_Duration, this, branch); } @@ -71,7 +71,7 @@ void ForceMovementBehavior::Load() { this->m_Yaw = GetFloat("yaw"); } -void ForceMovementBehavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ForceMovementBehavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* casterEntity = Game::entityManager->GetEntity(context->caster); if (casterEntity != nullptr) { auto* controllablePhysicsComponent = casterEntity->GetComponent(); diff --git a/dGame/dBehaviors/ForceMovementBehavior.h b/dGame/dBehaviors/ForceMovementBehavior.h index 8d5fd9f4..ffcea0f4 100644 --- a/dGame/dBehaviors/ForceMovementBehavior.h +++ b/dGame/dBehaviors/ForceMovementBehavior.h @@ -22,13 +22,13 @@ public: explicit ForceMovementBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void SyncCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; diff --git a/dGame/dBehaviors/HealBehavior.cpp b/dGame/dBehaviors/HealBehavior.cpp index 3eb4928c..e2553671 100644 --- a/dGame/dBehaviors/HealBehavior.cpp +++ b/dGame/dBehaviors/HealBehavior.cpp @@ -7,7 +7,7 @@ #include "eReplicaComponentType.h" -void HealBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) { +void HealBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, const BehaviorBranchContext branch) { auto* entity = Game::entityManager->GetEntity(branch.target); if (entity == nullptr) { @@ -28,7 +28,7 @@ void HealBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_strea } -void HealBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) { +void HealBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, const BehaviorBranchContext branch) { Handle(context, bit_stream, branch); } diff --git a/dGame/dBehaviors/HealBehavior.h b/dGame/dBehaviors/HealBehavior.h index e967135a..9ce678a4 100644 --- a/dGame/dBehaviors/HealBehavior.h +++ b/dGame/dBehaviors/HealBehavior.h @@ -13,9 +13,9 @@ public: explicit HealBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/ImaginationBehavior.cpp b/dGame/dBehaviors/ImaginationBehavior.cpp index c57fd0c7..be426e44 100644 --- a/dGame/dBehaviors/ImaginationBehavior.cpp +++ b/dGame/dBehaviors/ImaginationBehavior.cpp @@ -6,7 +6,7 @@ #include "Logger.h" -void ImaginationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) { +void ImaginationBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, const BehaviorBranchContext branch) { auto* entity = Game::entityManager->GetEntity(branch.target); if (entity == nullptr) { @@ -23,7 +23,7 @@ void ImaginationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi } -void ImaginationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) { +void ImaginationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, const BehaviorBranchContext branch) { Handle(context, bit_stream, branch); } diff --git a/dGame/dBehaviors/ImaginationBehavior.h b/dGame/dBehaviors/ImaginationBehavior.h index a35c2ddd..ccebccc2 100644 --- a/dGame/dBehaviors/ImaginationBehavior.h +++ b/dGame/dBehaviors/ImaginationBehavior.h @@ -13,9 +13,9 @@ public: explicit ImaginationBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/ImmunityBehavior.cpp b/dGame/dBehaviors/ImmunityBehavior.cpp index 9824c479..77d43834 100644 --- a/dGame/dBehaviors/ImmunityBehavior.cpp +++ b/dGame/dBehaviors/ImmunityBehavior.cpp @@ -9,7 +9,7 @@ #include "ControllablePhysicsComponent.h" #include "eStateChangeType.h" -void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); if (!target) { @@ -51,7 +51,7 @@ void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt context->RegisterTimerBehavior(this, branch, target->GetObjectID()); } -void ImmunityBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ImmunityBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/ImmunityBehavior.h b/dGame/dBehaviors/ImmunityBehavior.h index 02cc0fae..d2f28b95 100644 --- a/dGame/dBehaviors/ImmunityBehavior.h +++ b/dGame/dBehaviors/ImmunityBehavior.h @@ -11,9 +11,9 @@ public: explicit ImmunityBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override; diff --git a/dGame/dBehaviors/InterruptBehavior.cpp b/dGame/dBehaviors/InterruptBehavior.cpp index bd3f0c4a..0b23c34d 100644 --- a/dGame/dBehaviors/InterruptBehavior.cpp +++ b/dGame/dBehaviors/InterruptBehavior.cpp @@ -7,12 +7,12 @@ #include "SkillComponent.h" -void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { if (branch.target != context->originator) { bool unknown = false; - if (!bitStream->Read(unknown)) { - LOG("Unable to read unknown1 from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(unknown)) { + LOG("Unable to read unknown1 from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -22,8 +22,8 @@ void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS if (!this->m_interruptBlock) { bool unknown = false; - if (!bitStream->Read(unknown)) { - LOG("Unable to read unknown2 from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(unknown)) { + LOG("Unable to read unknown2 from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -34,8 +34,8 @@ void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS { bool unknown = false; - if (!bitStream->Read(unknown)) { - LOG("Unable to read unknown3 from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(unknown)) { + LOG("Unable to read unknown3 from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; } @@ -54,16 +54,16 @@ void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS } -void InterruptBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void InterruptBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { if (branch.target != context->originator) { - bitStream->Write(false); + bitStream.Write(false); } if (!this->m_interruptBlock) { - bitStream->Write(false); + bitStream.Write(false); } - bitStream->Write(false); + bitStream.Write(false); if (branch.target == context->originator) return; diff --git a/dGame/dBehaviors/InterruptBehavior.h b/dGame/dBehaviors/InterruptBehavior.h index 9ba272c7..440bc559 100644 --- a/dGame/dBehaviors/InterruptBehavior.h +++ b/dGame/dBehaviors/InterruptBehavior.h @@ -15,9 +15,9 @@ public: explicit InterruptBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/JetPackBehavior.cpp b/dGame/dBehaviors/JetPackBehavior.cpp index 7fcd78b0..8cfb87da 100644 --- a/dGame/dBehaviors/JetPackBehavior.cpp +++ b/dGame/dBehaviors/JetPackBehavior.cpp @@ -5,7 +5,7 @@ #include "Character.h" -void JetPackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) { +void JetPackBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, const BehaviorBranchContext branch) { auto* entity = Game::entityManager->GetEntity(branch.target); GameMessages::SendSetJetPackMode(entity, true, this->m_BypassChecks, this->m_EnableHover, this->m_effectId, this->m_Airspeed, this->m_MaxAirspeed, this->m_VerticalVelocity, this->m_WarningEffectID); @@ -33,7 +33,7 @@ void JetPackBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext bra } } -void JetPackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) { +void JetPackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, const BehaviorBranchContext branch) { Handle(context, bit_stream, branch); } diff --git a/dGame/dBehaviors/JetPackBehavior.h b/dGame/dBehaviors/JetPackBehavior.h index 0cc6c399..bc82d5d2 100644 --- a/dGame/dBehaviors/JetPackBehavior.h +++ b/dGame/dBehaviors/JetPackBehavior.h @@ -18,11 +18,11 @@ public: explicit JetPackBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/KnockbackBehavior.cpp b/dGame/dBehaviors/KnockbackBehavior.cpp index d0f86597..4d7bf2ea 100644 --- a/dGame/dBehaviors/KnockbackBehavior.cpp +++ b/dGame/dBehaviors/KnockbackBehavior.cpp @@ -9,16 +9,16 @@ #include "Game.h" #include "Logger.h" -void KnockbackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void KnockbackBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { bool unknown{}; - if (!bitStream->Read(unknown)) { - LOG("Unable to read unknown from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(unknown)) { + LOG("Unable to read unknown from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; } -void KnockbackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void KnockbackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { bool blocked = false; auto* target = Game::entityManager->GetEntity(branch.target); @@ -31,7 +31,7 @@ void KnockbackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* b } } - bitStream->Write(blocked); + bitStream.Write(blocked); } void KnockbackBehavior::Load() { diff --git a/dGame/dBehaviors/KnockbackBehavior.h b/dGame/dBehaviors/KnockbackBehavior.h index c952bb41..89777a6d 100644 --- a/dGame/dBehaviors/KnockbackBehavior.h +++ b/dGame/dBehaviors/KnockbackBehavior.h @@ -17,9 +17,9 @@ public: explicit KnockbackBehavior(const uint32_t behaviorID) : Behavior(behaviorID) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/LootBuffBehavior.cpp b/dGame/dBehaviors/LootBuffBehavior.cpp index c7a6b36a..65b73422 100644 --- a/dGame/dBehaviors/LootBuffBehavior.cpp +++ b/dGame/dBehaviors/LootBuffBehavior.cpp @@ -1,6 +1,6 @@ #include "LootBuffBehavior.h" -void LootBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void LootBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto target = Game::entityManager->GetEntity(context->caster); if (!target) return; @@ -14,7 +14,7 @@ void LootBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt } -void LootBuffBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void LootBuffBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/LootBuffBehavior.h b/dGame/dBehaviors/LootBuffBehavior.h index b6f700ca..dba82d75 100644 --- a/dGame/dBehaviors/LootBuffBehavior.h +++ b/dGame/dBehaviors/LootBuffBehavior.h @@ -20,9 +20,9 @@ public: explicit LootBuffBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {} - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; diff --git a/dGame/dBehaviors/MovementSwitchBehavior.cpp b/dGame/dBehaviors/MovementSwitchBehavior.cpp index cddeeea9..cc2d7b34 100644 --- a/dGame/dBehaviors/MovementSwitchBehavior.cpp +++ b/dGame/dBehaviors/MovementSwitchBehavior.cpp @@ -3,9 +3,9 @@ #include "Game.h" #include "Logger.h" -void MovementSwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void MovementSwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { uint32_t movementType{}; - if (!bitStream->Read(movementType)) { + if (!bitStream.Read(movementType)) { if (this->m_groundAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_jumpAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_fallingAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && @@ -15,7 +15,7 @@ void MovementSwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* this->m_movingAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY) { return; } - LOG("Unable to read movementType from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read movementType from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; diff --git a/dGame/dBehaviors/MovementSwitchBehavior.h b/dGame/dBehaviors/MovementSwitchBehavior.h index e6ff96f6..75b13b54 100644 --- a/dGame/dBehaviors/MovementSwitchBehavior.h +++ b/dGame/dBehaviors/MovementSwitchBehavior.h @@ -36,7 +36,7 @@ public: explicit MovementSwitchBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/NpcCombatSkillBehavior.cpp b/dGame/dBehaviors/NpcCombatSkillBehavior.cpp index 5a8d03cf..69a6ea9d 100644 --- a/dGame/dBehaviors/NpcCombatSkillBehavior.cpp +++ b/dGame/dBehaviors/NpcCombatSkillBehavior.cpp @@ -3,7 +3,7 @@ #include "BehaviorContext.h" -void NpcCombatSkillBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) { +void NpcCombatSkillBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) { context->skillTime = this->m_npcSkillTime; for (auto* behavior : this->m_behaviors) { diff --git a/dGame/dBehaviors/NpcCombatSkillBehavior.h b/dGame/dBehaviors/NpcCombatSkillBehavior.h index 19ff3483..07826f48 100644 --- a/dGame/dBehaviors/NpcCombatSkillBehavior.h +++ b/dGame/dBehaviors/NpcCombatSkillBehavior.h @@ -15,7 +15,7 @@ public: explicit NpcCombatSkillBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/OverTimeBehavior.cpp b/dGame/dBehaviors/OverTimeBehavior.cpp index f66a5253..5a42993f 100644 --- a/dGame/dBehaviors/OverTimeBehavior.cpp +++ b/dGame/dBehaviors/OverTimeBehavior.cpp @@ -11,7 +11,7 @@ #include "CDSkillBehaviorTable.h" -void OverTimeBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void OverTimeBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { const auto originator = context->originator; auto* entity = Game::entityManager->GetEntity(originator); @@ -33,7 +33,7 @@ void OverTimeBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt } } -void OverTimeBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void OverTimeBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { } diff --git a/dGame/dBehaviors/OverTimeBehavior.h b/dGame/dBehaviors/OverTimeBehavior.h index 73a07865..78d9388b 100644 --- a/dGame/dBehaviors/OverTimeBehavior.h +++ b/dGame/dBehaviors/OverTimeBehavior.h @@ -16,9 +16,9 @@ public: explicit OverTimeBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/PlayEffectBehavior.cpp b/dGame/dBehaviors/PlayEffectBehavior.cpp index acd606a9..451c52de 100644 --- a/dGame/dBehaviors/PlayEffectBehavior.cpp +++ b/dGame/dBehaviors/PlayEffectBehavior.cpp @@ -3,7 +3,7 @@ #include "BehaviorContext.h" #include "BehaviorBranchContext.h" -void PlayEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void PlayEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { // On managed behaviors this is handled by the client if (!context->unmanaged) return; @@ -13,7 +13,7 @@ void PlayEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit PlayFx(u"", target); } -void PlayEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void PlayEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { const auto& target = branch.target == LWOOBJID_EMPTY ? context->originator : branch.target; //PlayFx(u"", target); diff --git a/dGame/dBehaviors/PlayEffectBehavior.h b/dGame/dBehaviors/PlayEffectBehavior.h index 5ef49161..c112579b 100644 --- a/dGame/dBehaviors/PlayEffectBehavior.h +++ b/dGame/dBehaviors/PlayEffectBehavior.h @@ -10,9 +10,9 @@ public: explicit PlayEffectBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/ProjectileAttackBehavior.cpp b/dGame/dBehaviors/ProjectileAttackBehavior.cpp index 504afc69..3e5118f7 100644 --- a/dGame/dBehaviors/ProjectileAttackBehavior.cpp +++ b/dGame/dBehaviors/ProjectileAttackBehavior.cpp @@ -8,11 +8,11 @@ #include "ObjectIDManager.h" #include "eObjectBits.h" -void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { LWOOBJID target{}; - if (!bitStream->Read(target)) { - LOG("Unable to read target from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(target)) { + LOG("Unable to read target from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -34,8 +34,8 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea if (m_useMouseposit && !branch.isSync) { NiPoint3 targetPosition = NiPoint3Constant::ZERO; - if (!bitStream->Read(targetPosition)) { - LOG("Unable to read targetPosition from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(targetPosition)) { + LOG("Unable to read targetPosition from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; } @@ -45,8 +45,8 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea for (auto i = 0u; i < this->m_projectileCount; ++i) { LWOOBJID projectileId{}; - if (!bitStream->Read(projectileId)) { - LOG("Unable to read projectileId from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(projectileId)) { + LOG("Unable to read projectileId from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -58,8 +58,8 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea } } -void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { - bitStream->Write(branch.target); +void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { + bitStream.Write(branch.target); auto* entity = Game::entityManager->GetEntity(context->originator); @@ -110,7 +110,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt GeneralUtils::SetBit(id, eObjectBits::SPAWNED); - bitStream->Write(id); + bitStream.Write(id); auto eulerAngles = rotation.GetEulerAngles(); diff --git a/dGame/dBehaviors/ProjectileAttackBehavior.h b/dGame/dBehaviors/ProjectileAttackBehavior.h index b307e66c..fee3a5c2 100644 --- a/dGame/dBehaviors/ProjectileAttackBehavior.h +++ b/dGame/dBehaviors/ProjectileAttackBehavior.h @@ -32,9 +32,9 @@ public: explicit ProjectileAttackBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/PropertyTeleportBehavior.cpp b/dGame/dBehaviors/PropertyTeleportBehavior.cpp index 939568f6..7e9ecee0 100644 --- a/dGame/dBehaviors/PropertyTeleportBehavior.cpp +++ b/dGame/dBehaviors/PropertyTeleportBehavior.cpp @@ -11,7 +11,7 @@ #include "ZoneInstanceManager.h" #include "dZoneManager.h" -void PropertyTeleportBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void PropertyTeleportBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* caster = Game::entityManager->GetEntity(context->caster); if (!caster) return; diff --git a/dGame/dBehaviors/PropertyTeleportBehavior.h b/dGame/dBehaviors/PropertyTeleportBehavior.h index 74eed03b..7dbec84c 100644 --- a/dGame/dBehaviors/PropertyTeleportBehavior.h +++ b/dGame/dBehaviors/PropertyTeleportBehavior.h @@ -11,7 +11,7 @@ public: explicit PropertyTeleportBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; diff --git a/dGame/dBehaviors/PullToPointBehavior.cpp b/dGame/dBehaviors/PullToPointBehavior.cpp index e18443f7..f776298f 100644 --- a/dGame/dBehaviors/PullToPointBehavior.cpp +++ b/dGame/dBehaviors/PullToPointBehavior.cpp @@ -5,7 +5,7 @@ #include "EntityManager.h" #include "MovementAIComponent.h" -void PullToPointBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void PullToPointBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* entity = Game::entityManager->GetEntity(context->originator); auto* target = Game::entityManager->GetEntity(branch.target); @@ -25,7 +25,7 @@ void PullToPointBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi movement->PullToPoint(position); } -void PullToPointBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void PullToPointBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/PullToPointBehavior.h b/dGame/dBehaviors/PullToPointBehavior.h index d448ad8d..83c8a944 100644 --- a/dGame/dBehaviors/PullToPointBehavior.h +++ b/dGame/dBehaviors/PullToPointBehavior.h @@ -12,9 +12,9 @@ public: explicit PullToPointBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/RemoveBuffBehavior.cpp b/dGame/dBehaviors/RemoveBuffBehavior.cpp index c6d2c9c9..ec2c15d4 100644 --- a/dGame/dBehaviors/RemoveBuffBehavior.cpp +++ b/dGame/dBehaviors/RemoveBuffBehavior.cpp @@ -5,7 +5,7 @@ #include "EntityManager.h" #include "BuffComponent.h" -void RemoveBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void RemoveBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* entity = Game::entityManager->GetEntity(context->caster); if (!entity) return; diff --git a/dGame/dBehaviors/RemoveBuffBehavior.h b/dGame/dBehaviors/RemoveBuffBehavior.h index f2d8547b..5e08ea7f 100644 --- a/dGame/dBehaviors/RemoveBuffBehavior.h +++ b/dGame/dBehaviors/RemoveBuffBehavior.h @@ -12,7 +12,7 @@ public: explicit RemoveBuffBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; diff --git a/dGame/dBehaviors/RepairBehavior.cpp b/dGame/dBehaviors/RepairBehavior.cpp index d0ce3fe8..95b8ed89 100644 --- a/dGame/dBehaviors/RepairBehavior.cpp +++ b/dGame/dBehaviors/RepairBehavior.cpp @@ -7,7 +7,7 @@ #include "Game.h" #include "eReplicaComponentType.h" -void RepairBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) { +void RepairBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, const BehaviorBranchContext branch) { auto* entity = Game::entityManager->GetEntity(branch.target); if (entity == nullptr) { @@ -27,7 +27,7 @@ void RepairBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_str destroyable->Repair(this->m_armor); } -void RepairBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) { +void RepairBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, const BehaviorBranchContext branch) { Handle(context, bit_stream, branch); } diff --git a/dGame/dBehaviors/RepairBehavior.h b/dGame/dBehaviors/RepairBehavior.h index 8d2f14e4..61b96543 100644 --- a/dGame/dBehaviors/RepairBehavior.h +++ b/dGame/dBehaviors/RepairBehavior.h @@ -13,9 +13,9 @@ public: explicit RepairBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/SkillCastFailedBehavior.cpp b/dGame/dBehaviors/SkillCastFailedBehavior.cpp index a663e709..a9babe61 100644 --- a/dGame/dBehaviors/SkillCastFailedBehavior.cpp +++ b/dGame/dBehaviors/SkillCastFailedBehavior.cpp @@ -3,11 +3,11 @@ #include "BehaviorContext.h" #include "BehaviorBranchContext.h" -void SkillCastFailedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SkillCastFailedBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { context->failed = true; } -void SkillCastFailedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SkillCastFailedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { context->failed = true; } diff --git a/dGame/dBehaviors/SkillCastFailedBehavior.h b/dGame/dBehaviors/SkillCastFailedBehavior.h index 5359cb42..5ccb12b2 100644 --- a/dGame/dBehaviors/SkillCastFailedBehavior.h +++ b/dGame/dBehaviors/SkillCastFailedBehavior.h @@ -11,9 +11,9 @@ public: explicit SkillCastFailedBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/SkillEventBehavior.cpp b/dGame/dBehaviors/SkillEventBehavior.cpp index 4205c28b..e007fbe2 100644 --- a/dGame/dBehaviors/SkillEventBehavior.cpp +++ b/dGame/dBehaviors/SkillEventBehavior.cpp @@ -4,7 +4,7 @@ #include "EntityManager.h" #include "CppScripts.h" -void SkillEventBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SkillEventBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); auto* caster = Game::entityManager->GetEntity(context->originator); @@ -16,7 +16,7 @@ void SkillEventBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit } void -SkillEventBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +SkillEventBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); auto* caster = Game::entityManager->GetEntity(context->originator); diff --git a/dGame/dBehaviors/SkillEventBehavior.h b/dGame/dBehaviors/SkillEventBehavior.h index 540f6d4a..6a334d90 100644 --- a/dGame/dBehaviors/SkillEventBehavior.h +++ b/dGame/dBehaviors/SkillEventBehavior.h @@ -9,7 +9,7 @@ public: explicit SkillEventBehavior(const uint32_t behaviorID) : Behavior(behaviorID) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; }; diff --git a/dGame/dBehaviors/SpawnBehavior.cpp b/dGame/dBehaviors/SpawnBehavior.cpp index dd45fb1b..e033d368 100644 --- a/dGame/dBehaviors/SpawnBehavior.cpp +++ b/dGame/dBehaviors/SpawnBehavior.cpp @@ -11,7 +11,7 @@ #include "EntityInfo.h" #include "eReplicaComponentType.h" -void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* origin = Game::entityManager->GetEntity(context->originator); if (origin == nullptr) { @@ -74,7 +74,7 @@ void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea }); } -void SpawnBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SpawnBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/SpawnBehavior.h b/dGame/dBehaviors/SpawnBehavior.h index 875e0a2b..fad57604 100644 --- a/dGame/dBehaviors/SpawnBehavior.h +++ b/dGame/dBehaviors/SpawnBehavior.h @@ -13,9 +13,9 @@ public: explicit SpawnBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override; diff --git a/dGame/dBehaviors/SpawnQuickbuildBehavior.cpp b/dGame/dBehaviors/SpawnQuickbuildBehavior.cpp index 514ae27a..a76ce980 100644 --- a/dGame/dBehaviors/SpawnQuickbuildBehavior.cpp +++ b/dGame/dBehaviors/SpawnQuickbuildBehavior.cpp @@ -3,7 +3,7 @@ #include "BehaviorBranchContext.h" #include "BehaviorContext.h" -void SpawnQuickbuildBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SpawnQuickbuildBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { } void SpawnQuickbuildBehavior::Load() { diff --git a/dGame/dBehaviors/SpawnQuickbuildBehavior.h b/dGame/dBehaviors/SpawnQuickbuildBehavior.h index 653c60e8..a5700cc5 100644 --- a/dGame/dBehaviors/SpawnQuickbuildBehavior.h +++ b/dGame/dBehaviors/SpawnQuickbuildBehavior.h @@ -11,7 +11,7 @@ public: explicit SpawnQuickbuildBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/SpeedBehavior.cpp b/dGame/dBehaviors/SpeedBehavior.cpp index f21fda7e..c9c99bed 100644 --- a/dGame/dBehaviors/SpeedBehavior.cpp +++ b/dGame/dBehaviors/SpeedBehavior.cpp @@ -6,7 +6,7 @@ #include "Logger.h" -void SpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { if (m_AffectsCaster) branch.target = context->caster; auto* target = Game::entityManager->GetEntity(branch.target); @@ -25,7 +25,7 @@ void SpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea } } -void SpeedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SpeedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/SpeedBehavior.h b/dGame/dBehaviors/SpeedBehavior.h index 88b85820..f122fde7 100644 --- a/dGame/dBehaviors/SpeedBehavior.h +++ b/dGame/dBehaviors/SpeedBehavior.h @@ -11,9 +11,9 @@ public: explicit SpeedBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; diff --git a/dGame/dBehaviors/StartBehavior.cpp b/dGame/dBehaviors/StartBehavior.cpp index 2bcaf325..cb23e31f 100644 --- a/dGame/dBehaviors/StartBehavior.cpp +++ b/dGame/dBehaviors/StartBehavior.cpp @@ -1,13 +1,13 @@ #include "StartBehavior.h" #include "BehaviorBranchContext.h" -void StartBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) { +void StartBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) { branch.start = this->m_behaviorId; this->m_action->Handle(context, bit_stream, branch); } -void StartBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) { +void StartBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) { branch.start = this->m_behaviorId; this->m_action->Calculate(context, bit_stream, branch); diff --git a/dGame/dBehaviors/StartBehavior.h b/dGame/dBehaviors/StartBehavior.h index 384fe64a..7d708d0a 100644 --- a/dGame/dBehaviors/StartBehavior.h +++ b/dGame/dBehaviors/StartBehavior.h @@ -13,9 +13,9 @@ public: explicit StartBehavior(const uint32_t behaviorID) : Behavior(behaviorID) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/StunBehavior.cpp b/dGame/dBehaviors/StunBehavior.cpp index 02144f69..bec6f409 100644 --- a/dGame/dBehaviors/StunBehavior.cpp +++ b/dGame/dBehaviors/StunBehavior.cpp @@ -10,14 +10,14 @@ #include "eReplicaComponentType.h" -void StunBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void StunBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { if (this->m_stunCaster || branch.target == context->originator) { return; } bool blocked{}; - if (!bitStream->Read(blocked)) { - LOG("Unable to read blocked from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(blocked)) { + LOG("Unable to read blocked from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -42,7 +42,7 @@ void StunBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream combatAiComponent->Stun(branch.duration); } -void StunBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void StunBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { if (this->m_stunCaster || branch.target == context->originator) { auto* self = Game::entityManager->GetEntity(context->originator); @@ -79,7 +79,7 @@ void StunBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStr } } - bitStream->Write(blocked); + bitStream.Write(blocked); if (target == nullptr) { LOG("Failed to find target (%llu)!", branch.target); diff --git a/dGame/dBehaviors/StunBehavior.h b/dGame/dBehaviors/StunBehavior.h index f4851b47..18ca31f4 100644 --- a/dGame/dBehaviors/StunBehavior.h +++ b/dGame/dBehaviors/StunBehavior.h @@ -12,9 +12,9 @@ public: explicit StunBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/SwitchBehavior.cpp b/dGame/dBehaviors/SwitchBehavior.cpp index db04650d..88f2d85a 100644 --- a/dGame/dBehaviors/SwitchBehavior.cpp +++ b/dGame/dBehaviors/SwitchBehavior.cpp @@ -6,12 +6,12 @@ #include "BehaviorContext.h" #include "BuffComponent.h" -void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { auto state = true; if (this->m_imagination > 0 || !this->m_isEnemyFaction) { - if (!bitStream->Read(state)) { - LOG("Unable to read state from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(state)) { + LOG("Unable to read state from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; } @@ -37,7 +37,7 @@ void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre } } -void SwitchBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SwitchBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto state = true; if (this->m_imagination > 0 || !this->m_isEnemyFaction) { @@ -53,7 +53,7 @@ void SwitchBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS } } - bitStream->Write(state); + bitStream.Write(state); } if (state) { diff --git a/dGame/dBehaviors/SwitchBehavior.h b/dGame/dBehaviors/SwitchBehavior.h index 5e40d659..b7fcb653 100644 --- a/dGame/dBehaviors/SwitchBehavior.h +++ b/dGame/dBehaviors/SwitchBehavior.h @@ -21,9 +21,9 @@ public: explicit SwitchBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/SwitchMultipleBehavior.cpp b/dGame/dBehaviors/SwitchMultipleBehavior.cpp index faaa0d23..92c9a8de 100644 --- a/dGame/dBehaviors/SwitchMultipleBehavior.cpp +++ b/dGame/dBehaviors/SwitchMultipleBehavior.cpp @@ -9,11 +9,11 @@ #include "EntityManager.h" -void SwitchMultipleBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SwitchMultipleBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { float value{}; - if (!bitStream->Read(value)) { - LOG("Unable to read value from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(value)) { + LOG("Unable to read value from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -32,7 +32,7 @@ void SwitchMultipleBehavior::Handle(BehaviorContext* context, RakNet::BitStream* behavior->Handle(context, bitStream, branch); } -void SwitchMultipleBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SwitchMultipleBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { // TODO } diff --git a/dGame/dBehaviors/SwitchMultipleBehavior.h b/dGame/dBehaviors/SwitchMultipleBehavior.h index 1e3dfe64..9f9754b8 100644 --- a/dGame/dBehaviors/SwitchMultipleBehavior.h +++ b/dGame/dBehaviors/SwitchMultipleBehavior.h @@ -15,9 +15,9 @@ public: explicit SwitchMultipleBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/TacArcBehavior.cpp b/dGame/dBehaviors/TacArcBehavior.cpp index 0cea8213..cb3430c8 100644 --- a/dGame/dBehaviors/TacArcBehavior.cpp +++ b/dGame/dBehaviors/TacArcBehavior.cpp @@ -11,7 +11,7 @@ #include -void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { std::vector targets = {}; if (this->m_usePickedTarget && branch.target != LWOOBJID_EMPTY) { @@ -28,16 +28,16 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre } bool hasTargets = false; - if (!bitStream->Read(hasTargets)) { - LOG("Unable to read hasTargets from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(hasTargets)) { + LOG("Unable to read hasTargets from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; if (this->m_checkEnv) { bool blocked = false; - if (!bitStream->Read(blocked)) { - LOG("Unable to read blocked from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(blocked)) { + LOG("Unable to read blocked from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -49,8 +49,8 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre if (hasTargets) { uint32_t count = 0; - if (!bitStream->Read(count)) { - LOG("Unable to read count from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(count)) { + LOG("Unable to read count from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -62,8 +62,8 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre for (auto i = 0u; i < count; i++) { LWOOBJID id{}; - if (!bitStream->Read(id)) { - LOG("Unable to read id from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(id)) { + LOG("Unable to read id from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -82,7 +82,7 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre } else this->m_missAction->Handle(context, bitStream, branch); } -void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* self = Game::entityManager->GetEntity(context->originator); if (self == nullptr) { LOG("Invalid self for (%llu)!", context->originator); @@ -155,11 +155,11 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS }); const auto hit = !targets.empty(); - bitStream->Write(hit); + bitStream.Write(hit); if (this->m_checkEnv) { const auto blocked = false; // TODO - bitStream->Write(blocked); + bitStream.Write(blocked); } if (hit) { @@ -168,9 +168,9 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS context->foundTarget = true; // We want to continue with this behavior const auto count = static_cast(targets.size()); - bitStream->Write(count); + bitStream.Write(count); for (auto* target : targets) { - bitStream->Write(target->GetObjectID()); + bitStream.Write(target->GetObjectID()); } for (auto* target : targets) { diff --git a/dGame/dBehaviors/TacArcBehavior.h b/dGame/dBehaviors/TacArcBehavior.h index d9345272..b331e6fc 100644 --- a/dGame/dBehaviors/TacArcBehavior.h +++ b/dGame/dBehaviors/TacArcBehavior.h @@ -7,8 +7,8 @@ class TacArcBehavior final : public Behavior { public: explicit TacArcBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {} - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; private: float m_maxRange; diff --git a/dGame/dBehaviors/TargetCasterBehavior.cpp b/dGame/dBehaviors/TargetCasterBehavior.cpp index ff9cfc03..1e2f82f0 100644 --- a/dGame/dBehaviors/TargetCasterBehavior.cpp +++ b/dGame/dBehaviors/TargetCasterBehavior.cpp @@ -3,7 +3,7 @@ #include "BehaviorContext.h" -void TargetCasterBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) { +void TargetCasterBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) { branch.target = context->caster; this->m_action->Handle(context, bit_stream, branch); @@ -13,7 +13,7 @@ void TargetCasterBehavior::UnCast(BehaviorContext* context, BehaviorBranchContex this->m_action->UnCast(context, branch); } -void TargetCasterBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) { +void TargetCasterBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) { branch.target = context->caster; this->m_action->Calculate(context, bit_stream, branch); diff --git a/dGame/dBehaviors/TargetCasterBehavior.h b/dGame/dBehaviors/TargetCasterBehavior.h index 387d2732..2713a1ce 100644 --- a/dGame/dBehaviors/TargetCasterBehavior.h +++ b/dGame/dBehaviors/TargetCasterBehavior.h @@ -13,11 +13,11 @@ public: explicit TargetCasterBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/TauntBehavior.cpp b/dGame/dBehaviors/TauntBehavior.cpp index 2e9f2168..43117ee3 100644 --- a/dGame/dBehaviors/TauntBehavior.cpp +++ b/dGame/dBehaviors/TauntBehavior.cpp @@ -6,7 +6,7 @@ #include "Logger.h" -void TauntBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void TauntBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { @@ -22,7 +22,7 @@ void TauntBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea } } -void TauntBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void TauntBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { diff --git a/dGame/dBehaviors/TauntBehavior.h b/dGame/dBehaviors/TauntBehavior.h index 3ae7db9d..b5b3196e 100644 --- a/dGame/dBehaviors/TauntBehavior.h +++ b/dGame/dBehaviors/TauntBehavior.h @@ -14,9 +14,9 @@ public: explicit TauntBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/VentureVisionBehavior.cpp b/dGame/dBehaviors/VentureVisionBehavior.cpp index 397bdebf..3aa3aac7 100644 --- a/dGame/dBehaviors/VentureVisionBehavior.cpp +++ b/dGame/dBehaviors/VentureVisionBehavior.cpp @@ -3,7 +3,7 @@ #include "CharacterComponent.h" #include "BehaviorContext.h" -void VentureVisionBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void VentureVisionBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { const auto targetEntity = Game::entityManager->GetEntity(branch.target); diff --git a/dGame/dBehaviors/VentureVisionBehavior.h b/dGame/dBehaviors/VentureVisionBehavior.h index 72758949..ee89dae9 100644 --- a/dGame/dBehaviors/VentureVisionBehavior.h +++ b/dGame/dBehaviors/VentureVisionBehavior.h @@ -28,7 +28,7 @@ public: explicit VentureVisionBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; diff --git a/dGame/dBehaviors/VerifyBehavior.cpp b/dGame/dBehaviors/VerifyBehavior.cpp index 2056f146..c7ede52f 100644 --- a/dGame/dBehaviors/VerifyBehavior.cpp +++ b/dGame/dBehaviors/VerifyBehavior.cpp @@ -7,7 +7,7 @@ #include "Logger.h" -void VerifyBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void VerifyBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* entity = Game::entityManager->GetEntity(branch.target); auto success = true; @@ -33,12 +33,12 @@ void VerifyBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS } if (branch.target != LWOOBJID_EMPTY && branch.target != context->originator) { - bitStream->Write(success); + bitStream.Write(success); if (success) { - bitStream->Write(1); - bitStream->Write0(); - bitStream->Write0(); + bitStream.Write(1); + bitStream.Write0(); + bitStream.Write0(); } } diff --git a/dGame/dBehaviors/VerifyBehavior.h b/dGame/dBehaviors/VerifyBehavior.h index a91ff7cf..ed32111d 100644 --- a/dGame/dBehaviors/VerifyBehavior.h +++ b/dGame/dBehaviors/VerifyBehavior.h @@ -19,7 +19,7 @@ public: explicit VerifyBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dComponents/AchievementVendorComponent.cpp b/dGame/dComponents/AchievementVendorComponent.cpp new file mode 100644 index 00000000..10a0ca29 --- /dev/null +++ b/dGame/dComponents/AchievementVendorComponent.cpp @@ -0,0 +1,72 @@ +#include "AchievementVendorComponent.h" +#include "MissionComponent.h" +#include "InventoryComponent.h" +#include "eMissionState.h" +#include "CDComponentsRegistryTable.h" +#include "CDItemComponentTable.h" +#include "eVendorTransactionResult.h" +#include "CheatDetection.h" +#include "UserManager.h" +#include "CDMissionsTable.h" + +bool AchievementVendorComponent::SellsItem(Entity* buyer, const LOT lot) { + auto* missionComponent = buyer->GetComponent(); + if (!missionComponent) return false; + + if (m_PlayerPurchasableItems[buyer->GetObjectID()].contains(lot)){ + return true; + } + + CDMissionsTable* missionsTable = CDClientManager::GetTable(); + const auto missions = missionsTable->GetMissionsForReward(lot); + for (const auto mission : missions) { + if (missionComponent->GetMissionState(mission) == eMissionState::COMPLETE) { + m_PlayerPurchasableItems[buyer->GetObjectID()].insert(lot); + return true; + } + } + return false; +} + +void AchievementVendorComponent::Buy(Entity* buyer, LOT lot, uint32_t count) { + // get the item Comp from the item LOT + CDComponentsRegistryTable* compRegistryTable = CDClientManager::GetTable(); + CDItemComponentTable* itemComponentTable = CDClientManager::GetTable(); + int itemCompID = compRegistryTable->GetByIDAndType(lot, eReplicaComponentType::ITEM); + CDItemComponent itemComp = itemComponentTable->GetItemComponentByID(itemCompID); + uint32_t costLOT = itemComp.commendationLOT; + + if (costLOT == -1 || !SellsItem(buyer, lot)) { + auto* user = UserManager::Instance()->GetUser(buyer->GetSystemAddress()); + CheatDetection::ReportCheat(user, buyer->GetSystemAddress(), "Attempted to buy item %i from achievement vendor %i that is not purchasable", lot, m_Parent->GetLOT()); + GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_FAIL); + return; + } + + auto* inventoryComponent = buyer->GetComponent(); + if (!inventoryComponent) { + GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_FAIL); + return; + } + + if (costLOT == 13763) { // Faction Token Proxy + auto* missionComponent = buyer->GetComponent(); + if (!missionComponent) return; + + if (missionComponent->GetMissionState(545) == eMissionState::COMPLETE) costLOT = 8318; // "Assembly Token" + if (missionComponent->GetMissionState(556) == eMissionState::COMPLETE) costLOT = 8321; // "Venture League Token" + if (missionComponent->GetMissionState(567) == eMissionState::COMPLETE) costLOT = 8319; // "Sentinels Token" + if (missionComponent->GetMissionState(578) == eMissionState::COMPLETE) costLOT = 8320; // "Paradox Token" + } + + const uint32_t altCurrencyCost = itemComp.commendationCost * count; + if (inventoryComponent->GetLotCount(costLOT) < altCurrencyCost) { + GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_FAIL); + return; + } + + inventoryComponent->RemoveItem(costLOT, altCurrencyCost); + inventoryComponent->AddItem(lot, count, eLootSourceType::VENDOR); + GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_SUCCESS); + +} \ No newline at end of file diff --git a/dGame/dComponents/AchievementVendorComponent.h b/dGame/dComponents/AchievementVendorComponent.h new file mode 100644 index 00000000..bffd3983 --- /dev/null +++ b/dGame/dComponents/AchievementVendorComponent.h @@ -0,0 +1,23 @@ +#ifndef __ACHIEVEMENTVENDORCOMPONENT__H__ +#define __ACHIEVEMENTVENDORCOMPONENT__H__ + +#include "VendorComponent.h" +#include "eReplicaComponentType.h" +#include +#include + +class Entity; + +class AchievementVendorComponent final : public VendorComponent { +public: + static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::ACHIEVEMENT_VENDOR; + AchievementVendorComponent(Entity* parent) : VendorComponent(parent) {}; + bool SellsItem(Entity* buyer, const LOT lot); + void Buy(Entity* buyer, LOT lot, uint32_t count); + +private: + std::map> m_PlayerPurchasableItems; +}; + + +#endif //!__ACHIEVEMENTVENDORCOMPONENT__H__ diff --git a/dGame/dComponents/ActivityComponent.cpp b/dGame/dComponents/ActivityComponent.cpp index 49ca4faf..ce82abe0 100644 --- a/dGame/dComponents/ActivityComponent.cpp +++ b/dGame/dComponents/ActivityComponent.cpp @@ -90,15 +90,15 @@ void ActivityComponent::LoadActivityData(const int32_t activityId) { } } -void ActivityComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(m_DirtyActivityInfo); +void ActivityComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(m_DirtyActivityInfo); if (m_DirtyActivityInfo) { - outBitStream->Write(m_ActivityPlayers.size()); + outBitStream.Write(m_ActivityPlayers.size()); if (!m_ActivityPlayers.empty()) { for (const auto& activityPlayer : m_ActivityPlayers) { - outBitStream->Write(activityPlayer->playerID); + outBitStream.Write(activityPlayer->playerID); for (const auto& activityValue : activityPlayer->values) { - outBitStream->Write(activityValue); + outBitStream.Write(activityValue); } } } diff --git a/dGame/dComponents/ActivityComponent.h b/dGame/dComponents/ActivityComponent.h index de63b343..296c6ccc 100644 --- a/dGame/dComponents/ActivityComponent.h +++ b/dGame/dComponents/ActivityComponent.h @@ -155,7 +155,7 @@ public: void LoadActivityData(const int32_t activityId); void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Makes some entity join the minigame, if it's a lobbied one, the entity will be placed in the lobby diff --git a/dGame/dComponents/BaseCombatAIComponent.cpp b/dGame/dComponents/BaseCombatAIComponent.cpp index 17183409..d40cf73e 100644 --- a/dGame/dComponents/BaseCombatAIComponent.cpp +++ b/dGame/dComponents/BaseCombatAIComponent.cpp @@ -520,11 +520,11 @@ bool BaseCombatAIComponent::IsMech() { } -void BaseCombatAIComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(m_DirtyStateOrTarget || bIsInitialUpdate); +void BaseCombatAIComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(m_DirtyStateOrTarget || bIsInitialUpdate); if (m_DirtyStateOrTarget || bIsInitialUpdate) { - outBitStream->Write(m_State); - outBitStream->Write(m_Target); + outBitStream.Write(m_State); + outBitStream.Write(m_Target); m_DirtyStateOrTarget = false; } } diff --git a/dGame/dComponents/BaseCombatAIComponent.h b/dGame/dComponents/BaseCombatAIComponent.h index f00910e7..89985d64 100644 --- a/dGame/dComponents/BaseCombatAIComponent.h +++ b/dGame/dComponents/BaseCombatAIComponent.h @@ -53,7 +53,7 @@ public: ~BaseCombatAIComponent() override; void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Get the current behavioral state of the enemy diff --git a/dGame/dComponents/BouncerComponent.cpp b/dGame/dComponents/BouncerComponent.cpp index 78ee3637..d1c63bf4 100644 --- a/dGame/dComponents/BouncerComponent.cpp +++ b/dGame/dComponents/BouncerComponent.cpp @@ -22,10 +22,10 @@ BouncerComponent::BouncerComponent(Entity* parent) : Component(parent) { BouncerComponent::~BouncerComponent() { } -void BouncerComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(m_PetEnabled); +void BouncerComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(m_PetEnabled); if (m_PetEnabled) { - outBitStream->Write(m_PetBouncerEnabled); + outBitStream.Write(m_PetBouncerEnabled); } } diff --git a/dGame/dComponents/BouncerComponent.h b/dGame/dComponents/BouncerComponent.h index b41881c6..441ba58e 100644 --- a/dGame/dComponents/BouncerComponent.h +++ b/dGame/dComponents/BouncerComponent.h @@ -17,7 +17,7 @@ public: BouncerComponent(Entity* parentEntity); ~BouncerComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; Entity* GetParentEntity() const; diff --git a/dGame/dComponents/BuffComponent.cpp b/dGame/dComponents/BuffComponent.cpp index cdf1d5bc..8b76e423 100644 --- a/dGame/dComponents/BuffComponent.cpp +++ b/dGame/dComponents/BuffComponent.cpp @@ -32,24 +32,24 @@ BuffComponent::BuffComponent(Entity* parent) : Component(parent) { BuffComponent::~BuffComponent() { } -void BuffComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void BuffComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { if (!bIsInitialUpdate) return; - outBitStream->Write(!m_Buffs.empty()); + outBitStream.Write(!m_Buffs.empty()); if (!m_Buffs.empty()) { - outBitStream->Write(m_Buffs.size()); + outBitStream.Write(m_Buffs.size()); for (const auto& [id, buff] : m_Buffs) { - outBitStream->Write(id); - outBitStream->Write(buff.time != 0.0f); - if (buff.time != 0.0f) outBitStream->Write(buff.time * 1000.0f); - outBitStream->Write(buff.cancelOnDeath); - outBitStream->Write(buff.cancelOnZone); - outBitStream->Write(buff.cancelOnDamaged); - outBitStream->Write(buff.cancelOnRemoveBuff); - outBitStream->Write(buff.cancelOnUi); - outBitStream->Write(buff.cancelOnLogout); - outBitStream->Write(buff.cancelOnUnequip); - outBitStream->Write0(); // Cancel on Damage Absorb Ran Out. Generally false from what I can tell + outBitStream.Write(id); + outBitStream.Write(buff.time != 0.0f); + if (buff.time != 0.0f) outBitStream.Write(buff.time * 1000.0f); + outBitStream.Write(buff.cancelOnDeath); + outBitStream.Write(buff.cancelOnZone); + outBitStream.Write(buff.cancelOnDamaged); + outBitStream.Write(buff.cancelOnRemoveBuff); + outBitStream.Write(buff.cancelOnUi); + outBitStream.Write(buff.cancelOnLogout); + outBitStream.Write(buff.cancelOnUnequip); + outBitStream.Write0(); // Cancel on Damage Absorb Ran Out. Generally false from what I can tell auto* team = TeamManager::Instance()->GetTeam(buff.source); bool addedByTeammate = false; @@ -57,15 +57,15 @@ void BuffComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUp addedByTeammate = std::count(team->members.begin(), team->members.end(), m_Parent->GetObjectID()) > 0; } - outBitStream->Write(addedByTeammate); // Added by teammate. If source is in the same team as the target, this is true. Otherwise, false. - outBitStream->Write(buff.applyOnTeammates); - if (addedByTeammate) outBitStream->Write(buff.source); + outBitStream.Write(addedByTeammate); // Added by teammate. If source is in the same team as the target, this is true. Otherwise, false. + outBitStream.Write(buff.applyOnTeammates); + if (addedByTeammate) outBitStream.Write(buff.source); - outBitStream->Write(buff.refCount); + outBitStream.Write(buff.refCount); } } - outBitStream->Write0(); // something to do with immunity buffs? + outBitStream.Write0(); // something to do with immunity buffs? } void BuffComponent::Update(float deltaTime) { @@ -208,9 +208,8 @@ void BuffComponent::ApplyBuff(const int32_t id, const float duration, const LWOO void BuffComponent::RemoveBuff(int32_t id, bool fromUnEquip, bool removeImmunity, bool ignoreRefCount) { const auto& iter = m_Buffs.find(id); - if (iter == m_Buffs.end()) { - return; - } + // If the buff is already scheduled to be removed, don't do it again + if (iter == m_Buffs.end() || m_BuffsToRemove.contains(id)) return; if (!ignoreRefCount && !iter->second.cancelOnRemoveBuff) { iter->second.refCount--; @@ -222,7 +221,7 @@ void BuffComponent::RemoveBuff(int32_t id, bool fromUnEquip, bool removeImmunity GameMessages::SendRemoveBuff(m_Parent, fromUnEquip, removeImmunity, id); - m_BuffsToRemove.push_back(id); + m_BuffsToRemove.insert(id); RemoveBuffEffect(id); } diff --git a/dGame/dComponents/BuffComponent.h b/dGame/dComponents/BuffComponent.h index 18aa7a42..df3c6a78 100644 --- a/dGame/dComponents/BuffComponent.h +++ b/dGame/dComponents/BuffComponent.h @@ -61,7 +61,7 @@ public: void UpdateXml(tinyxml2::XMLDocument* doc) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; @@ -141,7 +141,7 @@ private: std::map m_Buffs; // Buffs to remove at the end of the update frame. - std::vector m_BuffsToRemove; + std::set m_BuffsToRemove; /** * Parameters (=effects) for each buff diff --git a/dGame/dComponents/CMakeLists.txt b/dGame/dComponents/CMakeLists.txt index ac509e11..21fe9207 100644 --- a/dGame/dComponents/CMakeLists.txt +++ b/dGame/dComponents/CMakeLists.txt @@ -1,4 +1,5 @@ set(DGAME_DCOMPONENTS_SOURCES + "AchievementVendorComponent.cpp" "ActivityComponent.cpp" "BaseCombatAIComponent.cpp" "BouncerComponent.cpp" diff --git a/dGame/dComponents/CharacterComponent.cpp b/dGame/dComponents/CharacterComponent.cpp index e4e2ba4b..3eafd924 100644 --- a/dGame/dComponents/CharacterComponent.cpp +++ b/dGame/dComponents/CharacterComponent.cpp @@ -78,94 +78,94 @@ bool CharacterComponent::LandingAnimDisabled(int zoneID) { CharacterComponent::~CharacterComponent() { } -void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void CharacterComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { if (bIsInitialUpdate) { - outBitStream->Write(m_ClaimCodes[0] != 0); - if (m_ClaimCodes[0] != 0) outBitStream->Write(m_ClaimCodes[0]); - outBitStream->Write(m_ClaimCodes[1] != 0); - if (m_ClaimCodes[1] != 0) outBitStream->Write(m_ClaimCodes[1]); - outBitStream->Write(m_ClaimCodes[2] != 0); - if (m_ClaimCodes[2] != 0) outBitStream->Write(m_ClaimCodes[2]); - outBitStream->Write(m_ClaimCodes[3] != 0); - if (m_ClaimCodes[3] != 0) outBitStream->Write(m_ClaimCodes[3]); + outBitStream.Write(m_ClaimCodes[0] != 0); + if (m_ClaimCodes[0] != 0) outBitStream.Write(m_ClaimCodes[0]); + outBitStream.Write(m_ClaimCodes[1] != 0); + if (m_ClaimCodes[1] != 0) outBitStream.Write(m_ClaimCodes[1]); + outBitStream.Write(m_ClaimCodes[2] != 0); + if (m_ClaimCodes[2] != 0) outBitStream.Write(m_ClaimCodes[2]); + outBitStream.Write(m_ClaimCodes[3] != 0); + if (m_ClaimCodes[3] != 0) outBitStream.Write(m_ClaimCodes[3]); - outBitStream->Write(m_Character->GetHairColor()); - outBitStream->Write(m_Character->GetHairStyle()); - outBitStream->Write(0); //Default "head" - outBitStream->Write(m_Character->GetShirtColor()); - outBitStream->Write(m_Character->GetPantsColor()); - outBitStream->Write(m_Character->GetShirtStyle()); - outBitStream->Write(0); //Default "head color" - outBitStream->Write(m_Character->GetEyebrows()); - outBitStream->Write(m_Character->GetEyes()); - outBitStream->Write(m_Character->GetMouth()); - outBitStream->Write(0); //AccountID, trying out if 0 works. - outBitStream->Write(m_Character->GetLastLogin()); //Last login - outBitStream->Write(0); //"prop mod last display time" - outBitStream->Write(m_Uscore); //u-score - outBitStream->Write0(); //Not free-to-play (disabled in DLU) + outBitStream.Write(m_Character->GetHairColor()); + outBitStream.Write(m_Character->GetHairStyle()); + outBitStream.Write(0); //Default "head" + outBitStream.Write(m_Character->GetShirtColor()); + outBitStream.Write(m_Character->GetPantsColor()); + outBitStream.Write(m_Character->GetShirtStyle()); + outBitStream.Write(0); //Default "head color" + outBitStream.Write(m_Character->GetEyebrows()); + outBitStream.Write(m_Character->GetEyes()); + outBitStream.Write(m_Character->GetMouth()); + outBitStream.Write(0); //AccountID, trying out if 0 works. + outBitStream.Write(m_Character->GetLastLogin()); //Last login + outBitStream.Write(0); //"prop mod last display time" + outBitStream.Write(m_Uscore); //u-score + outBitStream.Write0(); //Not free-to-play (disabled in DLU) //Stats: - outBitStream->Write(m_CurrencyCollected); - outBitStream->Write(m_BricksCollected); - outBitStream->Write(m_SmashablesSmashed); - outBitStream->Write(m_QuickBuildsCompleted); - outBitStream->Write(m_EnemiesSmashed); - outBitStream->Write(m_RocketsUsed); - outBitStream->Write(m_MissionsCompleted); - outBitStream->Write(m_PetsTamed); - outBitStream->Write(m_ImaginationPowerUpsCollected); - outBitStream->Write(m_LifePowerUpsCollected); - outBitStream->Write(m_ArmorPowerUpsCollected); - outBitStream->Write(m_MetersTraveled); - outBitStream->Write(m_TimesSmashed); - outBitStream->Write(m_TotalDamageTaken); - outBitStream->Write(m_TotalDamageHealed); - outBitStream->Write(m_TotalArmorRepaired); - outBitStream->Write(m_TotalImaginationRestored); - outBitStream->Write(m_TotalImaginationUsed); - outBitStream->Write(m_DistanceDriven); - outBitStream->Write(m_TimeAirborneInCar); - outBitStream->Write(m_RacingImaginationPowerUpsCollected); - outBitStream->Write(m_RacingImaginationCratesSmashed); - outBitStream->Write(m_RacingCarBoostsActivated); - outBitStream->Write(m_RacingTimesWrecked); - outBitStream->Write(m_RacingSmashablesSmashed); - outBitStream->Write(m_RacesFinished); - outBitStream->Write(m_FirstPlaceRaceFinishes); + outBitStream.Write(m_CurrencyCollected); + outBitStream.Write(m_BricksCollected); + outBitStream.Write(m_SmashablesSmashed); + outBitStream.Write(m_QuickBuildsCompleted); + outBitStream.Write(m_EnemiesSmashed); + outBitStream.Write(m_RocketsUsed); + outBitStream.Write(m_MissionsCompleted); + outBitStream.Write(m_PetsTamed); + outBitStream.Write(m_ImaginationPowerUpsCollected); + outBitStream.Write(m_LifePowerUpsCollected); + outBitStream.Write(m_ArmorPowerUpsCollected); + outBitStream.Write(m_MetersTraveled); + outBitStream.Write(m_TimesSmashed); + outBitStream.Write(m_TotalDamageTaken); + outBitStream.Write(m_TotalDamageHealed); + outBitStream.Write(m_TotalArmorRepaired); + outBitStream.Write(m_TotalImaginationRestored); + outBitStream.Write(m_TotalImaginationUsed); + outBitStream.Write(m_DistanceDriven); + outBitStream.Write(m_TimeAirborneInCar); + outBitStream.Write(m_RacingImaginationPowerUpsCollected); + outBitStream.Write(m_RacingImaginationCratesSmashed); + outBitStream.Write(m_RacingCarBoostsActivated); + outBitStream.Write(m_RacingTimesWrecked); + outBitStream.Write(m_RacingSmashablesSmashed); + outBitStream.Write(m_RacesFinished); + outBitStream.Write(m_FirstPlaceRaceFinishes); - outBitStream->Write0(); - outBitStream->Write(m_IsLanding); + outBitStream.Write0(); + outBitStream.Write(m_IsLanding); if (m_IsLanding) { - outBitStream->Write(m_LastRocketConfig.size()); + outBitStream.Write(m_LastRocketConfig.size()); for (uint16_t character : m_LastRocketConfig) { - outBitStream->Write(character); + outBitStream.Write(character); } } } - outBitStream->Write(m_DirtyGMInfo); + outBitStream.Write(m_DirtyGMInfo); if (m_DirtyGMInfo) { - outBitStream->Write(m_PvpEnabled); - outBitStream->Write(m_IsGM); - outBitStream->Write(m_GMLevel); - outBitStream->Write(m_EditorEnabled); - outBitStream->Write(m_EditorLevel); + outBitStream.Write(m_PvpEnabled); + outBitStream.Write(m_IsGM); + outBitStream.Write(m_GMLevel); + outBitStream.Write(m_EditorEnabled); + outBitStream.Write(m_EditorLevel); } - outBitStream->Write(m_DirtyCurrentActivity); - if (m_DirtyCurrentActivity) outBitStream->Write(m_CurrentActivity); + outBitStream.Write(m_DirtyCurrentActivity); + if (m_DirtyCurrentActivity) outBitStream.Write(m_CurrentActivity); - outBitStream->Write(m_DirtySocialInfo); + outBitStream.Write(m_DirtySocialInfo); if (m_DirtySocialInfo) { - outBitStream->Write(m_GuildID); - outBitStream->Write(m_GuildName.size()); + outBitStream.Write(m_GuildID); + outBitStream.Write(m_GuildName.size()); if (!m_GuildName.empty()) - outBitStream->WriteBits(reinterpret_cast(m_GuildName.c_str()), static_cast(m_GuildName.size()) * sizeof(wchar_t) * 8); + outBitStream.WriteBits(reinterpret_cast(m_GuildName.c_str()), static_cast(m_GuildName.size()) * sizeof(wchar_t) * 8); - outBitStream->Write(m_IsLEGOClubMember); - outBitStream->Write(m_CountryCode); + outBitStream.Write(m_IsLEGOClubMember); + outBitStream.Write(m_CountryCode); } } diff --git a/dGame/dComponents/CharacterComponent.h b/dGame/dComponents/CharacterComponent.h index 01c26f9a..797347ed 100644 --- a/dGame/dComponents/CharacterComponent.h +++ b/dGame/dComponents/CharacterComponent.h @@ -72,7 +72,7 @@ public: void LoadFromXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Updates the rocket configuration using a LOT string separated by commas diff --git a/dGame/dComponents/CollectibleComponent.cpp b/dGame/dComponents/CollectibleComponent.cpp index 99fcc681..f6ba25b2 100644 --- a/dGame/dComponents/CollectibleComponent.cpp +++ b/dGame/dComponents/CollectibleComponent.cpp @@ -1,5 +1,5 @@ #include "CollectibleComponent.h" -void CollectibleComponent::Serialize(RakNet::BitStream* outBitStream, bool isConstruction) { - outBitStream->Write(GetCollectibleId()); +void CollectibleComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) { + outBitStream.Write(GetCollectibleId()); } diff --git a/dGame/dComponents/CollectibleComponent.h b/dGame/dComponents/CollectibleComponent.h index 10a23293..5ecfb97e 100644 --- a/dGame/dComponents/CollectibleComponent.h +++ b/dGame/dComponents/CollectibleComponent.h @@ -10,7 +10,7 @@ public: CollectibleComponent(Entity* parentEntity, int32_t collectibleId) : Component(parentEntity), m_CollectibleId(collectibleId) {} int16_t GetCollectibleId() const { return m_CollectibleId; } - void Serialize(RakNet::BitStream* outBitStream, bool isConstruction) override; + void Serialize(RakNet::BitStream& outBitStream, bool isConstruction) override; private: int16_t m_CollectibleId = 0; }; diff --git a/dGame/dComponents/Component.cpp b/dGame/dComponents/Component.cpp index 1136456c..705c44a7 100644 --- a/dGame/dComponents/Component.cpp +++ b/dGame/dComponents/Component.cpp @@ -29,6 +29,6 @@ void Component::LoadFromXml(tinyxml2::XMLDocument* doc) { } -void Component::Serialize(RakNet::BitStream* outBitStream, bool isConstruction) { +void Component::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) { } diff --git a/dGame/dComponents/Component.h b/dGame/dComponents/Component.h index 70f30f76..062924f7 100644 --- a/dGame/dComponents/Component.h +++ b/dGame/dComponents/Component.h @@ -42,7 +42,7 @@ public: */ virtual void LoadFromXml(tinyxml2::XMLDocument* doc); - virtual void Serialize(RakNet::BitStream* outBitStream, bool isConstruction); + virtual void Serialize(RakNet::BitStream& outBitStream, bool isConstruction); protected: diff --git a/dGame/dComponents/ControllablePhysicsComponent.cpp b/dGame/dComponents/ControllablePhysicsComponent.cpp index be5227a0..daa14ac3 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.cpp +++ b/dGame/dComponents/ControllablePhysicsComponent.cpp @@ -71,89 +71,89 @@ void ControllablePhysicsComponent::Update(float deltaTime) { } -void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void ControllablePhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { //If this is a creation, then we assume the position is dirty, even when it isn't. //This is because new clients will still need to receive the position. //if (bIsInitialUpdate) m_DirtyPosition = true; if (bIsInitialUpdate) { - outBitStream->Write(m_InJetpackMode); + outBitStream.Write(m_InJetpackMode); if (m_InJetpackMode) { - outBitStream->Write(m_JetpackEffectID); - outBitStream->Write(m_JetpackFlying); - outBitStream->Write(m_JetpackBypassChecks); + outBitStream.Write(m_JetpackEffectID); + outBitStream.Write(m_JetpackFlying); + outBitStream.Write(m_JetpackBypassChecks); } - outBitStream->Write1(); // always write these on construction - outBitStream->Write(m_ImmuneToStunMoveCount); - outBitStream->Write(m_ImmuneToStunJumpCount); - outBitStream->Write(m_ImmuneToStunTurnCount); - outBitStream->Write(m_ImmuneToStunAttackCount); - outBitStream->Write(m_ImmuneToStunUseItemCount); - outBitStream->Write(m_ImmuneToStunEquipCount); - outBitStream->Write(m_ImmuneToStunInteractCount); + outBitStream.Write1(); // always write these on construction + outBitStream.Write(m_ImmuneToStunMoveCount); + outBitStream.Write(m_ImmuneToStunJumpCount); + outBitStream.Write(m_ImmuneToStunTurnCount); + outBitStream.Write(m_ImmuneToStunAttackCount); + outBitStream.Write(m_ImmuneToStunUseItemCount); + outBitStream.Write(m_ImmuneToStunEquipCount); + outBitStream.Write(m_ImmuneToStunInteractCount); } if (m_IgnoreMultipliers) m_DirtyCheats = false; - outBitStream->Write(m_DirtyCheats); + outBitStream.Write(m_DirtyCheats); if (m_DirtyCheats) { - outBitStream->Write(m_GravityScale); - outBitStream->Write(m_SpeedMultiplier); + outBitStream.Write(m_GravityScale); + outBitStream.Write(m_SpeedMultiplier); m_DirtyCheats = false; } - outBitStream->Write(m_DirtyEquippedItemInfo); + outBitStream.Write(m_DirtyEquippedItemInfo); if (m_DirtyEquippedItemInfo) { - outBitStream->Write(m_PickupRadius); - outBitStream->Write(m_InJetpackMode); + outBitStream.Write(m_PickupRadius); + outBitStream.Write(m_InJetpackMode); m_DirtyEquippedItemInfo = false; } - outBitStream->Write(m_DirtyBubble); + outBitStream.Write(m_DirtyBubble); if (m_DirtyBubble) { - outBitStream->Write(m_IsInBubble); + outBitStream.Write(m_IsInBubble); if (m_IsInBubble) { - outBitStream->Write(m_BubbleType); - outBitStream->Write(m_SpecialAnims); + outBitStream.Write(m_BubbleType); + outBitStream.Write(m_SpecialAnims); } m_DirtyBubble = false; } - outBitStream->Write(m_DirtyPosition || bIsInitialUpdate); + outBitStream.Write(m_DirtyPosition || bIsInitialUpdate); if (m_DirtyPosition || bIsInitialUpdate) { - outBitStream->Write(m_Position.x); - outBitStream->Write(m_Position.y); - outBitStream->Write(m_Position.z); + outBitStream.Write(m_Position.x); + outBitStream.Write(m_Position.y); + outBitStream.Write(m_Position.z); - outBitStream->Write(m_Rotation.x); - outBitStream->Write(m_Rotation.y); - outBitStream->Write(m_Rotation.z); - outBitStream->Write(m_Rotation.w); + outBitStream.Write(m_Rotation.x); + outBitStream.Write(m_Rotation.y); + outBitStream.Write(m_Rotation.z); + outBitStream.Write(m_Rotation.w); - outBitStream->Write(m_IsOnGround); - outBitStream->Write(m_IsOnRail); + outBitStream.Write(m_IsOnGround); + outBitStream.Write(m_IsOnRail); - outBitStream->Write(m_DirtyVelocity); + outBitStream.Write(m_DirtyVelocity); if (m_DirtyVelocity) { - outBitStream->Write(m_Velocity.x); - outBitStream->Write(m_Velocity.y); - outBitStream->Write(m_Velocity.z); + outBitStream.Write(m_Velocity.x); + outBitStream.Write(m_Velocity.y); + outBitStream.Write(m_Velocity.z); } - outBitStream->Write(m_DirtyAngularVelocity); + outBitStream.Write(m_DirtyAngularVelocity); if (m_DirtyAngularVelocity) { - outBitStream->Write(m_AngularVelocity.x); - outBitStream->Write(m_AngularVelocity.y); - outBitStream->Write(m_AngularVelocity.z); + outBitStream.Write(m_AngularVelocity.x); + outBitStream.Write(m_AngularVelocity.y); + outBitStream.Write(m_AngularVelocity.z); } - outBitStream->Write0(); + outBitStream.Write0(); } if (!bIsInitialUpdate) { - outBitStream->Write(m_IsTeleporting); + outBitStream.Write(m_IsTeleporting); m_IsTeleporting = false; } } diff --git a/dGame/dComponents/ControllablePhysicsComponent.h b/dGame/dComponents/ControllablePhysicsComponent.h index e850cfeb..313f80de 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.h +++ b/dGame/dComponents/ControllablePhysicsComponent.h @@ -27,7 +27,7 @@ public: ~ControllablePhysicsComponent() override; void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void LoadFromXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override; diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index 68271f26..39643baf 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -122,61 +122,61 @@ void DestroyableComponent::Reinitialize(LOT templateID) { } } -void DestroyableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void DestroyableComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { if (bIsInitialUpdate) { - outBitStream->Write1(); // always write these on construction - outBitStream->Write(m_ImmuneToBasicAttackCount); - outBitStream->Write(m_ImmuneToDamageOverTimeCount); - outBitStream->Write(m_ImmuneToKnockbackCount); - outBitStream->Write(m_ImmuneToInterruptCount); - outBitStream->Write(m_ImmuneToSpeedCount); - outBitStream->Write(m_ImmuneToImaginationGainCount); - outBitStream->Write(m_ImmuneToImaginationLossCount); - outBitStream->Write(m_ImmuneToQuickbuildInterruptCount); - outBitStream->Write(m_ImmuneToPullToPointCount); + outBitStream.Write1(); // always write these on construction + outBitStream.Write(m_ImmuneToBasicAttackCount); + outBitStream.Write(m_ImmuneToDamageOverTimeCount); + outBitStream.Write(m_ImmuneToKnockbackCount); + outBitStream.Write(m_ImmuneToInterruptCount); + outBitStream.Write(m_ImmuneToSpeedCount); + outBitStream.Write(m_ImmuneToImaginationGainCount); + outBitStream.Write(m_ImmuneToImaginationLossCount); + outBitStream.Write(m_ImmuneToQuickbuildInterruptCount); + outBitStream.Write(m_ImmuneToPullToPointCount); } - outBitStream->Write(m_DirtyHealth || bIsInitialUpdate); + outBitStream.Write(m_DirtyHealth || bIsInitialUpdate); if (m_DirtyHealth || bIsInitialUpdate) { - outBitStream->Write(m_iHealth); - outBitStream->Write(m_fMaxHealth); - outBitStream->Write(m_iArmor); - outBitStream->Write(m_fMaxArmor); - outBitStream->Write(m_iImagination); - outBitStream->Write(m_fMaxImagination); + outBitStream.Write(m_iHealth); + outBitStream.Write(m_fMaxHealth); + outBitStream.Write(m_iArmor); + outBitStream.Write(m_fMaxArmor); + outBitStream.Write(m_iImagination); + outBitStream.Write(m_fMaxImagination); - outBitStream->Write(m_DamageToAbsorb); - outBitStream->Write(IsImmune()); - outBitStream->Write(m_IsGMImmune); - outBitStream->Write(m_IsShielded); + outBitStream.Write(m_DamageToAbsorb); + outBitStream.Write(IsImmune()); + outBitStream.Write(m_IsGMImmune); + outBitStream.Write(m_IsShielded); - outBitStream->Write(m_fMaxHealth); - outBitStream->Write(m_fMaxArmor); - outBitStream->Write(m_fMaxImagination); + outBitStream.Write(m_fMaxHealth); + outBitStream.Write(m_fMaxArmor); + outBitStream.Write(m_fMaxImagination); - outBitStream->Write(m_FactionIDs.size()); + outBitStream.Write(m_FactionIDs.size()); for (size_t i = 0; i < m_FactionIDs.size(); ++i) { - outBitStream->Write(m_FactionIDs[i]); + outBitStream.Write(m_FactionIDs[i]); } - outBitStream->Write(m_IsSmashable); + outBitStream.Write(m_IsSmashable); if (bIsInitialUpdate) { - outBitStream->Write(m_IsDead); - outBitStream->Write(m_IsSmashed); + outBitStream.Write(m_IsDead); + outBitStream.Write(m_IsSmashed); if (m_IsSmashable) { - outBitStream->Write(m_IsModuleAssembly); - outBitStream->Write(m_ExplodeFactor != 1.0f); - if (m_ExplodeFactor != 1.0f) outBitStream->Write(m_ExplodeFactor); + outBitStream.Write(m_IsModuleAssembly); + outBitStream.Write(m_ExplodeFactor != 1.0f); + if (m_ExplodeFactor != 1.0f) outBitStream.Write(m_ExplodeFactor); } } m_DirtyHealth = false; } - outBitStream->Write(m_DirtyThreatList || bIsInitialUpdate); + outBitStream.Write(m_DirtyThreatList || bIsInitialUpdate); if (m_DirtyThreatList || bIsInitialUpdate) { - outBitStream->Write(m_HasThreats); + outBitStream.Write(m_HasThreats); m_DirtyThreatList = false; } } diff --git a/dGame/dComponents/DestroyableComponent.h b/dGame/dComponents/DestroyableComponent.h index 1f45b43e..85a4f941 100644 --- a/dGame/dComponents/DestroyableComponent.h +++ b/dGame/dComponents/DestroyableComponent.h @@ -25,7 +25,7 @@ public: ~DestroyableComponent() override; void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void LoadFromXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override; diff --git a/dGame/dComponents/DonationVendorComponent.cpp b/dGame/dComponents/DonationVendorComponent.cpp index 6abc959a..7fb06a90 100644 --- a/dGame/dComponents/DonationVendorComponent.cpp +++ b/dGame/dComponents/DonationVendorComponent.cpp @@ -36,13 +36,13 @@ void DonationVendorComponent::SubmitDonation(uint32_t count) { m_DirtyDonationVendor = true; } -void DonationVendorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void DonationVendorComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { VendorComponent::Serialize(outBitStream, bIsInitialUpdate); - outBitStream->Write(bIsInitialUpdate || m_DirtyDonationVendor); + outBitStream.Write(bIsInitialUpdate || m_DirtyDonationVendor); if (bIsInitialUpdate || m_DirtyDonationVendor) { - outBitStream->Write(m_PercentComplete); - outBitStream->Write(m_TotalDonated); - outBitStream->Write(m_TotalRemaining); + outBitStream.Write(m_PercentComplete); + outBitStream.Write(m_TotalDonated); + outBitStream.Write(m_TotalRemaining); if (!bIsInitialUpdate) m_DirtyDonationVendor = false; } } diff --git a/dGame/dComponents/DonationVendorComponent.h b/dGame/dComponents/DonationVendorComponent.h index 7eb60849..af1eb829 100644 --- a/dGame/dComponents/DonationVendorComponent.h +++ b/dGame/dComponents/DonationVendorComponent.h @@ -10,7 +10,7 @@ class DonationVendorComponent final : public VendorComponent { public: static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::DONATION_VENDOR; DonationVendorComponent(Entity* parent); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; uint32_t GetActivityID() {return m_ActivityId;}; void SubmitDonation(uint32_t count); diff --git a/dGame/dComponents/HavokVehiclePhysicsComponent.cpp b/dGame/dComponents/HavokVehiclePhysicsComponent.cpp index 8c8e14fe..464cb357 100644 --- a/dGame/dComponents/HavokVehiclePhysicsComponent.cpp +++ b/dGame/dComponents/HavokVehiclePhysicsComponent.cpp @@ -50,65 +50,65 @@ void HavokVehiclePhysicsComponent::SetDirtyAngularVelocity(bool val) { m_DirtyAngularVelocity = val; } -void HavokVehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(bIsInitialUpdate || m_DirtyPosition); +void HavokVehiclePhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(bIsInitialUpdate || m_DirtyPosition); if (bIsInitialUpdate || m_DirtyPosition) { m_DirtyPosition = false; - outBitStream->Write(m_Position.x); - outBitStream->Write(m_Position.y); - outBitStream->Write(m_Position.z); + outBitStream.Write(m_Position.x); + outBitStream.Write(m_Position.y); + outBitStream.Write(m_Position.z); - outBitStream->Write(m_Rotation.x); - outBitStream->Write(m_Rotation.y); - outBitStream->Write(m_Rotation.z); - outBitStream->Write(m_Rotation.w); + outBitStream.Write(m_Rotation.x); + outBitStream.Write(m_Rotation.y); + outBitStream.Write(m_Rotation.z); + outBitStream.Write(m_Rotation.w); - outBitStream->Write(m_IsOnGround); - outBitStream->Write(m_IsOnRail); + outBitStream.Write(m_IsOnGround); + outBitStream.Write(m_IsOnRail); - outBitStream->Write(bIsInitialUpdate || m_DirtyVelocity); + outBitStream.Write(bIsInitialUpdate || m_DirtyVelocity); if (bIsInitialUpdate || m_DirtyVelocity) { - outBitStream->Write(m_Velocity.x); - outBitStream->Write(m_Velocity.y); - outBitStream->Write(m_Velocity.z); + outBitStream.Write(m_Velocity.x); + outBitStream.Write(m_Velocity.y); + outBitStream.Write(m_Velocity.z); m_DirtyVelocity = false; } - outBitStream->Write(bIsInitialUpdate || m_DirtyAngularVelocity); + outBitStream.Write(bIsInitialUpdate || m_DirtyAngularVelocity); if (bIsInitialUpdate || m_DirtyAngularVelocity) { - outBitStream->Write(m_AngularVelocity.x); - outBitStream->Write(m_AngularVelocity.y); - outBitStream->Write(m_AngularVelocity.z); + outBitStream.Write(m_AngularVelocity.x); + outBitStream.Write(m_AngularVelocity.y); + outBitStream.Write(m_AngularVelocity.z); m_DirtyAngularVelocity = false; } - outBitStream->Write0(); // local_space_info. TODO: Implement this + outBitStream.Write0(); // local_space_info. TODO: Implement this - outBitStream->Write(m_DirtyRemoteInput || bIsInitialUpdate); // remote_input_info + outBitStream.Write(m_DirtyRemoteInput || bIsInitialUpdate); // remote_input_info if (m_DirtyRemoteInput || bIsInitialUpdate) { - outBitStream->Write(m_RemoteInputInfo.m_RemoteInputX); - outBitStream->Write(m_RemoteInputInfo.m_RemoteInputY); - outBitStream->Write(m_RemoteInputInfo.m_IsPowersliding); - outBitStream->Write(m_RemoteInputInfo.m_IsModified); + outBitStream.Write(m_RemoteInputInfo.m_RemoteInputX); + outBitStream.Write(m_RemoteInputInfo.m_RemoteInputY); + outBitStream.Write(m_RemoteInputInfo.m_IsPowersliding); + outBitStream.Write(m_RemoteInputInfo.m_IsModified); m_DirtyRemoteInput = false; } - outBitStream->Write(125.0f); // remote_input_ping TODO: Figure out how this should be calculated as it seems to be constant through the whole race. + outBitStream.Write(125.0f); // remote_input_ping TODO: Figure out how this should be calculated as it seems to be constant through the whole race. if (!bIsInitialUpdate) { - outBitStream->Write0(); + outBitStream.Write0(); } } if (bIsInitialUpdate) { - outBitStream->Write(m_EndBehavior); - outBitStream->Write1(); // is input locked? + outBitStream.Write(m_EndBehavior); + outBitStream.Write1(); // is input locked? } - outBitStream->Write0(); + outBitStream.Write0(); } void HavokVehiclePhysicsComponent::Update(float deltaTime) { diff --git a/dGame/dComponents/HavokVehiclePhysicsComponent.h b/dGame/dComponents/HavokVehiclePhysicsComponent.h index 85a0e279..94c14ec6 100644 --- a/dGame/dComponents/HavokVehiclePhysicsComponent.h +++ b/dGame/dComponents/HavokVehiclePhysicsComponent.h @@ -15,7 +15,7 @@ public: HavokVehiclePhysicsComponent(Entity* parentEntity); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index 591e0505..161d7b91 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -694,11 +694,11 @@ void InventoryComponent::UpdateXml(tinyxml2::XMLDocument* document) { } } -void InventoryComponent::Serialize(RakNet::BitStream* outBitStream, const bool bIsInitialUpdate) { +void InventoryComponent::Serialize(RakNet::BitStream& outBitStream, const bool bIsInitialUpdate) { if (bIsInitialUpdate || m_Dirty) { - outBitStream->Write(true); + outBitStream.Write(true); - outBitStream->Write(m_Equipped.size()); + outBitStream.Write(m_Equipped.size()); for (const auto& pair : m_Equipped) { const auto item = pair.second; @@ -707,21 +707,21 @@ void InventoryComponent::Serialize(RakNet::BitStream* outBitStream, const bool b AddItemSkills(item.lot); } - outBitStream->Write(item.id); - outBitStream->Write(item.lot); + outBitStream.Write(item.id); + outBitStream.Write(item.lot); - outBitStream->Write0(); + outBitStream.Write0(); - outBitStream->Write(item.count > 0); - if (item.count > 0) outBitStream->Write(item.count); + outBitStream.Write(item.count > 0); + if (item.count > 0) outBitStream.Write(item.count); - outBitStream->Write(item.slot != 0); - if (item.slot != 0) outBitStream->Write(item.slot); + outBitStream.Write(item.slot != 0); + if (item.slot != 0) outBitStream.Write(item.slot); - outBitStream->Write0(); + outBitStream.Write0(); bool flag = !item.config.empty(); - outBitStream->Write(flag); + outBitStream.Write(flag); if (flag) { RakNet::BitStream ldfStream; ldfStream.Write(item.config.size()); // Key count @@ -730,26 +730,26 @@ void InventoryComponent::Serialize(RakNet::BitStream* outBitStream, const bool b std::string newRocketStr = data->GetValueAsString() + ";"; GeneralUtils::ReplaceInString(newRocketStr, "+", ";"); LDFData* ldf_data = new LDFData(u"assemblyPartLOTs", GeneralUtils::ASCIIToUTF16(newRocketStr)); - ldf_data->WriteToPacket(&ldfStream); + ldf_data->WriteToPacket(ldfStream); delete ldf_data; } else { - data->WriteToPacket(&ldfStream); + data->WriteToPacket(ldfStream); } } - outBitStream->Write(ldfStream.GetNumberOfBytesUsed() + 1); - outBitStream->Write(0); // Don't compress - outBitStream->Write(ldfStream); + outBitStream.Write(ldfStream.GetNumberOfBytesUsed() + 1); + outBitStream.Write(0); // Don't compress + outBitStream.Write(ldfStream); } - outBitStream->Write1(); + outBitStream.Write1(); } m_Dirty = false; } else { - outBitStream->Write(false); + outBitStream.Write(false); } - outBitStream->Write(false); + outBitStream.Write(false); } void InventoryComponent::Update(float deltaTime) { diff --git a/dGame/dComponents/InventoryComponent.h b/dGame/dComponents/InventoryComponent.h index e47e6a59..8f58a523 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -41,7 +41,7 @@ public: explicit InventoryComponent(Entity* parent, tinyxml2::XMLDocument* document = nullptr); void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void LoadXml(tinyxml2::XMLDocument* document); void UpdateXml(tinyxml2::XMLDocument* document) override; diff --git a/dGame/dComponents/ItemComponent.cpp b/dGame/dComponents/ItemComponent.cpp index dc413b17..799cd935 100644 --- a/dGame/dComponents/ItemComponent.cpp +++ b/dGame/dComponents/ItemComponent.cpp @@ -1,5 +1,5 @@ #include "ItemComponent.h" -void ItemComponent::Serialize(RakNet::BitStream* outBitStream, bool isConstruction) { - outBitStream->Write0(); +void ItemComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) { + outBitStream.Write0(); } diff --git a/dGame/dComponents/ItemComponent.h b/dGame/dComponents/ItemComponent.h index 875ef0a5..1a02ad11 100644 --- a/dGame/dComponents/ItemComponent.h +++ b/dGame/dComponents/ItemComponent.h @@ -10,7 +10,7 @@ public: ItemComponent(Entity* entity) : Component(entity) {} - void Serialize(RakNet::BitStream* bitStream, bool isConstruction) override; + void Serialize(RakNet::BitStream& bitStream, bool isConstruction) override; }; #endif //!__ITEMCOMPONENT__H__ diff --git a/dGame/dComponents/LUPExhibitComponent.cpp b/dGame/dComponents/LUPExhibitComponent.cpp index a312617d..00a8cf03 100644 --- a/dGame/dComponents/LUPExhibitComponent.cpp +++ b/dGame/dComponents/LUPExhibitComponent.cpp @@ -15,10 +15,10 @@ void LUPExhibitComponent::NextLUPExhibit() { Game::entityManager->SerializeEntity(m_Parent); } -void LUPExhibitComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(m_DirtyLUPExhibit); +void LUPExhibitComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(m_DirtyLUPExhibit); if (m_DirtyLUPExhibit) { - outBitStream->Write(m_LUPExhibits[m_LUPExhibitIndex % m_LUPExhibits.size()]); + outBitStream.Write(m_LUPExhibits[m_LUPExhibitIndex % m_LUPExhibits.size()]); if (!bIsInitialUpdate) m_DirtyLUPExhibit = false; } } diff --git a/dGame/dComponents/LUPExhibitComponent.h b/dGame/dComponents/LUPExhibitComponent.h index e6653868..8fd6d7ee 100644 --- a/dGame/dComponents/LUPExhibitComponent.h +++ b/dGame/dComponents/LUPExhibitComponent.h @@ -18,7 +18,7 @@ public: LUPExhibitComponent(Entity* parent) : Component(parent) {}; void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void NextLUPExhibit(); private: float m_UpdateTimer = 0.0f; diff --git a/dGame/dComponents/LevelProgressionComponent.cpp b/dGame/dComponents/LevelProgressionComponent.cpp index d271f97b..2d3d5144 100644 --- a/dGame/dComponents/LevelProgressionComponent.cpp +++ b/dGame/dComponents/LevelProgressionComponent.cpp @@ -37,9 +37,9 @@ void LevelProgressionComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { m_CharacterVersion = static_cast(characterVersion); } -void LevelProgressionComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(bIsInitialUpdate || m_DirtyLevelInfo); - if (bIsInitialUpdate || m_DirtyLevelInfo) outBitStream->Write(m_Level); +void LevelProgressionComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(bIsInitialUpdate || m_DirtyLevelInfo); + if (bIsInitialUpdate || m_DirtyLevelInfo) outBitStream.Write(m_Level); m_DirtyLevelInfo = false; } diff --git a/dGame/dComponents/LevelProgressionComponent.h b/dGame/dComponents/LevelProgressionComponent.h index 6083738c..a27039f3 100644 --- a/dGame/dComponents/LevelProgressionComponent.h +++ b/dGame/dComponents/LevelProgressionComponent.h @@ -21,7 +21,7 @@ public: */ LevelProgressionComponent(Entity* parent); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Save data from this componennt to character XML diff --git a/dGame/dComponents/MiniGameControlComponent.cpp b/dGame/dComponents/MiniGameControlComponent.cpp index fdd56a2c..088ee354 100644 --- a/dGame/dComponents/MiniGameControlComponent.cpp +++ b/dGame/dComponents/MiniGameControlComponent.cpp @@ -1,5 +1,5 @@ #include "MiniGameControlComponent.h" -void MiniGameControlComponent::Serialize(RakNet::BitStream* outBitStream, bool isConstruction) { - outBitStream->Write(0x40000000); +void MiniGameControlComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) { + outBitStream.Write(0x40000000); } diff --git a/dGame/dComponents/MiniGameControlComponent.h b/dGame/dComponents/MiniGameControlComponent.h index e2581b2d..2cd9ac6a 100644 --- a/dGame/dComponents/MiniGameControlComponent.h +++ b/dGame/dComponents/MiniGameControlComponent.h @@ -9,7 +9,7 @@ public: static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MINI_GAME_CONTROL; MiniGameControlComponent(Entity* parent) : Component(parent) {} - void Serialize(RakNet::BitStream* outBitStream, bool isConstruction); + void Serialize(RakNet::BitStream& outBitStream, bool isConstruction); }; #endif //!__MINIGAMECONTROLCOMPONENT__H__ diff --git a/dGame/dComponents/MinigameComponent.cpp b/dGame/dComponents/MinigameComponent.cpp index 6bcb985e..2174cd8a 100644 --- a/dGame/dComponents/MinigameComponent.cpp +++ b/dGame/dComponents/MinigameComponent.cpp @@ -1,5 +1,5 @@ #include "MinigameComponent.h" -void MinigameComponent::Serialize(RakNet::BitStream* outBitStream, bool isConstruction) { - outBitStream->Write(0x40000000); +void MinigameComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) { + outBitStream.Write(0x40000000); } diff --git a/dGame/dComponents/MissionComponent.h b/dGame/dComponents/MissionComponent.h index 42c4df08..866f1650 100644 --- a/dGame/dComponents/MissionComponent.h +++ b/dGame/dComponents/MissionComponent.h @@ -30,7 +30,7 @@ public: explicit MissionComponent(Entity* parent); ~MissionComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate, unsigned int& flags); void LoadFromXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override; diff --git a/dGame/dComponents/ModelComponent.cpp b/dGame/dComponents/ModelComponent.cpp index 3f8858c0..75f2a019 100644 --- a/dGame/dComponents/ModelComponent.cpp +++ b/dGame/dComponents/ModelComponent.cpp @@ -14,26 +14,26 @@ ModelComponent::ModelComponent(Entity* parent) : Component(parent) { m_userModelID = m_Parent->GetVarAs(u"userModelID"); } -void ModelComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void ModelComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { // ItemComponent Serialization. Pets do not get this serialization. if (!m_Parent->HasComponent(eReplicaComponentType::PET)) { - outBitStream->Write1(); - outBitStream->Write(m_userModelID != LWOOBJID_EMPTY ? m_userModelID : m_Parent->GetObjectID()); - outBitStream->Write(0); - outBitStream->Write0(); + outBitStream.Write1(); + outBitStream.Write(m_userModelID != LWOOBJID_EMPTY ? m_userModelID : m_Parent->GetObjectID()); + outBitStream.Write(0); + outBitStream.Write0(); } //actual model component: - outBitStream->Write1(); // Yes we are writing model info - outBitStream->Write0(); // Is pickable - outBitStream->Write(2); // Physics type - outBitStream->Write(m_OriginalPosition); // Original position - outBitStream->Write(m_OriginalRotation); // Original rotation + outBitStream.Write1(); // Yes we are writing model info + outBitStream.Write0(); // Is pickable + outBitStream.Write(2); // Physics type + outBitStream.Write(m_OriginalPosition); // Original position + outBitStream.Write(m_OriginalRotation); // Original rotation - outBitStream->Write1(); // We are writing behavior info - outBitStream->Write(0); // Number of behaviors - outBitStream->Write1(); // Is this model paused - if (bIsInitialUpdate) outBitStream->Write0(); // We are not writing model editing info + outBitStream.Write1(); // We are writing behavior info + outBitStream.Write(0); // Number of behaviors + outBitStream.Write1(); // Is this model paused + if (bIsInitialUpdate) outBitStream.Write0(); // We are not writing model editing info } void ModelComponent::UpdatePendingBehaviorId(const int32_t newId) { diff --git a/dGame/dComponents/ModelComponent.h b/dGame/dComponents/ModelComponent.h index c98b0274..d798a69c 100644 --- a/dGame/dComponents/ModelComponent.h +++ b/dGame/dComponents/ModelComponent.h @@ -28,7 +28,7 @@ public: ModelComponent(Entity* parent); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Returns the original position of the model diff --git a/dGame/dComponents/ModuleAssemblyComponent.cpp b/dGame/dComponents/ModuleAssemblyComponent.cpp index 5b7042df..e217d9b7 100644 --- a/dGame/dComponents/ModuleAssemblyComponent.cpp +++ b/dGame/dComponents/ModuleAssemblyComponent.cpp @@ -46,20 +46,20 @@ const std::u16string& ModuleAssemblyComponent::GetAssemblyPartsLOTs() const { return m_AssemblyPartsLOTs; } -void ModuleAssemblyComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void ModuleAssemblyComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { if (bIsInitialUpdate) { - outBitStream->Write1(); + outBitStream.Write1(); - outBitStream->Write(m_SubKey != LWOOBJID_EMPTY); + outBitStream.Write(m_SubKey != LWOOBJID_EMPTY); if (m_SubKey != LWOOBJID_EMPTY) { - outBitStream->Write(m_SubKey); + outBitStream.Write(m_SubKey); } - outBitStream->Write(m_UseOptionalParts); + outBitStream.Write(m_UseOptionalParts); - outBitStream->Write(m_AssemblyPartsLOTs.size()); + outBitStream.Write(m_AssemblyPartsLOTs.size()); for (char16_t character : m_AssemblyPartsLOTs) { - outBitStream->Write(character); + outBitStream.Write(character); } } } diff --git a/dGame/dComponents/ModuleAssemblyComponent.h b/dGame/dComponents/ModuleAssemblyComponent.h index 47e7baa6..7e050ec7 100644 --- a/dGame/dComponents/ModuleAssemblyComponent.h +++ b/dGame/dComponents/ModuleAssemblyComponent.h @@ -17,7 +17,7 @@ public: ModuleAssemblyComponent(Entity* parent); ~ModuleAssemblyComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; /** diff --git a/dGame/dComponents/MovingPlatformComponent.cpp b/dGame/dComponents/MovingPlatformComponent.cpp index 366bebd3..4bcf78c0 100644 --- a/dGame/dComponents/MovingPlatformComponent.cpp +++ b/dGame/dComponents/MovingPlatformComponent.cpp @@ -32,25 +32,25 @@ MoverSubComponent::MoverSubComponent(const NiPoint3& startPos) { MoverSubComponent::~MoverSubComponent() = default; -void MoverSubComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(true); +void MoverSubComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(true); - outBitStream->Write(mState); - outBitStream->Write(mDesiredWaypointIndex); - outBitStream->Write(mShouldStopAtDesiredWaypoint); - outBitStream->Write(mInReverse); + outBitStream.Write(mState); + outBitStream.Write(mDesiredWaypointIndex); + outBitStream.Write(mShouldStopAtDesiredWaypoint); + outBitStream.Write(mInReverse); - outBitStream->Write(mPercentBetweenPoints); + outBitStream.Write(mPercentBetweenPoints); - outBitStream->Write(mPosition.x); - outBitStream->Write(mPosition.y); - outBitStream->Write(mPosition.z); + outBitStream.Write(mPosition.x); + outBitStream.Write(mPosition.y); + outBitStream.Write(mPosition.z); - outBitStream->Write(mCurrentWaypointIndex); - outBitStream->Write(mNextWaypointIndex); + outBitStream.Write(mCurrentWaypointIndex); + outBitStream.Write(mNextWaypointIndex); - outBitStream->Write(mIdleTimeElapsed); - outBitStream->Write(0.0f); // Move time elapsed + outBitStream.Write(mIdleTimeElapsed); + outBitStream.Write(0.0f); // Move time elapsed } //------------- MovingPlatformComponent below -------------- @@ -71,43 +71,43 @@ MovingPlatformComponent::~MovingPlatformComponent() { delete static_cast(m_MoverSubComponent); } -void MovingPlatformComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void MovingPlatformComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { // Here we don't serialize the moving platform to let the client simulate the movement if (!m_Serialize) { - outBitStream->Write(false); - outBitStream->Write(false); + outBitStream.Write(false); + outBitStream.Write(false); return; } - outBitStream->Write(true); + outBitStream.Write(true); auto hasPath = !m_PathingStopped && !m_PathName.empty(); - outBitStream->Write(hasPath); + outBitStream.Write(hasPath); if (hasPath) { // Is on rail - outBitStream->Write1(); + outBitStream.Write1(); - outBitStream->Write(m_PathName.size()); + outBitStream.Write(m_PathName.size()); for (const auto& c : m_PathName) { - outBitStream->Write(c); + outBitStream.Write(c); } // Starting point - outBitStream->Write(0); + outBitStream.Write(0); // Reverse - outBitStream->Write(false); + outBitStream.Write(false); } const auto hasPlatform = m_MoverSubComponent != nullptr; - outBitStream->Write(hasPlatform); + outBitStream.Write(hasPlatform); if (hasPlatform) { auto* mover = static_cast(m_MoverSubComponent); - outBitStream->Write(m_MoverSubComponentType); + outBitStream.Write(m_MoverSubComponentType); if (m_MoverSubComponentType == eMoverSubComponentType::simpleMover) { // TODO diff --git a/dGame/dComponents/MovingPlatformComponent.h b/dGame/dComponents/MovingPlatformComponent.h index cf47b9c3..c4fbf308 100644 --- a/dGame/dComponents/MovingPlatformComponent.h +++ b/dGame/dComponents/MovingPlatformComponent.h @@ -38,7 +38,7 @@ public: MoverSubComponent(const NiPoint3& startPos); ~MoverSubComponent(); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate); + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate); /** * The state the platform is currently in @@ -111,7 +111,7 @@ public: MovingPlatformComponent(Entity* parent, const std::string& pathName); ~MovingPlatformComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Stops all pathing, called when an entity starts a quick build associated with this platform diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index 1af65b4e..a016eb36 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -96,42 +96,42 @@ PetComponent::PetComponent(Entity* parentEntity, uint32_t componentId) : Compone } } -void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void PetComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { const bool tamed = m_Owner != LWOOBJID_EMPTY; - outBitStream->Write1(); // Always serialize as dirty for now + outBitStream.Write1(); // Always serialize as dirty for now - outBitStream->Write(m_Status); - outBitStream->Write(tamed ? m_Ability : ePetAbilityType::Invalid); // Something with the overhead icon? + outBitStream.Write(m_Status); + outBitStream.Write(tamed ? m_Ability : ePetAbilityType::Invalid); // Something with the overhead icon? const bool interacting = m_Interaction != LWOOBJID_EMPTY; - outBitStream->Write(interacting); + outBitStream.Write(interacting); if (interacting) { - outBitStream->Write(m_Interaction); + outBitStream.Write(m_Interaction); } - outBitStream->Write(tamed); + outBitStream.Write(tamed); if (tamed) { - outBitStream->Write(m_Owner); + outBitStream.Write(m_Owner); } if (bIsInitialUpdate) { - outBitStream->Write(tamed); + outBitStream.Write(tamed); if (tamed) { - outBitStream->Write(m_ModerationStatus); + outBitStream.Write(m_ModerationStatus); const auto nameData = GeneralUtils::UTF8ToUTF16(m_Name); const auto ownerNameData = GeneralUtils::UTF8ToUTF16(m_OwnerName); - outBitStream->Write(nameData.size()); + outBitStream.Write(nameData.size()); for (const auto c : nameData) { - outBitStream->Write(c); + outBitStream.Write(c); } - outBitStream->Write(ownerNameData.size()); + outBitStream.Write(ownerNameData.size()); for (const auto c : ownerNameData) { - outBitStream->Write(c); + outBitStream.Write(c); } } } diff --git a/dGame/dComponents/PetComponent.h b/dGame/dComponents/PetComponent.h index 6d13bea9..0254c5f5 100644 --- a/dGame/dComponents/PetComponent.h +++ b/dGame/dComponents/PetComponent.h @@ -21,7 +21,7 @@ public: explicit PetComponent(Entity* parentEntity, uint32_t componentId); ~PetComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; /** diff --git a/dGame/dComponents/PhantomPhysicsComponent.cpp b/dGame/dComponents/PhantomPhysicsComponent.cpp index 592c2a6b..276184b1 100644 --- a/dGame/dComponents/PhantomPhysicsComponent.cpp +++ b/dGame/dComponents/PhantomPhysicsComponent.cpp @@ -264,30 +264,30 @@ void PhantomPhysicsComponent::CreatePhysics() { m_HasCreatedPhysics = true; } -void PhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void PhantomPhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { PhysicsComponent::Serialize(outBitStream, bIsInitialUpdate); - outBitStream->Write(m_EffectInfoDirty || bIsInitialUpdate); + outBitStream.Write(m_EffectInfoDirty || bIsInitialUpdate); if (m_EffectInfoDirty || bIsInitialUpdate) { - outBitStream->Write(m_IsPhysicsEffectActive); + outBitStream.Write(m_IsPhysicsEffectActive); if (m_IsPhysicsEffectActive) { - outBitStream->Write(m_EffectType); - outBitStream->Write(m_DirectionalMultiplier); + outBitStream.Write(m_EffectType); + outBitStream.Write(m_DirectionalMultiplier); // forgive me father for i have sinned - outBitStream->Write0(); - //outBitStream->Write(m_MinMax); + outBitStream.Write0(); + //outBitStream.Write(m_MinMax); //if (m_MinMax) { - //outBitStream->Write(m_Min); - //outBitStream->Write(m_Max); + //outBitStream.Write(m_Min); + //outBitStream.Write(m_Max); //} - outBitStream->Write(m_IsDirectional); + outBitStream.Write(m_IsDirectional); if (m_IsDirectional) { - outBitStream->Write(m_Direction.x); - outBitStream->Write(m_Direction.y); - outBitStream->Write(m_Direction.z); + outBitStream.Write(m_Direction.x); + outBitStream.Write(m_Direction.y); + outBitStream.Write(m_Direction.z); } } diff --git a/dGame/dComponents/PhantomPhysicsComponent.h b/dGame/dComponents/PhantomPhysicsComponent.h index 2ea9e979..1aae9527 100644 --- a/dGame/dComponents/PhantomPhysicsComponent.h +++ b/dGame/dComponents/PhantomPhysicsComponent.h @@ -32,7 +32,7 @@ public: PhantomPhysicsComponent(Entity* parent); ~PhantomPhysicsComponent() override; void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Creates the physics shape for this entity based on LDF data diff --git a/dGame/dComponents/PhysicsComponent.cpp b/dGame/dComponents/PhysicsComponent.cpp index ea57735f..3a84c4ce 100644 --- a/dGame/dComponents/PhysicsComponent.cpp +++ b/dGame/dComponents/PhysicsComponent.cpp @@ -6,16 +6,16 @@ PhysicsComponent::PhysicsComponent(Entity* parent) : Component(parent) { m_DirtyPosition = false; } -void PhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(bIsInitialUpdate || m_DirtyPosition); +void PhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(bIsInitialUpdate || m_DirtyPosition); if (bIsInitialUpdate || m_DirtyPosition) { - outBitStream->Write(m_Position.x); - outBitStream->Write(m_Position.y); - outBitStream->Write(m_Position.z); - outBitStream->Write(m_Rotation.x); - outBitStream->Write(m_Rotation.y); - outBitStream->Write(m_Rotation.z); - outBitStream->Write(m_Rotation.w); + outBitStream.Write(m_Position.x); + outBitStream.Write(m_Position.y); + outBitStream.Write(m_Position.z); + outBitStream.Write(m_Rotation.x); + outBitStream.Write(m_Rotation.y); + outBitStream.Write(m_Rotation.z); + outBitStream.Write(m_Rotation.w); if (!bIsInitialUpdate) m_DirtyPosition = false; } } diff --git a/dGame/dComponents/PhysicsComponent.h b/dGame/dComponents/PhysicsComponent.h index c1a7f34a..71f52e54 100644 --- a/dGame/dComponents/PhysicsComponent.h +++ b/dGame/dComponents/PhysicsComponent.h @@ -14,7 +14,7 @@ public: PhysicsComponent(Entity* parent); virtual ~PhysicsComponent() = default; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; const NiPoint3& GetPosition() const { return m_Position; } virtual void SetPosition(const NiPoint3& pos) { if (m_Position == pos) return; m_Position = pos; m_DirtyPosition = true; } diff --git a/dGame/dComponents/PlayerForcedMovementComponent.cpp b/dGame/dComponents/PlayerForcedMovementComponent.cpp index d511ad78..0aea882c 100644 --- a/dGame/dComponents/PlayerForcedMovementComponent.cpp +++ b/dGame/dComponents/PlayerForcedMovementComponent.cpp @@ -6,11 +6,11 @@ PlayerForcedMovementComponent::PlayerForcedMovementComponent(Entity* parent) : C PlayerForcedMovementComponent::~PlayerForcedMovementComponent() {} -void PlayerForcedMovementComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(m_DirtyInfo || bIsInitialUpdate); +void PlayerForcedMovementComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(m_DirtyInfo || bIsInitialUpdate); if (m_DirtyInfo || bIsInitialUpdate) { - outBitStream->Write(m_PlayerOnRail); - outBitStream->Write(m_ShowBillboard); + outBitStream.Write(m_PlayerOnRail); + outBitStream.Write(m_ShowBillboard); } m_DirtyInfo = false; } diff --git a/dGame/dComponents/PlayerForcedMovementComponent.h b/dGame/dComponents/PlayerForcedMovementComponent.h index e5aca37d..f184ede2 100644 --- a/dGame/dComponents/PlayerForcedMovementComponent.h +++ b/dGame/dComponents/PlayerForcedMovementComponent.h @@ -19,7 +19,7 @@ public: PlayerForcedMovementComponent(Entity* parent); ~PlayerForcedMovementComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * @brief Set the Player On Rail object diff --git a/dGame/dComponents/PossessableComponent.cpp b/dGame/dComponents/PossessableComponent.cpp index 509b1a07..ae5b05b3 100644 --- a/dGame/dComponents/PossessableComponent.cpp +++ b/dGame/dComponents/PossessableComponent.cpp @@ -27,17 +27,17 @@ PossessableComponent::PossessableComponent(Entity* parent, uint32_t componentId) result.finalize(); } -void PossessableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(m_DirtyPossessable || bIsInitialUpdate); +void PossessableComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(m_DirtyPossessable || bIsInitialUpdate); if (m_DirtyPossessable || bIsInitialUpdate) { m_DirtyPossessable = false; // reset flag - outBitStream->Write(m_Possessor != LWOOBJID_EMPTY); - if (m_Possessor != LWOOBJID_EMPTY) outBitStream->Write(m_Possessor); + outBitStream.Write(m_Possessor != LWOOBJID_EMPTY); + if (m_Possessor != LWOOBJID_EMPTY) outBitStream.Write(m_Possessor); - outBitStream->Write(m_AnimationFlag != eAnimationFlags::IDLE_NONE); - if (m_AnimationFlag != eAnimationFlags::IDLE_NONE) outBitStream->Write(m_AnimationFlag); + outBitStream.Write(m_AnimationFlag != eAnimationFlags::IDLE_NONE); + if (m_AnimationFlag != eAnimationFlags::IDLE_NONE) outBitStream.Write(m_AnimationFlag); - outBitStream->Write(m_ImmediatelyDepossess); + outBitStream.Write(m_ImmediatelyDepossess); m_ImmediatelyDepossess = false; // reset flag } } diff --git a/dGame/dComponents/PossessableComponent.h b/dGame/dComponents/PossessableComponent.h index 3b075d33..6f1968a5 100644 --- a/dGame/dComponents/PossessableComponent.h +++ b/dGame/dComponents/PossessableComponent.h @@ -18,7 +18,7 @@ public: PossessableComponent(Entity* parentEntity, uint32_t componentId); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * @brief mounts the Entity diff --git a/dGame/dComponents/PossessorComponent.cpp b/dGame/dComponents/PossessorComponent.cpp index 0cb64956..46ccbffb 100644 --- a/dGame/dComponents/PossessorComponent.cpp +++ b/dGame/dComponents/PossessorComponent.cpp @@ -26,15 +26,15 @@ PossessorComponent::~PossessorComponent() { } } -void PossessorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(m_DirtyPossesor || bIsInitialUpdate); +void PossessorComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(m_DirtyPossesor || bIsInitialUpdate); if (m_DirtyPossesor || bIsInitialUpdate) { m_DirtyPossesor = false; - outBitStream->Write(m_Possessable != LWOOBJID_EMPTY); + outBitStream.Write(m_Possessable != LWOOBJID_EMPTY); if (m_Possessable != LWOOBJID_EMPTY) { - outBitStream->Write(m_Possessable); + outBitStream.Write(m_Possessable); } - outBitStream->Write(m_PossessableType); + outBitStream.Write(m_PossessableType); } } diff --git a/dGame/dComponents/PossessorComponent.h b/dGame/dComponents/PossessorComponent.h index e1aba048..3fa6153d 100644 --- a/dGame/dComponents/PossessorComponent.h +++ b/dGame/dComponents/PossessorComponent.h @@ -23,7 +23,7 @@ public: PossessorComponent(Entity* parent); ~PossessorComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * @brief Mounts the entity diff --git a/dGame/dComponents/QuickBuildComponent.cpp b/dGame/dComponents/QuickBuildComponent.cpp index 6cef87d3..c8ca4407 100644 --- a/dGame/dComponents/QuickBuildComponent.cpp +++ b/dGame/dComponents/QuickBuildComponent.cpp @@ -55,55 +55,55 @@ QuickBuildComponent::~QuickBuildComponent() { DespawnActivator(); } -void QuickBuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void QuickBuildComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { if (m_Parent->GetComponent(eReplicaComponentType::DESTROYABLE) == nullptr) { if (bIsInitialUpdate) { - outBitStream->Write(false); + outBitStream.Write(false); } - outBitStream->Write(false); + outBitStream.Write(false); - outBitStream->Write(false); + outBitStream.Write(false); } // If build state is completed and we've already serialized once in the completed state, // don't serializing this component anymore as this will cause the build to jump again. // If state changes, serialization will begin again. if (!m_StateDirty && m_State == eQuickBuildState::COMPLETED) { - outBitStream->Write0(); - outBitStream->Write0(); + outBitStream.Write0(); + outBitStream.Write0(); return; } // BEGIN Scripted Activity - outBitStream->Write1(); + outBitStream.Write1(); Entity* builder = GetBuilder(); if (builder) { - outBitStream->Write(1); - outBitStream->Write(builder->GetObjectID()); + outBitStream.Write(1); + outBitStream.Write(builder->GetObjectID()); for (int i = 0; i < 10; i++) { - outBitStream->Write(0.0f); + outBitStream.Write(0.0f); } } else { - outBitStream->Write(0); + outBitStream.Write(0); } // END Scripted Activity - outBitStream->Write1(); + outBitStream.Write1(); - outBitStream->Write(m_State); + outBitStream.Write(m_State); - outBitStream->Write(m_ShowResetEffect); - outBitStream->Write(m_Activator != nullptr); + outBitStream.Write(m_ShowResetEffect); + outBitStream.Write(m_Activator != nullptr); - outBitStream->Write(m_Timer); - outBitStream->Write(m_TimerIncomplete); + outBitStream.Write(m_Timer); + outBitStream.Write(m_TimerIncomplete); if (bIsInitialUpdate) { - outBitStream->Write(false); - outBitStream->Write(m_ActivatorPosition); - outBitStream->Write(m_RepositionPlayer); + outBitStream.Write(false); + outBitStream.Write(m_ActivatorPosition); + outBitStream.Write(m_RepositionPlayer); } m_StateDirty = false; } diff --git a/dGame/dComponents/QuickBuildComponent.h b/dGame/dComponents/QuickBuildComponent.h index 556264a8..1cab8660 100644 --- a/dGame/dComponents/QuickBuildComponent.h +++ b/dGame/dComponents/QuickBuildComponent.h @@ -27,7 +27,7 @@ public: QuickBuildComponent(Entity* const entity); ~QuickBuildComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; /** diff --git a/dGame/dComponents/RacingControlComponent.cpp b/dGame/dComponents/RacingControlComponent.cpp index f3772aad..d7e01f94 100644 --- a/dGame/dComponents/RacingControlComponent.cpp +++ b/dGame/dComponents/RacingControlComponent.cpp @@ -433,83 +433,83 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t bu } } -void RacingControlComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void RacingControlComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { // BEGIN Scripted Activity - outBitStream->Write1(); + outBitStream.Write1(); - outBitStream->Write(m_RacingPlayers.size()); + outBitStream.Write(m_RacingPlayers.size()); for (const auto& player : m_RacingPlayers) { - outBitStream->Write(player.playerID); + outBitStream.Write(player.playerID); - outBitStream->Write(player.data[0]); - if (player.finished != 0) outBitStream->Write(player.raceTime); - else outBitStream->Write(player.data[1]); - if (player.finished != 0) outBitStream->Write(player.bestLapTime); - else outBitStream->Write(player.data[2]); - if (player.finished == 1) outBitStream->Write(1.0f); - else outBitStream->Write(player.data[3]); - outBitStream->Write(player.data[4]); - outBitStream->Write(player.data[5]); - outBitStream->Write(player.data[6]); - outBitStream->Write(player.data[7]); - outBitStream->Write(player.data[8]); - outBitStream->Write(player.data[9]); + outBitStream.Write(player.data[0]); + if (player.finished != 0) outBitStream.Write(player.raceTime); + else outBitStream.Write(player.data[1]); + if (player.finished != 0) outBitStream.Write(player.bestLapTime); + else outBitStream.Write(player.data[2]); + if (player.finished == 1) outBitStream.Write(1.0f); + else outBitStream.Write(player.data[3]); + outBitStream.Write(player.data[4]); + outBitStream.Write(player.data[5]); + outBitStream.Write(player.data[6]); + outBitStream.Write(player.data[7]); + outBitStream.Write(player.data[8]); + outBitStream.Write(player.data[9]); } // END Scripted Activity - outBitStream->Write1(); - outBitStream->Write(m_RacingPlayers.size()); + outBitStream.Write1(); + outBitStream.Write(m_RacingPlayers.size()); - outBitStream->Write(!m_AllPlayersReady); + outBitStream.Write(!m_AllPlayersReady); if (!m_AllPlayersReady) { int32_t numReady = 0; for (const auto& player : m_RacingPlayers) { - outBitStream->Write1(); // Has more player data - outBitStream->Write(player.playerID); - outBitStream->Write(player.vehicleID); - outBitStream->Write(player.playerIndex); - outBitStream->Write(player.playerLoaded); + outBitStream.Write1(); // Has more player data + outBitStream.Write(player.playerID); + outBitStream.Write(player.vehicleID); + outBitStream.Write(player.playerIndex); + outBitStream.Write(player.playerLoaded); if (player.playerLoaded) numReady++; } - outBitStream->Write0(); // No more data + outBitStream.Write0(); // No more data if (numReady == m_RacingPlayers.size()) m_AllPlayersReady = true; } - outBitStream->Write(!m_RacingPlayers.empty()); + outBitStream.Write(!m_RacingPlayers.empty()); if (!m_RacingPlayers.empty()) { for (const auto& player : m_RacingPlayers) { if (player.finished == 0) continue; - outBitStream->Write1(); // Has more date + outBitStream.Write1(); // Has more date - outBitStream->Write(player.playerID); - outBitStream->Write(player.finished); + outBitStream.Write(player.playerID); + outBitStream.Write(player.finished); } - outBitStream->Write0(); // No more data + outBitStream.Write0(); // No more data } - outBitStream->Write(bIsInitialUpdate); + outBitStream.Write(bIsInitialUpdate); if (bIsInitialUpdate) { - outBitStream->Write(m_RemainingLaps); - outBitStream->Write(m_PathName.size()); + outBitStream.Write(m_RemainingLaps); + outBitStream.Write(m_PathName.size()); for (const auto character : m_PathName) { - outBitStream->Write(character); + outBitStream.Write(character); } } - outBitStream->Write(!m_RacingPlayers.empty()); + outBitStream.Write(!m_RacingPlayers.empty()); if (!m_RacingPlayers.empty()) { for (const auto& player : m_RacingPlayers) { if (player.finished == 0) continue; - outBitStream->Write1(); // Has more data - outBitStream->Write(player.playerID); - outBitStream->Write(player.bestLapTime); - outBitStream->Write(player.raceTime); + outBitStream.Write1(); // Has more data + outBitStream.Write(player.playerID); + outBitStream.Write(player.bestLapTime); + outBitStream.Write(player.raceTime); } - outBitStream->Write0(); // No more data + outBitStream.Write0(); // No more data } } diff --git a/dGame/dComponents/RacingControlComponent.h b/dGame/dComponents/RacingControlComponent.h index 4a7d387f..790459e3 100644 --- a/dGame/dComponents/RacingControlComponent.h +++ b/dGame/dComponents/RacingControlComponent.h @@ -110,7 +110,7 @@ public: RacingControlComponent(Entity* parentEntity); ~RacingControlComponent(); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; /** diff --git a/dGame/dComponents/RenderComponent.cpp b/dGame/dComponents/RenderComponent.cpp index 118e4847..2067ef2a 100644 --- a/dGame/dComponents/RenderComponent.cpp +++ b/dGame/dComponents/RenderComponent.cpp @@ -45,25 +45,25 @@ RenderComponent::RenderComponent(Entity* const parentEntity, const int32_t compo result.finalize(); } -void RenderComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void RenderComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { if (!bIsInitialUpdate) return; - outBitStream->Write(m_Effects.size()); + outBitStream.Write(m_Effects.size()); for (auto& eff : m_Effects) { - outBitStream->Write(eff.name.size()); + outBitStream.Write(eff.name.size()); // if there is no name, then we don't write anything else if (eff.name.empty()) continue; - for (const auto& value : eff.name) outBitStream->Write(value); + for (const auto& value : eff.name) outBitStream.Write(value); - outBitStream->Write(eff.effectID); + outBitStream.Write(eff.effectID); - outBitStream->Write(eff.type.size()); - for (const auto& value : eff.type) outBitStream->Write(value); + outBitStream.Write(eff.type.size()); + for (const auto& value : eff.type) outBitStream.Write(value); - outBitStream->Write(eff.priority); - outBitStream->Write(eff.secondary); + outBitStream.Write(eff.priority); + outBitStream.Write(eff.secondary); } } diff --git a/dGame/dComponents/RenderComponent.h b/dGame/dComponents/RenderComponent.h index 87b210d7..e2bbcff5 100644 --- a/dGame/dComponents/RenderComponent.h +++ b/dGame/dComponents/RenderComponent.h @@ -65,7 +65,7 @@ public: RenderComponent(Entity* const parentEntity, const int32_t componentId = -1); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; /** diff --git a/dGame/dComponents/RigidbodyPhantomPhysicsComponent.cpp b/dGame/dComponents/RigidbodyPhantomPhysicsComponent.cpp index 414ce2e8..30faa688 100644 --- a/dGame/dComponents/RigidbodyPhantomPhysicsComponent.cpp +++ b/dGame/dComponents/RigidbodyPhantomPhysicsComponent.cpp @@ -11,6 +11,6 @@ RigidbodyPhantomPhysicsComponent::RigidbodyPhantomPhysicsComponent(Entity* paren m_Rotation = m_Parent->GetDefaultRotation(); } -void RigidbodyPhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void RigidbodyPhantomPhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { PhysicsComponent::Serialize(outBitStream, bIsInitialUpdate); } diff --git a/dGame/dComponents/RigidbodyPhantomPhysicsComponent.h b/dGame/dComponents/RigidbodyPhantomPhysicsComponent.h index 082dd1e7..09820f8e 100644 --- a/dGame/dComponents/RigidbodyPhantomPhysicsComponent.h +++ b/dGame/dComponents/RigidbodyPhantomPhysicsComponent.h @@ -23,7 +23,7 @@ public: RigidbodyPhantomPhysicsComponent(Entity* parent); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; }; #endif // __RIGIDBODYPHANTOMPHYSICS_H__ diff --git a/dGame/dComponents/RocketLaunchpadControlComponent.cpp b/dGame/dComponents/RocketLaunchpadControlComponent.cpp index 5a385546..2bc4deec 100644 --- a/dGame/dComponents/RocketLaunchpadControlComponent.cpp +++ b/dGame/dComponents/RocketLaunchpadControlComponent.cpp @@ -139,7 +139,7 @@ void RocketLaunchpadControlComponent::TellMasterToPrepZone(int zoneID) { CBITSTREAM; BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::PREP_ZONE); bitStream.Write(zoneID); - Game::server->SendToMaster(&bitStream); + Game::server->SendToMaster(bitStream); } diff --git a/dGame/dComponents/ShootingGalleryComponent.cpp b/dGame/dComponents/ShootingGalleryComponent.cpp index 45cd9342..20665a01 100644 --- a/dGame/dComponents/ShootingGalleryComponent.cpp +++ b/dGame/dComponents/ShootingGalleryComponent.cpp @@ -17,50 +17,50 @@ void ShootingGalleryComponent::SetDynamicParams(const DynamicShootingGalleryPara Game::entityManager->SerializeEntity(m_Parent); } -void ShootingGalleryComponent::Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate) { +void ShootingGalleryComponent::Serialize(RakNet::BitStream& outBitStream, bool isInitialUpdate) { // Start ScriptedActivityComponent - outBitStream->Write(true); + outBitStream.Write(true); if (m_CurrentPlayerID == LWOOBJID_EMPTY) { - outBitStream->Write(0); + outBitStream.Write(0); } else { - outBitStream->Write(1); - outBitStream->Write(m_CurrentPlayerID); + outBitStream.Write(1); + outBitStream.Write(m_CurrentPlayerID); for (size_t i = 0; i < 10; i++) { - outBitStream->Write(0.0f); + outBitStream.Write(0.0f); } } // End ScriptedActivityComponent if (isInitialUpdate) { - outBitStream->Write(m_StaticParams.cameraPosition.GetX()); - outBitStream->Write(m_StaticParams.cameraPosition.GetY()); - outBitStream->Write(m_StaticParams.cameraPosition.GetZ()); + outBitStream.Write(m_StaticParams.cameraPosition.GetX()); + outBitStream.Write(m_StaticParams.cameraPosition.GetY()); + outBitStream.Write(m_StaticParams.cameraPosition.GetZ()); - outBitStream->Write(m_StaticParams.cameraLookatPosition.GetX()); - outBitStream->Write(m_StaticParams.cameraLookatPosition.GetY()); - outBitStream->Write(m_StaticParams.cameraLookatPosition.GetZ()); + outBitStream.Write(m_StaticParams.cameraLookatPosition.GetX()); + outBitStream.Write(m_StaticParams.cameraLookatPosition.GetY()); + outBitStream.Write(m_StaticParams.cameraLookatPosition.GetZ()); } - outBitStream->Write(m_Dirty || isInitialUpdate); + outBitStream.Write(m_Dirty || isInitialUpdate); if (m_Dirty || isInitialUpdate) { - outBitStream->Write(m_DynamicParams.cannonVelocity); - outBitStream->Write(m_DynamicParams.cannonRefireRate); - outBitStream->Write(m_DynamicParams.cannonMinDistance); + outBitStream.Write(m_DynamicParams.cannonVelocity); + outBitStream.Write(m_DynamicParams.cannonRefireRate); + outBitStream.Write(m_DynamicParams.cannonMinDistance); - outBitStream->Write(m_DynamicParams.cameraBarrelOffset.GetX()); - outBitStream->Write(m_DynamicParams.cameraBarrelOffset.GetY()); - outBitStream->Write(m_DynamicParams.cameraBarrelOffset.GetZ()); + outBitStream.Write(m_DynamicParams.cameraBarrelOffset.GetX()); + outBitStream.Write(m_DynamicParams.cameraBarrelOffset.GetY()); + outBitStream.Write(m_DynamicParams.cameraBarrelOffset.GetZ()); - outBitStream->Write(m_DynamicParams.cannonAngle); + outBitStream.Write(m_DynamicParams.cannonAngle); - outBitStream->Write(m_DynamicParams.facing.GetX()); - outBitStream->Write(m_DynamicParams.facing.GetY()); - outBitStream->Write(m_DynamicParams.facing.GetZ()); + outBitStream.Write(m_DynamicParams.facing.GetX()); + outBitStream.Write(m_DynamicParams.facing.GetY()); + outBitStream.Write(m_DynamicParams.facing.GetZ()); - outBitStream->Write(m_CurrentPlayerID); - outBitStream->Write(m_DynamicParams.cannonTimeout); - outBitStream->Write(m_DynamicParams.cannonFOV); + outBitStream.Write(m_CurrentPlayerID); + outBitStream.Write(m_DynamicParams.cannonTimeout); + outBitStream.Write(m_DynamicParams.cannonFOV); if (!isInitialUpdate) m_Dirty = false; } } diff --git a/dGame/dComponents/ShootingGalleryComponent.h b/dGame/dComponents/ShootingGalleryComponent.h index c4b8fea2..9382d87e 100644 --- a/dGame/dComponents/ShootingGalleryComponent.h +++ b/dGame/dComponents/ShootingGalleryComponent.h @@ -77,7 +77,7 @@ public: explicit ShootingGalleryComponent(Entity* parent); ~ShootingGalleryComponent(); - void Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool isInitialUpdate) override; /** * Returns the static params for the shooting gallery diff --git a/dGame/dComponents/SimplePhysicsComponent.cpp b/dGame/dComponents/SimplePhysicsComponent.cpp index 3d8165dd..3b52395e 100644 --- a/dGame/dComponents/SimplePhysicsComponent.cpp +++ b/dGame/dComponents/SimplePhysicsComponent.cpp @@ -32,26 +32,26 @@ SimplePhysicsComponent::SimplePhysicsComponent(Entity* parent, uint32_t componen SimplePhysicsComponent::~SimplePhysicsComponent() { } -void SimplePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void SimplePhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { if (bIsInitialUpdate) { - outBitStream->Write(m_ClimbableType != eClimbableType::CLIMBABLE_TYPE_NOT); - outBitStream->Write(m_ClimbableType); + outBitStream.Write(m_ClimbableType != eClimbableType::CLIMBABLE_TYPE_NOT); + outBitStream.Write(m_ClimbableType); } - outBitStream->Write(m_DirtyVelocity || bIsInitialUpdate); + outBitStream.Write(m_DirtyVelocity || bIsInitialUpdate); if (m_DirtyVelocity || bIsInitialUpdate) { - outBitStream->Write(m_Velocity); - outBitStream->Write(m_AngularVelocity); + outBitStream.Write(m_Velocity); + outBitStream.Write(m_AngularVelocity); m_DirtyVelocity = false; } // Physics motion state if (m_PhysicsMotionState != 0) { - outBitStream->Write1(); - outBitStream->Write(m_PhysicsMotionState); + outBitStream.Write1(); + outBitStream.Write(m_PhysicsMotionState); } else { - outBitStream->Write0(); + outBitStream.Write0(); } PhysicsComponent::Serialize(outBitStream, bIsInitialUpdate); } diff --git a/dGame/dComponents/SimplePhysicsComponent.h b/dGame/dComponents/SimplePhysicsComponent.h index 8f92dd95..c6ef52a0 100644 --- a/dGame/dComponents/SimplePhysicsComponent.h +++ b/dGame/dComponents/SimplePhysicsComponent.h @@ -33,7 +33,7 @@ public: SimplePhysicsComponent(Entity* parent, uint32_t componentID); ~SimplePhysicsComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Returns the velocity of this entity diff --git a/dGame/dComponents/SkillComponent.cpp b/dGame/dComponents/SkillComponent.cpp index c43813c1..329246f4 100644 --- a/dGame/dComponents/SkillComponent.cpp +++ b/dGame/dComponents/SkillComponent.cpp @@ -31,7 +31,7 @@ ProjectileSyncEntry::ProjectileSyncEntry() { std::unordered_map SkillComponent::m_skillBehaviorCache = {}; -bool SkillComponent::CastPlayerSkill(const uint32_t behaviorId, const uint32_t skillUid, RakNet::BitStream* bitStream, const LWOOBJID target, uint32_t skillID) { +bool SkillComponent::CastPlayerSkill(const uint32_t behaviorId, const uint32_t skillUid, RakNet::BitStream& bitStream, const LWOOBJID target, uint32_t skillID) { auto* context = new BehaviorContext(this->m_Parent->GetObjectID()); context->caster = m_Parent->GetObjectID(); @@ -51,7 +51,7 @@ bool SkillComponent::CastPlayerSkill(const uint32_t behaviorId, const uint32_t s return !context->failed; } -void SkillComponent::SyncPlayerSkill(const uint32_t skillUid, const uint32_t syncId, RakNet::BitStream* bitStream) { +void SkillComponent::SyncPlayerSkill(const uint32_t skillUid, const uint32_t syncId, RakNet::BitStream& bitStream) { const auto index = this->m_managedBehaviors.find(skillUid); if (index == this->m_managedBehaviors.end()) { @@ -66,7 +66,7 @@ void SkillComponent::SyncPlayerSkill(const uint32_t skillUid, const uint32_t syn } -void SkillComponent::SyncPlayerProjectile(const LWOOBJID projectileId, RakNet::BitStream* bitStream, const LWOOBJID target) { +void SkillComponent::SyncPlayerProjectile(const LWOOBJID projectileId, RakNet::BitStream& bitStream, const LWOOBJID target) { auto index = -1; for (auto i = 0u; i < this->m_managedProjectiles.size(); ++i) { @@ -252,7 +252,7 @@ bool SkillComponent::CastSkill(const uint32_t skillId, LWOOBJID target, const LW SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, const uint32_t behaviorId, const LWOOBJID target, const bool ignoreTarget, const bool clientInitalized, const LWOOBJID originatorOverride) { - auto* bitStream = new RakNet::BitStream(); + RakNet::BitStream bitStream{}; auto* behavior = Behavior::CreateBehavior(behaviorId); @@ -273,7 +273,6 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c } if (!context->foundTarget) { - delete bitStream; delete context; // Invalid attack @@ -299,22 +298,20 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c } //start.optionalTargetID = target; - start.sBitStream.assign(reinterpret_cast(bitStream->GetData()), bitStream->GetNumberOfBytesUsed()); + start.sBitStream.assign(reinterpret_cast(bitStream.GetData()), bitStream.GetNumberOfBytesUsed()); // Write message RakNet::BitStream message; BitStreamUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG); message.Write(this->m_Parent->GetObjectID()); - start.Serialize(&message); + start.Serialize(message); - Game::server->Send(&message, UNASSIGNED_SYSTEM_ADDRESS, true); + Game::server->Send(message, UNASSIGNED_SYSTEM_ADDRESS, true); } context->ExecuteUpdates(); - delete bitStream; - // Valid attack return { true, context->skillTime }; } @@ -424,13 +421,13 @@ void SkillComponent::SyncProjectileCalculation(const ProjectileSyncEntry& entry) auto* behavior = Behavior::CreateBehavior(behaviorId); - auto* bitStream = new RakNet::BitStream(); + RakNet::BitStream bitStream{}; behavior->Calculate(entry.context, bitStream, entry.branchContext); DoClientProjectileImpact projectileImpact; - projectileImpact.sBitStream.assign(reinterpret_cast(bitStream->GetData()), bitStream->GetNumberOfBytesUsed()); + projectileImpact.sBitStream.assign(reinterpret_cast(bitStream.GetData()), bitStream.GetNumberOfBytesUsed()); projectileImpact.i64OwnerID = this->m_Parent->GetObjectID(); projectileImpact.i64OrgID = entry.id; projectileImpact.i64TargetID = entry.branchContext.target; @@ -439,42 +436,34 @@ void SkillComponent::SyncProjectileCalculation(const ProjectileSyncEntry& entry) BitStreamUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG); message.Write(this->m_Parent->GetObjectID()); - projectileImpact.Serialize(&message); + projectileImpact.Serialize(message); - Game::server->Send(&message, UNASSIGNED_SYSTEM_ADDRESS, true); + Game::server->Send(message, UNASSIGNED_SYSTEM_ADDRESS, true); entry.context->ExecuteUpdates(); - - delete bitStream; } void SkillComponent::HandleUnmanaged(const uint32_t behaviorId, const LWOOBJID target, LWOOBJID source) { - auto* context = new BehaviorContext(source); + BehaviorContext context{ source }; - context->unmanaged = true; - context->caster = target; + context.unmanaged = true; + context.caster = target; auto* behavior = Behavior::CreateBehavior(behaviorId); - auto* bitStream = new RakNet::BitStream(); + RakNet::BitStream bitStream{}; - behavior->Handle(context, bitStream, { target }); - - delete bitStream; - - delete context; + behavior->Handle(&context, bitStream, { target }); } void SkillComponent::HandleUnCast(const uint32_t behaviorId, const LWOOBJID target) { - auto* context = new BehaviorContext(target); + BehaviorContext context{ target }; - context->caster = target; + context.caster = target; auto* behavior = Behavior::CreateBehavior(behaviorId); - behavior->UnCast(context, { target }); - - delete context; + behavior->UnCast(&context, { target }); } SkillComponent::SkillComponent(Entity* parent): Component(parent) { @@ -485,8 +474,8 @@ SkillComponent::~SkillComponent() { Reset(); } -void SkillComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - if (bIsInitialUpdate) outBitStream->Write0(); +void SkillComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + if (bIsInitialUpdate) outBitStream.Write0(); } /// diff --git a/dGame/dComponents/SkillComponent.h b/dGame/dComponents/SkillComponent.h index 530c2a25..2acae5d7 100644 --- a/dGame/dComponents/SkillComponent.h +++ b/dGame/dComponents/SkillComponent.h @@ -64,7 +64,7 @@ public: explicit SkillComponent(Entity* parent); ~SkillComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Computes skill updates. Invokes CalculateUpdate. @@ -93,7 +93,7 @@ public: * @param bitStream the bitSteam given by the client to determine the behavior path * @param target the explicit target of the skill */ - bool CastPlayerSkill(uint32_t behaviorId, uint32_t skillUid, RakNet::BitStream* bitStream, LWOOBJID target, uint32_t skillID = 0); + bool CastPlayerSkill(uint32_t behaviorId, uint32_t skillUid, RakNet::BitStream& bitStream, LWOOBJID target, uint32_t skillID = 0); /** * Continues a player skill. Should only be called when the server receives a sync message from the client. @@ -101,7 +101,7 @@ public: * @param syncId the unique sync ID of the skill given by the client * @param bitStream the bitSteam given by the client to determine the behavior path */ - void SyncPlayerSkill(uint32_t skillUid, uint32_t syncId, RakNet::BitStream* bitStream); + void SyncPlayerSkill(uint32_t skillUid, uint32_t syncId, RakNet::BitStream& bitStream); /** * Continues a player projectile calculation. Should only be called when the server receives a projectile sync message from the client. @@ -109,7 +109,7 @@ public: * @param bitStream the bitSteam given by the client to determine the behavior path * @param target the explicit target of the target */ - void SyncPlayerProjectile(LWOOBJID projectileId, RakNet::BitStream* bitStream, LWOOBJID target); + void SyncPlayerProjectile(LWOOBJID projectileId, RakNet::BitStream& bitStream, LWOOBJID target); /** * Registers a player projectile. Should only be called when the server is computing a player projectile. diff --git a/dGame/dComponents/SoundTriggerComponent.cpp b/dGame/dComponents/SoundTriggerComponent.cpp index 34d2441c..878ce848 100644 --- a/dGame/dComponents/SoundTriggerComponent.cpp +++ b/dGame/dComponents/SoundTriggerComponent.cpp @@ -2,28 +2,28 @@ #include "Game.h" #include "Logger.h" -void MusicCue::Serialize(RakNet::BitStream* outBitStream){ - outBitStream->Write(name.size()); - outBitStream->Write(name.c_str(), name.size()); - outBitStream->Write(result); - outBitStream->Write(boredomTime); +void MusicCue::Serialize(RakNet::BitStream& outBitStream){ + outBitStream.Write(name.size()); + outBitStream.Write(name.c_str(), name.size()); + outBitStream.Write(result); + outBitStream.Write(boredomTime); } -void MusicParameter::Serialize(RakNet::BitStream* outBitStream){ - outBitStream->Write(name.size()); - outBitStream->Write(name.c_str(), name.size()); - outBitStream->Write(value); +void MusicParameter::Serialize(RakNet::BitStream& outBitStream){ + outBitStream.Write(name.size()); + outBitStream.Write(name.c_str(), name.size()); + outBitStream.Write(value); } -void GUIDResults::Serialize(RakNet::BitStream* outBitStream){ +void GUIDResults::Serialize(RakNet::BitStream& outBitStream){ guid.Serialize(outBitStream); - outBitStream->Write(result); + outBitStream.Write(result); } -void MixerProgram::Serialize(RakNet::BitStream* outBitStream){ - outBitStream->Write(name.size()); - outBitStream->Write(name.c_str(), name.size()); - outBitStream->Write(result); +void MixerProgram::Serialize(RakNet::BitStream& outBitStream){ + outBitStream.Write(name.size()); + outBitStream.Write(name.c_str(), name.size()); + outBitStream.Write(result); } SoundTriggerComponent::SoundTriggerComponent(Entity* parent) : Component(parent) { @@ -55,30 +55,30 @@ SoundTriggerComponent::SoundTriggerComponent(Entity* parent) : Component(parent) if (!mixerName.empty()) this->m_MixerPrograms.push_back(MixerProgram(mixerName)); } -void SoundTriggerComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(this->m_Dirty || bIsInitialUpdate); +void SoundTriggerComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(this->m_Dirty || bIsInitialUpdate); if (this->m_Dirty || bIsInitialUpdate) { - outBitStream->Write(this->m_MusicCues.size()); + outBitStream.Write(this->m_MusicCues.size()); for (auto& musicCue : this->m_MusicCues) { musicCue.Serialize(outBitStream); } - outBitStream->Write(this->m_MusicParameters.size()); + outBitStream.Write(this->m_MusicParameters.size()); for (auto& musicParam : this->m_MusicParameters) { musicParam.Serialize(outBitStream); } - outBitStream->Write(this->m_2DAmbientSounds.size()); + outBitStream.Write(this->m_2DAmbientSounds.size()); for (auto twoDAmbientSound : this->m_2DAmbientSounds) { twoDAmbientSound.Serialize(outBitStream); } - outBitStream->Write(this->m_3DAmbientSounds.size()); + outBitStream.Write(this->m_3DAmbientSounds.size()); for (auto threeDAmbientSound : this->m_3DAmbientSounds) { threeDAmbientSound.Serialize(outBitStream); } - outBitStream->Write(this->m_MixerPrograms.size()); + outBitStream.Write(this->m_MixerPrograms.size()); for (auto& mixerProgram : this->m_MixerPrograms) { mixerProgram.Serialize(outBitStream); } diff --git a/dGame/dComponents/SoundTriggerComponent.h b/dGame/dComponents/SoundTriggerComponent.h index 48366017..2851aff1 100644 --- a/dGame/dComponents/SoundTriggerComponent.h +++ b/dGame/dComponents/SoundTriggerComponent.h @@ -17,7 +17,7 @@ struct MusicCue { this->boredomTime = boredomTime; }; - void Serialize(RakNet::BitStream* outBitStream); + void Serialize(RakNet::BitStream& outBitStream); }; struct MusicParameter { @@ -29,7 +29,7 @@ struct MusicParameter { this->value = value; } - void Serialize(RakNet::BitStream* outBitStream); + void Serialize(RakNet::BitStream& outBitStream); }; struct GUIDResults{ @@ -41,7 +41,7 @@ struct GUIDResults{ this->result = result; } - void Serialize(RakNet::BitStream* outBitStream); + void Serialize(RakNet::BitStream& outBitStream); }; struct MixerProgram { @@ -53,7 +53,7 @@ struct MixerProgram { this->result = result; } - void Serialize(RakNet::BitStream* outBitStream); + void Serialize(RakNet::BitStream& outBitStream); }; @@ -61,7 +61,7 @@ class SoundTriggerComponent : public Component { public: static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SOUND_TRIGGER; explicit SoundTriggerComponent(Entity* parent); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void ActivateMusicCue(const std::string& name, float bordemTime = -1.0); void DeactivateMusicCue(const std::string& name); diff --git a/dGame/dComponents/SwitchComponent.cpp b/dGame/dComponents/SwitchComponent.cpp index 25f18a4d..e6ad6d00 100644 --- a/dGame/dComponents/SwitchComponent.cpp +++ b/dGame/dComponents/SwitchComponent.cpp @@ -21,8 +21,8 @@ SwitchComponent::~SwitchComponent() { } } -void SwitchComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(m_Active); +void SwitchComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(m_Active); } void SwitchComponent::SetActive(bool active) { diff --git a/dGame/dComponents/SwitchComponent.h b/dGame/dComponents/SwitchComponent.h index f732a8c1..862e5719 100644 --- a/dGame/dComponents/SwitchComponent.h +++ b/dGame/dComponents/SwitchComponent.h @@ -25,7 +25,7 @@ public: Entity* GetParentEntity() const; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Sets whether the switch is on or off. diff --git a/dGame/dComponents/VendorComponent.cpp b/dGame/dComponents/VendorComponent.cpp index afa3d013..8a26399c 100644 --- a/dGame/dComponents/VendorComponent.cpp +++ b/dGame/dComponents/VendorComponent.cpp @@ -8,6 +8,11 @@ #include "CDLootMatrixTable.h" #include "CDLootTableTable.h" #include "CDItemComponentTable.h" +#include "InventoryComponent.h" +#include "Character.h" +#include "eVendorTransactionResult.h" +#include "UserManager.h" +#include "CheatDetection.h" VendorComponent::VendorComponent(Entity* parent) : Component(parent) { m_HasStandardCostItems = false; @@ -16,11 +21,11 @@ VendorComponent::VendorComponent(Entity* parent) : Component(parent) { RefreshInventory(true); } -void VendorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(bIsInitialUpdate || m_DirtyVendor); +void VendorComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(bIsInitialUpdate || m_DirtyVendor); if (bIsInitialUpdate || m_DirtyVendor) { - outBitStream->Write(m_HasStandardCostItems); - outBitStream->Write(m_HasMultiCostItems); + outBitStream.Write(m_HasStandardCostItems); + outBitStream.Write(m_HasMultiCostItems); if (!bIsInitialUpdate) m_DirtyVendor = false; } } @@ -151,3 +156,60 @@ void VendorComponent::HandleMrReeCameras(){ m_Inventory.push_back(SoldItem(camera, 0)); } } + + +void VendorComponent::Buy(Entity* buyer, LOT lot, uint32_t count) { + + if (!SellsItem(lot)) { + auto* user = UserManager::Instance()->GetUser(buyer->GetSystemAddress()); + CheatDetection::ReportCheat(user, buyer->GetSystemAddress(), "Attempted to buy item %i from achievement vendor %i that is not purchasable", lot, m_Parent->GetLOT()); + GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_FAIL); + return; + } + + auto* inventoryComponent = buyer->GetComponent(); + if (!inventoryComponent) { + GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_FAIL); + return; + } + CDComponentsRegistryTable* compRegistryTable = CDClientManager::GetTable(); + CDItemComponentTable* itemComponentTable = CDClientManager::GetTable(); + int itemCompID = compRegistryTable->GetByIDAndType(lot, eReplicaComponentType::ITEM); + CDItemComponent itemComp = itemComponentTable->GetItemComponentByID(itemCompID); + + // Extra currency that needs to be deducted in case of crafting + auto craftingCurrencies = CDItemComponentTable::ParseCraftingCurrencies(itemComp); + for (const auto& [crafintCurrencyLOT, crafintCurrencyCount]: craftingCurrencies) { + if (inventoryComponent->GetLotCount(crafintCurrencyLOT) < (crafintCurrencyCount * count)) { + GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_FAIL); + return; + } + } + for (const auto& [crafintCurrencyLOT, crafintCurrencyCount]: craftingCurrencies) { + inventoryComponent->RemoveItem(crafintCurrencyLOT, crafintCurrencyCount * count); + } + + + float buyScalar = GetBuyScalar(); + const auto coinCost = static_cast(std::floor((itemComp.baseValue * buyScalar) * count)); + + Character* character = buyer->GetCharacter(); + if (!character || character->GetCoins() < coinCost) { + GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_FAIL); + return; + } + + if (Inventory::IsValidItem(itemComp.currencyLOT)) { + const uint32_t altCurrencyCost = std::floor(itemComp.altCurrencyCost * buyScalar) * count; + if (inventoryComponent->GetLotCount(itemComp.currencyLOT) < altCurrencyCost) { + GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_FAIL); + return; + } + inventoryComponent->RemoveItem(itemComp.currencyLOT, altCurrencyCost); + } + + character->SetCoins(character->GetCoins() - (coinCost), eLootSourceType::VENDOR); + inventoryComponent->AddItem(lot, count, eLootSourceType::VENDOR); + GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_SUCCESS); + +} \ No newline at end of file diff --git a/dGame/dComponents/VendorComponent.h b/dGame/dComponents/VendorComponent.h index 48b766d2..2abd3536 100644 --- a/dGame/dComponents/VendorComponent.h +++ b/dGame/dComponents/VendorComponent.h @@ -23,7 +23,7 @@ public: static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::VENDOR; VendorComponent(Entity* parent); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void OnUse(Entity* originator) override; void RefreshInventory(bool isCreation = false); @@ -47,6 +47,7 @@ public: m_DirtyVendor = true; } + void Buy(Entity* buyer, LOT lot, uint32_t count); private: void SetupMaxCustomVendor(); diff --git a/dGame/dGameMessages/DoClientProjectileImpact.h b/dGame/dGameMessages/DoClientProjectileImpact.h index 6b381aa5..b8e3b528 100644 --- a/dGame/dGameMessages/DoClientProjectileImpact.h +++ b/dGame/dGameMessages/DoClientProjectileImpact.h @@ -19,51 +19,51 @@ public: sBitStream = _sBitStream; } - DoClientProjectileImpact(RakNet::BitStream* stream) : DoClientProjectileImpact() { + DoClientProjectileImpact(RakNet::BitStream& stream) : DoClientProjectileImpact() { Deserialize(stream); } ~DoClientProjectileImpact() { } - void Serialize(RakNet::BitStream* stream) { - stream->Write(eGameMessageType::DO_CLIENT_PROJECTILE_IMPACT); + void Serialize(RakNet::BitStream& stream) { + stream.Write(eGameMessageType::DO_CLIENT_PROJECTILE_IMPACT); - stream->Write(i64OrgID != LWOOBJID_EMPTY); - if (i64OrgID != LWOOBJID_EMPTY) stream->Write(i64OrgID); + stream.Write(i64OrgID != LWOOBJID_EMPTY); + if (i64OrgID != LWOOBJID_EMPTY) stream.Write(i64OrgID); - stream->Write(i64OwnerID != LWOOBJID_EMPTY); - if (i64OwnerID != LWOOBJID_EMPTY) stream->Write(i64OwnerID); + stream.Write(i64OwnerID != LWOOBJID_EMPTY); + if (i64OwnerID != LWOOBJID_EMPTY) stream.Write(i64OwnerID); - stream->Write(i64TargetID != LWOOBJID_EMPTY); - if (i64TargetID != LWOOBJID_EMPTY) stream->Write(i64TargetID); + stream.Write(i64TargetID != LWOOBJID_EMPTY); + if (i64TargetID != LWOOBJID_EMPTY) stream.Write(i64TargetID); uint32_t sBitStreamLength = sBitStream.length(); - stream->Write(sBitStreamLength); + stream.Write(sBitStreamLength); for (uint32_t k = 0; k < sBitStreamLength; k++) { - stream->Write(sBitStream[k]); + stream.Write(sBitStream[k]); } } - bool Deserialize(RakNet::BitStream* stream) { + bool Deserialize(RakNet::BitStream& stream) { bool i64OrgIDIsDefault{}; - stream->Read(i64OrgIDIsDefault); - if (i64OrgIDIsDefault != 0) stream->Read(i64OrgID); + stream.Read(i64OrgIDIsDefault); + if (i64OrgIDIsDefault != 0) stream.Read(i64OrgID); bool i64OwnerIDIsDefault{}; - stream->Read(i64OwnerIDIsDefault); - if (i64OwnerIDIsDefault != 0) stream->Read(i64OwnerID); + stream.Read(i64OwnerIDIsDefault); + if (i64OwnerIDIsDefault != 0) stream.Read(i64OwnerID); bool i64TargetIDIsDefault{}; - stream->Read(i64TargetIDIsDefault); - if (i64TargetIDIsDefault != 0) stream->Read(i64TargetID); + stream.Read(i64TargetIDIsDefault); + if (i64TargetIDIsDefault != 0) stream.Read(i64TargetID); uint32_t sBitStreamLength{}; - stream->Read(sBitStreamLength); + stream.Read(sBitStreamLength); for (uint32_t k = 0; k < sBitStreamLength; k++) { unsigned char character; - stream->Read(character); + stream.Read(character); sBitStream.push_back(character); } diff --git a/dGame/dGameMessages/EchoStartSkill.h b/dGame/dGameMessages/EchoStartSkill.h index 389a81e0..dfb79021 100644 --- a/dGame/dGameMessages/EchoStartSkill.h +++ b/dGame/dGameMessages/EchoStartSkill.h @@ -32,85 +32,85 @@ public: uiSkillHandle = _uiSkillHandle; } - EchoStartSkill(RakNet::BitStream* stream) : EchoStartSkill() { + EchoStartSkill(RakNet::BitStream& stream) : EchoStartSkill() { Deserialize(stream); } ~EchoStartSkill() { } - void Serialize(RakNet::BitStream* stream) { - stream->Write(eGameMessageType::ECHO_START_SKILL); + void Serialize(RakNet::BitStream& stream) { + stream.Write(eGameMessageType::ECHO_START_SKILL); - stream->Write(bUsedMouse); + stream.Write(bUsedMouse); - stream->Write(fCasterLatency != 0.0f); - if (fCasterLatency != 0.0f) stream->Write(fCasterLatency); + stream.Write(fCasterLatency != 0.0f); + if (fCasterLatency != 0.0f) stream.Write(fCasterLatency); - stream->Write(iCastType != 0); - if (iCastType != 0) stream->Write(iCastType); + stream.Write(iCastType != 0); + if (iCastType != 0) stream.Write(iCastType); - stream->Write(lastClickedPosit != NiPoint3Constant::ZERO); - if (lastClickedPosit != NiPoint3Constant::ZERO) stream->Write(lastClickedPosit); + stream.Write(lastClickedPosit != NiPoint3Constant::ZERO); + if (lastClickedPosit != NiPoint3Constant::ZERO) stream.Write(lastClickedPosit); - stream->Write(optionalOriginatorID); + stream.Write(optionalOriginatorID); - stream->Write(optionalTargetID != LWOOBJID_EMPTY); - if (optionalTargetID != LWOOBJID_EMPTY) stream->Write(optionalTargetID); + stream.Write(optionalTargetID != LWOOBJID_EMPTY); + if (optionalTargetID != LWOOBJID_EMPTY) stream.Write(optionalTargetID); - stream->Write(originatorRot != NiQuaternionConstant::IDENTITY); - if (originatorRot != NiQuaternionConstant::IDENTITY) stream->Write(originatorRot); + stream.Write(originatorRot != NiQuaternionConstant::IDENTITY); + if (originatorRot != NiQuaternionConstant::IDENTITY) stream.Write(originatorRot); uint32_t sBitStreamLength = sBitStream.length(); - stream->Write(sBitStreamLength); + stream.Write(sBitStreamLength); for (uint32_t k = 0; k < sBitStreamLength; k++) { - stream->Write(sBitStream[k]); + stream.Write(sBitStream[k]); } - stream->Write(skillID); + stream.Write(skillID); - stream->Write(uiSkillHandle != 0); - if (uiSkillHandle != 0) stream->Write(uiSkillHandle); + stream.Write(uiSkillHandle != 0); + if (uiSkillHandle != 0) stream.Write(uiSkillHandle); } - bool Deserialize(RakNet::BitStream* stream) { - stream->Read(bUsedMouse); + bool Deserialize(RakNet::BitStream& stream) { + stream.Read(bUsedMouse); bool fCasterLatencyIsDefault{}; - stream->Read(fCasterLatencyIsDefault); - if (fCasterLatencyIsDefault != 0) stream->Read(fCasterLatency); + stream.Read(fCasterLatencyIsDefault); + if (fCasterLatencyIsDefault != 0) stream.Read(fCasterLatency); bool iCastTypeIsDefault{}; - stream->Read(iCastTypeIsDefault); - if (iCastTypeIsDefault != 0) stream->Read(iCastType); + stream.Read(iCastTypeIsDefault); + if (iCastTypeIsDefault != 0) stream.Read(iCastType); bool lastClickedPositIsDefault{}; - stream->Read(lastClickedPositIsDefault); - if (lastClickedPositIsDefault != 0) stream->Read(lastClickedPosit); + stream.Read(lastClickedPositIsDefault); + if (lastClickedPositIsDefault != 0) stream.Read(lastClickedPosit); - stream->Read(optionalOriginatorID); + stream.Read(optionalOriginatorID); bool optionalTargetIDIsDefault{}; - stream->Read(optionalTargetIDIsDefault); - if (optionalTargetIDIsDefault != 0) stream->Read(optionalTargetID); + stream.Read(optionalTargetIDIsDefault); + if (optionalTargetIDIsDefault != 0) stream.Read(optionalTargetID); bool originatorRotIsDefault{}; - stream->Read(originatorRotIsDefault); - if (originatorRotIsDefault != 0) stream->Read(originatorRot); + stream.Read(originatorRotIsDefault); + if (originatorRotIsDefault != 0) stream.Read(originatorRot); uint32_t sBitStreamLength{}; - stream->Read(sBitStreamLength); + stream.Read(sBitStreamLength); for (uint32_t k = 0; k < sBitStreamLength; k++) { unsigned char character; - stream->Read(character); + stream.Read(character); sBitStream.push_back(character); } - stream->Read(skillID); + stream.Read(skillID); bool uiSkillHandleIsDefault{}; - stream->Read(uiSkillHandleIsDefault); - if (uiSkillHandleIsDefault != 0) stream->Read(uiSkillHandle); + stream.Read(uiSkillHandleIsDefault); + if (uiSkillHandleIsDefault != 0) stream.Read(uiSkillHandle); return true; } diff --git a/dGame/dGameMessages/EchoSyncSkill.h b/dGame/dGameMessages/EchoSyncSkill.h index ab5a3f2b..f65daab7 100644 --- a/dGame/dGameMessages/EchoSyncSkill.h +++ b/dGame/dGameMessages/EchoSyncSkill.h @@ -21,40 +21,40 @@ public: uiSkillHandle = _uiSkillHandle; } - EchoSyncSkill(RakNet::BitStream* stream) : EchoSyncSkill() { + EchoSyncSkill(RakNet::BitStream& stream) : EchoSyncSkill() { Deserialize(stream); } ~EchoSyncSkill() { } - void Serialize(RakNet::BitStream* stream) { - stream->Write(eGameMessageType::ECHO_SYNC_SKILL); + void Serialize(RakNet::BitStream& stream) { + stream.Write(eGameMessageType::ECHO_SYNC_SKILL); - stream->Write(bDone); + stream.Write(bDone); uint32_t sBitStreamLength = sBitStream.length(); - stream->Write(sBitStreamLength); + stream.Write(sBitStreamLength); for (uint32_t k = 0; k < sBitStreamLength; k++) { - stream->Write(sBitStream[k]); + stream.Write(sBitStream[k]); } - stream->Write(uiBehaviorHandle); - stream->Write(uiSkillHandle); + stream.Write(uiBehaviorHandle); + stream.Write(uiSkillHandle); } - bool Deserialize(RakNet::BitStream* stream) { - stream->Read(bDone); + bool Deserialize(RakNet::BitStream& stream) { + stream.Read(bDone); uint32_t sBitStreamLength{}; - stream->Read(sBitStreamLength); + stream.Read(sBitStreamLength); for (unsigned int k = 0; k < sBitStreamLength; k++) { unsigned char character; - stream->Read(character); + stream.Read(character); sBitStream.push_back(character); } - stream->Read(uiBehaviorHandle); - stream->Read(uiSkillHandle); + stream.Read(uiBehaviorHandle); + stream.Read(uiSkillHandle); return true; } diff --git a/dGame/dGameMessages/GameMessageHandler.cpp b/dGame/dGameMessages/GameMessageHandler.cpp index 64790e31..3aab4b3d 100644 --- a/dGame/dGameMessages/GameMessageHandler.cpp +++ b/dGame/dGameMessages/GameMessageHandler.cpp @@ -39,7 +39,7 @@ #include "GhostComponent.h" #include "StringifiedEnum.h" -void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const SystemAddress& sysAddr, LWOOBJID objectID, eGameMessageType messageID) { +void GameMessageHandler::HandleMessage(RakNet::BitStream& inStream, const SystemAddress& sysAddr, LWOOBJID objectID, eGameMessageType messageID) { CBITSTREAM; @@ -269,11 +269,9 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System auto* skill_component = entity->GetComponent(); if (skill_component != nullptr) { - auto* bs = new RakNet::BitStream(reinterpret_cast(const_cast(message.sBitStream.c_str())), message.sBitStream.size(), false); + auto bs = RakNet::BitStream(reinterpret_cast(&message.sBitStream[0]), message.sBitStream.size(), false); skill_component->SyncPlayerProjectile(message.i64LocalID, bs, message.i64TargetID); - - delete bs; } break; @@ -296,7 +294,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System bool success = false; if (behaviorId > 0) { - RakNet::BitStream* bs = new RakNet::BitStream(reinterpret_cast(const_cast(startSkill.sBitStream.c_str())), startSkill.sBitStream.size(), false); + auto bs = RakNet::BitStream(reinterpret_cast(&startSkill.sBitStream[0]), startSkill.sBitStream.size(), false); auto* skillComponent = entity->GetComponent(); @@ -306,8 +304,6 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System DestroyableComponent* destComp = entity->GetComponent(); destComp->SetImagination(destComp->GetImagination() - skillTable->GetSkillByID(startSkill.skillID).imaginationcost); } - - delete bs; } if (Game::server->GetZoneID() == 1302) { @@ -331,9 +327,9 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System echoStartSkill.sBitStream = startSkill.sBitStream; echoStartSkill.skillID = startSkill.skillID; echoStartSkill.uiSkillHandle = startSkill.uiSkillHandle; - echoStartSkill.Serialize(&bitStreamLocal); + echoStartSkill.Serialize(bitStreamLocal); - Game::server->Send(&bitStreamLocal, entity->GetSystemAddress(), true); + Game::server->Send(bitStreamLocal, entity->GetSystemAddress(), true); } } break; @@ -353,13 +349,11 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System } if (usr != nullptr) { - RakNet::BitStream* bs = new RakNet::BitStream(reinterpret_cast(const_cast(sync.sBitStream.c_str())), sync.sBitStream.size(), false); + auto bs = RakNet::BitStream(reinterpret_cast(&sync.sBitStream[0]), sync.sBitStream.size(), false); auto* skillComponent = entity->GetComponent(); skillComponent->SyncPlayerSkill(sync.uiSkillHandle, sync.uiBehaviorHandle, bs); - - delete bs; } EchoSyncSkill echo = EchoSyncSkill(); @@ -368,9 +362,9 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System echo.uiBehaviorHandle = sync.uiBehaviorHandle; echo.uiSkillHandle = sync.uiSkillHandle; - echo.Serialize(&bitStreamLocal); + echo.Serialize(bitStreamLocal); - Game::server->Send(&bitStreamLocal, sysAddr, true); + Game::server->Send(bitStreamLocal, sysAddr, true); } break; case eGameMessageType::REQUEST_SMASH_PLAYER: diff --git a/dGame/dGameMessages/GameMessageHandler.h b/dGame/dGameMessages/GameMessageHandler.h index aed3d496..2fefd008 100644 --- a/dGame/dGameMessages/GameMessageHandler.h +++ b/dGame/dGameMessages/GameMessageHandler.h @@ -22,7 +22,7 @@ #include "eGameMessageType.h" namespace GameMessageHandler { - void HandleMessage(RakNet::BitStream* inStream, const SystemAddress& sysAddr, LWOOBJID objectID, eGameMessageType messageID); + void HandleMessage(RakNet::BitStream& inStream, const SystemAddress& sysAddr, LWOOBJID objectID, eGameMessageType messageID); }; #endif // GAMEMESSAGEHANDLER_H diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 0157c640..0bb9d008 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -78,6 +78,7 @@ #include "LevelProgressionComponent.h" #include "DonationVendorComponent.h" #include "GhostComponent.h" +#include "AchievementVendorComponent.h" // Message includes: #include "dZoneManager.h" @@ -97,6 +98,7 @@ #include "ePetAbilityType.h" #include "ActivityManager.h" #include "PlayerManager.h" +#include "eVendorTransactionResult.h" #include "CDComponentsRegistryTable.h" #include "CDObjectsTable.h" @@ -1323,15 +1325,14 @@ void GameMessages::SendVendorStatusUpdate(Entity* entity, const SystemAddress& s SEND_PACKET; } -void GameMessages::SendVendorTransactionResult(Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::SendVendorTransactionResult(Entity* entity, const SystemAddress& sysAddr, eVendorTransactionResult result) { CBITSTREAM; CMSGHEADER; - int iResult = 0x02; // success, seems to be the only relevant one bitStream.Write(entity->GetObjectID()); bitStream.Write(eGameMessageType::VENDOR_TRANSACTION_RESULT); - bitStream.Write(iResult); + bitStream.Write(result); SEND_PACKET; } @@ -1643,17 +1644,17 @@ void GameMessages::SendNotifyClientShootingGalleryScore(LWOOBJID objectId, const } -void GameMessages::HandleUpdateShootingGalleryRotation(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleUpdateShootingGalleryRotation(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { float angle = 0.0f; NiPoint3 facing = NiPoint3Constant::ZERO; NiPoint3 muzzlePos = NiPoint3Constant::ZERO; - inStream->Read(angle); - inStream->Read(facing); - inStream->Read(muzzlePos); + inStream.Read(angle); + inStream.Read(facing); + inStream.Read(muzzlePos); } -void GameMessages::HandleActivitySummaryLeaderboardData(RakNet::BitStream* instream, Entity* entity, +void GameMessages::HandleActivitySummaryLeaderboardData(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { LOG("We got mail!"); } @@ -1665,48 +1666,48 @@ void GameMessages::SendActivitySummaryLeaderboardData(const LWOOBJID& objectID, bitStream.Write(objectID); bitStream.Write(eGameMessageType::SEND_ACTIVITY_SUMMARY_LEADERBOARD_DATA); - leaderboard->Serialize(&bitStream); + leaderboard->Serialize(bitStream); SEND_PACKET; } -void GameMessages::HandleRequestActivitySummaryLeaderboardData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleRequestActivitySummaryLeaderboardData(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { int32_t gameID = 0; - if (inStream->ReadBit()) inStream->Read(gameID); + if (inStream.ReadBit()) inStream.Read(gameID); Leaderboard::InfoType queryType = Leaderboard::InfoType::MyStanding; - if (inStream->ReadBit()) inStream->Read(queryType); + if (inStream.ReadBit()) inStream.Read(queryType); int32_t resultsEnd = 10; - if (inStream->ReadBit()) inStream->Read(resultsEnd); + if (inStream.ReadBit()) inStream.Read(resultsEnd); int32_t resultsStart = 0; - if (inStream->ReadBit()) inStream->Read(resultsStart); + if (inStream.ReadBit()) inStream.Read(resultsStart); LWOOBJID target{}; - inStream->Read(target); + inStream.Read(target); - bool weekly = inStream->ReadBit(); + bool weekly = inStream.ReadBit(); LeaderboardManager::SendLeaderboard(gameID, queryType, weekly, entity->GetObjectID(), entity->GetObjectID(), resultsStart, resultsEnd); } -void GameMessages::HandleActivityStateChangeRequest(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleActivityStateChangeRequest(RakNet::BitStream& inStream, Entity* entity) { LWOOBJID objectID; - inStream->Read(objectID); + inStream.Read(objectID); int32_t value1; - inStream->Read(value1); + inStream.Read(value1); int32_t value2; - inStream->Read(value2); + inStream.Read(value2); uint32_t stringValueLength; - inStream->Read(stringValueLength); + inStream.Read(stringValueLength); std::u16string stringValue; for (uint32_t i = 0; i < stringValueLength; ++i) { uint16_t character; - inStream->Read(character); + inStream.Read(character); stringValue.push_back(character); } @@ -2159,17 +2160,17 @@ void GameMessages::SendUGCEquipPostDeleteBasedOnEditMode(LWOOBJID objectId, cons SEND_PACKET; } -void GameMessages::HandleSetPropertyAccess(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleSetPropertyAccess(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { uint8_t accessType{}; int32_t renew{}; bool accessTypeIsDefault{}; - inStream->Read(accessTypeIsDefault); - if (accessTypeIsDefault != 0) inStream->Read(accessType); + inStream.Read(accessTypeIsDefault); + if (accessTypeIsDefault != 0) inStream.Read(accessType); bool renewIsDefault{}; - inStream->Read(renewIsDefault); - if (renewIsDefault != 0) inStream->Read(renew); + inStream.Read(renewIsDefault); + if (renewIsDefault != 0) inStream.Read(renew); LOG("Set privacy option to: %i", accessType); @@ -2178,11 +2179,11 @@ void GameMessages::HandleSetPropertyAccess(RakNet::BitStream* inStream, Entity* PropertyManagementComponent::Instance()->SetPrivacyOption(static_cast(accessType)); } -void GameMessages::HandleUnUseModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleUnUseModel(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { bool unknown{}; LWOOBJID objIdToAddToInventory{}; - inStream->Read(unknown); - inStream->Read(objIdToAddToInventory); + inStream.Read(unknown); + inStream.Read(objIdToAddToInventory); auto* inventoryComponent = entity->GetComponent(); if (inventoryComponent) { auto* inventory = inventoryComponent->GetInventory(eInventoryType::MODELS_IN_BBB); @@ -2204,7 +2205,7 @@ void GameMessages::HandleUnUseModel(RakNet::BitStream* inStream, Entity* entity, } } -void GameMessages::HandleUpdatePropertyOrModelForFilterCheck(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleUpdatePropertyOrModelForFilterCheck(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { bool isProperty{}; LWOOBJID objectId{}; LWOOBJID playerId{}; @@ -2214,29 +2215,29 @@ void GameMessages::HandleUpdatePropertyOrModelForFilterCheck(RakNet::BitStream* uint32_t descriptionLength{}; std::u16string description{}; - inStream->Read(isProperty); - inStream->Read(objectId); - inStream->Read(playerId); - inStream->Read(worldId); + inStream.Read(isProperty); + inStream.Read(objectId); + inStream.Read(playerId); + inStream.Read(worldId); - inStream->Read(descriptionLength); + inStream.Read(descriptionLength); for (uint32_t i = 0; i < descriptionLength; ++i) { uint16_t character; - inStream->Read(character); + inStream.Read(character); description.push_back(character); } - inStream->Read(nameLength); + inStream.Read(nameLength); for (uint32_t i = 0; i < nameLength; ++i) { uint16_t character; - inStream->Read(character); + inStream.Read(character); name.push_back(character); } PropertyManagementComponent::Instance()->UpdatePropertyDetails(GeneralUtils::UTF16ToWTF8(name), GeneralUtils::UTF16ToWTF8(description)); } -void GameMessages::HandleQueryPropertyData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleQueryPropertyData(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { LOG("Entity (%i) requesting data", entity->GetLOT()); /* @@ -2264,7 +2265,7 @@ void GameMessages::HandleQueryPropertyData(RakNet::BitStream* inStream, Entity* } } -void GameMessages::HandleSetBuildMode(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleSetBuildMode(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { bool start{}; int32_t distanceType = -1; bool modePaused{}; @@ -2272,20 +2273,20 @@ void GameMessages::HandleSetBuildMode(RakNet::BitStream* inStream, Entity* entit LWOOBJID playerId{}; NiPoint3 startPosition = NiPoint3Constant::ZERO; - inStream->Read(start); + inStream.Read(start); - if (inStream->ReadBit()) - inStream->Read(distanceType); + if (inStream.ReadBit()) + inStream.Read(distanceType); - inStream->Read(modePaused); + inStream.Read(modePaused); - if (inStream->ReadBit()) - inStream->Read(modeValue); + if (inStream.ReadBit()) + inStream.Read(modeValue); - inStream->Read(playerId); + inStream.Read(playerId); - if (inStream->ReadBit()) - inStream->Read(startPosition); + if (inStream.ReadBit()) + inStream.Read(startPosition); auto* player = Game::entityManager->GetEntity(playerId); @@ -2300,7 +2301,7 @@ void GameMessages::HandleSetBuildMode(RakNet::BitStream* inStream, Entity* entit SendSetBuildModeConfirmed(entity->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS, start, false, modePaused, modeValue, playerId, startPosition); } -void GameMessages::HandleStartBuildingWithItem(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleStartBuildingWithItem(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { if (!entity->HasComponent(eReplicaComponentType::PROPERTY_MANAGEMENT)) { return; } @@ -2316,16 +2317,16 @@ void GameMessages::HandleStartBuildingWithItem(RakNet::BitStream* inStream, Enti NiPoint3 targetPosition{}; int32_t targetType{}; - inStream->Read(firstTime); - inStream->Read(success); - inStream->Read(sourceBag); - inStream->Read(sourceId); - inStream->Read(sourceLot); - inStream->Read(sourceType); - inStream->Read(targetId); - inStream->Read(targetLot); - inStream->Read(targetPosition); - inStream->Read(targetType); + inStream.Read(firstTime); + inStream.Read(success); + inStream.Read(sourceBag); + inStream.Read(sourceId); + inStream.Read(sourceLot); + inStream.Read(sourceType); + inStream.Read(targetId); + inStream.Read(targetLot); + inStream.Read(targetPosition); + inStream.Read(targetType); if (sourceType == 1) { sourceType = 4; @@ -2354,19 +2355,19 @@ void GameMessages::HandleStartBuildingWithItem(RakNet::BitStream* inStream, Enti ); } -void GameMessages::HandlePropertyEditorBegin(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandlePropertyEditorBegin(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { PropertyManagementComponent::Instance()->OnStartBuilding(); Game::zoneManager->GetZoneControlObject()->OnZonePropertyEditBegin(); } -void GameMessages::HandlePropertyEditorEnd(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandlePropertyEditorEnd(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { PropertyManagementComponent::Instance()->OnFinishBuilding(); Game::zoneManager->GetZoneControlObject()->OnZonePropertyEditEnd(); } -void GameMessages::HandlePropertyContentsFromClient(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandlePropertyContentsFromClient(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { User* user = UserManager::Instance()->GetUser(sysAddr); Entity* player = Game::entityManager->GetEntity(user->GetLoggedInChar()); @@ -2374,52 +2375,52 @@ void GameMessages::HandlePropertyContentsFromClient(RakNet::BitStream* inStream, SendGetModelsOnProperty(player->GetObjectID(), PropertyManagementComponent::Instance()->GetModels(), UNASSIGNED_SYSTEM_ADDRESS); } -void GameMessages::HandlePropertyModelEquipped(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandlePropertyModelEquipped(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { Game::zoneManager->GetZoneControlObject()->OnZonePropertyModelEquipped(); } -void GameMessages::HandlePlacePropertyModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandlePlacePropertyModel(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { LWOOBJID model; - inStream->Read(model); + inStream.Read(model); PropertyManagementComponent::Instance()->UpdateModelPosition(model, NiPoint3Constant::ZERO, NiQuaternionConstant::IDENTITY); } -void GameMessages::HandleUpdatePropertyModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleUpdatePropertyModel(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { LWOOBJID model; NiPoint3 position; NiQuaternion rotation = NiQuaternionConstant::IDENTITY; - inStream->Read(model); - inStream->Read(position); + inStream.Read(model); + inStream.Read(position); - if (inStream->ReadBit()) { - inStream->Read(rotation); + if (inStream.ReadBit()) { + inStream.Read(rotation); } PropertyManagementComponent::Instance()->UpdateModelPosition(model, position, rotation); } -void GameMessages::HandleDeletePropertyModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleDeletePropertyModel(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { LWOOBJID model = LWOOBJID_EMPTY; int deleteReason = 0; - if (inStream->ReadBit()) { - inStream->Read(model); + if (inStream.ReadBit()) { + inStream.Read(model); } - if (inStream->ReadBit()) { - inStream->Read(deleteReason); + if (inStream.ReadBit()) { + inStream.Read(deleteReason); } PropertyManagementComponent::Instance()->DeleteModel(model, deleteReason); } -void GameMessages::HandleBBBLoadItemRequest(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleBBBLoadItemRequest(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { LWOOBJID previousItemID = LWOOBJID_EMPTY; - inStream->Read(previousItemID); + inStream.Read(previousItemID); LOG("Load item request for: %lld", previousItemID); LWOOBJID newId = previousItemID; @@ -2486,19 +2487,19 @@ void GameMessages::SendUnSmash(Entity* entity, LWOOBJID builderID, float duratio SEND_PACKET_BROADCAST; } -void GameMessages::HandleControlBehaviors(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleControlBehaviors(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { AMFDeserialize reader; std::unique_ptr amfArguments{ static_cast(reader.Read(inStream).release()) }; if (amfArguments->GetValueType() != eAmf::Array) return; uint32_t commandLength{}; - inStream->Read(commandLength); + inStream.Read(commandLength); std::string command; command.reserve(commandLength); for (uint32_t i = 0; i < commandLength; ++i) { unsigned char character; - inStream->Read(character); + inStream.Read(character); command.push_back(character); } @@ -2508,7 +2509,7 @@ void GameMessages::HandleControlBehaviors(RakNet::BitStream* inStream, Entity* e ControlBehaviors::Instance().ProcessCommand(entity, *amfArguments, command, owner); } -void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleBBBSaveRequest(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { /* ___ ___ /\ /\___ _ __ ___ / __\ ___ / \_ __ __ _ __ _ ___ _ __ ___ @@ -2539,18 +2540,18 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent */ LWOOBJID localId; - inStream->Read(localId); + inStream.Read(localId); uint32_t sd0Size; - inStream->Read(sd0Size); + inStream.Read(sd0Size); std::shared_ptr sd0Data(new char[sd0Size]); if (sd0Data == nullptr) return; - inStream->ReadAlignedBytes(reinterpret_cast(sd0Data.get()), sd0Size); + inStream.ReadAlignedBytes(reinterpret_cast(sd0Data.get()), sd0Size); uint32_t timeTaken; - inStream->Read(timeTaken); + inStream.Read(timeTaken); /* Disabled this, as it's kinda silly to do this roundabout way of storing plaintext lxfml, then recompressing @@ -2687,7 +2688,7 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent }); } -void GameMessages::HandlePropertyEntranceSync(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandlePropertyEntranceSync(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { bool includeNullAddress{}; bool includeNullDescription{}; bool playerOwn{}; @@ -2699,19 +2700,19 @@ void GameMessages::HandlePropertyEntranceSync(RakNet::BitStream* inStream, Entit uint32_t filterTextLength{}; std::string filterText{}; - inStream->Read(includeNullAddress); - inStream->Read(includeNullDescription); - inStream->Read(playerOwn); - inStream->Read(updateUi); - inStream->Read(numResults); - inStream->Read(reputation); - inStream->Read(sortMethod); - inStream->Read(startIndex); - inStream->Read(filterTextLength); + inStream.Read(includeNullAddress); + inStream.Read(includeNullDescription); + inStream.Read(playerOwn); + inStream.Read(updateUi); + inStream.Read(numResults); + inStream.Read(reputation); + inStream.Read(sortMethod); + inStream.Read(startIndex); + inStream.Read(filterTextLength); for (auto i = 0u; i < filterTextLength; i++) { char c; - inStream->Read(c); + inStream.Read(c); filterText.push_back(c); } @@ -2735,12 +2736,12 @@ void GameMessages::HandlePropertyEntranceSync(RakNet::BitStream* inStream, Entit ); } -void GameMessages::HandleEnterProperty(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleEnterProperty(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { uint32_t index{}; bool returnToZone{}; - inStream->Read(index); - inStream->Read(returnToZone); + inStream.Read(index); + inStream.Read(returnToZone); auto* player = PlayerManager::GetPlayer(sysAddr); @@ -2756,10 +2757,10 @@ void GameMessages::HandleEnterProperty(RakNet::BitStream* inStream, Entity* enti } } -void GameMessages::HandleSetConsumableItem(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleSetConsumableItem(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { LOT lot; - inStream->Read(lot); + inStream.Read(lot); auto* inventory = entity->GetComponent(); @@ -2831,43 +2832,43 @@ void GameMessages::SendEndCinematic(LWOOBJID objectId, std::u16string pathName, SEND_PACKET; } -void GameMessages::HandleCinematicUpdate(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleCinematicUpdate(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { eCinematicEvent event; - if (!inStream->ReadBit()) { + if (!inStream.ReadBit()) { event = eCinematicEvent::STARTED; } else { - inStream->Read(event); + inStream.Read(event); } float_t overallTime; - if (!inStream->ReadBit()) { + if (!inStream.ReadBit()) { overallTime = -1.0f; } else { - inStream->Read(overallTime); + inStream.Read(overallTime); } uint32_t pathNameLength; - inStream->Read(pathNameLength); + inStream.Read(pathNameLength); std::u16string pathName; for (size_t i = 0; i < pathNameLength; i++) { char16_t character; - inStream->Read(character); + inStream.Read(character); pathName.push_back(character); } float_t pathTime; - if (!inStream->ReadBit()) { + if (!inStream.ReadBit()) { pathTime = -1.0f; } else { - inStream->Read(pathTime); + inStream.Read(pathTime); } int32_t waypoint; - if (!inStream->ReadBit()) { + if (!inStream.ReadBit()) { waypoint = -1; } else { - inStream->Read(waypoint); + inStream.Read(waypoint); } std::vector scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPT); @@ -3088,23 +3089,23 @@ void GameMessages::SendNotifyObject(LWOOBJID objectId, LWOOBJID objIDSender, std SEND_PACKET; } -void GameMessages::HandleVerifyAck(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleVerifyAck(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { bool bDifferent; std::string sBitStream; uint32_t uiHandle = 0; - bDifferent = inStream->ReadBit(); + bDifferent = inStream.ReadBit(); uint32_t sBitStreamLength = 0; - inStream->Read(sBitStreamLength); + inStream.Read(sBitStreamLength); for (uint64_t k = 0; k < sBitStreamLength; k++) { uint8_t character; - inStream->Read(character); + inStream.Read(character); sBitStream.push_back(character); } - if (inStream->ReadBit()) { - inStream->Read(uiHandle); + if (inStream.ReadBit()) { + inStream.Read(uiHandle); } } @@ -3231,7 +3232,7 @@ void GameMessages::SendServerTradeUpdate(LWOOBJID objectId, uint64_t coins, cons SEND_PACKET; } -void GameMessages::HandleClientTradeRequest(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleClientTradeRequest(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { // Check if the player has restricted trade access auto* character = entity->GetCharacter(); @@ -3245,10 +3246,10 @@ void GameMessages::HandleClientTradeRequest(RakNet::BitStream* inStream, Entity* return; } - bool bNeedInvitePopUp = inStream->ReadBit(); + bool bNeedInvitePopUp = inStream.ReadBit(); LWOOBJID i64Invitee; - inStream->Read(i64Invitee); + inStream.Read(i64Invitee); auto* invitee = Game::entityManager->GetEntity(i64Invitee); @@ -3289,7 +3290,7 @@ void GameMessages::HandleClientTradeRequest(RakNet::BitStream* inStream, Entity* } } -void GameMessages::HandleClientTradeCancel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleClientTradeCancel(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { auto* trade = TradingManager::Instance()->GetPlayerTrade(entity->GetObjectID()); if (trade == nullptr) return; @@ -3299,8 +3300,8 @@ void GameMessages::HandleClientTradeCancel(RakNet::BitStream* inStream, Entity* TradingManager::Instance()->CancelTrade(entity->GetObjectID(), trade->GetTradeId()); } -void GameMessages::HandleClientTradeAccept(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { - bool bFirst = inStream->ReadBit(); +void GameMessages::HandleClientTradeAccept(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { + bool bFirst = inStream.ReadBit(); LOG("Trade accepted from (%llu) -> (%d)", entity->GetObjectID(), bFirst); @@ -3311,12 +3312,12 @@ void GameMessages::HandleClientTradeAccept(RakNet::BitStream* inStream, Entity* trade->SetAccepted(entity->GetObjectID(), bFirst); } -void GameMessages::HandleClientTradeUpdate(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleClientTradeUpdate(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { uint64_t currency; uint32_t itemCount; - inStream->Read(currency); - inStream->Read(itemCount); + inStream.Read(currency); + inStream.Read(itemCount); LOG("Trade update from (%llu) -> (%llu), (%i)", entity->GetObjectID(), currency, itemCount); @@ -3326,8 +3327,8 @@ void GameMessages::HandleClientTradeUpdate(RakNet::BitStream* inStream, Entity* LWOOBJID itemId; LWOOBJID itemId2; - inStream->Read(itemId); - inStream->Read(itemId2); + inStream.Read(itemId); + inStream.Read(itemId2); LOT lot = 0; LWOOBJID unknown1 = 0; @@ -3337,32 +3338,32 @@ void GameMessages::HandleClientTradeUpdate(RakNet::BitStream* inStream, Entity* uint32_t ldfSize = 0; bool unknown4; - inStream->Read(lot); - if (inStream->ReadBit()) { - inStream->Read(unknown1); + inStream.Read(lot); + if (inStream.ReadBit()) { + inStream.Read(unknown1); } - if (inStream->ReadBit()) { - inStream->Read(unknown2); + if (inStream.ReadBit()) { + inStream.Read(unknown2); } - if (inStream->ReadBit()) { - inStream->Read(slot); + if (inStream.ReadBit()) { + inStream.Read(slot); } - if (inStream->ReadBit()) { - inStream->Read(unknown3); + if (inStream.ReadBit()) { + inStream.Read(unknown3); } - if (inStream->ReadBit()) // No + if (inStream.ReadBit()) // No { - inStream->Read(ldfSize); - bool compressed = inStream->ReadBit(); + inStream.Read(ldfSize); + bool compressed = inStream.ReadBit(); if (compressed) { uint32_t ldfCompressedSize = 0; - inStream->Read(ldfCompressedSize); - inStream->IgnoreBytes(ldfCompressedSize); + inStream.Read(ldfCompressedSize); + inStream.IgnoreBytes(ldfCompressedSize); } else { - inStream->IgnoreBytes(ldfSize); + inStream.IgnoreBytes(ldfSize); } } - unknown4 = inStream->ReadBit(); + unknown4 = inStream.ReadBit(); items.push_back({ itemId, lot, unknown2 }); @@ -3657,8 +3658,8 @@ void GameMessages::SendPetNameChanged(LWOOBJID objectId, int32_t moderationStatu } -void GameMessages::HandleClientExitTamingMinigame(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { - bool bVoluntaryExit = inStream->ReadBit(); +void GameMessages::HandleClientExitTamingMinigame(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { + bool bVoluntaryExit = inStream.ReadBit(); auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); @@ -3669,7 +3670,7 @@ void GameMessages::HandleClientExitTamingMinigame(RakNet::BitStream* inStream, E petComponent->ClientExitTamingMinigame(bVoluntaryExit); } -void GameMessages::HandleStartServerPetMinigameTimer(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleStartServerPetMinigameTimer(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); if (petComponent == nullptr) { @@ -3679,24 +3680,24 @@ void GameMessages::HandleStartServerPetMinigameTimer(RakNet::BitStream* inStream petComponent->StartTimer(); } -void GameMessages::HandlePetTamingTryBuild(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandlePetTamingTryBuild(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { uint32_t brickCount; std::vector bricks; bool clientFailed; - inStream->Read(brickCount); + inStream.Read(brickCount); bricks.reserve(brickCount); for (uint32_t i = 0; i < brickCount; i++) { Brick brick; - inStream->Read(brick); + inStream.Read(brick); bricks.push_back(brick); } - clientFailed = inStream->ReadBit(); + clientFailed = inStream.ReadBit(); auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); @@ -3707,10 +3708,10 @@ void GameMessages::HandlePetTamingTryBuild(RakNet::BitStream* inStream, Entity* petComponent->TryBuild(bricks.size(), clientFailed); } -void GameMessages::HandleNotifyTamingBuildSuccess(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleNotifyTamingBuildSuccess(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { NiPoint3 position; - inStream->Read(position); + inStream.Read(position); auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); @@ -3721,15 +3722,15 @@ void GameMessages::HandleNotifyTamingBuildSuccess(RakNet::BitStream* inStream, E petComponent->NotifyTamingBuildSuccess(position); } -void GameMessages::HandleRequestSetPetName(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleRequestSetPetName(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { uint32_t nameLength; std::u16string name; - inStream->Read(nameLength); + inStream.Read(nameLength); for (size_t i = 0; i < nameLength; i++) { char16_t character; - inStream->Read(character); + inStream.Read(character); name.push_back(character); } @@ -3746,18 +3747,18 @@ void GameMessages::HandleRequestSetPetName(RakNet::BitStream* inStream, Entity* petComponent->RequestSetPetName(name); } -void GameMessages::HandleCommandPet(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleCommandPet(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { NiPoint3 genericPosInfo; LWOOBJID objIdSource; int32_t iPetCommandType; int32_t iTypeID; bool overrideObey; - inStream->Read(genericPosInfo); - inStream->Read(objIdSource); - inStream->Read(iPetCommandType); - inStream->Read(iTypeID); - overrideObey = inStream->ReadBit(); + inStream.Read(genericPosInfo); + inStream.Read(objIdSource); + inStream.Read(iPetCommandType); + inStream.Read(iTypeID); + overrideObey = inStream.ReadBit(); auto* petComponent = entity->GetComponent(); @@ -3768,10 +3769,10 @@ void GameMessages::HandleCommandPet(RakNet::BitStream* inStream, Entity* entity, petComponent->Command(genericPosInfo, objIdSource, iPetCommandType, iTypeID, overrideObey); } -void GameMessages::HandleDespawnPet(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleDespawnPet(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { bool bDeletePet; - bDeletePet = inStream->ReadBit(); + bDeletePet = inStream.ReadBit(); auto* petComponent = PetComponent::GetActivePet(entity->GetObjectID()); @@ -3786,26 +3787,26 @@ void GameMessages::HandleDespawnPet(RakNet::BitStream* inStream, Entity* entity, } } -void GameMessages::HandleMessageBoxResponse(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleMessageBoxResponse(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { int32_t iButton; uint32_t identifierLength; std::u16string identifier; uint32_t userDataLength; std::u16string userData; - inStream->Read(iButton); + inStream.Read(iButton); - inStream->Read(identifierLength); + inStream.Read(identifierLength); for (size_t i = 0; i < identifierLength; i++) { char16_t character; - inStream->Read(character); + inStream.Read(character); identifier.push_back(character); } - inStream->Read(userDataLength); + inStream.Read(userDataLength); for (size_t i = 0; i < userDataLength; i++) { char16_t character; - inStream->Read(character); + inStream.Read(character); userData.push_back(character); } @@ -3842,26 +3843,26 @@ void GameMessages::HandleMessageBoxResponse(RakNet::BitStream* inStream, Entity* } } -void GameMessages::HandleChoiceBoxRespond(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleChoiceBoxRespond(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { int32_t iButton; uint32_t buttonIdentifierLength; std::u16string buttonIdentifier; uint32_t identifierLength; std::u16string identifier; - inStream->Read(buttonIdentifierLength); + inStream.Read(buttonIdentifierLength); for (size_t i = 0; i < buttonIdentifierLength; i++) { char16_t character; - inStream->Read(character); + inStream.Read(character); buttonIdentifier.push_back(character); } - inStream->Read(iButton); + inStream.Read(iButton); - inStream->Read(identifierLength); + inStream.Read(identifierLength); for (size_t i = 0; i < identifierLength; i++) { char16_t character; - inStream->Read(character); + inStream.Read(character); identifier.push_back(character); } @@ -3990,10 +3991,10 @@ void GameMessages::SendSetMountInventoryID(Entity* entity, const LWOOBJID& objec } -void GameMessages::HandleDismountComplete(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleDismountComplete(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { // Get the objectID from the bitstream LWOOBJID objectId{}; - inStream->Read(objectId); + inStream.Read(objectId); // If we aren't possessing somethings, the don't do anything if (objectId != LWOOBJID_EMPTY) { @@ -4032,17 +4033,17 @@ void GameMessages::HandleDismountComplete(RakNet::BitStream* inStream, Entity* e } -void GameMessages::HandleAcknowledgePossession(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleAcknowledgePossession(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { Game::entityManager->SerializeEntity(entity); LWOOBJID objectId{}; - inStream->Read(objectId); + inStream.Read(objectId); auto* mount = Game::entityManager->GetEntity(objectId); if (mount) Game::entityManager->SerializeEntity(mount); } //Racing -void GameMessages::HandleModuleAssemblyQueryData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleModuleAssemblyQueryData(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { auto* moduleAssemblyComponent = entity->GetComponent(); LOG("Got Query from %i", entity->GetLOT()); @@ -4055,23 +4056,23 @@ void GameMessages::HandleModuleAssemblyQueryData(RakNet::BitStream* inStream, En } -void GameMessages::HandleModularAssemblyNIFCompleted(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleModularAssemblyNIFCompleted(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { LWOOBJID objectID; - inStream->Read(objectID); + inStream.Read(objectID); } -void GameMessages::HandleVehicleSetWheelLockState(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { - bool bExtraFriction = inStream->ReadBit(); - bool bLocked = inStream->ReadBit(); +void GameMessages::HandleVehicleSetWheelLockState(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { + bool bExtraFriction = inStream.ReadBit(); + bool bLocked = inStream.ReadBit(); } -void GameMessages::HandleRacingClientReady(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleRacingClientReady(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { LWOOBJID playerID; - inStream->Read(playerID); + inStream.Read(playerID); auto* player = Game::entityManager->GetEntity(playerID); @@ -4089,7 +4090,7 @@ void GameMessages::HandleRacingClientReady(RakNet::BitStream* inStream, Entity* } -void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleRequestDie(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { bool bClientDeath; bool bSpawnLoot; std::u16string deathType; @@ -4100,31 +4101,31 @@ void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity, LWOOBJID killerID; LWOOBJID lootOwnerID = LWOOBJID_EMPTY; - bClientDeath = inStream->ReadBit(); - bSpawnLoot = inStream->ReadBit(); + bClientDeath = inStream.ReadBit(); + bSpawnLoot = inStream.ReadBit(); uint32_t deathTypeLength = 0; - inStream->Read(deathTypeLength); + inStream.Read(deathTypeLength); for (size_t i = 0; i < deathTypeLength; i++) { char16_t character; - inStream->Read(character); + inStream.Read(character); deathType.push_back(character); } - inStream->Read(directionRelativeAngleXZ); - inStream->Read(directionRelativeAngleY); - inStream->Read(directionRelativeForce); + inStream.Read(directionRelativeAngleXZ); + inStream.Read(directionRelativeAngleY); + inStream.Read(directionRelativeForce); - if (inStream->ReadBit()) { - inStream->Read(killType); + if (inStream.ReadBit()) { + inStream.Read(killType); } - inStream->Read(killerID); + inStream.Read(killerID); - if (inStream->ReadBit()) { - inStream->Read(lootOwnerID); + if (inStream.ReadBit()) { + inStream.Read(lootOwnerID); } auto* zoneController = Game::zoneManager->GetZoneControlObject(); @@ -4155,20 +4156,20 @@ void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity, } -void GameMessages::HandleVehicleNotifyServerAddPassiveBoostAction(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleVehicleNotifyServerAddPassiveBoostAction(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { //SendVehicleAddPassiveBoostAction(entity->GetObjectID(), sysAddr); } -void GameMessages::HandleVehicleNotifyServerRemovePassiveBoostAction(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleVehicleNotifyServerRemovePassiveBoostAction(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { //SendVehicleRemovePassiveBoostAction(entity->GetObjectID(), sysAddr); } -void GameMessages::HandleRacingPlayerInfoResetFinished(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleRacingPlayerInfoResetFinished(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { LWOOBJID playerID; - inStream->Read(playerID); + inStream.Read(playerID); auto* player = Game::entityManager->GetEntity(playerID); @@ -4199,10 +4200,10 @@ void GameMessages::SendUpdateReputation(const LWOOBJID objectId, const int64_t r SEND_PACKET; } -void GameMessages::HandleUpdatePropertyPerformanceCost(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleUpdatePropertyPerformanceCost(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { float performanceCost = 0.0f; - if (inStream->ReadBit()) inStream->Read(performanceCost); + if (inStream.ReadBit()) inStream.Read(performanceCost); if (performanceCost == 0.0f) return; @@ -4215,16 +4216,16 @@ void GameMessages::HandleUpdatePropertyPerformanceCost(RakNet::BitStream* inStre Database::Get()->UpdatePerformanceCost(zone->GetZoneID(), performanceCost); } -void GameMessages::HandleVehicleNotifyHitImaginationServer(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleVehicleNotifyHitImaginationServer(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { LWOOBJID pickupObjID = LWOOBJID_EMPTY; LWOOBJID pickupSpawnerID = LWOOBJID_EMPTY; int32_t pickupSpawnerIndex = -1; NiPoint3 vehiclePosition = NiPoint3Constant::ZERO; - if (inStream->ReadBit()) inStream->Read(pickupObjID); - if (inStream->ReadBit()) inStream->Read(pickupSpawnerID); - if (inStream->ReadBit()) inStream->Read(pickupSpawnerIndex); - if (inStream->ReadBit()) inStream->Read(vehiclePosition); + if (inStream.ReadBit()) inStream.Read(pickupObjID); + if (inStream.ReadBit()) inStream.Read(pickupSpawnerID); + if (inStream.ReadBit()) inStream.Read(pickupSpawnerIndex); + if (inStream.ReadBit()) inStream.Read(vehiclePosition); auto* pickup = Game::entityManager->GetEntity(pickupObjID); @@ -4546,7 +4547,7 @@ void GameMessages::SendAddBuff(LWOOBJID& objectID, const LWOOBJID& casterID, uin // NT -void GameMessages::HandleRequestMoveItemBetweenInventoryTypes(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleRequestMoveItemBetweenInventoryTypes(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { bool bAllowPartial{}; int32_t destSlot = -1; int32_t iStackCount = 1; @@ -4557,15 +4558,15 @@ void GameMessages::HandleRequestMoveItemBetweenInventoryTypes(RakNet::BitStream* LWOOBJID subkey = LWOOBJID_EMPTY; LOT itemLOT = 0; - bAllowPartial = inStream->ReadBit(); - if (inStream->ReadBit()) inStream->Read(destSlot); - if (inStream->ReadBit()) inStream->Read(iStackCount); - if (inStream->ReadBit()) inStream->Read(invTypeDst); - if (inStream->ReadBit()) inStream->Read(invTypeSrc); - if (inStream->ReadBit()) inStream->Read(itemID); - showFlyingLoot = inStream->ReadBit(); - if (inStream->ReadBit()) inStream->Read(subkey); - if (inStream->ReadBit()) inStream->Read(itemLOT); + bAllowPartial = inStream.ReadBit(); + if (inStream.ReadBit()) inStream.Read(destSlot); + if (inStream.ReadBit()) inStream.Read(iStackCount); + if (inStream.ReadBit()) inStream.Read(invTypeDst); + if (inStream.ReadBit()) inStream.Read(invTypeSrc); + if (inStream.ReadBit()) inStream.Read(itemID); + showFlyingLoot = inStream.ReadBit(); + if (inStream.ReadBit()) inStream.Read(subkey); + if (inStream.ReadBit()) inStream.Read(itemLOT); if (invTypeDst == invTypeSrc) { return; @@ -4618,10 +4619,10 @@ void GameMessages::SendShowActivityCountdown(LWOOBJID objectId, bool bPlayAdditi //------------------------------------------------------------------- Handlers ------------------------------------------------------------------ //----------------------------------------------------------------------------------------------------------------------------------------------- -void GameMessages::HandleToggleGhostReferenceOverride(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleToggleGhostReferenceOverride(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { bool bOverride = false; - inStream->Read(bOverride); + inStream.Read(bOverride); auto* player = PlayerManager::GetPlayer(sysAddr); @@ -4634,10 +4635,10 @@ void GameMessages::HandleToggleGhostReferenceOverride(RakNet::BitStream* inStrea } -void GameMessages::HandleSetGhostReferencePosition(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleSetGhostReferencePosition(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { NiPoint3 position; - inStream->Read(position); + inStream.Read(position); auto* player = PlayerManager::GetPlayer(sysAddr); @@ -4650,119 +4651,52 @@ void GameMessages::HandleSetGhostReferencePosition(RakNet::BitStream* inStream, } -void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleBuyFromVendor(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { bool bConfirmed{}; // This doesn't appear to do anything. Further research is needed. bool countIsDefault{}; int count = 1; LOT item; - inStream->Read(bConfirmed); - inStream->Read(countIsDefault); - if (countIsDefault) inStream->Read(count); - inStream->Read(item); + inStream.Read(bConfirmed); + inStream.Read(countIsDefault); + if (countIsDefault) inStream.Read(count); + inStream.Read(item); User* user = UserManager::Instance()->GetUser(sysAddr); if (!user) return; Entity* player = Game::entityManager->GetEntity(user->GetLoggedInChar()); if (!player) return; + + // handle buying normal items + auto* vendorComponent = entity->GetComponent(); + if (vendorComponent) { + vendorComponent->Buy(player, item, count); + return; + } - auto* propertyVendorComponent = static_cast(entity->GetComponent(eReplicaComponentType::PROPERTY_VENDOR)); + // handle buying achievement items + auto* achievementVendorComponent = entity->GetComponent(); + if (achievementVendorComponent) { + achievementVendorComponent->Buy(player, item, count); + return; + } - if (propertyVendorComponent != nullptr) { + // Handle buying properties + auto* propertyVendorComponent = entity->GetComponent(); + if (propertyVendorComponent) { propertyVendorComponent->OnBuyFromVendor(player, bConfirmed, item, count); - return; } - - const auto isCommendationVendor = entity->GetLOT() == 13806; - - auto* vend = entity->GetComponent(); - if (!vend && !isCommendationVendor) return; - - auto* inv = player->GetComponent(); - if (!inv) return; - - if (!isCommendationVendor && !vend->SellsItem(item)) { - LOG("User %llu %s tried to buy an item %i from a vendor when they do not sell said item", player->GetObjectID(), user->GetUsername().c_str(), item); - return; - } - - CDComponentsRegistryTable* compRegistryTable = CDClientManager::GetTable(); - CDItemComponentTable* itemComponentTable = CDClientManager::GetTable(); - - int itemCompID = compRegistryTable->GetByIDAndType(item, eReplicaComponentType::ITEM); - CDItemComponent itemComp = itemComponentTable->GetItemComponentByID(itemCompID); - - Character* character = player->GetCharacter(); - if (!character) return; - - // Extra currency that needs to be deducted in case of crafting - auto craftingCurrencies = CDItemComponentTable::ParseCraftingCurrencies(itemComp); - for (const auto& craftingCurrency : craftingCurrencies) { - inv->RemoveItem(craftingCurrency.first, craftingCurrency.second * count); - } - - if (isCommendationVendor) { - if (itemComp.commendationLOT != 13763) { - return; - } - - auto* missionComponent = player->GetComponent(); - - if (missionComponent == nullptr) { - return; - } - - LOT tokenId = -1; - - if (missionComponent->GetMissionState(545) == eMissionState::COMPLETE) tokenId = 8318; // "Assembly Token" - if (missionComponent->GetMissionState(556) == eMissionState::COMPLETE) tokenId = 8321; // "Venture League Token" - if (missionComponent->GetMissionState(567) == eMissionState::COMPLETE) tokenId = 8319; // "Sentinels Token" - if (missionComponent->GetMissionState(578) == eMissionState::COMPLETE) tokenId = 8320; // "Paradox Token" - - const uint32_t altCurrencyCost = itemComp.commendationCost * count; - - if (inv->GetLotCount(tokenId) < altCurrencyCost) { - return; - } - - inv->RemoveItem(tokenId, altCurrencyCost); - - inv->AddItem(item, count, eLootSourceType::VENDOR); - } else { - float buyScalar = vend->GetBuyScalar(); - - const auto coinCost = static_cast(std::floor((itemComp.baseValue * buyScalar) * count)); - - if (character->GetCoins() < coinCost) { - return; - } - - if (Inventory::IsValidItem(itemComp.currencyLOT)) { - const uint32_t altCurrencyCost = std::floor(itemComp.altCurrencyCost * buyScalar) * count; - - if (inv->GetLotCount(itemComp.currencyLOT) < altCurrencyCost) { - return; - } - - inv->RemoveItem(itemComp.currencyLOT, altCurrencyCost); - } - - character->SetCoins(character->GetCoins() - (coinCost), eLootSourceType::VENDOR); - inv->AddItem(item, count, eLootSourceType::VENDOR); - } - - GameMessages::SendVendorTransactionResult(entity, sysAddr); } -void GameMessages::HandleSellToVendor(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleSellToVendor(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { bool countIsDefault{}; int count = 1; LWOOBJID iObjID; - inStream->Read(countIsDefault); - if (countIsDefault) inStream->Read(count); - inStream->Read(iObjID); + inStream.Read(countIsDefault); + if (countIsDefault) inStream.Read(count); + inStream.Read(iObjID); User* user = UserManager::Instance()->GetUser(sysAddr); if (!user) return; @@ -4786,7 +4720,10 @@ void GameMessages::HandleSellToVendor(RakNet::BitStream* inStream, Entity* entit CDItemComponent itemComp = itemComponentTable->GetItemComponentByID(itemCompID); // Items with a base value of 0 or max int are special items that should not be sold if they're not sub items - if (itemComp.baseValue == 0 || itemComp.baseValue == UINT_MAX) return; + if (itemComp.baseValue == 0 || itemComp.baseValue == UINT_MAX) { + GameMessages::SendVendorTransactionResult(entity, sysAddr, eVendorTransactionResult::SELL_FAIL); + return; + } float sellScalar = vend->GetSellScalar(); if (Inventory::IsValidItem(itemComp.currencyLOT)) { @@ -4794,23 +4731,21 @@ void GameMessages::HandleSellToVendor(RakNet::BitStream* inStream, Entity* entit inv->AddItem(itemComp.currencyLOT, std::floor(altCurrency), eLootSourceType::VENDOR); // Return alt currencies like faction tokens. } - //inv->RemoveItem(count, -1, iObjID); inv->MoveItemToInventory(item, eInventoryType::VENDOR_BUYBACK, count, true, false, true); character->SetCoins(std::floor(character->GetCoins() + (static_cast(itemComp.baseValue * sellScalar) * count)), eLootSourceType::VENDOR); - //Game::entityManager->SerializeEntity(player); // so inventory updates - GameMessages::SendVendorTransactionResult(entity, sysAddr); + GameMessages::SendVendorTransactionResult(entity, sysAddr, eVendorTransactionResult::SELL_SUCCESS); } -void GameMessages::HandleBuybackFromVendor(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleBuybackFromVendor(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { bool confirmed = false; bool countIsDefault{}; int count = 1; LWOOBJID iObjID; - inStream->Read(confirmed); - inStream->Read(countIsDefault); - if (countIsDefault) inStream->Read(count); - inStream->Read(iObjID); + inStream.Read(confirmed); + inStream.Read(countIsDefault); + if (countIsDefault) inStream.Read(count); + inStream.Read(iObjID); //if (!confirmed) return; they always built in this confirmed garbage... but never used it? @@ -4840,16 +4775,16 @@ void GameMessages::HandleBuybackFromVendor(RakNet::BitStream* inStream, Entity* const auto cost = static_cast(std::floor(((itemComp.baseValue * sellScalar) * count))); if (character->GetCoins() < cost) { + GameMessages::SendVendorTransactionResult(entity, sysAddr, eVendorTransactionResult::PURCHASE_FAIL); return; } if (Inventory::IsValidItem(itemComp.currencyLOT)) { const uint32_t altCurrencyCost = std::floor(itemComp.altCurrencyCost * sellScalar) * count; - if (inv->GetLotCount(itemComp.currencyLOT) < altCurrencyCost) { + GameMessages::SendVendorTransactionResult(entity, sysAddr, eVendorTransactionResult::PURCHASE_FAIL); return; } - inv->RemoveItem(itemComp.currencyLOT, altCurrencyCost); } @@ -4857,19 +4792,19 @@ void GameMessages::HandleBuybackFromVendor(RakNet::BitStream* inStream, Entity* inv->MoveItemToInventory(item, Inventory::FindInventoryTypeForLot(item->GetLot()), count, true, false); character->SetCoins(character->GetCoins() - cost, eLootSourceType::VENDOR); //Game::entityManager->SerializeEntity(player); // so inventory updates - GameMessages::SendVendorTransactionResult(entity, sysAddr); + GameMessages::SendVendorTransactionResult(entity, sysAddr, eVendorTransactionResult::PURCHASE_SUCCESS); } -void GameMessages::HandleParseChatMessage(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleParseChatMessage(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { std::u16string wsString; int iClientState; - inStream->Read(iClientState); + inStream.Read(iClientState); uint32_t wsStringLength; - inStream->Read(wsStringLength); + inStream.Read(wsStringLength); for (uint32_t i = 0; i < wsStringLength; ++i) { uint16_t character; - inStream->Read(character); + inStream.Read(character); wsString.push_back(character); } @@ -4878,7 +4813,7 @@ void GameMessages::HandleParseChatMessage(RakNet::BitStream* inStream, Entity* e } } -void GameMessages::HandleFireEventServerSide(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleFireEventServerSide(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { uint32_t argsLength{}; std::u16string args{}; bool param1IsDefault{}; @@ -4889,19 +4824,19 @@ void GameMessages::HandleFireEventServerSide(RakNet::BitStream* inStream, Entity int param3 = -1; LWOOBJID senderID{}; - inStream->Read(argsLength); + inStream.Read(argsLength); for (uint32_t i = 0; i < argsLength; ++i) { uint16_t character; - inStream->Read(character); + inStream.Read(character); args.push_back(character); } - inStream->Read(param1IsDefault); - if (param1IsDefault) inStream->Read(param1); - inStream->Read(param2IsDefault); - if (param2IsDefault) inStream->Read(param2); - inStream->Read(param3IsDefault); - if (param3IsDefault) inStream->Read(param3); - inStream->Read(senderID); + inStream.Read(param1IsDefault); + if (param1IsDefault) inStream.Read(param1); + inStream.Read(param2IsDefault); + if (param2IsDefault) inStream.Read(param2); + inStream.Read(param3IsDefault); + if (param3IsDefault) inStream.Read(param3); + inStream.Read(senderID); auto* sender = Game::entityManager->GetEntity(senderID); auto* player = PlayerManager::GetPlayer(sysAddr); @@ -4962,17 +4897,17 @@ void GameMessages::HandleFireEventServerSide(RakNet::BitStream* inStream, Entity entity->OnFireEventServerSide(sender, GeneralUtils::UTF16ToWTF8(args), param1, param2, param3); } -void GameMessages::HandleRequestPlatformResync(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleRequestPlatformResync(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { if (entity->GetLOT() == 6267 || entity->GetLOT() == 16141) return; GameMessages::SendPlatformResync(entity, sysAddr); } -void GameMessages::HandleQuickBuildCancel(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleQuickBuildCancel(RakNet::BitStream& inStream, Entity* entity) { bool bEarlyRelease; LWOOBJID userID; - inStream->Read(bEarlyRelease); - inStream->Read(userID); + inStream.Read(bEarlyRelease); + inStream.Read(userID); auto* quickBuildComponent = static_cast(entity->GetComponent(eReplicaComponentType::QUICK_BUILD));; if (!quickBuildComponent) return; @@ -4980,18 +4915,18 @@ void GameMessages::HandleQuickBuildCancel(RakNet::BitStream* inStream, Entity* e quickBuildComponent->CancelQuickBuild(Game::entityManager->GetEntity(userID), eQuickBuildFailReason::CANCELED_EARLY); } -void GameMessages::HandleRequestUse(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleRequestUse(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { bool bIsMultiInteractUse = false; unsigned int multiInteractID; int multiInteractType; bool secondary; LWOOBJID objectID; - inStream->Read(bIsMultiInteractUse); - inStream->Read(multiInteractID); - inStream->Read(multiInteractType); - inStream->Read(objectID); - inStream->Read(secondary); + inStream.Read(bIsMultiInteractUse); + inStream.Read(multiInteractID); + inStream.Read(multiInteractType); + inStream.Read(objectID); + inStream.Read(secondary); Entity* interactedObject = Game::entityManager->GetEntity(objectID); @@ -5028,12 +4963,12 @@ void GameMessages::HandleRequestUse(RakNet::BitStream* inStream, Entity* entity, missionComponent->Progress(eMissionTaskType::INTERACT, interactedObject->GetLOT(), interactedObject->GetObjectID()); } -void GameMessages::HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandlePlayEmote(RakNet::BitStream& inStream, Entity* entity) { int emoteID; LWOOBJID targetID; - inStream->Read(emoteID); - inStream->Read(targetID); + inStream.Read(emoteID); + inStream.Read(targetID); LOG_DEBUG("Emote (%i) (%llu)", emoteID, targetID); @@ -5077,10 +5012,10 @@ void GameMessages::HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity) } } -void GameMessages::HandleModularBuildConvertModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleModularBuildConvertModel(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { LWOOBJID modelID; - inStream->Read(modelID); + inStream.Read(modelID); User* user = UserManager::Instance()->GetUser(sysAddr); if (!user) return; @@ -5104,29 +5039,29 @@ void GameMessages::HandleModularBuildConvertModel(RakNet::BitStream* inStream, E item->SetCount(item->GetCount() - 1, false, false, true, eLootSourceType::QUICKBUILD); } -void GameMessages::HandleSetFlag(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleSetFlag(RakNet::BitStream& inStream, Entity* entity) { bool bFlag{}; int32_t iFlagID{}; - inStream->Read(bFlag); - inStream->Read(iFlagID); + inStream.Read(bFlag); + inStream.Read(iFlagID); auto character = entity->GetCharacter(); if (character) character->SetPlayerFlag(iFlagID, bFlag); } -void GameMessages::HandleRespondToMission(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleRespondToMission(RakNet::BitStream& inStream, Entity* entity) { int missionID{}; LWOOBJID playerID{}; LWOOBJID receiverID{}; bool isDefaultReward{}; LOT reward = LOT_NULL; - inStream->Read(missionID); - inStream->Read(playerID); - inStream->Read(receiverID); - inStream->Read(isDefaultReward); - if (isDefaultReward) inStream->Read(reward); + inStream.Read(missionID); + inStream.Read(playerID); + inStream.Read(receiverID); + inStream.Read(isDefaultReward); + if (isDefaultReward) inStream.Read(reward); MissionComponent* missionComponent = static_cast(entity->GetComponent(eReplicaComponentType::MISSION)); if (!missionComponent) { @@ -5153,17 +5088,17 @@ void GameMessages::HandleRespondToMission(RakNet::BitStream* inStream, Entity* e } } -void GameMessages::HandleMissionDialogOK(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleMissionDialogOK(RakNet::BitStream& inStream, Entity* entity) { bool bIsComplete{}; eMissionState iMissionState{}; int missionID{}; LWOOBJID responder{}; Entity* player = nullptr; - inStream->Read(bIsComplete); - inStream->Read(iMissionState); - inStream->Read(missionID); - inStream->Read(responder); + inStream.Read(bIsComplete); + inStream.Read(iMissionState); + inStream.Read(missionID); + inStream.Read(responder); player = Game::entityManager->GetEntity(responder); for (CppScripts::Script* script : CppScripts::GetEntityScripts(entity)) { @@ -5192,14 +5127,14 @@ void GameMessages::HandleMissionDialogOK(RakNet::BitStream* inStream, Entity* en }); } -void GameMessages::HandleRequestLinkedMission(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleRequestLinkedMission(RakNet::BitStream& inStream, Entity* entity) { LWOOBJID playerId{}; int missionId{}; bool bMissionOffered{}; - inStream->Read(playerId); - inStream->Read(missionId); - inStream->Read(bMissionOffered); + inStream.Read(playerId); + inStream.Read(missionId); + inStream.Read(bMissionOffered); auto* player = Game::entityManager->GetEntity(playerId); @@ -5210,9 +5145,9 @@ void GameMessages::HandleRequestLinkedMission(RakNet::BitStream* inStream, Entit } } -void GameMessages::HandleHasBeenCollected(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleHasBeenCollected(RakNet::BitStream& inStream, Entity* entity) { LWOOBJID playerID; - inStream->Read(playerID); + inStream.Read(playerID); Entity* player = Game::entityManager->GetEntity(playerID); if (!player || !entity || entity->GetCollectibleID() == 0) return; @@ -5223,7 +5158,7 @@ void GameMessages::HandleHasBeenCollected(RakNet::BitStream* inStream, Entity* e } } -void GameMessages::HandleNotifyServerLevelProcessingComplete(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleNotifyServerLevelProcessingComplete(RakNet::BitStream& inStream, Entity* entity) { auto* levelComp = entity->GetComponent(); if (!levelComp) return; auto* character = entity->GetComponent(); @@ -5262,9 +5197,9 @@ void GameMessages::HandleNotifyServerLevelProcessingComplete(RakNet::BitStream* GameMessages::SendBroadcastTextToChatbox(entity, UNASSIGNED_SYSTEM_ADDRESS, attrs, wsText); } -void GameMessages::HandlePickupCurrency(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandlePickupCurrency(RakNet::BitStream& inStream, Entity* entity) { unsigned int currency; - inStream->Read(currency); + inStream.Read(currency); if (currency == 0) return; @@ -5274,7 +5209,7 @@ void GameMessages::HandlePickupCurrency(RakNet::BitStream* inStream, Entity* ent } } -void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleRequestDie(RakNet::BitStream& inStream, Entity* entity) { LWOOBJID killerID; LWOOBJID lootOwnerID; bool bDieAccepted = false; @@ -5287,38 +5222,38 @@ void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity) bool bSpawnLoot = true; float coinSpawnTime = -1.0f; - inStream->Read(bClientDeath); - inStream->Read(bDieAccepted); - inStream->Read(bSpawnLoot); + inStream.Read(bClientDeath); + inStream.Read(bDieAccepted); + inStream.Read(bSpawnLoot); bool coinSpawnTimeIsDefault{}; - inStream->Read(coinSpawnTimeIsDefault); - if (coinSpawnTimeIsDefault != 0) inStream->Read(coinSpawnTime); + inStream.Read(coinSpawnTimeIsDefault); + if (coinSpawnTimeIsDefault != 0) inStream.Read(coinSpawnTime); /*uint32_t deathTypeLength = deathType.size(); - inStream->Read(deathTypeLength); + inStream.Read(deathTypeLength); for (uint32_t k = 0; k < deathTypeLength; k++) { - inStream->Read(deathType[k]); + inStream.Read(deathType[k]); }*/ - inStream->Read(directionRelative_AngleXZ); - inStream->Read(directionRelative_AngleY); - inStream->Read(directionRelative_Force); + inStream.Read(directionRelative_AngleXZ); + inStream.Read(directionRelative_AngleY); + inStream.Read(directionRelative_Force); bool killTypeIsDefault{}; - inStream->Read(killTypeIsDefault); - if (killTypeIsDefault != 0) inStream->Read(killType); + inStream.Read(killTypeIsDefault); + if (killTypeIsDefault != 0) inStream.Read(killType); - inStream->Read(lootOwnerID); - inStream->Read(killerID); + inStream.Read(lootOwnerID); + inStream.Read(killerID); } -void GameMessages::HandleEquipItem(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleEquipItem(RakNet::BitStream& inStream, Entity* entity) { bool immediate; LWOOBJID objectID; - inStream->Read(immediate); - inStream->Read(immediate); //twice? - inStream->Read(objectID); + inStream.Read(immediate); + inStream.Read(immediate); //twice? + inStream.Read(objectID); InventoryComponent* inv = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); if (!inv) return; @@ -5331,13 +5266,13 @@ void GameMessages::HandleEquipItem(RakNet::BitStream* inStream, Entity* entity) Game::entityManager->SerializeEntity(entity); } -void GameMessages::HandleUnequipItem(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleUnequipItem(RakNet::BitStream& inStream, Entity* entity) { bool immediate; LWOOBJID objectID; - inStream->Read(immediate); - inStream->Read(immediate); - inStream->Read(immediate); - inStream->Read(objectID); + inStream.Read(immediate); + inStream.Read(immediate); + inStream.Read(immediate); + inStream.Read(objectID); InventoryComponent* inv = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); if (!inv) return; @@ -5351,7 +5286,7 @@ void GameMessages::HandleUnequipItem(RakNet::BitStream* inStream, Entity* entity Game::entityManager->SerializeEntity(entity); } -void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { // this is used for a lot more than just inventory trashing (trades, vendors, etc.) but for now since it's just used for that, that's all im going to implement bool bConfirmed = false; bool bDeleteItem = true; @@ -5379,40 +5314,40 @@ void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream* inStream, En bool iTradeIDIsDefault = false; LWOOBJID iTradeID = LWOOBJID_EMPTY; - inStream->Read(bConfirmed); - inStream->Read(bDeleteItem); - inStream->Read(bOutSuccess); - inStream->Read(eInvTypeIsDefault); - if (eInvTypeIsDefault) inStream->Read(eInvType); - inStream->Read(eLootTypeSourceIsDefault); - if (eLootTypeSourceIsDefault) inStream->Read(eLootTypeSource); - inStream->Read(extraInfo.length); + inStream.Read(bConfirmed); + inStream.Read(bDeleteItem); + inStream.Read(bOutSuccess); + inStream.Read(eInvTypeIsDefault); + if (eInvTypeIsDefault) inStream.Read(eInvType); + inStream.Read(eLootTypeSourceIsDefault); + if (eLootTypeSourceIsDefault) inStream.Read(eLootTypeSource); + inStream.Read(extraInfo.length); if (extraInfo.length > 0) { for (uint32_t i = 0; i < extraInfo.length; ++i) { uint16_t character; - inStream->Read(character); + inStream.Read(character); extraInfo.name.push_back(character); } uint16_t nullTerm; - inStream->Read(nullTerm); + inStream.Read(nullTerm); } - inStream->Read(forceDeletion); - inStream->Read(iLootTypeSourceIsDefault); - if (iLootTypeSourceIsDefault) inStream->Read(iLootTypeSource); - inStream->Read(iObjIDIsDefault); - if (iObjIDIsDefault) inStream->Read(iObjID); - inStream->Read(iObjTemplateIsDefault); - if (iObjTemplateIsDefault) inStream->Read(iObjTemplate); - inStream->Read(iRequestingObjIDIsDefault); - if (iRequestingObjIDIsDefault) inStream->Read(iRequestingObjID); - inStream->Read(iStackCountIsDefault); - if (iStackCountIsDefault) inStream->Read(iStackCount); - inStream->Read(iStackRemainingIsDefault); - if (iStackRemainingIsDefault) inStream->Read(iStackRemaining); - inStream->Read(iSubkeyIsDefault); - if (iSubkeyIsDefault) inStream->Read(iSubkey); - inStream->Read(iTradeIDIsDefault); - if (iTradeIDIsDefault) inStream->Read(iTradeID); + inStream.Read(forceDeletion); + inStream.Read(iLootTypeSourceIsDefault); + if (iLootTypeSourceIsDefault) inStream.Read(iLootTypeSource); + inStream.Read(iObjIDIsDefault); + if (iObjIDIsDefault) inStream.Read(iObjID); + inStream.Read(iObjTemplateIsDefault); + if (iObjTemplateIsDefault) inStream.Read(iObjTemplate); + inStream.Read(iRequestingObjIDIsDefault); + if (iRequestingObjIDIsDefault) inStream.Read(iRequestingObjID); + inStream.Read(iStackCountIsDefault); + if (iStackCountIsDefault) inStream.Read(iStackCount); + inStream.Read(iStackRemainingIsDefault); + if (iStackRemainingIsDefault) inStream.Read(iStackRemaining); + inStream.Read(iSubkeyIsDefault); + if (iSubkeyIsDefault) inStream.Read(iSubkey); + inStream.Read(iTradeIDIsDefault); + if (iTradeIDIsDefault) inStream.Read(iTradeID); InventoryComponent* inv = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); if (!inv) return; @@ -5453,19 +5388,19 @@ void GameMessages::SendSetGravityScale(const LWOOBJID& target, const float effec SEND_PACKET; } -void GameMessages::HandleMoveItemInInventory(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleMoveItemInInventory(RakNet::BitStream& inStream, Entity* entity) { bool destInvTypeIsDefault = false; int32_t destInvType = eInventoryType::INVALID; LWOOBJID iObjID; int inventoryType; int responseCode; int slot; - inStream->Read(destInvTypeIsDefault); - if (destInvTypeIsDefault) { inStream->Read(destInvType); } - inStream->Read(iObjID); - inStream->Read(inventoryType); - inStream->Read(responseCode); - inStream->Read(slot); + inStream.Read(destInvTypeIsDefault); + if (destInvTypeIsDefault) { inStream.Read(destInvType); } + inStream.Read(iObjID); + inStream.Read(inventoryType); + inStream.Read(responseCode); + inStream.Read(slot); InventoryComponent* inv = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); if (!inv) return; @@ -5480,7 +5415,7 @@ void GameMessages::HandleMoveItemInInventory(RakNet::BitStream* inStream, Entity Game::entityManager->SerializeEntity(entity); } -void GameMessages::HandleMoveItemBetweenInventoryTypes(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleMoveItemBetweenInventoryTypes(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { eInventoryType inventoryTypeA; eInventoryType inventoryTypeB; LWOOBJID objectID; @@ -5490,14 +5425,14 @@ void GameMessages::HandleMoveItemBetweenInventoryTypes(RakNet::BitStream* inStre bool templateIDIsDefault = false; LOT templateID = LOT_NULL; - inStream->Read(inventoryTypeA); - inStream->Read(inventoryTypeB); - inStream->Read(objectID); - inStream->Read(showFlyingLoot); - inStream->Read(stackCountIsDefault); - if (stackCountIsDefault) inStream->Read(stackCount); - inStream->Read(templateIDIsDefault); - if (templateIDIsDefault) inStream->Read(templateID); + inStream.Read(inventoryTypeA); + inStream.Read(inventoryTypeB); + inStream.Read(objectID); + inStream.Read(showFlyingLoot); + inStream.Read(stackCountIsDefault); + if (stackCountIsDefault) inStream.Read(stackCount); + inStream.Read(templateIDIsDefault); + if (templateIDIsDefault) inStream.Read(templateID); auto inv = entity->GetComponent(); if (!inv) return; @@ -5526,10 +5461,10 @@ void GameMessages::HandleMoveItemBetweenInventoryTypes(RakNet::BitStream* inStre Game::entityManager->SerializeEntity(entity); } -void GameMessages::HandleBuildModeSet(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleBuildModeSet(RakNet::BitStream& inStream, Entity* entity) { bool bStart = false; - inStream->Read(bStart); + inStream.Read(bStart); // there's more here but we don't need it (for now?) LOG("Set build mode to (%d) for (%llu)", bStart, entity->GetObjectID()); @@ -5539,7 +5474,7 @@ void GameMessages::HandleBuildModeSet(RakNet::BitStream* inStream, Entity* entit } } -void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleModularBuildFinish(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { User* user = UserManager::Instance()->GetUser(sysAddr); if (!user) return; Entity* character = Game::entityManager->GetEntity(user->GetLoggedInChar()); @@ -5550,7 +5485,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity* uint8_t count; // 3 for rockets, 7 for cars - inStream->Read(count); + inStream.Read(count); auto* temp = inv->GetInventory(TEMP_MODELS); std::vector modList; @@ -5561,7 +5496,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity* for (uint32_t k = 0; k < count; k++) { uint32_t mod; - inStream->Read(mod); + inStream.Read(mod); modList.push_back(mod); auto modToStr = GeneralUtils::to_u16string(mod); modules += u"1:" + (modToStr); @@ -5639,7 +5574,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity* } } -void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { User* user = UserManager::Instance()->GetUser(sysAddr); if (!user) return; Entity* character = Game::entityManager->GetEntity(user->GetLoggedInChar()); @@ -5674,18 +5609,18 @@ void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Enti LOT oldItemLOT = 0; int oldItemTYPE = 0; - inStream->Read(newSourceBAG); - inStream->Read(newSourceID); - inStream->Read(newSourceLOT); - inStream->Read(newSourceTYPE); - inStream->Read(newTargetID); - inStream->Read(newTargetLOT); - inStream->Read(newTargetTYPE); - inStream->Read(newTargetPOS); - inStream->Read(oldItemBAG); - inStream->Read(oldItemID); - inStream->Read(oldItemLOT); - inStream->Read(oldItemTYPE); + inStream.Read(newSourceBAG); + inStream.Read(newSourceID); + inStream.Read(newSourceLOT); + inStream.Read(newSourceTYPE); + inStream.Read(newTargetID); + inStream.Read(newTargetLOT); + inStream.Read(newTargetTYPE); + inStream.Read(newTargetPOS); + inStream.Read(oldItemBAG); + inStream.Read(oldItemID); + inStream.Read(oldItemLOT); + inStream.Read(oldItemTYPE); /* LOG("GameMessages", @@ -5750,7 +5685,7 @@ void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Enti } } -void GameMessages::HandleModularBuildMoveAndEquip(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleModularBuildMoveAndEquip(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { User* user = UserManager::Instance()->GetUser(sysAddr); if (!user) return; Entity* character = Game::entityManager->GetEntity(user->GetLoggedInChar()); @@ -5760,7 +5695,7 @@ void GameMessages::HandleModularBuildMoveAndEquip(RakNet::BitStream* inStream, E LOT templateID; - inStream->Read(templateID); + inStream.Read(templateID); InventoryComponent* inv = static_cast(character->GetComponent(eReplicaComponentType::INVENTORY)); if (!inv) return; @@ -5774,11 +5709,11 @@ void GameMessages::HandleModularBuildMoveAndEquip(RakNet::BitStream* inStream, E inv->MoveItemToInventory(item, eInventoryType::MODELS, 1, false, true); } -void GameMessages::HandlePickupItem(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandlePickupItem(RakNet::BitStream& inStream, Entity* entity) { LWOOBJID lootObjectID; LWOOBJID playerID; - inStream->Read(lootObjectID); - inStream->Read(playerID); + inStream.Read(lootObjectID); + inStream.Read(playerID); entity->PickupItem(lootObjectID); @@ -5795,8 +5730,8 @@ void GameMessages::HandlePickupItem(RakNet::BitStream* inStream, Entity* entity) } } -void GameMessages::HandleResurrect(RakNet::BitStream* inStream, Entity* entity) { - bool immediate = inStream->ReadBit(); +void GameMessages::HandleResurrect(RakNet::BitStream& inStream, Entity* entity) { + bool immediate = inStream.ReadBit(); Entity* zoneControl = Game::entityManager->GetZoneControlEntity(); for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) { @@ -5813,13 +5748,13 @@ void GameMessages::HandleResurrect(RakNet::BitStream* inStream, Entity* entity) } } -void GameMessages::HandlePushEquippedItemsState(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandlePushEquippedItemsState(RakNet::BitStream& inStream, Entity* entity) { InventoryComponent* inv = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); if (!inv) return; inv->PushEquippedItems(); } -void GameMessages::HandlePopEquippedItemsState(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandlePopEquippedItemsState(RakNet::BitStream& inStream, Entity* entity) { InventoryComponent* inv = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); if (!inv) return; inv->PopEquippedItems(); @@ -5827,10 +5762,10 @@ void GameMessages::HandlePopEquippedItemsState(RakNet::BitStream* inStream, Enti } -void GameMessages::HandleClientItemConsumed(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleClientItemConsumed(RakNet::BitStream& inStream, Entity* entity) { LWOOBJID itemConsumed; - inStream->Read(itemConsumed); + inStream.Read(itemConsumed); auto* inventory = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); @@ -5853,10 +5788,10 @@ void GameMessages::HandleClientItemConsumed(RakNet::BitStream* inStream, Entity* } -void GameMessages::HandleUseNonEquipmentItem(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleUseNonEquipmentItem(RakNet::BitStream& inStream, Entity* entity) { LWOOBJID itemConsumed; - inStream->Read(itemConsumed); + inStream.Read(itemConsumed); auto* inv = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); @@ -5867,7 +5802,7 @@ void GameMessages::HandleUseNonEquipmentItem(RakNet::BitStream* inStream, Entity if (item) item->UseNonEquip(item); } -void GameMessages::HandleMatchRequest(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleMatchRequest(RakNet::BitStream& inStream, Entity* entity) { LWOOBJID activator; //std::map additionalPlayers; uint32_t playerChoicesLen; @@ -5875,19 +5810,19 @@ void GameMessages::HandleMatchRequest(RakNet::BitStream* inStream, Entity* entit int type; int value; - inStream->Read(activator); - inStream->Read(playerChoicesLen); + inStream.Read(activator); + inStream.Read(playerChoicesLen); for (uint32_t i = 0; i < playerChoicesLen; ++i) { uint16_t character; - inStream->Read(character); + inStream.Read(character); playerChoices.push_back(character); } if (playerChoicesLen > 0) { uint16_t nullTerm; - inStream->Read(nullTerm); + inStream.Read(nullTerm); } - inStream->Read(type); - inStream->Read(value); + inStream.Read(type); + inStream.Read(value); std::vector scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY); if (type == 0) { // join @@ -5913,11 +5848,11 @@ void GameMessages::HandleMatchRequest(RakNet::BitStream* inStream, Entity* entit } } -void GameMessages::HandleGetHotPropertyData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleGetHotPropertyData(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { SendGetHotPropertyData(inStream, entity, sysAddr); } -void GameMessages::SendGetHotPropertyData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::SendGetHotPropertyData(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { CBITSTREAM; CMSGHEADER; /** @@ -5958,17 +5893,17 @@ void GameMessages::SendGetHotPropertyData(RakNet::BitStream* inStream, Entity* e SEND_PACKET*/ } -void GameMessages::HandleReportBug(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleReportBug(RakNet::BitStream& inStream, Entity* entity) { //Definitely not stolen from autogenerated code, no sir: IBugReports::Info reportInfo; //Reading: uint32_t messageLength; - inStream->Read(messageLength); + inStream.Read(messageLength); for (uint32_t i = 0; i < (messageLength); ++i) { uint16_t character; - inStream->Read(character); + inStream.Read(character); reportInfo.body.push_back(static_cast(character)); } @@ -5976,26 +5911,26 @@ void GameMessages::HandleReportBug(RakNet::BitStream* inStream, Entity* entity) if (character) reportInfo.characterId = character->GetID(); uint32_t clientVersionLength; - inStream->Read(clientVersionLength); + inStream.Read(clientVersionLength); for (unsigned int k = 0; k < clientVersionLength; k++) { unsigned char character; - inStream->Read(character); + inStream.Read(character); reportInfo.clientVersion.push_back(character); } uint32_t nOtherPlayerIDLength; - inStream->Read(nOtherPlayerIDLength); + inStream.Read(nOtherPlayerIDLength); for (unsigned int k = 0; k < nOtherPlayerIDLength; k++) { unsigned char character; - inStream->Read(character); + inStream.Read(character); reportInfo.otherPlayer.push_back(character); } uint32_t selectionLength; - inStream->Read(selectionLength); + inStream.Read(selectionLength); for (unsigned int k = 0; k < selectionLength; k++) { unsigned char character; - inStream->Read(character); + inStream.Read(character); reportInfo.selection.push_back(character); } @@ -6003,7 +5938,7 @@ void GameMessages::HandleReportBug(RakNet::BitStream* inStream, Entity* entity) } void -GameMessages::HandleClientRailMovementReady(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +GameMessages::HandleClientRailMovementReady(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { const auto possibleRails = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR); for (const auto* possibleRail : possibleRails) { const auto* rail = possibleRail->GetComponent(); @@ -6013,8 +5948,8 @@ GameMessages::HandleClientRailMovementReady(RakNet::BitStream* inStream, Entity* } } -void GameMessages::HandleCancelRailMovement(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { - const auto immediate = inStream->ReadBit(); +void GameMessages::HandleCancelRailMovement(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { + const auto immediate = inStream.ReadBit(); const auto possibleRails = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR); for (const auto* possibleRail : possibleRails) { @@ -6025,20 +5960,20 @@ void GameMessages::HandleCancelRailMovement(RakNet::BitStream* inStream, Entity* } } -void GameMessages::HandlePlayerRailArrivedNotification(RakNet::BitStream* inStream, Entity* entity, +void GameMessages::HandlePlayerRailArrivedNotification(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { uint32_t pathNameLength; - inStream->Read(pathNameLength); + inStream.Read(pathNameLength); std::u16string pathName; for (auto k = 0; k < pathNameLength; k++) { uint16_t c; - inStream->Read(c); + inStream.Read(c); pathName.push_back(c); } int32_t waypointNumber; - inStream->Read(waypointNumber); + inStream.Read(waypointNumber); const auto possibleRails = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR); for (auto* possibleRail : possibleRails) { @@ -6048,20 +5983,20 @@ void GameMessages::HandlePlayerRailArrivedNotification(RakNet::BitStream* inStre } } -void GameMessages::HandleModifyPlayerZoneStatistic(RakNet::BitStream* inStream, Entity* entity) { - const auto set = inStream->ReadBit(); +void GameMessages::HandleModifyPlayerZoneStatistic(RakNet::BitStream& inStream, Entity* entity) { + const auto set = inStream.ReadBit(); const auto statisticsName = GeneralUtils::ReadWString(inStream); int32_t value; - if (inStream->ReadBit()) { - inStream->Read(value); + if (inStream.ReadBit()) { + inStream.Read(value); } else { value = 0; } LWOMAPID zone; - if (inStream->ReadBit()) { - inStream->Read(zone); + if (inStream.ReadBit()) { + inStream.Read(zone); } else { zone = LWOMAPID_INVALID; } @@ -6073,13 +6008,13 @@ void GameMessages::HandleModifyPlayerZoneStatistic(RakNet::BitStream* inStream, } } -void GameMessages::HandleUpdatePlayerStatistic(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleUpdatePlayerStatistic(RakNet::BitStream& inStream, Entity* entity) { int32_t updateID; - inStream->Read(updateID); + inStream.Read(updateID); int64_t updateValue; - if (inStream->ReadBit()) { - inStream->Read(updateValue); + if (inStream.ReadBit()) { + inStream.Read(updateValue); } else { updateValue = 1; } @@ -6090,14 +6025,14 @@ void GameMessages::HandleUpdatePlayerStatistic(RakNet::BitStream* inStream, Enti } } -void GameMessages::HandleDeactivateBubbleBuff(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleDeactivateBubbleBuff(RakNet::BitStream& inStream, Entity* entity) { auto controllablePhysicsComponent = entity->GetComponent(); if (controllablePhysicsComponent) controllablePhysicsComponent->DeactivateBubbleBuff(); } -void GameMessages::HandleActivateBubbleBuff(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleActivateBubbleBuff(RakNet::BitStream& inStream, Entity* entity) { bool specialAnimations; - if (!inStream->Read(specialAnimations)) return; + if (!inStream.Read(specialAnimations)) return; std::u16string type = GeneralUtils::ReadWString(inStream); auto bubbleType = eBubbleType::DEFAULT; @@ -6130,9 +6065,9 @@ void GameMessages::SendDeactivateBubbleBuffFromServer(LWOOBJID objectId, const S SEND_PACKET; } -void GameMessages::HandleZoneSummaryDismissed(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleZoneSummaryDismissed(RakNet::BitStream& inStream, Entity* entity) { LWOOBJID player_id; - inStream->Read(player_id); + inStream.Read(player_id); auto target = Game::entityManager->GetEntity(player_id); entity->TriggerEvent(eTriggerEventType::ZONE_SUMMARY_DISMISSED, target); }; @@ -6166,25 +6101,25 @@ void GameMessages::SendShowBillboardInteractIcon(const SystemAddress& sysAddr, L else SEND_PACKET } -void GameMessages::HandleRequestActivityExit(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleRequestActivityExit(RakNet::BitStream& inStream, Entity* entity) { bool canceled = false; - inStream->Read(canceled); + inStream.Read(canceled); if (!canceled) return; LWOOBJID player_id = LWOOBJID_EMPTY; - inStream->Read(player_id); + inStream.Read(player_id); auto player = Game::entityManager->GetEntity(player_id); if (!entity || !player) return; entity->RequestActivityExit(entity, player_id, canceled); } -void GameMessages::HandleAddDonationItem(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleAddDonationItem(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { uint32_t count = 1; bool hasCount = false; - inStream->Read(hasCount); - if (hasCount) inStream->Read(count); + inStream.Read(hasCount); + if (hasCount) inStream.Read(count); LWOOBJID itemId = LWOOBJID_EMPTY; - inStream->Read(itemId); + inStream.Read(itemId); if (!itemId) return; auto* donationVendorComponent = entity->GetComponent(); @@ -6208,15 +6143,15 @@ void GameMessages::HandleAddDonationItem(RakNet::BitStream* inStream, Entity* en inventoryComponent->MoveItemToInventory(item, eInventoryType::DONATION, count, true, false, true); } -void GameMessages::HandleRemoveDonationItem(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { +void GameMessages::HandleRemoveDonationItem(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) { bool confirmed = false; - inStream->Read(confirmed); + inStream.Read(confirmed); uint32_t count = 1; bool hasCount = false; - inStream->Read(hasCount); - if (hasCount) inStream->Read(count); + inStream.Read(hasCount); + if (hasCount) inStream.Read(count); LWOOBJID itemId = LWOOBJID_EMPTY; - inStream->Read(itemId); + inStream.Read(itemId); if (!itemId) return; User* user = UserManager::Instance()->GetUser(sysAddr); @@ -6233,7 +6168,7 @@ void GameMessages::HandleRemoveDonationItem(RakNet::BitStream* inStream, Entity* inventoryComponent->MoveItemToInventory(item, eInventoryType::BRICKS, count, true, false, true); } -void GameMessages::HandleConfirmDonationOnPlayer(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleConfirmDonationOnPlayer(RakNet::BitStream& inStream, Entity* entity) { auto* inventoryComponent = entity->GetComponent(); if (!inventoryComponent) return; auto* missionComponent = entity->GetComponent(); @@ -6265,7 +6200,7 @@ void GameMessages::HandleConfirmDonationOnPlayer(RakNet::BitStream* inStream, En characterComponent->SetCurrentInteracting(LWOOBJID_EMPTY); } -void GameMessages::HandleCancelDonationOnPlayer(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleCancelDonationOnPlayer(RakNet::BitStream& inStream, Entity* entity) { auto* inventoryComponent = entity->GetComponent(); if (!inventoryComponent) return; auto* inventory = inventoryComponent->GetInventory(eInventoryType::DONATION); diff --git a/dGame/dGameMessages/GameMessages.h b/dGame/dGameMessages/GameMessages.h index a96bbf60..96bbf7c3 100644 --- a/dGame/dGameMessages/GameMessages.h +++ b/dGame/dGameMessages/GameMessages.h @@ -38,6 +38,7 @@ enum class eUseItemResponse : uint32_t; enum class eQuickBuildFailReason : uint32_t; enum class eQuickBuildState : uint32_t; enum class BehaviorSlot : int32_t; +enum class eVendorTransactionResult : uint32_t; namespace GameMessages { class PropertyDataMessage; @@ -135,7 +136,7 @@ namespace GameMessages { void SendVendorOpenWindow(Entity* entity, const SystemAddress& sysAddr); void SendVendorStatusUpdate(Entity* entity, const SystemAddress& sysAddr, bool bUpdateOnly = false); - void SendVendorTransactionResult(Entity* entity, const SystemAddress& sysAddr); + void SendVendorTransactionResult(Entity* entity, const SystemAddress& sysAddr, eVendorTransactionResult result); void SendRemoveItemFromInventory(Entity* entity, const SystemAddress& sysAddr, LWOOBJID iObjID, LOT templateID, int inventoryType, uint32_t stackCount, uint32_t stackRemaining); void SendConsumeClientItem(Entity* entity, bool bSuccess, LWOOBJID item); @@ -145,7 +146,7 @@ namespace GameMessages { void SendMatchResponse(Entity* entity, const SystemAddress& sysAddr, int response); void SendMatchUpdate(Entity* entity, const SystemAddress& sysAddr, std::string data, eMatchUpdate type); - void HandleUnUseModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleUnUseModel(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); void SendStartCelebrationEffect(Entity* entity, const SystemAddress& sysAddr, int celebrationID); // https://lcdruniverse.org/lu_packets/lu_packets/world/gm/client/struct.SetResurrectRestoreValues.html @@ -182,7 +183,7 @@ namespace GameMessages { * @param entity The Entity that sent the message * @param sysAddr The SystemAddress that sent the message */ - void HandleControlBehaviors(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleControlBehaviors(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); // Rails stuff void SendSetRailMovement(const LWOOBJID& objectID, bool pathGoForward, std::u16string pathName, uint32_t pathStart, @@ -196,9 +197,9 @@ namespace GameMessages { bool collisionEnabled = true, bool useDB = true, int32_t railComponentID = -1, LWOOBJID railActivatorObjectID = LWOOBJID_EMPTY); - void HandleClientRailMovementReady(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleCancelRailMovement(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandlePlayerRailArrivedNotification(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleClientRailMovementReady(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleCancelRailMovement(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandlePlayerRailArrivedNotification(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); void SendNotifyClientObject(const LWOOBJID& objectID, std::u16string name, int param1 = 0, int param2 = 0, const LWOOBJID& paramObj = LWOOBJID_EMPTY, std::string paramStr = "", const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS); void SendNotifyClientZoneObject(const LWOOBJID& objectID, const std::u16string& name, int param1, int param2, const LWOOBJID& paramObj, const std::string& paramStr, const SystemAddress& sysAddr); @@ -251,39 +252,39 @@ namespace GameMessages { void SendUGCEquipPostDeleteBasedOnEditMode(LWOOBJID objectId, const SystemAddress& sysAddr, LWOOBJID inventoryItem, int itemTotal); - void HandleSetPropertyAccess(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleSetPropertyAccess(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleUpdatePropertyOrModelForFilterCheck(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleUpdatePropertyOrModelForFilterCheck(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleQueryPropertyData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleQueryPropertyData(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleSetBuildMode(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleSetBuildMode(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleStartBuildingWithItem(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleStartBuildingWithItem(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandlePropertyEditorBegin(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandlePropertyEditorBegin(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandlePropertyEditorEnd(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandlePropertyEditorEnd(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandlePropertyContentsFromClient(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandlePropertyContentsFromClient(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandlePropertyModelEquipped(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandlePropertyModelEquipped(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandlePlacePropertyModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandlePlacePropertyModel(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleUpdatePropertyModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleUpdatePropertyModel(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleDeletePropertyModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleDeletePropertyModel(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleBBBLoadItemRequest(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleBBBLoadItemRequest(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleBBBSaveRequest(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandlePropertyEntranceSync(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandlePropertyEntranceSync(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleEnterProperty(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleEnterProperty(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleSetConsumableItem(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleSetConsumableItem(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); void SendPlayCinematic(LWOOBJID objectId, std::u16string pathName, const SystemAddress& sysAddr, bool allowGhostUpdates = true, bool bCloseMultiInteract = true, bool bSendServerNotify = false, bool bUseControlledObjectForAudioListener = false, @@ -292,7 +293,7 @@ namespace GameMessages { void SendEndCinematic(LWOOBJID objectID, std::u16string pathName, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS, float leadOut = -1.0f, bool leavePlayerLocked = false); - void HandleCinematicUpdate(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleCinematicUpdate(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); void SendSetStunned(LWOOBJID objectId, eStateChangeType stateChangeType, const SystemAddress& sysAddr, LWOOBJID originator = LWOOBJID_EMPTY, bool bCantAttack = false, bool bCantEquip = false, @@ -344,7 +345,7 @@ namespace GameMessages { void SendNotifyObject(LWOOBJID objectId, LWOOBJID objIDSender, std::u16string name, const SystemAddress& sysAddr, int param1 = 0, int param2 = 0); - void HandleVerifyAck(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleVerifyAck(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); void SendTeamPickupItem(LWOOBJID objectId, LWOOBJID lootID, LWOOBJID lootOwnerID, const SystemAddress& sysAddr); @@ -361,13 +362,13 @@ namespace GameMessages { void SendServerTradeUpdate(LWOOBJID objectId, uint64_t coins, const std::vector& items, const SystemAddress& sysAddr); - void HandleClientTradeRequest(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleClientTradeRequest(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleClientTradeCancel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleClientTradeCancel(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleClientTradeAccept(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleClientTradeAccept(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleClientTradeUpdate(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleClientTradeUpdate(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); //Pets: void SendNotifyPetTamingMinigame(LWOOBJID objectId, LWOOBJID petId, LWOOBJID playerTamingId, bool bForceTeleport, ePetTamingNotifyType notifyType, NiPoint3 petsDestPos, NiPoint3 telePos, NiQuaternion teleRot, const SystemAddress& sysAddr); @@ -402,23 +403,23 @@ namespace GameMessages { void SendPetNameChanged(LWOOBJID objectId, int32_t moderationStatus, std::u16string name, std::u16string ownerName, const SystemAddress& sysAddr); - void HandleClientExitTamingMinigame(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleClientExitTamingMinigame(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleStartServerPetMinigameTimer(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleStartServerPetMinigameTimer(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandlePetTamingTryBuild(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandlePetTamingTryBuild(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleNotifyTamingBuildSuccess(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleNotifyTamingBuildSuccess(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleRequestSetPetName(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleRequestSetPetName(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleCommandPet(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleCommandPet(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleDespawnPet(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleDespawnPet(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleMessageBoxResponse(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleMessageBoxResponse(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleChoiceBoxRespond(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleChoiceBoxRespond(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); void SendDisplayZoneSummary(LWOOBJID objectId, const SystemAddress& sysAddr, bool isPropertyMap = false, bool isZoneStart = false, LWOOBJID sender = LWOOBJID_EMPTY); @@ -455,7 +456,7 @@ namespace GameMessages { * @param entity The Entity that is dismounting * @param sysAddr the system address to send game message responses to */ - void HandleDismountComplete(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleDismountComplete(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); /** * @brief Handle acknowledging that the client possessed something @@ -464,7 +465,7 @@ namespace GameMessages { * @param entity The Entity that is possessing * @param sysAddr the system address to send game message responses to */ - void HandleAcknowledgePossession(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleAcknowledgePossession(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); /** * @brief A request from a client to get the hot properties that would appear on the news feed @@ -474,7 +475,7 @@ namespace GameMessages { * @param entity The Entity that sent the request * @param sysAddr The SystemAddress of the Entity that sent the request */ - void HandleGetHotPropertyData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleGetHotPropertyData(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); /** * @brief A request from a client to get the hot properties that would appear on the news feed @@ -496,26 +497,26 @@ namespace GameMessages { * @param entity The Entity that sent the request * @param sysAddr The SystemAddress of the Entity that sent the request */ - void SendGetHotPropertyData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void SendGetHotPropertyData(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); //Racing: - void HandleModuleAssemblyQueryData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleModuleAssemblyQueryData(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleModularAssemblyNIFCompleted(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleModularAssemblyNIFCompleted(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleVehicleSetWheelLockState(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleVehicleSetWheelLockState(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleRacingClientReady(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleRacingClientReady(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleRequestDie(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleRequestDie(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleVehicleNotifyServerAddPassiveBoostAction(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleVehicleNotifyServerAddPassiveBoostAction(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleVehicleNotifyServerRemovePassiveBoostAction(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleVehicleNotifyServerRemovePassiveBoostAction(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleRacingPlayerInfoResetFinished(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleRacingPlayerInfoResetFinished(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleVehicleNotifyHitImaginationServer(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleVehicleNotifyHitImaginationServer(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); void SendModuleAssemblyDBDataForClient(LWOOBJID objectId, LWOOBJID assemblyID, const std::u16string& data, const SystemAddress& sysAddr); @@ -555,7 +556,7 @@ namespace GameMessages { bool bUseLeaderboards ); - void HandleUpdatePropertyPerformanceCost(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleUpdatePropertyPerformanceCost(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); void SendNotifyClientShootingGalleryScore(LWOOBJID objectId, const SystemAddress& sysAddr, float addTime, @@ -564,20 +565,20 @@ namespace GameMessages { NiPoint3 targetPos ); - void HandleUpdateShootingGalleryRotation(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleUpdateShootingGalleryRotation(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); void SendUpdateReputation(const LWOOBJID objectId, const int64_t reputation, const SystemAddress& sysAddr); // Leaderboards void SendActivitySummaryLeaderboardData(const LWOOBJID& objectID, const Leaderboard* leaderboard, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS); - void HandleActivitySummaryLeaderboardData(RakNet::BitStream* instream, Entity* entity, const SystemAddress& sysAddr); + void HandleActivitySummaryLeaderboardData(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); void SendRequestActivitySummaryLeaderboardData(const LWOOBJID& objectID, const LWOOBJID& targetID, const SystemAddress& sysAddr, const int32_t& gameID = 0, const int32_t& queryType = 1, const int32_t& resultsEnd = 10, const int32_t& resultsStart = 0, bool weekly = false); - void HandleRequestActivitySummaryLeaderboardData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleActivityStateChangeRequest(RakNet::BitStream* inStream, Entity* entity); + void HandleRequestActivitySummaryLeaderboardData(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleActivityStateChangeRequest(RakNet::BitStream& inStream, Entity* entity); void SendVehicleAddPassiveBoostAction(LWOOBJID objectId, const SystemAddress& sysAddr); @@ -587,82 +588,82 @@ namespace GameMessages { //NT: - void HandleRequestMoveItemBetweenInventoryTypes(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleRequestMoveItemBetweenInventoryTypes(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); void SendShowActivityCountdown(LWOOBJID objectId, bool bPlayAdditionalSound, bool bPlayCountdownSound, std::u16string sndName, int32_t stateToPlaySoundOn, const SystemAddress& sysAddr); //Handlers: - void HandleToggleGhostReferenceOverride(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleSetGhostReferencePosition(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleToggleGhostReferenceOverride(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleSetGhostReferencePosition(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); void SendSetNamebillboardState(const SystemAddress& sysAddr, LWOOBJID objectId); void SendShowBillboardInteractIcon(const SystemAddress& sysAddr, LWOOBJID objectId); - void HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleSellToVendor(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleBuybackFromVendor(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleParseChatMessage(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleToggleGhostReffrenceOverride(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleSetGhostReffrenceOverride(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleFireEventServerSide(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleRequestPlatformResync(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleQuickBuildCancel(RakNet::BitStream* inStream, Entity* entity); - void HandleRequestUse(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity); - void HandleModularBuildConvertModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleSetFlag(RakNet::BitStream* inStream, Entity* entity); - void HandleRespondToMission(RakNet::BitStream* inStream, Entity* entity); - void HandleMissionDialogOK(RakNet::BitStream* inStream, Entity* entity); - void HandleRequestLinkedMission(RakNet::BitStream* inStream, Entity* entity); - void HandleHasBeenCollected(RakNet::BitStream* inStream, Entity* entity); - void HandleNotifyServerLevelProcessingComplete(RakNet::BitStream* inStream, Entity* entity); - void HandlePickupCurrency(RakNet::BitStream* inStream, Entity* entity); - void HandleRequestDie(RakNet::BitStream* inStream, Entity* entity); - void HandleEquipItem(RakNet::BitStream* inStream, Entity* entity); - void HandleUnequipItem(RakNet::BitStream* inStream, Entity* entity); - void HandleRemoveItemFromInventory(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleMoveItemInInventory(RakNet::BitStream* inStream, Entity* entity); - void HandleMoveItemBetweenInventoryTypes(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleBuildModeSet(RakNet::BitStream* inStream, Entity* entity); - void HandleModularBuildFinish(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleModularBuildMoveAndEquip(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandlePickupItem(RakNet::BitStream* inStream, Entity* entity); - void HandleResurrect(RakNet::BitStream* inStream, Entity* entity); - void HandleModifyPlayerZoneStatistic(RakNet::BitStream* inStream, Entity* entity); - void HandleUpdatePlayerStatistic(RakNet::BitStream* inStream, Entity* entity); + void HandleBuyFromVendor(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleSellToVendor(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleBuybackFromVendor(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleParseChatMessage(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleToggleGhostReffrenceOverride(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleSetGhostReffrenceOverride(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleFireEventServerSide(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleRequestPlatformResync(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleQuickBuildCancel(RakNet::BitStream& inStream, Entity* entity); + void HandleRequestUse(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandlePlayEmote(RakNet::BitStream& inStream, Entity* entity); + void HandleModularBuildConvertModel(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleSetFlag(RakNet::BitStream& inStream, Entity* entity); + void HandleRespondToMission(RakNet::BitStream& inStream, Entity* entity); + void HandleMissionDialogOK(RakNet::BitStream& inStream, Entity* entity); + void HandleRequestLinkedMission(RakNet::BitStream& inStream, Entity* entity); + void HandleHasBeenCollected(RakNet::BitStream& inStream, Entity* entity); + void HandleNotifyServerLevelProcessingComplete(RakNet::BitStream& inStream, Entity* entity); + void HandlePickupCurrency(RakNet::BitStream& inStream, Entity* entity); + void HandleRequestDie(RakNet::BitStream& inStream, Entity* entity); + void HandleEquipItem(RakNet::BitStream& inStream, Entity* entity); + void HandleUnequipItem(RakNet::BitStream& inStream, Entity* entity); + void HandleRemoveItemFromInventory(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleMoveItemInInventory(RakNet::BitStream& inStream, Entity* entity); + void HandleMoveItemBetweenInventoryTypes(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleBuildModeSet(RakNet::BitStream& inStream, Entity* entity); + void HandleModularBuildFinish(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleDoneArrangingWithItem(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleModularBuildMoveAndEquip(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandlePickupItem(RakNet::BitStream& inStream, Entity* entity); + void HandleResurrect(RakNet::BitStream& inStream, Entity* entity); + void HandleModifyPlayerZoneStatistic(RakNet::BitStream& inStream, Entity* entity); + void HandleUpdatePlayerStatistic(RakNet::BitStream& inStream, Entity* entity); - void HandlePushEquippedItemsState(RakNet::BitStream* inStream, Entity* entity); + void HandlePushEquippedItemsState(RakNet::BitStream& inStream, Entity* entity); - void HandlePopEquippedItemsState(RakNet::BitStream* inStream, Entity* entity); + void HandlePopEquippedItemsState(RakNet::BitStream& inStream, Entity* entity); - void HandleClientItemConsumed(RakNet::BitStream* inStream, Entity* entity); + void HandleClientItemConsumed(RakNet::BitStream& inStream, Entity* entity); - void HandleUseNonEquipmentItem(RakNet::BitStream* inStream, Entity* entity); + void HandleUseNonEquipmentItem(RakNet::BitStream& inStream, Entity* entity); - void HandleMatchRequest(RakNet::BitStream* inStream, Entity* entity); + void HandleMatchRequest(RakNet::BitStream& inStream, Entity* entity); - void HandleReportBug(RakNet::BitStream* inStream, Entity* entity); + void HandleReportBug(RakNet::BitStream& inStream, Entity* entity); void SendRemoveBuff(Entity* entity, bool fromUnEquip, bool removeImmunity, uint32_t buffId); // bubble - void HandleDeactivateBubbleBuff(RakNet::BitStream* inStream, Entity* entity); + void HandleDeactivateBubbleBuff(RakNet::BitStream& inStream, Entity* entity); - void HandleActivateBubbleBuff(RakNet::BitStream* inStream, Entity* entity); + void HandleActivateBubbleBuff(RakNet::BitStream& inStream, Entity* entity); void SendActivateBubbleBuffFromServer(LWOOBJID objectId, const SystemAddress& sysAddr); void SendDeactivateBubbleBuffFromServer(LWOOBJID objectId, const SystemAddress& sysAddr); - void HandleZoneSummaryDismissed(RakNet::BitStream* inStream, Entity* entity); - void HandleRequestActivityExit(RakNet::BitStream* inStream, Entity* entity); + void HandleZoneSummaryDismissed(RakNet::BitStream& inStream, Entity* entity); + void HandleRequestActivityExit(RakNet::BitStream& inStream, Entity* entity); // Donation vendor - void HandleAddDonationItem(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleRemoveDonationItem(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleConfirmDonationOnPlayer(RakNet::BitStream* inStream, Entity* entity); - void HandleCancelDonationOnPlayer(RakNet::BitStream* inStream, Entity* entity); + void HandleAddDonationItem(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleRemoveDonationItem(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr); + void HandleConfirmDonationOnPlayer(RakNet::BitStream& inStream, Entity* entity); + void HandleCancelDonationOnPlayer(RakNet::BitStream& inStream, Entity* entity); }; #endif // GAMEMESSAGES_H diff --git a/dGame/dGameMessages/RequestServerProjectileImpact.h b/dGame/dGameMessages/RequestServerProjectileImpact.h index 090d8274..c15090c0 100644 --- a/dGame/dGameMessages/RequestServerProjectileImpact.h +++ b/dGame/dGameMessages/RequestServerProjectileImpact.h @@ -19,44 +19,44 @@ public: sBitStream = _sBitStream; } - RequestServerProjectileImpact(RakNet::BitStream* stream) : RequestServerProjectileImpact() { + RequestServerProjectileImpact(RakNet::BitStream& stream) : RequestServerProjectileImpact() { Deserialize(stream); } ~RequestServerProjectileImpact() { } - void Serialize(RakNet::BitStream* stream) { - stream->Write(eGameMessageType::REQUEST_SERVER_PROJECTILE_IMPACT); + void Serialize(RakNet::BitStream& stream) { + stream.Write(eGameMessageType::REQUEST_SERVER_PROJECTILE_IMPACT); - stream->Write(i64LocalID != LWOOBJID_EMPTY); - if (i64LocalID != LWOOBJID_EMPTY) stream->Write(i64LocalID); + stream.Write(i64LocalID != LWOOBJID_EMPTY); + if (i64LocalID != LWOOBJID_EMPTY) stream.Write(i64LocalID); - stream->Write(i64TargetID != LWOOBJID_EMPTY); - if (i64TargetID != LWOOBJID_EMPTY) stream->Write(i64TargetID); + stream.Write(i64TargetID != LWOOBJID_EMPTY); + if (i64TargetID != LWOOBJID_EMPTY) stream.Write(i64TargetID); uint32_t sBitStreamLength = sBitStream.length(); - stream->Write(sBitStreamLength); + stream.Write(sBitStreamLength); for (uint32_t k = 0; k < sBitStreamLength; k++) { - stream->Write(sBitStream[k]); + stream.Write(sBitStream[k]); } } - bool Deserialize(RakNet::BitStream* stream) { + bool Deserialize(RakNet::BitStream& stream) { bool i64LocalIDIsDefault{}; - stream->Read(i64LocalIDIsDefault); - if (i64LocalIDIsDefault != 0) stream->Read(i64LocalID); + stream.Read(i64LocalIDIsDefault); + if (i64LocalIDIsDefault != 0) stream.Read(i64LocalID); bool i64TargetIDIsDefault{}; - stream->Read(i64TargetIDIsDefault); - if (i64TargetIDIsDefault != 0) stream->Read(i64TargetID); + stream.Read(i64TargetIDIsDefault); + if (i64TargetIDIsDefault != 0) stream.Read(i64TargetID); uint32_t sBitStreamLength{}; - stream->Read(sBitStreamLength); + stream.Read(sBitStreamLength); for (uint32_t k = 0; k < sBitStreamLength; k++) { unsigned char character; - stream->Read(character); + stream.Read(character); sBitStream.push_back(character); } diff --git a/dGame/dGameMessages/StartSkill.h b/dGame/dGameMessages/StartSkill.h index 6b0d267a..bc0f18d7 100644 --- a/dGame/dGameMessages/StartSkill.h +++ b/dGame/dGameMessages/StartSkill.h @@ -36,92 +36,92 @@ public: uiSkillHandle = _uiSkillHandle; } - StartSkill(RakNet::BitStream* stream) : StartSkill() { + StartSkill(RakNet::BitStream& stream) : StartSkill() { Deserialize(stream); } ~StartSkill() { } - void Serialize(RakNet::BitStream* stream) { - stream->Write(eGameMessageType::START_SKILL); + void Serialize(RakNet::BitStream& stream) { + stream.Write(eGameMessageType::START_SKILL); - stream->Write(bUsedMouse); + stream.Write(bUsedMouse); - stream->Write(consumableItemID != LWOOBJID_EMPTY); - if (consumableItemID != LWOOBJID_EMPTY) stream->Write(consumableItemID); + stream.Write(consumableItemID != LWOOBJID_EMPTY); + if (consumableItemID != LWOOBJID_EMPTY) stream.Write(consumableItemID); - stream->Write(fCasterLatency != 0.0f); - if (fCasterLatency != 0.0f) stream->Write(fCasterLatency); + stream.Write(fCasterLatency != 0.0f); + if (fCasterLatency != 0.0f) stream.Write(fCasterLatency); - stream->Write(iCastType != 0); - if (iCastType != 0) stream->Write(iCastType); + stream.Write(iCastType != 0); + if (iCastType != 0) stream.Write(iCastType); - stream->Write(lastClickedPosit != NiPoint3Constant::ZERO); - if (lastClickedPosit != NiPoint3Constant::ZERO) stream->Write(lastClickedPosit); + stream.Write(lastClickedPosit != NiPoint3Constant::ZERO); + if (lastClickedPosit != NiPoint3Constant::ZERO) stream.Write(lastClickedPosit); - stream->Write(optionalOriginatorID); + stream.Write(optionalOriginatorID); - stream->Write(optionalTargetID != LWOOBJID_EMPTY); - if (optionalTargetID != LWOOBJID_EMPTY) stream->Write(optionalTargetID); + stream.Write(optionalTargetID != LWOOBJID_EMPTY); + if (optionalTargetID != LWOOBJID_EMPTY) stream.Write(optionalTargetID); - stream->Write(originatorRot != NiQuaternionConstant::IDENTITY); - if (originatorRot != NiQuaternionConstant::IDENTITY) stream->Write(originatorRot); + stream.Write(originatorRot != NiQuaternionConstant::IDENTITY); + if (originatorRot != NiQuaternionConstant::IDENTITY) stream.Write(originatorRot); uint32_t sBitStreamLength = sBitStream.length(); - stream->Write(sBitStreamLength); + stream.Write(sBitStreamLength); for (uint32_t k = 0; k < sBitStreamLength; k++) { - stream->Write(sBitStream[k]); + stream.Write(sBitStream[k]); } - stream->Write(skillID); + stream.Write(skillID); - stream->Write(uiSkillHandle != 0); - if (uiSkillHandle != 0) stream->Write(uiSkillHandle); + stream.Write(uiSkillHandle != 0); + if (uiSkillHandle != 0) stream.Write(uiSkillHandle); } - bool Deserialize(RakNet::BitStream* stream) { - stream->Read(bUsedMouse); + bool Deserialize(RakNet::BitStream& stream) { + stream.Read(bUsedMouse); bool consumableItemIDIsDefault{}; - stream->Read(consumableItemIDIsDefault); - if (consumableItemIDIsDefault != 0) stream->Read(consumableItemID); + stream.Read(consumableItemIDIsDefault); + if (consumableItemIDIsDefault != 0) stream.Read(consumableItemID); bool fCasterLatencyIsDefault{}; - stream->Read(fCasterLatencyIsDefault); - if (fCasterLatencyIsDefault != 0) stream->Read(fCasterLatency); + stream.Read(fCasterLatencyIsDefault); + if (fCasterLatencyIsDefault != 0) stream.Read(fCasterLatency); bool iCastTypeIsDefault{}; - stream->Read(iCastTypeIsDefault); - if (iCastTypeIsDefault != 0) stream->Read(iCastType); + stream.Read(iCastTypeIsDefault); + if (iCastTypeIsDefault != 0) stream.Read(iCastType); bool lastClickedPositIsDefault{}; - stream->Read(lastClickedPositIsDefault); - if (lastClickedPositIsDefault != 0) stream->Read(lastClickedPosit); + stream.Read(lastClickedPositIsDefault); + if (lastClickedPositIsDefault != 0) stream.Read(lastClickedPosit); - stream->Read(optionalOriginatorID); + stream.Read(optionalOriginatorID); bool optionalTargetIDIsDefault{}; - stream->Read(optionalTargetIDIsDefault); - if (optionalTargetIDIsDefault != 0) stream->Read(optionalTargetID); + stream.Read(optionalTargetIDIsDefault); + if (optionalTargetIDIsDefault != 0) stream.Read(optionalTargetID); bool originatorRotIsDefault{}; - stream->Read(originatorRotIsDefault); - if (originatorRotIsDefault != 0) stream->Read(originatorRot); + stream.Read(originatorRotIsDefault); + if (originatorRotIsDefault != 0) stream.Read(originatorRot); uint32_t sBitStreamLength{}; - stream->Read(sBitStreamLength); + stream.Read(sBitStreamLength); for (uint32_t k = 0; k < sBitStreamLength; k++) { unsigned char character; - stream->Read(character); + stream.Read(character); sBitStream.push_back(character); } - stream->Read(skillID); + stream.Read(skillID); bool uiSkillHandleIsDefault{}; - stream->Read(uiSkillHandleIsDefault); - if (uiSkillHandleIsDefault != 0) stream->Read(uiSkillHandle); + stream.Read(uiSkillHandleIsDefault); + if (uiSkillHandleIsDefault != 0) stream.Read(uiSkillHandle); return true; } diff --git a/dGame/dGameMessages/SyncSkill.h b/dGame/dGameMessages/SyncSkill.h index 6485199e..b881d270 100644 --- a/dGame/dGameMessages/SyncSkill.h +++ b/dGame/dGameMessages/SyncSkill.h @@ -21,39 +21,39 @@ public: uiSkillHandle = _uiSkillHandle; } - SyncSkill(RakNet::BitStream* stream) : SyncSkill() { + SyncSkill(RakNet::BitStream& stream) : SyncSkill() { Deserialize(stream); } ~SyncSkill() { } - void Serialize(RakNet::BitStream* stream) { - stream->Write(eGameMessageType::SYNC_SKILL); + void Serialize(RakNet::BitStream& stream) { + stream.Write(eGameMessageType::SYNC_SKILL); - stream->Write(bDone); + stream.Write(bDone); uint32_t sBitStreamLength = sBitStream.length(); - stream->Write(sBitStreamLength); + stream.Write(sBitStreamLength); for (unsigned int k = 0; k < sBitStreamLength; k++) { - stream->Write(sBitStream[k]); + stream.Write(sBitStream[k]); } - stream->Write(uiBehaviorHandle); - stream->Write(uiSkillHandle); + stream.Write(uiBehaviorHandle); + stream.Write(uiSkillHandle); } - bool Deserialize(RakNet::BitStream* stream) { - stream->Read(bDone); + bool Deserialize(RakNet::BitStream& stream) { + stream.Read(bDone); uint32_t sBitStreamLength{}; - stream->Read(sBitStreamLength); + stream.Read(sBitStreamLength); for (uint32_t k = 0; k < sBitStreamLength; k++) { unsigned char character; - stream->Read(character); + stream.Read(character); sBitStream.push_back(character); } - stream->Read(uiBehaviorHandle); - stream->Read(uiSkillHandle); + stream.Read(uiBehaviorHandle); + stream.Read(uiSkillHandle); return true; } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp index 7e42da1c..c2933fbf 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp @@ -13,7 +13,7 @@ AddStripMessage::AddStripMessage(const AMFArrayValue& arguments) const auto* const actions = strip->GetArray("actions"); if (!actions) return; - for (size_t actionNumber = 0; actionNumber < actions->GetDense().size(); actionNumber++) { + for (size_t actionNumber = 0; actionNumber < actions->GetDense().size(); ++actionNumber) { const auto* const actionValue = actions->GetArray(actionNumber); if (!actionValue) continue; diff --git a/dGame/dPropertyBehaviors/ControlBehaviors.cpp b/dGame/dPropertyBehaviors/ControlBehaviors.cpp index 55a8c591..756a615c 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviors.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviors.cpp @@ -95,7 +95,7 @@ void ControlBehaviors::UpdateAction(const AMFArrayValue& arguments) { } } -void ControlBehaviors::ProcessCommand(Entity* modelEntity, const AMFArrayValue& arguments, const std::string_view command, Entity* const modelOwner) { +void ControlBehaviors::ProcessCommand(Entity* const modelEntity, const AMFArrayValue& arguments, const std::string_view command, Entity* const modelOwner) { if (!isInitialized || !modelEntity || !modelOwner) return; auto* const modelComponent = modelEntity->GetComponent(); diff --git a/dGame/dPropertyBehaviors/ControlBehaviors.h b/dGame/dPropertyBehaviors/ControlBehaviors.h index ec5e78fe..fdb86746 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviors.h +++ b/dGame/dPropertyBehaviors/ControlBehaviors.h @@ -43,7 +43,7 @@ public: * @param command The command to perform * @param modelOwner The owner of the model which sent this command */ - void ProcessCommand(Entity* modelEntity, const AMFArrayValue& arguments, std::string_view command, Entity* modelOwner); + void ProcessCommand(Entity* const modelEntity, const AMFArrayValue& arguments, const std::string_view command, Entity* const modelOwner); /** * @brief Gets a blocks parameter values by the name diff --git a/dGame/dUtilities/GUID.cpp b/dGame/dUtilities/GUID.cpp index 50ac8b03..ac4042a0 100644 --- a/dGame/dUtilities/GUID.cpp +++ b/dGame/dUtilities/GUID.cpp @@ -13,12 +13,12 @@ GUID::GUID(const std::string& guid) { &this->data4[4], &this->data4[5], &this->data4[6], &this->data4[7]); } -void GUID::Serialize(RakNet::BitStream* outBitStream) { - outBitStream->Write(GetData1()); - outBitStream->Write(GetData2()); - outBitStream->Write(GetData3()); +void GUID::Serialize(RakNet::BitStream& outBitStream) { + outBitStream.Write(GetData1()); + outBitStream.Write(GetData2()); + outBitStream.Write(GetData3()); for (const auto& guidSubPart : GetData4()) { - outBitStream->Write(guidSubPart); + outBitStream.Write(guidSubPart); } } diff --git a/dGame/dUtilities/GUID.h b/dGame/dUtilities/GUID.h index 38e57a6a..ce6d40c1 100644 --- a/dGame/dUtilities/GUID.h +++ b/dGame/dUtilities/GUID.h @@ -7,7 +7,7 @@ class GUID { public: explicit GUID(); explicit GUID(const std::string& guid); - void Serialize(RakNet::BitStream* outBitStream); + void Serialize(RakNet::BitStream& outBitStream); uint32_t GetData1() const { return data1; diff --git a/dGame/dUtilities/Mail.cpp b/dGame/dUtilities/Mail.cpp index fc0c833e..a610c3a7 100644 --- a/dGame/dUtilities/Mail.cpp +++ b/dGame/dUtilities/Mail.cpp @@ -95,39 +95,39 @@ void Mail::SendMail(const LWOOBJID sender, const std::string& senderName, LWOOBJ } //Because we need it: -std::string ReadWStringAsString(RakNet::BitStream* bitStream, uint32_t size) { +std::string ReadWStringAsString(RakNet::BitStream& bitStream, uint32_t size) { std::string toReturn = ""; uint8_t buffer; bool isFinishedReading = false; for (uint32_t i = 0; i < size; ++i) { - bitStream->Read(buffer); + bitStream.Read(buffer); if (!isFinishedReading) toReturn.push_back(buffer); if (buffer == '\0') isFinishedReading = true; //so we don't continue to read garbage as part of the string. - bitStream->Read(buffer); //Read the null term + bitStream.Read(buffer); //Read the null term } return toReturn; } -void WriteStringAsWString(RakNet::BitStream* bitStream, std::string str, uint32_t size) { +void WriteStringAsWString(RakNet::BitStream& bitStream, std::string str, uint32_t size) { uint32_t sizeToFill = size - str.size(); for (uint32_t i = 0; i < str.size(); ++i) { - bitStream->Write(str[i]); - bitStream->Write(uint8_t(0)); + bitStream.Write(str[i]); + bitStream.Write(uint8_t(0)); } for (uint32_t i = 0; i < sizeToFill; ++i) { - bitStream->Write(uint16_t(0)); + bitStream.Write(uint16_t(0)); } } -void Mail::HandleMailStuff(RakNet::BitStream* packet, const SystemAddress& sysAddr, Entity* entity) { +void Mail::HandleMailStuff(RakNet::BitStream& packet, const SystemAddress& sysAddr, Entity* entity) { int mailStuffID = 0; - packet->Read(mailStuffID); + packet.Read(mailStuffID); - auto returnVal = std::async(std::launch::async, [packet, &sysAddr, entity, mailStuffID]() { + auto returnVal = std::async(std::launch::async, [&packet, &sysAddr, entity, mailStuffID]() { Mail::MailMessageID stuffID = MailMessageID(mailStuffID); switch (stuffID) { case MailMessageID::AttachmentCollect: @@ -154,7 +154,7 @@ void Mail::HandleMailStuff(RakNet::BitStream* packet, const SystemAddress& sysAd }); } -void Mail::HandleSendMail(RakNet::BitStream* packet, const SystemAddress& sysAddr, Entity* entity) { +void Mail::HandleSendMail(RakNet::BitStream& packet, const SystemAddress& sysAddr, Entity* entity) { //std::string subject = GeneralUtils::WStringToString(ReadFromPacket(packet, 50)); //std::string body = GeneralUtils::WStringToString(ReadFromPacket(packet, 400)); //std::string recipient = GeneralUtils::WStringToString(ReadFromPacket(packet, 32)); @@ -186,9 +186,9 @@ void Mail::HandleSendMail(RakNet::BitStream* packet, const SystemAddress& sysAdd LWOOBJID attachmentID; uint16_t attachmentCount; - packet->Read(unknown64); - packet->Read(attachmentID); - packet->Read(attachmentCount); //We don't care about the rest of the packet. + packet.Read(unknown64); + packet.Read(attachmentID); + packet.Read(attachmentCount); //We don't care about the rest of the packet. uint32_t itemID = static_cast(attachmentID); LOT itemLOT = 0; //Inventory::InventoryType itemType; @@ -261,7 +261,7 @@ void Mail::HandleSendMail(RakNet::BitStream* packet, const SystemAddress& sysAdd character->SaveXMLToDatabase(); } -void Mail::HandleDataRequest(RakNet::BitStream* packet, const SystemAddress& sysAddr, Entity* player) { +void Mail::HandleDataRequest(RakNet::BitStream& packet, const SystemAddress& sysAddr, Entity* player) { auto playerMail = Database::Get()->GetMailForPlayer(player->GetCharacter()->GetID(), 20); RakNet::BitStream bitStream; @@ -275,9 +275,9 @@ void Mail::HandleDataRequest(RakNet::BitStream* packet, const SystemAddress& sys for (const auto& mail : playerMail) { bitStream.Write(mail.id); //MailID - WriteStringAsWString(&bitStream, mail.subject.c_str(), 50); //subject - WriteStringAsWString(&bitStream, mail.body.c_str(), 400); //body - WriteStringAsWString(&bitStream, mail.senderUsername.c_str(), 32); //sender + WriteStringAsWString(bitStream, mail.subject.c_str(), 50); //subject + WriteStringAsWString(bitStream, mail.body.c_str(), 400); //body + WriteStringAsWString(bitStream, mail.senderUsername.c_str(), 32); //sender bitStream.Write(uint32_t(0)); bitStream.Write(uint64_t(0)); @@ -303,16 +303,16 @@ void Mail::HandleDataRequest(RakNet::BitStream* packet, const SystemAddress& sys bitStream.Write(uint32_t(0)); } - Game::server->Send(&bitStream, sysAddr, false); + Game::server->Send(bitStream, sysAddr, false); } -void Mail::HandleAttachmentCollect(RakNet::BitStream* packet, const SystemAddress& sysAddr, Entity* player) { +void Mail::HandleAttachmentCollect(RakNet::BitStream& packet, const SystemAddress& sysAddr, Entity* player) { int unknown; uint64_t mailID; LWOOBJID playerID; - packet->Read(unknown); - packet->Read(mailID); - packet->Read(playerID); + packet.Read(unknown); + packet.Read(mailID); + packet.Read(playerID); if (mailID > 0 && playerID == player->GetObjectID()) { auto playerMail = Database::Get()->GetMail(mailID); @@ -336,22 +336,22 @@ void Mail::HandleAttachmentCollect(RakNet::BitStream* packet, const SystemAddres } } -void Mail::HandleMailDelete(RakNet::BitStream* packet, const SystemAddress& sysAddr) { +void Mail::HandleMailDelete(RakNet::BitStream& packet, const SystemAddress& sysAddr) { int unknown; uint64_t mailID; LWOOBJID playerID; - packet->Read(unknown); - packet->Read(mailID); - packet->Read(playerID); + packet.Read(unknown); + packet.Read(mailID); + packet.Read(playerID); if (mailID > 0) Mail::SendDeleteConfirm(sysAddr, mailID, playerID); } -void Mail::HandleMailRead(RakNet::BitStream* packet, const SystemAddress& sysAddr) { +void Mail::HandleMailRead(RakNet::BitStream& packet, const SystemAddress& sysAddr) { int unknown; uint64_t mailID; - packet->Read(unknown); - packet->Read(mailID); + packet.Read(unknown); + packet.Read(mailID); if (mailID > 0) Mail::SendReadConfirm(sysAddr, mailID); } @@ -367,7 +367,7 @@ void Mail::SendSendResponse(const SystemAddress& sysAddr, MailSendResponse respo BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::MAIL); bitStream.Write(int(MailMessageID::SendResponse)); bitStream.Write(int(response)); - Game::server->Send(&bitStream, sysAddr, false); + Game::server->Send(bitStream, sysAddr, false); } void Mail::SendNotification(const SystemAddress& sysAddr, int mailCount) { @@ -386,7 +386,7 @@ void Mail::SendNotification(const SystemAddress& sysAddr, int mailCount) { bitStream.Write(s4); bitStream.Write(mailCount); bitStream.Write(int(0)); //Unknown - Game::server->Send(&bitStream, sysAddr, false); + Game::server->Send(bitStream, sysAddr, false); } void Mail::SendAttachmentRemoveConfirm(const SystemAddress& sysAddr, uint64_t mailID) { @@ -395,7 +395,7 @@ void Mail::SendAttachmentRemoveConfirm(const SystemAddress& sysAddr, uint64_t ma bitStream.Write(int(MailMessageID::AttachmentCollectConfirm)); bitStream.Write(int(0)); //unknown bitStream.Write(mailID); - Game::server->Send(&bitStream, sysAddr, false); + Game::server->Send(bitStream, sysAddr, false); } void Mail::SendDeleteConfirm(const SystemAddress& sysAddr, uint64_t mailID, LWOOBJID playerID) { @@ -404,7 +404,7 @@ void Mail::SendDeleteConfirm(const SystemAddress& sysAddr, uint64_t mailID, LWOO bitStream.Write(int(MailMessageID::MailDeleteConfirm)); bitStream.Write(int(0)); //unknown bitStream.Write(mailID); - Game::server->Send(&bitStream, sysAddr, false); + Game::server->Send(bitStream, sysAddr, false); Database::Get()->DeleteMail(mailID); } @@ -415,7 +415,7 @@ void Mail::SendReadConfirm(const SystemAddress& sysAddr, uint64_t mailID) { bitStream.Write(int(MailMessageID::MailReadConfirm)); bitStream.Write(int(0)); //unknown bitStream.Write(mailID); - Game::server->Send(&bitStream, sysAddr, false); + Game::server->Send(bitStream, sysAddr, false); Database::Get()->MarkMailRead(mailID); } diff --git a/dGame/dUtilities/Mail.h b/dGame/dUtilities/Mail.h index c8eabe6b..07c3e37f 100644 --- a/dGame/dUtilities/Mail.h +++ b/dGame/dUtilities/Mail.h @@ -79,12 +79,12 @@ namespace Mail { const SystemAddress& sysAddr ); - void HandleMailStuff(RakNet::BitStream* packet, const SystemAddress& sysAddr, Entity* entity); - void HandleSendMail(RakNet::BitStream* packet, const SystemAddress& sysAddr, Entity* entity); - void HandleDataRequest(RakNet::BitStream* packet, const SystemAddress& sysAddr, Entity* player); - void HandleAttachmentCollect(RakNet::BitStream* packet, const SystemAddress& sysAddr, Entity* player); - void HandleMailDelete(RakNet::BitStream* packet, const SystemAddress& sysAddr); - void HandleMailRead(RakNet::BitStream* packet, const SystemAddress& sysAddr); + void HandleMailStuff(RakNet::BitStream& packet, const SystemAddress& sysAddr, Entity* entity); + void HandleSendMail(RakNet::BitStream& packet, const SystemAddress& sysAddr, Entity* entity); + void HandleDataRequest(RakNet::BitStream& packet, const SystemAddress& sysAddr, Entity* player); + void HandleAttachmentCollect(RakNet::BitStream& packet, const SystemAddress& sysAddr, Entity* player); + void HandleMailDelete(RakNet::BitStream& packet, const SystemAddress& sysAddr); + void HandleMailRead(RakNet::BitStream& packet, const SystemAddress& sysAddr); void HandleNotificationRequest(const SystemAddress& sysAddr, uint32_t objectID); void SendSendResponse(const SystemAddress& sysAddr, MailSendResponse response); diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index cd938bab..d0620121 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -757,7 +757,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit //Tell the master server that we're going to be shutting down whole "universe": CBITSTREAM; BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SHUTDOWN_UNIVERSE); - Game::server->SendToMaster(&bitStream); + Game::server->SendToMaster(bitStream); ChatPackets::SendSystemMessage(sysAddr, u"Sent universe shutdown notification to master."); //Tell chat to send an announcement to all servers diff --git a/dGame/dUtilities/VanityUtilities.cpp b/dGame/dUtilities/VanityUtilities.cpp index fa1a3eac..3e93f830 100644 --- a/dGame/dUtilities/VanityUtilities.cpp +++ b/dGame/dUtilities/VanityUtilities.cpp @@ -22,143 +22,13 @@ #include -std::vector VanityUtilities::m_NPCs = {}; -std::vector VanityUtilities::m_Parties = {}; -std::vector VanityUtilities::m_PartyPhrases = {}; +std::vector VanityUtilities::m_Objects = {}; +std::set VanityUtilities::m_LoadedFiles = {}; + void VanityUtilities::SpawnVanity() { - if (Game::config->GetValue("disable_vanity") == "1") { - return; - } - const uint32_t zoneID = Game::server->GetZoneID(); - for (const auto& npc : m_NPCs) { - if (npc.m_ID == LWOOBJID_EMPTY) continue; - if (npc.m_LOT == 176){ - Game::zoneManager->RemoveSpawner(npc.m_ID); - } else{ - auto* entity = Game::entityManager->GetEntity(npc.m_ID); - if (!entity) continue; - entity->Smash(LWOOBJID_EMPTY, eKillType::VIOLENT); - } - } - - m_NPCs.clear(); - m_Parties.clear(); - m_PartyPhrases.clear(); - - ParseXML((BinaryPathFinder::GetBinaryDir() / "vanity/NPC.xml").string()); - - // Loop through all parties - for (const auto& party : m_Parties) { - const auto chance = party.m_Chance; - const auto zone = party.m_Zone; - - if (zone != Game::server->GetZoneID()) { - continue; - } - - float rate = GeneralUtils::GenerateRandomNumber(0, 1); - if (chance < rate) { - continue; - } - - // Copy m_NPCs into a new vector - std::vector npcList = m_NPCs; - std::vector taken = {}; - - LOG("Spawning party with %i locations", party.m_Locations.size()); - - // Loop through all locations - for (const auto& location : party.m_Locations) { - rate = GeneralUtils::GenerateRandomNumber(0, 1); - if (0.75f < rate) { - continue; - } - - // Get a random NPC - auto npcIndex = GeneralUtils::GenerateRandomNumber(0, npcList.size() - 1); - - while (std::find(taken.begin(), taken.end(), npcIndex) != taken.end()) { - npcIndex = GeneralUtils::GenerateRandomNumber(0, npcList.size() - 1); - } - - auto& npc = npcList[npcIndex]; - // Skip spawners - if (npc.m_LOT == 176) continue; - - taken.push_back(npcIndex); - - LOG("ldf size is %i", npc.ldf.size()); - if (npc.ldf.empty()) { - npc.ldf = { - new LDFData>(u"syncLDF", { u"custom_script_client" }), - new LDFData(u"custom_script_client", u"scripts\\ai\\SPEC\\MISSION_MINIGAME_CLIENT.lua") - }; - } - - // Spawn the NPC - if (npc.m_LOT == 176){ - npc.m_ID = SpawnSpawner(npc.m_LOT, location.m_Position, location.m_Rotation, npc.ldf); - } else { - auto* npcEntity = SpawnNPC(npc.m_LOT, npc.m_Name, location.m_Position, location.m_Rotation, npc.m_Equipment, npc.ldf); - if (!npc.m_Phrases.empty()) { - npcEntity->SetVar>(u"chats", m_PartyPhrases); - SetupNPCTalk(npcEntity); - } - } - } - return; - } - - // Loop through all NPCs - for (auto& npc : m_NPCs) { - if (npc.m_Locations.find(Game::server->GetZoneID()) == npc.m_Locations.end()) - continue; - - const std::vector& locations = npc.m_Locations.at(Game::server->GetZoneID()); - - // Pick a random location - const auto& location = locations[GeneralUtils::GenerateRandomNumber( - static_cast(0), static_cast(locations.size() - 1))]; - - float rate = GeneralUtils::GenerateRandomNumber(0, 1); - if (location.m_Chance < rate) { - continue; - } - - if (npc.ldf.empty()) { - npc.ldf = { - new LDFData>(u"syncLDF", { u"custom_script_client" }), - new LDFData(u"custom_script_client", u"scripts\\ai\\SPEC\\MISSION_MINIGAME_CLIENT.lua") - }; - } - if (npc.m_LOT == 176){ - npc.m_ID = SpawnSpawner(npc.m_LOT, location.m_Position, location.m_Rotation, npc.ldf); - } else { - // Spawn the NPC - auto* npcEntity = SpawnNPC(npc.m_LOT, npc.m_Name, location.m_Position, location.m_Rotation, npc.m_Equipment, npc.ldf); - if (!npcEntity) continue; - npc.m_ID = npcEntity->GetObjectID(); - if (!npc.m_Phrases.empty()){ - npcEntity->SetVar>(u"chats", npc.m_Phrases); - - auto* scriptComponent = npcEntity->GetComponent(); - - if (scriptComponent && !npc.m_Script.empty()) { - scriptComponent->SetScript(npc.m_Script); - scriptComponent->SetSerialized(false); - - for (const auto& npc : npc.m_Flags) { - npcEntity->SetVar(GeneralUtils::ASCIIToUTF16(npc.first), npc.second); - } - } - SetupNPCTalk(npcEntity); - } - } - } - if (zoneID == 1200) { { EntityInfo info; @@ -175,38 +45,99 @@ void VanityUtilities::SpawnVanity() { Game::entityManager->ConstructEntity(entity); } } + + if (Game::config->GetValue("disable_vanity") == "1") { + return; + } + + for (const auto& npc : m_Objects) { + if (npc.m_ID == LWOOBJID_EMPTY) continue; + if (npc.m_LOT == 176){ + Game::zoneManager->RemoveSpawner(npc.m_ID); + } else{ + auto* entity = Game::entityManager->GetEntity(npc.m_ID); + if (!entity) continue; + entity->Smash(LWOOBJID_EMPTY, eKillType::VIOLENT); + } + } + + m_Objects.clear(); + m_LoadedFiles.clear(); + + ParseXML((BinaryPathFinder::GetBinaryDir() / "vanity/root.xml").string()); + + // Loop through all objects + for (auto& object : m_Objects) { + if (object.m_Locations.find(Game::server->GetZoneID()) == object.m_Locations.end()) continue; + + const std::vector& locations = object.m_Locations.at(Game::server->GetZoneID()); + + // Pick a random location + const auto& location = locations[GeneralUtils::GenerateRandomNumber( + static_cast(0), static_cast(locations.size() - 1))]; + + float rate = GeneralUtils::GenerateRandomNumber(0, 1); + if (location.m_Chance < rate) continue; + + if (object.m_Config.empty()) { + object.m_Config = { + new LDFData>(u"syncLDF", { u"custom_script_client" }), + new LDFData(u"custom_script_client", u"scripts\\ai\\SPEC\\MISSION_MINIGAME_CLIENT.lua") + }; + } + if (object.m_LOT == 176){ + object.m_ID = SpawnSpawner(object, location); + } else { + // Spawn the NPC + auto* objectEntity = SpawnObject(object, location); + if (!objectEntity) continue; + object.m_ID = objectEntity->GetObjectID(); + if (!object.m_Phrases.empty()){ + objectEntity->SetVar>(u"chats", object.m_Phrases); + + auto* scriptComponent = objectEntity->GetComponent(); + + if (scriptComponent && !object.m_Script.empty()) { + scriptComponent->SetScript(object.m_Script); + scriptComponent->SetSerialized(false); + } + SetupNPCTalk(objectEntity); + } + } + } } -LWOOBJID VanityUtilities::SpawnSpawner(LOT lot, const NiPoint3& position, const NiQuaternion& rotation, const std::vector& ldf){ +LWOOBJID VanityUtilities::SpawnSpawner(const VanityObject& object, const VanityObjectLocation& location) { SceneObject obj; - obj.lot = lot; + obj.lot = object.m_LOT; // guratantee we have no collisions do { obj.id = ObjectIDManager::GenerateObjectID(); } while(Game::zoneManager->GetSpawner(obj.id)); - obj.position = position; - obj.rotation = rotation; - obj.settings = ldf; + obj.position = location.m_Position; + obj.rotation = location.m_Rotation; + obj.settings = object.m_Config; Level::MakeSpawner(obj); return obj.id; } -Entity* VanityUtilities::SpawnNPC(LOT lot, const std::string& name, const NiPoint3& position, const NiQuaternion& rotation, const std::vector& inventory, const std::vector& ldf) { +Entity* VanityUtilities::SpawnObject(const VanityObject& object, const VanityObjectLocation& location) { EntityInfo info; - info.lot = lot; - info.pos = position; - info.rot = rotation; + info.lot = object.m_LOT; + info.pos = location.m_Position; + info.rot = location.m_Rotation; + info.scale = location.m_Scale; info.spawnerID = Game::entityManager->GetZoneControlEntity()->GetObjectID(); - info.settings = ldf; + info.settings = object.m_Config; auto* entity = Game::entityManager->CreateEntity(info); - entity->SetVar(u"npcName", name); + entity->SetVar(u"npcName", object.m_Name); if (entity->GetVar(u"noGhosting")) entity->SetIsGhostingCandidate(false); auto* inventoryComponent = entity->GetComponent(); - if (inventoryComponent && !inventory.empty()) { - inventoryComponent->SetNPCItems(inventory); + if (inventoryComponent && !object.m_Equipment.empty()) { + inventoryComponent->SetNPCItems(object.m_Equipment); } auto* destroyableComponent = entity->GetComponent(); @@ -223,6 +154,11 @@ Entity* VanityUtilities::SpawnNPC(LOT lot, const std::string& name, const NiPoin } void VanityUtilities::ParseXML(const std::string& file) { + if (m_LoadedFiles.contains(file)){ + LOG("Trying to load vanity file %s twice!!!", file.c_str()); + return; + } + m_LoadedFiles.insert(file); // Read the entire file std::ifstream xmlFile(file); std::string xml((std::istreambuf_iterator(xmlFile)), std::istreambuf_iterator()); @@ -231,210 +167,112 @@ void VanityUtilities::ParseXML(const std::string& file) { tinyxml2::XMLDocument doc; doc.Parse(xml.c_str(), xml.size()); - // Read the NPCs - auto* npcs = doc.FirstChildElement("npcs"); - - if (npcs == nullptr) { - LOG("Failed to parse NPCs"); - return; - } - - for (auto* party = npcs->FirstChildElement("party"); party != nullptr; party = party->NextSiblingElement("party")) { - // Get 'zone' as uint32_t and 'chance' as float - uint32_t zone = 0; - float chance = 0.0f; - - if (party->Attribute("zone") != nullptr) { - zone = std::stoul(party->Attribute("zone")); - } - - if (party->Attribute("chance") != nullptr) { - chance = std::stof(party->Attribute("chance")); - } - - VanityParty partyInfo; - partyInfo.m_Zone = zone; - partyInfo.m_Chance = chance; - - auto* locations = party->FirstChildElement("locations"); - - if (locations == nullptr) { - LOG("Failed to parse party locations"); - continue; - } - - for (auto* location = locations->FirstChildElement("location"); location != nullptr; - location = location->NextSiblingElement("location")) { - // Get the location data - auto* x = location->Attribute("x"); - auto* y = location->Attribute("y"); - auto* z = location->Attribute("z"); - auto* rw = location->Attribute("rw"); - auto* rx = location->Attribute("rx"); - auto* ry = location->Attribute("ry"); - auto* rz = location->Attribute("rz"); - - if (x == nullptr || y == nullptr || z == nullptr || rw == nullptr || rx == nullptr || ry == nullptr - || rz == nullptr) { - LOG("Failed to parse party location data"); + // Read the objects + auto* files = doc.FirstChildElement("files"); + if (files) { + for (auto* file = files->FirstChildElement("file"); file != nullptr; file = file->NextSiblingElement("file")) { + std::string enabled = file->Attribute("enabled"); + std::string filename = file->Attribute("name"); + if (enabled != "1") { continue; } - - VanityNPCLocation locationData; - locationData.m_Position = { std::stof(x), std::stof(y), std::stof(z) }; - locationData.m_Rotation = { std::stof(rw), std::stof(rx), std::stof(ry), std::stof(rz) }; - locationData.m_Chance = 1.0f; - - partyInfo.m_Locations.push_back(locationData); - } - - m_Parties.push_back(partyInfo); - } - - auto* partyPhrases = npcs->FirstChildElement("partyphrases"); - - if (partyPhrases == nullptr) { - LOG("No party phrases found"); - } else { - for (auto* phrase = partyPhrases->FirstChildElement("phrase"); phrase != nullptr; - phrase = phrase->NextSiblingElement("phrase")) { - // Get the phrase - auto* text = phrase->GetText(); - - if (text == nullptr) { - LOG("Failed to parse party phrase"); - continue; - } - - m_PartyPhrases.push_back(text); + ParseXML((BinaryPathFinder::GetBinaryDir() / "vanity" / filename).string()); } } - for (auto* npc = npcs->FirstChildElement("npc"); npc != nullptr; npc = npc->NextSiblingElement("npc")) { - // Get the NPC name - auto* name = npc->Attribute("name"); + // Read the objects + auto* objects = doc.FirstChildElement("objects"); - if (!name) name = ""; + if (objects) { + for (auto* object = objects->FirstChildElement("object"); object != nullptr; object = object->NextSiblingElement("object")) { + // Get the NPC name + auto* name = object->Attribute("name"); - // Get the NPC lot - auto* lot = npc->Attribute("lot"); + if (!name) name = ""; - if (lot == nullptr) { - LOG("Failed to parse NPC lot"); - continue; - } + // Get the NPC lot + auto* lot = object->Attribute("lot"); - // Get the equipment - auto* equipment = npc->FirstChildElement("equipment"); - std::vector inventory; - - if (equipment) { - auto* text = equipment->GetText(); - - if (text != nullptr) { - std::string equipmentString(text); - - std::vector splitEquipment = GeneralUtils::SplitString(equipmentString, ','); - - for (auto& item : splitEquipment) { - inventory.push_back(std::stoi(item)); - } - } - } - - - // Get the phrases - auto* phrases = npc->FirstChildElement("phrases"); - - std::vector phraseList = {}; - - if (phrases) { - for (auto* phrase = phrases->FirstChildElement("phrase"); phrase != nullptr; - phrase = phrase->NextSiblingElement("phrase")) { - // Get the phrase - auto* text = phrase->GetText(); - if (text == nullptr) { - LOG("Failed to parse NPC phrase"); - continue; - } - phraseList.push_back(text); - } - } - - // Get the script - auto* scriptElement = npc->FirstChildElement("script"); - - std::string scriptName = ""; - - if (scriptElement != nullptr) { - auto* scriptNameAttribute = scriptElement->Attribute("name"); - if (scriptNameAttribute) scriptName = scriptNameAttribute; - } - - auto* ldfElement = npc->FirstChildElement("ldf"); - std::vector keys = {}; - - std::vector ldf = {}; - if(ldfElement) { - for (auto* entry = ldfElement->FirstChildElement("entry"); entry != nullptr; - entry = entry->NextSiblingElement("entry")) { - // Get the ldf data - auto* data = entry->Attribute("data"); - if (!data) continue; - - LDFBaseData* ldfData = LDFBaseData::DataFromString(data); - keys.push_back(ldfData->GetKey()); - ldf.push_back(ldfData); - } - } - if (!keys.empty()) ldf.push_back(new LDFData>(u"syncLDF", keys)); - - VanityNPC npcData; - npcData.m_Name = name; - npcData.m_LOT = std::stoi(lot); - npcData.m_Equipment = inventory; - npcData.m_Phrases = phraseList; - npcData.m_Script = scriptName; - npcData.ldf = ldf; - - // Get flags - auto* flags = npc->FirstChildElement("flags"); - - if (flags != nullptr) { - for (auto* flag = flags->FirstChildElement("flag"); flag != nullptr; - flag = flag->NextSiblingElement("flag")) { - // Get the flag name - auto* name = flag->Attribute("name"); - - if (name == nullptr) { - LOG("Failed to parse NPC flag name"); - continue; - } - - // Get the flag value - auto* value = flag->Attribute("value"); - - if (value == nullptr) { - LOG("Failed to parse NPC flag value"); - continue; - } - - npcData.m_Flags[name] = std::stoi(value); - } - } - - // Get the zones - for (auto* zone = npc->FirstChildElement("zone"); zone != nullptr; zone = zone->NextSiblingElement("zone")) { - // Get the zone ID - auto* zoneID = zone->Attribute("id"); - - if (zoneID == nullptr) { - LOG("Failed to parse NPC zone ID"); + if (lot == nullptr) { + LOG("Failed to parse object lot"); continue; } + // Get the equipment + auto* equipment = object->FirstChildElement("equipment"); + std::vector inventory; + + if (equipment) { + auto* text = equipment->GetText(); + + if (text != nullptr) { + std::string equipmentString(text); + + std::vector splitEquipment = GeneralUtils::SplitString(equipmentString, ','); + + for (auto& item : splitEquipment) { + inventory.push_back(std::stoi(item)); + } + } + } + + + // Get the phrases + auto* phrases = object->FirstChildElement("phrases"); + + std::vector phraseList = {}; + + if (phrases) { + for (auto* phrase = phrases->FirstChildElement("phrase"); phrase != nullptr; + phrase = phrase->NextSiblingElement("phrase")) { + // Get the phrase + auto* text = phrase->GetText(); + if (text == nullptr) { + LOG("Failed to parse NPC phrase"); + continue; + } + phraseList.push_back(text); + } + } + + // Get the script + auto* scriptElement = object->FirstChildElement("script"); + + std::string scriptName = ""; + + if (scriptElement != nullptr) { + auto* scriptNameAttribute = scriptElement->Attribute("name"); + if (scriptNameAttribute) scriptName = scriptNameAttribute; + } + + auto* configElement = object->FirstChildElement("config"); + std::vector keys = {}; + + std::vector config = {}; + if(configElement) { + for (auto* key = configElement->FirstChildElement("key"); key != nullptr; + key = key->NextSiblingElement("key")) { + // Get the config data + auto* data = key->Attribute("data"); + if (!data) continue; + + LDFBaseData* configData = LDFBaseData::DataFromString(data); + keys.push_back(configData->GetKey()); + config.push_back(configData); + } + } + if (!keys.empty()) config.push_back(new LDFData>(u"syncLDF", keys)); + + VanityObject objectData; + objectData.m_Name = name; + objectData.m_LOT = std::stoi(lot); + objectData.m_Equipment = inventory; + objectData.m_Phrases = phraseList; + objectData.m_Script = scriptName; + objectData.m_Config = config; + // Get the locations - auto* locations = zone->FirstChildElement("locations"); + auto* locations = object->FirstChildElement("locations"); if (locations == nullptr) { LOG("Failed to parse NPC locations"); @@ -443,7 +281,9 @@ void VanityUtilities::ParseXML(const std::string& file) { for (auto* location = locations->FirstChildElement("location"); location != nullptr; location = location->NextSiblingElement("location")) { + // Get the location data + auto* zoneID = location->Attribute("zone"); auto* x = location->Attribute("x"); auto* y = location->Attribute("y"); auto* z = location->Attribute("z"); @@ -452,41 +292,52 @@ void VanityUtilities::ParseXML(const std::string& file) { auto* ry = location->Attribute("ry"); auto* rz = location->Attribute("rz"); - if (x == nullptr || y == nullptr || z == nullptr || rw == nullptr || rx == nullptr || ry == nullptr + if (zoneID == nullptr || x == nullptr || y == nullptr || z == nullptr || rw == nullptr || rx == nullptr || ry == nullptr || rz == nullptr) { LOG("Failed to parse NPC location data"); continue; } - VanityNPCLocation locationData; + VanityObjectLocation locationData; locationData.m_Position = { std::stof(x), std::stof(y), std::stof(z) }; locationData.m_Rotation = { std::stof(rw), std::stof(rx), std::stof(ry), std::stof(rz) }; locationData.m_Chance = 1.0f; - if (location->Attribute("chance") != nullptr) { + if (location->Attribute("chance")) { locationData.m_Chance = std::stof(location->Attribute("chance")); } - const auto& it = npcData.m_Locations.find(std::stoi(zoneID)); + if (location->Attribute("scale")) { + locationData.m_Scale = std::stof(location->Attribute("scale")); + } - if (it != npcData.m_Locations.end()) { + + const auto& it = objectData.m_Locations.find(std::stoi(zoneID)); + + if (it != objectData.m_Locations.end()) { it->second.push_back(locationData); } else { - std::vector locations; + std::vector locations; locations.push_back(locationData); - npcData.m_Locations.insert(std::make_pair(std::stoi(zoneID), locations)); + objectData.m_Locations.insert(std::make_pair(std::stoi(zoneID), locations)); + } + + if (!(std::find(keys.begin(), keys.end(), u"teleport") != keys.end())) { + m_Objects.push_back(objectData); + objectData.m_Locations.clear(); } } + if (std::find(keys.begin(), keys.end(), u"teleport") != keys.end()) { + m_Objects.push_back(objectData); + } } - - m_NPCs.push_back(npcData); } } -VanityNPC* VanityUtilities::GetNPC(const std::string& name) { - for (size_t i = 0; i < m_NPCs.size(); i++) { - if (m_NPCs[i].m_Name == name) { - return &m_NPCs[i]; +VanityObject* VanityUtilities::GetObject(const std::string& name) { + for (size_t i = 0; i < m_Objects.size(); i++) { + if (m_Objects[i].m_Name == name) { + return &m_Objects[i]; } } @@ -498,10 +349,13 @@ std::string VanityUtilities::ParseMarkdown(const std::string& file) { // Read the file into a string std::ifstream t(file); - + std::stringstream output; // If the file does not exist, return an empty string. if (!t.good()) { - return ""; + output << "File "; + output << file.substr(file.rfind("/") + 1); + output << " not found!\nContact your DarkflameServer admin\nor find the server source at https://github.com/DarkflameUniverse/DarkflameServer"; + return output.str(); } std::stringstream buffer; @@ -511,7 +365,6 @@ std::string VanityUtilities::ParseMarkdown(const std::string& file) { // Loop through all lines in the file. // Replace all instances of the markdown syntax with the corresponding HTML. // Only care about headers - std::stringstream output; std::string line; std::stringstream ss; ss << fileContents; diff --git a/dGame/dUtilities/VanityUtilities.h b/dGame/dUtilities/VanityUtilities.h index cff73bce..49bd23ab 100644 --- a/dGame/dUtilities/VanityUtilities.h +++ b/dGame/dUtilities/VanityUtilities.h @@ -3,15 +3,17 @@ #include "dCommonVars.h" #include "Entity.h" #include +#include -struct VanityNPCLocation +struct VanityObjectLocation { float m_Chance = 1.0f; NiPoint3 m_Position; NiQuaternion m_Rotation; + float m_Scale = 1.0f; }; -struct VanityNPC +struct VanityObject { LWOOBJID m_ID = LWOOBJID_EMPTY; std::string m_Name; @@ -19,37 +21,24 @@ struct VanityNPC std::vector m_Equipment; std::vector m_Phrases; std::string m_Script; - std::map m_Flags; - std::map> m_Locations; - std::vector ldf; + std::map> m_Locations; + std::vector m_Config; }; -struct VanityParty -{ - uint32_t m_Zone; - float m_Chance = 1.0f; - std::vector m_Locations; -}; class VanityUtilities { public: static void SpawnVanity(); - static Entity* SpawnNPC( - LOT lot, - const std::string& name, - const NiPoint3& position, - const NiQuaternion& rotation, - const std::vector& inventory, - const std::vector& ldf + static Entity* SpawnObject( + const VanityObject& object, + const VanityObjectLocation& location ); static LWOOBJID SpawnSpawner( - LOT lot, - const NiPoint3& position, - const NiQuaternion& rotation, - const std::vector& ldf + const VanityObject& object, + const VanityObjectLocation& location ); static std::string ParseMarkdown( @@ -60,16 +49,14 @@ public: const std::string& file ); - static VanityNPC* GetNPC(const std::string& name); + static VanityObject* GetObject(const std::string& name); private: static void SetupNPCTalk(Entity* npc); static void NPCTalk(Entity* npc); - static std::vector m_NPCs; - - static std::vector m_Parties; - - static std::vector m_PartyPhrases; + static std::vector m_Objects; + + static std::set m_LoadedFiles; }; diff --git a/dMasterServer/InstanceManager.cpp b/dMasterServer/InstanceManager.cpp index 9ae9930c..3ec42634 100644 --- a/dMasterServer/InstanceManager.cpp +++ b/dMasterServer/InstanceManager.cpp @@ -181,7 +181,7 @@ void InstanceManager::RequestAffirmation(Instance* instance, const PendingInstan bitStream.Write(request.id); - Game::server->Send(&bitStream, instance->GetSysAddr(), false); + Game::server->Send(bitStream, instance->GetSysAddr(), false); LOG("Sent affirmation request %llu to %i/%i", request.id, static_cast(instance->GetZoneID().GetMapID()), @@ -361,7 +361,7 @@ void Instance::Shutdown() { BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SHUTDOWN); - Game::server->Send(&bitStream, this->m_SysAddr, false); + Game::server->Send(bitStream, this->m_SysAddr, false); LOG("Triggered world shutdown for zone/clone/instance %i/%i/%i", GetMapID(), GetCloneID(), GetInstanceID()); } diff --git a/dMasterServer/MasterServer.cpp b/dMasterServer/MasterServer.cpp index 1fade06e..4104f5ea 100644 --- a/dMasterServer/MasterServer.cpp +++ b/dMasterServer/MasterServer.cpp @@ -576,7 +576,7 @@ void HandlePacket(Packet* packet) { BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SESSION_KEY_RESPONSE); bitStream.Write(key.first); bitStream.Write(username); - Game::server->Send(&bitStream, packet->systemAddress, false); + Game::server->Send(bitStream, packet->systemAddress, false); break; } } @@ -786,7 +786,7 @@ int ShutdownSequence(int32_t signal) { { CBITSTREAM; BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SHUTDOWN); - Game::server->Send(&bitStream, UNASSIGNED_SYSTEM_ADDRESS, true); + Game::server->Send(bitStream, UNASSIGNED_SYSTEM_ADDRESS, true); LOG("Triggered master shutdown"); } diff --git a/dNet/AuthPackets.cpp b/dNet/AuthPackets.cpp index 25ccc902..2ba33ab5 100644 --- a/dNet/AuthPackets.cpp +++ b/dNet/AuthPackets.cpp @@ -28,10 +28,10 @@ namespace { std::vector claimCodes; } -void Stamp::Serialize(RakNet::BitStream* outBitStream){ - outBitStream->Write(type); - outBitStream->Write(value); - outBitStream->Write(timestamp); +void Stamp::Serialize(RakNet::BitStream& outBitStream){ + outBitStream.Write(type); + outBitStream.Write(value); + outBitStream.Write(timestamp); }; void AuthPackets::LoadClaimCodes() { @@ -82,9 +82,9 @@ void AuthPackets::SendHandshake(dServer* server, const SystemAddress& sysAddr, c if (serverType == ServerType::Auth) bitStream.Write(ServiceId::Auth); else if (serverType == ServerType::World) bitStream.Write(ServiceId::World); else bitStream.Write(ServiceId::General); - bitStream.Write(774909490); + bitStream.Write(215523405360); - server->Send(&bitStream, sysAddr, false); + server->Send(bitStream, sysAddr, false); } void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { @@ -291,16 +291,16 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd stamps.emplace_back(eStamps::PASSPORT_AUTH_WORLD_COMMUNICATION_FINISH, 1); loginResponse.Write((sizeof(Stamp) * stamps.size()) + sizeof(uint32_t)); - for (auto& stamp : stamps) stamp.Serialize(&loginResponse); + for (auto& stamp : stamps) stamp.Serialize(loginResponse); - server->Send(&loginResponse, sysAddr, false); + server->Send(loginResponse, sysAddr, false); //Inform the master server that we've created a session for this user: if (responseCode == eLoginResponse::SUCCESS) { CBITSTREAM; BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SET_SESSION_KEY); bitStream.Write(sessionKey); bitStream.Write(LUString(username)); - server->SendToMaster(&bitStream); + server->SendToMaster(bitStream); LOG("Set sessionKey: %i for user %s", sessionKey, username.c_str()); } diff --git a/dNet/AuthPackets.h b/dNet/AuthPackets.h index 539bae75..ee1e4586 100644 --- a/dNet/AuthPackets.h +++ b/dNet/AuthPackets.h @@ -63,7 +63,7 @@ struct Stamp { this->timestamp = timestamp; } - void Serialize(RakNet::BitStream* outBitStream); + void Serialize(RakNet::BitStream& outBitStream); }; enum class ClientOS : uint8_t { diff --git a/dNet/MasterPackets.cpp b/dNet/MasterPackets.cpp index 6d70fedb..7bd8f4a5 100644 --- a/dNet/MasterPackets.cpp +++ b/dNet/MasterPackets.cpp @@ -12,7 +12,7 @@ void MasterPackets::SendPersistentIDRequest(dServer* server, uint64_t requestID) CBITSTREAM; BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_PERSISTENT_ID); bitStream.Write(requestID); - server->SendToMaster(&bitStream); + server->SendToMaster(bitStream); } void MasterPackets::SendPersistentIDResponse(dServer* server, const SystemAddress& sysAddr, uint64_t requestID, uint32_t objID) { @@ -22,7 +22,7 @@ void MasterPackets::SendPersistentIDResponse(dServer* server, const SystemAddres bitStream.Write(requestID); bitStream.Write(objID); - server->Send(&bitStream, sysAddr, false); + server->Send(bitStream, sysAddr, false); } void MasterPackets::SendZoneTransferRequest(dServer* server, uint64_t requestID, bool mythranShift, uint32_t zoneID, uint32_t cloneID) { @@ -34,7 +34,7 @@ void MasterPackets::SendZoneTransferRequest(dServer* server, uint64_t requestID, bitStream.Write(zoneID); bitStream.Write(cloneID); - server->SendToMaster(&bitStream); + server->SendToMaster(bitStream); } void MasterPackets::SendZoneCreatePrivate(dServer* server, uint32_t zoneID, uint32_t cloneID, const std::string& password) { @@ -49,7 +49,7 @@ void MasterPackets::SendZoneCreatePrivate(dServer* server, uint32_t zoneID, uint bitStream.Write(character); } - server->SendToMaster(&bitStream); + server->SendToMaster(bitStream); } void MasterPackets::SendZoneRequestPrivate(dServer* server, uint64_t requestID, bool mythranShift, const std::string& password) { @@ -64,7 +64,7 @@ void MasterPackets::SendZoneRequestPrivate(dServer* server, uint64_t requestID, bitStream.Write(character); } - server->SendToMaster(&bitStream); + server->SendToMaster(bitStream); } void MasterPackets::SendWorldReady(dServer* server, LWOMAPID zoneId, LWOINSTANCEID instanceId) { @@ -74,7 +74,7 @@ void MasterPackets::SendWorldReady(dServer* server, LWOMAPID zoneId, LWOINSTANCE bitStream.Write(zoneId); bitStream.Write(instanceId); - server->SendToMaster(&bitStream); + server->SendToMaster(bitStream); } void MasterPackets::SendZoneTransferResponse(dServer* server, const SystemAddress& sysAddr, uint64_t requestID, bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, const std::string& serverIP, uint32_t serverPort) { @@ -89,7 +89,7 @@ void MasterPackets::SendZoneTransferResponse(dServer* server, const SystemAddres bitStream.Write(serverPort); bitStream.Write(LUString(serverIP, 255)); - server->Send(&bitStream, sysAddr, false); + server->Send(bitStream, sysAddr, false); } void MasterPackets::HandleServerInfo(Packet* packet) { @@ -119,5 +119,5 @@ void MasterPackets::SendServerInfo(dServer* server, Packet* packet) { bitStream.Write(server->GetServerType()); bitStream.Write(LUString(server->GetIP())); - server->SendToMaster(&bitStream); + server->SendToMaster(bitStream); } diff --git a/dNet/WorldPackets.cpp b/dNet/WorldPackets.cpp index f92a971f..1c2b8dec 100644 --- a/dNet/WorldPackets.cpp +++ b/dNet/WorldPackets.cpp @@ -87,13 +87,13 @@ void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, int64_t rep std::unique_ptr> chatmode(new LDFData(u"chatmode", static_cast(gm))); std::unique_ptr> reputationLdf(new LDFData(u"reputation", reputation)); - objid->WriteToPacket(&data); - lot->WriteToPacket(&data); - name->WriteToPacket(&data); - gmlevel->WriteToPacket(&data); - chatmode->WriteToPacket(&data); - xmlConfigData->WriteToPacket(&data); - reputationLdf->WriteToPacket(&data); + objid->WriteToPacket(data); + lot->WriteToPacket(data); + name->WriteToPacket(data); + gmlevel->WriteToPacket(data); + chatmode->WriteToPacket(data); + xmlConfigData->WriteToPacket(data); + reputationLdf->WriteToPacket(data); //Compress the data before sending: const uint32_t reservedSize = ZCompression::GetMaxCompressedLength(data.GetNumberOfBytesUsed()); diff --git a/dNet/dServer.cpp b/dNet/dServer.cpp index ed66b42c..e504a985 100644 --- a/dNet/dServer.cpp +++ b/dNet/dServer.cpp @@ -159,13 +159,13 @@ void dServer::DeallocateMasterPacket(Packet* packet) { mMasterPeer->DeallocatePacket(packet); } -void dServer::Send(RakNet::BitStream* bitStream, const SystemAddress& sysAddr, bool broadcast) { - mPeer->Send(bitStream, SYSTEM_PRIORITY, RELIABLE_ORDERED, 0, sysAddr, broadcast); +void dServer::Send(RakNet::BitStream& bitStream, const SystemAddress& sysAddr, bool broadcast) { + mPeer->Send(&bitStream, SYSTEM_PRIORITY, RELIABLE_ORDERED, 0, sysAddr, broadcast); } -void dServer::SendToMaster(RakNet::BitStream* bitStream) { +void dServer::SendToMaster(RakNet::BitStream& bitStream) { if (!mMasterConnectionActive) ConnectToMaster(); - mMasterPeer->Send(bitStream, SYSTEM_PRIORITY, RELIABLE_ORDERED, 0, mMasterSystemAddress, false); + mMasterPeer->Send(&bitStream, SYSTEM_PRIORITY, RELIABLE_ORDERED, 0, mMasterSystemAddress, false); } void dServer::Disconnect(const SystemAddress& sysAddr, eServerDisconnectIdentifiers disconNotifyID) { diff --git a/dNet/dServer.h b/dNet/dServer.h index ef47eea4..40f606f1 100644 --- a/dNet/dServer.h +++ b/dNet/dServer.h @@ -52,8 +52,8 @@ public: Packet* Receive(); void DeallocatePacket(Packet* packet); void DeallocateMasterPacket(Packet* packet); - virtual void Send(RakNet::BitStream* bitStream, const SystemAddress& sysAddr, bool broadcast); - void SendToMaster(RakNet::BitStream* bitStream); + virtual void Send(RakNet::BitStream& bitStream, const SystemAddress& sysAddr, bool broadcast); + void SendToMaster(RakNet::BitStream& bitStream); void Disconnect(const SystemAddress& sysAddr, eServerDisconnectIdentifiers disconNotifyID); diff --git a/dScripts/02_server/DLU/CMakeLists.txt b/dScripts/02_server/DLU/CMakeLists.txt index 64d4cbbd..fb257d3e 100644 --- a/dScripts/02_server/DLU/CMakeLists.txt +++ b/dScripts/02_server/DLU/CMakeLists.txt @@ -1,3 +1,3 @@ set(DSCRIPTS_SOURCES_02_SERVER_DLU - "DLUVanityNPC.cpp" + "DLUVanityTeleportingObject.cpp" PARENT_SCOPE) diff --git a/dScripts/02_server/DLU/DLUVanityNPC.cpp b/dScripts/02_server/DLU/DLUVanityTeleportingObject.cpp similarity index 51% rename from dScripts/02_server/DLU/DLUVanityNPC.cpp rename to dScripts/02_server/DLU/DLUVanityTeleportingObject.cpp index ba2c6604..8aff1995 100644 --- a/dScripts/02_server/DLU/DLUVanityNPC.cpp +++ b/dScripts/02_server/DLU/DLUVanityTeleportingObject.cpp @@ -1,22 +1,22 @@ -#include "DLUVanityNPC.h" +#include "DLUVanityTeleportingObject.h" #include "GameMessages.h" #include "dServer.h" #include "VanityUtilities.h" #include "RenderComponent.h" -void DLUVanityNPC::OnStartup(Entity* self) { - m_NPC = VanityUtilities::GetNPC("averysumner - Destroyer of Worlds"); +void DLUVanityTeleportingObject::OnStartup(Entity* self) { + if (!self->HasVar(u"npcName") || !self->HasVar(u"teleport")) return; + m_Object = VanityUtilities::GetObject(self->GetVarAsString(u"npcName")); - if (m_NPC == nullptr) { - return; - } + if (!m_Object) return; + if (self->HasVar(u"teleportInterval")) m_TeleportInterval = self->GetVar(u"teleportInterval"); if (self->GetVar(u"teleport")) { - self->AddTimer("setupTeleport", 15.0f); + self->AddTimer("setupTeleport", m_TeleportInterval); } } -void DLUVanityNPC::OnTimerDone(Entity* self, std::string timerName) { +void DLUVanityTeleportingObject::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "setupTeleport") { RenderComponent::PlayAnimation(self, u"interact"); GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportBeam", "teleportBeam"); @@ -28,20 +28,22 @@ void DLUVanityNPC::OnTimerDone(Entity* self, std::string timerName) { GameMessages::SendStopFXEffect(self, true, "teleportBeam"); GameMessages::SendStopFXEffect(self, true, "teleportRings"); } else if (timerName == "teleport") { - std::vector& locations = m_NPC->m_Locations[Game::server->GetZoneID()]; + std::vector& locations = m_Object->m_Locations[Game::server->GetZoneID()]; selectLocation: - VanityNPCLocation& newLocation = locations[GeneralUtils::GenerateRandomNumber(0, locations.size() - 1)]; + VanityObjectLocation& newLocation = locations[GeneralUtils::GenerateRandomNumber(0, locations.size() - 1)]; + // try to get not the same position, but if we get the same one twice, it's fine if (self->GetPosition() == newLocation.m_Position) { - goto selectLocation; // cry about it + VanityObjectLocation& newLocation = locations[GeneralUtils::GenerateRandomNumber(0, locations.size() - 1)]; } self->SetPosition(newLocation.m_Position); self->SetRotation(newLocation.m_Rotation); + self->SetScale(newLocation.m_Scale); GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportBeam", "teleportBeam"); GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportRings", "teleportRings"); self->AddTimer("stopFX", 2.0f); - self->AddTimer("setupTeleport", 15.0f); + self->AddTimer("setupTeleport", m_TeleportInterval); } } diff --git a/dScripts/02_server/DLU/DLUVanityNPC.h b/dScripts/02_server/DLU/DLUVanityTeleportingObject.h similarity index 54% rename from dScripts/02_server/DLU/DLUVanityNPC.h rename to dScripts/02_server/DLU/DLUVanityTeleportingObject.h index aeb8e051..a13ba901 100644 --- a/dScripts/02_server/DLU/DLUVanityNPC.h +++ b/dScripts/02_server/DLU/DLUVanityTeleportingObject.h @@ -1,13 +1,14 @@ #pragma once #include "CppScripts.h" -class VanityNPC; -class DLUVanityNPC : public CppScripts::Script +class VanityObject; +class DLUVanityTeleportingObject : public CppScripts::Script { public: void OnStartup(Entity* self) override; void OnTimerDone(Entity* self, std::string timerName) override; private: - VanityNPC* m_NPC; + VanityObject* m_Object; + float m_TeleportInterval = 15.0f; }; diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index 071bd7a3..7cb853e6 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -216,7 +216,7 @@ #include "NtNaomiBreadcrumbServer.h" // DLU Scripts -#include "DLUVanityNPC.h" +#include "DLUVanityTeleportingObject.h" // AM Scripts #include "AmConsoleTeleportServer.h" @@ -834,8 +834,8 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr script = new NjNyaMissionitems(); //DLU: - else if (scriptName == "scripts\\02_server\\DLU\\DLUVanityNPC.lua") - script = new DLUVanityNPC(); + else if (scriptName == "scripts\\02_server\\DLU\\DLUVanityTeleportingObject.lua") + script = new DLUVanityTeleportingObject(); // Survival minigame else if (scriptName == "scripts\\02_server\\Enemy\\Survival\\L_AG_SURVIVAL_STROMBIE.lua") diff --git a/dScripts/ScriptComponent.cpp b/dScripts/ScriptComponent.cpp index 7c44ded3..57e6e832 100644 --- a/dScripts/ScriptComponent.cpp +++ b/dScripts/ScriptComponent.cpp @@ -17,11 +17,11 @@ ScriptComponent::~ScriptComponent() { } -void ScriptComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void ScriptComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { if (bIsInitialUpdate) { const auto& networkSettings = m_Parent->GetNetworkSettings(); auto hasNetworkSettings = !networkSettings.empty(); - outBitStream->Write(hasNetworkSettings); + outBitStream.Write(hasNetworkSettings); if (hasNetworkSettings) { @@ -31,12 +31,12 @@ void ScriptComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitial ldfData.Write(networkSettings.size()); for (auto* networkSetting : networkSettings) { - networkSetting->WriteToPacket(&ldfData); + networkSetting->WriteToPacket(ldfData); } // Finally write everything to the stream - outBitStream->Write(ldfData.GetNumberOfBytesUsed()); - outBitStream->Write(ldfData); + outBitStream.Write(ldfData.GetNumberOfBytesUsed()); + outBitStream.Write(ldfData); } } } diff --git a/dScripts/ScriptComponent.h b/dScripts/ScriptComponent.h index a28c9419..a1371109 100644 --- a/dScripts/ScriptComponent.h +++ b/dScripts/ScriptComponent.h @@ -24,7 +24,7 @@ public: ScriptComponent(Entity* parent, std::string scriptName, bool serialized, bool client = false); ~ScriptComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Returns the script that's attached to this entity diff --git a/dWorldServer/WorldServer.cpp b/dWorldServer/WorldServer.cpp index bb879dbd..fde5a2a6 100644 --- a/dWorldServer/WorldServer.cpp +++ b/dWorldServer/WorldServer.cpp @@ -730,7 +730,7 @@ void HandleMasterPacket(Packet* packet) { BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::PLAYER_ADDED); bitStream.Write((LWOMAPID)Game::server->GetZoneID()); bitStream.Write((LWOINSTANCEID)instanceID); - Game::server->SendToMaster(&bitStream); + Game::server->SendToMaster(bitStream); } } @@ -746,7 +746,7 @@ void HandleMasterPacket(Packet* packet) { BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::AFFIRM_TRANSFER_RESPONSE); bitStream.Write(requestID); - Game::server->SendToMaster(&bitStream); + Game::server->SendToMaster(bitStream); break; } @@ -832,7 +832,7 @@ void HandlePacket(Packet* packet) { BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::PLAYER_REMOVED); bitStream.Write((LWOMAPID)Game::server->GetZoneID()); bitStream.Write((LWOINSTANCEID)instanceID); - Game::server->SendToMaster(&bitStream); + Game::server->SendToMaster(bitStream); } if (packet->data[0] != ID_USER_PACKET_ENUM || packet->length < 4) return; @@ -895,7 +895,7 @@ void HandlePacket(Packet* packet) { CBITSTREAM; BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_SESSION_KEY); bitStream.Write(username); - Game::server->SendToMaster(&bitStream); + Game::server->SendToMaster(bitStream); //Insert info into our pending list tempSessionInfo info; @@ -950,7 +950,7 @@ void HandlePacket(Packet* packet) { static_cast(messageID) ); - if (isSender) GameMessageHandler::HandleMessage(&dataStream, packet->systemAddress, objectID, messageID); + if (isSender) GameMessageHandler::HandleMessage(dataStream, packet->systemAddress, objectID, messageID); break; } @@ -1177,7 +1177,7 @@ void HandlePacket(Packet* packet) { // FIXME: Change this to the macro to skip the header... LWOOBJID space; bitStream.Read(space); - Mail::HandleMailStuff(&bitStream, packet->systemAddress, UserManager::Instance()->GetUser(packet->systemAddress)->GetLastUsedChar()->GetEntity()); + Mail::HandleMailStuff(bitStream, packet->systemAddress, UserManager::Instance()->GetUser(packet->systemAddress)->GetLastUsedChar()->GetEntity()); break; } @@ -1461,5 +1461,5 @@ void FinalizeShutdown() { void SendShutdownMessageToMaster() { CBITSTREAM; BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SHUTDOWN_RESPONSE); - Game::server->SendToMaster(&bitStream); + Game::server->SendToMaster(bitStream); } diff --git a/dZoneManager/Level.cpp b/dZoneManager/Level.cpp index 9524d908..5f35b629 100644 --- a/dZoneManager/Level.cpp +++ b/dZoneManager/Level.cpp @@ -200,9 +200,6 @@ void Level::ReadFileInfoChunk(std::istream& file, Header& header) { BinaryIO::BinaryRead(file, header.fileInfo.enviromentChunkStart); BinaryIO::BinaryRead(file, header.fileInfo.objectChunkStart); BinaryIO::BinaryRead(file, header.fileInfo.particleChunkStart); - - //PATCH FOR AG: (messed up file?) - if (header.fileInfo.revision == 0xCDCDCDCD && m_ParentZone->GetZoneID().GetMapID() == 1100) header.fileInfo.revision = 26; } void Level::ReadSceneObjectDataChunk(std::istream& file, Header& header) { diff --git a/tests/dCommonTests/AMFDeserializeTests.cpp b/tests/dCommonTests/AMFDeserializeTests.cpp index cc3ea551..fb1946c5 100644 --- a/tests/dCommonTests/AMFDeserializeTests.cpp +++ b/tests/dCommonTests/AMFDeserializeTests.cpp @@ -11,9 +11,9 @@ /** * Helper method that all tests use to get their respective AMF. */ -std::unique_ptr ReadFromBitStream(RakNet::BitStream* bitStream) { +std::unique_ptr ReadFromBitStream(RakNet::BitStream& bitStream) { AMFDeserialize deserializer; - return std::unique_ptr{ static_cast(deserializer.Read(bitStream).release()) }; + return deserializer.Read(bitStream); } /** @@ -22,7 +22,7 @@ std::unique_ptr ReadFromBitStream(RakNet::BitStream* bitStream) { TEST(dCommonTests, AMFDeserializeAMFUndefinedTest) { CBITSTREAM; bitStream.Write(0x00); - std::unique_ptr res{ ReadFromBitStream(&bitStream) }; + std::unique_ptr res{ ReadFromBitStream(bitStream) }; ASSERT_EQ(res->GetValueType(), eAmf::Undefined); } @@ -33,7 +33,7 @@ TEST(dCommonTests, AMFDeserializeAMFUndefinedTest) { TEST(dCommonTests, AMFDeserializeAMFNullTest) { CBITSTREAM; bitStream.Write(0x01); - std::unique_ptr res{ ReadFromBitStream(&bitStream) }; + std::unique_ptr res{ ReadFromBitStream(bitStream) }; ASSERT_EQ(res->GetValueType(), eAmf::Null); } @@ -43,7 +43,7 @@ TEST(dCommonTests, AMFDeserializeAMFNullTest) { TEST(dCommonTests, AMFDeserializeAMFFalseTest) { CBITSTREAM; bitStream.Write(0x02); - std::unique_ptr res{ ReadFromBitStream(&bitStream) }; + std::unique_ptr res{ ReadFromBitStream(bitStream) }; ASSERT_EQ(res->GetValueType(), eAmf::False); } @@ -53,7 +53,7 @@ TEST(dCommonTests, AMFDeserializeAMFFalseTest) { TEST(dCommonTests, AMFDeserializeAMFTrueTest) { CBITSTREAM; bitStream.Write(0x03); - std::unique_ptr res{ ReadFromBitStream(&bitStream) }; + std::unique_ptr res{ ReadFromBitStream(bitStream) }; ASSERT_EQ(res->GetValueType(), eAmf::True); } @@ -66,7 +66,7 @@ TEST(dCommonTests, AMFDeserializeAMFIntegerTest) { bitStream.Write(0x04); // 127 == 01111111 bitStream.Write(127); - std::unique_ptr res{ ReadFromBitStream(&bitStream) }; + std::unique_ptr res{ ReadFromBitStream(bitStream) }; ASSERT_EQ(res->GetValueType(), eAmf::Integer); // Check that the max value of a byte can be read correctly ASSERT_EQ(static_cast(res.get())->GetValue(), 127); @@ -75,7 +75,7 @@ TEST(dCommonTests, AMFDeserializeAMFIntegerTest) { { bitStream.Write(0x04); bitStream.Write(UINT32_MAX); - std::unique_ptr res{ ReadFromBitStream(&bitStream) }; + std::unique_ptr res{ ReadFromBitStream(bitStream) }; ASSERT_EQ(res->GetValueType(), eAmf::Integer); // Check that we can read the maximum value correctly ASSERT_EQ(static_cast(res.get())->GetValue(), 536870911); @@ -89,7 +89,7 @@ TEST(dCommonTests, AMFDeserializeAMFIntegerTest) { bitStream.Write(255); // 127 == 01111111 bitStream.Write(127); - std::unique_ptr res{ ReadFromBitStream(&bitStream) }; + std::unique_ptr res{ ReadFromBitStream(bitStream) }; ASSERT_EQ(res->GetValueType(), eAmf::Integer); // Check that short max can be read correctly ASSERT_EQ(static_cast(res.get())->GetValue(), UINT16_MAX); @@ -101,7 +101,7 @@ TEST(dCommonTests, AMFDeserializeAMFIntegerTest) { bitStream.Write(255); // 127 == 01111111 bitStream.Write(127); - std::unique_ptr res{ ReadFromBitStream(&bitStream) }; + std::unique_ptr res{ ReadFromBitStream(bitStream) }; ASSERT_EQ(res->GetValueType(), eAmf::Integer); // Check that 2 byte max can be read correctly ASSERT_EQ(static_cast(res.get())->GetValue(), 16383); @@ -115,7 +115,7 @@ TEST(dCommonTests, AMFDeserializeAMFDoubleTest) { CBITSTREAM; bitStream.Write(0x05); bitStream.Write(25346.4f); - std::unique_ptr res{ ReadFromBitStream(&bitStream) }; + std::unique_ptr res{ ReadFromBitStream(bitStream) }; ASSERT_EQ(res->GetValueType(), eAmf::Double); ASSERT_EQ(static_cast(res.get())->GetValue(), 25346.4f); } @@ -129,7 +129,7 @@ TEST(dCommonTests, AMFDeserializeAMFStringTest) { bitStream.Write(0x0F); std::string toWrite = "stateID"; for (auto e : toWrite) bitStream.Write(e); - std::unique_ptr res{ ReadFromBitStream(&bitStream) }; + std::unique_ptr res{ ReadFromBitStream(bitStream) }; ASSERT_EQ(res->GetValueType(), eAmf::String); ASSERT_EQ(static_cast(res.get())->GetValue(), "stateID"); } @@ -144,7 +144,7 @@ TEST(dCommonTests, AMFDeserializeAMFArrayTest) { bitStream.Write(0x01); bitStream.Write(0x01); { - std::unique_ptr res{ ReadFromBitStream(&bitStream) }; + std::unique_ptr res{ ReadFromBitStream(bitStream) }; ASSERT_EQ(res->GetValueType(), eAmf::Array); ASSERT_EQ(static_cast(res.get())->GetAssociative().size(), 0); ASSERT_EQ(static_cast(res.get())->GetDense().size(), 0); @@ -163,7 +163,7 @@ TEST(dCommonTests, AMFDeserializeAMFArrayTest) { bitStream.Write(0x0B); for (auto e : "10447") if (e != '\0') bitStream.Write(e); { - std::unique_ptr res{ ReadFromBitStream(&bitStream) }; + std::unique_ptr res{ ReadFromBitStream(bitStream) }; ASSERT_EQ(res->GetValueType(), eAmf::Array); ASSERT_EQ(static_cast(res.get())->GetAssociative().size(), 1); ASSERT_EQ(static_cast(res.get())->GetDense().size(), 1); @@ -212,7 +212,7 @@ TEST(dCommonTests, AMFDeserializeUnimplementedValuesTest) { testBitStream.Write(value); bool caughtException = false; try { - ReadFromBitStream(&testBitStream); + ReadFromBitStream(testBitStream); } catch (eAmf unimplementedValueType) { caughtException = true; } @@ -237,7 +237,7 @@ TEST(dCommonTests, AMFDeserializeLivePacketTest) { testFileStream.close(); - std::unique_ptr resultFromFn{ ReadFromBitStream(&testBitStream) }; + std::unique_ptr resultFromFn{ ReadFromBitStream(testBitStream) }; auto* result = static_cast(resultFromFn.get()); // Test the outermost array @@ -342,14 +342,6 @@ TEST(dCommonTests, AMFDeserializeLivePacketTest) { ASSERT_EQ(thirdDistance->GetValue(), 25.0f); } -/** - * @brief Tests that having no BitStream returns a nullptr. - */ -TEST(dCommonTests, AMFDeserializeNullTest) { - std::unique_ptr result(ReadFromBitStream(nullptr)); - ASSERT_EQ(result.get(), nullptr); -} - TEST(dCommonTests, AMFBadConversionTest) { std::ifstream testFileStream; testFileStream.open("AMFBitStreamTest.bin", std::ios::binary); @@ -363,7 +355,7 @@ TEST(dCommonTests, AMFBadConversionTest) { testFileStream.close(); - std::unique_ptr resultFromFn(ReadFromBitStream(&testBitStream)); + std::unique_ptr resultFromFn(ReadFromBitStream(testBitStream)); auto result = static_cast(resultFromFn.get()); // Actually a string value. diff --git a/tests/dGameTests/GameDependencies.h b/tests/dGameTests/GameDependencies.h index 5d9c99bf..52e3919a 100644 --- a/tests/dGameTests/GameDependencies.h +++ b/tests/dGameTests/GameDependencies.h @@ -19,7 +19,7 @@ public: dServerMock() {}; ~dServerMock() {}; RakNet::BitStream* GetMostRecentBitStream() { return sentBitStream; }; - void Send(RakNet::BitStream* bitStream, const SystemAddress& sysAddr, bool broadcast) override { sentBitStream = bitStream; }; + void Send(RakNet::BitStream& bitStream, const SystemAddress& sysAddr, bool broadcast) override { sentBitStream = &bitStream; }; }; class GameDependenciesTest : public ::testing::Test { diff --git a/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp b/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp index ff37f154..d14004ee 100644 --- a/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp @@ -48,7 +48,7 @@ TEST_F(DestroyableTest, PlacementNewAddComponentTest) { * Test Construction of a DestroyableComponent */ TEST_F(DestroyableTest, DestroyableComponentSerializeConstructionTest) { - destroyableComponent->Serialize(&bitStream, true); + destroyableComponent->Serialize(bitStream, true); // Assert that the full number of bits are present ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 748); { @@ -178,7 +178,7 @@ TEST_F(DestroyableTest, DestroyableComponentSerializeTest) { destroyableComponent->SetMaxHealth(1233.0f); // Now we test a serialization for correctness. - destroyableComponent->Serialize(&bitStream, false); + destroyableComponent->Serialize(bitStream, false); ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 422); { // Now read in the full serialized BitStream diff --git a/tests/dGameTests/dComponentsTests/SimplePhysicsComponentTests.cpp b/tests/dGameTests/dComponentsTests/SimplePhysicsComponentTests.cpp index 896dcf5a..0116dfcc 100644 --- a/tests/dGameTests/dComponentsTests/SimplePhysicsComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/SimplePhysicsComponentTests.cpp @@ -30,7 +30,7 @@ protected: }; TEST_F(SimplePhysicsTest, SimplePhysicsSerializeTest) { - simplePhysicsComponent->Serialize(&bitStream, false); + simplePhysicsComponent->Serialize(bitStream, false); constexpr uint32_t sizeOfStream = 3 + BYTES_TO_BITS(3 * sizeof(NiPoint3)) + BYTES_TO_BITS(1 * sizeof(NiQuaternion)) + 1 * BYTES_TO_BITS(sizeof(uint32_t)); ASSERT_EQ(bitStream.GetNumberOfBitsUsed(), sizeOfStream); @@ -77,7 +77,7 @@ TEST_F(SimplePhysicsTest, SimplePhysicsSerializeTest) { } TEST_F(SimplePhysicsTest, SimplePhysicsConstructionTest) { - simplePhysicsComponent->Serialize(&bitStream, true); + simplePhysicsComponent->Serialize(bitStream, true); constexpr uint32_t sizeOfStream = 4 + BYTES_TO_BITS(1 * sizeof(int32_t)) + BYTES_TO_BITS(3 * sizeof(NiPoint3)) + BYTES_TO_BITS(1 * sizeof(NiQuaternion)) + 1 * BYTES_TO_BITS(sizeof(uint32_t)); ASSERT_EQ(bitStream.GetNumberOfBitsUsed(), sizeOfStream); diff --git a/tests/dGameTests/dGameMessagesTests/GameMessageTests.cpp b/tests/dGameTests/dGameMessagesTests/GameMessageTests.cpp index d4bdf420..e62c6d17 100644 --- a/tests/dGameTests/dGameMessagesTests/GameMessageTests.cpp +++ b/tests/dGameTests/dGameMessagesTests/GameMessageTests.cpp @@ -38,7 +38,7 @@ protected: } return readFile; } - std::unique_ptr ReadArrayFromBitStream(RakNet::BitStream* inStream) { + std::unique_ptr ReadArrayFromBitStream(RakNet::BitStream& inStream) { AMFDeserialize des; AMFBaseValue* readArray = des.Read(inStream).release(); EXPECT_EQ(readArray->GetValueType(), eAmf::Array); @@ -88,8 +88,8 @@ TEST_F(GameMessageTests, SendBlueprintLoadItemResponse) { TEST_F(GameMessageTests, ControlBehaviorAddStrip) { auto data = ReadFromFile("addStrip"); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); - auto msg = ReadArrayFromBitStream(&inStream); - AddStripMessage addStrip(*msg.get()); + auto msg = ReadArrayFromBitStream(inStream); + AddStripMessage addStrip(*msg); ASSERT_FLOAT_EQ(addStrip.GetPosition().GetX(), 50.65); ASSERT_FLOAT_EQ(addStrip.GetPosition().GetY(), 178.05); ASSERT_EQ(addStrip.GetActionContext().GetStripId(), 0); @@ -104,8 +104,8 @@ TEST_F(GameMessageTests, ControlBehaviorAddStrip) { TEST_F(GameMessageTests, ControlBehaviorRemoveStrip) { auto data = ReadFromFile("removeStrip"); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); - auto msg = ReadArrayFromBitStream(&inStream); - RemoveStripMessage removeStrip(*msg.get()); + auto msg = ReadArrayFromBitStream(inStream); + RemoveStripMessage removeStrip(*msg); ASSERT_EQ(static_cast(removeStrip.GetActionContext().GetStripId()), 1); ASSERT_EQ(static_cast(removeStrip.GetActionContext().GetStateId()), 0); ASSERT_EQ(removeStrip.GetBehaviorId(), BehaviorMessageBase::DefaultBehaviorId); @@ -114,8 +114,8 @@ TEST_F(GameMessageTests, ControlBehaviorRemoveStrip) { TEST_F(GameMessageTests, ControlBehaviorMergeStrips) { auto data = ReadFromFile("mergeStrips"); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); - auto msg = ReadArrayFromBitStream(&inStream); - MergeStripsMessage mergeStrips(*msg.get()); + auto msg = ReadArrayFromBitStream(inStream); + MergeStripsMessage mergeStrips(*msg); ASSERT_EQ(mergeStrips.GetSourceActionContext().GetStripId(), 2); ASSERT_EQ(mergeStrips.GetDestinationActionContext().GetStripId(), 0); ASSERT_EQ(static_cast(mergeStrips.GetSourceActionContext().GetStateId()), 0); @@ -127,8 +127,8 @@ TEST_F(GameMessageTests, ControlBehaviorMergeStrips) { TEST_F(GameMessageTests, ControlBehaviorSplitStrip) { auto data = ReadFromFile("splitStrip"); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); - auto msg = ReadArrayFromBitStream(&inStream); - SplitStripMessage splitStrip(*msg.get()); + auto msg = ReadArrayFromBitStream(inStream); + SplitStripMessage splitStrip(*msg); ASSERT_EQ(splitStrip.GetBehaviorId(), BehaviorMessageBase::DefaultBehaviorId); ASSERT_FLOAT_EQ(splitStrip.GetPosition().GetX(), 275.65); @@ -143,8 +143,8 @@ TEST_F(GameMessageTests, ControlBehaviorSplitStrip) { TEST_F(GameMessageTests, ControlBehaviorUpdateStripUI) { auto data = ReadFromFile("updateStripUI"); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); - auto msg = ReadArrayFromBitStream(&inStream); - UpdateStripUiMessage updateStripUi(*msg.get()); + auto msg = ReadArrayFromBitStream(inStream); + UpdateStripUiMessage updateStripUi(*msg); ASSERT_FLOAT_EQ(updateStripUi.GetPosition().GetX(), 116.65); ASSERT_FLOAT_EQ(updateStripUi.GetPosition().GetY(), 35.35); ASSERT_EQ(updateStripUi.GetActionContext().GetStripId(), 0); @@ -155,8 +155,8 @@ TEST_F(GameMessageTests, ControlBehaviorUpdateStripUI) { TEST_F(GameMessageTests, ControlBehaviorAddAction) { auto data = ReadFromFile("addAction"); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); - auto msg = ReadArrayFromBitStream(&inStream); - AddActionMessage addAction{ *msg.get() }; + auto msg = ReadArrayFromBitStream(inStream); + AddActionMessage addAction{ *msg }; ASSERT_EQ(addAction.GetActionIndex(), 3); ASSERT_EQ(addAction.GetActionContext().GetStripId(), 0); ASSERT_EQ(static_cast(addAction.GetActionContext().GetStateId()), 0); @@ -170,8 +170,8 @@ TEST_F(GameMessageTests, ControlBehaviorAddAction) { TEST_F(GameMessageTests, ControlBehaviorMigrateActions) { auto data = ReadFromFile("migrateActions"); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); - auto msg = ReadArrayFromBitStream(&inStream); - MigrateActionsMessage migrateActions(*msg.get()); + auto msg = ReadArrayFromBitStream(inStream); + MigrateActionsMessage migrateActions(*msg); ASSERT_EQ(migrateActions.GetSrcActionIndex(), 1); ASSERT_EQ(migrateActions.GetDstActionIndex(), 2); ASSERT_EQ(migrateActions.GetSourceActionContext().GetStripId(), 1); @@ -184,8 +184,8 @@ TEST_F(GameMessageTests, ControlBehaviorMigrateActions) { TEST_F(GameMessageTests, ControlBehaviorRearrangeStrip) { auto data = ReadFromFile("rearrangeStrip"); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); - auto msg = ReadArrayFromBitStream(&inStream); - RearrangeStripMessage rearrangeStrip(*msg.get()); + auto msg = ReadArrayFromBitStream(inStream); + RearrangeStripMessage rearrangeStrip(*msg); ASSERT_EQ(rearrangeStrip.GetSrcActionIndex(), 2); ASSERT_EQ(rearrangeStrip.GetDstActionIndex(), 1); ASSERT_EQ(rearrangeStrip.GetActionContext().GetStripId(), 0); @@ -196,8 +196,8 @@ TEST_F(GameMessageTests, ControlBehaviorRearrangeStrip) { TEST_F(GameMessageTests, ControlBehaviorAdd) { auto data = ReadFromFile("add"); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); - auto msg = ReadArrayFromBitStream(&inStream); - AddMessage add(*msg.get()); + auto msg = ReadArrayFromBitStream(inStream); + AddMessage add(*msg); ASSERT_EQ(add.GetBehaviorId(), 10446); ASSERT_EQ(add.GetBehaviorIndex(), 0); } @@ -205,8 +205,8 @@ TEST_F(GameMessageTests, ControlBehaviorAdd) { TEST_F(GameMessageTests, ControlBehaviorRemoveActions) { auto data = ReadFromFile("removeActions"); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); - auto msg = ReadArrayFromBitStream(&inStream); - RemoveActionsMessage removeActions(*msg.get()); + auto msg = ReadArrayFromBitStream(inStream); + RemoveActionsMessage removeActions(*msg); ASSERT_EQ(removeActions.GetBehaviorId(), -1); ASSERT_EQ(removeActions.GetActionIndex(), 1); ASSERT_EQ(removeActions.GetActionContext().GetStripId(), 0); @@ -216,8 +216,8 @@ TEST_F(GameMessageTests, ControlBehaviorRemoveActions) { TEST_F(GameMessageTests, ControlBehaviorRename) { auto data = ReadFromFile("rename"); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); - auto msg = ReadArrayFromBitStream(&inStream); - RenameMessage rename(*msg.get()); + auto msg = ReadArrayFromBitStream(inStream); + RenameMessage rename(*msg); ASSERT_EQ(rename.GetName(), "test"); ASSERT_EQ(rename.GetBehaviorId(), BehaviorMessageBase::DefaultBehaviorId); } @@ -225,8 +225,8 @@ TEST_F(GameMessageTests, ControlBehaviorRename) { TEST_F(GameMessageTests, ControlBehaviorUpdateAction) { auto data = ReadFromFile("updateAction"); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); - auto msg = ReadArrayFromBitStream(&inStream); - UpdateActionMessage updateAction(*msg.get()); + auto msg = ReadArrayFromBitStream(inStream); + UpdateActionMessage updateAction(*msg); ASSERT_EQ(updateAction.GetAction().GetType(), "FlyDown"); ASSERT_EQ(updateAction.GetAction().GetValueParameterName(), "Distance"); ASSERT_EQ(updateAction.GetAction().GetValueParameterString(), ""); diff --git a/vanity/atm.xml b/vanity/atm.xml new file mode 100644 index 00000000..96ed1a2b --- /dev/null +++ b/vanity/atm.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vanity/NPC.xml b/vanity/dev-tribute.xml similarity index 65% rename from vanity/NPC.xml rename to vanity/dev-tribute.xml index 2311ab46..d20e31a6 100644 --- a/vanity/NPC.xml +++ b/vanity/dev-tribute.xml @@ -1,5 +1,5 @@ - - + + 6802, 2519, 2623, 14806 Sorry for the mess. @@ -11,39 +11,33 @@ Everything is awesome! I hope my behaviors are behaving themselves. - - - - - - - + + + + + 12947, 12949, 12962, 12963 I hope quickbulds are still working! Be careful crossing the gap! Have The Maelstrom stopped going invisible? - - - - - - - + + + + + 9950, 9944, 14102, 14092 Hello Explorer! It's great to see you made it! Have you heard about Darkflame? I've traveled across this entire system, but nothing beats the view here. - - - - - - - + + + + + cmerw[acowipaejio;fawjioefasdl;kfjm; @@ -51,20 +45,18 @@ zxnpoasdfiopwemsadf'kawpfo[ekasdf;'s *teleports behind you* -