Skip to content

feat(server): implement live map hot-reload without restarting server (closes #11) - #364

Open
ThiagoLPereira wants to merge 4 commits into
Bitcoindefi:mainfrom
ThiagoLPereira:feat/live-map-hot-reload
Open

ThiagoLPereira wants to merge 4 commits into
Bitcoindefi:mainfrom
ThiagoLPereira:feat/live-map-hot-reload

Conversation

@ThiagoLPereira

@ThiagoLPereira ThiagoLPereira commented Sep 8, 2026

Copy link
Copy Markdown

Summary

Resolves #11 by introducing live map hot-reloading capabilities without requiring a server reboot.

Key Changes

  1. Live Map Reload (server/src/loadMaps.ts):
    • Implemented reloadMap(mapNum) and reloadAllMaps().
    • Re-reads map definition files while seamlessly preserving all runtime character and NPC entities in vars.mapData.
    • Added findNearestWalkableTile() safe-warp resolution: if a new map version places a blocked tile on an active entity coordinate, the entity is automatically relocated to the nearest walkable tile within a 5-tile radius.
    • Extracted reconcileEntities() generic helper to ensure DRY compliance and unified entity restoration.
  2. Real-time Game State Sync (server/src/gameDataSync.ts):
    • Added reloadMapsDiff() bridge.
    • Added notifyCharactersOnReloadedMaps() to broadcast real-time map updates to connected WebSockets on affected maps.
  3. Admin GM Commands (server/src/commands.ts):
    • /recargarmapa [id]: Reloads a specific map by numeric ID.
    • /recargarmapas: Batch reloads all available maps.
    • Guarded by hasAdminPrivileges(user).
  4. Automated Test Suite (server/tests/):
    • server/tests/reloadMaps.test.ts: 5/5 unit tests covering entity preservation, safe-warp, non-existent map handling, and sync bridge.
    • server/tests/e2e_runtime_verification.test.ts: Comprehensive end-to-end runtime lifecycle simulation.

Verification & Quality Gates

  • tsc --noEmit: 0 errors
  • eslint ./src/**/*.ts: 0 errors, 0 warnings
  • Node Test Runner (tsx --test): 6/6 tests passing
  • Zero-Crash error handling for invalid/negative map IDs

@gitar-bot

gitar-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

Gitar is working

Gitar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Etapa 3: publicar mapas en vivo sin reiniciar el server

1 participant