Skip to content

Commit

Permalink
feat(mechanics,licenses): support "inline" license specifications
Browse files Browse the repository at this point in the history
The wiki describes `licenses` as "a list of names" and provides no examples of what was intended (an indented list).
Rather than issue a warning diagnostic for a license that was specified in the same line, add support for that syntax.
  • Loading branch information
tehhowch committed Jul 17, 2021
1 parent ee7b173 commit 251fa5a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions source/Outfit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,22 @@ void Outfit::Load(const DataNode &node)
cost = child.Value(1);
else if(child.Token(0) == "mass" && child.Size() >= 2)
mass = child.Value(1);
else if(child.Token(0) == "licenses")
else if(child.Token(0) == "licenses" && (child.HasChildren() || child.Size() >= 2))
{
auto isNewLicense = [](const vector<string> &c, const string &val) noexcept -> bool {
return find(c.begin(), c.end(), val) == c.end();
};
// Add any new licenses that were specified "inline".
if(child.Size() >= 2)
{
for(auto it = ++begin(child.Tokens()); it != end(child.Tokens()); ++it)
if(isNewLicense(licenses, *it))
licenses.push_back(*it);
}
// Add any new licenses that were specifed as an indented list.
for(const DataNode &grand : child)
licenses.push_back(grand.Token(0));
if(isNewLicense(licenses, grand.Token(0)))
licenses.push_back(grand.Token(0));
}
else if(child.Token(0) == "jump range" && child.Size() >= 2)
{
Expand Down

0 comments on commit 251fa5a

Please sign in to comment.