X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Finit.c;h=37c0a1fefc624d78356d5d39a6a53a7cfb9ff34e;hp=ecafc3b848cc3932394cf38ebf9184248b621782;hb=40a487dcc5d3028343ff9123a72b8b3839a42861;hpb=1cacebfb41c20889c904155001a5b88ace962348 diff --git a/src/init.c b/src/init.c index ecafc3b8..37c0a1fe 100644 --- a/src/init.c +++ b/src/init.c @@ -20,20 +20,20 @@ #include "tools.h" #include "files.h" #include "joystick.h" -#include "gfxload.h" -#include "gifload.h" +#include "image.h" #include "network.h" +#include "netserv.h" #ifdef DEBUG -/* + #define DEBUG_TIMING -*/ + #endif struct PictureFileInfo { char *picture_filename; - BOOL picture_with_mask; + boolean picture_with_mask; }; struct IconFileInfo @@ -56,12 +56,20 @@ static void InitElementProperties(void); void OpenAll(int argc, char *argv[]) { + if (options.serveronly) + { + NetworkServer(options.server_port, options.serveronly); + + /* never reached */ + exit(0); + } + InitLevelAndPlayerInfo(); InitCounter(); InitSound(); InitSoundServer(); - InitJoystick(); + InitJoysticks(); InitRND(NEW_RANDOMIZE); signal(SIGINT, CloseAllAndExit); @@ -83,28 +91,39 @@ void OpenAll(int argc, char *argv[]) void InitLevelAndPlayerInfo() { + int i; + + /* choose default local player */ local_player = &stored_player[0]; + for (i=0; iconnected = TRUE; + if (!LoadLevelInfo()) /* global level info */ Error(ERR_EXIT, NULL); - LoadPlayerInfo(PLAYER_SETUP); /* global setup info */ - LoadPlayerInfo(PLAYER_LEVEL); /* level specific info */ + LoadSetup(); /* global setup info */ + LoadLevelSetup(); /* info about last played level */ } void InitNetworkServer() { int nr_wanted; - if (standalone) + if (!options.network) return; nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED); - if (!ConnectToServer(server_host, server_port)) + if (!ConnectToServer(options.server_host, options.server_port)) Error(ERR_EXIT, "cannot connect to multiplayer server"); - SendToServer_Nickname(local_player->alias_name); + SendToServer_Nickname(setup.alias_name); SendToServer_ProtocolVersion(); if (nr_wanted) @@ -119,16 +138,16 @@ void InitSound() return; #ifndef MSDOS - if (access(sound_device_name,W_OK)<0) + if (access(sound_device_name, W_OK) != 0) { - Error(ERR_RETURN, "cannot access sound device - no sounds"); + Error(ERR_WARN, "cannot access sound device - no sounds"); sound_status = SOUND_OFF; return; } if ((sound_device = open(sound_device_name,O_WRONLY))<0) { - Error(ERR_RETURN, "cannot open sound device - no sounds"); + Error(ERR_WARN, "cannot open sound device - no sounds"); sound_status = SOUND_OFF; return; } @@ -138,11 +157,19 @@ void InitSound() #ifdef VOXWARE sound_loops_allowed = TRUE; - sound_loops_on = TRUE; + + /* + setup.sound_loops_on = TRUE; + */ + #endif #else sound_loops_allowed = TRUE; - sound_loops_on = TRUE; + + /* + setup.sound_loops_on = TRUE; + */ + #endif for(i=0; ipicture_filename) { - sprintf(basefilename,"%s%s",pic->picture_filename,picture_ext); - DrawInitText(basefilename,150,FC_YELLOW); - sprintf(filename,"%s/%s",GFX_PATH,basefilename); + sprintf(basefilename, "%s%s", pic->picture_filename, picture_ext); + DrawInitText(basefilename, 150, FC_YELLOW); + sprintf(filename, "%s/%s/%s", + options.base_directory, GRAPHICS_DIRECTORY, basefilename); #ifdef MSDOS rest(100); @@ -646,30 +693,30 @@ void LoadGfx(int pos, struct PictureFileInfo *pic) #else - gif_err = Read_GIF_to_Pixmaps(display, window, filename, + pcx_err = Read_PCX_to_Pixmaps(display, window, gc, filename, &pix[pos], &clipmask[pos]); - switch(gif_err) + switch(pcx_err) { - case GIF_Success: + case PCX_Success: break; - case GIF_OpenFailed: - Error(ERR_EXIT, "cannot open GIF file '%s'", filename); - case GIF_ReadFailed: - Error(ERR_EXIT, "cannot read GIF file '%s'", filename); - case GIF_FileInvalid: - Error(ERR_EXIT, "invalid GIF file '%s'", filename); - case GIF_NoMemory: - Error(ERR_EXIT, "not enough memory for GIF file '%s'", filename); - case GIF_ColorFailed: - Error(ERR_EXIT, "cannot get colors for GIF file '%s'", filename); + case PCX_OpenFailed: + Error(ERR_EXIT, "cannot open PCX file '%s'", filename); + case PCX_ReadFailed: + Error(ERR_EXIT, "cannot read PCX file '%s'", filename); + case PCX_FileInvalid: + Error(ERR_EXIT, "invalid PCX file '%s'", filename); + case PCX_NoMemory: + Error(ERR_EXIT, "not enough memory for PCX file '%s'", filename); + case PCX_ColorFailed: + Error(ERR_EXIT, "cannot get colors for PCX file '%s'", filename); default: break; } #ifdef DEBUG_TIMING count2 = Counter(); - printf("GIF LOADING %s IN %.2f SECONDS\n", + printf("PCX LOADING %s IN %.2f SECONDS\n", filename,(float)(count2-count1)/1000.0); #endif @@ -685,9 +732,10 @@ void LoadGfx(int pos, struct PictureFileInfo *pic) #ifdef XPM_INCLUDE_FILE - sprintf(basefilename,"%s%s",pic->picture_filename,picturemask_ext); - DrawInitText(basefilename,150,FC_YELLOW); - sprintf(filename,"%s/%s",GFX_PATH,basefilename); + sprintf(basefilename, "%s%s", pic->picture_filename, picturemask_ext); + DrawInitText(basefilename, 150, FC_YELLOW); + sprintf(filename, "%s/%s/%s", + options.base_directory, GRAPHICS_DIRECTORY, basefilename); #ifdef DEBUG_TIMING count1 = Counter();