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()
|
void Creature::DeleteFromDB()
|
||||||
{
|
{
|
||||||
if (!HasStaticDBSpawnData())
|
CreatureData const* data = sObjectMgr.GetCreatureData(GetGUIDLow());
|
||||||
|
if (!data)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("Trying to delete not saved creature!");
|
DEBUG_LOG("Trying to delete not saved creature!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreatureRespawnDeleteWorker worker (GetGUIDLow());
|
DeleteFromDB(GetGUIDLow(), data);
|
||||||
sMapPersistentStateMgr.DoForAllStatesWithMapId(GetMapId(), worker);
|
}
|
||||||
|
|
||||||
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.BeginTransaction();
|
||||||
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid=%u", GetGUIDLow());
|
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid=%u", lowguid);
|
||||||
WorldDatabase.PExecuteLog("DELETE FROM creature_addon WHERE guid=%u", GetGUIDLow());
|
WorldDatabase.PExecuteLog("DELETE FROM creature_addon WHERE guid=%u", lowguid);
|
||||||
WorldDatabase.PExecuteLog("DELETE FROM creature_movement WHERE id=%u", GetGUIDLow());
|
WorldDatabase.PExecuteLog("DELETE FROM creature_movement WHERE id=%u", lowguid);
|
||||||
WorldDatabase.PExecuteLog("DELETE FROM game_event_creature WHERE guid=%u", GetGUIDLow());
|
WorldDatabase.PExecuteLog("DELETE FROM game_event_creature WHERE guid=%u", lowguid);
|
||||||
WorldDatabase.PExecuteLog("DELETE FROM game_event_creature_data WHERE guid=%u", GetGUIDLow());
|
WorldDatabase.PExecuteLog("DELETE FROM game_event_creature_data WHERE guid=%u", lowguid);
|
||||||
WorldDatabase.PExecuteLog("DELETE FROM creature_battleground WHERE guid=%u", GetGUIDLow());
|
WorldDatabase.PExecuteLog("DELETE FROM creature_battleground WHERE guid=%u", lowguid);
|
||||||
WorldDatabase.CommitTransaction();
|
WorldDatabase.CommitTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -596,6 +596,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
||||||
// overwrited in Pet
|
// overwrited in Pet
|
||||||
virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
|
virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
|
||||||
virtual void DeleteFromDB(); // overwrited in Pet
|
virtual void DeleteFromDB(); // overwrited in Pet
|
||||||
|
static void DeleteFromDB(uint32 lowguid, CreatureData const* data);
|
||||||
|
|
||||||
Loot loot;
|
Loot loot;
|
||||||
bool lootForPickPocketed;
|
bool lootForPickPocketed;
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,12 @@
|
||||||
#include "DBCStores.h"
|
#include "DBCStores.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
#include "ObjectGuid.h"
|
#include "ObjectGuid.h"
|
||||||
#include "Player.h"
|
|
||||||
#include "Item.h"
|
#include "Item.h"
|
||||||
|
#include "Player.h"
|
||||||
|
#include "TemporarySummon.h"
|
||||||
|
#include "Totem.h"
|
||||||
|
#include "Pet.h"
|
||||||
|
#include "Vehicle.h"
|
||||||
#include "GameObject.h"
|
#include "GameObject.h"
|
||||||
#include "Opcodes.h"
|
#include "Opcodes.h"
|
||||||
#include "Chat.h"
|
#include "Chat.h"
|
||||||
|
|
@ -41,7 +45,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "TemporarySummon.h"
|
|
||||||
|
|
||||||
#include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand
|
#include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand
|
||||||
|
|
||||||
|
|
@ -1811,24 +1814,41 @@ bool ChatHandler::HandleNpcDeleteCommand(char* args)
|
||||||
else
|
else
|
||||||
unit = getSelectedCreature();
|
unit = getSelectedCreature();
|
||||||
|
|
||||||
if (!unit || unit->IsPet() || unit->IsTotem() || unit->IsVehicle())
|
if (!unit)
|
||||||
{
|
{
|
||||||
SendSysMessage(LANG_SELECT_CREATURE);
|
SendSysMessage(LANG_SELECT_CREATURE);
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the creature
|
switch (unit->GetSubtype())
|
||||||
if(!unit->IsTemporarySummon())
|
|
||||||
{
|
{
|
||||||
unit->CombatStop();
|
case CREATURE_SUBTYPE_GENERIC:
|
||||||
unit->DeleteFromDB();
|
{
|
||||||
unit->AddObjectToRemoveList();
|
unit->CombatStop();
|
||||||
}
|
if (CreatureData const* data = sObjectMgr.GetCreatureData(unit->GetGUIDLow()))
|
||||||
else
|
{
|
||||||
{
|
Creature::AddToRemoveListInMaps(unit->GetGUIDLow(), data);
|
||||||
TemporarySummon * pSummon = static_cast<TemporarySummon* >(unit);
|
Creature::DeleteFromDB(unit->GetGUIDLow(), data);
|
||||||
pSummon->UnSummon();
|
}
|
||||||
|
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);
|
SendSysMessage(LANG_COMMAND_DELCREATMESSAGE);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11343"
|
#define REVISION_NR "11344"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue