summaryrefslogtreecommitdiff
path: root/src/client/tile.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-08-19 22:23:47 +0200
committerGitHub <noreply@github.com>2017-08-19 22:23:47 +0200
commit88b436e6a9c98af7215bd115e1b7a3f1a1db99d3 (patch)
treef07cdd7f93ca26b84192d7b89f7b952e603ba5cf /src/client/tile.cpp
parent7528986e4449febead9b18b6118f0b096f7cf800 (diff)
downloadminetest-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/tile.cpp')
-rw-r--r--src/client/tile.cpp46
1 files changed, 19 insertions, 27 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);