[Doors] Have NPCs trigger double doors (#2821)

This commit is contained in:
Chris Miles 2023-02-06 17:47:03 -06:00 committed by GitHub
parent 2b224d42ad
commit 0a114fae9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 1 deletions

View File

@ -770,3 +770,16 @@ int Strings::ToInt(const std::string &s, int fallback)
{
return Strings::IsNumber(s) ? std::stoi(s) : fallback;
}
std::string Strings::RemoveNumbers(std::string s)
{
int current = 0;
for (int i = 0; i < s.length(); i++) {
if (!isdigit(s[i])) {
s[current] = s[i];
current++;
}
}
return s.substr(0, current);
}

View File

@ -88,6 +88,7 @@ public:
static bool Contains(const std::string& subject, const std::string& search);
static int ToInt(const std::string &s, int fallback = 0);
static bool IsNumber(const std::string &s);
static std::string RemoveNumbers(std::string s);
static bool IsFloat(const std::string &s);
static const std::string ToLower(std::string s);
static const std::string ToUpper(std::string s);

View File

@ -999,7 +999,13 @@ void Mob::AI_Process() {
}
if (door->GetTriggerDoorID() > 0) {
continue;
auto trigger_door = entity_list.GetDoorsByDoorID(door->GetTriggerDoorID());
if (trigger_door) {
if (Strings::RemoveNumbers(door->GetDoorName()) !=
Strings::RemoveNumbers(trigger_door->GetDoorName())) {
continue;
}
}
}
if (door->GetDoorParam() > 0) {