mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
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
This commit is contained in:
parent
603297cc35
commit
da34a2b33e
25 changed files with 180 additions and 193 deletions
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue