mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 17:13:51 +00:00
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:
parent
58e0069404
commit
8039dff51f
1 changed files with 5 additions and 0 deletions
|
|
@ -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>());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue