Commit graph

416 commits

Author SHA1 Message Date
Kelsi
55f9616aa6 fix(camera): NaN guards on pivot orbit, setPosition, setYawPitch
Three issues:
- processMiddleMouseMotion: NaN pivot poisons camera position
  permanently; the next frame produces NaN view/proj matrices.
- setPosition: no input validation — used by bookmark restore and
  fly-to-target which could be passed a NaN target.
- setYawPitch: same; also clamp pitch to [-89, 89] to match the
  mouse-motion path so a saved bookmark with bad pitch doesn't
  roll the camera upside down.
2026-05-06 08:03:57 -07:00
Kelsi
98f2a6c3bf fix(gizmo): hide on NaN target instead of building NaN geometry
setTarget previously stored the position raw, then updateBuffers
ran glm::normalize on axis offsets. NaN target → NaN normalized
axes → NaN gizmo vertices → Vulkan validation drops the whole
draw and the gizmo is invisible regardless of target value.

Hide the gizmo upfront so the user sees no gizmo (which is the
intent of the NaN handling) without leaking garbage into the
vertex buffer.
2026-05-06 08:01:23 -07:00
Kelsi
cdc9bb94ee fix(npc): NaN guards in NpcSpawner::selectAt distance test
Same NaN-comparison short-circuit pattern: NaN worldPos or NaN
spawn position would short-circuit dist < bestDist (NaN < x is
false), so it never updates bestIdx — but if every entry had NaN
the bestIdx stays -1 (correct) only because the first comparison
also fails. Belt and braces: skip NaN entries explicitly.
2026-05-06 08:00:36 -07:00
Kelsi
94469592f2 fix(objects): NaN guards in selectAt ray-sphere test
Without these, NaN ray or NaN object position would short-circuit
the disc < 0 early-out (NaN comparisons return false) and select
the object at a garbage t — silently 'picking' arbitrary objects.
2026-05-06 07:59:33 -07:00
Kelsi
0f15d0f3a0 fix(terrain): reject NaN rays in raycastTerrain
Without this, the AABB tests divide by ray.direction components and
NaN propagates through tmin/tmax into the triangle intersection,
returning undefined behavior at the hit position.
2026-05-06 07:58:56 -07:00
Kelsi
493cb68ddc fix(viewport): defensive NaN checks in patrol path ribbon
len < 0.001f returns false for NaN — same short-circuit class of
bug as elsewhere. Reject non-finite endpoints upfront and double-
check the computed length before dividing.
2026-05-06 07:57:54 -07:00
Kelsi
ba017193db fix(viewport): skip NPCs with NaN position in marker update
Same defensive pattern as updateObjectMarkers — non-finite NPC
position would produce NaN vertex positions and Vulkan would drop
the entire NPC marker batch, hiding every NPC marker in the zone.
2026-05-06 07:57:19 -07:00
Kelsi
b1cfef8264 fix(markers): skip objects with NaN position/scale on update
A non-finite object transform would produce NaN vertex positions
in the marker mesh — Vulkan validation flags it and dropping the
entire batch leaves all markers invisible. Skip the bad object
instead so the rest of the markers still render.
2026-05-06 07:56:26 -07:00
Kelsi
45dabaff44 fix(wcp): normalize separators before traversal check on unpack
Older WCP files packed on Windows (before pack-side normalization
was added) carry backslash separators. Normalize to '/' first so
the unpack works on any platform — and so the traversal check sees
a consistent canonical form (no more '\' special case).
2026-05-06 07:54:54 -07:00
Kelsi
439d1381f0 fix(editor): catch NaN-from-normalize when camera flies to a target
When the camera looks straight up/down, projecting forward onto XY
gives a zero vector — glm::normalize then returns NaN. The original
length<0.001 fallback ran AFTER the divide-by-zero, and NaN length
< 0.001 is false (NaN comparisons return false), so the fallback
never fired. Length-check the source before normalizing.
2026-05-06 07:53:41 -07:00
Kelsi
130aa34d73 fix(viewport): hide path preview on zero-length input
start == end would call glm::normalize on a zero vector, producing
NaN dir/perp and NaN ribbon vertex positions. Vulkan would either
drop the draw silently or trip a validation error. Hide the preview
when the segment is degenerate.
2026-05-06 07:53:07 -07:00
Kelsi
4babaebf86 fix(stamp): scrub NaN samples at save time
Symmetric with the load-side scrub. Without this, a stamp captured
on terrain that had a NaN mid-edit would throw on serialize and
abort the whole save.
2026-05-06 07:51:56 -07:00
Kelsi
ebb7e0f831 fix(wcp): normalize path separators on pack for cross-platform reads
WCP packs created on Windows would store paths with backslashes;
unpack on Linux/macOS would either fail the path-traversal check
('\' treated as absolute prefix) or land each file as a single
opaque filename rather than a directory tree. Normalize to '/' on
write so the format is portable in both directions.
2026-05-06 07:50:10 -07:00
Kelsi
5366c53734 fix(objects): NaN guards on transform deltas
A NaN move/rotate/scale delta would poison every selected object's
transform permanently and produce NaN model matrices in the
renderer. Reject upfront.
2026-05-06 07:45:26 -07:00
Kelsi
2c5710b910 fix(terrain): NaN guards + zero-length checks on river/road/ridge generators
Same defensive pattern as paintAlongPath. carveRiver, flattenRoad,
and createRidge all called glm::normalize on a possibly-zero
direction vector, then divided by lineLen later. NaN endpoints
short-circuited dist comparisons and applied the height delta
to every vertex on every chunk.
2026-05-06 07:43:39 -07:00
Kelsi
869cee70b1 fix(painter): reject NaN endpoints and zero-length lines in paintAlongPath
Two bugs:
1. NaN start/end produced NaN distances that the chunk-skip check
   (dist > width + 40) treated as 'always within range', so every
   chunk got painted.
2. Zero-length line caused glm::normalize to return NaN; same
   downstream effect.

Compute lineDir manually after the length check so we never hit
the divide-by-zero path.
2026-05-06 07:41:58 -07:00
Kelsi
7e48658ab1 fix(terrain): NaN guards on createCrater and createMesa
Same defensive pattern as createHill — NaN center/radius would
short-circuit dist comparisons and apply the height delta to every
vertex on every chunk. Reject upfront.
2026-05-06 07:40:29 -07:00
Kelsi
f484b742db fix(editor): NaN guards on flattenAroundSelected and createHill
Same NaN-comparison short-circuit pattern: dist >= radius is false
when dist is NaN, so the loop body would run for every vertex and
write garbage heights / bend the terrain unbounded.
2026-05-06 07:39:35 -07:00
Kelsi
12bcd0ef8c fix(brush): defensive guards in EditorBrush::getInfluence
Three issues:
1. NaN distance returned 1.0 (full influence) because distance >=
   radius is false for NaN; the inner-radius check then returned 1.
2. Non-positive radius would divide by zero in the t computation.
3. falloff = 0 produces division by zero in the outer falloff path.

Also clamps falloff to [0,1] so a slider extreme can't break the math.
2026-05-06 07:38:50 -07:00
Kelsi
bd6e5fe3de fix(brush): reject NaN/non-positive brush settings before sculpt apply
Same NaN-comparison short-circuit bug as the texture painter — a
brush with a NaN cursor position would mark every vertex in every
'affected' chunk as full influence and silently rewrite huge
swaths of terrain. Reject upfront in applyBrush.
2026-05-06 07:37:54 -07:00
Kelsi
9207d54f20 fix(painter): reject NaN brush center / non-positive radius
NaN comparisons return false, so the dist >= radius early-out
would never fire and the falloff path would skip its inner check
too — the brush would paint full strength on every texel in the
chunk. Reject upfront.
2026-05-06 07:37:11 -07:00
Kelsi
891bb711a0 fix(editor): bound tile coords + NaN-guard baseHeight in createNewTerrain
Same defensive validation as loadADT — out-of-range tile coords
would generate broken save paths. Also guards against a NaN
baseHeight slider (would propagate into every terrain vertex).
2026-05-06 07:36:32 -07:00
Kelsi
d9d0797b7f fix(wcp): cap info JSON string lengths at pack time
A stray gigantic name/description/author field would inflate the
info JSON past the 16MB unpack cap and make the pack unreadable
via readInfo/unpackZone. Caps mirror the zone manifest limits.
2026-05-06 07:35:44 -07:00
Kelsi
efd0a6de29 fix(editor): reject out-of-range tile coords in loadADT
A tileX/tileY outside 0..63 would generate ADT paths the asset
manager refuses, then poison the manifest.tiles entries on save.
Reject upfront with a log message.
2026-05-06 07:34:58 -07:00
Kelsi
237cc67b24 fix(wcp): sanitize zone name before using it as a directory path
The unpacker used info.name verbatim as the destination subdirectory.
A malicious WCP could carry a name like '../etc' or '/usr/bin' to
write extracted files outside destDir. Now slugified to alphanumeric
+ underscore/dash, matching the server module slug rule.
2026-05-06 07:34:09 -07:00
Kelsi
6b06bd07f9 feat(quest): detect orphan quests + speed up chain validation
validateChains now also flags quests with no questgiver and no
turn-in NPC — those are unreachable in-game and a common authoring
mistake. Also replaced the O(n²) inner lookup with an O(1)
unordered_map of id → nextId so circular detection scales.
2026-05-06 07:33:31 -07:00
Kelsi
9d944ed2f9 feat(editor): add --list-wcp CLI to print every file in a WCP archive
--info-wcp gives counts and totals; --list-wcp gives the full file
listing sorted by path. Useful for spotting missing texture/model
entries before unpacking and shipping a zone.
2026-05-06 07:30:26 -07:00
Kelsi
7a03011625 fix(sql): expand string escape to handle NUL, CR/LF/tab, Ctrl-Z
The previous escape only doubled quotes and backslashes. A quest
description containing a literal newline would emit a multi-line
INSERT that breaks per-line execution scripts; a NUL byte could
prematurely terminate the string in non-length-prefixed clients;
Ctrl-Z is the historical MySQL string terminator on Windows.

Now full MySQL/MariaDB string-literal escape: NUL drops, CR/LF/tab
become \r/\n/\t, Ctrl-Z becomes \Z.
2026-05-06 07:22:04 -07:00
Kelsi
a2a554dff7 feat(editor): add --info-quests CLI for quests.json summary
Completes the --info-* family. Reports total/chained quest counts,
reward/item counts, total XP awarded, objective-type breakdown
(kill/collect/talk), and any quest-chain validation errors. Lets
zone authors spot broken chains, missing rewards, and lopsided XP
balance from the command line.
2026-05-06 07:16:27 -07:00
Kelsi
df2027463a feat(editor): add --info-objects CLI for objects.json summary
Mirrors --info-creatures and the other format inspectors. Reports
total placement count, M2/WMO breakdown, unique source paths, and
scale range. Useful for spotting empty zones, accidental scale
extremes, or duplicated placements before packing.
2026-05-06 07:15:40 -07:00
Kelsi
93e67ae31b feat(editor): add --info-creatures CLI for creature.json summary
Mirrors the existing --info-wom/wob/woc/wot/wcp inspectors. Reports
total spawn count, hostile/questgiver/vendor/trainer flag counts,
behavior breakdown (stationary/wander/patrol), and unique displayId
count. Useful for triaging zone NPC content from the command line.
2026-05-06 07:14:42 -07:00
Kelsi
5af4bba556 feat(validate): report file counts and per-format invalid totals
The previous --validate output told you whether *some* file of each
type existed, which was hard to act on for partially-valid zones.
Now reports the per-format file count and how many failed magic
validation, e.g. 'WOM (12 invalid: 2)' so a zone author can spot
missing or corrupted models without grepping through file listings.
2026-05-06 07:12:04 -07:00
Kelsi
7e2dc4ec1d fix(wcp): apply unpack-side header bounds to readInfo + categorize .woc
readInfo previously trusted fileCount/infoSize blindly, so a malicious
or corrupted WCP could allocate a 4GB string just to print metadata
via --info-wcp. Same 1M file / 16MB info caps now applied. Also
categorizes .woc collision files (was bucketed under 'other').
2026-05-06 07:10:53 -07:00
Kelsi
1135e499d7 fix(zone): scrub NaN/inf manifest floats at save time
Mirrors the load-side sanitize. nlohmann throws on NaN/inf, so
a corrupted in-memory baseHeight or volume would abort the manifest
save and lose all zone-level settings (flags, audio config, etc.).
2026-05-06 07:05:13 -07:00
Kelsi
49feb8b9f6 fix(objects): scrub NaN/inf floats at save time
Same json-serialization-safety fix as for NPC and WOT saves.
Object position/rotation NaN would abort the entire objects.json
save and lose all placement work in the session.
2026-05-06 07:04:27 -07:00
Kelsi
999388b805 fix(npc): scrub NaN/inf floats at save time
nlohmann::json throws on non-finite serialization, which would
abort the entire creatures.json save and lose every spawn change
in the session. Scrub position/orientation/scale/radii/patrol
floats on the way out so a single corrupt NPC can't kill the
batch save.
2026-05-06 07:03:51 -07:00
Kelsi
9ef04414d1 fix(wot): scrub NaN/inf in doodad/WMO placements at save time
nlohmann::json serialization throws on NaN/inf floats, which would
abort the entire WOT save and leave the user with an unsaved zone
state. Scrub on the way out so a single corrupted placement can't
take down the whole save.
2026-05-06 07:03:02 -07:00
Kelsi
826d218226 fix(zone): cap manifest strings at AzerothCore SQL limits
map_dbc.MapName / area_table_dbc.AreaName are varchar(100). Edited
zone.json could carry longer strings that would either fail the
INSERT or silently truncate. Cap mapName/displayName at 100,
biome at 64, description at 4096.
2026-05-06 07:02:09 -07:00
Kelsi
2119546a7a fix(npc): truncate over-long NPC name/modelPath at SQL limits
creature_template.name is varchar(100) in AzerothCore. Edited
creature JSON could carry longer names that would either fail
the INSERT or silently truncate. Cap name at 100 and modelPath
at 1024 on load.
2026-05-06 07:01:25 -07:00
Kelsi
280fe1e6e8 fix(quest): truncate over-long title/desc/completion to SQL limits
quest_template.LogTitle is varchar(200) in AzerothCore. Edited
quest JSON could carry longer strings that would either fail the
INSERT or silently truncate at the server. Cap title at 200 chars
and the longer text fields at 8KB on load.
2026-05-06 07:01:00 -07:00
Kelsi
6651eccf3b feat(editor): add --info-wot CLI for inspecting terrain metadata
Mirrors the existing --info-wom/--info-wob/--info-woc/--info-wcp
inspectors. Reports the tile coord, populated chunks, layer count,
water count, texture/doodad/WMO counts, and computed height range
across all chunks. Useful for triaging zones from the command line
without opening the GUI.
2026-05-06 06:58:34 -07:00
Kelsi
d127053e21 fix(objects): bound populateBiome density and asset scale ranges
Same defensive guards as scatter: cap per-asset count at 50k to
prevent editor freeze under a high-density biome, and ensure scale
range preconditions (a<b, both positive) so distScale construction
doesn't undermine validity.
2026-05-06 06:56:32 -07:00
Kelsi
c1af157587 fix(objects): guard ObjectPlacer::scatter against bad inputs
Same defensive guards now applied to NPC scatter: reject NaN/inf
center/radius, cap count at 100k (prevents editor freeze on huge
inputs), and ensure minScale < maxScale so uniform_real_distribution
preconditions hold.
2026-05-06 06:55:43 -07:00
Kelsi
10e77f1c2e fix(npc): guard NpcSpawner::scatter against zero radius and bad inputs
A radius of 0 would either throw from the uniform distribution
constructor (uniform_real_distribution requires a < b) or divide
by zero in the sqrt-based area-uniform sampler. Also reject NaN
center, non-positive radius, and absurdly large counts (>10k)
which would freeze the editor on placement.
2026-05-06 06:54:48 -07:00
Kelsi
d96d040831 fix(sql): substitute generic displayId for NPCs with displayId=0
A creature_template row with modelid1=0 spawns an invisible NPC
in-game. Fall back to 11707 (a generic humanoid) on export so
"Creature"-named placeholder spawns are at least usable; the user
can edit the displayId after.
2026-05-06 06:53:47 -07:00
Kelsi
aa9ef6f2ca fix(adt): scrub NaN/inf floats at write time
ADTWriter::writeFloat now coerces non-finite values to 0 before
emitting bits, so a stray NaN in a chunk position, MDDF rotation,
or MODF extent can't leak into the saved ADT and produce invisible
terrain or off-map placements after reload.
2026-05-06 06:49:51 -07:00
Kelsi
bc1839d9ab fix(zone): drop out-of-range tile coords on manifest load
WoW's tile grid is 64x64. A tile (200,200) entry would generate an
ADT filename the loader rejects and silently leave the zone with no
terrain. Drop bad entries instead.
2026-05-06 06:48:28 -07:00
Kelsi
4a98dd7a2c fix(editor): slugify mapName for module dir + conf keys
A zone named with spaces or punctuation (e.g. "My Zone!") used to
produce a module directory path "mod_wowee_My Zone!/" and conf
keys like "Wowee.My Zone!.Enabled" which AzerothCore's config
parser rejects. The slug is now stripped to [A-Za-z0-9_-], with
spaces/slashes mapped to underscores. SQL VALUES still use the
raw display text via SQLExporter::escape.
2026-05-06 06:47:43 -07:00
Kelsi
a8464fc367 fix(editor): escape user strings in server module map/zone/tele SQL
The map_dbc, area_table_dbc, and game_tele INSERTs previously
embedded mapName/displayName/manifest.mapName as raw strings — a
zone called "King's Land" or anything containing a single quote
would emit malformed SQL that AzerothCore would reject. Promotes
the existing escapeSql helper to a public SQLExporter::escape and
uses it in all three INSERTs.
2026-05-06 06:46:58 -07:00
Kelsi
cc1e1cb7fa fix(editor): cap stamp vertex count and skip NaN samples on load
A malformed stamp JSON could carry millions of entries (would OOM)
or NaN dx/dy/height (would propagate through brush blends and leave
permanent holes in the heightmap).
2026-05-06 06:45:41 -07:00