Exemplo n.º 1
0
        public PlayerSaver AddPlayer(CSCommon.Data.PlayerDataEx roleId)
        {
            PlayerSaver       saver    = null;
            PlayerSaverThread thread   = null;
            Int32             mincount = Int32.MaxValue;

            foreach (var i in mSaveThreads)
            {
                int count = i.GetPlayerCount();
                if (count < mincount)
                {
                    mincount = count;
                    thread   = i;
                }
                saver = i.FindPlayerSaver(roleId);
                if (saver != null)
                {
                    return(saver);
                }
            }

            if (thread == null)
            {
                Log.Log.Common.Print("AddPlayer thread is null");
            }

            saver = thread.AddPlayer(roleId);
            return(saver);
        }
Exemplo n.º 2
0
        public void PushExecuter(CSCommon.Data.PlayerDataEx roleId, ServerFrame.DB.AsyncExecuter exec)
        {
            PlayerSaver       saver    = null;
            PlayerSaverThread thread   = null;
            Int32             mincount = Int32.MaxValue;

            foreach (var i in mSaveThreads)
            {
                int count = i.GetPlayerCount();
                if (count < mincount)
                {
                    mincount = count;
                    thread   = i;
                }
                saver = i.FindPlayerSaver(roleId);
                if (saver != null)
                {
                    break;
                }
            }
            if (saver == null)
            {
                saver = thread.AddPlayer(roleId);
            }
            ServerFrame.DB.DBOperator sqlAtom = new ServerFrame.DB.DBOperator();
            sqlAtom.Executer = exec;
            saver.Push(sqlAtom);
            saver.mWaitRemove = false;//只要有数据重新要存储,说明他又登陆进来了,不需要remove了
        }
Exemplo n.º 3
0
        public PlayerSaver AddPlayer(CSCommon.Data.PlayerDataEx player)
        {
            PlayerSaver saver;

            lock (this)
            {
                saver = FindPlayerSaver(player);
                if (saver != null)
                {
                    return(saver);
                }
                saver = new PlayerSaver();
                saver.mPlayerDataEx = player;
                if (player == null || player.RoleDetail == null)
                {
                    Log.Log.Common.Print("player  is null");
                }
                if (player.mSaverThread != null)
                {
                    Log.Log.Common.Print("AddPlayer mSaverThread is null");
                }
                player.mSaverThread = this;
                mPushPlayers.Add(player, saver);
            }

            return(saver);
        }
Exemplo n.º 4
0
        public void PushSave(CSCommon.Data.PlayerDataEx roleId, string SqlCode, SqlExeType ExeType)
        {
            PlayerSaver saver = AddPlayer(roleId);

            ServerFrame.DB.DBOperator sqlAtom = new ServerFrame.DB.DBOperator();
            sqlAtom.SqlCode = SqlCode;
            sqlAtom.ExeType = ExeType;
            saver.Push(sqlAtom);
            saver.mWaitRemove = false;//只要有数据重新要存储,说明他又登陆进来了,不需要remove了
        }
Exemplo n.º 5
0
        public void _ClearSaver(CSCommon.Data.PlayerDataEx roleId)
        {
            PlayerSaver saver = null;

            foreach (var i in mSaveThreads)
            {
                saver = i.FindPlayerSaver(roleId);
                if (saver != null)
                {
                    saver.Clear();
                }
            }
        }
Exemplo n.º 6
0
        public PlayerSaver FindPlayerSaverById(ulong roleId)
        {
            PlayerSaver saver = null;

            foreach (var i in mSaveThreads)
            {
                saver = i.FindPlayerSaverById(roleId);
                if (saver != null)
                {
                    return(saver);
                }
            }
            return(null);
        }
Exemplo n.º 7
0
        public bool InPool(CSCommon.Data.PlayerDataEx roleId)
        {
            PlayerSaver saver = null;

            foreach (var i in mSaveThreads)
            {
                saver = i.FindPlayerSaver(roleId);
                if (saver != null)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 8
0
        public void RemovePlayer(CSCommon.Data.PlayerDataEx roleId)
        {
            PlayerSaver saver = null;

            foreach (var i in mSaveThreads)
            {
                saver = i.FindPlayerSaver(roleId);
                if (saver != null)
                {
                    break;
                }
            }
            if (saver != null)
            {
                saver.mWaitRemove = true;
            }
        }
Exemplo n.º 9
0
        public void PushSave(CSCommon.Data.PlayerDataEx roleId, ServerFrame.DB.DBOperator dbOp)
        {
            if (dbOp == null)
            {
                return;
            }
            if (roleId == null)
            {
                //走到这里说明DataServer已经重启过了,之前的在线玩家需要存盘,放到一个特殊线程处理就好了
                switch (dbOp.ExeType)
                {
                case SqlExeType.Update:
                {
                    PlayerEnterThread.Instance.DBConnect._ExecuteUpdate(dbOp);
                }
                break;

                case SqlExeType.Insert:
                {
                    PlayerEnterThread.Instance.DBConnect._ExecuteInsert(dbOp);
                }
                break;

                case SqlExeType.Delete:
                {
                    PlayerEnterThread.Instance.DBConnect._ExecuteDelete(dbOp);
                }
                break;

                case SqlExeType.Destroy:
                {
                    PlayerEnterThread.Instance.DBConnect._ExecuteDestroy(dbOp);
                }
                break;
                }
                return;
            }
            PlayerSaver saver = AddPlayer(roleId);

            saver.Push(dbOp);
            saver.mWaitRemove = false;//只要有数据重新要存储,说明他又登陆进来了,不需要remove了
        }