Skip to content

Commit

Permalink
CreatureEvents improvement: avoid registering with similar names, enf…
Browse files Browse the repository at this point in the history
…orce lowercase in all cases (#4817)
  • Loading branch information
ramon-bernardo authored Nov 1, 2024
1 parent cbd51af commit 99c5124
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/creatureevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool CreatureEvents::registerEvent(Event_ptr event, const pugi::xml_node&)
}

// if not, register it normally
creatureEvents.emplace(creatureEvent->getName(), std::move(*creatureEvent));
creatureEvents.emplace(boost::algorithm::to_lower_copy(creatureEvent->getName()), std::move(*creatureEvent));
return true;
}

Expand All @@ -85,13 +85,13 @@ bool CreatureEvents::registerLuaEvent(CreatureEvent* event)
}

// if not, register it normally
creatureEvents.emplace(creatureEvent->getName(), std::move(*creatureEvent));
creatureEvents.emplace(boost::algorithm::to_lower_copy(creatureEvent->getName()), std::move(*creatureEvent));
return true;
}

CreatureEvent* CreatureEvents::getEventByName(const std::string& name, bool forceLoaded /*= true*/)
{
auto it = creatureEvents.find(name);
auto it = creatureEvents.find(boost::algorithm::to_lower_copy(name));
if (it != creatureEvents.end()) {
if (!forceLoaded || it->second.isLoaded()) {
return &it->second;
Expand Down

0 comments on commit 99c5124

Please sign in to comment.