Example #1
0
        void SetAccountData(AccountDataTypes type, uint time, string data)
        {
            if (Convert.ToBoolean((1 << (int)type) & (int)AccountDataTypes.GlobalCacheMask))
            {
                PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.REP_ACCOUNT_DATA);
                stmt.AddValue(0, GetAccountId());
                stmt.AddValue(1, type);
                stmt.AddValue(2, time);
                stmt.AddValue(3, data);
                DB.Characters.Execute(stmt);
            }
            else
            {
                // _player can be NULL and packet received after logout but m_GUID still store correct guid
                if (m_GUIDLow == 0)
                {
                    return;
                }

                PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.REP_PLAYER_ACCOUNT_DATA);
                stmt.AddValue(0, m_GUIDLow);
                stmt.AddValue(1, type);
                stmt.AddValue(2, time);
                stmt.AddValue(3, data);
                DB.Characters.Execute(stmt);
            }

            _accountData[(int)type].Time = time;
            _accountData[(int)type].Data = data;
        }
Example #2
0
        public void SendAccountDataTimes(ObjectGuid playerGuid, AccountDataTypes mask)
        {
            AccountDataTimes accountDataTimes = new();

            accountDataTimes.PlayerGuid = playerGuid;
            accountDataTimes.ServerTime = GameTime.GetGameTime();
            for (int i = 0; i < (int)AccountDataTypes.Max; ++i)
            {
                if (((int)mask & (1 << i)) != 0)
                {
                    accountDataTimes.AccountTimes[i] = GetAccountData((AccountDataTypes)i).Time;
                }
            }

            SendPacket(accountDataTimes);
        }
Example #3
0
        void LoadAccountData(SQLResult result, AccountDataTypes mask)
        {
            for (int i = 0; i < (int)AccountDataTypes.Max; ++i)
            {
                if (Convert.ToBoolean((int)mask & (1 << i)))
                {
                    _accountData[i] = new AccountData();
                }
            }

            if (result.IsEmpty())
            {
                return;
            }

            do
            {
                int type = result.Read <byte>(0);
                if (type >= (int)AccountDataTypes.Max)
                {
                    Log.outError(LogFilter.Server, "Table `{0}` have invalid account data type ({1}), ignore.",
                                 mask == AccountDataTypes.GlobalCacheMask ? "account_data" : "character_account_data", type);
                    continue;
                }

                if (((int)mask & (1 << type)) == 0)
                {
                    Log.outError(LogFilter.Server, "Table `{0}` have non appropriate for table  account data type ({1}), ignore.",
                                 mask == AccountDataTypes.GlobalCacheMask ? "account_data" : "character_account_data", type);
                    continue;
                }

                _accountData[type].Time = result.Read <uint>(1);
                var bytes = result.Read <byte[]>(2);
                var line  = Encoding.Default.GetString(bytes);
                _accountData[type].Data = line;
            }while (result.NextRow());
        }
Example #4
0
 AccountData GetAccountData(AccountDataTypes type)
 {
     return(_accountData[(int)type]);
 }