Files
DarkflameServer/dDatabase/CDClientDatabase/CDClientTables/CDComponentsRegistryTable.h
Aaron Kimbrell a4fa7eb30a perf(cdclient): read ComponentsRegistry, ItemComponent and Objects from the fdb
The world and master servers pass the client's res/cdclient.fdb to
CDClientManager. When it opens, these three tables, all looked up by
their first column, find rows through the fdb's buckets instead of each
process caching the whole table: ComponentsRegistry keeps nothing,
ItemComponent and Objects keep only the entries asked for (their API
returns references). Ids whose rows CDServer.sqlite changes are loaded
from SQLite at startup and win. Without an fdb (or with one whose
columns don't match) the tables load from CDServer.sqlite as before.

ItemComponent and Objects now fill entries from one template for both
sources instead of copies of the same field list.

Tests cover the SQLite changes on top of the fdb, the no-fdb and
unmapped paths, and, when DLU_CLIENT_RES points at a client, every id of
the three tables through the fdb against CDServer.sqlite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 22:07:46 -05:00

35 lines
1.1 KiB
C++

#pragma once
// Custom Classes
#include "CDTable.h"
#include <unordered_map>
#include "FdbReader.h"
enum class eReplicaComponentType : uint32_t;
struct CDComponentsRegistry {
uint32_t id; //!< The LOT is used as the ID
eReplicaComponentType component_type; //!< See ComponentTypes enum for values
uint32_t component_id; //!< The ID used within the component's table (0 may either mean it's non-networked, or that the ID is actually 0
};
class CDComponentsRegistryTable : public CDTable<CDComponentsRegistryTable, std::unordered_map<uint64_t, uint32_t>> {
public:
void LoadValuesFromDatabase();
// Reads rows from the client's fdb from now on, if it is open; false keeps the table on CDServer.sqlite
bool LoadFromFdb();
int32_t GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue = 0);
private:
// Caches every row of one id from CDServer.sqlite
void LoadFromSqlite(uint32_t id);
const FdbReader::Table* m_FdbTable = nullptr;
int32_t m_TypeColumn = -1;
int32_t m_ComponentIdColumn = -1;
};