Compare commits
2 Commits
557d4ff8ca
...
7d8eaee2c2
Author | SHA1 | Date |
---|---|---|
|
7d8eaee2c2 | |
|
91bb5820f9 |
|
@ -1,45 +0,0 @@
|
||||||
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
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
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,7 +561,6 @@ func init() {
|
||||||
return nil
|
return nil
|
||||||
}))
|
}))
|
||||||
|
|
||||||
common.RegisterMulticastHandler()
|
|
||||||
// 玩家离开
|
// 玩家离开
|
||||||
//netlib.Register(int(server.SSPacketID_PACKET_WG_PlayerLEAVE), server.WGPlayerLeave{}, HandleWGPlayerLeave)
|
//netlib.Register(int(server.SSPacketID_PACKET_WG_PlayerLEAVE), server.WGPlayerLeave{}, HandleWGPlayerLeave)
|
||||||
// 同步记牌器过期时间
|
// 同步记牌器过期时间
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package base
|
package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
server_proto "mongo.games.com/game/protocol/server"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"mongo.games.com/game/common"
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
"mongo.games.com/goserver/core/module"
|
"mongo.games.com/goserver/core/module"
|
||||||
"mongo.games.com/goserver/core/netlib"
|
"mongo.games.com/goserver/core/netlib"
|
||||||
"mongo.games.com/goserver/srvlib"
|
"mongo.games.com/goserver/srvlib"
|
||||||
"mongo.games.com/goserver/srvlib/protocol"
|
|
||||||
|
"mongo.games.com/game/common"
|
||||||
|
serverproto "mongo.games.com/game/protocol/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
var PlayerMgrSington = &PlayerMgr{
|
var PlayerMgrSington = &PlayerMgr{
|
||||||
|
@ -154,20 +154,8 @@ func (this *PlayerMgr) GetPlayerByAccount(acc string) *Player {
|
||||||
// return nil
|
// 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 {
|
func (this *PlayerMgr) BroadcastMessageToGroup(packetid int, rawpack interface{}, tags []string) bool {
|
||||||
pack := &server_proto.SSCustomTagMulticast{
|
pack := &serverproto.SSCustomTagMulticast{
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
}
|
}
|
||||||
if byteData, ok := rawpack.([]byte); ok {
|
if byteData, ok := rawpack.([]byte); ok {
|
||||||
|
@ -181,7 +169,7 @@ func (this *PlayerMgr) BroadcastMessageToGroup(packetid int, rawpack interface{}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
srvlib.ServerSessionMgrSington.Broadcast(int(server_proto.SSPacketID_PACKET_SS_CUSTOMTAG_MULTICAST), pack, common.GetSelfAreaId(), srvlib.GateServerType)
|
srvlib.ServerSessionMgrSington.Broadcast(int(serverproto.SSPacketID_PACKET_SS_CUSTOMTAG_MULTICAST), pack, common.GetSelfAreaId(), srvlib.GateServerType)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,15 +4,14 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"mongo.games.com/game/protocol/webapi"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
rawproto "google.golang.org/protobuf/proto"
|
rawproto "google.golang.org/protobuf/proto"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
"mongo.games.com/goserver/core/netlib"
|
"mongo.games.com/goserver/core/netlib"
|
||||||
"mongo.games.com/goserver/core/utils"
|
"mongo.games.com/goserver/core/utils"
|
||||||
|
"mongo.games.com/goserver/srvlib/action"
|
||||||
srvlibproto "mongo.games.com/goserver/srvlib/protocol"
|
srvlibproto "mongo.games.com/goserver/srvlib/protocol"
|
||||||
|
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
|
@ -21,6 +20,7 @@ import (
|
||||||
"mongo.games.com/game/protocol/gamehall"
|
"mongo.games.com/game/protocol/gamehall"
|
||||||
"mongo.games.com/game/protocol/player"
|
"mongo.games.com/game/protocol/player"
|
||||||
"mongo.games.com/game/protocol/server"
|
"mongo.games.com/game/protocol/server"
|
||||||
|
"mongo.games.com/game/protocol/webapi"
|
||||||
"mongo.games.com/game/srvdata"
|
"mongo.games.com/game/srvdata"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -716,11 +716,7 @@ func (this *Scene) Broadcast(packetid int, msg rawproto.Message, excludeSid int6
|
||||||
}
|
}
|
||||||
for gateSess, v := range mgs {
|
for gateSess, v := range mgs {
|
||||||
if gateSess != nil && len(v) != 0 {
|
if gateSess != nil && len(v) != 0 {
|
||||||
pack, err := common.CreateMulticastPacket(packetid, msg, v...)
|
action.MulticastMessageToServer(gateSess, packetid, msg, v...)
|
||||||
if err == nil {
|
|
||||||
proto.SetDefaults(pack)
|
|
||||||
gateSess.Send(int(srvlibproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -740,11 +736,7 @@ func (this *Scene) RobotBroadcast(packetid int, msg rawproto.Message) {
|
||||||
}
|
}
|
||||||
for gateSess, v := range mgs {
|
for gateSess, v := range mgs {
|
||||||
if gateSess != nil && len(v) != 0 {
|
if gateSess != nil && len(v) != 0 {
|
||||||
pack, err := common.CreateMulticastPacket(packetid, msg, v...)
|
action.MulticastMessageToServer(gateSess, packetid, msg, v...)
|
||||||
if err == nil {
|
|
||||||
proto.SetDefaults(pack)
|
|
||||||
gateSess.Send(int(srvlibproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -765,11 +757,7 @@ func (this *Scene) BroadcastToAudience(packetid int, msg rawproto.Message) {
|
||||||
}
|
}
|
||||||
for gateSess, v := range mgs {
|
for gateSess, v := range mgs {
|
||||||
if gateSess != nil && len(v) != 0 {
|
if gateSess != nil && len(v) != 0 {
|
||||||
pack, err := common.CreateMulticastPacket(packetid, msg, v...)
|
action.MulticastMessageToServer(gateSess, packetid, msg, v...)
|
||||||
if err == nil {
|
|
||||||
proto.SetDefaults(pack)
|
|
||||||
gateSess.Send(int(srvlibproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
package base
|
package base
|
||||||
|
|
||||||
import (
|
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"
|
"time"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
"mongo.games.com/goserver/core/module"
|
"mongo.games.com/goserver/core/module"
|
||||||
"mongo.games.com/goserver/core/netlib"
|
"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{
|
var SceneMgrSington = &SceneMgr{
|
||||||
|
@ -142,11 +144,7 @@ func (this *SceneMgr) JackPotSync(platform string, gameIds ...int32) {
|
||||||
|
|
||||||
for gateSess, v := range mgs {
|
for gateSess, v := range mgs {
|
||||||
if gateSess != nil && len(v) != 0 {
|
if gateSess != nil && len(v) != 0 {
|
||||||
cPack, err := common.CreateMulticastPacket(int(gamehall.HundredScenePacketID_PACKET_SC_GAMEJACKPOT), pack, v...)
|
action.MulticastMessageToServer(gateSess, int(gamehall.HundredScenePacketID_PACKET_SC_GAMEJACKPOT), pack, v...)
|
||||||
if err == nil {
|
|
||||||
proto.SetDefaults(cPack)
|
|
||||||
gateSess.Send(int(srvlibproto.SrvlibPacketID_PACKET_SS_MULTICAST), cPack)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -914,8 +914,6 @@ func (this *SceneStateChessInit) OnEnter(s *base.Scene) {
|
||||||
s.NotifySceneRoundStart(s.NumOfGames)
|
s.NotifySceneRoundStart(s.NumOfGames)
|
||||||
this.BroadcastRoomState(s, this.GetState(), int64(s.NumOfGames))
|
this.BroadcastRoomState(s, this.GetState(), int64(s.NumOfGames))
|
||||||
|
|
||||||
//同步防伙牌数据
|
|
||||||
sceneEx.SyncScenePlayer()
|
|
||||||
//发牌
|
//发牌
|
||||||
sceneEx.ChessInit()
|
sceneEx.ChessInit()
|
||||||
|
|
||||||
|
|
|
@ -2,25 +2,27 @@ package fishing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/cihub/seelog"
|
|
||||||
"math"
|
"math"
|
||||||
"math/rand"
|
"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"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"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/common"
|
||||||
"mongo.games.com/game/gamerule/fishing"
|
"mongo.games.com/game/gamerule/fishing"
|
||||||
|
"mongo.games.com/game/gamesrv/base"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/proto"
|
"mongo.games.com/game/proto"
|
||||||
"mongo.games.com/goserver/core/netlib"
|
fishing_proto "mongo.games.com/game/protocol/fishing"
|
||||||
srvlibproto "mongo.games.com/goserver/srvlib/protocol"
|
"mongo.games.com/game/srvdata"
|
||||||
)
|
)
|
||||||
|
|
||||||
var fishlogger seelog.LoggerInterface
|
var fishlogger seelog.LoggerInterface
|
||||||
|
@ -1457,11 +1459,7 @@ func (this *FishingSceneData) BroadCastMessage(packetid int, msg proto.Message,
|
||||||
if gateSess == nil || len(v) == 0 {
|
if gateSess == nil || len(v) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
pack, err := common.CreateMulticastPacket(packetid, msg, v...)
|
action.MulticastMessageToServer(gateSess, packetid, msg, v...)
|
||||||
if err == nil {
|
|
||||||
proto.SetDefaults(pack)
|
|
||||||
gateSess.Send(int(srvlibproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -986,8 +986,6 @@ func (this *SceneHandCardStateTienLen) OnEnter(s *base.Scene) {
|
||||||
s.SyncSceneState(common.SceneStateStart)
|
s.SyncSceneState(common.SceneStateStart)
|
||||||
}
|
}
|
||||||
|
|
||||||
//同步防伙牌数据
|
|
||||||
sceneEx.SyncScenePlayer()
|
|
||||||
//发牌
|
//发牌
|
||||||
if rule.TestOpen {
|
if rule.TestOpen {
|
||||||
sceneEx.SendHandCardTest()
|
sceneEx.SendHandCardTest()
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
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
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
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
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
package api
|
|
||||||
|
|
||||||
import (
|
|
||||||
"mongo.games.com/game/common"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
common.RegisterBoardCastHandler()
|
|
||||||
}
|
|
|
@ -2,23 +2,25 @@ package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"mongo.games.com/game/common"
|
"net/http"
|
||||||
"mongo.games.com/game/model"
|
"os/exec"
|
||||||
"mongo.games.com/game/proto"
|
"strconv"
|
||||||
msg_proto "mongo.games.com/game/protocol/message"
|
"time"
|
||||||
"mongo.games.com/game/protocol/server"
|
|
||||||
"mongo.games.com/game/protocol/webapi"
|
|
||||||
"mongo.games.com/goserver/core/admin"
|
"mongo.games.com/goserver/core/admin"
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
"mongo.games.com/goserver/core/timer"
|
"mongo.games.com/goserver/core/timer"
|
||||||
"mongo.games.com/goserver/core/utils"
|
"mongo.games.com/goserver/core/utils"
|
||||||
"mongo.games.com/goserver/srvlib"
|
"mongo.games.com/goserver/srvlib"
|
||||||
|
"mongo.games.com/goserver/srvlib/action"
|
||||||
"mongo.games.com/goserver/srvlib/protocol"
|
"mongo.games.com/goserver/srvlib/protocol"
|
||||||
srvlibprotocol "mongo.games.com/goserver/srvlib/protocol"
|
|
||||||
"net/http"
|
"mongo.games.com/game/common"
|
||||||
"os/exec"
|
"mongo.games.com/game/model"
|
||||||
"strconv"
|
"mongo.games.com/game/proto"
|
||||||
"time"
|
msgproto "mongo.games.com/game/protocol/message"
|
||||||
|
"mongo.games.com/game/protocol/server"
|
||||||
|
"mongo.games.com/game/protocol/webapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
//-------------------------------切换状态-------------------------------------------------------
|
//-------------------------------切换状态-------------------------------------------------------
|
||||||
|
@ -225,20 +227,8 @@ func SrvCtrlNotice(rw http.ResponseWriter, data []byte) {
|
||||||
noticePacket := &server.ServerNotice{
|
noticePacket := &server.ServerNotice{
|
||||||
Text: proto.String(msg.GetNotice()),
|
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() {
|
funcNotice := func() {
|
||||||
srvlib.ServerSessionMgrSington.Broadcast(int(srvlibprotocol.SrvlibPacketID_PACKET_SS_BROADCAST), broadcast, common.GetSelfAreaId(), srvlib.GateServerType)
|
action.BroadcastMessage(common.GetSelfAreaId(), srvlib.GateServerType, int(msgproto.MSGPacketID_PACKET_SC_NOTICE), noticePacket, &protocol.BCSessionUnion{})
|
||||||
}
|
}
|
||||||
funcNotice()
|
funcNotice()
|
||||||
h, b := timer.StartTimer(timer.TimerActionWrapper(func(h timer.TimerHandle, ud interface{}) bool {
|
h, b := timer.StartTimer(timer.TimerActionWrapper(func(h timer.TimerHandle, ud interface{}) bool {
|
||||||
|
|
|
@ -85,6 +85,8 @@ type GameParam struct {
|
||||||
GuideStepMaxNum int32 // 新手引导步骤最大值
|
GuideStepMaxNum int32 // 新手引导步骤最大值
|
||||||
GuideTs int64 // 新手引导时间戳,小于这个时间的玩家不显示新手引导
|
GuideTs int64 // 新手引导时间戳,小于这个时间的玩家不显示新手引导
|
||||||
CustomAwardUpdateTime int // 竞技馆奖励更新时间
|
CustomAwardUpdateTime int // 竞技馆奖励更新时间
|
||||||
|
CustomAwardMinAddTime int // 竞技馆假奖励方法周期,单位秒
|
||||||
|
CustomAwardMaxAddTime int // 竞技馆假奖励方法周期,单位秒
|
||||||
}
|
}
|
||||||
|
|
||||||
var GameParamPath = "../data/gameparam.json"
|
var GameParamPath = "../data/gameparam.json"
|
||||||
|
@ -221,4 +223,10 @@ func InitGameParam() {
|
||||||
if GameParamData.CustomAwardUpdateTime == 0 {
|
if GameParamData.CustomAwardUpdateTime == 0 {
|
||||||
GameParamData.CustomAwardUpdateTime = 60
|
GameParamData.CustomAwardUpdateTime = 60
|
||||||
}
|
}
|
||||||
|
if GameParamData.CustomAwardMinAddTime == 0 {
|
||||||
|
GameParamData.CustomAwardMinAddTime = 20 * 60
|
||||||
|
}
|
||||||
|
if GameParamData.CustomAwardMaxAddTime == 0 {
|
||||||
|
GameParamData.CustomAwardMaxAddTime = 30 * 60
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,9 @@ const (
|
||||||
Rank_PACKET_RANK_CSPermit Rank = 10012
|
Rank_PACKET_RANK_CSPermit Rank = 10012
|
||||||
Rank_PACKET_RANK_SCPermit Rank = 10013
|
Rank_PACKET_RANK_SCPermit Rank = 10013
|
||||||
// 竞技馆获奖记录
|
// 竞技馆获奖记录
|
||||||
Rank_PACKET_CSRoomAward Rank = 10014
|
Rank_PACKET_CSRoomAward Rank = 10014
|
||||||
Rank_PACKET_SCRoomAward Rank = 10015
|
Rank_PACKET_SCRoomAward Rank = 10015
|
||||||
|
Rank_PACKET_SCRoomAwardOne Rank = 10016 // 竞技馆获奖记录通知
|
||||||
)
|
)
|
||||||
|
|
||||||
// Enum value maps for Rank.
|
// Enum value maps for Rank.
|
||||||
|
@ -70,6 +71,7 @@ var (
|
||||||
10013: "PACKET_RANK_SCPermit",
|
10013: "PACKET_RANK_SCPermit",
|
||||||
10014: "PACKET_CSRoomAward",
|
10014: "PACKET_CSRoomAward",
|
||||||
10015: "PACKET_SCRoomAward",
|
10015: "PACKET_SCRoomAward",
|
||||||
|
10016: "PACKET_SCRoomAwardOne",
|
||||||
}
|
}
|
||||||
Rank_value = map[string]int32{
|
Rank_value = map[string]int32{
|
||||||
"PACKET_RANK_ZERO": 0,
|
"PACKET_RANK_ZERO": 0,
|
||||||
|
@ -89,6 +91,7 @@ var (
|
||||||
"PACKET_RANK_SCPermit": 10013,
|
"PACKET_RANK_SCPermit": 10013,
|
||||||
"PACKET_CSRoomAward": 10014,
|
"PACKET_CSRoomAward": 10014,
|
||||||
"PACKET_SCRoomAward": 10015,
|
"PACKET_SCRoomAward": 10015,
|
||||||
|
"PACKET_SCRoomAwardOne": 10016,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1907,6 +1910,7 @@ func (x *Item) GetN() int64 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PACKET_SCRoomAwardOne
|
||||||
type UserAward struct {
|
type UserAward struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
|
@ -2235,7 +2239,7 @@ var file_rank_proto_rawDesc = []byte{
|
||||||
0x6b, 0x69, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01,
|
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,
|
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,
|
0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x2a,
|
||||||
0xc6, 0x03, 0x0a, 0x04, 0x52, 0x61, 0x6e, 0x6b, 0x12, 0x14, 0x0a, 0x10, 0x50, 0x41, 0x43, 0x4b,
|
0xe2, 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,
|
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,
|
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,
|
0x52, 0x61, 0x6e, 0x6b, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x10, 0x90, 0x4e, 0x12, 0x1c, 0x0a, 0x17,
|
||||||
|
@ -2263,19 +2267,21 @@ var file_rank_proto_rawDesc = []byte{
|
||||||
0x6d, 0x69, 0x74, 0x10, 0x9d, 0x4e, 0x12, 0x17, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54,
|
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,
|
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,
|
0x17, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x52, 0x6f, 0x6f, 0x6d,
|
||||||
0x41, 0x77, 0x61, 0x72, 0x64, 0x10, 0x9f, 0x4e, 0x2a, 0x8d, 0x01, 0x0a, 0x0a, 0x52, 0x61, 0x6e,
|
0x41, 0x77, 0x61, 0x72, 0x64, 0x10, 0x9f, 0x4e, 0x12, 0x1a, 0x0a, 0x15, 0x50, 0x41, 0x43, 0x4b,
|
||||||
0x6b, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x12, 0x13, 0x0a, 0x0f, 0x49, 0x6e, 0x76, 0x69, 0x74,
|
0x45, 0x54, 0x5f, 0x53, 0x43, 0x52, 0x6f, 0x6f, 0x6d, 0x41, 0x77, 0x61, 0x72, 0x64, 0x4f, 0x6e,
|
||||||
0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10,
|
0x65, 0x10, 0xa0, 0x4e, 0x2a, 0x8d, 0x01, 0x0a, 0x0a, 0x52, 0x61, 0x6e, 0x6b, 0x49, 0x6e, 0x76,
|
||||||
0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x54, 0x6f, 0x74, 0x61, 0x6c,
|
0x69, 0x74, 0x65, 0x12, 0x13, 0x0a, 0x0f, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70,
|
||||||
0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65,
|
0x65, 0x5f, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x49, 0x6e, 0x76, 0x69,
|
||||||
0x5f, 0x57, 0x65, 0x65, 0x6b, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x49, 0x6e, 0x76, 0x69, 0x74,
|
0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x10, 0x01, 0x12, 0x13,
|
||||||
0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4d, 0x6f, 0x6e, 0x74, 0x68, 0x10, 0x03, 0x12, 0x15, 0x0a,
|
0x0a, 0x0f, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x57, 0x65, 0x65,
|
||||||
0x11, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x55, 0x70, 0x57, 0x65,
|
0x6b, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70,
|
||||||
0x65, 0x6b, 0x10, 0x04, 0x12, 0x12, 0x0a, 0x0e, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79,
|
0x65, 0x5f, 0x4d, 0x6f, 0x6e, 0x74, 0x68, 0x10, 0x03, 0x12, 0x15, 0x0a, 0x11, 0x49, 0x6e, 0x76,
|
||||||
0x70, 0x65, 0x5f, 0x4d, 0x61, 0x78, 0x10, 0x05, 0x42, 0x24, 0x5a, 0x22, 0x6d, 0x6f, 0x6e, 0x67,
|
0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x55, 0x70, 0x57, 0x65, 0x65, 0x6b, 0x10, 0x04,
|
||||||
0x6f, 0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65,
|
0x12, 0x12, 0x0a, 0x0e, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4d,
|
||||||
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x72, 0x61, 0x6e, 0x6b, 0x62, 0x06,
|
0x61, 0x78, 0x10, 0x05, 0x42, 0x24, 0x5a, 0x22, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x2e, 0x67, 0x61,
|
||||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
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 (
|
var (
|
||||||
|
|
|
@ -28,6 +28,7 @@ enum Rank{
|
||||||
// 竞技馆获奖记录
|
// 竞技馆获奖记录
|
||||||
PACKET_CSRoomAward = 10014;
|
PACKET_CSRoomAward = 10014;
|
||||||
PACKET_SCRoomAward = 10015;
|
PACKET_SCRoomAward = 10015;
|
||||||
|
PACKET_SCRoomAwardOne = 10016; // 竞技馆获奖记录通知
|
||||||
}
|
}
|
||||||
|
|
||||||
// 排位榜
|
// 排位榜
|
||||||
|
@ -223,6 +224,7 @@ message Item{
|
||||||
int64 N = 2; // 道具数量
|
int64 N = 2; // 道具数量
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PACKET_SCRoomAwardOne
|
||||||
message UserAward{
|
message UserAward{
|
||||||
int32 Snid = 1; // 玩家id
|
int32 Snid = 1; // 玩家id
|
||||||
string Name = 2; // 昵称
|
string Name = 2; // 昵称
|
||||||
|
|
|
@ -6,17 +6,27 @@ import (
|
||||||
"go.etcd.io/etcd/client/v3"
|
"go.etcd.io/etcd/client/v3"
|
||||||
|
|
||||||
"mongo.games.com/game/etcd"
|
"mongo.games.com/game/etcd"
|
||||||
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/protocol/webapi"
|
"mongo.games.com/game/protocol/webapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var ConfigMgrInst = model.NewConfigMgr()
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// 平台信息
|
// 平台信息
|
||||||
etcd.Register(etcd.ETCDKEY_PLATFORM_PREFIX, webapi.Platform{}, PlatformConfigEtcd)
|
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{}) {
|
func PlatformConfigEtcd(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
||||||
if event.Type == clientv3.EventTypeDelete {
|
if event.Type == clientv3.EventTypeDelete {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
PlatformConfigSingleton.Update(data)
|
switch config := data.(type) {
|
||||||
|
case *webapi.Platform:
|
||||||
|
PlatformConfigSingleton.Update(config)
|
||||||
|
case *webapi.RoomConfig:
|
||||||
|
ConfigMgrInst.UpdateRoomConfig(config)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
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,6 +23,7 @@ func main() {
|
||||||
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
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)
|
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.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()
|
err := model.InitGameKVData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
|
@ -1,13 +1,20 @@
|
||||||
package rank
|
package rank
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jinzhu/now"
|
"github.com/jinzhu/now"
|
||||||
"mongo.games.com/goserver/core/logger"
|
"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/model"
|
||||||
|
"mongo.games.com/game/protocol/rank"
|
||||||
"mongo.games.com/game/ranksrv/com"
|
"mongo.games.com/game/ranksrv/com"
|
||||||
|
"mongo.games.com/game/srvdata"
|
||||||
)
|
)
|
||||||
|
|
||||||
var CustomAwardMgrInstance = com.NewListMgr[*model.CustomLogAward](
|
var CustomAwardMgrInstance = com.NewListMgr[*model.CustomLogAward](
|
||||||
|
@ -22,3 +29,79 @@ var CustomAwardMgrInstance = com.NewListMgr[*model.CustomLogAward](
|
||||||
ret, err := model.CustomLogAwardFind(platform, startTs, endTs)
|
ret, err := model.CustomLogAwardFind(platform, startTs, endTs)
|
||||||
return ret, err
|
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,19 +330,6 @@ func init() {
|
||||||
return nil
|
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{} {
|
netlib.RegisterFactory(int(serverproto.SSPacketID_PACKET_GW_PLAYERFORCELEAVE), netlib.PacketFactoryWrapper(func() interface{} {
|
||||||
|
@ -707,9 +694,6 @@ func (this *CSAccountInvalidHandler) Process(s *netlib.Session, packetid int, da
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
common.RegisterBoardCastHandler()
|
|
||||||
common.RegisterMulticastHandler()
|
|
||||||
|
|
||||||
common.RegisterHandler(int(playerproto.PlayerPacketID_PACKET_CS_PMCMD), &CSPMCmdHandler{})
|
common.RegisterHandler(int(playerproto.PlayerPacketID_PACKET_CS_PMCMD), &CSPMCmdHandler{})
|
||||||
netlib.RegisterFactory(int(playerproto.PlayerPacketID_PACKET_CS_PMCMD), &CSPMCmdPacketFactory{})
|
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
|
return false
|
||||||
}
|
}
|
||||||
// 同局限制
|
// 同局限制
|
||||||
if s.dbGameFree.GetSamePlaceLimit() > 0 && sceneLimitMgr.LimitSamePlace(p, s) {
|
//if s.dbGameFree.GetSamePlaceLimit() > 0 && sceneLimitMgr.LimitSamePlace(p, s) {
|
||||||
return false
|
// return false
|
||||||
}
|
//}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,9 +65,9 @@ func (this *BaseCoinScenePool) PlayerEnter(pool *CoinScenePool, p *Player, exclu
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// 多少局只能禁止再配对
|
// 多少局只能禁止再配对
|
||||||
if s.dbGameFree.GetSamePlaceLimit() > 0 && sceneLimitMgr.LimitSamePlace(p, s) {
|
//if s.dbGameFree.GetSamePlaceLimit() > 0 && sceneLimitMgr.LimitSamePlace(p, s) {
|
||||||
continue
|
// continue
|
||||||
}
|
//}
|
||||||
// 牌局开始后禁止进入
|
// 牌局开始后禁止进入
|
||||||
if s.sp.CanEnter(s, p.SnId) != 0 {
|
if s.sp.CanEnter(s, p.SnId) != 0 {
|
||||||
continue
|
continue
|
||||||
|
@ -87,9 +87,9 @@ func (this *BaseCoinScenePool) PlayerEnter(pool *CoinScenePool, p *Player, exclu
|
||||||
var loseScene *Scene
|
var loseScene *Scene
|
||||||
for _, s := range scenes {
|
for _, s := range scenes {
|
||||||
if s != nil {
|
if s != nil {
|
||||||
if sceneLimitMgr.LimitAvgPlayer(s, len(pool.players)) {
|
//if sceneLimitMgr.LimitAvgPlayer(s, len(pool.players)) {
|
||||||
continue
|
// continue
|
||||||
}
|
//}
|
||||||
cnt := s.GetWhitePlayerCnt()
|
cnt := s.GetWhitePlayerCnt()
|
||||||
if cnt > cntWhite {
|
if cnt > cntWhite {
|
||||||
cntWhite = cnt
|
cntWhite = cnt
|
||||||
|
@ -114,9 +114,9 @@ func (this *BaseCoinScenePool) PlayerEnter(pool *CoinScenePool, p *Player, exclu
|
||||||
var winScene *Scene
|
var winScene *Scene
|
||||||
for _, s := range scenes {
|
for _, s := range scenes {
|
||||||
if s != nil {
|
if s != nil {
|
||||||
if sceneLimitMgr.LimitAvgPlayer(s, len(pool.players)) {
|
//if sceneLimitMgr.LimitAvgPlayer(s, len(pool.players)) {
|
||||||
continue
|
// continue
|
||||||
}
|
//}
|
||||||
cnt := s.GetBlackPlayerCnt()
|
cnt := s.GetBlackPlayerCnt()
|
||||||
if cnt > cntBlack {
|
if cnt > cntBlack {
|
||||||
cntBlack = cnt
|
cntBlack = cnt
|
||||||
|
|
|
@ -75,9 +75,9 @@ func (l *CoinScenePoolLocal) PlayerEnter(pool *CoinScenePool, p *Player, exclude
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// 多少局只能禁止再配对
|
// 多少局只能禁止再配对
|
||||||
if s.dbGameFree.GetSamePlaceLimit() > 0 && sceneLimitMgr.LimitSamePlace(p, s) {
|
//if s.dbGameFree.GetSamePlaceLimit() > 0 && sceneLimitMgr.LimitSamePlace(p, s) {
|
||||||
continue
|
// continue
|
||||||
}
|
//}
|
||||||
// 牌局开始后禁止进入
|
// 牌局开始后禁止进入
|
||||||
if sp, ok := s.sp.(*ScenePolicyData); ok {
|
if sp, ok := s.sp.(*ScenePolicyData); ok {
|
||||||
if s.starting && !sp.EnterAfterStart {
|
if s.starting && !sp.EnterAfterStart {
|
||||||
|
@ -105,9 +105,9 @@ func (l *CoinScenePoolLocal) PlayerEnter(pool *CoinScenePool, p *Player, exclude
|
||||||
var loseScene *Scene
|
var loseScene *Scene
|
||||||
for _, s := range scenes {
|
for _, s := range scenes {
|
||||||
if s != nil {
|
if s != nil {
|
||||||
if sceneLimitMgr.LimitAvgPlayer(s, len(pool.players)) {
|
//if sceneLimitMgr.LimitAvgPlayer(s, len(pool.players)) {
|
||||||
continue
|
// continue
|
||||||
}
|
//}
|
||||||
cnt := s.GetWhitePlayerCnt()
|
cnt := s.GetWhitePlayerCnt()
|
||||||
if cnt > cntWhite {
|
if cnt > cntWhite {
|
||||||
cntWhite = cnt
|
cntWhite = cnt
|
||||||
|
@ -132,9 +132,9 @@ func (l *CoinScenePoolLocal) PlayerEnter(pool *CoinScenePool, p *Player, exclude
|
||||||
var winScene *Scene
|
var winScene *Scene
|
||||||
for _, s := range scenes {
|
for _, s := range scenes {
|
||||||
if s != nil {
|
if s != nil {
|
||||||
if sceneLimitMgr.LimitAvgPlayer(s, len(pool.players)) {
|
//if sceneLimitMgr.LimitAvgPlayer(s, len(pool.players)) {
|
||||||
continue
|
// continue
|
||||||
}
|
//}
|
||||||
cnt := s.GetBlackPlayerCnt()
|
cnt := s.GetBlackPlayerCnt()
|
||||||
if cnt > cntBlack {
|
if cnt > cntBlack {
|
||||||
cntBlack = cnt
|
cntBlack = cnt
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"mongo.games.com/game/proto"
|
"mongo.games.com/game/proto"
|
||||||
"mongo.games.com/game/srvdata"
|
"mongo.games.com/game/srvdata"
|
||||||
"mongo.games.com/goserver/core/netlib"
|
"mongo.games.com/goserver/core/netlib"
|
||||||
|
"mongo.games.com/goserver/srvlib/action"
|
||||||
srvproto "mongo.games.com/goserver/srvlib/protocol"
|
srvproto "mongo.games.com/goserver/srvlib/protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -75,11 +76,7 @@ func (gsm *GameStateManager) BrodcastGameState(gameId int32, platform string, pa
|
||||||
}
|
}
|
||||||
for gateSess, v := range mgs {
|
for gateSess, v := range mgs {
|
||||||
if gateSess != nil && len(v) != 0 {
|
if gateSess != nil && len(v) != 0 {
|
||||||
pack, err := common.CreateMulticastPacket(packid, pack, v...)
|
action.MulticastMessageToServer(gateSess, packid, pack, v...)
|
||||||
if err == nil {
|
|
||||||
proto.SetDefaults(pack)
|
|
||||||
gateSess.Send(int(srvproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"mongo.games.com/goserver/core/module"
|
"mongo.games.com/goserver/core/module"
|
||||||
"mongo.games.com/goserver/core/netlib"
|
"mongo.games.com/goserver/core/netlib"
|
||||||
"mongo.games.com/goserver/core/utils"
|
"mongo.games.com/goserver/core/utils"
|
||||||
|
"mongo.games.com/goserver/srvlib/action"
|
||||||
srvlibproto "mongo.games.com/goserver/srvlib/protocol"
|
srvlibproto "mongo.games.com/goserver/srvlib/protocol"
|
||||||
|
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
|
@ -301,10 +302,7 @@ func (pm *PlatformMgr) Broadcast(packetid int, packet interface{}, players map[i
|
||||||
}
|
}
|
||||||
for gateSess, v := range mgs {
|
for gateSess, v := range mgs {
|
||||||
if gateSess != nil && len(v) != 0 {
|
if gateSess != nil && len(v) != 0 {
|
||||||
pack, err := common.CreateMulticastPacket(packetid, packet, v...)
|
action.MulticastMessageToServer(gateSess, packetid, packet, v...)
|
||||||
if err == nil {
|
|
||||||
gateSess.Send(int(srvlibproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"mongo.games.com/goserver/core/task"
|
"mongo.games.com/goserver/core/task"
|
||||||
"mongo.games.com/goserver/core/utils"
|
"mongo.games.com/goserver/core/utils"
|
||||||
"mongo.games.com/goserver/srvlib"
|
"mongo.games.com/goserver/srvlib"
|
||||||
|
"mongo.games.com/goserver/srvlib/action"
|
||||||
srvproto "mongo.games.com/goserver/srvlib/protocol"
|
srvproto "mongo.games.com/goserver/srvlib/protocol"
|
||||||
|
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
|
@ -290,14 +291,8 @@ func (this *PlayerMgr) UpdatePlayerToken(p *Player, newToken string) {
|
||||||
|
|
||||||
// BroadcastMessage 给所有玩家发消息
|
// BroadcastMessage 给所有玩家发消息
|
||||||
func (this *PlayerMgr) BroadcastMessage(packetid int, rawpack interface{}) bool {
|
func (this *PlayerMgr) BroadcastMessage(packetid int, rawpack interface{}) bool {
|
||||||
sc := &srvproto.BCSessionUnion{
|
sc := &srvproto.BCSessionUnion{}
|
||||||
Bccs: &srvproto.BCClientSession{},
|
action.BroadcastMessage(common.GetSelfAreaId(), srvlib.GateServerType, packetid, rawpack, sc)
|
||||||
}
|
|
||||||
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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,11 +314,7 @@ func (this *PlayerMgr) BroadcastMessageToPlatform(platform string, packetid int,
|
||||||
}
|
}
|
||||||
for gateSess, v := range mgs {
|
for gateSess, v := range mgs {
|
||||||
if gateSess != nil && len(v) != 0 {
|
if gateSess != nil && len(v) != 0 {
|
||||||
pack, err := common.CreateMulticastPacket(packetid, rawpack, v...)
|
action.MulticastMessageToServer(gateSess, packetid, rawpack, v...)
|
||||||
if err == nil {
|
|
||||||
proto.SetDefaults(pack)
|
|
||||||
gateSess.Send(int(srvproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -361,11 +352,7 @@ func (this *PlayerMgr) BroadcastMessageToPlatformByFunc(platform string, packeti
|
||||||
}
|
}
|
||||||
for gateSess, v := range mgs {
|
for gateSess, v := range mgs {
|
||||||
if gateSess != nil && len(v) != 0 {
|
if gateSess != nil && len(v) != 0 {
|
||||||
pack, err := common.CreateMulticastPacket(packetid, rawpack, v...)
|
action.MulticastMessageToServer(gateSess, packetid, rawpack, v...)
|
||||||
if err == nil {
|
|
||||||
proto.SetDefaults(pack)
|
|
||||||
gateSess.Send(int(srvproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -394,11 +381,7 @@ func (this *PlayerMgr) BroadcastMessageToPlatformWithHall(platform string, snid
|
||||||
}
|
}
|
||||||
for gateSess, v := range mgs {
|
for gateSess, v := range mgs {
|
||||||
if gateSess != nil && len(v) != 0 {
|
if gateSess != nil && len(v) != 0 {
|
||||||
pack, err := common.CreateMulticastPacket(packetid, rawpack, v...)
|
action.MulticastMessageToServer(gateSess, packetid, rawpack, v...)
|
||||||
if err == nil {
|
|
||||||
proto.SetDefaults(pack)
|
|
||||||
gateSess.Send(int(srvproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -441,11 +424,7 @@ func (this *PlayerMgr) BroadcastMessageToTarget(target []int32, packetid int, ra
|
||||||
|
|
||||||
for gateSess, v := range mgs {
|
for gateSess, v := range mgs {
|
||||||
if gateSess != nil && len(v) != 0 {
|
if gateSess != nil && len(v) != 0 {
|
||||||
pack, err := common.CreateMulticastPacket(packetid, rawpack, v...)
|
action.MulticastMessageToServer(gateSess, packetid, rawpack, v...)
|
||||||
if err == nil {
|
|
||||||
proto.SetDefaults(pack)
|
|
||||||
gateSess.Send(int(srvproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
"mongo.games.com/goserver/core/netlib"
|
"mongo.games.com/goserver/core/netlib"
|
||||||
"mongo.games.com/goserver/srvlib"
|
"mongo.games.com/goserver/srvlib"
|
||||||
|
"mongo.games.com/goserver/srvlib/action"
|
||||||
srvlibproto "mongo.games.com/goserver/srvlib/protocol"
|
srvlibproto "mongo.games.com/goserver/srvlib/protocol"
|
||||||
|
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
|
@ -864,11 +865,7 @@ func (this *Scene) Broadcast(packetId int, msg rawproto.Message, excludeSid int6
|
||||||
|
|
||||||
for gateSess, v := range mgs {
|
for gateSess, v := range mgs {
|
||||||
if gateSess != nil && len(v) != 0 {
|
if gateSess != nil && len(v) != 0 {
|
||||||
pack, err := common.CreateMulticastPacket(packetId, msg, v...)
|
action.MulticastMessageToServer(gateSess, packetId, msg, v...)
|
||||||
if err == nil {
|
|
||||||
proto.SetDefaults(pack)
|
|
||||||
gateSess.Send(int(srvlibproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,163 +0,0 @@
|
||||||
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
|
|
||||||
}
|
|
|
@ -1,99 +0,0 @@
|
||||||
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,6 +9,7 @@ import (
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
"mongo.games.com/goserver/core/netlib"
|
"mongo.games.com/goserver/core/netlib"
|
||||||
"mongo.games.com/goserver/core/timer"
|
"mongo.games.com/goserver/core/timer"
|
||||||
|
"mongo.games.com/goserver/srvlib/action"
|
||||||
srvproto "mongo.games.com/goserver/srvlib/protocol"
|
srvproto "mongo.games.com/goserver/srvlib/protocol"
|
||||||
|
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
|
@ -112,11 +113,7 @@ func (tm *TmMatch) BroadcastMessage(packetId int, rawPack interface{}) {
|
||||||
}
|
}
|
||||||
for gateSess, v := range mgs {
|
for gateSess, v := range mgs {
|
||||||
if gateSess != nil && len(v) != 0 {
|
if gateSess != nil && len(v) != 0 {
|
||||||
pack, err := common.CreateMulticastPacket(packetId, rawPack, v...)
|
action.MulticastMessageToServer(gateSess, packetId, rawPack, v...)
|
||||||
if err == nil {
|
|
||||||
proto.SetDefaults(pack)
|
|
||||||
gateSess.Send(int(srvproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue