Skip to content

Commit

Permalink
rebuildSearchPath: Only load terrain overrides once
Browse files Browse the repository at this point in the history
And output the containing path
  • Loading branch information
past-due authored and pull[bot] committed Nov 17, 2023
1 parent 1866ea7 commit 10685d9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/init.cpp
Expand Up @@ -690,13 +690,17 @@ bool rebuildSearchPath(searchPathMode mode, bool force, const char *current_map,
// Add plain dir
WZ_PHYSFS_MountSearchPathWrapper(curSearchPath->path.c_str(), NULL, PHYSFS_APPEND);

if (terrainQualityOverrideBasePath.has_value())
if (terrainQualityOverrideBasePath.has_value() && !loadedTerrainTextureOverrides)
{
// Add terrain quality override files
tmpstr = curSearchPath->path + terrainQualityOverrideBasePath.value();
loadedTerrainTextureOverrides = WZ_PHYSFS_MountSearchPathWrapper(tmpstr.c_str(), NULL, PHYSFS_APPEND) || loadedTerrainTextureOverrides;
tmpstr += ".wz";
loadedTerrainTextureOverrides = WZ_PHYSFS_MountSearchPathWrapper(tmpstr.c_str(), NULL, PHYSFS_APPEND) || loadedTerrainTextureOverrides;
if (loadedTerrainTextureOverrides)
{
debug(LOG_INFO, "Loaded terrain overrides from: %s", curSearchPath->path.c_str());
}
}

// Add base files
Expand Down Expand Up @@ -775,13 +779,17 @@ bool rebuildSearchPath(searchPathMode mode, bool force, const char *current_map,
// Add plain dir
WZ_PHYSFS_MountSearchPathWrapper(curSearchPath->path.c_str(), NULL, PHYSFS_APPEND);

if (terrainQualityOverrideBasePath.has_value())
if (terrainQualityOverrideBasePath.has_value() && !loadedTerrainTextureOverrides)
{
// Add terrain quality override files
tmpstr = curSearchPath->path + terrainQualityOverrideBasePath.value();
loadedTerrainTextureOverrides = WZ_PHYSFS_MountSearchPathWrapper(tmpstr.c_str(), NULL, PHYSFS_APPEND) || loadedTerrainTextureOverrides;
tmpstr += ".wz";
loadedTerrainTextureOverrides = WZ_PHYSFS_MountSearchPathWrapper(tmpstr.c_str(), NULL, PHYSFS_APPEND) || loadedTerrainTextureOverrides;
if (loadedTerrainTextureOverrides)
{
debug(LOG_INFO, "Loaded terrain overrides from: %s", curSearchPath->path.c_str());
}
}

// Add base files
Expand Down

0 comments on commit 10685d9

Please sign in to comment.