Make PreparedStatements static for each database.

This commit is contained in:
hondacrx
2023-02-04 20:55:14 -05:00
parent e0e20b6b1c
commit 149fadccab
90 changed files with 922 additions and 923 deletions
@@ -270,13 +270,13 @@ namespace Game.Maps
$"{entries.MapDifficulty.DifficultyID}-{CliDB.DifficultyStorage.LookupByKey(entries.MapDifficulty.DifficultyID).Name}] Expired instance lock for {playerGuid} in instance {updateEvent.InstanceId} is now active");
}
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_CHARACTER_INSTANCE_LOCK);
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.DEL_CHARACTER_INSTANCE_LOCK);
stmt.AddValue(0, playerGuid.GetCounter());
stmt.AddValue(1, entries.MapDifficulty.MapID);
stmt.AddValue(2, entries.MapDifficulty.LockID);
trans.Append(stmt);
stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_CHARACTER_INSTANCE_LOCK);
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.INS_CHARACTER_INSTANCE_LOCK);
stmt.AddValue(0, playerGuid.GetCounter());
stmt.AddValue(1, entries.MapDifficulty.MapID);
stmt.AddValue(2, entries.MapDifficulty.LockID);
@@ -308,11 +308,11 @@ namespace Game.Maps
if (updateEvent.EntranceWorldSafeLocId.HasValue)
sharedData.EntranceWorldSafeLocId = updateEvent.EntranceWorldSafeLocId.Value;
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_INSTANCE);
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.DEL_INSTANCE);
stmt.AddValue(0, sharedData.InstanceId);
trans.Append(stmt);
stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_INSTANCE);
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.INS_INSTANCE);
stmt.AddValue(0, sharedData.InstanceId);
stmt.AddValue(1, sharedData.Data);
stmt.AddValue(2, sharedData.CompletedEncountersMask);
@@ -326,7 +326,7 @@ namespace Game.Maps
return;
_instanceLockDataById.Remove(instanceId);
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_INSTANCE);
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.DEL_INSTANCE);
stmt.AddValue(0, instanceId);
DB.Characters.Execute(stmt);
Log.outDebug(LogFilter.Instance, $"Deleting instance {instanceId} as it is no longer referenced by any player");
@@ -339,7 +339,7 @@ namespace Game.Maps
{
DateTime oldExpiryTime = instanceLock.GetEffectiveExpiryTime();
instanceLock.SetExtended(extended);
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHARACTER_INSTANCE_LOCK_EXTENSION);
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.UPD_CHARACTER_INSTANCE_LOCK_EXTENSION);
stmt.AddValue(0, extended ? 1 : 0);
stmt.AddValue(1, playerGuid.GetCounter());
stmt.AddValue(2, entries.MapDifficulty.MapID);
@@ -395,7 +395,7 @@ namespace Game.Maps
instanceLock.SetExpiryTime(newExpiryTime);
instanceLock.SetExtended(false);
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHARACTER_INSTANCE_LOCK_FORCE_EXPIRE);
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.UPD_CHARACTER_INSTANCE_LOCK_FORCE_EXPIRE);
stmt.AddValue(0, (ulong)Time.DateTimeToUnixTime(newExpiryTime));
stmt.AddValue(1, playerGuid.GetCounter());
stmt.AddValue(2, entries.MapDifficulty.MapID);
+8 -8
View File
@@ -2052,7 +2052,7 @@ namespace Game.Maps
if (Instanceable())
return;
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_RESPAWN);
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.DEL_RESPAWN);
stmt.AddValue(0, (ushort)type);
stmt.AddValue(1, spawnId);
stmt.AddValue(2, GetId());
@@ -2692,7 +2692,7 @@ namespace Game.Maps
if (Instanceable())
return;
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.REP_RESPAWN);
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.REP_RESPAWN);
stmt.AddValue(0, (ushort)info.type);
stmt.AddValue(1, info.spawnId);
stmt.AddValue(2, info.respawnTime);
@@ -2706,7 +2706,7 @@ namespace Game.Maps
if (Instanceable())
return;
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_RESPAWNS);
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.SEL_RESPAWNS);
stmt.AddValue(0, GetId());
stmt.AddValue(1, GetInstanceId());
SQLResult result = DB.Characters.Query(stmt);
@@ -2744,7 +2744,7 @@ namespace Game.Maps
if (Instanceable())
return;
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_ALL_RESPAWNS);
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.DEL_ALL_RESPAWNS);
stmt.AddValue(0, GetId());
stmt.AddValue(1, GetInstanceId());
DB.Characters.Execute(stmt);
@@ -2768,7 +2768,7 @@ namespace Game.Maps
public void LoadCorpseData()
{
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CORPSES);
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.SEL_CORPSES);
stmt.AddValue(0, GetId());
stmt.AddValue(1, GetInstanceId());
@@ -2781,7 +2781,7 @@ namespace Game.Maps
MultiMap<ulong, uint> phases = new();
MultiMap<ulong, ChrCustomizationChoice> customizations = new();
stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CORPSE_PHASES);
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.SEL_CORPSE_PHASES);
stmt.AddValue(0, GetId());
stmt.AddValue(1, GetInstanceId());
@@ -2800,7 +2800,7 @@ namespace Game.Maps
} while (phaseResult.NextRow());
}
stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CORPSE_CUSTOMIZATIONS);
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.SEL_CORPSE_CUSTOMIZATIONS);
stmt.AddValue(0, GetId());
stmt.AddValue(1, GetInstanceId());
@@ -2847,7 +2847,7 @@ namespace Game.Maps
public void DeleteCorpseData()
{
// DELETE cp, c FROM corpse_phases cp INNER JOIN corpse c ON cp.OwnerGuid = c.guid WHERE c.mapId = ? AND c.instanceId = ?
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_CORPSES_FROM_MAP);
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.DEL_CORPSES_FROM_MAP);
stmt.AddValue(0, GetId());
stmt.AddValue(1, GetInstanceId());
DB.Characters.Execute(stmt);