瀏覽代碼

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 年之前
父節點
當前提交
2906365c97
共有 1 個文件被更改,包括 5 次插入6 次删除
  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(';');