mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +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
|
|
@ -1385,24 +1385,30 @@ struct CreatureRespawnDeleteWorker
|
|||
|
||||
void Creature::DeleteFromDB()
|
||||
{
|
||||
if (!HasStaticDBSpawnData())
|
||||
CreatureData const* data = sObjectMgr.GetCreatureData(GetGUIDLow());
|
||||
if (!data)
|
||||
{
|
||||
DEBUG_LOG("Trying to delete not saved creature!");
|
||||
return;
|
||||
}
|
||||
|
||||
CreatureRespawnDeleteWorker worker (GetGUIDLow());
|
||||
sMapPersistentStateMgr.DoForAllStatesWithMapId(GetMapId(), worker);
|
||||
DeleteFromDB(GetGUIDLow(), data);
|
||||
}
|
||||
|
||||
sObjectMgr.DeleteCreatureData(GetGUIDLow());
|
||||
void Creature::DeleteFromDB(uint32 lowguid, CreatureData const* data)
|
||||
{
|
||||
CreatureRespawnDeleteWorker worker (lowguid);
|
||||
sMapPersistentStateMgr.DoForAllStatesWithMapId(data->mapid, worker);
|
||||
|
||||
sObjectMgr.DeleteCreatureData(lowguid);
|
||||
|
||||
WorldDatabase.BeginTransaction();
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid=%u", GetGUIDLow());
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature_addon WHERE guid=%u", GetGUIDLow());
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature_movement WHERE id=%u", GetGUIDLow());
|
||||
WorldDatabase.PExecuteLog("DELETE FROM game_event_creature WHERE guid=%u", GetGUIDLow());
|
||||
WorldDatabase.PExecuteLog("DELETE FROM game_event_creature_data WHERE guid=%u", GetGUIDLow());
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature_battleground WHERE guid=%u", GetGUIDLow());
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid=%u", lowguid);
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature_addon WHERE guid=%u", lowguid);
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature_movement WHERE id=%u", lowguid);
|
||||
WorldDatabase.PExecuteLog("DELETE FROM game_event_creature WHERE guid=%u", lowguid);
|
||||
WorldDatabase.PExecuteLog("DELETE FROM game_event_creature_data WHERE guid=%u", lowguid);
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature_battleground WHERE guid=%u", lowguid);
|
||||
WorldDatabase.CommitTransaction();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -596,6 +596,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
|||
// overwrited in Pet
|
||||
virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
|
||||
virtual void DeleteFromDB(); // overwrited in Pet
|
||||
static void DeleteFromDB(uint32 lowguid, CreatureData const* data);
|
||||
|
||||
Loot loot;
|
||||
bool lootForPickPocketed;
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
{
|
||||
case CREATURE_SUBTYPE_GENERIC:
|
||||
{
|
||||
unit->CombatStop();
|
||||
unit->DeleteFromDB();
|
||||
unit->AddObjectToRemoveList();
|
||||
if (CreatureData const* data = sObjectMgr.GetCreatureData(unit->GetGUIDLow()))
|
||||
{
|
||||
Creature::AddToRemoveListInMaps(unit->GetGUIDLow(), data);
|
||||
Creature::DeleteFromDB(unit->GetGUIDLow(), data);
|
||||
}
|
||||
else
|
||||
{
|
||||
TemporarySummon * pSummon = static_cast<TemporarySummon* >(unit);
|
||||
pSummon->UnSummon();
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11343"
|
||||
#define REVISION_NR "11344"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue