fix(editor): cap quest count at 4096 and object count at 100k on load

A stale autosave or hand-edited JSON could carry an unbounded list:
- 100k quests would emit 100k quest_template + queststarter/ender
  INSERTs (huge SQL, slow validate, slow chain walks).
- 1M+ objects bloats the M2 instance SSBO and drags editor framerate
  to single digits.

Caps mirror the 256-waypoint cap added in the previous batch — log
a warning and drop the rest so the editor stays responsive.
This commit is contained in:
Kelsi 2026-05-06 09:56:03 -07:00
parent 8039dff51f
commit 49a2907bc5
2 changed files with 21 additions and 0 deletions

View file

@ -337,7 +337,17 @@ bool ObjectPlacer::loadFromFile(const std::string& path) {
selectedIndices_.clear();
uniqueIdCounter_ = 1;
// Cap object count — a stale autosave or biome-populate runaway
// could produce 100k+ entries that bloat the renderer instance
// SSBO and drag the editor framerate to single digits.
constexpr size_t kMaxObjects = 100'000;
for (const auto& jo : arr) {
if (objects_.size() >= kMaxObjects) {
LOG_WARNING("Object cap reached (", kMaxObjects,
") — remaining entries dropped");
break;
}
PlacedObject obj;
obj.type = static_cast<PlaceableType>(jo.value("type", 0));
obj.path = jo.value("path", "");

View file

@ -77,7 +77,18 @@ bool QuestEditor::loadFromFile(const std::string& path) {
quests_.clear();
uint32_t maxId = 0;
// Cap total quest count — a stale autosave or hand-edited file
// could carry thousands of empty quests, each emitting a
// quest_template INSERT (and queststarter/questender + chain
// walks) on export. 4096 covers any realistic zone.
constexpr size_t kMaxQuests = 4096;
for (const auto& jq : arr) {
if (quests_.size() >= kMaxQuests) {
LOG_WARNING("Quest cap reached (", kMaxQuests,
") — remaining entries dropped");
break;
}
Quest q;
q.id = jq.value("id", 0u);
q.title = jq.value("title", "Untitled");