diff --git a/src/Library/AttackLibrary.cpp b/src/Library/AttackLibrary.cpp index 6acd0e2..01d6500 100644 --- a/src/Library/AttackLibrary.cpp +++ b/src/Library/AttackLibrary.cpp @@ -2,7 +2,9 @@ bool CreatureLib::Library::AttackLibrary::TryGetAttack(const std::string& name, const CreatureLib::Library::AttackData*& move) const { - auto find = _attacks.find(name); + std::string key = name; + std::transform(key.begin(), key.end(), key.begin(), ::tolower); + auto find = _attacks.find(key); if (find == _attacks.end()) { move = nullptr; return false; @@ -12,7 +14,9 @@ bool CreatureLib::Library::AttackLibrary::TryGetAttack(const std::string& name, } const CreatureLib::Library::AttackData* CreatureLib::Library::AttackLibrary::GetAttack(const std::string& name) const { - return this->_attacks.at(name); + std::string key = name; + std::transform(key.begin(), key.end(), key.begin(), ::tolower); + return this->_attacks.at(key); } const CreatureLib::Library::AttackData* CreatureLib::Library::AttackLibrary::operator[](const std::string& name) const { @@ -21,7 +25,13 @@ const CreatureLib::Library::AttackData* CreatureLib::Library::AttackLibrary::ope void CreatureLib::Library::AttackLibrary::LoadAttack(const std::string& name, const CreatureLib::Library::AttackData* attack) { - this->_attacks.insert({name, attack}); + std::string key = name; + std::transform(key.begin(), key.end(), key.begin(), ::tolower); + this->_attacks.insert({key, attack}); } -void CreatureLib::Library::AttackLibrary::DeleteAttack(const std::string& name) { this->_attacks.erase(name); } +void CreatureLib::Library::AttackLibrary::DeleteAttack(const std::string& name) { + std::string key = name; + std::transform(key.begin(), key.end(), key.begin(), ::tolower); + this->_attacks.erase(key); +} diff --git a/src/Library/ItemLibrary.cpp b/src/Library/ItemLibrary.cpp index 5337bbe..eafd8eb 100644 --- a/src/Library/ItemLibrary.cpp +++ b/src/Library/ItemLibrary.cpp @@ -2,7 +2,9 @@ bool CreatureLib::Library::ItemLibrary::TryGetItem(const std::string& name, const CreatureLib::Library::Item*& item) const { - auto find = this->_items.find(name); + std::string key = name; + std::transform(key.begin(), key.end(), key.begin(), ::tolower); + auto find = this->_items.find(key); if (find == this->_items.end()) { item = nullptr; return false; @@ -12,7 +14,9 @@ bool CreatureLib::Library::ItemLibrary::TryGetItem(const std::string& name, } const CreatureLib::Library::Item* CreatureLib::Library::ItemLibrary::GetItem(const std::string& name) const { - return this->_items.at(name); + std::string key = name; + std::transform(key.begin(), key.end(), key.begin(), ::tolower); + return this->_items.at(key); } const CreatureLib::Library::Item* CreatureLib::Library::ItemLibrary::operator[](const std::string& name) const { @@ -20,7 +24,13 @@ const CreatureLib::Library::Item* CreatureLib::Library::ItemLibrary::operator[]( } void CreatureLib::Library::ItemLibrary::LoadItem(const std::string& name, const CreatureLib::Library::Item* item) { - this->_items.insert({name, item}); + std::string key = name; + std::transform(key.begin(), key.end(), key.begin(), ::tolower); + this->_items.insert({key, item}); } -void CreatureLib::Library::ItemLibrary::DeleteItem(const std::string& name) { this->_items.erase(name); } +void CreatureLib::Library::ItemLibrary::DeleteItem(const std::string& name) { + std::string key = name; + std::transform(key.begin(), key.end(), key.begin(), ::tolower); + this->_items.erase(key); +} diff --git a/src/Library/SpeciesLibrary.cpp b/src/Library/SpeciesLibrary.cpp index 4ee2958..7328a90 100644 --- a/src/Library/SpeciesLibrary.cpp +++ b/src/Library/SpeciesLibrary.cpp @@ -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); +}