mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 05:27:19 +00:00
fix: activity id not using overridden id (#1400)
* patch activity id not using overridden id Update ActivityComponent.h * Update ActivityComponent.cpp * Update ActivityComponent.cpp
This commit is contained in:
parent
dbe4a0ced3
commit
e4469f997e
@ -30,23 +30,17 @@
|
|||||||
#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;
|
/*
|
||||||
else m_ActivityID = parent->GetVar<int32_t>(u"activityID");
|
* This is precisely what the client does functionally
|
||||||
CDActivitiesTable* activitiesTable = CDClientManager::Instance().GetTable<CDActivitiesTable>();
|
* Use the component id as the default activity id and load its data from the database
|
||||||
std::vector<CDActivities> activities = activitiesTable->Query([this](CDActivities entry) {return (entry.ActivityID == m_ActivityID); });
|
* if activityID is specified and if that column exists in the activities table, update the activity info with that data.
|
||||||
|
*/
|
||||||
|
|
||||||
for (CDActivities activity : activities) {
|
m_ActivityID = activityID;
|
||||||
m_ActivityInfo = activity;
|
LoadActivityData(activityID);
|
||||||
if (static_cast<Leaderboard::Type>(activity.leaderboardType) == Leaderboard::Type::Racing && Game::config->GetValue("solo_racing") == "1") {
|
if (m_Parent->HasVar(u"activityID")) {
|
||||||
m_ActivityInfo.minTeamSize = 1;
|
m_ActivityID = parent->GetVar<int32_t>(u"activityID");
|
||||||
m_ActivityInfo.minTeams = 1;
|
LoadActivityData(m_ActivityID);
|
||||||
}
|
|
||||||
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 +68,25 @@ 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); });
|
||||||
|
|
||||||
|
bool soloRacing = Game::config->GetValue("solo_racing") == "1";
|
||||||
|
for (CDActivities activity : activities) {
|
||||||
|
m_ActivityInfo = activity;
|
||||||
|
if (static_cast<Leaderboard::Type>(activity.leaderboardType) == Leaderboard::Type::Racing && soloRacing) {
|
||||||
|
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);
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user