mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-06 11:57:13 +00:00
refactor: look up the oldest zone files' scenes in a CDClient SceneTable table
Zone held a std::function that queried the SceneTable, so tests could swap it out. CDSceneTableTable now loads the table with the others, and Zone looks scenes up in it; tests fill its entries like the zone table's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include "CDRebuildComponentTable.h"
|
||||
#include "CDScriptComponentTable.h"
|
||||
#include "CDSkillBehaviorTable.h"
|
||||
#include "CDSceneTableTable.h"
|
||||
#include "CDZoneTableTable.h"
|
||||
#include "CDTamingBuildPuzzleTable.h"
|
||||
#include "CDVendorComponentTable.h"
|
||||
@@ -144,6 +145,7 @@ void CDClientManager::LoadValuesFromDatabase() {
|
||||
CDRebuildComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDRewardCodesTable::Instance().LoadValuesFromDatabase();
|
||||
CDRewardsTable::Instance().LoadValuesFromDatabase();
|
||||
CDSceneTableTable::LoadValuesFromDatabase();
|
||||
CDScriptComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDSkillBehaviorTable::Instance().LoadValuesFromDatabase();
|
||||
CDTamingBuildPuzzleTable::Instance().LoadValuesFromDatabase();
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "CDSceneTableTable.h"
|
||||
|
||||
namespace CDSceneTableTable {
|
||||
Table entries;
|
||||
|
||||
void LoadValuesFromDatabase() {
|
||||
// Get the data from the database
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM SceneTable");
|
||||
while (!tableData.eof()) {
|
||||
CDSceneTable entry;
|
||||
entry.sceneID = tableData.getIntField("sceneID", -1);
|
||||
entry.sceneName = tableData.getStringField("sceneName", "");
|
||||
|
||||
entries[entry.sceneID] = entry;
|
||||
tableData.nextRow();
|
||||
}
|
||||
}
|
||||
|
||||
//! Queries the table with a sceneID to find.
|
||||
const CDSceneTable* Query(uint32_t sceneID) {
|
||||
const auto& iter = entries.find(sceneID);
|
||||
if (iter != entries.end()) {
|
||||
return &iter->second;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
// Custom Classes
|
||||
#include "CDTable.h"
|
||||
|
||||
struct CDSceneTable {
|
||||
uint32_t sceneID; //!< The scene's ID, as zone files before version 30 list their scenes
|
||||
std::string sceneName; //!< The scene's file
|
||||
};
|
||||
|
||||
namespace CDSceneTableTable {
|
||||
using Table = std::map<uint32_t, CDSceneTable>;
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
// Queries the table with a sceneID to find.
|
||||
const CDSceneTable* Query(uint32_t sceneID);
|
||||
};
|
||||
@@ -35,6 +35,7 @@ set(DDATABASE_CDCLIENTDATABASE_CDCLIENTTABLES_SOURCES "CDActivitiesTable.cpp"
|
||||
"CDRebuildComponentTable.cpp"
|
||||
"CDRewardCodesTable.cpp"
|
||||
"CDRewardsTable.cpp"
|
||||
"CDSceneTableTable.cpp"
|
||||
"CDScriptComponentTable.cpp"
|
||||
"CDSkillBehaviorTable.cpp"
|
||||
"CDTamingBuildPuzzleTable.cpp"
|
||||
|
||||
Reference in New Issue
Block a user