fix(npc): cap patrol path length at 256 waypoints on load

A stale autosave or hand-edited creature.json could carry an
unbounded patrolPath. The SQL exporter would emit one waypoint_data
INSERT per entry and produce huge SQL files. 256 waypoints covers
any realistic route.
This commit is contained in:
Kelsi 2026-05-06 09:54:25 -07:00
parent 58e0069404
commit 8039dff51f

View file

@ -224,7 +224,12 @@ bool NpcSpawner::loadFromFile(const std::string& path) {
}
if (js.contains("patrol") && js["patrol"].is_array()) {
// Cap patrol size at 256 waypoints — covers any realistic
// route and keeps SQL export size bounded for malformed
// input (a stale autosave that grew unbounded).
constexpr size_t kMaxPatrolPoints = 256;
for (const auto& pt : js["patrol"]) {
if (s.patrolPath.size() >= kMaxPatrolPoints) break;
if (pt.is_array() && pt.size() >= 4) {
PatrolPoint pp;
pp.position = glm::vec3(pt[0].get<float>(), pt[1].get<float>(), pt[2].get<float>());