Pārlūkot izejas kodu

Making Game::loadConfig() check to see if "game.config" exists before trying to load it.

Adam Blake 13 gadi atpakaļ
vecāks
revīzija
9fa26a5cc2
1 mainītis faili ar 10 papildinājumiem un 2 dzēšanām
  1. 10 2
      gameplay/src/Game.cpp

+ 10 - 2
gameplay/src/Game.cpp

@@ -325,9 +325,17 @@ void Game::loadConfig()
     if (_properties == NULL)
     if (_properties == NULL)
     {
     {
         // Try to load custom config from file.
         // Try to load custom config from file.
-        _properties = Properties::create("game.config");
-        if (_properties == NULL)
+        // Check if file exists.
+        FILE* file = FileSystem::openFile("game.config", "rb");
+        if (file)
+        {
+            fclose(file);
+            _properties = Properties::create("game.config");
+        }
+        else
+        {
             _properties = new Properties();
             _properties = new Properties();
+        }
 
 
         // Load filesystem aliases
         // Load filesystem aliases
         Properties* aliases = _properties->getNamespace("aliases", true);
         Properties* aliases = _properties->getNamespace("aliases", true);