C++03 oldify in various source files
authorSmallJoker <mk939@ymail.com>
Fri, 18 May 2018 09:10:53 +0000 (11:10 +0200)
committerSmallJoker <mk939@ymail.com>
Sun, 3 Jun 2018 15:32:00 +0000 (17:32 +0200)
src/content_cao.cpp
src/localplayer.cpp
src/mapnode.cpp
src/server.cpp
src/serverenvironment.cpp
src/sound_openal.cpp

index 994ff5bb53c6fff0a81177cd9a0cb1d7062d20d5..7f1293ac341d9ce657f56e3f786fa60efc42c5d9 100644 (file)
@@ -837,8 +837,8 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr,
                        };
                        if (m_is_player) {
                                // Move minimal Y position to 0 (feet position)
-                               for (video::S3DVertex &vertex : vertices)
-                                       vertex.Pos.Y += dy;
+                               for (size_t i = 0; i < 4; i++)
+                                       vertices[i].Pos.Y += dy;
                        }
                        u16 indices[] = {0,1,2,2,3,0};
                        buf->append(vertices, 4, indices, 6);
@@ -861,8 +861,8 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr,
                        };
                        if (m_is_player) {
                                // Move minimal Y position to 0 (feet position)
-                               for (video::S3DVertex &vertex : vertices)
-                                       vertex.Pos.Y += dy;
+                               for (size_t i = 0; i < 4; i++)
+                                       vertices[i].Pos.Y += dy;
                        }
                        u16 indices[] = {0,1,2,2,3,0};
                        buf->append(vertices, 4, indices, 6);
index ea2da15da79b9c78dbf2558f38fcaa5ab150b903..05195c91fb3df9c2e6b5149c38093361f73b4b40 100644 (file)
@@ -362,20 +362,22 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
                // Force update each ClientEnvironment::step()
                bool is_first = collision_info->empty();
 
-               for (const auto &colinfo : result.collisions) {
-                       collision_info->push_back(colinfo);
+               for (std::vector<CollisionInfo>::const_iterator
+                               colinfo = result.collisions.begin();
+                               colinfo != result.collisions.end(); ++colinfo) {
+                       collision_info->push_back(*colinfo);
 
-                       if (colinfo.type != COLLISION_NODE ||
-                                       colinfo.new_speed.Y != 0 ||
+                       if (colinfo->type != COLLISION_NODE ||
+                                       colinfo->new_speed.Y != 0 ||
                                        (could_sneak && m_sneak_node_exists))
                                continue;
 
-                       diff = intToFloat(colinfo.node_p, BS) - position;
+                       diff = intToFloat(colinfo->node_p, BS) - position;
 
                        // Find nearest colliding node
                        f32 len = diff.getLength();
                        if (is_first || len < distance) {
-                               m_standing_node = colinfo.node_p;
+                               m_standing_node = colinfo->node_p;
                                distance = len;
                        }
                }
index ff5ad5557137fc04ab22eb44e08d82610e76b86a..aaea3831eb3f5ec9ed9753ebd80cfec30e69f4db 100644 (file)
@@ -249,7 +249,11 @@ void transformNodeBox(const MapNode &n, const NodeBox &nodebox,
                int facedir = n.getFaceDir(nodemgr);
                u8 axisdir = facedir>>2;
                facedir&=0x03;
-               for (aabb3f box : fixed) {
+               for (std::vector<aabb3f>::const_iterator
+                               i = fixed.begin();
+                               i != fixed.end(); ++i) {
+                       aabb3f box = *i;
+
                        if (nodebox.type == NODEBOX_LEVELED)
                                box.MaxEdge.Y = (-0.5f + n.getLevel(nodemgr) / 64.0f) * BS;
 
index 3630659959f5b09915ca6317adbd4eea1a41566e..71a349b08ec6bba06416edef2571acda52a36f96 100644 (file)
@@ -1660,8 +1660,10 @@ void Server::SendChatMessage(u16 peer_id, const std::wstring &message)
 
                Send(&pkt);
        } else {
-               for (u16 id : m_clients.getClientIDs())
-                       SendChatMessage(id, message);
+               std::vector<u16> clients = m_clients.getClientIDs();
+               for (std::vector<u16>::iterator it = clients.begin();
+                               it != clients.end(); ++it)
+                       SendChatMessage(*it, message);
        }
 }
 
index da4aaf006e8a61b1241cce8324652b00f7172d2f..8c3c3485426662025360dfecf506d16ee648ff50 100644 (file)
@@ -265,7 +265,7 @@ void LBMManager::applyLBMs(ServerEnvironment *env, MapBlock *block, u32 stamp)
        for (; it != m_lbm_lookup.end(); ++it) {
                // Cache previous version to speedup lookup which has a very high performance
                // penalty on each call
-               content_t previous_c{};
+               content_t previous_c = CONTENT_IGNORE;
                std::vector<LoadingBlockModifierDef *> *lbm_list = NULL;
 
                for (pos.X = 0; pos.X < MAP_BLOCKSIZE; pos.X++)
@@ -1026,9 +1026,10 @@ void ServerEnvironment::clearObjects(ClearObjectsMode mode)
        infostream << "ServerEnvironment::clearObjects(): "
                << "Removing all active objects" << std::endl;
        std::vector<u16> objects_to_remove;
-       for (auto &it : m_active_objects) {
-               u16 id = it.first;
-               ServerActiveObject* obj = it.second;
+       for (ActiveObjectMap::iterator it = m_active_objects.begin();
+                       it != m_active_objects.end(); ++it) {
+               u16 id = it->first;
+               ServerActiveObject* obj = it->second;
                if (obj->getType() == ACTIVEOBJECT_TYPE_PLAYER)
                        continue;
 
@@ -1054,8 +1055,9 @@ void ServerEnvironment::clearObjects(ClearObjectsMode mode)
        }
 
        // Remove references from m_active_objects
-       for (u16 i : objects_to_remove) {
-               m_active_objects.erase(i);
+       for (std::vector<u16>::iterator it = objects_to_remove.begin();
+                       it != objects_to_remove.end(); ++it) {
+               m_active_objects.erase(*it);
        }
 
        // Get list of loaded blocks
@@ -1822,8 +1824,9 @@ void ServerEnvironment::removeRemovedObjects()
                objects_to_remove.push_back(id);
        }
        // Remove references from m_active_objects
-       for (u16 i : objects_to_remove) {
-               m_active_objects.erase(i);
+       for (std::vector<u16>::iterator it = objects_to_remove.begin();
+                       it != objects_to_remove.end(); ++it) {
+               m_active_objects.erase(*it);
        }
 }
 
@@ -2093,8 +2096,9 @@ void ServerEnvironment::deactivateFarObjects(bool _force_delete)
        }
 
        // Remove references from m_active_objects
-       for (u16 i : objects_to_remove) {
-               m_active_objects.erase(i);
+       for (std::vector<u16>::iterator it = objects_to_remove.begin();
+                       it != objects_to_remove.end(); ++it) {
+               m_active_objects.erase(*it);
        }
 }
 
@@ -2128,7 +2132,7 @@ bool ServerEnvironment::saveStaticToBlock(
                ServerActiveObject *obj, const StaticObject &s_obj,
                u32 mod_reason)
 {
-       MapBlock *block = nullptr;
+       MapBlock *block = NULL;
        try {
                block = m_map->emergeBlock(blockpos);
        } catch (InvalidPositionException &e) {
index 1bad04b9cef64b5a506522671380388fc852bf22..e56de31788f492b9b1b14280175dec22267a2e0a 100644 (file)
@@ -408,7 +408,7 @@ public:
                alSource3f(sound->source_id, AL_POSITION, 0, 0, 0);
                alSource3f(sound->source_id, AL_VELOCITY, 0, 0, 0);
                alSourcei(sound->source_id, AL_LOOPING, loop ? AL_TRUE : AL_FALSE);
-               volume = std::fmax(0.0f, volume);
+               volume = MYMAX(0.0f, volume);
                alSourcef(sound->source_id, AL_GAIN, volume);
                alSourcePlay(sound->source_id);
                warn_if_error(alGetError(), "createPlayingSound");
@@ -436,7 +436,7 @@ public:
                alSourcei(sound->source_id, AL_LOOPING, loop ? AL_TRUE : AL_FALSE);
                // Multiply by 3 to compensate for reducing AL_REFERENCE_DISTANCE from
                // the previous value of 30 to the new value of 10
-               volume = std::fmax(0.0f, volume * 3.0f);
+               volume = MYMAX(0.0f, volume * 3.0f);
                alSourcef(sound->source_id, AL_GAIN, volume);
                alSourcePlay(sound->source_id);
                warn_if_error(alGetError(), "createPlayingSoundAt");