X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=f1c7ffd9c297f78a313cd408a3ed079bf1af37e3;hb=d5b2ac0f473b0868014826e2c6488c72c79008f1;hp=64f748019cac0e9050ef5048b0939bb616c9a7c1;hpb=6d639c557d602855b9866959445f3f5b5513d289;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index 64f74801..f1c7ffd9 100644 --- a/src/init.c +++ b/src/init.c @@ -41,9 +41,12 @@ struct IconFileInfo char *picturemask_filename; }; +#ifndef USE_SDL_LIBRARY static int sound_process_id = 0; +#endif -static void InitLevelAndPlayerInfo(void); +static void InitPlayerInfo(void); +static void InitLevelInfo(void); static void InitNetworkServer(void); static void InitDisplay(void); static void InitSound(void); @@ -56,18 +59,24 @@ static void InitElementProperties(void); void OpenAll(int argc, char *argv[]) { -#ifdef MSDOS +#if defined(MSDOS) || defined(WIN32) initErrorFile(); #endif if (options.serveronly) { +#ifdef WIN32 + Error(ERR_WARN, "networking not supported in Windows version"); +#else NetworkServer(options.server_port, options.serveronly); +#endif /* never reached */ exit(0); } + InitPlayerInfo(); + InitCounter(); InitSound(); InitSoundServer(); @@ -88,7 +97,7 @@ void OpenAll(int argc, char *argv[]) InitGfx(); InitElementProperties(); /* initializes IS_CHAR() for el2gfx() */ - InitLevelAndPlayerInfo(); + InitLevelInfo(); InitGadgets(); /* needs to know number of level series */ DrawMainMenu(); @@ -96,7 +105,7 @@ void OpenAll(int argc, char *argv[]) InitNetworkServer(); } -void InitLevelAndPlayerInfo() +void InitPlayerInfo() { int i; @@ -111,22 +120,26 @@ void InitLevelAndPlayerInfo() local_player->connected = TRUE; - LoadLevelInfo(); /* global level info */ LoadSetup(); /* global setup info */ +} + +void InitLevelInfo() +{ + LoadLevelInfo(); /* global level info */ LoadLevelSetup_LastSeries(); /* last played series info */ LoadLevelSetup_SeriesInfo(); /* last played level info */ } void InitNetworkServer() { -#ifndef MSDOS +#if !defined(MSDOS) && !defined(WIN32) int nr_wanted; #endif if (!options.network) return; -#ifndef MSDOS +#if !defined(MSDOS) && !defined(WIN32) nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED); if (!ConnectToServer(options.server_host, options.server_port)) @@ -152,14 +165,14 @@ void InitSound() if (SDL_Init(SDL_INIT_AUDIO) < 0) { - Error(ERR_WARN, "SDL_Init() failed: %s\n", SDL_GetError()); + Error(ERR_WARN, "SDL_Init() failed: %s", SDL_GetError()); sound_status = SOUND_OFF; return; } if (Mix_OpenAudio(22050, AUDIO_S16, 2, 256) < 0) { - Error(ERR_WARN, "Mix_OpenAudio() failed: %s\n", SDL_GetError()); + Error(ERR_WARN, "Mix_OpenAudio() failed: %s", SDL_GetError()); sound_status = SOUND_OFF; return; } @@ -172,7 +185,7 @@ void InitSound() #else /* !USE_SDL_LIBRARY */ -#ifndef MSDOS +#if !defined(MSDOS) && !defined(WIN32) if (access(sound_device_name, W_OK) != 0) { Error(ERR_WARN, "cannot access sound device - no sounds"); @@ -198,14 +211,14 @@ void InitSound() */ #endif -#else /* MSDOS */ +#else /* MSDOS || WIN32 */ sound_loops_allowed = TRUE; /* setup.sound_loops_on = TRUE; */ -#endif /* MSDOS */ +#endif /* MSDOS || WIN32 */ #endif /* !USE_SDL_LIBRARY */ for(i=0; iformat, 0x00, 0x00, 0x00)); if ((tile_masked[tile] = SDL_DisplayFormat(sdl_image_tmp)) == NULL) - Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError()); + Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError()); SDL_FreeSurface(sdl_image_tmp); @@ -906,17 +924,17 @@ void LoadGfx(int pos, struct PictureFileInfo *pic) #ifdef USE_SDL_LIBRARY /* load image to temporary surface */ if ((sdl_image_tmp = IMG_Load(filename)) == NULL) - Error(ERR_EXIT, "IMG_Load() failed: %s\n", SDL_GetError()); + Error(ERR_EXIT, "IMG_Load() failed: %s", SDL_GetError()); /* create native non-transparent surface for current image */ if ((pix[pos] = SDL_DisplayFormat(sdl_image_tmp)) == NULL) - Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError()); + Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError()); /* create native transparent surface for current image */ SDL_SetColorKey(sdl_image_tmp, SDL_SRCCOLORKEY, SDL_MapRGB(sdl_image_tmp->format, 0x00, 0x00, 0x00)); if ((pix_masked[pos] = SDL_DisplayFormat(sdl_image_tmp)) == NULL) - Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError()); + Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError()); /* free temporary surface */ SDL_FreeSurface(sdl_image_tmp); @@ -2193,12 +2211,17 @@ void CloseAllAndExit(int exit_value) { int i; +#ifdef USE_SDL_LIBRARY + StopSounds(); + FreeSounds(NUM_SOUNDS); +#else if (sound_process_id) { StopSounds(); kill(sound_process_id, SIGTERM); FreeSounds(NUM_SOUNDS); } +#endif for(i=0; i