添加好友优化
This commit is contained in:
parent
23c232d0d3
commit
bd792c72b8
@ -477,6 +477,42 @@ func (ad *GameLogic) GetResSimplePlayerByUid(Id int) *msg.ResPlayerSimple {
|
||||
}
|
||||
}
|
||||
|
||||
func (ad *GameLogic) GetResFriendPlayerByUid(Id int) *msg.ResFriendPlayerSimple {
|
||||
Idstr := strconv.Itoa(Id)
|
||||
Value, _ := db.RedisGetKey(Idstr)
|
||||
player := &PlayerSimpleData{}
|
||||
player.Uid = Id
|
||||
if Value == "" {
|
||||
p := new(Player)
|
||||
err := p.GetSimpleData(Id, player)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
value, _ := json.Marshal(player)
|
||||
db.RedisSetKey(Idstr, string(value), 0)
|
||||
} else {
|
||||
err := json.Unmarshal([]byte(Value), player)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return &msg.ResFriendPlayerSimple{
|
||||
Uid: int64(player.Uid),
|
||||
Name: player.Name,
|
||||
Level: int32(player.Level),
|
||||
Avatar: int32(player.Avatar),
|
||||
Face: int32(player.Face),
|
||||
Decorate: int32(player.Decorate),
|
||||
Login: int32(player.Login),
|
||||
Loginout: int32(player.Loginout),
|
||||
Emoji: GoUtil.MapIntToInt32(player.Emoji),
|
||||
Facebook: player.FaceBook,
|
||||
Playroom: GoUtil.MapIntToInt32(player.Playroom),
|
||||
DressSet: GoUtil.MapIntToInt32(player.DressSet),
|
||||
Friend: GoUtil.IntToInt32(player.Friend),
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化服务器协程
|
||||
func G_getGameLogic() *GameLogic {
|
||||
if !isInitGameLogic {
|
||||
@ -669,6 +705,7 @@ func (ad *GameLogic) RegisterNetWorkFunc() {
|
||||
|
||||
RegisterMsgProcessFunc("ReqRemoveAd", ReqRemoveAdFunc)
|
||||
RegisterMsgProcessFunc("ReqPlayerBriefProfileData", ReqPlayerBriefProfileDataFunc)
|
||||
RegisterMsgProcessFunc("ReqFriendPlayerSimple", ReqFriendPlayerSimple)
|
||||
// RegisterMsgProcessFunc("ReqOfflineReconnect", ReqOfflineReconnectFunc)
|
||||
RegisterMsgProcessFunc("ReqPlayerAsset", ReqPlayerAsset)
|
||||
RegisterMsgProcessFunc("ReqId2Verify", ReqId2Verify) // 身份证验证
|
||||
|
||||
@ -964,6 +964,7 @@ func (p *Player) UpdateUserInfo() {
|
||||
simple.Upvote = p.PlayMod.getPlayroomMod().Upvote
|
||||
simple.DressSet = p.PlayMod.getPlayroomMod().DressSet
|
||||
simple.CardInfo = CardMod.GetCardList()
|
||||
simple.ActLog = p.PlayMod.getFriendMod().GetActLogLast()
|
||||
value, _ := json.Marshal(simple)
|
||||
IdStr := strconv.Itoa(int(p.M_DwUin))
|
||||
db.RedisSetKey(IdStr, string(value), 0)
|
||||
|
||||
@ -79,6 +79,26 @@ func ReqPlayerBriefProfileDataFunc(player *Player, buf []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func ReqFriendPlayerSimple(player *Player, buf []byte) error {
|
||||
detail := &msg.ReqFriendPlayerSimple{}
|
||||
proto.Unmarshal(buf, detail)
|
||||
Uid := int(detail.Uid)
|
||||
PlayerSimpleData := G_GameLogicPtr.GetResFriendPlayerByUid(Uid)
|
||||
if PlayerSimpleData == nil {
|
||||
log.Debug("玩家不存在, Uid:%d", Uid)
|
||||
}
|
||||
FriendMod := player.PlayMod.getFriendMod()
|
||||
PlayerSimpleData.AddTime = FriendMod.GetAddTime(Uid)
|
||||
PlayerSimpleData.Interact = FriendMod.GetInteractTime(Uid)
|
||||
LastActLog := FriendMod.GetActLogLast()
|
||||
PlayerSimpleData.Last = &msg.ActLog{
|
||||
Type: int32(LastActLog.Type),
|
||||
Time: LastActLog.Time,
|
||||
Param: LastActLog.Param,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 移除广告
|
||||
func ReqRemoveAdFunc(player *Player, buf []byte) error {
|
||||
player.PlayerBaseMod.ReqRemoveAd(player, buf)
|
||||
@ -1698,7 +1718,6 @@ func ReqSearchPlayer(player *Player, buf []byte) error {
|
||||
player.PushClientRes(&msg.ResSearchPlayer{
|
||||
List: l2,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package game
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"server/game/mod/friend"
|
||||
"server/game/mod/limitedTimeEvent"
|
||||
"server/game/mod/msg"
|
||||
)
|
||||
@ -28,6 +29,7 @@ type PlayerSimpleData struct {
|
||||
Upvote int
|
||||
DressSet map[int]int
|
||||
CardInfo []int
|
||||
ActLog *friend.ActLogInfo
|
||||
}
|
||||
|
||||
type VarGoldCard struct {
|
||||
|
||||
@ -226,6 +226,13 @@ func (f *FriendMod) GetInteractTime(id int) int64 {
|
||||
return LastTime
|
||||
}
|
||||
|
||||
func (f *FriendMod) GetAddTime(id int) int64 {
|
||||
if _, ok := f.NewFriendList[id]; !ok {
|
||||
return 0
|
||||
}
|
||||
return f.NewFriendList[id].AddTime
|
||||
}
|
||||
|
||||
func (f *FriendMod) AddFriend(id int) {
|
||||
f.NewFriendList[id] = &FriendInfo{
|
||||
AddTime: GoUtil.Now(),
|
||||
@ -457,3 +464,7 @@ func (f *FriendMod) ApplyWish(Uid int64) error {
|
||||
}
|
||||
return fmt.Errorf("wish apply not exist")
|
||||
}
|
||||
|
||||
func (f *FriendMod) GetActLogLast() *ActLogInfo {
|
||||
return f.ActivityLog[len(f.ActivityLog)-1]
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user