//更新爵位信息 public void UpdateGuanJueInfo(GuanJueInfo info) { //先删-- 然后再排序 for (int i = 0; i < mListInfo.Count; i++) { if (mListInfo[i].id == info.id) { mListInfo.RemoveAt(i); break; } } bool bInsert = false; for (int i = 0; i < mListInfo.Count; i++) { if (info.guanjue > mListInfo[i].guanjue) { mListInfo.Insert(i, info); bInsert = true; break; } } if (!bInsert && mListInfo.Count < GameBase.Config.Define.MAX_JUEWEICOUNT) { mListInfo.Add(info); } }
//载入数据 public void DB_Load() { String sql = string.Format("select id,name,guanjue from cq_user ORDER BY guanjue DESC"); MySqlCommand command = new MySqlCommand(sql, MysqlConn.GetConn()); MysqlConn.Conn_Open(); MySqlDataReader reader = command.ExecuteReader(); //最多五十个排名 const int MAX_JUEWEI = 50; int index = 0; while (reader.Read()) { if (!reader.HasRows) { break; } ulong guanjue = reader.GetUInt64("guanjue"); if (guanjue == 0) { break; } GuanJueInfo info = new GuanJueInfo(); info.guanjue = guanjue; info.id = reader.GetUInt32("id"); info.name = reader.GetString("name"); info.name = Coding.Latin1ToGB2312(info.name); mListInfo.Add(info); index++; if (index > MAX_JUEWEI) { break; } } MysqlConn.Conn_Close(); command.Dispose(); }
public void SetValue(int play_id, String name, ulong guanjue) { // bool bFind = false; for (int i = 0; i < mList.Count; i++) { if (mList[i].id == play_id) { //mList[i].guanjue = guanjue; mList.RemoveAt(i); //bFind = true; break; } } GuanJueInfo info = new GuanJueInfo(); info.id = (uint)play_id; info.name = name; info.guanjue = guanjue; //插入-- bool bInsert = false; for (int i = 0; i < mList.Count; i++) { if (guanjue > mList[i].guanjue) { mList.Insert(i, info); bInsert = true; break; } } if (!bInsert && mList.Count < GameBase.Config.Define.MAX_JUEWEICOUNT) { mList.Add(info); } }