java-topology/defects/warzone2100-0001/test
russell@unturf.com 1a7022ea83 warzone2100-0001: PROJECTILE::psDamaged std::find O(G*D) per tick, 9.5x
Defect: projectile.cpp line 872, std::find on std::vector<BASE_OBJECT*>
psDamaged inside grid neighbor iteration loop. Every projectile tick,
for each nearby object, does O(D) linear scan to check if already
damaged. Penetrating weapons inherit and grow psDamaged across hits.

Fix: replace std::vector with std::unordered_set for O(1) lookup.
push_back becomes insert, std::find becomes count, remove_if becomes
iterator-based erase loop.

Severity: MEDIUM. Hot path (per projectile per tick), scales with
battle density. D=200 damaged, G=100 grid neighbors: 9.5x speedup.

MOAD 0002-0005 CLEAN:
- 0002: global state is architectural (Eidos-era C game), not coupling defect
- 0003: no thread_local usage found
- 0004: no secrets logged (public keys and IPs only, standard for server logs)
- 0005: no unsynchronized cache patterns (game logic is single-threaded)
2026-03-31 12:25:06 -04:00
..
test_psDamaged_lookup warzone2100-0001: PROJECTILE::psDamaged std::find O(G*D) per tick, 9.5x 2026-03-31 12:25:06 -04:00
test_psDamaged_lookup.cpp warzone2100-0001: PROJECTILE::psDamaged std::find O(G*D) per tick, 9.5x 2026-03-31 12:25:06 -04:00