crash fix

This commit is contained in:
tomrus88 2008-11-16 17:04:27 +03:00
parent 681cc6ecf4
commit 4e76f1ac98
7 changed files with 32 additions and 20 deletions

Binary file not shown.

View file

@ -692,7 +692,7 @@ Map::Remove(T *obj, bool remove)
CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP )
{ {
sLog.outError("Map::Remove: Object " I64FMTD " have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); sLog.outError("Map::Remove: Object " I64FMT " have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
return; return;
} }
@ -700,7 +700,7 @@ Map::Remove(T *obj, bool remove)
if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) ) if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) )
return; return;
DEBUG_LOG("Remove object " I64FMTD " from grid[%u,%u]", obj->GetGUID(), cell.data.Part.grid_x, cell.data.Part.grid_y); DEBUG_LOG("Remove object " I64FMT " from grid[%u,%u]", obj->GetGUID(), cell.data.Part.grid_x, cell.data.Part.grid_y);
NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); NGridType *grid = getNGrid(cell.GridX(), cell.GridY());
assert( grid != NULL ); assert( grid != NULL );
@ -954,7 +954,7 @@ bool Map::UnloadGrid(const uint32 &x, const uint32 &y, bool pForce)
if (i_InstanceId == 0) if (i_InstanceId == 0)
{ {
if(GridMaps[gx][gy]) delete (GridMaps[gx][gy]); if(GridMaps[gx][gy]) delete (GridMaps[gx][gy]);
// x and y are swaped // x and y are swapped
VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(GetId(), gy, gx); VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(GetId(), gy, gx);
} }
else else

View file

@ -364,7 +364,7 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
data.append(recv_data.contents(), recv_data.size()); data.append(recv_data.contents(), recv_data.size());
GetPlayer()->SendMessageToSet(&data, false); GetPlayer()->SendMessageToSet(&data, false);
if(!_player->GetCharmGUID()) if(!_player->GetCharmGUID()) // nothing is charmed
{ {
_player->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o); _player->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
_player->m_movementInfo = movementInfo; _player->m_movementInfo = movementInfo;
@ -372,12 +372,13 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
} }
else else
{ {
if(mover->GetTypeId() != TYPEID_PLAYER) if(mover->GetTypeId() != TYPEID_PLAYER) // unit, creature, pet, vehicle...
{ {
mover->Relocate(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o); if(Map *map = mover->GetMap())
map->CreatureRelocation((Creature*)mover, movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
mover->SetUnitMovementFlags(MovementFlags); mover->SetUnitMovementFlags(MovementFlags);
} }
else else // player
{ {
((Player*)mover)->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o); ((Player*)mover)->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
((Player*)mover)->m_movementInfo = movementInfo; ((Player*)mover)->m_movementInfo = movementInfo;

View file

@ -517,7 +517,7 @@ void Pet::Update(uint32 diff)
{ {
// unsummon pet that lost owner // unsummon pet that lost owner
Unit* owner = GetOwner(); Unit* owner = GetOwner();
if(!owner || !IsWithinDistInMap(owner, OWNER_MAX_DISTANCE) || isControlled() && !owner->GetPetGUID()) if(!owner || (!IsWithinDistInMap(owner, OWNER_MAX_DISTANCE) && (owner->GetCharmGUID() && (owner->GetCharmGUID() != GetGUID()))) || (isControlled() && !owner->GetPetGUID()))
{ {
Remove(PET_SAVE_NOT_IN_SLOT, true); Remove(PET_SAVE_NOT_IN_SLOT, true);
return; return;

View file

@ -1222,7 +1222,7 @@ void Player::Update( uint32 p_time )
SendUpdateToOutOfRangeGroupMembers(); SendUpdateToOutOfRangeGroupMembers();
Pet* pet = GetPet(); Pet* pet = GetPet();
if(pet && !IsWithinDistInMap(pet, OWNER_MAX_DISTANCE)) if(pet && !IsWithinDistInMap(pet, OWNER_MAX_DISTANCE) && (GetCharmGUID() && (pet->GetGUID() != GetCharmGUID())))
{ {
RemovePet(pet, PET_SAVE_NOT_IN_SLOT, true); RemovePet(pet, PET_SAVE_NOT_IN_SLOT, true);
return; return;
@ -15889,8 +15889,8 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent)
m_guardianPets.erase(pet->GetGUID()); m_guardianPets.erase(pet->GetGUID());
break; break;
default: default:
if(GetPetGUID()==pet->GetGUID()) if(GetPetGUID() == pet->GetGUID())
SetPet(0); SetPet(NULL);
break; break;
} }

View file

@ -2983,19 +2983,30 @@ void Aura::HandleModPossessPet(bool apply, bool Real)
return; return;
Unit* caster = GetCaster(); Unit* caster = GetCaster();
if(!caster || caster->GetTypeId() != TYPEID_PLAYER) Pet *pet = caster->GetPet();
return; if(!pet || (pet != m_target) || !caster || (caster->GetTypeId() != TYPEID_PLAYER))
if(caster->GetPet() != m_target)
return; return;
if(apply) if(apply)
m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNKNOWN5); pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNKNOWN5);
else else
m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNKNOWN5); pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNKNOWN5);
((Player*)caster)->SetFarSight(apply ? m_target->GetGUID() : NULL); ((Player*)caster)->SetFarSight(apply ? pet->GetGUID() : NULL);
((Player*)caster)->SetCharm(apply ? m_target : NULL); ((Player*)caster)->SetCharm(apply ? pet : NULL);
((Player*)caster)->SetClientControl(m_target, apply ? 1 : 0); ((Player*)caster)->SetClientControl(pet, apply ? 1 : 0);
if(apply)
{
pet->StopMoving();
pet->GetMotionMaster()->Clear();
pet->GetMotionMaster()->MoveIdle();
}
else
{
pet->AttackStop();
pet->GetMotionMaster()->MoveFollow(caster, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
}
} }
void Aura::HandleModCharm(bool apply, bool Real) void Aura::HandleModCharm(bool apply, bool Real)

View file

@ -4133,7 +4133,7 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode)
m_Auras.erase(i); m_Auras.erase(i);
++m_removedAuras; // internal count used by unit update ++m_removedAuras; // internal count used by unit update
// Status unsummoned at aura remove // Statue unsummoned at aura remove
Totem* statue = NULL; Totem* statue = NULL;
if(IsChanneledSpell(Aur->GetSpellProto())) if(IsChanneledSpell(Aur->GetSpellProto()))
if(Unit* caster = Aur->GetCaster()) if(Unit* caster = Aur->GetCaster())