From 885074607c694dda30439099fb94660eb37e36c2 Mon Sep 17 00:00:00 2001 From: zicodxx <> Date: Sun, 1 Jun 2008 12:53:03 +0000 Subject: [PATCH] Using Windows code to play HMP files on Windows build; Fixed Jukebox keys in help screen; Allow -noredundancy in Singleplayer; Fixed processing of Console keys if Console is not active; Added Multiplayer hints to README; Made INI wrapping safer and more accurate --- CHANGELOG.txt | 4 ++++ README.txt | 14 +++++++++-- arch/sdl/digi_audio.c | 5 ---- arch/sdl/digi_mixer.c | 45 ++++++++++++++++++++++++++++++++++-- arch/sdl/digi_mixer_music.c | 4 ++-- arch/win32/hmpfile.c | 2 ++ arch/win32/include/hmpfile.h | 3 +++ d1x.ini | 2 +- include/args.h | 2 +- main/game.c | 10 ++++---- main/hud.c | 2 +- main/inferno.c | 2 +- misc/args.c | 25 ++++++++++++-------- 13 files changed, 89 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 53523c493..bc18f6f4f 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,9 @@ D1X-Rebirth Changelog +20080601 +-------- +include/args.h, main/inferno.c, main/hud.c, main/game.c, main/gamecntl.c, misc/args.c, d2x.ini, README.txt, arch/sdl/digi_mixer.c, arch/sdl/digi_mixer_music.c, arch/sdl/digi_audio.c, arch/win32/include/hmpfile.h, arch/win32/hmpfile.c: Using Windows code to play HMP files on Windows build; Fixed Jukebox keys in help screen; Allow -noredundancy in Singleplayer; Fixed processing of Console keys if Console is not active; Added Multiplayer hints to README; Made INI wrapping safer and more accurate + 20080528 -------- arch/sdl/rbaudio.c, main/songs.c: allow an audio CD to be played if it's inserted after D1X is launched, hopefully find the first audio CD if multiple CDs are inserted diff --git a/README.txt b/README.txt index 97f0ed790..d71188697 100644 --- a/README.txt +++ b/README.txt @@ -53,12 +53,22 @@ For example: See INSTALL.txt. -3. Legal stuff +3. Multiplayer + +DXX-Rebirth supports Multiplayer over (obsoleted) IPX and UDP/IP. +Using UDP/IP works over LAN and Internet. Since the Networking code of the Descent Engine is Peer-to-Peer, it is necessary for +all players (Host and Clients) to open port UDP 31017. +Clients can put an offset to this port by using '-ip_baseport OFFSET'. +Hosts can also use option '-ip_relay' to route players with closed ports. Use this with caution. It will increase Lag and Ping drastically. +UDP/IP also supports IPv6 by compiling the game with the designated flag. Please note IPv4- and IPv6-builds cannot play together. + + +4. Legal stuff See COPYING.txt -4. Contact +5. Contact http://www.dxx-rebirth.de/ zicodxx [at] yahoo [dot] de diff --git a/arch/sdl/digi_audio.c b/arch/sdl/digi_audio.c index 25ac5b780..e75d6d7cc 100644 --- a/arch/sdl/digi_audio.c +++ b/arch/sdl/digi_audio.c @@ -431,11 +431,6 @@ void digi_audio_end_sound(int channel) SoundSlots[channel].persistent = 0; } -#ifdef _WIN32 -hmp_file *hmp = NULL; -static int digi_midi_song_playing = 0; -#endif - // MIDI stuff follows. void digi_audio_set_midi_volume( int mvolume ) { diff --git a/arch/sdl/digi_mixer.c b/arch/sdl/digi_mixer.c index 9a2b42973..a1cca44c3 100644 --- a/arch/sdl/digi_mixer.c +++ b/arch/sdl/digi_mixer.c @@ -33,6 +33,10 @@ #include "gr.h" // needed for piggy.h #include "piggy.h" +#ifdef _WIN32 +#include "hmpfile.h" +#endif + #define MIX_DIGI_DEBUG 0 #define MIX_OUTPUT_FORMAT AUDIO_S16 #define MIX_OUTPUT_CHANNELS 2 @@ -182,6 +186,23 @@ void digi_mixer_set_digi_volume( int dvolume ) } void digi_mixer_set_midi_volume( int mvolume ) { +#ifdef _WIN32 + int mm_volume; + + if (mvolume < 0) + midi_volume = 0; + else if (mvolume > 127) + midi_volume = 127; + else + midi_volume = mvolume; + + // scale up from 0-127 to 0-0xffff + mm_volume = (midi_volume << 1) | (midi_volume & 1); + mm_volume |= (mm_volume << 8); + + if (hmp) + midiOutSetVolume((HMIDIOUT)hmp->hmidi, mm_volume | mm_volume << 16); +#endif midi_volume = mvolume; if (!digi_initialised) return; mix_set_music_volume(mvolume); @@ -223,9 +244,21 @@ void digi_mixer_play_midi_song(char * filename, char * melodic_bank, char * drum // use jukebox jukebox_play(loop); } - else { + else { // standard song playback - mix_play_music(filename, loop); +#ifdef _WIN32 + if (!GameArg.SndExternalMusic) + { + if ((hmp = hmp_open(filename))) + { + hmp_play(hmp,loop); + digi_midi_song_playing = 1; + digi_set_midi_volume(midi_volume); + } + } + else +#endif + mix_play_music(filename, loop); } } @@ -235,6 +268,14 @@ int digi_mixer_music_exists(const char *filename) } void digi_mixer_stop_current_song() { +#ifdef _WIN32 + if (digi_midi_song_playing) + { + hmp_close(hmp); + hmp = NULL; + digi_midi_song_playing = 0; + } +#endif jukebox_stop(); //stops jukebox as well as standard music } diff --git a/arch/sdl/digi_mixer_music.c b/arch/sdl/digi_mixer_music.c index a0a5dddfd..5e715179c 100644 --- a/arch/sdl/digi_mixer_music.c +++ b/arch/sdl/digi_mixer_music.c @@ -94,10 +94,10 @@ void mix_play_music(char *filename, int loop) { // What is the extension of external files? If none, default to internal MIDI if (GameArg.SndExternalMusic) { - sprintf(rel_filename, "%s/%s.%3s", basedir, music_title, GameArg.SndExternalMusic); // add extension + snprintf(rel_filename, strlen(basedir)+strlen(music_title)+6, "%s/%s.%s", basedir, music_title, GameArg.SndExternalMusic); // add extension } else { - sprintf(rel_filename, "%s/%s.mid", basedir, music_title); + snprintf(rel_filename, strlen(basedir)+strlen(music_title)+6, "%s/%s.mid", basedir, music_title); convert_hmp(filename, rel_filename); } diff --git a/arch/win32/hmpfile.c b/arch/win32/hmpfile.c index ac8b3dfad..b935bc3fc 100644 --- a/arch/win32/hmpfile.c +++ b/arch/win32/hmpfile.c @@ -15,6 +15,8 @@ #endif extern void PumpMessages(void); +hmp_file *hmp = NULL; +int digi_midi_song_playing = 0; hmp_file *hmp_open(const char *filename) { int i; diff --git a/arch/win32/include/hmpfile.h b/arch/win32/include/hmpfile.h index eb3984237..43c9f0c03 100644 --- a/arch/win32/include/hmpfile.h +++ b/arch/win32/include/hmpfile.h @@ -51,4 +51,7 @@ hmp_file *hmp_open(const char *filename); int hmp_play(hmp_file *hmp, int bLoop); void hmp_close(hmp_file *hmp); +extern hmp_file *hmp; +extern int digi_midi_song_playing; + #endif diff --git a/d1x.ini b/d1x.ini index c67db91b2..e1416d829 100644 --- a/d1x.ini +++ b/d1x.ini @@ -12,6 +12,7 @@ ;-autodemo Start in demo mode ;-notitles Skip title screens ;-window Run the game in a window +;-noredundancy Do not send messages when picking up redundant items Controls: @@ -36,7 +37,6 @@ Multiplayer: ;-mprofile Enable multiplayer game profiles -;-noredundancy Do not send messages when picking up redundant items in multiplayer ;-playermessages View only messages from other players in multi - overrides -noredundancy ;-ipxnetwork Use IPX network number ;-ip_baseport Use

as offset from normal port diff --git a/include/args.h b/include/args.h index 578a9bdad..c41d84141 100644 --- a/include/args.h +++ b/include/args.h @@ -52,6 +52,7 @@ typedef struct Arg int SysWindow; int SysAutoDemo; int SysNoTitles; + int SysNoRedundancy; int CtlNoMouse; int CtlNoJoystick; int CtlMouselook; @@ -67,7 +68,6 @@ typedef struct Arg #endif int EdiNoBm; int MplGameProfile; - int MplNoRedundancy; int MplPlayerMessages; const char *MplIpxNetwork; int MplIpBasePort; diff --git a/main/game.c b/main/game.c index bcb86f658..e5d180f45 100644 --- a/main/game.c +++ b/main/game.c @@ -1414,8 +1414,8 @@ void show_help() m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = TXT_HELP_1TO5; m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = TXT_HELP_6TO10; #ifdef USE_SDLMIXER - m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "Shift-F9/F10\t Play/Pause Jukebox"; - m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "Shift-F11/F12\t Previous/Next Song"; + m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "Alt-Shift-F9/F10\t Play/Pause Jukebox"; + m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "Alt-Shift-F11/F12\t Previous/Next Song"; #endif m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = ""; m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "MULTIPLAYER:"; @@ -2508,11 +2508,9 @@ void ReadControls() #endif while ((key=key_inkey_time(&key_time)) != 0) { - if (con_events(key)) - { + if (con_events(key) && con_render) game_flush_inputs(); - continue; - } + if (Player_is_dead) HandleDeathKey(key); diff --git a/main/hud.c b/main/hud.c index 6fe29ecce..46df2eed5 100644 --- a/main/hud.c +++ b/main/hud.c @@ -163,7 +163,7 @@ int HUD_init_message_va(char * format, va_list args) // Added by Leighton - if ((Game_mode & GM_MULTI) && GameArg.MplNoRedundancy) + if (GameArg.SysNoRedundancy) if (!strnicmp ("You already",message,11) || !stricmp("your laser is maxed out!",message)) return 0; diff --git a/main/inferno.c b/main/inferno.c index 56aecce95..24940ebfe 100644 --- a/main/inferno.c +++ b/main/inferno.c @@ -148,6 +148,7 @@ void show_commandline_help() printf( " -autodemo %s\n", "Start in demo mode"); printf( " -notitles %s\n", "Skip title screens"); printf( " -window %s\n", "Run the game in a window"); + printf( " -noredundancy %s\n", "Do not send messages when picking up redundant items"); printf( "\n Controls:\n\n"); printf( " -nomouse %s\n", "Deactivate mouse"); @@ -173,7 +174,6 @@ void show_commandline_help() #ifdef NETWORK printf( "\n Multiplayer:\n\n"); printf( " -mprofile %s\n", "Enable multiplayer game profiles"); - printf( " -noredundancy %s\n", "Do not send messages when picking up redundant items in multiplayer"); printf( " -playermessages %s\n", "View only messages from other players in multi - overrides -noredundancy"); printf( " -ipxnetwork %s\n", "Use IPX network number "); printf( " -ip_baseport %s\n", "Use as offset from normal port (allows multiple instances of d1x to be run on a single computer)"); diff --git a/misc/args.c b/misc/args.c index 642675db3..c20f16429 100644 --- a/misc/args.c +++ b/misc/args.c @@ -85,7 +85,8 @@ int FindResArg(char *prefix, int *sw, int *sh) void AppendIniArgs(void) { PHYSFS_file *f; - char *line,*word; + char *line, *token; + char separator[] = " "; f = PHYSFSX_openReadBuffered(INI_FILENAME); @@ -93,14 +94,18 @@ void AppendIniArgs(void) while(!PHYSFS_eof(f) && Num_args < MAX_ARGS) { line=fgets_unlimited(f); - word=splitword(line,' '); - - Args[Num_args++] = d_strdup(word); - - if(line) - Args[Num_args++] = d_strdup(line); - - d_free(line); d_free(word); + + token = strtok(line, separator); /* first token in current line */ + if (token) + Args[Num_args++] = d_strdup(token); + while( token != NULL ) + { + token = strtok(NULL, separator); /* next tokens in current line */ + if (token) + Args[Num_args++] = d_strdup(token); + } + + d_free(line); } PHYSFS_close(f); } @@ -142,6 +147,7 @@ void ReadCmdArgs(void) GameArg.SysWindow = FindArg("-window"); GameArg.SysNoTitles = FindArg("-notitles"); GameArg.SysAutoDemo = FindArg("-autodemo"); + GameArg.SysNoRedundancy = FindArg("-noredundancy"); // Control Options @@ -174,7 +180,6 @@ void ReadCmdArgs(void) // Multiplayer Options GameArg.MplGameProfile = FindArg("-mprofile"); - GameArg.MplNoRedundancy = FindArg("-noredundancy"); GameArg.MplPlayerMessages = FindArg("-playermessages"); GameArg.MplIpxNetwork = get_str_arg("-ipxnetwork", NULL); GameArg.MplIpBasePort = get_int_arg("-ip_baseport", 0);