Core/DBLayer: Move tables reserved_name, gameobject_respawn and creature_respawn from WORLD database to CHARACTER database as it's content is realm-specific and should be preserved (thanks to leak for the cleanup)
*** TO PRESERVE (COPY) THE DATA CONTAINED IN THE OLD TABLES, YOU MUST FOLLOW THE FOLLOWING SQL-RECIPE (REPLACE DATABASENAMES WHERE NEEDED!) *** -- Move creature_respawn from world to characters db INSERT INTO `characters`.`creature_respawn` (`guid`, `respawntime`, `instance`) SELECT `guid, `respawntime` `instance` * FROM `world`.`creature_respawn`; -- Remove creature_respawn table from world db DROP TABLE `world`.`creature_respawn`; -- Move gameobject_respawn from world to characters db INSERT INTO `characters`.`gameobject_respawn` (`guid`, `respawntime`, `instance`) SELECT `guid`, `respawntime`, `instance` FROM `world`.`gameobject_respawn`; -- Remove creature_respawn table from world db DROP TABLE `world`.`gameobject_respawn`; -- Move reserved names from world to characters db INSERT INTO `characters`.`reserved_name` (`name`) SELECT `name` FROM `world`.`reserved_name`; -- Remove reserved_names table from world db DROP TABLE `world`.`reserved_name`; *** THE ABOVE MUST BE DONE, OR EXISTING INSTANCES WILL BE FULLY RESPAWNED - YOU HAVE BEEN WARNED *** Closes issue 4842. Closes issue 4849. --HG-- branch : trunk
This commit is contained in:
@@ -217,8 +217,8 @@ Battleground::~Battleground()
|
||||
if (GetInstanceID()) // not spam by useless queries in case BG templates
|
||||
{
|
||||
// delete creature and go respawn times
|
||||
WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE instance = '%u'",GetInstanceID());
|
||||
WorldDatabase.PExecute("DELETE FROM gameobject_respawn WHERE instance = '%u'",GetInstanceID());
|
||||
CharacterDatabase.PExecute("DELETE FROM creature_respawn WHERE instance = '%u'",GetInstanceID());
|
||||
CharacterDatabase.PExecute("DELETE FROM gameobject_respawn WHERE instance = '%u'",GetInstanceID());
|
||||
// delete instance from db
|
||||
CharacterDatabase.PExecute("DELETE FROM instance WHERE id = '%u'",GetInstanceID());
|
||||
// remove from battlegrounds
|
||||
|
||||
@@ -1814,7 +1814,7 @@ void ObjectMgr::LoadCreatureRespawnTimes()
|
||||
{
|
||||
uint32 count = 0;
|
||||
|
||||
QueryResult result = WorldDatabase.Query("SELECT guid,respawntime,instance FROM creature_respawn");
|
||||
QueryResult result = CharacterDatabase.Query("SELECT guid,respawntime,instance FROM creature_respawn");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
@@ -1850,12 +1850,12 @@ void ObjectMgr::LoadCreatureRespawnTimes()
|
||||
void ObjectMgr::LoadGameobjectRespawnTimes()
|
||||
{
|
||||
// remove outdated data
|
||||
PreparedStatement *stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAMEOBJECT_RESPAWN_TIMES);
|
||||
WorldDatabase.Execute(stmt);
|
||||
PreparedStatement *stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GAMEOBJECT_RESPAWN_TIMES);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
QueryResult result = WorldDatabase.Query("SELECT guid,respawntime,instance FROM gameobject_respawn");
|
||||
QueryResult result = CharacterDatabase.Query("SELECT guid,respawntime,instance FROM gameobject_respawn");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
@@ -7518,18 +7518,18 @@ void ObjectMgr::SaveCreatureRespawnTime(uint32 loguid, uint32 instance, time_t t
|
||||
m_CreatureRespawnTimesMtx.release();
|
||||
}
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CRESPAWNTIME);
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CRESPAWNTIME);
|
||||
stmt->setUInt32(0, loguid);
|
||||
stmt->setUInt32(1, instance);
|
||||
WorldDatabase.Execute(stmt);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
if (t)
|
||||
{
|
||||
stmt = WorldDatabase.GetPreparedStatement(WORLD_ADD_CRESPAWNTIME);
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_CRESPAWNTIME);
|
||||
stmt->setUInt32(0, loguid);
|
||||
stmt->setUInt64(1, uint64(t));
|
||||
stmt->setUInt32(2, instance);
|
||||
WorldDatabase.Execute(stmt);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7552,9 +7552,9 @@ void ObjectMgr::SaveGORespawnTime(uint32 loguid, uint32 instance, time_t t)
|
||||
m_GORespawnTimesMtx.release();
|
||||
}
|
||||
|
||||
WorldDatabase.PExecute("DELETE FROM gameobject_respawn WHERE guid = '%u' AND instance = '%u'", loguid, instance);
|
||||
CharacterDatabase.PExecute("DELETE FROM gameobject_respawn WHERE guid = '%u' AND instance = '%u'", loguid, instance);
|
||||
if (t)
|
||||
WorldDatabase.PExecute("INSERT INTO gameobject_respawn VALUES ('%u', '" UI64FMTD "', '%u')", loguid, uint64(t), instance);
|
||||
CharacterDatabase.PExecute("INSERT INTO gameobject_respawn VALUES ('%u', '" UI64FMTD "', '%u')", loguid, uint64(t), instance);
|
||||
}
|
||||
|
||||
void ObjectMgr::DeleteRespawnTimeForInstance(uint32 instance)
|
||||
@@ -7586,8 +7586,8 @@ void ObjectMgr::DeleteRespawnTimeForInstance(uint32 instance)
|
||||
}
|
||||
m_CreatureRespawnTimesMtx.release();
|
||||
}
|
||||
WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE instance = '%u'", instance);
|
||||
WorldDatabase.PExecute("DELETE FROM gameobject_respawn WHERE instance = '%u'", instance);
|
||||
CharacterDatabase.PExecute("DELETE FROM creature_respawn WHERE instance = '%u'", instance);
|
||||
CharacterDatabase.PExecute("DELETE FROM gameobject_respawn WHERE instance = '%u'", instance);
|
||||
}
|
||||
|
||||
void ObjectMgr::DeleteGOData(uint32 guid)
|
||||
@@ -7725,7 +7725,7 @@ void ObjectMgr::LoadReservedPlayersNames()
|
||||
{
|
||||
m_ReservedNames.clear(); // need for reload case
|
||||
|
||||
QueryResult result = WorldDatabase.Query("SELECT name FROM reserved_name");
|
||||
QueryResult result = CharacterDatabase.Query("SELECT name FROM reserved_name");
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
|
||||
@@ -265,7 +265,10 @@ void InstanceSaveManager::CleanupInstances()
|
||||
_DelHelper("character_instance.guid, instance", "character_instance", "LEFT JOIN instance ON character_instance.instance = instance.id WHERE instance.id IS NULL");
|
||||
_DelHelper("guid, instance", "group_instance", "LEFT JOIN instance ON group_instance.instance = instance.id WHERE instance.id IS NULL");
|
||||
|
||||
// creature_respawn and gameobject_respawn are in another database
|
||||
// Clean respawn data from non existing instances
|
||||
CharacterDatabase.PExecute("DELETE FROM creature_respawn WHERE instance <> 0 AND instance NOT IN (SELECT id FROM instance)");
|
||||
CharacterDatabase.PExecute("DELETE FROM gameobject_respawn WHERE instance <> 0 AND instance NOT IN (SELECT id FROM instance)");
|
||||
|
||||
// first, obtain total instance set
|
||||
std::set<uint32> InstanceSet;
|
||||
QueryResult result = CharacterDatabase.Query("SELECT id FROM instance");
|
||||
@@ -279,32 +282,6 @@ void InstanceSaveManager::CleanupInstances()
|
||||
while (result->NextRow());
|
||||
}
|
||||
|
||||
// creature_respawn
|
||||
result = WorldDatabase.Query("SELECT DISTINCT(instance) FROM creature_respawn WHERE instance <> 0");
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
if (InstanceSet.find(fields[0].GetUInt32()) == InstanceSet.end())
|
||||
WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE instance = '%u'", fields[0].GetUInt32());
|
||||
}
|
||||
while (result->NextRow());
|
||||
}
|
||||
|
||||
// gameobject_respawn
|
||||
result = WorldDatabase.Query("SELECT DISTINCT(instance) FROM gameobject_respawn WHERE instance <> 0");
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
if (InstanceSet.find(fields[0].GetUInt32()) == InstanceSet.end())
|
||||
WorldDatabase.PExecute("DELETE FROM gameobject_respawn WHERE instance = '%u'", fields[0].GetUInt32());
|
||||
}
|
||||
while (result->NextRow());
|
||||
}
|
||||
|
||||
// characters
|
||||
result = CharacterDatabase.Query("SELECT DISTINCT(instance_id) FROM characters WHERE instance_id <> 0");
|
||||
if (result)
|
||||
@@ -368,8 +345,8 @@ void InstanceSaveManager::PackInstances()
|
||||
if (*i != InstanceNumber)
|
||||
{
|
||||
// remap instance id
|
||||
WorldDatabase.PExecute("UPDATE creature_respawn SET instance = '%u' WHERE instance = '%u'", InstanceNumber, *i);
|
||||
WorldDatabase.PExecute("UPDATE gameobject_respawn SET instance = '%u' WHERE instance = '%u'", InstanceNumber, *i);
|
||||
CharacterDatabase.PExecute("UPDATE creature_respawn SET instance = '%u' WHERE instance = '%u'", InstanceNumber, *i);
|
||||
CharacterDatabase.PExecute("UPDATE gameobject_respawn SET instance = '%u' WHERE instance = '%u'", InstanceNumber, *i);
|
||||
CharacterDatabase.PExecute("UPDATE characters SET instance_id = '%u' WHERE instance_id = '%u'", InstanceNumber, *i);
|
||||
CharacterDatabase.PExecute("UPDATE corpse SET instance = '%u' WHERE instance = '%u'", InstanceNumber, *i);
|
||||
CharacterDatabase.PExecute("UPDATE character_instance SET instance = '%u' WHERE instance = '%u'", InstanceNumber, *i);
|
||||
@@ -420,7 +397,7 @@ void InstanceSaveManager::LoadResetTimes()
|
||||
while (result->NextRow());
|
||||
|
||||
// update reset time for normal instances with the max creature respawn time + X hours
|
||||
result = WorldDatabase.Query("SELECT MAX(respawntime), instance FROM creature_respawn WHERE instance > 0 GROUP BY instance");
|
||||
result = CharacterDatabase.Query("SELECT MAX(respawntime), instance FROM creature_respawn WHERE instance > 0 GROUP BY instance");
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
|
||||
Reference in New Issue
Block a user