*Fix a frequent crash caused by wintergrasp. Thanks to drahy.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-28 20:04:46 -05:00
parent dc5c054ab9
commit 594a1f8a36
+13 -12
View File
@@ -357,6 +357,8 @@ void OPvPWintergrasp::OnCreatureCreate(Creature *creature, bool add)
return;
TeamId team;
if(add)
{
if(creature->getFaction() == WintergraspFaction[TEAM_ALLIANCE])
team = TEAM_ALLIANCE;
else if(creature->getFaction() == WintergraspFaction[TEAM_HORDE])
@@ -367,8 +369,6 @@ void OPvPWintergrasp::OnCreatureCreate(Creature *creature, bool add)
if(uint32 engLowguid = GUID_LOPART(((TempSummon*)creature)->GetSummonerGUID()))
{
if(SiegeWorkshop *workshop = GetWorkshopByEngGuid(engLowguid))
{
if(add)
{
if(CanBuildVehicle(workshop))
{
@@ -382,17 +382,8 @@ void OPvPWintergrasp::OnCreatureCreate(Creature *creature, bool add)
return;
}
}
// TODO: now you have to wait until the corpse of vehicle disappear to build a new one
else
{
m_vehicles[team].erase(creature);
//if(!workshop->m_vehicles.erase(creature))
// sLog.outError("OPvPWintergrasp::OnCreatureCreate: a vehicle is removed but it does not have record in workshop!");
}
}
}
if(add)
{
if(m_tenacityStack > 0)
{
if(team == TEAM_ALLIANCE)
@@ -404,6 +395,16 @@ void OPvPWintergrasp::OnCreatureCreate(Creature *creature, bool add)
creature->SetAuraStack(SPELL_TENACITY_VEHICLE, creature, -m_tenacityStack);
}
}
else // the faction may be changed in uncharm
{
// TODO: now you have to wait until the corpse of vehicle disappear to build a new one
if(m_vehicles[TEAM_ALLIANCE].erase(creature))
team = TEAM_ALLIANCE;
else if(m_vehicles[TEAM_HORDE].erase(creature))
team = TEAM_HORDE;
else
return;
}
SendUpdateWorldState(VehNumWorldState[team], m_vehicles[team].size());
break;
}