Check wrong slot/skill to avoid leaks

This commit is contained in:
Eduardo Bart 2012-06-25 20:48:36 -03:00
parent 472e78d368
commit 16d4729f06
1 changed files with 10 additions and 0 deletions

View File

@ -202,6 +202,11 @@ void LocalPlayer::setStates(int states)
void LocalPlayer::setSkill(Otc::Skill skill, int level, int levelPercent)
{
if(skill >= Otc::LastSkill) {
g_logger.traceError("invalid skill");
return;
}
int oldLevel = m_skillsLevel[skill];
int oldLevelPercent = m_skillsLevelPercent[skill];
@ -310,6 +315,11 @@ void LocalPlayer::setStamina(double stamina)
void LocalPlayer::setInventoryItem(Otc::Inventory inventory, const ItemPtr& item)
{
if(inventory >= Otc::LastInventory) {
g_logger.traceError("invalid slot");
return;
}
if(m_inventoryItems[inventory] != item) {
ItemPtr oldItem = m_inventoryItems[inventory];
m_inventoryItems[inventory] = item;