//插入函数 //插入种类 public bool InsertGameType(tagGameType pGameType) { //if (pGameType == null) return false; //变量定义 CGameTypeItem pGameTypeItem = null; bool bInsert = false; if (m_GameTypeItemMap.ContainsKey(pGameType.wTypeID)) { pGameTypeItem = m_GameTypeItemMap[pGameType.wTypeID]; } else { pGameTypeItem = new CGameTypeItem(); bInsert = true; } if (pGameTypeItem == null) { return(false); } //设置数据 var buf = StructConverterByteArray.StructToBytes(pGameType); pGameTypeItem.m_GameType = (tagGameType)StructConverterByteArray.BytesToStruct(buf, typeof(tagGameType)); //memcpy(&pGameTypeItem.m_GameType, pGameType, sizeof(tagGameType)); //插入处理 if (bInsert == true) { //设置索引 m_GameTypeItemMap[pGameType.wTypeID] = pGameTypeItem; //界面更新 if (m_pIServerListDataSink != null) { m_pIServerListDataSink.OnGameItemInsert(pGameTypeItem); } } else { //界面更新 if (m_pIServerListDataSink != null) { m_pIServerListDataSink.OnGameItemUpdate(pGameTypeItem); } } return(true); }
//删除函数 //删除种类 public bool DeleteGameType(ushort wTypeID) { //查找种类 if (m_GameTypeItemMap.ContainsKey(wTypeID) == false) { return(false); } CGameTypeItem pGameTypeItem = m_GameTypeItemMap[wTypeID]; //删除通知 //ASSERT(m_pIServerListDataSink!=0); if (m_pIServerListDataSink != null) { m_pIServerListDataSink.OnGameItemDelete(pGameTypeItem); } //重置数据 pGameTypeItem = null; //删除数据 m_GameTypeItemMap.Remove(wTypeID); return(true); }