/// <summary>
    /// Assumes that the characters array is the same length as the selectButtons arrays.
    /// </summary>
    public void UpdateLabels()
    {
        ClearLabels();

        CharacterRecord[] records = PlayerData.Instance.characterList.TakeSet(currSetIndex, 4);

        int counter = 0;

        for (int i = 0; i < records.Length; i++)
        {
            if (counter < characterButtons.Length)
            {
                CharacterRecord record        = records[i];
                CharacterData   characterData = CharacterBuilder.Instance.GetCharacterData(record.id);
                Button          button        = characterButtons[counter];
                button.GetComponent <CanvasGroup>().alpha = 1;
                button.interactable = true;
                button.image.sprite = characterData.sprite;
                Text buttonName = button.GetComponentInChildren <Text>();
                buttonName.text = characterData.name;

                button.onClick.RemoveAllListeners();
                if (characterCard != null)
                {
                    button.onClick.AddListener(() => characterCard.UpdateCard(record.id));
                }

                button.onClick.AddListener(() => _characterCallback(record.id));
            }

            counter++;
        }
    }
Example #2
0
        public GuildMemberRecord Map(GuildMemberRecord record, CharacterRecord character)
        {
            GuildMemberRecord result;

            if (record == null)
            {
                result = this.m_current;
            }
            else
            {
                if (this.m_current != null && this.m_current.CharacterId == record.CharacterId)
                {
                    this.m_current.Character = character;
                    result = null;
                }
                else
                {
                    GuildMemberRecord current = this.m_current;
                    this.m_current           = record;
                    this.m_current.Character = character;
                    result = current;
                }
            }
            return(result);
        }
Example #3
0
        /// <summary>Handles an incoming name query.</summary>
        /// <param name="client">the Session the incoming packet belongs to</param>
        /// <param name="packet">the full packet</param>
        public static void NameQueryRequest(IRealmClient client, RealmPacketIn packet)
        {
            EntityId      id     = packet.ReadEntityId();
            ILivingEntity entity = (ILivingEntity)client.ActiveCharacter;

            if ((int)entity.EntityId.Low != (int)id.Low)
            {
                entity = World.GetNamedEntity(id.Low) as ILivingEntity;
            }
            if (entity != null)
            {
                QueryHandler.SendNameQueryReply((IPacketReceiver)client, entity);
            }
            else
            {
                ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((IMessage) new Message((Action)(() =>
                {
                    CharacterRecord characterRecord = CharacterRecord.LoadRecordByEntityId(id.Low);
                    if (characterRecord == null)
                    {
                        QueryHandler.s_log.Warn("{0} queried name of non-existing Character: " + (object)id,
                                                (object)client);
                    }
                    else
                    {
                        QueryHandler.SendNameQueryReply((IPacketReceiver)client, (ILivingEntity)characterRecord);
                    }
                })));
            }
        }
Example #4
0
 public void Initialize(CharacterRecord record)
 {
     Fields = new Dictionary <DefineEnum, StatsData>
     {
         { DefineEnum.HP, new StatsData(Owner, DefineEnum.HP, record.HP) },
         { DefineEnum.MP, new StatsData(Owner, DefineEnum.MP, 200) },
         { DefineEnum.GP, new StatsData(Owner, DefineEnum.GP, 2) },
         { DefineEnum.LV, new StatsData(Owner, DefineEnum.LV, record.Level) },
         { DefineEnum.VIT, new StatsData(Owner, DefineEnum.VIT, 290) },
         { DefineEnum.FLV, new StatsData(Owner, DefineEnum.FLV, 1) },
         { DefineEnum.FHP, new StatsData(Owner, DefineEnum.FHP, 450) },
         { DefineEnum.FMP, new StatsData(Owner, DefineEnum.FMP, 290) },
         { DefineEnum.MOVE_SPEED, new StatsData(Owner, DefineEnum.MOVE_SPEED, 6000) },
         { DefineEnum.STR, new StatsData(Owner, DefineEnum.STR, record.Strenght) },
         { DefineEnum.STA, new StatsData(Owner, DefineEnum.STA, record.Stamina) },
         { DefineEnum.INT, new StatsData(Owner, DefineEnum.INT, record.Intelligence) },
         { DefineEnum.DEX, new StatsData(Owner, DefineEnum.DEX, record.Dexterity) },
         { DefineEnum.SPI, new StatsData(Owner, DefineEnum.SPI, record.SPI) },
         { DefineEnum.MONEY, new StatsData(Owner, DefineEnum.MONEY, (int)record.Money) },
         { DefineEnum.GOLD, new StatsData(Owner, DefineEnum.GOLD, (int)0) },
         { DefineEnum.EP, new StatsData(Owner, DefineEnum.EP, (int)record.Experience << 31 >> 31) },
         { DefineEnum.EP2, new StatsData(Owner, DefineEnum.EP, 1500000 << 31 >> 31) },
         { DefineEnum.MAXHP, new StatsData(Owner, DefineEnum.MAXHP, record.HP) },
         { DefineEnum.MAXMP, new StatsData(Owner, DefineEnum.MAXHP, 200) },
         { DefineEnum.ATK_BASE, new StatsData(Owner, DefineEnum.ATK_BASE, 10) }
     };
 }
Example #5
0
        public static Character FromCharacterRecord(CharacterRecord record, GameDatabase gameDatabase)
        {
            var character = new Character
            {
                Id            = record.Id,
                MaxHp         = record.MaxHp,
                MaxMp         = record.MaxMp,
                CurrentHp     = record.CurrentHp,
                CurrentMp     = record.CurrentMp,
                Name          = record.Name,
                Level         = record.Level,
                Weapon        = gameDatabase.WeaponDatabase.FirstOrDefault(w => w.Id == record.Weapon),
                Armlet        = gameDatabase.ArmletDatabase.FirstOrDefault(a => a.Id == record.Armor),
                Accessory     = gameDatabase.AccessoryDatabase.FirstOrDefault(a => a.Id == record.Accessory),
                WeaponMateria = new Materia[8],
                ArmletMateria = new Materia[8],
                Face          = record.DefaultName.SanitizedDefaultName,
                BackRow       = !record.AtFront,
            };

            for (var m = 0; m < record.WeaponMateria.Length; ++m)
            {
                character.WeaponMateria[m] = gameDatabase.MateriaDatabase.FirstOrDefault(x => x.Id == record.WeaponMateria[m].Id);
            }
            for (var m = 0; m < record.ArmorMateria.Length; ++m)
            {
                character.ArmletMateria[m] = gameDatabase.MateriaDatabase.FirstOrDefault(x => x.Id == record.ArmorMateria[m].Id);
            }

            return(character);
        }
Example #6
0
 public static void HandleCharacterCreationRequestMessage(Client client, CharacterCreationRequestMessage message)
 {
     if (client.Account.Characters.Count >= 5)
     {
         client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.ERR_TOO_MANY_CHARACTERS));
     }
     else
     {
         if (CharacterRecord.NameExist(message.name)) //need to add check for non allowed char
         {
             client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.ERR_NAME_ALREADY_EXISTS));
         }
         else
         {
             Breed           breed     = Breed.Breeds[(BreedEnum)message.breed];
             string          look      = message.sex == false ? breed.MaleLook : breed.FemaleLook;
             CharacterRecord character = new CharacterRecord(client.Account.Id, message.name, 1, 0, (BreedEnum)message.breed, message.colors.Distinct().Count() != 1 ? look.Insert(look.IndexOf("||") + 1, $"1={message.colors[0]},2={message.colors[1]},3={message.colors[2]},4={message.colors[3]},5={message.colors[4]}") : look, message.sex, Config.StartMap != 0 ? Config.StartMap : breed.StartMapId, Config.StartCellId != 0 ? Config.StartCellId : breed.StartDisposition.cellId, Config.StartDirection != 0 ? (DirectionsEnum)Config.StartDirection : (DirectionsEnum)breed.StartDisposition.direction, AlignmentSideEnum.ALIGNMENT_NEUTRAL, 0, 0, false, 0, 0, 0, DateTime.Now);
             character.Create();
             client.Account.Characters = CharacterRecord.ReturnCharacters(client.Account.Id);
             new List <CharacterSpellRecord>(new CharacterSpellRecord[] { new CharacterSpellRecord(client.Account.Characters.FirstOrDefault(chara => chara.Name == character.Name).Id, 64, 0, 1), new CharacterSpellRecord(client.Account.Characters.FirstOrDefault(chara => chara.Name == character.Name).Id, 65, breed.BreedSpellsId[0], 1), new CharacterSpellRecord(client.Account.Characters.FirstOrDefault(chara => chara.Name == character.Name).Id, 66, breed.BreedSpellsId[1], 1), new CharacterSpellRecord(client.Account.Characters.FirstOrDefault(chara => chara.Name == character.Name).Id, 67, breed.BreedSpellsId[2], 1) }).ForEach(spell => spell.Create());
             client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.OK));
             SendCharactersListMessage(client, false);
         }
     }
 }
Example #7
0
    public void ForceUpdate()
    {
        var ht = Johny.HashtablePool.Claim();

        CharacterRecord.GetRecordHashtable(this, ht);
        _api.Update(_characterRecord.Id, ht, null, true);
    }
Example #8
0
 public void GiveGiftTo(CharacterRecord character)
 {
     foreach (var item in Items)
     {
         item.GiveTo(character);
     }
 }
Example #9
0
        public static void SelectCharacter(Client client, int id)
        {
            CharacterRecord characterRecord = client.Account.Characters.FirstOrDefault(character => character.Id == id);

            if (characterRecord != null)
            {
                CharacterEngine character = new CharacterEngine(characterRecord, client);
                client.Character = character;
                client.Send(new CharacterSelectedSuccessMessage(character.GetCharacterBaseInformations));
                ContextRoleplayHandler.SendEmoteListMessage(client, new sbyte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19, 21, 22, 23, 24 });
                ChatHandler.SendEnabledChannelsMessage(client, new sbyte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 });
                InventoryHandler.SendInventoryContentMessage(client, new ObjectItem[0], character.Kamas); //TODO Get the characters items
                InventoryHandler.SendInventoryWeightMessage(client, 0, character.MaxPods);
                InventoryHandler.SendSpellListMessage(client);
                PvPHandler.SendAlignmentRankUpdateMessage(client, 1);
                PvPHandler.SendAlignmentSubAreasListMessage(client);
                SendSetCharacterRestrictionsMessage(client);
                SendLifePointsRegenBeginMessage(client, 10);
                SendCharacterStatsListMessage(client);
                client.Character.SendLoginMessage();

                /*if (tutorial == true)
                 * {
                 *  character.CurrentMapId = 35651584; //mapid of the tutorial map
                 *  character.CellId = 324;
                 *  client.Send(new QuestStartedMessage(489)); //start the tutorial quest
                 * }*/
            }
            else
            {
                client.Send(new CharacterSelectedErrorMessage());
            }
        }
    /// <summary>
    /// Assumes that the characters array is the same length as the selectButtons arrays.
    /// </summary>
    public void UpdatePlayerItemCards(CharacterRecord[] characterRecordSet)
    {
        ClearPlayerItemCards();

        int counter = 0;

        for (int i = 0; i < characterRecordSet.Length; i++)
        {
            if (counter < merchantItemCards.Length)
            {
                CharacterRecord  record        = characterRecordSet[i];
                CharacterData    characterData = CharacterBuilder.Instance.GetCharacterData(record.id);
                UIPlayerItemCard card          = playerItemCards[counter];

                CanvasGroup cardGroup = card.GetComponent <CanvasGroup>();
                cardGroup.alpha        = 1;
                cardGroup.interactable = true;

                card.focusCallback = _focusCallback;
                card.sellCallback  = _sellCallback;
                card.UpdateCard(characterData, record.count);
            }

            counter++;
        }
    }
        void DisplaySaveCharacterGUI()
        {
            // Get character record
            List <SaveTreeBaseRecord> records = currentSaveTree.FindRecords(RecordTypes.Character);

            if (records.Count != 1)
            {
                return;
            }

            CharacterRecord characterRecord = (CharacterRecord)records[0];

            //CharacterSheet characterSheet = characterRecord.ToCharacterSheet();

            EditorGUILayout.Space();
            GUILayoutHelper.Horizontal(() =>
            {
                EditorGUILayout.LabelField(new GUIContent("Name"), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                EditorGUILayout.SelectableLabel(characterRecord.ParsedData.characterName, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            });
            GUILayoutHelper.Horizontal(() =>
            {
                EditorGUILayout.LabelField(new GUIContent("Gender"), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                EditorGUILayout.SelectableLabel(((int)characterRecord.ParsedData.gender).ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            });
        }
Example #12
0
        /// <summary>
        /// Adds a new guild member
        /// Calls GuildMgr.OnJoinGuild
        /// </summary>
        /// <param name="chr">character to add</param>
        /// <param name="update">if true, sends event to the guild</param>
        /// <returns>GuildMember of new member</returns>
        public GuildMember AddMember(CharacterRecord chr)
        {
            GuildMember newMember;

            /*using (syncRoot.Enter())
             * {*/
            lock (this)
            {
                if (Members.TryGetValue(chr.EntityLowId, out newMember))
                {
                    return(newMember);
                }
                newMember = new GuildMember(chr, this, m_ranks.Last());
                Members.Add(newMember.Id, newMember);
                newMember.Create();
            }
            /*}*/

            GuildMgr.Instance.RegisterGuildMember(newMember);

            EventLog.AddJoinEvent(newMember.Id);
            GuildHandler.SendEventToGuild(this, GuildEvents.JOINED, newMember);
            var character = World.GetCharacterByAccId((uint)chr.AccountId);

            foreach (var activeSkill in ActiveSkills)
            {
                activeSkill.ApplyToCharacter(character);
            }
            character.GuildMember = newMember;
            Asda2GuildHandler.SendGuildNotificationResponse(this, GuildNotificationType.Joined, newMember);
            Asda2GuildHandler.SendGuildMembersInfoResponse(character.Client, this);
            AddHistoryMessage(Asda2GuildHistoryType.Joined, 0, chr.Name, DateTime.Now.ToLongTimeString());
            return(newMember);
        }
Example #13
0
        /// <summary>
        /// Creates a new GuildRecord row in the database with the given information.
        /// </summary>
        /// <param name="leader">leader's character record</param>
        /// <param name="name">the name of the new character</param>
        /// <returns>the <seealso cref="Guild"/> object</returns>
        public Guild(CharacterRecord leader, string name)
            : this(true)
        {
            _created     = DateTime.Now;
            _id          = _idGenerator.Next();
            _leaderLowId = (int)leader.EntityLowId;
            _name        = name;
            _tabard      = new GuildTabard();
            _MOTD        = "Default MOTD";
            _info        = "Default info";
            _level       = 1;
            m_ranks      = GuildMgr.CreateDefaultRanks(this);
            foreach (var guildRank in m_ranks)
            {
                guildRank.CreateLater();
            }
            //m_leader = new GuildMember(leader, this, HighestRank);

            Register();

            m_leader = AddMember(leader);
            var chr = World.GetCharacter(leader.Name, true);
            Leader.Character = chr;

            //Set the leader as guild master rank
            m_leader.RankId = 0;
            _clanCrest      = new byte[40];
            this.CreateLater();                                         // save to DB, asynchronously
        }
Example #14
0
        public override bool Validate(CharacterRecord charInfo, CharacterRecord relatedCharInfo, out RelationResult relResult)
        {
            //Check if the character exists. This should always be true in theory
            if (charInfo == null)
            {
                relResult = RelationResult.FRIEND_DB_ERROR;
                return false;
            }

            //Checks if the relation target char exist 
            if (relatedCharInfo == null)
            {
                relResult = RelationResult.IGNORE_NOT_FOUND;
                return false;
            }

            //Checks if the target char is the same as the related one
            if (charInfo.EntityLowId == relatedCharInfo.EntityLowId)
            {
                relResult = RelationResult.IGNORE_SELF;
                return false;
            }

            //Checks if the relation currently exist
            if (RelationMgr.Instance.HasRelation(charInfo.EntityLowId, relatedCharInfo.EntityLowId, this.Type))
            {
                relResult = RelationResult.IGNORE_ALREADY;
                return false;
            }

            relResult = RelationResult.IGNORE_ADDED;
            return true;
        }
Example #15
0
        /// <summary>
        /// Handles an incoming name query.
        /// </summary>
        /// <param name="client">the Session the incoming packet belongs to</param>
        /// <param name="packet">the full packet</param>
        //[ClientPacketHandler((RealmServerOpCode.CMSG_NAME_QUERY)]
        public static void NameQueryRequest(IRealmClient client, RealmPacketIn packet)
        {
            var id = packet.ReadEntityId();

            ILivingEntity entity = client.ActiveCharacter;

            if (entity.EntityId.Low != id.Low)
            {
                entity = World.GetNamedEntity(id.Low) as ILivingEntity;
            }

            if (entity != null)
            {
                SendNameQueryReply(client, entity);
            }
            else
            {
                RealmServer.IOQueue.AddMessage(new Message(() =>
                {
                    var record = CharacterRecord.LoadRecordByEntityId(id.Low);
                    if (record == null)
                    {
                        s_log.Warn("{0} queried name of non-existing Character: " + id, client);
                    }
                    else
                    {
                        SendNameQueryReply(client, record);
                    }
                }));
            }
        }
Example #16
0
        /// <summary>
        /// Adds a new guild member
        /// Calls GuildMgr.OnJoinGuild
        /// </summary>
        /// <param name="chr">character to add</param>
        /// <param name="update">if true, sends event to the guild</param>
        /// <returns>GuildMember of new member</returns>
        public GuildMember AddMember(CharacterRecord chr)
        {
            GuildMember guildMember;

            lock (this)
            {
                if (this.Members.TryGetValue(chr.EntityLowId, out guildMember))
                {
                    return(guildMember);
                }
                guildMember = new GuildMember(chr, this, this.m_ranks.Last <GuildRank>());
                this.Members.Add(guildMember.Id, guildMember);
                guildMember.Create();
            }

            Singleton <GuildMgr> .Instance.RegisterGuildMember(guildMember);

            this.EventLog.AddJoinEvent(guildMember.Id);
            GuildHandler.SendEventToGuild(this, GuildEvents.JOINED, guildMember);
            Character characterByAccId = World.GetCharacterByAccId((uint)chr.AccountId);

            foreach (GuildSkill activeSkill in this.ActiveSkills)
            {
                activeSkill.ApplyToCharacter(characterByAccId);
            }
            characterByAccId.GuildMember = guildMember;
            Asda2GuildHandler.SendGuildNotificationResponse(this, GuildNotificationType.Joined, guildMember);
            Asda2GuildHandler.SendGuildMembersInfoResponse(characterByAccId.Client, this);
            this.AddHistoryMessage(Asda2GuildHistoryType.Joined, 0, chr.Name, DateTime.Now.ToLongTimeString());
            return(guildMember);
        }
Example #17
0
        private static void Login(AuthClient client, bool autoconnect)
        {
            ServersManager.DisconnectAlreadyConnectedClient(client, client.Account.Id);
            AuthServer.Instance.AuthClients.Add(client);
            bool hasRights = false;

            if (client.Account.Role > ServerRoleEnum.PLAYER)
            {
                hasRights = true;
            }
            client.Send(new IdentificationSuccessMessage(hasRights, false, client.Account.Username, client.Account.Nickname, client.Account.Id, 0, "Supprimer ce personnage?", 2, 1, 0));
            var characters = CharacterRecord.GetAccountCharacters(client.Account.Id);

            if (!autoconnect)
            {
                SendServerListMessage(client, characters.Count);
                return;
            }
            else
            {
                if (WorldServer.Instance.ServerState == ServerStatusEnum.ONLINE)
                {
                    SelectedServer(null, client);
                }
                else
                {
                    SendServerListMessage(client, characters.Count);
                }
            }
        }
Example #18
0
 /// <summary>
 /// Reloads all characters belonging to this account from the database.
 /// Blocking call. Make sure to call this from outside the Map-Thread.
 /// </summary>
 private void LoadCharacters()
 {
     foreach (CharacterRecord characterRecord in CharacterRecord.FindAllOfAccount(this))
     {
         this.Characters.Add(characterRecord);
     }
 }
Example #19
0
        public static SubEntity[] GetSubEntity(CharacterRecord character)
        {
            try
            {
                var returnSubEntity = new List <SubEntity>();

                if (character.Direction == (DirectionsEnum)2 && character.Level >= 100 && character.Level != 200)
                {
                    var sub = new SubEntity()
                    {
                        bindingPointCategory = 6,
                        bindingPointIndex    = 0,
                        subEntityLook        = new EntityLook(169, new short[0], new int[0], new short[0], new SubEntity[0])
                    };
                    returnSubEntity.Add(sub);
                }
                else if (character.Direction == (DirectionsEnum)2 && character.Level == 200)
                {
                    var sub = new SubEntity()
                    {
                        bindingPointCategory = 6,
                        bindingPointIndex    = 0,
                        subEntityLook        = new EntityLook(170, new short[0], new int[0], new short[0], new SubEntity[0])
                    };
                    returnSubEntity.Add(sub);
                }

                return(returnSubEntity.ToArray());
            }
            catch (Exception ex)
            {
                ConsoleUtils.Write(ConsoleUtils.Type.ERROR, ex.Message);
                return(new SubEntity[0]);
            }
        }
Example #20
0
        public override bool Validate(CharacterRecord charInfo, CharacterRecord relatedCharInfo, out RelationResult relResult)
        {
            //Check if the character exists. This should always be true in theory
            if (charInfo == null)
            {
                relResult = RelationResult.FRIEND_DB_ERROR;
                return(false);
            }

            //Checks if the relation target char exist
            if (relatedCharInfo == null)
            {
                relResult = RelationResult.IGNORE_NOT_FOUND;
                return(false);
            }

            //Checks if the target char is the same as the related one
            if (charInfo.EntityLowId == relatedCharInfo.EntityLowId)
            {
                relResult = RelationResult.IGNORE_SELF;
                return(false);
            }

            //Checks if the relation currently exist
            if (RelationMgr.Instance.HasRelation(charInfo.EntityLowId, relatedCharInfo.EntityLowId, this.Type))
            {
                relResult = RelationResult.IGNORE_ALREADY;
                return(false);
            }

            relResult = RelationResult.IGNORE_ADDED;
            return(true);
        }
Example #21
0
        public override bool Validate(CharacterRecord charInfo, CharacterRecord relatedCharInfo,
                                      out RelationResult relResult)
        {
            if (charInfo == null)
            {
                relResult = RelationResult.FRIEND_DB_ERROR;
                return(false);
            }

            if (relatedCharInfo == null)
            {
                relResult = RelationResult.IGNORE_NOT_FOUND;
                return(false);
            }

            if ((int)charInfo.EntityLowId == (int)relatedCharInfo.EntityLowId)
            {
                relResult = RelationResult.IGNORE_SELF;
                return(false);
            }

            if (Singleton <RelationMgr> .Instance.HasRelation(charInfo.EntityLowId, relatedCharInfo.EntityLowId,
                                                              this.Type))
            {
                relResult = RelationResult.IGNORE_ALREADY;
                return(false);
            }

            relResult = RelationResult.IGNORE_ADDED;
            return(true);
        }
        public virtual void Move(List <short> keys, short cellid, sbyte direction)
        {
            if (Fight.Ended)
            {
                return;
            }

            List <short> path = Pathfinding.FightMove(PathParser.ReturnDispatchedCells(keys)).Keys.ToList();

            path.Insert(0, CellId);
            path = CheckMarks(path);
            ApplyFighterEvent(FighterEventType.BEFORE_MOVE, path);
            this.Fight.TryStartSequence(ContextualId, 5);
            this.Fight.Send(new GameMapMovementMessage(path, ContextualId));
            this.AddToLastPosition(path);
            short mpcost = (short)PathHelper.GetDistanceBetween(CellId, path.Last());

            FighterStats.Stats.MovementPoints -= mpcost;
            this.CellId    = path.Last();
            this.Direction = direction;
            RefreshStats();
            GameActionFightPointsVariation(ActionsEnum.ACTION_CHARACTER_MOVEMENT_POINTS_USE, (short)-mpcost);
            this.Fight.TryEndSequence(5, 5);
            ApplyFighterEvent(FighterEventType.AFTER_MOVE, mpcost, path);
            if (CharacterRecord.GetCharacterRecordById(this.ContextualId) != null && CharacterRecord.GetCharacterRecordById(this.ContextualId).GodMod)
            {
                FighterStats.Stats.MovementPoints += mpcost;
                GameActionFightPointsVariation(ActionsEnum.ACTION_CHARACTER_MOVEMENT_POINTS_WIN, (short)mpcost);
            }
        }
Example #23
0
 public static void HandleAuthenticationTicketMessage(GameClient client, AuthenticationTicketMessage message)
 {
     if (message.ticket != string.Empty)
     {
         AccountRecord account = AccountRecord.ReturnAccountWithTicket(message.ticket);
         if (account != null)
         {
             client.Account = account;
             if (GameServer.Clients.Count(x => x.Account.Login == account.Login) > 1)
             {
                 GameServer.Clients.First(x => x.Account.Login == account.Login).Disconnect();
             }
             client.Account.Characters = CharacterRecord.ReturnCharacters(account.Id);
             client.Send(new AuthenticationTicketAcceptedMessage());
             BasicHandler.SendBasicTimeMessage(client);
         }
         else
         {
             client.Send(new AuthenticationTicketRefusedMessage());
         }
     }
     else
     {
         client.Send(new AuthenticationTicketRefusedMessage());
     }
 }
Example #24
0
 public static void HandleCharacterCreationRequestMessage(GameClient client, CharacterCreationRequestMessage message)
 {
     if (client.Account.Characters.Count >= 5 && !client.Account.HasRights)
     {
         client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.ERR_TOO_MANY_CHARACTERS));
     }
     else
     {
         if (CharacterRecord.NameExist(message.name))
         {
             client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.ERR_NAME_ALREADY_EXISTS));
         }
         else if (!new Regex("^[A-Z][a-z]{2,9}(?:-[A-Z][a-z]{2,9}|[a-z]{1,10})$").IsMatch(message.name))
         {
             client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.ERR_INVALID_NAME));
         }
         else
         {
             Breed           breed           = Breed.Breeds[message.breed - 1];
             string          look            = message.sex == false ? breed.MaleLook : breed.FemaleLook;
             CharacterRecord characterRecord = new CharacterRecord(client.Account.Id, message.name, 1, 0, (BreedEnum)message.breed, message.colors.Distinct().Count() != 1 ? look.Insert(look.IndexOf("||") + 1, $"1={message.colors[0]},2={message.colors[1]},3={message.colors[2]},4={message.colors[3]},5={message.colors[4]}") : look, message.sex, Config.StartMap != 0 ? Config.StartMap : breed.StartMapId, Config.StartCellId != 0 ? Config.StartCellId : breed.StartDisposition.cellId, Config.StartDirection != 0 ? (DirectionsEnum)Config.StartDirection : (DirectionsEnum)breed.StartDisposition.direction, AlignmentSideEnum.ALIGNMENT_NEUTRAL, 0, 0, false, 0, 0, 0, DateTime.Now);
             characterRecord.Create();
             client.Account.Characters = CharacterRecord.ReturnCharacters(client.Account.Id);
             CharacterRecord firstOrDefault = client.Account.Characters.FirstOrDefault(character => character.Name == characterRecord.Name);
             if (firstOrDefault != null)
             {
                 new List <CharacterSpellRecord>(new[] { new CharacterSpellRecord(firstOrDefault.Id, 64, 0, 1), new CharacterSpellRecord(firstOrDefault.Id, 65, breed.BreedSpellsId[0], 1), new CharacterSpellRecord(firstOrDefault.Id, 66, breed.BreedSpellsId[1], 1), new CharacterSpellRecord(firstOrDefault.Id, 67, breed.BreedSpellsId[2], 1) }).ForEach(spell => spell.Create());
             }
             client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.OK));
             SendCharactersListMessage(client, false);
         }
     }
 }
Example #25
0
        public static void HandleBS_CS_CHARACTER_LIST(SimpleClient client, BS_CS_CHARACTER_LIST message)
        {
            if (client.Account.SessionKey != message.sessionKey)
            {
                client.Disconnect();
                return;
            }

            CharacterRecord character = CharacterManager.Instance.GetCharacterByAccountId(client.Account.Id);

            if (character == null)
            {
                client.Send(new BM_SC_CHARACTER_LIST("", 1, 0, new List <ListCharacterInfoType>()));
            }
            else
            {
                client.Account.Character = new Character(character, client);
                client.Send(new BM_SC_CHARACTER_LIST(client.Character.Name, 0, 1, new List <ListCharacterInfoType>()
                {
                    new ListCharacterInfoType(0, 0, 0)                                                                                                  /*, new ListCharacterInfoType(0, 1, 0), new ListCharacterInfoType(0, 2, 0), new ListCharacterInfoType(0, 3, 0), new ListCharacterInfoType(0, 4, 0), new ListCharacterInfoType(0, 5, 0) */
                }));
                Thread.Sleep(4000);
                client.Send(new BM_SC_CHARACTER_LIST2(client.Character.Name, (short)client.Character.Type, 6, new List <ListCharacterInfoType2>()
                {
                    new ListCharacterInfoType2(0, 0, 0), new ListCharacterInfoType2(1, 1, 1), new ListCharacterInfoType2(2, 2, 2), new ListCharacterInfoType2(3, 3, 3), new ListCharacterInfoType2(4, 4, 4), new ListCharacterInfoType2(5, 5, 5)
                }));
                //client.Send(new BM_SC_SELECT_CHARACTER());
            }
        }
Example #26
0
 public CharacterEngine(CharacterRecord record, GameClient client)
 {
     Record = record;
     Client = client;
     Stats  = new StatEngine(this);
     Spells = CharacterSpellRecord.ReturnCharacterSpells(Id);
 }
        public static void HandleCharactersListRequestMessage(WorldClient client, CharactersListRequestMessage message)
        {
            if (client.Account != null && client.Account.Login != "")
            {
                CharacterRecord characterRecord = CharacterHandler.FindCharacterFightReconnection(client);
                if (characterRecord != null)
                {
                    var fight = Singleton <FightManager> .Instance.GetFight(characterRecord.LeftFightId.Value);

                    CharacterHandler.SendCharacterSelectedForceMessage(client, characterRecord);
                    CharacterHandler.CommonCharacterForceSelection(client, characterRecord, fight);
                }
                else
                {
                    CharacterHandler.SendCharactersListMessage(client);
                    if (client.WorldAccount != null && client.StartupActions.Count > 0)
                    {
                        StartupHandler.SendStartupActionsListMessage(client, client.StartupActions);
                    }
                }
            }
            else
            {
                client.Send(new IdentificationFailedMessage((sbyte)IdentificationFailureReasonEnum.UNKNOWN_AUTH_ERROR));
                client.DisconnectLater(1000);
            }
        }
Example #28
0
        public void RemodelCosmetic(CharacterRecord record, ushort cosmeticId)
        {
            var skinId = HeadRecord.GetSkin(record.CosmeticId);

            record.Look.RemoveSkin(skinId);
            record.Look.AddSkin(HeadRecord.GetSkin(cosmeticId));
            record.CosmeticId = cosmeticId;
        }
Example #29
0
    public override void Load(Hashtable record)
    {
        base.Load(record);

        CharacterRecord.ReadFromHashtable(this, record);

        //Leaderboards.ReportAccountXP();
    }
Example #30
0
        public void RemodelColors(CharacterRecord record, int[] colors)
        {
            var dic = ContextActorLook.GetConvertedColorsWithIndex(colors);
            var col = ContextActorLook.GetConvertedColorSortedByIndex(dic);

            col = BreedRecord.VerifiyColors(col, record.Sex, BreedRecord.GetBreed(record.BreedId)).ToList();
            record.Look.SetColors(ContextActorLook.GetConvertedColors(col));
        }
Example #31
0
			Guild CreateGuild(CmdTrigger<RealmServerCmdArgs> trigger, string name, CharacterRecord record)
			{
				var guild = new Guild(record, name);

				trigger.Reply("Guild created");

				return guild;
			}
Example #32
0
            Guild CreateGuild(CmdTrigger <RealmServerCmdArgs> trigger, string name, CharacterRecord record)
            {
                var guild = new Guild(record, name);

                trigger.Reply("Guild created");

                return(guild);
            }
Example #33
0
        public override bool Validate(CharacterRecord charInfo, CharacterRecord relatedCharInfo, out RelationResult relResult)
        {
            //Check if the character exists. This should always be true in theory
            if (charInfo == null)
            {
                relResult = RelationResult.FRIEND_DB_ERROR;
                return false;
            }

            //Checks if the relation target char exist 
            if (relatedCharInfo == null)
            {
                relResult = RelationResult.FRIEND_NOT_FOUND;
                return false;
            }

            //Checks if the target char is the same as the related one
            if (charInfo.EntityLowId == relatedCharInfo.EntityLowId)
            {
                relResult = RelationResult.FRIEND_SELF;
                return false;
            }

            //Checks if both chars are in the same faction
			if (FactionMgr.GetFactionGroup(charInfo.Race) != FactionMgr.GetFactionGroup(relatedCharInfo.Race))
            {
                relResult = RelationResult.FRIEND_ENEMY;
                return false;
            }

            //Checks if the relation currently exist
            if (RelationMgr.Instance.HasRelation(charInfo.EntityLowId, relatedCharInfo.EntityLowId, Type))
            {
                relResult = RelationResult.FRIEND_ALREADY;
                return false;
            }

            //All checks are ok so check if the related char is online
            if (World.GetCharacter(relatedCharInfo.EntityLowId) != null)
            {
                relResult = RelationResult.FRIEND_ADDED_ONLINE;
            }
            else
            {
                relResult = RelationResult.FRIEND_ADDED_OFFLINE;
            }
            return true;
        }
Example #34
0
		public TestCharacter(TestAccount acc, CharacterRecord record, Archetype archetype, bool isNew)
		{
			Create(acc, PrepareRecord(acc, record, archetype, isNew), CreateClient(acc));
			record.ExploredZones = new byte[UpdateFieldMgr.ExplorationZoneFieldSize * 4];
			acc.Characters.Add(record);
			acc.Character = this;

			BaseHealth = 1000;
			Health = 1000;
			Assert.AreEqual(1000, BaseHealth);
			Asser.GreaterOrEqual(MaxHealth, BaseHealth);
			Assert.AreEqual(1000, Health);
			Assert.IsFalse(string.IsNullOrEmpty(Name));

			SpecProfiles = new[] { WCell.RealmServer.Talents.SpecProfile.NewSpecProfile(this, 0) };
		}
Example #35
0
		public static CharacterRecord PrepareRecord(TestAccount acc, CharacterRecord record, Archetype archetype, bool isNew)
		{
			var race = archetype.Race;

			record.Name = "TestChar" + record.EntityLowId;
			record.AccountId = acc.AccountId;
			record.Created = DateTime.Now;
			record.New = isNew;
			record.TotalPlayTime = 0;
			record.LevelPlayTime = 0;
			record.TutorialFlags = new byte[32];
			record.SetupNewRecord(archetype);

			record.CreateAndFlush();

			return record;
		}
Example #36
0
        public override bool Validate(CharacterRecord charInfo, CharacterRecord relatedCharInfo, out RelationResult relResult)
        {
            //Check if the character exists. This should always be true in theory
            if (charInfo == null)
            {
                relResult = RelationResult.FRIEND_DB_ERROR;
                return false;
            }

            //Checks if the relation target char exist
            if (relatedCharInfo == null)
            {
                relResult = RelationResult.MUTED_NOT_FOUND;
                return false;
            }

            //Checks if the target char is the same as the related one
            if (charInfo.EntityLowId == relatedCharInfo.EntityLowId)
            {
                relResult = RelationResult.MUTED_SELF;
                return false;
            }

            ////Checks if both chars are in the same faction
            //if (Factions.FactionMgr.GetFactionGroup(charInfo.Race) != Factions.FactionMgr.GetFactionGroup((RaceType)relatedCharInfo.Race))
            //{
            //    relResult = RelationResult.MUTED_ENEMY;
            //    return false;
            //}

            //Checks if the relation currently exist
            if (RelationMgr.Instance.HasRelation(charInfo.EntityLowId, relatedCharInfo.EntityLowId, this.Type))
            {
                relResult = RelationResult.MUTED_ALREADY;
                return false;
            }

            relResult = RelationResult.MUTED_ADDED;
            return true;
        }
Example #37
0
		public TestCharacter(CharacterRecord record, Archetype archetype, bool isNew)
			: this(Setup.AccountPool.CreateAccount(), record, archetype, isNew)
		{
		}
Example #38
0
		/// <summary>
		/// Creates and sends a new Mail with the given parameters
		/// </summary>
		public MailError SendMail(CharacterRecord recipient,
			string subject,
			string body,
			MailStationary stationary,
			ICollection<Item> items,
			uint money,
			uint cod)
		{
			if (subject.Length > MailMgr.MaxMailSubjectLength ||
				body.Length > MailMgr.MaxMailBodyLength)
			{
				// Player cannot send mails this long through the mail dialog
				return MailError.INTERNAL_ERROR;
			}

			// Can't send mail to yourself.
			if (recipient.EntityLowId == m_chr.EntityId.Low)
			{
				MailHandler.SendResult(m_chr.Client, 0, MailResult.MailSent, MailError.CANNOT_SEND_TO_SELF);
				return MailError.CANNOT_SEND_TO_SELF;
			}

		    var requiredCash = money;

			// Check that sender is good for the money.
			if (MailMgr.ChargePostage)
			{
                if (!m_chr.GodMode)
                {
                    requiredCash += MailMgr.PostagePrice;

                    var count = (items == null) ? 0u : (uint) items.Count;
                    if (count > 0)
                    {
                        requiredCash += ((count - 1)*MailMgr.PostagePrice);
                    }
                }
			}

            if (requiredCash > m_chr.Money)
            {
                MailHandler.SendResult(m_chr.Client, 0u, MailResult.MailSent, MailError.NOT_ENOUGH_MONEY);
                return MailError.NOT_ENOUGH_MONEY;
            }

            // Charge for the letter (already checked, Character has enough)
            m_chr.Money -= requiredCash;

			// All good, send an ok message
			MailHandler.SendResult(m_chr.Client, 0u, MailResult.MailSent, MailError.OK);
            m_chr.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.GoldSpentForMail, requiredCash);

			var deliveryDelay = 0u;
			if (!m_chr.GodMode)
			{
				if ((money > 0 || (items != null && items.Count > 0)) && (m_chr.Account.AccountId != recipient.AccountId))
				{
					deliveryDelay = MailMgr.MaxPacketDeliveryDelay;
				}
			}

			// Create a new letter object
			var letter = new MailMessage(subject, body)
			{
				LastModifiedOn = null,
				SenderId = m_chr.EntityId.Low,
				ReceiverId = recipient.EntityLowId,
				MessageStationary = stationary,
				MessageType = MailType.Normal,
				CashOnDelivery = cod,
				IncludedMoney = money,
				SendTime = DateTime.Now,
				DeliveryTime = DateTime.Now.AddSeconds(deliveryDelay)
			};

			// Attach items to the new letter
			if (items != null && items.Count > 0)
			{
				// remove the item from the sender's inventory and add them to the list
				letter.SetItems(items);
			}

			MailMgr.SendMail(letter);
			return MailError.OK;
		}
Example #39
0
		/// <summary>
		/// Creates a new character and loads all required character data from the database
		/// </summary>
		/// <param name="acc">The account the character is associated with</param>
		/// <param name="record">The name of the character to load</param>
		/// <param name="client">The client to associate with this character</param>
		internal protected void Create(RealmAccount acc, CharacterRecord record, IRealmClient client)
		{			client.ActiveCharacter = this;
			acc.ActiveCharacter = this;

			Type |= ObjectTypes.Player;
			ChatChannels = new List<ChatChannel>();

			m_logoutTimer = new TimerEntry(0.0f, DefaultLogoutDelay, totalTime => FinishLogout());

			Account = acc;
			m_client = client;

			m_record = record;
			EntityId = EntityId.GetPlayerId(m_record.EntityLowId);
			m_name = m_record.Name;

			Archetype = ArchetypeMgr.GetArchetype(record.Race, record.Class);
			MainWeapon = GenericWeapon.Fists;
			PowerType = m_archetype.Class.PowerType;

			StandState = StandState.Sit;

			Money = (uint)m_record.Money;
			Outfit = m_record.Outfit;
			//ScaleX = m_archetype.Race.Scale;
			ScaleX = 1;
			Gender = m_record.Gender;
			Skin = m_record.Skin;
			Facial = m_record.Face;
			HairStyle = m_record.HairStyle;
			HairColor = m_record.HairColor;
			FacialHair = m_record.FacialHair;
			UnitFlags = UnitFlags.PlayerControlled;
			XP = m_record.Xp;
			RestXp = m_record.RestXp;
			Level = m_record.Level;
			NextLevelXP = XpGenerator.GetXpForlevel(m_record.Level + 1);
			MaxLevel = RealmServerConfiguration.MaxCharacterLevel;

			RestState = RestState.Normal;

			Orientation = m_record.Orientation;

			m_bindLocation = new ZoneWorldLocation(
				m_record.BindRegion,
				new Vector3(m_record.BindX, m_record.BindY, m_record.BindZ),
				m_record.BindZone);

			PvPRank = 1;
			YieldsXpOrHonor = true;

			foreach (var school in WCellDef.AllDamageSchools)
			{
				SetInt32(PlayerFields.MOD_DAMAGE_DONE_PCT + (int)school, 1);
			}
			SetFloat(PlayerFields.DODGE_PERCENTAGE, 1.0f);

			// Auras
			m_auras = new PlayerAuraCollection(this);

			// spells
			PlayerSpellCollection spells;
			if (!record.JustCreated && SpellHandler.PlayerSpellCollections.TryGetValue(EntityId.Low, out spells))
			{
				SpellHandler.PlayerSpellCollections.Remove(EntityId.Low);
				m_spells = spells;
				((PlayerSpellCollection)m_spells).OnReconnectOwner(this);
			}
			else
			{
				m_spells = new PlayerSpellCollection(this);
			}

			// factions
			WatchedFaction = m_record.WatchedFaction;
			Faction = FactionMgr.ByRace[(uint)record.Race];
			m_reputations = new ReputationCollection(this);

			// skills
			m_skills = new SkillCollection(this);

			// talents
			m_talents = new TalentCollection(this);

			// Items
			m_inventory = new PlayerInventory(this);

			m_mailAccount = new MailAccount(this);

			m_questLog = new QuestLog(this);

			// Talents
			m_record.SpecProfile = SpecProfile.NewSpecProfile(this);
			FreeTalentPoints = m_record.FreeTalentPoints;

			// tutorial flags
			TutorialFlags = new TutorialFlags(m_record.TutorialFlags);

			// Make sure client and internal state is updated with combat base values
			UnitUpdates.UpdateSpellCritChance(this);

			// Mask of activated TaxiNodes
			m_taxiNodeMask = new TaxiNodeMask();

			PowerCostMultiplier = 1f;

			m_lastPlayTimeUpdate = DateTime.Now;

			MoveControl.Mover = this;
			MoveControl.CanControl = true;

			BaseHealth = m_record.BaseHealth;
			SetBasePowerDontUpdate(m_record.BasePower);

			SetBaseStat(StatType.Strength, m_record.BaseStrength);
			SetBaseStat(StatType.Stamina, m_record.BaseStamina);
			SetBaseStat(StatType.Spirit, m_record.BaseSpirit);
			SetBaseStat(StatType.Intellect, m_record.BaseIntellect);
			SetBaseStat(StatType.Agility, m_record.BaseAgility);

			CanMelee = true;

			// basic setup
			if (record.JustCreated)
			{
				Power = PowerType == PowerType.Rage ? 0 : MaxPower;
				SetInt32(UnitFields.HEALTH, MaxHealth);
			}
			else
			{
				Power = m_record.Power;
				SetInt32(UnitFields.HEALTH, m_record.Health);
			}

		}
Example #40
0
		/// <summary>
		/// Creates a new character and loads all required character data from the database
		/// </summary>
		/// <param name="acc">The account the character is associated with</param>
		/// <param name="record">The name of the character to load</param>
		/// <param name="client">The client to associate with this character</param>
		internal protected void Create(RealmAccount acc, CharacterRecord record, IRealmClient client)
		{
			client.ActiveCharacter = this;
			acc.ActiveCharacter = this;

			Type |= ObjectTypes.Player;
			ChatChannels = new List<ChatChannel>(5);

			m_logoutTimer = new TimerEntry(0, DefaultLogoutDelayMillis, totalTime => FinishLogout());

			Account = acc;
			m_client = client;

			m_record = record;
			EntityId = EntityId.GetPlayerId(m_record.EntityLowId);
			m_name = m_record.Name;

			Archetype = ArchetypeMgr.GetArchetype(record.Race, record.Class);
			MainWeapon = GenericWeapon.Fists;
			PowerType = m_archetype.Class.DefaultPowerType;

			StandState = StandState.Sit;

			Money = (uint) m_record.Money;
			Outfit = m_record.Outfit;
			//ScaleX = m_archetype.Race.Scale;
			ScaleX = 1;
			Gender = m_record.Gender;
			Skin = m_record.Skin;
			Facial = m_record.Face;
			HairStyle = m_record.HairStyle;
			HairColor = m_record.HairColor;
			FacialHair = m_record.FacialHair;
			UnitFlags = UnitFlags.PlayerControlled;
			Experience = m_record.Xp;
			RestXp = m_record.RestXp;

			SetInt32(UnitFields.LEVEL, m_record.Level);
				// cannot use Level property, since it will trigger certain events that we don't want triggered
			NextLevelXP = XpGenerator.GetXpForlevel(m_record.Level + 1);
			MaxLevel = RealmServerConfiguration.MaxCharacterLevel;

			RestState = RestState.Normal;

			Orientation = m_record.Orientation;

			m_bindLocation = new WorldZoneLocation(
				m_record.BindMap,
				new Vector3(m_record.BindX, m_record.BindY, m_record.BindZ),
				m_record.BindZone);

			PvPRank = 1;
			YieldsXpOrHonor = true;

			foreach (var school in WCellDef.AllDamageSchools)
			{
				SetFloat(PlayerFields.MOD_DAMAGE_DONE_PCT + (int) school, 1);
			}
			SetFloat(PlayerFields.DODGE_PERCENTAGE, 1.0f);

			// Auras
			m_auras = new PlayerAuraCollection(this);

			// spells
			m_spells = PlayerSpellCollection.Obtain(this);

			// factions
			WatchedFaction = m_record.WatchedFaction;
			Faction = FactionMgr.ByRace[(uint) record.Race];
			m_reputations = new ReputationCollection(this);

			// skills
			m_skills = new SkillCollection(this);

			// talents
			m_talents = new PlayerTalentCollection(this);

			// achievements
			m_achievements = new AchievementCollection(this);

			// Items
			m_inventory = new PlayerInventory(this);

			m_mailAccount = new MailAccount(this);

			m_questLog = new QuestLog(this);

			// tutorial flags
			TutorialFlags = new TutorialFlags(m_record.TutorialFlags);

			// Make sure client and internal state is updated with combat base values
			UnitUpdates.UpdateSpellCritChance(this);

			// Mask of activated TaxiNodes
			m_taxiNodeMask = new TaxiNodeMask();

			PowerCostMultiplier = 1f;

			m_lastPlayTimeUpdate = DateTime.Now;

			MoveControl.Mover = this;
			MoveControl.CanControl = true;

			CanMelee = true;

			SpeedFactor = DefaultSpeedFactor;

			// basic setup
			if (record.JustCreated)
			{
				ModStatsForLevel(m_record.Level);
				BasePower = RegenerationFormulas.GetPowerForLevel(this);
			}
			else
			{
				BaseHealth = m_record.BaseHealth;
				SetBasePowerDontUpdate(m_record.BasePower);

				SetBaseStat(StatType.Strength, m_record.BaseStrength);
				SetBaseStat(StatType.Stamina, m_record.BaseStamina);
				SetBaseStat(StatType.Spirit, m_record.BaseSpirit);
				SetBaseStat(StatType.Intellect, m_record.BaseIntellect);
				SetBaseStat(StatType.Agility, m_record.BaseAgility);

				Power = m_record.Power;
				SetInt32(UnitFields.HEALTH, m_record.Health);
			}
		}
Example #41
0
        private static void CharacterRenameCallback(IRealmClient client, CharacterRecord ch, string newName, EntityId guid)
        {
            if (CharacterRecord.Exists(newName))
            {
                SendCharacterRenameError(client, LoginErrorCode.CHAR_CREATE_NAME_IN_USE);
            }
            else
            {
                log.Debug(WCell_RealmServer.RenamingCharacter, ch.Name, newName);

                ch.Name = newName;

                SendCharacterRename(client, guid, ch.Name);
            }
        }
Example #42
0
 public virtual bool Validate(CharacterRecord charInfo, CharacterRecord relatedCharInfo,
     out RelationResult relResult)
 {
     relResult = RelationResult.FRIEND_DB_ERROR;
     return true;
 }
Example #43
0
		/// <summary>
		/// Creates a new unique CharacterRecord (not unique within the DB though)
		/// </summary>
		public static CharacterRecord CreateCharRecord()
		{
			var record = new CharacterRecord(0) { EntityLowId = CharacterRecord.NextId() };
			//record.EntityLowId = nextCharId++;
			return record;
		}
Example #44
0
        private static void CharCreateCallback(IRealmClient client, CharacterRecord newCharRecord)
        {
            // check again, to avoid people creating 2 chars with the same name at the same time screwing up the server
            if (CharacterRecord.Exists(newCharRecord.Name))
            {
                SendCharCreateReply(client, LoginErrorCode.CHAR_CREATE_NAME_IN_USE);
            }
            else
            {
                try
                {
                    newCharRecord.CreateAndFlush();
                }
                catch (Exception e)
                {
                    //LogUtil.ErrorException(e, "Could not create Character \"{0}\" for: {1}", newCharRecord.Name, client.Account);
                    //SendCharCreateReply(client, LoginErrorCode.CHAR_CREATE_ERROR);
                    try
                    {
                        RealmDBMgr.OnDBError(e);
                        newCharRecord.CreateAndFlush();
                    }
                    catch (Exception)
                    {
                        SendCharCreateReply(client, LoginErrorCode.CHAR_CREATE_ERROR);
                        return;
                    }
                }

                client.Account.Characters.Add(newCharRecord);

                SendCharCreateReply(client, LoginErrorCode.CHAR_CREATE_SUCCESS);
            }
        }