fix: integrate SQLite event storage into load/save system
- Fix load_game to use World.create_with_db() for SQLite event storage - Add get_events_db_path() to compute event database path from save path - Add JSON to SQLite migration for backward compatibility with old saves - Close old EventManager before loading new save to prevent connection leaks - Add events_db metadata to save file - Add comprehensive tests for database switching bug and save/load cycle
This commit is contained in:
@@ -1307,6 +1307,11 @@ def api_load_game(req: LoadGameRequest):
|
||||
if not target_path.exists():
|
||||
raise HTTPException(status_code=404, detail="File not found")
|
||||
|
||||
# 关闭旧 World 的 EventManager,释放 SQLite 连接。
|
||||
old_world = game_instance.get("world")
|
||||
if old_world and hasattr(old_world, "event_manager"):
|
||||
old_world.event_manager.close()
|
||||
|
||||
# 加载
|
||||
new_world, new_sim, new_sects = load_game(target_path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user