Index: /orxonox/branches/bensch/orxonox_gui_file.c
===================================================================
--- /orxonox/branches/bensch/orxonox_gui_file.c	(revision 1830)
+++ /orxonox/branches/bensch/orxonox_gui_file.c	(revision 1831)
@@ -36,22 +36,30 @@
 
   IOFILE = fopen( local_config_file, "w");
-  if (verbose >= 1)
-    printf ("Saving settings to %s\n", local_config_file);
-  
-  fprintf (IOFILE, "%s\n", "Configuration file of orxonox (do not edit if ou do not know what you are doing)");
-  fprintf (IOFILE, "orxonox_settings->video_fullscreen = %i\n", orxonox_settings->video_fullscreen);
-  fprintf (IOFILE, "orxonox_settings->video_wireframe = %i\n", orxonox_settings->video_wireframe);
-
-  fprintf (IOFILE, "orxonox_settings->audio_enable_sound = %i\n", orxonox_settings->audio_enable_sound);
-  fprintf (IOFILE, "orxonox_settings->audio_music_volume = %i\n", orxonox_settings->audio_music_volume);
-  fprintf (IOFILE, "orxonox_settings->audio_effects_volume = %i\n", orxonox_settings->audio_effects_volume);
-
-  fprintf (IOFILE, "orxonox_settings->exec_save_settings = %i\n", orxonox_settings->exec_save_settings);
-  fprintf (IOFILE, "orxonox_settings->exec_show_menu = %i\n", orxonox_settings->exec_show_menu);
-
-  fprintf (IOFILE, "orxonox_settings->verbose = %i\n", verbose);
-  
-  fclose( IOFILE );
-  return;
+  if (IOFILE)
+    {
+      if (verbose >= 1)
+	printf ("Saving settings to '%s'\n", local_config_file);
+      
+      fprintf (IOFILE, "%s\n", "Configuration file of orxonox (do not edit if ou do not know what you are doing)");
+      fprintf (IOFILE, "orxonox_settings->video_fullscreen = %i\n", orxonox_settings->video_fullscreen);
+      fprintf (IOFILE, "orxonox_settings->video_wireframe = %i\n", orxonox_settings->video_wireframe);
+      
+      fprintf (IOFILE, "orxonox_settings->audio_enable_sound = %i\n", orxonox_settings->audio_enable_sound);
+      fprintf (IOFILE, "orxonox_settings->audio_music_volume = %i\n", orxonox_settings->audio_music_volume);
+      fprintf (IOFILE, "orxonox_settings->audio_effects_volume = %i\n", orxonox_settings->audio_effects_volume);
+      
+      fprintf (IOFILE, "orxonox_settings->exec_save_settings = %i\n", orxonox_settings->exec_save_settings);
+      fprintf (IOFILE, "orxonox_settings->exec_show_menu = %i\n", orxonox_settings->exec_show_menu);
+      
+      fprintf (IOFILE, "orxonox_settings->verbose = %i\n", verbose);
+      
+      fclose( IOFILE );
+      return;
+    }
+  else
+    {
+      if (verbose >= 1)
+	printf ("Settingsfile '%s' does not exist.\n", local_config_file);
+    }
 }
 
@@ -75,49 +83,57 @@
 
   IOFILE = fopen(local_config_file, "r");
-  if (verbose >= 1)
-    printf ("Loading settings from '%s'\n", local_config_file);
-  
-  fscanf (IOFILE, "Configuration file of orxonox (do not edit if ou do not know what you are doing)");
-  while (fscanf (IOFILE,"%s %s %s", variable, equals, value) != EOF)
+  if (IOFILE)
     {
-      if ( !strcmp (variable, "orxonox_settings->video_fullscreen"))
+      if (verbose >= 1)
+	printf ("Loading settings from '%s'\n", local_config_file);
+      
+      fscanf (IOFILE, "Configuration file of orxonox (do not edit if ou do not know what you are doing)");
+      while (fscanf (IOFILE,"%s %s %s", variable, equals, value) != EOF)
 	{
-	  orxonox_settings->video_fullscreen = atoi (value);
+	  if ( !strcmp (variable, "orxonox_settings->video_fullscreen"))
+	    {
+	      orxonox_settings->video_fullscreen = atoi (value);
+	    }
+	  else if ( !strcmp (variable, "orxonox_settings->video_wireframe"))
+	    {
+	      orxonox_settings->video_wireframe = atoi (value);
+	    }
+	  
+	  else if ( !strcmp (variable, "orxonox_settings->audio_enable_sound"))
+	    {
+	      orxonox_settings->audio_enable_sound = atoi (value);
+	    }
+	  else if ( !strcmp (variable, "orxonox_settings->audio_music_volume"))
+	    {
+	      orxonox_settings->audio_music_volume = atoi (value);
+	    }
+	  else if ( !strcmp (variable, "orxonox_settings->audio_effects_volume"))
+	    {
+	      orxonox_settings->audio_effects_volume = atoi (value);
+	    }
+	  
+	  else if ( !strcmp (variable, "orxonox_settings->exec_save_settings"))
+	    {
+	      orxonox_settings->exec_save_settings = atoi (value);
+	    }
+	  else if ( !strcmp (variable, "orxonox_settings->exec_show_menu"))
+	    {
+	      orxonox_settings->exec_show_menu = atoi (value);
+	    }
+	  
+	  else if ( !strcmp (variable, "orxonox_settings->verbose"))
+	    {
+	      verbose = atoi (value);
+	    }
+	  
 	}
-      else if ( !strcmp (variable, "orxonox_settings->video_wireframe"))
-	{
-	  orxonox_settings->video_wireframe = atoi (value);
-	}
+      fclose( IOFILE );      
+      return;
+    }
 
-      else if ( !strcmp (variable, "orxonox_settings->audio_enable_sound"))
-	{
-	  orxonox_settings->audio_enable_sound = atoi (value);
-	}
-      else if ( !strcmp (variable, "orxonox_settings->audio_music_volume"))
-	{
-	  orxonox_settings->audio_music_volume = atoi (value);
-	}
-      else if ( !strcmp (variable, "orxonox_settings->audio_effects_volume"))
-	{
-	  orxonox_settings->audio_effects_volume = atoi (value);
-	}
-
-      else if ( !strcmp (variable, "orxonox_settings->exec_save_settings"))
-	{
-	  orxonox_settings->exec_save_settings = atoi (value);
-	}
-      else if ( !strcmp (variable, "orxonox_settings->exec_show_menu"))
-	{
-	  orxonox_settings->exec_show_menu = atoi (value);
-	}
-
-      else if ( !strcmp (variable, "orxonox_settings->verbose"))
-	{
-	  verbose = atoi (value);
-	}
-
+  else
+    {
+      if (verbose >= 1)
+	printf ("File '%s' does not exist. Can not load orxonox-states.\n", local_config_file);
     }
-  fclose( IOFILE );      
-  return;
 }
-
