fix(editor): quest objective load clamps type, count, and per-quest size

Three guards on quest objective loading from JSON:
  - type out of QuestObjectiveType range (0..5) -> defaults to 0 (Kill)
  - targetCount of 0 -> 1 (no-op objectives are nonsense)
  - targetCount > 1000 -> 1000 (typo guard, biggest legit WoW quest is ~100)
  - >10 objectives per quest -> dropped (matches SQL slot capacity, also
    bounds per-quest memory)
This commit is contained in:
Kelsi 2026-05-06 05:56:11 -07:00
parent 62b668e898
commit c4c8d9e7ed

View file

@ -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<QuestObjectiveType>(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<QuestObjectiveType>(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);
}
}