mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-20 10:45:27 +00:00
refactor(component): activities load their activity in the client's phases
The component ID's activity in LoadDataFromTemplate, the level's activityID in LoadConfigData; racing control picks its world's activity after both, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -38,16 +38,22 @@ namespace {
|
|||||||
|
|
||||||
ActivityComponent::ActivityComponent(Entity* parent, int32_t componentID) : Component(parent, componentID) {
|
ActivityComponent::ActivityComponent(Entity* parent, int32_t componentID) : Component(parent, componentID) {
|
||||||
RegisterMsg(&ActivityComponent::OnGetObjectReportInfo);
|
RegisterMsg(&ActivityComponent::OnGetObjectReportInfo);
|
||||||
/*
|
}
|
||||||
* This is precisely what the client does functionally
|
|
||||||
* Use the component id as the default activity id and load its data from the database
|
|
||||||
* if activityID is specified and if that column exists in the activities table, update the activity info with that data.
|
|
||||||
*/
|
|
||||||
|
|
||||||
m_ActivityID = componentID;
|
/*
|
||||||
LoadActivityData(componentID);
|
* This is precisely what the client does functionally
|
||||||
|
* Use the component id as the default activity id and load its data from the database
|
||||||
|
* if activityID is specified and if that column exists in the activities table, update the activity info with that data.
|
||||||
|
*/
|
||||||
|
void ActivityComponent::LoadDataFromTemplate() {
|
||||||
|
m_ActivityID = m_ComponentID;
|
||||||
|
LoadActivityData(m_ComponentID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The level config's activityID, when there, replaces it
|
||||||
|
void ActivityComponent::LoadConfigData() {
|
||||||
if (m_Parent->HasVar(u"activityID")) {
|
if (m_Parent->HasVar(u"activityID")) {
|
||||||
m_ActivityID = parent->GetVar<int32_t>(u"activityID");
|
m_ActivityID = m_Parent->GetVar<int32_t>(u"activityID");
|
||||||
LoadActivityData(m_ActivityID);
|
LoadActivityData(m_ActivityID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,6 +128,9 @@ class ActivityComponent : public Component {
|
|||||||
public:
|
public:
|
||||||
ActivityComponent(Entity* parent, int32_t activityID);
|
ActivityComponent(Entity* parent, int32_t activityID);
|
||||||
|
|
||||||
|
void LoadDataFromTemplate() override;
|
||||||
|
void LoadConfigData() override;
|
||||||
|
|
||||||
void LoadActivityData(const int32_t activityId);
|
void LoadActivityData(const int32_t activityId);
|
||||||
|
|
||||||
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
||||||
|
|||||||
@@ -58,11 +58,18 @@ RacingControlComponent::RacingControlComponent(Entity* parent, const int32_t com
|
|||||||
const auto worldID = Game::server->GetZoneID();
|
const auto worldID = Game::server->GetZoneID();
|
||||||
if (Game::zoneManager->CheckIfAccessibleZone((worldID / 10) * 10)) m_MainWorld = (worldID / 10) * 10;
|
if (Game::zoneManager->CheckIfAccessibleZone((worldID / 10) * 10)) m_MainWorld = (worldID / 10) * 10;
|
||||||
|
|
||||||
|
RegisterMsg(&RacingControlComponent::MsgConfigureRacingControl);
|
||||||
|
}
|
||||||
|
|
||||||
|
// After the activity's own loading: the race's activity is the one of this world (42 when none)
|
||||||
|
void RacingControlComponent::LoadConfigData() {
|
||||||
|
ActivityComponent::LoadConfigData();
|
||||||
|
|
||||||
|
const auto worldID = Game::server->GetZoneID();
|
||||||
m_ActivityID = 42;
|
m_ActivityID = 42;
|
||||||
CDActivitiesTable* activitiesTable = CDClientManager::GetTable<CDActivitiesTable>();
|
CDActivitiesTable* activitiesTable = CDClientManager::GetTable<CDActivitiesTable>();
|
||||||
std::vector<CDActivities> activities = activitiesTable->Query([=](CDActivities entry) {return (entry.instanceMapID == worldID); });
|
std::vector<CDActivities> activities = activitiesTable->Query([=](CDActivities entry) {return (entry.instanceMapID == worldID); });
|
||||||
for (CDActivities activity : activities) m_ActivityID = activity.ActivityID;
|
for (CDActivities activity : activities) m_ActivityID = activity.ActivityID;
|
||||||
RegisterMsg(&RacingControlComponent::MsgConfigureRacingControl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RacingControlComponent::~RacingControlComponent() {}
|
RacingControlComponent::~RacingControlComponent() {}
|
||||||
|
|||||||
@@ -126,6 +126,8 @@ public:
|
|||||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::RACING_CONTROL;
|
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::RACING_CONTROL;
|
||||||
|
|
||||||
RacingControlComponent(Entity* parentEntity, const int32_t componentID);
|
RacingControlComponent(Entity* parentEntity, const int32_t componentID);
|
||||||
|
|
||||||
|
void LoadConfigData() override;
|
||||||
~RacingControlComponent();
|
~RacingControlComponent();
|
||||||
|
|
||||||
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
||||||
|
|||||||
Reference in New Issue
Block a user