diff --git a/tools/editor/quest_editor.cpp b/tools/editor/quest_editor.cpp index 7e419cec..94041b70 100644 --- a/tools/editor/quest_editor.cpp +++ b/tools/editor/quest_editor.cpp @@ -102,10 +102,19 @@ bool QuestEditor::loadFromFile(const std::string& path) { if (jq.contains("objectives") && jq["objectives"].is_array()) { for (const auto& jo : jq["objectives"]) { QuestObjective obj; - obj.type = static_cast(jo.value("type", 0)); + int t = jo.value("type", 0); + // Clamp to known QuestObjectiveType range to avoid + // garbage enum values from edited JSON. + if (t < 0 || t > 5) t = 0; + obj.type = static_cast(t); obj.description = jo.value("desc", ""); obj.targetName = jo.value("target", ""); obj.targetCount = jo.value("count", 1u); + if (obj.targetCount == 0) obj.targetCount = 1; + if (obj.targetCount > 1000) obj.targetCount = 1000; + // Cap stored objectives to 10 (matches SQL slot capacity) + // — also bounds the per-quest memory. + if (q.objectives.size() >= 10) break; q.objectives.push_back(obj); } }