From bd97470929951938dea54ac7e84413ba94786a5d Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 09:56:55 -0700 Subject: [PATCH] fix(npc): cap spawn count at 50k on load Same defense pattern as QuestEditor (4096) and ObjectPlacer (100k). A stale autosave or scatter-runaway could carry millions of NPCs; each emits creature_template + creature + optional addon/waypoint rows, drowning the SQL output and the M2 marker mesh. Every editor JSON loader now has a matched-to-cost upper bound (NPCs 50k, quests 4k, objects 100k, waypoints 256). --- tools/editor/npc_spawner.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/editor/npc_spawner.cpp b/tools/editor/npc_spawner.cpp index 7b314d6a..8e261fb6 100644 --- a/tools/editor/npc_spawner.cpp +++ b/tools/editor/npc_spawner.cpp @@ -154,7 +154,17 @@ bool NpcSpawner::loadFromFile(const std::string& path) { selectedIdx_ = -1; idCounter_ = 1; + // Cap NPC count — same defense pattern as QuestEditor / ObjectPlacer. + // 50k creatures is generous; each emits a creature_template + + // creature INSERT, plus optional addon/waypoint rows. + constexpr size_t kMaxSpawns = 50'000; + for (const auto& js : arr) { + if (spawns_.size() >= kMaxSpawns) { + LOG_WARNING("NPC cap reached (", kMaxSpawns, + ") — remaining entries dropped"); + break; + } CreatureSpawn s; s.name = js.value("name", ""); s.modelPath = js.value("model", "");