From d0fbbed20d42f119b21cd7849a79efaa9cb7530d Mon Sep 17 00:00:00 2001 From: Uleat Date: Thu, 4 Aug 2016 07:09:34 -0400 Subject: [PATCH] Added a trap for Bot::GetNeedsCured() random crash (bot server admins: watch your logs!) --- zone/bot.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 14acc9b57..a3dd19b2d 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -8159,7 +8159,25 @@ bool Bot::GetNeedsCured(Mob *tar) { int buffsWithCounters = 0; needCured = true; for (unsigned int j = 0; j < buff_count; j++) { - if(tar->GetBuffs()[j].spellid != SPELL_UNKNOWN) { + // this should prevent crashes until the cause can be found + if (!tar->GetBuffs()) { + std::string mob_type = "Unknown"; + if (tar->IsClient()) + mob_type = "Client"; + else if (tar->IsBot()) + mob_type = "Bot"; + else if (tar->IsMerc()) + mob_type = "Merc"; + else if (tar->IsPet()) + mob_type = "Pet"; + else if (tar->IsNPC()) + mob_type = "NPC"; + + Log.Out(Logs::General, Logs::Error, "Bot::GetNeedsCured() processed mob type '%s' with a null buffs pointer (mob: '%s')", mob_type.c_str(), tar->GetName()); + + continue; + } + else if(tar->GetBuffs()[j].spellid != SPELL_UNKNOWN) { if(CalculateCounters(tar->GetBuffs()[j].spellid) > 0) { buffsWithCounters++; if(buffsWithCounters == 1 && (tar->GetBuffs()[j].ticsremaining < 2 || (int32)((tar->GetBuffs()[j].ticsremaining * 6) / tar->GetBuffs()[j].counters) < 2)) {