X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=d48e713c51b629d2e2c7a4acb617728d7313cbac;hb=da14f69fd95c7bd5a0d70cdf4935af06f1f20a04;hp=a8ce6a50bc357ce2dde3cede3b3535b47224973e;hpb=b96c3dc500494652748c24f0aa48a8201ea202dd;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index a8ce6a50..d48e713c 100644 --- a/src/init.c +++ b/src/init.c @@ -13,10 +13,10 @@ #include +#include "libgame/libgame.h" + #include "init.h" #include "events.h" -#include "misc.h" -#include "sound.h" #include "screens.h" #include "editor.h" #include "game.h" @@ -24,8 +24,6 @@ #include "tools.h" #include "files.h" #include "joystick.h" -#include "image.h" -#include "pcx.h" #include "network.h" #include "netserv.h" @@ -35,10 +33,6 @@ struct PictureFileInfo boolean picture_with_mask; }; -#ifndef USE_SDL_LIBRARY -static int sound_process_id = 0; -#endif - static void InitPlayerInfo(void); static void InitLevelInfo(void); static void InitNetworkServer(void); @@ -52,16 +46,16 @@ static void InitElementProperties(void); void OpenAll(int argc, char *argv[]) { -#if defined(MSDOS) || defined(WIN32) +#if !defined(PLATFORM_UNIX) initErrorFile(); #endif if (options.serveronly) { -#ifdef WIN32 - Error(ERR_WARN, "networking not supported in Windows version"); -#else +#if defined(PLATFORM_UNIX) NetworkServer(options.server_port, options.serveronly); +#else + Error(ERR_WARN, "networking not supported in Windows version"); #endif /* never reached */ @@ -121,14 +115,14 @@ void InitLevelInfo() void InitNetworkServer() { -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) int nr_wanted; #endif if (!options.network) return; -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED); if (!ConnectToServer(options.server_host, options.server_port)) @@ -146,69 +140,7 @@ void InitSound() { int i; - if (sound_status == SOUND_OFF) - return; - -#ifdef USE_SDL_LIBRARY - /* initialize SDL audio */ - - if (SDL_Init(SDL_INIT_AUDIO) < 0) - { - Error(ERR_WARN, "SDL_Init() failed: %s", SDL_GetError()); - sound_status = SOUND_OFF; - return; - } - - if (Mix_OpenAudio(22050, AUDIO_S16, 2, 512) < 0) - { - Error(ERR_WARN, "Mix_OpenAudio() failed: %s", SDL_GetError()); - sound_status = SOUND_OFF; - return; - } - - Mix_Volume(-1, SDL_MIX_MAXVOLUME / 4); - Mix_VolumeMusic(SDL_MIX_MAXVOLUME / 4); - - sound_status = SOUND_AVAILABLE; - sound_loops_allowed = TRUE; - -#else /* !USE_SDL_LIBRARY */ - -#if !defined(MSDOS) && !defined(WIN32) - if (access(sound_device_name, W_OK) != 0) - { - Error(ERR_WARN, "cannot access sound device - no sounds"); - sound_status = SOUND_OFF; - return; - } - - if ((sound_device = OpenAudio(sound_device_name)) < 0) - { - Error(ERR_WARN, "cannot open sound device - no sounds"); - sound_status = SOUND_OFF; - return; - } - - close(sound_device); - sound_status = SOUND_AVAILABLE; - -#ifdef VOXWARE - sound_loops_allowed = TRUE; - - /* - setup.sound_loops_on = TRUE; - */ - -#endif -#else /* MSDOS || WIN32 */ - sound_loops_allowed = TRUE; - - /* - setup.sound_loops_on = TRUE; - */ - -#endif /* MSDOS || WIN32 */ -#endif /* !USE_SDL_LIBRARY */ + OpenAudio(&audio); for(i=0; ipicture_with_mask && !clipmask[pos]) Error(ERR_EXIT, "cannot get clipmask for '%s'", pic->picture_filename); -#endif /* !USE_SDL_LIBRARY */ +#endif } void InitGadgets() @@ -1847,14 +1772,14 @@ void CloseAllAndExit(int exit_value) { int i; -#ifdef USE_SDL_LIBRARY +#if defined(TARGET_SDL) StopSounds(); FreeSounds(NUM_SOUNDS); #else - if (sound_process_id) + if (audio.soundserver_pid) { StopSounds(); - kill(sound_process_id, SIGTERM); + kill(audio.soundserver_pid, SIGTERM); FreeSounds(NUM_SOUNDS); } #endif @@ -1864,7 +1789,7 @@ void CloseAllAndExit(int exit_value) if (pix[i]) FreeBitmap(pix[i]); -#ifdef USE_SDL_LIBRARY +#if defined(TARGET_SDL) FreeBitmap(pix_masked[i]); #else if (clipmask[i]) @@ -1874,7 +1799,7 @@ void CloseAllAndExit(int exit_value) #endif } -#ifdef USE_SDL_LIBRARY +#if defined(TARGET_SDL) KeyboardAutoRepeatOn(); #else if (gc) @@ -1887,7 +1812,7 @@ void CloseAllAndExit(int exit_value) } #endif -#if defined(MSDOS) || defined(WIN32) +#if !defined(PLATFORM_UNIX) dumpErrorFile(); #endif