]> git.lizzy.rs Git - minetest.git/commitdiff
More C++03 fixes
authorLoic Blot <loic.blot@unix-experience.fr>
Mon, 14 May 2018 05:42:20 +0000 (07:42 +0200)
committerSmallJoker <mk939@ymail.com>
Sun, 3 Jun 2018 15:32:00 +0000 (17:32 +0200)
12 files changed:
src/client/clientlauncher.h
src/client/joystick_controller.h
src/clientmap.cpp
src/itemstackmetadata.cpp
src/reflowscan.cpp
src/remoteplayer.cpp
src/remoteplayer.h
src/script/cpp_api/s_item.h
src/script/lua_api/l_env.cpp
src/script/lua_api/l_object.cpp
src/serverenvironment.cpp
src/serverobject.h

index 3d82b9cdca2f3c5715a653e6a9783fe978937797..4ff77bc03e650c6b9670549458a6bcd5f2927a3c 100644 (file)
@@ -81,7 +81,7 @@ class ClientLauncher
        scene::ISceneManager *smgr;
        SubgameSpec gamespec;
        WorldSpec worldspec;
-       bool simple_singleplayer_mode = false;
+       bool simple_singleplayer_mode;
 
        // These are set up based on the menu and other things
        // TODO: Are these required since there's already playername, password, etc
index ea1db684a9362485130a47649c5684ead08ec486..7443150115dc7a4fe620d20a4691165cd5435bca 100644 (file)
@@ -79,6 +79,8 @@ struct JoystickAxisCmb : public JoystickCombination {
                this->key = key;
        }
 
+       virtual ~JoystickAxisCmb() {}
+
        virtual bool isTriggered(const irr::SEvent::SJoystickEvent &ev) const;
 
        u16 axis_to_compare;
index d00443c62165360c1864278a40ea573eadbd92f2..21937ac81dea90495e0fd75df9801097b7b85ec8 100644 (file)
@@ -314,14 +314,15 @@ struct MeshBufListList
                // Append to the correct layer
                std::vector<MeshBufList> &list = lists[layer];
                const video::SMaterial &m = buf->getMaterial();
-               for (MeshBufList &l : list) {
+               for (std::vector<MeshBufList>::iterator it = list.begin(); it != list.end();
+                       ++it) {
                        // comparing a full material is quite expensive so we don't do it if
                        // not even first texture is equal
-                       if (l.m.TextureLayer[0].Texture != m.TextureLayer[0].Texture)
+                       if ((*it).m.TextureLayer[0].Texture != m.TextureLayer[0].Texture)
                                continue;
 
-                       if (l.m == m) {
-                               l.bufs.push_back(buf);
+                       if ((*it).m == m) {
+                               (*it).bufs.push_back(buf);
                                return;
                        }
                }
@@ -356,7 +357,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
                Measuring time is very useful for long delays when the
                machine is swapping a lot.
        */
-       std::time_t time1 = time(0);
+       time_t time1 = time(0);
 
        /*
                Get animation parameters
@@ -477,11 +478,12 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
                std::vector<MeshBufList> &lists = drawbufs.lists[layer];
 
                int timecheck_counter = 0;
-               for (MeshBufList &list : lists) {
+               for (std::vector<MeshBufList>::iterator it = lists.begin(); it != lists.end();
+                       ++it) {
                        timecheck_counter++;
                        if (timecheck_counter > 50) {
                                timecheck_counter = 0;
-                               std::time_t time2 = time(0);
+                               time_t time2 = time(0);
                                if (time2 > time1 + 4) {
                                        infostream << "ClientMap::renderMap(): "
                                                "Rendering takes ages, returning."
@@ -490,11 +492,12 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
                                }
                        }
 
-                       driver->setMaterial(list.m);
+                       driver->setMaterial((*it).m);
 
-                       for (scene::IMeshBuffer *buf : list.bufs) {
-                               driver->drawMeshBuffer(buf);
-                               vertex_count += buf->getVertexCount();
+                       for (std::vector<scene::IMeshBuffer*>::iterator it2 = (*it).bufs.begin();
+                               it2 != (*it).bufs.end(); ++it2) {
+                               driver->drawMeshBuffer(*it2);
+                               vertex_count += (*it2)->getVertexCount();
                                meshbuffer_count++;
                        }
                }
index f63671425d390222397a35df81aa0a0dbbe68b10..9847cb6f99a6773c1553a5013b15ac2a75b32fee 100644 (file)
@@ -13,10 +13,11 @@ void ItemStackMetadata::serialize(std::ostream &os) const
 {
        std::ostringstream os2;
        os2 << DESERIALIZE_START;
-       for (const auto &stringvar : m_stringvars) {
-               if (!stringvar.first.empty() || !stringvar.second.empty())
-                       os2 << stringvar.first << DESERIALIZE_KV_DELIM
-                               << stringvar.second << DESERIALIZE_PAIR_DELIM;
+       for (StringMap::const_iterator it = m_stringvars.begin(); it != m_stringvars.end();
+               ++it) {
+               if (!(*it).first.empty() || !(*it).second.empty())
+                       os2 << (*it).first << DESERIALIZE_KV_DELIM
+                               << (*it).second << DESERIALIZE_PAIR_DELIM;
        }
        os << serializeJsonStringIfNeeded(os2.str());
 }
index eec37102220bb2a5da280361379dcc6b39bc8cd8..ba7898d52e26219aa4278c676cbc0c096d6c3208 100644 (file)
@@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 ReflowScan::ReflowScan(Map *map, INodeDefManager *ndef) :
        m_map(map),
        m_ndef(ndef),
-       m_liquid_queue(nullptr)
+       m_liquid_queue(NULL)
 {
 }
 
@@ -42,7 +42,7 @@ void ReflowScan::scan(MapBlock *block, UniqueQueue<v3s16> *liquid_queue)
        // scanned block. Blocks are only added to the lookup if they are really
        // needed. The lookup is indexed manually to use the same index in a
        // bit-array (of uint32 type) which stores for unloaded blocks that they
-       // were already fetched from Map but were actually nullptr.
+       // were already fetched from Map but were actually NULL.
        memset(m_lookup, 0, sizeof(m_lookup));
        int block_idx = 1 + (1 * 9) + (1 * 3);
        m_lookup[block_idx] = block;
index 540132978a5cbedb9a983a708d4187046d1a3a75..df9542630d7a397db50f276a5b63b7eedb818482 100644 (file)
@@ -43,6 +43,7 @@ RemotePlayer::RemotePlayer(const char *name, IItemDefManager *idef):
        m_last_chat_message_sent(time(NULL)),
        m_chat_message_allowance(5.0f),
        m_message_rate_overhead(0),
+       m_day_night_ratio_do_override(false),
        hud_hotbar_image(""),
        hud_hotbar_selected_image("")
 {
index cbb9386cecc7c1a09c1b165a7569ffe0e4038378..ee0d625b6b32fbf8e1513251bf4249409d51284d 100644 (file)
@@ -156,7 +156,7 @@ class RemotePlayer : public Player
        float m_chat_message_allowance;
        u16 m_message_rate_overhead;
 
-       bool m_day_night_ratio_do_override = false;
+       bool m_day_night_ratio_do_override;
        float m_day_night_ratio;
        std::string hud_hotbar_image;
        std::string hud_hotbar_selected_image;
index b4b02b0c50214724f5630f7c5f2041870eb59619..daff15bf1fdb104861dee5bd0e623f519f28328c 100644 (file)
@@ -53,7 +53,7 @@ class ScriptApiItem
        friend class LuaItemStack;
        friend class ModApiItemMod;
 
-       bool getItemCallback(const char *name, const char *callbackname, const v3s16 *p = nullptr);
+       bool getItemCallback(const char *name, const char *callbackname, const v3s16 *p = NULL);
        void pushPointedThing(const PointedThing& pointed);
 
 };
index 4a7885da7639acdc347e6abd9641a86cfee7ad38..630f6cc646ccbe16aeb328ec85feba35e6f37eab 100644 (file)
@@ -292,7 +292,7 @@ int ModApiEnvMod::l_place_node(lua_State *L)
        pointed.node_abovesurface = pos;
        pointed.node_undersurface = pos + v3s16(0,-1,0);
        // Place it with a NULL placer (appears in Lua as nil)
-       bool success = scriptIfaceItem->item_OnPlace(item, nullptr, pointed);
+       bool success = scriptIfaceItem->item_OnPlace(item, NULL, pointed);
        lua_pushboolean(L, success);
        return 1;
 }
@@ -676,7 +676,7 @@ int ModApiEnvMod::l_find_nodes_in_area(lua_State *L)
                ndef->getIds(lua_tostring(L, 3), filter);
        }
 
-       std::unordered_map<content_t, u32> individual_count;
+       UNORDERED_MAP<content_t, u32> individual_count;
 
        lua_newtable(L);
        u64 i = 0;
index 0195dc3990fc36ac0973f236f2c5d09936854235..8905f2d0ce3bd9e364ffb5ce3538b80405af8d70 100644 (file)
@@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "lua_api/l_item.h"
 #include "common/c_converter.h"
 #include "common/c_content.h"
+#include "util/cpp11_container.h"
 #include "log.h"
 #include "tool.h"
 #include "serverobject.h"
@@ -137,10 +138,11 @@ int ObjectRef::l_remove(lua_State *L)
        if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER)
                return 0;
 
-       const std::unordered_set<int> &child_ids = co->getAttachmentChildIds();
-       for (int child_id : child_ids) {
+       const UNORDERED_SET<int> &child_ids = co->getAttachmentChildIds();
+       for (UNORDERED_SET<int>::const_iterator it = child_ids.begin(); it != child_ids.end();
+                       ++it) {
                // Child can be NULL if it was deleted earlier
-               if (ServerActiveObject *child = env->getActiveObject(child_id))
+               if (ServerActiveObject *child = env->getActiveObject(*it))
                        child->setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0));
        }
 
index be1ddd7f0e4f205b2ee4c87ce637742ed705fee9..da4aaf006e8a61b1241cce8324652b00f7172d2f 100644 (file)
@@ -266,7 +266,7 @@ void LBMManager::applyLBMs(ServerEnvironment *env, MapBlock *block, u32 stamp)
                // Cache previous version to speedup lookup which has a very high performance
                // penalty on each call
                content_t previous_c{};
-               std::vector<LoadingBlockModifierDef *> *lbm_list = nullptr;
+               std::vector<LoadingBlockModifierDef *> *lbm_list = NULL;
 
                for (pos.X = 0; pos.X < MAP_BLOCKSIZE; pos.X++)
                        for (pos.Y = 0; pos.Y < MAP_BLOCKSIZE; pos.Y++)
index 31af5d6a7faa670d58c8e6c4d1df99895d4474cc..d6072e1a30d3bc96e0888e208d17a513a7d78635 100644 (file)
@@ -213,7 +213,7 @@ class ServerActiveObject : public ActiveObject
                - This is usually set to true by the step() method when the object wants
                  to be deleted but can be set by anything else too.
        */
-       bool m_pending_removal = false;
+       bool m_pending_removal;
 
        /*
                Same purpose as m_pending_removal but for deactivation.
@@ -222,7 +222,7 @@ class ServerActiveObject : public ActiveObject
                If this is set alongside with m_pending_removal, removal takes
                priority.
        */
-       bool m_pending_deactivation = false;
+       bool m_pending_deactivation;
 
        /*
                A getter that unifies the above to answer the question: