@@ -119,7 +119,7 @@ class TestCAO : public ClientActiveObject
119
119
{
120
120
public:
121
121
TestCAO (Client *client, ClientEnvironment *env);
122
- virtual ~TestCAO ();
122
+ virtual ~TestCAO () = default ;
123
123
124
124
ActiveObjectType getType () const
125
125
{
@@ -155,10 +155,6 @@ TestCAO::TestCAO(Client *client, ClientEnvironment *env):
155
155
ClientActiveObject::registerType (getType (), create);
156
156
}
157
157
158
- TestCAO::~TestCAO ()
159
- {
160
- }
161
-
162
158
ClientActiveObject* TestCAO::create (Client *client, ClientEnvironment *env)
163
159
{
164
160
return new TestCAO (client, env);
@@ -261,7 +257,7 @@ class ItemCAO : public ClientActiveObject
261
257
{
262
258
public:
263
259
ItemCAO (Client *client, ClientEnvironment *env);
264
- virtual ~ItemCAO ();
260
+ virtual ~ItemCAO () = default ;
265
261
266
262
ActiveObjectType getType () const
267
263
{
@@ -323,10 +319,6 @@ ItemCAO::ItemCAO(Client *client, ClientEnvironment *env):
323
319
}
324
320
}
325
321
326
- ItemCAO::~ItemCAO ()
327
- {
328
- }
329
-
330
322
ClientActiveObject* ItemCAO::create (Client *client, ClientEnvironment *env)
331
323
{
332
324
return new ItemCAO (client, env);
@@ -563,7 +555,7 @@ void GenericCAO::initialize(const std::string &data)
563
555
player->setCAO (this );
564
556
}
565
557
if (m_client->getProtoVersion () < 33 )
566
- m_env->addPlayerName (m_name. c_str () );
558
+ m_env->addPlayerName (m_name);
567
559
}
568
560
}
569
561
@@ -607,7 +599,7 @@ void GenericCAO::processInitData(const std::string &data)
607
599
GenericCAO::~GenericCAO ()
608
600
{
609
601
if (m_is_player && m_client->getProtoVersion () < 33 ) {
610
- m_env->removePlayerName (m_name. c_str () );
602
+ m_env->removePlayerName (m_name);
611
603
}
612
604
removeFromScene (true );
613
605
}
@@ -628,8 +620,8 @@ v3f GenericCAO::getPosition()
628
620
scene::ISceneNode *node = getSceneNode ();
629
621
if (node)
630
622
return node->getAbsolutePosition ();
631
- else
632
- return m_position;
623
+
624
+ return m_position;
633
625
}
634
626
return pos_translator.vect_show ;
635
627
}
@@ -638,11 +630,17 @@ scene::ISceneNode* GenericCAO::getSceneNode()
638
630
{
639
631
if (m_meshnode) {
640
632
return m_meshnode;
641
- } else if (m_animated_meshnode) {
633
+ }
634
+
635
+ if (m_animated_meshnode) {
642
636
return m_animated_meshnode;
643
- } else if (m_wield_meshnode) {
637
+ }
638
+
639
+ if (m_wield_meshnode) {
644
640
return m_wield_meshnode;
645
- } else if (m_spritenode) {
641
+ }
642
+
643
+ if (m_spritenode) {
646
644
return m_spritenode;
647
645
}
648
646
return NULL ;
@@ -655,8 +653,8 @@ scene::IAnimatedMeshSceneNode* GenericCAO::getAnimatedMeshSceneNode()
655
653
656
654
void GenericCAO::setChildrenVisible (bool toset)
657
655
{
658
- for (std::vector< u16>::size_type i = 0 ; i < m_children. size (); i++ ) {
659
- GenericCAO *obj = m_env->getGenericCAO (m_children[i] );
656
+ for (u16 cao_id : m_children) {
657
+ GenericCAO *obj = m_env->getGenericCAO (cao_id );
660
658
if (obj) {
661
659
obj->setVisible (toset);
662
660
}
@@ -686,8 +684,7 @@ void GenericCAO::removeFromScene(bool permanent)
686
684
// Should be true when removing the object permanently and false when refreshing (eg: updating visuals)
687
685
if ((m_env != NULL ) && (permanent))
688
686
{
689
- for (std::vector<u16>::size_type i = 0 ; i < m_children.size (); i++) {
690
- u16 ci = m_children[i];
687
+ for (u16 ci : m_children) {
691
688
if (m_env->attachement_parent_ids [ci] == getId ()) {
692
689
m_env->attachement_parent_ids [ci] = 0 ;
693
690
}
@@ -858,14 +855,13 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
858
855
}
859
856
else
860
857
errorstream<<" GenericCAO::addToScene(): Could not load mesh " <<m_prop.mesh <<std::endl;
861
- }
862
- else if (m_prop.visual == " wielditem" ) {
858
+ } else if (m_prop.visual == " wielditem" ) {
863
859
ItemStack item;
864
860
infostream << " GenericCAO::addToScene(): wielditem" << std::endl;
865
- if (m_prop.wield_item == " " ) {
861
+ if (m_prop.wield_item . empty () ) {
866
862
// Old format, only textures are specified.
867
863
infostream << " textures: " << m_prop.textures .size () << std::endl;
868
- if (m_prop.textures .size () >= 1 ) {
864
+ if (! m_prop.textures .empty () ) {
869
865
infostream << " textures[0]: " << m_prop.textures [0 ]
870
866
<< std::endl;
871
867
IItemDefManager *idef = m_client->idef ();
@@ -894,7 +890,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
894
890
updateTextures (m_current_texture_modifier);
895
891
896
892
scene::ISceneNode *node = getSceneNode ();
897
- if (node && m_prop.nametag != " " && !m_is_local_player) {
893
+ if (node && ! m_prop.nametag . empty () && !m_is_local_player) {
898
894
// Add nametag
899
895
v3f pos;
900
896
pos.Y = m_prop.collisionbox .MaxEdge .Y + 0 .3f ;
@@ -919,8 +915,8 @@ void GenericCAO::updateLight(u8 light_at_pos)
919
915
updateLightNoCheck (light_at_pos);
920
916
921
917
// Update light of all children
922
- for (std::vector< u16>::size_type i = 0 ; i < m_children. size (); i++ ) {
923
- ClientActiveObject *obj = m_env->getActiveObject (m_children[i] );
918
+ for (u16 i : m_children) {
919
+ ClientActiveObject *obj = m_env->getActiveObject (i );
924
920
if (obj) {
925
921
obj->updateLightNoCheck (light_at_pos);
926
922
}
@@ -1046,9 +1042,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
1046
1042
1047
1043
// Attachments, part 1: All attached objects must be unparented first,
1048
1044
// or Irrlicht causes a segmentation fault
1049
- for (std::vector<u16>::iterator ci = m_children.begin ();
1050
- ci != m_children.end ();)
1051
- {
1045
+ for (auto ci = m_children.begin (); ci != m_children.end ();) {
1052
1046
if (m_env->attachement_parent_ids [*ci] != getId ()) {
1053
1047
ci = m_children.erase (ci);
1054
1048
continue ;
@@ -1066,9 +1060,9 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
1066
1060
addToScene (m_client->tsrc ());
1067
1061
1068
1062
// Attachments, part 2: Now that the parent has been refreshed, put its attachments back
1069
- for (std::vector< u16>::size_type i = 0 ; i < m_children. size (); i++ ) {
1063
+ for (u16 cao_id : m_children) {
1070
1064
// Get the object of the child
1071
- ClientActiveObject *obj = m_env->getActiveObject (m_children[i] );
1065
+ ClientActiveObject *obj = m_env->getActiveObject (cao_id );
1072
1066
if (obj)
1073
1067
obj->setAttachments ();
1074
1068
}
@@ -1248,12 +1242,10 @@ void GenericCAO::updateTextures(std::string mod)
1248
1242
m_previous_texture_modifier = m_current_texture_modifier;
1249
1243
m_current_texture_modifier = mod;
1250
1244
1251
- if (m_spritenode)
1252
- {
1253
- if (m_prop.visual == " sprite" )
1254
- {
1245
+ if (m_spritenode) {
1246
+ if (m_prop.visual == " sprite" ) {
1255
1247
std::string texturestring = " unknown_node.png" ;
1256
- if ( m_prop.textures .size () >= 1 )
1248
+ if (! m_prop.textures .empty () )
1257
1249
texturestring = m_prop.textures [0 ];
1258
1250
texturestring += mod;
1259
1251
m_spritenode->setMaterialTexture (0 ,
@@ -1262,8 +1254,7 @@ void GenericCAO::updateTextures(std::string mod)
1262
1254
// This allows setting per-material colors. However, until a real lighting
1263
1255
// system is added, the code below will have no effect. Once MineTest
1264
1256
// has directional lighting, it should work automatically.
1265
- if (m_prop.colors .size () >= 1 )
1266
- {
1257
+ if (!m_prop.colors .empty ()) {
1267
1258
m_spritenode->getMaterial (0 ).AmbientColor = m_prop.colors [0 ];
1268
1259
m_spritenode->getMaterial (0 ).DiffuseColor = m_prop.colors [0 ];
1269
1260
m_spritenode->getMaterial (0 ).SpecularColor = m_prop.colors [0 ];
@@ -1274,20 +1265,17 @@ void GenericCAO::updateTextures(std::string mod)
1274
1265
m_spritenode->getMaterial (0 ).setFlag (video::EMF_ANISOTROPIC_FILTER, use_anisotropic_filter);
1275
1266
}
1276
1267
}
1277
- if (m_animated_meshnode)
1278
- {
1279
- if (m_prop.visual == " mesh" )
1280
- {
1268
+
1269
+ if (m_animated_meshnode) {
1270
+ if (m_prop.visual == " mesh" ) {
1281
1271
for (u32 i = 0 ; i < m_prop.textures .size () &&
1282
- i < m_animated_meshnode->getMaterialCount (); ++i)
1283
- {
1272
+ i < m_animated_meshnode->getMaterialCount (); ++i) {
1284
1273
std::string texturestring = m_prop.textures [i];
1285
- if (texturestring == " " )
1274
+ if (texturestring. empty () )
1286
1275
continue ; // Empty texture string means don't modify that material
1287
1276
texturestring += mod;
1288
1277
video::ITexture* texture = tsrc->getTextureForMesh (texturestring);
1289
- if (!texture)
1290
- {
1278
+ if (!texture) {
1291
1279
errorstream<<" GenericCAO::updateTextures(): Could not load texture " <<texturestring<<std::endl;
1292
1280
continue ;
1293
1281
}
@@ -1351,13 +1339,11 @@ void GenericCAO::updateTextures(std::string mod)
1351
1339
m_meshnode->getMaterial (i).setFlag (video::EMF_BILINEAR_FILTER, use_bilinear_filter);
1352
1340
m_meshnode->getMaterial (i).setFlag (video::EMF_ANISOTROPIC_FILTER, use_anisotropic_filter);
1353
1341
}
1354
- }
1355
- else if (m_prop.visual == " upright_sprite" )
1356
- {
1342
+ } else if (m_prop.visual == " upright_sprite" ) {
1357
1343
scene::IMesh *mesh = m_meshnode->getMesh ();
1358
1344
{
1359
1345
std::string tname = " unknown_object.png" ;
1360
- if ( m_prop.textures .size () >= 1 )
1346
+ if (! m_prop.textures .empty () )
1361
1347
tname = m_prop.textures [0 ];
1362
1348
tname += mod;
1363
1349
scene::IMeshBuffer *buf = mesh->getMeshBuffer (0 );
@@ -1367,8 +1353,7 @@ void GenericCAO::updateTextures(std::string mod)
1367
1353
// This allows setting per-material colors. However, until a real lighting
1368
1354
// system is added, the code below will have no effect. Once MineTest
1369
1355
// has directional lighting, it should work automatically.
1370
- if (m_prop.colors .size () >= 1 )
1371
- {
1356
+ if (!m_prop.colors .empty ()) {
1372
1357
buf->getMaterial ().AmbientColor = m_prop.colors [0 ];
1373
1358
buf->getMaterial ().DiffuseColor = m_prop.colors [0 ];
1374
1359
buf->getMaterial ().SpecularColor = m_prop.colors [0 ];
@@ -1380,9 +1365,9 @@ void GenericCAO::updateTextures(std::string mod)
1380
1365
}
1381
1366
{
1382
1367
std::string tname = " unknown_object.png" ;
1383
- if (m_prop.textures .size () >= 2 )
1368
+ if (m_prop.textures .size () >= 2 )
1384
1369
tname = m_prop.textures [1 ];
1385
- else if ( m_prop.textures .size () >= 1 )
1370
+ else if (! m_prop.textures .empty () )
1386
1371
tname = m_prop.textures [0 ];
1387
1372
tname += mod;
1388
1373
scene::IMeshBuffer *buf = mesh->getMeshBuffer (1 );
@@ -1392,14 +1377,11 @@ void GenericCAO::updateTextures(std::string mod)
1392
1377
// This allows setting per-material colors. However, until a real lighting
1393
1378
// system is added, the code below will have no effect. Once MineTest
1394
1379
// has directional lighting, it should work automatically.
1395
- if (m_prop.colors .size () >= 2 )
1396
- {
1380
+ if (m_prop.colors .size () >= 2 ) {
1397
1381
buf->getMaterial ().AmbientColor = m_prop.colors [1 ];
1398
1382
buf->getMaterial ().DiffuseColor = m_prop.colors [1 ];
1399
1383
buf->getMaterial ().SpecularColor = m_prop.colors [1 ];
1400
- }
1401
- else if (m_prop.colors .size () >= 1 )
1402
- {
1384
+ } else if (!m_prop.colors .empty ()) {
1403
1385
buf->getMaterial ().AmbientColor = m_prop.colors [0 ];
1404
1386
buf->getMaterial ().DiffuseColor = m_prop.colors [0 ];
1405
1387
buf->getMaterial ().SpecularColor = m_prop.colors [0 ];
@@ -1476,7 +1458,7 @@ void GenericCAO::updateAttachments()
1476
1458
scene::ISceneNode *parent_node = getParent ()->getSceneNode ();
1477
1459
scene::IAnimatedMeshSceneNode *parent_animated_mesh_node =
1478
1460
getParent ()->getAnimatedMeshSceneNode ();
1479
- if (parent_animated_mesh_node && m_attachment_bone != " " ) {
1461
+ if (parent_animated_mesh_node && !m_attachment_bone. empty () ) {
1480
1462
parent_node = parent_animated_mesh_node->getJointNode (m_attachment_bone.c_str ());
1481
1463
}
1482
1464
@@ -1519,7 +1501,7 @@ void GenericCAO::processMessage(const std::string &data)
1519
1501
player->setCollisionbox (m_selection_box);
1520
1502
}
1521
1503
1522
- if ((m_is_player && !m_is_local_player) && m_prop.nametag == " " )
1504
+ if ((m_is_player && !m_is_local_player) && m_prop.nametag . empty () )
1523
1505
m_prop.nametag = m_name;
1524
1506
1525
1507
expireVisuals ();
0 commit comments