Пример #1
0
        static public bool CreateChar(Character Char)
        {
            AccountChars Chars = GetAccountChar(Char.AccountId);

            Char.SlotId = Chars.GenerateFreeSlot();
            if (Char.SlotId < 0)
            {
                return(false);
            }

            lock (_Chars)
            {
                int Id = GenerateMaxCharId();

                while (_Chars[Id] != null)
                {
                    Id = GenerateMaxCharId();
                }

                if (Id >= MAX_CHARACTERS || Id <= 0)
                {
                    Log.Error("CreateChar", "Maximum number of characters reaches !");
                    return(false);
                }

                Char.CharacterId = Id;
                _Chars[Id]       = Char;
                Chars.AddChar(Char);
            }
            Database.AddObject(Char);

            return(true);
        }
Пример #2
0
        static public AccountChars GetAccountChar(int AccountId)
        {
            lock (_AcctChars)
            {
                if (!_AcctChars.ContainsKey(AccountId))
                {
                    _AcctChars[AccountId] = new AccountChars(AccountId);
                }

                return(_AcctChars[AccountId]);
            }
        }
Пример #3
0
        public static AccountChars GetAccountChar(int AccountId)
        {
            lock (_AcctChars)
            {
                if (!_AcctChars.ContainsKey(AccountId))
                    _AcctChars[AccountId] = new AccountChars(AccountId);

                return _AcctChars[AccountId];
            }
        }