Add LoadValuesFromDefaults for CDClient tables used by ActivityComponent

Co-authored-by: aronwk-aaron <26027722+aronwk-aaron@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-08-31 20:45:21 +00:00
parent a18a3f5b25
commit 6d96eb208c
7 changed files with 71 additions and 0 deletions

View File

@@ -155,4 +155,7 @@ void CDClientManager::LoadValuesFromDefaults() {
LOG("Loading default CDClient tables!"); LOG("Loading default CDClient tables!");
CDPetComponentTable::Instance().LoadValuesFromDefaults(); CDPetComponentTable::Instance().LoadValuesFromDefaults();
CDActivitiesTable::Instance().LoadValuesFromDefaults();
CDActivityRewardsTable::Instance().LoadValuesFromDefaults();
CDCurrencyTableTable::Instance().LoadValuesFromDefaults();
} }

View File

@@ -1,5 +1,29 @@
#include "CDActivitiesTable.h" #include "CDActivitiesTable.h"
namespace {
// Default entries for fallback
CDActivities defaultEntry{
.ActivityID = 1,
.locStatus = 0,
.instanceMapID = 0,
.minTeams = 1,
.maxTeams = 1,
.minTeamSize = 1,
.maxTeamSize = 1,
.waitTime = 0,
.startDelay = 0,
.requiresUniqueData = false,
.leaderboardType = 0,
.localize = false,
.optionalCostLOT = -1,
.optionalCostCount = -1,
.showUIRewards = false,
.CommunityActivityFlagID = 0,
.gate_version = "",
.noTeamLootOnDeath = false,
.optionalPercentage = 0.0f,
};
}
void CDActivitiesTable::LoadValuesFromDatabase() { void CDActivitiesTable::LoadValuesFromDatabase() {
// First, get the size of the table // First, get the size of the table
@@ -48,6 +72,12 @@ void CDActivitiesTable::LoadValuesFromDatabase() {
tableData.finalize(); tableData.finalize();
} }
void CDActivitiesTable::LoadValuesFromDefaults() {
auto& entries = GetEntriesMutable();
entries.clear();
entries.push_back(defaultEntry);
}
std::vector<CDActivities> CDActivitiesTable::Query(std::function<bool(CDActivities)> predicate) { std::vector<CDActivities> CDActivitiesTable::Query(std::function<bool(CDActivities)> predicate) {
std::vector<CDActivities> data = cpplinq::from(GetEntries()) std::vector<CDActivities> data = cpplinq::from(GetEntries())

View File

@@ -28,6 +28,7 @@ struct CDActivities {
class CDActivitiesTable : public CDTable<CDActivitiesTable, std::vector<CDActivities>> { class CDActivitiesTable : public CDTable<CDActivitiesTable, std::vector<CDActivities>> {
public: public:
void LoadValuesFromDatabase(); void LoadValuesFromDatabase();
void LoadValuesFromDefaults();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDActivities> Query(std::function<bool(CDActivities)> predicate); std::vector<CDActivities> Query(std::function<bool(CDActivities)> predicate);

View File

@@ -1,5 +1,17 @@
#include "CDActivityRewardsTable.h" #include "CDActivityRewardsTable.h"
namespace {
// Default entries for fallback
CDActivityRewards defaultEntry{
.objectTemplate = 1,
.ActivityRewardIndex = 1,
.activityRating = 1,
.LootMatrixIndex = 0,
.CurrencyIndex = 1,
.ChallengeRating = 1,
.description = "Default test activity reward",
};
}
void CDActivityRewardsTable::LoadValuesFromDatabase() { void CDActivityRewardsTable::LoadValuesFromDatabase() {
@@ -37,6 +49,12 @@ void CDActivityRewardsTable::LoadValuesFromDatabase() {
tableData.finalize(); tableData.finalize();
} }
void CDActivityRewardsTable::LoadValuesFromDefaults() {
auto& entries = GetEntriesMutable();
entries.clear();
entries.push_back(defaultEntry);
}
std::vector<CDActivityRewards> CDActivityRewardsTable::Query(std::function<bool(CDActivityRewards)> predicate) { std::vector<CDActivityRewards> CDActivityRewardsTable::Query(std::function<bool(CDActivityRewards)> predicate) {
std::vector<CDActivityRewards> data = cpplinq::from(GetEntries()) std::vector<CDActivityRewards> data = cpplinq::from(GetEntries())

View File

@@ -16,6 +16,7 @@ struct CDActivityRewards {
class CDActivityRewardsTable : public CDTable<CDActivityRewardsTable, std::vector<CDActivityRewards>> { class CDActivityRewardsTable : public CDTable<CDActivityRewardsTable, std::vector<CDActivityRewards>> {
public: public:
void LoadValuesFromDatabase(); void LoadValuesFromDatabase();
void LoadValuesFromDefaults();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDActivityRewards> Query(std::function<bool(CDActivityRewards)> predicate); std::vector<CDActivityRewards> Query(std::function<bool(CDActivityRewards)> predicate);
}; };

View File

@@ -1,5 +1,16 @@
#include "CDCurrencyTableTable.h" #include "CDCurrencyTableTable.h"
namespace {
// Default entries for fallback
CDCurrencyTable defaultEntry{
.currencyIndex = 1,
.npcminlevel = 1,
.minvalue = 1,
.maxvalue = 10,
.id = 1,
};
}
//! Constructor //! Constructor
void CDCurrencyTableTable::LoadValuesFromDatabase() { void CDCurrencyTableTable::LoadValuesFromDatabase() {
@@ -35,6 +46,12 @@ void CDCurrencyTableTable::LoadValuesFromDatabase() {
tableData.finalize(); tableData.finalize();
} }
void CDCurrencyTableTable::LoadValuesFromDefaults() {
auto& entries = GetEntriesMutable();
entries.clear();
entries.push_back(defaultEntry);
}
std::vector<CDCurrencyTable> CDCurrencyTableTable::Query(std::function<bool(CDCurrencyTable)> predicate) { std::vector<CDCurrencyTable> CDCurrencyTableTable::Query(std::function<bool(CDCurrencyTable)> predicate) {
std::vector<CDCurrencyTable> data = cpplinq::from(GetEntries()) std::vector<CDCurrencyTable> data = cpplinq::from(GetEntries())
>> cpplinq::where(predicate) >> cpplinq::where(predicate)

View File

@@ -21,6 +21,7 @@ struct CDCurrencyTable {
class CDCurrencyTableTable : public CDTable<CDCurrencyTableTable, std::vector<CDCurrencyTable>> { class CDCurrencyTableTable : public CDTable<CDCurrencyTableTable, std::vector<CDCurrencyTable>> {
public: public:
void LoadValuesFromDatabase(); void LoadValuesFromDatabase();
void LoadValuesFromDefaults();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDCurrencyTable> Query(std::function<bool(CDCurrencyTable)> predicate); std::vector<CDCurrencyTable> Query(std::function<bool(CDCurrencyTable)> predicate);
}; };