diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-08-19 22:23:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-19 22:23:47 +0200 |
commit | 88b436e6a9c98af7215bd115e1b7a3f1a1db99d3 (patch) | |
tree | f07cdd7f93ca26b84192d7b89f7b952e603ba5cf /src/client | |
parent | 7528986e4449febead9b18b6118f0b096f7cf800 (diff) | |
download | minetest-88b436e6a9c98af7215bd115e1b7a3f1a1db99d3.tar.gz minetest-88b436e6a9c98af7215bd115e1b7a3f1a1db99d3.tar.bz2 minetest-88b436e6a9c98af7215bd115e1b7a3f1a1db99d3.zip |
Code modernization: subfolders (#6283)
* Code modernization: subfolders
Modernize various code on subfolders client, network, script, threading, unittests, util
* empty function
* default constructor/destructor
* for range-based loops
* use emplace_back instead of push_back
* C++ STL header style
* Make connection.cpp readable in a pointed place + typo
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/tile.cpp | 46 | ||||
-rw-r--r-- | src/client/tile.h | 6 |
2 files changed, 23 insertions, 29 deletions
diff --git a/src/client/tile.cpp b/src/client/tile.cpp index 150e621d9..a2284eed3 100644 --- a/src/client/tile.cpp +++ b/src/client/tile.cpp @@ -484,43 +484,35 @@ u32 TextureSource::getTextureId(const std::string &name) /* Get texture */ - if (std::this_thread::get_id() == m_main_thread) - { + if (std::this_thread::get_id() == m_main_thread) { return generateTexture(name); } - else - { - infostream<<"getTextureId(): Queued: name=\""<<name<<"\""<<std::endl; - // We're gonna ask the result to be put into here - static ResultQueue<std::string, u32, u8, u8> result_queue; - // Throw a request in - m_get_texture_queue.add(name, 0, 0, &result_queue); + infostream<<"getTextureId(): Queued: name=\""<<name<<"\""<<std::endl; - /*infostream<<"Waiting for texture from main thread, name=\"" - <<name<<"\""<<std::endl;*/ + // We're gonna ask the result to be put into here + static ResultQueue<std::string, u32, u8, u8> result_queue; - try - { - while(true) { - // Wait result for a second - GetResult<std::string, u32, u8, u8> - result = result_queue.pop_front(1000); + // Throw a request in + m_get_texture_queue.add(name, 0, 0, &result_queue); - if (result.key == name) { - return result.item; - } + try { + while(true) { + // Wait result for a second + GetResult<std::string, u32, u8, u8> + result = result_queue.pop_front(1000); + + if (result.key == name) { + return result.item; } } - catch(ItemNotFoundException &e) - { - errorstream<<"Waiting for texture " << name << " timed out."<<std::endl; - return 0; - } + } catch(ItemNotFoundException &e) { + errorstream << "Waiting for texture " << name << " timed out." << std::endl; + return 0; } - infostream<<"getTextureId(): Failed"<<std::endl; + infostream << "getTextureId(): Failed" << std::endl; return 0; } @@ -673,7 +665,7 @@ Palette* TextureSource::getPalette(const std::string &name) // Only the main thread may load images sanity_check(std::this_thread::get_id() == m_main_thread); - if (name == "") + if (name.empty()) return NULL; auto it = m_palettes.find(name); diff --git a/src/client/tile.h b/src/client/tile.h index 8a8c5bd47..d4e25ea6a 100644 --- a/src/client/tile.h +++ b/src/client/tile.h @@ -237,6 +237,8 @@ struct TileLayer case TILE_MATERIAL_LIQUID_TRANSPARENT: material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; break; + default: + break; } material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) != 0; if (!(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL)) { @@ -304,8 +306,8 @@ struct TileLayer struct TileSpec { TileSpec() { - for (int layer = 0; layer < MAX_TILE_LAYERS; layer++) - layers[layer] = TileLayer(); + for (auto &layer : layers) + layer = TileLayer(); } /*! |