From ba064327b0fe94d02d9ea29461e49c1cd15f3b11 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 21 Apr 2021 18:06:46 -0400 Subject: [PATCH] Core/DB: Fixes sometimes wrong values added to DB, also fixes errors when trying to convert updatefield to object. --- .../Networking/Services/GameUtilities.cs | 2 +- .../Framework/Database/PreparedStatement.cs | 62 ++++++++++++++++++- Source/Framework/Logging/Appender.cs | 2 +- Source/Framework/Realm/RealmManager.cs | 2 +- Source/Game/Accounts/AccountManager.cs | 4 +- Source/Game/Accounts/BNetAccountManager.cs | 4 +- Source/Game/BattleGrounds/BattleGround.cs | 4 +- Source/Game/Calendar/CalendarManager.cs | 8 +-- Source/Game/Chat/Channels/Channel.cs | 8 +-- .../Game/Chat/Commands/CharacterCommands.cs | 8 +-- Source/Game/Chat/Commands/DisableCommands.cs | 8 +-- Source/Game/Chat/Commands/GMCommands.cs | 2 +- Source/Game/Chat/Commands/NPCCommands.cs | 4 +- Source/Game/DungeonFinding/LFGManager.cs | 2 +- Source/Game/Entities/Creature/Creature.cs | 4 +- Source/Game/Entities/GameObject/GameObject.cs | 2 +- Source/Game/Entities/Pet.cs | 40 ++++++------ .../Game/Entities/Player/CollectionManager.cs | 4 +- Source/Game/Entities/Player/Player.DB.cs | 8 +-- Source/Game/Entities/Player/Player.Map.cs | 4 +- Source/Game/Entities/Player/SocialMgr.cs | 6 +- Source/Game/Events/GameEventManager.cs | 2 +- Source/Game/Globals/ObjectManager.cs | 8 +-- Source/Game/Groups/Group.cs | 8 +-- Source/Game/Guilds/Guild.cs | 14 ++--- Source/Game/Handlers/CharacterHandler.cs | 6 +- Source/Game/Handlers/NPCHandler.cs | 4 +- Source/Game/Reputation/ReputationManager.cs | 2 +- Source/Game/Server/WorldSession.cs | 4 +- Source/Game/SupportSystem/SupportTickets.cs | 2 +- 30 files changed, 149 insertions(+), 89 deletions(-) diff --git a/Source/BNetServer/Networking/Services/GameUtilities.cs b/Source/BNetServer/Networking/Services/GameUtilities.cs index d20de084f..7c2170782 100644 --- a/Source/BNetServer/Networking/Services/GameUtilities.cs +++ b/Source/BNetServer/Networking/Services/GameUtilities.cs @@ -98,7 +98,7 @@ namespace BNetServer.Networking PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.UpdBnetLastLoginInfo); stmt.AddValue(0, GetRemoteIpEndPoint().ToString()); - stmt.AddValue(1, Enum.Parse(typeof(Locale), locale)); + stmt.AddValue(1, (byte)Enum.Parse(typeof(Locale), locale)); stmt.AddValue(2, os); stmt.AddValue(3, accountInfo.Id); diff --git a/Source/Framework/Database/PreparedStatement.cs b/Source/Framework/Database/PreparedStatement.cs index 7636345f8..ed32b6b9f 100644 --- a/Source/Framework/Database/PreparedStatement.cs +++ b/Source/Framework/Database/PreparedStatement.cs @@ -30,11 +30,71 @@ namespace Framework.Database CommandText = commandText; } - public void AddValue(int index, object value) + public void AddValue(int index, sbyte value) { Parameters.Add(index, value); } + public void AddValue(int index, byte value) + { + Parameters.Add(index, value); + } + + public void AddValue(int index, short value) + { + Parameters.Add(index, value); + } + + public void AddValue(int index, ushort value) + { + Parameters.Add(index, value); + } + + public void AddValue(int index, int value) + { + Parameters.Add(index, value); + } + + public void AddValue(int index, uint value) + { + Parameters.Add(index, value); + } + + public void AddValue(int index, long value) + { + Parameters.Add(index, value); + } + + public void AddValue(int index, ulong value) + { + Parameters.Add(index, value); + } + + public void AddValue(int index, float value) + { + Parameters.Add(index, value); + } + + public void AddValue(int index, byte[] value) + { + Parameters.Add(index, value); + } + + public void AddValue(int index, string value) + { + Parameters.Add(index, value); + } + + public void AddValue(int index, bool value) + { + Parameters.Add(index, value); + } + + public void AddNull(int index) + { + Parameters.Add(index, null); + } + public void Clear() { Parameters.Clear(); diff --git a/Source/Framework/Logging/Appender.cs b/Source/Framework/Logging/Appender.cs index 822bb747e..934f4f5b8 100644 --- a/Source/Framework/Logging/Appender.cs +++ b/Source/Framework/Logging/Appender.cs @@ -141,7 +141,7 @@ class DBAppender : Appender PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.INS_LOG); stmt.AddValue(0, Time.DateTimeToUnixTime(message.mtime)); stmt.AddValue(1, realmId); - stmt.AddValue(2, message.type); + stmt.AddValue(2, message.type.ToString()); stmt.AddValue(3, (byte)message.level); stmt.AddValue(4, message.text); DB.Login.Execute(stmt); diff --git a/Source/Framework/Realm/RealmManager.cs b/Source/Framework/Realm/RealmManager.cs index 3bb43a309..c2dab5453 100644 --- a/Source/Framework/Realm/RealmManager.cs +++ b/Source/Framework/Realm/RealmManager.cs @@ -297,7 +297,7 @@ public class RealmManager : Singleton PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_BNET_GAME_ACCOUNT_LOGIN_INFO); stmt.AddValue(0, keyData); stmt.AddValue(1, clientAddress.ToString()); - stmt.AddValue(2, locale); + stmt.AddValue(2, (byte)locale); stmt.AddValue(3, os); stmt.AddValue(4, accountName); DB.Login.DirectExecute(stmt); diff --git a/Source/Game/Accounts/AccountManager.cs b/Source/Game/Accounts/AccountManager.cs index f249402cb..7b60cfb79 100644 --- a/Source/Game/Accounts/AccountManager.cs +++ b/Source/Game/Accounts/AccountManager.cs @@ -63,8 +63,8 @@ namespace Game } else { - stmt.AddValue(5, null); - stmt.AddValue(6, null); + stmt.AddNull(5); + stmt.AddNull(6); } DB.Login.DirectExecute(stmt); // Enforce saving, otherwise AddGroup can fail diff --git a/Source/Game/Accounts/BNetAccountManager.cs b/Source/Game/Accounts/BNetAccountManager.cs index 0960eba0a..effd94186 100644 --- a/Source/Game/Accounts/BNetAccountManager.cs +++ b/Source/Game/Accounts/BNetAccountManager.cs @@ -117,8 +117,8 @@ namespace Game return AccountOpResult.BadLink; PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_BNET_GAME_ACCOUNT_LINK); - stmt.AddValue(0, null); - stmt.AddValue(1, null); + stmt.AddNull(0); + stmt.AddNull(1); stmt.AddValue(2, gameAccountId); DB.Login.Execute(stmt); return AccountOpResult.Ok; diff --git a/Source/Game/BattleGrounds/BattleGround.cs b/Source/Game/BattleGrounds/BattleGround.cs index a915b90b0..04f13eba3 100644 --- a/Source/Game/BattleGrounds/BattleGround.cs +++ b/Source/Game/BattleGrounds/BattleGround.cs @@ -689,9 +689,9 @@ namespace Game.BattleGrounds stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_PVPSTATS_BATTLEGROUND); stmt.AddValue(0, battlegroundId); - stmt.AddValue(1, GetWinner()); + stmt.AddValue(1, (byte)GetWinner()); stmt.AddValue(2, GetUniqueBracketId()); - stmt.AddValue(3, GetTypeID(true)); + stmt.AddValue(3, (byte)GetTypeID(true)); DB.Characters.Execute(stmt); } diff --git a/Source/Game/Calendar/CalendarManager.cs b/Source/Game/Calendar/CalendarManager.cs index a3c6b4023..a457814dd 100644 --- a/Source/Game/Calendar/CalendarManager.cs +++ b/Source/Game/Calendar/CalendarManager.cs @@ -223,10 +223,10 @@ namespace Game stmt.AddValue(1, calendarEvent.OwnerGuid.GetCounter()); stmt.AddValue(2, calendarEvent.Title); stmt.AddValue(3, calendarEvent.Description); - stmt.AddValue(4, calendarEvent.EventType); + stmt.AddValue(4, (byte)calendarEvent.EventType); stmt.AddValue(5, calendarEvent.TextureId); stmt.AddValue(6, calendarEvent.Date); - stmt.AddValue(7, calendarEvent.Flags); + stmt.AddValue(7, (uint)calendarEvent.Flags); stmt.AddValue(8, calendarEvent.LockDate); trans.Append(stmt); DB.Characters.CommitTransaction(trans); @@ -239,9 +239,9 @@ namespace Game stmt.AddValue(1, invite.EventId); stmt.AddValue(2, invite.InviteeGuid.GetCounter()); stmt.AddValue(3, invite.SenderGuid.GetCounter()); - stmt.AddValue(4, invite.Status); + stmt.AddValue(4, (byte)invite.Status); stmt.AddValue(5, invite.ResponseTime); - stmt.AddValue(6, invite.Rank); + stmt.AddValue(6, (byte)invite.Rank); stmt.AddValue(7, invite.Note); DB.Characters.ExecuteOrAppend(trans, stmt); } diff --git a/Source/Game/Chat/Channels/Channel.cs b/Source/Game/Chat/Channels/Channel.cs index 287d083e1..25faaec8c 100644 --- a/Source/Game/Chat/Channels/Channel.cs +++ b/Source/Game/Chat/Channels/Channel.cs @@ -65,7 +65,7 @@ namespace Game.Chat { PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CHANNEL); stmt.AddValue(0, _channelName); - stmt.AddValue(1, _channelTeam); + stmt.AddValue(1, (uint)_channelTeam); SQLResult result = DB.Characters.Query(stmt); if (!result.IsEmpty()) //load @@ -97,7 +97,7 @@ namespace Game.Chat { stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_CHANNEL); stmt.AddValue(0, _channelName); - stmt.AddValue(1, _channelTeam); + stmt.AddValue(1, (uint)_channelTeam); DB.Characters.Execute(stmt); Log.outDebug(LogFilter.ChatSystem, "Channel({0}) saved in database", _channelName); } @@ -145,7 +145,7 @@ namespace Game.Chat stmt.AddValue(2, _channelPassword); stmt.AddValue(3, banlist); stmt.AddValue(4, _channelName); - stmt.AddValue(5, _channelTeam); + stmt.AddValue(5, (uint)_channelTeam); DB.Characters.Execute(stmt); Log.outDebug(LogFilter.ChatSystem, "Channel({0}) updated in database", _channelName); @@ -156,7 +156,7 @@ namespace Game.Chat { PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHANNEL_USAGE); stmt.AddValue(0, _channelName); - stmt.AddValue(1, _channelTeam); + stmt.AddValue(1, (uint)_channelTeam); DB.Characters.Execute(stmt); } diff --git a/Source/Game/Chat/Commands/CharacterCommands.cs b/Source/Game/Chat/Commands/CharacterCommands.cs index 219ec1e29..3c52fe53f 100644 --- a/Source/Game/Chat/Commands/CharacterCommands.cs +++ b/Source/Game/Chat/Commands/CharacterCommands.cs @@ -185,7 +185,7 @@ namespace Game.Chat handler.SendSysMessage(CypherStrings.RenamePlayerGuid, oldNameLink, targetGuid.ToString()); PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_ADD_AT_LOGIN_FLAG); - stmt.AddValue(0, AtLoginFlags.Rename); + stmt.AddValue(0, (ushort)AtLoginFlags.Rename); stmt.AddValue(1, targetGuid.GetCounter()); DB.Characters.Execute(stmt); } @@ -248,7 +248,7 @@ namespace Game.Chat return false; PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_ADD_AT_LOGIN_FLAG); - stmt.AddValue(0, AtLoginFlags.Customize); + stmt.AddValue(0, (ushort)AtLoginFlags.Customize); if (target) { handler.SendSysMessage(CypherStrings.CustomizePlayer, handler.GetNameLink(target)); @@ -350,7 +350,7 @@ namespace Game.Chat return false; PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_ADD_AT_LOGIN_FLAG); - stmt.AddValue(0, AtLoginFlags.ChangeFaction); + stmt.AddValue(0, (ushort)AtLoginFlags.ChangeFaction); if (target) { handler.SendSysMessage(CypherStrings.CustomizePlayer, handler.GetNameLink(target)); @@ -378,7 +378,7 @@ namespace Game.Chat return false; PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_ADD_AT_LOGIN_FLAG); - stmt.AddValue(0, AtLoginFlags.ChangeRace); + stmt.AddValue(0, (ushort)AtLoginFlags.ChangeRace); if (target) { // @todo add text into database diff --git a/Source/Game/Chat/Commands/DisableCommands.cs b/Source/Game/Chat/Commands/DisableCommands.cs index 443519b18..d2422a154 100644 --- a/Source/Game/Chat/Commands/DisableCommands.cs +++ b/Source/Game/Chat/Commands/DisableCommands.cs @@ -129,7 +129,7 @@ namespace Game.Chat.Commands PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_DISABLES); stmt.AddValue(0, entry); - stmt.AddValue(1, disableType); + stmt.AddValue(1, (byte)disableType); SQLResult result = DB.World.Query(stmt); if (!result.IsEmpty()) { @@ -139,7 +139,7 @@ namespace Game.Chat.Commands stmt = DB.World.GetPreparedStatement(WorldStatements.INS_DISABLES); stmt.AddValue(0, entry); - stmt.AddValue(1, disableType); + stmt.AddValue(1, (byte)disableType); stmt.AddValue(2, flags); stmt.AddValue(3, disableComment); DB.World.Execute(stmt); @@ -261,7 +261,7 @@ namespace Game.Chat.Commands PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_DISABLES); stmt.AddValue(0, entry); - stmt.AddValue(1, disableType); + stmt.AddValue(1, (byte)disableType); SQLResult result = DB.World.Query(stmt); if (result.IsEmpty()) { @@ -271,7 +271,7 @@ namespace Game.Chat.Commands stmt = DB.World.GetPreparedStatement(WorldStatements.DEL_DISABLES); stmt.AddValue(0, entry); - stmt.AddValue(1, disableType); + stmt.AddValue(1, (byte)disableType); DB.World.Execute(stmt); handler.SendSysMessage("Remove Disabled {0} (Id: {1})", disableTypeStr, entry); diff --git a/Source/Game/Chat/Commands/GMCommands.cs b/Source/Game/Chat/Commands/GMCommands.cs index 18ac7fb5d..ebf9880c5 100644 --- a/Source/Game/Chat/Commands/GMCommands.cs +++ b/Source/Game/Chat/Commands/GMCommands.cs @@ -169,7 +169,7 @@ namespace Game.Chat { // Get the accounts with GM Level >0 PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_GM_ACCOUNTS); - stmt.AddValue(0, AccountTypes.Moderator); + stmt.AddValue(0, (byte)AccountTypes.Moderator); stmt.AddValue(1, Global.WorldMgr.GetRealm().Id.Index); SQLResult result = DB.Login.Query(stmt); diff --git a/Source/Game/Chat/Commands/NPCCommands.cs b/Source/Game/Chat/Commands/NPCCommands.cs index 05b4afcc0..46ecadc0a 100644 --- a/Source/Game/Chat/Commands/NPCCommands.cs +++ b/Source/Game/Chat/Commands/NPCCommands.cs @@ -772,7 +772,7 @@ namespace Game.Chat // Update movement type PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_CREATURE_MOVEMENT_TYPE); - stmt.AddValue(0, MovementGeneratorType.Waypoint); + stmt.AddValue(0, (byte)MovementGeneratorType.Waypoint); stmt.AddValue(1, lowGuid); DB.World.Execute(stmt); @@ -1435,7 +1435,7 @@ namespace Game.Chat PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_CREATURE_SPAWN_DISTANCE); stmt.AddValue(0, option); - stmt.AddValue(1, mtype); + stmt.AddValue(1, (byte)mtype); stmt.AddValue(2, guidLow); DB.World.Execute(stmt); diff --git a/Source/Game/DungeonFinding/LFGManager.cs b/Source/Game/DungeonFinding/LFGManager.cs index 8334eae17..9d02e5bac 100644 --- a/Source/Game/DungeonFinding/LFGManager.cs +++ b/Source/Game/DungeonFinding/LFGManager.cs @@ -100,7 +100,7 @@ namespace Game.DungeonFinding stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_LFG_DATA); stmt.AddValue(0, db_guid); stmt.AddValue(1, GetDungeon(guid)); - stmt.AddValue(2, GetState(guid)); + stmt.AddValue(2, (uint)GetState(guid)); trans.Append(stmt); DB.Characters.CommitTransaction(trans); diff --git a/Source/Game/Entities/Creature/Creature.cs b/Source/Game/Entities/Creature/Creature.cs index e2b1ab291..6a8ede463 100644 --- a/Source/Game/Entities/Creature/Creature.cs +++ b/Source/Game/Entities/Creature/Creature.cs @@ -1207,12 +1207,12 @@ namespace Game.Entities stmt.AddValue(index++, 0); stmt.AddValue(index++, GetHealth()); stmt.AddValue(index++, GetPower(PowerType.Mana)); - stmt.AddValue(index++, GetDefaultMovementType()); + stmt.AddValue(index++, (byte)GetDefaultMovementType()); stmt.AddValue(index++, npcflag); stmt.AddValue(index++, unitFlags); stmt.AddValue(index++, unitFlags2); stmt.AddValue(index++, unitFlags3); - stmt.AddValue(index++, dynamicflags); + stmt.AddValue(index++, (uint)dynamicflags); trans.Append(stmt); DB.World.CommitTransaction(trans); diff --git a/Source/Game/Entities/GameObject/GameObject.cs b/Source/Game/Entities/GameObject/GameObject.cs index 1104ce9dd..89110ccaf 100644 --- a/Source/Game/Entities/GameObject/GameObject.cs +++ b/Source/Game/Entities/GameObject/GameObject.cs @@ -995,7 +995,7 @@ namespace Game.Entities stmt.AddValue(index++, m_worldRotation.W); stmt.AddValue(index++, m_respawnDelayTime); stmt.AddValue(index++, GetGoAnimProgress()); - stmt.AddValue(index++, GetGoState()); + stmt.AddValue(index++, (byte)GetGoState()); DB.World.Execute(stmt); } diff --git a/Source/Game/Entities/Pet.cs b/Source/Game/Entities/Pet.cs index ea498249a..b2d1b322c 100644 --- a/Source/Game/Entities/Pet.cs +++ b/Source/Game/Entities/Pet.cs @@ -113,7 +113,7 @@ namespace Game.Entities // Current pet (slot 0) stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CHAR_PET_BY_ENTRY_AND_SLOT); stmt.AddValue(0, ownerid); - stmt.AddValue(1, PetSaveMode.AsCurrent); + stmt.AddValue(1, (byte)PetSaveMode.AsCurrent); } else if (petEntry != 0) { @@ -121,16 +121,16 @@ namespace Game.Entities stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CHAR_PET_BY_ENTRY_AND_SLOT_2); stmt.AddValue(0, ownerid); stmt.AddValue(1, petEntry); - stmt.AddValue(2, PetSaveMode.AsCurrent); - stmt.AddValue(3, PetSaveMode.LastStableSlot); + stmt.AddValue(2, (byte)PetSaveMode.AsCurrent); + stmt.AddValue(3, (byte)PetSaveMode.LastStableSlot); } else { // Any current or other non-stabled pet (for hunter "call pet") stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CHAR_PET_BY_SLOT); stmt.AddValue(0, ownerid); - stmt.AddValue(1, PetSaveMode.AsCurrent); - stmt.AddValue(2, PetSaveMode.LastStableSlot); + stmt.AddValue(1, (byte)PetSaveMode.AsCurrent); + stmt.AddValue(2, (byte)PetSaveMode.LastStableSlot); } SQLResult result = DB.Characters.Query(stmt); @@ -266,14 +266,14 @@ namespace Game.Entities if (result.Read(7) != 0) { stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHAR_PET_SLOT_BY_SLOT_EXCLUDE_ID); - stmt.AddValue(0, PetSaveMode.NotInSlot); + stmt.AddValue(0, (byte)PetSaveMode.NotInSlot); stmt.AddValue(1, ownerid); - stmt.AddValue(2, PetSaveMode.AsCurrent); + stmt.AddValue(2, (byte)PetSaveMode.AsCurrent); stmt.AddValue(3, GetCharmInfo().GetPetNumber()); DB.Characters.Execute(stmt); stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHAR_PET_SLOT_BY_ID); - stmt.AddValue(0, PetSaveMode.AsCurrent); + stmt.AddValue(0, (byte)PetSaveMode.AsCurrent); stmt.AddValue(1, ownerid); stmt.AddValue(2, GetCharmInfo().GetPetNumber()); DB.Characters.Execute(stmt); @@ -422,9 +422,9 @@ namespace Game.Entities if (mode <= PetSaveMode.LastStableSlot) { stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHAR_PET_SLOT_BY_SLOT); - stmt.AddValue(0, PetSaveMode.NotInSlot); + stmt.AddValue(0, (byte)PetSaveMode.NotInSlot); stmt.AddValue(1, ownerLowGUID); - stmt.AddValue(2, mode); + stmt.AddValue(2, (byte)mode); trans.Append(stmt); } @@ -433,8 +433,8 @@ namespace Game.Entities { stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_CHAR_PET_BY_SLOT); stmt.AddValue(0, ownerLowGUID); - stmt.AddValue(1, PetSaveMode.AsCurrent); - stmt.AddValue(2, PetSaveMode.LastStableSlot); + stmt.AddValue(1, (byte)PetSaveMode.AsCurrent); + stmt.AddValue(2, (byte)PetSaveMode.LastStableSlot); trans.Append(stmt); } @@ -445,17 +445,17 @@ namespace Game.Entities stmt.AddValue(2, ownerLowGUID); stmt.AddValue(3, GetNativeDisplayId()); stmt.AddValue(4, GetLevel()); - stmt.AddValue(5, (uint)m_unitData.PetExperience); - stmt.AddValue(6, GetReactState()); - stmt.AddValue(7, mode); + stmt.AddValue(5, m_unitData.PetExperience); + stmt.AddValue(6, (byte)GetReactState()); + stmt.AddValue(7, (byte)mode); stmt.AddValue(8, GetName()); stmt.AddValue(9, HasPetFlag(UnitPetFlags.CanBeRenamed) ? 0 : 1); stmt.AddValue(10, curhealth); stmt.AddValue(11, curmana); stmt.AddValue(12, GenerateActionBarData()); stmt.AddValue(13, GameTime.GetGameTime()); - stmt.AddValue(14, (uint)m_unitData.CreatedBySpell); - stmt.AddValue(15, GetPetType()); + stmt.AddValue(14, m_unitData.CreatedBySpell); + stmt.AddValue(15, (byte)GetPetType()); stmt.AddValue(16, m_petSpecialization); trans.Append(stmt); @@ -823,14 +823,14 @@ namespace Game.Entities stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_PET_SPELL); stmt.AddValue(0, GetCharmInfo().GetPetNumber()); stmt.AddValue(1, pair.Key); - stmt.AddValue(2, pair.Value.active); + stmt.AddValue(2, (byte)pair.Value.active); trans.Append(stmt); break; case PetSpellState.New: stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_PET_SPELL); stmt.AddValue(0, GetCharmInfo().GetPetNumber()); stmt.AddValue(1, pair.Key); - stmt.AddValue(2, pair.Value.active); + stmt.AddValue(2, (byte)pair.Value.active); trans.Append(stmt); break; case PetSpellState.Unchanged: @@ -976,7 +976,7 @@ namespace Game.Entities stmt.AddValue(index++, key.SpellId); stmt.AddValue(index++, key.EffectMask); stmt.AddValue(index++, recalculateMask); - stmt.AddValue(index++, aura.GetCastDifficulty()); + stmt.AddValue(index++, (byte)aura.GetCastDifficulty()); stmt.AddValue(index++, aura.GetStackAmount()); stmt.AddValue(index++, aura.GetMaxDuration()); stmt.AddValue(index++, aura.GetDuration()); diff --git a/Source/Game/Entities/Player/CollectionManager.cs b/Source/Game/Entities/Player/CollectionManager.cs index cd7f8f373..d3c446a6d 100644 --- a/Source/Game/Entities/Player/CollectionManager.cs +++ b/Source/Game/Entities/Player/CollectionManager.cs @@ -206,7 +206,7 @@ namespace Game.Entities stmt = DB.Login.GetPreparedStatement(LoginStatements.REP_ACCOUNT_HEIRLOOMS); stmt.AddValue(0, _owner.GetBattlenetAccountId()); stmt.AddValue(1, heirloom.Key); - stmt.AddValue(2, heirloom.Value.flags); + stmt.AddValue(2, (uint)heirloom.Value.flags); trans.Append(stmt); } } @@ -404,7 +404,7 @@ namespace Game.Entities PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.REP_ACCOUNT_MOUNTS); stmt.AddValue(0, _owner.GetBattlenetAccountId()); stmt.AddValue(1, mount.Key); - stmt.AddValue(2, mount.Value); + stmt.AddValue(2, (byte)mount.Value); trans.Append(stmt); } } diff --git a/Source/Game/Entities/Player/Player.DB.cs b/Source/Game/Entities/Player/Player.DB.cs index 88d6e03c0..174c2242d 100644 --- a/Source/Game/Entities/Player/Player.DB.cs +++ b/Source/Game/Entities/Player/Player.DB.cs @@ -1778,7 +1778,7 @@ namespace Game.Entities stmt.AddValue(index++, key.SpellId); stmt.AddValue(index++, key.EffectMask); stmt.AddValue(index++, recalculateMask); - stmt.AddValue(index++, aura.GetCastDifficulty()); + stmt.AddValue(index++, (byte)aura.GetCastDifficulty()); stmt.AddValue(index++, aura.GetStackAmount()); stmt.AddValue(index++, aura.GetMaxDuration()); stmt.AddValue(index++, aura.GetDuration()); @@ -1911,7 +1911,7 @@ namespace Game.Entities stmt.AddValue(1, GetActiveTalentGroup()); stmt.AddValue(2, pair.Key); stmt.AddValue(3, pair.Value.GetAction()); - stmt.AddValue(4, pair.Value.GetButtonType()); + stmt.AddValue(4, (byte)pair.Value.GetButtonType()); trans.Append(stmt); pair.Value.uState = ActionButtonUpdateState.UnChanged; @@ -1919,7 +1919,7 @@ namespace Game.Entities case ActionButtonUpdateState.Changed: stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHAR_ACTION); stmt.AddValue(0, pair.Value.GetAction()); - stmt.AddValue(1, pair.Value.GetButtonType()); + stmt.AddValue(1, (byte)pair.Value.GetButtonType()); stmt.AddValue(2, GetGUID().GetCounter()); stmt.AddValue(3, pair.Key); stmt.AddValue(4, GetActiveTalentGroup()); @@ -1960,7 +1960,7 @@ namespace Game.Entities stmt = DB.Characters.GetPreparedStatement(CharStatements.REP_CHAR_QUESTSTATUS); stmt.AddValue(0, GetGUID().GetCounter()); stmt.AddValue(1, save.Key); - stmt.AddValue(2, data.Status); + stmt.AddValue(2, (byte)data.Status); stmt.AddValue(3, data.Timer / Time.InMilliseconds + GameTime.GetGameTime()); trans.Append(stmt); diff --git a/Source/Game/Entities/Player/Player.Map.cs b/Source/Game/Entities/Player/Player.Map.cs index c60d3b857..330741405 100644 --- a/Source/Game/Entities/Player/Player.Map.cs +++ b/Source/Game/Entities/Player/Player.Map.cs @@ -386,7 +386,7 @@ namespace Game.Entities stmt.AddValue(0, save.GetInstanceId()); stmt.AddValue(1, permanent); - stmt.AddValue(2, extendState); + stmt.AddValue(2, (byte)extendState); stmt.AddValue(3, GetGUID().GetCounter()); stmt.AddValue(4, bind.save.GetInstanceId()); @@ -399,7 +399,7 @@ namespace Game.Entities stmt.AddValue(0, GetGUID().GetCounter()); stmt.AddValue(1, save.GetInstanceId()); stmt.AddValue(2, permanent); - stmt.AddValue(3, extendState); + stmt.AddValue(3, (byte)extendState); DB.Characters.Execute(stmt); } } diff --git a/Source/Game/Entities/Player/SocialMgr.cs b/Source/Game/Entities/Player/SocialMgr.cs index 319064609..4725e2166 100644 --- a/Source/Game/Entities/Player/SocialMgr.cs +++ b/Source/Game/Entities/Player/SocialMgr.cs @@ -176,7 +176,7 @@ namespace Game.Entities friendInfo.Flags |= flag; PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHARACTER_SOCIAL_FLAGS); - stmt.AddValue(0, friendInfo.Flags); + stmt.AddValue(0, (byte)friendInfo.Flags); stmt.AddValue(1, GetPlayerGUID().GetCounter()); stmt.AddValue(2, friendGuid.GetCounter()); DB.Characters.Execute(stmt); @@ -190,7 +190,7 @@ namespace Game.Entities PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_CHARACTER_SOCIAL); stmt.AddValue(0, GetPlayerGUID().GetCounter()); stmt.AddValue(1, friendGuid.GetCounter()); - stmt.AddValue(2, flag); + stmt.AddValue(2, (byte)flag); DB.Characters.Execute(stmt); } return true; @@ -216,7 +216,7 @@ namespace Game.Entities else { PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHARACTER_SOCIAL_FLAGS); - stmt.AddValue(0, friendInfo.Flags); + stmt.AddValue(0, (byte)friendInfo.Flags); stmt.AddValue(1, GetPlayerGUID().GetCounter()); stmt.AddValue(2, friendGuid.GetCounter()); DB.Characters.Execute(stmt); diff --git a/Source/Game/Events/GameEventManager.cs b/Source/Game/Events/GameEventManager.cs index 97d185cee..c585713c8 100644 --- a/Source/Game/Events/GameEventManager.cs +++ b/Source/Game/Events/GameEventManager.cs @@ -1542,7 +1542,7 @@ namespace Game stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_GAME_EVENT_SAVE); stmt.AddValue(0, event_id); - stmt.AddValue(1, mGameEvent[event_id].state); + stmt.AddValue(1, (byte)mGameEvent[event_id].state); stmt.AddValue(2, mGameEvent[event_id].nextstart != 0 ? mGameEvent[event_id].nextstart : 0L); trans.Append(stmt); DB.Characters.CommitTransaction(trans); diff --git a/Source/Game/Globals/ObjectManager.cs b/Source/Game/Globals/ObjectManager.cs index 35025a145..808b99eb6 100644 --- a/Source/Game/Globals/ObjectManager.cs +++ b/Source/Game/Globals/ObjectManager.cs @@ -1028,7 +1028,7 @@ namespace Game stmt.AddValue(0, id); stmt.AddValue(1, zoneId); - stmt.AddValue(2, team); + stmt.AddValue(2, (uint)team); DB.World.Execute(stmt); } @@ -1076,7 +1076,7 @@ namespace Game stmt.AddValue(0, id); stmt.AddValue(1, zoneId); - stmt.AddValue(2, team); + stmt.AddValue(2, (uint)team); DB.World.Execute(stmt); } @@ -4785,7 +4785,7 @@ namespace Game stmt.AddValue(2, vItem.maxcount); stmt.AddValue(3, vItem.incrtime); stmt.AddValue(4, vItem.ExtendedCost); - stmt.AddValue(5, vItem.Type); + stmt.AddValue(5, (byte)vItem.Type); DB.World.Execute(stmt); } @@ -9184,7 +9184,7 @@ namespace Game stmt.AddValue(1, m.sender); stmt.AddValue(2, curTime + 30 * Time.Day); stmt.AddValue(3, curTime); - stmt.AddValue(4, MailCheckMask.Returned); + stmt.AddValue(4, (byte)MailCheckMask.Returned); stmt.AddValue(5, m.messageID); DB.Characters.Execute(stmt); foreach (var itemInfo in m.items) diff --git a/Source/Game/Groups/Group.cs b/Source/Game/Groups/Group.cs index 7a6f47e75..1d6658df6 100644 --- a/Source/Game/Groups/Group.cs +++ b/Source/Game/Groups/Group.cs @@ -381,9 +381,9 @@ namespace Game.Groups stmt.AddValue(0, m_dbStoreId); stmt.AddValue(1, member.guid.GetCounter()); - stmt.AddValue(2, member.flags); + stmt.AddValue(2, (byte)member.flags); stmt.AddValue(3, member.group); - stmt.AddValue(4, member.roles); + stmt.AddValue(4, (byte)member.roles); DB.Characters.Execute(stmt); @@ -1846,7 +1846,7 @@ namespace Game.Groups { PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_GROUP_LEGACY_RAID_DIFFICULTY); - stmt.AddValue(0, m_legacyRaidDifficulty); + stmt.AddValue(0, (byte)m_legacyRaidDifficulty); stmt.AddValue(1, m_dbStoreId); DB.Characters.Execute(stmt); @@ -2480,7 +2480,7 @@ namespace Game.Groups // Preserve the new setting in the db PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_GROUP_MEMBER_FLAG); - stmt.AddValue(0, slot.flags); + stmt.AddValue(0, (byte)slot.flags); stmt.AddValue(1, guid.GetCounter()); DB.Characters.Execute(stmt); diff --git a/Source/Game/Guilds/Guild.cs b/Source/Game/Guilds/Guild.cs index 782f84161..32a5a5f33 100644 --- a/Source/Game/Guilds/Guild.cs +++ b/Source/Game/Guilds/Guild.cs @@ -2802,7 +2802,7 @@ namespace Game.Guilds stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_GUILD_EVENTLOG); stmt.AddValue(index, m_guildId); stmt.AddValue(++index, m_guid); - stmt.AddValue(++index, m_eventType); + stmt.AddValue(++index, (byte)m_eventType); stmt.AddValue(++index, m_playerGuid1); stmt.AddValue(++index, m_playerGuid2); stmt.AddValue(++index, m_newRank); @@ -2883,7 +2883,7 @@ namespace Game.Guilds stmt.AddValue(index, m_guildId); stmt.AddValue(++index, m_guid); stmt.AddValue(++index, m_bankTabId); - stmt.AddValue(++index, m_eventType); + stmt.AddValue(++index, (byte)m_eventType); stmt.AddValue(++index, m_playerGuid); stmt.AddValue(++index, m_itemOrMoney); stmt.AddValue(++index, m_itemStackCount); @@ -2973,7 +2973,7 @@ namespace Game.Guilds PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_GUILD_NEWS); stmt.AddValue(index, m_guildId); stmt.AddValue(++index, GetGUID()); - stmt.AddValue(++index, GetNewsType()); + stmt.AddValue(++index, (byte)GetNewsType()); stmt.AddValue(++index, GetPlayerGuid().GetCounter()); stmt.AddValue(++index, GetFlags()); stmt.AddValue(++index, GetValue()); @@ -3100,7 +3100,7 @@ namespace Game.Guilds stmt.AddValue(0, m_guildId); stmt.AddValue(1, m_rankId); stmt.AddValue(2, m_name); - stmt.AddValue(3, m_rights); + stmt.AddValue(3, (uint)m_rights); stmt.AddValue(4, m_bankMoneyPerDay); DB.Characters.ExecuteOrAppend(trans, stmt); } @@ -3124,7 +3124,7 @@ namespace Game.Guilds stmt.AddValue(0, m_guildId); stmt.AddValue(1, i); stmt.AddValue(2, m_rankId); - stmt.AddValue(3, rightsAndSlots.GetRights()); + stmt.AddValue(3, (sbyte)rightsAndSlots.GetRights()); stmt.AddValue(4, rightsAndSlots.GetSlots()); trans.Append(stmt); } @@ -3155,7 +3155,7 @@ namespace Game.Guilds m_rights = rights; PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_GUILD_RANK_RIGHTS); - stmt.AddValue(0, m_rights); + stmt.AddValue(0, (uint)m_rights); stmt.AddValue(1, m_rankId); stmt.AddValue(2, m_guildId); DB.Characters.Execute(stmt); @@ -3188,7 +3188,7 @@ namespace Game.Guilds stmt.AddValue(0, m_guildId); stmt.AddValue(1, rightsAndSlots.GetTabId()); stmt.AddValue(2, m_rankId); - stmt.AddValue(3, rightsAndSlots.GetRights()); + stmt.AddValue(3, (sbyte)rightsAndSlots.GetRights()); stmt.AddValue(4, rightsAndSlots.GetSlots()); DB.Characters.Execute(stmt); } diff --git a/Source/Game/Handlers/CharacterHandler.cs b/Source/Game/Handlers/CharacterHandler.cs index daa1be894..d41d25b2f 100644 --- a/Source/Game/Handlers/CharacterHandler.cs +++ b/Source/Game/Handlers/CharacterHandler.cs @@ -1252,7 +1252,7 @@ namespace Game // Update name and at_login flag in the db PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHAR_NAME_AT_LOGIN); stmt.AddValue(0, renameInfo.NewName); - stmt.AddValue(1, atLoginFlags); + stmt.AddValue(1, (ushort)atLoginFlags); stmt.AddValue(2, lowGuid); trans.Append(stmt); @@ -1467,7 +1467,7 @@ namespace Game { stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHAR_NAME_AT_LOGIN); stmt.AddValue(0, customizeInfo.CharName); - stmt.AddValue(1, atLoginFlags); + stmt.AddValue(1, (ushort)atLoginFlags); stmt.AddValue(2, lowGuid); trans.Append(stmt); @@ -1794,7 +1794,7 @@ namespace Game // Race Change { stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHAR_RACE); - stmt.AddValue(0, factionChangeInfo.RaceID); + stmt.AddValue(0, (byte)factionChangeInfo.RaceID); stmt.AddValue(1, lowGuid); trans.Append(stmt); diff --git a/Source/Game/Handlers/NPCHandler.cs b/Source/Game/Handlers/NPCHandler.cs index 555639eb5..536836b10 100644 --- a/Source/Game/Handlers/NPCHandler.cs +++ b/Source/Game/Handlers/NPCHandler.cs @@ -345,8 +345,8 @@ namespace Game { PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_PET_SLOTS_DETAIL); stmt.AddValue(0, guid.GetCounter()); - stmt.AddValue(1, PetSaveMode.FirstStableSlot); - stmt.AddValue(2, PetSaveMode.LastStableSlot); + stmt.AddValue(1, (byte)PetSaveMode.FirstStableSlot); + stmt.AddValue(2, (byte)PetSaveMode.LastStableSlot); _queryProcessor.AddCallback(DB.Characters.AsyncQuery(stmt).WithCallback(SendStablePetCallback, guid)); } diff --git a/Source/Game/Reputation/ReputationManager.cs b/Source/Game/Reputation/ReputationManager.cs index c4cac3dca..6e76871c9 100644 --- a/Source/Game/Reputation/ReputationManager.cs +++ b/Source/Game/Reputation/ReputationManager.cs @@ -572,7 +572,7 @@ namespace Game stmt.AddValue(0, _player.GetGUID().GetCounter()); stmt.AddValue(1, factionState.Id); stmt.AddValue(2, factionState.Standing); - stmt.AddValue(3, factionState.Flags); + stmt.AddValue(3, (ushort)factionState.Flags); trans.Append(stmt); factionState.needSave = false; diff --git a/Source/Game/Server/WorldSession.cs b/Source/Game/Server/WorldSession.cs index 71b470ae2..8248af40d 100644 --- a/Source/Game/Server/WorldSession.cs +++ b/Source/Game/Server/WorldSession.cs @@ -527,7 +527,7 @@ namespace Game { PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.REP_ACCOUNT_DATA); stmt.AddValue(0, GetAccountId()); - stmt.AddValue(1, type); + stmt.AddValue(1, (byte)type); stmt.AddValue(2, time); stmt.AddValue(3, data); DB.Characters.Execute(stmt); @@ -540,7 +540,7 @@ namespace Game PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.REP_PLAYER_ACCOUNT_DATA); stmt.AddValue(0, m_GUIDLow); - stmt.AddValue(1, type); + stmt.AddValue(1, (byte)type); stmt.AddValue(2, time); stmt.AddValue(3, data); DB.Characters.Execute(stmt); diff --git a/Source/Game/SupportSystem/SupportTickets.cs b/Source/Game/SupportSystem/SupportTickets.cs index 2a5a00c02..df31b3475 100644 --- a/Source/Game/SupportSystem/SupportTickets.cs +++ b/Source/Game/SupportSystem/SupportTickets.cs @@ -282,7 +282,7 @@ namespace Game.SupportSystem stmt.AddValue(++idx, _pos.Z); stmt.AddValue(++idx, _facing); stmt.AddValue(++idx, _targetCharacterGuid.GetCounter()); - stmt.AddValue(++idx, _complaintType); + stmt.AddValue(++idx, (byte)_complaintType); if (_chatLog.ReportLineIndex.HasValue) stmt.AddValue(++idx, _chatLog.ReportLineIndex.Value); else