mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
- Code optimalizations
This commit is contained in:
@@ -93,18 +93,26 @@ bool CastSpiritWalkAction::Execute(Event event)
|
||||
|
||||
bool SetTotemAction::Execute(Event event)
|
||||
{
|
||||
size_t spellIdsCount = sizeof(totemSpellIds) / sizeof(uint32);
|
||||
const size_t spellIdsCount = sizeof(totemSpellIds) / sizeof(uint32);
|
||||
if (spellIdsCount == 0)
|
||||
return false; // early return
|
||||
|
||||
uint32 totemSpell = 0;
|
||||
for (int i = (int)spellIdsCount - 1; i >= 0; --i)
|
||||
|
||||
// Iterate backwards due signed/unsigned int
|
||||
for (size_t i = spellIdsCount; i-- > 0;)
|
||||
{
|
||||
if (bot->HasSpell(totemSpellIds[i]))
|
||||
const uint32 spellId = totemSpellIds[i];
|
||||
if (bot->HasSpell(spellId))
|
||||
{
|
||||
totemSpell = totemSpellIds[i];
|
||||
totemSpell = spellId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!totemSpell)
|
||||
|
||||
if (totemSpell == 0)
|
||||
return false;
|
||||
|
||||
bot->addActionButton(actionButtonId, totemSpell, ACTION_BUTTON_SPELL);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -424,6 +424,7 @@ bool SetTotemTrigger::IsActive()
|
||||
{
|
||||
if (!bot->HasSpell(SPELL_CALL_OF_THE_ELEMENTS))
|
||||
return false;
|
||||
|
||||
if (!bot->HasSpell(requiredSpellId))
|
||||
return false;
|
||||
|
||||
@@ -431,14 +432,18 @@ bool SetTotemTrigger::IsActive()
|
||||
if (!button || button->GetType() != ACTION_BUTTON_SPELL || button->GetAction() == 0)
|
||||
return true;
|
||||
|
||||
size_t totemSpellIdsCount = sizeof(totemSpellIds) / sizeof(uint32);
|
||||
for (int i = (int)totemSpellIdsCount - 1; i >= 0; --i)
|
||||
|
||||
const size_t totemSpellIdsCount = sizeof(totemSpellIds) / sizeof(uint32);
|
||||
if (totemSpellIdsCount == 0)
|
||||
{
|
||||
if (bot->HasSpell(totemSpellIds[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = (int)totemSpellIdsCount - 1; i >= 0; --i)
|
||||
{
|
||||
const uint32 spellId = totemSpellIds[i];
|
||||
if (bot->HasSpell(spellId))
|
||||
{
|
||||
return button->GetAction() != totemSpellIds[i];
|
||||
return button->GetAction() != spellId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user