Skip to content

fix(quest): harden quest parsing and mission update mapping across server variants#4206

Open
boscv wants to merge 4 commits intoOpenKore:masterfrom
boscv:huntMission
Open

fix(quest): harden quest parsing and mission update mapping across server variants#4206
boscv wants to merge 4 commits intoOpenKore:masterfrom
boscv:huntMission

Conversation

@boscv
Copy link
Copy Markdown
Contributor

@boscv boscv commented Apr 9, 2026

Summary

This PR improves quest hunt mission parsing/mapping for servers that send incomplete or non-standard identifiers (e.g., unresolved mission_id, atypical hunt_id, or hunt_id_cont patterns), and adds regression coverage for the new behavior.

What changed

Quest mission mapping robustness

  • Improved quest_update_mission_hunt mapping flow to better handle hunt-only updates where mob_id is missing.
  • Preserved deterministic mapping through multiple strategies, including:
    • direct hunt_id / mob_id lookups,
    • cross-lookup between stored mission keys,
    • mission index derivation from hunt identifiers,
    • packet-order fallback,
    • progress-delta fallback.
  • Added support for reconstructing synthetic hunt identifiers from hunt_id_cont (ROla-like behavior) to keep mission index mapping deterministic.

Recent-kill fallback behavior

  • Kept recent-kill heuristic as a controlled fallback for ambiguous hunt-only updates.
  • Ensured the recent-kill signal is consumed after successful use so it is not reused on subsequent unrelated updates.

Logging / diagnostics

  • Added structured unresolved-mapping debug logging when mission resolution fails.
  • Improved mission progress debug output so resolved mission values are used (avoiding empty MobID / Name in hunt-only packet scenarios).
  • Removed unnecessary noisy “mapped via [...]” debug line.

Tests

  • Added src/test/QuestReceiveTest.pm with focused coverage for:
    1. synthetic mapping via hunt_id_cont,
    2. recent-kill fallback consumption,
    3. unresolved mapping debug path.
  • Registered the new test module in src/test/unittests.pl.

Why

Some servers send hunt mission updates with identifiers that are incomplete, swapped, or non-standard.
These changes reduce incorrect mission updates, improve compatibility across server variants, and make troubleshooting easier when packets are ambiguous.

Validation

  • Ran: perl src/test/unittests.pl QuestReceiveTest
  • New and updated quest mapping tests pass.

boscv added 4 commits April 8, 2026 19:20
Normalize and harden quest handling across servers: add helpers to resolve mob names and normalize (possibly reversed) quest time windows; prefer start time for certain no-mission quests in cmdQuest. Store last killed monster nameID/time to help map hunt-only updates. Rework quest mission parsing and quest_update_mission_hunt to handle various server formats (hunt_id, hunt_id_cont, mob_id), build synthetic hunt identifiers, prefer exact mission_index matches, use packet-order and recent-kill/progress-delta fallbacks for ambiguous updates, and avoid noisy duplicate progress messages by only notifying on real changes. Add debug logging for resolved time windows and ambiguous mappings.
Normalize and robustly handle quest data from server packets. Add helpers to normalize swapped start/expire times and to resolve mob names (falling back to monsters_lut when packet names are empty or contain control chars). Use quest start time as display_time for wait/return quests without missions. Track last killed monster nameID/time to aid mapping of hunt-only updates. Rework quest_update_mission_hunt to derive a stable hunt identifier (including hunt_id_cont), maintain per-quest packet sequence, and attempt multiple deterministic fallbacks (direct hunt/mob lookup, exact/legacy mission_index, packet-order, recent kill, and progress-delta) while skipping ambiguous updates. Suppress display/logging when mission progress didn't actually change.
Refactor quest_update_mission_hunt to tighten conditional blocks, improve deterministic mapping, and add a recent-kill fallback lifecycle. Introduces a $used_recent_kill_fallback flag so the last-killed-monster signal is consumed and cleared only when actually used, and enhances debug output to show the resolved mob id/name and detailed unresolved mapping info. Also normalizes indentation/brace placement to reduce accidental logic errors. Adds new QuestReceiveTest with cases for hunt_id_cont mapping, recent-kill fallback consumption, and unresolved update logging, and registers it in test/unittests.pl.
@boscv boscv marked this pull request as ready for review April 9, 2026 04:40
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.

1 participant