本文整理汇总了C++中Creature::AddObjectToRemoveList方法的典型用法代码示例。如果您正苦于以下问题:C++ Creature::AddObjectToRemoveList方法的具体用法?C++ Creature::AddObjectToRemoveList怎么用?C++ Creature::AddObjectToRemoveList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Creature
的用法示例。
在下文中一共展示了Creature::AddObjectToRemoveList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DelCreature
bool OutdoorPvPObjective::DelCreature(uint32 type)
{
if(!m_Creatures[type])
{
sLog.outDebug("OutdoorPvPObjective: creature type %u was already deleted",type);
return false;
}
Creature *cr = HashMapHolder<Creature>::Find(m_Creatures[type]);
if(!cr)
{
sLog.outError("OutdoorPvPObjective: Can't find creature guid: %u", GUID_LOPART(m_Creatures[type]));
return false;
}
sLog.outDebug("OutdoorPvPObjective: deleting creature type %u", type);
uint32 guid = cr->GetDBTableGUIDLow();
// dont save respawn time
// delete respawn time for this creature
WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE guid = '%u'", guid);
cr->AddObjectToRemoveList();
objmgr.DeleteCreatureData(guid); // i think this is needed, cause the data gets created through a hack
m_CreatureTypes[m_Creatures[type]] = 0;
m_Creatures[type] = 0;
return true;
}
示例2: DelCapturePoint
bool OutdoorPvPObjective::DelCapturePoint()
{
Map* map = m_PvP->GetMap();
if (m_CapturePoint)
{
GameObject *obj = map->GetGameObject(m_CapturePoint);
if (obj)
{
obj->SetRespawnTime(0); // not save respawn time
obj->Delete();
}
m_CapturePoint = 0;
}
if (m_CapturePointCreature)
{
Creature *cr = map->GetCreature(m_CapturePointCreature);
if (cr)
cr->AddObjectToRemoveList();
m_CapturePointCreature = 0;
}
return true;
}
示例3: DelCreature
bool OPvPCapturePoint::DelCreature(uint32 type)
{
if(!m_Creatures[type])
{
sLog.outDebug("opvp creature type %u was already deleted",type);
return false;
}
Creature* cr = sMapMgr.FindMap(530)->GetCreature(m_Creatures[type]);
if(!cr)
{
// can happen when closing the core
m_Creatures[type] = 0;
return false;
}
sLog.outDebug("deleting opvp creature type %u",type);
uint32 guid = cr->GetDBTableGUIDLow();
// Don't save respawn time
cr->SetRespawnTime(0);
cr->RemoveCorpse();
// explicit removal from map
// beats me why this is needed, but with the recent removal "cleanup" some creatures stay in the map if "properly" deleted
// so this is a big fat workaround, if AddObjectToRemoveList and DoDelayedMovesAndRemoves worked correctly, this wouldn't be needed
//if(Map * map = MapManager::Instance().FindMap(cr->GetMapId()))
// map->Remove(cr,false);
// delete respawn time for this creature
WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE guid = '%u'", guid);
cr->AddObjectToRemoveList();
sObjectMgr.DeleteCreatureData(guid);
m_CreatureTypes[m_Creatures[type]] = 0;
m_Creatures[type] = 0;
return true;
}
示例4: HandleNpcBotDeleteCommand
static bool HandleNpcBotDeleteCommand(ChatHandler* handler, const char* /*args*/)
{
Player* chr = handler->GetSession()->GetPlayer();
Unit* ubot = chr->GetSelectedUnit();
if (!ubot)
{
handler->SendSysMessage(".npcbot delete");
handler->SendSysMessage("Deletes selected npcbot spawn from world and DB");
handler->SetSentErrorMessage(true);
return false;
}
Creature* bot = ubot->ToCreature();
if (!bot || !bot->IsNPCBot())
{
handler->SendSysMessage("No npcbot selected");
handler->SetSentErrorMessage(true);
return false;
}
if (Player* botowner = bot->GetBotOwner()->ToPlayer())
botowner->GetBotMgr()->RemoveBot(bot->GetGUID(), BOT_REMOVE_DISMISS);
uint32 id = bot->GetEntry();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_NPCBOT_EQUIP);
//"SELECT equipMhEx, equipOhEx, equipRhEx, equipHead, equipShoulders, equipChest, equipWaist, equipLegs, equipFeet, equipWrist, equipHands, equipBack, equipBody, equipFinger1, equipFinger2, equipTrinket1, equipTrinket2, equipNeck
//FROM characters_npcbot WHERE entry = ?", CONNECTION_SYNCH
stmt->setUInt32(0, id);
PreparedQueryResult res = CharacterDatabase.Query(stmt);
ASSERT(res);
Field* fields = res->Fetch();
for (uint8 i = 0; i != BOT_INVENTORY_SIZE; ++i)
{
if (fields[i].GetUInt32())
{
handler->PSendSysMessage("%s still has eqipment assigned. Please remove equips before deleting bot!", bot->GetName().c_str());
handler->SetSentErrorMessage(true);
return false;
}
}
bot->CombatStop();
bot->DeleteFromDB();
bot->AddObjectToRemoveList();
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_NPCBOT);
//"DELETE FROM characters_npcbot WHERE entry = ?", CONNECTION_ASYNC
stmt->setUInt32(0, id);
CharacterDatabase.Execute(stmt);
handler->SendSysMessage("Npcbot successfully deleted.");
return true;
}
示例5: DelCreature
bool BattleGround::DelCreature(uint32 type)
{
Creature *cr = HashMapHolder<Creature>::Find(m_BgCreatures[type]);
if(!cr)
{
sLog.outError("Can't find creature guid: %u",m_BgCreatures[type]);
return false;
}
cr->CleanupsBeforeDelete();
cr->AddObjectToRemoveList();
m_BgCreatures[type] = 0;
return true;
}
示例6: SpawnBGCreature
/*
void BattleGround::SpawnBGCreature(uint32 type, uint32 respawntime)
{
Map * map = MapManager::Instance().FindMap(GetMapId(),GetInstanceId());
if(!map)
return false;
if(respawntime == 0)
{
Creature *obj = HashMapHolder<Creature>::Find(m_BgCreatures[type]);
if(obj)
{
//obj->Respawn(); // bugged
obj->SetRespawnTime(0);
objmgr.SaveCreatureRespawnTime(obj->GetGUIDLow(), GetInstanceID(), 0);
map->Add(obj);
}
}
else
{
Creature *obj = HashMapHolder<Creature>::Find(m_BgCreatures[type]);
if(obj)
{
obj->setDeathState(DEAD);
obj->SetRespawnTime(respawntime);
map->Add(obj);
}
}
}
*/
bool BattleGround::DelCreature(uint32 type)
{
Creature *cr = HashMapHolder<Creature>::Find(m_BgCreatures[type]);
if(!cr)
{
sLog.outError("Can't find creature guid: %u",GUID_LOPART(m_BgCreatures[type]));
return false;
}
//TODO: only delete creature after not in combat
cr->CleanupsBeforeDelete();
cr->AddObjectToRemoveList();
m_BgCreatures[type] = 0;
return true;
}
示例7: HandleNpcDeleteCommand
static bool HandleNpcDeleteCommand(ChatHandler* handler, const char* args) {
Creature* unit = NULL;
if (*args) {
// number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r
char* cId = handler->extractKeyFromLink((char*) args, "Hcreature");
if (!cId)
return false;
uint32 lowguid = atoi(cId);
if (!lowguid)
return false;
if (CreatureData const* cr_data = sObjectMgr->GetCreatureData(lowguid))
unit =
handler->GetSession()->GetPlayer()->GetMap()->GetCreature(
MAKE_NEW_GUID(lowguid, cr_data->id, HIGHGUID_UNIT));
} else
unit = handler->getSelectedCreature();
if (!unit || unit->isPet() || unit->isTotem()) {
handler->SendSysMessage(LANG_SELECT_CREATURE);
handler->SetSentErrorMessage(true);
return false;
}
QueryResult result;
result = WorldDatabase.PQuery("SELECT * FROM creature_spawn WHERE guid='%u' AND account='%u'", unit->GetGUIDLow(), handler->GetSession()->GetAccountId());
if (!result)
{
handler->PSendSysMessage(LANG_CREATURE_ACCOUNT);
handler->SetSentErrorMessage(true);
return false;
}
// Delete the creature
unit->CombatStop();
unit->DeleteFromDB();
unit->AddObjectToRemoveList();
handler->SendSysMessage(LANG_COMMAND_DELCREATMESSAGE);
sLog->outSQLDev("DELETE FROM creature WHERE guid = %u;", unit->GetGUIDLow());
return true;
}
示例8:
void PoolGroup<Creature>::Despawn1Object(ObjectGuid::LowType guid)
{
if (CreatureData const* data = sObjectMgr->GetCreatureData(guid))
{
sObjectMgr->RemoveCreatureFromGrid(guid, data);
Map* map = sMapMgr->CreateBaseMap(data->mapid);
if (!map->Instanceable())
{
auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(guid);
for (auto itr = creatureBounds.first; itr != creatureBounds.second;)
{
Creature* creature = itr->second;
++itr;
creature->AddObjectToRemoveList();
}
}
}
}
示例9: DelCreature
bool OutdoorPvPObjective::DelCreature(uint32 type)
{
if (!m_Creatures[type])
{
sLog.outDebug("OutdoorPvP creature type %u was already deleted",type);
return false;
}
Map* map = m_PvP->GetMap();
Creature *cr = map->GetCreature(m_Creatures[type]);
if (!cr)
{
sLog.outError("OutdoorPvPObjective: Can't find creature guid: %u", GUID_LOPART(m_Creatures[type]));
return false;
}
cr->AddObjectToRemoveList();
m_CreatureTypes[m_Creatures[type]] = 0;
m_Creatures[type] = 0;
return true;
}
示例10:
void PoolGroup<Creature>::Despawn1Object(ObjectGuid::LowType guid)
{
if (CreatureData const* data = sObjectMgr->GetCreatureData(guid))
{
sObjectMgr->RemoveCreatureFromGrid(guid, data);
Map* map = sMapMgr->CreateBaseMap(data->spawnPoint.GetMapId());
if (!map->Instanceable())
{
auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(guid);
for (auto itr = creatureBounds.first; itr != creatureBounds.second;)
{
Creature* creature = itr->second;
++itr;
// For dynamic spawns, save respawn time here
if (!creature->GetRespawnCompatibilityMode())
creature->SaveRespawnTime(0, false);
creature->AddObjectToRemoveList();
}
}
}
}
示例11: DelCreature
bool OPvPCapturePoint::DelCreature(uint32 type)
{
ObjectGuid::LowType spawnId = m_Creatures[type];
if (!spawnId)
{
TC_LOG_DEBUG("outdoorpvp", "opvp creature type %u was already deleted", type);
return false;
}
auto bounds = m_PvP->GetMap()->GetCreatureBySpawnIdStore().equal_range(spawnId);
for (auto itr = bounds.first; itr != bounds.second;)
{
Creature* c = itr->second;
++itr;
// Don't save respawn time
c->SetRespawnTime(0);
c->RemoveCorpse();
c->AddObjectToRemoveList();
}
TC_LOG_DEBUG("outdoorpvp", "deleting opvp creature type %u", type);
// explicit removal from map
// beats me why this is needed, but with the recent removal "cleanup" some creatures stay in the map if "properly" deleted
// so this is a big fat workaround, if AddObjectToRemoveList and DoDelayedMovesAndRemoves worked correctly, this wouldn't be needed
//if (Map* map = sMapMgr->FindMap(cr->GetMapId()))
// map->Remove(cr, false);
// delete respawn time for this creature
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CREATURE_RESPAWN);
stmt->setUInt64(0, spawnId);
stmt->setUInt16(1, m_PvP->GetMap()->GetId());
stmt->setUInt32(2, 0); // instance id, always 0 for world maps
CharacterDatabase.Execute(stmt);
sObjectMgr->DeleteCreatureData(spawnId);
m_CreatureTypes[m_Creatures[type]] = 0;
m_Creatures[type] = 0;
return true;
}
示例12: DelCreature
bool OPvPCapturePoint::DelCreature(uint32 type)
{
if (!m_Creatures[type])
{
TC_LOG_DEBUG(LOG_FILTER_OUTDOORPVP, "opvp creature type %u was already deleted", type);
return false;
}
Creature* cr = HashMapHolder<Creature>::Find(m_Creatures[type]);
if (!cr)
{
// can happen when closing the core
m_Creatures[type] = 0;
return false;
}
TC_LOG_DEBUG(LOG_FILTER_OUTDOORPVP, "deleting opvp creature type %u", type);
uint32 guid = cr->GetDBTableGUIDLow();
// Don't save respawn time
cr->SetRespawnTime(0);
cr->RemoveCorpse();
// explicit removal from map
// beats me why this is needed, but with the recent removal "cleanup" some creatures stay in the map if "properly" deleted
// so this is a big fat workaround, if AddObjectToRemoveList and DoDelayedMovesAndRemoves worked correctly, this wouldn't be needed
//if (Map* map = sMapMgr->FindMap(cr->GetMapId()))
// map->Remove(cr, false);
// delete respawn time for this creature
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CREATURE_RESPAWN);
stmt->setUInt32(0, guid);
stmt->setUInt16(1, cr->GetMapId());
stmt->setUInt32(2, 0); // instance id, always 0 for world maps
CharacterDatabase.Execute(stmt);
cr->AddObjectToRemoveList();
sObjectMgr->DeleteCreatureData(guid);
m_CreatureTypes[m_Creatures[type]] = 0;
m_Creatures[type] = 0;
return true;
}
示例13: HandleNpcDeleteCommand
static bool HandleNpcDeleteCommand(ChatHandler* handler, const char* args)
{
Creature* unit = NULL;
if (*args)
{
// number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r
char* cId = handler->extractKeyFromLink((char*)args,"Hcreature");
if (!cId)
return false;
uint32 lowguid = atoi(cId);
if (!lowguid)
return false;
if (CreatureData const* cr_data = sObjectMgr->GetCreatureData(lowguid))
unit = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(lowguid, cr_data->id, HIGHGUID_UNIT));
}
else
unit = handler->getSelectedCreature();
if (!unit || unit->isPet() || unit->isTotem())
{
handler->SendSysMessage(LANG_SELECT_CREATURE);
handler->SetSentErrorMessage(true);
return false;
}
// Delete the creature
unit->CombatStop();
unit->DeleteFromDB();
unit->AddObjectToRemoveList();
handler->SendSysMessage(LANG_COMMAND_DELCREATMESSAGE);
return true;
}
示例14: HandleWpShowCommand
//.........这里部分代码省略.........
handler->SetSentErrorMessage(true);
return false;
}
handler->PSendSysMessage("|cff00ff00DEBUG: wp on, PathID: |cff00ffff%u|r", pathid);
// Delete all visuals for this NPC
QueryResult result2 = WorldDatabase.PQuery("SELECT wpguid FROM waypoint_data WHERE id = '%u' and wpguid <> 0", pathid);
if (result2)
{
bool hasError = false;
do
{
Field* fields = result2->Fetch();
uint32 wpguid = fields[0].GetUInt32();
Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpguid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
if (!creature)
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpguid);
hasError = true;
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE);
stmt->setUInt32(0, wpguid);
WorldDatabase.Execute(stmt);
}
else
{
creature->CombatStop();
creature->DeleteFromDB();
creature->AddObjectToRemoveList();
}
}
while (result2->NextRow());
if (hasError)
{
handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR1);
handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR2);
handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR3);
}
}
do
{
Field* fields = result->Fetch();
uint32 point = fields[0].GetUInt32();
float x = fields[1].GetFloat();
float y = fields[2].GetFloat();
float z = fields[3].GetFloat();
uint32 id = VISUAL_WAYPOINT;
Player* chr = handler->GetSession()->GetPlayer();
Map* map = chr->GetMap();
float o = chr->GetOrientation();
Creature* wpCreature = new Creature;
if (!wpCreature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o))
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
delete wpCreature;
示例15: HandleWpModifyCommand
static bool HandleWpModifyCommand(ChatHandler* handler, const char* args)
{
if (!*args)
return false;
// first arg: add del text emote spell waittime move
char* show_str = strtok((char*)args, " ");
if (!show_str)
{
return false;
}
std::string show = show_str;
// Check
// Remember: "show" must also be the name of a column!
if ((show != "delay") && (show != "action") && (show != "action_chance")
&& (show != "move_flag") && (show != "del") && (show != "move") && (show != "wpadd")
)
{
return false;
}
// Next arg is: <PATHID> <WPNUM> <ARGUMENT>
char* arg_str = NULL;
// Did user provide a GUID
// or did the user select a creature?
// -> variable lowguid is filled with the GUID of the NPC
uint32 pathid = 0;
uint32 point = 0;
uint32 wpGuid = 0;
Creature* target = handler->getSelectedCreature();
if (!target || target->GetEntry() != VISUAL_WAYPOINT)
{
handler->SendSysMessage("|cffff33ffERROR: You must select a waypoint.|r");
return false;
}
// The visual waypoint
wpGuid = target->GetGUIDLow();
// User did select a visual waypoint?
// Check the creature
QueryResult result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE wpguid = %u", wpGuid);
if (!result)
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUIDLow());
// Select waypoint number from database
// Since we compare float values, we have to deal with
// some difficulties.
// Here we search for all waypoints that only differ in one from 1 thousand
// (0.001) - There is no other way to compare C++ floats with mySQL floats
// See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html
const char* maxDIFF = "0.01";
result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE (abs(position_x - %f) <= %s) and (abs(position_y - %f) <= %s) and (abs(position_z - %f) <= %s)",
target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF);
if (!result)
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid);
return true;
}
}
do
{
Field* fields = result->Fetch();
pathid = fields[0].GetUInt32();
point = fields[1].GetUInt32();
}
while (result->NextRow());
// We have the waypoint number and the GUID of the "master npc"
// Text is enclosed in "<>", all other arguments not
arg_str = strtok((char*)NULL, " ");
// Check for argument
if (show != "del" && show != "move" && arg_str == NULL)
{
handler->PSendSysMessage(LANG_WAYPOINT_ARGUMENTREQ, show_str);
return false;
}
if (show == "del" && target)
{
handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid);
// wpCreature
Creature* wpCreature = NULL;
if (wpGuid != 0)
{
wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
wpCreature->CombatStop();
wpCreature->DeleteFromDB();
wpCreature->AddObjectToRemoveList();
}
//.........这里部分代码省略.........