aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorn0n4m3 <none@none>2009-12-17 06:49:36 +0100
committern0n4m3 <none@none>2009-12-17 06:49:36 +0100
commit365f0ae5626f86e5a8b38b45cb2a9bdb95d6d7ad (patch)
tree03b7e236a73e6b8b4cb617861b602e7e2ed3f058
parent3e03b0aa2d7b369d7e12a9bcee81e421735c4dac (diff)
Replace some assert with return statement, fixed some crash bugs
--HG-- branch : trunk
-rw-r--r--src/game/Map.cpp17
-rw-r--r--src/game/Object.h3
-rw-r--r--src/game/Player.cpp2
-rw-r--r--src/game/Unit.cpp7
4 files changed, 21 insertions, 8 deletions
diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index 64e7e8dd4e6..53702235f7a 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -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
diff --git a/src/game/Object.h b/src/game/Object.h
index 3d07b4625e6..b068033bdf3 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -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;
}
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index d0b1a25f192..eae3418a0d7 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -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;
}
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 4b9d8f47dc7..935bd136724 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -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);