Skip to content

Commit 88b436e

Browse files
authoredAug 19, 2017
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
1 parent 7528986 commit 88b436e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+396
-516
lines changed
 

‎src/client/tile.cpp

+19-27
Original file line numberDiff line numberDiff line change
@@ -484,43 +484,35 @@ u32 TextureSource::getTextureId(const std::string &name)
484484
/*
485485
Get texture
486486
*/
487-
if (std::this_thread::get_id() == m_main_thread)
488-
{
487+
if (std::this_thread::get_id() == m_main_thread) {
489488
return generateTexture(name);
490489
}
491-
else
492-
{
493-
infostream<<"getTextureId(): Queued: name=\""<<name<<"\""<<std::endl;
494490

495-
// We're gonna ask the result to be put into here
496-
static ResultQueue<std::string, u32, u8, u8> result_queue;
497491

498-
// Throw a request in
499-
m_get_texture_queue.add(name, 0, 0, &result_queue);
492+
infostream<<"getTextureId(): Queued: name=\""<<name<<"\""<<std::endl;
500493

501-
/*infostream<<"Waiting for texture from main thread, name=\""
502-
<<name<<"\""<<std::endl;*/
494+
// We're gonna ask the result to be put into here
495+
static ResultQueue<std::string, u32, u8, u8> result_queue;
503496

504-
try
505-
{
506-
while(true) {
507-
// Wait result for a second
508-
GetResult<std::string, u32, u8, u8>
509-
result = result_queue.pop_front(1000);
497+
// Throw a request in
498+
m_get_texture_queue.add(name, 0, 0, &result_queue);
510499

511-
if (result.key == name) {
512-
return result.item;
513-
}
500+
try {
501+
while(true) {
502+
// Wait result for a second
503+
GetResult<std::string, u32, u8, u8>
504+
result = result_queue.pop_front(1000);
505+
506+
if (result.key == name) {
507+
return result.item;
514508
}
515509
}
516-
catch(ItemNotFoundException &e)
517-
{
518-
errorstream<<"Waiting for texture " << name << " timed out."<<std::endl;
519-
return 0;
520-
}
510+
} catch(ItemNotFoundException &e) {
511+
errorstream << "Waiting for texture " << name << " timed out." << std::endl;
512+
return 0;
521513
}
522514

523-
infostream<<"getTextureId(): Failed"<<std::endl;
515+
infostream << "getTextureId(): Failed" << std::endl;
524516

525517
return 0;
526518
}
@@ -673,7 +665,7 @@ Palette* TextureSource::getPalette(const std::string &name)
673665
// Only the main thread may load images
674666
sanity_check(std::this_thread::get_id() == m_main_thread);
675667

676-
if (name == "")
668+
if (name.empty())
677669
return NULL;
678670

679671
auto it = m_palettes.find(name);

‎src/client/tile.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ struct TileLayer
237237
case TILE_MATERIAL_LIQUID_TRANSPARENT:
238238
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
239239
break;
240+
default:
241+
break;
240242
}
241243
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) != 0;
242244
if (!(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL)) {
@@ -304,8 +306,8 @@ struct TileLayer
304306
struct TileSpec
305307
{
306308
TileSpec() {
307-
for (int layer = 0; layer < MAX_TILE_LAYERS; layer++)
308-
layers[layer] = TileLayer();
309+
for (auto &layer : layers)
310+
layer = TileLayer();
309311
}
Has a conversation. Original line has a conversation.
310312

311313
/*!

0 commit comments

Comments
 (0)
Please sign in to comment.