Update of /cvsroot/netrek/client/netrekxp/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6804/src
Modified Files:
beeplite.c cowmain.c data.c dmessage.c findslot.c getname.c
local.c makefile newwin.c playback.c sound.c warning.c
Log Message:
This latest series of changes adds stereo quasi-3D sound effects for both players and observers, as well as adding much improved support for observer sounds (previously they were limited as to what sounds they would hear).
Index: findslot.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/findslot.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- findslot.c 24 Apr 2006 15:30:38 -0000 1.4
+++ findslot.c 26 Apr 2006 02:04:24 -0000 1.5
@@ -23,6 +23,8 @@
#include "struct.h"
#include "data.h"
#include "proto.h"
+#include "SDL.h"
+#include "SDL_mixer.h"
#define WAITMOTD
@@ -115,6 +117,8 @@
#if defined(SOUND)
if (!newSound)
Exit_Sound();
+ else
+ Mix_CloseAudio();
#endif
LineToConsole ("Shit! Ghostbusted!\n");
@@ -162,6 +166,8 @@
#if defined(SOUND)
if (!newSound)
Exit_Sound();
+ else
+ Mix_CloseAudio();
#endif
LineToConsole ("Damn, We've been ghostbusted!\n");
@@ -222,6 +228,8 @@
#if defined(SOUND)
if (!newSound)
Exit_Sound();
+ else
+ Mix_CloseAudio();
#endif
LineToConsole ("OK, bye!\n");
Index: dmessage.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/dmessage.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- dmessage.c 21 Apr 2006 12:00:06 -0000 1.4
+++ dmessage.c 26 Apr 2006 02:04:24 -0000 1.5
@@ -121,7 +121,7 @@
register int len;
W_Color color;
char timebuf[10];
- LONG curtime;
+ time_t curtime;
struct tm *tm;
int take, destroy, team, kill, killp, killa, bomb, conq;
struct distress dist;
Index: sound.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/sound.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- sound.c 24 Apr 2006 15:30:38 -0000 1.4
+++ sound.c 26 Apr 2006 02:04:24 -0000 1.5
@@ -53,6 +53,7 @@
{"nt_shield_up", 3, 1},
{"nt_torp_hit", 8, 1},
{"nt_warning", 5, 1},
+ {"nt_red_alert", 5, 1},
{"nt_engine", 0, 0},
{"nt_enter_ship", 4, 1},
{"nt_self_destruct", 6, 1},
@@ -97,8 +98,9 @@
newsounds[EXPLOSION_WAV] = Mix_LoadWAV(DATAFILE("nt_explosion.wav"));
newsounds[EXPLOSION_OTHER_WAV] = Mix_LoadWAV(DATAFILE("nt_explosion_other.wav"));
newsounds[FIRE_PLASMA_WAV] = Mix_LoadWAV(DATAFILE("nt_fire_plasma.wav"));
+ newsounds[OTHER_FIRE_PLASMA_WAV] = Mix_LoadWAV(DATAFILE("nt_fire_plasma_other.wav"));
newsounds[FIRE_TORP_WAV] = Mix_LoadWAV(DATAFILE("nt_fire_torp.wav"));
- newsounds[FIRE_TORP_OTHER_WAV] = Mix_LoadWAV(DATAFILE("nt_fire_torp_other.wav"));
+ newsounds[OTHER_FIRE_TORP_WAV] = Mix_LoadWAV(DATAFILE("nt_fire_torp_other.wav"));
newsounds[INTRO_WAV] = Mix_LoadWAV(DATAFILE("nt_intro.wav"));
newsounds[MESSAGE_WAV] = Mix_LoadWAV(DATAFILE("nt_message.wav"));
newsounds[PHASER_WAV] = Mix_LoadWAV(DATAFILE("nt_phaser.wav"));
@@ -207,14 +209,18 @@
{
if (newSound)
{
+ int channel;
+
if (!sound_init)
return;
if ((type >= NUM_WAVES) || (type < 0))
LineToConsole("Invalid sound type %d\n", type);
- if (Mix_PlayChannel(-1, newsounds[type], 0) < 0)
+ if ((channel = Mix_PlayChannel(-1, newsounds[type], 0)) < 0)
LineToConsole("Mix_PlayChannel: %s\n", Mix_GetError());
+
+ Group_Sound(type, channel);
}
else
{
@@ -238,6 +244,58 @@
current_sound = NO_SOUND;
}
}
+extern void Play_Sound_Loc (int type, int angle, int distance)
+{
+ int channel;
+
+ if (!sound_init)
+ return;
+
+ if ((type >= NUM_WAVES) || (type < 0))
+ LineToConsole("Invalid sound type %d\n", type);
+
+ if ((channel = Mix_PlayChannel(-1, newsounds[type], 0)) < 0)
+ {
+ LineToConsole("Mix_PlayChannel: %s\n", Mix_GetError());
+ return;
+ }
+ /* Make sure distance in boundary range that function accepts */
+ if (distance < 0)
+ distance = 0;
+ if (distance > 255)
+ distance = 255;
+ // Adjust volume with distance and angle
+ if (Mix_SetPosition(channel, angle, distance) == 0)
+ LineToConsole("Mix_SetPosition: %s\n", Mix_GetError());
+
+ Group_Sound(type, channel);
+ return;
+}
+
+void Group_Sound (int type, int channel)
+{
+ // Add channel to group by type, useful for aborting specific sounds
+ // at a later time
+ // Current designations:
+ // group 1 = cloaked_wav
+ // group 2 = warning_wav
+ // group 3 = red_alert_wav
+ switch(type)
+ {
+ case CLOAKED_WAV:
+ if(!Mix_GroupChannel(channel,1))
+ LineToConsole("Mix_GroupChannel: %s\n", Mix_GetError());
+ break;
+ case WARNING_WAV:
+ if(!Mix_GroupChannel(channel,2))
+ LineToConsole("Mix_GroupChannel: %s\n", Mix_GetError());
+ break;
+ case RED_ALERT_WAV:
+ if(!Mix_GroupChannel(channel,3))
+ LineToConsole("Mix_GroupChannel: %s\n", Mix_GetError());
+ break;
+ }
+}
extern void Abort_Sound (int type)
{
@@ -315,6 +373,9 @@
case WARNING_SOUND:
sprintf (buf, "Warning sound is %s", flag);
break;
+ case RED_ALERT_SOUND:
+ sprintf (buf, "Red alert sound is %s", flag);
+ break;
case SHIELD_DOWN_SOUND:
sprintf (buf, "Shield down sound is %s", flag);
break;
Index: newwin.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/newwin.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- newwin.c 24 Apr 2006 15:30:38 -0000 1.11
+++ newwin.c 26 Apr 2006 02:04:24 -0000 1.12
@@ -9,11 +9,11 @@
/******************************************************************************/
#include <stdio.h>
+#include <io.h>
#include <stdlib.h>
#include <math.h>
#include <signal.h>
#include <sys/types.h>
-
#include <time.h>
#include <winsock.h>
@@ -739,7 +739,7 @@
/******************************************************************************/
savebitmaps (void)
{
- int i, j, k;
+ int i, k;
char *Planlib;
char *MPlanlib;
@@ -1058,7 +1058,7 @@
UpdatePlayerList (); /* Otherwise */
- autoQuit = (time_t) intDefault ("autoQuit", autoQuit); /* allow extra */
+ autoQuit = intDefault ("autoQuit", autoQuit); /* allow extra */
/* quit time -RW */
do
@@ -1089,7 +1089,7 @@
readFromServer (&rfds);
}
elapsed = time (0) - startTime;
- if (elapsed > autoQuit)
+ if (elapsed > (time_t)(autoQuit))
{
LineToConsole ("Auto-Quit.\n");
*team = 4;
Index: cowmain.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/cowmain.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- cowmain.c 24 Apr 2006 15:30:38 -0000 1.9
+++ cowmain.c 26 Apr 2006 02:04:24 -0000 1.10
@@ -29,6 +29,8 @@
#include "parsemeta.h"
#include "map.h"
#include "proto.h"
+#include "SDL.h"
+#include "SDL_mixer.h"
/******************************************************************************/
/*** Local Globals ***/
@@ -583,7 +585,7 @@
(void) SIGNAL (SIGFPE, handle_exception);
#endif
- SRANDOM (time (0));
+ SRANDOM ((unsigned int)time (0));
initDefaults (deffile);
@@ -603,8 +605,8 @@
if (!serverName)
serverName = server;
}
-
- SRANDOM (getpid () * time ((LONG *) 0));
+
+ SRANDOM (getpid () * (unsigned int)time (NULL));
if (!passive)
{
@@ -964,6 +966,8 @@
#if defined(SOUND)
if (!newSound)
Exit_Sound();
+ else
+ Mix_CloseAudio();
#endif
sleep (1);
Index: local.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/local.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- local.c 24 Apr 2006 15:30:38 -0000 1.8
+++ local.c 26 Apr 2006 02:04:24 -0000 1.9
@@ -20,11 +20,12 @@
#include "data.h"
#include "local.h"
#include "proto.h"
-
+#include "SDL.h"
+#include "SDL_mixer.h"
#include "bitmaps.h"
/* Local Variables */
-
+#define XPI 3.1415926
static int clearcount = 0;
static int clearzone[4][(MAXTORP + 1) * MAXPLAYER +
(MAXPLASMA + 1) * MAXPLAYER + MAXPLANETS];
@@ -43,9 +44,18 @@
static int sound_other_torps = 0;
static int num_other_torps = 0;
static int sound_plasma = 0;
-static int sound_other_plasma = 0;
+static int sound_other_plasmas = 0;
+static int num_other_plasmas = 0;
static int sound_other_explode = 0;
static unsigned int sound_flags = 0;
+static int other_torp_dist = 0;
+static int new_other_torp_dist = 0;
+static int other_torp_angle = 0;
+static int old_t_fuse = 0;
+static int other_plasma_dist = 0;
+static int new_other_plasma_dist = 0;
+static int other_plasma_angle = 0;
+static int old_pt_fuse = 0;
#endif
/* Background Stars Definitions */
@@ -442,6 +452,7 @@
const int view = SCALE * WINSIDE / 2 + BMP_SHIELD_WIDTH * SCALE / 2;
int dx, dy, px, py, wx, wy, tx, ty, lx, ly;
int new_dx, new_dy;
+ int newdx, newdy, distance, angle; /* For newSound */
W_Icon (*ship_bits)[SHIP_VIEWS];
@@ -470,21 +481,47 @@
if (!(j->p_flags & PFCLOAK))
continue;
}
+
+ dx = j->p_x - me->p_x;
+ dy = j->p_y - me->p_y;
+ if (dx > view || dx < -view || dy > view || dy < -view)
+ continue;
- /* jmn - observer support.. tried to diplay tractors but no works */
-
+ dx = dx / SCALE + WINSIDE / 2;
+ dy = dy / SCALE + WINSIDE / 2;
+
if (j->p_flags & PFCLOAK)
{
if (j->p_cloakphase < (CLOAK_PHASES - 1))
{
-
+
#ifdef SOUND
- if (myPlayer(j) && (j->p_cloakphase == 0))
+ if (j->p_cloakphase == 0)
{
if (newSound)
- Play_Sound(CLOAKED_WAV);
+ {
+ newdx = dx - WINSIDE/2;
+ newdy = dy - WINSIDE/2;
+
+ distance = (int) sqrt((newdx)*(newdx) + (newdy)*(newdy));
+ // Normalize from 0 to 255, 0 being on top of player, 255 being max distance
+ // which would be a diagonal from player to corner of tactical
+ // Reason for normalization is Mix_SetDistance requires that range
+ distance = (int)((255 * distance)/CORNER_DIST);
+ // Calculate angle, then adjust as necessary for Mix_SetDistance
+ angle = (int)(atan2(newdy, newdx)*180/XPI);
+ angle = 270 - angle;
+ // At short distances, don't use angular sound
+ if (distance < 10)
+ Play_Sound(CLOAKED_WAV);
+ else
+ Play_Sound_Loc(CLOAKED_WAV, angle, distance);
+ }
else
- Play_Sound(CLOAK_SOUND);
+ {
+ if (myPlayer(j) || isObsLockPlayer(j))
+ Play_Sound(CLOAK_SOUND);
+ }
}
#endif
@@ -497,32 +534,47 @@
{
#ifdef SOUND
- if (myPlayer(j))
+ if (newSound)
+ {
if (j->p_cloakphase == CLOAK_PHASES - 1)
{
- if (newSound)
+ newdx = dx - WINSIDE/2;
+ newdy = dy - WINSIDE/2;
+
+ distance = (int) sqrt((newdx)*(newdx) + (newdy)*(newdy));
+ // Normalize from 0 to 255, 0 being on top of player, 255 being max distance
+ // which would be a diagonal from player to corner of tactical
+ // Reason for normalization is Mix_SetDistance requires that range
+ distance = (int)((255 * distance)/CORNER_DIST);
+ // Calculate angle, then adjust as necessary for Mix_SetDistance
+ angle = (int)(atan2(newdy, newdx)*180/XPI);
+ angle = 270 - angle;
+ // At short distances, don't use angular sound
+ if (distance < 10)
Play_Sound(UNCLOAK_WAV);
else
- Play_Sound(UNCLOAK_SOUND);
+ Play_Sound_Loc(UNCLOAK_WAV, angle, distance);
}
- else
+ else // Kill any channels with CLOAKED_WAV on them (group 1)
+ Mix_HaltGroup(1);
+
+ }
+ else
+ {
+ if (myPlayer(j) || isObsLockPlayer(j))
{
- if (!newSound)
- Abort_Sound(CLOAK_SOUND);
- }
+ if (j->p_cloakphase == CLOAK_PHASES - 1)
+ Play_Sound(UNCLOAK_SOUND);
+ else
+ Abort_Sound(CLOAK_SOUND);
+ }
+ }
+
#endif
j->p_cloakphase--;
}
}
- dx = j->p_x - me->p_x;
- dy = j->p_y - me->p_y;
- if (dx > view || dx < -view || dy > view || dy < -view)
- continue;
-
- dx = dx / SCALE + WINSIDE / 2;
- dy = dy / SCALE + WINSIDE / 2;
-
if (j->p_flags & PFCLOAK && (j->p_cloakphase == (CLOAK_PHASES - 1)))
{
@@ -714,7 +766,7 @@
#endif
#ifdef SOUND
- if (j->p_no == me->p_no)
+ if (myPlayer(j) || isObsLockPlayer(j))
{
if ((sound_flags & PFSHIELD) && !(j->p_flags & PFSHIELD))
{
@@ -881,9 +933,34 @@
if (i == 1)
{
if (newSound)
- Play_Sound(j == me ? EXPLOSION_WAV : EXPLOSION_OTHER_WAV);
+ {
+ if (myPlayer(j) || isObsLockPlayer(j))
+ Play_Sound(EXPLOSION_WAV);
+ else
+ {
+ int newdx, newdy, distance, angle;
+
+ newdx = dx - WINSIDE/2;
+ newdy = dy - WINSIDE/2;
+
+ distance = (int) sqrt((newdx)*(newdx) + (newdy)*(newdy));
+ // Normalize from 0 to 255, 0 being on top of player, 255 being max distance
+ // which would be a diagonal from player to corner of tactical
+ // Reason for normalization is Mix_SetDistance requires that range
+ distance = (int)((255 * distance)/CORNER_DIST);
+ // Calculate angle, then adjust as necessary for Mix_SetDistance
+ angle = (int)(atan2(newdy, newdx)*180/XPI);
+ angle = 270 - angle;
+ // At short distances, don't use angular sound
+ if (distance < 10)
+ Play_Sound(EXPLOSION_OTHER_WAV);
+ else
+ Play_Sound_Loc(EXPLOSION_OTHER_WAV, angle, distance);
+ }
+ }
else
- Play_Sound(j == me ? EXPLOSION_SOUND : OTHER_EXPLOSION_SOUND);
+ Play_Sound((myPlayer(j) || isObsLockPlayer(j))
+ ? EXPLOSION_SOUND : OTHER_EXPLOSION_SOUND);
}
#endif
@@ -930,11 +1007,37 @@
#ifdef SOUND
if (!sound_phaser)
- {
+ {
if (newSound)
- Play_Sound(j == me ? PHASER_WAV : PHASER_OTHER_WAV);
+ {
+ if (myPlayer(j) || isObsLockPlayer(j))
+ Play_Sound(PHASER_WAV);
+ else
+ {
+ int newdx, newdy, distance, angle;
+
+ newdx = dx - WINSIDE/2;
+ newdy = dy - WINSIDE/2;
+
+ distance = (int) sqrt((newdx)*(newdx) + (newdy)*(newdy));
+ // Normalize from 0 to 255, 0 being on top of player, 255 being max distance
+ // which would be a diagonal from player to corner of tactical
+ // Reason for normalization is Mix_SetDistance requires that range
+ distance = (int)((255 * distance)/CORNER_DIST);
+ // Calculate angle, then adjust as necessary for Mix_SetDistance
+ angle = (int)(atan2(newdy, newdx)*180/XPI);
+ angle = 270 - angle;
+ // At short distances, don't use angular sound
+ if (distance < 10)
+ Play_Sound(PHASER_OTHER_WAV);
+ else
+ Play_Sound_Loc(PHASER_OTHER_WAV, angle, distance);
+ }
+ }
else
- Play_Sound(j == me ? PHASER_SOUND : OTHER_PHASER_SOUND);
+ Play_Sound((myPlayer(j) || isObsLockPlayer(j))
+ ? PHASER_SOUND : OTHER_PHASER_SOUND);
+
sound_phaser++;
}
#endif
@@ -1116,11 +1219,9 @@
#ifdef SHORT_PACKETS
if (php->ph_status != PHMISS) /* KOC 10/20/95 */
{ /* hack for SP_2 */
-#define XPI 3.1415926
dir = (unsigned char)
nint (atan2((double) (ty - py),
(double) (tx - px)) / XPI * 128.0);
-#undef XPI
}
else
#endif
@@ -1170,7 +1271,7 @@
}
#ifdef SOUND
- else if (j->p_no == me->p_no)
+ else if (myPlayer(j) || isObsLockPlayer(j))
sound_phaser = 0;
#endif
@@ -1215,7 +1316,6 @@
continue; /* this had better be last
* in for(..) */
-#define XPI 3.1415926
theta = atan2 ((double) (px - dx),
(double) (dy - py)) + XPI / 2.0;
dir = (unsigned char) nint (theta / XPI * 128.0);
@@ -1229,7 +1329,6 @@
ly[0] = (int) (py + (Sin[dir] * (target_width / 2)));
lx[1] = (int) (px - (Cos[dir] * (target_width / 2)));
ly[1] = (int) (py - (Sin[dir] * (target_width / 2)));
-#undef XPI
if (j->p_flags & PFPRESS)
{
W_MakeTractLine (w, dx, dy, lx[0], ly[0], W_Yellow);
@@ -1354,9 +1453,50 @@
continue;
}
+#ifdef SOUND
+ if (j != me && newSound)
+ {
+ int new_t_fuse;
+ int new_angle;
+ int newdy, newdx;
+
+ newdy = dy / SCALE;
+ newdx = dx / SCALE;
+ // Store location of torp.
+ new_other_torp_dist = (int) sqrt((newdx)*(newdx) + (newdy)*(newdy));
+ // Normalize from 0 to 255, 0 being on top of player, 255 being max distance
+ // which would be a diagonal from player to corner of tactical
+ // Reason for normalization is Mix_SetDistance requires that range
+ new_other_torp_dist = (int)((255 * new_other_torp_dist)/CORNER_DIST);
+ // Find how long till torp expires...BROKEN!
+ new_t_fuse = k->t_updateFuse;
+ // Calculate angle, then adjust as necessary for Mix_SetDistance
+ new_angle = (int)(atan2(newdy, newdx)*180/XPI);
+ new_angle = 270 - new_angle;
+ // Find torp that has been around the least time, that is the one to play
+ // the sound from. In case of tie, choose closest one.
+ if (new_t_fuse > old_t_fuse)
+ {
+ other_torp_dist = new_other_torp_dist;
+ old_t_fuse = new_t_fuse;
+ other_torp_angle = new_angle;
+ }
+ else if (new_t_fuse == old_t_fuse)
+ {
+ if (new_other_torp_dist < other_torp_dist)
+ {
+ other_torp_dist = new_other_torp_dist;
+ old_t_fuse = new_t_fuse;
+ other_torp_angle = new_angle;
+ }
+ }
+
+ }
+#endif
dx = dx / SCALE + WINSIDE / 2;
dy = dy / SCALE + WINSIDE / 2;
+
if (k->t_status == TEXPLODE)
{
@@ -1376,7 +1516,26 @@
if (k->t_fuse == BMP_TORPDET_FRAMES - 1)
{
if (newSound)
- Play_Sound(TORP_HIT_WAV);
+ {
+ int newdx, newdy, distance, angle;
+
+ newdx = dx - WINSIDE/2;
+ newdy = dy - WINSIDE/2;
+
+ distance = (int) sqrt((newdx)*(newdx) + (newdy)*(newdy));
+ // Normalize from 0 to 255, 0 being on top of player, 255 being max distance
+ // which would be a diagonal from player to corner of tactical
+ // Reason for normalization is Mix_SetDistance requires that range
+ distance = (int)((255 * distance)/CORNER_DIST);
+ // Calculate angle, then adjust as necessary for Mix_SetDistance
+ angle = (int)(atan2(newdy, newdx)*180/XPI);
+ angle = 270 - angle;
+ // At short distances, don't use angular sound
+ if (distance < 10)
+ Play_Sound(TORP_HIT_WAV);
+ else
+ Play_Sound_Loc(TORP_HIT_WAV, angle, distance);
+ }
else
Play_Sound(TORP_HIT_SOUND);
}
@@ -1509,7 +1668,10 @@
{
if (!pt->pt_status)
continue;
-
+#ifdef SOUND
+ if (pt->pt_owner != me->p_no)
+ num_other_plasmas++;
+#endif
if ((pt->pt_updateFuse -= weaponUpdate) == 0)
{
if (pt->pt_status != PTEXPLODE)
@@ -1537,6 +1699,47 @@
if (dx > view || dx < -view || dy > view || dy < -view)
continue;
+
+#ifdef SOUND
+ if (pt->pt_owner != me->p_no && newSound)
+ {
+ int new_pt_fuse;
+ int new_angle;
+ int newdy, newdx;
+
+ newdy = dy / SCALE;
+ newdx = dx / SCALE;
+ // Store location of plasma.
+ new_other_plasma_dist = (int) sqrt((newdx)*(newdx) + (newdy)*(newdy));
+ // Normalize from 0 to 255, 0 being on top of player, 255 being max distance
+ // which would be a diagonal from player to corner of tactical
+ // Reason for normalization is Mix_SetDistance requires that range
+ new_other_plasma_dist = (int)((255 * new_other_plasma_dist)/CORNER_DIST);
+ // Find how long till torp expires...BROKEN!
+ new_pt_fuse = pt->pt_updateFuse;
+ // Calculate angle, then adjust as necessary for Mix_SetDistance
+ new_angle = (int)(atan2(newdy, newdx)*180/XPI);
+ new_angle = 270 - new_angle;
+ // Find plasma that has been around the least time, that is the one to play
+ // the sound from. In case of tie, choose closest one.
+ if (new_pt_fuse > old_pt_fuse)
+ {
+ other_plasma_dist = new_other_plasma_dist;
+ old_pt_fuse = new_pt_fuse;
+ other_plasma_angle = new_angle;
+ }
+ else if (new_pt_fuse == old_pt_fuse)
+ {
+ if (new_other_torp_dist < other_torp_dist)
+ {
+ other_plasma_dist = new_other_plasma_dist;
+ old_pt_fuse = new_pt_fuse;
+ other_plasma_angle = new_angle;
+ }
+ }
+ }
+#endif
+
dx = dx / SCALE + WINSIDE / 2;
dy = dy / SCALE + WINSIDE / 2;
@@ -1559,7 +1762,26 @@
if (pt->pt_fuse == BMP_TORPDET_FRAMES - 1)
{
if (newSound)
- Play_Sound(PLASMA_HIT_WAV);
+ {
+ int newdx, newdy, distance, angle;
+
+ newdx = dx - WINSIDE/2;
+ newdy = dy - WINSIDE/2;
+
+ distance = (int) sqrt((newdx)*(newdx) + (newdy)*(newdy));
+ // Normalize from 0 to 255, 0 being on top of player, 255 being max distance
+ // which would be a diagonal from player to corner of tactical
+ // Reason for normalization is Mix_SetDistance requires that range
+ distance = (int)((255 * distance)/CORNER_DIST);
+ // Calculate angle, then adjust as necessary for Mix_SetDistance
+ angle = (int)(atan2(newdy, newdx)*180/XPI);
+ angle = 270 - angle;
+ // At short distances, don't use angular sound
+ if (distance < 10)
+ Play_Sound(PLASMA_HIT_WAV);
+ else
+ Play_Sound_Loc(PLASMA_HIT_WAV, angle, distance);
+ }
else
Play_Sound(PLASMA_HIT_SOUND);
}
@@ -1865,8 +2087,18 @@
W_ChangeBorder (baseWin, gColor);
#if defined(SOUND)
- if (!newSound)
+ if (newSound)
+ { // Kill any channels with WARNING_WAV on them (group 2)
+ // or RED_ALERT_WAV (group 3)
+ Mix_HaltGroup(2);
+ Mix_HaltGroup(3);
+ }
+ else
+ {
Abort_Sound(WARNING_SOUND);
+ Abort_Sound(RED_ALERT_SOUND);
+ }
+
#endif
break;
@@ -1881,8 +2113,18 @@
W_ChangeBorder (baseWin, yColor);
#if defined(SOUND)
- if (!newSound)
- Abort_Sound(WARNING_SOUND);
+
+ if (newSound) // Kill any channels with RED_ALERT_WAV on them (group 3)
+ {
+ Mix_HaltGroup(3);
+ Play_Sound(WARNING_WAV);
+ }
+ else
+ {
+ Abort_Sound(RED_ALERT_SOUND);
+ Play_Sound(WARNING_SOUND);
+ }
+
#endif
break;
@@ -1896,26 +2138,47 @@
}
W_ChangeBorder (baseWin, rColor);
-#ifdef SOUND
+#if defined(SOUND)
if (newSound)
- Play_Sound(WARNING_WAV);
+ Play_Sound(RED_ALERT_WAV);
else
- Play_Sound(WARNING_SOUND);
+ Play_Sound(RED_ALERT_SOUND);
#endif
break;
}
}
-#ifdef SOUND
+#if defined(SOUND)
if (newSound)
{
if (sound_torps < me->p_ntorp)
Play_Sound(FIRE_TORP_WAV);
if (sound_other_torps < num_other_torps)
- Play_Sound(FIRE_TORP_OTHER_WAV);
+ {
+ if (other_torp_dist < 10)
+ Play_Sound(OTHER_FIRE_TORP_WAV);
+ else
+ Play_Sound_Loc(OTHER_FIRE_TORP_WAV, other_torp_angle, other_torp_dist);
+ }
if (sound_plasma < me->p_nplasmatorp)
Play_Sound(FIRE_PLASMA_WAV);
+ if (sound_other_plasmas < num_other_plasmas)
+ {
+ if (other_plasma_dist < 10)
+ Play_Sound(OTHER_FIRE_PLASMA_WAV);
+ else
+ Play_Sound_Loc(OTHER_FIRE_PLASMA_WAV, other_plasma_angle, other_plasma_dist);
+ }
+ // Reset locations and fuses of other's closest torps and plasmas
+ other_torp_dist = CORNER_DIST;
+ new_other_torp_dist = 0;
+ old_t_fuse = 0;
+ other_torp_angle = 0;
+ other_plasma_dist = CORNER_DIST;
+ new_other_plasma_dist = 0;
+ old_pt_fuse = 0;
+ other_plasma_angle = 0;
}
else
{
@@ -1925,6 +2188,8 @@
Play_Sound(OTHER_FIRE_TORP_SOUND);
if (sound_plasma < me->p_nplasmatorp)
Play_Sound(FIRE_PLASMA_SOUND);
+ if (sound_other_plasmas < num_other_plasmas)
+ Play_Sound(OTHER_FIRE_PLASMA_SOUND);
}
sound_flags = me->p_flags;
@@ -1932,6 +2197,8 @@
sound_other_torps = num_other_torps;
num_other_torps = 0;
sound_plasma = me->p_nplasmatorp;
+ sound_other_plasmas = num_other_plasmas;
+ num_other_plasmas = 0;
#endif
/* show 'lock' icon on local map (Actually an EM hack ) */
Index: makefile
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/makefile,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- makefile 24 Apr 2006 14:13:25 -0000 1.6
+++ makefile 26 Apr 2006 02:04:24 -0000 1.7
@@ -65,19 +65,19 @@
# wsock32.lib kernel32.lib shell32.lib winmm.lib mpr.lib
# Borland Libs
-LIBOPTS = /LC:\Borland\bcc55\lib;c:\Borland\bcc55\lib\psdk /Tpe
+LIBOPTS = /LC:\Borland\bcc55\lib;c:\Borland\bcc55\lib\psdk;..\Win32\lib\BCC /Tpe
!IFDEF RSA
-GMPLIB = ..\Win32\lib\libgmpbcc.lib
-#..\Win32\lib\libmpbcc.lib
+GMPLIB = ..\Win32\lib\BCC\libgmpbcc.lib
+#..\Win32\lib\BCC\libmpbcc.lib
!ENDIF
-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)
+LIBS = SDL.LIB SDL_mixer.LIB SDLmain.LIB CW32mt.LIB IMPORT32.LIB user32.lib gdi32.lib wsock32.lib kernel32.lib shell32.lib winmm.lib mpr.lib $(GMPLIB)
# ---------------------------------------------------------------------------
# - Start of makefile proper
-INCS = -I..\win32 -I..\win32\h -I..\win32\h\gmp -I..\include
+INCS = -I..\win32 -I..\win32\h -I..\win32\SDL -I..\win32\h\gmp -I..\include
ARCH = Intel/Win32
!IFDEF RSA
Index: getname.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/getname.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- getname.c 21 Apr 2006 12:00:07 -0000 1.3
+++ getname.c 26 Apr 2006 02:04:24 -0000 1.4
@@ -403,7 +403,7 @@
W_Event event;
unsigned char ch;
char tempstr[40];
- long lasttime;
+ time_t lasttime;
int j;
struct timeval tv;
fd_set mask;
Index: playback.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/playback.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- playback.c 24 Apr 2006 15:30:38 -0000 1.10
+++ playback.c 26 Apr 2006 02:04:24 -0000 1.11
@@ -32,6 +32,8 @@
#include "defs.h"
#include "playerlist.h"
#include "proto.h"
+#include "SDL.h"
+#include "SDL_mixer.h"
#ifdef RECORDGAME
@@ -69,11 +71,11 @@
outmessage[i] = '\0';
}
- SRANDOM (time (0));
+ SRANDOM ((unsigned int)time (0));
initDefaults (deffile);
-
- SRANDOM (getpid () * time ((LONG *) 0));
+
+ SRANDOM (getpid () * (unsigned int)time (NULL));
fed_ship_bmp = "bitmaps/shiplib/fedship.bmp";
if ((stringDefault ("fedshipbmpfile")) != NULL)
Index: data.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/data.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- data.c 24 Apr 2006 15:30:38 -0000 1.11
+++ data.c 26 Apr 2006 02:04:24 -0000 1.12
@@ -81,7 +81,7 @@
int delay = 0; /* delay for decaring war */
int rdelay = 0; /* delay for refitting */
int showPlanetNames = 1;
-time_t autoQuit = 60;
+int autoQuit = 60;
int showStats = 0;
int showHints = 1;
int warnShields = 0;
Index: beeplite.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/beeplite.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- beeplite.c 24 Apr 2006 15:30:38 -0000 1.5
+++ beeplite.c 26 Apr 2006 02:04:24 -0000 1.6
@@ -20,8 +20,10 @@
#include "data.h"
#include "map.h"
#include "proto.h"
+#include "SDL.h"
+#include "SDL_mixer.h"
-rcdlite(struct distress *dist)
+void rcdlite(struct distress *dist)
/* the info */
{
char message[100];
@@ -43,7 +45,7 @@
}
-litedefaults(void)
+void litedefaults(void)
{
if (distlite[take] == NULL)
distlite[take] = "/c/l";
@@ -55,7 +57,7 @@
distlite[generic] = "%?%S=SB%{/c%}";
}
-liteplanet(struct planet *l)
+void liteplanet(struct planet *l)
{
emph_planet_seq_n[l->pl_no] = beep_lite_cycle_time_planet;
l->pl_flags |= PLREDRAW; /* Leave redraw on until * *
@@ -64,7 +66,7 @@
* done highlighting */
}
-liteplayer(struct player *j)
+void liteplayer(struct player *j)
{
if (!j || (j->p_flags & PFCLOAK))
return;
Index: warning.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/warning.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- warning.c 15 Apr 2006 09:58:25 -0000 1.3
+++ warning.c 26 Apr 2006 02:04:24 -0000 1.4
@@ -27,7 +27,7 @@
warning (char *text)
{
int doPhaser;
- LONG curtime;
+ time_t curtime;
struct tm *tm;
char newtext[128];
char newtext2[128];