aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2017-04-11 23:57:29 -0300
committerariel- <ariel-@users.noreply.github.com>2017-04-12 02:19:55 -0300
commit4c593f12caa162c1bfb831bdbed934bb39155ddb (patch)
tree57dfc52e6a0f38e2f9a1a382ea8722d6764e5505
parente32a4f26aaa51fba2647aeb8ef751dd398bc09d8 (diff)
Core/Instance: stop updating the instance resettimes based on creature respawns
- Rather update normal instance reset time to 2 hours after last creature kill - This fixes yet another integer overflow due to the possibility of having time_t max showing up - Also change respawntime and resettime fields to bigint on respawn/instance related tables - Start using prepared statements on the InstanceSaveMgr
-rw-r--r--sql/base/characters_database.sql10
-rw-r--r--sql/updates/characters/3.3.5/2017_04_12_01_characters.sql4
-rw-r--r--src/server/database/Database/Implementation/CharacterDatabase.cpp5
-rw-r--r--src/server/database/Database/Implementation/CharacterDatabase.h3
-rw-r--r--src/server/game/Entities/Player/Player.cpp5
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp2
-rw-r--r--src/server/game/Instances/InstanceSaveMgr.cpp62
-rw-r--r--src/server/game/Maps/Map.cpp8
8 files changed, 53 insertions, 46 deletions
diff --git a/sql/base/characters_database.sql b/sql/base/characters_database.sql
index 9e02a5cada7..caa9e5a93ac 100644
--- a/sql/base/characters_database.sql
+++ b/sql/base/characters_database.sql
@@ -1427,7 +1427,7 @@ DROP TABLE IF EXISTS `creature_respawn`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `creature_respawn` (
`guid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Global Unique Identifier',
- `respawnTime` int(10) unsigned NOT NULL DEFAULT '0',
+ `respawnTime` bigint(20) unsigned NOT NULL DEFAULT '0',
`mapId` smallint(10) unsigned NOT NULL DEFAULT '0',
`instanceId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Instance Identifier',
PRIMARY KEY (`guid`,`instanceId`),
@@ -1501,7 +1501,7 @@ DROP TABLE IF EXISTS `gameobject_respawn`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `gameobject_respawn` (
`guid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Global Unique Identifier',
- `respawnTime` int(10) unsigned NOT NULL DEFAULT '0',
+ `respawnTime` bigint(20) unsigned NOT NULL DEFAULT '0',
`mapId` smallint(10) unsigned NOT NULL DEFAULT '0',
`instanceId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Instance Identifier',
PRIMARY KEY (`guid`,`instanceId`),
@@ -1972,7 +1972,7 @@ DROP TABLE IF EXISTS `instance`;
CREATE TABLE `instance` (
`id` int(10) unsigned NOT NULL DEFAULT '0',
`map` smallint(5) unsigned NOT NULL DEFAULT '0',
- `resettime` int(10) unsigned NOT NULL DEFAULT '0',
+ `resettime` bigint(20) unsigned NOT NULL DEFAULT '0',
`difficulty` tinyint(3) unsigned NOT NULL DEFAULT '0',
`completedEncounters` int(10) unsigned NOT NULL DEFAULT '0',
`data` tinytext NOT NULL,
@@ -2002,7 +2002,7 @@ DROP TABLE IF EXISTS `instance_reset`;
CREATE TABLE `instance_reset` (
`mapid` smallint(5) unsigned NOT NULL DEFAULT '0',
`difficulty` tinyint(3) unsigned NOT NULL DEFAULT '0',
- `resettime` int(10) unsigned NOT NULL DEFAULT '0',
+ `resettime` bigint(20) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`mapid`,`difficulty`),
KEY `difficulty` (`difficulty`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -2568,7 +2568,7 @@ CREATE TABLE `updates` (
LOCK TABLES `updates` WRITE;
/*!40000 ALTER TABLE `updates` DISABLE KEYS */;
-INSERT INTO `updates` VALUES ('2015_03_20_00_characters.sql','B761760804EA73BD297F296C5C1919687DF7191C','ARCHIVED','2015-03-21 21:44:15',0),('2015_03_20_01_characters.sql','894F08B70449A5481FFAF394EE5571D7FC4D8A3A','ARCHIVED','2015-03-21 21:44:15',0),('2015_03_20_02_characters.sql','97D7BE0CAADC79F3F11B9FD296B8C6CD40FE593B','ARCHIVED','2015-03-21 21:44:51',0),('2015_06_26_00_characters_335.sql','C2CC6E50AFA1ACCBEBF77CC519AAEB09F3BBAEBC','ARCHIVED','2015-07-13 23:49:22',0),('2015_09_28_00_characters_335.sql','F8682A431D50E54BDC4AC0E7DBED21AE8AAB6AD4','ARCHIVED','2015-09-28 21:00:00',0),('2015_08_26_00_characters_335.sql','C7D6A3A00FECA3EBFF1E71744CA40D3076582374','ARCHIVED','2015-08-26 21:00:00',0),('2015_10_06_00_characters.sql','16842FDD7E8547F2260D3312F53EFF8761EFAB35','ARCHIVED','2015-10-06 16:06:38',0),('2015_10_07_00_characters.sql','E15AB463CEBE321001D7BFDEA4B662FF618728FD','ARCHIVED','2015-10-07 23:32:00',0),('2015_10_12_00_characters.sql','D6F9927BDED72AD0A81D6EC2C6500CBC34A39FA2','ARCHIVED','2015-10-12 15:35:47',0),('2015_10_28_00_characters.sql','622A9CA8FCE690429EBE23BA071A37C7A007BF8B','ARCHIVED','2015-10-19 14:32:22',0),('2015_10_29_00_characters_335.sql','4555A7F35C107E54C13D74D20F141039ED42943E','ARCHIVED','2015-10-29 17:05:43',0),('2015_11_03_00_characters.sql','CC045717B8FDD9733351E52A5302560CD08AAD57','ARCHIVED','2015-10-12 15:23:33',0),('2015_11_07_00_characters.sql','0ACDD35EC9745231BCFA701B78056DEF94D0CC53','ARCHIVED','2016-04-11 00:42:36',94),('2016_02_10_00_characters.sql','F1B4DA202819CABC7319A4470A2D224A34609E97','ARCHIVED','2016-02-10 00:00:00',0),('2016_03_13_2016_01_05_00_characters.sql','0EAD24977F40DE2476B4567DA2B477867CC0DA1A','ARCHIVED','2016-03-13 20:03:56',0),('2016_04_11_00_characters.sql','0ACDD35EC9745231BCFA701B78056DEF94D0CC53','ARCHIVED','2016-04-11 03:18:17',0),('2016_09_13_00_characters.sql','27A04615B11B2CFC3A26778F52F74C071E4F9C54','ARCHIVED','2016-07-06 18:55:18',0),('2016_10_16_00_characters.sql','0ACDD35EC9745231BCFA701B78056DEF94D0CC53','ARCHIVED','2016-10-16 14:02:49',35),('2016_10_30_00_characters.sql','7E2D5B226907B5A9AF320797F46E86DC27B7EC90','ARCHIVED','2016-10-30 00:00:00',0),('2017_04_03_00_characters.sql','CB072C56692C9FBF170C4036F15773DD86D368B5','RELEASED','2017-04-03 00:00:00',0),('2017_04_12_00_characters.sql','4FE3C6866A6DCD4926D451F6009464D290C2EF1F','RELEASED','2017-04-12 00:00:00',0);
+INSERT INTO `updates` VALUES ('2015_03_20_00_characters.sql','B761760804EA73BD297F296C5C1919687DF7191C','ARCHIVED','2015-03-21 21:44:15',0),('2015_03_20_01_characters.sql','894F08B70449A5481FFAF394EE5571D7FC4D8A3A','ARCHIVED','2015-03-21 21:44:15',0),('2015_03_20_02_characters.sql','97D7BE0CAADC79F3F11B9FD296B8C6CD40FE593B','ARCHIVED','2015-03-21 21:44:51',0),('2015_06_26_00_characters_335.sql','C2CC6E50AFA1ACCBEBF77CC519AAEB09F3BBAEBC','ARCHIVED','2015-07-13 23:49:22',0),('2015_09_28_00_characters_335.sql','F8682A431D50E54BDC4AC0E7DBED21AE8AAB6AD4','ARCHIVED','2015-09-28 21:00:00',0),('2015_08_26_00_characters_335.sql','C7D6A3A00FECA3EBFF1E71744CA40D3076582374','ARCHIVED','2015-08-26 21:00:00',0),('2015_10_06_00_characters.sql','16842FDD7E8547F2260D3312F53EFF8761EFAB35','ARCHIVED','2015-10-06 16:06:38',0),('2015_10_07_00_characters.sql','E15AB463CEBE321001D7BFDEA4B662FF618728FD','ARCHIVED','2015-10-07 23:32:00',0),('2015_10_12_00_characters.sql','D6F9927BDED72AD0A81D6EC2C6500CBC34A39FA2','ARCHIVED','2015-10-12 15:35:47',0),('2015_10_28_00_characters.sql','622A9CA8FCE690429EBE23BA071A37C7A007BF8B','ARCHIVED','2015-10-19 14:32:22',0),('2015_10_29_00_characters_335.sql','4555A7F35C107E54C13D74D20F141039ED42943E','ARCHIVED','2015-10-29 17:05:43',0),('2015_11_03_00_characters.sql','CC045717B8FDD9733351E52A5302560CD08AAD57','ARCHIVED','2015-10-12 15:23:33',0),('2015_11_07_00_characters.sql','0ACDD35EC9745231BCFA701B78056DEF94D0CC53','ARCHIVED','2016-04-11 00:42:36',94),('2016_02_10_00_characters.sql','F1B4DA202819CABC7319A4470A2D224A34609E97','ARCHIVED','2016-02-10 00:00:00',0),('2016_03_13_2016_01_05_00_characters.sql','0EAD24977F40DE2476B4567DA2B477867CC0DA1A','ARCHIVED','2016-03-13 20:03:56',0),('2016_04_11_00_characters.sql','0ACDD35EC9745231BCFA701B78056DEF94D0CC53','ARCHIVED','2016-04-11 03:18:17',0),('2016_09_13_00_characters.sql','27A04615B11B2CFC3A26778F52F74C071E4F9C54','ARCHIVED','2016-07-06 18:55:18',0),('2016_10_16_00_characters.sql','0ACDD35EC9745231BCFA701B78056DEF94D0CC53','ARCHIVED','2016-10-16 14:02:49',35),('2016_10_30_00_characters.sql','7E2D5B226907B5A9AF320797F46E86DC27B7EC90','ARCHIVED','2016-10-30 00:00:00',0),('2017_04_03_00_characters.sql','CB072C56692C9FBF170C4036F15773DD86D368B5','RELEASED','2017-04-03 00:00:00',0),('2017_04_12_00_characters.sql','4FE3C6866A6DCD4926D451F6009464D290C2EF1F','RELEASED','2017-04-12 00:00:00',0),('2017_04_12_01_characters.sql','5A8A1215E3A2356722F52CD7A64BBE03D21FBEA3','RELEASED','2017-04-12 00:00:00',0);
/*!40000 ALTER TABLE `updates` ENABLE KEYS */;
UNLOCK TABLES;
diff --git a/sql/updates/characters/3.3.5/2017_04_12_01_characters.sql b/sql/updates/characters/3.3.5/2017_04_12_01_characters.sql
new file mode 100644
index 00000000000..ed5617d2750
--- /dev/null
+++ b/sql/updates/characters/3.3.5/2017_04_12_01_characters.sql
@@ -0,0 +1,4 @@
+ALTER TABLE `creature_respawn` CHANGE `respawnTime` `respawnTime` bigint(20) unsigned NOT NULL DEFAULT '0';
+ALTER TABLE `gameobject_respawn` CHANGE `respawnTime` `respawnTime` bigint(20) unsigned NOT NULL DEFAULT '0';
+ALTER TABLE `instance` CHANGE `resettime` `resettime` bigint(20) unsigned NOT NULL DEFAULT '0';
+ALTER TABLE `instance_reset` CHANGE `resettime` `resettime` bigint(20) unsigned NOT NULL DEFAULT '0';
diff --git a/src/server/database/Database/Implementation/CharacterDatabase.cpp b/src/server/database/Database/Implementation/CharacterDatabase.cpp
index 819ff8ecc62..ca845ccd5a9 100644
--- a/src/server/database/Database/Implementation/CharacterDatabase.cpp
+++ b/src/server/database/Database/Implementation/CharacterDatabase.cpp
@@ -317,7 +317,6 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_REP_CREATURE_RESPAWN, "REPLACE INTO creature_respawn (guid, respawnTime, mapId, instanceId) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_CREATURE_RESPAWN, "DELETE FROM creature_respawn WHERE guid = ? AND mapId = ? AND instanceId = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_CREATURE_RESPAWN_BY_INSTANCE, "DELETE FROM creature_respawn WHERE mapId = ? AND instanceId = ?", CONNECTION_ASYNC);
- PrepareStatement(CHAR_SEL_MAX_CREATURE_RESPAWNS, "SELECT MAX(respawnTime), instanceId FROM creature_respawn WHERE instanceId > 0 GROUP BY instanceId", CONNECTION_SYNCH);
// Gameobject respawn
PrepareStatement(CHAR_SEL_GO_RESPAWNS, "SELECT guid, respawnTime FROM gameobject_respawn WHERE mapId = ? AND instanceId = ?", CONNECTION_SYNCH);
@@ -390,7 +389,9 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_DEL_GROUP_INSTANCE_BY_GUID, "DELETE FROM group_instance WHERE guid = ? AND instance = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_REP_GROUP_INSTANCE, "REPLACE INTO group_instance (guid, instance, permanent) VALUES (?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_UPD_INSTANCE_RESETTIME, "UPDATE instance SET resettime = ? WHERE id = ?", CONNECTION_ASYNC);
- PrepareStatement(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME, "UPDATE instance_reset SET resettime = ? WHERE mapid = ? AND difficulty = ?", CONNECTION_ASYNC);
+ PrepareStatement(CHAR_INS_GLOBAL_INSTANCE_RESETTIME, "INSERT INTO instance_reset (mapid, difficulty, resettime) VALUES (?, ?, ?)", CONNECTION_SYNCH);
+ PrepareStatement(CHAR_DEL_GLOBAL_INSTANCE_RESETTIME, "DELETE FROM instance_reset WHERE mapid = ? AND difficulty = ?", CONNECTION_SYNCH);
+ PrepareStatement(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME, "UPDATE instance_reset SET resettime = ? WHERE mapid = ? AND difficulty = ?", CONNECTION_BOTH);
PrepareStatement(CHAR_UPD_CHAR_ONLINE, "UPDATE characters SET online = 1 WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_UPD_CHAR_NAME_AT_LOGIN, "UPDATE characters set name = ?, at_login = ? WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_UPD_WORLDSTATE, "UPDATE worldstates SET value = ? WHERE entry = ?", CONNECTION_ASYNC);
diff --git a/src/server/database/Database/Implementation/CharacterDatabase.h b/src/server/database/Database/Implementation/CharacterDatabase.h
index 1991c9e4b68..28408886a8e 100644
--- a/src/server/database/Database/Implementation/CharacterDatabase.h
+++ b/src/server/database/Database/Implementation/CharacterDatabase.h
@@ -265,7 +265,6 @@ enum CharacterDatabaseStatements
CHAR_REP_CREATURE_RESPAWN,
CHAR_DEL_CREATURE_RESPAWN,
CHAR_DEL_CREATURE_RESPAWN_BY_INSTANCE,
- CHAR_SEL_MAX_CREATURE_RESPAWNS,
CHAR_SEL_GO_RESPAWNS,
CHAR_REP_GO_RESPAWN,
@@ -317,6 +316,8 @@ enum CharacterDatabaseStatements
CHAR_DEL_GROUP_INSTANCE_BY_GUID,
CHAR_REP_GROUP_INSTANCE,
CHAR_UPD_INSTANCE_RESETTIME,
+ CHAR_INS_GLOBAL_INSTANCE_RESETTIME,
+ CHAR_DEL_GLOBAL_INSTANCE_RESETTIME,
CHAR_UPD_GLOBAL_INSTANCE_RESETTIME,
CHAR_UPD_CHAR_ONLINE,
CHAR_UPD_CHAR_NAME_AT_LOGIN,
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 6f2ba8dcdd8..5db36e22530 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -18721,7 +18721,8 @@ void Player::_LoadBoundInstances(PreparedQueryResult result)
Group* group = GetGroup();
- //QueryResult* result = CharacterDatabase.PQuery("SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid));
+ // 0 1 2 3 4 5
+ // SELECT id, permanent, map, difficulty, extendState, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = ?
if (result)
{
do
@@ -18734,7 +18735,7 @@ void Player::_LoadBoundInstances(PreparedQueryResult result)
uint8 difficulty = fields[3].GetUInt8();
BindExtensionState extendState = BindExtensionState(fields[4].GetUInt8());
- time_t resetTime = time_t(fields[5].GetUInt32());
+ time_t resetTime = time_t(fields[5].GetUInt64());
// the resettime for normal instances is only saved when the InstanceSave is unloaded
// so the value read from the DB may be wrong here but only if the InstanceSave is loaded
// and in that case it is not used
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 6646254bc60..ffffdc1ea01 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -12132,7 +12132,7 @@ void Unit::Kill(Unit* victim, bool durabilityLoss)
{
// the reset time is set but not added to the scheduler
// until the players leave the instance
- time_t resettime = creature->GetRespawnTimeEx() + 2 * HOUR;
+ time_t resettime = GameTime::GetGameTime() + 2 * HOUR;
if (InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(creature->GetInstanceId()))
if (save->GetResetTime() < resettime)
save->SetResetTime(resettime);
diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp
index e48c3095e49..2b5841d2fc4 100644
--- a/src/server/game/Instances/InstanceSaveMgr.cpp
+++ b/src/server/game/Instances/InstanceSaveMgr.cpp
@@ -155,7 +155,7 @@ void InstanceSaveManager::RemoveInstanceSave(uint32 InstanceId)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_INSTANCE_RESETTIME);
- stmt->setUInt32(0, uint32(resettime));
+ stmt->setUInt64(0, uint64(resettime));
stmt->setUInt32(1, InstanceId);
CharacterDatabase.Execute(stmt);
@@ -209,7 +209,7 @@ void InstanceSave::SaveToDB()
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_INSTANCE_SAVE);
stmt->setUInt32(0, m_instanceid);
stmt->setUInt16(1, GetMapId());
- stmt->setUInt32(2, uint32(GetResetTimeForDB()));
+ stmt->setUInt64(2, uint64(GetResetTimeForDB()));
stmt->setUInt8(3, uint8(GetDifficulty()));
stmt->setUInt32(4, completedEncounters);
stmt->setString(5, data);
@@ -315,8 +315,7 @@ void InstanceSaveManager::LoadResetTimes()
typedef std::pair<ResetTimeMapDiffInstances::const_iterator, ResetTimeMapDiffInstances::const_iterator> ResetTimeMapDiffInstancesBounds;
ResetTimeMapDiffInstances mapDiffResetInstances;
- QueryResult result = CharacterDatabase.Query("SELECT id, map, difficulty, resettime FROM instance ORDER BY id ASC");
- if (result)
+ if (QueryResult result = CharacterDatabase.Query("SELECT id, map, difficulty, resettime FROM instance ORDER BY id ASC"))
{
do
{
@@ -332,7 +331,7 @@ void InstanceSaveManager::LoadResetTimes()
// Mark instance id as being used
sMapMgr->RegisterInstanceId(instanceId);
- if (time_t resettime = time_t(fields[3].GetUInt32()))
+ if (time_t resettime = time_t(fields[3].GetUInt64()))
{
uint32 mapid = fields[1].GetUInt16();
uint32 difficulty = fields[2].GetUInt8();
@@ -343,24 +342,6 @@ void InstanceSaveManager::LoadResetTimes()
}
while (result->NextRow());
- // update reset time for normal instances with the max creature respawn time + X hours
- if (PreparedQueryResult result2 = CharacterDatabase.Query(CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAX_CREATURE_RESPAWNS)))
- {
- do
- {
- Field* fields = result2->Fetch();
- uint32 instance = fields[1].GetUInt32();
- time_t resettime = time_t(fields[0].GetUInt32() + 2 * HOUR);
- InstResetTimeMapDiffType::iterator itr = instResetTime.find(instance);
- if (itr != instResetTime.end() && itr->second.second != resettime)
- {
- CharacterDatabase.DirectPExecute("UPDATE instance SET resettime = '" UI64FMTD "' WHERE id = '%u'", uint64(resettime), instance);
- itr->second.second = resettime;
- }
- }
- while (result->NextRow());
- }
-
// schedule the reset times
for (InstResetTimeMapDiffType::iterator itr = instResetTime.begin(); itr != instResetTime.end(); ++itr)
if (itr->second.second > now)
@@ -369,28 +350,37 @@ void InstanceSaveManager::LoadResetTimes()
// load the global respawn times for raid/heroic instances
uint32 diff = sWorld->getIntConfig(CONFIG_INSTANCE_RESET_TIME_HOUR) * HOUR;
- result = CharacterDatabase.Query("SELECT mapid, difficulty, resettime FROM instance_reset");
- if (result)
+ if (QueryResult result = CharacterDatabase.Query("SELECT mapid, difficulty, resettime FROM instance_reset"))
{
do
{
Field* fields = result->Fetch();
uint32 mapid = fields[0].GetUInt16();
Difficulty difficulty = Difficulty(fields[1].GetUInt8());
- uint64 oldresettime = fields[2].GetUInt32();
+ uint64 oldresettime = fields[2].GetUInt64();
MapDifficulty const* mapDiff = GetMapDifficultyData(mapid, difficulty);
if (!mapDiff)
{
TC_LOG_ERROR("misc", "InstanceSaveManager::LoadResetTimes: invalid mapid(%u)/difficulty(%u) pair in instance_reset!", mapid, difficulty);
- CharacterDatabase.DirectPExecute("DELETE FROM instance_reset WHERE mapid = '%u' AND difficulty = '%u'", mapid, difficulty);
+
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GLOBAL_INSTANCE_RESETTIME);
+ stmt->setUInt16(0, uint16(mapid));
+ stmt->setUInt8(1, uint8(difficulty));
+ CharacterDatabase.DirectExecute(stmt);
continue;
}
// update the reset time if the hour in the configs changes
uint64 newresettime = (oldresettime / DAY) * DAY + diff;
if (oldresettime != newresettime)
- CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '%u' WHERE mapid = '%u' AND difficulty = '%u'", uint32(newresettime), mapid, difficulty);
+ {
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME);
+ stmt->setUInt64(0, uint64(newresettime));
+ stmt->setUInt16(1, uint16(mapid));
+ stmt->setUInt8(2, uint8(difficulty));
+ CharacterDatabase.DirectExecute(stmt);
+ }
InitializeResetTimeFor(mapid, difficulty, newresettime);
} while (result->NextRow());
@@ -417,7 +407,12 @@ void InstanceSaveManager::LoadResetTimes()
{
// initialize the reset time
t = today + period + diff;
- CharacterDatabase.DirectPExecute("INSERT INTO instance_reset VALUES ('%u', '%u', '%u')", mapid, difficulty, (uint32)t);
+
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GLOBAL_INSTANCE_RESETTIME);
+ stmt->setUInt16(0, uint16(mapid));
+ stmt->setUInt8(1, uint8(difficulty));
+ stmt->setUInt64(2, uint64(t));
+ CharacterDatabase.DirectExecute(stmt);
}
if (t < now)
@@ -426,7 +421,12 @@ void InstanceSaveManager::LoadResetTimes()
// calculate the next reset time
t = (t / DAY) * DAY;
t += ((today - t) / period + 1) * period + diff;
- CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '" UI64FMTD "' WHERE mapid = '%u' AND difficulty= '%u'", (uint64)t, mapid, difficulty);
+
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME);
+ stmt->setUInt64(0, uint64(t));
+ stmt->setUInt16(1, uint16(mapid));
+ stmt->setUInt8(2, uint8(difficulty));
+ CharacterDatabase.DirectExecute(stmt);
}
InitializeResetTimeFor(mapid, difficulty, t);
@@ -678,7 +678,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b
// Update it in the DB
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME);
- stmt->setUInt32(0, next_reset);
+ stmt->setUInt64(0, uint64(next_reset));
stmt->setUInt16(1, uint16(mapid));
stmt->setUInt8(2, uint8(difficulty));
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 943f4bd759b..b3eb7fa275d 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -3565,7 +3565,7 @@ void Map::SaveCreatureRespawnTime(ObjectGuid::LowType dbGuid, time_t respawnTime
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CREATURE_RESPAWN);
stmt->setUInt32(0, dbGuid);
- stmt->setUInt32(1, uint32(respawnTime));
+ stmt->setUInt64(1, uint64(respawnTime));
stmt->setUInt16(2, GetId());
stmt->setUInt32(3, GetInstanceId());
CharacterDatabase.Execute(stmt);
@@ -3595,7 +3595,7 @@ void Map::SaveGORespawnTime(ObjectGuid::LowType dbGuid, time_t respawnTime)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_GO_RESPAWN);
stmt->setUInt32(0, dbGuid);
- stmt->setUInt32(1, uint32(respawnTime));
+ stmt->setUInt64(1, uint64(respawnTime));
stmt->setUInt16(2, GetId());
stmt->setUInt32(3, GetInstanceId());
CharacterDatabase.Execute(stmt);
@@ -3623,7 +3623,7 @@ void Map::LoadRespawnTimes()
{
Field* fields = result->Fetch();
ObjectGuid::LowType loguid = fields[0].GetUInt32();
- uint32 respawnTime = fields[1].GetUInt32();
+ uint64 respawnTime = fields[1].GetUInt64();
_creatureRespawnTimes[loguid] = time_t(respawnTime);
} while (result->NextRow());
@@ -3638,7 +3638,7 @@ void Map::LoadRespawnTimes()
{
Field* fields = result->Fetch();
ObjectGuid::LowType loguid = fields[0].GetUInt32();
- uint32 respawnTime = fields[1].GetUInt32();
+ uint64 respawnTime = fields[1].GetUInt64();
_goRespawnTimes[loguid] = time_t(respawnTime);
} while (result->NextRow());