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) 2019 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -166,6 +166,7 @@ void add(const char* key, AtObj& data); void set(const char* key, const char* value); void set(const char* key, AtObj& data); + void unset(const char* key); void setBool(const char* key, bool value); void setDouble(const char* key, double value); void setInt(const char* key, int value); 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) 2019 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -48,6 +48,7 @@ const AtNode::Ptr setValue(const char* value) const; const AtNode::Ptr addChild(const char* key, const AtNode::Ptr &data) const; const AtNode::Ptr setChild(const char* key, const AtNode::Ptr &data) const; + const AtNode::Ptr unsetChild(const char* key) const; const AtNode::Ptr addOverlay(const AtNode::Ptr &data) const; const AtIter getChild(const char* key) const; 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) 2019 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -182,6 +182,14 @@ m_Node = m_Node->setChild(key, AtNode::Ptr(o)); } +void AtObj::unset(const char* key) +{ + if (!m_Node) + m_Node = new AtNode(); + + m_Node = m_Node->unsetChild(key); +} + void AtObj::setBool(const char* key, bool value) { AtNode* o = new AtNode(value ? "true" : "false"); @@ -287,6 +295,13 @@ return AtNode::Ptr(newNode); } +const AtNode::Ptr AtNode::unsetChild(const char* key) const +{ + AtNode* newNode = new AtNode(this); + newNode->m_Children.erase(key); + return AtNode::Ptr(newNode); +} + const AtNode::Ptr AtNode::addChild(const char* key, const AtNode::Ptr &data) const { AtNode* newNode = new AtNode(this); Index: ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.cpp =================================================================== --- ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.cpp +++ ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -861,7 +861,7 @@ player.set("Civ", str->GetData()); } else - player.set("Civ", playerDefs["Civ"]); + player.unset("Civ"); // color if (controls.color->IsEnabled())