Merge remote-tracking branch 'origin/develop' into dev_slots
This commit is contained in:
commit
29e9c7bfe8
|
@ -1,50 +0,0 @@
|
||||||
package common
|
|
||||||
|
|
||||||
import (
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
A_USER_BLACK = 1 //增加黑名单
|
|
||||||
)
|
|
||||||
|
|
||||||
type Action struct {
|
|
||||||
ActionID int //执行id
|
|
||||||
ActionParamInt64 []int //整形参数
|
|
||||||
ActionParamFloat []float64 //浮点参数
|
|
||||||
ActionParamString []string //字符串参数
|
|
||||||
}
|
|
||||||
|
|
||||||
var ActionMgrSington = &ActionMgr{
|
|
||||||
pool: make(map[int]ActionBase),
|
|
||||||
}
|
|
||||||
|
|
||||||
type ActionMgr struct {
|
|
||||||
pool map[int]ActionBase
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ActionMgr) ActionGroup(need interface{}, action []*Action) bool {
|
|
||||||
for i := 0; i < len(action); i++ {
|
|
||||||
this.action(need, action[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ActionMgr) action(need interface{}, action *Action) bool {
|
|
||||||
a, ok := this.pool[action.ActionID]
|
|
||||||
if !ok {
|
|
||||||
logger.Logger.Warnf("no this action %v", action.ActionID)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return a.Action(need, action)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ActionMgr) Register(cid int, c ActionBase) {
|
|
||||||
this.pool[cid] = c
|
|
||||||
}
|
|
||||||
|
|
||||||
type ActionBase interface {
|
|
||||||
Action(need interface{}, action *Action) bool
|
|
||||||
}
|
|
|
@ -1,54 +1,55 @@
|
||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"mongo.games.com/game/protocol/server"
|
|
||||||
"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/mongo"
|
||||||
"mongo.games.com/goserver/core/netlib"
|
"mongo.games.com/goserver/core/netlib"
|
||||||
|
|
||||||
|
"mongo.games.com/game/protocol/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GameSessState 服务状态
|
||||||
type GameSessState int
|
type GameSessState int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
GAME_SESS_STATE_OFF GameSessState = iota //关闭状态
|
GameSessStateOff GameSessState = iota //关闭状态
|
||||||
GAME_SESS_STATE_ON //开启状态
|
GameSessStateOn //开启状态
|
||||||
)
|
)
|
||||||
|
|
||||||
var ServerCtrlCallback func(int32)
|
var SrvIsMaintaining = true
|
||||||
|
|
||||||
func RegisteServerCtrlCallback(cb func(int32)) {
|
var ServerCtrlCallback func(msg *server.ServerCtrl)
|
||||||
|
|
||||||
|
func RegisterServerCtrlCallback(cb func(msg *server.ServerCtrl)) {
|
||||||
ServerCtrlCallback = cb
|
ServerCtrlCallback = cb
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServerCtrlPacketFactory struct {
|
func init() {
|
||||||
|
netlib.Register(int(server.SSPacketID_PACKET_MS_SRVCTRL), &server.ServerCtrl{}, ServerCtrlHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServerCtrlHandler struct {
|
// ServerCtrlHandler 服务器控制,通用事件
|
||||||
}
|
func ServerCtrlHandler(s *netlib.Session, packetid int, data interface{}) error {
|
||||||
|
logger.Logger.Infof("ServerCtrlHandler %v", data)
|
||||||
|
msg, ok := data.(*server.ServerCtrl)
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
switch msg.GetCtrlCode() {
|
||||||
|
case SrvCtrlCloseCode:
|
||||||
|
module.Stop()
|
||||||
|
|
||||||
func (this *ServerCtrlPacketFactory) CreatePacket() interface{} {
|
case SrvCtrlResetMgoSession:
|
||||||
pack := &server.ServerCtrl{}
|
mongo.ResetAllSession()
|
||||||
return pack
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ServerCtrlHandler) Process(s *netlib.Session, packetid int, data interface{}) error {
|
default:
|
||||||
|
logger.Logger.Errorf("unknow server ctrl %v", msg)
|
||||||
|
}
|
||||||
|
|
||||||
if sc, ok := data.(*server.ServerCtrl); ok {
|
// 服务自己处理的特殊事件
|
||||||
logger.Logger.Trace("ServerCtrlHandler.Process== ", *sc)
|
if ServerCtrlCallback != nil {
|
||||||
switch sc.GetCtrlCode() {
|
ServerCtrlCallback(msg)
|
||||||
case SrvCtrlCloseCode:
|
|
||||||
module.Stop()
|
|
||||||
}
|
|
||||||
|
|
||||||
//回调
|
|
||||||
if ServerCtrlCallback != nil {
|
|
||||||
ServerCtrlCallback(sc.GetCtrlCode())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
netlib.RegisterHandler(int(server.SSPacketID_PACKET_MS_SRVCTRL), &ServerCtrlHandler{})
|
|
||||||
netlib.RegisterFactory(int(server.SSPacketID_PACKET_MS_SRVCTRL), &ServerCtrlPacketFactory{})
|
|
||||||
}
|
|
||||||
|
|
172
common/aes.go
172
common/aes.go
|
@ -1,172 +0,0 @@
|
||||||
package common
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"crypto/aes"
|
|
||||||
"crypto/cipher"
|
|
||||||
"encoding/base64"
|
|
||||||
"fmt"
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
|
||||||
"regexp"
|
|
||||||
"strconv"
|
|
||||||
)
|
|
||||||
|
|
||||||
var key = []byte("kjh-vgjhhionoommmkokmokoo$%JH")
|
|
||||||
|
|
||||||
// 加密
|
|
||||||
func EnCrypt(orig []byte) (str string) {
|
|
||||||
defer func() {
|
|
||||||
err := recover()
|
|
||||||
if err != nil {
|
|
||||||
logger.Logger.Errorf("EnCrypt %v Error %v", string(orig), err)
|
|
||||||
str = string(orig)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
//将秘钥中的每个字节累加,通过sum实现orig的加密工作
|
|
||||||
sum := 0
|
|
||||||
for i := 0; i < len(key); i++ {
|
|
||||||
sum += int(key[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
//给明文补码
|
|
||||||
var pkcs_code = PKCS5Padding(orig, 8)
|
|
||||||
|
|
||||||
//通过秘钥,对补码后的明文进行加密
|
|
||||||
for j := 0; j < len(pkcs_code); j++ {
|
|
||||||
pkcs_code[j] += byte(sum)
|
|
||||||
}
|
|
||||||
//base64.URLEncoding.EncodeToString()
|
|
||||||
return base64.URLEncoding.EncodeToString(pkcs_code)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 补码
|
|
||||||
func PKCS5Padding(orig []byte, size int) []byte {
|
|
||||||
//计算明文的长度
|
|
||||||
length := len(orig)
|
|
||||||
padding := size - length%size
|
|
||||||
//向byte类型的数组中重复添加padding
|
|
||||||
repeats := bytes.Repeat([]byte{byte(padding)}, padding)
|
|
||||||
return append(orig, repeats...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 解密
|
|
||||||
func DeCrypt(text string) (str string) {
|
|
||||||
defer func() {
|
|
||||||
err := recover()
|
|
||||||
if err != nil {
|
|
||||||
logger.Logger.Errorf("DeCrypt %v Error %v", text, err)
|
|
||||||
str = text
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
//orig, err := base64.StdEncoding.DecodeString(text)
|
|
||||||
orig, err := base64.URLEncoding.DecodeString(text)
|
|
||||||
if err != nil {
|
|
||||||
return "密文类型错误"
|
|
||||||
}
|
|
||||||
sum := 0
|
|
||||||
for i := 0; i < len(key); i++ {
|
|
||||||
sum += int(key[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
//解密
|
|
||||||
for j := 0; j < len(orig); j++ {
|
|
||||||
orig[j] -= byte(sum)
|
|
||||||
}
|
|
||||||
|
|
||||||
//去码
|
|
||||||
var pkcs_unCode = PKCS5UnPadding(orig)
|
|
||||||
return string(pkcs_unCode)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 去码
|
|
||||||
func PKCS5UnPadding(orig []byte) []byte {
|
|
||||||
//获取最后一位补码的数字
|
|
||||||
var tail = int(orig[len(orig)-1])
|
|
||||||
return orig[:(len(orig) - tail)]
|
|
||||||
}
|
|
||||||
|
|
||||||
var aesRule, _ = regexp.Compile(`^[0-9]+$`)
|
|
||||||
|
|
||||||
const (
|
|
||||||
aeskey = "DoNotEditThisKeyDoNotEditThisKey" // 加密的密钥,绝不可以更改
|
|
||||||
)
|
|
||||||
|
|
||||||
// 下面的字符串,也绝不可以更改
|
|
||||||
var defaultLetters = []rune("idjGfiRogsFnkdKgokdfgdow07u6978uxcvvLiPiDfjafOd2fuFJYYGBJuykbvfk")
|
|
||||||
|
|
||||||
func AesEncrypt(origDataStr string) (str string) {
|
|
||||||
defer func() {
|
|
||||||
err := recover()
|
|
||||||
if err != nil {
|
|
||||||
logger.Logger.Errorf("AesEncrypt %v Error %v", origDataStr, err)
|
|
||||||
str = origDataStr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
strlen := len(origDataStr)
|
|
||||||
b := aesRule.MatchString(origDataStr)
|
|
||||||
//不全是数字,或长度为零,不加密
|
|
||||||
if !b || strlen == 0 {
|
|
||||||
return origDataStr
|
|
||||||
}
|
|
||||||
phonenum, errint := strconv.Atoi(origDataStr)
|
|
||||||
if errint != nil {
|
|
||||||
return origDataStr
|
|
||||||
}
|
|
||||||
|
|
||||||
text := []byte(origDataStr)
|
|
||||||
//指定加密、解密算法为AES,返回一个AES的Block接口对象
|
|
||||||
block, err := aes.NewCipher([]byte(aeskey))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
//指定计数器,长度必须等于block的块尺寸
|
|
||||||
iv := string(defaultLetters[phonenum%(len(defaultLetters))])
|
|
||||||
count := []byte(fmt.Sprintf("%016v", iv))
|
|
||||||
//指定分组模式
|
|
||||||
blockMode := cipher.NewCTR(block, count)
|
|
||||||
//执行加密、解密操作
|
|
||||||
message := make([]byte, len(text))
|
|
||||||
blockMode.XORKeyStream(message, text)
|
|
||||||
//返回明文或密文
|
|
||||||
return fmt.Sprintf("%v%v", iv, base64.StdEncoding.EncodeToString(message))
|
|
||||||
//return base64.StdEncoding.EncodeToString(message)
|
|
||||||
}
|
|
||||||
|
|
||||||
func AesDecrypt(cryptedstr string) (str string) {
|
|
||||||
defer func() {
|
|
||||||
err := recover()
|
|
||||||
if err != nil {
|
|
||||||
logger.Logger.Errorf("AesDecrypt %v Error %v", cryptedstr, err)
|
|
||||||
str = cryptedstr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
strlen := len(cryptedstr)
|
|
||||||
b := aesRule.MatchString(cryptedstr)
|
|
||||||
//全是数字,或长度为零,不解密
|
|
||||||
if b || strlen == 0 {
|
|
||||||
return cryptedstr
|
|
||||||
}
|
|
||||||
|
|
||||||
iv := cryptedstr[:1]
|
|
||||||
str = cryptedstr[1:]
|
|
||||||
text, err := base64.StdEncoding.DecodeString(str)
|
|
||||||
if err != nil {
|
|
||||||
logger.Logger.Errorf("AesDecrypt %v Err:%v", cryptedstr, err)
|
|
||||||
return cryptedstr
|
|
||||||
}
|
|
||||||
|
|
||||||
//指定加密、解密算法为AES,返回一个AES的Block接口对象
|
|
||||||
block, err := aes.NewCipher([]byte(aeskey))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
//指定计数器,长度必须等于block的块尺寸
|
|
||||||
count := []byte(fmt.Sprintf("%016v", iv))
|
|
||||||
//指定分组模式
|
|
||||||
blockMode := cipher.NewCTR(block, count)
|
|
||||||
//执行加密、解密操作
|
|
||||||
message := make([]byte, len(text))
|
|
||||||
blockMode.XORKeyStream(message, text)
|
|
||||||
//返回明文或密文
|
|
||||||
return string(message)
|
|
||||||
}
|
|
|
@ -6,6 +6,14 @@ import (
|
||||||
"mongo.games.com/goserver/core/module"
|
"mongo.games.com/goserver/core/module"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
时钟
|
||||||
|
*/
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
module.RegisteModule(ClockMgrSingleton, time.Millisecond*500, 0)
|
||||||
|
}
|
||||||
|
|
||||||
var ClockMgrSingleton = &ClockMgr{
|
var ClockMgrSingleton = &ClockMgr{
|
||||||
LastHour: -1,
|
LastHour: -1,
|
||||||
LastDay: -1,
|
LastDay: -1,
|
||||||
|
@ -99,9 +107,9 @@ func (this *ClockMgr) Update() {
|
||||||
this.LastSec = sec
|
this.LastSec = sec
|
||||||
this.fireSecondEvent()
|
this.fireSecondEvent()
|
||||||
|
|
||||||
min := tNow.Minute()
|
minute := tNow.Minute()
|
||||||
if min != this.LastMini {
|
if minute != this.LastMini {
|
||||||
this.LastMini = min
|
this.LastMini = minute
|
||||||
this.fireMinuteEvent()
|
this.fireMinuteEvent()
|
||||||
|
|
||||||
hour := tNow.Hour()
|
hour := tNow.Hour()
|
||||||
|
@ -182,6 +190,87 @@ func (this *ClockMgr) GetLast() (int, int, int, int, int, int) {
|
||||||
return this.LastSec, this.LastMini, this.LastHour, this.LastDay, this.LastWeek, int(this.LastMonth)
|
return this.LastSec, this.LastMini, this.LastHour, this.LastDay, this.LastWeek, int(this.LastMonth)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
type ClockFunc struct {
|
||||||
module.RegisteModule(ClockMgrSingleton, time.Millisecond*500, 0)
|
event int
|
||||||
|
OnSecTimerFunc func()
|
||||||
|
OnMiniTimerFunc func()
|
||||||
|
OnHourTimerFunc func()
|
||||||
|
OnDayTimerFunc func()
|
||||||
|
OnWeekTimerFunc func()
|
||||||
|
OnMonthTimerFunc func()
|
||||||
|
OnShutdownFunc func()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClockFunc) InterestClockEvent() int { return s.event }
|
||||||
|
|
||||||
|
func (s *ClockFunc) OnSecTimer() {
|
||||||
|
if s.OnSecTimerFunc != nil {
|
||||||
|
s.OnSecTimerFunc()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClockFunc) OnMiniTimer() {
|
||||||
|
if s.OnMiniTimerFunc != nil {
|
||||||
|
s.OnMiniTimerFunc()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClockFunc) OnHourTimer() {
|
||||||
|
if s.OnHourTimerFunc != nil {
|
||||||
|
s.OnHourTimerFunc()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClockFunc) OnDayTimer() {
|
||||||
|
if s.OnDayTimerFunc != nil {
|
||||||
|
s.OnDayTimerFunc()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClockFunc) OnWeekTimer() {
|
||||||
|
if s.OnWeekTimerFunc != nil {
|
||||||
|
s.OnWeekTimerFunc()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClockFunc) OnMonthTimer() {
|
||||||
|
if s.OnMonthTimerFunc != nil {
|
||||||
|
s.OnMonthTimerFunc()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClockFunc) OnShutdown() {
|
||||||
|
if s.OnShutdownFunc != nil {
|
||||||
|
s.OnShutdownFunc()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterClockFunc 注册时钟事件
|
||||||
|
func RegisterClockFunc(fs *ClockFunc) {
|
||||||
|
if fs == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if fs.OnSecTimerFunc != nil {
|
||||||
|
fs.event = fs.event | ClockEventSecond
|
||||||
|
}
|
||||||
|
if fs.OnMiniTimerFunc != nil {
|
||||||
|
fs.event = fs.event | ClockEventMinute
|
||||||
|
}
|
||||||
|
if fs.OnHourTimerFunc != nil {
|
||||||
|
fs.event = fs.event | ClockEventHour
|
||||||
|
}
|
||||||
|
if fs.OnDayTimerFunc != nil {
|
||||||
|
fs.event = fs.event | ClockEventDay
|
||||||
|
}
|
||||||
|
if fs.OnWeekTimerFunc != nil {
|
||||||
|
fs.event = fs.event | ClockEventWeek
|
||||||
|
}
|
||||||
|
if fs.OnMonthTimerFunc != nil {
|
||||||
|
fs.event = fs.event | ClockEventMonth
|
||||||
|
}
|
||||||
|
if fs.OnShutdownFunc != nil {
|
||||||
|
fs.event = fs.event | ClockEventShutdown
|
||||||
|
}
|
||||||
|
|
||||||
|
ClockMgrSingleton.RegisterSinker(fs)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
protocol_game "mongo.games.com/game/protocol/server"
|
protocol_game "mongo.games.com/game/protocol/server"
|
||||||
"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/protocol"
|
"mongo.games.com/goserver/srvlib/protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -45,11 +44,11 @@ func createMulticastPacket(packetid int, data interface{}, sis ...*protocol.MCSe
|
||||||
return pack, nil
|
return pack, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendToGate(sid int64, packetid int, rawpack interface{}, s *netlib.Session) bool {
|
func SendToGate(sid int64, packetId int, pack interface{}, s *netlib.Session) bool {
|
||||||
if s == nil || rawpack == nil || sid == 0 {
|
if s == nil || pack == nil || sid == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
pack, err := createMulticastPacket(packetid, rawpack,
|
pack, err := createMulticastPacket(packetId, pack,
|
||||||
&protocol.MCSessionUnion{
|
&protocol.MCSessionUnion{
|
||||||
Mccs: &protocol.MCClientSession{
|
Mccs: &protocol.MCClientSession{
|
||||||
SId: proto.Int64(sid)}})
|
SId: proto.Int64(sid)}})
|
||||||
|
@ -63,25 +62,17 @@ func SendToGate(sid int64, packetid int, rawpack interface{}, s *netlib.Session)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendToActThrSrv(packetid int, rawpack interface{}) bool {
|
// TransmitToServer 转发消息到指定服务器
|
||||||
if rawpack == nil {
|
// sid: 客户端连接标识
|
||||||
return false
|
// packetId: 消息id
|
||||||
}
|
// pack: 消息内容
|
||||||
|
// s: 接收消息的服务器连接
|
||||||
replaySess := srvlib.ServerSessionMgrSington.GetSession(GetSelfAreaId(), ActThrServerType, ActThrServerID)
|
func TransmitToServer(sid int64, packetId int, pack interface{}, s *netlib.Session) bool {
|
||||||
if replaySess != nil {
|
if d, err := netlib.MarshalPacket(packetId, pack); err == nil {
|
||||||
return replaySess.Send(int(packetid), rawpack)
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func TransmitToServer(sid int64, packetid int, rawpack interface{}, s *netlib.Session) bool {
|
|
||||||
if d, err := netlib.MarshalPacket(packetid, rawpack); err == nil {
|
|
||||||
pack := &protocol_game.SSTransmit{
|
pack := &protocol_game.SSTransmit{
|
||||||
PacketData: d,
|
PacketData: d,
|
||||||
SessionId: sid,
|
SessionId: sid,
|
||||||
}
|
}
|
||||||
proto.SetDefaults(pack)
|
|
||||||
return s.Send(int(protocol_game.TransmitPacketID_PACKET_SS_PACKET_TRANSMIT), pack, true)
|
return s.Send(int(protocol_game.TransmitPacketID_PACKET_SS_PACKET_TRANSMIT), pack, true)
|
||||||
} else {
|
} else {
|
||||||
logger.Logger.Warn("TransmitToServer err:", err)
|
logger.Logger.Warn("TransmitToServer err:", err)
|
||||||
|
|
|
@ -807,9 +807,10 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
AttributeGuideStep = 1 // 引导步骤
|
AttributeGuideStep = 1 // 引导步骤
|
||||||
AttributeGuideSkip = 2 // 跳过引导
|
AttributeGuideSkip = 2 // 跳过引导
|
||||||
AttributeGuideTest = 3 // 测试引导
|
AttributeGuideTest = 3 // 测试引导
|
||||||
|
AttributeGuideCustom = 4 // 竞技馆引导页
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -861,3 +862,8 @@ const (
|
||||||
PlayerChangeTypeCoin = 0 // 金币
|
PlayerChangeTypeCoin = 0 // 金币
|
||||||
PlayerChangeTypeNum = 1 // 积分
|
PlayerChangeTypeNum = 1 // 积分
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 玩家状态标记
|
||||||
|
const (
|
||||||
|
PlayerFlagsGuideCustom = 1 << iota // 竞技馆引导页关闭状态
|
||||||
|
)
|
||||||
|
|
Binary file not shown.
|
@ -486,13 +486,13 @@
|
||||||
"Id": 40003,
|
"Id": 40003,
|
||||||
"Name": "娃娃卡",
|
"Name": "娃娃卡",
|
||||||
"ShowLocation": [
|
"ShowLocation": [
|
||||||
1,
|
0,
|
||||||
1,
|
0,
|
||||||
0
|
1
|
||||||
],
|
],
|
||||||
"Classify": [
|
"Classify": [
|
||||||
1,
|
1,
|
||||||
1,
|
0,
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
"Type": 23,
|
"Type": 23,
|
||||||
|
@ -6270,9 +6270,8 @@
|
||||||
1
|
1
|
||||||
],
|
],
|
||||||
"SaleType": 1,
|
"SaleType": 1,
|
||||||
"SaleGold": 5000,
|
"SaleGold": 30,
|
||||||
"CompositionMax": 1,
|
"CompositionMax": 1,
|
||||||
"Time": 360,
|
|
||||||
"Location": "0",
|
"Location": "0",
|
||||||
"Describe": "可联系客服兑换实物奖励",
|
"Describe": "可联系客服兑换实物奖励",
|
||||||
"Gain": {
|
"Gain": {
|
||||||
|
@ -6308,9 +6307,8 @@
|
||||||
1
|
1
|
||||||
],
|
],
|
||||||
"SaleType": 1,
|
"SaleType": 1,
|
||||||
"SaleGold": 5000,
|
"SaleGold": 30,
|
||||||
"CompositionMax": 1,
|
"CompositionMax": 1,
|
||||||
"Time": 360,
|
|
||||||
"Location": "0",
|
"Location": "0",
|
||||||
"Describe": "可联系客服兑换实物奖励",
|
"Describe": "可联系客服兑换实物奖励",
|
||||||
"Gain": {
|
"Gain": {
|
||||||
|
|
Binary file not shown.
BIN
data/DB_Task.dat
BIN
data/DB_Task.dat
Binary file not shown.
|
@ -116,23 +116,33 @@ func (svc *ItemLogSvc) UpdateState(req *model.UpdateParam, res *model.UpdateRes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *ItemLogSvc) GetClawdollItemLog(args *model.ClawdollItemLogReq, ret *model.GetClawdollItemLogRet) (err error) {
|
func (svc *ItemLogSvc) GetClawdollItemLog(args *model.ClawdollItemLogReq, ret *model.GetClawdollItemLogRet) (err error) {
|
||||||
//itemTypeIds := []int32{common.GainWayClawdollCostItem, common.GainWayItemShopChangeDoll}
|
var sql []bson.M
|
||||||
|
|
||||||
cond := bson.M{"snid": args.Snid, "typeid": bson.M{"$in": args.TypeIds}}
|
var Logs []model.RetClawdollItemLog
|
||||||
c := ItemLogsCollection(args.Platform)
|
for _, typeId := range args.TypeIds {
|
||||||
if c == nil {
|
var SubLogs []model.RetClawdollItemLog
|
||||||
return
|
sql = append(sql, bson.M{"snid": args.Snid, "typeid": typeId})
|
||||||
|
|
||||||
|
switch typeId {
|
||||||
|
case common.GainWay_Shop_Buy: // 商城兑换
|
||||||
|
sql = append(sql, bson.M{"itemid": common.ItemIDClawdoll})
|
||||||
|
case common.GainWayItemShopChangeDoll: // 积分支出
|
||||||
|
sql = append(sql, bson.M{"itemid": common.ItemDollCard})
|
||||||
|
case common.GainWayItemFenGain: // 积分获取
|
||||||
|
sql = append(sql, bson.M{"itemid": common.ItemDollCard})
|
||||||
|
}
|
||||||
|
|
||||||
|
c := ItemLogsCollection(args.Platform)
|
||||||
|
if c == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = c.Find(bson.M{"$and": sql}).Select(bson.M{"itemid": 1, "createts": 1, "typeid": 1, "count": 1, "logtype": 1}).All(&SubLogs)
|
||||||
|
|
||||||
|
Logs = append(Logs, SubLogs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
type RetClawdollItemLog struct {
|
ret.Logs = Logs
|
||||||
ItemId int32 //道具ID
|
|
||||||
Time int64 //时间
|
|
||||||
TypeId int32 //道具记录类型
|
|
||||||
Num int64 //数量
|
|
||||||
LogType int32 //记录类型 0.获取 1.消耗
|
|
||||||
}
|
|
||||||
|
|
||||||
err = c.Find(cond).Limit(1000).Select(bson.M{"itemid": 1, "createts": 1, "typeid": 1, "count": 1, "logtype": 1}).All(&ret.Logs)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +156,7 @@ func (svc *ItemLogSvc) GetClawdollSuccessItemLog(args *model.ClawdollSuccessItem
|
||||||
}
|
}
|
||||||
|
|
||||||
var datas []model.ItemLog
|
var datas []model.ItemLog
|
||||||
err = c.Find(cond).Limit(1000).All(&datas)
|
err = c.Find(cond).All(&datas)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Logger.Error("GetClawdollSuccessItemLog error: ", err)
|
logger.Logger.Error("GetClawdollSuccessItemLog error: ", err)
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -1844,7 +1844,7 @@ func (this *Scene) RandInt(args ...int) int {
|
||||||
|
|
||||||
func (this *Scene) CheckNeedDestroy() bool {
|
func (this *Scene) CheckNeedDestroy() bool {
|
||||||
//if common.IsLocalGame(this.GameId) {
|
//if common.IsLocalGame(this.GameId) {
|
||||||
return ServerStateMgr.GetState() == common.GAME_SESS_STATE_OFF || this.graceDestroy
|
return ServerStateMgr.GetState() == common.GameSessStateOff || this.graceDestroy
|
||||||
//} else {
|
//} else {
|
||||||
// return (ServerStateMgr.GetState() == common.GAME_SESS_STATE_OFF || this.graceDestroy) || (this.IsPrivateScene() && this.NumOfGames >= this.TotalOfGames)
|
// return (ServerStateMgr.GetState() == common.GAME_SESS_STATE_OFF || this.graceDestroy) || (this.IsPrivateScene() && this.NumOfGames >= this.TotalOfGames)
|
||||||
//}
|
//}
|
||||||
|
|
|
@ -1,25 +1,26 @@
|
||||||
package base
|
package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
"mongo.games.com/goserver/srvlib"
|
||||||
|
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/proto"
|
"mongo.games.com/game/proto"
|
||||||
"mongo.games.com/game/protocol/server"
|
"mongo.games.com/game/protocol/server"
|
||||||
"mongo.games.com/goserver/core/mongo"
|
|
||||||
"mongo.games.com/goserver/srvlib"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
common.RegisteServerCtrlCallback(func(code int32) {
|
common.RegisterServerCtrlCallback(func(msg *server.ServerCtrl) {
|
||||||
switch code {
|
switch msg.GetCtrlCode() {
|
||||||
case common.SrvCtrlStateSwitchCode:
|
case common.SrvCtrlStateSwitchCode:
|
||||||
pack := &server.ServerStateSwitch{
|
pack := &server.ServerStateSwitch{
|
||||||
SrvType: proto.Int(common.GetSelfSrvType()),
|
SrvType: proto.Int(common.GetSelfSrvType()),
|
||||||
SrvId: proto.Int(common.GetSelfSrvId()),
|
SrvId: proto.Int(common.GetSelfSrvId()),
|
||||||
}
|
}
|
||||||
proto.SetDefaults(pack)
|
|
||||||
srvlib.ServerSessionMgrSington.Broadcast(int(server.SSPacketID_PACKET_GB_STATE_SWITCH), pack, common.GetSelfAreaId(), srvlib.WorldServerType)
|
srvlib.ServerSessionMgrSington.Broadcast(int(server.SSPacketID_PACKET_GB_STATE_SWITCH), pack, common.GetSelfAreaId(), srvlib.WorldServerType)
|
||||||
case common.SrvCtrlResetMgoSession:
|
|
||||||
mongo.ResetAllSession()
|
default:
|
||||||
|
logger.Logger.Errorf("unknow server ctrl code:%d", msg.GetCtrlCode())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var ServerStateMgr = &ServerStateManager{
|
var ServerStateMgr = &ServerStateManager{
|
||||||
State: common.GAME_SESS_STATE_ON,
|
State: common.GameSessStateOn,
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServerStateManager struct {
|
type ServerStateManager struct {
|
||||||
|
@ -13,7 +13,7 @@ type ServerStateManager struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ServerStateManager) Init() {
|
func (this *ServerStateManager) Init() {
|
||||||
this.State = common.GAME_SESS_STATE_ON
|
this.State = common.GameSessStateOn
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ServerStateManager) SetState(state common.GameSessState) {
|
func (this *ServerStateManager) SetState(state common.GameSessState) {
|
||||||
|
|
|
@ -1968,7 +1968,7 @@ func (this *TienLenSceneData) TrySmallGameBilled() {
|
||||||
score = losePlayerCoin
|
score = losePlayerCoin
|
||||||
}
|
}
|
||||||
//判断宠物技能生不生效
|
//判断宠物技能生不生效
|
||||||
if losePlayer.PetUseSkill() {
|
if losePlayer.PetUseSkill() && !this.IsCustom() && !this.IsMatchScene() {
|
||||||
score = 0
|
score = 0
|
||||||
//通知客户端宠物技能生效 炸弹不扣分
|
//通知客户端宠物技能生效 炸弹不扣分
|
||||||
pack := &tienlen.SCTienLenPetSkillRes{}
|
pack := &tienlen.SCTienLenPetSkillRes{}
|
||||||
|
@ -1997,7 +1997,7 @@ func (this *TienLenSceneData) TrySmallGameBilled() {
|
||||||
winPlayer.bombRankScore += rankScore * rule.RankBaseScore
|
winPlayer.bombRankScore += rankScore * rule.RankBaseScore
|
||||||
}
|
}
|
||||||
//lose
|
//lose
|
||||||
if this.IsMatchScene() && this.IsCustom() {
|
if this.IsMatchScene() || this.IsCustom() {
|
||||||
losePlayer.AddCoinNoLog(-score, 0)
|
losePlayer.AddCoinNoLog(-score, 0)
|
||||||
} else {
|
} else {
|
||||||
losePlayer.AddCoin(-score, common.GainWay_CoinSceneLost, 0, "system", this.GetSceneName())
|
losePlayer.AddCoin(-score, common.GainWay_CoinSceneLost, 0, "system", this.GetSceneName())
|
||||||
|
|
|
@ -1,25 +1,26 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
"mongo.games.com/goserver/srvlib"
|
||||||
|
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/proto"
|
"mongo.games.com/game/proto"
|
||||||
"mongo.games.com/game/protocol/server"
|
"mongo.games.com/game/protocol/server"
|
||||||
"mongo.games.com/goserver/core/mongo"
|
|
||||||
"mongo.games.com/goserver/srvlib"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
common.RegisteServerCtrlCallback(func(code int32) {
|
common.RegisterServerCtrlCallback(func(msg *server.ServerCtrl) {
|
||||||
switch code {
|
switch msg.GetCtrlCode() {
|
||||||
case common.SrvCtrlStateSwitchCode:
|
case common.SrvCtrlStateSwitchCode:
|
||||||
pack := &server.ServerStateSwitch{
|
pack := &server.ServerStateSwitch{
|
||||||
SrvType: proto.Int(common.GetSelfSrvType()),
|
SrvType: proto.Int(common.GetSelfSrvType()),
|
||||||
SrvId: proto.Int(common.GetSelfSrvId()),
|
SrvId: proto.Int(common.GetSelfSrvId()),
|
||||||
}
|
}
|
||||||
proto.SetDefaults(pack)
|
|
||||||
srvlib.ServerSessionMgrSington.Broadcast(int(server.SSPacketID_PACKET_GB_STATE_SWITCH), pack, common.GetSelfAreaId(), srvlib.WorldServerType)
|
srvlib.ServerSessionMgrSington.Broadcast(int(server.SSPacketID_PACKET_GB_STATE_SWITCH), pack, common.GetSelfAreaId(), srvlib.WorldServerType)
|
||||||
case common.SrvCtrlResetMgoSession:
|
|
||||||
mongo.ResetAllSession()
|
default:
|
||||||
|
logger.Logger.Errorf("unknown server ctrl code:%d", msg.GetCtrlCode())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,11 +132,19 @@ type ClawdollItemLogReq struct {
|
||||||
TypeIds []int32
|
TypeIds []int32
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetClawdollItemLogRet struct {
|
type RetClawdollItemLog struct {
|
||||||
Logs []ItemLog
|
ItemId int32 //道具ID
|
||||||
|
CreateTs int64 //记录时间
|
||||||
|
TypeId int32 // 变化类型
|
||||||
|
Count int64 //个数
|
||||||
|
LogType int32 //记录类型 0.获取 1.消耗
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetClawdollItemLog(plt string, snid int32, typeIds []int32) (logs []ItemLog, err error) {
|
type GetClawdollItemLogRet struct {
|
||||||
|
Logs []RetClawdollItemLog
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetClawdollItemLog(plt string, snid int32, typeIds []int32) (logs []RetClawdollItemLog, err error) {
|
||||||
|
|
||||||
if rpcCli == nil {
|
if rpcCli == nil {
|
||||||
logger.Logger.Error("model.GetClawdollItemLog rpcCli == nil")
|
logger.Logger.Error("model.GetClawdollItemLog rpcCli == nil")
|
||||||
|
|
|
@ -29,13 +29,6 @@ const (
|
||||||
VER_PLAYER_MAX
|
VER_PLAYER_MAX
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
PLAYER_FLAGS_PRIVILEGE int64 = 1 << iota
|
|
||||||
PLAYER_FLAGS_FIRSTGAME //首次游戏
|
|
||||||
PLAYER_FLAGS_FIRSTBINDTEL //首次绑定账号
|
|
||||||
PLAYER_FLAGS_CANREBATE //是否能够返利
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DEFAULT_PLAYER_SAFEBOX_PWD = "" //保险箱默认密码
|
DEFAULT_PLAYER_SAFEBOX_PWD = "" //保险箱默认密码
|
||||||
)
|
)
|
||||||
|
@ -402,7 +395,7 @@ type PlayerData struct {
|
||||||
InviterHead int32 //邀请人头像
|
InviterHead int32 //邀请人头像
|
||||||
BeUnderAgentCode string //隶属经销商(推广人)
|
BeUnderAgentCode string //隶属经销商(推广人)
|
||||||
SubBeUnderAgentCode string //经销商子id
|
SubBeUnderAgentCode string //经销商子id
|
||||||
Flags int64 //标记
|
Flags int //标记
|
||||||
GameCoinTs int64 //游服金币对账时间戳
|
GameCoinTs int64 //游服金币对账时间戳
|
||||||
Ver int32 //数据版本号
|
Ver int32 //数据版本号
|
||||||
CheckSum uint32 //校验码(预防暴库修改数据)
|
CheckSum uint32 //校验码(预防暴库修改数据)
|
||||||
|
@ -501,7 +494,7 @@ type PlayerData struct {
|
||||||
DiamondLotteryScore int64 //钻石抽奖幸运值
|
DiamondLotteryScore int64 //钻石抽奖幸运值
|
||||||
VCardCost int64 // 消耗v卡数量
|
VCardCost int64 // 消耗v卡数量
|
||||||
MoneyTotal int64 // 现金总充值金额,不包含api加币时的现金
|
MoneyTotal int64 // 现金总充值金额,不包含api加币时的现金
|
||||||
GuideStep int32 // 引导步骤;跳过引导后,该值会置为-1
|
GuideStep int32 // tienlen游戏引导步骤;跳过引导后,该值会置为-1
|
||||||
}
|
}
|
||||||
|
|
||||||
// 七日签到数据
|
// 七日签到数据
|
||||||
|
@ -802,15 +795,15 @@ func ConvertPlayerDataToWebData(param *WebPlayerDataParam) *webapi.PlayerData {
|
||||||
return pdfw
|
return pdfw
|
||||||
}
|
}
|
||||||
func (this *PlayerData) IsMarkFlag(flag int) bool {
|
func (this *PlayerData) IsMarkFlag(flag int) bool {
|
||||||
return this.Flags&(1<<flag) != 0
|
return this.Flags&flag != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *PlayerData) MarkFlag(flag int) {
|
func (this *PlayerData) MarkFlag(flag int) {
|
||||||
this.Flags |= (1 << flag)
|
this.Flags |= flag
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *PlayerData) UnmarkFlag(flag int) {
|
func (this *PlayerData) UnmarkFlag(flag int) {
|
||||||
this.Flags &= ^(1 << flag)
|
this.Flags &= ^flag
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *PlayerData) GetSnId() int32 {
|
func (this *PlayerData) GetSnId() int32 {
|
||||||
|
|
|
@ -10746,7 +10746,7 @@ type CSUpdateAttribute struct {
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Tp int32 `protobuf:"varint,1,opt,name=Tp,proto3" json:"Tp,omitempty"` // 1.更新新手引导阶段 2.跳过新手引导 3.更新新手引导状态(测试用)
|
Tp int32 `protobuf:"varint,1,opt,name=Tp,proto3" json:"Tp,omitempty"` // 1.更新新手引导阶段 2.跳过新手引导 3.更新新手引导状态(测试用) 4.竞技馆引导结束
|
||||||
Param []int64 `protobuf:"varint,2,rep,packed,name=Param,proto3" json:"Param,omitempty"`
|
Param []int64 `protobuf:"varint,2,rep,packed,name=Param,proto3" json:"Param,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1337,7 +1337,7 @@ message WindowsInfo{
|
||||||
|
|
||||||
//PACKET_CSUpdateAttribute
|
//PACKET_CSUpdateAttribute
|
||||||
message CSUpdateAttribute{
|
message CSUpdateAttribute{
|
||||||
int32 Tp = 1; // 1.更新新手引导阶段 2.跳过新手引导 3.更新新手引导状态(测试用)
|
int32 Tp = 1; // 1.更新新手引导阶段 2.跳过新手引导 3.更新新手引导状态(测试用) 4.竞技馆引导结束
|
||||||
repeated int64 Param = 2;
|
repeated int64 Param = 2;
|
||||||
}
|
}
|
||||||
//PACKET_SCUpdateAttribute
|
//PACKET_SCUpdateAttribute
|
||||||
|
|
|
@ -139,7 +139,7 @@ func (this *CSLoginHandler) Process(s *netlib.Session, packetid int, data interf
|
||||||
}
|
}
|
||||||
|
|
||||||
// 是否正在维护
|
// 是否正在维护
|
||||||
if model.GameParamData.SrvMaintain && SrvIsMaintaining {
|
if model.GameParamData.SrvMaintain && common.SrvIsMaintaining {
|
||||||
inWhiteList := false
|
inWhiteList := false
|
||||||
for i := 0; i < len(model.GMACData.WhiteList); i++ {
|
for i := 0; i < len(model.GMACData.WhiteList); i++ {
|
||||||
if model.GMACData.WhiteList[i] == csl.GetUsername() {
|
if model.GMACData.WhiteList[i] == csl.GetUsername() {
|
||||||
|
|
|
@ -3159,6 +3159,11 @@ func CSUpdateAttribute(s *netlib.Session, packetId int, data interface{}, sid in
|
||||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_Sucess
|
pack.OpRetCode = player_proto.OpResultCode_OPRC_Sucess
|
||||||
send()
|
send()
|
||||||
return nil
|
return nil
|
||||||
|
case common.AttributeGuideCustom:
|
||||||
|
p.MarkFlag(common.PlayerFlagsGuideCustom)
|
||||||
|
pack.OpRetCode = player_proto.OpResultCode_OPRC_Sucess
|
||||||
|
send()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -3180,7 +3185,7 @@ func CSClawdollItemLog(s *netlib.Session, packetId int, data interface{}, sid in
|
||||||
ret.TypeIds = append(ret.TypeIds, msg.TypeIds...)
|
ret.TypeIds = append(ret.TypeIds, msg.TypeIds...)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
var ItemUseLogs []model.ItemLog
|
var ItemUseLogs []model.RetClawdollItemLog
|
||||||
|
|
||||||
//娃娃机道具使用日志
|
//娃娃机道具使用日志
|
||||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||||
|
|
|
@ -296,18 +296,18 @@ func init() {
|
||||||
srvid := int(sr.GetSrvId())
|
srvid := int(sr.GetSrvId())
|
||||||
gameSess := GameSessMgrSington.GetGameSess(srvid)
|
gameSess := GameSessMgrSington.GetGameSess(srvid)
|
||||||
if gameSess != nil {
|
if gameSess != nil {
|
||||||
if gameSess.state == common.GAME_SESS_STATE_ON {
|
if gameSess.state == common.GameSessStateOn {
|
||||||
gameSess.SwitchState(common.GAME_SESS_STATE_OFF)
|
gameSess.SwitchState(common.GameSessStateOff)
|
||||||
} else {
|
} else {
|
||||||
gameSess.SwitchState(common.GAME_SESS_STATE_ON)
|
gameSess.SwitchState(common.GameSessStateOn)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gateSess := GameSessMgrSington.GetGateSess(srvid)
|
gateSess := GameSessMgrSington.GetGateSess(srvid)
|
||||||
if gateSess != nil {
|
if gateSess != nil {
|
||||||
if gateSess.state == common.GAME_SESS_STATE_ON {
|
if gateSess.state == common.GameSessStateOn {
|
||||||
gateSess.SwitchState(common.GAME_SESS_STATE_OFF)
|
gateSess.SwitchState(common.GameSessStateOff)
|
||||||
} else {
|
} else {
|
||||||
gateSess.SwitchState(common.GAME_SESS_STATE_ON)
|
gateSess.SwitchState(common.GameSessStateOn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -615,13 +615,7 @@ func (this *CSPMCmdHandler) Process(s *netlib.Session, packetid int, data interf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case common.PMCmd_Privilege:
|
case common.PMCmd_Privilege:
|
||||||
if p.GMLevel >= 3 {
|
|
||||||
if p.Flags&model.PLAYER_FLAGS_PRIVILEGE == 0 {
|
|
||||||
p.Flags |= model.PLAYER_FLAGS_PRIVILEGE
|
|
||||||
} else {
|
|
||||||
p.Flags &= ^model.PLAYER_FLAGS_PRIVILEGE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,13 +43,12 @@ type GameSession struct {
|
||||||
gameIds []int32
|
gameIds []int32
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构造函数
|
|
||||||
func NewGameSession(srvId, srvType int, s *netlib.Session) *GameSession {
|
func NewGameSession(srvId, srvType int, s *netlib.Session) *GameSession {
|
||||||
gs := &GameSession{
|
gs := &GameSession{
|
||||||
Session: s,
|
Session: s,
|
||||||
srvId: srvId,
|
srvId: srvId,
|
||||||
srvType: srvType,
|
srvType: srvType,
|
||||||
state: common.GAME_SESS_STATE_ON,
|
state: common.GameSessStateOn,
|
||||||
players: make(map[int32]*Player),
|
players: make(map[int32]*Player),
|
||||||
scenes: make(map[int]*Scene),
|
scenes: make(map[int]*Scene),
|
||||||
cps: make(map[string]*model.CoinPoolSetting),
|
cps: make(map[string]*model.CoinPoolSetting),
|
||||||
|
@ -57,13 +56,6 @@ func NewGameSession(srvId, srvType int, s *netlib.Session) *GameSession {
|
||||||
return gs
|
return gs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GameSession) RebindPlayerSnId(oldSnId, newSnId int32) {
|
|
||||||
if p, exist := this.players[oldSnId]; exist {
|
|
||||||
delete(this.players, oldSnId)
|
|
||||||
this.players[newSnId] = p
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *GameSession) GetSrvId() int32 {
|
func (this *GameSession) GetSrvId() int32 {
|
||||||
if this.Session == nil {
|
if this.Session == nil {
|
||||||
return 0
|
return 0
|
||||||
|
@ -85,7 +77,6 @@ func (this *GameSession) CloseAllScene() {
|
||||||
OpRetCode: gamehall_proto.OpResultCode_Game_OPRC_Sucess_Game,
|
OpRetCode: gamehall_proto.OpResultCode_Game_OPRC_Sucess_Game,
|
||||||
IsForce: proto.Int(1),
|
IsForce: proto.Int(1),
|
||||||
}
|
}
|
||||||
proto.SetDefaults(scDestroyRoom)
|
|
||||||
scene.Broadcast(int(gamehall_proto.GameHallPacketID_PACKET_SC_DESTROYROOM), scDestroyRoom, 0)
|
scene.Broadcast(int(gamehall_proto.GameHallPacketID_PACKET_SC_DESTROYROOM), scDestroyRoom, 0)
|
||||||
SceneMgrSingleton.DestroyScene(sceneId, true)
|
SceneMgrSingleton.DestroyScene(sceneId, true)
|
||||||
}
|
}
|
||||||
|
@ -105,11 +96,8 @@ func (this *GameSession) OnRegiste() {
|
||||||
|
|
||||||
// 注销事件
|
// 注销事件
|
||||||
func (this *GameSession) OnUnregiste() {
|
func (this *GameSession) OnUnregiste() {
|
||||||
//销毁比赛
|
|
||||||
//MatchMgrSington.DestroyAllMatchByGameSession(this)
|
|
||||||
//解散房间
|
//解散房间
|
||||||
this.CloseAllScene()
|
this.CloseAllScene()
|
||||||
|
|
||||||
GameSessionListenerSet.Range(func(key, val interface{}) bool {
|
GameSessionListenerSet.Range(func(key, val interface{}) bool {
|
||||||
if lis, ok := val.(GameSessionListener); ok {
|
if lis, ok := val.(GameSessionListener); ok {
|
||||||
lis.OnGameSessionUnregiste(this)
|
lis.OnGameSessionUnregiste(this)
|
||||||
|
@ -130,12 +118,13 @@ func (this *GameSession) SwitchState(state common.GameSessState) {
|
||||||
}
|
}
|
||||||
this.state = state
|
this.state = state
|
||||||
switch state {
|
switch state {
|
||||||
case common.GAME_SESS_STATE_ON:
|
case common.GameSessStateOn:
|
||||||
this.OnStateOn()
|
this.OnStateOn()
|
||||||
case common.GAME_SESS_STATE_OFF:
|
case common.GameSessStateOff:
|
||||||
this.OnStateOff()
|
this.OnStateOff()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GameSession) OnStateOn() {
|
func (this *GameSession) OnStateOn() {
|
||||||
pack := &server_proto.ServerState{
|
pack := &server_proto.ServerState{
|
||||||
SrvState: proto.Int(int(this.state)),
|
SrvState: proto.Int(int(this.state)),
|
||||||
|
@ -143,6 +132,7 @@ func (this *GameSession) OnStateOn() {
|
||||||
proto.SetDefaults(pack)
|
proto.SetDefaults(pack)
|
||||||
this.Send(int(server_proto.SSPacketID_PACKET_WG_SERVER_STATE), pack)
|
this.Send(int(server_proto.SSPacketID_PACKET_WG_SERVER_STATE), pack)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GameSession) OnStateOff() {
|
func (this *GameSession) OnStateOff() {
|
||||||
pack := &server_proto.ServerState{
|
pack := &server_proto.ServerState{
|
||||||
SrvState: proto.Int(int(this.state)),
|
SrvState: proto.Int(int(this.state)),
|
||||||
|
|
|
@ -2,21 +2,18 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
"mongo.games.com/game/protocol/webapi"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"mongo.games.com/game/common"
|
|
||||||
"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/protocol"
|
"mongo.games.com/goserver/srvlib/protocol"
|
||||||
)
|
|
||||||
|
|
||||||
//const (
|
"mongo.games.com/game/common"
|
||||||
// ReplayServerType int = 8
|
"mongo.games.com/game/model"
|
||||||
// ReplayServerId = 801
|
"mongo.games.com/game/protocol/webapi"
|
||||||
//)
|
)
|
||||||
|
|
||||||
var GameSessMgrSington = &GameSessMgr{
|
var GameSessMgrSington = &GameSessMgr{
|
||||||
servers: make(map[int]*GameSession),
|
servers: make(map[int]*GameSession),
|
||||||
|
@ -25,9 +22,9 @@ var GameSessMgrSington = &GameSessMgr{
|
||||||
}
|
}
|
||||||
|
|
||||||
type GameSessMgr struct {
|
type GameSessMgr struct {
|
||||||
servers map[int]*GameSession
|
servers map[int]*GameSession // 游戏服务id
|
||||||
gamesrvs map[int][]*GameSession
|
gamesrvs map[int][]*GameSession // 游戏id
|
||||||
gates map[int]*GameSession
|
gates map[int]*GameSession // 网关id
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注册事件
|
// 注册事件
|
||||||
|
@ -134,6 +131,7 @@ func (this *GameSessMgr) OnUnregiste(s *netlib.Session) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GameSessMgr) GetGameServerSess(gameid int) []*GameSession {
|
func (this *GameSessMgr) GetGameServerSess(gameid int) []*GameSession {
|
||||||
return this.gamesrvs[gameid]
|
return this.gamesrvs[gameid]
|
||||||
}
|
}
|
||||||
|
@ -146,7 +144,7 @@ func (this *GameSessMgr) GetMinLoadSess(gameid int) *GameSession {
|
||||||
if gss, exist := this.gamesrvs[gameid]; exist {
|
if gss, exist := this.gamesrvs[gameid]; exist {
|
||||||
if gss != nil {
|
if gss != nil {
|
||||||
for _, s := range gss {
|
for _, s := range gss {
|
||||||
if s.state == common.GAME_SESS_STATE_ON {
|
if s.state == common.GameSessStateOn {
|
||||||
loadFactor = s.GetLoadFactor()
|
loadFactor = s.GetLoadFactor()
|
||||||
if minLoad > loadFactor {
|
if minLoad > loadFactor {
|
||||||
minLoad = loadFactor
|
minLoad = loadFactor
|
||||||
|
@ -162,7 +160,7 @@ func (this *GameSessMgr) GetMinLoadSess(gameid int) *GameSession {
|
||||||
if gss, exist := this.gamesrvs[0]; exist {
|
if gss, exist := this.gamesrvs[0]; exist {
|
||||||
if gss != nil {
|
if gss != nil {
|
||||||
for _, s := range gss {
|
for _, s := range gss {
|
||||||
if s.state == common.GAME_SESS_STATE_ON {
|
if s.state == common.GameSessStateOn {
|
||||||
loadFactor = s.GetLoadFactor()
|
loadFactor = s.GetLoadFactor()
|
||||||
if minLoad > loadFactor {
|
if minLoad > loadFactor {
|
||||||
minLoad = loadFactor
|
minLoad = loadFactor
|
||||||
|
@ -184,6 +182,7 @@ func (this *GameSessMgr) GetGameSess(srvId int) *GameSession {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GameSessMgr) GetAllGameSess() []*GameSession {
|
func (this *GameSessMgr) GetAllGameSess() []*GameSession {
|
||||||
servers := make([]*GameSession, 0)
|
servers := make([]*GameSession, 0)
|
||||||
for _, v := range this.servers {
|
for _, v := range this.servers {
|
||||||
|
@ -191,17 +190,13 @@ func (this *GameSessMgr) GetAllGameSess() []*GameSession {
|
||||||
}
|
}
|
||||||
return servers
|
return servers
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GameSessMgr) GetGateSess(srvId int) *GameSession {
|
func (this *GameSessMgr) GetGateSess(srvId int) *GameSession {
|
||||||
if gs, exist := this.gates[srvId]; exist {
|
if gs, exist := this.gates[srvId]; exist {
|
||||||
return gs
|
return gs
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (this *GameSessMgr) RebindPlayerSnId(oldSnId, newSnId int32) {
|
|
||||||
for _, gs := range this.servers {
|
|
||||||
gs.RebindPlayerSnId(oldSnId, newSnId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *GameSessMgr) ListServerState(srvId, srvType int) []*webapi.ServerInfo {
|
func (this *GameSessMgr) ListServerState(srvId, srvType int) []*webapi.ServerInfo {
|
||||||
_createGateServerInfo := func(srvId, srvType int, s *GameSession) *webapi.ServerInfo {
|
_createGateServerInfo := func(srvId, srvType int, s *GameSession) *webapi.ServerInfo {
|
||||||
|
@ -299,15 +294,17 @@ func (this *GameSessMgr) ListServerState(srvId, srvType int) []*webapi.ServerInf
|
||||||
myInfo := &webapi.ServerInfo{
|
myInfo := &webapi.ServerInfo{
|
||||||
SrvId: int32(common.GetSelfSrvId()),
|
SrvId: int32(common.GetSelfSrvId()),
|
||||||
SrvType: int32(common.GetSelfSrvType()),
|
SrvType: int32(common.GetSelfSrvType()),
|
||||||
State: int32(common.GAME_SESS_STATE_ON),
|
State: int32(common.GameSessStateOn),
|
||||||
PlayerNum: int32(len(PlayerMgrSington.players)),
|
PlayerNum: int32(len(PlayerMgrSington.players)),
|
||||||
RobotNum: int32(len(PlayerMgrSington.snidMap) - len(PlayerMgrSington.players)),
|
RobotNum: int32(len(PlayerMgrSington.snidMap) - len(PlayerMgrSington.players)),
|
||||||
SceneNum: int32(len(SceneMgrSingleton.scenes)),
|
SceneNum: int32(len(SceneMgrSingleton.scenes)),
|
||||||
}
|
}
|
||||||
if SrvIsMaintaining {
|
if model.GameParamData.SrvMaintain {
|
||||||
myInfo.State = int32(common.GAME_SESS_STATE_ON)
|
if !common.SrvIsMaintaining {
|
||||||
} else {
|
myInfo.State = int32(common.GameSessStateOn)
|
||||||
myInfo.State = int32(common.GAME_SESS_STATE_OFF)
|
} else {
|
||||||
|
myInfo.State = int32(common.GameSessStateOff)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//把自己加进去
|
//把自己加进去
|
||||||
datas = append(datas, myInfo)
|
datas = append(datas, myInfo)
|
||||||
|
|
|
@ -3161,25 +3161,6 @@ func (this *Player) AddCoinPayTotal(coin int64) {
|
||||||
this.CoinPayTotal += coin
|
this.CoinPayTotal += coin
|
||||||
}
|
}
|
||||||
|
|
||||||
// 当用户充值
|
|
||||||
func OnPlayerPay(pd *model.PlayerData, coin int64) {
|
|
||||||
if pd == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
buf, err := pd.GetPlayerDataEncoder()
|
|
||||||
if err == nil {
|
|
||||||
pack := &serverproto.WTPlayerPay{
|
|
||||||
AddCoin: proto.Int64(coin),
|
|
||||||
PlayerData: buf.Bytes(),
|
|
||||||
}
|
|
||||||
proto.SetDefaults(pack)
|
|
||||||
common.SendToActThrSrv(int(serverproto.SSPacketID_PACKET_WT_PLAYERPAY), pack)
|
|
||||||
}
|
|
||||||
|
|
||||||
//ActFPayMgrSington.OnPlayerPay(pd.SnId, pd.Platform, coin)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *Player) SendPlatformCanUsePromoterBind() {
|
func (this *Player) SendPlatformCanUsePromoterBind() {
|
||||||
state := int32(0)
|
state := int32(0)
|
||||||
plt := PlatformMgrSingleton.GetPlatform(this.Platform)
|
plt := PlatformMgrSingleton.GetPlatform(this.Platform)
|
||||||
|
|
|
@ -1,19 +1,23 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/goserver/core/mongo"
|
"mongo.games.com/game/model"
|
||||||
|
"mongo.games.com/game/protocol/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
var SrvIsMaintaining = true
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
common.RegisteServerCtrlCallback(func(code int32) {
|
common.RegisterServerCtrlCallback(func(msg *server.ServerCtrl) {
|
||||||
switch code {
|
switch msg.GetCtrlCode() {
|
||||||
case common.SrvCtrlStateSwitchCode:
|
case common.SrvCtrlStateSwitchCode:
|
||||||
SrvIsMaintaining = !SrvIsMaintaining
|
if model.GameParamData.SrvMaintain {
|
||||||
case common.SrvCtrlResetMgoSession:
|
common.SrvIsMaintaining = !common.SrvIsMaintaining
|
||||||
mongo.ResetAllSession()
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
logger.Logger.Errorf("unknown server ctrl code:%d", msg.GetCtrlCode())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue