本文整理汇总了C++中Creature::DeleteFromDB方法的典型用法代码示例。如果您正苦于以下问题:C++ Creature::DeleteFromDB方法的具体用法?C++ Creature::DeleteFromDB怎么用?C++ Creature::DeleteFromDB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Creature
的用法示例。
在下文中一共展示了Creature::DeleteFromDB方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleDeleteCommand
bool ChatHandler::HandleDeleteCommand(const char* args, WorldSession *m_session)
{
uint64 guid = m_session->GetPlayer()->GetSelection();
if(guid == 0)
{
SystemMessage(m_session, "No selection.");
return true;
}
Creature *unit = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
if(!unit)
{
SystemMessage(m_session, "You should select a creature.");
return true;
}
if(unit->IsPet())
{
SystemMessage(m_session, "You can't delete a pet." );
return true;
}
sGMLog.writefromsession(m_session, "used npc delete, sqlid %u, creature %s, pos %f %f %f", unit->GetSQL_id(), unit->GetCreatureInfo()->Name, unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ());
unit->GetAIInterface()->hideWayPoints( m_session->GetPlayer() );
unit->DeleteFromDB();
if(unit->IsInWorld())
{
if(unit->m_spawn)
{
uint32 cellx = uint32(((_maxX-unit->m_spawn->x)/_cellSize));
uint32 celly = uint32(((_maxY-unit->m_spawn->y)/_cellSize));
if(cellx <= _sizeX && celly <= _sizeY)
{
CellSpawns * sp = unit->GetMapMgr()->GetBaseMap()->GetSpawnsList(cellx, celly);
if( sp != NULL )
{
for( CreatureSpawnList::iterator itr = sp->CreatureSpawns.begin(); itr != sp->CreatureSpawns.end(); ++itr )
if( (*itr) == unit->m_spawn )
{
sp->CreatureSpawns.erase( itr );
break;
}
}
delete unit->m_spawn;
unit->m_spawn = NULL;
}
}
unit->RemoveFromWorld(false,true);
}
BlueSystemMessage(m_session, "Creature deleted");
return true;
}
示例2: 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;
}
示例3: HandleDeleteCommand
bool ChatHandler::HandleDeleteCommand(const char* args, WorldSession *m_session)
{
uint64 guid = m_session->GetPlayer()->GetSelection();
if (guid == 0)
{
SystemMessage(m_session, "No selection.");
return true;
}
Creature *unit = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
if(!unit)
{
SystemMessage(m_session, "You should select a creature.");
return true;
}
if ( unit->IsPet() )
{
SystemMessage(m_session, "You can't delete a pet." );
return true;
}
sGMLog.writefromsession(m_session, "used npc delete, sqlid %u, creature %s, pos %f %f %f", unit->GetSQL_id(), unit->GetCreatureInfo() ? unit->GetCreatureInfo()->Name : "wtfbbqhax", unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ());
if( unit->m_spawn == NULL )
return false;
BlueSystemMessage(m_session, "Deleted creature ID %u", unit->spawnid);
if(unit->IsInWorld())
{
if(unit->m_spawn)
{
uint32 cellx=float2int32(((_maxX-unit->m_spawn->x)/_cellSize));
uint32 celly=float2int32(((_maxY-unit->m_spawn->y)/_cellSize));
if(cellx <= _sizeX && celly <= _sizeY)
{
CellSpawns * c = unit->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cellx, celly);
for(CreatureSpawnList::iterator itr = c->CreatureSpawns.begin(); itr != c->CreatureSpawns.end(); ++itr)
if((*itr) == unit->m_spawn)
{
c->CreatureSpawns.erase(itr);
break;
}
delete unit->m_spawn;
}
}
unit->RemoveFromWorld(false,true);
}
unit->DeleteFromDB();
delete unit;
return true;
}
示例4: 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;
}
示例5: HandleDeleteCommand
bool ChatHandler::HandleDeleteCommand(const char* args)
{
Creature *unit = getSelectedCreature();
if(!unit)
{
SendSysMessage(LANG_SELECT_CREATURE);
return true;
}
unit->CombatStop();
unit->DeleteFromDB();
ObjectAccessor::Instance().AddObjectToRemoveList(unit);
SendSysMessage("Creature Removed");
return true;
}
示例6: HandleDeleteCommand
bool ChatHandler::HandleDeleteCommand(const char* args, WorldSession *m_session)
{
uint64 guid = m_session->GetPlayer()->GetSelection();
if (guid == 0)
{
SystemMessage(m_session, "No selection.");
return true;
}
Creature *unit = m_session->GetPlayer()->GetMapMgr()->GetCreature(guid);
if(!unit)
{
SystemMessage(m_session, "You should select a creature.");
return true;
}
sGMLog.writefromsession(m_session, "used npc delete, sqlid %u, creature %s, pos %f %f %f",
unit->GetSQL_id(), unit->GetCreatureName()->Name, unit->GetPositionX(), unit->GetPositionY(),
unit->GetPositionZ());
if(unit->m_spawn == 0)
return false;
BlueSystemMessage(m_session, "Deleted creature ID %u", unit->spawnid);
if(unit->IsInWorld())
{
if(unit->m_spawn)
{
uint32 cellx=float2int32(((_maxX-unit->m_spawn->x)/_cellSize));
uint32 celly=float2int32(((_maxY-unit->m_spawn->y)/_cellSize));
unit->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cellx, celly)->CreatureSpawns.erase(unit->m_spawn);
}
unit->RemoveFromWorld(false);
}
unit->DeleteFromDB();
delete unit;
return true;
}
示例7:
bool
ChatHandler::Command_NPC_Delete (const char* args)
{
// Just in case, clear waypoint indicators
Command_WP_Hide (NULL);
WorldPacket data;
uint64 guid = m_session->GetPlayer()->GetSelection();
if (guid == 0)
{
m_session->SystemMessage (LANG_CMD_NOSEL);
return true;
}
Creature *unit = objmgr.GetObject<Creature>(guid);
if(!unit)
{
m_session->SystemMessage (LANG_CMD_NOSEL);
return true;
}
data.Initialize (SMSG_DESTROY_OBJECT);
data << unit->GetGUID();
m_session->SendPacket (&data);
unit->SendMessageToSet (&data, true);
if (unit->GetMapCell())
unit->GetMapCell()->RemoveObject (unit);
unit->RemoveFromMap();
unit->RemoveFromWorld();
unit->DeleteFromDB();
objmgr.RemoveObject_Free(unit);
return true;
}
示例8: 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;
}
示例9: HandleWpShowCommand
//.........这里部分代码省略.........
handler->SendSysMessage("|cffff33ffPath no found.|r");
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);
示例10: 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();
}
//.........这里部分代码省略.........
示例11: Creature
void
Spell::Effect_Summon_Pet(uint32 i)
{
WorldPacket data;
if(m_caster->GetUInt64Value(UNIT_FIELD_SUMMON) != 0)//If there is already a summon
{
Creature *OldSummon = objmgr.GetObject<Creature>(m_caster->GetUInt64Value(UNIT_FIELD_SUMMON));
if(!OldSummon)
{
m_caster->SetUInt64Value(UNIT_FIELD_SUMMON, 0);
sLog.outError("Warning!Old Summon could not be found!");
} else {
data.clear();
data.Initialize(SMSG_DESTROY_OBJECT);
data << OldSummon->GetGUID();
OldSummon->SendMessageToSet (&data, true);
if (OldSummon->GetMapCell())
OldSummon->GetMapCell()->RemoveObject (OldSummon);
OldSummon->RemoveFromMap();
OldSummon->RemoveFromWorld();
OldSummon->DeleteFromDB();
objmgr.RemoveObject_Free(OldSummon);
}
}
//Create new summon
Creature *NewSummon = new Creature();
CreatureTemplate *SummonInfo = objmgr.GetCreatureTemplate(m_spellInfo->EffectMiscValue[i]);
if(SummonInfo == NULL)
{
sLog.outError("No Minion found for CreatureTemplate %u", m_spellInfo->EffectMiscValue[i]);
return;
}
NewSummon->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), SummonInfo->Name.c_str(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), m_caster->GetOrientation());
NewSummon->SetLevel(m_caster->GetLevel());
NewSummon->SetUInt32Value(UNIT_FIELD_DISPLAYID, SummonInfo->Model);
NewSummon->SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, SummonInfo->Model);
NewSummon->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, m_caster->GetGUID());
NewSummon->SetUInt32Value(UNIT_NPC_FLAGS , 0);
NewSummon->SetUInt32Value(UNIT_FIELD_HEALTH , 28 + 30 * m_caster->GetLevel());
NewSummon->SetUInt32Value(UNIT_FIELD_MAXHEALTH , 28 + 30 * m_caster->GetLevel());
NewSummon->SetFaction(m_caster->GetFaction());
NewSummon->SetScale( SummonInfo->Size );
NewSummon->SetUInt32Value(UNIT_FIELD_BYTES_0,2048);
NewSummon->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NONE);
NewSummon->SetUInt32Value(UNIT_FIELD_BASEATTACKTIME, SummonInfo->Attack[0]);
NewSummon->SetUInt32Value(UNIT_FIELD_BASEATTACKTIME+1, SummonInfo->Attack[1]);
NewSummon->SetUInt32Value(UNIT_FIELD_BOUNDINGRADIUS, SummonInfo->BoundingRadius);
NewSummon->SetUInt32Value(UNIT_FIELD_COMBATREACH, SummonInfo->CombatReach);
NewSummon->SetMinDamage((float)SummonInfo->Damage[0]);
NewSummon->SetMaxDamage((float)SummonInfo->Damage[1]);
NewSummon->SetUInt32Value(UNIT_FIELD_BYTES_1,0);
NewSummon->SetUInt32Value(UNIT_FIELD_PETNUMBER, NewSummon->GetGUIDLow());
NewSummon->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP,5);
NewSummon->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE,0);
NewSummon->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP,1000);
NewSummon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
NewSummon->SetUInt32Value(UNIT_FIELD_STAT0,22);
NewSummon->SetUInt32Value(UNIT_FIELD_STAT1,22); //////////TODO: GET THE RIGHT INFORMATIONS FOR THIS!!!
NewSummon->SetUInt32Value(UNIT_FIELD_STAT2,25);
NewSummon->SetUInt32Value(UNIT_FIELD_STAT3,28);
NewSummon->SetUInt32Value(UNIT_FIELD_STAT4,27);
NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+0,0);
NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+1,0);
NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+2,0);
NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+3,0);
NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+4,0);
NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+5,0);
NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+6,0);
NewSummon->SetUInt32Value(UNIT_FIELD_ATTACK_POWER,24);
NewSummon->SetUInt32Value(UNIT_FIELD_BASE_MANA, SummonInfo->MaxMana);
NewSummon->SetUInt32Value(OBJECT_FIELD_ENTRY, SummonInfo->Entry);
NewSummon->SetPosition(m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), m_caster->GetOrientation());
NewSummon->SetZoneId(m_caster->GetZoneId());
NewSummon->SaveToDB();
objmgr.AddObject( NewSummon );
NewSummon->PlaceOnMap();
NewSummon->AddToWorld();
m_caster->SetUInt64Value(UNIT_FIELD_SUMMON, NewSummon->GetGUID());
sLog.outDebug("New Pet has guid %u", NewSummon->GetGUID());
if(objmgr.GetObject<Player>(m_caster->GetGUID()) )//if the caster is a player
{
data.clear();
data.Initialize(SMSG_PET_SPELLS);
data << (uint64)NewSummon->GetGUID() << uint32(0x00000101) << uint32(0x00000000) << uint32(0x07000001) << uint32(0x07000002);
data << uint32(0x02000000) << uint32(0x07000000) << uint32(0x04000000) << uint32(0x03000000) << uint32(0x06000002) << uint32(0x05000000);
data << uint32(0x06000000) << uint32(0x06000001) << uint8(0x02)/*Number of spells*/ << uint32(3110)/*SpellID1*/ << uint32(6307)/*SpellID2*/;
((Player*)m_caster)->GetSession()->SendPacket(&data);
}
}
示例12: HandleDeleteCommand
bool ChatHandler::HandleDeleteCommand(const char* args, WorldSession *m_session)
{
uint64 guid = m_session->GetPlayer()->GetSelection();
if (guid == 0)
{
SystemMessage(m_session, "No selection.");
return true;
}
Creature* unit = NULL;
if(m_session->GetPlayer()->GetMapMgr()->GetVehicle(GET_LOWGUID_PART(guid)))
unit = m_session->GetPlayer()->GetMapMgr()->GetVehicle(GET_LOWGUID_PART(guid));
else
unit = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
if(!unit)
{
SystemMessage(m_session, "You should select a creature.");
return true;
}
if( unit->m_spawn != NULL && !m_session->CanUseCommand('z') )
{
SystemMessage(m_session, "You do not have permission to do that. Please contact higher staff for removing of saved spawns.");
return true;
}
if(unit->GetAIInterface())
unit->GetAIInterface()->StopMovement(10000);
if(unit->IsVehicle())
{
Vehicle* veh = TO_VEHICLE(unit);
for(int i = 0; i < 8; i++)
{
if(!veh->GetPassenger(i))
continue;
// Remove any players
if(veh->GetPassenger(i)->IsPlayer())
veh->RemovePassenger(veh->GetPassenger(i));
else // Remove any units.
veh->GetPassenger(i)->RemoveFromWorld(true);
}
}
sGMLog.writefromsession(m_session, "used npc delete, sqlid %u, creature %s, pos %f %f %f",
unit->m_spawn ? unit->m_spawn : 0, unit->GetCreatureInfo() ? unit->GetCreatureInfo()->Name : "wtfbbqhax", unit->GetPositionX(), unit->GetPositionY(),
unit->GetPositionZ());
BlueSystemMessage(m_session, "Deleted creature ID %u", unit->spawnid);
MapMgr* unitMgr = unit->GetMapMgr();
unit->DeleteFromDB();
if(!unit->IsInWorld())
return true;
if(unit->m_spawn)
{
uint32 cellx=float2int32(((_maxX-unit->m_spawn->x)/_cellSize));
uint32 celly=float2int32(((_maxY-unit->m_spawn->y)/_cellSize));
if(cellx <= _sizeX && celly <= _sizeY && unitMgr != NULL)
{
CellSpawns * c = unitMgr->GetBaseMap()->GetSpawnsList(cellx, celly);
if( c != NULL )
{
CreatureSpawnList::iterator itr, itr2;
for(itr = c->CreatureSpawns.begin(); itr != c->CreatureSpawns.end();)
{
itr2 = itr;
++itr;
if((*itr2) == unit->m_spawn)
{
c->CreatureSpawns.erase(itr2);
delete unit->m_spawn;
break;
}
}
}
}
}
unit->RemoveFromWorld(false,true);
if(unit->IsVehicle())
TO_VEHICLE(unit)->Destructor();
else
unit->Destructor();
return true;
}
示例13: HandleDeleteCommand
bool ChatHandler::HandleDeleteCommand(const char* args, WorldSession *m_session)
{
Creature* unit = getSelectedCreature(m_session, false);
if(!unit)
{
SystemMessage(m_session, "You should select a creature.");
return true;
}
else if(unit->IsPet() || unit->IsSummon())
{
SystemMessage(m_session, "You can't delete playerpets.");
return true;
}
if( unit->m_spawn != NULL && !m_session->CanUseCommand('z') )
{
SystemMessage(m_session, "You do not have permission to do that. Please contact higher staff for removing of saved spawns.");
return true;
}
if(unit->IsVehicle())
{
Vehicle* veh = TO_VEHICLE(unit);
for(int i = 0; i < 8; i++)
{
if(!veh->GetPassenger(i))
continue;
// Remove any players
if(veh->GetPassenger(i)->IsPlayer())
veh->RemovePassenger(veh->GetPassenger(i));
else // Remove any units.
veh->GetPassenger(i)->RemoveFromWorld(true);
}
}
sWorld.LogGM(m_session, "used npc delete, sqlid %u, creature %s, pos %f %f %f",
unit->m_spawn ? unit->m_spawn->id : 0, unit->GetCreatureInfo() ? unit->GetCreatureInfo()->Name : "wtfbbqhax", unit->GetPositionX(), unit->GetPositionY(),
unit->GetPositionZ());
BlueSystemMessage(m_session, "Deleted creature ID %u", unit->spawnid);
unit->DeleteFromDB();
if(!unit->IsInWorld())
return true;
MapMgr* unitMgr = unit->GetMapMgr();
if(unit->m_spawn)
{
uint32 cellx = unitMgr->GetPosX(unit->m_spawn->x);
uint32 celly = unitMgr->GetPosX(unit->m_spawn->y);
if(cellx <= _sizeX && celly <= _sizeY )
{
CellSpawns *c = unitMgr->GetBaseMap()->GetSpawnsList(cellx, celly);
if( c != NULL )
{
CreatureSpawnList::iterator itr, itr2;
for(itr = c->CreatureSpawns.begin(); itr != c->CreatureSpawns.end();)
{
itr2 = itr++;
if((*itr2) == unit->m_spawn)
{
c->CreatureSpawns.erase(itr2);
delete unit->m_spawn;
break;
}
}
}
}
}
unit->RemoveFromWorld(false, true);
if(unit->IsVehicle())
TO_VEHICLE(unit)->Destruct();
else
unit->Destruct();
m_session->GetPlayer()->SetSelection(NULL);
return true;
}