mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-16 00:35:27 +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:
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "AssetManager.h"
|
||||
#include "CDClientManager.h"
|
||||
#include "CDSceneTableTable.h"
|
||||
#include "CDZoneTableTable.h"
|
||||
#include "CDClientDatabase.h"
|
||||
#include "Spawner.h"
|
||||
@@ -32,13 +33,6 @@ Zone::Zone(const LWOZONEID zoneID) :
|
||||
m_CheckSum = 0;
|
||||
m_WorldID = 0;
|
||||
m_SceneCount = 0;
|
||||
m_SceneTableLookup = [](uint32_t sceneTableID) -> std::optional<std::string> {
|
||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT sceneName FROM SceneTable WHERE sceneID = ?;");
|
||||
query.bind(1, static_cast<int32_t>(sceneTableID));
|
||||
auto result = query.execQuery();
|
||||
if (result.eof() || result.fieldIsNull("sceneName")) return std::nullopt;
|
||||
return std::string(result.getStringField("sceneName"));
|
||||
};
|
||||
}
|
||||
|
||||
Zone::~Zone() {
|
||||
@@ -70,7 +64,11 @@ void Zone::LoadZoneIntoMemory() {
|
||||
ZoneFile zoneFile;
|
||||
zoneFile.Read(file);
|
||||
// The oldest files name their scenes by SceneTable ID
|
||||
zoneFile.ResolveSceneTable(m_SceneTableLookup);
|
||||
zoneFile.ResolveSceneTable([](uint32_t sceneTableID) -> std::optional<std::string> {
|
||||
const auto* sceneTableEntry = CDSceneTableTable::Query(sceneTableID);
|
||||
if (!sceneTableEntry) return std::nullopt;
|
||||
return sceneTableEntry->sceneName;
|
||||
});
|
||||
m_FileFormatVersion = zoneFile.fileFormatVersion;
|
||||
m_WorldID = zoneFile.worldID;
|
||||
if (static_cast<LWOMAPID>(m_WorldID) != m_ZoneID.GetMapID()) LOG("WorldID: %i doesn't match MapID %i! Is this intended?", m_WorldID, m_ZoneID.GetMapID());
|
||||
|
||||
Reference in New Issue
Block a user