void HandleDeclinePetition(DeclinePetition packet) { PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_PETITION_OWNER_BY_GUID); stmt.AddValue(0, packet.PetitionGUID.GetCounter()); SQLResult result = DB.Characters.Query(stmt); if (result.IsEmpty()) { return; } ObjectGuid ownerguid = ObjectGuid.Create(HighGuid.Player, result.Read <ulong>(0)); Player owner = Global.ObjAccessor.FindPlayer(ownerguid); if (owner) // petition owner online { // Disabled because packet isn't handled by the client in any way /* * WorldPacket data = new WorldPacket(ServerOpcodes.PetitionDecline); * data.WritePackedGuid(GetPlayer().GetGUID()); * owner.SendPacket(data); */ } }
static bool HandleAuraCommand(CommandHandler handler, StringArguments args) { Unit target = handler.GetSelectedUnit(); if (!target) { handler.SendSysMessage(CypherStrings.SelectCharOrCreature); return(false); } // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint spellId = handler.ExtractSpellIdFromLink(args); SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, target.GetMap().GetDifficultyID()); if (spellInfo != null) { ObjectGuid castId = ObjectGuid.Create(HighGuid.Cast, SpellCastSource.Normal, target.GetMapId(), spellId, target.GetMap().GenerateLowGuid(HighGuid.Cast)); AuraCreateInfo createInfo = new(castId, spellInfo, target.GetMap().GetDifficultyID(), SpellConst.MaxEffectMask, target); createInfo.SetCaster(target); Aura.TryRefreshStackOrCreate(createInfo); } return(true); }
public void AddPet(uint species, uint creatureId, ushort breed, byte quality, ushort level = 1) { BattlePetSpeciesRecord battlePetSpecies = CliDB.BattlePetSpeciesStorage.LookupByKey(species); if (battlePetSpecies == null) // should never happen { return; } BattlePet pet = new BattlePet(); pet.PacketInfo.Guid = ObjectGuid.Create(HighGuid.BattlePet, Global.ObjectMgr.GetGenerator(HighGuid.BattlePet).Generate()); pet.PacketInfo.Species = species; pet.PacketInfo.CreatureID = creatureId; pet.PacketInfo.Level = level; pet.PacketInfo.Exp = 0; pet.PacketInfo.Flags = 0; pet.PacketInfo.Breed = breed; pet.PacketInfo.Quality = quality; pet.PacketInfo.Name = ""; pet.CalculateStats(); pet.PacketInfo.Health = pet.PacketInfo.MaxHealth; pet.SaveInfo = BattlePetSaveInfo.New; _pets[pet.PacketInfo.Guid.GetCounter()] = pet; List <BattlePet> updates = new List <BattlePet>(); updates.Add(pet); SendUpdates(updates, true); _owner.GetPlayer().UpdateCriteria(CriteriaTypes.OwnBattlePet, species); }
public bool LoadFromDB(SQLFields fields) { _marketId = fields.Read <uint>(0); // Invalid MarketID BlackMarketTemplate templ = Global.BlackMarketMgr.GetTemplateByID(_marketId); if (templ == null) { Log.outError(LogFilter.Misc, "Black market auction {0} does not have a valid id.", _marketId); return(false); } _currentBid = fields.Read <ulong>(1); _secondsRemaining = (uint)(fields.Read <uint>(2) - Global.BlackMarketMgr.GetLastUpdate()); _numBids = fields.Read <uint>(3); _bidder = fields.Read <ulong>(4); // Either no bidder or existing player if (_bidder != 0 && ObjectManager.GetPlayerAccountIdByGUID(ObjectGuid.Create(HighGuid.Player, _bidder)) == 0) // Probably a better way to check if player exists { Log.outError(LogFilter.Misc, "Black market auction {0} does not have a valid bidder (GUID: {1}).", _marketId, _bidder); return(false); } return(true); }
public void SendAuctionOutbidMail(BlackMarketEntry entry, SQLTransaction trans) { ObjectGuid oldBidder_guid = ObjectGuid.Create(HighGuid.Player, entry.GetBidder()); Player oldBidder = Global.ObjAccessor.FindConnectedPlayer(oldBidder_guid); uint oldBidder_accId = 0; if (!oldBidder) { oldBidder_accId = Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(oldBidder_guid); } // old bidder exist if (!oldBidder && oldBidder_accId == 0) { return; } if (oldBidder) { oldBidder.GetSession().SendBlackMarketOutbidNotification(entry.GetTemplate()); } new MailDraft(entry.BuildAuctionMailSubject(BMAHMailAuctionAnswers.Outbid), entry.BuildAuctionMailBody()) .AddMoney(entry.GetCurrentBid()) .SendMailTo(trans, new MailReceiver(oldBidder, entry.GetBidder()), new MailSender(entry), MailCheckMask.Copied); }
void HandlePetitionShowSignatures(PetitionShowSignatures packet) { Log.outDebug(LogFilter.Network, "Received opcode CMSG_PETITION_SHOW_SIGNATURES"); // if has guild => error, return; if (GetPlayer().GetGuildId() != 0) { return; } PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_PETITION_SIGNATURE); stmt.AddValue(0, packet.Item.GetCounter()); SQLResult result = DB.Characters.Query(stmt); ServerPetitionShowSignatures signaturesPacket = new ServerPetitionShowSignatures(); signaturesPacket.Item = packet.Item; signaturesPacket.Owner = GetPlayer().GetGUID(); signaturesPacket.OwnerAccountID = ObjectGuid.Create(HighGuid.WowAccount, ObjectManager.GetPlayerAccountIdByGUID(GetPlayer().GetGUID())); signaturesPacket.PetitionID = (int)packet.Item.GetCounter(); // @todo verify that... do { ObjectGuid signerGUID = ObjectGuid.Create(HighGuid.Player, result.Read <ulong>(0)); ServerPetitionShowSignatures.PetitionSignature signature = new ServerPetitionShowSignatures.PetitionSignature(); signature.Signer = signerGUID; signature.Choice = 0; signaturesPacket.Signatures.Add(signature); }while (result.NextRow()); SendPacket(signaturesPacket); }
//does not clear ram public void SendAuctionExpiredMail(AuctionEntry auction, SQLTransaction trans) { //return an item in auction to its owner by mail Item item = GetAItem(auction.itemGUIDLow); if (!item) { return; } ObjectGuid owner_guid = ObjectGuid.Create(HighGuid.Player, auction.owner); Player owner = Global.ObjAccessor.FindPlayer(owner_guid); uint owner_accId = Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(owner_guid); // owner exist if (owner || owner_accId != 0) { if (owner) { owner.GetSession().SendAuctionClosedNotification(auction, 0f, false, item); } new MailDraft(auction.BuildAuctionMailSubject(MailAuctionAnswers.Expired), AuctionEntry.BuildAuctionMailBody(0, 0, auction.buyout, auction.deposit, 0)) .AddItem(item) .SendMailTo(trans, new MailReceiver(owner, auction.owner), new MailSender(auction), MailCheckMask.Copied, 0); } else { // owner doesn't exist, delete the item Global.AuctionMgr.RemoveAItem(auction.itemGUIDLow, true); } }
//this function sends mail to old bidder public void SendAuctionOutbiddedMail(AuctionEntry auction, ulong newPrice, Player newBidder, SQLTransaction trans) { ObjectGuid oldBidder_guid = ObjectGuid.Create(HighGuid.Player, auction.bidder); Player oldBidder = Global.ObjAccessor.FindPlayer(oldBidder_guid); uint oldBidder_accId = 0; if (oldBidder == null) { oldBidder_accId = Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(oldBidder_guid); } Item item = GetAItem(auction.itemGUIDLow); // old bidder exist if (oldBidder || oldBidder_accId != 0) { if (oldBidder && item) { oldBidder.GetSession().SendAuctionOutBidNotification(auction, item); } new MailDraft(auction.BuildAuctionMailSubject(MailAuctionAnswers.Outbidded), AuctionEntry.BuildAuctionMailBody(auction.owner, auction.bid, auction.buyout, auction.deposit, auction.GetAuctionCut())) .AddMoney(auction.bid) .SendMailTo(trans, new MailReceiver(oldBidder, auction.bidder), new MailSender(auction), MailCheckMask.Copied); } }
void HandleAddFriendCallBack(string friendNote, SQLResult result) { if (!GetPlayer()) { return; } ObjectGuid friendGuid = ObjectGuid.Empty; FriendsResult friendResult = FriendsResult.NotFound; if (!result.IsEmpty()) { ulong lowGuid = result.Read <ulong>(0); if (lowGuid != 0) { friendGuid = ObjectGuid.Create(HighGuid.Player, lowGuid); Team team = Player.TeamForRace((Race)result.Read <byte>(1)); uint friendAccountId = result.Read <uint>(2); if (HasPermission(RBACPermissions.AllowGmFriend) || Global.AccountMgr.IsPlayerAccount(Global.AccountMgr.GetSecurity(friendAccountId, (int)Global.WorldMgr.GetRealm().Id.Realm))) { if (friendGuid == GetPlayer().GetGUID()) { friendResult = FriendsResult.Self; } else if (GetPlayer().GetTeam() != team && !HasPermission(RBACPermissions.TwoSideAddFriend)) { friendResult = FriendsResult.Enemy; } else if (GetPlayer().GetSocial().HasFriend(friendGuid)) { friendResult = FriendsResult.Already; } else { Player playerFriend = Global.ObjAccessor.FindPlayer(friendGuid); if (playerFriend && playerFriend.IsVisibleGloballyFor(GetPlayer())) { friendResult = FriendsResult.AddedOnline; } else { friendResult = FriendsResult.AddedOffline; } if (GetPlayer().GetSocial().AddToSocialList(friendGuid, SocialFlag.Friend)) { GetPlayer().GetSocial().SetFriendNote(friendGuid, friendNote); } else { friendResult = FriendsResult.ListFull; } } } } } Global.SocialMgr.SendFriendStatus(GetPlayer(), friendResult, friendGuid); }
//call this method to send mail to auction owner, when auction is successful, it does not clear ram public void SendAuctionSuccessfulMail(AuctionEntry auction, SQLTransaction trans) { ObjectGuid owner_guid = ObjectGuid.Create(HighGuid.Player, auction.owner); Player owner = Global.ObjAccessor.FindPlayer(owner_guid); uint owner_accId = Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(owner_guid); Item item = GetAItem(auction.itemGUIDLow); // owner exist if (owner || owner_accId != 0) { ulong profit = auction.bid + auction.deposit - auction.GetAuctionCut(); //FIXME: what do if owner offline if (owner && item) { owner.UpdateCriteria(CriteriaTypes.GoldEarnedByAuctions, profit); owner.UpdateCriteria(CriteriaTypes.HighestAuctionSold, auction.bid); // send auction owner notification, bidder must be current! owner.GetSession().SendAuctionClosedNotification(auction, WorldConfig.GetIntValue(WorldCfg.MailDeliveryDelay), true, item); } new MailDraft(auction.BuildAuctionMailSubject(MailAuctionAnswers.Successful), AuctionEntry.BuildAuctionMailBody(auction.bidder, auction.bid, auction.buyout, auction.deposit, auction.GetAuctionCut())) .AddMoney(profit) .SendMailTo(trans, new MailReceiver(owner, auction.owner), new MailSender(auction), MailCheckMask.Copied, WorldConfig.GetUIntValue(WorldCfg.MailDeliveryDelay)); } }
public override bool GossipSelect(Player player, uint menuId, uint gossipListId) { if (gossipListId >= TeleportSpells.Length) { return(false); } player.PlayerTalkClass.ClearMenus(); player.CLOSE_GOSSIP_MENU(); SpellInfo spell = Global.SpellMgr.GetSpellInfo(TeleportSpells[gossipListId]); if (spell == null) { return(false); } if (player.IsInCombat()) { ObjectGuid castId = ObjectGuid.Create(HighGuid.Cast, SpellCastSource.Normal, player.GetMapId(), spell.Id, player.GetMap().GenerateLowGuid(HighGuid.Cast)); Spell.SendCastResult(player, spell, 0, castId, SpellCastResult.AffectingCombat); return(true); } return(true); }
public override bool OnTrigger(Player player, AreaTriggerRecord areaTrigger, bool entered) { if (player.IsInCombat()) { SpellInfo spell = Global.SpellMgr.GetSpellInfo(TeleporterSpells.FROZEN_THRONE_TELEPORT); if (spell != null) { ObjectGuid castId = ObjectGuid.Create(HighGuid.Cast, SpellCastSource.Normal, player.GetMapId(), spell.Id, player.GetMap().GenerateLowGuid(HighGuid.Cast)); Spell.SendCastResult(player, spell, 0, castId, SpellCastResult.AffectingCombat); } return(true); } InstanceScript instance = player.GetInstanceScript(); if (instance != null) { if (instance.GetBossState(Bosses.ProfessorPutricide) == EncounterState.Done && instance.GetBossState(Bosses.BloodQueenLanaThel) == EncounterState.Done && instance.GetBossState(Bosses.Sindragosa) == EncounterState.Done && instance.GetBossState(Bosses.TheLichKing) != EncounterState.InProgress) { player.CastSpell(player, TeleporterSpells.FROZEN_THRONE_TELEPORT, true); } } return(true); }
public bool LoadArenaTeamFromDB(SQLResult result) { if (result.IsEmpty()) { return(false); } teamId = result.Read <uint>(0); TeamName = result.Read <string>(1); CaptainGuid = ObjectGuid.Create(HighGuid.Player, result.Read <ulong>(2)); type = result.Read <byte>(3); BackgroundColor = result.Read <uint>(4); EmblemStyle = result.Read <byte>(5); EmblemColor = result.Read <uint>(6); BorderStyle = result.Read <byte>(7); BorderColor = result.Read <uint>(8); stats.Rating = result.Read <ushort>(9); stats.WeekGames = result.Read <ushort>(10); stats.WeekWins = result.Read <ushort>(11); stats.SeasonGames = result.Read <ushort>(12); stats.SeasonWins = result.Read <ushort>(13); stats.Rank = result.Read <uint>(14); return(true); }
void SetSender(WorldObject sender, LocaleConstant locale) { SenderGUID = sender.GetGUID(); Creature creatureSender = sender.ToCreature(); if (creatureSender) { SenderName = creatureSender.GetName(locale); } Player playerSender = sender.ToPlayer(); if (playerSender) { SenderAccountGUID = playerSender.GetSession().GetAccountGUID(); _ChatFlags = playerSender.GetChatFlags(); SenderGuildGUID = ObjectGuid.Create(HighGuid.Guild, playerSender.GetGuildId()); Group group = playerSender.GetGroup(); if (group) { PartyGUID = group.GetGUID(); } } }
void HandleAddFriend(AddFriend packet) { if (!ObjectManager.NormalizePlayerName(ref packet.Name)) { return; } FriendsResult friendResult = FriendsResult.NotFound; ObjectGuid friendGuid = ObjectGuid.Empty; CharacterCacheEntry characterInfo = Global.CharacterCacheStorage.GetCharacterCacheByName(packet.Name); if (characterInfo != null) { friendGuid = characterInfo.Guid; ObjectGuid friendAccountGuid = ObjectGuid.Create(HighGuid.WowAccount, characterInfo.AccountId); 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.Index))) { if (friendGuid == GetPlayer().GetGUID()) { friendResult = FriendsResult.Self; } else if (GetPlayer().GetTeam() != team && !HasPermission(RBACPermissions.TwoSideAddFriend)) { friendResult = FriendsResult.Enemy; } else if (GetPlayer().GetSocial().HasFriend(friendGuid)) { friendResult = FriendsResult.Already; } else { Player playerFriend = Global.ObjAccessor.FindPlayer(friendGuid); if (playerFriend && playerFriend.IsVisibleGloballyFor(GetPlayer())) { friendResult = FriendsResult.AddedOnline; } else { friendResult = FriendsResult.AddedOffline; } if (GetPlayer().GetSocial().AddToSocialList(friendGuid, friendAccountGuid, SocialFlag.Friend)) { GetPlayer().GetSocial().SetFriendNote(friendGuid, packet.Notes); } else { friendResult = FriendsResult.ListFull; } } } } Global.SocialMgr.SendFriendStatus(GetPlayer(), friendResult, friendGuid); }
public void Write(WorldPacket data) { data.WritePackedGuid(Pet.Guid.IsEmpty() ? ObjectGuid.Create(HighGuid.BattlePet, 0) : Pet.Guid); data.WriteUInt32(CollarID); data.WriteUInt8(Index); data.WriteBit(Locked); data.FlushBits(); }
public bool LoadMembersFromDB(SQLResult result) { if (result.IsEmpty()) { return(false); } bool captainPresentInTeam = false; do { uint arenaTeamId = result.Read <uint>(0); // We loaded all members for this arena_team already, break cycle if (arenaTeamId > teamId) { break; } ArenaTeamMember newMember = new ArenaTeamMember(); newMember.Guid = ObjectGuid.Create(HighGuid.Player, result.Read <ulong>(1)); newMember.WeekGames = result.Read <ushort>(2); newMember.WeekWins = result.Read <ushort>(3); newMember.SeasonGames = result.Read <ushort>(4); newMember.SeasonWins = result.Read <ushort>(5); newMember.Name = result.Read <string>(6); newMember.Class = result.Read <byte>(7); newMember.PersonalRating = result.Read <ushort>(8); newMember.MatchMakerRating = (ushort)(result.Read <ushort>(9) > 0 ? result.Read <ushort>(9) : 1500); // Delete member if character information is missing if (string.IsNullOrEmpty(newMember.Name)) { Log.outError(LogFilter.Sql, "ArenaTeam {0} has member with empty name - probably {1} doesn't exist, deleting him from memberlist!", arenaTeamId, newMember.Guid.ToString()); DelMember(newMember.Guid, true); continue; } // Check if team team has a valid captain if (newMember.Guid == GetCaptain()) { captainPresentInTeam = true; } // Put the player in the team Members.Add(newMember); Global.CharacterCacheStorage.UpdateCharacterArenaTeamId(newMember.Guid, GetSlot(), GetId()); }while (result.NextRow()); if (Empty() || !captainPresentInTeam) { // Arena team is empty or captain is not in team, delete from db Log.outDebug(LogFilter.Arena, "ArenaTeam {0} does not have any members or its captain is not in team, disbanding it...", teamId); return(false); } return(true); }
static bool GetDeletedCharacterInfoList(List <DeletedInfo> foundList, string searchString) { SQLResult result; PreparedStatement stmt; if (!searchString.IsEmpty()) { // search by GUID if (searchString.IsNumber()) { if (!ulong.TryParse(searchString, out ulong guid)) { return(false); } stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CHAR_DEL_INFO_BY_GUID); stmt.AddValue(0, guid); result = DB.Characters.Query(stmt); } // search by name else { if (!ObjectManager.NormalizePlayerName(ref searchString)) { return(false); } stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CHAR_DEL_INFO_BY_NAME); stmt.AddValue(0, searchString); result = DB.Characters.Query(stmt); } } else { stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CHAR_DEL_INFO); result = DB.Characters.Query(stmt); } if (!result.IsEmpty()) { do { DeletedInfo info; info.guid = ObjectGuid.Create(HighGuid.Player, result.Read <ulong>(0)); info.name = result.Read <string>(1); info.accountId = result.Read <uint>(2); // account name will be empty for not existed account Global.AccountMgr.GetName(info.accountId, out info.accountName); info.deleteDate = result.Read <uint>(3); foundList.Add(info); }while (result.NextRow()); } return(true); }
public void SendAuctionOwnerBidNotification(AuctionEntry auction, Item item) { AuctionOwnerBidNotification packet = new AuctionOwnerBidNotification(); packet.Info.Initialize(auction, item); packet.Bidder = ObjectGuid.Create(HighGuid.Player, auction.bidder); packet.MinIncrement = auction.GetAuctionOutBid(); SendPacket(packet); }
public void BuildAuctionInfo(List <AuctionItem> items, bool listAuctionItems) { Item item = Global.AuctionMgr.GetAItem(itemGUIDLow); if (!item) { Log.outError(LogFilter.Server, "AuctionEntry:BuildAuctionInfo: Auction {0} has a non-existent item: {1}", Id, itemGUIDLow); return; } AuctionItem auctionItem = new AuctionItem(); auctionItem.AuctionItemID = (int)Id; auctionItem.Item = new ItemInstance(item); auctionItem.BuyoutPrice = buyout; auctionItem.CensorBidInfo = false; auctionItem.CensorServerSideInfo = listAuctionItems; auctionItem.Charges = item.GetSpellCharges(); auctionItem.Count = (int)item.GetCount(); auctionItem.DeleteReason = 0; // Always 0 ? auctionItem.DurationLeft = (int)((expire_time - Time.UnixTime) * Time.InMilliseconds); auctionItem.EndTime = (uint)expire_time; auctionItem.Flags = 0; // todo auctionItem.ItemGuid = item.GetGUID(); auctionItem.MinBid = startbid; auctionItem.Owner = ObjectGuid.Create(HighGuid.Player, owner); auctionItem.OwnerAccountID = ObjectGuid.Create(HighGuid.WowAccount, Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(auctionItem.Owner)); auctionItem.MinIncrement = bidder != 0 ? GetAuctionOutBid() : 0; auctionItem.Bidder = bidder != 0 ? ObjectGuid.Create(HighGuid.Player, bidder) : ObjectGuid.Empty; auctionItem.BidAmount = bidder != 0 ? bid : 0; for (EnchantmentSlot c = 0; c < EnchantmentSlot.MaxInspected; c++) { if (item.GetEnchantmentId(c) == 0) { continue; } auctionItem.Enchantments.Add(new ItemEnchantData((int)item.GetEnchantmentId(c), item.GetEnchantmentDuration(c), (int)item.GetEnchantmentCharges(c), (byte)c)); } byte i = 0; foreach (SocketedGem gemData in item.m_itemData.Gems) { if (gemData.ItemId != 0) { ItemGemData gem = new ItemGemData(); gem.Slot = i; gem.Item = new ItemInstance(gemData); auctionItem.Gems.Add(gem); } ++i; } items.Add(auctionItem); }
public void InitializeAuction(AuctionEntry auction) { if (auction != null) { AuctionItemID = auction.Id; Money = auction.bid == auction.buyout ? 0 : auction.bid; MinIncrement = auction.bid == auction.buyout ? 0 : auction.GetAuctionOutBid(); Guid = ObjectGuid.Create(HighGuid.Player, auction.bidder); } }
public override void OnConversationCreate(Conversation conversation, Unit creator) { conversation.AddActor(ObjectGuid.Create(HighGuid.Player, 0xFFFFFFFFFFFFFFFF), 1); Player player = creator.ToPlayer(); if (player != null) { player.KilledMonsterCredit(NpcTalkToYourCommanderCredit); } }
public void LoadFromDB(SQLResult petsResult, SQLResult slotsResult) { if (!petsResult.IsEmpty()) { do { uint species = petsResult.Read <uint>(1); BattlePetSpeciesRecord speciesEntry = CliDB.BattlePetSpeciesStorage.LookupByKey(species); if (speciesEntry != null) { if (GetPetCount(species) >= SharedConst.MaxBattlePetsPerSpecies) { Log.outError(LogFilter.Misc, "Battlenet account with id {0} has more than 3 battle pets of species {1}", _owner.GetBattlenetAccountId(), species); continue; } BattlePet pet = new BattlePet(); pet.PacketInfo.Guid = ObjectGuid.Create(HighGuid.BattlePet, petsResult.Read <ulong>(0)); pet.PacketInfo.Species = species; pet.PacketInfo.Breed = petsResult.Read <ushort>(2); pet.PacketInfo.Level = petsResult.Read <ushort>(3); pet.PacketInfo.Exp = petsResult.Read <ushort>(4); pet.PacketInfo.Health = petsResult.Read <uint>(5); pet.PacketInfo.Quality = petsResult.Read <byte>(6); pet.PacketInfo.Flags = petsResult.Read <ushort>(7); pet.PacketInfo.Name = petsResult.Read <string>(8); pet.PacketInfo.CreatureID = speciesEntry.CreatureID; pet.SaveInfo = BattlePetSaveInfo.Unchanged; pet.CalculateStats(); _pets[pet.PacketInfo.Guid.GetCounter()] = pet; } } while (petsResult.NextRow()); } if (!slotsResult.IsEmpty()) { byte i = 0; // slots.GetRowCount() should equal MAX_BATTLE_PET_SLOTS do { _slots[i].Index = slotsResult.Read <byte>(0); var battlePet = _pets.LookupByKey(slotsResult.Read <ulong>(1)); if (battlePet != null) { _slots[i].Pet = battlePet.PacketInfo; } _slots[i].Locked = slotsResult.Read <bool>(2); i++; } while (slotsResult.NextRow()); } }
void HandleVoidSwapItem(SwapVoidItem swapVoidItem) { Player player = GetPlayer(); Creature unit = player.GetNPCIfCanInteractWith(swapVoidItem.Npc, NPCFlags.VaultKeeper, NPCFlags2.None); if (!unit) { Log.outDebug(LogFilter.Network, "WORLD: HandleVoidSwapItem - {0} not found or player can't interact with it.", swapVoidItem.Npc.ToString()); return; } if (!player.IsVoidStorageUnlocked()) { Log.outDebug(LogFilter.Network, "WORLD: HandleVoidSwapItem - Player ({0}, name: {1}) queried void storage without unlocking it.", player.GetGUID().ToString(), player.GetName()); return; } byte oldSlot; if (player.GetVoidStorageItem(swapVoidItem.VoidItemGuid.GetCounter(), out oldSlot) == null) { Log.outDebug(LogFilter.Network, "WORLD: HandleVoidSwapItem - Player (GUID: {0}, name: {1}) requested swapping an invalid item (slot: {2}, itemid: {3}).", player.GetGUID().ToString(), player.GetName(), swapVoidItem.DstSlot, swapVoidItem.VoidItemGuid.ToString()); return; } bool usedDestSlot = player.GetVoidStorageItem((byte)swapVoidItem.DstSlot) != null; ObjectGuid itemIdDest = ObjectGuid.Empty; if (usedDestSlot) { itemIdDest = ObjectGuid.Create(HighGuid.Item, player.GetVoidStorageItem((byte)swapVoidItem.DstSlot).ItemId); } if (!player.SwapVoidStorageItem(oldSlot, (byte)swapVoidItem.DstSlot)) { SendVoidStorageTransferResult(VoidTransferError.InternalError1); return; } VoidItemSwapResponse voidItemSwapResponse = new VoidItemSwapResponse(); voidItemSwapResponse.VoidItemA = swapVoidItem.VoidItemGuid; voidItemSwapResponse.VoidItemSlotA = swapVoidItem.DstSlot; if (usedDestSlot) { voidItemSwapResponse.VoidItemB = itemIdDest; voidItemSwapResponse.VoidItemSlotB = oldSlot; } SendPacket(voidItemSwapResponse); }
public void SendAuctionSalePendingMail(AuctionEntry auction, SQLTransaction trans) { ObjectGuid owner_guid = ObjectGuid.Create(HighGuid.Player, auction.owner); Player owner = Global.ObjAccessor.FindPlayer(owner_guid); uint owner_accId = Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(owner_guid); // owner exist (online or offline) if (owner || owner_accId != 0) { new MailDraft(auction.BuildAuctionMailSubject(MailAuctionAnswers.SalePending), AuctionEntry.BuildAuctionMailBody(auction.bidder, auction.bid, auction.buyout, auction.deposit, auction.GetAuctionCut())) .SendMailTo(trans, new MailReceiver(owner, auction.owner), new MailSender(auction), MailCheckMask.Copied); } }
void HandleVoidStorageQuery(QueryVoidStorage queryVoidStorage) { Player player = GetPlayer(); Creature unit = player.GetNPCIfCanInteractWith(queryVoidStorage.Npc, NPCFlags.Transmogrifier | NPCFlags.VaultKeeper); if (!unit) { Log.outDebug(LogFilter.Network, "WORLD: HandleVoidStorageQuery - {0} not found or player can't interact with it.", queryVoidStorage.Npc.ToString()); SendPacket(new VoidStorageFailed()); return; } if (!GetPlayer().IsVoidStorageUnlocked()) { Log.outDebug(LogFilter.Network, "WORLD: HandleVoidStorageQuery - {0} name: {1} queried void storage without unlocking it.", player.GetGUID().ToString(), player.GetName()); SendPacket(new VoidStorageFailed()); return; } byte count = 0; for (byte i = 0; i < SharedConst.VoidStorageMaxSlot; ++i) { if (player.GetVoidStorageItem(i) != null) { ++count; } } VoidStorageContents voidStorageContents = new VoidStorageContents(); for (byte i = 0; i < SharedConst.VoidStorageMaxSlot; ++i) { VoidStorageItem item = player.GetVoidStorageItem(i); if (item == null) { continue; } VoidItem voidItem = new VoidItem(); voidItem.Guid = ObjectGuid.Create(HighGuid.Item, item.ItemId); voidItem.Creator = item.CreatorGuid; voidItem.Slot = i; voidItem.Item = new ItemInstance(item); voidStorageContents.Items.Add(voidItem); } SendPacket(voidStorageContents); }
void HandleOfferPetition(OfferPetition packet) { Player player = Global.ObjAccessor.FindConnectedPlayer(packet.TargetPlayer); if (!player) { return; } if (!WorldConfig.GetBoolValue(WorldCfg.AllowTwoSideInteractionGuild) && GetPlayer().GetTeam() != player.GetTeam()) { Guild.SendCommandResult(this, GuildCommandType.CreateGuild, GuildCommandError.NotAllied); return; } if (player.GetGuildId() != 0) { Guild.SendCommandResult(this, GuildCommandType.InvitePlayer, GuildCommandError.AlreadyInGuild_S, GetPlayer().GetName()); return; } if (player.GetGuildIdInvited() != 0) { Guild.SendCommandResult(this, GuildCommandType.InvitePlayer, GuildCommandError.AlreadyInvitedToGuild_S, GetPlayer().GetName()); return; } PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_PETITION_SIGNATURE); stmt.AddValue(0, packet.ItemGUID.GetCounter()); SQLResult result = DB.Characters.Query(stmt); ServerPetitionShowSignatures signaturesPacket = new ServerPetitionShowSignatures(); signaturesPacket.Item = packet.ItemGUID; signaturesPacket.Owner = GetPlayer().GetGUID(); signaturesPacket.OwnerAccountID = ObjectGuid.Create(HighGuid.WowAccount, player.GetSession().GetAccountId()); signaturesPacket.PetitionID = (int)packet.ItemGUID.GetCounter(); // @todo verify that... do { ObjectGuid signerGUID = ObjectGuid.Create(HighGuid.Player, result.Read <ulong>(0)); ServerPetitionShowSignatures.PetitionSignature signature = new ServerPetitionShowSignatures.PetitionSignature(); signature.Signer = signerGUID; signature.Choice = 0; signaturesPacket.Signatures.Add(signature); }while (result.NextRow()); player.SendPacket(signaturesPacket); }
public void AddPet(uint species, uint display, ushort breed, BattlePetBreedQuality quality, ushort level = 1) { BattlePetSpeciesRecord battlePetSpecies = CliDB.BattlePetSpeciesStorage.LookupByKey(species); if (battlePetSpecies == null) // should never happen { return; } if (!battlePetSpecies.GetFlags().HasFlag(BattlePetSpeciesFlags.WellKnown)) // Not learnable { return; } BattlePet pet = new(); pet.PacketInfo.Guid = ObjectGuid.Create(HighGuid.BattlePet, Global.ObjectMgr.GetGenerator(HighGuid.BattlePet).Generate()); pet.PacketInfo.Species = species; pet.PacketInfo.CreatureID = battlePetSpecies.CreatureID; pet.PacketInfo.DisplayID = display; pet.PacketInfo.Level = level; pet.PacketInfo.Exp = 0; pet.PacketInfo.Flags = 0; pet.PacketInfo.Breed = breed; pet.PacketInfo.Quality = (byte)quality; pet.PacketInfo.Name = ""; pet.CalculateStats(); pet.PacketInfo.Health = pet.PacketInfo.MaxHealth; Player player = _owner.GetPlayer(); if (battlePetSpecies.GetFlags().HasFlag(BattlePetSpeciesFlags.NotAccountWide)) { pet.PacketInfo.OwnerInfo.Value = new(); pet.PacketInfo.OwnerInfo.Value.Guid = player.GetGUID(); pet.PacketInfo.OwnerInfo.Value.PlayerVirtualRealm = Global.WorldMgr.GetVirtualRealmAddress(); pet.PacketInfo.OwnerInfo.Value.PlayerNativeRealm = Global.WorldMgr.GetVirtualRealmAddress(); } pet.SaveInfo = BattlePetSaveInfo.New; _pets[pet.PacketInfo.Guid.GetCounter()] = pet; List <BattlePet> updates = new(); updates.Add(pet); SendUpdates(updates, true); player.UpdateCriteria(CriteriaType.UniquePetsOwned); player.UpdateCriteria(CriteriaType.LearnedNewPet, species); }
public override void LoadFromDB(SQLFields fields) { byte idx = 0; _id = fields.Read <uint>(idx); _playerGuid = ObjectGuid.Create(HighGuid.Player, fields.Read <ulong>(++idx)); _note = fields.Read <string>(++idx); _createTime = fields.Read <ulong>(++idx); _mapId = fields.Read <ushort>(++idx); _pos = new Vector3(fields.Read <float>(++idx), fields.Read <float>(++idx), fields.Read <float>(++idx)); _facing = fields.Read <float>(++idx); _targetCharacterGuid = ObjectGuid.Create(HighGuid.Player, fields.Read <ulong>(++idx)); _complaintType = (GMSupportComplaintType)fields.Read <byte>(++idx); int reportLineIndex = fields.Read <int>(++idx); if (reportLineIndex != -1) { _chatLog.ReportLineIndex.Set((uint)reportLineIndex); } long closedBy = fields.Read <long>(++idx); if (closedBy == 0) { _closedBy = ObjectGuid.Empty; } else if (closedBy < 0) { _closedBy.SetRawValue(0, (ulong)closedBy); } else { _closedBy = ObjectGuid.Create(HighGuid.Player, (ulong)closedBy); } ulong assignedTo = fields.Read <ulong>(++idx); if (assignedTo == 0) { _assignedTo = ObjectGuid.Empty; } else { _assignedTo = ObjectGuid.Create(HighGuid.Player, assignedTo); } _comment = fields.Read <string>(++idx); }
public bool Initialize(ObjectGuid guid, Player player = null) { CharacterInfo characterInfo = Global.WorldMgr.GetCharacterInfo(guid); if (characterInfo == null) { return(false); } if (player) { Contract.Assert(player.GetGUID() == guid); AccountID = player.GetSession().GetAccountGUID(); BnetAccountID = player.GetSession().GetBattlenetAccountGUID(); Name = player.GetName(); RaceID = player.GetRace(); Sex = (Gender)player.GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetGender); ClassID = player.GetClass(); Level = (byte)player.getLevel(); DeclinedName names = player.GetDeclinedNames(); if (names != null) { DeclinedNames = names; } } else { uint accountId = ObjectManager.GetPlayerAccountIdByGUID(guid); uint bnetAccountId = Global.BNetAccountMgr.GetIdByGameAccount(accountId); AccountID = ObjectGuid.Create(HighGuid.WowAccount, accountId); BnetAccountID = ObjectGuid.Create(HighGuid.BNetAccount, bnetAccountId); Name = characterInfo.Name; RaceID = characterInfo.RaceID; Sex = characterInfo.Sex; ClassID = characterInfo.ClassID; Level = characterInfo.Level; } IsDeleted = characterInfo.IsDeleted; GuidActual = guid; VirtualRealmAddress = Global.WorldMgr.GetVirtualRealmAddress(); return(true); }