private void DecorMove(Player player, ClientHousingDecorUpdate.DecorUpdate update) { Decor decor = residence.GetDecor(update.DecorId); if (decor == null) { throw new InvalidPacketValueException(); } HousingResult GetResult() { if (!IsValidPlotForPosition(update)) { return(HousingResult.Decor_InvalidPosition); } return(HousingResult.Success); } HousingResult result = GetResult(); if (result == HousingResult.Success) { if (update.PlotIndex != decor.PlotIndex) { decor.PlotIndex = update.PlotIndex; } if (update.ColourShiftId != decor.ColourShiftId) { if (update.ColourShiftId != 0u) { ColorShiftEntry colourEntry = GameTableManager.Instance.ColorShift.GetEntry(update.ColourShiftId); if (colourEntry == null) { throw new InvalidPacketValueException(); } } decor.ColourShiftId = update.ColourShiftId; } if (decor.Type == DecorType.Crate) { if (decor.Entry.Creature2IdActiveProp != 0u) { // TODO: used for decor that have an associated entity } // crate->world decor.Move(update.DecorType, update.Position, update.Rotation, update.Scale); } else { if (update.DecorType == DecorType.Crate) { decor.Crate(); } else { // world->world decor.Move(update.DecorType, update.Position, update.Rotation, update.Scale); decor.DecorParentId = update.ParentDecorId; } } } else { player.Session.EnqueueMessageEncrypted(new ServerHousingResult { RealmId = WorldServer.RealmId, ResidenceId = residence.Id, PlayerName = player.Name, Result = result }); } EnqueueToAll(new ServerHousingResidenceDecor { Operation = 0, DecorData = new List <ServerHousingResidenceDecor.Decor> { new ServerHousingResidenceDecor.Decor { RealmId = WorldServer.RealmId, DecorId = decor.DecorId, ResidenceId = residence.Id, DecorType = decor.Type, PlotIndex = decor.PlotIndex, Scale = decor.Scale, Position = decor.Position, Rotation = decor.Rotation, DecorInfoId = decor.Entry.Id, ParentDecorId = decor.DecorParentId, ColourShift = decor.ColourShiftId } } }); }
public static void HandleHousingCommunityRename(WorldSession session, ClientHousingCommunityRename housingCommunityRename) { if (session.Player.Map is not ResidenceMapInstance) { throw new InvalidPacketValueException(); } // ignore the value in the packet Community community = session.Player.GuildManager.GetGuild <Community>(GuildType.Community); if (community == null) { throw new InvalidPacketValueException(); } HousingResult GetResult() { // client checks if the player has a rank of 0, this is the same if (community.LeaderId != session.Player.CharacterId) { return(HousingResult.InvalidPermissions); } if (!TextFilterManager.Instance.IsTextValid(housingCommunityRename.Name) || !TextFilterManager.Instance.IsTextValid(housingCommunityRename.Name, UserText.HousingResidenceName)) { return(HousingResult.InvalidResidenceName); } GameFormulaEntry entry = GameTableManager.Instance.GameFormula.GetEntry(2395); if (entry == null) { return(HousingResult.Failed); } bool canAfford; if (housingCommunityRename.AlternativeCurrency) { canAfford = session.Player.CurrencyManager.CanAfford(CurrencyType.Renown, entry.Dataint01); } else { canAfford = session.Player.CurrencyManager.CanAfford(CurrencyType.Credits, entry.Dataint0); } if (!canAfford) { return(HousingResult.InsufficientFunds); } return(HousingResult.Success); } HousingResult result = GetResult(); if (result == HousingResult.Success) { // fun fact: 2395 is the final game formula entry GameFormulaEntry entry = GameTableManager.Instance.GameFormula.GetEntry(2395); if (housingCommunityRename.AlternativeCurrency) { session.Player.CurrencyManager.CurrencySubtractAmount(CurrencyType.Renown, entry.Dataint01); } else { session.Player.CurrencyManager.CurrencySubtractAmount(CurrencyType.Credits, entry.Dataint0); } community.RenameGuild(housingCommunityRename.Name); community.Residence.Map?.RenameResidence(community.Residence, housingCommunityRename.Name); } session.EnqueueMessageEncrypted(new ServerHousingCommunityRename { Result = HousingResult.Success, TargetGuild = new TargetGuild { RealmId = WorldServer.RealmId, GuildId = community.Id } }); }