Merge branch 'develop' of git.pogorockgames.com:mango-games/server/game into develop
This commit is contained in:
commit
86bbeb8c9b
|
@ -14,6 +14,12 @@ default:
|
|||
tags:
|
||||
- gitlab
|
||||
|
||||
cache:
|
||||
key: ${CI_COMMIT_REF_SLUG}
|
||||
paths:
|
||||
- ${GOPATH}/pkg/mod
|
||||
- ${GOPATH}/bin
|
||||
|
||||
# 锁定作业,防止并发流水线执行
|
||||
lock_job:
|
||||
stage: lock
|
||||
|
|
|
@ -42,7 +42,7 @@ func Register(key string, msgType interface{}, f func(ctx context.Context, compl
|
|||
logger.Logger.Errorf("ETCD %v proto.Unmarshal error:%v", key, err)
|
||||
continue
|
||||
}
|
||||
logger.Logger.Tracef("ETCD 拉取成功 %v ==> %v", string(res.Kvs[i].Key), d)
|
||||
logger.Logger.Debugf("ETCD 拉取成功 %v ==> %v", string(res.Kvs[i].Key), d)
|
||||
event := &clientv3.Event{
|
||||
Type: 0,
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ func Register(key string, msgType interface{}, f func(ctx context.Context, compl
|
|||
logger.Logger.Errorf("ETCD %v josn.Unmarshal error:%v", key, err)
|
||||
continue
|
||||
}
|
||||
logger.Logger.Tracef("ETCD 拉取成功 %v ==> %v", string(res.Kvs[i].Key), d)
|
||||
logger.Logger.Debugf("ETCD 拉取成功 %v ==> %v", string(res.Kvs[i].Key), d)
|
||||
event := &clientv3.Event{
|
||||
Type: 0,
|
||||
}
|
||||
|
|
|
@ -505,13 +505,21 @@ func (this *ScenePolicyFortuneDragon) GetSceneState(s *base.Scene, stateid int)
|
|||
func FortuneDragonAndSaveLog(sceneEx *FortuneDragonSceneData, playerEx *FortuneDragonPlayerData, data assemble.GameEnd) {
|
||||
if !playerEx.IsRob {
|
||||
data.SnId = playerEx.SnId
|
||||
if data.Results[0].FreeStatus != 1 && data.Results[0].FreeNumMax != 0 {
|
||||
data.TotalBet = 0
|
||||
}
|
||||
info, err := model.MarshalGameNoteByROLL(data)
|
||||
if err == nil {
|
||||
logid, _ := model.AutoIncGameLogId()
|
||||
playerEx.currentLogId = logid
|
||||
sceneEx.SaveGameDetailedLog(logid, info, &base.GameDetailedParam{})
|
||||
totalin := playerEx.totalBet
|
||||
totalout := int64(data.RoundReward) + playerEx.taxCoin
|
||||
var totalin, totalout int64
|
||||
if data.Results[0].FreeStatus == 1 || data.Results[0].FreeNumMax == 0 {
|
||||
totalin = playerEx.totalBet
|
||||
}
|
||||
if data.Results[0].FreeStatus == 3 || data.Results[0].FreeNumMax == 0 {
|
||||
totalout = int64(data.RoundReward) + playerEx.taxCoin
|
||||
}
|
||||
validFlow := totalin + totalout
|
||||
validBet := common.AbsI64(totalin - totalout)
|
||||
logParam := &base.SaveGamePlayerListLogParam{
|
||||
|
@ -524,8 +532,8 @@ func FortuneDragonAndSaveLog(sceneEx *FortuneDragonSceneData, playerEx *FortuneD
|
|||
TotalIn: totalin,
|
||||
TotalOut: totalout,
|
||||
TaxCoin: playerEx.taxCoin,
|
||||
BetAmount: playerEx.totalBet,
|
||||
WinAmountNoAnyTax: int64(data.RoundReward) + playerEx.taxCoin,
|
||||
BetAmount: totalin,
|
||||
WinAmountNoAnyTax: totalout - totalin - playerEx.taxCoin,
|
||||
ValidBet: validBet,
|
||||
ValidFlow: validFlow,
|
||||
IsFirstGame: sceneEx.IsPlayerFirst(playerEx.Player),
|
||||
|
|
|
@ -510,13 +510,21 @@ func (this *ScenePolicyFortuneOx) GetSceneState(s *base.Scene, stateid int) base
|
|||
func FortuneOxAndSaveLog(sceneEx *FortuneOxSceneData, playerEx *FortuneOxPlayerData, data assemble.GameEnd) {
|
||||
if !playerEx.IsRob {
|
||||
data.SnId = playerEx.SnId
|
||||
if data.Results[0].FreeStatus != 1 && data.Results[0].FreeNumMax != 0 {
|
||||
data.TotalBet = 0
|
||||
}
|
||||
info, err := model.MarshalGameNoteByROLL(data)
|
||||
if err == nil {
|
||||
logid, _ := model.AutoIncGameLogId()
|
||||
playerEx.currentLogId = logid
|
||||
sceneEx.SaveGameDetailedLog(logid, info, &base.GameDetailedParam{})
|
||||
totalin := playerEx.totalBet
|
||||
totalout := int64(data.RoundReward) + playerEx.taxCoin
|
||||
var totalin, totalout int64
|
||||
if data.Results[0].FreeStatus == 1 || data.Results[0].FreeNumMax == 0 {
|
||||
totalin = playerEx.totalBet
|
||||
}
|
||||
if data.Results[0].FreeStatus == 3 || data.Results[0].FreeNumMax == 0 {
|
||||
totalout = int64(data.RoundReward) + playerEx.taxCoin
|
||||
}
|
||||
validFlow := totalin + totalout
|
||||
validBet := common.AbsI64(totalin - totalout)
|
||||
logParam := &base.SaveGamePlayerListLogParam{
|
||||
|
@ -530,7 +538,7 @@ func FortuneOxAndSaveLog(sceneEx *FortuneOxSceneData, playerEx *FortuneOxPlayerD
|
|||
TotalOut: totalout,
|
||||
TaxCoin: playerEx.taxCoin,
|
||||
BetAmount: playerEx.totalBet,
|
||||
WinAmountNoAnyTax: int64(data.RoundReward) + playerEx.taxCoin,
|
||||
WinAmountNoAnyTax: totalout - totalin - playerEx.taxCoin,
|
||||
ValidBet: validBet,
|
||||
ValidFlow: validFlow,
|
||||
IsFirstGame: sceneEx.IsPlayerFirst(playerEx.Player),
|
||||
|
|
|
@ -504,13 +504,21 @@ func (this *ScenePolicyFortuneRabbit) GetSceneState(s *base.Scene, stateid int)
|
|||
func FortuneRabbitAndSaveLog(sceneEx *FortuneRabbitSceneData, playerEx *FortuneRabbitPlayerData, data assemble.GameEnd) {
|
||||
if !playerEx.IsRob {
|
||||
data.SnId = playerEx.SnId
|
||||
if data.Results[0].FreeStatus != 1 && data.Results[0].FreeNumMax != 0 {
|
||||
data.TotalBet = 0
|
||||
}
|
||||
info, err := model.MarshalGameNoteByROLL(data)
|
||||
if err == nil {
|
||||
logid, _ := model.AutoIncGameLogId()
|
||||
playerEx.currentLogId = logid
|
||||
sceneEx.SaveGameDetailedLog(logid, info, &base.GameDetailedParam{})
|
||||
totalin := playerEx.totalBet
|
||||
totalout := int64(data.RoundReward) + playerEx.taxCoin
|
||||
var totalin, totalout int64
|
||||
if data.Results[0].FreeStatus == 1 || data.Results[0].FreeNumMax == 0 {
|
||||
totalin = playerEx.totalBet
|
||||
}
|
||||
if data.Results[0].FreeStatus == 3 || data.Results[0].FreeNumMax == 0 {
|
||||
totalout = int64(data.RoundReward) + playerEx.taxCoin
|
||||
}
|
||||
validFlow := totalin + totalout
|
||||
validBet := common.AbsI64(totalin - totalout)
|
||||
logParam := &base.SaveGamePlayerListLogParam{
|
||||
|
@ -524,7 +532,7 @@ func FortuneRabbitAndSaveLog(sceneEx *FortuneRabbitSceneData, playerEx *FortuneR
|
|||
TotalOut: totalout,
|
||||
TaxCoin: playerEx.taxCoin,
|
||||
BetAmount: playerEx.totalBet,
|
||||
WinAmountNoAnyTax: int64(data.RoundReward) + playerEx.taxCoin,
|
||||
WinAmountNoAnyTax: totalout - totalin - playerEx.taxCoin,
|
||||
ValidBet: validBet,
|
||||
ValidFlow: validFlow,
|
||||
IsFirstGame: sceneEx.IsPlayerFirst(playerEx.Player),
|
||||
|
|
|
@ -507,13 +507,21 @@ func (this *ScenePolicyFortuneTiger) GetSceneState(s *base.Scene, stateid int) b
|
|||
func FortuneTigerAndSaveLog(sceneEx *FortuneTigerSceneData, playerEx *FortuneTigerPlayerData, data assemble.GameEnd) {
|
||||
if !playerEx.IsRob {
|
||||
data.SnId = playerEx.SnId
|
||||
if data.Results[0].FreeStatus != 1 && data.Results[0].FreeNumMax != 0 {
|
||||
data.TotalBet = 0
|
||||
}
|
||||
info, err := model.MarshalGameNoteByROLL(data)
|
||||
if err == nil {
|
||||
logid, _ := model.AutoIncGameLogId()
|
||||
playerEx.currentLogId = logid
|
||||
sceneEx.SaveGameDetailedLog(logid, info, &base.GameDetailedParam{})
|
||||
totalin := playerEx.totalBet
|
||||
totalout := int64(data.RoundReward) + playerEx.taxCoin
|
||||
var totalin, totalout int64
|
||||
if data.Results[0].FreeStatus == 1 || data.Results[0].FreeNumMax == 0 {
|
||||
totalin = playerEx.totalBet
|
||||
}
|
||||
if data.Results[0].FreeStatus == 3 || data.Results[0].FreeNumMax == 0 {
|
||||
totalout = int64(data.RoundReward) + playerEx.taxCoin
|
||||
}
|
||||
validFlow := totalin + totalout
|
||||
validBet := common.AbsI64(totalin - totalout)
|
||||
logParam := &base.SaveGamePlayerListLogParam{
|
||||
|
@ -527,7 +535,7 @@ func FortuneTigerAndSaveLog(sceneEx *FortuneTigerSceneData, playerEx *FortuneTig
|
|||
TotalOut: totalout,
|
||||
TaxCoin: playerEx.taxCoin,
|
||||
BetAmount: playerEx.totalBet,
|
||||
WinAmountNoAnyTax: int64(data.RoundReward) + playerEx.taxCoin,
|
||||
WinAmountNoAnyTax: totalout - totalin - playerEx.taxCoin,
|
||||
ValidBet: validBet,
|
||||
ValidFlow: validFlow,
|
||||
IsFirstGame: sceneEx.IsPlayerFirst(playerEx.Player),
|
||||
|
|
|
@ -1136,20 +1136,26 @@ func (this *StateShow) OnEnter(s *base.Scene) {
|
|||
sceneEx.specialTime = 0
|
||||
// pk动画 2秒
|
||||
sceneEx.specialTime += time.Second * 2
|
||||
// 2人且有特殊牌型,直接播放特殊牌型动画'
|
||||
var n int // 玩家数量
|
||||
var has bool // 是否有青龙
|
||||
// 2人且有特殊牌型,直接播放特殊牌型动画
|
||||
var n int // 玩家数量
|
||||
var has bool // 是否有青龙
|
||||
var hasDP bool // 是否有倒水
|
||||
for _, v := range sceneEx.players {
|
||||
if v != nil && v.IsGameing() && v.cardsO != nil {
|
||||
n++
|
||||
if v.cardsO.PokerType == 1 { // 有青龙
|
||||
has = true
|
||||
}
|
||||
if v.isDP {
|
||||
hasDP = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
normalNum := n - sceneEx.specialTypeNum
|
||||
|
||||
if hasDP {
|
||||
sceneEx.specialTime += time.Second
|
||||
}
|
||||
if normalNum > 1 {
|
||||
sceneEx.specialTime += time.Second * time.Duration(5)
|
||||
}
|
||||
|
|
|
@ -209,7 +209,7 @@ type ThirteenWaterPerson struct {
|
|||
EndName string // 尾墩牌型名称
|
||||
SpecialName string // 特殊牌型名称
|
||||
IsDP bool // 是否倒排
|
||||
TestLog []string
|
||||
TestLog []string `json:"-"`
|
||||
}
|
||||
|
||||
// 二人麻将
|
||||
|
@ -1554,13 +1554,13 @@ type TienLenPerson struct {
|
|||
DelOrderCards map[int][]int32 //已出牌
|
||||
CardInfoEnd []int32 //结算时的牌型
|
||||
IsTianHu bool //是否天胡
|
||||
TestLog []string
|
||||
WinRankScore int64 // 排位积分变化(包含额外加分)
|
||||
RankScore int64 // 排位积分
|
||||
AddScore int64 // 排位积额外加分
|
||||
BombRankScore int64 // 排位炸弹分
|
||||
CardsScore int // 手牌分
|
||||
FaPaiType int // 发牌类型
|
||||
TestLog []string `json:"-"`
|
||||
WinRankScore int64 // 排位积分变化(包含额外加分)
|
||||
RankScore int64 // 排位积分
|
||||
AddScore int64 // 排位积额外加分
|
||||
BombRankScore int64 // 排位炸弹分
|
||||
CardsScore int // 手牌分
|
||||
FaPaiType int // 发牌类型
|
||||
}
|
||||
|
||||
// chesstitians
|
||||
|
|
|
@ -108,7 +108,7 @@ func (c *MessageMgr) RegisterHandler(param *RegisterHandlerParam) {
|
|||
logger.Logger.Errorf("RabbitMQ Unmarshal error: %v", err)
|
||||
return
|
||||
}
|
||||
logger.Logger.Tracef("==> Receive RabbitMQ(%v): %#v", param.Name, log)
|
||||
logger.Logger.Tracef("MQ Receive[%v]: %#v", param.Name, log)
|
||||
|
||||
return c.handler[param.Name].F(log)
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ func StopPublisher() {
|
|||
|
||||
func Send(topic string, msg interface{}, opts ...broker.PublishOption) (err error) {
|
||||
if globalPublisher != nil {
|
||||
logger.Logger.Tracef("==> RabbitMQ(%v): %#v", topic, msg)
|
||||
logger.Logger.Tracef("MQ Send[%v]: %#v", topic, msg)
|
||||
return globalPublisher.Send(topic, msg, opts...)
|
||||
}
|
||||
logger.Logger.Errorf("RabbitMQPublisher not start!")
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"mongo.games.com/game/mysql/internal"
|
||||
)
|
||||
|
||||
var NotInitError = errors.New("mysql manager is nil, please call Init() first")
|
||||
|
||||
type Config = internal.Config
|
||||
type DatabaseConfig = internal.DatabaseConfig
|
||||
type Database = internal.Database
|
||||
|
||||
var manager *internal.Manager
|
||||
|
||||
func Init(conf *Config) error {
|
||||
manager = internal.NewManager(conf)
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetAutoMigrateTables(tables []interface{}) {
|
||||
if manager == nil {
|
||||
return
|
||||
}
|
||||
manager.SetAutoMigrateTables(tables)
|
||||
}
|
||||
|
||||
func GetConfig() *Config {
|
||||
if manager == nil {
|
||||
return nil
|
||||
}
|
||||
return manager.GetConfig()
|
||||
}
|
||||
|
||||
func Close() {
|
||||
if manager == nil {
|
||||
return
|
||||
}
|
||||
manager.Close()
|
||||
}
|
||||
|
||||
func GetDatabase(platform string) (*Database, error) {
|
||||
if manager == nil {
|
||||
return nil, NotInitError
|
||||
}
|
||||
return manager.GetDatabase(platform)
|
||||
}
|
|
@ -1,150 +0,0 @@
|
|||
package internal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Platforms map[string]*DatabaseConfig
|
||||
MaxIdleConns int
|
||||
MaxOpenConns int
|
||||
ConnMaxLifetime int
|
||||
ConnMaxIdletime int
|
||||
}
|
||||
|
||||
type DatabaseConfig struct {
|
||||
HostName string
|
||||
HostPort int32
|
||||
Database string
|
||||
Username string
|
||||
Password string
|
||||
Options string
|
||||
}
|
||||
|
||||
type Database struct {
|
||||
*Manager
|
||||
*Config
|
||||
*DatabaseConfig
|
||||
*gorm.DB
|
||||
}
|
||||
|
||||
func (d *Database) Connect() error {
|
||||
if d.DatabaseConfig == nil {
|
||||
err := fmt.Errorf("mysql Connect error, DatabaseConifg not found")
|
||||
logger.Logger.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
login := ""
|
||||
if d.DatabaseConfig.Username != "" {
|
||||
login = d.DatabaseConfig.Username + ":" + d.DatabaseConfig.Password + "@"
|
||||
}
|
||||
host := d.DatabaseConfig.HostName
|
||||
if d.DatabaseConfig.HostName == "" {
|
||||
host = "127.0.0.1"
|
||||
}
|
||||
port := d.DatabaseConfig.HostPort
|
||||
if d.DatabaseConfig.HostPort == 0 {
|
||||
port = 3306
|
||||
}
|
||||
database := d.DatabaseConfig.Database
|
||||
if database == "" {
|
||||
database = "mysql"
|
||||
}
|
||||
myOptions := d.DatabaseConfig.Options
|
||||
if myOptions != "" {
|
||||
myOptions = "?" + myOptions
|
||||
}
|
||||
|
||||
// [username[:password]@][protocol[(address)]]/dbname[?param1=value1&...¶mN=valueN]
|
||||
s := fmt.Sprintf("%stcp(%s:%d)/%s%s", login, host, port, "mysql", myOptions)
|
||||
db, err := gorm.Open(mysql.Open(s), &gorm.Config{})
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql Connect %v error: %v config:%+v", s, err, *d.DatabaseConfig)
|
||||
return err
|
||||
}
|
||||
logger.Logger.Tracef("mysql connect success %+v", *d.DatabaseConfig)
|
||||
|
||||
err = db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci", d.DatabaseConfig.Database)).Error
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql create database %s error: %v", d.DatabaseConfig.Database, err)
|
||||
return err
|
||||
}
|
||||
|
||||
s = fmt.Sprintf("%stcp(%s:%d)/%s%s", login, host, port, d.DatabaseConfig.Database, myOptions)
|
||||
db, err = gorm.Open(mysql.Open(s), &gorm.Config{SkipDefaultTransaction: true})
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql Connect %v error: %v config:%+v", s, err, *d.DatabaseConfig)
|
||||
return err
|
||||
}
|
||||
|
||||
sqlDB, err := db.DB()
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql get DB error: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if len(d.tables) > 0 {
|
||||
if err := db.AutoMigrate(d.tables...); err != nil {
|
||||
logger.Logger.Warnf("mysql migrate error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
sqlDB.SetMaxIdleConns(d.MaxIdleConns)
|
||||
sqlDB.SetMaxOpenConns(d.MaxOpenConns)
|
||||
sqlDB.SetConnMaxLifetime(time.Duration(d.ConnMaxLifetime))
|
||||
sqlDB.SetConnMaxIdleTime(time.Duration(d.ConnMaxIdletime))
|
||||
|
||||
d.DB = db.Session(&gorm.Session{SkipDefaultTransaction: true})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type Manager struct {
|
||||
conf *Config
|
||||
platforms sync.Map // 平台id:Database
|
||||
tables []interface{}
|
||||
}
|
||||
|
||||
func (m *Manager) GetConfig() *Config {
|
||||
return m.conf
|
||||
}
|
||||
|
||||
func (m *Manager) SetAutoMigrateTables(tables []interface{}) {
|
||||
m.tables = tables
|
||||
}
|
||||
|
||||
func (m *Manager) GetDatabase(key string) (*Database, error) {
|
||||
v, ok := m.platforms.Load(key) // 平台id
|
||||
if !ok {
|
||||
db := &Database{
|
||||
Manager: m,
|
||||
Config: m.conf,
|
||||
DatabaseConfig: m.conf.Platforms[key],
|
||||
}
|
||||
if err := db.Connect(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v = db
|
||||
m.platforms.Store(key, v)
|
||||
}
|
||||
d, _ := v.(*Database)
|
||||
return d, nil
|
||||
}
|
||||
|
||||
func (m *Manager) Close() {
|
||||
|
||||
}
|
||||
|
||||
func NewManager(conf *Config) *Manager {
|
||||
return &Manager{
|
||||
conf: conf,
|
||||
platforms: sync.Map{},
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
mongodb库升级:
|
||||
旧的库最高只支持mongodb4.0,并且不再维护了
|
||||
|
||||
dbproxy优化:
|
||||
自动生成数据表操作代码, dao层
|
||||
自动生成rpc代码
|
||||
参考 https://go-zero.dev/ 中的goctl工具
|
||||
|
||||
消息队列数据恢复发送:
|
||||
发送失败的消息会写入本地文件,等mq正常后尝试重新发送
|
|
@ -65,15 +65,15 @@ func CSChatMsgHandler(s *netlib.Session, packetid int, data interface{}, sid int
|
|||
} else { //私聊
|
||||
FriendUnreadMgrSington.DelFriendUnread(p.Platform, p.SnId, msg.GetMsg2Snid())
|
||||
pack.Content = content
|
||||
if !FriendMgrSington.IsFriend(p.Platform, p.SnId, msg.GetMsg2Snid()) {
|
||||
if !FriendMgrSingleton.IsFriend(p.Platform, p.SnId, msg.GetMsg2Snid()) {
|
||||
pack.OpRetCode = chat.OpResultCode_OPRC_Chat_NotFriend
|
||||
logger.Logger.Warn("CSChatMsgHandler not friend")
|
||||
} else {
|
||||
if FriendMgrSington.IsShield(p.Platform, msg.GetMsg2Snid(), p.SnId) { //对方有没有屏蔽发送者
|
||||
if FriendMgrSingleton.IsShield(p.Platform, msg.GetMsg2Snid(), p.SnId) { //对方有没有屏蔽发送者
|
||||
pack.OpRetCode = chat.OpResultCode_OPRC_Chat_IsShield
|
||||
logger.Logger.Warn("CSChatMsgHandler IsShield")
|
||||
}
|
||||
if FriendMgrSington.IsShield(p.Platform, p.SnId, msg.GetMsg2Snid()) { //有没有屏蔽对方
|
||||
if FriendMgrSingleton.IsShield(p.Platform, p.SnId, msg.GetMsg2Snid()) { //有没有屏蔽对方
|
||||
pack.OpRetCode = chat.OpResultCode_OPRC_Chat_Shield
|
||||
logger.Logger.Warn("CSChatMsgHandler Shield")
|
||||
}
|
||||
|
@ -117,11 +117,11 @@ func CSGetChatLogHandler(s *netlib.Session, packetid int, data interface{}, sid
|
|||
logger.Logger.Warn("CSGetChatLogHandler platform == nil")
|
||||
return nil
|
||||
}
|
||||
if !FriendMgrSington.IsFriend(p.Platform, p.SnId, msg.GetSnid()) {
|
||||
if !FriendMgrSingleton.IsFriend(p.Platform, p.SnId, msg.GetSnid()) {
|
||||
logger.Logger.Warn("CSGetChatLogHandler not friend")
|
||||
return nil
|
||||
}
|
||||
friendInfo := FriendMgrSington.GetFriendList(p.Platform, p.SnId)
|
||||
friendInfo := FriendMgrSingleton.GetFriendList(p.Platform, p.SnId)
|
||||
var bf *model.BindFriend
|
||||
if friendInfo != nil && len(friendInfo) != 0 {
|
||||
for _, friend := range friendInfo {
|
||||
|
@ -275,7 +275,7 @@ func CSReadChatMsgHandler(s *netlib.Session, packetid int, data interface{}, sid
|
|||
logger.Logger.Warn("CSReadChatMsgHandler platform == nil")
|
||||
return nil
|
||||
}
|
||||
if !FriendMgrSington.IsFriend(p.Platform, p.SnId, msg.GetSnid()) {
|
||||
if !FriendMgrSingleton.IsFriend(p.Platform, p.SnId, msg.GetSnid()) {
|
||||
logger.Logger.Warn("CSReadChatMsgHandler not friend")
|
||||
return nil
|
||||
}
|
||||
|
@ -307,21 +307,21 @@ func CSShieldMsgHandler(s *netlib.Session, packetid int, data interface{}, sid i
|
|||
OpRetCode: chat.OpResultCode_OPRC_Sucess,
|
||||
}
|
||||
if msg.GetShield() {
|
||||
if FriendMgrSington.IsShield(p.Platform, p.SnId, msg.GetShieldSnid()) {
|
||||
if FriendMgrSingleton.IsShield(p.Platform, p.SnId, msg.GetShieldSnid()) {
|
||||
logger.Logger.Warn("重复屏蔽")
|
||||
pack.OpRetCode = chat.OpResultCode_OPRC_Chat_ReShield
|
||||
}
|
||||
} else {
|
||||
if !FriendMgrSington.IsShield(p.Platform, p.SnId, msg.GetShieldSnid()) {
|
||||
if !FriendMgrSingleton.IsShield(p.Platform, p.SnId, msg.GetShieldSnid()) {
|
||||
logger.Logger.Warn("重复解除")
|
||||
pack.OpRetCode = chat.OpResultCode_OPRC_Chat_ReUnShield
|
||||
}
|
||||
}
|
||||
if pack.OpRetCode == chat.OpResultCode_OPRC_Sucess {
|
||||
if msg.GetShield() {
|
||||
FriendMgrSington.AddShield(p.Platform, p.SnId, msg.GetShieldSnid())
|
||||
FriendMgrSingleton.AddShield(p.Platform, p.SnId, msg.GetShieldSnid())
|
||||
} else {
|
||||
FriendMgrSington.DelShield(p.Platform, p.SnId, msg.GetShieldSnid())
|
||||
FriendMgrSingleton.DelShield(p.Platform, p.SnId, msg.GetShieldSnid())
|
||||
}
|
||||
}
|
||||
proto.SetDefaults(pack)
|
||||
|
|
|
@ -46,8 +46,8 @@ func (this *CSFriendListHandler) Process(s *netlib.Session, packetid int, data i
|
|||
OpRetCode: friend.OpResultCode_OPRC_Sucess,
|
||||
}
|
||||
switch msg.GetListType() {
|
||||
case ListType_Friend:
|
||||
dfl := FriendMgrSington.GetFriendList(p.Platform, p.GetSnId())
|
||||
case ListTypeFriend:
|
||||
dfl := FriendMgrSingleton.GetFriendList(p.Platform, p.GetSnId())
|
||||
if dfl != nil {
|
||||
for _, bf := range dfl {
|
||||
if bf.SnId == p.SnId {
|
||||
|
@ -62,7 +62,7 @@ func (this *CSFriendListHandler) Process(s *netlib.Session, packetid int, data i
|
|||
CreateTs: proto.Int64(bf.CreateTime),
|
||||
LogoutTs: proto.Int64(bf.LogoutTime),
|
||||
LastChatTs: proto.Int64(bf.CreateTime),
|
||||
IsShield: proto.Bool(FriendMgrSington.IsShield(p.Platform, p.SnId, bf.SnId)),
|
||||
IsShield: proto.Bool(FriendMgrSingleton.IsShield(p.Platform, p.SnId, bf.SnId)),
|
||||
RoleId: bf.RoleId,
|
||||
}
|
||||
fi.Online = false
|
||||
|
@ -80,7 +80,7 @@ func (this *CSFriendListHandler) Process(s *netlib.Session, packetid int, data i
|
|||
proto.SetDefaults(pack)
|
||||
p.SendToClient(int(friend.FriendPacketID_PACKET_SCFriendList), pack)
|
||||
logger.Logger.Trace("SCFriendListHandler:", pack)
|
||||
case ListType_Apply:
|
||||
case ListTypeApply:
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
ret, err := model.QueryFriendApplyBySnid(p.Platform, p.SnId)
|
||||
if err != nil {
|
||||
|
@ -113,7 +113,7 @@ func (this *CSFriendListHandler) Process(s *netlib.Session, packetid int, data i
|
|||
p.SendToClient(int(friend.FriendPacketID_PACKET_SCFriendList), pack)
|
||||
logger.Logger.Trace("SCFriendListHandler: ", pack)
|
||||
})).Start()
|
||||
case ListType_Recommend:
|
||||
case ListTypeRecommend:
|
||||
friends := PlayerMgrSington.RecommendFriendRule(p.Platform, p.SnId)
|
||||
for _, f := range friends {
|
||||
if f.Snid == p.SnId {
|
||||
|
@ -165,7 +165,7 @@ func (this *CSFriendOpHandler) Process(s *netlib.Session, packetid int, data int
|
|||
if destP.Roles != nil {
|
||||
roleId = int(destP.Roles.ModId)
|
||||
}
|
||||
FriendMgrSington.FriendOp(msg.OpCode, p, &model.BindFriend{
|
||||
FriendMgrSingleton.FriendOp(msg.OpCode, p, &model.BindFriend{
|
||||
SnId: destP.SnId,
|
||||
Platform: destP.Platform,
|
||||
Name: destP.Name,
|
||||
|
@ -194,7 +194,7 @@ func (this *CSFriendOpHandler) Process(s *netlib.Session, packetid int, data int
|
|||
if destPlayer.Roles != nil {
|
||||
roleId = int(destPlayer.Roles.ModId)
|
||||
}
|
||||
FriendMgrSington.FriendOp(msg.OpCode, p, &model.BindFriend{
|
||||
FriendMgrSingleton.FriendOp(msg.OpCode, p, &model.BindFriend{
|
||||
SnId: destPlayer.SnId,
|
||||
Platform: destPlayer.Platform,
|
||||
Name: destPlayer.Name,
|
||||
|
@ -325,7 +325,7 @@ func (this *CSInviteFriendHandler) Process(s *netlib.Session, packetid int, data
|
|||
return nil
|
||||
}
|
||||
//不是好友
|
||||
if !FriendMgrSington.IsFriend(p.Platform, p.SnId, friendSnid) {
|
||||
if !FriendMgrSingleton.IsFriend(p.Platform, p.SnId, friendSnid) {
|
||||
logger.Logger.Warn("CSInviteFriendHandler not friend")
|
||||
opRetCode = friend.OpResultCode_OPRC_InviteFriend_NotFriend
|
||||
send(p)
|
||||
|
@ -340,7 +340,7 @@ func (this *CSInviteFriendHandler) Process(s *netlib.Session, packetid int, data
|
|||
return nil
|
||||
}
|
||||
//CD
|
||||
if !FriendMgrSington.CanInvite(p.Platform, p.SnId, friendSnid) {
|
||||
if !FriendMgrSingleton.CanInvite(p.Platform, p.SnId, friendSnid) {
|
||||
logger.Logger.Warn("CSInviteFriendHandler in cd time")
|
||||
opRetCode = friend.OpResultCode_OPRC_Error
|
||||
send(p)
|
||||
|
@ -437,7 +437,7 @@ func (this *CSInviteFriendOpHandler) Process(s *netlib.Session, packetid int, da
|
|||
return nil
|
||||
}
|
||||
//不是好友
|
||||
if !FriendMgrSington.IsFriend(p.Platform, p.SnId, srcSnid) {
|
||||
if !FriendMgrSingleton.IsFriend(p.Platform, p.SnId, srcSnid) {
|
||||
logger.Logger.Warn("CSInviteFriendHandler not friend")
|
||||
opRetCode = friend.OpResultCode_OPRC_InviteFriend_NotFriend
|
||||
send(p)
|
||||
|
@ -445,7 +445,7 @@ func (this *CSInviteFriendOpHandler) Process(s *netlib.Session, packetid int, da
|
|||
}
|
||||
|
||||
switch int(opcode) {
|
||||
case Invite_Agree:
|
||||
case InviteAgree:
|
||||
logger.Logger.Trace("同意邀请")
|
||||
if p.scene != nil {
|
||||
logger.Logger.Warn("CSInviteFriendHandler scene is not nil")
|
||||
|
@ -574,7 +574,7 @@ func (this *CSInviteFriendOpHandler) Process(s *netlib.Session, packetid int, da
|
|||
}
|
||||
}
|
||||
}
|
||||
case Invite_Refuse:
|
||||
case InviteRefuse:
|
||||
logger.Logger.Trace("拒绝邀请")
|
||||
send(fp) //通知邀请者
|
||||
}
|
||||
|
@ -612,7 +612,7 @@ func (this *CSFuzzyQueryPlayerHandler) Process(s *netlib.Session, packetid int,
|
|||
|
||||
// 优先搜索在线玩家
|
||||
for _, player := range PlayerMgrSington.snidMap {
|
||||
if player != nil && player.IsOnLine() /*&& !player.IsRobot() && !FriendMgrSington.IsFriend(p.SnId, player.SnId)*/ { //在线
|
||||
if player != nil && player.IsOnLine() /*&& !player.IsRobot() && !FriendMgrSingleton.IsFriend(p.SnId, player.SnId)*/ { //在线
|
||||
if !player.IsRob && player.Platform != p.Platform { //不同平台的真人不能匹配
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -325,7 +325,7 @@ func (this *CSQueryRoomInfoHandler) ProcessLocalGame(s *netlib.Session, packetid
|
|||
|
||||
// 私人房需要是好友
|
||||
if scene.sceneMode == common.SceneModePrivate {
|
||||
if !FriendMgrSington.IsFriend(p.Platform, p.SnId, scene.creator) {
|
||||
if !FriendMgrSingleton.IsFriend(p.Platform, p.SnId, scene.creator) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ func (this *CSRisingStarHandler) Process(s *netlib.Session, packetid int, data i
|
|||
})
|
||||
//人物模型状态处理
|
||||
p.Roles.ModUnlock[msg.RisingModId]++
|
||||
FriendMgrSington.UpdateInfo(p.Platform, p.SnId)
|
||||
FriendMgrSingleton.UpdateInfo(p.Platform, p.SnId)
|
||||
p.dirty = true
|
||||
//人物
|
||||
SendInfoRole(pets.OpResultCode_OPRC_Sucess, ModelMgrSingleton.GetRoleInfo(p, msg.RisingModId))
|
||||
|
@ -213,7 +213,7 @@ func (this *CSRisingStarHandler) Process(s *netlib.Session, packetid int, data i
|
|||
Remark: remark,
|
||||
})
|
||||
p.Pets.ModUnlock[msg.RisingModId]++
|
||||
FriendMgrSington.UpdateInfo(p.Platform, p.SnId)
|
||||
FriendMgrSingleton.UpdateInfo(p.Platform, p.SnId)
|
||||
p.dirty = true
|
||||
//宠物
|
||||
SendInfoPet(pets.OpResultCode_OPRC_Sucess, ModelMgrSingleton.GetPetInfo(p, msg.RisingModId))
|
||||
|
@ -346,7 +346,7 @@ func (this *CSRolePetUnlockHandler) Process(s *netlib.Session, packetid int, dat
|
|||
if p.Roles.Mod[msg.UseModId].Ts == 0 {
|
||||
p.Roles.Mod[msg.UseModId].Ts = time.Now().Unix()
|
||||
}
|
||||
FriendMgrSington.UpdateInfo(p.Platform, p.SnId)
|
||||
FriendMgrSingleton.UpdateInfo(p.Platform, p.SnId)
|
||||
p.dirty = true
|
||||
logger.Logger.Trace("解锁人物", msg.UseModId)
|
||||
SendMsg(pets.OpResultCode_OPRC_Sucess, ModelMgrSingleton.GetRoleInfo(p, msg.UseModId), nil)
|
||||
|
@ -381,7 +381,7 @@ func (this *CSRolePetUnlockHandler) Process(s *netlib.Session, packetid int, dat
|
|||
if p.Pets.Mod[msg.UseModId].Ts == 0 {
|
||||
p.Pets.Mod[msg.UseModId].Ts = time.Now().Unix()
|
||||
}
|
||||
FriendMgrSington.UpdateInfo(p.Platform, p.SnId)
|
||||
FriendMgrSingleton.UpdateInfo(p.Platform, p.SnId)
|
||||
p.dirty = true
|
||||
logger.Logger.Trace("解锁宠物", msg.UseModId)
|
||||
SendMsg(pets.OpResultCode_OPRC_Sucess, nil, ModelMgrSingleton.GetPetInfo(p, msg.UseModId))
|
||||
|
|
|
@ -2172,9 +2172,9 @@ func CSQueryPlayer(s *netlib.Session, packetid int, data interface{}, sid int64)
|
|||
GameID: f.GameID,
|
||||
}
|
||||
//IsFriend
|
||||
pack.IsFriend = FriendMgrSington.IsFriend(p.Platform, p.SnId, f.SnId)
|
||||
pack.IsFriend = FriendMgrSingleton.IsFriend(p.Platform, p.SnId, f.SnId)
|
||||
//IsShield
|
||||
pack.IsShield = FriendMgrSington.IsShield(p.Platform, p.SnId, f.SnId)
|
||||
pack.IsShield = FriendMgrSingleton.IsShield(p.Platform, p.SnId, f.SnId)
|
||||
//Role
|
||||
roleInfo := f.Roles
|
||||
if roleInfo != nil {
|
||||
|
@ -2227,7 +2227,7 @@ func CSQueryPlayer(s *netlib.Session, packetid int, data interface{}, sid int64)
|
|||
p.SendToClient(int(player_proto.PlayerPacketID_PACKET_SC_QUERYPLAYER), pack)
|
||||
logger.Logger.Trace("SCQueryPlayerHandler ok: ", ok, " pack: ", pack)
|
||||
} else { // 真人去friend取信息
|
||||
friend := FriendMgrSington.GetPlayer(p.Platform, destSnId)
|
||||
friend := FriendMgrSingleton.GetPlayer(p.Platform, destSnId)
|
||||
if friend != nil {
|
||||
send(friend)
|
||||
} else {
|
||||
|
|
|
@ -148,7 +148,7 @@ func init() {
|
|||
|
||||
// 更新好友信息
|
||||
if param.ItemId == common.ItemIDVCard {
|
||||
FriendMgrSington.UpdateInfo(p.Platform, p.SnId)
|
||||
FriendMgrSingleton.UpdateInfo(p.Platform, p.SnId)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ func (c *CustomRoomMgr) GetRoomList(plt string) []*gamehall.PrivateRoomInfo {
|
|||
}
|
||||
|
||||
func (c *CustomRoomMgr) tryCreate(plt string, configId int32) {
|
||||
logger.Logger.Tracef("尝试创建竞技馆系统房间 %v CloseCustomRoomCreate:%v", configId, model.GameParamData.CloseCustomRoomCreate)
|
||||
logger.Logger.Debugf("尝试创建竞技馆系统房间 %v CloseCustomRoomCreate:%v", configId, model.GameParamData.CloseCustomRoomCreate)
|
||||
cfg := PlatformMgrSingleton.GetConfig(plt).RoomConfigSystem[configId]
|
||||
if model.GameParamData.CloseCustomRoomCreate || cfg == nil || cfg.GetOn() == common.Off {
|
||||
return
|
||||
|
@ -162,7 +162,7 @@ func (c *CustomRoomMgr) tryCreate(plt string, configId int32) {
|
|||
}
|
||||
|
||||
func (c *CustomRoomMgr) TryDestroy(plt string, configId int32) {
|
||||
logger.Logger.Tracef("尝试解散竞技馆系统房间 %v", configId)
|
||||
logger.Logger.Debugf("尝试解散竞技馆系统房间 %v", configId)
|
||||
cfg := PlatformMgrSingleton.GetConfig(plt).RoomConfigSystem[configId]
|
||||
if cfg == nil {
|
||||
return
|
||||
|
@ -190,7 +190,7 @@ func (c *CustomRoomMgr) TryDestroy(plt string, configId int32) {
|
|||
}
|
||||
|
||||
func (c *CustomRoomMgr) Release(plt string, configId int32) {
|
||||
logger.Logger.Tracef("释放竞技馆房间创建记录 %v", configId)
|
||||
logger.Logger.Debugf("释放竞技馆房间创建记录 %v", configId)
|
||||
v, ok := c.data[plt]
|
||||
if !ok || v == nil {
|
||||
return
|
||||
|
@ -261,7 +261,7 @@ func (c *CustomRoomMgr) UpdateCreate(plt string, configId int32, mustCreate bool
|
|||
}
|
||||
|
||||
if cfg.GetAutoCreate() == 1 || mustCreate {
|
||||
logger.Logger.Tracef("Update 竞技馆系统房间创建 %v", configId)
|
||||
logger.Logger.Debugf("Update 竞技馆系统房间创建 %v", configId)
|
||||
f(func() {
|
||||
gf = PlatformMgrSingleton.GetGameFree(plt, cfg.GetGameFreeId())
|
||||
if gf == nil || !gf.GetStatus() || cfg.GetOn() == common.Off {
|
||||
|
@ -307,7 +307,7 @@ func (c *CustomRoomMgr) UpdateCreate(plt string, configId int32, mustCreate bool
|
|||
IsRecruit: true,
|
||||
})
|
||||
if scene != nil {
|
||||
logger.Logger.Tracef("竞技馆系统房间创建成功 roomId:%v", scene.sceneId)
|
||||
logger.Logger.Debugf("竞技馆系统房间创建成功 roomId:%v", scene.sceneId)
|
||||
csp.AddScene(scene)
|
||||
info.Scene = scene
|
||||
} else {
|
||||
|
@ -339,7 +339,7 @@ func (c *CustomRoomMgr) UpdateCreate(plt string, configId int32, mustCreate bool
|
|||
})
|
||||
}
|
||||
info.Notify(common.ListAdd)
|
||||
logger.Logger.Tracef("竞技馆假房间创建成功 %v", info.PrivateRoomInfo)
|
||||
logger.Logger.Debugf("竞技馆假房间创建成功 %v", info.PrivateRoomInfo)
|
||||
if cfg.FullTime <= 0 {
|
||||
cfg.FullTime = int32(model.GameParamData.SceneMaxIdle)
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ func (c *CustomRoomMgr) UpdateCreate(plt string, configId int32, mustCreate bool
|
|||
cfg.FullTime = 3 // 至少3秒
|
||||
}
|
||||
b, _ := timer.AfterTimer(func(h timer.TimerHandle, ud interface{}) bool {
|
||||
logger.Logger.Tracef("竞技馆假房间解散 %v", info)
|
||||
logger.Logger.Debugf("竞技馆假房间解散 %v", info)
|
||||
c.Release(plt, configId)
|
||||
c.UpdateCreate(plt, configId, false)
|
||||
return true
|
||||
|
|
|
@ -18,37 +18,40 @@ import (
|
|||
"mongo.games.com/game/worldsrv/internal"
|
||||
)
|
||||
|
||||
// 列表类型
|
||||
const (
|
||||
ListType_Friend int32 = iota // 0.好友列表
|
||||
ListType_Apply // 1.申请列表
|
||||
ListType_Recommend // 2.推荐列表
|
||||
ListTypeFriend int32 = iota // 0.好友列表
|
||||
ListTypeApply // 1.申请列表
|
||||
ListTypeRecommend // 2.推荐列表
|
||||
)
|
||||
|
||||
// 好友操作
|
||||
const (
|
||||
OpType_Apply int32 = iota // 0.申请
|
||||
OpType_Agree // 1.同意
|
||||
OpType_Refuse // 2.拒绝
|
||||
OpType_Delete // 3.删除
|
||||
OpTypeApply int32 = iota // 0.申请,申请添加好友
|
||||
OpTypeAgree // 1.同意,同意添加好友
|
||||
OpTypeRefuse // 2.拒绝,拒绝添加好友
|
||||
OpTypeDelete // 3.删除,删除好友
|
||||
)
|
||||
|
||||
// 是否同意邀请进入游戏
|
||||
const (
|
||||
Invite_Agree int = iota // 0.同意
|
||||
Invite_Refuse // 1.拒绝
|
||||
InviteAgree int = iota // 0.同意
|
||||
InviteRefuse // 1.拒绝
|
||||
)
|
||||
|
||||
const FriendMaxNum = 200
|
||||
const ShieldMaxNum = 10000
|
||||
const FriendApplyMaxNum = 1000 //好友申请上限
|
||||
const FriendWrite = "FriendWrite"
|
||||
const FriendMaxNum = 200 // 好友最大数量
|
||||
const ShieldMaxNum = 10000 // 最大屏蔽人数
|
||||
const FriendApplyMaxNum = 1000 // 好友申请上限
|
||||
const FriendWrite = "FriendWrite" // 好友数据修改线程名称
|
||||
|
||||
var FriendMgrSington = &FriendMgr{
|
||||
var FriendMgrSingleton = &FriendMgr{
|
||||
FriendList: make(map[string]map[int32]*model.Friend),
|
||||
TsInviteCd: make(map[string]map[string]int64),
|
||||
}
|
||||
|
||||
type FriendMgr struct {
|
||||
FriendList map[string]map[int32]*model.Friend // 平台id:snid:好友信息
|
||||
TsInviteCd map[string]map[string]int64 // 平台id:snid:邀请cd时间
|
||||
TsInviteCd map[string]map[string]int64 // 平台id:邀请人id_被邀请人id:邀请cd时间
|
||||
}
|
||||
|
||||
func (this *FriendMgr) ModuleName() string {
|
||||
|
@ -84,6 +87,8 @@ func (this *FriendMgr) Del(platform string, snid int32) {
|
|||
}
|
||||
|
||||
// CanInvite 是否可以邀请,邀请冷却
|
||||
// snid 发起人
|
||||
// fsnid 被邀请人
|
||||
func (this *FriendMgr) CanInvite(platform string, snid, fsnid int32) bool {
|
||||
if this.TsInviteCd[platform] == nil {
|
||||
this.TsInviteCd[platform] = make(map[string]int64)
|
||||
|
@ -275,6 +280,10 @@ func (this *FriendMgr) ApplyList(platform string, snid int32) {
|
|||
if ret != nil && ret.ApplySnids != nil {
|
||||
pack := &friend.SCFriendApplyData{}
|
||||
for _, as := range ret.ApplySnids {
|
||||
p := PlayerMgrSington.GetPlayerBySnId(as.SnId)
|
||||
if p != nil {
|
||||
as.Name = p.Name
|
||||
}
|
||||
fa := &friend.FriendApply{
|
||||
Snid: proto.Int32(as.SnId),
|
||||
Name: proto.String(as.Name),
|
||||
|
@ -302,6 +311,7 @@ func (this *FriendMgr) ApplyList(platform string, snid int32) {
|
|||
}
|
||||
|
||||
// AddShield 屏蔽好友消息
|
||||
// snid屏蔽ssnid的消息
|
||||
func (this *FriendMgr) AddShield(platform string, snid, ssnid int32) {
|
||||
if this.FriendList[platform] == nil {
|
||||
return
|
||||
|
@ -382,16 +392,16 @@ func (this *FriendMgr) UpdateLogoutTime(platform string, snid int32) {
|
|||
|
||||
func (this *FriendMgr) FriendOp(opcode int32, p *Player, destP *model.BindFriend) {
|
||||
switch opcode {
|
||||
case OpType_Apply:
|
||||
case OpTypeApply:
|
||||
logger.Logger.Trace("@Apply friend", p.SnId, " -> ", destP.SnId)
|
||||
this.FriendApply(p, destP)
|
||||
case OpType_Agree:
|
||||
case OpTypeAgree:
|
||||
logger.Logger.Trace("@AgreeApply friend", p.SnId, " -> ", destP.SnId)
|
||||
this.FriendAgree(p, destP)
|
||||
case OpType_Refuse:
|
||||
case OpTypeRefuse:
|
||||
logger.Logger.Trace("@Refuse friend", p.SnId, " -> ", destP.SnId)
|
||||
this.FriendRefuse(p, destP)
|
||||
case OpType_Delete:
|
||||
case OpTypeDelete:
|
||||
logger.Logger.Trace("@Delete friend", p.SnId, " -> ", destP.SnId)
|
||||
this.FriendDelete(p, destP)
|
||||
}
|
||||
|
@ -399,11 +409,13 @@ func (this *FriendMgr) FriendOp(opcode int32, p *Player, destP *model.BindFriend
|
|||
|
||||
// FriendApply 好友申请
|
||||
// 记录在数据库
|
||||
// p 发起方
|
||||
// destP 接收方
|
||||
func (this *FriendMgr) FriendApply(p *Player, destP *model.BindFriend) {
|
||||
var applyList []int32
|
||||
SendToClick := func(retCode friend.OpResultCode, self ...bool) {
|
||||
pack := &friend.SCFriendOp{
|
||||
OpCode: proto.Int32(OpType_Apply),
|
||||
OpCode: proto.Int32(OpTypeApply),
|
||||
SnId: proto.Int32(destP.SnId),
|
||||
OpRetCode: retCode,
|
||||
}
|
||||
|
@ -435,7 +447,7 @@ func (this *FriendMgr) FriendApply(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
logger.Logger.Tracef(">>FriendApply %d -> %d, %v", p.SnId, destP.SnId, pack)
|
||||
}
|
||||
if FriendMgrSington.IsFriend(p.Platform, p.SnId, destP.SnId) {
|
||||
if FriendMgrSingleton.IsFriend(p.Platform, p.SnId, destP.SnId) {
|
||||
SendToClick(friend.OpResultCode_OPRC_Friend_AlreadyAdd)
|
||||
return
|
||||
}
|
||||
|
@ -496,11 +508,13 @@ func (this *FriendMgr) FriendApply(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
|
||||
// FriendAgree 同意好友申请
|
||||
// p 同意者
|
||||
// destP 申请者
|
||||
func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
||||
var applyList []int32
|
||||
SendToClick := func(retCode friend.OpResultCode, self ...bool) {
|
||||
pack := &friend.SCFriendOp{
|
||||
OpCode: proto.Int32(OpType_Agree),
|
||||
OpCode: proto.Int32(OpTypeAgree),
|
||||
SnId: proto.Int32(destP.SnId),
|
||||
OpRetCode: retCode,
|
||||
}
|
||||
|
@ -546,12 +560,12 @@ func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
logger.Logger.Tracef(">>FriendAgree %d -> %d, %v", p.SnId, destP.SnId, pack)
|
||||
}
|
||||
me := FriendMgrSington.GetPlayer(p.Platform, p.SnId)
|
||||
me := FriendMgrSingleton.GetPlayer(p.Platform, p.SnId)
|
||||
if me == nil {
|
||||
SendToClick(friend.OpResultCode_OPRC_Error)
|
||||
return
|
||||
}
|
||||
if FriendMgrSington.IsFriend(p.Platform, p.SnId, destP.SnId) { //已经是好友了
|
||||
if FriendMgrSingleton.IsFriend(p.Platform, p.SnId, destP.SnId) { //已经是好友了
|
||||
SendToClick(friend.OpResultCode_OPRC_Friend_AlreadyAdd)
|
||||
return
|
||||
}
|
||||
|
@ -561,7 +575,7 @@ func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
|||
return
|
||||
}
|
||||
|
||||
destPFriend := FriendMgrSington.GetPlayer(destP.Platform, destP.SnId)
|
||||
destPFriend := FriendMgrSingleton.GetPlayer(destP.Platform, destP.SnId)
|
||||
if destPFriend != nil {
|
||||
if len(destPFriend.BindFriend) >= FriendMaxNum {
|
||||
SendToClick(friend.OpResultCode_OPRC_Friend_DestFriendMax)
|
||||
|
@ -569,7 +583,7 @@ func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
}
|
||||
|
||||
var friendDB *model.Friend
|
||||
var friendDB *model.Friend // 申请者好友列表
|
||||
var err error
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
if destPFriend == nil {
|
||||
|
@ -598,15 +612,17 @@ func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
|||
if err != nil {
|
||||
return friend.OpResultCode_OPRC_Error
|
||||
}
|
||||
// 维护申请放和被申请方的申请列表
|
||||
//查看是否在申请列表
|
||||
if ret != nil {
|
||||
if ret.ApplySnids != nil {
|
||||
for i, as := range ret.ApplySnids {
|
||||
if as.SnId == destP.SnId {
|
||||
//在申请列表 删除
|
||||
// 删除被申请者的申请列表
|
||||
ret.ApplySnids = append(ret.ApplySnids[:i], ret.ApplySnids[i+1:]...)
|
||||
model.UpsertFriendApply(p.Platform, p.SnId, ret)
|
||||
|
||||
// 删除发起方的申请列表
|
||||
data, err := model.QueryFriendApplyListBySnid(p.Platform, destP.SnId)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("QueryFriendApplyListBySnid err:%v", err)
|
||||
|
@ -646,12 +662,12 @@ func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
|
||||
//同意者加入到被同意者好友里
|
||||
if destPlayer := FriendMgrSington.GetPlayer(destP.Platform, destP.SnId); destPlayer != nil {
|
||||
if destPlayer := FriendMgrSingleton.GetPlayer(destP.Platform, destP.SnId); destPlayer != nil {
|
||||
roleId := common.DefaultRoleId
|
||||
if p.Roles != nil {
|
||||
roleId = int(p.Roles.ModId)
|
||||
}
|
||||
result := FriendMgrSington.AgreeApply(destP.Platform, destP.SnId, &model.BindFriend{
|
||||
result := FriendMgrSingleton.AgreeApply(destP.Platform, destP.SnId, &model.BindFriend{
|
||||
SnId: p.SnId,
|
||||
CreateTime: time.Now().Unix(),
|
||||
Platform: p.Platform,
|
||||
|
@ -670,7 +686,7 @@ func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
|
||||
// 被同意者加入到同意者好友里
|
||||
result := FriendMgrSington.AgreeApply(p.Platform, p.SnId, destP)
|
||||
result := FriendMgrSingleton.AgreeApply(p.Platform, p.SnId, destP)
|
||||
if result != friend.OpResultCode_OPRC_Sucess {
|
||||
SendToClick(result, false)
|
||||
SendToClick(result)
|
||||
|
@ -685,7 +701,7 @@ func (this *FriendMgr) FriendRefuse(p *Player, destP *model.BindFriend) {
|
|||
var applyList []int32
|
||||
SendToClick := func(retCode friend.OpResultCode, self ...bool) {
|
||||
pack := &friend.SCFriendOp{
|
||||
OpCode: proto.Int32(OpType_Refuse),
|
||||
OpCode: proto.Int32(OpTypeRefuse),
|
||||
SnId: proto.Int32(destP.SnId),
|
||||
OpRetCode: retCode,
|
||||
}
|
||||
|
@ -699,7 +715,7 @@ func (this *FriendMgr) FriendRefuse(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
logger.Logger.Tracef(">>FriendRefuse %d -> %d, %v", p.SnId, destP.SnId, pack)
|
||||
}
|
||||
if FriendMgrSington.IsFriend(p.Platform, p.SnId, destP.SnId) {
|
||||
if FriendMgrSingleton.IsFriend(p.Platform, p.SnId, destP.SnId) {
|
||||
SendToClick(friend.OpResultCode_OPRC_Friend_AlreadyAdd)
|
||||
return
|
||||
}
|
||||
|
@ -744,6 +760,7 @@ func (this *FriendMgr) FriendRefuse(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
SendToClick(friend.OpResultCode_OPRC_Sucess)
|
||||
|
||||
// 刷新发起者的申请好友列表
|
||||
destPs := PlayerMgrSington.GetPlayerBySnId(destP.SnId)
|
||||
if destPs != nil && destPs.IsOnLine() {
|
||||
if applyList != nil {
|
||||
|
@ -757,7 +774,7 @@ func (this *FriendMgr) FriendRefuse(p *Player, destP *model.BindFriend) {
|
|||
func (this *FriendMgr) FriendDelete(p *Player, destP *model.BindFriend) {
|
||||
SendToClick := func(retCode friend.OpResultCode, self ...bool) {
|
||||
pack := &friend.SCFriendOp{
|
||||
OpCode: proto.Int32(OpType_Delete),
|
||||
OpCode: proto.Int32(OpTypeDelete),
|
||||
SnId: proto.Int32(destP.SnId),
|
||||
OpRetCode: retCode,
|
||||
}
|
||||
|
@ -774,17 +791,17 @@ func (this *FriendMgr) FriendDelete(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
}
|
||||
}
|
||||
f := FriendMgrSington.GetPlayer(p.Platform, destP.SnId)
|
||||
f := FriendMgrSingleton.GetPlayer(p.Platform, destP.SnId)
|
||||
if f != nil {
|
||||
//发起者删除被删除者
|
||||
isok1 := FriendMgrSington.RemoveFriend(p.Platform, p.SnId, f.SnId)
|
||||
isok1 := FriendMgrSingleton.RemoveFriend(p.Platform, p.SnId, f.SnId)
|
||||
if !isok1 {
|
||||
logger.Logger.Warn("RemoveFriend error: ", p.SnId, " del friend:", f.SnId)
|
||||
SendToClick(friend.OpResultCode_OPRC_Error)
|
||||
return
|
||||
}
|
||||
//被删除者删除发起者
|
||||
isok2 := FriendMgrSington.RemoveFriend(f.Platform, f.SnId, p.SnId)
|
||||
isok2 := FriendMgrSingleton.RemoveFriend(f.Platform, f.SnId, p.SnId)
|
||||
if !isok2 {
|
||||
logger.Logger.Warn("RemoveFriend error: ", f.SnId, " del friend:", p.SnId)
|
||||
//删除失败不用通知
|
||||
|
@ -817,7 +834,7 @@ func (this *FriendMgr) FriendDelete(p *Player, destP *model.BindFriend) {
|
|||
return
|
||||
} else {
|
||||
//发起者删除被删除者
|
||||
isok1 := FriendMgrSington.RemoveFriend(p.Platform, p.SnId, destP.SnId)
|
||||
isok1 := FriendMgrSingleton.RemoveFriend(p.Platform, p.SnId, destP.SnId)
|
||||
if !isok1 {
|
||||
logger.Logger.Warn("RemoveFriend error: ", p.SnId, " del friend:", destP.SnId)
|
||||
//SendToClick(friend.OpResultCode_OPRC_Error)
|
||||
|
@ -875,6 +892,7 @@ func (this *FriendMgr) LoadAfter(platform string, snid int32) *internal.PlayerLo
|
|||
Snid: snid,
|
||||
}
|
||||
|
||||
// 查询好友列表
|
||||
friendDB, err := model.QueryFriendBySnid(platform, snid)
|
||||
if err != nil {
|
||||
logger.Logger.Error("QueryFriendBySnid:", err, snid)
|
||||
|
@ -886,6 +904,7 @@ func (this *FriendMgr) LoadAfter(platform string, snid int32) *internal.PlayerLo
|
|||
return ret
|
||||
}
|
||||
|
||||
// 查询好友信息
|
||||
var offSnID []int32
|
||||
for _, v := range friendDB.BindFriend {
|
||||
roleId := common.DefaultRoleId
|
||||
|
@ -1011,6 +1030,6 @@ func (this *FriendMgr) Release(platform string, snid int32) {
|
|||
}
|
||||
|
||||
func init() {
|
||||
module.RegisteModule(FriendMgrSington, time.Hour, 0)
|
||||
internal.RegisterPlayerLoad(FriendMgrSington)
|
||||
module.RegisteModule(FriendMgrSingleton, time.Hour, 0)
|
||||
internal.RegisterPlayerLoad(FriendMgrSingleton)
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ func (this *FriendUnreadMgr) CheckSendFriendUnreadData(platform string, snid int
|
|||
}
|
||||
pack := &friend.SCFriendUnreadData{}
|
||||
for cSnid, unreadNum := range ful {
|
||||
isFriend := FriendMgrSington.IsFriend(platform, snid, cSnid)
|
||||
isFriend := FriendMgrSingleton.IsFriend(platform, snid, cSnid)
|
||||
if isFriend {
|
||||
fu := &friend.FriendUnread{
|
||||
Snid: proto.Int32(cSnid),
|
||||
|
@ -135,7 +135,7 @@ func (this *FriendUnreadMgr) SaveFriendUnreadData(platform string, snid int32) {
|
|||
if ful, ok := this.FriendUnreadList[platform][snid]; ok {
|
||||
fu := model.NewFriendUnread(snid)
|
||||
for cSnid, unreadNum := range ful {
|
||||
if unreadNum > 0 && FriendMgrSington.IsFriend(platform, snid, cSnid) {
|
||||
if unreadNum > 0 && FriendMgrSingleton.IsFriend(platform, snid, cSnid) {
|
||||
us := &model.FriendUnreadSnid{
|
||||
SnId: cSnid,
|
||||
UnreadNum: int32(unreadNum),
|
||||
|
|
|
@ -120,7 +120,7 @@ func (l *LotteryData) Reset() {
|
|||
l.CostCard = 0
|
||||
l.RobotCodeCount = 0
|
||||
l.PlayerNum = 0
|
||||
logger.Logger.Tracef("LotteryData Reset: %v", l.CId)
|
||||
logger.Logger.Debugf("LotteryData Reset: %v", l.CId)
|
||||
}
|
||||
|
||||
// GetCode 获取抽奖码
|
||||
|
|
|
@ -395,7 +395,7 @@ func (this *Player) OnRehold() {
|
|||
//登录事件
|
||||
this.ReportLoginEvent()
|
||||
|
||||
FriendMgrSington.ApplyList(this.Platform, this.SnId)
|
||||
FriendMgrSingleton.ApplyList(this.Platform, this.SnId)
|
||||
FriendUnreadMgrSington.CheckSendFriendUnreadData(this.Platform, this.SnId)
|
||||
|
||||
if !this.IsRob {
|
||||
|
@ -1122,7 +1122,7 @@ func (this *Player) GetMessageByGiftId(id string) *model.Message {
|
|||
}
|
||||
|
||||
func (this *Player) IsOnLine() bool {
|
||||
return this.state != PlayerStateOffline
|
||||
return this.state == PlayerStateOnline
|
||||
}
|
||||
|
||||
func (this *Player) SetOnline() {
|
||||
|
@ -1130,7 +1130,7 @@ func (this *Player) SetOnline() {
|
|||
}
|
||||
|
||||
func (this *Player) IsOffline() bool {
|
||||
return this.state == PlayerStateOffline
|
||||
return this.state != PlayerStateOnline
|
||||
}
|
||||
|
||||
func (this *Player) SetOffline() {
|
||||
|
@ -1200,7 +1200,7 @@ func (this *Player) DropLine() {
|
|||
this.SendToGame(int(serverproto.SSPacketID_PACKET_WG_PLAYERDROPLINE), pack)
|
||||
}
|
||||
|
||||
FriendMgrSington.UpdateLogoutTime(this.Platform, this.SnId)
|
||||
FriendMgrSingleton.UpdateLogoutTime(this.Platform, this.SnId)
|
||||
PlayerMgrSington.DropPlayer(this)
|
||||
}
|
||||
|
||||
|
@ -1212,7 +1212,7 @@ func (this *Player) Logout() {
|
|||
}
|
||||
this.SendToClient(int(loginproto.LoginPacketID_PACKET_SC_LOGOUT), scLogout)
|
||||
|
||||
FriendMgrSington.UpdateLogoutTime(this.Platform, this.SnId)
|
||||
FriendMgrSingleton.UpdateLogoutTime(this.Platform, this.SnId)
|
||||
PlayerMgrSington.DropPlayer(this)
|
||||
}
|
||||
|
||||
|
@ -1638,8 +1638,8 @@ func (this *Player) OnMiniTimer() {
|
|||
})
|
||||
}
|
||||
// 长时间掉线又没有删除缓存
|
||||
if !this.dropTime.IsZero() && this.scene == nil && time.Now().Sub(this.dropTime).Minutes() > 20 {
|
||||
logger.Logger.Errorf("清除缓存异常 snid:%v dirty:%v lastLogoutTime:%v lastGameId:%v", this.SnId, this.dirty, this.LastLogoutTime, this.LastGameId)
|
||||
if this.IsOffline() && time.Now().Sub(this.LastLogoutTime) > time.Hour*2 {
|
||||
logger.Logger.Warnf("清除缓存异常 snid:%v dirty:%v lastLogoutTime:%v lastGameId:%v", this.SnId, this.dirty, this.LastLogoutTime, this.LastGameId)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2006,7 +2006,7 @@ func (this *Player) SendDiffData() {
|
|||
}
|
||||
|
||||
if dirty {
|
||||
FriendMgrSington.UpdateInfo(this.Platform, this.SnId)
|
||||
FriendMgrSingleton.UpdateInfo(this.Platform, this.SnId)
|
||||
this.SendToClient(int(playerproto.PlayerPacketID_PACKET_SC_PLAYERDATAUPDATE), pack)
|
||||
logger.Logger.Trace("(this *Player) SendDiffData() ", pack)
|
||||
}
|
||||
|
|
|
@ -410,7 +410,7 @@ func (this *PlayerMgr) BroadcastMessageToPlatformWithHall(platform string, snid
|
|||
mgs := make(map[*netlib.Session][]*srvproto.MCSessionUnion)
|
||||
for _, p := range players {
|
||||
if p != nil && p.gateSess != nil && p.IsOnLine() && p.scene == nil {
|
||||
if FriendMgrSington.IsShield(p.Platform, p.SnId, snid) {
|
||||
if FriendMgrSingleton.IsShield(p.Platform, p.SnId, snid) {
|
||||
continue
|
||||
}
|
||||
mgs[p.gateSess] = append(mgs[p.gateSess], &srvproto.MCSessionUnion{
|
||||
|
@ -663,7 +663,7 @@ func (this *PlayerMgr) RecommendFriendRule(platform string, snid int32) []Recomm
|
|||
rets := []RecommendFriend{}
|
||||
players := this.playerOfPlatform[platform]
|
||||
for _, player := range players { //优先真人
|
||||
if player.SnId != snid && !FriendMgrSington.IsFriend(platform, snid, player.SnId) {
|
||||
if player.SnId != snid && !FriendMgrSingleton.IsFriend(platform, snid, player.SnId) {
|
||||
roleId := common.DefaultRoleId
|
||||
if player.Roles != nil {
|
||||
roleId = int(player.Roles.ModId)
|
||||
|
@ -734,8 +734,8 @@ func init() {
|
|||
PlayerSubjectSign.AttachHeadOutline(PlayerMgrSington)
|
||||
PlayerSubjectSign.AttachHeadUrl(PlayerMgrSington)
|
||||
|
||||
PlayerSubjectSign.AttachName(FriendMgrSington)
|
||||
PlayerSubjectSign.AttachHead(FriendMgrSington)
|
||||
PlayerSubjectSign.AttachName(FriendMgrSingleton)
|
||||
PlayerSubjectSign.AttachHead(FriendMgrSingleton)
|
||||
|
||||
// 定时器
|
||||
common.RegisterClockFunc(&common.ClockFunc{
|
||||
|
|
Loading…
Reference in New Issue