Replace some assert with return statement, fixed some crash bugs

--HG--
branch : trunk
This commit is contained in:
n0n4m3
2009-12-17 06:49:36 +01:00
parent 3e03b0aa2d
commit 365f0ae562
4 changed files with 21 additions and 8 deletions
+13 -4
View File
@@ -683,11 +683,20 @@ void Map::RemoveUnitFromNotify(Unit *unit)
else if(slot < i_unitsToNotify.size() && i_unitsToNotify[slot] == unit)
i_unitsToNotify[slot] = NULL;
else
assert(false);
{
sLog.outError("Map::RemoveUnitFromNotify(Unit*) unit has incorrect notify slot=%d, cleaning up",slot);
unit->m_NotifyListPos = -1;
return;
}
}
else
{
assert(slot < i_unitsToNotify.size());
if(slot >= i_unitsToNotify.size())
{
sLog.outError("Map::RemoveUnitFromNotify(Unit*) unit has incorrect notify slot=%d, cleaning up", slot);
unit->m_NotifyListPos = -1;
return;
}
i_unitsToNotify[slot] = NULL;
}
@@ -2584,7 +2593,7 @@ bool InstanceMap::Add(Player *player)
if(playerBind->save != mapSave)
{
sLog.outError("InstanceMap::Add: player %s(%d) is permanently bound to instance %d,%d,%d,%d,%d,%d but he is being put in instance %d,%d,%d,%d,%d,%d", player->GetName(), player->GetGUIDLow(), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(), playerBind->save->CanReset(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->GetPlayerCount(), mapSave->GetGroupCount(), mapSave->CanReset());
assert(false);
return false;
}
}
else
@@ -2618,7 +2627,7 @@ bool InstanceMap::Add(Player *player)
sLog.outError("GroupBind save players: %d, group count: %d", groupBind->save->GetPlayerCount(), groupBind->save->GetGroupCount());
else
sLog.outError("GroupBind save NULL");
assert(false);
return false;
}
// if the group/leader is permanently bound to the instance
// players also become permanently bound when they enter
+2 -1
View File
@@ -237,7 +237,8 @@ class TRINITY_DLL_SPEC Object
bool HasFlag( uint16 index, uint32 flag ) const
{
ASSERT( index < m_valuesCount || PrintIndexError( index , false ) );
if(index >= m_valuesCount && !PrintIndexError(index , false))
return false;
return (m_uint32Values[ index ] & flag) != 0;
}
+1 -1
View File
@@ -1148,7 +1148,7 @@ void Player::Update( uint32 p_time )
//sLog.outCrash("Player has m_pad %u during update!", m_pad);
//if(m_spellModTakingSpell)
sLog.outCrash("Player has m_spellModTakingSpell %u during update!", m_spellModTakingSpell->m_spellInfo->Id);
assert(false);
return;
m_spellModTakingSpell = NULL;
}
+5 -2
View File
@@ -4481,7 +4481,9 @@ GameObject* Unit::GetGameObject(uint32 spellId) const
void Unit::AddGameObject(GameObject* gameObj)
{
assert(gameObj && gameObj->GetOwnerGUID()==0);
if(!gameObj || !gameObj->GetOwnerGUID()==0)
return;
m_gameObj.push_back(gameObj);
gameObj->SetOwnerGUID(GetGUID());
@@ -4497,7 +4499,8 @@ void Unit::AddGameObject(GameObject* gameObj)
void Unit::RemoveGameObject(GameObject* gameObj, bool del)
{
assert(gameObj && gameObj->GetOwnerGUID()==GetGUID());
if(!gameObj || !gameObj->GetOwnerGUID()==GetGUID())
return;
gameObj->SetOwnerGUID(0);