mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-12-01 05:38:18 +00:00
Merge remote-tracking branch 'upstream/main' into PetFixes
This commit is contained in:
72
dGame/dComponents/AchievementVendorComponent.cpp
Normal file
72
dGame/dComponents/AchievementVendorComponent.cpp
Normal file
@@ -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<MissionComponent>();
|
||||
if (!missionComponent) return false;
|
||||
|
||||
if (m_PlayerPurchasableItems[buyer->GetObjectID()].contains(lot)){
|
||||
return true;
|
||||
}
|
||||
|
||||
CDMissionsTable* missionsTable = CDClientManager::GetTable<CDMissionsTable>();
|
||||
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<CDComponentsRegistryTable>();
|
||||
CDItemComponentTable* itemComponentTable = CDClientManager::GetTable<CDItemComponentTable>();
|
||||
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<InventoryComponent>();
|
||||
if (!inventoryComponent) {
|
||||
GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_FAIL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (costLOT == 13763) { // Faction Token Proxy
|
||||
auto* missionComponent = buyer->GetComponent<MissionComponent>();
|
||||
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);
|
||||
|
||||
}
|
||||
23
dGame/dComponents/AchievementVendorComponent.h
Normal file
23
dGame/dComponents/AchievementVendorComponent.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef __ACHIEVEMENTVENDORCOMPONENT__H__
|
||||
#define __ACHIEVEMENTVENDORCOMPONENT__H__
|
||||
|
||||
#include "VendorComponent.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
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<LWOOBJID,std::set<LOT>> m_PlayerPurchasableItems;
|
||||
};
|
||||
|
||||
|
||||
#endif //!__ACHIEVEMENTVENDORCOMPONENT__H__
|
||||
@@ -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<uint32_t>(m_ActivityPlayers.size());
|
||||
outBitStream.Write<uint32_t>(m_ActivityPlayers.size());
|
||||
if (!m_ActivityPlayers.empty()) {
|
||||
for (const auto& activityPlayer : m_ActivityPlayers) {
|
||||
outBitStream->Write<LWOOBJID>(activityPlayer->playerID);
|
||||
outBitStream.Write<LWOOBJID>(activityPlayer->playerID);
|
||||
for (const auto& activityValue : activityPlayer->values) {
|
||||
outBitStream->Write<float_t>(activityValue);
|
||||
outBitStream.Write<float_t>(activityValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<uint32_t>(m_Buffs.size());
|
||||
outBitStream.Write<uint32_t>(m_Buffs.size());
|
||||
|
||||
for (const auto& [id, buff] : m_Buffs) {
|
||||
outBitStream->Write<uint32_t>(id);
|
||||
outBitStream->Write(buff.time != 0.0f);
|
||||
if (buff.time != 0.0f) outBitStream->Write<uint32_t>(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<uint32_t>(id);
|
||||
outBitStream.Write(buff.time != 0.0f);
|
||||
if (buff.time != 0.0f) outBitStream.Write<uint32_t>(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<uint32_t>(buff.refCount);
|
||||
outBitStream.Write<uint32_t>(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);
|
||||
}
|
||||
|
||||
@@ -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<int32_t, Buff> m_Buffs;
|
||||
|
||||
// Buffs to remove at the end of the update frame.
|
||||
std::vector<int32_t> m_BuffsToRemove;
|
||||
std::set<int32_t> m_BuffsToRemove;
|
||||
|
||||
/**
|
||||
* Parameters (=effects) for each buff
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
set(DGAME_DCOMPONENTS_SOURCES
|
||||
"AchievementVendorComponent.cpp"
|
||||
"ActivityComponent.cpp"
|
||||
"BaseCombatAIComponent.cpp"
|
||||
"BouncerComponent.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<uint32_t>(0); //Default "head"
|
||||
outBitStream->Write(m_Character->GetShirtColor());
|
||||
outBitStream->Write(m_Character->GetPantsColor());
|
||||
outBitStream->Write(m_Character->GetShirtStyle());
|
||||
outBitStream->Write<uint32_t>(0); //Default "head color"
|
||||
outBitStream->Write(m_Character->GetEyebrows());
|
||||
outBitStream->Write(m_Character->GetEyes());
|
||||
outBitStream->Write(m_Character->GetMouth());
|
||||
outBitStream->Write<uint64_t>(0); //AccountID, trying out if 0 works.
|
||||
outBitStream->Write(m_Character->GetLastLogin()); //Last login
|
||||
outBitStream->Write<uint64_t>(0); //"prop mod last display time"
|
||||
outBitStream->Write<uint64_t>(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<uint32_t>(0); //Default "head"
|
||||
outBitStream.Write(m_Character->GetShirtColor());
|
||||
outBitStream.Write(m_Character->GetPantsColor());
|
||||
outBitStream.Write(m_Character->GetShirtStyle());
|
||||
outBitStream.Write<uint32_t>(0); //Default "head color"
|
||||
outBitStream.Write(m_Character->GetEyebrows());
|
||||
outBitStream.Write(m_Character->GetEyes());
|
||||
outBitStream.Write(m_Character->GetMouth());
|
||||
outBitStream.Write<uint64_t>(0); //AccountID, trying out if 0 works.
|
||||
outBitStream.Write(m_Character->GetLastLogin()); //Last login
|
||||
outBitStream.Write<uint64_t>(0); //"prop mod last display time"
|
||||
outBitStream.Write<uint64_t>(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<uint16_t>(m_LastRocketConfig.size());
|
||||
outBitStream.Write<uint16_t>(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<unsigned char>(m_GuildName.size());
|
||||
outBitStream.Write(m_GuildID);
|
||||
outBitStream.Write<unsigned char>(m_GuildName.size());
|
||||
if (!m_GuildName.empty())
|
||||
outBitStream->WriteBits(reinterpret_cast<const unsigned char*>(m_GuildName.c_str()), static_cast<unsigned char>(m_GuildName.size()) * sizeof(wchar_t) * 8);
|
||||
outBitStream.WriteBits(reinterpret_cast<const unsigned char*>(m_GuildName.c_str()), static_cast<unsigned char>(m_GuildName.size()) * sizeof(wchar_t) * 8);
|
||||
|
||||
outBitStream->Write(m_IsLEGOClubMember);
|
||||
outBitStream->Write(m_CountryCode);
|
||||
outBitStream.Write(m_IsLEGOClubMember);
|
||||
outBitStream.Write(m_CountryCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<uint32_t>(m_FactionIDs.size());
|
||||
outBitStream.Write<uint32_t>(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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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<uint8_t>(m_EndBehavior);
|
||||
outBitStream->Write1(); // is input locked?
|
||||
outBitStream.Write<uint8_t>(m_EndBehavior);
|
||||
outBitStream.Write1(); // is input locked?
|
||||
}
|
||||
|
||||
outBitStream->Write0();
|
||||
outBitStream.Write0();
|
||||
}
|
||||
|
||||
void HavokVehiclePhysicsComponent::Update(float deltaTime) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<uint32_t>(m_Equipped.size());
|
||||
outBitStream.Write<uint32_t>(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<uint16_t>(item.slot);
|
||||
outBitStream.Write(item.slot != 0);
|
||||
if (item.slot != 0) outBitStream.Write<uint16_t>(item.slot);
|
||||
|
||||
outBitStream->Write0();
|
||||
outBitStream.Write0();
|
||||
|
||||
bool flag = !item.config.empty();
|
||||
outBitStream->Write(flag);
|
||||
outBitStream.Write(flag);
|
||||
if (flag) {
|
||||
RakNet::BitStream ldfStream;
|
||||
ldfStream.Write<int32_t>(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<std::u16string>* ldf_data = new LDFData<std::u16string>(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<uint8_t>(0); // Don't compress
|
||||
outBitStream->Write(ldfStream);
|
||||
outBitStream.Write(ldfStream.GetNumberOfBytesUsed() + 1);
|
||||
outBitStream.Write<uint8_t>(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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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__
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -37,9 +37,9 @@ void LevelProgressionComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
|
||||
m_CharacterVersion = static_cast<eCharacterVersion>(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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "MiniGameControlComponent.h"
|
||||
|
||||
void MiniGameControlComponent::Serialize(RakNet::BitStream* outBitStream, bool isConstruction) {
|
||||
outBitStream->Write<uint32_t>(0x40000000);
|
||||
void MiniGameControlComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) {
|
||||
outBitStream.Write<uint32_t>(0x40000000);
|
||||
}
|
||||
|
||||
@@ -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__
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "MinigameComponent.h"
|
||||
|
||||
void MinigameComponent::Serialize(RakNet::BitStream* outBitStream, bool isConstruction) {
|
||||
outBitStream->Write<uint32_t>(0x40000000);
|
||||
void MinigameComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) {
|
||||
outBitStream.Write<uint32_t>(0x40000000);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -14,26 +14,26 @@ ModelComponent::ModelComponent(Entity* parent) : Component(parent) {
|
||||
m_userModelID = m_Parent->GetVarAs<LWOOBJID>(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<LWOOBJID>(m_userModelID != LWOOBJID_EMPTY ? m_userModelID : m_Parent->GetObjectID());
|
||||
outBitStream->Write<int>(0);
|
||||
outBitStream->Write0();
|
||||
outBitStream.Write1();
|
||||
outBitStream.Write<LWOOBJID>(m_userModelID != LWOOBJID_EMPTY ? m_userModelID : m_Parent->GetObjectID());
|
||||
outBitStream.Write<int>(0);
|
||||
outBitStream.Write0();
|
||||
}
|
||||
|
||||
//actual model component:
|
||||
outBitStream->Write1(); // Yes we are writing model info
|
||||
outBitStream->Write0(); // Is pickable
|
||||
outBitStream->Write<uint32_t>(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<uint32_t>(2); // Physics type
|
||||
outBitStream.Write(m_OriginalPosition); // Original position
|
||||
outBitStream.Write(m_OriginalRotation); // Original rotation
|
||||
|
||||
outBitStream->Write1(); // We are writing behavior info
|
||||
outBitStream->Write<uint32_t>(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<uint32_t>(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) {
|
||||
|
||||
@@ -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
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
* @param args the arguments of the message to be deserialized
|
||||
*/
|
||||
template<typename Msg>
|
||||
void HandleControlBehaviorsMsg(AMFArrayValue* args) {
|
||||
void HandleControlBehaviorsMsg(const AMFArrayValue& args) {
|
||||
static_assert(std::is_base_of_v<BehaviorMessageBase, Msg>, "Msg must be a BehaviorMessageBase");
|
||||
Msg msg(args);
|
||||
for (auto& behavior : m_Behaviors) {
|
||||
|
||||
@@ -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<uint16_t>(m_AssemblyPartsLOTs.size());
|
||||
outBitStream.Write<uint16_t>(m_AssemblyPartsLOTs.size());
|
||||
for (char16_t character : m_AssemblyPartsLOTs) {
|
||||
outBitStream->Write(character);
|
||||
outBitStream.Write(character);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,25 +32,25 @@ MoverSubComponent::MoverSubComponent(const NiPoint3& startPos) {
|
||||
|
||||
MoverSubComponent::~MoverSubComponent() = default;
|
||||
|
||||
void MoverSubComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
|
||||
outBitStream->Write<bool>(true);
|
||||
void MoverSubComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) {
|
||||
outBitStream.Write<bool>(true);
|
||||
|
||||
outBitStream->Write(mState);
|
||||
outBitStream->Write<int32_t>(mDesiredWaypointIndex);
|
||||
outBitStream->Write(mShouldStopAtDesiredWaypoint);
|
||||
outBitStream->Write(mInReverse);
|
||||
outBitStream.Write(mState);
|
||||
outBitStream.Write<int32_t>(mDesiredWaypointIndex);
|
||||
outBitStream.Write(mShouldStopAtDesiredWaypoint);
|
||||
outBitStream.Write(mInReverse);
|
||||
|
||||
outBitStream->Write<float_t>(mPercentBetweenPoints);
|
||||
outBitStream.Write<float_t>(mPercentBetweenPoints);
|
||||
|
||||
outBitStream->Write<float_t>(mPosition.x);
|
||||
outBitStream->Write<float_t>(mPosition.y);
|
||||
outBitStream->Write<float_t>(mPosition.z);
|
||||
outBitStream.Write<float_t>(mPosition.x);
|
||||
outBitStream.Write<float_t>(mPosition.y);
|
||||
outBitStream.Write<float_t>(mPosition.z);
|
||||
|
||||
outBitStream->Write<uint32_t>(mCurrentWaypointIndex);
|
||||
outBitStream->Write<uint32_t>(mNextWaypointIndex);
|
||||
outBitStream.Write<uint32_t>(mCurrentWaypointIndex);
|
||||
outBitStream.Write<uint32_t>(mNextWaypointIndex);
|
||||
|
||||
outBitStream->Write<float_t>(mIdleTimeElapsed);
|
||||
outBitStream->Write<float_t>(0.0f); // Move time elapsed
|
||||
outBitStream.Write<float_t>(mIdleTimeElapsed);
|
||||
outBitStream.Write<float_t>(0.0f); // Move time elapsed
|
||||
}
|
||||
|
||||
//------------- MovingPlatformComponent below --------------
|
||||
@@ -71,43 +71,43 @@ MovingPlatformComponent::~MovingPlatformComponent() {
|
||||
delete static_cast<MoverSubComponent*>(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<bool>(false);
|
||||
outBitStream->Write<bool>(false);
|
||||
outBitStream.Write<bool>(false);
|
||||
outBitStream.Write<bool>(false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
outBitStream->Write<bool>(true);
|
||||
outBitStream.Write<bool>(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<uint16_t>(m_PathName.size());
|
||||
outBitStream.Write<uint16_t>(m_PathName.size());
|
||||
for (const auto& c : m_PathName) {
|
||||
outBitStream->Write<uint16_t>(c);
|
||||
outBitStream.Write<uint16_t>(c);
|
||||
}
|
||||
|
||||
// Starting point
|
||||
outBitStream->Write<uint32_t>(0);
|
||||
outBitStream.Write<uint32_t>(0);
|
||||
|
||||
// Reverse
|
||||
outBitStream->Write<bool>(false);
|
||||
outBitStream.Write<bool>(false);
|
||||
}
|
||||
|
||||
const auto hasPlatform = m_MoverSubComponent != nullptr;
|
||||
outBitStream->Write<bool>(hasPlatform);
|
||||
outBitStream.Write<bool>(hasPlatform);
|
||||
|
||||
if (hasPlatform) {
|
||||
auto* mover = static_cast<MoverSubComponent*>(m_MoverSubComponent);
|
||||
outBitStream->Write(m_MoverSubComponentType);
|
||||
outBitStream.Write(m_MoverSubComponentType);
|
||||
|
||||
if (m_MoverSubComponentType == eMoverSubComponentType::simpleMover) {
|
||||
// TODO
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -106,42 +106,42 @@ PetComponent::PetComponent(Entity* parentEntity, uint32_t componentId) : Compone
|
||||
m_FollowRadius = 8.0f; //Game::zoneManager->GetPetFollowRadius(); // TODO: FIX THIS TO LOAD DYNAMICALLY
|
||||
}
|
||||
|
||||
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<uint32_t>(m_Flags);
|
||||
outBitStream->Write(tamed ? m_Ability : ePetAbilityType::Invalid); // Something with the overhead icon?
|
||||
outBitStream.Write<uint32_t>(m_Flags);
|
||||
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<uint8_t>(nameData.size());
|
||||
outBitStream.Write<uint8_t>(nameData.size());
|
||||
for (const auto c : nameData) {
|
||||
outBitStream->Write(c);
|
||||
outBitStream.Write(c);
|
||||
}
|
||||
|
||||
outBitStream->Write<uint8_t>(ownerNameData.size());
|
||||
outBitStream.Write<uint8_t>(ownerNameData.size());
|
||||
for (const auto c : ownerNameData) {
|
||||
outBitStream->Write(c);
|
||||
outBitStream.Write(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
* @param outBitStream The output bitstream
|
||||
* @param bIsInitialUpdate Boolean value of whether this is the initial update
|
||||
*/
|
||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
|
||||
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
||||
|
||||
/**
|
||||
* Sets the AI state of the pet
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<uint32_t>(1);
|
||||
outBitStream->Write(builder->GetObjectID());
|
||||
outBitStream.Write<uint32_t>(1);
|
||||
outBitStream.Write(builder->GetObjectID());
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
outBitStream->Write(0.0f);
|
||||
outBitStream.Write(0.0f);
|
||||
}
|
||||
} else {
|
||||
outBitStream->Write<uint32_t>(0);
|
||||
outBitStream.Write<uint32_t>(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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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<uint32_t>(m_RacingPlayers.size());
|
||||
outBitStream.Write<uint32_t>(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<float>(player.raceTime);
|
||||
else outBitStream->Write(player.data[1]);
|
||||
if (player.finished != 0) outBitStream->Write<float>(player.bestLapTime);
|
||||
else outBitStream->Write(player.data[2]);
|
||||
if (player.finished == 1) outBitStream->Write<float>(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<float>(player.raceTime);
|
||||
else outBitStream.Write(player.data[1]);
|
||||
if (player.finished != 0) outBitStream.Write<float>(player.bestLapTime);
|
||||
else outBitStream.Write(player.data[2]);
|
||||
if (player.finished == 1) outBitStream.Write<float>(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<uint16_t>(m_RacingPlayers.size());
|
||||
outBitStream.Write1();
|
||||
outBitStream.Write<uint16_t>(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<uint16_t>(m_PathName.size());
|
||||
outBitStream.Write(m_RemainingLaps);
|
||||
outBitStream.Write<uint16_t>(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<float>(player.bestLapTime);
|
||||
outBitStream->Write<float>(player.raceTime);
|
||||
outBitStream.Write1(); // Has more data
|
||||
outBitStream.Write(player.playerID);
|
||||
outBitStream.Write<float>(player.bestLapTime);
|
||||
outBitStream.Write<float>(player.raceTime);
|
||||
}
|
||||
|
||||
outBitStream->Write0(); // No more data
|
||||
outBitStream.Write0(); // No more data
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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<uint32_t>(m_Effects.size());
|
||||
outBitStream.Write<uint32_t>(m_Effects.size());
|
||||
|
||||
for (auto& eff : m_Effects) {
|
||||
outBitStream->Write<uint8_t>(eff.name.size());
|
||||
outBitStream.Write<uint8_t>(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<uint8_t>(value);
|
||||
for (const auto& value : eff.name) outBitStream.Write<uint8_t>(value);
|
||||
|
||||
outBitStream->Write(eff.effectID);
|
||||
outBitStream.Write(eff.effectID);
|
||||
|
||||
outBitStream->Write<uint8_t>(eff.type.size());
|
||||
for (const auto& value : eff.type) outBitStream->Write<uint16_t>(value);
|
||||
outBitStream.Write<uint8_t>(eff.type.size());
|
||||
for (const auto& value : eff.type) outBitStream.Write<uint16_t>(value);
|
||||
|
||||
outBitStream->Write<float_t>(eff.priority);
|
||||
outBitStream->Write<int64_t>(eff.secondary);
|
||||
outBitStream.Write<float_t>(eff.priority);
|
||||
outBitStream.Write<int64_t>(eff.secondary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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__
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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<bool>(true);
|
||||
outBitStream.Write<bool>(true);
|
||||
if (m_CurrentPlayerID == LWOOBJID_EMPTY) {
|
||||
outBitStream->Write<uint32_t>(0);
|
||||
outBitStream.Write<uint32_t>(0);
|
||||
} else {
|
||||
outBitStream->Write<uint32_t>(1);
|
||||
outBitStream->Write<LWOOBJID>(m_CurrentPlayerID);
|
||||
outBitStream.Write<uint32_t>(1);
|
||||
outBitStream.Write<LWOOBJID>(m_CurrentPlayerID);
|
||||
for (size_t i = 0; i < 10; i++) {
|
||||
outBitStream->Write<float_t>(0.0f);
|
||||
outBitStream.Write<float_t>(0.0f);
|
||||
}
|
||||
|
||||
}
|
||||
// End ScriptedActivityComponent
|
||||
|
||||
if (isInitialUpdate) {
|
||||
outBitStream->Write<float_t>(m_StaticParams.cameraPosition.GetX());
|
||||
outBitStream->Write<float_t>(m_StaticParams.cameraPosition.GetY());
|
||||
outBitStream->Write<float_t>(m_StaticParams.cameraPosition.GetZ());
|
||||
outBitStream.Write<float_t>(m_StaticParams.cameraPosition.GetX());
|
||||
outBitStream.Write<float_t>(m_StaticParams.cameraPosition.GetY());
|
||||
outBitStream.Write<float_t>(m_StaticParams.cameraPosition.GetZ());
|
||||
|
||||
outBitStream->Write<float_t>(m_StaticParams.cameraLookatPosition.GetX());
|
||||
outBitStream->Write<float_t>(m_StaticParams.cameraLookatPosition.GetY());
|
||||
outBitStream->Write<float_t>(m_StaticParams.cameraLookatPosition.GetZ());
|
||||
outBitStream.Write<float_t>(m_StaticParams.cameraLookatPosition.GetX());
|
||||
outBitStream.Write<float_t>(m_StaticParams.cameraLookatPosition.GetY());
|
||||
outBitStream.Write<float_t>(m_StaticParams.cameraLookatPosition.GetZ());
|
||||
}
|
||||
|
||||
outBitStream->Write<bool>(m_Dirty || isInitialUpdate);
|
||||
outBitStream.Write<bool>(m_Dirty || isInitialUpdate);
|
||||
if (m_Dirty || isInitialUpdate) {
|
||||
outBitStream->Write<double_t>(m_DynamicParams.cannonVelocity);
|
||||
outBitStream->Write<double_t>(m_DynamicParams.cannonRefireRate);
|
||||
outBitStream->Write<double_t>(m_DynamicParams.cannonMinDistance);
|
||||
outBitStream.Write<double_t>(m_DynamicParams.cannonVelocity);
|
||||
outBitStream.Write<double_t>(m_DynamicParams.cannonRefireRate);
|
||||
outBitStream.Write<double_t>(m_DynamicParams.cannonMinDistance);
|
||||
|
||||
outBitStream->Write<float_t>(m_DynamicParams.cameraBarrelOffset.GetX());
|
||||
outBitStream->Write<float_t>(m_DynamicParams.cameraBarrelOffset.GetY());
|
||||
outBitStream->Write<float_t>(m_DynamicParams.cameraBarrelOffset.GetZ());
|
||||
outBitStream.Write<float_t>(m_DynamicParams.cameraBarrelOffset.GetX());
|
||||
outBitStream.Write<float_t>(m_DynamicParams.cameraBarrelOffset.GetY());
|
||||
outBitStream.Write<float_t>(m_DynamicParams.cameraBarrelOffset.GetZ());
|
||||
|
||||
outBitStream->Write<float_t>(m_DynamicParams.cannonAngle);
|
||||
outBitStream.Write<float_t>(m_DynamicParams.cannonAngle);
|
||||
|
||||
outBitStream->Write<float_t>(m_DynamicParams.facing.GetX());
|
||||
outBitStream->Write<float_t>(m_DynamicParams.facing.GetY());
|
||||
outBitStream->Write<float_t>(m_DynamicParams.facing.GetZ());
|
||||
outBitStream.Write<float_t>(m_DynamicParams.facing.GetX());
|
||||
outBitStream.Write<float_t>(m_DynamicParams.facing.GetY());
|
||||
outBitStream.Write<float_t>(m_DynamicParams.facing.GetZ());
|
||||
|
||||
outBitStream->Write<LWOOBJID>(m_CurrentPlayerID);
|
||||
outBitStream->Write<float_t>(m_DynamicParams.cannonTimeout);
|
||||
outBitStream->Write<float_t>(m_DynamicParams.cannonFOV);
|
||||
outBitStream.Write<LWOOBJID>(m_CurrentPlayerID);
|
||||
outBitStream.Write<float_t>(m_DynamicParams.cannonTimeout);
|
||||
outBitStream.Write<float_t>(m_DynamicParams.cannonFOV);
|
||||
if (!isInitialUpdate) m_Dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<uint32_t>(m_PhysicsMotionState);
|
||||
outBitStream.Write1();
|
||||
outBitStream.Write<uint32_t>(m_PhysicsMotionState);
|
||||
} else {
|
||||
outBitStream->Write0();
|
||||
outBitStream.Write0();
|
||||
}
|
||||
PhysicsComponent::Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -31,7 +31,7 @@ ProjectileSyncEntry::ProjectileSyncEntry() {
|
||||
|
||||
std::unordered_map<uint32_t, uint32_t> 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<char*>(bitStream->GetData()), bitStream->GetNumberOfBytesUsed());
|
||||
start.sBitStream.assign(reinterpret_cast<char*>(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<char*>(bitStream->GetData()), bitStream->GetNumberOfBytesUsed());
|
||||
projectileImpact.sBitStream.assign(reinterpret_cast<char*>(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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -2,28 +2,28 @@
|
||||
#include "Game.h"
|
||||
#include "Logger.h"
|
||||
|
||||
void MusicCue::Serialize(RakNet::BitStream* outBitStream){
|
||||
outBitStream->Write<uint8_t>(name.size());
|
||||
outBitStream->Write(name.c_str(), name.size());
|
||||
outBitStream->Write(result);
|
||||
outBitStream->Write(boredomTime);
|
||||
void MusicCue::Serialize(RakNet::BitStream& outBitStream){
|
||||
outBitStream.Write<uint8_t>(name.size());
|
||||
outBitStream.Write(name.c_str(), name.size());
|
||||
outBitStream.Write(result);
|
||||
outBitStream.Write(boredomTime);
|
||||
}
|
||||
|
||||
void MusicParameter::Serialize(RakNet::BitStream* outBitStream){
|
||||
outBitStream->Write<uint8_t>(name.size());
|
||||
outBitStream->Write(name.c_str(), name.size());
|
||||
outBitStream->Write(value);
|
||||
void MusicParameter::Serialize(RakNet::BitStream& outBitStream){
|
||||
outBitStream.Write<uint8_t>(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<uint8_t>(name.size());
|
||||
outBitStream->Write(name.c_str(), name.size());
|
||||
outBitStream->Write(result);
|
||||
void MixerProgram::Serialize(RakNet::BitStream& outBitStream){
|
||||
outBitStream.Write<uint8_t>(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<uint8_t>(this->m_MusicCues.size());
|
||||
outBitStream.Write<uint8_t>(this->m_MusicCues.size());
|
||||
for (auto& musicCue : this->m_MusicCues) {
|
||||
musicCue.Serialize(outBitStream);
|
||||
}
|
||||
|
||||
outBitStream->Write<uint8_t>(this->m_MusicParameters.size());
|
||||
outBitStream.Write<uint8_t>(this->m_MusicParameters.size());
|
||||
for (auto& musicParam : this->m_MusicParameters) {
|
||||
musicParam.Serialize(outBitStream);
|
||||
}
|
||||
|
||||
outBitStream->Write<uint8_t>(this->m_2DAmbientSounds.size());
|
||||
outBitStream.Write<uint8_t>(this->m_2DAmbientSounds.size());
|
||||
for (auto twoDAmbientSound : this->m_2DAmbientSounds) {
|
||||
twoDAmbientSound.Serialize(outBitStream);
|
||||
}
|
||||
|
||||
outBitStream->Write<uint8_t>(this->m_3DAmbientSounds.size());
|
||||
outBitStream.Write<uint8_t>(this->m_3DAmbientSounds.size());
|
||||
for (auto threeDAmbientSound : this->m_3DAmbientSounds) {
|
||||
threeDAmbientSound.Serialize(outBitStream);
|
||||
}
|
||||
|
||||
outBitStream->Write<uint8_t>(this->m_MixerPrograms.size());
|
||||
outBitStream.Write<uint8_t>(this->m_MixerPrograms.size());
|
||||
for (auto& mixerProgram : this->m_MixerPrograms) {
|
||||
mixerProgram.Serialize(outBitStream);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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<InventoryComponent>();
|
||||
if (!inventoryComponent) {
|
||||
GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_FAIL);
|
||||
return;
|
||||
}
|
||||
CDComponentsRegistryTable* compRegistryTable = CDClientManager::GetTable<CDComponentsRegistryTable>();
|
||||
CDItemComponentTable* itemComponentTable = CDClientManager::GetTable<CDItemComponentTable>();
|
||||
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<uint32_t>(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);
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user