mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-10 02:53:51 +00:00
refactor(editor): extract gen-audio-* handlers into cli_gen_audio.cpp
main.cpp had grown past 28k lines, with each new procedural-
generation command adding 100-200 lines to the inline if/else
dispatch chain. This commit starts breaking that up by moving
the four audio-related handlers (--gen-audio-tone, -noise,
-sweep, --gen-zone-audio-pack) into their own translation unit.
Pattern established here for future family extractions:
- Family lives in cli_<family>.{hpp,cpp}
- Single dispatch entry point: bool handle<Family>(int& i, int argc,
char** argv, int& outRc) — true if matched (writes outRc), false
to fall through.
- main.cpp's argv loop calls each family's dispatcher first and
returns its outRc on match, before the legacy in-line chain.
Side-benefit: consolidated the duplicated 25-line WAV header
writer + 5ms attack/release envelope into shared helpers
(writeWavMono16, applyEdgeEnvelope) at the top of the new file.
main.cpp drops from 28,943 → 28,329 lines (-614). Audio family
is fully self-contained (~440 lines), behavior unchanged
(verified by re-running tone/noise/sweep + zone-audio-pack).
This commit is contained in:
parent
9365792c57
commit
6c9ab6faed
4 changed files with 457 additions and 442 deletions
20
tools/editor/cli_gen_audio.hpp
Normal file
20
tools/editor/cli_gen_audio.hpp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
namespace wowee {
|
||||
namespace editor {
|
||||
namespace cli {
|
||||
|
||||
// Dispatch the four --gen-audio-* / --gen-zone-audio-pack handlers.
|
||||
//
|
||||
// Returns true if argv[i] matched one of these flags; in that case
|
||||
// outRc holds the exit code (0 success, non-zero failure) and main()
|
||||
// should `return outRc` immediately. Returns false if no match —
|
||||
// caller should continue its dispatch chain.
|
||||
//
|
||||
// On match, advances `i` past the consumed arguments (same semantics
|
||||
// as the in-line handlers it replaces).
|
||||
bool handleGenAudio(int& i, int argc, char** argv, int& outRc);
|
||||
|
||||
} // namespace cli
|
||||
} // namespace editor
|
||||
} // namespace wowee
|
||||
Loading…
Add table
Add a link
Reference in a new issue