mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[11344] Make .npc delete safe for instances and complete no static creatures code cases.
This commit is contained in:
parent
6c8efb4458
commit
b4ab2b2441
4 changed files with 51 additions and 24 deletions
|
|
@ -21,8 +21,12 @@
|
|||
#include "DBCStores.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "Player.h"
|
||||
#include "Item.h"
|
||||
#include "Player.h"
|
||||
#include "TemporarySummon.h"
|
||||
#include "Totem.h"
|
||||
#include "Pet.h"
|
||||
#include "Vehicle.h"
|
||||
#include "GameObject.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Chat.h"
|
||||
|
|
@ -41,7 +45,6 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include "TemporarySummon.h"
|
||||
|
||||
#include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand
|
||||
|
||||
|
|
@ -1811,24 +1814,41 @@ bool ChatHandler::HandleNpcDeleteCommand(char* args)
|
|||
else
|
||||
unit = getSelectedCreature();
|
||||
|
||||
if (!unit || unit->IsPet() || unit->IsTotem() || unit->IsVehicle())
|
||||
if (!unit)
|
||||
{
|
||||
SendSysMessage(LANG_SELECT_CREATURE);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete the creature
|
||||
if(!unit->IsTemporarySummon())
|
||||
switch (unit->GetSubtype())
|
||||
{
|
||||
unit->CombatStop();
|
||||
unit->DeleteFromDB();
|
||||
unit->AddObjectToRemoveList();
|
||||
}
|
||||
else
|
||||
{
|
||||
TemporarySummon * pSummon = static_cast<TemporarySummon* >(unit);
|
||||
pSummon->UnSummon();
|
||||
case CREATURE_SUBTYPE_GENERIC:
|
||||
{
|
||||
unit->CombatStop();
|
||||
if (CreatureData const* data = sObjectMgr.GetCreatureData(unit->GetGUIDLow()))
|
||||
{
|
||||
Creature::AddToRemoveListInMaps(unit->GetGUIDLow(), data);
|
||||
Creature::DeleteFromDB(unit->GetGUIDLow(), data);
|
||||
}
|
||||
else
|
||||
unit->AddObjectToRemoveList();
|
||||
break;
|
||||
}
|
||||
case CREATURE_SUBTYPE_PET:
|
||||
((Pet*)unit)->Unsummon(PET_SAVE_AS_CURRENT);
|
||||
break;
|
||||
case CREATURE_SUBTYPE_TOTEM:
|
||||
((Totem*)unit)->UnSummon();
|
||||
break;
|
||||
case CREATURE_SUBTYPE_TEMPORARY_SUMMON:
|
||||
((TemporarySummon*)unit)->UnSummon();
|
||||
break;
|
||||
case CREATURE_SUBTYPE_VEHICLE:
|
||||
((Vehicle*)unit)->Dismiss();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
SendSysMessage(LANG_COMMAND_DELCREATMESSAGE);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue