Skip to content

Commit 82bc605

Browse files
committed
Remove BTech persistence preload shim
1 parent 655f6e2 commit 82bc605

6 files changed

Lines changed: 11 additions & 19 deletions

File tree

src/btech/persistence/btech_persistence_sqlite.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3685,7 +3685,7 @@ static void btech_store_repair_event(MuxEvent *event, void *context_argument) {
36853685
context->result = -1;
36863686
}
36873687

3688-
/* Mirror map dynamic state and repair queues without changing legacy reads. */
3688+
/* Store map dynamic state and repair queues in the SQLite snapshot. */
36893689
static int btech_persistence_store_special_state(
36903690
sqlite3 *sqlite, PersistenceContext *persistence, void *extension_context) {
36913691
BtechContext *btech = extension_context;
@@ -3861,15 +3861,6 @@ static int btech_persistence_store_special_state(
38613861
return result;
38623862
}
38633863

3864-
/* Reads remain on the legacy files during this first BTech dual-write slice. */
3865-
static int btech_persistence_preload_special_state(
3866-
sqlite3 *sqlite, PersistenceContext *persistence, void *extension_context) {
3867-
(void)persistence;
3868-
(void)extension_context;
3869-
(void)sqlite;
3870-
return 0;
3871-
}
3872-
38733864
typedef struct btech_special_object_counts BTECH_SPECIAL_OBJECT_COUNTS;
38743865
struct btech_special_object_counts {
38753866
int maps;
@@ -4313,8 +4304,7 @@ static int btech_persistence_store_economy(sqlite3 *sqlite,
43134304
int btech_persistence_register(PersistenceContext *context,
43144305
BtechContext *btech) {
43154306
if (persistence_register_sqlite_extension(
4316-
context, "btech_special_state",
4317-
btech_persistence_preload_special_state,
4307+
context, "btech_special_state", nullptr,
43184308
btech_persistence_store_special_state, btech) < 0)
43194309
return -1;
43204310
#ifdef BT_ADVANCED_ECON

src/mux/persistence/commac_persistence_sqlite.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
#include "mux/server/server_config.h"
1818
#include "mux/support/utf8.h"
1919

20-
/* The legacy file is read during this phase; SQLite is an atomic dump mirror.
21-
*/
20+
/* SQLite schema for commac, comsys, and macro state. */
2221
static const char commac_schema_sql[] =
2322
"CREATE TABLE commac_entries ("
2423
" who INTEGER PRIMARY KEY, curmac INTEGER NOT NULL,"

src/mux/persistence/gamedb.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ void persistence_context_initialize(
6161
/*
6262
* Register a named SQLite extension before gamedb_load() or gamedb_dump().
6363
* The callbacks are invoked with the SQLite connection owned by this module;
64-
* store callbacks run inside the snapshot transaction. Returns 0 on success
65-
* and -1 if the registration is invalid or the extension limit is reached.
64+
* store callbacks run inside the snapshot transaction. A load callback may be
65+
* nullptr when the subsystem restores its data after core loading. Returns 0
66+
* on success and -1 if the registration is invalid or the extension limit is
67+
* reached.
6668
*/
6769
int persistence_register_sqlite_extension(PersistenceContext *context,
6870
const char *name,

src/mux/persistence/gamedb_sqlite.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ static int gamedb_load_extensions(PersistenceContext *context, sqlite3 *sqlite,
212212

213213
for (index = 0; index < context->extension_count; index++) {
214214
PersistenceSqliteExtension *extension = &context->extensions[index];
215+
if (extension->load == nullptr)
216+
continue;
215217
if (extension->load(sqlite, context, extension->context) < 0) {
216218
gamedb_log_extension_failure(context->log, "loading", extension->name,
217219
path, sqlite);

src/mux/persistence/persistence_registry.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ int persistence_register_sqlite_extension(PersistenceContext *context,
2828
void *extension_context) {
2929
assert(context != nullptr);
3030

31-
if (name == nullptr || *name == '\0' || load == nullptr || store == nullptr)
31+
if (name == nullptr || *name == '\0' || store == nullptr)
3232
return -1;
3333
for (size_t index = 0; index < context->extension_count; index++) {
3434
PersistenceSqliteExtension *extension = &context->extensions[index];

tests/gamedb_integration.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ static int run_server(const char *binary_path, const char *config,
3737
return waitpid(child, status, 0) == child ? 0 : -1;
3838
}
3939

40-
/* Run an isolated server instance so legacy dual-write artifacts stay
41-
* disposable. */
40+
/* Run an isolated server instance so snapshot artifacts stay disposable. */
4241
static int run_server_in_directory_for(const char *binary_path,
4342
const char *config,
4443
const char *directory, int make_minimal,

0 commit comments

Comments
 (0)