patch activity id not using overridden id

Update ActivityComponent.h
This commit is contained in:
David Markowitz 2024-01-06 01:44:11 -08:00
parent 14c20fbd62
commit 20f7a8ff88
2 changed files with 25 additions and 17 deletions

View File

@ -30,23 +30,11 @@
#include "LeaderboardManager.h" #include "LeaderboardManager.h"
ActivityComponent::ActivityComponent(Entity* parent, int32_t activityID) : Component(parent) { ActivityComponent::ActivityComponent(Entity* parent, int32_t activityID) : Component(parent) {
if (activityID > 0) m_ActivityID = activityID; m_ActivityID = activityID;
else m_ActivityID = parent->GetVar<int32_t>(u"activityID"); LoadActivityData(activityID);
CDActivitiesTable* activitiesTable = CDClientManager::Instance().GetTable<CDActivitiesTable>(); if (m_Parent->HasVar(u"activityID")) {
std::vector<CDActivities> activities = activitiesTable->Query([this](CDActivities entry) {return (entry.ActivityID == m_ActivityID); }); m_ActivityID = parent->GetVar<int32_t>(u"activityID");
LoadActivityData(m_ActivityID);
for (CDActivities activity : activities) {
m_ActivityInfo = activity;
if (static_cast<Leaderboard::Type>(activity.leaderboardType) == Leaderboard::Type::Racing && Game::config->GetValue("solo_racing") == "1") {
m_ActivityInfo.minTeamSize = 1;
m_ActivityInfo.minTeams = 1;
}
if (m_ActivityInfo.instanceMapID == -1) {
const auto& transferOverride = parent->GetVarAsString(u"transferZoneID");
if (!transferOverride.empty()) {
GeneralUtils::TryParse(transferOverride, m_ActivityInfo.instanceMapID);
}
}
} }
auto* destroyableComponent = m_Parent->GetComponent<DestroyableComponent>(); auto* destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
@ -74,6 +62,24 @@ ActivityComponent::ActivityComponent(Entity* parent, int32_t activityID) : Compo
} }
} }
} }
void ActivityComponent::LoadActivityData(const int32_t activityId) {
CDActivitiesTable* activitiesTable = CDClientManager::Instance().GetTable<CDActivitiesTable>();
std::vector<CDActivities> activities = activitiesTable->Query([activityId](CDActivities entry) {return (entry.ActivityID == activityId); });
for (CDActivities activity : activities) {
m_ActivityInfo = activity;
if (static_cast<Leaderboard::Type>(activity.leaderboardType) == Leaderboard::Type::Racing && Game::config->GetValue("solo_racing") == "1") {
m_ActivityInfo.minTeamSize = 1;
m_ActivityInfo.minTeams = 1;
}
if (m_ActivityInfo.instanceMapID == -1) {
const auto& transferOverride = m_Parent->GetVarAsString(u"transferZoneID");
if (!transferOverride.empty()) {
GeneralUtils::TryParse(transferOverride, m_ActivityInfo.instanceMapID);
}
}
}
}
void ActivityComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { void ActivityComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write(m_DirtyActivityInfo); outBitStream->Write(m_DirtyActivityInfo);

View File

@ -152,6 +152,8 @@ class ActivityComponent : public Component {
public: public:
ActivityComponent(Entity* parent, int32_t activityID); ActivityComponent(Entity* parent, int32_t activityID);
void LoadActivityData(const int32_t activityId);
void Update(float deltaTime) override; void Update(float deltaTime) override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;