mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-21 20:22:48 +00:00
feat(cdclient): make a new CDServer.sqlite off-thread and swap tables in place
CDClientSnapshot converts a copy of the client's fdb into its own CDServer-<hash>.sqlite with the cdserver migrations applied, on its own connection. CDClientDatabase::Reconnect opens the new file before letting go of the old one; CDClientManager::Reload empties every table (old entries kept alive so references from spawned objects stay valid), retires the old fdb view and loads again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
#include "CDZoneTableTable.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace CDZoneTableTable {
|
||||
Table entries;
|
||||
|
||||
void Reset() {
|
||||
static std::vector<std::unique_ptr<Table>> retired;
|
||||
retired.push_back(std::make_unique<Table>(std::move(entries)));
|
||||
entries = {};
|
||||
}
|
||||
|
||||
void LoadValuesFromDatabase() {
|
||||
// Get the data from the database
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ZoneTable");
|
||||
|
||||
@@ -37,6 +37,9 @@ namespace CDZoneTableTable {
|
||||
using Table = std::map<uint32_t, CDZoneTable>;
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
// Empties the table for a CDClient reload. The old entries are kept alive, so a pointer from Query stays valid
|
||||
void Reset();
|
||||
|
||||
// Queries the table with a zoneID to find.
|
||||
const CDZoneTable* Query(uint32_t zoneID);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user