[Bug Fix] NPC Faction War prevention. (#3595)

* [Bug] NPC Faction War prevention.

This should assist with prevention of NPC Faction waring. I have been using this code on my server for over 5 years with no coredumps or any noted bugs. This was brought up as users have reported a few events where they can trigger NPC's to fight each other.

* Correct a few entries to line up with updated code.

* Re-add missing RestTimer functionality
This commit is contained in:
Fryguy
2023-11-19 11:40:15 -05:00
committed by GitHub
parent c0fe0f11f7
commit f7780b0247
7 changed files with 69 additions and 63 deletions
+16 -17
View File
@@ -42,27 +42,26 @@ HateList::~HateList()
{
}
void HateList::WipeHateList()
{
void HateList::WipeHateList(bool npc_only) {
auto iterator = list.begin();
while (iterator != list.end()) {
Mob *m = (*iterator)->entity_on_hatelist;
if (m && (m->IsClient() || (m->IsPet() && m->GetOwner()->IsClient())) && npc_only) {
iterator++;
} else {
if (m) {
if (parse->HasQuestSub(hate_owner->GetNPCTypeID(), EVENT_HATE_LIST)) {
parse->EventNPC(EVENT_HATE_LIST, hate_owner->CastToNPC(), m, "0", 0);
}
while (iterator != list.end())
{
Mob* m = (*iterator)->entity_on_hatelist;
if (m)
{
if (parse->HasQuestSub(hate_owner->GetNPCTypeID(), EVENT_HATE_LIST)) {
parse->EventNPC(EVENT_HATE_LIST, hate_owner->CastToNPC(), m, "0", 0);
}
if (m->IsClient()) {
m->CastToClient()->DecrementAggroCount();
m->CastToClient()->RemoveXTarget(hate_owner, true);
if (m->IsClient()) {
m->CastToClient()->DecrementAggroCount();
m->CastToClient()->RemoveXTarget(hate_owner, true);
}
delete (*iterator);
iterator = list.erase(iterator);
}
}
delete (*iterator);
iterator = list.erase(iterator);
}
}