Compare commits
No commits in common. "7d8eaee2c22524c19b5918f75a6f08490a422ce9" and "557d4ff8cad663d23dab5d681ff910ef3023a64c" have entirely different histories.
7d8eaee2c2
...
557d4ff8ca
|
@ -0,0 +1,45 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
rawproto "google.golang.org/protobuf/proto"
|
||||
"mongo.games.com/game/proto"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/netlib"
|
||||
"mongo.games.com/goserver/srvlib"
|
||||
"mongo.games.com/goserver/srvlib/protocol"
|
||||
)
|
||||
|
||||
func RegisterBoardCastHandler() {
|
||||
netlib.Register(int(protocol.SrvlibPacketID_PACKET_SS_BROADCAST), &protocol.SSPacketBroadcast{}, BroadcastHandler)
|
||||
}
|
||||
|
||||
func BroadcastHandler(s *netlib.Session, packetId int, data interface{}) error {
|
||||
if bp, ok := data.(*protocol.SSPacketBroadcast); ok {
|
||||
pd := bp.GetData()
|
||||
sp := bp.GetSessParam()
|
||||
if bcss := sp.GetBcss(); bcss != nil {
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(bp.GetPacketId()), pd, int(bcss.GetSArea()), int(bcss.GetSType()))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CreateBroadcastPacket(sp *protocol.BCSessionUnion, packetId int, data interface{}) (rawproto.Message, error) {
|
||||
pack := &protocol.SSPacketBroadcast{
|
||||
SessParam: sp,
|
||||
PacketId: proto.Int(packetId),
|
||||
}
|
||||
|
||||
if byteData, ok := data.([]byte); ok {
|
||||
pack.Data = byteData
|
||||
} else {
|
||||
byteData, err := netlib.MarshalPacket(packetId, data)
|
||||
if err == nil {
|
||||
pack.Data = byteData
|
||||
} else {
|
||||
logger.Logger.Warnf("CreateBroadcastPacket err:%v", err)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return pack, nil
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
rawproto "google.golang.org/protobuf/proto"
|
||||
"mongo.games.com/game/proto"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/netlib"
|
||||
"mongo.games.com/goserver/srvlib"
|
||||
"mongo.games.com/goserver/srvlib/protocol"
|
||||
)
|
||||
|
||||
func RegisterMulticastHandler() {
|
||||
netlib.Register(int(protocol.SrvlibPacketID_PACKET_SS_MULTICAST), &protocol.SSPacketMulticast{}, MulticastHandler)
|
||||
}
|
||||
|
||||
func MulticastHandler(s *netlib.Session, packetId int, data interface{}) error {
|
||||
if mp, ok := data.(*protocol.SSPacketMulticast); ok {
|
||||
pd := mp.GetData()
|
||||
sis := mp.GetSessions()
|
||||
for _, si := range sis {
|
||||
ss := si.GetMcss()
|
||||
if ss != nil {
|
||||
ns := srvlib.ServerSessionMgrSington.GetSession(int(ss.GetSArea()), int(ss.GetSType()), int(ss.GetSId()))
|
||||
if ns != nil {
|
||||
ns.Send(int(mp.GetPacketId()), pd /*, s.GetSessionConfig().IsInnerLink*/)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CreateMulticastPacket(packetId int, data interface{}, sis ...*protocol.MCSessionUnion) (rawproto.Message, error) {
|
||||
pack := &protocol.SSPacketMulticast{
|
||||
Sessions: sis,
|
||||
PacketId: proto.Int(packetId),
|
||||
}
|
||||
if byteData, ok := data.([]byte); ok {
|
||||
pack.Data = byteData
|
||||
} else {
|
||||
byteData, err := netlib.MarshalPacket(packetId, data)
|
||||
if err == nil {
|
||||
pack.Data = byteData
|
||||
} else {
|
||||
logger.Logger.Errorf("CreateMulticastPacket err:%v", err)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return pack, nil
|
||||
}
|
|
@ -561,6 +561,7 @@ func init() {
|
|||
return nil
|
||||
}))
|
||||
|
||||
common.RegisterMulticastHandler()
|
||||
// 玩家离开
|
||||
//netlib.Register(int(server.SSPacketID_PACKET_WG_PlayerLEAVE), server.WGPlayerLeave{}, HandleWGPlayerLeave)
|
||||
// 同步记牌器过期时间
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package base
|
||||
|
||||
import (
|
||||
server_proto "mongo.games.com/game/protocol/server"
|
||||
"time"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/module"
|
||||
"mongo.games.com/goserver/core/netlib"
|
||||
"mongo.games.com/goserver/srvlib"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
serverproto "mongo.games.com/game/protocol/server"
|
||||
"mongo.games.com/goserver/srvlib/protocol"
|
||||
)
|
||||
|
||||
var PlayerMgrSington = &PlayerMgr{
|
||||
|
@ -154,8 +154,20 @@ func (this *PlayerMgr) GetPlayerByAccount(acc string) *Player {
|
|||
// return nil
|
||||
//}
|
||||
|
||||
func (this *PlayerMgr) BroadcastMessage(packetid int, rawpack interface{}) bool {
|
||||
sc := &protocol.BCSessionUnion{
|
||||
Bccs: &protocol.BCClientSession{},
|
||||
}
|
||||
pack, err := common.CreateBroadcastPacket(sc, packetid, rawpack)
|
||||
if err == nil && pack != nil {
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(protocol.SrvlibPacketID_PACKET_SS_BROADCAST), pack, common.GetSelfAreaId(), srvlib.GateServerType)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (this *PlayerMgr) BroadcastMessageToGroup(packetid int, rawpack interface{}, tags []string) bool {
|
||||
pack := &serverproto.SSCustomTagMulticast{
|
||||
pack := &server_proto.SSCustomTagMulticast{
|
||||
Tags: tags,
|
||||
}
|
||||
if byteData, ok := rawpack.([]byte); ok {
|
||||
|
@ -169,7 +181,7 @@ func (this *PlayerMgr) BroadcastMessageToGroup(packetid int, rawpack interface{}
|
|||
return false
|
||||
}
|
||||
}
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(serverproto.SSPacketID_PACKET_SS_CUSTOMTAG_MULTICAST), pack, common.GetSelfAreaId(), srvlib.GateServerType)
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(server_proto.SSPacketID_PACKET_SS_CUSTOMTAG_MULTICAST), pack, common.GetSelfAreaId(), srvlib.GateServerType)
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -4,14 +4,15 @@ import (
|
|||
"fmt"
|
||||
"math"
|
||||
"math/rand"
|
||||
"mongo.games.com/game/protocol/webapi"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
rawproto "google.golang.org/protobuf/proto"
|
||||
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/netlib"
|
||||
"mongo.games.com/goserver/core/utils"
|
||||
"mongo.games.com/goserver/srvlib/action"
|
||||
srvlibproto "mongo.games.com/goserver/srvlib/protocol"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
|
@ -20,7 +21,6 @@ import (
|
|||
"mongo.games.com/game/protocol/gamehall"
|
||||
"mongo.games.com/game/protocol/player"
|
||||
"mongo.games.com/game/protocol/server"
|
||||
"mongo.games.com/game/protocol/webapi"
|
||||
"mongo.games.com/game/srvdata"
|
||||
)
|
||||
|
||||
|
@ -716,7 +716,11 @@ func (this *Scene) Broadcast(packetid int, msg rawproto.Message, excludeSid int6
|
|||
}
|
||||
for gateSess, v := range mgs {
|
||||
if gateSess != nil && len(v) != 0 {
|
||||
action.MulticastMessageToServer(gateSess, packetid, msg, v...)
|
||||
pack, err := common.CreateMulticastPacket(packetid, msg, v...)
|
||||
if err == nil {
|
||||
proto.SetDefaults(pack)
|
||||
gateSess.Send(int(srvlibproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -736,7 +740,11 @@ func (this *Scene) RobotBroadcast(packetid int, msg rawproto.Message) {
|
|||
}
|
||||
for gateSess, v := range mgs {
|
||||
if gateSess != nil && len(v) != 0 {
|
||||
action.MulticastMessageToServer(gateSess, packetid, msg, v...)
|
||||
pack, err := common.CreateMulticastPacket(packetid, msg, v...)
|
||||
if err == nil {
|
||||
proto.SetDefaults(pack)
|
||||
gateSess.Send(int(srvlibproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -757,7 +765,11 @@ func (this *Scene) BroadcastToAudience(packetid int, msg rawproto.Message) {
|
|||
}
|
||||
for gateSess, v := range mgs {
|
||||
if gateSess != nil && len(v) != 0 {
|
||||
action.MulticastMessageToServer(gateSess, packetid, msg, v...)
|
||||
pack, err := common.CreateMulticastPacket(packetid, msg, v...)
|
||||
if err == nil {
|
||||
proto.SetDefaults(pack)
|
||||
gateSess.Send(int(srvlibproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
package base
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/proto"
|
||||
"mongo.games.com/game/protocol/gamehall"
|
||||
"mongo.games.com/game/protocol/server"
|
||||
srvlibproto "mongo.games.com/goserver/srvlib/protocol"
|
||||
"time"
|
||||
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/module"
|
||||
"mongo.games.com/goserver/core/netlib"
|
||||
"mongo.games.com/goserver/srvlib/action"
|
||||
srvlibproto "mongo.games.com/goserver/srvlib/protocol"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/proto"
|
||||
"mongo.games.com/game/protocol/gamehall"
|
||||
"mongo.games.com/game/protocol/server"
|
||||
)
|
||||
|
||||
var SceneMgrSington = &SceneMgr{
|
||||
|
@ -144,7 +142,11 @@ func (this *SceneMgr) JackPotSync(platform string, gameIds ...int32) {
|
|||
|
||||
for gateSess, v := range mgs {
|
||||
if gateSess != nil && len(v) != 0 {
|
||||
action.MulticastMessageToServer(gateSess, int(gamehall.HundredScenePacketID_PACKET_SC_GAMEJACKPOT), pack, v...)
|
||||
cPack, err := common.CreateMulticastPacket(int(gamehall.HundredScenePacketID_PACKET_SC_GAMEJACKPOT), pack, v...)
|
||||
if err == nil {
|
||||
proto.SetDefaults(cPack)
|
||||
gateSess.Send(int(srvlibproto.SrvlibPacketID_PACKET_SS_MULTICAST), cPack)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -914,6 +914,8 @@ func (this *SceneStateChessInit) OnEnter(s *base.Scene) {
|
|||
s.NotifySceneRoundStart(s.NumOfGames)
|
||||
this.BroadcastRoomState(s, this.GetState(), int64(s.NumOfGames))
|
||||
|
||||
//同步防伙牌数据
|
||||
sceneEx.SyncScenePlayer()
|
||||
//发牌
|
||||
sceneEx.ChessInit()
|
||||
|
||||
|
|
|
@ -2,27 +2,25 @@ package fishing
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cihub/seelog"
|
||||
"math"
|
||||
"math/rand"
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
fishing_proto "mongo.games.com/game/protocol/fishing"
|
||||
"mongo.games.com/game/srvdata"
|
||||
"mongo.games.com/goserver/core"
|
||||
"mongo.games.com/goserver/core/timer"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/cihub/seelog"
|
||||
"mongo.games.com/goserver/core"
|
||||
"mongo.games.com/goserver/core/netlib"
|
||||
"mongo.games.com/goserver/core/timer"
|
||||
"mongo.games.com/goserver/srvlib/action"
|
||||
srvlibproto "mongo.games.com/goserver/srvlib/protocol"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/gamerule/fishing"
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/game/proto"
|
||||
fishing_proto "mongo.games.com/game/protocol/fishing"
|
||||
"mongo.games.com/game/srvdata"
|
||||
"mongo.games.com/goserver/core/netlib"
|
||||
srvlibproto "mongo.games.com/goserver/srvlib/protocol"
|
||||
)
|
||||
|
||||
var fishlogger seelog.LoggerInterface
|
||||
|
@ -1459,7 +1457,11 @@ func (this *FishingSceneData) BroadCastMessage(packetid int, msg proto.Message,
|
|||
if gateSess == nil || len(v) == 0 {
|
||||
continue
|
||||
}
|
||||
action.MulticastMessageToServer(gateSess, packetid, msg, v...)
|
||||
pack, err := common.CreateMulticastPacket(packetid, msg, v...)
|
||||
if err == nil {
|
||||
proto.SetDefaults(pack)
|
||||
gateSess.Send(int(srvlibproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -986,6 +986,8 @@ func (this *SceneHandCardStateTienLen) OnEnter(s *base.Scene) {
|
|||
s.SyncSceneState(common.SceneStateStart)
|
||||
}
|
||||
|
||||
//同步防伙牌数据
|
||||
sceneEx.SyncScenePlayer()
|
||||
//发牌
|
||||
if rule.TestOpen {
|
||||
sceneEx.SendHandCardTest()
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"mongo.games.com/goserver/core/netlib"
|
||||
"mongo.games.com/goserver/srvlib"
|
||||
"mongo.games.com/goserver/srvlib/protocol"
|
||||
)
|
||||
|
||||
func init() {
|
||||
netlib.Register(int(protocol.SrvlibPacketID_PACKET_SS_BROADCAST), &protocol.SSPacketBroadcast{}, BroadcastHandler)
|
||||
}
|
||||
|
||||
func BroadcastHandler(s *netlib.Session, packetid int, data interface{}) error {
|
||||
if bp, ok := data.(*protocol.SSPacketBroadcast); ok {
|
||||
pd := bp.GetData()
|
||||
sp := bp.GetSessParam()
|
||||
if bcss := sp.GetBcss(); bcss != nil {
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(bp.GetPacketId()), pd, int(bcss.GetSArea()), int(bcss.GetSType()))
|
||||
} else {
|
||||
srvlib.ClientSessionMgrSington.Broadcast(int(bp.GetPacketId()), pd)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"mongo.games.com/goserver/core/netlib"
|
||||
"mongo.games.com/goserver/srvlib"
|
||||
"mongo.games.com/goserver/srvlib/protocol"
|
||||
)
|
||||
|
||||
func init() {
|
||||
netlib.Register(int(protocol.SrvlibPacketID_PACKET_SS_MULTICAST), &protocol.SSPacketMulticast{}, MulticastHandler)
|
||||
}
|
||||
|
||||
func MulticastHandler(s *netlib.Session, packetid int, data interface{}) error {
|
||||
if mp, ok := data.(*protocol.SSPacketMulticast); ok {
|
||||
pd := mp.GetData()
|
||||
sis := mp.GetSessions()
|
||||
for _, si := range sis {
|
||||
ns := getSession(si)
|
||||
if ns != nil {
|
||||
ns.Send(int(mp.GetPacketId()), pd /*, s.GetSessionConfig().IsInnerLink*/)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getSession(su *protocol.MCSessionUnion) *netlib.Session {
|
||||
cs := su.GetMccs()
|
||||
if cs != nil {
|
||||
return srvlib.ClientSessionMgrSington.GetSession(cs.GetSId())
|
||||
}
|
||||
|
||||
ss := su.GetMcss()
|
||||
if ss != nil {
|
||||
return srvlib.ServerSessionMgrSington.GetSession(int(ss.GetSArea()), int(ss.GetSType()), int(ss.GetSId()))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/common"
|
||||
)
|
||||
|
||||
func init() {
|
||||
common.RegisterBoardCastHandler()
|
||||
}
|
|
@ -2,25 +2,23 @@ package api
|
|||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/game/proto"
|
||||
msg_proto "mongo.games.com/game/protocol/message"
|
||||
"mongo.games.com/game/protocol/server"
|
||||
"mongo.games.com/game/protocol/webapi"
|
||||
"mongo.games.com/goserver/core/admin"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/timer"
|
||||
"mongo.games.com/goserver/core/utils"
|
||||
"mongo.games.com/goserver/srvlib"
|
||||
"mongo.games.com/goserver/srvlib/action"
|
||||
"mongo.games.com/goserver/srvlib/protocol"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/game/proto"
|
||||
msgproto "mongo.games.com/game/protocol/message"
|
||||
"mongo.games.com/game/protocol/server"
|
||||
"mongo.games.com/game/protocol/webapi"
|
||||
srvlibprotocol "mongo.games.com/goserver/srvlib/protocol"
|
||||
"net/http"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
//-------------------------------切换状态-------------------------------------------------------
|
||||
|
@ -227,8 +225,20 @@ func SrvCtrlNotice(rw http.ResponseWriter, data []byte) {
|
|||
noticePacket := &server.ServerNotice{
|
||||
Text: proto.String(msg.GetNotice()),
|
||||
}
|
||||
proto.SetDefaults(noticePacket)
|
||||
sc := &protocol.BCSessionUnion{
|
||||
Bccs: &protocol.BCClientSession{},
|
||||
}
|
||||
broadcast, err := common.CreateBroadcastPacket(sc, int(msg_proto.MSGPacketID_PACKET_SC_NOTICE), noticePacket)
|
||||
if err != nil || broadcast == nil {
|
||||
pack.Tag = webapi.TagCode_FAILED
|
||||
pack.Msg = "send notice failed(inner error)"
|
||||
r, _ := proto.Marshal(pack)
|
||||
webApiResponse(rw, r)
|
||||
return
|
||||
}
|
||||
funcNotice := func() {
|
||||
action.BroadcastMessage(common.GetSelfAreaId(), srvlib.GateServerType, int(msgproto.MSGPacketID_PACKET_SC_NOTICE), noticePacket, &protocol.BCSessionUnion{})
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(srvlibprotocol.SrvlibPacketID_PACKET_SS_BROADCAST), broadcast, common.GetSelfAreaId(), srvlib.GateServerType)
|
||||
}
|
||||
funcNotice()
|
||||
h, b := timer.StartTimer(timer.TimerActionWrapper(func(h timer.TimerHandle, ud interface{}) bool {
|
||||
|
|
|
@ -85,8 +85,6 @@ type GameParam struct {
|
|||
GuideStepMaxNum int32 // 新手引导步骤最大值
|
||||
GuideTs int64 // 新手引导时间戳,小于这个时间的玩家不显示新手引导
|
||||
CustomAwardUpdateTime int // 竞技馆奖励更新时间
|
||||
CustomAwardMinAddTime int // 竞技馆假奖励方法周期,单位秒
|
||||
CustomAwardMaxAddTime int // 竞技馆假奖励方法周期,单位秒
|
||||
}
|
||||
|
||||
var GameParamPath = "../data/gameparam.json"
|
||||
|
@ -223,10 +221,4 @@ func InitGameParam() {
|
|||
if GameParamData.CustomAwardUpdateTime == 0 {
|
||||
GameParamData.CustomAwardUpdateTime = 60
|
||||
}
|
||||
if GameParamData.CustomAwardMinAddTime == 0 {
|
||||
GameParamData.CustomAwardMinAddTime = 20 * 60
|
||||
}
|
||||
if GameParamData.CustomAwardMaxAddTime == 0 {
|
||||
GameParamData.CustomAwardMaxAddTime = 30 * 60
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,9 +46,8 @@ const (
|
|||
Rank_PACKET_RANK_CSPermit Rank = 10012
|
||||
Rank_PACKET_RANK_SCPermit Rank = 10013
|
||||
// 竞技馆获奖记录
|
||||
Rank_PACKET_CSRoomAward Rank = 10014
|
||||
Rank_PACKET_SCRoomAward Rank = 10015
|
||||
Rank_PACKET_SCRoomAwardOne Rank = 10016 // 竞技馆获奖记录通知
|
||||
Rank_PACKET_CSRoomAward Rank = 10014
|
||||
Rank_PACKET_SCRoomAward Rank = 10015
|
||||
)
|
||||
|
||||
// Enum value maps for Rank.
|
||||
|
@ -71,7 +70,6 @@ var (
|
|||
10013: "PACKET_RANK_SCPermit",
|
||||
10014: "PACKET_CSRoomAward",
|
||||
10015: "PACKET_SCRoomAward",
|
||||
10016: "PACKET_SCRoomAwardOne",
|
||||
}
|
||||
Rank_value = map[string]int32{
|
||||
"PACKET_RANK_ZERO": 0,
|
||||
|
@ -91,7 +89,6 @@ var (
|
|||
"PACKET_RANK_SCPermit": 10013,
|
||||
"PACKET_CSRoomAward": 10014,
|
||||
"PACKET_SCRoomAward": 10015,
|
||||
"PACKET_SCRoomAwardOne": 10016,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -1910,7 +1907,6 @@ func (x *Item) GetN() int64 {
|
|||
return 0
|
||||
}
|
||||
|
||||
// PACKET_SCRoomAwardOne
|
||||
type UserAward struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
|
@ -2239,7 +2235,7 @@ var file_rank_proto_rawDesc = []byte{
|
|||
0x6b, 0x69, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01,
|
||||
0x28, 0x05, 0x52, 0x05, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x6f, 0x74,
|
||||
0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x2a,
|
||||
0xe2, 0x03, 0x0a, 0x04, 0x52, 0x61, 0x6e, 0x6b, 0x12, 0x14, 0x0a, 0x10, 0x50, 0x41, 0x43, 0x4b,
|
||||
0xc6, 0x03, 0x0a, 0x04, 0x52, 0x61, 0x6e, 0x6b, 0x12, 0x14, 0x0a, 0x10, 0x50, 0x41, 0x43, 0x4b,
|
||||
0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f, 0x5a, 0x45, 0x52, 0x4f, 0x10, 0x00, 0x12, 0x1c,
|
||||
0x0a, 0x17, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x52, 0x41, 0x4e, 0x4b, 0x5f, 0x43, 0x53,
|
||||
0x52, 0x61, 0x6e, 0x6b, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x10, 0x90, 0x4e, 0x12, 0x1c, 0x0a, 0x17,
|
||||
|
@ -2267,21 +2263,19 @@ var file_rank_proto_rawDesc = []byte{
|
|||
0x6d, 0x69, 0x74, 0x10, 0x9d, 0x4e, 0x12, 0x17, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54,
|
||||
0x5f, 0x43, 0x53, 0x52, 0x6f, 0x6f, 0x6d, 0x41, 0x77, 0x61, 0x72, 0x64, 0x10, 0x9e, 0x4e, 0x12,
|
||||
0x17, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x52, 0x6f, 0x6f, 0x6d,
|
||||
0x41, 0x77, 0x61, 0x72, 0x64, 0x10, 0x9f, 0x4e, 0x12, 0x1a, 0x0a, 0x15, 0x50, 0x41, 0x43, 0x4b,
|
||||
0x45, 0x54, 0x5f, 0x53, 0x43, 0x52, 0x6f, 0x6f, 0x6d, 0x41, 0x77, 0x61, 0x72, 0x64, 0x4f, 0x6e,
|
||||
0x65, 0x10, 0xa0, 0x4e, 0x2a, 0x8d, 0x01, 0x0a, 0x0a, 0x52, 0x61, 0x6e, 0x6b, 0x49, 0x6e, 0x76,
|
||||
0x69, 0x74, 0x65, 0x12, 0x13, 0x0a, 0x0f, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70,
|
||||
0x65, 0x5f, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x49, 0x6e, 0x76, 0x69,
|
||||
0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x10, 0x01, 0x12, 0x13,
|
||||
0x0a, 0x0f, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x57, 0x65, 0x65,
|
||||
0x6b, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70,
|
||||
0x65, 0x5f, 0x4d, 0x6f, 0x6e, 0x74, 0x68, 0x10, 0x03, 0x12, 0x15, 0x0a, 0x11, 0x49, 0x6e, 0x76,
|
||||
0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x55, 0x70, 0x57, 0x65, 0x65, 0x6b, 0x10, 0x04,
|
||||
0x12, 0x12, 0x0a, 0x0e, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4d,
|
||||
0x61, 0x78, 0x10, 0x05, 0x42, 0x24, 0x5a, 0x22, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x2e, 0x67, 0x61,
|
||||
0x6d, 0x65, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65, 0x2f, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x72, 0x61, 0x6e, 0x6b, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
0x41, 0x77, 0x61, 0x72, 0x64, 0x10, 0x9f, 0x4e, 0x2a, 0x8d, 0x01, 0x0a, 0x0a, 0x52, 0x61, 0x6e,
|
||||
0x6b, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x12, 0x13, 0x0a, 0x0f, 0x49, 0x6e, 0x76, 0x69, 0x74,
|
||||
0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10,
|
||||
0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x54, 0x6f, 0x74, 0x61, 0x6c,
|
||||
0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65,
|
||||
0x5f, 0x57, 0x65, 0x65, 0x6b, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x49, 0x6e, 0x76, 0x69, 0x74,
|
||||
0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4d, 0x6f, 0x6e, 0x74, 0x68, 0x10, 0x03, 0x12, 0x15, 0x0a,
|
||||
0x11, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x55, 0x70, 0x57, 0x65,
|
||||
0x65, 0x6b, 0x10, 0x04, 0x12, 0x12, 0x0a, 0x0e, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79,
|
||||
0x70, 0x65, 0x5f, 0x4d, 0x61, 0x78, 0x10, 0x05, 0x42, 0x24, 0x5a, 0x22, 0x6d, 0x6f, 0x6e, 0x67,
|
||||
0x6f, 0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65,
|
||||
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x72, 0x61, 0x6e, 0x6b, 0x62, 0x06,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
|
@ -28,7 +28,6 @@ enum Rank{
|
|||
// 竞技馆获奖记录
|
||||
PACKET_CSRoomAward = 10014;
|
||||
PACKET_SCRoomAward = 10015;
|
||||
PACKET_SCRoomAwardOne = 10016; // 竞技馆获奖记录通知
|
||||
}
|
||||
|
||||
// 排位榜
|
||||
|
@ -224,7 +223,6 @@ message Item{
|
|||
int64 N = 2; // 道具数量
|
||||
}
|
||||
|
||||
// PACKET_SCRoomAwardOne
|
||||
message UserAward{
|
||||
int32 Snid = 1; // 玩家id
|
||||
string Name = 2; // 昵称
|
||||
|
|
|
@ -6,27 +6,17 @@ import (
|
|||
"go.etcd.io/etcd/client/v3"
|
||||
|
||||
"mongo.games.com/game/etcd"
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/game/protocol/webapi"
|
||||
)
|
||||
|
||||
var ConfigMgrInst = model.NewConfigMgr()
|
||||
|
||||
func init() {
|
||||
// 平台信息
|
||||
etcd.Register(etcd.ETCDKEY_PLATFORM_PREFIX, webapi.Platform{}, PlatformConfigEtcd)
|
||||
// 竞技馆房间配置
|
||||
etcd.Register(etcd.ETCDKEY_RoomConfig, webapi.RoomConfig{}, PlatformConfigEtcd)
|
||||
}
|
||||
|
||||
func PlatformConfigEtcd(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
||||
if event.Type == clientv3.EventTypeDelete {
|
||||
return
|
||||
}
|
||||
switch config := data.(type) {
|
||||
case *webapi.Platform:
|
||||
PlatformConfigSingleton.Update(config)
|
||||
case *webapi.RoomConfig:
|
||||
ConfigMgrInst.UpdateRoomConfig(config)
|
||||
}
|
||||
PlatformConfigSingleton.Update(data)
|
||||
}
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
package com
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/game/mq"
|
||||
)
|
||||
|
||||
// LogChannelSingleton 日志记录器
|
||||
var LogChannelSingleton = &LogChannel{
|
||||
cName: make(map[reflect.Type]string),
|
||||
}
|
||||
|
||||
type LogChannel struct {
|
||||
cName map[reflect.Type]string
|
||||
}
|
||||
|
||||
func (c *LogChannel) RegisterLogCName(cname string, log interface{}) {
|
||||
t := c.getLogType(log)
|
||||
c.cName[t] = cname
|
||||
}
|
||||
|
||||
func (c *LogChannel) getLogType(log interface{}) reflect.Type {
|
||||
return reflect.Indirect(reflect.ValueOf(log)).Type()
|
||||
}
|
||||
|
||||
func (c *LogChannel) getLogCName(log interface{}) string {
|
||||
t := c.getLogType(log)
|
||||
if name, exist := c.cName[t]; exist {
|
||||
return name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (c *LogChannel) WriteLog(log interface{}) {
|
||||
cname := c.getLogCName(log)
|
||||
if cname == "" {
|
||||
cname = "_null_"
|
||||
}
|
||||
logger.Logger.Tracef("LogChannel ==> %#v", log)
|
||||
mq.Send(cname, log)
|
||||
}
|
||||
|
||||
func (c *LogChannel) WriteMQData(data *model.RabbitMQData) {
|
||||
mq.Send(data.MQName, data.Data)
|
||||
}
|
||||
|
||||
func init() {
|
||||
LogChannelSingleton.RegisterLogCName(mq.DBCustomLogAward, &model.CustomLogAward{})
|
||||
}
|
|
@ -23,7 +23,6 @@ func main() {
|
|||
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
||||
model.StartupRPClient(common.CustomConfig.GetString("MgoRpcCliNet"), common.CustomConfig.GetString("MgoRpcCliAddr"), time.Duration(common.CustomConfig.GetInt("MgoRpcCliReconnInterV"))*time.Second)
|
||||
mq.StartConsumer(common.CustomConfig.GetString("RabbitMQURL"), common.CustomConfig.GetString("RMQExchange"), true)
|
||||
mq.StartPublisher(common.CustomConfig.GetString("RabbitMQURL"), common.CustomConfig.GetString("RMQExchange"), true, common.CustomConfig.GetInt("RMQPublishBacklog"))
|
||||
err := model.InitGameKVData()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
@ -1,20 +1,13 @@
|
|||
package rank
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/now"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/module"
|
||||
"mongo.games.com/goserver/srvlib"
|
||||
"mongo.games.com/goserver/srvlib/action"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/game/protocol/rank"
|
||||
"mongo.games.com/game/ranksrv/com"
|
||||
"mongo.games.com/game/srvdata"
|
||||
)
|
||||
|
||||
var CustomAwardMgrInstance = com.NewListMgr[*model.CustomLogAward](
|
||||
|
@ -29,79 +22,3 @@ var CustomAwardMgrInstance = com.NewListMgr[*model.CustomLogAward](
|
|||
ret, err := model.CustomLogAwardFind(platform, startTs, endTs)
|
||||
return ret, err
|
||||
})
|
||||
|
||||
var CustomAwardMgrSingle = &CustomAwardMgr{}
|
||||
|
||||
type CustomAwardMgr struct {
|
||||
updateTime time.Time
|
||||
}
|
||||
|
||||
func (c *CustomAwardMgr) ModuleName() string {
|
||||
return "customaward"
|
||||
}
|
||||
|
||||
func (c *CustomAwardMgr) Init() {
|
||||
}
|
||||
|
||||
func (c *CustomAwardMgr) Update() {
|
||||
nowTime := time.Now()
|
||||
if nowTime.Unix() < c.updateTime.Unix() {
|
||||
return
|
||||
}
|
||||
c.updateTime = nowTime.Add(time.Duration(common.RandInt(model.GameParamData.CustomAwardMinAddTime, model.GameParamData.CustomAwardMaxAddTime)) * time.Second)
|
||||
|
||||
// 随机添加假数据
|
||||
for k := range com.PlatformConfigSingleton.Platforms {
|
||||
for _, vv := range com.ConfigMgrInst.GetConfig(k).RoomConfig {
|
||||
if vv.GetOn() == common.Off {
|
||||
continue
|
||||
}
|
||||
var awards []*model.Item
|
||||
var items []*rank.Item
|
||||
for _, item := range vv.GetReward() {
|
||||
awards = append(awards, &model.Item{
|
||||
ItemId: item.ItemId,
|
||||
ItemNum: item.ItemNum,
|
||||
ObtainTime: nowTime.Unix(),
|
||||
})
|
||||
items = append(items, &rank.Item{
|
||||
Id: item.ItemId,
|
||||
N: item.ItemNum,
|
||||
})
|
||||
}
|
||||
name := ""
|
||||
if len(srvdata.PBDB_NameMgr.Datas.GetArr()) > 0 {
|
||||
n := rand.Intn(len(srvdata.PBDB_NameMgr.Datas.GetArr()))
|
||||
name = srvdata.PBDB_NameMgr.Datas.GetArr()[n].Name
|
||||
}
|
||||
id := common.RandInt(20000000, 99999999)
|
||||
com.LogChannelSingleton.WriteLog(&model.CustomLogAward{
|
||||
Platform: k,
|
||||
CycleId: "",
|
||||
SnId: int32(id),
|
||||
Name: name,
|
||||
Awards: awards,
|
||||
StartTs: nowTime.Add(-time.Minute * 8).Unix(),
|
||||
EndTs: nowTime.Unix(),
|
||||
})
|
||||
// 通知获奖
|
||||
pack := &rank.UserAward{
|
||||
Snid: int32(id),
|
||||
Name: name,
|
||||
Awards: items,
|
||||
Ts: nowTime.Unix(),
|
||||
}
|
||||
action.BroadcastMessage(common.GetSelfAreaId(), srvlib.GateServerType, int(rank.Rank_PACKET_SCRoomAwardOne), pack, nil)
|
||||
logger.Logger.Tracef("BroadcastMessage UserAward: %v", pack)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CustomAwardMgr) Shutdown() {
|
||||
module.UnregisteModule(c)
|
||||
}
|
||||
|
||||
func init() {
|
||||
module.RegisteModule(CustomAwardMgrSingle, time.Second*5, 0)
|
||||
}
|
||||
|
|
|
@ -330,6 +330,19 @@ func init() {
|
|||
return nil
|
||||
}))
|
||||
|
||||
// 同步每局游戏那些玩家一起玩的
|
||||
netlib.RegisterFactory(int(serverproto.SSPacketID_PACKET_GW_SCENEPLAYERLOG), netlib.PacketFactoryWrapper(func() interface{} {
|
||||
return &serverproto.GWScenePlayerLog{}
|
||||
}))
|
||||
netlib.RegisterHandler(int(serverproto.SSPacketID_PACKET_GW_SCENEPLAYERLOG), netlib.HandlerWrapper(func(s *netlib.Session,
|
||||
packetid int, pack interface{}) error {
|
||||
logger.Logger.Trace("receive GWScenePlayerLog:", pack)
|
||||
if msg, ok := pack.(*serverproto.GWScenePlayerLog); ok {
|
||||
sceneLimitMgr.ReceiveData(msg.GetGameId(), msg.GetSnids())
|
||||
}
|
||||
return nil
|
||||
}))
|
||||
|
||||
// 强制离开房间
|
||||
// 返回房间失败
|
||||
netlib.RegisterFactory(int(serverproto.SSPacketID_PACKET_GW_PLAYERFORCELEAVE), netlib.PacketFactoryWrapper(func() interface{} {
|
||||
|
@ -694,6 +707,9 @@ func (this *CSAccountInvalidHandler) Process(s *netlib.Session, packetid int, da
|
|||
}
|
||||
|
||||
func init() {
|
||||
common.RegisterBoardCastHandler()
|
||||
common.RegisterMulticastHandler()
|
||||
|
||||
common.RegisterHandler(int(playerproto.PlayerPacketID_PACKET_CS_PMCMD), &CSPMCmdHandler{})
|
||||
netlib.RegisterFactory(int(playerproto.PlayerPacketID_PACKET_CS_PMCMD), &CSPMCmdPacketFactory{})
|
||||
|
||||
|
|
|
@ -137,9 +137,9 @@ func ChessMatchFunc(csp *CoinScenePool, p *Player, scenes map[int]*Scene, sameIp
|
|||
return false
|
||||
}
|
||||
// 同局限制
|
||||
//if s.dbGameFree.GetSamePlaceLimit() > 0 && sceneLimitMgr.LimitSamePlace(p, s) {
|
||||
// return false
|
||||
//}
|
||||
if s.dbGameFree.GetSamePlaceLimit() > 0 && sceneLimitMgr.LimitSamePlace(p, s) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -65,9 +65,9 @@ func (this *BaseCoinScenePool) PlayerEnter(pool *CoinScenePool, p *Player, exclu
|
|||
continue
|
||||
}
|
||||
// 多少局只能禁止再配对
|
||||
//if s.dbGameFree.GetSamePlaceLimit() > 0 && sceneLimitMgr.LimitSamePlace(p, s) {
|
||||
// continue
|
||||
//}
|
||||
if s.dbGameFree.GetSamePlaceLimit() > 0 && sceneLimitMgr.LimitSamePlace(p, s) {
|
||||
continue
|
||||
}
|
||||
// 牌局开始后禁止进入
|
||||
if s.sp.CanEnter(s, p.SnId) != 0 {
|
||||
continue
|
||||
|
@ -87,9 +87,9 @@ func (this *BaseCoinScenePool) PlayerEnter(pool *CoinScenePool, p *Player, exclu
|
|||
var loseScene *Scene
|
||||
for _, s := range scenes {
|
||||
if s != nil {
|
||||
//if sceneLimitMgr.LimitAvgPlayer(s, len(pool.players)) {
|
||||
// continue
|
||||
//}
|
||||
if sceneLimitMgr.LimitAvgPlayer(s, len(pool.players)) {
|
||||
continue
|
||||
}
|
||||
cnt := s.GetWhitePlayerCnt()
|
||||
if cnt > cntWhite {
|
||||
cntWhite = cnt
|
||||
|
@ -114,9 +114,9 @@ func (this *BaseCoinScenePool) PlayerEnter(pool *CoinScenePool, p *Player, exclu
|
|||
var winScene *Scene
|
||||
for _, s := range scenes {
|
||||
if s != nil {
|
||||
//if sceneLimitMgr.LimitAvgPlayer(s, len(pool.players)) {
|
||||
// continue
|
||||
//}
|
||||
if sceneLimitMgr.LimitAvgPlayer(s, len(pool.players)) {
|
||||
continue
|
||||
}
|
||||
cnt := s.GetBlackPlayerCnt()
|
||||
if cnt > cntBlack {
|
||||
cntBlack = cnt
|
||||
|
|
|
@ -75,9 +75,9 @@ func (l *CoinScenePoolLocal) PlayerEnter(pool *CoinScenePool, p *Player, exclude
|
|||
continue
|
||||
}
|
||||
// 多少局只能禁止再配对
|
||||
//if s.dbGameFree.GetSamePlaceLimit() > 0 && sceneLimitMgr.LimitSamePlace(p, s) {
|
||||
// continue
|
||||
//}
|
||||
if s.dbGameFree.GetSamePlaceLimit() > 0 && sceneLimitMgr.LimitSamePlace(p, s) {
|
||||
continue
|
||||
}
|
||||
// 牌局开始后禁止进入
|
||||
if sp, ok := s.sp.(*ScenePolicyData); ok {
|
||||
if s.starting && !sp.EnterAfterStart {
|
||||
|
@ -105,9 +105,9 @@ func (l *CoinScenePoolLocal) PlayerEnter(pool *CoinScenePool, p *Player, exclude
|
|||
var loseScene *Scene
|
||||
for _, s := range scenes {
|
||||
if s != nil {
|
||||
//if sceneLimitMgr.LimitAvgPlayer(s, len(pool.players)) {
|
||||
// continue
|
||||
//}
|
||||
if sceneLimitMgr.LimitAvgPlayer(s, len(pool.players)) {
|
||||
continue
|
||||
}
|
||||
cnt := s.GetWhitePlayerCnt()
|
||||
if cnt > cntWhite {
|
||||
cntWhite = cnt
|
||||
|
@ -132,9 +132,9 @@ func (l *CoinScenePoolLocal) PlayerEnter(pool *CoinScenePool, p *Player, exclude
|
|||
var winScene *Scene
|
||||
for _, s := range scenes {
|
||||
if s != nil {
|
||||
//if sceneLimitMgr.LimitAvgPlayer(s, len(pool.players)) {
|
||||
// continue
|
||||
//}
|
||||
if sceneLimitMgr.LimitAvgPlayer(s, len(pool.players)) {
|
||||
continue
|
||||
}
|
||||
cnt := s.GetBlackPlayerCnt()
|
||||
if cnt > cntBlack {
|
||||
cntBlack = cnt
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"mongo.games.com/game/proto"
|
||||
"mongo.games.com/game/srvdata"
|
||||
"mongo.games.com/goserver/core/netlib"
|
||||
"mongo.games.com/goserver/srvlib/action"
|
||||
srvproto "mongo.games.com/goserver/srvlib/protocol"
|
||||
)
|
||||
|
||||
|
@ -76,7 +75,11 @@ func (gsm *GameStateManager) BrodcastGameState(gameId int32, platform string, pa
|
|||
}
|
||||
for gateSess, v := range mgs {
|
||||
if gateSess != nil && len(v) != 0 {
|
||||
action.MulticastMessageToServer(gateSess, packid, pack, v...)
|
||||
pack, err := common.CreateMulticastPacket(packid, pack, v...)
|
||||
if err == nil {
|
||||
proto.SetDefaults(pack)
|
||||
gateSess.Send(int(srvproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"mongo.games.com/goserver/core/module"
|
||||
"mongo.games.com/goserver/core/netlib"
|
||||
"mongo.games.com/goserver/core/utils"
|
||||
"mongo.games.com/goserver/srvlib/action"
|
||||
srvlibproto "mongo.games.com/goserver/srvlib/protocol"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
|
@ -302,7 +301,10 @@ func (pm *PlatformMgr) Broadcast(packetid int, packet interface{}, players map[i
|
|||
}
|
||||
for gateSess, v := range mgs {
|
||||
if gateSess != nil && len(v) != 0 {
|
||||
action.MulticastMessageToServer(gateSess, packetid, packet, v...)
|
||||
pack, err := common.CreateMulticastPacket(packetid, packet, v...)
|
||||
if err == nil {
|
||||
gateSess.Send(int(srvlibproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"mongo.games.com/goserver/core/task"
|
||||
"mongo.games.com/goserver/core/utils"
|
||||
"mongo.games.com/goserver/srvlib"
|
||||
"mongo.games.com/goserver/srvlib/action"
|
||||
srvproto "mongo.games.com/goserver/srvlib/protocol"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
|
@ -291,8 +290,14 @@ func (this *PlayerMgr) UpdatePlayerToken(p *Player, newToken string) {
|
|||
|
||||
// BroadcastMessage 给所有玩家发消息
|
||||
func (this *PlayerMgr) BroadcastMessage(packetid int, rawpack interface{}) bool {
|
||||
sc := &srvproto.BCSessionUnion{}
|
||||
action.BroadcastMessage(common.GetSelfAreaId(), srvlib.GateServerType, packetid, rawpack, sc)
|
||||
sc := &srvproto.BCSessionUnion{
|
||||
Bccs: &srvproto.BCClientSession{},
|
||||
}
|
||||
pack, err := common.CreateBroadcastPacket(sc, packetid, rawpack)
|
||||
if err == nil && pack != nil {
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(srvproto.SrvlibPacketID_PACKET_SS_BROADCAST), pack, common.GetSelfAreaId(), srvlib.GateServerType)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -314,7 +319,11 @@ func (this *PlayerMgr) BroadcastMessageToPlatform(platform string, packetid int,
|
|||
}
|
||||
for gateSess, v := range mgs {
|
||||
if gateSess != nil && len(v) != 0 {
|
||||
action.MulticastMessageToServer(gateSess, packetid, rawpack, v...)
|
||||
pack, err := common.CreateMulticastPacket(packetid, rawpack, v...)
|
||||
if err == nil {
|
||||
proto.SetDefaults(pack)
|
||||
gateSess.Send(int(srvproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -352,7 +361,11 @@ func (this *PlayerMgr) BroadcastMessageToPlatformByFunc(platform string, packeti
|
|||
}
|
||||
for gateSess, v := range mgs {
|
||||
if gateSess != nil && len(v) != 0 {
|
||||
action.MulticastMessageToServer(gateSess, packetid, rawpack, v...)
|
||||
pack, err := common.CreateMulticastPacket(packetid, rawpack, v...)
|
||||
if err == nil {
|
||||
proto.SetDefaults(pack)
|
||||
gateSess.Send(int(srvproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -381,7 +394,11 @@ func (this *PlayerMgr) BroadcastMessageToPlatformWithHall(platform string, snid
|
|||
}
|
||||
for gateSess, v := range mgs {
|
||||
if gateSess != nil && len(v) != 0 {
|
||||
action.MulticastMessageToServer(gateSess, packetid, rawpack, v...)
|
||||
pack, err := common.CreateMulticastPacket(packetid, rawpack, v...)
|
||||
if err == nil {
|
||||
proto.SetDefaults(pack)
|
||||
gateSess.Send(int(srvproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -424,7 +441,11 @@ func (this *PlayerMgr) BroadcastMessageToTarget(target []int32, packetid int, ra
|
|||
|
||||
for gateSess, v := range mgs {
|
||||
if gateSess != nil && len(v) != 0 {
|
||||
action.MulticastMessageToServer(gateSess, packetid, rawpack, v...)
|
||||
pack, err := common.CreateMulticastPacket(packetid, rawpack, v...)
|
||||
if err == nil {
|
||||
proto.SetDefaults(pack)
|
||||
gateSess.Send(int(srvproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/netlib"
|
||||
"mongo.games.com/goserver/srvlib"
|
||||
"mongo.games.com/goserver/srvlib/action"
|
||||
srvlibproto "mongo.games.com/goserver/srvlib/protocol"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
|
@ -865,7 +864,11 @@ func (this *Scene) Broadcast(packetId int, msg rawproto.Message, excludeSid int6
|
|||
|
||||
for gateSess, v := range mgs {
|
||||
if gateSess != nil && len(v) != 0 {
|
||||
action.MulticastMessageToServer(gateSess, packetId, msg, v...)
|
||||
pack, err := common.CreateMulticastPacket(packetId, msg, v...)
|
||||
if err == nil {
|
||||
proto.SetDefaults(pack)
|
||||
gateSess.Send(int(srvlibproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,163 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
)
|
||||
|
||||
var sceneLimitMgr = SceneLimitManager{
|
||||
SameRoomData: make(map[string][][]int32),
|
||||
}
|
||||
|
||||
type SceneLimitManager struct {
|
||||
SameRoomData map[string][][]int32 //用户的同房数据,保存了用户一局游戏中,房间人员的SNID
|
||||
}
|
||||
|
||||
func (m *SceneLimitManager) Key(gameid, snid int32) string {
|
||||
return fmt.Sprintf("%v-%v", snid, gameid)
|
||||
}
|
||||
|
||||
// LimitSamePlace 连续同局检测
|
||||
func (m *SceneLimitManager) LimitSamePlace(player *Player, s *Scene) bool {
|
||||
if player.IsRob {
|
||||
return false
|
||||
}
|
||||
key := m.Key(int32(s.gameId), player.SnId)
|
||||
var logArr = m.SameRoomData[key]
|
||||
var samePlaceLimit = int(s.dbGameFree.GetSamePlaceLimit())
|
||||
if len(logArr) > samePlaceLimit {
|
||||
logArr = logArr[len(logArr)-samePlaceLimit:]
|
||||
m.SameRoomData[key] = logArr
|
||||
}
|
||||
//新用户的防伙牌数据中,有没有场景中用户的检查
|
||||
for _, value := range s.players {
|
||||
if value.IsRob {
|
||||
continue
|
||||
}
|
||||
limitCount := 0
|
||||
for _, log := range logArr {
|
||||
if common.InSliceInt32(log, value.SnId) {
|
||||
limitCount++
|
||||
}
|
||||
}
|
||||
if limitCount >= samePlaceLimit {
|
||||
return true
|
||||
}
|
||||
}
|
||||
//场景中用户的防伙牌数据中,有没有新用户的检查
|
||||
for _, value := range s.players {
|
||||
if value.IsRob {
|
||||
continue
|
||||
}
|
||||
key := m.Key(int32(s.gameId), value.SnId)
|
||||
var logArr = m.SameRoomData[key]
|
||||
limitCount := 0
|
||||
for _, log := range logArr {
|
||||
if common.InSliceInt32(log, player.SnId) {
|
||||
limitCount++
|
||||
}
|
||||
}
|
||||
if limitCount >= samePlaceLimit {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// LimitSamePlaceBySnid 连续同局检测
|
||||
// limit 最大同局数
|
||||
func (m *SceneLimitManager) LimitSamePlaceBySnid(member []*Player, player *Player, gameId, limit int32) bool {
|
||||
if player.IsRob {
|
||||
return false
|
||||
}
|
||||
key := m.Key(gameId, player.SnId)
|
||||
var logArr = m.SameRoomData[key]
|
||||
var samePlaceLimit = int(limit)
|
||||
if len(logArr) > samePlaceLimit {
|
||||
logArr = logArr[len(logArr)-samePlaceLimit:]
|
||||
m.SameRoomData[key] = logArr
|
||||
}
|
||||
//新用户的防伙牌数据中,有没有场景中用户的检查
|
||||
for _, value := range member {
|
||||
if value.IsRob {
|
||||
continue
|
||||
}
|
||||
limitCount := 0
|
||||
for _, log := range logArr {
|
||||
if common.InSliceInt32(log, value.SnId) {
|
||||
limitCount++
|
||||
}
|
||||
}
|
||||
if limitCount >= samePlaceLimit {
|
||||
return true
|
||||
}
|
||||
}
|
||||
//场景中用户的防伙牌数据中,有没有新用户的检查
|
||||
for _, value := range member {
|
||||
if value.IsRob {
|
||||
continue
|
||||
}
|
||||
key := m.Key(gameId, value.SnId)
|
||||
var logArr = m.SameRoomData[key]
|
||||
limitCount := 0
|
||||
for _, log := range logArr {
|
||||
if common.InSliceInt32(log, player.SnId) {
|
||||
limitCount++
|
||||
}
|
||||
}
|
||||
if limitCount >= samePlaceLimit {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ReceiveData 同局记录
|
||||
func (m *SceneLimitManager) ReceiveData(gameid int32, data []int32) {
|
||||
for _, value := range data {
|
||||
key := m.Key(gameid, value)
|
||||
m.SameRoomData[key] = append(m.SameRoomData[key], data)
|
||||
}
|
||||
}
|
||||
|
||||
// LimitAvgPlayer 人数的平均分配问题
|
||||
func (m *SceneLimitManager) LimitAvgPlayer(s *Scene, totlePlayer int) bool {
|
||||
scenePlayerCount := s.GetTruePlayerCnt()
|
||||
switch {
|
||||
case totlePlayer > 1 && totlePlayer < 15:
|
||||
//4、如果游戏场的同时在线人数2-14人时,系统每2个人分一个桌,如果有剩余的没有分桌,随机找一个桌子进行分配;
|
||||
// 如果有机器人,系统加入机器人,并且保证同桌机器人数量1-3个
|
||||
if scenePlayerCount > 2 {
|
||||
return true
|
||||
}
|
||||
case totlePlayer >= 15 && totlePlayer < 22:
|
||||
//5、如果游戏场的同时在线人数15-21人,系统每3个人分一个桌,如果有剩余的没有分桌,随机找一个桌子进行分配;
|
||||
// 如果有机器人,系统加入机器人,并且保证同桌机器人数量1-3个;
|
||||
if scenePlayerCount > 3 {
|
||||
return true
|
||||
}
|
||||
case totlePlayer >= 22 && totlePlayer < 29:
|
||||
//6、如果游戏场的同时在线人数22-28人,系统每4个人分一个桌,如果有剩余的没有分桌,随机找一个桌子进行分配;
|
||||
// 如果有机器人,系统加入机器人,并且保证同桌机器人数量1-3个;
|
||||
if scenePlayerCount > 4 {
|
||||
return true
|
||||
}
|
||||
case totlePlayer >= 29 && totlePlayer < 35:
|
||||
//7、如果游戏场的同时在线人数29-35人,系统每5个人分一个桌,如果有剩余的没有分桌,随机找一个桌子进行分配;
|
||||
if scenePlayerCount > 5 {
|
||||
return true
|
||||
}
|
||||
case totlePlayer >= 35 && totlePlayer < 42:
|
||||
//8、如果游戏场的同时在线人数36-42人,系统每6个人分一个桌,如果有剩余的没有分桌,随机找一个桌子进行分配;
|
||||
if scenePlayerCount > 6 {
|
||||
return true
|
||||
}
|
||||
case totlePlayer >= 43:
|
||||
//9、如果游戏场的同时在线人数43人以上时,系统每7个人分一个桌,如果有剩余的没有分桌,随机找一个桌子进行分配;
|
||||
if scenePlayerCount > 7 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package main
|
||||
|
||||
//转移到schedulesrv中专门处理
|
||||
//import (
|
||||
// "time"
|
||||
|
||||
// "mongo.games.com/game/model"
|
||||
|
||||
// "mongo.games.com/goserver/core"
|
||||
// "mongo.games.com/goserver/core/logger"
|
||||
// "mongo.games.com/goserver/core/schedule"
|
||||
//)
|
||||
|
||||
//func init() {
|
||||
// core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
||||
// //每日凌晨4点执行清理任务
|
||||
// //0 0 4 * * *
|
||||
// task := schedule.NewTask("定期清理cardlog", "0 0 4 * * *", func() error {
|
||||
// logger.Logger.Info("@@@执行定期清理任务@@@")
|
||||
// tNow := time.Now()
|
||||
// m := model.GameParamData.LogHoldDuration
|
||||
// if m <= 0 {
|
||||
// m = 1
|
||||
// }
|
||||
// tStart := tNow.AddDate(0, int(-m), 0)
|
||||
// changeInfo, err := model.RemoveCoinLog(tStart.Unix())
|
||||
// if err != nil {
|
||||
// logger.Logger.Warnf("定期清理coinlog失败: %v", err)
|
||||
// } else {
|
||||
// logger.Logger.Warnf("定期清理coinlog成功: updated:%v removed:%v", changeInfo.Updated, changeInfo.Removed)
|
||||
// }
|
||||
// //1个月前的回放记录
|
||||
// changeInfo, err = model.RemoveGameRecs(tStart)
|
||||
// if err != nil {
|
||||
// logger.Logger.Warnf("定期清理gamerec失败: %v", err)
|
||||
// } else {
|
||||
// logger.Logger.Warnf("定期清理gamerec成功: updated:%v removed:%v", changeInfo.Updated, changeInfo.Removed)
|
||||
// }
|
||||
// //APIlog
|
||||
// changeInfo, err = model.RemoveAPILog(tStart.Unix())
|
||||
// if err != nil {
|
||||
// logger.Logger.Warnf("定期清理APIlog失败: %v", err)
|
||||
// } else {
|
||||
// logger.Logger.Warnf("定期清理APIlog成功: updated:%v removed:%v", changeInfo.Updated, changeInfo.Removed)
|
||||
// }
|
||||
|
||||
// //10天前的数据
|
||||
// tStart = tNow.AddDate(0, 0, -10)
|
||||
// changeInfo, err = model.RemoveAgentGameRecs(tStart.Unix())
|
||||
// if err != nil {
|
||||
// logger.Logger.Warnf("定期清理user_agentgamerec失败: %v", err)
|
||||
// } else {
|
||||
// logger.Logger.Warnf("定期清理user_agentgamerec成功: updated:%v removed:%v", changeInfo.Updated, changeInfo.Removed)
|
||||
// }
|
||||
|
||||
// //3天前的数据
|
||||
// tStart = tNow.AddDate(0, 0, -3)
|
||||
// changeInfo, err = model.RemoveSceneCoinLog(tStart.Unix())
|
||||
// if err != nil {
|
||||
// logger.Logger.Warnf("定期清理scenecoinlog失败: %v", err)
|
||||
// } else {
|
||||
// logger.Logger.Warnf("定期清理scenecoinlog成功: updated:%v removed:%v", changeInfo.Updated, changeInfo.Removed)
|
||||
// }
|
||||
|
||||
// //7天前的数据
|
||||
// tStart = tNow.AddDate(0, 0, -7)
|
||||
// changeInfo, err = model.RemoveGameCoinLog(tStart.Unix())
|
||||
// if err != nil {
|
||||
// logger.Logger.Warnf("定期清理gamecoinlog失败: %v", err)
|
||||
// } else {
|
||||
// logger.Logger.Warnf("定期清理gamecoinlog成功: updated:%v removed:%v", changeInfo.Updated, changeInfo.Removed)
|
||||
// }
|
||||
// //游戏记录
|
||||
// changeInfo, err = model.RemoveGameLog(tStart.Unix())
|
||||
// if err != nil {
|
||||
// logger.Logger.Warnf("定期清理游戏记录失败: %v", err)
|
||||
// } else {
|
||||
// logger.Logger.Warnf("定期清理游戏记录成功: updated:%v removed:%v", changeInfo.Updated, changeInfo.Removed)
|
||||
// }
|
||||
// return nil
|
||||
// })
|
||||
// if task != nil {
|
||||
// logger.Logger.Info("@@@执行定期清理任务@@@加入调度")
|
||||
// schedule.AddTask(task.Taskname, task)
|
||||
// }
|
||||
|
||||
// //每日凌晨执行汇总任务
|
||||
// //0 0 0 * * *
|
||||
// taskDay := schedule.NewTask("定期汇总玩家金币总额", "0 0 0 * * *", func() error {
|
||||
// logger.Logger.Info("@@@执行定期汇总任务@@@")
|
||||
// return model.AggregatePlayerCoin()
|
||||
// })
|
||||
// if taskDay != nil {
|
||||
// logger.Logger.Info("@@@执行定期汇总任务@@@加入调度")
|
||||
// schedule.AddTask(taskDay.Taskname, taskDay)
|
||||
// }
|
||||
// return nil
|
||||
// })
|
||||
//}
|
|
@ -9,7 +9,6 @@ import (
|
|||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/netlib"
|
||||
"mongo.games.com/goserver/core/timer"
|
||||
"mongo.games.com/goserver/srvlib/action"
|
||||
srvproto "mongo.games.com/goserver/srvlib/protocol"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
|
@ -113,7 +112,11 @@ func (tm *TmMatch) BroadcastMessage(packetId int, rawPack interface{}) {
|
|||
}
|
||||
for gateSess, v := range mgs {
|
||||
if gateSess != nil && len(v) != 0 {
|
||||
action.MulticastMessageToServer(gateSess, packetId, rawPack, v...)
|
||||
pack, err := common.CreateMulticastPacket(packetId, rawPack, v...)
|
||||
if err == nil {
|
||||
proto.SetDefaults(pack)
|
||||
gateSess.Send(int(srvproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue