3.1 KiB
PORT dungeon / calendar extension
The dungeons query reads only the installed dragon_lair_access / dragon_lair_weekly settings functions and own PC flags through GetPCForce. It preserves the quest Lua stack/context. This adapter is specific to the audited quest implementation: changes to its flag names, NPCs or admission logic require review. Only the function settings are dynamic, not an arbitrary automatic quest interpreter. No gate bypass or reward/warp command is added.
Calendar uses a stateless interval scheduler shared by the actual drop gates and the read-only query. Configure LocaleService_GetBasePath()/port_events.tsv (same shared locale path for all cores):
MTCALENDAR 1
# id kind UTC_start_epoch UTC_end_epoch channel empire
Kinds 1 and 2 enable the existing moonlight-box and Christmas-sock branches in CreateQuestDropItem. They do not replace the probabilities, RNG or eligibility in those branches. Existing administrator event flags remain effective independently; ending a scheduled interval does not clear an unrelated administrator flag. Other activity types are rejected. Scope 0 means all channels/empires; channel 1..255, empire 1..3. Time is Unix UTC, start inclusive/end exclusive, unsigned 32-bit bounds; ID unique/nonzero, at most 256 events / 64 KiB. Overlapping intervals do not multiply a drop. There are no repeated start/end grants or database mutations.
Use tools/calendar/port_events.tsv.example as a valid empty template. Review dates and effects before publishing. Write a temporary file then atomic rename on the common locale filesystem. Each process refreshes within 5 seconds; runtime uses server time for every interval check so restarts and clock adjustments do not leave event flags stuck on. Atomic inode replacement is detected even for same-size/same-second edits. An invalid/missing file clears scheduled effects and returns schedule_unavailable. Roll back by publishing a valid empty schedule. The production file was not installed by development/validation.
Validation:
python3 tests/features/test_queries.py
python3 tests/features/test_calendar.py
On FreeBSD compile tests/features/dungeon_lua_probe.cpp with -std=c++17, game/src and liblua/include include paths, linking project's liblualib.a then liblua.a and -lm. Run with the installed compiled quest files quest/object/state/dragon_lair_access and dragon_lair_weekly. This independent process does not connect to the game/DB and does not modify quest files. It verifies actual task functions rather than hardcoded fixture timing alone.
The full game target was rebuilt only under /root/metin2-features-dev, with forced rebuild of item_manager.cpp/cmd_general.cpp. No production binary replacement, restart, DB migration or event activation occurred. Live deployment acceptance, real Android interaction, other dungeons and other activity types remain outside this batch.
Update 2026-10-15: this code went live on 203 together with switchbot and pickup (main 3b7e158); see the production deployment section of FEATURE-SWITCHBOT.md. No port_events.tsv is installed, so the calendar gates are still inert.