Skip to content

Commit 9dd0f95

Browse files
authoredAug 15, 2017
Modernize client code (#6250)
* Various code style fixes * Use range based for loops * Use empty instead of empty objects * Use C++11 default keyword for trivial constructors and destructors * Drop some useless casts * Use emplace_back instead of push_back to improve performance of some vectors push
1 parent 64c7a68 commit 9dd0f95

9 files changed

+104
-113
lines changed
 

Diff for: ‎src/client/clientlauncher.cpp

+13-14
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
132132
g_menuclouds->setHeight(100.0f);
133133
g_menuclouds->update(v3f(0, 0, 0), video::SColor(255, 200, 200, 255));
134134
scene::ICameraSceneNode* camera;
135-
camera = g_menucloudsmgr->addCameraSceneNode(0,
136-
v3f(0, 0, 0), v3f(0, 60, 100));
135+
camera = g_menucloudsmgr->addCameraSceneNode(NULL, v3f(0, 0, 0), v3f(0, 60, 100));
137136
camera->setFarValue(10000);
138137

139138
/*
@@ -192,13 +191,13 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
192191
if (!game_has_run) {
193192
if (skip_main_menu)
194193
break;
195-
else
196-
continue;
194+
195+
continue;
197196
}
198197

199198
// Break out of menu-game loop to shut down cleanly
200199
if (!RenderingEngine::get_raw_device()->run() || *kill) {
201-
if (g_settings_path != "")
200+
if (!g_settings_path.empty())
202201
g_settings->updateConfigFile(g_settings_path.c_str());
203202
break;
204203
}
@@ -285,7 +284,7 @@ void ClientLauncher::init_args(GameParams &game_params, const Settings &cmd_args
285284
* supplied on the command line
286285
*/
287286
address = g_settings->get("address");
288-
if (game_params.world_path != "" && !skip_main_menu)
287+
if (!game_params.world_path.empty() && !skip_main_menu)
289288
address = "";
290289
else if (cmd_args.exists("address"))
291290
address = cmd_args.get("address");
@@ -355,11 +354,11 @@ bool ClientLauncher::launch_game(std::string &error_message,
355354
menudata.password = cmd_args.get("password");
356355

357356
// If a world was commanded, append and select it
358-
if (game_params.world_path != "") {
357+
if (!game_params.world_path.empty()) {
359358
worldspec.gameid = getWorldGameId(game_params.world_path, true);
360359
worldspec.name = _("[--world parameter]");
361360

362-
if (worldspec.gameid == "") { // Create new
361+
if (worldspec.gameid.empty()) { // Create new
363362
worldspec.gameid = g_settings->get("default_game");
364363
worldspec.name += " [new]";
365364
}
@@ -400,7 +399,7 @@ bool ClientLauncher::launch_game(std::string &error_message,
400399
return false;
401400
}
402401

403-
if (menudata.name == "" && !simple_singleplayer_mode) {
402+
if (menudata.name.empty() && !simple_singleplayer_mode) {
404403
error_message = gettext("Please choose a name!");
405404
errorstream << error_message << std::endl;
406405
return false;
@@ -416,14 +415,14 @@ bool ClientLauncher::launch_game(std::string &error_message,
416415

417416
// If using simple singleplayer mode, override
418417
if (simple_singleplayer_mode) {
419-
assert(skip_main_menu == false);
418+
assert(!skip_main_menu);
420419
current_playername = "singleplayer";
421420
current_password = "";
422421
current_address = "";
423422
current_port = myrand_range(49152, 65535);
424423
} else {
425424
g_settings->set("name", playername);
426-
if (address != "") {
425+
if (!address.empty()) {
427426
ServerListSpec server;
428427
server["name"] = menudata.servername;
429428
server["address"] = menudata.address;
@@ -436,8 +435,8 @@ bool ClientLauncher::launch_game(std::string &error_message,
436435
infostream << "Selected world: " << worldspec.name
437436
<< " [" << worldspec.path << "]" << std::endl;
438437

439-
if (current_address == "") { // If local game
440-
if (worldspec.path == "") {
438+
if (current_address.empty()) { // If local game
439+
if (worldspec.path.empty()) {
441440
error_message = gettext("No world selected and no address "
442441
"provided. Nothing to do.");
443442
errorstream << error_message << std::endl;
@@ -488,7 +487,7 @@ void ClientLauncher::main_menu(MainMenuData *menudata)
488487
video::IVideoDriver *driver = RenderingEngine::get_video_driver();
489488

490489
infostream << "Waiting for other menus" << std::endl;
491-
while (RenderingEngine::get_raw_device()->run() && *kill == false) {
490+
while (RenderingEngine::get_raw_device()->run() && !*kill) {
492491
if (!isMenuActive())
493492
break;
494493
driver->beginScene(true, true, video::SColor(255, 128, 128, 128));

Diff for: ‎src/client/clientlauncher.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class RenderingEngine;
2929
class ClientLauncher
3030
{
3131
public:
32-
ClientLauncher() {}
32+
ClientLauncher() = default;
3333

3434
~ClientLauncher();
3535

Diff for: ‎src/client/inputhandler.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
102102
};
103103
assert(event.LogEvent.Level < ARRLEN(irr_loglev_conv));
104104
g_logger.log(irr_loglev_conv[event.LogEvent.Level],
105-
std::string("Irrlicht: ") +
106-
(const char *)event.LogEvent.Text);
105+
std::string("Irrlicht: ") + event.LogEvent.Text);
107106
return true;
108107
}
109108
/* always return false in order to continue processing events */

Diff for: ‎src/client/inputhandler.h

+8-5
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,9 @@ class MyEventReceiver : public IEventReceiver
180180
class InputHandler
181181
{
182182
public:
183-
InputHandler() {}
184-
virtual ~InputHandler() {}
183+
InputHandler() = default;
184+
185+
virtual ~InputHandler() = default;
185186

186187
virtual bool isKeyDown(const KeyPress &keyCode) = 0;
187188
virtual bool wasKeyDown(const KeyPress &keyCode) = 0;
@@ -243,9 +244,10 @@ class RealInputHandler : public InputHandler
243244
return RenderingEngine::get_raw_device()
244245
->getCursorControl()
245246
->getPosition();
246-
} else {
247-
return m_mousepos;
248247
}
248+
249+
return m_mousepos;
250+
249251
}
250252
virtual void setMousePos(s32 x, s32 y)
251253
{
@@ -287,7 +289,8 @@ class RealInputHandler : public InputHandler
287289
class RandomInputHandler : public InputHandler
288290
{
289291
public:
290-
RandomInputHandler() {}
292+
RandomInputHandler() = default;
293+
291294
virtual bool isKeyDown(const KeyPress &keyCode) { return keydown[keyCode]; }
292295
virtual bool wasKeyDown(const KeyPress &keyCode) { return false; }
293296
virtual v2s32 getMousePos() { return mousepos; }

Diff for: ‎src/client/joystick_controller.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ bool JoystickAxisCmb::isTriggered(const irr::SEvent::SJoystickEvent &ev) const
4141
}
4242

4343
// spares many characters
44-
#define JLO_B_PB(A, B, C) jlo.button_keys.push_back(JoystickButtonCmb(A, B, C))
45-
#define JLO_A_PB(A, B, C, D) jlo.axis_keys.push_back(JoystickAxisCmb(A, B, C, D))
44+
#define JLO_B_PB(A, B, C) jlo.button_keys.emplace_back(A, B, C)
45+
#define JLO_A_PB(A, B, C, D) jlo.axis_keys.emplace_back(A, B, C, D)
4646

4747
JoystickLayout create_default_layout()
4848
{
@@ -157,8 +157,8 @@ JoystickLayout create_xbox_layout()
157157
JoystickController::JoystickController() :
158158
doubling_dtime(g_settings->getFloat("repeat_joystick_button_time"))
159159
{
160-
for (size_t i = 0; i < KeyType::INTERNAL_ENUM_COUNT; i++) {
161-
m_past_pressed_time[i] = 0;
160+
for (float &i : m_past_pressed_time) {
161+
i = 0;
162162
}
163163
clear();
164164
}
@@ -203,15 +203,15 @@ bool JoystickController::handleEvent(const irr::SEvent::SJoystickEvent &ev)
203203

204204
// First generate a list of keys pressed
205205

206-
for (size_t i = 0; i < m_layout.button_keys.size(); i++) {
207-
if (m_layout.button_keys[i].isTriggered(ev)) {
208-
keys_pressed.set(m_layout.button_keys[i].key);
206+
for (const auto &button_key : m_layout.button_keys) {
207+
if (button_key.isTriggered(ev)) {
208+
keys_pressed.set(button_key.key);
209209
}
210210
}
211211

212-
for (size_t i = 0; i < m_layout.axis_keys.size(); i++) {
213-
if (m_layout.axis_keys[i].isTriggered(ev)) {
214-
keys_pressed.set(m_layout.axis_keys[i].key);
212+
for (const auto &axis_key : m_layout.axis_keys) {
213+
if (axis_key.isTriggered(ev)) {
214+
keys_pressed.set(axis_key.key);
215215
}
216216
}
217217

Diff for: ‎src/client/joystick_controller.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ struct JoystickCombination {
5252

5353
struct JoystickButtonCmb : public JoystickCombination {
5454

55-
JoystickButtonCmb() {}
55+
JoystickButtonCmb() = default;
56+
5657
JoystickButtonCmb(GameKeyType key, u32 filter_mask, u32 compare_mask) :
5758
filter_mask(filter_mask),
5859
compare_mask(compare_mask)
@@ -68,7 +69,8 @@ struct JoystickButtonCmb : public JoystickCombination {
6869

6970
struct JoystickAxisCmb : public JoystickCombination {
7071

71-
JoystickAxisCmb() {}
72+
JoystickAxisCmb() = default;
73+
7274
JoystickAxisCmb(GameKeyType key, u16 axis_to_compare, int direction, s16 thresh) :
7375
axis_to_compare(axis_to_compare),
7476
direction(direction),

Diff for: ‎src/client/renderingengine.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,7 @@ std::vector<core::vector3d<u32>> RenderingEngine::getSupportedVideoModes()
419419
for (s32 i = 0; i != num_modes; i++) {
420420
core::dimension2d<u32> mode_res = modelist->getVideoModeResolution(i);
421421
u32 mode_depth = (u32)modelist->getVideoModeDepth(i);
422-
mlist.push_back(core::vector3d<u32>(
423-
mode_res.Width, mode_res.Height, mode_depth));
422+
mlist.emplace_back(mode_res.Width, mode_res.Height, mode_depth);
424423
}
425424

426425
nulldevice->drop();

Diff for: ‎src/client/tile.cpp

+48-64
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2323
#include "util/string.h"
2424
#include "util/container.h"
2525
#include "util/thread.h"
26-
#include "util/numeric.h"
27-
#include "irrlichttypes_extrabloated.h"
28-
#include "debug.h"
2926
#include "filesys.h"
3027
#include "settings.h"
3128
#include "mesh.h"
32-
#include "log.h"
3329
#include "gamedef.h"
3430
#include "util/strfnd.h"
35-
#include "util/string.h" // for parseColorString()
3631
#include "imagefilters.h"
3732
#include "guiscalingfilter.h"
38-
#include "nodedef.h"
3933
#include "renderingengine.h"
4034

4135

@@ -96,13 +90,13 @@ std::string getImagePath(std::string path)
9690
NULL
9791
};
9892
// If there is no extension, add one
99-
if (removeStringEnd(path, extensions) == "")
93+
if (removeStringEnd(path, extensions).empty())
10094
path = path + ".png";
10195
// Check paths until something is found to exist
10296
const char **ext = extensions;
10397
do{
10498
bool r = replace_ext(path, *ext);
105-
if (r == false)
99+
if (!r)
106100
return "";
107101
if (fs::PathExists(path))
108102
return path;
@@ -124,7 +118,7 @@ std::string getImagePath(std::string path)
124118
*/
125119
std::string getTexturePath(const std::string &filename)
126120
{
127-
std::string fullpath = "";
121+
std::string fullpath;
128122
/*
129123
Check from cache
130124
*/
@@ -136,7 +130,7 @@ std::string getTexturePath(const std::string &filename)
136130
Check from texture_path
137131
*/
138132
const std::string &texture_path = g_settings->get("texture_path");
139-
if (texture_path != "") {
133+
if (!texture_path.empty()) {
140134
std::string testpath = texture_path + DIR_DELIM + filename;
141135
// Check all filename extensions. Returns "" if not found.
142136
fullpath = getImagePath(testpath);
@@ -145,7 +139,7 @@ std::string getTexturePath(const std::string &filename)
145139
/*
146140
Check from default data directory
147141
*/
148-
if (fullpath == "")
142+
if (fullpath.empty())
149143
{
150144
std::string base_path = porting::path_share + DIR_DELIM + "textures"
151145
+ DIR_DELIM + "base" + DIR_DELIM + "pack";
@@ -193,9 +187,8 @@ class SourceImageCache
193187
{
194188
public:
195189
~SourceImageCache() {
196-
for (std::map<std::string, video::IImage*>::iterator iter = m_images.begin();
197-
iter != m_images.end(); ++iter) {
198-
iter->second->drop();
190+
for (auto &m_image : m_images) {
191+
m_image.second->drop();
199192
}
200193
m_images.clear();
201194
}
@@ -216,7 +209,7 @@ class SourceImageCache
216209
// Try to use local texture instead if asked to
217210
if (prefer_local){
218211
std::string path = getTexturePath(name);
219-
if (path != ""){
212+
if (!path.empty()) {
220213
video::IImage *img2 = RenderingEngine::get_video_driver()->
221214
createImageFromFile(path.c_str());
222215
if (img2){
@@ -249,7 +242,7 @@ class SourceImageCache
249242
}
250243
video::IVideoDriver *driver = RenderingEngine::get_video_driver();
251244
std::string path = getTexturePath(name);
252-
if (path == ""){
245+
if (path.empty()) {
253246
infostream<<"SourceImageCache::getOrLoad(): No path found for \""
254247
<<name<<"\""<<std::endl;
255248
return NULL;
@@ -351,7 +344,7 @@ class TextureSource : public IWritableTextureSource
351344
if (cache_found)
352345
return is_known;
353346
// Not found in cache; find out if a local file exists
354-
is_known = (getTexturePath(name) != "");
347+
is_known = (!getTexturePath(name).empty());
355348
m_source_image_existence.set(name, is_known);
356349
return is_known;
357350
}
@@ -438,7 +431,7 @@ TextureSource::TextureSource()
438431
m_main_thread = std::this_thread::get_id();
439432

440433
// Add a NULL TextureInfo as the first index, named ""
441-
m_textureinfo_cache.push_back(TextureInfo(""));
434+
m_textureinfo_cache.emplace_back("");
442435
m_name_to_id[""] = 0;
443436

444437
// Cache some settings
@@ -455,21 +448,14 @@ TextureSource::~TextureSource()
455448

456449
unsigned int textures_before = driver->getTextureCount();
457450

458-
for (std::vector<TextureInfo>::iterator iter =
459-
m_textureinfo_cache.begin();
460-
iter != m_textureinfo_cache.end(); ++iter)
461-
{
451+
for (const auto &iter : m_textureinfo_cache) {
462452
//cleanup texture
463-
if (iter->texture)
464-
driver->removeTexture(iter->texture);
453+
if (iter.texture)
454+
driver->removeTexture(iter.texture);
465455
}
466456
m_textureinfo_cache.clear();
467457

468-
for (std::vector<video::ITexture*>::iterator iter =
469-
m_texture_trash.begin(); iter != m_texture_trash.end();
470-
++iter) {
471-
video::ITexture *t = *iter;
472-
458+
for (auto t : m_texture_trash) {
473459
//cleanup trashed texture
474460
driver->removeTexture(t);
475461
}
@@ -586,7 +572,7 @@ u32 TextureSource::generateTexture(const std::string &name)
586572
//infostream << "generateTexture(): name=\"" << name << "\"" << std::endl;
587573

588574
// Empty name means texture 0
589-
if (name == "") {
575+
if (name.empty()) {
590576
infostream<<"generateTexture(): name is empty"<<std::endl;
591577
return 0;
592578
}
@@ -690,7 +676,7 @@ Palette* TextureSource::getPalette(const std::string &name)
690676
if (name == "")
691677
return NULL;
692678

693-
std::unordered_map<std::string, Palette>::iterator it = m_palettes.find(name);
679+
auto it = m_palettes.find(name);
694680
if (it == m_palettes.end()) {
695681
// Create palette
696682
video::IImage *img = generateImage(name);
@@ -728,7 +714,7 @@ Palette* TextureSource::getPalette(const std::string &name)
728714
img->drop();
729715
// Fill in remaining elements
730716
while (new_palette.size() < 256)
731-
new_palette.push_back(video::SColor(0xFFFFFFFF));
717+
new_palette.emplace_back(0xFFFFFFFF);
732718
m_palettes[name] = new_palette;
733719
it = m_palettes.find(name);
734720
}
@@ -775,22 +761,21 @@ void TextureSource::rebuildImagesAndTextures()
775761
sanity_check(driver);
776762

777763
// Recreate textures
778-
for (u32 i=0; i<m_textureinfo_cache.size(); i++){
779-
TextureInfo *ti = &m_textureinfo_cache[i];
780-
video::IImage *img = generateImage(ti->name);
764+
for (TextureInfo &ti : m_textureinfo_cache) {
765+
video::IImage *img = generateImage(ti.name);
781766
#ifdef __ANDROID__
782767
img = Align2Npot2(img, driver);
783768
#endif
784769
// Create texture from resulting image
785770
video::ITexture *t = NULL;
786771
if (img) {
787-
t = driver->addTexture(ti->name.c_str(), img);
788-
guiScalingCache(io::path(ti->name.c_str()), driver, img);
772+
t = driver->addTexture(ti.name.c_str(), img);
773+
guiScalingCache(io::path(ti.name.c_str()), driver, img);
789774
img->drop();
790775
}
791-
video::ITexture *t_old = ti->texture;
776+
video::ITexture *t_old = ti.texture;
792777
// Replace texture
793-
ti->texture = t;
778+
ti.texture = t;
794779

795780
if (t_old)
796781
m_texture_trash.push_back(t_old);
@@ -1185,14 +1170,13 @@ bool TextureSource::generateImagePart(std::string part_of_name,
11851170
sanity_check(driver);
11861171

11871172
// Stuff starting with [ are special commands
1188-
if (part_of_name.size() == 0 || part_of_name[0] != '[')
1189-
{
1173+
if (part_of_name.empty() || part_of_name[0] != '[') {
11901174
video::IImage *image = m_sourcecache.getOrLoad(part_of_name);
11911175
#ifdef __ANDROID__
11921176
image = Align2Npot2(image, driver);
11931177
#endif
11941178
if (image == NULL) {
1195-
if (part_of_name != "") {
1179+
if (!part_of_name.empty()) {
11961180

11971181
// Do not create normalmap dummies
11981182
if (part_of_name.find("_normal.png") != std::string::npos) {
@@ -1343,7 +1327,7 @@ bool TextureSource::generateImagePart(std::string part_of_name,
13431327
baseimg = driver->createImage(video::ECF_A8R8G8B8, dim);
13441328
baseimg->fill(video::SColor(0,0,0,0));
13451329
}
1346-
while (sf.at_end() == false) {
1330+
while (!sf.at_end()) {
13471331
u32 x = stoi(sf.next(","));
13481332
u32 y = stoi(sf.next("="));
13491333
std::string filename = unescape_string(sf.next_esc(":", escape), escape);
@@ -1896,13 +1880,13 @@ bool TextureSource::generateImagePart(std::string part_of_name,
18961880

18971881
std::string mode = sf.next("");
18981882
u32 mask = 0;
1899-
if (mode.find("a") != std::string::npos)
1883+
if (mode.find('a') != std::string::npos)
19001884
mask |= 0xff000000UL;
1901-
if (mode.find("r") != std::string::npos)
1885+
if (mode.find('r') != std::string::npos)
19021886
mask |= 0x00ff0000UL;
1903-
if (mode.find("g") != std::string::npos)
1887+
if (mode.find('g') != std::string::npos)
19041888
mask |= 0x0000ff00UL;
1905-
if (mode.find("b") != std::string::npos)
1889+
if (mode.find('b') != std::string::npos)
19061890
mask |= 0x000000ffUL;
19071891

19081892
core::dimension2d<u32> dim = baseimg->getDimension();
@@ -2240,9 +2224,8 @@ u32 parseImageTransform(const std::string& s)
22402224
pos++;
22412225
break;
22422226
}
2243-
else if (!(name_i.empty()) &&
2244-
lowercase(s.substr(pos, name_i.size())) == name_i)
2245-
{
2227+
2228+
if (!(name_i.empty()) && lowercase(s.substr(pos, name_i.size())) == name_i) {
22462229
transform = i;
22472230
pos += name_i.size();
22482231
break;
@@ -2269,8 +2252,8 @@ core::dimension2d<u32> imageTransformDimension(u32 transform, core::dimension2d<
22692252
{
22702253
if (transform % 2 == 0)
22712254
return dim;
2272-
else
2273-
return core::dimension2d<u32>(dim.Height, dim.Width);
2255+
2256+
return core::dimension2d<u32>(dim.Height, dim.Width);
22742257
}
22752258

22762259
void imageTransform(u32 transform, video::IImage *src, video::IImage *dst)
@@ -2325,12 +2308,12 @@ video::ITexture* TextureSource::getNormalTexture(const std::string &name)
23252308
std::string fname_base = name;
23262309
static const char *normal_ext = "_normal.png";
23272310
static const u32 normal_ext_size = strlen(normal_ext);
2328-
size_t pos = fname_base.find(".");
2311+
size_t pos = fname_base.find('.');
23292312
std::string fname_normal = fname_base.substr(0, pos) + normal_ext;
23302313
if (isKnownSourceImage(fname_normal)) {
23312314
// look for image extension and replace it
23322315
size_t i = 0;
2333-
while ((i = fname_base.find(".", i)) != std::string::npos) {
2316+
while ((i = fname_base.find('.', i)) != std::string::npos) {
23342317
fname_base.replace(i, 4, normal_ext);
23352318
i += normal_ext_size;
23362319
}
@@ -2384,15 +2367,16 @@ video::ITexture *TextureSource::getShaderFlagsTexture(bool normalmap_present)
23842367

23852368
if (isKnownSourceImage(tname)) {
23862369
return getTexture(tname);
2387-
} else {
2388-
video::IVideoDriver *driver = RenderingEngine::get_video_driver();
2389-
video::IImage *flags_image = driver->createImage(
2390-
video::ECF_A8R8G8B8, core::dimension2d<u32>(1, 1));
2391-
sanity_check(flags_image != NULL);
2392-
video::SColor c(255, normalmap_present ? 255 : 0, 0, 0);
2393-
flags_image->setPixel(0, 0, c);
2394-
insertSourceImage(tname, flags_image);
2395-
flags_image->drop();
2396-
return getTexture(tname);
23972370
}
2371+
2372+
video::IVideoDriver *driver = RenderingEngine::get_video_driver();
2373+
video::IImage *flags_image = driver->createImage(
2374+
video::ECF_A8R8G8B8, core::dimension2d<u32>(1, 1));
2375+
sanity_check(flags_image != NULL);
2376+
video::SColor c(255, normalmap_present ? 255 : 0, 0, 0);
2377+
flags_image->setPixel(0, 0, c);
2378+
insertSourceImage(tname, flags_image);
2379+
flags_image->drop();
2380+
return getTexture(tname);
2381+
23982382
}

Diff for: ‎src/client/tile.h

+18-13
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,21 @@ struct TextureFromMeshParams
9090
class ISimpleTextureSource
9191
{
9292
public:
93-
ISimpleTextureSource(){}
94-
virtual ~ISimpleTextureSource(){}
93+
ISimpleTextureSource() = default;
94+
95+
virtual ~ISimpleTextureSource() = default;
96+
9597
virtual video::ITexture* getTexture(
9698
const std::string &name, u32 *id = nullptr) = 0;
9799
};
98100

99101
class ITextureSource : public ISimpleTextureSource
100102
{
101103
public:
102-
ITextureSource(){}
103-
virtual ~ITextureSource(){}
104+
ITextureSource() = default;
105+
106+
virtual ~ITextureSource() = default;
107+
104108
virtual u32 getTextureId(const std::string &name)=0;
105109
virtual std::string getTextureName(u32 id)=0;
106110
virtual video::ITexture* getTexture(u32 id)=0;
@@ -126,8 +130,10 @@ class ITextureSource : public ISimpleTextureSource
126130
class IWritableTextureSource : public ITextureSource
127131
{
128132
public:
129-
IWritableTextureSource(){}
130-
virtual ~IWritableTextureSource(){}
133+
IWritableTextureSource() = default;
134+
135+
virtual ~IWritableTextureSource() = default;
136+
131137
virtual u32 getTextureId(const std::string &name)=0;
132138
virtual std::string getTextureName(u32 id)=0;
133139
virtual video::ITexture* getTexture(u32 id)=0;
@@ -170,7 +176,7 @@ enum MaterialType{
170176
// Ignored if MATERIAL_FLAG_CRACK is not set.
171177
#define MATERIAL_FLAG_CRACK_OVERLAY 0x04
172178
#define MATERIAL_FLAG_ANIMATION 0x08
173-
#define MATERIAL_FLAG_HIGHLIGHTED 0x10
179+
//#define MATERIAL_FLAG_HIGHLIGHTED 0x10
174180
#define MATERIAL_FLAG_TILEABLE_HORIZONTAL 0x20
175181
#define MATERIAL_FLAG_TILEABLE_VERTICAL 0x40
176182

@@ -180,7 +186,8 @@ enum MaterialType{
180186
*/
181187
struct FrameSpec
182188
{
183-
FrameSpec() {}
189+
FrameSpec() = default;
190+
184191
u32 texture_id = 0;
185192
video::ITexture *texture = nullptr;
186193
video::ITexture *normal_texture = nullptr;
@@ -192,7 +199,7 @@ struct FrameSpec
192199
//! Defines a layer of a tile.
193200
struct TileLayer
194201
{
195-
TileLayer() {}
202+
TileLayer() = default;
196203

197204
/*!
198205
* Two layers are equal if they can be merged.
@@ -232,8 +239,7 @@ struct TileLayer
232239
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
233240
break;
234241
}
235-
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING)
236-
? true : false;
242+
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) != 0;
237243
if (!(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL)) {
238244
material.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
239245
}
@@ -244,8 +250,7 @@ struct TileLayer
244250

245251
void applyMaterialOptionsWithShaders(video::SMaterial &material) const
246252
{
247-
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING)
248-
? true : false;
253+
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) != 0;
249254
if (!(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL)) {
250255
material.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
251256
material.TextureLayer[1].TextureWrapU = video::ETC_CLAMP_TO_EDGE;

0 commit comments

Comments
 (0)
Please sign in to comment.