summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_nodemeta.cpp
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-05-19 02:24:14 -0400
committerkwolekr <kwolekr@minetest.net>2015-05-19 16:10:49 -0400
commitda34a2b33e1f600ec11172f599384b9a92835403 (patch)
treef09a158be783f0486447d0c61750a7509760d83b /src/script/lua_api/l_nodemeta.cpp
parent603297cc352cab685dd01dcd645999624ad17c0b (diff)
downloadminetest-da34a2b33e1f600ec11172f599384b9a92835403.tar.gz
minetest-da34a2b33e1f600ec11172f599384b9a92835403.tar.bz2
minetest-da34a2b33e1f600ec11172f599384b9a92835403.zip
Replace instances of std::map<std::string, std::string> with StringMap
Also, clean up surrounding code style Replace by-value parameter passing with const refs when possible Fix post-increment of iterators
Diffstat (limited to 'src/script/lua_api/l_nodemeta.cpp')
-rw-r--r--src/script/lua_api/l_nodemeta.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/script/lua_api/l_nodemeta.cpp b/src/script/lua_api/l_nodemeta.cpp
index 906cc3172..6cdbe5c68 100644
--- a/src/script/lua_api/l_nodemeta.cpp
+++ b/src/script/lua_api/l_nodemeta.cpp
@@ -190,32 +190,34 @@ int NodeMetaRef::l_to_table(lua_State *L)
NodeMetaRef *ref = checkobject(L, 1);
NodeMetadata *meta = getmeta(ref, true);
- if(meta == NULL){
+ if (meta == NULL) {
lua_pushnil(L);
return 1;
}
lua_newtable(L);
+
// fields
lua_newtable(L);
{
- std::map<std::string, std::string> fields = meta->getStrings();
- for(std::map<std::string, std::string>::const_iterator
- i = fields.begin(); i != fields.end(); i++){
- const std::string &name = i->first;
- const std::string &value = i->second;
+ StringMap fields = meta->getStrings();
+ for (StringMap::const_iterator
+ it = fields.begin(); it != fields.end(); ++it) {
+ const std::string &name = it->first;
+ const std::string &value = it->second;
lua_pushlstring(L, name.c_str(), name.size());
lua_pushlstring(L, value.c_str(), value.size());
lua_settable(L, -3);
}
}
lua_setfield(L, -2, "fields");
+
// inventory
lua_newtable(L);
Inventory *inv = meta->getInventory();
- if(inv){
- std::vector<const InventoryList*> lists = inv->getLists();
- for(std::vector<const InventoryList*>::const_iterator
- i = lists.begin(); i != lists.end(); i++){
+ if (inv) {
+ std::vector<const InventoryList *> lists = inv->getLists();
+ for(std::vector<const InventoryList *>::const_iterator
+ i = lists.begin(); i != lists.end(); i++) {
push_inventory_list(L, inv, (*i)->getName().c_str());
lua_setfield(L, -2, (*i)->getName().c_str());
}