public static void HandleCharacterList(WorldSession session, ClientCharacterList characterList)
        {
            session.EnqueueEvent(new TaskGenericEvent <List <Character> >(CharacterDatabase.GetCharacters(session.Account.Id),
                                                                          characters =>
            {
                session.Characters.Clear();
                session.Characters.AddRange(characters);

                session.EnqueueMessageEncrypted(new ServerAccountEntitlements
                {
                    Entitlements =
                    {
                        new ServerAccountEntitlements.AccountEntitlementInfo
                        {
                            Entitlement = Entitlement.BaseCharacterSlots,
                            Count       = 12
                        },
                        new ServerAccountEntitlements.AccountEntitlementInfo
                        {
                            Entitlement = Entitlement.ChuaWarriorUnlock,
                            Count       = 1
                        },
                        new ServerAccountEntitlements.AccountEntitlementInfo
                        {
                            Entitlement = Entitlement.AurinEngineerUnlock,
                            Count       = 1
                        }
                    }
                });

                session.EnqueueMessageEncrypted(new ServerMaxCharacterLevelAchieved
                {
                    Level = 50
                });

                var serverCharacterList = new ServerCharacterList
                {
                    RealmId = WorldServer.RealmId
                };
                foreach (Character character in characters)
                {
                    var listCharacter = new ServerCharacterList.Character
                    {
                        Id          = character.Id,
                        Name        = character.Name,
                        Sex         = (Sex)character.Sex,
                        Race        = (Race)character.Race,
                        Class       = (Class)character.Class,
                        Faction     = character.FactionId,
                        Level       = character.Level,
                        WorldId     = 3460,
                        WorldZoneId = 5967,
                        RealmId     = WorldServer.RealmId
                    };

                    // create a temporary inventory to show equipped gear
                    var inventory = new Inventory(null, character);
                    foreach (ItemVisual itemVisual in inventory.GetItemVisuals())
                    {
                        listCharacter.Gear.Add(itemVisual);
                    }

                    foreach (CharacterAppearance appearance in character.CharacterAppearance)
                    {
                        listCharacter.Appearance.Add(new ItemVisual
                        {
                            Slot      = (ItemSlot)appearance.Slot,
                            DisplayId = appearance.DisplayId
                        });
                    }

                    foreach (CharacterCustomisation customisation in character.CharacterCustomisation)
                    {
                        listCharacter.Labels.Add(customisation.Label);
                        listCharacter.Values.Add(customisation.Value);
                    }

                    foreach (CharacterBone bone in character.CharacterBone.OrderBy(bone => bone.BoneIndex))
                    {
                        listCharacter.Bones.Add(bone.Bone);
                    }

                    serverCharacterList.Characters.Add(listCharacter);
                }

                session.EnqueueMessageEncrypted(serverCharacterList);
            }));
        }
Beispiel #2
0
        public static void HandleCharacterList(WorldSession session, ClientCharacterList characterList)
        {
            session.EnqueueEvent(new TaskGenericEvent <List <Character> >(CharacterDatabase.GetCharacters(session.Account.Id),
                                                                          characters =>
            {
                byte MaxCharacterLevelAchieved = 1;

                session.Characters.Clear();
                session.Characters.AddRange(characters);

                session.GenericUnlockManager.SendUnlockList();
                session.EnqueueMessageEncrypted(new ServerAccountEntitlements
                {
                    Entitlements =
                    {
                        new ServerAccountEntitlements.AccountEntitlementInfo
                        {
                            Entitlement = Entitlement.BaseCharacterSlots,
                            Count       = 12
                        },
                        new ServerAccountEntitlements.AccountEntitlementInfo
                        {
                            Entitlement = Entitlement.ExtraDecorSlots,
                            Count       = 2000
                        },
                        new ServerAccountEntitlements.AccountEntitlementInfo
                        {
                            Entitlement = Entitlement.ChuaWarriorUnlock,
                            Count       = 1
                        },
                        new ServerAccountEntitlements.AccountEntitlementInfo
                        {
                            Entitlement = Entitlement.AurinEngineerUnlock,
                            Count       = 1
                        }
                    }
                });

                var serverCharacterList = new ServerCharacterList
                {
                    RealmId = WorldServer.RealmId
                };

                foreach (Character character in characters)
                {
                    var listCharacter = new ServerCharacterList.Character
                    {
                        Id          = character.Id,
                        Name        = character.Name,
                        Sex         = (Sex)character.Sex,
                        Race        = (Race)character.Race,
                        Class       = (Class)character.Class,
                        Faction     = character.FactionId,
                        Level       = character.Level,
                        WorldId     = character.WorldId,
                        WorldZoneId = character.WorldZoneId,
                        RealmId     = WorldServer.RealmId,
                        Path        = (byte)character.ActivePath
                    };

                    MaxCharacterLevelAchieved = (byte)Math.Max(MaxCharacterLevelAchieved, character.Level);

                    // create a temporary Inventory and CostumeManager to show equipped gear
                    var inventory      = new Inventory(null, character);
                    var costumeManager = new CostumeManager(null, session.Account, character);

                    CostumeEntity costume = null;
                    if (character.ActiveCostumeIndex >= 0)
                    {
                        costume = costumeManager.GetCostume((byte)character.ActiveCostumeIndex);
                    }

                    listCharacter.GearMask = costume?.Mask ?? 0xFFFFFFFF;

                    foreach (ItemVisual itemVisual in inventory.GetItemVisuals(costume))
                    {
                        listCharacter.Gear.Add(itemVisual);
                    }

                    foreach (CharacterAppearance appearance in character.CharacterAppearance)
                    {
                        listCharacter.Appearance.Add(new ItemVisual
                        {
                            Slot      = (ItemSlot)appearance.Slot,
                            DisplayId = appearance.DisplayId
                        });
                    }

                    /*foreach (CharacterCustomisation customisation in character.CharacterCustomisation)
                     * {
                     *  listCharacter.Labels.Add(customisation.Label);
                     *  listCharacter.Values.Add(customisation.Value);
                     * }*/

                    foreach (CharacterBone bone in character.CharacterBone.OrderBy(bone => bone.BoneIndex))
                    {
                        listCharacter.Bones.Add(bone.Bone);
                    }

                    foreach (CharacterStat stat in character.CharacterStat)
                    {
                        if ((Stat)stat.Stat == Stat.Level)
                        {
                            listCharacter.Level = (uint)stat.Value;
                            break;
                        }
                    }

                    serverCharacterList.Characters.Add(listCharacter);
                }

                session.EnqueueMessageEncrypted(new ServerMaxCharacterLevelAchieved
                {
                    Level = MaxCharacterLevelAchieved
                });

                session.EnqueueMessageEncrypted(serverCharacterList);
            }));
        }
Beispiel #3
0
        public static void HandleCharacterList(WorldSession session, ClientCharacterList characterList)
        {
            session.EnqueueEvent(new TaskGenericEvent <List <CharacterModel> >(DatabaseManager.Instance.CharacterDatabase.GetCharacters(session.Account.Id),
                                                                               characters =>
            {
                byte maxCharacterLevelAchieved = 1;

                session.Characters.Clear();
                session.Characters.AddRange(characters);

                session.AccountCurrencyManager.SendCharacterListPacket();
                session.GenericUnlockManager.SendUnlockList();

                session.EnqueueMessageEncrypted(new ServerAccountEntitlements
                {
                    Entitlements = session.EntitlementManager.GetAccountEntitlements()
                                   .Select(e => new ServerAccountEntitlements.AccountEntitlementInfo
                    {
                        Entitlement = e.Type,
                        Count       = e.Amount
                    })
                                   .ToList()
                });
                session.EnqueueMessageEncrypted(new ServerAccountTier
                {
                    Tier = session.AccountTier
                });

                // 2 is just a fail safe for the minimum amount of character slots
                // this is set in the tbl files so a value should always exist
                uint characterSlots = (uint)(session.EntitlementManager.GetRewardProperty(RewardPropertyType.CharacterSlots).GetValue(0u) ?? 2u);
                uint characterCount = (uint)characters.Count(c => c.DeleteTime == null);

                var serverCharacterList = new ServerCharacterList
                {
                    RealmId = WorldServer.RealmId,
                    // no longer used as replaced by entitlements but retail server still used to send this
                    AdditionalCount = characterCount,
                    AdditionalAllowedCharCreations = (uint)Math.Max(0, (int)(characterSlots - characterCount))
                };

                foreach (CharacterModel character in characters.Where(c => c.DeleteTime == null))
                {
                    var listCharacter = new ServerCharacterList.Character
                    {
                        Id                = character.Id,
                        Name              = character.Name,
                        Sex               = (Sex)character.Sex,
                        Race              = (Race)character.Race,
                        Class             = (Class)character.Class,
                        Faction           = character.FactionId,
                        Level             = character.Level,
                        WorldId           = character.WorldId,
                        WorldZoneId       = character.WorldZoneId,
                        RealmId           = WorldServer.RealmId,
                        Path              = (byte)character.ActivePath,
                        LastLoggedOutDays = (float)DateTime.UtcNow.Subtract(character.LastOnline ?? DateTime.UtcNow).TotalDays * -1f
                    };

                    maxCharacterLevelAchieved = Math.Max(maxCharacterLevelAchieved, character.Level);

                    try
                    {
                        // create a temporary Inventory and CostumeManager to show equipped gear
                        var inventory      = new Inventory(null, character);
                        var costumeManager = new CostumeManager(null, session.Account, character);

                        CostumeEntity costume = null;
                        if (character.ActiveCostumeIndex >= 0)
                        {
                            costume = costumeManager.GetCostume((byte)character.ActiveCostumeIndex);
                        }

                        listCharacter.GearMask = costume?.Mask ?? 0xFFFFFFFF;

                        foreach (ItemVisual itemVisual in inventory.GetItemVisuals(costume))
                        {
                            listCharacter.Gear.Add(itemVisual);
                        }

                        foreach (CharacterAppearanceModel appearance in character.Appearance)
                        {
                            listCharacter.Appearance.Add(new ItemVisual
                            {
                                Slot      = (ItemSlot)appearance.Slot,
                                DisplayId = appearance.DisplayId
                            });
                        }

                        /*foreach (CharacterCustomisation customisation in character.CharacterCustomisation)
                         * {
                         *  listCharacter.Labels.Add(customisation.Label);
                         *  listCharacter.Values.Add(customisation.Value);
                         * }*/

                        foreach (CharacterBoneModel bone in character.Bone.OrderBy(bone => bone.BoneIndex))
                        {
                            listCharacter.Bones.Add(bone.Bone);
                        }

                        foreach (CharacterStatModel stat in character.Stat)
                        {
                            if ((Stat)stat.Stat == Stat.Level)
                            {
                                listCharacter.Level = (uint)stat.Value;
                                break;
                            }
                        }

                        serverCharacterList.Characters.Add(listCharacter);
                    }
                    catch (Exception ex)
                    {
                        log.Fatal(ex, $"An error has occured while loading character '{character.Name}'");
                        continue;
                    }
                }

                session.EnqueueMessageEncrypted(new ServerMaxCharacterLevelAchieved
                {
                    Level = maxCharacterLevelAchieved
                });

                session.EnqueueMessageEncrypted(serverCharacterList);
            }));
        }
Beispiel #4
0
        public static void HandleCharacterList(WorldSession session, ClientCharacterList characterList)
        {
            session.EnqueueEvent(new TaskGenericEvent <List <CharacterModel> >(DatabaseManager.Instance.CharacterDatabase.GetCharacters(session.Account.Id),
                                                                               characters =>
            {
                byte maxCharacterLevelAchieved = 1;

                session.Characters.Clear();
                session.Characters.AddRange(characters);

                session.AccountCurrencyManager.SendCharacterListPacket();
                session.GenericUnlockManager.SendUnlockList();

                session.EnqueueMessageEncrypted(new ServerAccountEntitlements
                {
                    Entitlements = session.EntitlementManager.GetAccountEntitlements()
                                   .Select(e => new ServerAccountEntitlements.AccountEntitlementInfo
                    {
                        Entitlement = e.Type,
                        Count       = e.Amount
                    })
                                   .ToList()
                });

                var serverCharacterList = new ServerCharacterList
                {
                    RealmId = WorldServer.RealmId
                };

                foreach (CharacterModel character in characters)
                {
                    if (character.DeleteTime != null)
                    {
                        continue;
                    }

                    var listCharacter = new ServerCharacterList.Character
                    {
                        Id          = character.Id,
                        Name        = character.Name,
                        Sex         = (Sex)character.Sex,
                        Race        = (Race)character.Race,
                        Class       = (Class)character.Class,
                        Faction     = character.FactionId,
                        Level       = character.Level,
                        WorldId     = character.WorldId,
                        WorldZoneId = character.WorldZoneId,
                        RealmId     = WorldServer.RealmId,
                        Path        = (byte)character.ActivePath
                    };

                    maxCharacterLevelAchieved = (byte)Math.Max(maxCharacterLevelAchieved, character.Level);

                    // create a temporary Inventory and CostumeManager to show equipped gear
                    var inventory      = new Inventory(null, character);
                    var costumeManager = new CostumeManager(null, session.Account, character);

                    CostumeEntity costume = null;
                    if (character.ActiveCostumeIndex >= 0)
                    {
                        costume = costumeManager.GetCostume((byte)character.ActiveCostumeIndex);
                    }

                    listCharacter.GearMask = costume?.Mask ?? 0xFFFFFFFF;

                    foreach (ItemVisual itemVisual in inventory.GetItemVisuals(costume))
                    {
                        listCharacter.Gear.Add(itemVisual);
                    }

                    foreach (CharacterAppearanceModel appearance in character.Appearance)
                    {
                        listCharacter.Appearance.Add(new ItemVisual
                        {
                            Slot      = (ItemSlot)appearance.Slot,
                            DisplayId = appearance.DisplayId
                        });
                    }

                    /*foreach (CharacterCustomisation customisation in character.CharacterCustomisation)
                     * {
                     *  listCharacter.Labels.Add(customisation.Label);
                     *  listCharacter.Values.Add(customisation.Value);
                     * }*/

                    foreach (CharacterBoneModel bone in character.Bone.OrderBy(bone => bone.BoneIndex))
                    {
                        listCharacter.Bones.Add(bone.Bone);
                    }

                    foreach (CharacterStatModel stat in character.Stat)
                    {
                        if ((Stat)stat.Stat == Stat.Level)
                        {
                            listCharacter.Level = (uint)stat.Value;
                            break;
                        }
                    }

                    serverCharacterList.Characters.Add(listCharacter);
                }

                session.EnqueueMessageEncrypted(new ServerMaxCharacterLevelAchieved
                {
                    Level = maxCharacterLevelAchieved
                });

                session.EnqueueMessageEncrypted(serverCharacterList);
            }));
        }