Remove unnecessary return in CanBuffStack, cleanup

This commit is contained in:
nytmyr
2025-01-26 22:40:57 -06:00
parent b84ccab24a
commit 65b2fa3533
+23 -8
View File
@@ -3840,41 +3840,56 @@ int Mob::CanBuffStack(uint16 spellid, uint8 caster_level, bool iFailIfOverwrite)
if (!IsValidSpell(curbuf.spellid)) if (!IsValidSpell(curbuf.spellid))
{ {
// if we haven't found a free slot, this is the first one so save it // if we haven't found a free slot, this is the first one so save it
if(firstfree == -2) if (firstfree == -2) {
firstfree = i; firstfree = i;
}
continue; continue;
} }
if (IsBot() && (GetClass() == Class::Bard) && curbuf.spellid == spellid && curbuf.ticsremaining == 0 && curbuf.casterid == GetID()) { if (
IsBot() &&
GetClass() == Class::Bard &&
curbuf.spellid == spellid &&
curbuf.ticsremaining == 0 &&
curbuf.casterid == GetID()
) {
LogAI("Bard check for song, spell [{}] has [{}] ticks remaining.", spellid, curbuf.ticsremaining); LogAI("Bard check for song, spell [{}] has [{}] ticks remaining.", spellid, curbuf.ticsremaining);
firstfree = i; firstfree = i;
return firstfree;
} }
else { else {
if (curbuf.spellid == spellid) if (curbuf.spellid == spellid) {
return(-1); //do not recast a buff we already have on, we recast fast enough that we dont need to refresh our buffs return(-1); //do not recast a buff we already have on, we recast fast enough that we dont need to refresh our buffs
} }
}
// there's a buff in this slot // there's a buff in this slot
ret = CheckStackConflict(curbuf.spellid, curbuf.casterlevel, spellid, caster_level, nullptr, nullptr, i); ret = CheckStackConflict(curbuf.spellid, curbuf.casterlevel, spellid, caster_level, nullptr, nullptr, i);
if(ret == 1) {
if (ret == 1) {
// should overwrite current slot // should overwrite current slot
if(iFailIfOverwrite) { if (iFailIfOverwrite) {
LogAIDetail("Buff [{}] would overwrite [{}] in slot [{}], reporting stack failure", spellid, curbuf.spellid, i); LogAIDetail("Buff [{}] would overwrite [{}] in slot [{}], reporting stack failure", spellid, curbuf.spellid, i);
return(-1); return(-1);
} }
if(firstfree == -2)
if (firstfree == -2) {
firstfree = i; firstfree = i;
} }
if(ret == -1) { }
if(ret == -1) {
LogAIDetail("Buff [{}] would conflict with [{}] in slot [{}], reporting stack failure", spellid, curbuf.spellid, i); LogAIDetail("Buff [{}] would conflict with [{}] in slot [{}], reporting stack failure", spellid, curbuf.spellid, i);
return -1; // stop the spell, can't stack it return -1; // stop the spell, can't stack it
} }
if (ret == 2) { //ResurrectionEffectBlock handling to move potential overwrites to a new buff slock while keeping Res Sickness if (ret == 2) { //ResurrectionEffectBlock handling to move potential overwrites to a new buff slock while keeping Res Sickness
LogAIDetail("Adding buff [{}] will overwrite spell [{}] in slot [{}] with caster level [{}], but ResurrectionEffectBlock is set to 2. Attempting to move [{}] to an empty buff slot.", LogAIDetail("Adding buff [{}] will overwrite spell [{}] in slot [{}] with caster level [{}], but ResurrectionEffectBlock is set to 2. Attempting to move [{}] to an empty buff slot.",
spellid, curbuf.spellid, i, curbuf.casterlevel, spellid); spellid, curbuf.spellid, i, curbuf.casterlevel, spellid);
for (int x = 0; x < buff_count; x++) { for (int x = 0; x < buff_count; x++) {
const Buffs_Struct& curbuf = buffs[x]; const Buffs_Struct& curbuf = buffs[x];
if (IsValidSpell(curbuf.spellid)) { if (IsValidSpell(curbuf.spellid)) {
continue; continue;
} }