[8807] Better check playercreateinfo_action data at server startup.

This commit is contained in:
VladimirMangos 2009-11-11 18:05:14 +03:00
parent 413a44d114
commit 4ac1bcc37a
4 changed files with 43 additions and 15 deletions

View file

@ -5548,18 +5548,24 @@ void Player::SendInitialActionButtons() const
sLog.outDetail( "Action Buttons for '%u' Initialized", GetGUIDLow() );
}
ActionButton* Player::addActionButton(uint8 button, uint32 action, uint8 type)
bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type, Player* player)
{
if(button >= MAX_ACTION_BUTTONS)
{
sLog.outError( "Action %u not added into button %u for player %s: button must be < 144", action, button, GetName() );
return NULL;
if (player)
sLog.outError( "Action %u not added into button %u for player %s: button must be < %u", action, button, player->GetName(), MAX_ACTION_BUTTONS );
else
sLog.outError( "Table `playercreateinfo_action` have action %u into button %u : button must be < %u", action, button, MAX_ACTION_BUTTONS );
return false;
}
if(action >= MAX_ACTION_BUTTON_ACTION_VALUE)
{
sLog.outError( "Action %u not added into button %u for player %s: action must be < %u", action, button, GetName(), MAX_ACTION_BUTTON_ACTION_VALUE );
return NULL;
if (player)
sLog.outError( "Action %u not added into button %u for player %s: action must be < %u", action, button, player->GetName(), MAX_ACTION_BUTTON_ACTION_VALUE );
else
sLog.outError( "Table `playercreateinfo_action` have action %u into button %u : action must be < %u", action, button, MAX_ACTION_BUTTON_ACTION_VALUE );
return false;
}
switch(type)
@ -5567,27 +5573,41 @@ ActionButton* Player::addActionButton(uint8 button, uint32 action, uint8 type)
case ACTION_BUTTON_SPELL:
if(!sSpellStore.LookupEntry(action))
{
sLog.outError( "Action %u not added into button %u for player %s: spell not exist", action, button, GetName() );
return NULL;
if (player)
sLog.outError( "Spell action %u not added into button %u for player %s: spell not exist", action, button, player->GetName() );
else
sLog.outError( "Table `playercreateinfo_action` have spell action %u into button %u: spell not exist", action, button );
return false;
}
if(!HasSpell(action))
if(player && !player->HasSpell(action))
{
sLog.outError( "Action %u not added into button %u for player %s: player don't known this spell", action, button, GetName() );
return NULL;
sLog.outError( "Spell action %u not added into button %u for player %s: player don't known this spell", action, button, player->GetName() );
return false;
}
break;
case ACTION_BUTTON_ITEM:
if(!ObjectMgr::GetItemPrototype(action))
{
sLog.outError( "Action %u not added into button %u for player %s: item not exist", action, button, GetName() );
return NULL;
if (player)
sLog.outError( "Item action %u not added into button %u for player %s: item not exist", action, button, player->GetName() );
else
sLog.outError( "Table `playercreateinfo_action` have item action %u into button %u: item not exist", action, button );
return false;
}
break;
default:
break; // pther cases not checked at this moment
break; // other cases not checked at this moment
}
return true;
}
ActionButton* Player::addActionButton(uint8 button, uint32 action, uint8 type)
{
if (!IsActionButtonDataValid(button,action,type,this))
return NULL;
// it create new button (NEW state) if need or return existed
ActionButton& ab = m_actionButtons[button];