From 2abcb142ad3685d2051538ccbf78538a7f5f2afd Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Mon, 26 Jun 2023 22:39:15 -0700 Subject: [PATCH] Character fixes - get it compiling again - Pass componentID to activity component constructor - use int componentid so -1 can denote no component --- dGame/dComponents/ActivityComponent.cpp | 4 +- dGame/dComponents/ActivityComponent.h | 2 +- dGame/dComponents/BuildBorderComponent.h | 2 +- dGame/dComponents/CharacterComponent.cpp | 152 +++++++++--------- dGame/dComponents/CharacterComponent.h | 3 +- dGame/dComponents/GateRushComponent.cpp | 2 +- dGame/dComponents/GateRushComponent.h | 2 +- .../dComponents/MinigameControlComponent.cpp | 2 +- dGame/dComponents/MinigameControlComponent.h | 2 +- dGame/dComponents/QuickBuildComponent.cpp | 2 +- dGame/dComponents/QuickBuildComponent.h | 4 +- dGame/dComponents/RacingComponent.cpp | 2 +- dGame/dComponents/RacingComponent.h | 2 +- dGame/dComponents/RacingControlComponent.cpp | 2 +- dGame/dComponents/RacingControlComponent.h | 2 +- .../dComponents/ScriptedActivityComponent.cpp | 2 +- dGame/dComponents/ScriptedActivityComponent.h | 2 +- .../dComponents/ShootingGalleryComponent.cpp | 2 +- dGame/dComponents/ShootingGalleryComponent.h | 2 +- dGame/dEntity/Entity.cpp | 6 +- 20 files changed, 96 insertions(+), 103 deletions(-) diff --git a/dGame/dComponents/ActivityComponent.cpp b/dGame/dComponents/ActivityComponent.cpp index 13c362f7..f4cdf981 100644 --- a/dGame/dComponents/ActivityComponent.cpp +++ b/dGame/dComponents/ActivityComponent.cpp @@ -29,8 +29,8 @@ #include "CDActivitiesTable.h" #include "LeaderboardManager.h" -ActivityComponent::ActivityComponent(Entity* parent) : Component(parent) { - m_ActivityID = activityID; +ActivityComponent::ActivityComponent(Entity* parent, int32_t componentId) : Component(parent) { + m_ActivityID = componentId; CDActivitiesTable* activitiesTable = CDClientManager::Instance().GetTable(); std::vector activities = activitiesTable->Query([=](CDActivities entry) {return (entry.ActivityID == m_ActivityID); }); diff --git a/dGame/dComponents/ActivityComponent.h b/dGame/dComponents/ActivityComponent.h index 587f982a..1164df99 100644 --- a/dGame/dComponents/ActivityComponent.h +++ b/dGame/dComponents/ActivityComponent.h @@ -156,7 +156,7 @@ struct ActivityPlayer { */ class ActivityComponent : public Component { public: - ActivityComponent(Entity* parent); + ActivityComponent(Entity* parent, int32_t componentId); ~ActivityComponent() override; void Update(float deltaTime) override; diff --git a/dGame/dComponents/BuildBorderComponent.h b/dGame/dComponents/BuildBorderComponent.h index be2e4378..49693a21 100644 --- a/dGame/dComponents/BuildBorderComponent.h +++ b/dGame/dComponents/BuildBorderComponent.h @@ -12,7 +12,7 @@ /** * Component for the build border, allowing the user to start building when interacting with it */ -class BuildBorderComponent : public Component { +class BuildBorderComponent final : public Component { public: inline static const eReplicaComponentType ComponentType = eReplicaComponentType::BUILD_BORDER; diff --git a/dGame/dComponents/CharacterComponent.cpp b/dGame/dComponents/CharacterComponent.cpp index 10c47a8e..37ea6fad 100644 --- a/dGame/dComponents/CharacterComponent.cpp +++ b/dGame/dComponents/CharacterComponent.cpp @@ -66,16 +66,12 @@ bool CharacterComponent::LandingAnimDisabled(int zoneID) { return false; } -CharacterComponent::~CharacterComponent() { -} - void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { - if (bIsInitialUpdate) { - outBitStream->Write0(); - outBitStream->Write0(); - outBitStream->Write0(); - outBitStream->Write0(); + outBitStream->Write0(); // Claim codes. Dont't belive these have an effect. + outBitStream->Write0(); // Claim codes. Dont't belive these have an effect. + outBitStream->Write0(); // Claim codes. Dont't belive these have an effect. + outBitStream->Write0(); // Claim codes. Dont't belive these have an effect. outBitStream->Write(m_Character->GetHairColor()); outBitStream->Write(m_Character->GetHairStyle()); @@ -122,6 +118,8 @@ void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInit outBitStream->Write(m_RacesFinished); outBitStream->Write(m_FirstPlaceRaceFinishes); + // This is a really weird bit of serialization. This is serialized as a two bit integer, but the first bit written is always zero. + // If the 2 bit integer is exactly 1, we write the rocket configuration. outBitStream->Write0(); outBitStream->Write(m_IsLanding); if (m_IsLanding) { @@ -132,20 +130,24 @@ void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInit } } - outBitStream->Write(m_DirtyGMInfo); - if (m_DirtyGMInfo) { + outBitStream->Write(bIsInitialUpdate || m_DirtyGMInfo); + if (bIsInitialUpdate || m_DirtyGMInfo) { outBitStream->Write(m_PvpEnabled); outBitStream->Write(m_IsGM); outBitStream->Write(m_GMLevel); outBitStream->Write(m_EditorEnabled); outBitStream->Write(m_EditorLevel); + if (!bIsInitialUpdate) m_DirtyGMInfo = false; } - outBitStream->Write(m_DirtyCurrentActivity); - if (m_DirtyCurrentActivity) outBitStream->Write(m_CurrentActivity); + outBitStream->Write(bIsInitialUpdate || m_DirtyCurrentActivity); + if (bIsInitialUpdate || m_DirtyCurrentActivity) { + outBitStream->Write(m_CurrentActivity); + if (!bIsInitialUpdate) m_DirtyCurrentActivity = false; + } - outBitStream->Write(m_DirtySocialInfo); - if (m_DirtySocialInfo) { + outBitStream->Write(bIsInitialUpdate || m_DirtySocialInfo); + if (bIsInitialUpdate || m_DirtySocialInfo) { outBitStream->Write(m_GuildID); outBitStream->Write(static_cast(m_GuildName.size())); if (!m_GuildName.empty()) @@ -153,6 +155,7 @@ void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInit outBitStream->Write(m_IsLEGOClubMember); outBitStream->Write(m_CountryCode); + if (!bIsInitialUpdate) m_DirtySocialInfo = false; } } @@ -161,21 +164,21 @@ bool CharacterComponent::GetPvpEnabled() const { } void CharacterComponent::SetPvpEnabled(const bool value) { + if (m_PvpEnabled == value) return; m_DirtyGMInfo = true; m_PvpEnabled = value; } void CharacterComponent::SetGMLevel(eGameMasterLevel gmlevel) { + if (m_GMLevel == gmlevel) return; m_DirtyGMInfo = true; - if (gmlevel > eGameMasterLevel::CIVILIAN) m_IsGM = true; - else m_IsGM = false; + m_IsGM = gmlevel > eGameMasterLevel::CIVILIAN; m_GMLevel = gmlevel; } void CharacterComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { - - tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char"); + auto* character = doc->FirstChildElement("obj")->FirstChildElement("char"); if (!character) { Game::logger->Log("CharacterComponent", "Failed to find char tag while loading XML!"); return; @@ -195,7 +198,7 @@ void CharacterComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { } // Load the zone statistics - m_ZoneStatistics = {}; + m_ZoneStatistics.clear(); auto zoneStatistics = character->FirstChildElement("zs"); if (zoneStatistics) { @@ -218,20 +221,16 @@ void CharacterComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { } } - const tinyxml2::XMLAttribute* rocketConfig = character->FindAttribute("lcbp"); + const auto* rocketConfig = character->FindAttribute("lcbp"); - if (rocketConfig) { - m_LastRocketConfig = GeneralUtils::ASCIIToUTF16(rocketConfig->Value()); - } else { - m_LastRocketConfig = u""; - } + m_LastRocketConfig = rocketConfig ? GeneralUtils::ASCIIToUTF16(rocketConfig->Value()) : u""; // // Begin custom attributes // // Load the last rocket item ID - const tinyxml2::XMLAttribute* lastRocketItemID = character->FindAttribute("lrid"); + const auto* lastRocketItemID = character->FindAttribute("lrid"); if (lastRocketItemID) { m_LastRocketItemID = lastRocketItemID->Int64Value(); } @@ -244,11 +243,11 @@ void CharacterComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { m_IsGM = true; m_DirtyGMInfo = true; m_EditorLevel = m_GMLevel; - m_EditorEnabled = false; //We're not currently in HF if we're loading in + m_EditorEnabled = false; // We're not currently in HF if we're loading in } //Annoying guild bs: - const tinyxml2::XMLAttribute* guildName = character->FindAttribute("gn"); + const auto* guildName = character->FindAttribute("gn"); if (guildName) { const char* gn = guildName->Value(); int64_t gid = 0; @@ -269,10 +268,8 @@ void CharacterComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { if (!m_Character) return; - //Check to see if we're landing: - if (m_Character->GetZoneID() != Game::server->GetZoneID()) { - m_IsLanding = true; - } + // If the loaded zoneID is different from the current zoneID, we are landing + m_IsLanding = m_Character->GetZoneID() != Game::server->GetZoneID(); if (LandingAnimDisabled(m_Character->GetZoneID()) || LandingAnimDisabled(Game::server->GetZoneID()) || m_LastRocketConfig.empty()) { m_IsLanding = false; //Don't make us land on VE/minigames lol @@ -300,7 +297,7 @@ void CharacterComponent::UpdateXml(tinyxml2::XMLDocument* doc) { // done with minifig - tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char"); + auto* character = doc->FirstChildElement("obj")->FirstChildElement("char"); if (!character) { Game::logger->Log("CharacterComponent", "Failed to find char tag while updating XML!"); return; @@ -316,15 +313,15 @@ void CharacterComponent::UpdateXml(tinyxml2::XMLDocument* doc) { if (!zoneStatistics) zoneStatistics = doc->NewElement("zs"); zoneStatistics->DeleteChildren(); - for (auto pair : m_ZoneStatistics) { + for (const auto&[mapId, zoneStatisticToSave] : m_ZoneStatistics) { auto zoneStatistic = doc->NewElement("s"); - zoneStatistic->SetAttribute("map", pair.first); - zoneStatistic->SetAttribute("ac", pair.second.m_AchievementsCollected); - zoneStatistic->SetAttribute("bc", pair.second.m_BricksCollected); - zoneStatistic->SetAttribute("cc", pair.second.m_CoinsCollected); - zoneStatistic->SetAttribute("es", pair.second.m_EnemiesSmashed); - zoneStatistic->SetAttribute("qbc", pair.second.m_QuickBuildsCompleted); + zoneStatistic->SetAttribute("map", mapId); + zoneStatistic->SetAttribute("ac", zoneStatisticToSave.m_AchievementsCollected); + zoneStatistic->SetAttribute("bc", zoneStatisticToSave.m_BricksCollected); + zoneStatistic->SetAttribute("cc", zoneStatisticToSave.m_CoinsCollected); + zoneStatistic->SetAttribute("es", zoneStatisticToSave.m_EnemiesSmashed); + zoneStatistic->SetAttribute("qbc", zoneStatisticToSave.m_QuickBuildsCompleted); zoneStatistics->LinkEndChild(zoneStatistic); } @@ -350,7 +347,7 @@ void CharacterComponent::UpdateXml(tinyxml2::XMLDocument* doc) { // auto newUpdateTimestamp = std::time(nullptr); - Game::logger->Log("TotalTimePlayed", "Time since last save: %d", newUpdateTimestamp - m_LastUpdateTimestamp); + Game::logger->Log("TotalTimePlayed", "Time since %i last saved: %d", m_Character->GetID(), newUpdateTimestamp - m_LastUpdateTimestamp); m_TotalTimePlayed += newUpdateTimestamp - m_LastUpdateTimestamp; character->SetAttribute("time", m_TotalTimePlayed); @@ -391,7 +388,7 @@ Item* CharacterComponent::RocketEquip(Entity* player) { if (!rocket) return rocket; // build and define the rocket config - for (LDFBaseData* data : rocket->GetConfig()) { + for (auto* data : rocket->GetConfig()) { if (data->GetKey() == u"assemblyPartLOTs") { std::string newRocketStr = data->GetValueAsString() + ";"; GeneralUtils::ReplaceInString(newRocketStr, "+", ";"); @@ -471,9 +468,7 @@ void CharacterComponent::TrackImaginationDelta(int32_t imagination) { } void CharacterComponent::TrackArmorDelta(int32_t armor) { - if (armor > 0) { - UpdatePlayerStatistic(TotalArmorRepaired, armor); - } + if (armor > 0) UpdatePlayerStatistic(TotalArmorRepaired, armor); } void CharacterComponent::TrackRebuildComplete() { @@ -485,17 +480,16 @@ void CharacterComponent::TrackRebuildComplete() { void CharacterComponent::TrackRaceCompleted(bool won) { m_RacesFinished++; - if (won) - m_FirstPlaceRaceFinishes++; + if (won) m_FirstPlaceRaceFinishes++; } void CharacterComponent::TrackPositionUpdate(const NiPoint3& newPosition) { const auto distance = NiPoint3::Distance(newPosition, m_ParentEntity->GetPosition()); if (m_IsRacing) { - UpdatePlayerStatistic(DistanceDriven, (uint64_t)distance); + UpdatePlayerStatistic(DistanceDriven, static_cast(distance)); } else { - UpdatePlayerStatistic(MetersTraveled, (uint64_t)distance); + UpdatePlayerStatistic(MetersTraveled, static_cast(distance)); } } @@ -666,45 +660,45 @@ void CharacterComponent::InitializeEmptyStatistics() { std::string CharacterComponent::StatisticsToString() const { std::stringstream result; - result << std::to_string(m_CurrencyCollected) << ';' - << std::to_string(m_BricksCollected) << ';' - << std::to_string(m_SmashablesSmashed) << ';' - << std::to_string(m_QuickBuildsCompleted) << ';' - << std::to_string(m_EnemiesSmashed) << ';' - << std::to_string(m_RocketsUsed) << ';' - << std::to_string(m_MissionsCompleted) << ';' - << std::to_string(m_PetsTamed) << ';' - << std::to_string(m_ImaginationPowerUpsCollected) << ';' - << std::to_string(m_LifePowerUpsCollected) << ';' - << std::to_string(m_ArmorPowerUpsCollected) << ';' - << std::to_string(m_MetersTraveled) << ';' - << std::to_string(m_TimesSmashed) << ';' - << std::to_string(m_TotalDamageTaken) << ';' - << std::to_string(m_TotalDamageHealed) << ';' - << std::to_string(m_TotalArmorRepaired) << ';' - << std::to_string(m_TotalImaginationRestored) << ';' - << std::to_string(m_TotalImaginationUsed) << ';' - << std::to_string(m_DistanceDriven) << ';' - << std::to_string(m_TimeAirborneInCar) << ';' - << std::to_string(m_RacingImaginationPowerUpsCollected) << ';' - << std::to_string(m_RacingImaginationCratesSmashed) << ';' - << std::to_string(m_RacingCarBoostsActivated) << ';' - << std::to_string(m_RacingTimesWrecked) << ';' - << std::to_string(m_RacingSmashablesSmashed) << ';' - << std::to_string(m_RacesFinished) << ';' - << std::to_string(m_FirstPlaceRaceFinishes) << ';'; + result + << m_CurrencyCollected << ';' + << m_BricksCollected << ';' + << m_SmashablesSmashed << ';' + << m_QuickBuildsCompleted << ';' + << m_EnemiesSmashed << ';' + << m_RocketsUsed << ';' + << m_MissionsCompleted << ';' + << m_PetsTamed << ';' + << m_ImaginationPowerUpsCollected << ';' + << m_LifePowerUpsCollected << ';' + << m_ArmorPowerUpsCollected << ';' + << m_MetersTraveled << ';' + << m_TimesSmashed << ';' + << m_TotalDamageTaken << ';' + << m_TotalDamageHealed << ';' + << m_TotalArmorRepaired << ';' + << m_TotalImaginationRestored << ';' + << m_TotalImaginationUsed << ';' + << m_DistanceDriven << ';' + << m_TimeAirborneInCar << ';' + << m_RacingImaginationPowerUpsCollected << ';' + << m_RacingImaginationCratesSmashed << ';' + << m_RacingCarBoostsActivated << ';' + << m_RacingTimesWrecked << ';' + << m_RacingSmashablesSmashed << ';' + << m_RacesFinished << ';' + << m_FirstPlaceRaceFinishes << ';'; return result.str(); } uint64_t CharacterComponent::GetStatisticFromSplit(std::vector split, uint32_t index) { - return split.size() > index ? std::stoul(split.at(index)) : 0; + return index < split.size() ? std::stoul(split.at(index)) : 0; } ZoneStatistics& CharacterComponent::GetZoneStatisticsForMap(LWOMAPID mapID) { auto stats = m_ZoneStatistics.find(mapID); - if (stats == m_ZoneStatistics.end()) - m_ZoneStatistics.insert({ mapID, {0, 0, 0, 0, 0 } }); + if (stats == m_ZoneStatistics.end()) m_ZoneStatistics.insert({ mapID, {0, 0, 0, 0, 0 } }); return m_ZoneStatistics.at(mapID); } diff --git a/dGame/dComponents/CharacterComponent.h b/dGame/dComponents/CharacterComponent.h index 51a06d04..fc8f8e3b 100644 --- a/dGame/dComponents/CharacterComponent.h +++ b/dGame/dComponents/CharacterComponent.h @@ -60,12 +60,11 @@ enum StatisticID { /** * Represents a character, including their rockets and stats */ -class CharacterComponent : public Component { +class CharacterComponent final : public Component { public: inline static const eReplicaComponentType ComponentType = eReplicaComponentType::CHARACTER; CharacterComponent(Entity* parent, Character* character); - ~CharacterComponent() override; void LoadFromXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override; diff --git a/dGame/dComponents/GateRushComponent.cpp b/dGame/dComponents/GateRushComponent.cpp index ca48e1df..79e09e89 100644 --- a/dGame/dComponents/GateRushComponent.cpp +++ b/dGame/dComponents/GateRushComponent.cpp @@ -1,5 +1,5 @@ #include "GateRushComponent.h" -GateRushComponent::GateRushComponent(Entity* parent) : RacingControlComponent(parent) { +GateRushComponent::GateRushComponent(Entity* parent, int32_t componentId) : RacingControlComponent(parent, componentId) { } diff --git a/dGame/dComponents/GateRushComponent.h b/dGame/dComponents/GateRushComponent.h index 5a60e577..8680e2d7 100644 --- a/dGame/dComponents/GateRushComponent.h +++ b/dGame/dComponents/GateRushComponent.h @@ -9,7 +9,7 @@ class Entity; class GateRushComponent : public RacingControlComponent { public: inline static const eReplicaComponentType ComponentType = eReplicaComponentType::GATE_RUSH_CONTROL; - GateRushComponent(Entity* parent); + GateRushComponent(Entity* parent, int32_t componentId); }; #endif //!__GATERUSHCONTROLCOMPONENT__H__ diff --git a/dGame/dComponents/MinigameControlComponent.cpp b/dGame/dComponents/MinigameControlComponent.cpp index 8677d839..a0088d6b 100644 --- a/dGame/dComponents/MinigameControlComponent.cpp +++ b/dGame/dComponents/MinigameControlComponent.cpp @@ -2,6 +2,6 @@ #include "Entity.h" #include "MinigameControlComponent.h" -MinigameControlComponent::MinigameControlComponent(Entity* parent) : ActivityComponent(parent) { +MinigameControlComponent::MinigameControlComponent(Entity* parent, int32_t componentId) : ActivityComponent(parent, componentId) { } diff --git a/dGame/dComponents/MinigameControlComponent.h b/dGame/dComponents/MinigameControlComponent.h index b73add45..cfeef3f3 100644 --- a/dGame/dComponents/MinigameControlComponent.h +++ b/dGame/dComponents/MinigameControlComponent.h @@ -9,7 +9,7 @@ class Entity; class MinigameControlComponent : public ActivityComponent { public: inline static const eReplicaComponentType ComponentType = eReplicaComponentType::MINIGAME_CONTROL; - MinigameControlComponent(Entity* parent); + MinigameControlComponent(Entity* parent, int32_t componentId); }; #endif //!__MINIGAMECONTROLCOMPONENT__H__ diff --git a/dGame/dComponents/QuickBuildComponent.cpp b/dGame/dComponents/QuickBuildComponent.cpp index eb961a45..c6e888a4 100644 --- a/dGame/dComponents/QuickBuildComponent.cpp +++ b/dGame/dComponents/QuickBuildComponent.cpp @@ -25,7 +25,7 @@ #include "CppScripts.h" -QuickBuildComponent::QuickBuildComponent(Entity* entity) : ActivityComponent(entity) { +QuickBuildComponent::QuickBuildComponent(Entity* entity, int32_t componentId) : ActivityComponent(entity, componentId) { m_ComponentId = componentId; std::u16string checkPreconditions = entity->GetVar(u"CheckPrecondition"); diff --git a/dGame/dComponents/QuickBuildComponent.h b/dGame/dComponents/QuickBuildComponent.h index cbbcdb8f..23d92dbd 100644 --- a/dGame/dComponents/QuickBuildComponent.h +++ b/dGame/dComponents/QuickBuildComponent.h @@ -24,7 +24,7 @@ class QuickBuildComponent : public ActivityComponent { public: inline static const eReplicaComponentType ComponentType = eReplicaComponentType::QUICK_BUILD; - QuickBuildComponent(Entity* entity, uint32_t componentId = 0); + QuickBuildComponent(Entity* entity, int32_t componentId = 0); ~QuickBuildComponent() override; void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); @@ -351,7 +351,7 @@ private: */ PreconditionExpression* m_Precondition = nullptr; - uint32_t m_ComponentId = 0; + int32_t m_ComponentId = 0; /** * Starts the rebuild for a certain entity diff --git a/dGame/dComponents/RacingComponent.cpp b/dGame/dComponents/RacingComponent.cpp index 50c238c6..b203f02d 100644 --- a/dGame/dComponents/RacingComponent.cpp +++ b/dGame/dComponents/RacingComponent.cpp @@ -1,5 +1,5 @@ #include "RacingComponent.h" -RacingComponent::RacingComponent(Entity* parent) : RacingControlComponent(parent) { +RacingComponent::RacingComponent(Entity* parent, int32_t componentId) : RacingControlComponent(parent, componentId) { } diff --git a/dGame/dComponents/RacingComponent.h b/dGame/dComponents/RacingComponent.h index e7cce7a4..dcd87bb1 100644 --- a/dGame/dComponents/RacingComponent.h +++ b/dGame/dComponents/RacingComponent.h @@ -9,7 +9,7 @@ class Entity; class RacingComponent : public RacingControlComponent { public: inline static const eReplicaComponentType ComponentType = eReplicaComponentType::RACING_CONTROL; - RacingComponent(Entity* parent); + RacingComponent(Entity* parent, int32_t componentId); }; diff --git a/dGame/dComponents/RacingControlComponent.cpp b/dGame/dComponents/RacingControlComponent.cpp index 8f1b7ee7..0f31df04 100644 --- a/dGame/dComponents/RacingControlComponent.cpp +++ b/dGame/dComponents/RacingControlComponent.cpp @@ -29,7 +29,7 @@ #define M_PI 3.14159265358979323846264338327950288 #endif -RacingControlComponent::RacingControlComponent(Entity* parent) : ScriptedActivityComponent(parent) { +RacingControlComponent::RacingControlComponent(Entity* parent, int32_t componentId) : ScriptedActivityComponent(parent, componentId) { m_PathName = u"MainPath"; m_RemainingLaps = 3; m_LeadingPlayer = LWOOBJID_EMPTY; diff --git a/dGame/dComponents/RacingControlComponent.h b/dGame/dComponents/RacingControlComponent.h index 156403a8..6007e2d5 100644 --- a/dGame/dComponents/RacingControlComponent.h +++ b/dGame/dComponents/RacingControlComponent.h @@ -107,7 +107,7 @@ class RacingControlComponent : public ScriptedActivityComponent { public: inline static const eReplicaComponentType ComponentType = eReplicaComponentType::RACING_CONTROL; - RacingControlComponent(Entity* parentEntity); + RacingControlComponent(Entity* parentEntity, int32_t componentId); ~RacingControlComponent(); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); diff --git a/dGame/dComponents/ScriptedActivityComponent.cpp b/dGame/dComponents/ScriptedActivityComponent.cpp index 03063578..a90c08da 100644 --- a/dGame/dComponents/ScriptedActivityComponent.cpp +++ b/dGame/dComponents/ScriptedActivityComponent.cpp @@ -1,5 +1,5 @@ #include "ScriptedActivityComponent.h" -ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent) : ActivityComponent(parent) { +ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int32_t componentId) : ActivityComponent(parent, componentId) { } diff --git a/dGame/dComponents/ScriptedActivityComponent.h b/dGame/dComponents/ScriptedActivityComponent.h index adcbf42f..dd9c8629 100644 --- a/dGame/dComponents/ScriptedActivityComponent.h +++ b/dGame/dComponents/ScriptedActivityComponent.h @@ -10,7 +10,7 @@ class Entity; class ScriptedActivityComponent : public ActivityComponent { public: inline static const eReplicaComponentType ComponentType = eReplicaComponentType::SCRIPTED_ACTIVITY; - ScriptedActivityComponent(Entity* parent); + ScriptedActivityComponent(Entity* parent, int32_t componentId); }; #endif //!__SCRIPTEDACTIVITYCOMPONENT__H__ diff --git a/dGame/dComponents/ShootingGalleryComponent.cpp b/dGame/dComponents/ShootingGalleryComponent.cpp index f2c6d0e9..bf54861c 100644 --- a/dGame/dComponents/ShootingGalleryComponent.cpp +++ b/dGame/dComponents/ShootingGalleryComponent.cpp @@ -2,7 +2,7 @@ #include "EntityManager.h" #include "ScriptedActivityComponent.h" -ShootingGalleryComponent::ShootingGalleryComponent(Entity* parent) : ActivityComponent(parent) { +ShootingGalleryComponent::ShootingGalleryComponent(Entity* parent, int32_t componentId) : ActivityComponent(parent, componentId) { } ShootingGalleryComponent::~ShootingGalleryComponent() = default; diff --git a/dGame/dComponents/ShootingGalleryComponent.h b/dGame/dComponents/ShootingGalleryComponent.h index 319ac4ae..2f82b296 100644 --- a/dGame/dComponents/ShootingGalleryComponent.h +++ b/dGame/dComponents/ShootingGalleryComponent.h @@ -75,7 +75,7 @@ class ShootingGalleryComponent : public ActivityComponent { public: inline static const eReplicaComponentType ComponentType = eReplicaComponentType::SHOOTING_GALLERY; - explicit ShootingGalleryComponent(Entity* parent); + explicit ShootingGalleryComponent(Entity* parent, int32_t componentId); ~ShootingGalleryComponent(); void Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate, uint32_t& flags) const; diff --git a/dGame/dEntity/Entity.cpp b/dGame/dEntity/Entity.cpp index b08d95f4..274c7385 100644 --- a/dGame/dEntity/Entity.cpp +++ b/dGame/dEntity/Entity.cpp @@ -305,7 +305,7 @@ void Entity::Initialize() { AddComponent(); break; case eReplicaComponentType::SHOOTING_GALLERY: - AddComponent(); + AddComponent(componentId); break; case eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS: if (hasPhysicsComponent) continue; @@ -402,7 +402,7 @@ void Entity::Initialize() { AddComponent(); break; case eReplicaComponentType::MINIGAME_CONTROL: - AddComponent(); + AddComponent(componentId); break; case eReplicaComponentType::BASE_COMBAT_AI: { auto* baseCombatAiComponent = AddComponent(componentId); @@ -556,7 +556,7 @@ void Entity::Initialize() { case eReplicaComponentType::PLAYER_FORCED_MOVEMENT: case eReplicaComponentType::CRAFTING: case eReplicaComponentType::LEVEL_PROGRESSION: - case eReplicaComponentType::POSSESSOR: + case eReplicaComponentType::POSSESSION: case eReplicaComponentType::MOUNT_CONTROL: case eReplicaComponentType::UNKNOWN_112: case eReplicaComponentType::PROPERTY_PLAQUE: