Core/Instance: stop updating the instance resettimes based on creature respawns
Port From (https://github.com/TrinityCore/TrinityCore/commit/7dcc185a151745c8a12e23708bb5d457e5796032)
This commit is contained in:
@@ -425,7 +425,6 @@ namespace Framework.Database
|
||||
PrepareStatement(CharStatements.REP_CREATURE_RESPAWN, "REPLACE INTO creature_respawn (guid, respawnTime, mapId, instanceId) VALUES (?, ?, ?, ?)");
|
||||
PrepareStatement(CharStatements.DEL_CREATURE_RESPAWN, "DELETE FROM creature_respawn WHERE guid = ? AND mapId = ? AND instanceId = ?");
|
||||
PrepareStatement(CharStatements.DEL_CREATURE_RESPAWN_BY_INSTANCE, "DELETE FROM creature_respawn WHERE mapId = ? AND instanceId = ?");
|
||||
PrepareStatement(CharStatements.SEL_MAX_CREATURE_RESPAWNS, "SELECT MAX(respawnTime), instanceId FROM creature_respawn WHERE instanceId > 0 GROUP BY instanceId");
|
||||
|
||||
// Gameobject respawn
|
||||
PrepareStatement(CharStatements.SEL_GO_RESPAWNS, "SELECT guid, respawnTime FROM gameobject_respawn WHERE mapId = ? AND instanceId = ?");
|
||||
@@ -504,6 +503,8 @@ namespace Framework.Database
|
||||
PrepareStatement(CharStatements.DEL_GROUP_INSTANCE_BY_GUID, "DELETE FROM group_instance WHERE guid = ? AND instance = ?");
|
||||
PrepareStatement(CharStatements.REP_GROUP_INSTANCE, "REPLACE INTO group_instance (guid, instance, permanent) VALUES (?, ?, ?)");
|
||||
PrepareStatement(CharStatements.UPD_INSTANCE_RESETTIME, "UPDATE instance SET resettime = ? WHERE id = ?");
|
||||
PrepareStatement(CharStatements.INS_GLOBAL_INSTANCE_RESETTIME, "INSERT INTO instance_reset (mapid, difficulty, resettime) VALUES (?, ?, ?)");
|
||||
PrepareStatement(CharStatements.DEL_GLOBAL_INSTANCE_RESETTIME, "DELETE FROM instance_reset WHERE mapid = ? AND difficulty = ?");
|
||||
PrepareStatement(CharStatements.UPD_GLOBAL_INSTANCE_RESETTIME, "UPDATE instance_reset SET resettime = ? WHERE mapid = ? AND difficulty = ?");
|
||||
PrepareStatement(CharStatements.UPD_CHAR_ONLINE, "UPDATE characters SET online = 1 WHERE guid = ?");
|
||||
PrepareStatement(CharStatements.UPD_CHAR_NAME_AT_LOGIN, "UPDATE characters SET name = ?, at_login = ? WHERE guid = ?");
|
||||
@@ -1099,7 +1100,6 @@ namespace Framework.Database
|
||||
REP_CREATURE_RESPAWN,
|
||||
DEL_CREATURE_RESPAWN,
|
||||
DEL_CREATURE_RESPAWN_BY_INSTANCE,
|
||||
SEL_MAX_CREATURE_RESPAWNS,
|
||||
|
||||
SEL_GO_RESPAWNS,
|
||||
REP_GO_RESPAWN,
|
||||
@@ -1159,6 +1159,8 @@ namespace Framework.Database
|
||||
DEL_GROUP_INSTANCE_BY_GUID,
|
||||
REP_GROUP_INSTANCE,
|
||||
UPD_INSTANCE_RESETTIME,
|
||||
INS_GLOBAL_INSTANCE_RESETTIME,
|
||||
DEL_GLOBAL_INSTANCE_RESETTIME,
|
||||
UPD_GLOBAL_INSTANCE_RESETTIME,
|
||||
UPD_CHAR_ONLINE,
|
||||
UPD_CHAR_NAME_AT_LOGIN,
|
||||
|
||||
@@ -1030,7 +1030,7 @@ namespace Game.Entities
|
||||
byte difficulty = result.Read<byte>(3);
|
||||
BindExtensionState extendState = (BindExtensionState)result.Read<byte>(4);
|
||||
|
||||
long resetTime = result.Read<uint>(5);
|
||||
long resetTime = result.Read<long>(5);
|
||||
// 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
|
||||
|
||||
@@ -1609,7 +1609,7 @@ namespace Game.Entities
|
||||
{
|
||||
// the reset time is set but not added to the scheduler
|
||||
// until the players leave the instance
|
||||
long resettime = creature.GetRespawnTimeEx() + 2 * Time.Hour;
|
||||
long resettime = GameTime.GetGameTime() + 2 * Time.Hour;
|
||||
InstanceSave save = Global.InstanceSaveMgr.GetInstanceSave(creature.GetInstanceId());
|
||||
if (save != null)
|
||||
if (save.GetResetTime() < resettime)
|
||||
|
||||
@@ -126,10 +126,8 @@ namespace Game.Maps
|
||||
if (resettime != 0)
|
||||
{
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_INSTANCE_RESETTIME);
|
||||
|
||||
stmt.AddValue(0, resettime);
|
||||
stmt.AddValue(1, InstanceId);
|
||||
|
||||
DB.Characters.Execute(stmt);
|
||||
}
|
||||
|
||||
@@ -208,7 +206,7 @@ namespace Game.Maps
|
||||
|
||||
// Mark instance id as being used
|
||||
Global.MapMgr.RegisterInstanceId(instanceId);
|
||||
long resettime = result.Read<uint>(3);
|
||||
long resettime = result.Read<long>(3);
|
||||
if (resettime != 0)
|
||||
{
|
||||
uint mapid = result.Read<ushort>(1);
|
||||
@@ -220,24 +218,6 @@ namespace Game.Maps
|
||||
}
|
||||
while (result.NextRow());
|
||||
|
||||
// update reset time for normal instances with the max creature respawn time + X hours
|
||||
SQLResult result2 = DB.Characters.Query(DB.Characters.GetPreparedStatement(CharStatements.SEL_MAX_CREATURE_RESPAWNS));
|
||||
if (!result2.IsEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
uint instance = result2.Read<uint>(1);
|
||||
long resettime = result2.Read<uint>(0) + 2 * Time.Hour;
|
||||
var pair = instResetTime.LookupByKey(instance);
|
||||
if (pair != null && pair.Item2 != resettime)
|
||||
{
|
||||
DB.Characters.DirectExecute("UPDATE instance SET resettime = '{0}' WHERE id = '{1}'", resettime, instance);
|
||||
instResetTime[instance] = Tuple.Create(pair.Item1, resettime);
|
||||
}
|
||||
}
|
||||
while (result2.NextRow());
|
||||
}
|
||||
|
||||
// schedule the reset times
|
||||
foreach (var pair in instResetTime)
|
||||
if (pair.Value.Item2 > now)
|
||||
@@ -253,22 +233,31 @@ namespace Game.Maps
|
||||
{
|
||||
uint mapid = result.Read<ushort>(0);
|
||||
Difficulty difficulty = (Difficulty)result.Read<byte>(1);
|
||||
ulong oldresettime = result.Read<uint>(2);
|
||||
long oldresettime = result.Read<long>(2);
|
||||
|
||||
MapDifficultyRecord mapDiff = Global.DB2Mgr.GetMapDifficultyData(mapid, difficulty);
|
||||
if (mapDiff == null)
|
||||
{
|
||||
Log.outError(LogFilter.Server, "InstanceSaveManager.LoadResetTimes: invalid mapid({0})/difficulty({1}) pair in instance_reset!", mapid, difficulty);
|
||||
DB.Characters.DirectExecute("DELETE FROM instance_reset WHERE mapid = '{0}' AND difficulty = '{1}'", mapid, difficulty);
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_GLOBAL_INSTANCE_RESETTIME);
|
||||
stmt.AddValue(0, mapid);
|
||||
stmt.AddValue(1, (byte)difficulty);
|
||||
DB.Characters.DirectExecute(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
// update the reset time if the hour in the configs changes
|
||||
ulong newresettime = (oldresettime / Time.Day) * Time.Day + diff;
|
||||
long newresettime = (oldresettime / Time.Day) * Time.Day + diff;
|
||||
if (oldresettime != newresettime)
|
||||
DB.Characters.DirectExecute("UPDATE instance_reset SET resettime = '{0}' WHERE mapid = '{1}' AND difficulty = '{2}'", newresettime, mapid, difficulty);
|
||||
{
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_GLOBAL_INSTANCE_RESETTIME);
|
||||
stmt.AddValue(0, newresettime);
|
||||
stmt.AddValue(1, mapid);
|
||||
stmt.AddValue(2, (byte)difficulty);
|
||||
DB.Characters.DirectExecute(stmt);
|
||||
}
|
||||
|
||||
InitializeResetTimeFor(mapid, difficulty, (long)newresettime);
|
||||
InitializeResetTimeFor(mapid, difficulty, newresettime);
|
||||
} while (result.NextRow());
|
||||
}
|
||||
|
||||
@@ -295,7 +284,12 @@ namespace Game.Maps
|
||||
{
|
||||
// initialize the reset time
|
||||
t = today + period + diff;
|
||||
DB.Characters.DirectExecute("INSERT INTO instance_reset VALUES ('{0}', '{1}', '{2}')", mapid, (uint)difficulty, (uint)t);
|
||||
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_GLOBAL_INSTANCE_RESETTIME);
|
||||
stmt.AddValue(0, mapid);
|
||||
stmt.AddValue(1, (byte)difficulty);
|
||||
stmt.AddValue(2, t);
|
||||
DB.Characters.DirectExecute(stmt);
|
||||
}
|
||||
|
||||
if (t < now)
|
||||
@@ -304,7 +298,12 @@ namespace Game.Maps
|
||||
// calculate the next reset time
|
||||
t = (t / Time.Day) * Time.Day;
|
||||
t += ((today - t) / period + 1) * period + diff;
|
||||
DB.Characters.DirectExecute("UPDATE instance_reset SET resettime = '{0}' WHERE mapid = '{1}' AND difficulty= '{2}'", t, mapid, (uint)difficulty);
|
||||
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_GLOBAL_INSTANCE_RESETTIME);
|
||||
stmt.AddValue(0, t);
|
||||
stmt.AddValue(1, mapid);
|
||||
stmt.AddValue(2, (byte)difficulty);
|
||||
DB.Characters.DirectExecute(stmt);
|
||||
}
|
||||
|
||||
InitializeResetTimeFor(mapid, difficulty, t);
|
||||
|
||||
@@ -2553,7 +2553,7 @@ namespace Game.Maps
|
||||
do
|
||||
{
|
||||
var loguid = result.Read<uint>(0);
|
||||
var respawnTime = result.Read<uint>(1);
|
||||
var respawnTime = result.Read<long>(1);
|
||||
|
||||
_creatureRespawnTimes[loguid] = respawnTime;
|
||||
} while (result.NextRow());
|
||||
@@ -2568,7 +2568,7 @@ namespace Game.Maps
|
||||
do
|
||||
{
|
||||
var loguid = result.Read<uint>(0);
|
||||
var respawnTime = result.Read<uint>(1);
|
||||
var respawnTime = result.Read<long>(1);
|
||||
|
||||
_goRespawnTimes[loguid] = respawnTime;
|
||||
} while (result.NextRow());
|
||||
|
||||
@@ -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';
|
||||
Reference in New Issue
Block a user