From da34a2b33e1f600ec11172f599384b9a92835403 Mon Sep 17 00:00:00 2001 From: kwolekr Date: Tue, 19 May 2015 02:24:14 -0400 Subject: Replace instances of std::map with StringMap Also, clean up surrounding code style Replace by-value parameter passing with const refs when possible Fix post-increment of iterators --- src/client.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'src/client.cpp') diff --git a/src/client.cpp b/src/client.cpp index 1d0245c45..de8131875 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1102,7 +1102,7 @@ void Client::sendRemovedSounds(std::vector &soundList) } void Client::sendNodemetaFields(v3s16 p, const std::string &formname, - const std::map &fields) + const StringMap &fields) { size_t fields_size = fields.size(); @@ -1112,10 +1112,10 @@ void Client::sendNodemetaFields(v3s16 p, const std::string &formname, pkt << p << formname << (u16) (fields_size & 0xFFFF); - for(std::map::const_iterator - i = fields.begin(); i != fields.end(); i++) { - const std::string &name = i->first; - const std::string &value = i->second; + StringMap::const_iterator it; + for (it = fields.begin(); it != fields.end(); ++it) { + const std::string &name = it->first; + const std::string &value = it->second; pkt << name; pkt.putLongString(value); } @@ -1124,7 +1124,7 @@ void Client::sendNodemetaFields(v3s16 p, const std::string &formname, } void Client::sendInventoryFields(const std::string &formname, - const std::map &fields) + const StringMap &fields) { size_t fields_size = fields.size(); FATAL_ERROR_IF(fields_size > 0xFFFF, "Unsupported number of inventory fields"); @@ -1132,10 +1132,10 @@ void Client::sendInventoryFields(const std::string &formname, NetworkPacket pkt(TOSERVER_INVENTORY_FIELDS, 0); pkt << formname << (u16) (fields_size & 0xFFFF); - for(std::map::const_iterator - i = fields.begin(); i != fields.end(); i++) { - const std::string &name = i->first; - const std::string &value = i->second; + StringMap::const_iterator it; + for (it = fields.begin(); it != fields.end(); ++it) { + const std::string &name = it->first; + const std::string &value = it->second; pkt << name; pkt.putLongString(value); } @@ -1918,14 +1918,13 @@ ParticleManager* Client::getParticleManager() scene::IAnimatedMesh* Client::getMesh(const std::string &filename) { - std::map::const_iterator i = - m_mesh_data.find(filename); - if(i == m_mesh_data.end()){ - errorstream<<"Client::getMesh(): Mesh not found: \""<second; + const std::string &data = it->second; scene::ISceneManager *smgr = m_device->getSceneManager(); // Create the mesh, remove it from cache and return it -- cgit v1.2.3