竞技馆获奖假数据

This commit is contained in:
sk 2024-09-26 16:39:19 +08:00
parent 91bb5820f9
commit 7d8eaee2c2
24 changed files with 238 additions and 316 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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)
// 同步记牌器过期时间 // 同步记牌器过期时间

View File

@ -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
} }

View File

@ -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)
}
} }
} }
} }

View File

@ -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)
}
} }
} }
} }

View File

@ -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)
}
} }
} }

View File

@ -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
}

View File

@ -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
}

View File

@ -1,9 +0,0 @@
package api
import (
"mongo.games.com/game/common"
)
func init() {
common.RegisterBoardCastHandler()
}

View File

@ -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 {

View File

@ -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
}
} }

View File

@ -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 (

View File

@ -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; //

View File

@ -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)
}
} }

53
ranksrv/com/logchannel.go Normal file
View File

@ -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{})
}

View File

@ -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)

View File

@ -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)
}

View File

@ -694,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{})

View File

@ -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)
}
} }
} }
} }

View File

@ -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)
}
} }
} }
} }

View File

@ -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)
}
} }
} }
} }

View File

@ -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)
}
} }
} }
} }

View File

@ -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)
}
} }
} }
} }