通过删除重复添加同一个好友,会重复触发好友体力,造成刷体力的情况
This commit is contained in:
parent
25cfbf30a2
commit
87aef36237
@ -757,7 +757,7 @@ func (ad *GameLogic) RegisterNetWorkFunc() {
|
|||||||
RegisterMsgProcessFunc("ReqFriendTimeLine", ReqFriendTimeLine) // 请求好友时间线
|
RegisterMsgProcessFunc("ReqFriendTimeLine", ReqFriendTimeLine) // 请求好友时间线
|
||||||
RegisterMsgProcessFunc("ReqFriendRecommend", ReqFriendRecommend) // 获取推荐好友
|
RegisterMsgProcessFunc("ReqFriendRecommend", ReqFriendRecommend) // 获取推荐好友
|
||||||
RegisterMsgProcessFunc("ReqFriendTLUpvote", ReqFriendTLUpvote) // 请求时间线点赞
|
RegisterMsgProcessFunc("ReqFriendTLUpvote", ReqFriendTLUpvote) // 请求时间线点赞
|
||||||
RegisterMsgProcessFunc("ReqFriendTReward", ReqFriendTReward) // 请求时间线点赞
|
RegisterMsgProcessFunc("ReqFriendTReward", ReqFriendTReward) // 获取时间线奖励
|
||||||
RegisterMsgProcessFunc("ReqAddNpc", ReqAddNpc) // 增加npc
|
RegisterMsgProcessFunc("ReqAddNpc", ReqAddNpc) // 增加npc
|
||||||
RegisterMsgProcessFunc("ReqWishApply", ReqWishApply) // 同意好友心愿单请求
|
RegisterMsgProcessFunc("ReqWishApply", ReqWishApply) // 同意好友心愿单请求
|
||||||
RegisterMsgProcessFunc("ReqFriendByCode", ReqFriendByCode) // 根据邀请码查询好友
|
RegisterMsgProcessFunc("ReqFriendByCode", ReqFriendByCode) // 根据邀请码查询好友
|
||||||
|
|||||||
@ -54,6 +54,7 @@ type BubbleInfo struct {
|
|||||||
|
|
||||||
type FriendInfo struct {
|
type FriendInfo struct {
|
||||||
AddTime int64
|
AddTime int64
|
||||||
|
DelTime int64
|
||||||
Interact []*Interact // 拜访记录
|
Interact []*Interact // 拜访记录
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,6 +277,7 @@ func (f *FriendMod) GetAddTime(id int) int64 {
|
|||||||
func (f *FriendMod) AddFriend(id int) {
|
func (f *FriendMod) AddFriend(id int) {
|
||||||
f.NewFriendList[id] = &FriendInfo{
|
f.NewFriendList[id] = &FriendInfo{
|
||||||
AddTime: GoUtil.Now(),
|
AddTime: GoUtil.Now(),
|
||||||
|
DelTime: 0,
|
||||||
}
|
}
|
||||||
delete(f.ApplyList, id)
|
delete(f.ApplyList, id)
|
||||||
}
|
}
|
||||||
@ -297,12 +299,15 @@ func (f *FriendMod) DelCardInfo(Id string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendMod) DelFriend(id int) {
|
func (f *FriendMod) DelFriend(id int) {
|
||||||
delete(f.NewFriendList, id)
|
f.NewFriendList[id].DelTime = GoUtil.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendMod) CheckFriend(Uid int) bool {
|
func (f *FriendMod) CheckFriend(Uid int) bool {
|
||||||
_, ok := f.NewFriendList[Uid]
|
_, ok := f.NewFriendList[Uid]
|
||||||
return ok
|
if !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return f.NewFriendList[Uid].DelTime == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendMod) RefuseApply(id int) {
|
func (f *FriendMod) RefuseApply(id int) {
|
||||||
@ -315,19 +320,38 @@ func (f *FriendMod) CheckApply(id int) bool {
|
|||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
func (f *FriendMod) GetFriendNum() int {
|
func (f *FriendMod) GetFriendNum() int {
|
||||||
return len(f.NewFriendList)
|
i := 0
|
||||||
|
for _, v := range f.NewFriendList {
|
||||||
|
if v.DelTime == 0 {
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return i
|
||||||
}
|
}
|
||||||
func (f *FriendMod) GetFriendList() map[int]*FriendInfo {
|
func (f *FriendMod) GetFriendList() map[int]*FriendInfo {
|
||||||
return f.NewFriendList
|
res := make(map[int]*FriendInfo)
|
||||||
|
for k, v := range f.NewFriendList {
|
||||||
|
if v.DelTime == 0 {
|
||||||
|
res[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendMod) GetSimpleFriendList() []int {
|
func (f *FriendMod) GetSimpleFriendList() []int {
|
||||||
rs := make([]int, 0, len(f.NewFriendList))
|
rs := make([]int, 0, len(f.NewFriendList))
|
||||||
for k := range f.NewFriendList {
|
for k, v := range f.NewFriendList {
|
||||||
|
if v.DelTime != 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
rs = append(rs, k)
|
rs = append(rs, k)
|
||||||
}
|
}
|
||||||
return rs
|
return rs
|
||||||
}
|
}
|
||||||
|
func (f *FriendMod) CheckAddBefore(uid int) bool {
|
||||||
|
_, ok := f.NewFriendList[uid]
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
// 收到申请
|
// 收到申请
|
||||||
func (f *FriendMod) AddFriendApply(Uid int) bool {
|
func (f *FriendMod) AddFriendApply(Uid int) bool {
|
||||||
|
|||||||
@ -1928,15 +1928,12 @@ func ReqAgreeFriend(player *Player, buf []byte) error {
|
|||||||
})
|
})
|
||||||
return fmt.Errorf("apply uid not exist")
|
return fmt.Errorf("apply uid not exist")
|
||||||
}
|
}
|
||||||
m := &MsqMod.Msg{
|
|
||||||
Type: MsqMod.HADNLE_TYPE_AGREE,
|
// 新好友才可以打招呼
|
||||||
From: int(player.M_DwUin),
|
if !FriendMod.CheckAddBefore(Uid) {
|
||||||
To: Uid,
|
FriendMod.AddReplyInfo(Uid, friend.REPLY_TYPE_GREETING, "", GoUtil.Now()+24*3600, nil)
|
||||||
SendT: GoUtil.Now(),
|
|
||||||
}
|
}
|
||||||
FriendMgrSend(m)
|
|
||||||
FriendMod.AddFriend(Uid)
|
FriendMod.AddFriend(Uid)
|
||||||
FriendMod.AddReplyInfo(Uid, friend.REPLY_TYPE_GREETING, "", GoUtil.Now()+24*3600, nil)
|
|
||||||
player.PushClientRes(&msg.ResAgreeFriend{
|
player.PushClientRes(&msg.ResAgreeFriend{
|
||||||
Code: msg.RES_CODE_SUCCESS,
|
Code: msg.RES_CODE_SUCCESS,
|
||||||
Uid: req.Uid,
|
Uid: req.Uid,
|
||||||
@ -1947,6 +1944,13 @@ func ReqAgreeFriend(player *Player, buf []byte) error {
|
|||||||
"add_type": "接受申请",
|
"add_type": "接受申请",
|
||||||
})
|
})
|
||||||
player.AddLog(Uid, friend.LOG_TYPE_FRIEND_BECOME, "", GoUtil.Now())
|
player.AddLog(Uid, friend.LOG_TYPE_FRIEND_BECOME, "", GoUtil.Now())
|
||||||
|
m := &MsqMod.Msg{
|
||||||
|
Type: MsqMod.HADNLE_TYPE_AGREE,
|
||||||
|
From: int(player.M_DwUin),
|
||||||
|
To: Uid,
|
||||||
|
SendT: GoUtil.Now(),
|
||||||
|
}
|
||||||
|
FriendMgrSend(m)
|
||||||
player.FriendApplyBackData()
|
player.FriendApplyBackData()
|
||||||
player.FriendLogBackData()
|
player.FriendLogBackData()
|
||||||
player.PlayMod.save()
|
player.PlayMod.save()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user