fix 好友申请列表
This commit is contained in:
parent
211283fc65
commit
b76949b468
|
|
@ -564,53 +564,6 @@ func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
logger.Logger.Tracef(">>FriendAgree %d -> %d, %v", p.SnId, destP.SnId, pack)
|
||||
}
|
||||
me := FriendMgrSingleton.GetPlayer(p.Platform, p.SnId)
|
||||
if me == nil {
|
||||
SendToClick(friend.OpResultCode_OPRC_Error)
|
||||
return
|
||||
}
|
||||
if FriendMgrSingleton.IsFriend(p.Platform, p.SnId, destP.SnId) { //已经是好友了
|
||||
SendToClick(friend.OpResultCode_OPRC_Friend_AlreadyAdd)
|
||||
return
|
||||
}
|
||||
//验证自己
|
||||
if len(me.BindFriend) >= FriendMaxNum {
|
||||
SendToClick(friend.OpResultCode_OPRC_Friend_FriendMax)
|
||||
return
|
||||
}
|
||||
|
||||
destPFriend := FriendMgrSingleton.GetPlayer(destP.Platform, destP.SnId)
|
||||
if destPFriend != nil {
|
||||
if len(destPFriend.BindFriend) >= FriendMaxNum {
|
||||
SendToClick(friend.OpResultCode_OPRC_Friend_DestFriendMax)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var friendDB *model.Friend // 申请者好友列表
|
||||
var err error
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
if destPFriend == nil {
|
||||
// 不在线
|
||||
friendDB, err = model.QueryFriendBySnid(destP.Platform, destP.SnId)
|
||||
if err != nil {
|
||||
logger.Logger.Error("QueryFriendBySnid:", err, destP.SnId)
|
||||
return friend.OpResultCode_OPRC_Error
|
||||
}
|
||||
if friendDB == nil || friendDB.SnId != destP.SnId {
|
||||
friendDB = model.NewFriend(destP.Platform, destP.SnId)
|
||||
}
|
||||
|
||||
if len(friendDB.BindFriend) >= FriendMaxNum {
|
||||
return friend.OpResultCode_OPRC_Friend_FriendMax
|
||||
}
|
||||
|
||||
for _, v := range friendDB.BindFriend {
|
||||
if v.SnId == p.SnId {
|
||||
return friend.OpResultCode_OPRC_Friend_AlreadyAdd
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 删除申请者的申请列表
|
||||
delApplyListFunc := func(plt string, snid int32, applySnid int32) friend.OpResultCode {
|
||||
|
|
@ -660,6 +613,61 @@ func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
|||
return friend.OpResultCode_OPRC_Sucess
|
||||
}
|
||||
|
||||
me := FriendMgrSingleton.GetPlayer(p.Platform, p.SnId)
|
||||
if me == nil {
|
||||
SendToClick(friend.OpResultCode_OPRC_Error)
|
||||
return
|
||||
}
|
||||
if FriendMgrSingleton.IsFriend(p.Platform, p.SnId, destP.SnId) { //已经是好友了
|
||||
// 删除申请者的申请列表
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
delApplyListFunc(p.Platform, p.SnId, destP.SnId)
|
||||
delApplyListFunc(p.Platform, destP.SnId, p.SnId)
|
||||
return nil
|
||||
}), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) {
|
||||
SendToClick(friend.OpResultCode_OPRC_Friend_AlreadyAdd)
|
||||
})).StartByFixExecutor(FriendWrite)
|
||||
return
|
||||
}
|
||||
//验证自己
|
||||
if len(me.BindFriend) >= FriendMaxNum {
|
||||
SendToClick(friend.OpResultCode_OPRC_Friend_FriendMax)
|
||||
return
|
||||
}
|
||||
|
||||
destPFriend := FriendMgrSingleton.GetPlayer(destP.Platform, destP.SnId)
|
||||
if destPFriend != nil {
|
||||
if len(destPFriend.BindFriend) >= FriendMaxNum {
|
||||
SendToClick(friend.OpResultCode_OPRC_Friend_DestFriendMax)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var friendDB *model.Friend // 申请者好友列表
|
||||
var err error
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
if destPFriend == nil {
|
||||
// 不在线
|
||||
friendDB, err = model.QueryFriendBySnid(destP.Platform, destP.SnId)
|
||||
if err != nil {
|
||||
logger.Logger.Error("QueryFriendBySnid:", err, destP.SnId)
|
||||
return friend.OpResultCode_OPRC_Error
|
||||
}
|
||||
if friendDB == nil || friendDB.SnId != destP.SnId {
|
||||
friendDB = model.NewFriend(destP.Platform, destP.SnId)
|
||||
}
|
||||
|
||||
if len(friendDB.BindFriend) >= FriendMaxNum {
|
||||
return friend.OpResultCode_OPRC_Friend_FriendMax
|
||||
}
|
||||
|
||||
for _, v := range friendDB.BindFriend {
|
||||
if v.SnId == p.SnId {
|
||||
return friend.OpResultCode_OPRC_Friend_AlreadyAdd
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//查看是否在申请列表
|
||||
code := delApplyListFunc(p.Platform, p.SnId, destP.SnId)
|
||||
if code != friend.OpResultCode_OPRC_Sucess {
|
||||
|
|
|
|||
Loading…
Reference in New Issue