forked from Mirrorlandia_minetest/minetest
Very little performance fix on correctBlockNodeIds
+ C++11 codestyle
This commit is contained in:
parent
5117ce4c90
commit
14a1a712de
@ -492,19 +492,17 @@ static void correctBlockNodeIds(const NameIdMapping *nimap, MapNode *nodes,
|
|||||||
// the information to convert those to names.
|
// the information to convert those to names.
|
||||||
// nodedef contains information to convert our names to globally
|
// nodedef contains information to convert our names to globally
|
||||||
// correct ids.
|
// correct ids.
|
||||||
std::set<content_t> unnamed_contents;
|
std::unordered_set<content_t> unnamed_contents;
|
||||||
std::set<std::string> unallocatable_contents;
|
std::unordered_set<std::string> unallocatable_contents;
|
||||||
for (u32 i = 0; i < MapBlock::nodecount; i++) {
|
for (u32 i = 0; i < MapBlock::nodecount; i++) {
|
||||||
content_t local_id = nodes[i].getContent();
|
content_t local_id = nodes[i].getContent();
|
||||||
std::string name;
|
std::string name;
|
||||||
bool found = nimap->getName(local_id, name);
|
if (!nimap->getName(local_id, name)) {
|
||||||
if(!found){
|
|
||||||
unnamed_contents.insert(local_id);
|
unnamed_contents.insert(local_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
content_t global_id;
|
content_t global_id;
|
||||||
found = nodedef->getId(name, global_id);
|
if (!nodedef->getId(name, global_id)) {
|
||||||
if(!found){
|
|
||||||
global_id = gamedef->allocateUnknownNodeId(name);
|
global_id = gamedef->allocateUnknownNodeId(name);
|
||||||
if(global_id == CONTENT_IGNORE){
|
if(global_id == CONTENT_IGNORE){
|
||||||
unallocatable_contents.insert(name);
|
unallocatable_contents.insert(name);
|
||||||
@ -513,19 +511,16 @@ static void correctBlockNodeIds(const NameIdMapping *nimap, MapNode *nodes,
|
|||||||
}
|
}
|
||||||
nodes[i].setContent(global_id);
|
nodes[i].setContent(global_id);
|
||||||
}
|
}
|
||||||
for(std::set<content_t>::const_iterator
|
|
||||||
i = unnamed_contents.begin();
|
for (const content_t c: unnamed_contents) {
|
||||||
i != unnamed_contents.end(); ++i){
|
errorstream << "correctBlockNodeIds(): IGNORING ERROR: "
|
||||||
errorstream<<"correctBlockNodeIds(): IGNORING ERROR: "
|
<< "Block contains id " << c
|
||||||
<<"Block contains id "<<(*i)
|
<< " with no name mapping" << std::endl;
|
||||||
<<" with no name mapping"<<std::endl;
|
|
||||||
}
|
}
|
||||||
for(std::set<std::string>::const_iterator
|
for (const std::string &node_name: unallocatable_contents) {
|
||||||
i = unallocatable_contents.begin();
|
errorstream << "correctBlockNodeIds(): IGNORING ERROR: "
|
||||||
i != unallocatable_contents.end(); ++i){
|
<< "Could not allocate global id for node name \""
|
||||||
errorstream<<"correctBlockNodeIds(): IGNORING ERROR: "
|
<< node_name << "\"" << std::endl;
|
||||||
<<"Could not allocate global id for node name \""
|
|
||||||
<<(*i)<<"\""<<std::endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user