summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2020-03-31 09:28:06 +0200
committerPaweł Redman <pawel.redman@gmail.com>2020-03-31 09:28:06 +0200
commit1db3e2ee25ff7b4240f12211473af86af9b017f5 (patch)
treef0f5d8ae2ae29b2cf4c626ba377be29087460713 /src
parentb684f478ba3c55a21d132350f4e3e345ec6f9c6d (diff)
Mixing the sounds like a DJ
Diffstat (limited to 'src')
-rw-r--r--src/cgame/cg_local.h3
-rw-r--r--src/cgame/cg_main.c34
-rw-r--r--src/cgame/cg_syscalls.c1
3 files changed, 37 insertions, 1 deletions
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index f35c438..1a71e3b 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -1968,7 +1968,8 @@ void trap_S_UpdateEntityPosition( int entityNum, const vec3_t origin );
// respatialize recalculates the volumes of sound as they should be heard by the
// given entityNum and position
void trap_S_Respatialize( int entityNum, const vec3_t origin, vec3_t axis[3], int inwater );
-sfxHandle_t trap_S_RegisterSound( const char *sample, qboolean compressed ); // returns buzz if not found
+sfxHandle_t Hacked_S_RegisterSound( const char *sample, qboolean compressed ); // returns buzz if not found
+#define trap_S_RegisterSound Hacked_S_RegisterSound
void trap_S_StartBackgroundTrack( const char *intro, const char *loop ); // empty name stops music
void trap_S_StopBackgroundTrack( void );
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index 45e2506..5495a6f 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -2124,3 +2124,37 @@ char *CG_VoIPString( void )
return voipString;
}
+
+/*
+================
+Hacked_S_RegisterSound
+
+Replace sounds in the game without having to actually mess with the .pk3s
+================
+*/
+
+#undef trap_S_RegisterSound
+// This is the *actual* prototype
+sfxHandle_t trap_S_RegisterSound( const char *sample, qboolean compressed );
+
+struct { char *to, *from; } replacements[ ] =
+{
+ { "sound/player/level0/taunt.wav", "models/weapons/rifle/flash0.wav" },
+};
+
+int num_replacements = sizeof( replacements ) / sizeof( replacements[ 0 ] );
+
+sfxHandle_t Hacked_S_RegisterSound( const char *path, qboolean compressed )
+{
+ int i;
+
+ for ( i = 0; i < num_replacements; i++ )
+ {
+ if ( !Q_stricmp( path, replacements[ i ].from ) )
+ {
+ return trap_S_RegisterSound( replacements[ i ].to, compressed );
+ }
+ }
+
+ return trap_S_RegisterSound( path, compressed );
+}
diff --git a/src/cgame/cg_syscalls.c b/src/cgame/cg_syscalls.c
index aa42019..ad227e1 100644
--- a/src/cgame/cg_syscalls.c
+++ b/src/cgame/cg_syscalls.c
@@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "cg_local.h"
+#undef trap_S_RegisterSound
static intptr_t (QDECL *syscall)( intptr_t arg, ... ) = (intptr_t (QDECL *)( intptr_t, ...))-1;