Files
DarkflameServer/dMasterServer/WorldReloader.h
Aaron Kimbrell 16545d573e 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>
2026-09-30 02:51:21 -05:00

48 lines
1.5 KiB
C++

#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