예제 #1
0
        public CGameKindItem m_pGameKindItem; //游戏类型

        //函数定义
        public CGameServerItem() : base(enItemGenre.ItemGenre_Server)
        {
            m_bSignuped = false;
            //辅助变量
            m_pGameKindItem = null;

            //扩展数据
            m_ServerStatus = enServerStatus.ServerStatus_Normal;
        }
예제 #2
0
        //插入类型
        public bool InsertGameKind(tagGameKind pGameKind)
        {
            //效验参数
            //ASSERT(pGameKind!=0);
            //if (pGameKind == null) return false;

            //变量定义
            CGameKindItem pGameKindItem = null;
            bool          bInsert       = false;

            if (m_GameKindItemMap.ContainsKey(pGameKind.wKindID))
            {
                pGameKindItem = m_GameKindItemMap[pGameKind.wKindID];
            }
            else
            {
                pGameKindItem = new CGameKindItem();
                bInsert       = true;
            }

            if (pGameKindItem == null)
            {
                return(false);
            }

            //设置数据
            var buf = StructConverterByteArray.StructToBytes(pGameKind);

            pGameKindItem.m_GameKind = (tagGameKind)StructConverterByteArray.BytesToStruct(buf, typeof(tagGameKind));
            //memcpy(&pGameKindItem.m_GameKind, pGameKind, sizeof(tagGameKind));

            //插入处理
            if (bInsert == true)
            {
                //设置索引
                m_GameKindItemMap[pGameKind.wKindID] = pGameKindItem;

                //插入子项
                if (m_pIServerListDataSink != null)
                {
                    m_pIServerListDataSink.OnGameItemInsert(pGameKindItem);
                }
            }
            else
            {
                //更新子项
                if (m_pIServerListDataSink != null)
                {
                    m_pIServerListDataSink.OnGameItemUpdate(pGameKindItem);
                }
            }

            return(true);
        }
예제 #3
0
        //设置人数
        public void SetServerOnLineCount(ushort wServerID, uint dwOnLineCount)
        {
            //搜索房间
            CGameServerItem pGameServerItem = SearchGameServer(wServerID);

            //设置人数
            if (pGameServerItem != null)
            {
                //设置变量
                m_dwAllOnLineCount -= pGameServerItem.m_GameServer.dwOnLineCount;
                m_dwAllOnLineCount += dwOnLineCount;

                //设置变量
                pGameServerItem.m_GameServer.dwOnLineCount = dwOnLineCount;

                //事件通知
                //ASSERT(m_pIServerListDataSink!=0);
                if (m_pIServerListDataSink != null)
                {
                    m_pIServerListDataSink.OnGameItemUpdate(pGameServerItem);
                }

                //查找类型
                CGameKindItem pGameKindItem = SearchGameKind(pGameServerItem.m_GameServer.wKindID);
                if (pGameKindItem != null)
                {
                    //变量定义
                    uint dwGameKindOnline = 0;
                    foreach (var cGameServerItem in m_GameServerItemMap)
                    {
                        CGameServerItem pGameServerItem2 = cGameServerItem.Value;
                        //设置房间
                        if ((pGameServerItem2 != null) &&
                            (pGameServerItem2.m_GameServer.wKindID == pGameServerItem.m_GameServer.wKindID))
                        {
                            dwGameKindOnline += pGameServerItem2.m_GameServer.dwOnLineCount;
                        }
                    }
                    //设置变量
                    pGameKindItem.m_GameKind.dwOnLineCount = dwGameKindOnline;

                    //事件通知
                    //ASSERT(m_pIServerListDataSink!=0);
                    if (m_pIServerListDataSink != null)
                    {
                        m_pIServerListDataSink.OnGameItemUpdate(pGameKindItem);
                    }
                }
            }
        }
예제 #4
0
        //获取总在线人数
        public uint GetAllOnLineCount() //{return m_dwAllOnLineCount;}
        {
            //定义变量
            uint dwAllOnLineCount = 0;

            foreach (var cGameKindItem in m_GameKindItemMap)
            {
                CGameKindItem pGameKindItem = cGameKindItem.Value;
                if (pGameKindItem != null)
                {
                    dwAllOnLineCount += pGameKindItem.m_GameKind.dwOnLineCount;
                }
            }

            return(dwAllOnLineCount);
        }
예제 #5
0
        //人数函数

        //设置人数
        public void SetKindOnLineCount(ushort wKindID, uint dwOnLineCount)
        {
            //搜索类型
            CGameKindItem pGameKindItem = SearchGameKind(wKindID);

            //设置人数
            if (pGameKindItem != null)
            {
                //设置变量
                pGameKindItem.m_GameKind.dwOnLineCount = dwOnLineCount;

                //事件通知
                //ASSERT(m_pIServerListDataSink!=0);
                if (m_pIServerListDataSink != null)
                {
                    m_pIServerListDataSink.OnGameItemUpdate(pGameKindItem);
                }
            }
        }
예제 #6
0
        //删除类型
        public bool DeleteGameKind(ushort wKindID)
        {
            //查找类型
            if (m_GameKindItemMap.ContainsKey(wKindID) == false)
            {
                return(false);
            }
            CGameKindItem pGameKindItem = m_GameKindItemMap[wKindID];

            //删除通知
            //ASSERT(m_pIServerListDataSink!=0);
            if (m_pIServerListDataSink != null)
            {
                m_pIServerListDataSink.OnGameItemDelete(pGameKindItem);
            }

            //删除数据
            pGameKindItem = null;

            //删除数据
            m_GameKindItemMap.Remove(wKindID);

            return(true);
        }