Core/Misc: Moved CharacterInfo out of world to separate class
Port From (https://github.com/TrinityCore/TrinityCore/commit/ad4e63bae145ae49b584ab2fc621660430cec0d3)
This commit is contained in:
@@ -384,7 +384,7 @@ namespace Game
|
||||
// impossible have online own another character (use this for speedup check in case online owner)
|
||||
ObjectGuid ownerGuid = ObjectGuid.Create(HighGuid.Player, auction.owner);
|
||||
Player auction_owner = Global.ObjAccessor.FindPlayer(ownerGuid);
|
||||
if (!auction_owner && ObjectManager.GetPlayerAccountIdByGUID(ownerGuid) == player.GetSession().GetAccountId())
|
||||
if (!auction_owner && Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(ownerGuid) == player.GetSession().GetAccountId())
|
||||
{
|
||||
//you cannot bid your another character auction:
|
||||
SendAuctionCommandResult(null, AuctionAction.PlaceBid, AuctionError.BidOwn);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
using Framework.Constants;
|
||||
using Framework.Database;
|
||||
using Game.Cache;
|
||||
using Game.Entities;
|
||||
using Game.Guilds;
|
||||
using Game.Maps;
|
||||
@@ -255,14 +256,16 @@ namespace Game
|
||||
else
|
||||
{
|
||||
// Invitee offline, get data from database
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_GUID_RACE_ACC_BY_NAME);
|
||||
stmt.AddValue(0, calendarEventInvite.Name);
|
||||
SQLResult result = DB.Characters.Query(stmt);
|
||||
if (!result.IsEmpty())
|
||||
ObjectGuid guid = Global.CharacterCacheStorage.GetCharacterGuidByName(calendarEventInvite.Name);
|
||||
if (!guid.IsEmpty())
|
||||
{
|
||||
inviteeGuid = ObjectGuid.Create(HighGuid.Player, result.Read<ulong>(0));
|
||||
inviteeTeam = Player.TeamForRace((Race)result.Read<byte>(1));
|
||||
inviteeGuildId = Player.GetGuildIdFromDB(inviteeGuid);
|
||||
CharacterCacheEntry characterInfo = Global.CharacterCacheStorage.GetCharacterCacheByGuid(guid);
|
||||
if (characterInfo != null)
|
||||
{
|
||||
inviteeGuid = guid;
|
||||
inviteeTeam = Player.TeamForRace(characterInfo.RaceId);
|
||||
inviteeGuildId = characterInfo.GuildId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
using Framework.Collections;
|
||||
using Framework.Constants;
|
||||
using Framework.Database;
|
||||
using Game.Cache;
|
||||
using Game.DataStorage;
|
||||
using Game.Entities;
|
||||
using Game.Groups;
|
||||
@@ -97,8 +98,8 @@ namespace Game
|
||||
if (!charInfo.Flags.HasAnyFlag(CharacterFlags.CharacterLockedForTransfer | CharacterFlags.LockedByBilling))
|
||||
_legitCharacters.Add(charInfo.Guid);
|
||||
|
||||
if (!Global.WorldMgr.HasCharacterInfo(charInfo.Guid)) // This can happen if characters are inserted into the database manually. Core hasn't loaded name data yet.
|
||||
Global.WorldMgr.AddCharacterInfo(charInfo.Guid, GetAccountId(), charInfo.Name, charInfo.Sex, charInfo.RaceId, (byte)charInfo.ClassId, charInfo.Level, false);
|
||||
if (!Global.CharacterCacheStorage.HasCharacterCacheEntry(charInfo.Guid)) // This can happen if characters are inserted into the database manually. Core hasn't loaded name data yet.
|
||||
Global.CharacterCacheStorage.AddCharacterCacheEntry(charInfo.Guid, GetAccountId(), charInfo.Name, charInfo.Sex, charInfo.RaceId, (byte)charInfo.ClassId, charInfo.Level, false);
|
||||
|
||||
if (charInfo.ClassId == Class.DemonHunter)
|
||||
demonHunterCount++;
|
||||
@@ -161,8 +162,8 @@ namespace Game
|
||||
|
||||
Log.outInfo(LogFilter.Network, "Loading undeleted char guid {0} from account {1}.", charInfo.Guid.ToString(), GetAccountId());
|
||||
|
||||
if (!Global.WorldMgr.HasCharacterInfo(charInfo.Guid)) // This can happen if characters are inserted into the database manually. Core hasn't loaded name data yet.
|
||||
Global.WorldMgr.AddCharacterInfo(charInfo.Guid, GetAccountId(), charInfo.Name, charInfo.Sex, charInfo.RaceId, (byte)charInfo.ClassId, charInfo.Level, true);
|
||||
if (!Global.CharacterCacheStorage.HasCharacterCacheEntry(charInfo.Guid)) // This can happen if characters are inserted into the database manually. Core hasn't loaded name data yet.
|
||||
Global.CharacterCacheStorage.AddCharacterCacheEntry(charInfo.Guid, GetAccountId(), charInfo.Name, charInfo.Sex, charInfo.RaceId, (byte)charInfo.ClassId, charInfo.Level, true);
|
||||
|
||||
charEnum.Characters.Add(charInfo);
|
||||
}
|
||||
@@ -477,7 +478,7 @@ namespace Game
|
||||
|
||||
Log.outInfo(LogFilter.Player, "Account: {0} (IP: {1}) Create Character: {2} {3}", GetAccountId(), GetRemoteAddress(), createInfo.Name, newChar.GetGUID().ToString());
|
||||
Global.ScriptMgr.OnPlayerCreate(newChar);
|
||||
Global.WorldMgr.AddCharacterInfo(newChar.GetGUID(), GetAccountId(), newChar.GetName(), newChar.m_playerData.NativeSex, (byte)newChar.GetRace(), (byte)newChar.GetClass(), (byte)newChar.getLevel(), false);
|
||||
Global.CharacterCacheStorage.AddCharacterCacheEntry(newChar.GetGUID(), GetAccountId(), newChar.GetName(), newChar.m_playerData.NativeSex, (byte)newChar.GetRace(), (byte)newChar.GetClass(), (byte)newChar.getLevel(), false);
|
||||
|
||||
newChar.CleanupsBeforeDelete();
|
||||
}
|
||||
@@ -498,13 +499,20 @@ namespace Game
|
||||
[WorldPacketHandler(ClientOpcodes.CharDelete, Status = SessionStatus.Authed)]
|
||||
void HandleCharDelete(CharDelete charDelete)
|
||||
{
|
||||
// Initiating
|
||||
uint initAccountId = GetAccountId();
|
||||
|
||||
// can't delete loaded character
|
||||
if (Global.ObjAccessor.FindPlayer(charDelete.Guid))
|
||||
{
|
||||
Global.ScriptMgr.OnPlayerFailedDelete(charDelete.Guid, initAccountId);
|
||||
return;
|
||||
}
|
||||
|
||||
// is guild leader
|
||||
if (Global.GuildMgr.GetGuildByLeader(charDelete.Guid))
|
||||
{
|
||||
Global.ScriptMgr.OnPlayerFailedDelete(charDelete.Guid, initAccountId);
|
||||
SendCharDelete(ResponseCodes.CharDeleteFailedGuildLeader);
|
||||
return;
|
||||
}
|
||||
@@ -512,14 +520,15 @@ namespace Game
|
||||
// is arena team captain
|
||||
if (Global.ArenaTeamMgr.GetArenaTeamByCaptain(charDelete.Guid) != null)
|
||||
{
|
||||
Global.ScriptMgr.OnPlayerFailedDelete(charDelete.Guid, initAccountId);
|
||||
SendCharDelete(ResponseCodes.CharDeleteFailedArenaCaptain);
|
||||
return;
|
||||
}
|
||||
|
||||
CharacterInfo characterInfo = Global.WorldMgr.GetCharacterInfo(charDelete.Guid);
|
||||
CharacterCacheEntry characterInfo = Global.CharacterCacheStorage.GetCharacterCacheByGuid(charDelete.Guid);
|
||||
if (characterInfo == null)
|
||||
{
|
||||
//Global.ScriptMgr.OnPlayerFailedDelete(charDelete.Guid, initAccountId);
|
||||
Global.ScriptMgr.OnPlayerFailedDelete(charDelete.Guid, initAccountId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -529,11 +538,17 @@ namespace Game
|
||||
|
||||
// prevent deleting other players' characters using cheating tools
|
||||
if (accountId != GetAccountId())
|
||||
{
|
||||
Global.ScriptMgr.OnPlayerFailedDelete(charDelete.Guid, initAccountId);
|
||||
return;
|
||||
}
|
||||
|
||||
string IP_str = GetRemoteAddress();
|
||||
Log.outInfo(LogFilter.Player, "Account: {0}, IP: {1} deleted character: {2}, {3}, Level: {4}", accountId, IP_str, name, charDelete.Guid.ToString(), level);
|
||||
Global.ScriptMgr.OnPlayerDelete(charDelete.Guid);
|
||||
|
||||
// To prevent hook failure, place hook before removing reference from DB
|
||||
Global.ScriptMgr.OnPlayerDelete(charDelete.Guid, initAccountId); // To prevent race conditioning, but as it also makes sense, we hand the accountId over for successful delete.
|
||||
// Shouldn't interfere with character deletion though
|
||||
|
||||
Global.GuildFinderMgr.RemoveAllMembershipRequestsFromPlayer(charDelete.Guid);
|
||||
Global.CalendarMgr.RemoveAllPlayerEventsAndInvites(charDelete.Guid);
|
||||
@@ -1038,7 +1053,7 @@ namespace Game
|
||||
|
||||
SendCharRename(ResponseCodes.Success, renameInfo);
|
||||
|
||||
Global.WorldMgr.UpdateCharacterInfo(renameInfo.Guid, renameInfo.NewName);
|
||||
Global.CharacterCacheStorage.UpdateCharacterData(renameInfo.Guid, renameInfo.NewName);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.SetPlayerDeclinedNames, Status = SessionStatus.Authed)]
|
||||
@@ -1046,7 +1061,7 @@ namespace Game
|
||||
{
|
||||
// not accept declined names for unsupported languages
|
||||
string name;
|
||||
if (!ObjectManager.GetPlayerNameByGUID(packet.Player, out name))
|
||||
if (!Global.CharacterCacheStorage.GetCharacterNameByGuid(packet.Player, out name))
|
||||
{
|
||||
SendSetPlayerDeclinedNamesResult(DeclinedNameResult.Error, packet.Player);
|
||||
return;
|
||||
@@ -1248,7 +1263,7 @@ namespace Game
|
||||
|
||||
// character with this name already exist
|
||||
// @todo: make async
|
||||
ObjectGuid newGuid = ObjectManager.GetPlayerGUIDByName(customizeInfo.CharName);
|
||||
ObjectGuid newGuid = Global.CharacterCacheStorage.GetCharacterGuidByName(customizeInfo.CharName);
|
||||
if (!newGuid.IsEmpty())
|
||||
{
|
||||
if (newGuid != customizeInfo.CharGUID)
|
||||
@@ -1296,7 +1311,7 @@ namespace Game
|
||||
|
||||
DB.Characters.CommitTransaction(trans);
|
||||
|
||||
Global.WorldMgr.UpdateCharacterInfo(customizeInfo.CharGUID, customizeInfo.CharName, customizeInfo.SexID);
|
||||
Global.CharacterCacheStorage.UpdateCharacterData(customizeInfo.CharGUID, customizeInfo.CharName, (byte)customizeInfo.SexID);
|
||||
|
||||
SendCharCustomize(ResponseCodes.Success, customizeInfo);
|
||||
|
||||
@@ -1479,7 +1494,7 @@ namespace Game
|
||||
}
|
||||
|
||||
// get the players old (at this moment current) race
|
||||
CharacterInfo characterInfo = Global.WorldMgr.GetCharacterInfo(factionChangeInfo.Guid);
|
||||
CharacterCacheEntry characterInfo = Global.CharacterCacheStorage.GetCharacterCacheByGuid(factionChangeInfo.Guid);
|
||||
if (characterInfo == null)
|
||||
{
|
||||
SendCharFactionChange(ResponseCodes.CharCreateError, factionChangeInfo);
|
||||
@@ -1487,8 +1502,8 @@ namespace Game
|
||||
}
|
||||
|
||||
string oldName = characterInfo.Name;
|
||||
Race oldRace = characterInfo.RaceID;
|
||||
Class playerClass = characterInfo.ClassID;
|
||||
Race oldRace = characterInfo.RaceId;
|
||||
Class playerClass = characterInfo.ClassId;
|
||||
byte level = characterInfo.Level;
|
||||
|
||||
if (Global.ObjectMgr.GetPlayerInfo(factionChangeInfo.RaceID, playerClass) == null)
|
||||
@@ -1559,7 +1574,7 @@ namespace Game
|
||||
}
|
||||
|
||||
// character with this name already exist
|
||||
ObjectGuid newGuid = ObjectManager.GetPlayerGUIDByName(factionChangeInfo.Name);
|
||||
ObjectGuid newGuid = Global.CharacterCacheStorage.GetCharacterGuidByName(factionChangeInfo.Name);
|
||||
if (!newGuid.IsEmpty())
|
||||
{
|
||||
if (newGuid != factionChangeInfo.Guid)
|
||||
@@ -1625,7 +1640,7 @@ namespace Game
|
||||
trans.Append(stmt);
|
||||
}
|
||||
|
||||
Global.WorldMgr.UpdateCharacterInfo(factionChangeInfo.Guid, factionChangeInfo.Name, factionChangeInfo.SexID, factionChangeInfo.RaceID);
|
||||
Global.CharacterCacheStorage.UpdateCharacterData(factionChangeInfo.Guid, factionChangeInfo.Name, (byte)factionChangeInfo.SexID, (byte)factionChangeInfo.RaceID);
|
||||
|
||||
if (oldRace != factionChangeInfo.RaceID)
|
||||
{
|
||||
@@ -1730,20 +1745,12 @@ namespace Game
|
||||
trans.Append(stmt);
|
||||
}
|
||||
|
||||
// @todo: make this part asynch
|
||||
if (!WorldConfig.GetBoolValue(WorldCfg.AllowTwoSideInteractionGuild))
|
||||
{
|
||||
// Reset guild
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_GUILD_MEMBER);
|
||||
stmt.AddValue(0, lowGuid);
|
||||
|
||||
result = DB.Characters.Query(stmt);
|
||||
if (!result.IsEmpty())
|
||||
{
|
||||
Guild guild = Global.GuildMgr.GetGuildById(result.Read<ulong>(0));
|
||||
if (guild)
|
||||
guild.DeleteMember(trans, factionChangeInfo.Guid, false, false, true);
|
||||
}
|
||||
Guild guild = Global.GuildMgr.GetGuildById(characterInfo.GuildId);
|
||||
if (guild != null)
|
||||
guild.DeleteMember(trans, factionChangeInfo.Guid, false, false, true);
|
||||
|
||||
Player.LeaveAllArenaTeams(factionChangeInfo.Guid);
|
||||
}
|
||||
@@ -2132,7 +2139,7 @@ namespace Game
|
||||
stmt.AddValue(0, GetBattlenetAccountId());
|
||||
DB.Login.Execute(stmt);
|
||||
|
||||
Global.WorldMgr.UpdateCharacterInfoDeleted(undeleteInfo.CharacterGuid, false, undeleteInfo.Name);
|
||||
Global.CharacterCacheStorage.UpdateCharacterInfoDeleted(undeleteInfo.CharacterGuid, false, undeleteInfo.Name);
|
||||
|
||||
SendUndeleteCharacterResponse(CharacterUndeleteResult.Ok, undeleteInfo);
|
||||
}));
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
using Framework.Constants;
|
||||
using Game.Cache;
|
||||
using Game.Entities;
|
||||
using Game.Guilds;
|
||||
using Game.Network;
|
||||
@@ -193,12 +194,12 @@ namespace Game
|
||||
recruitData.SecondsSinceCreated = (uint)(now - recruitRequestPair.Value.GetSubmitTime());
|
||||
recruitData.SecondsUntilExpiration = (uint)(recruitRequestPair.Value.GetExpiryTime() - now);
|
||||
|
||||
CharacterInfo charInfo = Global.WorldMgr.GetCharacterInfo(recruitRequestPair.Key);
|
||||
CharacterCacheEntry charInfo = Global.CharacterCacheStorage.GetCharacterCacheByGuid(recruitRequestPair.Key);
|
||||
if (charInfo != null)
|
||||
{
|
||||
recruitData.Name = charInfo.Name;
|
||||
recruitData.CharacterClass = (int)charInfo.ClassID;
|
||||
recruitData.CharacterGender = (int)charInfo.Sex;
|
||||
recruitData.CharacterClass = (byte)charInfo.ClassId;
|
||||
recruitData.CharacterGender = (byte)charInfo.Sex;
|
||||
recruitData.CharacterLevel = charInfo.Level;
|
||||
}
|
||||
|
||||
|
||||
@@ -321,7 +321,7 @@ namespace Game
|
||||
{
|
||||
// Leader info MUST be sent 1st :S
|
||||
byte roles = (byte)roleCheck.roles.Find(roleCheck.leader).Value;
|
||||
lfgRoleCheckUpdate.Members.Add(new LFGRoleCheckUpdateMember(roleCheck.leader, roles, Global.WorldMgr.GetCharacterInfo(roleCheck.leader).Level, roles > 0));
|
||||
lfgRoleCheckUpdate.Members.Add(new LFGRoleCheckUpdateMember(roleCheck.leader, roles, Global.CharacterCacheStorage.GetCharacterCacheByGuid(roleCheck.leader).Level, roles > 0));
|
||||
|
||||
foreach (var it in roleCheck.roles)
|
||||
{
|
||||
@@ -329,7 +329,7 @@ namespace Game
|
||||
continue;
|
||||
|
||||
roles = (byte)it.Value;
|
||||
lfgRoleCheckUpdate.Members.Add(new LFGRoleCheckUpdateMember(it.Key, roles, Global.WorldMgr.GetCharacterInfo(it.Key).Level, roles > 0));
|
||||
lfgRoleCheckUpdate.Members.Add(new LFGRoleCheckUpdateMember(it.Key, roles, Global.CharacterCacheStorage.GetCharacterCacheByGuid(it.Key).Level, roles > 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
using Framework.Constants;
|
||||
using Framework.Database;
|
||||
using Game.Cache;
|
||||
using Game.DataStorage;
|
||||
using Game.Entities;
|
||||
using Game.Guilds;
|
||||
@@ -81,7 +82,7 @@ namespace Game
|
||||
|
||||
ObjectGuid receiverGuid = ObjectGuid.Empty;
|
||||
if (ObjectManager.NormalizePlayerName(ref packet.Info.Target))
|
||||
receiverGuid = ObjectManager.GetPlayerGUIDByName(packet.Info.Target);
|
||||
receiverGuid = Global.CharacterCacheStorage.GetCharacterGuidByName(packet.Info.Target);
|
||||
|
||||
if (receiverGuid.IsEmpty())
|
||||
{
|
||||
@@ -143,6 +144,7 @@ namespace Game
|
||||
byte mailsCount = 0; //do not allow to send to one player more than 100 mails
|
||||
byte receiverLevel = 0;
|
||||
uint receiverAccountId = 0;
|
||||
uint receiverBnetAccountId = 0;
|
||||
|
||||
if (receiver)
|
||||
{
|
||||
@@ -150,10 +152,17 @@ namespace Game
|
||||
mailsCount = (byte)receiver.GetMails().Count;
|
||||
receiverLevel = (byte)receiver.getLevel();
|
||||
receiverAccountId = receiver.GetSession().GetAccountId();
|
||||
receiverBnetAccountId = receiver.GetSession().GetBattlenetAccountId();
|
||||
}
|
||||
else
|
||||
{
|
||||
receiverTeam = ObjectManager.GetPlayerTeamByGUID(receiverGuid);
|
||||
CharacterCacheEntry characterInfo = Global.CharacterCacheStorage.GetCharacterCacheByGuid(receiverGuid);
|
||||
if (characterInfo != null)
|
||||
{
|
||||
receiverTeam = Player.TeamForRace(characterInfo.RaceId);
|
||||
receiverLevel = characterInfo.Level;
|
||||
receiverAccountId = characterInfo.AccountId;
|
||||
}
|
||||
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_MAIL_COUNT);
|
||||
stmt.AddValue(0, receiverGuid.GetCounter());
|
||||
@@ -162,14 +171,7 @@ namespace Game
|
||||
if (!result.IsEmpty())
|
||||
mailsCount = (byte)result.Read<ulong>(0);
|
||||
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CHAR_LEVEL);
|
||||
stmt.AddValue(0, receiverGuid.GetCounter());
|
||||
|
||||
result = DB.Characters.Query(stmt);
|
||||
if (!result.IsEmpty())
|
||||
receiverLevel = result.Read<byte>(0);
|
||||
|
||||
receiverAccountId = ObjectManager.GetPlayerAccountIdByGUID(receiverGuid);
|
||||
receiverBnetAccountId = Global.BNetAccountMgr.GetIdByGameAccount(receiverAccountId);
|
||||
}
|
||||
|
||||
// do not allow to have more than 100 mails in mailbox.. mails count is in opcode byte!!! - so max can be 255..
|
||||
@@ -233,8 +235,11 @@ namespace Game
|
||||
|
||||
if (item.IsBoundAccountWide() && item.IsSoulBound() && player.GetSession().GetAccountId() != receiverAccountId)
|
||||
{
|
||||
player.SendMailResult(0, MailResponseType.Send, MailResponseResult.EquipError, InventoryResult.NotSameAccount);
|
||||
return;
|
||||
if (!item.IsBattlenetAccountBound() || player.GetSession().GetBattlenetAccountId() == 0 || player.GetSession().GetBattlenetAccountId() != receiverBnetAccountId)
|
||||
{
|
||||
player.SendMailResult(0, MailResponseType.Send, MailResponseResult.EquipError, InventoryResult.NotSameAccount);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.GetTemplate().GetFlags().HasAnyFlag(ItemFlags.Conjured) || item.m_itemData.Expiration != 0)
|
||||
@@ -476,16 +481,16 @@ namespace Game
|
||||
else
|
||||
{
|
||||
// can be calculated early
|
||||
sender_accId = ObjectManager.GetPlayerAccountIdByGUID(sender_guid);
|
||||
sender_accId = Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(sender_guid);
|
||||
|
||||
if (!ObjectManager.GetPlayerNameByGUID(sender_guid, out sender_name))
|
||||
if (!Global.CharacterCacheStorage.GetCharacterNameByGuid(sender_guid, out sender_name))
|
||||
sender_name = Global.ObjectMgr.GetCypherString(CypherStrings.Unknown);
|
||||
}
|
||||
Log.outCommand(GetAccountId(), "GM {0} (Account: {1}) receiver mail item: {2} (Entry: {3} Count: {4}) and send COD money: {5} to player: {6} (Account: {7})",
|
||||
GetPlayerName(), GetAccountId(), it.GetTemplate().GetName(), it.GetEntry(), it.GetCount(), m.COD, sender_name, sender_accId);
|
||||
}
|
||||
else if (!receiver)
|
||||
sender_accId = ObjectManager.GetPlayerAccountIdByGUID(sender_guid);
|
||||
sender_accId = Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(sender_guid);
|
||||
|
||||
// check player existence
|
||||
if (receiver || sender_accId != 0)
|
||||
|
||||
@@ -289,13 +289,7 @@ namespace Game
|
||||
|
||||
if (corpseGrave != ghostGrave)
|
||||
GetPlayer().TeleportTo(corpseGrave.MapID, corpseGrave.Loc.X, corpseGrave.Loc.Y, corpseGrave.Loc.Z, GetPlayer().GetOrientation());
|
||||
// or update at original position
|
||||
else
|
||||
GetPlayer().UpdateObjectVisibility();
|
||||
}
|
||||
// or update at original position
|
||||
else
|
||||
GetPlayer().UpdateObjectVisibility();
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.BinderActivate)]
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace Game
|
||||
ServerPetitionShowSignatures signaturesPacket = new ServerPetitionShowSignatures();
|
||||
signaturesPacket.Item = packet.Item;
|
||||
signaturesPacket.Owner = GetPlayer().GetGUID();
|
||||
signaturesPacket.OwnerAccountID = ObjectGuid.Create(HighGuid.WowAccount, ObjectManager.GetPlayerAccountIdByGUID(GetPlayer().GetGUID()));
|
||||
signaturesPacket.OwnerAccountID = ObjectGuid.Create(HighGuid.WowAccount, Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(GetPlayer().GetGUID()));
|
||||
signaturesPacket.PetitionID = (int)packet.Item.GetCounter(); // @todo verify that...
|
||||
|
||||
do
|
||||
@@ -253,7 +253,7 @@ namespace Game
|
||||
return;
|
||||
|
||||
// not let enemies sign guild charter
|
||||
if (!WorldConfig.GetBoolValue(WorldCfg.AllowTwoSideInteractionGuild) && GetPlayer().GetTeam() != ObjectManager.GetPlayerTeamByGUID(ownerGuid))
|
||||
if (!WorldConfig.GetBoolValue(WorldCfg.AllowTwoSideInteractionGuild) && GetPlayer().GetTeam() != Global.CharacterCacheStorage.GetCharacterTeamByGuid(ownerGuid))
|
||||
{
|
||||
Guild.SendCommandResult(this, GuildCommandType.CreateGuild, GuildCommandError.NotAllied);
|
||||
return;
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
using Framework.Constants;
|
||||
using Framework.Database;
|
||||
using Game.Cache;
|
||||
using Game.DataStorage;
|
||||
using Game.Entities;
|
||||
using Game.Guilds;
|
||||
using Game.Network;
|
||||
using Game.Network.Packets;
|
||||
using System;
|
||||
@@ -220,28 +220,15 @@ namespace Game
|
||||
if (!ObjectManager.NormalizePlayerName(ref packet.Name))
|
||||
return;
|
||||
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_GUID_RACE_ACC_BY_NAME);
|
||||
stmt.AddValue(0, packet.Name);
|
||||
|
||||
_queryProcessor.AddQuery(DB.Characters.AsyncQuery(stmt).WithCallback(HandleAddFriendCallBack, packet.Notes));
|
||||
}
|
||||
|
||||
void HandleAddFriendCallBack(string friendNote, SQLResult result)
|
||||
{
|
||||
if (!GetPlayer())
|
||||
return;
|
||||
|
||||
ObjectGuid friendGuid = ObjectGuid.Empty;
|
||||
FriendsResult friendResult = FriendsResult.NotFound;
|
||||
|
||||
if (!result.IsEmpty())
|
||||
ObjectGuid friendGuid = Global.CharacterCacheStorage.GetCharacterGuidByName(packet.Name);
|
||||
if (!friendGuid.IsEmpty())
|
||||
{
|
||||
ulong lowGuid = result.Read<ulong>(0);
|
||||
if (lowGuid != 0)
|
||||
CharacterCacheEntry characterInfo = Global.CharacterCacheStorage.GetCharacterCacheByGuid(friendGuid);
|
||||
if (characterInfo != null)
|
||||
{
|
||||
friendGuid = ObjectGuid.Create(HighGuid.Player, lowGuid);
|
||||
Team team = Player.TeamForRace((Race)result.Read<byte>(1));
|
||||
uint friendAccountId = result.Read<uint>(2);
|
||||
Team team = Player.TeamForRace(characterInfo.RaceId);
|
||||
uint friendAccountId = characterInfo.AccountId;
|
||||
|
||||
if (HasPermission(RBACPermissions.AllowGmFriend) || Global.AccountMgr.IsPlayerAccount(Global.AccountMgr.GetSecurity(friendAccountId, (int)Global.WorldMgr.GetRealm().Id.Realm)))
|
||||
{
|
||||
@@ -260,7 +247,7 @@ namespace Game
|
||||
friendResult = FriendsResult.AddedOffline;
|
||||
|
||||
if (GetPlayer().GetSocial().AddToSocialList(friendGuid, SocialFlag.Friend))
|
||||
GetPlayer().GetSocial().SetFriendNote(friendGuid, friendNote);
|
||||
GetPlayer().GetSocial().SetFriendNote(friendGuid, packet.Notes);
|
||||
else
|
||||
friendResult = FriendsResult.ListFull;
|
||||
}
|
||||
@@ -286,39 +273,21 @@ namespace Game
|
||||
if (!ObjectManager.NormalizePlayerName(ref packet.Name))
|
||||
return;
|
||||
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_GUID_BY_NAME);
|
||||
stmt.AddValue(0, packet.Name);
|
||||
|
||||
_queryProcessor.AddQuery(DB.Characters.AsyncQuery(stmt).WithCallback(HandleAddIgnoreCallBack));
|
||||
}
|
||||
|
||||
void HandleAddIgnoreCallBack(SQLResult result)
|
||||
{
|
||||
if (!GetPlayer())
|
||||
return;
|
||||
|
||||
ObjectGuid IgnoreGuid = ObjectGuid.Empty;
|
||||
ObjectGuid IgnoreGuid = Global.CharacterCacheStorage.GetCharacterGuidByName(packet.Name);
|
||||
FriendsResult ignoreResult = FriendsResult.IgnoreNotFound;
|
||||
|
||||
if (result.IsEmpty())
|
||||
if (IgnoreGuid.IsEmpty())
|
||||
{
|
||||
ulong lowGuid = result.Read<ulong>(0);
|
||||
if (lowGuid != 0)
|
||||
if (IgnoreGuid == GetPlayer().GetGUID()) //not add yourself
|
||||
ignoreResult = FriendsResult.IgnoreSelf;
|
||||
else if (GetPlayer().GetSocial().HasIgnore(IgnoreGuid))
|
||||
ignoreResult = FriendsResult.IgnoreAlready;
|
||||
else
|
||||
{
|
||||
IgnoreGuid = ObjectGuid.Create(HighGuid.Player, lowGuid);
|
||||
ignoreResult = FriendsResult.IgnoreAdded;
|
||||
|
||||
if (IgnoreGuid == GetPlayer().GetGUID()) //not add yourself
|
||||
ignoreResult = FriendsResult.IgnoreSelf;
|
||||
else if (GetPlayer().GetSocial().HasIgnore(IgnoreGuid))
|
||||
ignoreResult = FriendsResult.IgnoreAlready;
|
||||
else
|
||||
{
|
||||
ignoreResult = FriendsResult.IgnoreAdded;
|
||||
|
||||
// ignore list full
|
||||
if (!GetPlayer().GetSocial().AddToSocialList(IgnoreGuid, SocialFlag.Ignored))
|
||||
ignoreResult = FriendsResult.IgnoreFull;
|
||||
}
|
||||
// ignore list full
|
||||
if (!GetPlayer().GetSocial().AddToSocialList(IgnoreGuid, SocialFlag.Ignored))
|
||||
ignoreResult = FriendsResult.IgnoreFull;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,6 +134,13 @@ namespace Game
|
||||
if (player.m_unitMovedByMe != player)
|
||||
return;
|
||||
|
||||
// additional check, client outputs message on its own
|
||||
if (!player.IsAlive())
|
||||
{
|
||||
player.SendEquipError(InventoryResult.PlayerDead);
|
||||
return;
|
||||
}
|
||||
|
||||
Item item = player.GetItemByPos(packet.Slot, packet.PackSlot);
|
||||
if (!item)
|
||||
{
|
||||
@@ -181,33 +188,51 @@ namespace Game
|
||||
{
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CHARACTER_GIFT_BY_ITEM);
|
||||
stmt.AddValue(0, item.GetGUID().GetCounter());
|
||||
SQLResult result = DB.Characters.Query(stmt);
|
||||
|
||||
if (!result.IsEmpty())
|
||||
{
|
||||
uint entry = result.Read<uint>(0);
|
||||
uint flags = result.Read<uint>(1);
|
||||
|
||||
item.SetGiftCreator(ObjectGuid.Empty);
|
||||
item.SetEntry(entry);
|
||||
item.SetItemFlags((ItemFieldFlags)flags);
|
||||
item.SetState(ItemUpdateState.Changed, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.outError(LogFilter.Network, "Wrapped item {0} don't have record in character_gifts table and will deleted", item.GetGUID().ToString());
|
||||
player.DestroyItem(item.GetBagSlot(), item.GetSlot(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_GIFT);
|
||||
stmt.AddValue(0, item.GetGUID().GetCounter());
|
||||
DB.Characters.Execute(stmt);
|
||||
_queryProcessor.AddQuery(DB.Characters.AsyncQuery(stmt)
|
||||
.WithCallback(result => HandleOpenWrappedItemCallback(item.GetPos(), item.GetGUID(), result)));
|
||||
}
|
||||
else
|
||||
player.SendLoot(item.GetGUID(), LootType.Corpse);
|
||||
}
|
||||
|
||||
void HandleOpenWrappedItemCallback(ushort pos, ObjectGuid itemGuid, SQLResult result)
|
||||
{
|
||||
if (!GetPlayer())
|
||||
return;
|
||||
|
||||
Item item = GetPlayer().GetItemByPos(pos);
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
if (item.GetGUID() != itemGuid || !item.HasItemFlag(ItemFieldFlags.Wrapped)) // during getting result, gift was swapped with another item
|
||||
return;
|
||||
|
||||
if (result.IsEmpty())
|
||||
{
|
||||
Log.outError(LogFilter.Network, $"Wrapped item {item.GetGUID().ToString()} don't have record in character_gifts table and will deleted");
|
||||
GetPlayer().DestroyItem(item.GetBagSlot(), item.GetSlot(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
SQLTransaction trans = new SQLTransaction();
|
||||
|
||||
uint entry = result.Read<uint>(0);
|
||||
uint flags = result.Read<uint>(1);
|
||||
|
||||
item.SetGiftCreator(ObjectGuid.Empty);
|
||||
item.SetEntry(entry);
|
||||
item.SetItemFlags((ItemFieldFlags)flags);
|
||||
item.SetState(ItemUpdateState.Changed, GetPlayer());
|
||||
|
||||
GetPlayer().SaveInventoryAndGoldToDB(trans);
|
||||
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_GIFT);
|
||||
stmt.AddValue(0, itemGuid.GetCounter());
|
||||
trans.Append(stmt);
|
||||
|
||||
DB.Characters.CommitTransaction(trans);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.GameObjUse)]
|
||||
void HandleGameObjectUse(GameObjUse packet)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user