mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +02:00
let PlayJA2SampleFromFile take a filename it will not write to
The parameter was STR8, a mutable char*, for a filename the function only
reads: it runs strstr over it and hands it to SoundPlay. environment.cpp picks
between two of them at runtime,
PlayJA2SampleFromFile( Chance( 50 ) ? "Sounds\\WATERSNAKE_ATTACK_01.WAV"
: "Sounds\\WATERSNAKE_ATTACK_02.WAV", ... );
and the conditional is a const char*, which STR8 has no room for. Literals
passed on their own are still accepted under the MSVC rules, which is why only
these two calls ever failed.
The cast at the call to SoundPlay was already written as (STR) and is left as
it is. SoundPlay, SoundPlayStreamed and SoundLoadSample below it all still
take STR, so making them const is a separate piece of work and a much larger
one; until then that cast is where const stops.
No call site changes. The (char*) cast at LuaInitNPCs.cpp:11640 is now
unnecessary but still valid, and is left for whoever next edits that line.
Verification:
ninja -C build parse # both environment.cpp sites gone
ninja -C build -k 0 # Release, four applications, green
ninja -C build-debug -k 0 # Debug, four applications, green
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
committed by
majcosta
co-authored by
Claude Opus 4.8
parent
aac53ce71d
commit
a7dcdcaec3
@@ -496,7 +496,7 @@ UINT32 PlayWeaponSound(STR8 szFileName, UINT32 ubVolume, UINT32 uiPan)
|
||||
return(SoundPlay((STR)szFileName, &spParms));
|
||||
}
|
||||
|
||||
UINT32 PlayJA2SampleFromFile( STR8 szFileName, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoops, UINT32 uiPan )
|
||||
UINT32 PlayJA2SampleFromFile( const CHAR8* szFileName, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoops, UINT32 uiPan )
|
||||
{
|
||||
//SoundLog((CHAR8 *)String(" Play sound %s on volume %d", szFileName, ubVolume));
|
||||
// does the same thing as PlayJA2Sound, but one only has to pass the filename, not the index of the sound array
|
||||
|
||||
@@ -420,7 +420,7 @@ BOOLEAN ShutdownJA2Sound( );
|
||||
UINT32 PlayJA2Sample( UINT32 usNum, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoops, UINT32 uiPan );
|
||||
UINT32 PlayJA2StreamingSample( UINT32 usNum, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoops, UINT32 uiPan );
|
||||
|
||||
UINT32 PlayJA2SampleFromFile( STR8 szFileName, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoops, UINT32 uiPan );
|
||||
UINT32 PlayJA2SampleFromFile( const CHAR8* szFileName, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoops, UINT32 uiPan );
|
||||
UINT32 PlayWeaponSound(STR8 szFileName, UINT32 ubVolume, UINT32 uiPan);
|
||||
UINT32 PlayJA2StreamingSampleFromFile( STR8 szFileName, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoops, UINT32 uiPan, SOUND_STOP_CALLBACK EndsCallback );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user