check if ID is already in use when creating new IDs

This commit is contained in:
Marc Zinnschlag 2013-07-28 15:27:15 +02:00
parent 124a70906f
commit 5ec9d370cb
3 changed files with 23 additions and 3 deletions

View file

@ -394,4 +394,22 @@ void CSMWorld::Data::loadFile (const boost::filesystem::path& path, bool base)
reader.skipRecord();
}
}
}
}
bool CSMWorld::Data::hasId (const std::string& id) const
{
return
getGlobals().searchId (id)!=-1 ||
getGmsts().searchId (id)!=-1 ||
getSkills().searchId (id)!=-1 ||
getClasses().searchId (id)!=-1 ||
getFactions().searchId (id)!=-1 ||
getRaces().searchId (id)!=-1 ||
getSounds().searchId (id)!=-1 ||
getScripts().searchId (id)!=-1 ||
getRegions().searchId (id)!=-1 ||
getBirthsigns().searchId (id)!=-1 ||
getSpells().searchId (id)!=-1 ||
getCells().searchId (id)!=-1 ||
getReferenceables().searchId (id)!=-1;
}

View file

@ -123,6 +123,8 @@ namespace CSMWorld
void loadFile (const boost::filesystem::path& path, bool base);
///< Merging content of a file into base or modified.
bool hasId (const std::string& id) const;
};
}

View file

@ -68,9 +68,9 @@ std::string CSVWorld::GenericCreator::getErrors() const
{
errors = "Missing ID";
}
else
else if (mData.hasId (id))
{
errors = "ID is already in use";
}
return errors;