diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-11-26 13:32:23 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-11-29 19:13:53 +0200 |
commit | 8bd178c2e59ca793b86594c70f657b769d645c8d (patch) | |
tree | fd97cb77d09677a4c33c4e9bbdf0f6750859fd34 /src | |
parent | b58dc083a98ee6c7668c8ec598034dc8a8a34db9 (diff) | |
download | minetest-8bd178c2e59ca793b86594c70f657b769d645c8d.tar.gz minetest-8bd178c2e59ca793b86594c70f657b769d645c8d.tar.bz2 minetest-8bd178c2e59ca793b86594c70f657b769d645c8d.zip |
If available, use local textures instead of those sent by server
Diffstat (limited to 'src')
-rw-r--r-- | src/tile.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/tile.cpp b/src/tile.cpp index f18086f41..f7d577b1f 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -183,18 +183,28 @@ class SourceImageCache { public: void insert(const std::string &name, video::IImage *img, - bool do_overwrite) + bool prefer_local, video::IVideoDriver *driver) { assert(img); + // Remove old image core::map<std::string, video::IImage*>::Node *n; n = m_images.find(name); if(n){ - if(!do_overwrite) - return; video::IImage *oldimg = n->getValue(); if(oldimg) oldimg->drop(); } + // Try to use local texture instead if asked to + if(prefer_local){ + std::string path = getTexturePath(name.c_str()); + if(path != ""){ + video::IImage *img2 = driver->createImageFromFile(path.c_str()); + if(img2){ + m_images[name] = img2; + return; + } + } + } img->grab(); m_images[name] = img; } @@ -725,7 +735,7 @@ void TextureSource::insertSourceImage(const std::string &name, video::IImage *im assert(get_current_thread_id() == m_main_thread); - m_sourcecache.insert(name, img, false); + m_sourcecache.insert(name, img, true, m_device->getVideoDriver()); } void TextureSource::rebuildImagesAndTextures() |