Index: ps/trunk/source/tools/atlas/AtlasObject/AtlasObject.h =================================================================== --- ps/trunk/source/tools/atlas/AtlasObject/AtlasObject.h +++ ps/trunk/source/tools/atlas/AtlasObject/AtlasObject.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -67,7 +67,7 @@ // Override -> T* operator->() const { return ptr; } // Test whether the pointer is pointing to anything - explicit operator bool() const { return ptr != NULL; } + explicit operator bool() const { return ptr != nullptr; } }; template @@ -123,7 +123,7 @@ // Private implementation. (But not 'private:', because it's a waste of time // adding loads of friend functions) - AtSmartPtr p; + AtSmartPtr m_Impl; }; @@ -131,7 +131,7 @@ { public: AtObj() {} - AtObj(const AtObj& r) : p(r.p) {} + AtObj(const AtObj& r) : m_Node(r.m_Node) {} // Return an iterator to the children matching 'key' const AtIter operator[] (const char* key) const; @@ -146,7 +146,7 @@ int getInt() const; // Check whether the object contains anything (even if those things are empty) - bool defined() const { return (bool)p; } + bool defined() const { return static_cast(m_Node); } // Check recursively whether there's actually any non-empty data in the object bool hasContent() const; @@ -169,7 +169,7 @@ void setString(const wchar_t* value); void addOverlay(AtObj& data); - AtSmartPtr p; + AtSmartPtr m_Node; }; Index: ps/trunk/source/tools/atlas/AtlasObject/AtlasObjectImpl.h =================================================================== --- ps/trunk/source/tools/atlas/AtlasObject/AtlasObjectImpl.h +++ ps/trunk/source/tools/atlas/AtlasObject/AtlasObjectImpl.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -39,9 +39,9 @@ public: typedef AtSmartPtr Ptr; - AtNode() : refcount(0) {} - explicit AtNode(const AtNode* n) { *this = *n; refcount = 0; } - explicit AtNode(const wchar_t* text) : refcount(0), value(text) {} + AtNode() : m_Refcount(0) {} + explicit AtNode(const AtNode* n) { *this = *n; m_Refcount = 0; } + explicit AtNode(const wchar_t* text) : m_Refcount(0), m_Value(text) {} // Create a new AtNode (since AtNodes are immutable, so it's not possible // to just change this one), with the relevant alterations to its content. @@ -57,15 +57,15 @@ //private: // (but not actually private, since I'm still too lazy to waste // time with dozens of friends) - std::wstring value; + std::wstring m_Value; typedef std::multimap child_maptype; typedef std::pair child_pairtype; - child_maptype children; + child_maptype m_Children; private: - mutable unsigned int refcount; + mutable unsigned int m_Refcount; }; // Implementation of AtIter @@ -74,13 +74,13 @@ friend class AtSmartPtr; public: - AtIterImpl() : refcount(0) {} + AtIterImpl() : m_Refcount(0) {} AtIterImpl(AtNode::child_maptype::const_iterator it, AtNode::child_maptype::const_iterator up) - : refcount(0), iter(it), iter_upperbound(up) {} + : m_Refcount(0), iter(it), iter_upperbound(up) {} AtNode::child_maptype::const_iterator iter, iter_upperbound; private: - mutable unsigned int refcount; + mutable unsigned int m_Refcount; }; Index: ps/trunk/source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp =================================================================== --- ps/trunk/source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp +++ ps/trunk/source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -26,12 +26,12 @@ #define ATSMARTPTR_IMPL(T) \ template<> void AtSmartPtr::inc_ref() \ { \ - if (ptr) ++ptr->refcount; \ + if (ptr) ++ptr->m_Refcount; \ } \ \ template<> void AtSmartPtr::dec_ref() \ { \ - if (ptr && --ptr->refcount == 0) \ + if (ptr && --ptr->m_Refcount == 0) \ delete ptr; \ } // (Don't set ptr=NULL, since it should never be possible for an // unreferenced pointer to exist; I would rather see it die in debug @@ -47,16 +47,16 @@ const AtIter AtIter::operator [] (const char* key) const { - if (p) - return p->iter->second->getChild(key); + if (m_Impl) + return m_Impl->iter->second->getChild(key); else return AtIter(); } AtIter::operator const wchar_t* () const { - if (p) - return p->iter->second->value.c_str(); + if (m_Impl) + return m_Impl->iter->second->m_Value.c_str(); else return L""; } @@ -64,10 +64,10 @@ //AtIter::operator const AtObj () const const AtObj AtIter::operator * () const { - if (p) + if (m_Impl) { AtObj ret; - ret.p = p->iter->second; + ret.m_Node = m_Impl->iter->second; return ret; } else @@ -77,46 +77,46 @@ AtIter& AtIter::operator ++ () { - assert(p); + assert(m_Impl); // Increment the internal iterator, and stop if we've run out children // to iterate over. - if (p && ++p->iter == p->iter_upperbound) - p = NULL; + if (m_Impl && ++m_Impl->iter == m_Impl->iter_upperbound) + m_Impl = nullptr; return *this; } bool AtIter::defined() const { - return (bool)p; + return static_cast(m_Impl); } bool AtIter::hasContent() const { - if (!p) + if (!m_Impl) return false; - if (! p->iter->second) + if (!m_Impl->iter->second) return false; - return p->iter->second->hasContent(); + return m_Impl->iter->second->hasContent(); } size_t AtIter::count() const { - if (!p) + if (!m_Impl) return 0; - return std::distance(p->iter, p->iter_upperbound); + return std::distance(m_Impl->iter, m_Impl->iter_upperbound); } ////////////////////////////////////////////////////////////////////////// const AtIter AtObj::operator [] (const char* key) const { - if (p) - return p->getChild(key); + if (m_Node) + return m_Node->getChild(key); else // This object doesn't exist, so return another object that doesn't exist return AtIter(); @@ -124,8 +124,8 @@ AtObj::operator const wchar_t* () const { - if (p) - return p->value.c_str(); + if (m_Node) + return m_Node->m_Value.c_str(); else return L""; } @@ -133,10 +133,10 @@ double AtObj::getDouble() const { double val = 0; - if (p) + if (m_Node) { std::wstringstream s; - s << p->value; + s << m_Node->m_Value; s >> val; } return val; @@ -145,10 +145,10 @@ int AtObj::getInt() const { int val = 0; - if (p) + if (m_Node) { std::wstringstream s; - s << p->value; + s << m_Node->m_Value; s >> val; } return val; @@ -156,10 +156,10 @@ void AtObj::add(const char* key, AtObj& data) { - if (!p) - p = new AtNode(); + if (!m_Node) + m_Node = new AtNode(); - p = p->addChild(key, data.p); + m_Node = m_Node->addChild(key, data.m_Node); } void AtObj::add(const char* key, const wxString& value) @@ -171,18 +171,18 @@ { const AtNode* o = new AtNode(value); - if (!p) - p = new AtNode(); + if (!m_Node) + m_Node = new AtNode(); - p = p->addChild(key, AtNode::Ptr(o)); + m_Node = m_Node->addChild(key, AtNode::Ptr(o)); } void AtObj::set(const char* key, AtObj& data) { - if (!p) - p = new AtNode(); + if (!m_Node) + m_Node = new AtNode(); - p = p->setChild(key, data.p); + m_Node = m_Node->setChild(key, data.m_Node); } void AtObj::set(const char* key, const wxString& value) @@ -194,21 +194,21 @@ { const AtNode* o = new AtNode(value); - if (!p) - p = new AtNode(); + if (!m_Node) + m_Node = new AtNode(); - p = p->setChild(key, AtNode::Ptr(o)); + m_Node = m_Node->setChild(key, AtNode::Ptr(o)); } void AtObj::setBool(const char* key, bool value) { AtNode* o = new AtNode(value ? L"true" : L"false"); - o->children.insert(AtNode::child_pairtype("@boolean", AtNode::Ptr(new AtNode()))); + o->m_Children.insert(AtNode::child_pairtype("@boolean", AtNode::Ptr(new AtNode()))); - if (!p) - p = new AtNode(); + if (!m_Node) + m_Node = new AtNode(); - p = p->setChild(key, AtNode::Ptr(o)); + m_Node = m_Node->setChild(key, AtNode::Ptr(o)); } void AtObj::setDouble(const char* key, double value) @@ -216,12 +216,12 @@ std::wstringstream str; str << value; AtNode* o = new AtNode(str.str().c_str()); - o->children.insert(AtNode::child_pairtype("@number", AtNode::Ptr(new AtNode()))); + o->m_Children.insert(AtNode::child_pairtype("@number", AtNode::Ptr(new AtNode()))); - if (!p) - p = new AtNode(); + if (!m_Node) + m_Node = new AtNode(); - p = p->setChild(key, AtNode::Ptr(o)); + m_Node = m_Node->setChild(key, AtNode::Ptr(o)); } void AtObj::setInt(const char* key, int value) @@ -229,36 +229,36 @@ std::wstringstream str; str << value; AtNode* o = new AtNode(str.str().c_str()); - o->children.insert(AtNode::child_pairtype("@number", AtNode::Ptr(new AtNode()))); + o->m_Children.insert(AtNode::child_pairtype("@number", AtNode::Ptr(new AtNode()))); - if (!p) - p = new AtNode(); + if (!m_Node) + m_Node = new AtNode(); - p = p->setChild(key, AtNode::Ptr(o)); + m_Node = m_Node->setChild(key, AtNode::Ptr(o)); } void AtObj::setString(const wchar_t* value) { - if (!p) - p = new AtNode(); + if (!m_Node) + m_Node = new AtNode(); - p = p->setValue(value); + m_Node = m_Node->setValue(value); } void AtObj::addOverlay(AtObj& data) { - if (!p) - p = new AtNode(); + if (!m_Node) + m_Node = new AtNode(); - p = p->addOverlay(data.p); + m_Node = m_Node->addOverlay(data.m_Node); } bool AtObj::hasContent() const { - if (!p) + if (!m_Node) return false; - return p->hasContent(); + return m_Node->hasContent(); } ////////////////////////////////////////////////////////////////////////// @@ -266,24 +266,24 @@ const AtIter AtNode::getChild(const char* key) const { // Find the range of matching children - AtNode::child_maptype::const_iterator it = children.lower_bound(key); - AtNode::child_maptype::const_iterator it_upper = children.upper_bound(key); + AtNode::child_maptype::const_iterator it = m_Children.lower_bound(key); + AtNode::child_maptype::const_iterator it_upper = m_Children.upper_bound(key); if (it == it_upper) // No match found return AtIter(); AtIter obj; - obj.p = new AtIterImpl(it, it_upper); + obj.m_Impl = new AtIterImpl(it, it_upper); return obj; } bool AtNode::hasContent() const { - if (value.length()) + if (m_Value.length()) return true; - for (child_maptype::const_iterator it = children.begin(); it != children.end(); ++it) - if (it->second && it->second->hasContent()) + for (const child_maptype::value_type& child : m_Children) + if (child.second && child.second->hasContent()) return true; return false; @@ -292,23 +292,23 @@ const AtNode::Ptr AtNode::setValue(const wchar_t* value) const { AtNode* newNode = new AtNode(); - newNode->children = children; - newNode->value = value; + newNode->m_Children = m_Children; + newNode->m_Value = value; return AtNode::Ptr(newNode); } const AtNode::Ptr AtNode::setChild(const char* key, const AtNode::Ptr &data) const { AtNode* newNode = new AtNode(this); - newNode->children.erase(key); - newNode->children.insert(AtNode::child_pairtype(key, data)); + newNode->m_Children.erase(key); + newNode->m_Children.insert(AtNode::child_pairtype(key, data)); return AtNode::Ptr(newNode); } const AtNode::Ptr AtNode::addChild(const char* key, const AtNode::Ptr &data) const { AtNode* newNode = new AtNode(this); - newNode->children.insert(AtNode::child_pairtype(key, data)); + newNode->m_Children.insert(AtNode::child_pairtype(key, data)); return AtNode::Ptr(newNode); } @@ -317,12 +317,12 @@ AtNode* newNode = new AtNode(this); // Delete old childs that are also in the overlay - for (AtNode::child_maptype::const_iterator it = data->children.begin(); it != data->children.end(); ++it) - newNode->children.erase(it->first); + for (AtNode::child_maptype::const_iterator it = data->m_Children.begin(); it != data->m_Children.end(); ++it) + newNode->m_Children.erase(it->first); // Add the overlay childs back in - for (AtNode::child_maptype::const_iterator it = data->children.begin(); it != data->children.end(); ++it) - newNode->children.insert(*it); + for (AtNode::child_maptype::const_iterator it = data->m_Children.begin(); it != data->m_Children.end(); ++it) + newNode->m_Children.insert(*it); return AtNode::Ptr(newNode); } @@ -332,14 +332,13 @@ { AtObj ret; - for (AtNode::child_maptype::const_iterator it = obj.p->children.begin(); - it != obj.p->children.end(); ++it) + for (const AtNode::child_maptype::value_type& child : obj.m_Node->m_Children) { - if (it->second && it->second->hasContent()) + if (child.second && child.second->hasContent()) { AtObj node; - node.p = it->second; - ret.add(it->first.c_str(), node); + node.m_Node = child.second; + ret.add(child.first.c_str(), node); } } Index: ps/trunk/source/tools/atlas/AtlasObject/AtlasObjectJS.cpp =================================================================== --- ps/trunk/source/tools/atlas/AtlasObject/AtlasObjectJS.cpp +++ ps/trunk/source/tools/atlas/AtlasObject/AtlasObjectJS.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -36,7 +36,7 @@ json_spirit::read_string(json, rootnode); AtObj obj; - obj.p = ConvertNode(rootnode); + obj.m_Node = ConvertNode(rootnode); return obj; } @@ -47,7 +47,7 @@ if (node.type() == json_spirit::str_type) { - obj->value = std::wstring(node.get_str().begin(),node.get_str().end()); + obj->m_Value = std::wstring(node.get_str().begin(),node.get_str().end()); } else if (node.type() == json_spirit::int_type || node.type() == json_spirit::real_type) { @@ -57,25 +57,25 @@ if (node.type() == json_spirit::real_type) stream << node.get_real(); - obj->value = stream.str().c_str(); - obj->children.insert(AtNode::child_pairtype( + obj->m_Value = stream.str().c_str(); + obj->m_Children.insert(AtNode::child_pairtype( "@number", AtSmartPtr(new AtNode()) )); } else if (node.type() == json_spirit::bool_type) { if (node.get_bool()) - obj->value = L"true"; + obj->m_Value = L"true"; else - obj->value = L"false"; + obj->m_Value = L"false"; - obj->children.insert(AtNode::child_pairtype( + obj->m_Children.insert(AtNode::child_pairtype( "@boolean", AtSmartPtr(new AtNode()) )); } else if (node.type() == json_spirit::array_type) { - obj->children.insert(AtNode::child_pairtype( + obj->m_Children.insert(AtNode::child_pairtype( "@array", AtSmartPtr(new AtNode()) )); @@ -84,7 +84,7 @@ for (; itr != nodeChildren.end(); ++itr) { - obj->children.insert(AtNode::child_pairtype( + obj->m_Children.insert(AtNode::child_pairtype( "item", ConvertNode(*itr) )); } @@ -95,7 +95,7 @@ json_spirit::Object::iterator itr = objectProperties.begin(); for (; itr != objectProperties.end(); ++itr) { - obj->children.insert(AtNode::child_pairtype( + obj->m_Children.insert(AtNode::child_pairtype( itr->name_, ConvertNode(itr->value_) )); } @@ -122,21 +122,21 @@ } // Special case for numbers/booleans to allow round-tripping - if (p->children.count("@number")) + if (p->m_Children.count("@number")) { // Convert to double std::wstringstream str; - str << p->value; + str << p->m_Value; double val = 0; str >> val; json_spirit::Value rval(val); return rval; } - else if (p->children.count("@boolean")) + else if (p->m_Children.count("@boolean")) { bool val = false; - if (p->value == L"true") + if (p->m_Value == L"true") val = true; json_spirit::Value rval(val); @@ -144,19 +144,19 @@ } // If no children, then use the value string instead - if (p->children.empty()) + if (p->m_Children.empty()) { - json_spirit::Value rval(std::string(p->value.begin(), p->value.end())); + json_spirit::Value rval(std::string(p->m_Value.begin(), p->m_Value.end())); return rval; } - if (p->children.find("@array") != p->children.end()) + if (p->m_Children.find("@array") != p->m_Children.end()) { json_spirit::Array rval; // Find the children - AtNode::child_maptype::const_iterator lower = p->children.lower_bound("item"); - AtNode::child_maptype::const_iterator upper = p->children.upper_bound("item"); + AtNode::child_maptype::const_iterator lower = p->m_Children.lower_bound("item"); + AtNode::child_maptype::const_iterator upper = p->m_Children.upper_bound("item"); unsigned int idx = 0; for (AtNode::child_maptype::const_iterator it = lower; it != upper; ++it) @@ -173,7 +173,7 @@ { json_spirit::Object rval; - for (AtNode::child_maptype::const_iterator it = p->children.begin(); it != p->children.end(); ++it) + for (AtNode::child_maptype::const_iterator it = p->m_Children.begin(); it != p->m_Children.end(); ++it) { json_spirit::Value child = BuildJSONNode(it->second); // We don't serialize childs with null value. @@ -189,7 +189,6 @@ std::string AtlasObject::SaveToJSON(AtObj& obj) { - json_spirit::Value root = BuildJSONNode(obj.p); - std::string ret = json_spirit::write_string(root, 0); - return ret; + json_spirit::Value root = BuildJSONNode(obj.m_Node); + return json_spirit::write_string(root, 0); } Index: ps/trunk/source/tools/atlas/AtlasObject/AtlasObjectText.cpp =================================================================== --- ps/trunk/source/tools/atlas/AtlasObject/AtlasObjectText.cpp +++ ps/trunk/source/tools/atlas/AtlasObject/AtlasObjectText.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -32,13 +32,13 @@ std::wstring result; - bool has_value = (obj->value.length() != 0); - bool has_children = (obj->children.size() != 0); + bool has_value = !obj->m_Value.empty(); + bool has_children = !obj->m_Children.empty(); if (has_value && has_children) - result = obj->value + L" "; + result = obj->m_Value + L" "; else if (has_value) - result = obj->value; + result = obj->m_Value; // else no value; result = L"" if (has_children) @@ -48,16 +48,14 @@ bool first_child = true; // so we can add ", " in appropriate places - for (AtNode::child_maptype::const_iterator it = obj->children.begin(); - it != obj->children.end(); - ++it) + for (const AtNode::child_maptype::value_type& child : obj->m_Children) { - if (! first_child) + if (!first_child) result += L", "; else first_child = false; - result += ConvertRecursive(it->second); + result += ConvertRecursive(child.second); } if (use_brackets) @@ -69,5 +67,5 @@ std::wstring AtlasObject::ConvertToString(const AtObj& obj) { - return ConvertRecursive(obj.p, false); + return ConvertRecursive(obj.m_Node, false); } Index: ps/trunk/source/tools/atlas/AtlasObject/AtlasObjectXML.cpp =================================================================== --- ps/trunk/source/tools/atlas/AtlasObject/AtlasObjectXML.cpp +++ ps/trunk/source/tools/atlas/AtlasObject/AtlasObjectXML.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -45,10 +45,9 @@ public: toXmlChar(const std::wstring& str) { - for (size_t i = 0; i < str.length(); ++i) + for(wchar_t ch : str) { unsigned short bytesToWrite; - wchar_t ch = str[i]; if (ch < 0x80) bytesToWrite = 1; else if (ch < 0x800) bytesToWrite = 2; @@ -124,7 +123,7 @@ xmlNodePtr root = xmlDocGetRootElement(doc); AtObj obj; - obj.p = ConvertNode(root); + obj.m_Node = ConvertNode(root); AtObj rootObj; rootObj.set((const char*)root->name, obj); @@ -149,7 +148,7 @@ xmlFree(content); AtNode* newNode = new AtNode(value.c_str()); - obj->children.insert(AtNode::child_pairtype( + obj->m_Children.insert(AtNode::child_pairtype( name.c_str(), AtNode::Ptr(newNode) )); } @@ -159,7 +158,7 @@ { if (cur_node->type == XML_ELEMENT_NODE) { - obj->children.insert(AtNode::child_pairtype( + obj->m_Children.insert(AtNode::child_pairtype( (const char*)cur_node->name, ConvertNode(cur_node) )); } @@ -168,19 +167,19 @@ xmlChar* content = xmlNodeGetContent(cur_node); std::wstring value (fromXmlChar(content)); xmlFree(content); - obj->value += value; + obj->m_Value += value; } } // Trim whitespace surrounding the string value const std::wstring whitespace = L" \t\r\n"; - size_t first = obj->value.find_first_not_of(whitespace); + size_t first = obj->m_Value.find_first_not_of(whitespace); if (first == std::wstring::npos) - obj->value = L""; + obj->m_Value = L""; else { - size_t last = obj->value.find_last_not_of(whitespace); - obj->value = obj->value.substr(first, 1+last-first); + size_t last = obj->m_Value.find_last_not_of(whitespace); + obj->m_Value = obj->m_Value.substr(first, 1+last-first); } return obj; @@ -191,30 +190,33 @@ { if (p) { - if (p->value.length()) - xmlNodeAddContent(node, toXmlChar(p->value)); + if (p->m_Value.length()) + xmlNodeAddContent(node, toXmlChar(p->m_Value)); - for (AtNode::child_maptype::const_iterator it = p->children.begin(); it != p->children.end(); ++it) + for (const AtNode::child_maptype::value_type& child : p->m_Children) { + const xmlChar* first_child = reinterpret_cast(child.first.c_str()); + // Test for attribute nodes (whose names start with @) - if (it->first.length() && it->first[0] == '@') + if (child.first.length() && child.first[0] == '@') { - assert(it->second); - assert(it->second->children.empty()); - xmlNewProp(node, (const xmlChar*)it->first.c_str()+1, toXmlChar(it->second->value)); + assert(child.second); + assert(child.second->m_Children.empty()); + xmlNewProp(node, first_child + 1, toXmlChar(child.second->m_Value)); } else { - if (node == NULL) // first node in the document - needs to be made the root node + // First node in the document - needs to be made the root node + if (node == nullptr) { - xmlNodePtr root = xmlNewNode(NULL, (const xmlChar*)it->first.c_str()); + xmlNodePtr root = xmlNewNode(nullptr, first_child); xmlDocSetRootElement(doc, root); - BuildDOMNode(doc, root, it->second); + BuildDOMNode(doc, root, child.second); } else { - xmlNodePtr child = xmlNewChild(node, NULL, (const xmlChar*)it->first.c_str(), NULL); - BuildDOMNode(doc, child, it->second); + xmlNodePtr newChild = xmlNewChild(node, nullptr, first_child, nullptr); + BuildDOMNode(doc, newChild, child.second); } } } @@ -223,16 +225,16 @@ std::string AtlasObject::SaveToXML(AtObj& obj) { - if (!obj.p || obj.p->children.size() != 1) + if (!obj.m_Node || obj.m_Node->m_Children.size() != 1) { assert(! "SaveToXML: root must only have one child"); return ""; } - AtNode::Ptr firstChild (obj.p->children.begin()->second); + AtNode::Ptr firstChild (obj.m_Node->m_Children.begin()->second); xmlDocPtr doc = xmlNewDoc((const xmlChar*)"1.0"); - BuildDOMNode(doc, NULL, obj.p); + BuildDOMNode(doc, nullptr, obj.m_Node); xmlChar* buf; int size; Index: ps/trunk/source/tools/atlas/AtlasUI/CustomControls/MapDialog/MapDialog.cpp =================================================================== --- ps/trunk/source/tools/atlas/AtlasUI/CustomControls/MapDialog/MapDialog.cpp +++ ps/trunk/source/tools/atlas/AtlasUI/CustomControls/MapDialog/MapDialog.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -166,13 +166,13 @@ else { wxString filePath = GetSelectedFilePath(); - AtlasMessage::qVFSFileExists qry(filePath.wc_str()); - qry.Post(); - if (!filePath.IsEmpty() && qry.exists) + AtlasMessage::qVFSFileExists fileExistsQuery(filePath.wc_str()); + fileExistsQuery.Post(); + if (!filePath.IsEmpty() && fileExistsQuery.exists) { - AtlasMessage::qVFSFileRealPath qry(filePath.wc_str()); - qry.Post(); - wxDynamicCast(FindWindow(ID_MapDialogFilename), wxTextCtrl)->ChangeValue(*qry.realPath); + AtlasMessage::qVFSFileRealPath pathQuery(filePath.wc_str()); + pathQuery.Post(); + wxDynamicCast(FindWindow(ID_MapDialogFilename), wxTextCtrl)->ChangeValue(*pathQuery.realPath); } } Index: ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp =================================================================== --- ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp +++ ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -739,8 +739,8 @@ SetOpenFilename(name); { // Wait for it to load, while the wxBusyInfo is telling the user that we're doing that - qPing qry; - qry.Post(); + qPing pingQuery; + pingQuery.Post(); } NotifyOnMapReload(); Index: ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Object/Object.h =================================================================== --- ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Object/Object.h +++ ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Object/Object.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -37,7 +37,7 @@ void OnSelectFilter(wxCommandEvent& evt); void OnSelectObject(wxCommandEvent& evt); - ObjectSidebarImpl* p; + ObjectSidebarImpl* m_Impl; DECLARE_EVENT_TABLE(); }; Index: ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Object/Object.cpp =================================================================== --- ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Object/Object.cpp +++ ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Object/Object.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -127,7 +127,7 @@ wxWindow* bottomBarContainer ) : Sidebar(scenarioEditor, sidebarContainer, bottomBarContainer), - p(new ObjectSidebarImpl(scenarioEditor)) + m_Impl(new ObjectSidebarImpl(scenarioEditor)) { wxSizer* scrollSizer = new wxBoxSizer(wxVERTICAL); wxScrolledWindow* scrolledWindow = new wxScrolledWindow(this); @@ -159,8 +159,8 @@ // ------------------------------------------------------------------------------------------ - p->m_ObjectListBox = new wxListBox(scrolledWindow, ID_SelectObject, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE|wxLB_HSCROLL); - scrollSizer->Add(p->m_ObjectListBox, wxSizerFlags().Proportion(1).Expand()); + m_Impl->m_ObjectListBox = new wxListBox(scrolledWindow, ID_SelectObject, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxLB_SINGLE|wxLB_HSCROLL); + scrollSizer->Add(m_Impl->m_ObjectListBox, wxSizerFlags().Proportion(1).Expand()); scrollSizer->AddSpacer(3); // ------------------------------------------------------------------------------------------ @@ -173,32 +173,32 @@ bottomBarContainer, scenarioEditor.GetObjectSettings(), scenarioEditor.GetMapSettings(), - p + m_Impl ); - p->m_ToolConn = scenarioEditor.GetToolManager().GetCurrentTool().RegisterObserver(0, &ObjectSidebar::OnToolChange, this); + m_Impl->m_ToolConn = scenarioEditor.GetToolManager().GetCurrentTool().RegisterObserver(0, &ObjectSidebar::OnToolChange, this); } ObjectSidebar::~ObjectSidebar() { - delete p; + delete m_Impl; } void ObjectSidebar::OnToolChange(ITool* tool) { if (wxString(tool->GetClassInfo()->GetClassName()) == _T("ActorViewerTool")) { - p->m_ActorViewerActive = true; - p->ActorViewerPostToGame(); + m_Impl->m_ActorViewerActive = true; + m_Impl->ActorViewerPostToGame(); wxDynamicCast(FindWindow(ID_ToggleViewer), wxButton)->SetLabel(_("Return to game view")); } else { - p->m_ActorViewerActive = false; + m_Impl->m_ActorViewerActive = false; wxDynamicCast(FindWindow(ID_ToggleViewer), wxButton)->SetLabel(_("Switch to Actor Viewer")); } - static_cast(m_BottomBar)->ShowActorViewer(p->m_ActorViewerActive); + static_cast(m_BottomBar)->ShowActorViewer(m_Impl->m_ActorViewerActive); } void ObjectSidebar::OnFirstDisplay() @@ -210,7 +210,7 @@ // Get the list of objects from the game AtlasMessage::qGetObjectsList qry; qry.Post(); - p->m_Objects = *qry.objects; + m_Impl->m_Objects = *qry.objects; // Display first group of objects FilterObjects(); } @@ -220,9 +220,9 @@ int filterType = wxDynamicCast(FindWindow(ID_ObjectType), wxChoice)->GetSelection(); wxString filterName = wxDynamicCast(FindWindow(ID_ObjectFilter), wxTextCtrl)->GetValue(); - p->m_ObjectListBox->Freeze(); - p->m_ObjectListBox->Clear(); - for (std::vector::iterator it = p->m_Objects.begin(); it != p->m_Objects.end(); ++it) + m_Impl->m_ObjectListBox->Freeze(); + m_Impl->m_ObjectListBox->Clear(); + for (std::vector::iterator it = m_Impl->m_Objects.begin(); it != m_Impl->m_Objects.end(); ++it) { if (it->type == filterType) { @@ -231,16 +231,16 @@ if (name.Lower().Find(filterName.Lower()) != wxNOT_FOUND) { - p->m_ObjectListBox->Append(name, new wxStringClientData(id)); + m_Impl->m_ObjectListBox->Append(name, new wxStringClientData(id)); } } } - p->m_ObjectListBox->Thaw(); + m_Impl->m_ObjectListBox->Thaw(); } void ObjectSidebar::OnToggleViewer(wxCommandEvent& WXUNUSED(evt)) { - if (p->m_ActorViewerActive) + if (m_Impl->m_ActorViewerActive) { m_ScenarioEditor.GetToolManager().SetCurrentTool(_T(""), NULL); } @@ -264,11 +264,11 @@ // Always update the actor viewer's state even if it's inactive, // so it will be correct when first enabled - p->m_ActorViewerEntity = id; + m_Impl->m_ActorViewerEntity = id; - if (p->m_ActorViewerActive) + if (m_Impl->m_ActorViewerActive) { - p->ActorViewerPostToGame(); + m_Impl->ActorViewerPostToGame(); } else { @@ -544,10 +544,9 @@ qryPlayers.Post(); AtObj playerData = AtlasObject::LoadFromJSON(*qryPlayers.defaults); AtObj playerDefs = *playerData["PlayerData"]; - for (AtIter p = playerDefs["item"]; p.defined(); ++p) - { - players.Add(wxString(p["Name"])); - } + for (AtIter iterator = playerDefs["item"]; iterator.defined(); ++iterator) + players.Add(wxString(iterator["Name"])); + wxDynamicCast(FindWindow(ID_PlayerSelect), PlayerComboBox)->SetPlayers(players); // Initialise the game with the default settings