Repository navigation
perf(memory): replace fixed-size sound arrays with per-set StringMaps - #46
Conversation
The [255][999][256] sound arrays reserved ~200 MB of plugin data (~405 MB at runtime). Sounds now live in one StringMap per set, so only the configured ones use memory: data size goes from 202,312,232 to 27,680 bytes. - Load every section with one loop instead of 10 copy-pasted blocks - Pick the kill sound once per set instead of once per client, and emit it with a single EmitSound() call per set - Fix the headshot streak logic, the teamkill config, the sound/text preferences, victim streak resets, late load and out-of-bounds indexes - Do not download nor precache sounds with config 0 Closes #45
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Core event, configuration, and playback paths were extensively rewritten without in-game validation.
Review effort: Balanced
Findings: None
What changed in this PR
Replaces oversized fixed sound arrays with per-set dynamic maps, substantially reducing plugin memory use while consolidating sound handling and fixing event/preference behavior.
Changes:
- Stores configured sounds in
StringMapandArrayListstructures. - Centralizes sound selection, targeting, loading, and playback.
- Updates contributor guidance for the new architecture.
| File | Description |
|---|---|
addons/sourcemod/scripting/QuakeSounds.sp |
Refactors sound storage and event handling, plus preference and behavior fixes. |
.github/copilot-instructions.md |
Documents the dynamic sound-storage design and extension process. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code reviewNo blocking issues found. Checked for bugs and CLAUDE.md compliance; the head compiles cleanly on SourceMod 1.13.0.7427 with no new diagnostics against master. A few non-blocking notes:
sm-plugin-QuakeSounds/addons/sourcemod/scripting/QuakeSounds.sp Lines 709 to 712 in 55f7634
sm-plugin-QuakeSounds/addons/sourcemod/scripting/QuakeSounds.sp Lines 728 to 734 in 55f7634
sm-plugin-QuakeSounds/addons/sourcemod/scripting/QuakeSounds.sp Lines 130 to 133 in 55f7634
|
…preset clamp) - Add Sound_LastNumbered so LoadSet() no longer hardcodes Sound_Combo - Skip non-numeric or negative numbered sub-sections with a warning - Re-clamp connected clients' sound preset after the sets are reloaded on map start
Closes #45
@cmer81 could you review this one?
Memory
Sounds now live in one
StringMapper set ("<type>:<num>"-> path + config), so only the configured ones use memory..smxOther changes
LoadSet()loads every section with one loop overg_sSoundSections[]instead of 10 copy-pasted blocks.EmitSound()call per set.sm_quakesounds_volumenow applies without a map change.Behavior changes (bug fixes)
1,3hattrick,5headhunter) now comes first, else the generic0. The old generic branch was keyed on the kill streak (L928): you could get the hattrick sound with the "Headshot" text, or nothing at all on a 2nd headshot.sm_quakesounds_selfkillorsm_quakesounds_teamkillis 0, because of an early return (L800-L801, L824-L825).killsound, the random sound comes from the set's configured kill sounds instead of a hard-coded list (L1116). It is the same list formaleandfemale. It uses that sound's own config instead of forcing "everyone"."config" "0"sounds are no longer downloaded nor precached, as the README says.Testing
sm plugins reload QuakeSoundswith players connected.