diff --git a/src/tools/wml_update.cpp b/src/tools/wml_update.cpp index 5f1232dd140..f202ec0d986 100644 --- a/src/tools/wml_update.cpp +++ b/src/tools/wml_update.cpp @@ -12,7 +12,7 @@ * Version 1.1.2 - * Update 6 + * Update 7 */ #include @@ -264,9 +264,9 @@ struct Level { return ret; } + std::string tag; bool is_tag; child_list data; - std::string tag; Level* parent; }; @@ -407,6 +407,39 @@ std::vector< std::string > split(std::string const &val, char c = ',', int flags void update_tree(Level& l,bool verbose); +bool level_compare(Level* a,Level* b) +{ + if(a->data.empty()) { + if(b->data.empty()) { + if(a->tag < b->tag) { + return true; + } else { + return false; + } + } else { + return true; + } + } else { + if(b->data.empty()) { + return false; + } else { + if(a->tag < b->tag) { + return true; + } else { + return false; + } + } + } +} + +void reorder_tree(Level& l) +{ + std::sort(l.data.begin(),l.data.end(),level_compare); + for(int w=0;w