More C++03 fixes

This commit is contained in:
Loic Blot 2018-05-14 07:42:20 +02:00 committed by SmallJoker
parent e2815d27f1
commit 695d02e6bd
12 changed files with 37 additions and 28 deletions

@ -81,7 +81,7 @@ protected:
scene::ISceneManager *smgr; scene::ISceneManager *smgr;
SubgameSpec gamespec; SubgameSpec gamespec;
WorldSpec worldspec; WorldSpec worldspec;
bool simple_singleplayer_mode = false; bool simple_singleplayer_mode;
// These are set up based on the menu and other things // These are set up based on the menu and other things
// TODO: Are these required since there's already playername, password, etc // TODO: Are these required since there's already playername, password, etc

@ -79,6 +79,8 @@ struct JoystickAxisCmb : public JoystickCombination {
this->key = key; this->key = key;
} }
virtual ~JoystickAxisCmb() {}
virtual bool isTriggered(const irr::SEvent::SJoystickEvent &ev) const; virtual bool isTriggered(const irr::SEvent::SJoystickEvent &ev) const;
u16 axis_to_compare; u16 axis_to_compare;

@ -314,14 +314,15 @@ struct MeshBufListList
// Append to the correct layer // Append to the correct layer
std::vector<MeshBufList> &list = lists[layer]; std::vector<MeshBufList> &list = lists[layer];
const video::SMaterial &m = buf->getMaterial(); 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 // comparing a full material is quite expensive so we don't do it if
// not even first texture is equal // 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; continue;
if (l.m == m) { if ((*it).m == m) {
l.bufs.push_back(buf); (*it).bufs.push_back(buf);
return; return;
} }
} }
@ -356,7 +357,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
Measuring time is very useful for long delays when the Measuring time is very useful for long delays when the
machine is swapping a lot. machine is swapping a lot.
*/ */
std::time_t time1 = time(0); time_t time1 = time(0);
/* /*
Get animation parameters Get animation parameters
@ -477,11 +478,12 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
std::vector<MeshBufList> &lists = drawbufs.lists[layer]; std::vector<MeshBufList> &lists = drawbufs.lists[layer];
int timecheck_counter = 0; int timecheck_counter = 0;
for (MeshBufList &list : lists) { for (std::vector<MeshBufList>::iterator it = lists.begin(); it != lists.end();
++it) {
timecheck_counter++; timecheck_counter++;
if (timecheck_counter > 50) { if (timecheck_counter > 50) {
timecheck_counter = 0; timecheck_counter = 0;
std::time_t time2 = time(0); time_t time2 = time(0);
if (time2 > time1 + 4) { if (time2 > time1 + 4) {
infostream << "ClientMap::renderMap(): " infostream << "ClientMap::renderMap(): "
"Rendering takes ages, returning." "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) { for (std::vector<scene::IMeshBuffer*>::iterator it2 = (*it).bufs.begin();
driver->drawMeshBuffer(buf); it2 != (*it).bufs.end(); ++it2) {
vertex_count += buf->getVertexCount(); driver->drawMeshBuffer(*it2);
vertex_count += (*it2)->getVertexCount();
meshbuffer_count++; meshbuffer_count++;
} }
} }

@ -13,10 +13,11 @@ void ItemStackMetadata::serialize(std::ostream &os) const
{ {
std::ostringstream os2; std::ostringstream os2;
os2 << DESERIALIZE_START; os2 << DESERIALIZE_START;
for (const auto &stringvar : m_stringvars) { for (StringMap::const_iterator it = m_stringvars.begin(); it != m_stringvars.end();
if (!stringvar.first.empty() || !stringvar.second.empty()) ++it) {
os2 << stringvar.first << DESERIALIZE_KV_DELIM if (!(*it).first.empty() || !(*it).second.empty())
<< stringvar.second << DESERIALIZE_PAIR_DELIM; os2 << (*it).first << DESERIALIZE_KV_DELIM
<< (*it).second << DESERIALIZE_PAIR_DELIM;
} }
os << serializeJsonStringIfNeeded(os2.str()); os << serializeJsonStringIfNeeded(os2.str());
} }

@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
ReflowScan::ReflowScan(Map *map, INodeDefManager *ndef) : ReflowScan::ReflowScan(Map *map, INodeDefManager *ndef) :
m_map(map), m_map(map),
m_ndef(ndef), 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 // 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 // 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 // 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)); memset(m_lookup, 0, sizeof(m_lookup));
int block_idx = 1 + (1 * 9) + (1 * 3); int block_idx = 1 + (1 * 9) + (1 * 3);
m_lookup[block_idx] = block; m_lookup[block_idx] = block;

@ -43,6 +43,7 @@ RemotePlayer::RemotePlayer(const char *name, IItemDefManager *idef):
m_last_chat_message_sent(time(NULL)), m_last_chat_message_sent(time(NULL)),
m_chat_message_allowance(5.0f), m_chat_message_allowance(5.0f),
m_message_rate_overhead(0), m_message_rate_overhead(0),
m_day_night_ratio_do_override(false),
hud_hotbar_image(""), hud_hotbar_image(""),
hud_hotbar_selected_image("") hud_hotbar_selected_image("")
{ {

@ -156,7 +156,7 @@ private:
float m_chat_message_allowance; float m_chat_message_allowance;
u16 m_message_rate_overhead; 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; float m_day_night_ratio;
std::string hud_hotbar_image; std::string hud_hotbar_image;
std::string hud_hotbar_selected_image; std::string hud_hotbar_selected_image;

@ -53,7 +53,7 @@ protected:
friend class LuaItemStack; friend class LuaItemStack;
friend class ModApiItemMod; 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); void pushPointedThing(const PointedThing& pointed);
}; };

@ -292,7 +292,7 @@ int ModApiEnvMod::l_place_node(lua_State *L)
pointed.node_abovesurface = pos; pointed.node_abovesurface = pos;
pointed.node_undersurface = pos + v3s16(0,-1,0); pointed.node_undersurface = pos + v3s16(0,-1,0);
// Place it with a NULL placer (appears in Lua as nil) // 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); lua_pushboolean(L, success);
return 1; return 1;
} }
@ -676,7 +676,7 @@ int ModApiEnvMod::l_find_nodes_in_area(lua_State *L)
ndef->getIds(lua_tostring(L, 3), filter); 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); lua_newtable(L);
u64 i = 0; u64 i = 0;

@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "lua_api/l_item.h" #include "lua_api/l_item.h"
#include "common/c_converter.h" #include "common/c_converter.h"
#include "common/c_content.h" #include "common/c_content.h"
#include "util/cpp11_container.h"
#include "log.h" #include "log.h"
#include "tool.h" #include "tool.h"
#include "serverobject.h" #include "serverobject.h"
@ -137,10 +138,11 @@ int ObjectRef::l_remove(lua_State *L)
if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER) if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER)
return 0; return 0;
const std::unordered_set<int> &child_ids = co->getAttachmentChildIds(); const UNORDERED_SET<int> &child_ids = co->getAttachmentChildIds();
for (int child_id : child_ids) { for (UNORDERED_SET<int>::const_iterator it = child_ids.begin(); it != child_ids.end();
++it) {
// Child can be NULL if it was deleted earlier // 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)); child->setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0));
} }

@ -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 // Cache previous version to speedup lookup which has a very high performance
// penalty on each call // penalty on each call
content_t previous_c{}; 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.X = 0; pos.X < MAP_BLOCKSIZE; pos.X++)
for (pos.Y = 0; pos.Y < MAP_BLOCKSIZE; pos.Y++) for (pos.Y = 0; pos.Y < MAP_BLOCKSIZE; pos.Y++)

@ -213,7 +213,7 @@ public:
- This is usually set to true by the step() method when the object wants - 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. 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. 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 If this is set alongside with m_pending_removal, removal takes
priority. priority.
*/ */
bool m_pending_deactivation = false; bool m_pending_deactivation;
/* /*
A getter that unifies the above to answer the question: A getter that unifies the above to answer the question: