Convert game message bit stream raw pointers to references (#1465)

This commit is contained in:
jadebenn 2024-02-26 08:17:22 -06:00 committed by GitHub
parent 94a467b361
commit 7235423c7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 675 additions and 684 deletions

View File

@ -9,12 +9,11 @@
* AMF3 Deserializer written by EmosewaMC * AMF3 Deserializer written by EmosewaMC
*/ */
AMFBaseValue* AMFDeserialize::Read(RakNet::BitStream* inStream) { AMFBaseValue* AMFDeserialize::Read(RakNet::BitStream& inStream) {
if (!inStream) return nullptr;
AMFBaseValue* returnValue = nullptr; AMFBaseValue* returnValue = nullptr;
// Read in the value type from the bitStream // Read in the value type from the bitStream
eAmf marker; eAmf marker;
inStream->Read(marker); inStream.Read(marker);
// Based on the typing, create the value associated with that and return the base value class // Based on the typing, create the value associated with that and return the base value class
switch (marker) { switch (marker) {
case eAmf::Undefined: { case eAmf::Undefined: {
@ -79,13 +78,13 @@ AMFBaseValue* AMFDeserialize::Read(RakNet::BitStream* inStream) {
return returnValue; return returnValue;
} }
uint32_t AMFDeserialize::ReadU29(RakNet::BitStream* inStream) { uint32_t AMFDeserialize::ReadU29(RakNet::BitStream& inStream) {
bool byteFlag = true; bool byteFlag = true;
uint32_t actualNumber{}; uint32_t actualNumber{};
uint8_t numberOfBytesRead{}; uint8_t numberOfBytesRead{};
while (byteFlag && numberOfBytesRead < 4) { while (byteFlag && numberOfBytesRead < 4) {
uint8_t byte{}; uint8_t byte{};
inStream->Read(byte); inStream.Read(byte);
// Parse the byte // Parse the byte
if (numberOfBytesRead < 3) { if (numberOfBytesRead < 3) {
byteFlag = byte & static_cast<uint8_t>(1 << 7); byteFlag = byte & static_cast<uint8_t>(1 << 7);
@ -101,7 +100,7 @@ uint32_t AMFDeserialize::ReadU29(RakNet::BitStream* inStream) {
return actualNumber; return actualNumber;
} }
const std::string AMFDeserialize::ReadString(RakNet::BitStream* inStream) { const std::string AMFDeserialize::ReadString(RakNet::BitStream& inStream) {
auto length = ReadU29(inStream); auto length = ReadU29(inStream);
// Check if this is a reference // Check if this is a reference
bool isReference = length % 2 == 1; bool isReference = length % 2 == 1;
@ -109,7 +108,7 @@ const std::string AMFDeserialize::ReadString(RakNet::BitStream* inStream) {
length = length >> 1; length = length >> 1;
if (isReference) { if (isReference) {
std::string value(length, 0); std::string value(length, 0);
inStream->Read(&value[0], length); inStream.Read(&value[0], length);
// Empty strings are never sent by reference // Empty strings are never sent by reference
if (!value.empty()) accessedElements.push_back(value); if (!value.empty()) accessedElements.push_back(value);
return value; return value;
@ -119,13 +118,13 @@ const std::string AMFDeserialize::ReadString(RakNet::BitStream* inStream) {
} }
} }
AMFBaseValue* AMFDeserialize::ReadAmfDouble(RakNet::BitStream* inStream) { AMFBaseValue* AMFDeserialize::ReadAmfDouble(RakNet::BitStream& inStream) {
double value; double value;
inStream->Read<double>(value); inStream.Read<double>(value);
return new AMFDoubleValue(value); return new AMFDoubleValue(value);
} }
AMFBaseValue* AMFDeserialize::ReadAmfArray(RakNet::BitStream* inStream) { AMFBaseValue* AMFDeserialize::ReadAmfArray(RakNet::BitStream& inStream) {
auto arrayValue = new AMFArrayValue(); auto arrayValue = new AMFArrayValue();
// Read size of dense array // Read size of dense array
@ -144,10 +143,10 @@ AMFBaseValue* AMFDeserialize::ReadAmfArray(RakNet::BitStream* inStream) {
return arrayValue; return arrayValue;
} }
AMFBaseValue* AMFDeserialize::ReadAmfString(RakNet::BitStream* inStream) { AMFBaseValue* AMFDeserialize::ReadAmfString(RakNet::BitStream& inStream) {
return new AMFStringValue(ReadString(inStream)); return new AMFStringValue(ReadString(inStream));
} }
AMFBaseValue* AMFDeserialize::ReadAmfInteger(RakNet::BitStream* inStream) { AMFBaseValue* AMFDeserialize::ReadAmfInteger(RakNet::BitStream& inStream) {
return new AMFIntValue(ReadU29(inStream)); return new AMFIntValue(ReadU29(inStream));
} }

View File

@ -15,7 +15,7 @@ public:
* @param inStream inStream to read value from. * @param inStream inStream to read value from.
* @return Returns an AMFValue with all the information from the bitStream in it. * @return Returns an AMFValue with all the information from the bitStream in it.
*/ */
AMFBaseValue* Read(RakNet::BitStream* inStream); AMFBaseValue* Read(RakNet::BitStream& inStream);
private: private:
/** /**
* @brief Private method to read a U29 integer from a bitstream * @brief Private method to read a U29 integer from a bitstream
@ -23,7 +23,7 @@ private:
* @param inStream bitstream to read data from * @param inStream bitstream to read data from
* @return The number as an unsigned 29 bit integer * @return The number as an unsigned 29 bit integer
*/ */
uint32_t ReadU29(RakNet::BitStream* inStream); uint32_t ReadU29(RakNet::BitStream& inStream);
/** /**
* @brief Reads a string from a bitstream * @brief Reads a string from a bitstream
@ -31,7 +31,7 @@ private:
* @param inStream bitStream to read data from * @param inStream bitStream to read data from
* @return The read string * @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 * @brief Read an AMFDouble value from a bitStream
@ -39,7 +39,7 @@ private:
* @param inStream bitStream to read data from * @param inStream bitStream to read data from
* @return Double value represented as an AMFValue * @return Double value represented as an AMFValue
*/ */
AMFBaseValue* ReadAmfDouble(RakNet::BitStream* inStream); AMFBaseValue* ReadAmfDouble(RakNet::BitStream& inStream);
/** /**
* @brief Read an AMFArray from a bitStream * @brief Read an AMFArray from a bitStream
@ -47,7 +47,7 @@ private:
* @param inStream bitStream to read data from * @param inStream bitStream to read data from
* @return Array value represented as an AMFValue * @return Array value represented as an AMFValue
*/ */
AMFBaseValue* ReadAmfArray(RakNet::BitStream* inStream); AMFBaseValue* ReadAmfArray(RakNet::BitStream& inStream);
/** /**
* @brief Read an AMFString from a bitStream * @brief Read an AMFString from a bitStream
@ -55,7 +55,7 @@ private:
* @param inStream bitStream to read data from * @param inStream bitStream to read data from
* @return String value represented as an AMFValue * @return String value represented as an AMFValue
*/ */
AMFBaseValue* ReadAmfString(RakNet::BitStream* inStream); AMFBaseValue* ReadAmfString(RakNet::BitStream& inStream);
/** /**
* @brief Read an AMFInteger from a bitStream * @brief Read an AMFInteger from a bitStream
@ -63,7 +63,7 @@ private:
* @param inStream bitStream to read data from * @param inStream bitStream to read data from
* @return Integer value represented as an AMFValue * @return Integer value represented as an AMFValue
*/ */
AMFBaseValue* ReadAmfInteger(RakNet::BitStream* inStream); AMFBaseValue* ReadAmfInteger(RakNet::BitStream& inStream);
/** /**
* List of strings read so far saved to be read by reference. * List of strings read so far saved to be read by reference.

View File

@ -278,14 +278,14 @@ std::vector<std::string> GeneralUtils::SplitString(const std::string& str, char
return vector; return vector;
} }
std::u16string GeneralUtils::ReadWString(RakNet::BitStream* inStream) { std::u16string GeneralUtils::ReadWString(RakNet::BitStream& inStream) {
uint32_t length; uint32_t length;
inStream->Read<uint32_t>(length); inStream.Read<uint32_t>(length);
std::u16string string; std::u16string string;
for (auto i = 0; i < length; i++) { for (auto i = 0; i < length; i++) {
uint16_t c; uint16_t c;
inStream->Read(c); inStream.Read(c);
string.push_back(c); string.push_back(c);
} }

View File

@ -116,7 +116,7 @@ namespace GeneralUtils {
bool ReplaceInString(std::string& str, const std::string& from, const std::string& to); 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<std::wstring> SplitString(std::wstring& str, wchar_t delimiter); std::vector<std::wstring> SplitString(std::wstring& str, wchar_t delimiter);

View File

@ -39,7 +39,7 @@
#include "GhostComponent.h" #include "GhostComponent.h"
#include "StringifiedEnum.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; CBITSTREAM;

View File

@ -22,7 +22,7 @@
#include "eGameMessageType.h" #include "eGameMessageType.h"
namespace GameMessageHandler { 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 #endif // GAMEMESSAGEHANDLER_H

File diff suppressed because it is too large Load Diff

View File

@ -146,7 +146,7 @@ namespace GameMessages {
void SendMatchResponse(Entity* entity, const SystemAddress& sysAddr, int response); void SendMatchResponse(Entity* entity, const SystemAddress& sysAddr, int response);
void SendMatchUpdate(Entity* entity, const SystemAddress& sysAddr, std::string data, eMatchUpdate type); 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); void SendStartCelebrationEffect(Entity* entity, const SystemAddress& sysAddr, int celebrationID);
// https://lcdruniverse.org/lu_packets/lu_packets/world/gm/client/struct.SetResurrectRestoreValues.html // https://lcdruniverse.org/lu_packets/lu_packets/world/gm/client/struct.SetResurrectRestoreValues.html
@ -183,7 +183,7 @@ namespace GameMessages {
* @param entity The Entity that sent the message * @param entity The Entity that sent the message
* @param sysAddr The SystemAddress 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 // Rails stuff
void SendSetRailMovement(const LWOOBJID& objectID, bool pathGoForward, std::u16string pathName, uint32_t pathStart, void SendSetRailMovement(const LWOOBJID& objectID, bool pathGoForward, std::u16string pathName, uint32_t pathStart,
@ -197,9 +197,9 @@ namespace GameMessages {
bool collisionEnabled = true, bool useDB = true, int32_t railComponentID = -1, bool collisionEnabled = true, bool useDB = true, int32_t railComponentID = -1,
LWOOBJID railActivatorObjectID = LWOOBJID_EMPTY); LWOOBJID railActivatorObjectID = LWOOBJID_EMPTY);
void HandleClientRailMovementReady(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 HandleCancelRailMovement(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
void HandlePlayerRailArrivedNotification(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 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); void SendNotifyClientZoneObject(const LWOOBJID& objectID, const std::u16string& name, int param1, int param2, const LWOOBJID& paramObj, const std::string& paramStr, const SystemAddress& sysAddr);
@ -252,39 +252,39 @@ namespace GameMessages {
void SendUGCEquipPostDeleteBasedOnEditMode(LWOOBJID objectId, const SystemAddress& sysAddr, LWOOBJID inventoryItem, int itemTotal); 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, void SendPlayCinematic(LWOOBJID objectId, std::u16string pathName, const SystemAddress& sysAddr,
bool allowGhostUpdates = true, bool bCloseMultiInteract = true, bool bSendServerNotify = false, bool bUseControlledObjectForAudioListener = false, bool allowGhostUpdates = true, bool bCloseMultiInteract = true, bool bSendServerNotify = false, bool bUseControlledObjectForAudioListener = false,
@ -293,7 +293,7 @@ namespace GameMessages {
void SendEndCinematic(LWOOBJID objectID, std::u16string pathName, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS, void SendEndCinematic(LWOOBJID objectID, std::u16string pathName, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS,
float leadOut = -1.0f, bool leavePlayerLocked = false); 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, void SendSetStunned(LWOOBJID objectId, eStateChangeType stateChangeType, const SystemAddress& sysAddr,
LWOOBJID originator = LWOOBJID_EMPTY, bool bCantAttack = false, bool bCantEquip = false, LWOOBJID originator = LWOOBJID_EMPTY, bool bCantAttack = false, bool bCantEquip = false,
@ -345,7 +345,7 @@ namespace GameMessages {
void SendNotifyObject(LWOOBJID objectId, LWOOBJID objIDSender, std::u16string name, const SystemAddress& sysAddr, int param1 = 0, int param2 = 0); 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); void SendTeamPickupItem(LWOOBJID objectId, LWOOBJID lootID, LWOOBJID lootOwnerID, const SystemAddress& sysAddr);
@ -362,13 +362,13 @@ namespace GameMessages {
void SendServerTradeUpdate(LWOOBJID objectId, uint64_t coins, const std::vector<TradeItem>& items, const SystemAddress& sysAddr); void SendServerTradeUpdate(LWOOBJID objectId, uint64_t coins, const std::vector<TradeItem>& 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: //Pets:
void SendNotifyPetTamingMinigame(LWOOBJID objectId, LWOOBJID petId, LWOOBJID playerTamingId, bool bForceTeleport, ePetTamingNotifyType notifyType, NiPoint3 petsDestPos, NiPoint3 telePos, NiQuaternion teleRot, const SystemAddress& sysAddr); void SendNotifyPetTamingMinigame(LWOOBJID objectId, LWOOBJID petId, LWOOBJID playerTamingId, bool bForceTeleport, ePetTamingNotifyType notifyType, NiPoint3 petsDestPos, NiPoint3 telePos, NiQuaternion teleRot, const SystemAddress& sysAddr);
@ -403,23 +403,23 @@ namespace GameMessages {
void SendPetNameChanged(LWOOBJID objectId, int32_t moderationStatus, std::u16string name, std::u16string ownerName, const SystemAddress& sysAddr); 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); void SendDisplayZoneSummary(LWOOBJID objectId, const SystemAddress& sysAddr, bool isPropertyMap = false, bool isZoneStart = false, LWOOBJID sender = LWOOBJID_EMPTY);
@ -456,7 +456,7 @@ namespace GameMessages {
* @param entity The Entity that is dismounting * @param entity The Entity that is dismounting
* @param sysAddr the system address to send game message responses to * @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 * @brief Handle acknowledging that the client possessed something
@ -465,7 +465,7 @@ namespace GameMessages {
* @param entity The Entity that is possessing * @param entity The Entity that is possessing
* @param sysAddr the system address to send game message responses to * @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 * @brief A request from a client to get the hot properties that would appear on the news feed
@ -475,7 +475,7 @@ namespace GameMessages {
* @param entity The Entity that sent the request * @param entity The Entity that sent the request
* @param sysAddr The SystemAddress of 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 * @brief A request from a client to get the hot properties that would appear on the news feed
@ -497,26 +497,26 @@ namespace GameMessages {
* @param entity The Entity that sent the request * @param entity The Entity that sent the request
* @param sysAddr The SystemAddress of 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: //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); void SendModuleAssemblyDBDataForClient(LWOOBJID objectId, LWOOBJID assemblyID, const std::u16string& data, const SystemAddress& sysAddr);
@ -556,7 +556,7 @@ namespace GameMessages {
bool bUseLeaderboards 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, void SendNotifyClientShootingGalleryScore(LWOOBJID objectId, const SystemAddress& sysAddr,
float addTime, float addTime,
@ -565,20 +565,20 @@ namespace GameMessages {
NiPoint3 targetPos 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); void SendUpdateReputation(const LWOOBJID objectId, const int64_t reputation, const SystemAddress& sysAddr);
// Leaderboards // Leaderboards
void SendActivitySummaryLeaderboardData(const LWOOBJID& objectID, const Leaderboard* leaderboard, void SendActivitySummaryLeaderboardData(const LWOOBJID& objectID, const Leaderboard* leaderboard,
const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS); 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, void SendRequestActivitySummaryLeaderboardData(const LWOOBJID& objectID, const LWOOBJID& targetID,
const SystemAddress& sysAddr, const int32_t& gameID = 0, const SystemAddress& sysAddr, const int32_t& gameID = 0,
const int32_t& queryType = 1, const int32_t& resultsEnd = 10, const int32_t& queryType = 1, const int32_t& resultsEnd = 10,
const int32_t& resultsStart = 0, bool weekly = false); const int32_t& resultsStart = 0, bool weekly = false);
void HandleRequestActivitySummaryLeaderboardData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); void HandleRequestActivitySummaryLeaderboardData(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
void HandleActivityStateChangeRequest(RakNet::BitStream* inStream, Entity* entity); void HandleActivityStateChangeRequest(RakNet::BitStream& inStream, Entity* entity);
void SendVehicleAddPassiveBoostAction(LWOOBJID objectId, const SystemAddress& sysAddr); void SendVehicleAddPassiveBoostAction(LWOOBJID objectId, const SystemAddress& sysAddr);
@ -588,82 +588,82 @@ namespace GameMessages {
//NT: //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); void SendShowActivityCountdown(LWOOBJID objectId, bool bPlayAdditionalSound, bool bPlayCountdownSound, std::u16string sndName, int32_t stateToPlaySoundOn, const SystemAddress& sysAddr);
//Handlers: //Handlers:
void HandleToggleGhostReferenceOverride(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 HandleSetGhostReferencePosition(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
void SendSetNamebillboardState(const SystemAddress& sysAddr, LWOOBJID objectId); void SendSetNamebillboardState(const SystemAddress& sysAddr, LWOOBJID objectId);
void SendShowBillboardInteractIcon(const SystemAddress& sysAddr, LWOOBJID objectId); void SendShowBillboardInteractIcon(const SystemAddress& sysAddr, LWOOBJID objectId);
void HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); void HandleBuyFromVendor(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
void HandleSellToVendor(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 HandleBuybackFromVendor(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
void HandleParseChatMessage(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 HandleToggleGhostReffrenceOverride(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
void HandleSetGhostReffrenceOverride(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 HandleFireEventServerSide(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
void HandleRequestPlatformResync(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 HandleQuickBuildCancel(RakNet::BitStream& inStream, Entity* entity);
void HandleRequestUse(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); void HandleRequestUse(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
void HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity); void HandlePlayEmote(RakNet::BitStream& inStream, Entity* entity);
void HandleModularBuildConvertModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); void HandleModularBuildConvertModel(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
void HandleSetFlag(RakNet::BitStream* inStream, Entity* entity); void HandleSetFlag(RakNet::BitStream& inStream, Entity* entity);
void HandleRespondToMission(RakNet::BitStream* inStream, Entity* entity); void HandleRespondToMission(RakNet::BitStream& inStream, Entity* entity);
void HandleMissionDialogOK(RakNet::BitStream* inStream, Entity* entity); void HandleMissionDialogOK(RakNet::BitStream& inStream, Entity* entity);
void HandleRequestLinkedMission(RakNet::BitStream* inStream, Entity* entity); void HandleRequestLinkedMission(RakNet::BitStream& inStream, Entity* entity);
void HandleHasBeenCollected(RakNet::BitStream* inStream, Entity* entity); void HandleHasBeenCollected(RakNet::BitStream& inStream, Entity* entity);
void HandleNotifyServerLevelProcessingComplete(RakNet::BitStream* inStream, Entity* entity); void HandleNotifyServerLevelProcessingComplete(RakNet::BitStream& inStream, Entity* entity);
void HandlePickupCurrency(RakNet::BitStream* inStream, Entity* entity); void HandlePickupCurrency(RakNet::BitStream& inStream, Entity* entity);
void HandleRequestDie(RakNet::BitStream* inStream, Entity* entity); void HandleRequestDie(RakNet::BitStream& inStream, Entity* entity);
void HandleEquipItem(RakNet::BitStream* inStream, Entity* entity); void HandleEquipItem(RakNet::BitStream& inStream, Entity* entity);
void HandleUnequipItem(RakNet::BitStream* inStream, Entity* entity); void HandleUnequipItem(RakNet::BitStream& inStream, Entity* entity);
void HandleRemoveItemFromInventory(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); void HandleRemoveItemFromInventory(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
void HandleMoveItemInInventory(RakNet::BitStream* inStream, Entity* entity); void HandleMoveItemInInventory(RakNet::BitStream& inStream, Entity* entity);
void HandleMoveItemBetweenInventoryTypes(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); void HandleMoveItemBetweenInventoryTypes(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
void HandleBuildModeSet(RakNet::BitStream* inStream, Entity* entity); void HandleBuildModeSet(RakNet::BitStream& inStream, Entity* entity);
void HandleModularBuildFinish(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); void HandleModularBuildFinish(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
void HandleDoneArrangingWithItem(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 HandleModularBuildMoveAndEquip(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
void HandlePickupItem(RakNet::BitStream* inStream, Entity* entity); void HandlePickupItem(RakNet::BitStream& inStream, Entity* entity);
void HandleResurrect(RakNet::BitStream* inStream, Entity* entity); void HandleResurrect(RakNet::BitStream& inStream, Entity* entity);
void HandleModifyPlayerZoneStatistic(RakNet::BitStream* inStream, Entity* entity); void HandleModifyPlayerZoneStatistic(RakNet::BitStream& inStream, Entity* entity);
void HandleUpdatePlayerStatistic(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); void SendRemoveBuff(Entity* entity, bool fromUnEquip, bool removeImmunity, uint32_t buffId);
// bubble // 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 SendActivateBubbleBuffFromServer(LWOOBJID objectId, const SystemAddress& sysAddr);
void SendDeactivateBubbleBuffFromServer(LWOOBJID objectId, const SystemAddress& sysAddr); void SendDeactivateBubbleBuffFromServer(LWOOBJID objectId, const SystemAddress& sysAddr);
void HandleZoneSummaryDismissed(RakNet::BitStream* inStream, Entity* entity); void HandleZoneSummaryDismissed(RakNet::BitStream& inStream, Entity* entity);
void HandleRequestActivityExit(RakNet::BitStream* inStream, Entity* entity); void HandleRequestActivityExit(RakNet::BitStream& inStream, Entity* entity);
// Donation vendor // Donation vendor
void HandleAddDonationItem(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); void HandleAddDonationItem(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
void HandleRemoveDonationItem(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 HandleConfirmDonationOnPlayer(RakNet::BitStream& inStream, Entity* entity);
void HandleCancelDonationOnPlayer(RakNet::BitStream* inStream, Entity* entity); void HandleCancelDonationOnPlayer(RakNet::BitStream& inStream, Entity* entity);
}; };
#endif // GAMEMESSAGES_H #endif // GAMEMESSAGES_H

View File

@ -19,44 +19,44 @@ public:
sBitStream = _sBitStream; sBitStream = _sBitStream;
} }
RequestServerProjectileImpact(RakNet::BitStream* stream) : RequestServerProjectileImpact() { RequestServerProjectileImpact(RakNet::BitStream& stream) : RequestServerProjectileImpact() {
Deserialize(stream); Deserialize(stream);
} }
~RequestServerProjectileImpact() { ~RequestServerProjectileImpact() {
} }
void Serialize(RakNet::BitStream* stream) { void Serialize(RakNet::BitStream& stream) {
stream->Write(eGameMessageType::REQUEST_SERVER_PROJECTILE_IMPACT); stream.Write(eGameMessageType::REQUEST_SERVER_PROJECTILE_IMPACT);
stream->Write(i64LocalID != LWOOBJID_EMPTY); stream.Write(i64LocalID != LWOOBJID_EMPTY);
if (i64LocalID != LWOOBJID_EMPTY) stream->Write(i64LocalID); if (i64LocalID != LWOOBJID_EMPTY) stream.Write(i64LocalID);
stream->Write(i64TargetID != LWOOBJID_EMPTY); stream.Write(i64TargetID != LWOOBJID_EMPTY);
if (i64TargetID != LWOOBJID_EMPTY) stream->Write(i64TargetID); if (i64TargetID != LWOOBJID_EMPTY) stream.Write(i64TargetID);
uint32_t sBitStreamLength = sBitStream.length(); uint32_t sBitStreamLength = sBitStream.length();
stream->Write(sBitStreamLength); stream.Write(sBitStreamLength);
for (uint32_t k = 0; k < sBitStreamLength; k++) { 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{}; bool i64LocalIDIsDefault{};
stream->Read(i64LocalIDIsDefault); stream.Read(i64LocalIDIsDefault);
if (i64LocalIDIsDefault != 0) stream->Read(i64LocalID); if (i64LocalIDIsDefault != 0) stream.Read(i64LocalID);
bool i64TargetIDIsDefault{}; bool i64TargetIDIsDefault{};
stream->Read(i64TargetIDIsDefault); stream.Read(i64TargetIDIsDefault);
if (i64TargetIDIsDefault != 0) stream->Read(i64TargetID); if (i64TargetIDIsDefault != 0) stream.Read(i64TargetID);
uint32_t sBitStreamLength{}; uint32_t sBitStreamLength{};
stream->Read(sBitStreamLength); stream.Read(sBitStreamLength);
for (uint32_t k = 0; k < sBitStreamLength; k++) { for (uint32_t k = 0; k < sBitStreamLength; k++) {
unsigned char character; unsigned char character;
stream->Read(character); stream.Read(character);
sBitStream.push_back(character); sBitStream.push_back(character);
} }

View File

@ -36,92 +36,92 @@ public:
uiSkillHandle = _uiSkillHandle; uiSkillHandle = _uiSkillHandle;
} }
StartSkill(RakNet::BitStream* stream) : StartSkill() { StartSkill(RakNet::BitStream& stream) : StartSkill() {
Deserialize(stream); Deserialize(stream);
} }
~StartSkill() { ~StartSkill() {
} }
void Serialize(RakNet::BitStream* stream) { void Serialize(RakNet::BitStream& stream) {
stream->Write(eGameMessageType::START_SKILL); stream.Write(eGameMessageType::START_SKILL);
stream->Write(bUsedMouse); stream.Write(bUsedMouse);
stream->Write(consumableItemID != LWOOBJID_EMPTY); stream.Write(consumableItemID != LWOOBJID_EMPTY);
if (consumableItemID != LWOOBJID_EMPTY) stream->Write(consumableItemID); if (consumableItemID != LWOOBJID_EMPTY) stream.Write(consumableItemID);
stream->Write(fCasterLatency != 0.0f); stream.Write(fCasterLatency != 0.0f);
if (fCasterLatency != 0.0f) stream->Write(fCasterLatency); if (fCasterLatency != 0.0f) stream.Write(fCasterLatency);
stream->Write(iCastType != 0); stream.Write(iCastType != 0);
if (iCastType != 0) stream->Write(iCastType); if (iCastType != 0) stream.Write(iCastType);
stream->Write(lastClickedPosit != NiPoint3Constant::ZERO); stream.Write(lastClickedPosit != NiPoint3Constant::ZERO);
if (lastClickedPosit != NiPoint3Constant::ZERO) stream->Write(lastClickedPosit); if (lastClickedPosit != NiPoint3Constant::ZERO) stream.Write(lastClickedPosit);
stream->Write(optionalOriginatorID); stream.Write(optionalOriginatorID);
stream->Write(optionalTargetID != LWOOBJID_EMPTY); stream.Write(optionalTargetID != LWOOBJID_EMPTY);
if (optionalTargetID != LWOOBJID_EMPTY) stream->Write(optionalTargetID); if (optionalTargetID != LWOOBJID_EMPTY) stream.Write(optionalTargetID);
stream->Write(originatorRot != NiQuaternionConstant::IDENTITY); stream.Write(originatorRot != NiQuaternionConstant::IDENTITY);
if (originatorRot != NiQuaternionConstant::IDENTITY) stream->Write(originatorRot); if (originatorRot != NiQuaternionConstant::IDENTITY) stream.Write(originatorRot);
uint32_t sBitStreamLength = sBitStream.length(); uint32_t sBitStreamLength = sBitStream.length();
stream->Write(sBitStreamLength); stream.Write(sBitStreamLength);
for (uint32_t k = 0; k < sBitStreamLength; k++) { 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); stream.Write(uiSkillHandle != 0);
if (uiSkillHandle != 0) stream->Write(uiSkillHandle); if (uiSkillHandle != 0) stream.Write(uiSkillHandle);
} }
bool Deserialize(RakNet::BitStream* stream) { bool Deserialize(RakNet::BitStream& stream) {
stream->Read(bUsedMouse); stream.Read(bUsedMouse);
bool consumableItemIDIsDefault{}; bool consumableItemIDIsDefault{};
stream->Read(consumableItemIDIsDefault); stream.Read(consumableItemIDIsDefault);
if (consumableItemIDIsDefault != 0) stream->Read(consumableItemID); if (consumableItemIDIsDefault != 0) stream.Read(consumableItemID);
bool fCasterLatencyIsDefault{}; bool fCasterLatencyIsDefault{};
stream->Read(fCasterLatencyIsDefault); stream.Read(fCasterLatencyIsDefault);
if (fCasterLatencyIsDefault != 0) stream->Read(fCasterLatency); if (fCasterLatencyIsDefault != 0) stream.Read(fCasterLatency);
bool iCastTypeIsDefault{}; bool iCastTypeIsDefault{};
stream->Read(iCastTypeIsDefault); stream.Read(iCastTypeIsDefault);
if (iCastTypeIsDefault != 0) stream->Read(iCastType); if (iCastTypeIsDefault != 0) stream.Read(iCastType);
bool lastClickedPositIsDefault{}; bool lastClickedPositIsDefault{};
stream->Read(lastClickedPositIsDefault); stream.Read(lastClickedPositIsDefault);
if (lastClickedPositIsDefault != 0) stream->Read(lastClickedPosit); if (lastClickedPositIsDefault != 0) stream.Read(lastClickedPosit);
stream->Read(optionalOriginatorID); stream.Read(optionalOriginatorID);
bool optionalTargetIDIsDefault{}; bool optionalTargetIDIsDefault{};
stream->Read(optionalTargetIDIsDefault); stream.Read(optionalTargetIDIsDefault);
if (optionalTargetIDIsDefault != 0) stream->Read(optionalTargetID); if (optionalTargetIDIsDefault != 0) stream.Read(optionalTargetID);
bool originatorRotIsDefault{}; bool originatorRotIsDefault{};
stream->Read(originatorRotIsDefault); stream.Read(originatorRotIsDefault);
if (originatorRotIsDefault != 0) stream->Read(originatorRot); if (originatorRotIsDefault != 0) stream.Read(originatorRot);
uint32_t sBitStreamLength{}; uint32_t sBitStreamLength{};
stream->Read(sBitStreamLength); stream.Read(sBitStreamLength);
for (uint32_t k = 0; k < sBitStreamLength; k++) { for (uint32_t k = 0; k < sBitStreamLength; k++) {
unsigned char character; unsigned char character;
stream->Read(character); stream.Read(character);
sBitStream.push_back(character); sBitStream.push_back(character);
} }
stream->Read(skillID); stream.Read(skillID);
bool uiSkillHandleIsDefault{}; bool uiSkillHandleIsDefault{};
stream->Read(uiSkillHandleIsDefault); stream.Read(uiSkillHandleIsDefault);
if (uiSkillHandleIsDefault != 0) stream->Read(uiSkillHandle); if (uiSkillHandleIsDefault != 0) stream.Read(uiSkillHandle);
return true; return true;
} }

View File

@ -21,39 +21,39 @@ public:
uiSkillHandle = _uiSkillHandle; uiSkillHandle = _uiSkillHandle;
} }
SyncSkill(RakNet::BitStream* stream) : SyncSkill() { SyncSkill(RakNet::BitStream& stream) : SyncSkill() {
Deserialize(stream); Deserialize(stream);
} }
~SyncSkill() { ~SyncSkill() {
} }
void Serialize(RakNet::BitStream* stream) { void Serialize(RakNet::BitStream& stream) {
stream->Write(eGameMessageType::SYNC_SKILL); stream.Write(eGameMessageType::SYNC_SKILL);
stream->Write(bDone); stream.Write(bDone);
uint32_t sBitStreamLength = sBitStream.length(); uint32_t sBitStreamLength = sBitStream.length();
stream->Write(sBitStreamLength); stream.Write(sBitStreamLength);
for (unsigned int k = 0; k < sBitStreamLength; k++) { for (unsigned int k = 0; k < sBitStreamLength; k++) {
stream->Write(sBitStream[k]); stream.Write(sBitStream[k]);
} }
stream->Write(uiBehaviorHandle); stream.Write(uiBehaviorHandle);
stream->Write(uiSkillHandle); stream.Write(uiSkillHandle);
} }
bool Deserialize(RakNet::BitStream* stream) { bool Deserialize(RakNet::BitStream& stream) {
stream->Read(bDone); stream.Read(bDone);
uint32_t sBitStreamLength{}; uint32_t sBitStreamLength{};
stream->Read(sBitStreamLength); stream.Read(sBitStreamLength);
for (uint32_t k = 0; k < sBitStreamLength; k++) { for (uint32_t k = 0; k < sBitStreamLength; k++) {
unsigned char character; unsigned char character;
stream->Read(character); stream.Read(character);
sBitStream.push_back(character); sBitStream.push_back(character);
} }
stream->Read(uiBehaviorHandle); stream.Read(uiBehaviorHandle);
stream->Read(uiSkillHandle); stream.Read(uiSkillHandle);
return true; return true;
} }

View File

@ -950,7 +950,7 @@ void HandlePacket(Packet* packet) {
static_cast<int32_t>(messageID) static_cast<int32_t>(messageID)
); );
if (isSender) GameMessageHandler::HandleMessage(&dataStream, packet->systemAddress, objectID, messageID); if (isSender) GameMessageHandler::HandleMessage(dataStream, packet->systemAddress, objectID, messageID);
break; break;
} }

View File

@ -11,7 +11,7 @@
/** /**
* Helper method that all tests use to get their respective AMF. * Helper method that all tests use to get their respective AMF.
*/ */
AMFBaseValue* ReadFromBitStream(RakNet::BitStream* bitStream) { AMFBaseValue* ReadFromBitStream(RakNet::BitStream& bitStream) {
AMFDeserialize deserializer; AMFDeserialize deserializer;
AMFBaseValue* returnValue(deserializer.Read(bitStream)); AMFBaseValue* returnValue(deserializer.Read(bitStream));
return returnValue; return returnValue;
@ -23,7 +23,7 @@ AMFBaseValue* ReadFromBitStream(RakNet::BitStream* bitStream) {
TEST(dCommonTests, AMFDeserializeAMFUndefinedTest) { TEST(dCommonTests, AMFDeserializeAMFUndefinedTest) {
CBITSTREAM; CBITSTREAM;
bitStream.Write<uint8_t>(0x00); bitStream.Write<uint8_t>(0x00);
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(&bitStream)); std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
ASSERT_EQ(res->GetValueType(), eAmf::Undefined); ASSERT_EQ(res->GetValueType(), eAmf::Undefined);
} }
@ -34,7 +34,7 @@ TEST(dCommonTests, AMFDeserializeAMFUndefinedTest) {
TEST(dCommonTests, AMFDeserializeAMFNullTest) { TEST(dCommonTests, AMFDeserializeAMFNullTest) {
CBITSTREAM; CBITSTREAM;
bitStream.Write<uint8_t>(0x01); bitStream.Write<uint8_t>(0x01);
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(&bitStream)); std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
ASSERT_EQ(res->GetValueType(), eAmf::Null); ASSERT_EQ(res->GetValueType(), eAmf::Null);
} }
@ -44,7 +44,7 @@ TEST(dCommonTests, AMFDeserializeAMFNullTest) {
TEST(dCommonTests, AMFDeserializeAMFFalseTest) { TEST(dCommonTests, AMFDeserializeAMFFalseTest) {
CBITSTREAM; CBITSTREAM;
bitStream.Write<uint8_t>(0x02); bitStream.Write<uint8_t>(0x02);
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(&bitStream)); std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
ASSERT_EQ(res->GetValueType(), eAmf::False); ASSERT_EQ(res->GetValueType(), eAmf::False);
} }
@ -54,7 +54,7 @@ TEST(dCommonTests, AMFDeserializeAMFFalseTest) {
TEST(dCommonTests, AMFDeserializeAMFTrueTest) { TEST(dCommonTests, AMFDeserializeAMFTrueTest) {
CBITSTREAM; CBITSTREAM;
bitStream.Write<uint8_t>(0x03); bitStream.Write<uint8_t>(0x03);
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(&bitStream)); std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
ASSERT_EQ(res->GetValueType(), eAmf::True); ASSERT_EQ(res->GetValueType(), eAmf::True);
} }
@ -67,7 +67,7 @@ TEST(dCommonTests, AMFDeserializeAMFIntegerTest) {
bitStream.Write<uint8_t>(0x04); bitStream.Write<uint8_t>(0x04);
// 127 == 01111111 // 127 == 01111111
bitStream.Write<uint8_t>(127); bitStream.Write<uint8_t>(127);
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(&bitStream)); std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
ASSERT_EQ(res->GetValueType(), eAmf::Integer); ASSERT_EQ(res->GetValueType(), eAmf::Integer);
// Check that the max value of a byte can be read correctly // Check that the max value of a byte can be read correctly
ASSERT_EQ(static_cast<AMFIntValue*>(res.get())->GetValue(), 127); ASSERT_EQ(static_cast<AMFIntValue*>(res.get())->GetValue(), 127);
@ -76,7 +76,7 @@ TEST(dCommonTests, AMFDeserializeAMFIntegerTest) {
{ {
bitStream.Write<uint8_t>(0x04); bitStream.Write<uint8_t>(0x04);
bitStream.Write<uint32_t>(UINT32_MAX); bitStream.Write<uint32_t>(UINT32_MAX);
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(&bitStream)); std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
ASSERT_EQ(res->GetValueType(), eAmf::Integer); ASSERT_EQ(res->GetValueType(), eAmf::Integer);
// Check that we can read the maximum value correctly // Check that we can read the maximum value correctly
ASSERT_EQ(static_cast<AMFIntValue*>(res.get())->GetValue(), 536870911); ASSERT_EQ(static_cast<AMFIntValue*>(res.get())->GetValue(), 536870911);
@ -90,7 +90,7 @@ TEST(dCommonTests, AMFDeserializeAMFIntegerTest) {
bitStream.Write<uint8_t>(255); bitStream.Write<uint8_t>(255);
// 127 == 01111111 // 127 == 01111111
bitStream.Write<uint8_t>(127); bitStream.Write<uint8_t>(127);
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(&bitStream)); std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
ASSERT_EQ(res->GetValueType(), eAmf::Integer); ASSERT_EQ(res->GetValueType(), eAmf::Integer);
// Check that short max can be read correctly // Check that short max can be read correctly
ASSERT_EQ(static_cast<AMFIntValue*>(res.get())->GetValue(), UINT16_MAX); ASSERT_EQ(static_cast<AMFIntValue*>(res.get())->GetValue(), UINT16_MAX);
@ -102,7 +102,7 @@ TEST(dCommonTests, AMFDeserializeAMFIntegerTest) {
bitStream.Write<uint8_t>(255); bitStream.Write<uint8_t>(255);
// 127 == 01111111 // 127 == 01111111
bitStream.Write<uint8_t>(127); bitStream.Write<uint8_t>(127);
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(&bitStream)); std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
ASSERT_EQ(res->GetValueType(), eAmf::Integer); ASSERT_EQ(res->GetValueType(), eAmf::Integer);
// Check that 2 byte max can be read correctly // Check that 2 byte max can be read correctly
ASSERT_EQ(static_cast<AMFIntValue*>(res.get())->GetValue(), 16383); ASSERT_EQ(static_cast<AMFIntValue*>(res.get())->GetValue(), 16383);
@ -116,7 +116,7 @@ TEST(dCommonTests, AMFDeserializeAMFDoubleTest) {
CBITSTREAM; CBITSTREAM;
bitStream.Write<uint8_t>(0x05); bitStream.Write<uint8_t>(0x05);
bitStream.Write<double>(25346.4f); bitStream.Write<double>(25346.4f);
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(&bitStream)); std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
ASSERT_EQ(res->GetValueType(), eAmf::Double); ASSERT_EQ(res->GetValueType(), eAmf::Double);
ASSERT_EQ(static_cast<AMFDoubleValue*>(res.get())->GetValue(), 25346.4f); ASSERT_EQ(static_cast<AMFDoubleValue*>(res.get())->GetValue(), 25346.4f);
} }
@ -130,7 +130,7 @@ TEST(dCommonTests, AMFDeserializeAMFStringTest) {
bitStream.Write<uint8_t>(0x0F); bitStream.Write<uint8_t>(0x0F);
std::string toWrite = "stateID"; std::string toWrite = "stateID";
for (auto e : toWrite) bitStream.Write<char>(e); for (auto e : toWrite) bitStream.Write<char>(e);
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(&bitStream)); std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
ASSERT_EQ(res->GetValueType(), eAmf::String); ASSERT_EQ(res->GetValueType(), eAmf::String);
ASSERT_EQ(static_cast<AMFStringValue*>(res.get())->GetValue(), "stateID"); ASSERT_EQ(static_cast<AMFStringValue*>(res.get())->GetValue(), "stateID");
} }
@ -145,7 +145,7 @@ TEST(dCommonTests, AMFDeserializeAMFArrayTest) {
bitStream.Write<uint8_t>(0x01); bitStream.Write<uint8_t>(0x01);
bitStream.Write<uint8_t>(0x01); bitStream.Write<uint8_t>(0x01);
{ {
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(&bitStream)); std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
ASSERT_EQ(res->GetValueType(), eAmf::Array); ASSERT_EQ(res->GetValueType(), eAmf::Array);
ASSERT_EQ(static_cast<AMFArrayValue*>(res.get())->GetAssociative().size(), 0); ASSERT_EQ(static_cast<AMFArrayValue*>(res.get())->GetAssociative().size(), 0);
ASSERT_EQ(static_cast<AMFArrayValue*>(res.get())->GetDense().size(), 0); ASSERT_EQ(static_cast<AMFArrayValue*>(res.get())->GetDense().size(), 0);
@ -164,7 +164,7 @@ TEST(dCommonTests, AMFDeserializeAMFArrayTest) {
bitStream.Write<uint8_t>(0x0B); bitStream.Write<uint8_t>(0x0B);
for (auto e : "10447") if (e != '\0') bitStream.Write<char>(e); for (auto e : "10447") if (e != '\0') bitStream.Write<char>(e);
{ {
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(&bitStream)); std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
ASSERT_EQ(res->GetValueType(), eAmf::Array); ASSERT_EQ(res->GetValueType(), eAmf::Array);
ASSERT_EQ(static_cast<AMFArrayValue*>(res.get())->GetAssociative().size(), 1); ASSERT_EQ(static_cast<AMFArrayValue*>(res.get())->GetAssociative().size(), 1);
ASSERT_EQ(static_cast<AMFArrayValue*>(res.get())->GetDense().size(), 1); ASSERT_EQ(static_cast<AMFArrayValue*>(res.get())->GetDense().size(), 1);
@ -213,7 +213,7 @@ TEST(dCommonTests, AMFDeserializeUnimplementedValuesTest) {
testBitStream.Write(value); testBitStream.Write(value);
bool caughtException = false; bool caughtException = false;
try { try {
ReadFromBitStream(&testBitStream); ReadFromBitStream(testBitStream);
} catch (eAmf unimplementedValueType) { } catch (eAmf unimplementedValueType) {
caughtException = true; caughtException = true;
} }
@ -238,7 +238,7 @@ TEST(dCommonTests, AMFDeserializeLivePacketTest) {
testFileStream.close(); testFileStream.close();
std::unique_ptr<AMFBaseValue> resultFromFn(ReadFromBitStream(&testBitStream)); std::unique_ptr<AMFBaseValue> resultFromFn(ReadFromBitStream(testBitStream));
auto result = static_cast<AMFArrayValue*>(resultFromFn.get()); auto result = static_cast<AMFArrayValue*>(resultFromFn.get());
// Test the outermost array // Test the outermost array
@ -343,14 +343,6 @@ TEST(dCommonTests, AMFDeserializeLivePacketTest) {
ASSERT_EQ(thirdDistance->GetValue(), 25.0f); ASSERT_EQ(thirdDistance->GetValue(), 25.0f);
} }
/**
* @brief Tests that having no BitStream returns a nullptr.
*/
TEST(dCommonTests, AMFDeserializeNullTest) {
std::unique_ptr<AMFBaseValue> result(ReadFromBitStream(nullptr));
ASSERT_EQ(result.get(), nullptr);
}
TEST(dCommonTests, AMFBadConversionTest) { TEST(dCommonTests, AMFBadConversionTest) {
std::ifstream testFileStream; std::ifstream testFileStream;
testFileStream.open("AMFBitStreamTest.bin", std::ios::binary); testFileStream.open("AMFBitStreamTest.bin", std::ios::binary);
@ -364,7 +356,7 @@ TEST(dCommonTests, AMFBadConversionTest) {
testFileStream.close(); testFileStream.close();
std::unique_ptr<AMFBaseValue> resultFromFn(ReadFromBitStream(&testBitStream)); std::unique_ptr<AMFBaseValue> resultFromFn(ReadFromBitStream(testBitStream));
auto result = static_cast<AMFArrayValue*>(resultFromFn.get()); auto result = static_cast<AMFArrayValue*>(resultFromFn.get());
// Actually a string value. // Actually a string value.

View File

@ -38,7 +38,7 @@ protected:
} }
return readFile; return readFile;
} }
AMFArrayValue* ReadArrayFromBitStream(RakNet::BitStream* inStream) { AMFArrayValue* ReadArrayFromBitStream(RakNet::BitStream& inStream) {
AMFDeserialize des; AMFDeserialize des;
AMFBaseValue* readArray = des.Read(inStream); AMFBaseValue* readArray = des.Read(inStream);
EXPECT_EQ(readArray->GetValueType(), eAmf::Array); EXPECT_EQ(readArray->GetValueType(), eAmf::Array);
@ -88,7 +88,7 @@ TEST_F(GameMessageTests, SendBlueprintLoadItemResponse) {
TEST_F(GameMessageTests, ControlBehaviorAddStrip) { TEST_F(GameMessageTests, ControlBehaviorAddStrip) {
auto data = ReadFromFile("addStrip"); auto data = ReadFromFile("addStrip");
RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true);
AddStripMessage addStrip(ReadArrayFromBitStream(&inStream)); AddStripMessage addStrip(ReadArrayFromBitStream(inStream));
ASSERT_FLOAT_EQ(addStrip.GetPosition().GetX(), 50.65); ASSERT_FLOAT_EQ(addStrip.GetPosition().GetX(), 50.65);
ASSERT_FLOAT_EQ(addStrip.GetPosition().GetY(), 178.05); ASSERT_FLOAT_EQ(addStrip.GetPosition().GetY(), 178.05);
ASSERT_EQ(addStrip.GetActionContext().GetStripId(), 0); ASSERT_EQ(addStrip.GetActionContext().GetStripId(), 0);
@ -103,7 +103,7 @@ TEST_F(GameMessageTests, ControlBehaviorAddStrip) {
TEST_F(GameMessageTests, ControlBehaviorRemoveStrip) { TEST_F(GameMessageTests, ControlBehaviorRemoveStrip) {
auto data = ReadFromFile("removeStrip"); auto data = ReadFromFile("removeStrip");
RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true);
RemoveStripMessage removeStrip(ReadArrayFromBitStream(&inStream)); RemoveStripMessage removeStrip(ReadArrayFromBitStream(inStream));
ASSERT_EQ(static_cast<int32_t>(removeStrip.GetActionContext().GetStripId()), 1); ASSERT_EQ(static_cast<int32_t>(removeStrip.GetActionContext().GetStripId()), 1);
ASSERT_EQ(static_cast<int32_t>(removeStrip.GetActionContext().GetStateId()), 0); ASSERT_EQ(static_cast<int32_t>(removeStrip.GetActionContext().GetStateId()), 0);
ASSERT_EQ(removeStrip.GetBehaviorId(), -1); ASSERT_EQ(removeStrip.GetBehaviorId(), -1);
@ -112,7 +112,7 @@ TEST_F(GameMessageTests, ControlBehaviorRemoveStrip) {
TEST_F(GameMessageTests, ControlBehaviorMergeStrips) { TEST_F(GameMessageTests, ControlBehaviorMergeStrips) {
auto data = ReadFromFile("mergeStrips"); auto data = ReadFromFile("mergeStrips");
RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true);
MergeStripsMessage mergeStrips(ReadArrayFromBitStream(&inStream)); MergeStripsMessage mergeStrips(ReadArrayFromBitStream(inStream));
ASSERT_EQ(mergeStrips.GetSourceActionContext().GetStripId(), 2); ASSERT_EQ(mergeStrips.GetSourceActionContext().GetStripId(), 2);
ASSERT_EQ(mergeStrips.GetDestinationActionContext().GetStripId(), 0); ASSERT_EQ(mergeStrips.GetDestinationActionContext().GetStripId(), 0);
ASSERT_EQ(static_cast<uint32_t>(mergeStrips.GetSourceActionContext().GetStateId()), 0); ASSERT_EQ(static_cast<uint32_t>(mergeStrips.GetSourceActionContext().GetStateId()), 0);
@ -124,7 +124,7 @@ TEST_F(GameMessageTests, ControlBehaviorMergeStrips) {
TEST_F(GameMessageTests, ControlBehaviorSplitStrip) { TEST_F(GameMessageTests, ControlBehaviorSplitStrip) {
auto data = ReadFromFile("splitStrip"); auto data = ReadFromFile("splitStrip");
RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true);
SplitStripMessage splitStrip(ReadArrayFromBitStream(&inStream)); SplitStripMessage splitStrip(ReadArrayFromBitStream(inStream));
ASSERT_EQ(splitStrip.GetBehaviorId(), -1); ASSERT_EQ(splitStrip.GetBehaviorId(), -1);
ASSERT_FLOAT_EQ(splitStrip.GetPosition().GetX(), 275.65); ASSERT_FLOAT_EQ(splitStrip.GetPosition().GetX(), 275.65);
@ -139,7 +139,7 @@ TEST_F(GameMessageTests, ControlBehaviorSplitStrip) {
TEST_F(GameMessageTests, ControlBehaviorUpdateStripUI) { TEST_F(GameMessageTests, ControlBehaviorUpdateStripUI) {
auto data = ReadFromFile("updateStripUI"); auto data = ReadFromFile("updateStripUI");
RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true);
UpdateStripUiMessage updateStripUi(ReadArrayFromBitStream(&inStream)); UpdateStripUiMessage updateStripUi(ReadArrayFromBitStream(inStream));
ASSERT_FLOAT_EQ(updateStripUi.GetPosition().GetX(), 116.65); ASSERT_FLOAT_EQ(updateStripUi.GetPosition().GetX(), 116.65);
ASSERT_FLOAT_EQ(updateStripUi.GetPosition().GetY(), 35.35); ASSERT_FLOAT_EQ(updateStripUi.GetPosition().GetY(), 35.35);
ASSERT_EQ(updateStripUi.GetActionContext().GetStripId(), 0); ASSERT_EQ(updateStripUi.GetActionContext().GetStripId(), 0);
@ -150,7 +150,7 @@ TEST_F(GameMessageTests, ControlBehaviorUpdateStripUI) {
TEST_F(GameMessageTests, ControlBehaviorAddAction) { TEST_F(GameMessageTests, ControlBehaviorAddAction) {
auto data = ReadFromFile("addAction"); auto data = ReadFromFile("addAction");
RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true);
AddActionMessage addAction(ReadArrayFromBitStream(&inStream)); AddActionMessage addAction(ReadArrayFromBitStream(inStream));
ASSERT_EQ(addAction.GetActionIndex(), 3); ASSERT_EQ(addAction.GetActionIndex(), 3);
ASSERT_EQ(addAction.GetActionContext().GetStripId(), 0); ASSERT_EQ(addAction.GetActionContext().GetStripId(), 0);
ASSERT_EQ(static_cast<uint32_t>(addAction.GetActionContext().GetStateId()), 0); ASSERT_EQ(static_cast<uint32_t>(addAction.GetActionContext().GetStateId()), 0);
@ -164,7 +164,7 @@ TEST_F(GameMessageTests, ControlBehaviorAddAction) {
TEST_F(GameMessageTests, ControlBehaviorMigrateActions) { TEST_F(GameMessageTests, ControlBehaviorMigrateActions) {
auto data = ReadFromFile("migrateActions"); auto data = ReadFromFile("migrateActions");
RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true);
MigrateActionsMessage migrateActions(ReadArrayFromBitStream(&inStream)); MigrateActionsMessage migrateActions(ReadArrayFromBitStream(inStream));
ASSERT_EQ(migrateActions.GetSrcActionIndex(), 1); ASSERT_EQ(migrateActions.GetSrcActionIndex(), 1);
ASSERT_EQ(migrateActions.GetDstActionIndex(), 2); ASSERT_EQ(migrateActions.GetDstActionIndex(), 2);
ASSERT_EQ(migrateActions.GetSourceActionContext().GetStripId(), 1); ASSERT_EQ(migrateActions.GetSourceActionContext().GetStripId(), 1);
@ -177,7 +177,7 @@ TEST_F(GameMessageTests, ControlBehaviorMigrateActions) {
TEST_F(GameMessageTests, ControlBehaviorRearrangeStrip) { TEST_F(GameMessageTests, ControlBehaviorRearrangeStrip) {
auto data = ReadFromFile("rearrangeStrip"); auto data = ReadFromFile("rearrangeStrip");
RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true);
RearrangeStripMessage rearrangeStrip(ReadArrayFromBitStream(&inStream)); RearrangeStripMessage rearrangeStrip(ReadArrayFromBitStream(inStream));
ASSERT_EQ(rearrangeStrip.GetSrcActionIndex(), 2); ASSERT_EQ(rearrangeStrip.GetSrcActionIndex(), 2);
ASSERT_EQ(rearrangeStrip.GetDstActionIndex(), 1); ASSERT_EQ(rearrangeStrip.GetDstActionIndex(), 1);
ASSERT_EQ(rearrangeStrip.GetActionContext().GetStripId(), 0); ASSERT_EQ(rearrangeStrip.GetActionContext().GetStripId(), 0);
@ -188,7 +188,7 @@ TEST_F(GameMessageTests, ControlBehaviorRearrangeStrip) {
TEST_F(GameMessageTests, ControlBehaviorAdd) { TEST_F(GameMessageTests, ControlBehaviorAdd) {
auto data = ReadFromFile("add"); auto data = ReadFromFile("add");
RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true);
AddMessage add(ReadArrayFromBitStream(&inStream)); AddMessage add(ReadArrayFromBitStream(inStream));
ASSERT_EQ(add.GetBehaviorId(), 10446); ASSERT_EQ(add.GetBehaviorId(), 10446);
ASSERT_EQ(add.GetBehaviorIndex(), 0); ASSERT_EQ(add.GetBehaviorIndex(), 0);
} }
@ -196,7 +196,7 @@ TEST_F(GameMessageTests, ControlBehaviorAdd) {
TEST_F(GameMessageTests, ControlBehaviorRemoveActions) { TEST_F(GameMessageTests, ControlBehaviorRemoveActions) {
auto data = ReadFromFile("removeActions"); auto data = ReadFromFile("removeActions");
RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true);
RemoveActionsMessage removeActions(ReadArrayFromBitStream(&inStream)); RemoveActionsMessage removeActions(ReadArrayFromBitStream(inStream));
ASSERT_EQ(removeActions.GetBehaviorId(), -1); ASSERT_EQ(removeActions.GetBehaviorId(), -1);
ASSERT_EQ(removeActions.GetActionIndex(), 1); ASSERT_EQ(removeActions.GetActionIndex(), 1);
ASSERT_EQ(removeActions.GetActionContext().GetStripId(), 0); ASSERT_EQ(removeActions.GetActionContext().GetStripId(), 0);
@ -206,7 +206,7 @@ TEST_F(GameMessageTests, ControlBehaviorRemoveActions) {
TEST_F(GameMessageTests, ControlBehaviorRename) { TEST_F(GameMessageTests, ControlBehaviorRename) {
auto data = ReadFromFile("rename"); auto data = ReadFromFile("rename");
RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true);
RenameMessage rename(ReadArrayFromBitStream(&inStream)); RenameMessage rename(ReadArrayFromBitStream(inStream));
ASSERT_EQ(rename.GetName(), "test"); ASSERT_EQ(rename.GetName(), "test");
ASSERT_EQ(rename.GetBehaviorId(), -1); ASSERT_EQ(rename.GetBehaviorId(), -1);
} }
@ -214,7 +214,7 @@ TEST_F(GameMessageTests, ControlBehaviorRename) {
TEST_F(GameMessageTests, ControlBehaviorUpdateAction) { TEST_F(GameMessageTests, ControlBehaviorUpdateAction) {
auto data = ReadFromFile("updateAction"); auto data = ReadFromFile("updateAction");
RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true);
UpdateActionMessage updateAction(ReadArrayFromBitStream(&inStream)); UpdateActionMessage updateAction(ReadArrayFromBitStream(inStream));
ASSERT_EQ(updateAction.GetAction().GetType(), "FlyDown"); ASSERT_EQ(updateAction.GetAction().GetType(), "FlyDown");
ASSERT_EQ(updateAction.GetAction().GetValueParameterName(), "Distance"); ASSERT_EQ(updateAction.GetAction().GetValueParameterName(), "Distance");
ASSERT_EQ(updateAction.GetAction().GetValueParameterString(), ""); ASSERT_EQ(updateAction.GetAction().GetValueParameterString(), "");