Update of /cvsroot/netrek/client/netrekxp/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30379/src
Modified Files:
beeplite.c cowmain.c findslot.c input.c local.c makefile
newwin.c playback.c sound.c
Log Message:
Initial SDL patch for multilayered sounds.
Index: findslot.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/findslot.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- findslot.c 21 Apr 2006 12:00:06 -0000 1.2
+++ findslot.c 24 Apr 2006 14:13:25 -0000 1.3
@@ -111,9 +111,9 @@
socketPause ();
if (isServerDead ())
{
-
-#ifdef SOUND
- Exit_Sound ();
+
+#if defined(SOUND) && !defined(HAVE_SDL)
+ Exit_Sound();
#endif
LineToConsole ("Shit! Ghostbusted!\n");
@@ -158,8 +158,8 @@
if (isServerDead ())
{
-#ifdef SOUND
- Exit_Sound ();
+#if defined(SOUND) && !defined(HAVE_SDL)
+ Exit_Sound();
#endif
LineToConsole ("Damn, We've been ghostbusted!\n");
@@ -217,8 +217,8 @@
else if (event.Window == qwin)
{
-#ifdef SOUND
- Exit_Sound ();
+#if defined(SOUND) && !defined(HAVE_SDL)
+ Exit_Sound();
#endif
LineToConsole ("OK, bye!\n");
Index: sound.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/sound.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- sound.c 21 Apr 2006 12:00:07 -0000 1.2
+++ sound.c 24 Apr 2006 14:13:25 -0000 1.3
@@ -10,6 +10,11 @@
#include "config.h"
#ifdef SOUND
+#if defined(HAVE_SDL)
+#include "SDL.h"
+#include "SDL_mixer.h"
+#endif
+
#include "copyright.h"
#include <stdio.h>
@@ -25,6 +30,11 @@
#include "audio.h"
#include "proto.h"
+#if defined(HAVE_SDL)
+/* This is probably unix specific path */
+Mix_Chunk *sounds[NUM_WAVES];
+
+#else
/* Each sound has a priority which controls what can override what
Currently these are set as follows:
@@ -69,21 +79,73 @@
{"nt_explosion_other", 10, 1}
};
-static char sound_prefix[PATH_MAX];
static int current_sound = NO_SOUND;
static int sound_other = 1; /* Play other ship's sounds? */
+#endif // Not SDL sound
-extern void
-Exit_Sound (void)
+static char sound_prefix[PATH_MAX];
+
+#if defined(HAVE_SDL)
+
+/*
+ * Build the patch to the sound files
+ */
+char *DATAFILE(const char* wav) {
+ strcpy(sound_prefix, sounddir);
+ strcat(sound_prefix, "/");
+ strcat(sound_prefix, wav);
+ return sound_prefix;
+}
+
+/*
+ * Load the .wave files into the sounds array
+ */
+int loadSounds(void) {
+ int i;
+
+ sounds[CLOAKED_WAV] = Mix_LoadWAV(DATAFILE("nt_cloaked.wav"));
+ sounds[ENGINE_WAV] = Mix_LoadWAV(DATAFILE("nt_engine.wav"));
+ sounds[ENTER_SHIP_WAV] = Mix_LoadWAV(DATAFILE("nt_enter_ship.wav"));
+ sounds[EXPLOSION_WAV] = Mix_LoadWAV(DATAFILE("nt_explosion.wav"));
+ sounds[EXPLOSION_OTHER_WAV] = Mix_LoadWAV(DATAFILE("nt_explosion_other.wav"));
+ sounds[FIRE_PLASMA_WAV] = Mix_LoadWAV(DATAFILE("nt_fire_plasma.wav"));
+ sounds[FIRE_TORP_WAV] = Mix_LoadWAV(DATAFILE("nt_fire_torp.wav"));
+ sounds[FIRE_TORP_OTHER_WAV] = Mix_LoadWAV(DATAFILE("nt_fire_torp_other.wav"));
+ sounds[INTRO_WAV] = Mix_LoadWAV(DATAFILE("nt_intro.wav"));
+ sounds[MESSAGE_WAV] = Mix_LoadWAV(DATAFILE("nt_message.wav"));
+ sounds[PHASER_WAV] = Mix_LoadWAV(DATAFILE("nt_phaser.wav"));
+ sounds[PHASER_OTHER_WAV] = Mix_LoadWAV(DATAFILE("nt_phaser_other.wav"));
+ sounds[PLASMA_HIT_WAV] = Mix_LoadWAV(DATAFILE("nt_plasma_hit.wav"));
+ sounds[RED_ALERT_WAV] = Mix_LoadWAV(DATAFILE("nt_red_alert.wav"));
+ sounds[SELF_DESTRUCT_WAV] = Mix_LoadWAV(DATAFILE("nt_self_destruct.wav"));
+ sounds[SHIELD_DOWN_WAV] = Mix_LoadWAV(DATAFILE("nt_shield_down.wav"));
+ sounds[SHIELD_UP_WAV] = Mix_LoadWAV(DATAFILE("nt_shield_up.wav"));
+ sounds[TORP_HIT_WAV] = Mix_LoadWAV(DATAFILE("nt_torp_hit.wav"));
+ sounds[UNCLOAK_WAV] = Mix_LoadWAV(DATAFILE("nt_uncloak.wav"));
+ sounds[WARNING_WAV] = Mix_LoadWAV(DATAFILE("nt_warning.wav"));
+
+ for (i=0; i < NUM_WAVES; i++) {
+ if (!sounds[i]) {
+ LineToConsole("Mix_LoadWAV sound[%d] could not be loaded. Check soundDir in your .netrekrc: %s\n", i, Mix_GetError());
+ return(-1);
+ }
+ }
+
+ return(1);
+}
+#endif
+
+#if !defined(HAVE_SDL)
+extern void Exit_Sound (void)
{
if (sound_init)
ExitSound ();
sound_init = 0;
sound_toggle = 0;
}
+#endif
-extern void
-Init_Sound (void)
+extern void Init_Sound (void)
{
char buf[PATH_MAX];
@@ -101,7 +163,33 @@
else
sounddir = "./sounds";
}
+
+#if defined(HAVE_SDL)
+#ifdef DEBUG
+ LineToConsole ("Init_Sound using SDL\n");
+#endif
+
+ /* Initialize the SDL library */
+ if (SDL_Init(SDL_INIT_AUDIO) < 0)
+ LineToConsole("Couldn't initialize SDL: %s\n",SDL_GetError());
+ atexit(SDL_Quit);
+
+ /* Open the audio device at 22050 Hz 8 bit Microsoft PCM with stereo */
+ if (Mix_OpenAudio(22050, AUDIO_U8, 2, 1024) < 0)
+ LineToConsole("Mix_OpenAudio: %s\n", Mix_GetError());
+
+ /* If we successfully loaded the wav files, so shut-off sound_init and play
+ * the introduction
+ */
+ if (loadSounds())
+ {
+ if (Mix_PlayChannel(-1, sounds[INTRO_WAV], 0) < 0)
+ LineToConsole("Mix_PlayChannel: %s\n", Mix_GetError());
+ }
+ /* Default of 8 channels not enough */
+ Mix_AllocateChannels(16);
+#else
if (InitSound () == -1)
{
sound_toggle = 0;
@@ -122,12 +210,25 @@
strcat (buf, "/nt_intro");
StartSound (buf);
}
+#endif
}
}
-extern void
-Play_Sound (int type)
+extern void Play_Sound (int type)
{
+#if defined(HAVE_SDL)
+
+ if (!sound_init)
+ return;
+
+ if ((type >= NUM_WAVES) || (type < 0))
+ LineToConsole("Invalid sound type %d\n", type);
+
+ if (Mix_PlayChannel(-1, sounds[type], 0) < 0)
+ LineToConsole("Mix_PlayChannel: %s\n", Mix_GetError());
+
+
+#else
char buf[PATH_MAX];
/* Don't play other ship's sounds if turned off */
@@ -146,15 +247,16 @@
if (!(sound_toggle))
current_sound = NO_SOUND;
+#endif
}
-extern void
-Abort_Sound (int type)
+#if !defined(HAVE_SDL)
+extern void Abort_Sound (int type)
{
if ((current_sound != NO_SOUND) && (type == current_sound))
StopSound ();
}
-
+#endif
/* Sound options window stuff */
@@ -165,20 +267,24 @@
static void soundrefresh (int i);
-extern void
-soundwindow (void)
+extern void soundwindow (void)
{
+#if defined(HAVE_SDL)
+ char *buf="All or nothing with SDL sound. Sorry";
+ W_WriteText(soundWin, 0, 0, textColor, buf, strlen(buf), 0);
+#else
int i;
for (i = 0; i <= SOUND_DONE; i++)
soundrefresh (i);
+#endif
/* Map window */
W_MapWindow (soundWin);
}
-static void
-soundrefresh (int i)
+#if !defined(HAVE_SDL)
+static void soundrefresh (int i)
{
char buf[BUFSIZ], *flag;
@@ -265,10 +371,11 @@
W_WriteText (soundWin, 0, i, textColor, buf, strlen (buf), 0);
}
+#endif /* HAVE_SDL */
-void
-soundaction (W_Event * data)
+void soundaction (W_Event * data)
{
+#if !defined(HAVE_SDL)
int i, j;
i = data->y;
@@ -322,10 +429,10 @@
{
sounddone ();
}
+#endif /* HAVE_SDL */
}
-extern void
-sounddone (void)
+extern void sounddone (void)
{
W_UnmapWindow (soundWin);
}
Index: newwin.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/newwin.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- newwin.c 21 Apr 2006 12:00:07 -0000 1.9
+++ newwin.c 24 Apr 2006 14:13:25 -0000 1.10
@@ -579,10 +579,15 @@
#endif
#ifdef SOUND
- soundWin = W_MakeMenu ("sound", WINSIDE + 20, -BORDER + 10, 30, MESSAGE_SOUND + 4, NULL, 2);
- W_SetWindowKeyDownHandler (soundWin, soundaction);
- W_SetWindowButtonHandler (soundWin, soundaction);
- W_DefineArrowCursor (soundWin);
+#if defined(HAVE_SDL)
+ soundWin = W_MakeMenu("sound", WINSIDE + 20, -BORDER + 10, 40, 1, NULL, 2);
+#else
+ soundWin = W_MakeMenu("sound", WINSIDE + 20, -BORDER + 10, 30,
+ MESSAGE_SOUND + 4, NULL, 2);
+ W_SetWindowKeyDownHandler(soundWin, soundaction);
+ W_SetWindowButtonHandler(soundWin, soundaction);
+ W_DefineArrowCursor(soundWin);
+#endif
#endif
#ifdef TOOLS
Index: input.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/input.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- input.c 21 Apr 2006 12:00:07 -0000 1.4
+++ input.c 24 Apr 2006 14:13:25 -0000 1.5
@@ -1510,7 +1510,11 @@
/* Here we will have to enter message_on () followed by
smessage to player */
#ifdef SOUND
- Play_Sound (MESSAGE_SOUND);
+#if defined(HAVE_SDL)
+ Play_Sound(MESSAGE_WAV);
+#else
+ Play_Sound(MESSAGE_SOUND);
+#endif
#endif
message_on ();
data->key = players[target->o_num].p_mapchars[1];
@@ -1524,7 +1528,11 @@
/* Here we will have to enter message_on () followed by
smessage to player */
#ifdef SOUND
- Play_Sound (MESSAGE_SOUND);
+#if defined(HAVE_SDL)
+ Play_Sound(MESSAGE_WAV);
+#else
+ Play_Sound(MESSAGE_SOUND);
+#endif
#endif
message_on ();
data->key = 'T';
@@ -1538,7 +1546,11 @@
/* Here we will have to enter message_on () followed by
smessage to player */
#ifdef SOUND
- Play_Sound (MESSAGE_SOUND);
+#if defined(HAVE_SDL)
+ Play_Sound(MESSAGE_WAV);
+#else
+ Play_Sound(MESSAGE_SOUND);
+#endif
#endif
message_on ();
data->key = 'A';
@@ -2713,7 +2725,11 @@
{
#ifdef SOUND
- Play_Sound (SELF_DESTRUCT_SOUND);
+#if defined(HAVE_SDL)
+ Play_Sound(SELF_DESTRUCT_WAV);
+#else
+ Play_Sound(SELF_DESTRUCT_SOUND);
+#endif
#endif
sendQuitReq ();
@@ -3133,7 +3149,11 @@
{
#ifdef SOUND
- Play_Sound (MESSAGE_SOUND);
+#if defined(HAVE_SDL)
+ Play_Sound(MESSAGE_WAV);
+#else
+ Play_Sound(MESSAGE_SOUND);
+#endif
#endif
message_on ();
@@ -3197,7 +3217,11 @@
{
#ifdef SOUND
- Play_Sound (SELF_DESTRUCT_SOUND);
+#if defined(HAVE_SDL)
+ Play_Sound(SELF_DESTRUCT_WAV);
+#else
+ Play_Sound(SELF_DESTRUCT_SOUND);
+#endif
#endif
fastQuit = 1;
Index: local.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/local.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- local.c 21 Apr 2006 12:00:07 -0000 1.6
+++ local.c 24 Apr 2006 14:13:25 -0000 1.7
@@ -148,8 +148,6 @@
/* redraw upper sector */
redrawStarSector (sectorx, sectory-1);
- /* redraw upper sector */
- redrawStarSector (sectorx, sectory-1);
if (r)
/* redraw upper-right sector */
@@ -481,8 +479,12 @@
{
#ifdef SOUND
- if (myPlayer (j) && (j->p_cloakphase == 0))
- Play_Sound (CLOAK_SOUND);
+ if (myPlayer(j) && (j->p_cloakphase == 0))
+#if defined(HAVE_SDL)
+ Play_Sound(CLOAKED_WAV);
+#else
+ Play_Sound(CLOAK_SOUND);
+#endif
#endif
j->p_cloakphase++;
@@ -492,13 +494,19 @@
{
if (j->p_cloakphase)
{
+
#ifdef SOUND
- if (myPlayer (j))
+ if (myPlayer(j))
if (j->p_cloakphase == CLOAK_PHASES - 1)
- Play_Sound (UNCLOAK_SOUND);
+#if defined(HAVE_SDL)
+ Play_Sound(UNCLOAK_WAV);
+#else
+ Play_Sound(UNCLOAK_SOUND);
else
- Abort_Sound (CLOAK_SOUND);
+ Abort_Sound(CLOAK_SOUND);
+#endif
#endif
+
j->p_cloakphase--;
}
}
@@ -704,9 +712,17 @@
if (j->p_no == me->p_no)
{
if ((sound_flags & PFSHIELD) && !(j->p_flags & PFSHIELD))
- Play_Sound (SHIELD_DOWN_SOUND);
+#if defined(HAVE_SDL)
+ Play_Sound(SHIELD_DOWN_WAV);
+#else
+ Play_Sound(SHIELD_DOWN_SOUND);
+#endif
if (!(sound_flags & PFSHIELD) && (j->p_flags & PFSHIELD))
- Play_Sound (SHIELD_UP_SOUND);
+#if defined(HAVE_SDL)
+ Play_Sound(SHIELD_UP_WAV);
+#else
+ Play_Sound(SHIELD_UP_SOUND);
+#endif
}
#endif
@@ -853,11 +869,14 @@
int i;
i = j->p_explode;
-
+
#ifdef SOUND
if (i == 1)
- Play_Sound (j ==
- me ? EXPLOSION_SOUND : OTHER_EXPLOSION_SOUND);
+#if defined(HAVE_SDL)
+ Play_Sound(j == me ? EXPLOSION_WAV : EXPLOSION_OTHER_WAV);
+#else
+ Play_Sound(j == me ? EXPLOSION_SOUND : OTHER_EXPLOSION_SOUND);
+#endif
#endif
if (i < BMP_SHIPEXPL_FRAMES ||
@@ -900,13 +919,19 @@
if (php->ph_status != PHFREE)
{
+
#ifdef SOUND
if (!sound_phaser)
{
- Play_Sound (j == me ? PHASER_SOUND : OTHER_PHASER_SOUND);
+#if defined(HAVE_SDL)
+ Play_Sound(j == me ? PHASER_WAV : PHASER_OTHER_WAV);
+#else
+ Play_Sound(j == me ? PHASER_SOUND : OTHER_PHASER_SOUND);
+#endif
sound_phaser++;
}
#endif
+
if ((php->ph_updateFuse -= weaponUpdate) == 0)
{
/* Expire the phaser */
@@ -1342,8 +1367,13 @@
#ifdef SOUND
if (k->t_fuse == BMP_TORPDET_FRAMES - 1)
- Play_Sound (TORP_HIT_SOUND);
+#if defined(HAVE_SDL)
+ Play_Sound(TORP_HIT_WAV);
+#else
+ Play_Sound(TORP_HIT_SOUND);
#endif
+#endif
+
#ifdef COLORIZEWEAPON
switch (j->p_team)
{
@@ -1516,11 +1546,16 @@
{
pt->pt_fuse = BMP_TORPDET_FRAMES - 1;
}
-
+
#ifdef SOUND
if (pt->pt_fuse == BMP_TORPDET_FRAMES - 1)
- Play_Sound (PLASMA_HIT_SOUND);
+#if defined(HAVE_SDL)
+ Play_Sound(PLASMA_HIT_WAV);
+#else
+ Play_Sound(PLASMA_HIT_SOUND);
#endif
+#endif
+
#ifdef COLORIZEWEAPON
switch (players[pt->pt_owner].p_team)
{
@@ -1820,8 +1855,8 @@
}
W_ChangeBorder (baseWin, gColor);
-#ifdef SOUND
- Abort_Sound (WARNING_SOUND);
+#if defined(SOUND) && !defined(HAVE_SDL)
+ Abort_Sound(WARNING_SOUND);
#endif
break;
@@ -1835,8 +1870,8 @@
}
W_ChangeBorder (baseWin, yColor);
-#ifdef SOUND
- Abort_Sound (WARNING_SOUND);
+#if defined(SOUND) && !defined(HAVE_SDL)
+ Abort_Sound(WARNING_SOUND);
#endif
break;
@@ -1849,9 +1884,13 @@
//W_ChangeBorderDB (localSDB, rColor);
}
W_ChangeBorder (baseWin, rColor);
-
+
#ifdef SOUND
- Play_Sound (WARNING_SOUND);
+#if defined(HAVE_SDL)
+ Play_Sound(WARNING_WAV);
+#else
+ Play_Sound(WARNING_SOUND);
+#endif
#endif
break;
@@ -1859,12 +1898,21 @@
}
#ifdef SOUND
+#if defined(HAVE_SDL)
if (sound_torps < me->p_ntorp)
- Play_Sound (FIRE_TORP_SOUND);
+ Play_Sound(FIRE_TORP_WAV);
if (sound_other_torps < num_other_torps)
- Play_Sound (OTHER_FIRE_TORP_SOUND);
+ Play_Sound(FIRE_TORP_OTHER_WAV);
if (sound_plasma < me->p_nplasmatorp)
- Play_Sound (FIRE_PLASMA_SOUND);
+ Play_Sound(FIRE_PLASMA_WAV);
+#else
+ if (sound_torps < me->p_ntorp)
+ Play_Sound(FIRE_TORP_SOUND);
+ if (sound_other_torps < num_other_torps)
+ Play_Sound(OTHER_FIRE_TORP_SOUND);
+ if (sound_plasma < me->p_nplasmatorp)
+ Play_Sound(FIRE_PLASMA_SOUND);
+#endif
sound_flags = me->p_flags;
sound_torps = me->p_ntorp;
Index: makefile
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/makefile,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- makefile 21 Apr 2006 12:00:07 -0000 1.5
+++ makefile 24 Apr 2006 14:13:25 -0000 1.6
@@ -48,7 +48,7 @@
#
!IFDEF DEBUG
-ldebug = /Gn /v
+ldebug = /Gn /v
!ELSE
ldebug = /Gn /w-dup
!ENDIF
@@ -72,7 +72,7 @@
#..\Win32\lib\libmpbcc.lib
!ENDIF
-LIBS = CW32mt.LIB IMPORT32.LIB user32.lib gdi32.lib wsock32.lib kernel32.lib shell32.lib winmm.lib mpr.lib $(GMPLIB)
+LIBS = SDL.LIB SDL_mixer.LIB SDL_main.LIB CW32mt.LIB IMPORT32.LIB user32.lib gdi32.lib wsock32.lib kernel32.lib shell32.lib winmm.lib mpr.lib $(GMPLIB)
# ---------------------------------------------------------------------------
# - Start of makefile proper
Index: playback.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/playback.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- playback.c 21 Apr 2006 12:00:07 -0000 1.8
+++ playback.c 24 Apr 2006 14:13:25 -0000 1.9
@@ -282,8 +282,8 @@
if (i >= RETURNBASE)
return (i - RETURNBASE); /* Terminate with retcode */
-#ifdef SOUND
- Abort_Sound (ENGINE_SOUND);
+#if defined(SOUND) && !defined(HAVE_SDL)
+ Abort_Sound(ENGINE_SOUND);
#endif
//#ifdef nodef
@@ -326,8 +326,13 @@
redrawPStats ();
#ifdef SOUND
- Play_Sound (ENTER_SHIP_SOUND);
- Play_Sound (ENGINE_SOUND);
+#if defined(HAVE_SDL)
+ Mix_HaltChannel(-1); /* Kill all currently playing sounds when entering game */
+ Play_Sound(ENTER_SHIP_WAV);
+#else
+ Play_Sound(ENTER_SHIP_SOUND);
+ Play_Sound(ENGINE_SOUND);
+#endif
#endif
while (1)
Index: beeplite.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/beeplite.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- beeplite.c 19 Apr 2006 15:18:27 -0000 1.3
+++ beeplite.c 24 Apr 2006 14:13:25 -0000 1.4
@@ -1,6 +1,9 @@
/* beeplite.c
*
* $Log$
+ * Revision 1.4 2006/04/24 14:13:25 modemhero
+ * Initial SDL patch for multilayered sounds.
+ *
* Revision 1.3 2006/04/19 15:18:27 modemhero
* Tidied up the save_options function, fixing some spacing errors, and puttting the
* keymap/buttonmap on the top of the list due to its importance. Also added the
@@ -217,17 +220,24 @@
if (F_beeplite_flags & LITE_SOUNDS)
{
-#ifdef SOUND
- if (sound_toggle)
- Play_Sound(MESSAGE_SOUND);
- else
+#if defined(SOUND)
+#if defined(HAVE_SDL)
+ Play_Sound(MESSAGE_WAV);
+#else
+ if (sound_toggle)
+ Play_Sound(MESSAGE_SOUND);
+ else
+ W_Beep();
+#endif
#endif
-
- W_Beep();
}
break;
+/* The sound files don't even exist in standard client, and
+ are not loaded into SDL library currently - can change at
+ a later time. */
#ifdef SOUND
+#if !defined(HAVE_SDL)
case '1':
if (F_beeplite_flags & LITE_SOUNDS)
Play_Sound(MESSAGE1_SOUND);
@@ -265,6 +275,7 @@
Play_Sound(MESSAGE9_SOUND);
break;
#endif
+#endif
/* Text between: /| | will be displayed with TTS */
case '|':
Index: cowmain.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/cowmain.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- cowmain.c 21 Apr 2006 12:00:06 -0000 1.7
+++ cowmain.c 24 Apr 2006 14:13:25 -0000 1.8
@@ -768,6 +768,10 @@
resetdefaults ();
savebitmaps ();
+
+#if defined(SOUND) && defined(HAVE_SDL)
+ Init_Sound();
+#endif
/* open memory...? */
openmem ();
@@ -892,18 +896,21 @@
init_hockey_lines ();
#endif
-#ifdef SOUND
- Init_Sound ();
+ /* Moved SDL sound initialization to right after readdefaults() so
+ * the intro can start playing ASAP */
+#if defined(SOUND) && !defined(HAVE_SDL)
+ Init_Sound();
#endif
+
isFirstEntry = 1; /* First entry into game */
i = setjmp (env); /* Reentry point of game */
if (i >= RETURNBASE)
return (i - RETURNBASE); /* Terminate with retcode */
-#ifdef SOUND
- Abort_Sound (ENGINE_SOUND);
+#if defined(SOUND) && !defined(HAVE_SDL)
+ Abort_Sound(ENGINE_SOUND);
#endif
/* give the player the motd and find out which team he wants */
@@ -950,8 +957,8 @@
sendByeReq ();
-#ifdef SOUND
- Exit_Sound ();
+#if defined(SOUND) && !defined(HAVE_SDL)
+ Exit_Sound();
#endif
sleep (1);
@@ -1034,8 +1041,13 @@
#ifdef SOUND
- Play_Sound (ENTER_SHIP_SOUND);
- Play_Sound (ENGINE_SOUND);
+#if defined(HAVE_SDL)
+ Mix_HaltChannel(-1); /* Kill all currently playing sounds when entering game */
+ Play_Sound(ENTER_SHIP_WAV);
+#else
+ Play_Sound(ENTER_SHIP_SOUND);
+ Play_Sound(ENGINE_SOUND);
+#endif /* HAVE_SDL */
#endif
/* Get input until the player quits or dies */