From 695d02e6bda939f7b00af402273b39a8fd75a203 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Mon, 14 May 2018 07:42:20 +0200 Subject: More C++03 fixes --- src/client/clientlauncher.h | 2 +- src/client/joystick_controller.h | 2 ++ src/clientmap.cpp | 25 ++++++++++++++----------- src/itemstackmetadata.cpp | 9 +++++---- src/reflowscan.cpp | 4 ++-- src/remoteplayer.cpp | 1 + src/remoteplayer.h | 2 +- src/script/cpp_api/s_item.h | 2 +- src/script/lua_api/l_env.cpp | 4 ++-- src/script/lua_api/l_object.cpp | 8 +++++--- src/serverenvironment.cpp | 2 +- src/serverobject.h | 4 ++-- 12 files changed, 37 insertions(+), 28 deletions(-) diff --git a/src/client/clientlauncher.h b/src/client/clientlauncher.h index 3d82b9cdc..4ff77bc03 100644 --- a/src/client/clientlauncher.h +++ b/src/client/clientlauncher.h @@ -81,7 +81,7 @@ protected: 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 diff --git a/src/client/joystick_controller.h b/src/client/joystick_controller.h index ea1db684a..744315011 100644 --- a/src/client/joystick_controller.h +++ b/src/client/joystick_controller.h @@ -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; diff --git a/src/clientmap.cpp b/src/clientmap.cpp index d00443c62..21937ac81 100644 --- a/src/clientmap.cpp +++ b/src/clientmap.cpp @@ -314,14 +314,15 @@ struct MeshBufListList // Append to the correct layer std::vector &list = lists[layer]; const video::SMaterial &m = buf->getMaterial(); - for (MeshBufList &l : list) { + for (std::vector::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 &lists = drawbufs.lists[layer]; int timecheck_counter = 0; - for (MeshBufList &list : lists) { + for (std::vector::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::iterator it2 = (*it).bufs.begin(); + it2 != (*it).bufs.end(); ++it2) { + driver->drawMeshBuffer(*it2); + vertex_count += (*it2)->getVertexCount(); meshbuffer_count++; } } diff --git a/src/itemstackmetadata.cpp b/src/itemstackmetadata.cpp index f63671425..9847cb6f9 100644 --- a/src/itemstackmetadata.cpp +++ b/src/itemstackmetadata.cpp @@ -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()); } diff --git a/src/reflowscan.cpp b/src/reflowscan.cpp index eec371022..ba7898d52 100644 --- a/src/reflowscan.cpp +++ b/src/reflowscan.cpp @@ -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 *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; diff --git a/src/remoteplayer.cpp b/src/remoteplayer.cpp index 540132978..df9542630 100644 --- a/src/remoteplayer.cpp +++ b/src/remoteplayer.cpp @@ -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("") { diff --git a/src/remoteplayer.h b/src/remoteplayer.h index cbb9386ce..ee0d625b6 100644 --- a/src/remoteplayer.h +++ b/src/remoteplayer.h @@ -156,7 +156,7 @@ private: 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; diff --git a/src/script/cpp_api/s_item.h b/src/script/cpp_api/s_item.h index b4b02b0c5..daff15bf1 100644 --- a/src/script/cpp_api/s_item.h +++ b/src/script/cpp_api/s_item.h @@ -53,7 +53,7 @@ protected: 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); }; diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp index 4a7885da7..630f6cc64 100644 --- a/src/script/lua_api/l_env.cpp +++ b/src/script/lua_api/l_env.cpp @@ -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 individual_count; + UNORDERED_MAP individual_count; lua_newtable(L); u64 i = 0; diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 0195dc399..8905f2d0c 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -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 &child_ids = co->getAttachmentChildIds(); - for (int child_id : child_ids) { + const UNORDERED_SET &child_ids = co->getAttachmentChildIds(); + for (UNORDERED_SET::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)); } diff --git a/src/serverenvironment.cpp b/src/serverenvironment.cpp index be1ddd7f0..da4aaf006 100644 --- a/src/serverenvironment.cpp +++ b/src/serverenvironment.cpp @@ -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 *lbm_list = nullptr; + std::vector *lbm_list = NULL; for (pos.X = 0; pos.X < MAP_BLOCKSIZE; pos.X++) for (pos.Y = 0; pos.Y < MAP_BLOCKSIZE; pos.Y++) diff --git a/src/serverobject.h b/src/serverobject.h index 31af5d6a7..d6072e1a3 100644 --- a/src/serverobject.h +++ b/src/serverobject.h @@ -213,7 +213,7 @@ public: - 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 @@ public: 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: -- cgit v1.2.3