From 724a0251d5fda2957766864846716912502f6989 Mon Sep 17 00:00:00 2001 From: relnev Date: Sun, 16 Jun 2002 01:43:23 +0000 Subject: [PATCH] fixed demo dogfight multiplayer mission minor sound changes --- README | 5 ++ src/io/joy-unix.cpp | 34 +++++++----- src/missionui/missionweaponchoice.cpp | 11 +++- src/sound/ds.cpp | 74 ++++++++++++++++++++------- src/sound/midifile.cpp | 36 ------------- src/sound/winmidi.cpp | 39 -------------- src/sound/winmidi_base.cpp | 39 -------------- 7 files changed, 91 insertions(+), 147 deletions(-) delete mode 100644 src/sound/midifile.cpp delete mode 100644 src/sound/winmidi.cpp delete mode 100644 src/sound/winmidi_base.cpp diff --git a/README b/README index ebd7eff..a8b25ce 100644 --- a/README +++ b/README @@ -1,6 +1,9 @@ Don't have the game? Where to buy: http://shop.store.yahoo.com/softwares4u/ga891.html +http://dynamic4.gamespy.com/~freespace/forums/ +http://fs2source.warpcore.org/ +http://www.icculus.org/projects/freespace2/ 06/08/2002 @@ -11,6 +14,8 @@ Current status: - It currently uses SDL (http://www.libsdl.org) and OpenAL (http://opensource.creative.com) +- Code currently REQUIRES gcc 3.0. gcc 2.95 and 3.1 won't work. + - The OpenGL code is complete minus one or two things, but it is unoptimized. - Keyboard and mouse work. Joystick code exists but it is not finished. diff --git a/src/io/joy-unix.cpp b/src/io/joy-unix.cpp index 6389b89..ee9dda3 100644 --- a/src/io/joy-unix.cpp +++ b/src/io/joy-unix.cpp @@ -1,3 +1,11 @@ +/* + * Copyright (C) Volition, Inc. 1999. All rights reserved. + * + * All source code herein is the property of Volition, Inc. You may not sell + * or otherwise commercially exploit the source or things you created based on + * the source. + */ + #include "pstypes.h" #include "joy.h" #include "fix.h" @@ -247,67 +255,67 @@ int joystick_read_raw_axis(int num_axes, int *axis) void joy_ff_adjust_handling(int speed) { - STUB_FUNCTION; +// STUB_FUNCTION; } void joy_ff_afterburn_off() { - STUB_FUNCTION; +// STUB_FUNCTION; } void joy_ff_afterburn_on() { - STUB_FUNCTION; +// STUB_FUNCTION; } void joy_ff_deathroll() { - STUB_FUNCTION; +// STUB_FUNCTION; } void joy_ff_docked() { - STUB_FUNCTION; +// STUB_FUNCTION; } void joy_ff_explode() { - STUB_FUNCTION; +// STUB_FUNCTION; } void joy_ff_fly_by(int mag) { - STUB_FUNCTION; +// STUB_FUNCTION; } void joy_ff_mission_init(vector v) { - STUB_FUNCTION; +// STUB_FUNCTION; } void joy_ff_play_dir_effect(float x, float y) { - STUB_FUNCTION; +// STUB_FUNCTION; } void joy_ff_play_primary_shoot(int gain) { - STUB_FUNCTION; +// STUB_FUNCTION; } void joy_ff_play_reload_effect() { - STUB_FUNCTION; +// STUB_FUNCTION; } void joy_ff_play_secondary_shoot(int gain) { - STUB_FUNCTION; +// STUB_FUNCTION; } void joy_ff_play_vector_effect(vector *v, float scaler) { - STUB_FUNCTION; +// STUB_FUNCTION; } void joy_ff_stop_effects() diff --git a/src/missionui/missionweaponchoice.cpp b/src/missionui/missionweaponchoice.cpp index 8852467..821c1a5 100644 --- a/src/missionui/missionweaponchoice.cpp +++ b/src/missionui/missionweaponchoice.cpp @@ -15,6 +15,11 @@ * C module for the weapon loadout screen * * $Log$ + * Revision 1.4 2002/06/16 01:43:23 relnev + * fixed demo dogfight multiplayer mission + * + * minor sound changes + * * Revision 1.3 2002/06/09 04:41:23 relnev * added copyright header * @@ -1205,10 +1210,14 @@ int weapon_allowed_for_game_type(int weapon_flags) { int rval = 0; +/* disable check for demo since it doesn't have "$Allowed Dogfight PBanks" */ +#ifndef FS2_DEMO if ((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_DOGFIGHT)) { if (weapon_flags & (1 << 1)) rval = 1; - } else if (weapon_flags & (1 << 0)) + } else +#endif + if (weapon_flags & (1 << 0)) rval = 1; return rval; diff --git a/src/sound/ds.cpp b/src/sound/ds.cpp index 8b0365d..7aac1ec 100644 --- a/src/sound/ds.cpp +++ b/src/sound/ds.cpp @@ -15,6 +15,11 @@ * C file for interface to DirectSound * * $Log$ + * Revision 1.11 2002/06/16 01:43:23 relnev + * fixed demo dogfight multiplayer mission + * + * minor sound changes + * * Revision 1.10 2002/06/09 04:41:26 relnev * added copyright header * @@ -516,6 +521,7 @@ typedef struct sound_buffer int bits_per_sample; int nchannels; int nseconds; + int nbytes; } sound_buffer; #define MAX_DS_SOFTWARE_BUFFERS 256 @@ -875,6 +881,7 @@ int ds_load_buffer(int *sid, int *hid, int *final_size, void *header, sound_info sound_buffers[*sid].bits_per_sample = si->bits; sound_buffers[*sid].nchannels = si->n_channels; sound_buffers[*sid].nseconds = si->size / si->avg_bytes_per_sec; + sound_buffers[*sid].nbytes = si->size; OpenAL_ErrorCheck(); @@ -2190,6 +2197,7 @@ int ds_create_buffer(int frequency, int bits_per_sample, int nchannels, int nsec sound_buffers[sid].bits_per_sample = bits_per_sample; sound_buffers[sid].nchannels = nchannels; sound_buffers[sid].nseconds = nseconds; + sound_buffers[sid].nbytes = nseconds * (bits_per_sample / 8) * nchannels * frequency; return sid; #else @@ -2261,7 +2269,9 @@ int ds_lock_data(int sid, unsigned char *data, int size) } else { return -1; } - + + sound_buffers[sid].nbytes = size; + alBufferData(buf_id, format, data, size, sound_buffers[sid].frequency); OpenAL_ErrorCheck(); @@ -2356,7 +2366,9 @@ int ds_play_easy(int sid, int volume) Channels[channel].buf_id = sid; - /* TODO: volume */ + ALfloat alvol = (volume != -10000) ? pow(10.0, (float)volume / (-600.0 / log10(.5))): 0.0; + + alSourcef(source_id, AL_GAIN, alvol); alSourcei(source_id, AL_LOOPING, AL_FALSE); alSourcePlay(source_id); @@ -2429,9 +2441,9 @@ int ds_play(int sid, int hid, int snd_id, int priority, int volume, int pan, int /* TODO: pan */ // Channels[channel].pdsb->SetPan(pan); - /* TODO: volume */ - // Channels[channel].pdsb->SetVolume(volume); - + ALfloat alvol = (volume != -10000) ? pow(10.0, (float)volume / (-600.0 / log10(.5))): 0.0; + alSourcef(Channels[channel].source_id, AL_GAIN, alvol); + Channels[channel].is_voice_msg = is_voice_msg; OpenAL_ErrorCheck(); @@ -2481,15 +2493,16 @@ int ds_play(int sid, int hid, int snd_id, int priority, int volume, int pan, int continue; } - // TODO: this thing - // DWORD current_position = ds_get_play_position(i); - // if (current_position != 0) { - // if (current_position < Channels[i].last_position) { - // ds_close_channel(i); - // } else { - // Channels[i].last_position = current_position; - // } - // } +#ifndef PLAT_UNIX /* TODO: play position still needs some work */ + DWORD current_position = ds_get_play_position(i); + if (current_position != 0) { + if (current_position < Channels[i].last_position) { + ds_stop_channel(i); + } else { + Channels[i].last_position = current_position; + } + } +#endif } } @@ -2600,6 +2613,7 @@ int ds_play(int sid, int hid, int snd_id, int priority, int volume, int pan, int continue; } +#ifndef PLAT_UNIX /* TODO: play position still needs some work */ DWORD current_position = ds_get_play_position(i); if (current_position != 0) { if (current_position < Channels[i].last_position) { @@ -2608,6 +2622,7 @@ int ds_play(int sid, int hid, int snd_id, int priority, int volume, int pan, int Channels[i].last_position = current_position; } } +#endif } } @@ -2739,7 +2754,13 @@ void ds_stop_channel_all() void ds_set_volume( int channel, int vol ) { #ifdef PLAT_UNIX - STUB_FUNCTION; + ALuint source_id = Channels[channel].source_id; + + if (source_id != 0) { + ALfloat alvol = (vol != -10000) ? pow(10.0, (float)vol / (-600.0 / log10(.5))): 0.0; + + alSourcef(source_id, AL_GAIN, alvol); + } #else HRESULT hr; unsigned long status; @@ -3073,9 +3094,14 @@ void ds_set_position(int channel, DWORD offset) DWORD ds_get_play_position(int channel) { #ifdef PLAT_UNIX - STUB_FUNCTION; + ALint pos; + + /* TODO: does this work ? */ + alGetSourceiv(Channels[channel].source_id, AL_BYTE_LOKI, &pos); - return 0; + if (pos == -1) + return 0; + return pos; #else DWORD play,write; if ( Channels[channel].pdsb ) { @@ -3109,8 +3135,12 @@ DWORD ds_get_write_position(int channel) int ds_get_channel_size(int channel) { #ifdef PLAT_UNIX - STUB_FUNCTION; - + int buf_id = Channels[channel].buf_id; + + if (buf_id != -1) { + return sound_buffers[buf_id].nbytes; + } + return 0; #else int size; @@ -3592,14 +3622,20 @@ void ds_do_frame() continue; } +#ifndef PLAT_UNIX /* TODO: get play position needs some work */ int current_position = ds_get_play_position(i); if (current_position != 0) { if (current_position < cp->last_position) { +#ifdef PLAT_UNIX + ds_stop_channel(i); +#else ds_close_channel(i); +#endif } else { cp->last_position = current_position; } } +#endif } } } diff --git a/src/sound/midifile.cpp b/src/sound/midifile.cpp deleted file mode 100644 index e573a02..0000000 --- a/src/sound/midifile.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) Volition, Inc. 1999. All rights reserved. - * - * All source code herein is the property of Volition, Inc. You may not sell - * or otherwise commercially exploit the source or things you created based on - * the source. - */ - -/* - * $Logfile: /Freespace2/code/Sound/midifile.cpp $ - * $Revision$ - * $Date$ - * $Author$ - * - * C module to handle MIDI file reading and manipulation - * - * $Log$ - * Revision 1.2 2002/06/09 04:41:27 relnev - * added copyright header - * - * Revision 1.1.1.1 2002/05/03 03:28:10 root - * Initial import. - * - * - * 2 10/07/98 10:54a Dave - * Initial checkin. - * - * 1 10/07/98 10:51a Dave - * - * 4 1/19/98 11:37p Lawrance - * Fixing Optimization build warnings - * - * - * $NoKeywords: $ - */ - diff --git a/src/sound/winmidi.cpp b/src/sound/winmidi.cpp deleted file mode 100644 index 3050acb..0000000 --- a/src/sound/winmidi.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) Volition, Inc. 1999. All rights reserved. - * - * All source code herein is the property of Volition, Inc. You may not sell - * or otherwise commercially exploit the source or things you created based on - * the source. - */ - -/* - * $Logfile: /Freespace2/code/Sound/WinMIDI.cpp $ - * $Revision$ - * $Date$ - * $Author$ - * - * C module for playing and managing MIDI files - * - * $Log$ - * Revision 1.3 2002/06/09 04:41:27 relnev - * added copyright header - * - * Revision 1.2 2002/05/07 03:16:52 theoddone33 - * The Great Newline Fix - * - * Revision 1.1.1.1 2002/05/03 03:28:10 root - * Initial import. - * - * - * 2 10/07/98 10:54a Dave - * Initial checkin. - * - * 1 10/07/98 10:51a Dave - * - * 3 1/19/98 11:37p Lawrance - * Fixing Optimization build warnings - * - * - * $NoKeywords: $ - */ - diff --git a/src/sound/winmidi_base.cpp b/src/sound/winmidi_base.cpp deleted file mode 100644 index 89db3ae..0000000 --- a/src/sound/winmidi_base.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) Volition, Inc. 1999. All rights reserved. - * - * All source code herein is the property of Volition, Inc. You may not sell - * or otherwise commercially exploit the source or things you created based on - * the source. - */ - -/* - * $Logfile: /Freespace2/code/Sound/winmidi_base.cpp $ - * $Revision$ - * $Date$ - * $Author$ - * - * C module that contains mid-level MIDI functions for streaming data - * - * $Log$ - * Revision 1.3 2002/06/09 04:41:27 relnev - * added copyright header - * - * Revision 1.2 2002/05/07 03:16:52 theoddone33 - * The Great Newline Fix - * - * Revision 1.1.1.1 2002/05/03 03:28:10 root - * Initial import. - * - * - * 2 10/07/98 10:54a Dave - * Initial checkin. - * - * 1 10/07/98 10:51a Dave - * - * 3 1/19/98 11:37p Lawrance - * Fixing Optimization build warnings - * - * - * $NoKeywords: $ - */ - -- 2.39.2