本文整理汇总了C++中Corpse::Create方法的典型用法代码示例。如果您正苦于以下问题:C++ Corpse::Create方法的具体用法?C++ Corpse::Create怎么用?C++ Corpse::Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Corpse
的用法示例。
在下文中一共展示了Corpse::Create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertCorpseForPlayer
Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia)
{
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
//sLog->outError("Try remove corpse that not in map for GUID %ul", player_guid);
return NULL;
}
sLog->outDebug("Deleting Corpse and spawned bones.");
Map *map = corpse->FindMap();
// remove corpse from player_guid -> corpse map
RemoveCorpse(corpse);
// done in removecorpse
// remove resurrectable corpse from grid object registry (loaded state checked into call)
// do not load the map if it's not loaded
//Map *map = sMapMgr->FindMap(corpse->GetMapId(), corpse->GetInstanceId());
//if (map)
// map->Remove(corpse, false);
// remove corpse from DB
corpse->DeleteFromDB();
Corpse* bones = NULL;
// create the bones only if the map and the grid is loaded at the corpse's location
// ignore bones creating option in case insignia
if (map && (insignia ||
(map->IsBattleGroundOrArena() ? sWorld->getConfig(CONFIG_DEATH_BONES_BG_OR_ARENA) : sWorld->getConfig(CONFIG_DEATH_BONES_WORLD))) &&
!map->IsRemovalGrid(corpse->GetPositionX(), corpse->GetPositionY()))
{
// Create bones, don't change Corpse
bones = new Corpse;
bones->Create(corpse->GetGUIDLow(), map);
for (int i = 3; i < CORPSE_END; ++i) // don't overwrite guid and object type
bones->SetUInt32Value(i, corpse->GetUInt32Value(i));
bones->SetGrid(corpse->GetGrid());
// bones->m_time = m_time; // don't overwrite time
// bones->m_inWorld = m_inWorld; // don't overwrite in-world state
// bones->m_type = m_type; // don't overwrite type
bones->Relocate(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetOrientation());
bones->SetUInt32Value(CORPSE_FIELD_FLAGS, CORPSE_FLAG_UNK2 | CORPSE_FLAG_BONES);
bones->SetUInt64Value(CORPSE_FIELD_OWNER, 0);
for (int i = 0; i < EQUIPMENT_SLOT_END; ++i)
{
if (corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i))
bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0);
}
// add bones in grid store if grid loaded where corpse placed
map->Add(bones);
}
// all references to the corpse should be removed at this point
delete corpse;
return bones;
}
示例2: ConvertCorpseForPlayer
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
return NULL;
}
TC_LOG_DEBUG("misc", "Deleting Corpse and spawned bones.");
// Map can be NULL
Map* map = corpse->FindMap();
// remove corpse from player_guid -> corpse map and from current map
RemoveCorpse(corpse);
// remove corpse from DB
SQLTransaction trans = CharacterDatabase.BeginTransaction();
corpse->DeleteFromDB(trans);
CharacterDatabase.CommitTransaction(trans);
Corpse* bones = nullptr;
// create the bones only if the map and the grid is loaded at the corpse's location
// ignore bones creating option in case insignia
if (map && (insignia ||
(map->IsBattlegroundOrArena() ? sWorld->getBoolConfig(CONFIG_DEATH_BONES_BG_OR_ARENA) : sWorld->getBoolConfig(CONFIG_DEATH_BONES_WORLD))) &&
!map->IsRemovalGrid(corpse->GetPositionX(), corpse->GetPositionY()))
{
// Create bones, don't change Corpse
bones = new Corpse;
bones->Create(corpse->GetGUIDLow(), map);
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->SetGridCoord(corpse->GetGridCoord());
// bones->m_time = m_time; // don't overwrite time
// bones->m_type = m_type; // don't overwrite type
bones->Relocate(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetOrientation());
bones->CopyPhaseFrom(corpse);
bones->SetUInt32Value(CORPSE_FIELD_FLAGS, CORPSE_FLAG_UNK2 | CORPSE_FLAG_BONES);
bones->SetUInt64Value(CORPSE_FIELD_OWNER, 0);
for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
{
if (corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i))
bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0);
}
// add bones in grid store if grid loaded where corpse placed
map->AddToMap(bones);
}
// all references to the corpse should be removed at this point
delete corpse;
return bones;
}
示例3: _HandleUpdateObjectOpcode
void WorldSession::_HandleUpdateObjectOpcode(WorldPacket& recvPacket)
{
uint8 utype;
//uint8 hasTransport;
uint32 usize, ublocks, readblocks=0;
uint64 uguid;
recvPacket >> ublocks; // >> hasTransport;
//logdev("UpdateObject: blocks = %u, hasTransport = %u", ublocks, hasTransport);
logdev("UpdateObject: blocks = %u", ublocks);
while((recvPacket.rpos() < recvPacket.size())&& (readblocks < ublocks))
{
recvPacket >> utype;
switch(utype)
{
case UPDATETYPE_VALUES:
{
uguid = recvPacket.GetPackedGuid();
_ValuesUpdate(uguid,recvPacket);
}
break;
case UPDATETYPE_MOVEMENT:
{
recvPacket >> uguid; // the guid is NOT packed here!
uint8 tyid;
Object *obj = objmgr.GetObj(uguid, true); // here we update also depleted objects, its just safer
if(obj)
tyid = obj->GetTypeId();
else // sometimes objects get deleted BEFORE a last update packet arrives, this must be handled also
{
tyid = GetTypeIdByGuid(uguid);
logerror("Got UpdateObject_Movement for unknown object "I64FMT". Using typeid %u",uguid,(uint32)tyid);
}
if(obj)
this->_MovementUpdate(tyid,uguid,recvPacket);
}
break;
case UPDATETYPE_CREATE_OBJECT2: // will be sent when our very own character is created
case UPDATETYPE_CREATE_OBJECT: // will be sent on any other object creation
{
uguid = recvPacket.GetPackedGuid();
uint8 objtypeid;
recvPacket >> objtypeid;
logdebug("Create Object type %u with guid "I64FMT,objtypeid,uguid);
// dont create objects if already present in memory.
// recreate every object except ourself!
if(objmgr.GetObj(uguid))
{
if(uguid != GetGuid())
{
logdev("- already exists, deleting old, creating new object");
objmgr.Remove(uguid, false);
// do not call script here, since the object does not really get deleted
}
else
{
logdev("- already exists, but not deleted (has our current GUID)");
}
}
// only if the obj didnt exist or was just deleted above, create it....
if(!objmgr.GetObj(uguid))
{
switch(objtypeid)
{
case TYPEID_OBJECT: // no data to read
{
logerror("Recieved wrong UPDATETYPE_CREATE_OBJECT to create Object base type!");
logerror("%s",toHexDump((uint8*)recvPacket.contents(),recvPacket.size(),true).c_str());
}
case TYPEID_ITEM:
{
Item *item = new Item();
item->Create(uguid);
objmgr.Add(item);
break;
}
case TYPEID_CONTAINER:
{
Bag *bag = new Bag();
bag->Create(uguid);
objmgr.Add(bag);
break;
}
case TYPEID_UNIT:
{
Unit *unit = new Unit();
unit->Create(uguid);
objmgr.Add(unit);
break;
}
case TYPEID_PLAYER:
{
if(GetGuid() == uguid) // objmgr.Add() would cause quite some trouble if we added ourself again
break;
Player *player = new Player();
player->Create(uguid);
objmgr.Add(player);
//.........这里部分代码省略.........