Browse Source

Simplify the resource prefix path engine parameter handling.
Also ensure that relative prefix path is being resolved relative to the program dir regardless of where the prefix path parameter value is coming from.

Yao Wei Tjong 姚伟忠 11 years ago
parent
commit
2906365c97
1 changed files with 5 additions and 6 deletions
  1. 5 6
      Source/Urho3D/Engine/Engine.cpp

+ 5 - 6
Source/Urho3D/Engine/Engine.cpp

@@ -199,12 +199,11 @@ bool Engine::Initialize(const VariantMap& parameters)
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     FileSystem* fileSystem = GetSubsystem<FileSystem>();
 
-    String defaultPrefixPath(AddTrailingSlash(getenv("URHO3D_PREFIX_PATH")));
-    if (defaultPrefixPath.Empty())
-        defaultPrefixPath = fileSystem->GetProgramDir();
-    else if (!IsAbsolutePath(defaultPrefixPath))
-        defaultPrefixPath = fileSystem->GetProgramDir() + defaultPrefixPath;
-    String resourcePrefixPath = AddTrailingSlash(GetParameter(parameters, "ResourcePrefixPath", defaultPrefixPath).GetString());
+    String resourcePrefixPath = AddTrailingSlash(GetParameter(parameters, "ResourcePrefixPath", getenv("URHO3D_PREFIX_PATH")).GetString());
+    if (resourcePrefixPath.Empty())
+        resourcePrefixPath = fileSystem->GetProgramDir();
+    else if (!IsAbsolutePath(resourcePrefixPath))
+        resourcePrefixPath = fileSystem->GetProgramDir() + resourcePrefixPath;
     Vector<String> resourcePaths = GetParameter(parameters, "ResourcePaths", "Data;CoreData").GetString().Split(';');
     Vector<String> resourcePackages = GetParameter(parameters, "ResourcePackages").GetString().Split(';');
     Vector<String> autoLoadPaths = GetParameter(parameters, "AutoloadPaths", "Autoload").GetString().Split(';');