diff options
author | Shauren <shauren.trinity@gmail.com> | 2020-05-01 15:41:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-01 15:41:32 +0200 |
commit | 57a5969c2672b36160fea1b7c38c424de562a57b (patch) | |
tree | ee52f8ddaa8d37297142e59029df461d3000ce31 /src/server/game/Instances/InstanceSaveMgr.cpp | |
parent | fbd74eb5d8b5aa3a6874ee99044054e097b5ef21 (diff) | |
parent | 05ba662d5daaa3428cc01cdaa3794bf5a073ef17 (diff) |
Merge pull request #24500 from funjoker/cherry-picks
Diffstat (limited to 'src/server/game/Instances/InstanceSaveMgr.cpp')
-rw-r--r-- | src/server/game/Instances/InstanceSaveMgr.cpp | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp index 903e4f084d6..fdeee7535a1 100644 --- a/src/server/game/Instances/InstanceSaveMgr.cpp +++ b/src/server/game/Instances/InstanceSaveMgr.cpp @@ -168,7 +168,7 @@ void InstanceSaveManager::RemoveInstanceSave(uint32 InstanceId) { CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_INSTANCE_RESETTIME); - stmt->setUInt32(0, uint32(resettime)); + stmt->setUInt64(0, uint64(resettime)); stmt->setUInt32(1, InstanceId); CharacterDatabase.Execute(stmt); @@ -222,7 +222,7 @@ void InstanceSave::SaveToDB() CharacterDatabasePreparedStatement* 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(GetDifficultyID())); stmt->setUInt32(4, completedEncounters); stmt->setString(5, data); @@ -329,8 +329,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 { @@ -346,7 +345,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(); @@ -357,24 +356,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 (result2->NextRow()); - } - // schedule the reset times for (InstResetTimeMapDiffType::iterator itr = instResetTime.begin(); itr != instResetTime.end(); ++itr) if (itr->second.second > now) @@ -383,28 +364,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(); MapDifficultyEntry const* mapDiff = sDB2Manager.GetMapDifficultyData(mapid, difficulty); if (!mapDiff) { TC_LOG_ERROR("misc", "InstanceSaveManager::LoadResetTimes: invalid mapid(%u)/difficulty(%u) pair in instance_reset!", mapid, uint32(difficulty)); - CharacterDatabase.DirectPExecute("DELETE FROM instance_reset WHERE mapid = '%u' AND difficulty = '%u'", mapid, uint32(difficulty)); + + CharacterDatabasePreparedStatement* 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, uint32(difficulty)); + { + CharacterDatabasePreparedStatement* 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()); @@ -433,7 +423,12 @@ void InstanceSaveManager::LoadResetTimes() { // initialize the reset time t = today + period + diff; - CharacterDatabase.DirectPExecute("INSERT INTO instance_reset VALUES ('%u', '%u', '%u')", mapid, uint32(difficulty), (uint32)t); + + CharacterDatabasePreparedStatement* 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) @@ -442,7 +437,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, uint32(difficulty)); + + CharacterDatabasePreparedStatement* 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); @@ -702,7 +702,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)); |