mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
feat(master): watch world zone files and replace instances that loaded old ones
Master hashes each reported file on a worker, polls size and mtime every world_watch_seconds (a change must hold still for one poll), and replaces stale instances with the instance migration (Mythran shift, or seamless with world_reload_seamless=1); empty ones are stopped. Also on WORLD_RELOAD. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
47
dMasterServer/WorldReloader.h
Normal file
47
dMasterServer/WorldReloader.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef WORLDRELOADER_H
|
||||
#define WORLDRELOADER_H
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include "RakNetTypes.h"
|
||||
|
||||
class Instance;
|
||||
struct MigrationStatus;
|
||||
struct WorldFilesReport;
|
||||
struct WorldFilesStatus;
|
||||
struct WorldReloadRequest;
|
||||
|
||||
/**
|
||||
* Master's side of world hot reload (docs/WorldHotReload.md). Worlds report the zone files they loaded (WORLD_FILES);
|
||||
* master watches them (size and mtime every world_watch_seconds, then a hash on a worker thread) and, when one changes
|
||||
* or a GM or the dashboard asks (WORLD_RELOAD), replaces the affected instances with new ones on the files on disk,
|
||||
* moving their players with the instance migration (MigrationCoordinator). Main thread only.
|
||||
*/
|
||||
namespace WorldReloader {
|
||||
// Where the dashboard's status goes (WORLD_FILES_STATUS)
|
||||
void SetPublisher(std::function<void(const WorldFilesStatus&)> publisher);
|
||||
|
||||
// A world reported its files
|
||||
void HandleReport(const SystemAddress& from, const WorldFilesReport& report);
|
||||
|
||||
// A GM's /reloadworld or the dashboard; who is for the log
|
||||
void HandleRequest(const WorldReloadRequest& request, const std::string& who);
|
||||
|
||||
// Every migration's progress (MigrationCoordinator's observer)
|
||||
void OnMigrationStatus(const MigrationStatus& status);
|
||||
|
||||
// A world server went away
|
||||
void OnInstanceGone(const Instance& instance);
|
||||
|
||||
// The dashboard connected: send it the status again
|
||||
void Republish();
|
||||
|
||||
// Every master frame: polls the files, finishes hashes and reloads what changed
|
||||
void Update();
|
||||
|
||||
// Waits for a running hash (at shutdown)
|
||||
void Shutdown();
|
||||
};
|
||||
|
||||
#endif // WORLDRELOADER_H
|
||||
Reference in New Issue
Block a user