rnd-19981026-2
[rocksndiamonds.git] / src / init.c
index 6931936ee00a902d1aa55ba437dfa8dba5d5fa95..488b4338c53a819df4c536e528a204ea2b5414f6 100644 (file)
@@ -34,7 +34,7 @@
 struct PictureFileInfo
 {
   char *picture_filename;
-  BOOL picture_with_mask;
+  boolean picture_with_mask;
 };
 
 struct IconFileInfo
@@ -57,9 +57,9 @@ static void InitElementProperties(void);
 
 void OpenAll(int argc, char *argv[])
 {
-  if (serveronly)
+  if (options.serveronly)
   {
-    NetworkServer(server_port, serveronly);
+    NetworkServer(options.server_port, options.serveronly);
 
     /* never reached */
     exit(0);
@@ -92,25 +92,31 @@ void OpenAll(int argc, char *argv[])
 
 void InitLevelAndPlayerInfo()
 {
+  int i;
+
+  /* choose default local player */
   local_player = &stored_player[0];
+  for (i=0; i<MAX_PLAYERS; i++)
+    stored_player[i].connected = FALSE;
+  local_player->connected = 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 (!network)
+  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);
@@ -130,14 +136,14 @@ void InitSound()
 #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)
   {
-    Error(ERR_RETURN, "cannot open sound device - no sounds");
+    Error(ERR_WARN, "cannot open sound device - no sounds");
     sound_status = SOUND_OFF;
     return;
   }
@@ -147,11 +153,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; i<NUM_SOUNDS; i++)
@@ -176,14 +190,14 @@ void InitSoundServer()
 #ifndef MSDOS
   if (pipe(sound_pipe)<0)
   {
-    Error(ERR_RETURN, "cannot create pipe - no sounds");
+    Error(ERR_WARN, "cannot create pipe - no sounds");
     sound_status = SOUND_OFF;
     return;
   }
 
   if ((sound_process_id = fork()) < 0)
   {       
-    Error(ERR_RETURN, "cannot create sound server process - no sounds");
+    Error(ERR_WARN, "cannot create sound server process - no sounds");
     sound_status = SOUND_OFF;
     return;
   }
@@ -204,21 +218,24 @@ void InitSoundServer()
 
 void InitJoystick()
 {
+  int joystick_nr = setup.input[0].joystick_nr;
+
   if (global_joystick_status == JOYSTICK_OFF)
     return;
 
 #ifndef MSDOS
-  if (access(joystick_device_name[joystick_nr],R_OK)<0)
+  if (access(joystick_device_name[joystick_nr], R_OK) < 0)
   {
-    Error(ERR_RETURN, "cannot access joystick device '%s'",
+    Error(ERR_WARN, "cannot access joystick device '%s'",
          joystick_device_name[joystick_nr]);
     joystick_status = JOYSTICK_OFF;
     return;
   }
 
-  if ((joystick_device = open(joystick_device_name[joystick_nr],O_RDONLY))<0)
+  if ((joystick_device =
+       open(joystick_device_name[joystick_nr], O_RDONLY)) < 0)
   {
-    Error(ERR_RETURN, "cannot open joystick device '%s'",
+    Error(ERR_WARN, "cannot open joystick device '%s'",
          joystick_device_name[joystick_nr]);
     joystick_status = JOYSTICK_OFF;
     return;
@@ -238,8 +255,9 @@ void InitDisplay()
   unsigned int depth;
 
   /* connect to X server */
-  if (!(display = XOpenDisplay(display_name)))
-    Error(ERR_EXIT,"cannot connect to X server %s",XDisplayName(display_name));
+  if (!(display = XOpenDisplay(options.display_name)))
+    Error(ERR_EXIT, "cannot connect to X server %s",
+         XDisplayName(options.display_name));
 
   screen = DefaultScreen(display);
   visual = DefaultVisual(display, screen);