public static void LoadRoleData_Friend(GameBase.Network.Internal.ROLEDATA_FRIEND info) { MySqlCommand command; String _key = String.Format(MysqlString.LOADROLEDATA_FRIEND, info.playerid); command = new MySqlCommand(_key, MysqlConn.GetConn()); MysqlConn.Conn_Open(); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { if (!reader.HasRows) { break; } GameBase.Network.Internal.RoleData_Friend friend = new GameBase.Network.Internal.RoleData_Friend(); friend.id = reader.GetInt32("id"); friend.friendid = reader.GetUInt32("friendid"); friend.friendname = reader.GetString("friendname"); friend.friendname = Coding.Latin1ToGB2312(friend.friendname); friend.friendtype = reader.GetByte("friendtype"); info.list_item.Add(friend); } MysqlConn.Conn_Close(); command.Dispose(); }
public static void SaveRoleData_Friend(GameBase.Network.Internal.ROLEDATA_FRIEND info) { MySqlCommand command; String sql = ""; bool bSave = false; for (int i = 0; i < info.list_item.Count; i++) { GameBase.Network.Internal.RoleData_Friend friend = info.list_item[i]; if (friend.id == -1) { //先删除己方- sql = String.Format(MysqlString.DELETEROLEDATA_FRIEND, friend.friendid, info.playerid); command = new MySqlCommand(sql, MysqlConn.GetConn()); MysqlConn.Conn_Open(); command.ExecuteNonQuery(); MysqlConn.Conn_Close(); command.Dispose(); //删除自己 sql = String.Format(MysqlString.DELETEROLEDATA_FRIEND, info.playerid, friend.friendid); bSave = true; } else if (friend.id == 0) { friend.friendname = Coding.GB2312ToLatin1(friend.friendname); sql = String.Format(MysqlString.SAVEROLEDATA_FRIEND, info.playerid, friend.friendtype, friend.friendid, friend.friendname); bSave = true; } if (!bSave) { continue; } command = new MySqlCommand(sql, MysqlConn.GetConn()); MysqlConn.Conn_Open(); command.ExecuteNonQuery(); MysqlConn.Conn_Close(); command.Dispose(); } }
// public void SetFriendTarget(uint typeid) // { // mTargetId = typeid; // } //public uint GetFriendTarget() { return mTargetId; } //添加好友 public void AddFriend(uint playerid,byte type,bool party =true) { PlayerObject target = UserEngine.Instance().FindPlayerObjectToPlayerId((int)playerid); if (target == null) return; for (int i = 0; i < mList.Count; i++) { if (mList[i].friendid == (uint)target.GetBaseAttr().player_id && mList[i].friendtype == type) { if (mList[i].id != -1) //删除标识 { return; } else { mList.RemoveAt(i); break; } } } play.LeftNotice(string.Format("{0},{1}锸血为盟,宣誓从此将生死与共,永不背叛!", play.GetName(), target.GetName())); RoleData_Friend friend = new RoleData_Friend(); friend.id = 0; friend.friendid = (uint)target.GetBaseAttr().player_id; friend.friendtype = type; friend.friendname = target.GetName(); mList.Add(friend); SendFriendInfo(friend); if (party) { target.GetFriendSystem().AddFriend((uint)play.GetBaseAttr().player_id, type, false); } }
public void Create(byte[] msg) { PackIn inpack = new PackIn(msg); inpack.ReadUInt16(); playerid = inpack.ReadInt32(); key = inpack.ReadInt32(); key2 = inpack.ReadInt32(); int count = inpack.ReadInt32(); for (int i = 0; i < count; i++) { RoleData_Friend item = new RoleData_Friend(); item.Create(null, inpack); list_item.Add(item); } }
public static void LoadRoleData_Friend(GameBase.Network.Internal.ROLEDATA_FRIEND info) { MySqlCommand command; String _key = String.Format(MysqlString.LOADROLEDATA_FRIEND, info.playerid); command = new MySqlCommand(_key, MysqlConn.GetConn()); MysqlConn.Conn_Open(); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { if (!reader.HasRows) break; GameBase.Network.Internal.RoleData_Friend friend = new GameBase.Network.Internal.RoleData_Friend(); friend.id = reader.GetInt32("id"); friend.friendid = reader.GetUInt32("friendid"); friend.friendname = reader.GetString("friendname"); friend.friendname = Coding.Latin1ToGB2312(friend.friendname); friend.friendtype = reader.GetByte("friendtype"); info.list_item.Add(friend); } MysqlConn.Conn_Close(); command.Dispose(); }
public void SendFriendInfo(RoleData_Friend info, byte type = NetMsg.MsgFriendInfo.TYPE_FRIEND) { NetMsg.MsgFriendInfo data = new NetMsg.MsgFriendInfo(); data.Create(null, play.GetGamePackKeyEx()); data.playerid = info.friendid; data.type = type; data.name = info.friendname; PlayerObject obj = UserEngine.Instance().FindPlayerObjectToPlayerId((int)info.friendid); if (obj != null) { data.Online = 1; data.level = obj.GetBaseAttr().level; data.fightpower = (uint)obj.GetFightSoul(); } play.SendData(data.GetBuffer()); }