Core/DB: Some DB improvements
This commit is contained in:
@@ -27,7 +27,7 @@ using System.Text;
|
||||
namespace Game
|
||||
{
|
||||
public sealed class AccountManager : Singleton<AccountManager>
|
||||
{
|
||||
{
|
||||
const int MaxAccountLength = 16;
|
||||
const int MaxEmailLength = 64;
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Game
|
||||
stmt.AddValue(4, null);
|
||||
stmt.AddValue(5, null);
|
||||
}
|
||||
DB.Login.Execute(stmt); // Enforce saving, otherwise AddGroup can fail
|
||||
DB.Login.DirectExecute(stmt); // Enforce saving, otherwise AddGroup can fail
|
||||
|
||||
stmt = DB.Login.GetPreparedStatement(LoginStatements.INS_REALM_CHARACTERS_INIT);
|
||||
DB.Login.Execute(stmt);
|
||||
@@ -73,7 +73,6 @@ namespace Game
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_ACCOUNT_BY_ID);
|
||||
stmt.AddValue(0, accountId);
|
||||
SQLResult result = DB.Login.Query(stmt);
|
||||
|
||||
if (result.IsEmpty())
|
||||
return AccountOpResult.NameNotExist;
|
||||
|
||||
@@ -81,7 +80,6 @@ namespace Game
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CHARS_BY_ACCOUNT_ID);
|
||||
stmt.AddValue(0, accountId);
|
||||
result = DB.Characters.Query(stmt);
|
||||
|
||||
if (!result.IsEmpty())
|
||||
{
|
||||
do
|
||||
@@ -147,7 +145,6 @@ namespace Game
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_ACCOUNT_BY_ID);
|
||||
stmt.AddValue(0, accountId);
|
||||
SQLResult result = DB.Login.Query(stmt);
|
||||
|
||||
if (result.IsEmpty())
|
||||
return AccountOpResult.NameNotExist;
|
||||
|
||||
@@ -231,7 +228,6 @@ namespace Game
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.GET_ACCOUNT_ID_BY_USERNAME);
|
||||
stmt.AddValue(0, username);
|
||||
SQLResult result = DB.Login.Query(stmt);
|
||||
|
||||
return !result.IsEmpty() ? result.Read<uint>(0) : 0;
|
||||
}
|
||||
|
||||
@@ -240,7 +236,6 @@ namespace Game
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.GET_ACCOUNT_ACCESS_GMLEVEL);
|
||||
stmt.AddValue(0, accountId);
|
||||
SQLResult result = DB.Login.Query(stmt);
|
||||
|
||||
return !result.IsEmpty() ? (AccountTypes)result.Read<byte>(0) : AccountTypes.Player;
|
||||
}
|
||||
|
||||
@@ -250,7 +245,6 @@ namespace Game
|
||||
stmt.AddValue(0, accountId);
|
||||
stmt.AddValue(1, realmId);
|
||||
SQLResult result = DB.Login.Query(stmt);
|
||||
|
||||
return !result.IsEmpty() ? (AccountTypes)result.Read<uint>(0) : AccountTypes.Player;
|
||||
}
|
||||
|
||||
@@ -260,7 +254,6 @@ namespace Game
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.GET_USERNAME_BY_ID);
|
||||
stmt.AddValue(0, accountId);
|
||||
SQLResult result = DB.Login.Query(stmt);
|
||||
|
||||
if (!result.IsEmpty())
|
||||
{
|
||||
name = result.Read<string>(0);
|
||||
@@ -276,7 +269,6 @@ namespace Game
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.GET_EMAIL_BY_ID);
|
||||
stmt.AddValue(0, accountId);
|
||||
SQLResult result = DB.Login.Query(stmt);
|
||||
|
||||
if (!result.IsEmpty())
|
||||
{
|
||||
email = result.Read<string>(0);
|
||||
@@ -297,7 +289,6 @@ namespace Game
|
||||
stmt.AddValue(0, accountId);
|
||||
stmt.AddValue(1, CalculateShaPassHash(username, password));
|
||||
SQLResult result = DB.Login.Query(stmt);
|
||||
|
||||
return result.IsEmpty() ? false : true;
|
||||
}
|
||||
|
||||
@@ -321,7 +312,6 @@ namespace Game
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_SUM_CHARS);
|
||||
stmt.AddValue(0, accountId);
|
||||
SQLResult result = DB.Characters.Query(stmt);
|
||||
|
||||
return result.IsEmpty() ? 0 : (uint)result.Read<ulong>(0);
|
||||
}
|
||||
|
||||
@@ -336,7 +326,6 @@ namespace Game
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_ACCOUNT_BANNED_BY_USERNAME);
|
||||
stmt.AddValue(0, name);
|
||||
SQLResult result = DB.Login.Query(stmt);
|
||||
|
||||
return !result.IsEmpty();
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Game
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.INS_BNET_ACCOUNT);
|
||||
stmt.AddValue(0, email);
|
||||
stmt.AddValue(1, CalculateShaPassHash(email, password));
|
||||
DB.Login.Execute(stmt);
|
||||
DB.Login.DirectExecute(stmt);
|
||||
|
||||
uint newAccountId = GetId(email);
|
||||
Contract.Assert(newAccountId != 0);
|
||||
@@ -173,7 +173,7 @@ namespace Game
|
||||
return 0;
|
||||
}
|
||||
|
||||
string CalculateShaPassHash(string name, string password)
|
||||
public string CalculateShaPassHash(string name, string password)
|
||||
{
|
||||
SHA256 sha256 = SHA256.Create();
|
||||
var i = sha256.ComputeHash(Encoding.UTF8.GetBytes(name));
|
||||
|
||||
@@ -719,10 +719,13 @@ namespace Game.Achievements
|
||||
CompletedAchievementData ca = _completedAchievements[achievementid];
|
||||
ca.Date = achievementResult.Read<uint>(1);
|
||||
var guids = new StringArray(achievementResult.Read<string>(2), ' ');
|
||||
for (int i = 0; i < guids.Length; ++i)
|
||||
if (!guids.IsEmpty())
|
||||
{
|
||||
if (ulong.TryParse(guids[i], out ulong guid))
|
||||
ca.CompletingPlayers.Add(ObjectGuid.Create(HighGuid.Player, guid));
|
||||
for (int i = 0; i < guids.Length; ++i)
|
||||
{
|
||||
if (ulong.TryParse(guids[i], out ulong guid))
|
||||
ca.CompletingPlayers.Add(ObjectGuid.Create(HighGuid.Player, guid));
|
||||
}
|
||||
}
|
||||
|
||||
ca.Changed = false;
|
||||
|
||||
@@ -79,13 +79,12 @@ namespace Game.Arenas
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
// Clean out the trash before loading anything
|
||||
DB.Characters.Execute("DELETE FROM arena_team_member WHERE arenaTeamId NOT IN (SELECT arenaTeamId FROM arena_team)"); // One-time query
|
||||
DB.Characters.DirectExecute("DELETE FROM arena_team_member WHERE arenaTeamId NOT IN (SELECT arenaTeamId FROM arena_team)"); // One-time query
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8
|
||||
SQLResult result = DB.Characters.Query("SELECT arenaTeamId, name, captainGuid, type, backgroundColor, emblemStyle, emblemColor, borderStyle, borderColor, " +
|
||||
// 9 10 11 12 13 14
|
||||
"rating, weekGames, weekWins, seasonGames, seasonWins, rank FROM arena_team ORDER BY arenaTeamId ASC");
|
||||
|
||||
if (result.IsEmpty())
|
||||
{
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 arena teams. DB table `arena_team` is empty!");
|
||||
|
||||
@@ -38,10 +38,13 @@ namespace Game.BlackMarket
|
||||
|
||||
var bonusListIDsTok = new StringArray(fields.Read<string>(7), ' ');
|
||||
List<uint> bonusListIDs = new List<uint>();
|
||||
foreach (string token in bonusListIDsTok)
|
||||
if (!bonusListIDsTok.IsEmpty())
|
||||
{
|
||||
if (uint.TryParse(token, out uint id))
|
||||
bonusListIDs.Add(id);
|
||||
foreach (string token in bonusListIDsTok)
|
||||
{
|
||||
if (uint.TryParse(token, out uint id))
|
||||
bonusListIDs.Add(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!bonusListIDs.Empty())
|
||||
|
||||
@@ -772,7 +772,7 @@ namespace Game.Chat
|
||||
{
|
||||
messageChat.Initialize(ChatMsg.System, Language.Universal, null, null, lines[i]);
|
||||
_session.SendPacket(messageChat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SendNotification(CypherStrings str, params object[] args)
|
||||
|
||||
@@ -1164,10 +1164,13 @@ namespace Game.Chat
|
||||
if (fbonuslist.IsEmpty())
|
||||
{
|
||||
var bonusListIDsTok = new StringArray(fbonuslist, ';');
|
||||
foreach (string token in bonusListIDsTok)
|
||||
if (!bonusListIDsTok.IsEmpty())
|
||||
{
|
||||
if (uint.TryParse(token, out uint id))
|
||||
vItem.BonusListIDs.Add(id);
|
||||
foreach (string token in bonusListIDsTok)
|
||||
{
|
||||
if (uint.TryParse(token, out uint id))
|
||||
vItem.BonusListIDs.Add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,6 @@ namespace Game
|
||||
if (uint.TryParse(array[i++], out uint id))
|
||||
data.param1.Add(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Game.DataStorage
|
||||
while (!(line = reader.ReadLine()).IsEmpty())
|
||||
{
|
||||
var values = new StringArray(line, '\t');
|
||||
if (values.Length == 0)
|
||||
if (values.IsEmpty())
|
||||
break;
|
||||
|
||||
var obj = new T();
|
||||
|
||||
@@ -421,11 +421,13 @@ namespace Game.Entities
|
||||
|
||||
var tokens = new StringArray(fields.Read<string>(6), ' ');
|
||||
if (tokens.Length == ItemConst.MaxProtoSpells)
|
||||
{
|
||||
for (byte i = 0; i < ItemConst.MaxProtoSpells; ++i)
|
||||
{
|
||||
if (int.TryParse(tokens[i], out int value))
|
||||
SetSpellCharges(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
SetUInt32Value(ItemFields.Flags, itemFlags);
|
||||
|
||||
@@ -466,10 +468,13 @@ namespace Game.Entities
|
||||
SetUInt32Value(ItemFields.Context, fields.Read<byte>(19));
|
||||
|
||||
var bonusListIDs = new StringArray(fields.Read<string>(20), ' ');
|
||||
for (var i = 0; i < bonusListIDs.Length; ++i)
|
||||
if (!tokens.IsEmpty())
|
||||
{
|
||||
if (uint.TryParse(tokens[i], out uint bonusListID))
|
||||
AddBonuses(bonusListID);
|
||||
for (var i = 0; i < bonusListIDs.Length; ++i)
|
||||
{
|
||||
if (uint.TryParse(tokens[i], out uint bonusListID))
|
||||
AddBonuses(bonusListID);
|
||||
}
|
||||
}
|
||||
|
||||
SetModifier(ItemModifier.TransmogAppearanceAllSpecs, fields.Read<uint>(21));
|
||||
@@ -491,11 +496,14 @@ namespace Game.Entities
|
||||
gemData[i] = new ItemDynamicFieldGems();
|
||||
gemData[i].ItemId = fields.Read<uint>(31 + i * gemFields);
|
||||
var gemBonusListIDs = new StringArray(fields.Read<string>(32 + i * gemFields), ' ');
|
||||
uint b = 0;
|
||||
foreach (string token in gemBonusListIDs)
|
||||
if (!gemBonusListIDs.IsEmpty())
|
||||
{
|
||||
if (uint.TryParse(token, out uint bonusListID) && bonusListID != 0)
|
||||
gemData[i].BonusListIDs[b++] = (ushort)bonusListID;
|
||||
uint b = 0;
|
||||
foreach (string token in gemBonusListIDs)
|
||||
{
|
||||
if (uint.TryParse(token, out uint bonusListID) && bonusListID != 0)
|
||||
gemData[i].BonusListIDs[b++] = (ushort)bonusListID;
|
||||
}
|
||||
}
|
||||
|
||||
gemData[i].Context = fields.Read<byte>(33 + i * gemFields);
|
||||
@@ -1920,10 +1928,13 @@ namespace Game.Entities
|
||||
loot_item.context = item_result.Read<byte>(11);
|
||||
|
||||
StringArray bonusLists = new StringArray(item_result.Read<string>(12), ' ');
|
||||
foreach (string line in bonusLists)
|
||||
if (!bonusLists.IsEmpty())
|
||||
{
|
||||
if (uint.TryParse(line, out uint id))
|
||||
loot_item.BonusListIDs.Add(id);
|
||||
foreach (string line in bonusLists)
|
||||
{
|
||||
if (uint.TryParse(line, out uint id))
|
||||
loot_item.BonusListIDs.Add(id);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy the extra loot conditions from the item in the loot template
|
||||
|
||||
@@ -3147,10 +3147,13 @@ namespace Game
|
||||
vItem.IgnoreFiltering = result.Read<bool>(8);
|
||||
|
||||
var bonusListIDsTok = new StringArray(result.Read<string>(6), ' ');
|
||||
foreach (string token in bonusListIDsTok)
|
||||
if (!bonusListIDsTok.IsEmpty())
|
||||
{
|
||||
if (uint.TryParse(token, out uint id))
|
||||
vItem.BonusListIDs.Add(id);
|
||||
foreach (string token in bonusListIDsTok)
|
||||
{
|
||||
if (uint.TryParse(token, out uint id))
|
||||
vItem.BonusListIDs.Add(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsVendorItemValid(entry, vItem, null, skipvendors))
|
||||
@@ -3196,10 +3199,13 @@ namespace Game
|
||||
vItem.IgnoreFiltering = result.Read<bool>(7);
|
||||
|
||||
var bonusListIDsTok = new StringArray(result.Read<string>(5), ' ');
|
||||
foreach (string token in bonusListIDsTok)
|
||||
if (!bonusListIDsTok.IsEmpty())
|
||||
{
|
||||
if (uint.TryParse(token, out uint id))
|
||||
vItem.BonusListIDs.Add(id);
|
||||
foreach (string token in bonusListIDsTok)
|
||||
{
|
||||
if (uint.TryParse(token, out uint id))
|
||||
vItem.BonusListIDs.Add(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsVendorItemValid((uint)vendor, vItem, null, skip_vendors))
|
||||
@@ -8925,8 +8931,12 @@ namespace Game
|
||||
uint itemId = rewardItem.Read<uint>(2);
|
||||
StringArray bonusListIDsTok = new StringArray(rewardItem.Read<string>(3), ' ');
|
||||
List<uint> bonusListIds = new List<uint>();
|
||||
foreach (uint token in bonusListIDsTok)
|
||||
bonusListIds.Add(token);
|
||||
if (!bonusListIDsTok.IsEmpty())
|
||||
{
|
||||
foreach (uint token in bonusListIDsTok)
|
||||
bonusListIds.Add(token);
|
||||
}
|
||||
|
||||
int quantity = rewardItem.Read<int>(4);
|
||||
|
||||
PlayerChoice choice = _playerChoices.LookupByKey(choiceId);
|
||||
|
||||
@@ -108,9 +108,9 @@ namespace Game.Groups
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
// Delete all groups whose leader does not exist
|
||||
DB.Characters.Execute("DELETE FROM groups WHERE leaderGuid NOT IN (SELECT guid FROM characters)");
|
||||
DB.Characters.DirectExecute("DELETE FROM groups WHERE leaderGuid NOT IN (SELECT guid FROM characters)");
|
||||
// Delete all groups with less than 2 members
|
||||
DB.Characters.Execute("DELETE FROM groups WHERE guid NOT IN (SELECT guid FROM group_member GROUP BY guid HAVING COUNT(guid) > 1)");
|
||||
DB.Characters.DirectExecute("DELETE FROM groups WHERE guid NOT IN (SELECT guid FROM group_member GROUP BY guid HAVING COUNT(guid) > 1)");
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9
|
||||
SQLResult result = DB.Characters.Query("SELECT g.leaderGuid, g.lootMethod, g.looterGuid, g.lootThreshold, g.icon1, g.icon2, g.icon3, g.icon4, g.icon5, g.icon6" +
|
||||
@@ -150,10 +150,10 @@ namespace Game.Groups
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
// Delete all rows from group_member or group_instance with no group
|
||||
DB.Characters.Execute("DELETE FROM group_member WHERE guid NOT IN (SELECT guid FROM groups)");
|
||||
DB.Characters.Execute("DELETE FROM group_instance WHERE guid NOT IN (SELECT guid FROM groups)");
|
||||
DB.Characters.DirectExecute("DELETE FROM group_member WHERE guid NOT IN (SELECT guid FROM groups)");
|
||||
DB.Characters.DirectExecute("DELETE FROM group_instance WHERE guid NOT IN (SELECT guid FROM groups)");
|
||||
// Delete all members that does not exist
|
||||
DB.Characters.Execute("DELETE FROM group_member WHERE memberGuid NOT IN (SELECT guid FROM characters)");
|
||||
DB.Characters.DirectExecute("DELETE FROM group_member WHERE memberGuid NOT IN (SELECT guid FROM characters)");
|
||||
|
||||
// 0 1 2 3 4
|
||||
SQLResult result = DB.Characters.Query("SELECT guid, memberGuid, memberFlags, subgroup, roles FROM group_member ORDER BY guid");
|
||||
@@ -184,6 +184,7 @@ namespace Game.Groups
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loading Group instance saves...");
|
||||
{
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
// 0 1 2 3 4 5 6 7
|
||||
SQLResult result = DB.Characters.Query("SELECT gi.guid, i.map, gi.instance, gi.permanent, i.difficulty, i.resettime, i.entranceId, COUNT(g.guid) " +
|
||||
"FROM group_instance gi INNER JOIN instance i ON gi.instance = i.id " +
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Game
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
// Delete orphaned guild rank entries before loading the valid ones
|
||||
DB.Characters.Execute("DELETE gr FROM guild_rank gr LEFT JOIN guild g ON gr.guildId = g.guildId WHERE g.guildId IS NULL");
|
||||
DB.Characters.DirectExecute("DELETE gr FROM guild_rank gr LEFT JOIN guild g ON gr.guildId = g.guildId WHERE g.guildId IS NULL");
|
||||
|
||||
// 0 1 2 3 4
|
||||
SQLResult result = DB.Characters.Query("SELECT guildid, rid, rname, rights, BankMoneyPerDay FROM guild_rank ORDER BY guildid ASC, rid ASC");
|
||||
@@ -173,8 +173,8 @@ namespace Game
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
// Delete orphaned guild member entries before loading the valid ones
|
||||
DB.Characters.Execute("DELETE gm FROM guild_member gm LEFT JOIN guild g ON gm.guildId = g.guildId WHERE g.guildId IS NULL");
|
||||
DB.Characters.Execute("DELETE gm FROM guild_member_withdraw gm LEFT JOIN guild_member g ON gm.guid = g.guid WHERE g.guid IS NULL");
|
||||
DB.Characters.DirectExecute("DELETE gm FROM guild_member gm LEFT JOIN guild g ON gm.guildId = g.guildId WHERE g.guildId IS NULL");
|
||||
DB.Characters.DirectExecute("DELETE gm FROM guild_member_withdraw gm LEFT JOIN guild_member g ON gm.guid = g.guid WHERE g.guid IS NULL");
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9 10
|
||||
SQLResult result = DB.Characters.Query("SELECT gm.guildid, gm.guid, rank, pnote, offnote, w.tab0, w.tab1, w.tab2, w.tab3, w.tab4, w.tab5, " +
|
||||
@@ -210,7 +210,7 @@ namespace Game
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
// Delete orphaned guild bank right entries before loading the valid ones
|
||||
DB.Characters.Execute("DELETE gbr FROM guild_bank_right gbr LEFT JOIN guild g ON gbr.guildId = g.guildId WHERE g.guildId IS NULL");
|
||||
DB.Characters.DirectExecute("DELETE gbr FROM guild_bank_right gbr LEFT JOIN guild g ON gbr.guildId = g.guildId WHERE g.guildId IS NULL");
|
||||
|
||||
// 0 1 2 3 4
|
||||
SQLResult result = DB.Characters.Query("SELECT guildid, TabId, rid, gbright, SlotPerDay FROM guild_bank_right ORDER BY guildid ASC, TabId ASC");
|
||||
@@ -242,7 +242,7 @@ namespace Game
|
||||
{
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
DB.Characters.Execute("DELETE FROM guild_eventlog WHERE LogGuid > {0}", GuildConst.EventLogMaxRecords);
|
||||
DB.Characters.DirectExecute("DELETE FROM guild_eventlog WHERE LogGuid > {0}", GuildConst.EventLogMaxRecords);
|
||||
|
||||
// 0 1 2 3 4 5 6
|
||||
SQLResult result = DB.Characters.Query("SELECT guildid, LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp FROM guild_eventlog ORDER BY TimeStamp DESC, LogGuid DESC");
|
||||
@@ -275,7 +275,7 @@ namespace Game
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
// Remove log entries that exceed the number of allowed entries per guild
|
||||
DB.Characters.Execute("DELETE FROM guild_bank_eventlog WHERE LogGuid > {0}", GuildConst.BankLogMaxRecords);
|
||||
DB.Characters.DirectExecute("DELETE FROM guild_bank_eventlog WHERE LogGuid > {0}", GuildConst.BankLogMaxRecords);
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8
|
||||
SQLResult result = DB.Characters.Query("SELECT guildid, TabId, LogGuid, EventType, PlayerGuid, ItemOrMoney, ItemStackCount, DestTabId, TimeStamp FROM guild_bank_eventlog ORDER BY TimeStamp DESC, LogGuid DESC");
|
||||
@@ -307,7 +307,7 @@ namespace Game
|
||||
{
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
DB.Characters.Execute("DELETE FROM guild_newslog WHERE LogGuid > {0}", GuildConst.NewsLogMaxRecords);
|
||||
DB.Characters.DirectExecute("DELETE FROM guild_newslog WHERE LogGuid > {0}", GuildConst.NewsLogMaxRecords);
|
||||
|
||||
// 0 1 2 3 4 5 6
|
||||
SQLResult result = DB.Characters.Query("SELECT guildid, LogGuid, EventType, PlayerGuid, Flags, Value, Timestamp FROM guild_newslog ORDER BY TimeStamp DESC, LogGuid DESC");
|
||||
@@ -338,7 +338,7 @@ namespace Game
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
// Delete orphaned guild bank tab entries before loading the valid ones
|
||||
DB.Characters.Execute("DELETE gbt FROM guild_bank_tab gbt LEFT JOIN guild g ON gbt.guildId = g.guildId WHERE g.guildId IS NULL");
|
||||
DB.Characters.DirectExecute("DELETE gbt FROM guild_bank_tab gbt LEFT JOIN guild g ON gbt.guildId = g.guildId WHERE g.guildId IS NULL");
|
||||
|
||||
// 0 1 2 3 4
|
||||
SQLResult result = DB.Characters.Query("SELECT guildid, TabId, TabName, TabIcon, TabText FROM guild_bank_tab ORDER BY guildid ASC, TabId ASC");
|
||||
@@ -371,7 +371,7 @@ namespace Game
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
// Delete orphan guild bank items
|
||||
DB.Characters.Execute("DELETE gbi FROM guild_bank_item gbi LEFT JOIN guild g ON gbi.guildId = g.guildId WHERE g.guildId IS NULL");
|
||||
DB.Characters.DirectExecute("DELETE gbi FROM guild_bank_item gbi LEFT JOIN guild g ON gbi.guildId = g.guildId WHERE g.guildId IS NULL");
|
||||
|
||||
SQLResult result = DB.Characters.Query(DB.Characters.GetPreparedStatement(CharStatements.SEL_GUILD_BANK_ITEMS));
|
||||
if (result.IsEmpty())
|
||||
|
||||
@@ -144,25 +144,25 @@ namespace Game.Maps
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
// Delete expired instances (Instance related spawns are removed in the following cleanup queries)
|
||||
DB.Characters.Execute("DELETE i FROM instance i LEFT JOIN instance_reset ir ON mapid = map AND i.difficulty = ir.difficulty " +
|
||||
DB.Characters.DirectExecute("DELETE i FROM instance i LEFT JOIN instance_reset ir ON mapid = map AND i.difficulty = ir.difficulty " +
|
||||
"WHERE (i.resettime > 0 AND i.resettime < UNIX_TIMESTAMP()) OR (ir.resettime IS NOT NULL AND ir.resettime < UNIX_TIMESTAMP())");
|
||||
|
||||
// Delete invalid character_instance and group_instance references
|
||||
DB.Characters.Execute("DELETE ci.* FROM character_instance AS ci LEFT JOIN characters AS c ON ci.guid = c.guid WHERE c.guid IS NULL");
|
||||
DB.Characters.Execute("DELETE gi.* FROM group_instance AS gi LEFT JOIN groups AS g ON gi.guid = g.guid WHERE g.guid IS NULL");
|
||||
DB.Characters.DirectExecute("DELETE ci.* FROM character_instance AS ci LEFT JOIN characters AS c ON ci.guid = c.guid WHERE c.guid IS NULL");
|
||||
DB.Characters.DirectExecute("DELETE gi.* FROM group_instance AS gi LEFT JOIN groups AS g ON gi.guid = g.guid WHERE g.guid IS NULL");
|
||||
|
||||
// Delete invalid instance references
|
||||
DB.Characters.Execute("DELETE i.* FROM instance AS i LEFT JOIN character_instance AS ci ON i.id = ci.instance LEFT JOIN group_instance AS gi ON i.id = gi.instance WHERE ci.guid IS NULL AND gi.guid IS NULL");
|
||||
DB.Characters.DirectExecute("DELETE i.* FROM instance AS i LEFT JOIN character_instance AS ci ON i.id = ci.instance LEFT JOIN group_instance AS gi ON i.id = gi.instance WHERE ci.guid IS NULL AND gi.guid IS NULL");
|
||||
|
||||
// Delete invalid references to instance
|
||||
DB.Characters.Execute("DELETE FROM creature_respawn WHERE instanceId > 0 AND instanceId NOT IN (SELECT id FROM instance)");
|
||||
DB.Characters.Execute("DELETE FROM gameobject_respawn WHERE instanceId > 0 AND instanceId NOT IN (SELECT id FROM instance)");
|
||||
DB.Characters.Execute("DELETE tmp.* FROM character_instance AS tmp LEFT JOIN instance ON tmp.instance = instance.id WHERE tmp.instance > 0 AND instance.id IS NULL");
|
||||
DB.Characters.Execute("DELETE tmp.* FROM group_instance AS tmp LEFT JOIN instance ON tmp.instance = instance.id WHERE tmp.instance > 0 AND instance.id IS NULL");
|
||||
DB.Characters.DirectExecute("DELETE FROM creature_respawn WHERE instanceId > 0 AND instanceId NOT IN (SELECT id FROM instance)");
|
||||
DB.Characters.DirectExecute("DELETE FROM gameobject_respawn WHERE instanceId > 0 AND instanceId NOT IN (SELECT id FROM instance)");
|
||||
DB.Characters.DirectExecute("DELETE tmp.* FROM character_instance AS tmp LEFT JOIN instance ON tmp.instance = instance.id WHERE tmp.instance > 0 AND instance.id IS NULL");
|
||||
DB.Characters.DirectExecute("DELETE tmp.* FROM group_instance AS tmp LEFT JOIN instance ON tmp.instance = instance.id WHERE tmp.instance > 0 AND instance.id IS NULL");
|
||||
|
||||
// Clean invalid references to instance
|
||||
DB.Characters.Execute("UPDATE corpse SET instanceId = 0 WHERE instanceId > 0 AND instanceId NOT IN (SELECT id FROM instance)");
|
||||
DB.Characters.Execute("UPDATE characters AS tmp LEFT JOIN instance ON tmp.instance_id = instance.id SET tmp.instance_id = 0 WHERE tmp.instance_id > 0 AND instance.id IS NULL");
|
||||
DB.Characters.DirectExecute("UPDATE corpse SET instanceId = 0 WHERE instanceId > 0 AND instanceId NOT IN (SELECT id FROM instance)");
|
||||
DB.Characters.DirectExecute("UPDATE characters AS tmp LEFT JOIN instance ON tmp.instance_id = instance.id SET tmp.instance_id = 0 WHERE tmp.instance_id > 0 AND instance.id IS NULL");
|
||||
|
||||
// Initialize instance id storage (Needs to be done after the trash has been clean out)
|
||||
Global.MapMgr.InitInstanceIds();
|
||||
@@ -225,7 +225,7 @@ namespace Game.Maps
|
||||
var pair = instResetTime.LookupByKey(instance);
|
||||
if (pair != null && pair.Item2 != resettime)
|
||||
{
|
||||
DB.Characters.Execute("UPDATE instance SET resettime = '{0}' WHERE id = '{1}'", resettime, instance);
|
||||
DB.Characters.DirectExecute("UPDATE instance SET resettime = '{0}' WHERE id = '{1}'", resettime, instance);
|
||||
instResetTime[instance] = Tuple.Create(pair.Item1, resettime);
|
||||
}
|
||||
}
|
||||
@@ -253,14 +253,14 @@ namespace Game.Maps
|
||||
if (mapDiff == null)
|
||||
{
|
||||
Log.outError(LogFilter.Server, "InstanceSaveManager.LoadResetTimes: invalid mapid({0})/difficulty({1}) pair in instance_reset!", mapid, difficulty);
|
||||
DB.Characters.Execute("DELETE FROM instance_reset WHERE mapid = '{0}' AND difficulty = '{1}'", mapid, difficulty);
|
||||
DB.Characters.DirectExecute("DELETE FROM instance_reset WHERE mapid = '{0}' AND difficulty = '{1}'", mapid, difficulty);
|
||||
continue;
|
||||
}
|
||||
|
||||
// update the reset time if the hour in the configs changes
|
||||
ulong newresettime = (oldresettime / Time.Day) * Time.Day + diff;
|
||||
if (oldresettime != newresettime)
|
||||
DB.Characters.Execute("UPDATE instance_reset SET resettime = '{0}' WHERE mapid = '{1}' AND difficulty = '{2}'", newresettime, mapid, difficulty);
|
||||
DB.Characters.DirectExecute("UPDATE instance_reset SET resettime = '{0}' WHERE mapid = '{1}' AND difficulty = '{2}'", newresettime, mapid, difficulty);
|
||||
|
||||
InitializeResetTimeFor(mapid, difficulty, (long)newresettime);
|
||||
} while (result.NextRow());
|
||||
@@ -289,7 +289,7 @@ namespace Game.Maps
|
||||
{
|
||||
// initialize the reset time
|
||||
t = today + period + diff;
|
||||
DB.Characters.Execute("INSERT INTO instance_reset VALUES ('{0}', '{1}', '{2}')", mapid, (uint)difficulty, (uint)t);
|
||||
DB.Characters.DirectExecute("INSERT INTO instance_reset VALUES ('{0}', '{1}', '{2}')", mapid, (uint)difficulty, (uint)t);
|
||||
}
|
||||
|
||||
if (t < now)
|
||||
@@ -298,7 +298,7 @@ namespace Game.Maps
|
||||
// calculate the next reset time
|
||||
t = (t / Time.Day) * Time.Day;
|
||||
t += ((today - t) / period + 1) * period + diff;
|
||||
DB.Characters.Execute("UPDATE instance_reset SET resettime = '{0}' WHERE mapid = '{1}' AND difficulty= '{2}'", t, mapid, (uint)difficulty);
|
||||
DB.Characters.DirectExecute("UPDATE instance_reset SET resettime = '{0}' WHERE mapid = '{1}' AND difficulty= '{2}'", t, mapid, (uint)difficulty);
|
||||
}
|
||||
|
||||
InitializeResetTimeFor(mapid, difficulty, t);
|
||||
@@ -566,7 +566,7 @@ namespace Game.Maps
|
||||
((InstanceMap)map2).Reset(InstanceResetMethod.Global);
|
||||
}
|
||||
|
||||
/// @todo delete creature/gameobject respawn times even if the maps are not loaded
|
||||
// @todo delete creature/gameobject respawn times even if the maps are not loaded
|
||||
}
|
||||
|
||||
public uint GetNumBoundPlayersTotal()
|
||||
|
||||
@@ -62,8 +62,8 @@ namespace Game
|
||||
|
||||
// NOTE: In order to have persistentFlags be set in worldstates for the next cleanup,
|
||||
// you need to define them at least once in worldstates.
|
||||
flags &= (CleaningFlags) WorldConfig.GetIntValue(WorldCfg.PersistentCharacterCleanFlags);
|
||||
DB.Characters.Execute("UPDATE worldstates SET value = {0} WHERE entry = {1}", flags, (uint)WorldStates.CleaningFlags);
|
||||
flags &= (CleaningFlags)WorldConfig.GetIntValue(WorldCfg.PersistentCharacterCleanFlags);
|
||||
DB.Characters.DirectExecute("UPDATE worldstates SET value = {0} WHERE entry = {1}", flags, (uint)WorldStates.CleaningFlags);
|
||||
|
||||
Global.WorldMgr.SetCleaningFlags(flags);
|
||||
|
||||
@@ -150,13 +150,13 @@ namespace Game
|
||||
|
||||
static void CleanCharacterTalent()
|
||||
{
|
||||
DB.Characters.Execute("DELETE FROM character_talent WHERE talentGroup > {0}", PlayerConst.MaxSpecializations);
|
||||
DB.Characters.DirectExecute("DELETE FROM character_talent WHERE talentGroup > {0}", PlayerConst.MaxSpecializations);
|
||||
CheckUnique("talentId", "character_talent", TalentCheck);
|
||||
}
|
||||
|
||||
static void CleanCharacterQuestStatus()
|
||||
{
|
||||
DB.Characters.Execute("DELETE FROM character_queststatus WHERE status = 0");
|
||||
DB.Characters.DirectExecute("DELETE FROM character_queststatus WHERE status = 0");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user