Make Attack, Item and Species libraries be case insensitive.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-02-13 16:05:27 +01:00
parent 8d4860f553
commit 611198009b
3 changed files with 42 additions and 12 deletions

View File

@@ -2,7 +2,9 @@
bool CreatureLib::Library::SpeciesLibrary::TryGetSpecies(
const std::string& name, const CreatureLib::Library::CreatureSpecies*& outSpecies) const {
auto find = _species.find(name);
std::string key = name;
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
auto find = _species.find(key);
if (find == _species.end()) {
outSpecies = nullptr;
return false;
@@ -13,7 +15,9 @@ bool CreatureLib::Library::SpeciesLibrary::TryGetSpecies(
const CreatureLib::Library::CreatureSpecies*
CreatureLib::Library::SpeciesLibrary::GetSpecies(const std::string& name) const {
return _species.at(name);
std::string key = name;
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
return _species.at(key);
}
const CreatureLib::Library::CreatureSpecies*
@@ -23,7 +27,13 @@ const CreatureLib::Library::CreatureSpecies*
void CreatureLib::Library::SpeciesLibrary::LoadSpecies(const std::string& name,
const CreatureLib::Library::CreatureSpecies* species) {
_species.insert({name, species});
std::string key = name;
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
_species.insert({key, species});
}
void CreatureLib::Library::SpeciesLibrary::DeleteSpecies(const std::string& name) { _species.erase(name); }
void CreatureLib::Library::SpeciesLibrary::DeleteSpecies(const std::string& name) {
std::string key = name;
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
_species.erase(key);
}