X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=488b4338c53a819df4c536e528a204ea2b5414f6;hb=82b1f76754f039e4ee151c7da7c49819c7310546;hp=88050961f227a372b6fcfdd17d5fc1d509e901a4;hpb=57562a0f29074feea1dc01ddf1b1d5e4e6d59730;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index 88050961..488b4338 100644 --- a/src/init.c +++ b/src/init.c @@ -23,6 +23,7 @@ #include "gfxload.h" #include "gifload.h" #include "network.h" +#include "netserv.h" #ifdef DEBUG /* @@ -33,7 +34,7 @@ struct PictureFileInfo { char *picture_filename; - BOOL picture_with_mask; + boolean picture_with_mask; }; struct IconFileInfo @@ -44,11 +45,11 @@ struct IconFileInfo static int sound_process_id = 0; -static void InitServer(void); static void InitLevelAndPlayerInfo(void); +static void InitNetworkServer(void); static void InitDisplay(void); static void InitSound(void); -static void InitSoundProcess(void); +static void InitSoundServer(void); static void InitWindow(int, char **); static void InitGfx(void); static void LoadGfx(int, struct PictureFileInfo *); @@ -56,12 +57,19 @@ static void InitElementProperties(void); void OpenAll(int argc, char *argv[]) { + if (options.serveronly) + { + NetworkServer(options.server_port, options.serveronly); + + /* never reached */ + exit(0); + } + InitLevelAndPlayerInfo(); - InitServer(); InitCounter(); InitSound(); - InitSoundProcess(); + InitSoundServer(); InitJoystick(); InitRND(NEW_RANDOMIZE); @@ -78,69 +86,89 @@ void OpenAll(int argc, char *argv[]) InitElementProperties(); DrawMainMenu(); + + InitNetworkServer(); } 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 InitServer() +void InitNetworkServer() { - standalone = FALSE; - networking = !standalone; + int nr_wanted; - if (standalone) + if (!options.network) return; - if (!ConnectToServer(server_host, server_port)) + nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED); + + if (!ConnectToServer(options.server_host, options.server_port)) Error(ERR_EXIT, "cannot connect to multiplayer server"); SendToServer_Nickname(local_player->alias_name); SendToServer_ProtocolVersion(); + + if (nr_wanted) + SendToServer_NrWanted(nr_wanted); } void InitSound() { int i; - if (sound_status==SOUND_OFF) + if (sound_status == SOUND_OFF) return; #ifndef MSDOS 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) + 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; } close(sound_device); - sound_status=SOUND_AVAILABLE; + sound_status = SOUND_AVAILABLE; #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;i