Skip to content

Commit 61e9c1b

Browse files
authoredSep 29, 2019
Textures: Load base pack only as last fallback (#8974)
1 parent c2458d3 commit 61e9c1b

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed
 

Diff for: ‎src/client/tile.cpp

+13-4
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,14 @@ std::string getImagePath(std::string path)
122122
123123
Utilizes a thread-safe cache.
124124
*/
125-
std::string getTexturePath(const std::string &filename)
125+
std::string getTexturePath(const std::string &filename, bool *is_base_pack)
126126
{
127127
std::string fullpath;
128+
129+
// This can set a wrong value on cached textures, but is irrelevant because
130+
// is_base_pack is only passed when initializing the textures the first time
131+
if (is_base_pack)
132+
*is_base_pack = false;
128133
/*
129134
Check from cache
130135
*/
@@ -154,6 +159,8 @@ std::string getTexturePath(const std::string &filename)
154159
std::string testpath = base_path + DIR_DELIM + filename;
155160
// Check all filename extensions. Returns "" if not found.
156161
fullpath = getImagePath(testpath);
162+
if (is_base_pack && !fullpath.empty())
163+
*is_base_pack = true;
157164
}
158165

159166
// Add to cache (also an empty result is cached)
@@ -215,9 +222,11 @@ class SourceImageCache
215222
bool need_to_grab = true;
216223

217224
// Try to use local texture instead if asked to
218-
if (prefer_local){
219-
std::string path = getTexturePath(name);
220-
if (!path.empty()) {
225+
if (prefer_local) {
226+
bool is_base_pack;
227+
std::string path = getTexturePath(name, &is_base_pack);
228+
// Ignore base pack
229+
if (!path.empty() && !is_base_pack) {
221230
video::IImage *img2 = RenderingEngine::get_video_driver()->
222231
createImageFromFile(path.c_str());
223232
if (img2){

Diff for: ‎src/client/tile.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ std::string getImagePath(std::string path);
6464
6565
Utilizes a thread-safe cache.
6666
*/
67-
std::string getTexturePath(const std::string &filename);
67+
std::string getTexturePath(const std::string &filename, bool *is_base_pack = nullptr);
6868

6969
void clearTextureNameCache();
7070

0 commit comments

Comments
 (0)
Please sign in to comment.