Core/Corpses: Fix a crash in ConvertCorpseForPlayer

This commit is contained in:
Machiavelli
2011-06-29 16:05:33 +02:00
parent 1bc9bb6499
commit 609efde598
2 changed files with 4 additions and 9 deletions

View File

@@ -8612,10 +8612,6 @@ void Player::RemovedInsignia(Player* looterPlr)
RepopAtGraveyard();
}
Corpse *corpse = GetCorpse();
if (!corpse)
return;
// We have to convert player corpse to bones, not to be able to resurrect there
// SpawnCorpseBones isn't handy, 'cos it saves player while he in BG
Corpse *bones = sObjectAccessor->ConvertCorpseForPlayer(GetGUID(), true);

View File

@@ -261,21 +261,20 @@ void ObjectAccessor::AddCorpsesToGrid(GridPair const& gridpair, GridType& grid,
}
}
Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia)
Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia /*=false*/)
{
Corpse* corpse = GetCorpseForPlayerGUID(player_guid);
if (!corpse)
{
//in fact this function is called from several places
//even when player doesn't have a corpse, not an error
// TODO: really, now...
//sLog->outError("Try remove corpse that not in map for GUID %ul", player_guid);
return NULL;
}
sLog->outStaticDebug("Deleting Corpse and spawned bones.");
Map* map = corpse->GetMap();
// Map can be NULL
Map* map = corpse->FindMap();
// remove corpse from player_guid -> corpse map and from current map
RemoveCorpse(corpse);
@@ -296,7 +295,7 @@ Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia
bones = new Corpse;
bones->Create(corpse->GetGUIDLow(), map);
for (uint8 i = 3; i < CORPSE_END; ++i) // don't overwrite guid and object type
for (uint8 i = OBJECT_FIELD_TYPE + 1; i < CORPSE_END; ++i) // don't overwrite guid and object type
bones->SetUInt32Value(i, corpse->GetUInt32Value(i));
bones->SetGrid(corpse->GetGrid());