示例#1
0
        public void PlayerAttackMonster(Connection client, AttackTargetRequest atr)
        {
            if (!_monsters.ContainsKey(atr.TargetID))
            {
                LogInterface.Log(string.Format("Character({0}) attacking non existant monster {1} on map {2}", client.Character.ID, atr.TargetID, client.Character.MapID), LogInterface.LogMessageType.Game);
                client.SendPacket(new SeePlayerAttack(atr.TargetID, 0, client.Character, atr, 6));        // Wrong target
            }
            else
            {
                Monster m = _monsters[atr.TargetID];

                client.Character.AttackTarget(m, atr);

                SeePlayerAttack pkt = new SeePlayerAttack(m.ID, m.CurHP, client.Character, atr);
                foreach (Connection c in _players.Values)
                {
                    c.SendPacket(pkt);
                }

                if (m.Dead)
                {
                    // Do loot!
                    m.GiveLoot(client);
                }
            }
        }
示例#2
0
        public void Database_OnQueryComplete(object sender, EventArgs e)
        {
            DBQuery q = (DBQuery)sender;

            _pqLock.WaitOne();
            LogInterface.Log("Finishing Query with key: " + q.Key, LogInterface.LogMessageType.Debug);
            Task task = _pendingQueries[q.Key];

            _pendingQueries.Remove(q.Key);
            _pqLock.ReleaseMutex();

            // reschedule the task to deal with the new data\
            if (task.Type >= 0)
            {
                AddTask(task);
            }
        }
示例#3
0
        public DBQuery AddDBQuery(string sql, Task task, bool read = true)
        {
            if (task == null)
            {
                task = new Task(-1);
            }

            long    key = UniqueKey();
            DBQuery q   = new DBQuery(sql, read, key);

            task.Query = q;

            _pqLock.WaitOne();
            LogInterface.Log("Adding Query with key: " + key, LogInterface.LogMessageType.Debug);
            _pendingQueries[key] = task;
            _pqLock.ReleaseMutex();

            _db.AddQuery(q);
            return(q);
        }
示例#4
0
        public void RegisterAuthString(string authString, int accountId, int hardCurrency, int vip, string displayName)
        {
            if (_accounts.Count > MAX_CACHED_ACCOUNTS)
            {
                int preDump = _accounts.Count;
                // Dump accounts that are a day old or more
                DumpAccounts(24 * 60 * 60);

                LogInterface.Log(string.Format("Dumping cached accounts: ({0}) -> ({1})", preDump, _accounts.Count), LogInterface.LogMessageType.System, true);
            }

            AuthAccountInfo aai = new AuthAccountInfo();

            aai.AccountID         = accountId;
            aai.HardCurrency      = hardCurrency;
            aai.Vip               = vip;
            aai.Timestamp         = DateTime.Now.Ticks;
            aai.DisplayName       = displayName;
            _accounts[authString] = aai;
        }
示例#5
0
 public static void Log(string text, bool addTimeStamp)
 {
     m_logInterface.Log(text, addTimeStamp);
 }
示例#6
0
 void BeginPacket(HPacketType type)
 {
     LogInterface.Log(string.Format("BeginPacket({0})", type), LogInterface.LogMessageType.Debug);
     BeginPacket((ushort)type);
 }