通过删除重复添加同一个好友,会重复触发好友体力,造成刷体力的情况

This commit is contained in:
hahwu 2026-02-03 17:40:08 +08:00
parent 25cfbf30a2
commit 87aef36237
3 changed files with 41 additions and 13 deletions

View File

@ -757,7 +757,7 @@ func (ad *GameLogic) RegisterNetWorkFunc() {
RegisterMsgProcessFunc("ReqFriendTimeLine", ReqFriendTimeLine) // 请求好友时间线
RegisterMsgProcessFunc("ReqFriendRecommend", ReqFriendRecommend) // 获取推荐好友
RegisterMsgProcessFunc("ReqFriendTLUpvote", ReqFriendTLUpvote) // 请求时间线点赞
RegisterMsgProcessFunc("ReqFriendTReward", ReqFriendTReward) // 请求时间线点赞
RegisterMsgProcessFunc("ReqFriendTReward", ReqFriendTReward) // 获取时间线奖励
RegisterMsgProcessFunc("ReqAddNpc", ReqAddNpc) // 增加npc
RegisterMsgProcessFunc("ReqWishApply", ReqWishApply) // 同意好友心愿单请求
RegisterMsgProcessFunc("ReqFriendByCode", ReqFriendByCode) // 根据邀请码查询好友

View File

@ -54,6 +54,7 @@ type BubbleInfo struct {
type FriendInfo struct {
AddTime int64
DelTime int64
Interact []*Interact // 拜访记录
}
@ -276,6 +277,7 @@ func (f *FriendMod) GetAddTime(id int) int64 {
func (f *FriendMod) AddFriend(id int) {
f.NewFriendList[id] = &FriendInfo{
AddTime: GoUtil.Now(),
DelTime: 0,
}
delete(f.ApplyList, id)
}
@ -297,12 +299,15 @@ func (f *FriendMod) DelCardInfo(Id string) {
}
func (f *FriendMod) DelFriend(id int) {
delete(f.NewFriendList, id)
f.NewFriendList[id].DelTime = GoUtil.Now()
}
func (f *FriendMod) CheckFriend(Uid int) bool {
_, ok := f.NewFriendList[Uid]
return ok
if !ok {
return false
}
return f.NewFriendList[Uid].DelTime == 0
}
func (f *FriendMod) RefuseApply(id int) {
@ -315,19 +320,38 @@ func (f *FriendMod) CheckApply(id int) bool {
return ok
}
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 {
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 {
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)
}
return rs
}
func (f *FriendMod) CheckAddBefore(uid int) bool {
_, ok := f.NewFriendList[uid]
return ok
}
// 收到申请
func (f *FriendMod) AddFriendApply(Uid int) bool {

View File

@ -1928,15 +1928,12 @@ func ReqAgreeFriend(player *Player, buf []byte) error {
})
return fmt.Errorf("apply uid not exist")
}
m := &MsqMod.Msg{
Type: MsqMod.HADNLE_TYPE_AGREE,
From: int(player.M_DwUin),
To: Uid,
SendT: GoUtil.Now(),
// 新好友才可以打招呼
if !FriendMod.CheckAddBefore(Uid) {
FriendMod.AddReplyInfo(Uid, friend.REPLY_TYPE_GREETING, "", GoUtil.Now()+24*3600, nil)
}
FriendMgrSend(m)
FriendMod.AddFriend(Uid)
FriendMod.AddReplyInfo(Uid, friend.REPLY_TYPE_GREETING, "", GoUtil.Now()+24*3600, nil)
player.PushClientRes(&msg.ResAgreeFriend{
Code: msg.RES_CODE_SUCCESS,
Uid: req.Uid,
@ -1947,6 +1944,13 @@ func ReqAgreeFriend(player *Player, buf []byte) error {
"add_type": "接受申请",
})
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.FriendLogBackData()
player.PlayMod.save()