mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[8807] Better check playercreateinfo_action data at server startup.
This commit is contained in:
parent
413a44d114
commit
4ac1bcc37a
4 changed files with 43 additions and 15 deletions
|
|
@ -2554,8 +2554,15 @@ void ObjectMgr::LoadPlayerInfo()
|
|||
continue;
|
||||
}
|
||||
|
||||
uint8 action_button = fields[2].GetUInt8();
|
||||
uint32 action = fields[3].GetUInt32();
|
||||
uint8 action_type = fields[4].GetUInt8();
|
||||
|
||||
if (!Player::IsActionButtonDataValid(action_button,action,action_type,NULL))
|
||||
continue;
|
||||
|
||||
PlayerInfo* pInfo = &playerInfo[current_race][current_class];
|
||||
pInfo->action.push_back(PlayerCreateInfoAction(fields[2].GetUInt8(),fields[3].GetUInt32(),fields[4].GetUInt8()));
|
||||
pInfo->action.push_back(PlayerCreateInfoAction(action_button,action,action_type));
|
||||
|
||||
bar.step();
|
||||
++count;
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -1621,6 +1621,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
m_cinematic = cine;
|
||||
}
|
||||
|
||||
static bool IsActionButtonDataValid(uint8 button, uint32 action, uint8 type, Player* player);
|
||||
ActionButton* addActionButton(uint8 button, uint32 action, uint8 type);
|
||||
void removeActionButton(uint8 button);
|
||||
void SendInitialActionButtons() const;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "8806"
|
||||
#define REVISION_NR "8807"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue