mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +00:00
[10503] Move *_respawn tables to characters DB.
This allow have in `mangos` DB only world static state data. Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
c5b0593855
commit
20f4a16f01
12 changed files with 102 additions and 107 deletions
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
DROP TABLE IF EXISTS `character_db_version`;
|
||||
CREATE TABLE `character_db_version` (
|
||||
`required_10332_02_characters_pet_aura` bit(1) default NULL
|
||||
`required_10503_02_characters_gameobject_respawn` bit(1) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB';
|
||||
|
||||
--
|
||||
|
|
@ -1019,6 +1019,50 @@ LOCK TABLES `corpse` WRITE;
|
|||
/*!40000 ALTER TABLE `corpse` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `creature_respawn`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `creature_respawn`;
|
||||
CREATE TABLE `creature_respawn` (
|
||||
`guid` int(10) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier',
|
||||
`respawntime` bigint(20) NOT NULL default '0',
|
||||
`instance` mediumint(8) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`guid`,`instance`),
|
||||
KEY `instance` (`instance`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Grid Loading System';
|
||||
|
||||
--
|
||||
-- Dumping data for table `creature_respawn`
|
||||
--
|
||||
|
||||
LOCK TABLES `creature_respawn` WRITE;
|
||||
/*!40000 ALTER TABLE `creature_respawn` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `creature_respawn` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `gameobject_respawn`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `gameobject_respawn`;
|
||||
CREATE TABLE `gameobject_respawn` (
|
||||
`guid` int(10) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier',
|
||||
`respawntime` bigint(20) NOT NULL default '0',
|
||||
`instance` mediumint(8) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`guid`,`instance`),
|
||||
KEY `instance` (`instance`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Grid Loading System';
|
||||
|
||||
--
|
||||
-- Dumping data for table `gameobject_respawn`
|
||||
--
|
||||
|
||||
LOCK TABLES `gameobject_respawn` WRITE;
|
||||
/*!40000 ALTER TABLE `gameobject_respawn` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `gameobject_respawn` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `groups`
|
||||
--
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
|
|||
`version` varchar(120) default NULL,
|
||||
`creature_ai_version` varchar(120) default NULL,
|
||||
`cache_id` int(10) default '0',
|
||||
`required_10500_01_mangos_scripts` bit(1) default NULL
|
||||
`required_10503_04_mangos_gameobject_respawn` bit(1) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
|
||||
|
||||
--
|
||||
|
|
@ -1166,28 +1166,6 @@ LOCK TABLES `creature_questrelation` WRITE;
|
|||
/*!40000 ALTER TABLE `creature_questrelation` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `creature_respawn`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `creature_respawn`;
|
||||
CREATE TABLE `creature_respawn` (
|
||||
`guid` int(10) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier',
|
||||
`respawntime` bigint(20) NOT NULL default '0',
|
||||
`instance` mediumint(8) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`guid`,`instance`),
|
||||
KEY `instance` (`instance`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Grid Loading System';
|
||||
|
||||
--
|
||||
-- Dumping data for table `creature_respawn`
|
||||
--
|
||||
|
||||
LOCK TABLES `creature_respawn` WRITE;
|
||||
/*!40000 ALTER TABLE `creature_respawn` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `creature_respawn` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `creature_template`
|
||||
--
|
||||
|
|
@ -1931,28 +1909,6 @@ LOCK TABLES `gameobject_questrelation` WRITE;
|
|||
/*!40000 ALTER TABLE `gameobject_questrelation` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `gameobject_respawn`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `gameobject_respawn`;
|
||||
CREATE TABLE `gameobject_respawn` (
|
||||
`guid` int(10) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier',
|
||||
`respawntime` bigint(20) NOT NULL default '0',
|
||||
`instance` mediumint(8) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`guid`,`instance`),
|
||||
KEY `instance` (`instance`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Grid Loading System';
|
||||
|
||||
--
|
||||
-- Dumping data for table `gameobject_respawn`
|
||||
--
|
||||
|
||||
LOCK TABLES `gameobject_respawn` WRITE;
|
||||
/*!40000 ALTER TABLE `gameobject_respawn` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `gameobject_respawn` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `gameobject_scripts`
|
||||
--
|
||||
|
|
|
|||
10
sql/updates/10503_01_characters_creature_respawn.sql
Normal file
10
sql/updates/10503_01_characters_creature_respawn.sql
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
ALTER TABLE character_db_version CHANGE COLUMN required_10332_02_characters_pet_aura required_10503_01_characters_creature_respawn bit;
|
||||
|
||||
DROP TABLE IF EXISTS `creature_respawn`;
|
||||
CREATE TABLE `creature_respawn` (
|
||||
`guid` int(10) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier',
|
||||
`respawntime` bigint(20) NOT NULL default '0',
|
||||
`instance` mediumint(8) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`guid`,`instance`),
|
||||
KEY `instance` (`instance`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Grid Loading System';
|
||||
10
sql/updates/10503_02_characters_gameobject_respawn.sql
Normal file
10
sql/updates/10503_02_characters_gameobject_respawn.sql
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
ALTER TABLE character_db_version CHANGE COLUMN required_10503_01_characters_creature_respawn required_10503_02_characters_gameobject_respawn bit;
|
||||
|
||||
DROP TABLE IF EXISTS `gameobject_respawn`;
|
||||
CREATE TABLE `gameobject_respawn` (
|
||||
`guid` int(10) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier',
|
||||
`respawntime` bigint(20) NOT NULL default '0',
|
||||
`instance` mediumint(8) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`guid`,`instance`),
|
||||
KEY `instance` (`instance`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Grid Loading System';
|
||||
3
sql/updates/10503_03_mangos_creature_respawn.sql
Normal file
3
sql/updates/10503_03_mangos_creature_respawn.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE db_version CHANGE COLUMN required_10500_01_mangos_scripts required_10503_03_mangos_creature_respawn bit;
|
||||
|
||||
DROP TABLE IF EXISTS `creature_respawn`;
|
||||
3
sql/updates/10503_04_mangos_gameobject_respawn.sql
Normal file
3
sql/updates/10503_04_mangos_gameobject_respawn.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE db_version CHANGE COLUMN required_10503_03_mangos_creature_respawn required_10503_04_mangos_gameobject_respawn bit;
|
||||
|
||||
DROP TABLE IF EXISTS `gameobject_respawn`;
|
||||
|
|
@ -97,6 +97,10 @@ pkgdata_DATA = \
|
|||
10454_01_mangos_spell_proc_event.sql \
|
||||
10457_01_mangos_spell_proc_event.sql \
|
||||
10500_01_mangos_scripts.sql \
|
||||
10503_01_characters_creature_respawn.sql \
|
||||
10503_02_characters_gameobject_respawn.sql \
|
||||
10503_03_mangos_creature_respawn.sql \
|
||||
10503_04_mangos_gameobject_respawn.sql \
|
||||
README
|
||||
|
||||
## Additional files to include when running 'make dist'
|
||||
|
|
@ -174,4 +178,8 @@ EXTRA_DIST = \
|
|||
10454_01_mangos_spell_proc_event.sql \
|
||||
10457_01_mangos_spell_proc_event.sql \
|
||||
10500_01_mangos_scripts.sql \
|
||||
10503_01_characters_creature_respawn.sql \
|
||||
10503_02_characters_gameobject_respawn.sql \
|
||||
10503_03_mangos_creature_respawn.sql \
|
||||
10503_04_mangos_gameobject_respawn.sql \
|
||||
README
|
||||
|
|
|
|||
|
|
@ -288,8 +288,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
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ void InstanceResetScheduler::LoadResetTimes()
|
|||
delete result;
|
||||
|
||||
// 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
|
||||
|
|
@ -482,52 +482,13 @@ void InstanceSaveManager::CleanupInstances()
|
|||
_DelHelper(CharacterDatabase, "character_instance.guid, instance", "character_instance", "LEFT JOIN instance ON character_instance.instance = instance.id WHERE instance.id IS NULL");
|
||||
_DelHelper(CharacterDatabase, "group_instance.leaderGuid, 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
|
||||
// first, obtain total instance set
|
||||
std::set<uint32> InstanceSet;
|
||||
QueryResult *result = CharacterDatabase.Query("SELECT id FROM instance");
|
||||
if( result )
|
||||
{
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
InstanceSet.insert(fields[0].GetUInt32());
|
||||
}
|
||||
while (result->NextRow());
|
||||
delete result;
|
||||
}
|
||||
|
||||
// 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.DirectPExecute("DELETE FROM creature_respawn WHERE instance = '%u'", fields[0].GetUInt32());
|
||||
}
|
||||
while (result->NextRow());
|
||||
delete result;
|
||||
}
|
||||
|
||||
// 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.DirectPExecute("DELETE FROM gameobject_respawn WHERE instance = '%u'", fields[0].GetUInt32());
|
||||
}
|
||||
while (result->NextRow());
|
||||
delete result;
|
||||
}
|
||||
// clean unused respawn data
|
||||
CharacterDatabase.DirectExecute("DELETE FROM creature_respawn WHERE instance <> 0 AND instance NOT IN (SELECT id FROM instance)");
|
||||
CharacterDatabase.DirectExecute("DELETE FROM gameobject_respawn WHERE instance <> 0 AND instance NOT IN (SELECT id FROM instance)");
|
||||
|
||||
bar.step();
|
||||
sLog.outString();
|
||||
sLog.outString( ">> Initialized %u instances", (uint32)InstanceSet.size());
|
||||
sLog.outString( ">> Instances cleaned up");
|
||||
}
|
||||
|
||||
void InstanceSaveManager::PackInstances()
|
||||
|
|
@ -563,8 +524,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 corpse SET instance = '%u' WHERE instance = '%u'", InstanceNumber, *i);
|
||||
CharacterDatabase.PExecute("UPDATE character_instance SET instance = '%u' WHERE instance = '%u'", InstanceNumber, *i);
|
||||
CharacterDatabase.PExecute("UPDATE instance SET id = '%u' WHERE id = '%u'", InstanceNumber, *i);
|
||||
|
|
|
|||
|
|
@ -1557,11 +1557,11 @@ void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data
|
|||
void ObjectMgr::LoadCreatureRespawnTimes()
|
||||
{
|
||||
// remove outdated data
|
||||
WorldDatabase.DirectExecute("DELETE FROM creature_respawn WHERE respawntime <= UNIX_TIMESTAMP(NOW())");
|
||||
CharacterDatabase.DirectExecute("DELETE FROM creature_respawn WHERE respawntime <= UNIX_TIMESTAMP(NOW())");
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
@ -1599,11 +1599,11 @@ void ObjectMgr::LoadCreatureRespawnTimes()
|
|||
void ObjectMgr::LoadGameobjectRespawnTimes()
|
||||
{
|
||||
// remove outdated data
|
||||
WorldDatabase.DirectExecute("DELETE FROM gameobject_respawn WHERE respawntime <= UNIX_TIMESTAMP(NOW())");
|
||||
CharacterDatabase.DirectExecute("DELETE FROM gameobject_respawn WHERE respawntime <= UNIX_TIMESTAMP(NOW())");
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
@ -7184,9 +7184,9 @@ void ObjectMgr::LoadWeatherZoneChances()
|
|||
void ObjectMgr::SaveCreatureRespawnTime(uint32 loguid, uint32 instance, time_t t)
|
||||
{
|
||||
mCreatureRespawnTimes[MAKE_PAIR64(loguid,instance)] = t;
|
||||
WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE guid = '%u' AND instance = '%u'", loguid, instance);
|
||||
CharacterDatabase.PExecute("DELETE FROM creature_respawn WHERE guid = '%u' AND instance = '%u'", loguid, instance);
|
||||
if(t)
|
||||
WorldDatabase.PExecute("INSERT INTO creature_respawn VALUES ( '%u', '" UI64FMTD "', '%u' )", loguid, uint64(t), instance);
|
||||
CharacterDatabase.PExecute("INSERT INTO creature_respawn VALUES ( '%u', '" UI64FMTD "', '%u' )", loguid, uint64(t), instance);
|
||||
}
|
||||
|
||||
void ObjectMgr::DeleteCreatureData(uint32 guid)
|
||||
|
|
@ -7202,9 +7202,9 @@ void ObjectMgr::DeleteCreatureData(uint32 guid)
|
|||
void ObjectMgr::SaveGORespawnTime(uint32 loguid, uint32 instance, time_t t)
|
||||
{
|
||||
mGORespawnTimes[MAKE_PAIR64(loguid,instance)] = t;
|
||||
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)
|
||||
|
|
@ -7229,8 +7229,8 @@ void ObjectMgr::DeleteRespawnTimeForInstance(uint32 instance)
|
|||
mCreatureRespawnTimes.erase(itr);
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "10502"
|
||||
#define REVISION_NR "10503"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef __REVISION_SQL_H__
|
||||
#define __REVISION_SQL_H__
|
||||
#define REVISION_DB_CHARACTERS "required_10332_02_characters_pet_aura"
|
||||
#define REVISION_DB_MANGOS "required_10500_01_mangos_scripts"
|
||||
#define REVISION_DB_CHARACTERS "required_10503_02_characters_gameobject_respawn"
|
||||
#define REVISION_DB_MANGOS "required_10503_04_mangos_gameobject_respawn"
|
||||
#define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version"
|
||||
#endif // __REVISION_SQL_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue