Merge branch 'develop' into dev_slots
This commit is contained in:
commit
77748f066f
|
@ -1,27 +1,26 @@
|
|||
package main
|
||||
package common
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/goserver/core/module"
|
||||
)
|
||||
|
||||
var ClockMgrSington = &ClockMgr{
|
||||
var ClockMgrSingleton = &ClockMgr{
|
||||
LastHour: -1,
|
||||
LastDay: -1,
|
||||
Notifying: false,
|
||||
}
|
||||
|
||||
const (
|
||||
CLOCK_EVENT_SECOND int = iota
|
||||
CLOCK_EVENT_MINUTE
|
||||
CLOCK_EVENT_HOUR
|
||||
CLOCK_EVENT_DAY
|
||||
CLOCK_EVENT_WEEK
|
||||
CLOCK_EVENT_MONTH
|
||||
CLOCK_EVENT_SHUTDOWN
|
||||
CLOCK_EVENT_MAX
|
||||
ClockEventSecond int = iota
|
||||
ClockEventMinute
|
||||
ClockEventHour
|
||||
ClockEventDay
|
||||
ClockEventWeek
|
||||
ClockEventMonth
|
||||
ClockEventShutdown
|
||||
ClockEventMax
|
||||
)
|
||||
|
||||
type ClockSinker interface {
|
||||
|
@ -38,7 +37,7 @@ type ClockSinker interface {
|
|||
type BaseClockSinker struct {
|
||||
}
|
||||
|
||||
func (s *BaseClockSinker) InterestClockEvent() int { return (1 << CLOCK_EVENT_MAX) - 1 }
|
||||
func (s *BaseClockSinker) InterestClockEvent() int { return (1 << ClockEventMax) - 1 }
|
||||
func (s *BaseClockSinker) OnSecTimer() {}
|
||||
func (s *BaseClockSinker) OnMiniTimer() {}
|
||||
func (s *BaseClockSinker) OnHourTimer() {}
|
||||
|
@ -48,7 +47,7 @@ func (s *BaseClockSinker) OnMonthTimer() {}
|
|||
func (s *BaseClockSinker) OnShutdown() {}
|
||||
|
||||
type ClockMgr struct {
|
||||
sinkers [CLOCK_EVENT_MAX][]ClockSinker
|
||||
sinkers [ClockEventMax][]ClockSinker
|
||||
LastTickTime time.Time
|
||||
LastMonth time.Month
|
||||
LastWeek int
|
||||
|
@ -60,9 +59,9 @@ type ClockMgr struct {
|
|||
LastFiveMin int
|
||||
}
|
||||
|
||||
func (this *ClockMgr) RegisteSinker(sinker ClockSinker) {
|
||||
func (this *ClockMgr) RegisterSinker(sinker ClockSinker) {
|
||||
interest := sinker.InterestClockEvent()
|
||||
for i := 0; i < CLOCK_EVENT_MAX; i++ {
|
||||
for i := 0; i < ClockEventMax; i++ {
|
||||
if (1<<i)&interest != 0 {
|
||||
found := false
|
||||
ss := this.sinkers[i]
|
||||
|
@ -115,7 +114,7 @@ func (this *ClockMgr) Update() {
|
|||
this.LastDay = day
|
||||
this.fireDayEvent()
|
||||
|
||||
week := common.GetWeekStartTs(tNow.Unix())
|
||||
week := GetWeekStartTs(tNow.Unix())
|
||||
if week != int64(this.LastWeek) {
|
||||
this.LastWeek = int(week)
|
||||
this.fireWeekEvent()
|
||||
|
@ -138,43 +137,43 @@ func (this *ClockMgr) Shutdown() {
|
|||
}
|
||||
|
||||
func (this *ClockMgr) fireSecondEvent() {
|
||||
for _, s := range this.sinkers[CLOCK_EVENT_SECOND] {
|
||||
for _, s := range this.sinkers[ClockEventSecond] {
|
||||
s.OnSecTimer()
|
||||
}
|
||||
}
|
||||
|
||||
func (this *ClockMgr) fireMinuteEvent() {
|
||||
for _, s := range this.sinkers[CLOCK_EVENT_MINUTE] {
|
||||
for _, s := range this.sinkers[ClockEventMinute] {
|
||||
s.OnMiniTimer()
|
||||
}
|
||||
}
|
||||
|
||||
func (this *ClockMgr) fireHourEvent() {
|
||||
for _, s := range this.sinkers[CLOCK_EVENT_HOUR] {
|
||||
for _, s := range this.sinkers[ClockEventHour] {
|
||||
s.OnHourTimer()
|
||||
}
|
||||
}
|
||||
|
||||
func (this *ClockMgr) fireDayEvent() {
|
||||
for _, s := range this.sinkers[CLOCK_EVENT_DAY] {
|
||||
for _, s := range this.sinkers[ClockEventDay] {
|
||||
s.OnDayTimer()
|
||||
}
|
||||
}
|
||||
|
||||
func (this *ClockMgr) fireWeekEvent() {
|
||||
for _, s := range this.sinkers[CLOCK_EVENT_WEEK] {
|
||||
for _, s := range this.sinkers[ClockEventWeek] {
|
||||
s.OnWeekTimer()
|
||||
}
|
||||
}
|
||||
|
||||
func (this *ClockMgr) fireMonthEvent() {
|
||||
for _, s := range this.sinkers[CLOCK_EVENT_MONTH] {
|
||||
for _, s := range this.sinkers[ClockEventMonth] {
|
||||
s.OnMonthTimer()
|
||||
}
|
||||
}
|
||||
|
||||
func (this *ClockMgr) fireShutdownEvent() {
|
||||
for _, s := range this.sinkers[CLOCK_EVENT_SHUTDOWN] {
|
||||
for _, s := range this.sinkers[ClockEventShutdown] {
|
||||
s.OnShutdown()
|
||||
}
|
||||
}
|
||||
|
@ -184,5 +183,5 @@ func (this *ClockMgr) GetLast() (int, int, int, int, int, int) {
|
|||
}
|
||||
|
||||
func init() {
|
||||
module.RegisteModule(ClockMgrSington, time.Millisecond*500, 0)
|
||||
module.RegisteModule(ClockMgrSingleton, time.Millisecond*500, 0)
|
||||
}
|
|
@ -38,19 +38,19 @@ func HandleWGBuyRecTimeItem(session *netlib.Session, packetId int, data interfac
|
|||
return nil
|
||||
}
|
||||
|
||||
func HandleWGPlayerLeave(session *netlib.Session, packetId int, data interface{}) error {
|
||||
logger.Logger.Trace("receive WGPlayerLeaveGame")
|
||||
if msg, ok := data.(*server.WGPlayerLeave); ok {
|
||||
p := base.PlayerMgrSington.GetPlayerBySnId(msg.GetSnId())
|
||||
if p != nil {
|
||||
scene := p.GetScene()
|
||||
if scene != nil {
|
||||
scene.PlayerLeave(p, common.PlayerLeaveReason_DropLine, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
//func HandleWGPlayerLeave(session *netlib.Session, packetId int, data interface{}) error {
|
||||
// logger.Logger.Trace("receive WGPlayerLeaveGame")
|
||||
// if msg, ok := data.(*server.WGPlayerLeave); ok {
|
||||
// p := base.PlayerMgrSington.GetPlayerBySnId(msg.GetSnId())
|
||||
// if p != nil {
|
||||
// scene := p.GetScene()
|
||||
// if scene != nil {
|
||||
// scene.PlayerLeave(p, common.PlayerLeaveReason_DropLine, false)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return nil
|
||||
//}
|
||||
|
||||
//func HandlePlayerChangeItems(session *netlib.Session, packetId int, data interface{}) error {
|
||||
// logger.Logger.Tracef("receive PlayerChangeItems %v", data)
|
||||
|
@ -561,9 +561,9 @@ func init() {
|
|||
}))
|
||||
|
||||
common.RegisterMulticastHandler()
|
||||
//玩家离开
|
||||
netlib.Register(int(server.SSPacketID_PACKET_WG_PlayerLEAVE), server.WGPlayerLeave{}, HandleWGPlayerLeave)
|
||||
//同步记牌器过期时间
|
||||
// 玩家离开
|
||||
//netlib.Register(int(server.SSPacketID_PACKET_WG_PlayerLEAVE), server.WGPlayerLeave{}, HandleWGPlayerLeave)
|
||||
// 同步记牌器过期时间
|
||||
netlib.Register(int(server.SSPacketID_PACKET_WG_BUYRECTIMEITEM), server.WGBuyRecTimeItem{}, HandleWGBuyRecTimeItem)
|
||||
// 修改皮肤
|
||||
netlib.Register(int(server.SSPacketID_PACKET_WG_UpdateSkin), server.WGUpdateSkin{}, HandleWGUpdateSkin)
|
||||
|
|
|
@ -21,15 +21,11 @@ var SceneMgrSington = &SceneMgr{
|
|||
}
|
||||
|
||||
type SceneMgr struct {
|
||||
scenes map[int]*Scene
|
||||
scenesByGame map[int]map[int]*Scene
|
||||
scenesByGameFree map[int32]map[int]*Scene
|
||||
lastSendJackPot time.Time
|
||||
PlatformScene map[string]bool
|
||||
}
|
||||
|
||||
func (this *SceneMgr) makeKey(gameid, gamemode int) int {
|
||||
return int(gameid*10000 + gamemode)
|
||||
scenes map[int]*Scene // 房间id
|
||||
scenesByGame map[int]map[int]*Scene // 游戏id:房间id
|
||||
scenesByGameFree map[int32]map[int]*Scene // 场次id:房间id
|
||||
lastSendJackPot time.Time //
|
||||
PlatformScene map[string]bool //
|
||||
}
|
||||
|
||||
type CreateSceneParam struct {
|
||||
|
@ -46,7 +42,6 @@ func (this *SceneMgr) CreateScene(args *CreateSceneParam) *Scene {
|
|||
|
||||
platform := args.GetPlatform()
|
||||
gameId := args.GetGameId()
|
||||
gameMode := args.GetGameMode()
|
||||
gameFreeId := args.GetDBGameFree().GetId()
|
||||
// 平台标记
|
||||
this.scenes[int(scene.SceneId)] = scene
|
||||
|
@ -54,13 +49,12 @@ func (this *SceneMgr) CreateScene(args *CreateSceneParam) *Scene {
|
|||
this.PlatformScene[platform] = true
|
||||
}
|
||||
// 游戏id索引
|
||||
key := this.makeKey(int(gameId), int(gameMode))
|
||||
if ss, exist := this.scenesByGame[key]; exist {
|
||||
if ss, exist := this.scenesByGame[int(gameId)]; exist {
|
||||
ss[int(scene.SceneId)] = scene
|
||||
} else {
|
||||
ss = make(map[int]*Scene)
|
||||
ss[int(scene.SceneId)] = scene
|
||||
this.scenesByGame[key] = ss
|
||||
this.scenesByGame[int(gameId)] = ss
|
||||
}
|
||||
// 场次id索引
|
||||
if ss, exist := this.scenesByGameFree[gameFreeId]; exist {
|
||||
|
@ -79,87 +73,30 @@ func (this *SceneMgr) CreateScene(args *CreateSceneParam) *Scene {
|
|||
func (this *SceneMgr) DestroyScene(sceneId int) {
|
||||
if scene, exist := this.scenes[sceneId]; exist {
|
||||
scene.OnStop()
|
||||
//
|
||||
key := this.makeKey(int(scene.GameId), int(scene.GameMode))
|
||||
if ss, exist := this.scenesByGame[key]; exist {
|
||||
// 游戏id
|
||||
if ss, exist := this.scenesByGame[scene.GetGameId()]; exist {
|
||||
delete(ss, int(scene.SceneId))
|
||||
}
|
||||
//
|
||||
// 场次id
|
||||
if ss, exist := this.scenesByGameFree[scene.GetGameFreeId()]; exist {
|
||||
delete(ss, int(scene.SceneId))
|
||||
}
|
||||
// 房间id
|
||||
delete(this.scenes, sceneId)
|
||||
logger.Logger.Infof("(this *SceneMgr) DestroyScene, sceneid = %v", sceneId)
|
||||
}
|
||||
}
|
||||
|
||||
func (this *SceneMgr) GetPlayerNumByGameFree(platform string, gamefreeid, groupId int32) int32 {
|
||||
var num int32
|
||||
if ss, exist := SceneMgrSington.scenesByGameFree[gamefreeid]; exist {
|
||||
for _, scene := range ss {
|
||||
if groupId != 0 {
|
||||
if scene.GroupId == groupId {
|
||||
cnt := scene.GetRealPlayerCnt()
|
||||
num += int32(cnt)
|
||||
}
|
||||
} else {
|
||||
if scene.Platform == platform {
|
||||
cnt := scene.GetRealPlayerCnt()
|
||||
num += int32(cnt)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return num
|
||||
}
|
||||
|
||||
func (this *SceneMgr) GetPlayerNumByGame(platform string, gameid, gamemode, groupId int32) map[int32]int32 {
|
||||
nums := make(map[int32]int32)
|
||||
key := this.makeKey(int(gameid), int(gamemode))
|
||||
if ss, exist := SceneMgrSington.scenesByGame[key]; exist {
|
||||
for _, scene := range ss {
|
||||
if groupId != 0 {
|
||||
if scene.GroupId == groupId {
|
||||
cnt := scene.GetRealPlayerCnt()
|
||||
nums[scene.GetGameFreeId()] = nums[scene.GetGameFreeId()] + int32(cnt)
|
||||
}
|
||||
} else {
|
||||
if scene.Platform == platform {
|
||||
cnt := scene.GetRealPlayerCnt()
|
||||
nums[scene.GetGameFreeId()] = nums[scene.GetGameFreeId()] + int32(cnt)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nums
|
||||
}
|
||||
|
||||
func (this *SceneMgr) GetPlayersByGameFree(platform string, gamefreeid int32) []*Player {
|
||||
players := make([]*Player, 0)
|
||||
if ss, exist := SceneMgrSington.scenesByGameFree[gamefreeid]; exist {
|
||||
for _, scene := range ss {
|
||||
if scene.Platform == platform {
|
||||
for _, p := range scene.Players {
|
||||
if p != nil {
|
||||
players = append(players, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return players
|
||||
}
|
||||
|
||||
func (this *SceneMgr) GetScene(sceneId int) *Scene {
|
||||
if s, exist := this.scenes[sceneId]; exist {
|
||||
return s
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *SceneMgr) GetSceneByGameId(platform string, gameId int32) []*Scene {
|
||||
key := this.makeKey(int(gameId), 0)
|
||||
var ss []*Scene
|
||||
if data, ok := this.scenesByGame[key]; ok {
|
||||
if data, ok := this.scenesByGame[int(gameId)]; ok {
|
||||
for _, scene := range data {
|
||||
if scene.Platform == platform {
|
||||
ss = append(ss, scene)
|
||||
|
@ -168,6 +105,7 @@ func (this *SceneMgr) GetSceneByGameId(platform string, gameId int32) []*Scene {
|
|||
}
|
||||
return ss
|
||||
}
|
||||
|
||||
func (this *SceneMgr) JackPotSync(platform string, gameIds ...int32) {
|
||||
for _, gameId := range gameIds {
|
||||
ss := this.GetSceneByGameId(platform, gameId)
|
||||
|
@ -214,16 +152,13 @@ func (this *SceneMgr) JackPotSync(platform string, gameIds ...int32) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (this *SceneMgr) OnMiniTimer() {
|
||||
for _, scene := range this.scenes {
|
||||
scene.SyncPlayerCoin()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (this *SceneMgr) OnHourTimer() {
|
||||
// for _, scene := range this.scenes {
|
||||
// scene.OnHourTimer()
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
func (this *SceneMgr) OnDayTimer() {
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
package base
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// 根据不同的房间模式,选择不同的房间业务逻辑
|
||||
var ScenePolicyPool = make(map[int]map[int]ScenePolicy) // gameId:gameMode
|
||||
|
||||
type ScenePolicy interface {
|
||||
//心跳间隔
|
||||
GetHeartBeatInterval() time.Duration
|
||||
//场景开启事件
|
||||
OnStart(s *Scene)
|
||||
//场景关闭事件
|
||||
|
@ -105,7 +99,6 @@ func RegisteScenePolicy(gameId, mode int, sp ScenePolicy) {
|
|||
type BaseScenePolicy struct {
|
||||
}
|
||||
|
||||
func (bsp *BaseScenePolicy) GetHeartBeatInterval() time.Duration { return time.Second }
|
||||
func (bsp *BaseScenePolicy) OnStart(s *Scene) {
|
||||
if s.aiMgr != nil {
|
||||
s.aiMgr.OnStart(s)
|
||||
|
|
|
@ -906,13 +906,20 @@ func (this *SceneWaitStartStateTienLen) OnTick(s *base.Scene) {
|
|||
return
|
||||
}
|
||||
//开始前再次检查开始条件
|
||||
if sceneEx.CanStart() == true {
|
||||
if sceneEx.CanStart() {
|
||||
s.ChangeSceneState(rule.TienLenSceneStateHandCard)
|
||||
} else {
|
||||
s.ChangeSceneState(rule.TienLenSceneStateWaitPlayer)
|
||||
}
|
||||
}
|
||||
}
|
||||
if sceneEx.IsCustom() {
|
||||
if sceneEx.CanStart() {
|
||||
s.ChangeSceneState(rule.TienLenSceneStateHandCard)
|
||||
} else {
|
||||
s.ChangeSceneState(rule.TienLenSceneStateWaitPlayer)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2626,6 +2633,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
|
|||
}
|
||||
}
|
||||
s.Broadcast(int(tienlen.TienLenPacketID_PACKET_SCTienLenCycleBilled), packBilled, 0)
|
||||
logger.Logger.Tracef("SCTienLenCycleBilled: %v", packBilled)
|
||||
s.SyncSceneState(common.SceneStateEnd)
|
||||
sceneEx.SaveCustomLog()
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
type AwardLogManager struct {
|
||||
BaseClockSinker
|
||||
common.BaseClockSinker
|
||||
AwardMap map[string]map[int32]map[int32]int64 //key1:plt key2:1话费 2实物 key3 itemId value:数量
|
||||
AnnouncerLog map[string]map[int32][]model.AnnouncerLog //key:1话费 2实物
|
||||
}
|
||||
|
@ -153,5 +153,5 @@ func (this *AwardLogManager) Save() {
|
|||
|
||||
func init() {
|
||||
module.RegisteModule(AwardLogMgr, time.Hour, 0)
|
||||
ClockMgrSington.RegisteSinker(AwardLogMgr)
|
||||
common.ClockMgrSingleton.RegisterSinker(AwardLogMgr)
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"mongo.games.com/game/common"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
@ -23,7 +24,7 @@ var CacheDataMgr = &CacheDataManager{
|
|||
}
|
||||
|
||||
type CacheDataManager struct {
|
||||
BaseClockSinker
|
||||
common.BaseClockSinker
|
||||
MiniCache *sync.Map
|
||||
HourCache *sync.Map
|
||||
DayCache *sync.Map
|
||||
|
@ -67,7 +68,7 @@ func (this *CacheDataManager) addCacheData(timeRange int, key string, data inter
|
|||
|
||||
// 感兴趣所有clock event
|
||||
func (this *CacheDataManager) InterestClockEvent() int {
|
||||
return 1 << CLOCK_EVENT_MINUTE
|
||||
return 1 << common.ClockEventMinute
|
||||
}
|
||||
|
||||
func (this *CacheDataManager) OnMiniTimer() {
|
||||
|
@ -129,5 +130,5 @@ func (this *CacheDataManager) ClearCacheBill(billNo int, platform string) {
|
|||
}
|
||||
|
||||
func init() {
|
||||
ClockMgrSington.RegisteSinker(CacheDataMgr)
|
||||
common.ClockMgrSingleton.RegisterSinker(CacheDataMgr)
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ import (
|
|||
var PermitMgrInst = new(PermitMgr)
|
||||
|
||||
type PermitMgr struct {
|
||||
BaseClockSinker
|
||||
common.BaseClockSinker
|
||||
}
|
||||
|
||||
func (r *PermitMgr) InterestClockEvent() int {
|
||||
return 1 << CLOCK_EVENT_DAY
|
||||
return 1 << common.ClockEventDay
|
||||
}
|
||||
|
||||
func (r *PermitMgr) OnDayTimer() {
|
||||
|
@ -180,5 +180,5 @@ func (r *PermitMgr) OnDayTimer() {
|
|||
}
|
||||
|
||||
func init() {
|
||||
ClockMgrSington.RegisteSinker(PermitMgrInst)
|
||||
common.ClockMgrSingleton.RegisterSinker(PermitMgrInst)
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ var PlatformMgrSingleton = &PlatformMgr{
|
|||
}
|
||||
|
||||
type PlatformMgr struct {
|
||||
BaseClockSinker
|
||||
common.BaseClockSinker
|
||||
*model.ConfigMgr
|
||||
platforms map[string]*Platform
|
||||
observers []PlatformObserver
|
||||
|
@ -493,7 +493,7 @@ func (this *PlatformMgr) Shutdown() {
|
|||
}
|
||||
|
||||
func (this *PlatformMgr) InterestClockEvent() int {
|
||||
return 1<<CLOCK_EVENT_HOUR | 1<<CLOCK_EVENT_DAY
|
||||
return 1<<common.ClockEventHour | 1<<common.ClockEventDay
|
||||
}
|
||||
|
||||
func (this *PlatformMgr) OnDayTimer() {
|
||||
|
@ -593,6 +593,6 @@ func CopyDBGameFreeField(src, dst *serverproto.DB_GameFree) {
|
|||
}
|
||||
|
||||
func init() {
|
||||
ClockMgrSington.RegisteSinker(PlatformMgrSingleton)
|
||||
common.ClockMgrSingleton.RegisterSinker(PlatformMgrSingleton)
|
||||
module.RegisteModule(PlatformMgrSingleton, time.Hour, 0)
|
||||
}
|
||||
|
|
|
@ -1845,8 +1845,8 @@ func (this *Player) Save(force bool) {
|
|||
pi := model.ClonePlayerData(this.PlayerData)
|
||||
if pi != nil {
|
||||
this.SendToRepSrv(pi)
|
||||
// 跨天任务依赖LastLogoutTime的准确性,跨天任务是定时器ClockMgrSington触发的,所以这里要用定时器的触发时间
|
||||
pi.LastLogoutTime = ClockMgrSington.LastTickTime
|
||||
// 跨天任务依赖LastLogoutTime的准确性,跨天任务是定时器common.ClockMgrSington触发的,所以这里要用定时器的触发时间
|
||||
pi.LastLogoutTime = common.ClockMgrSingleton.LastTickTime
|
||||
t := task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
if !model.SavePlayerData(pi) {
|
||||
//save 失败先写到json里面
|
||||
|
|
|
@ -36,7 +36,7 @@ type PlayerPendingData struct {
|
|||
}
|
||||
|
||||
type PlayerMgr struct {
|
||||
BaseClockSinker
|
||||
common.BaseClockSinker
|
||||
sidMap map[int64]*Player // sid
|
||||
snidMap map[int32]*Player // snid
|
||||
accountMap map[string]*Player // accountid
|
||||
|
@ -452,7 +452,7 @@ func (this *PlayerMgr) BroadcastMessageToTarget(target []int32, packetid int, ra
|
|||
|
||||
// 感兴趣所有clock event
|
||||
func (this *PlayerMgr) InterestClockEvent() int {
|
||||
return (1 << CLOCK_EVENT_MAX) - 1
|
||||
return (1 << common.ClockEventMax) - 1
|
||||
}
|
||||
|
||||
func (this *PlayerMgr) OnSecTimer() {
|
||||
|
@ -1138,5 +1138,5 @@ func init() {
|
|||
PlayerSubjectSign.AttachHead(FriendMgrSington)
|
||||
|
||||
// 定时器
|
||||
ClockMgrSington.RegisteSinker(PlayerMgrSington)
|
||||
common.ClockMgrSingleton.RegisterSinker(PlayerMgrSington)
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
ClockMgrSington.RegisteSinker(PlayerNotifySingle)
|
||||
common.ClockMgrSingleton.RegisterSinker(PlayerNotifySingle)
|
||||
}
|
||||
|
||||
var PlayerNotifySingle = &PlayerNotify{
|
||||
|
@ -20,12 +20,12 @@ type PlayerNotifyInfo struct {
|
|||
}
|
||||
|
||||
type PlayerNotify struct {
|
||||
BaseClockSinker
|
||||
common.BaseClockSinker
|
||||
players map[int32]map[int32]*PlayerNotifyInfo // 消息类型:玩家id:玩家信息
|
||||
}
|
||||
|
||||
func (p *PlayerNotify) InterestClockEvent() int {
|
||||
return 1 << CLOCK_EVENT_MINUTE
|
||||
return 1 << common.ClockEventMinute
|
||||
}
|
||||
|
||||
func (p *PlayerNotify) OnMiniTimer() {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/model"
|
||||
server_proto "mongo.games.com/game/protocol/server"
|
||||
"mongo.games.com/game/webapi"
|
||||
|
@ -13,7 +14,7 @@ import (
|
|||
)
|
||||
|
||||
type QMFlowManager struct {
|
||||
BaseClockSinker
|
||||
common.BaseClockSinker
|
||||
playerStatement map[int32]map[int32]*webapi.PlayerStatementSrc
|
||||
offPlayerStatement map[int32]map[int32]*webapi.PlayerStatementSrc
|
||||
}
|
||||
|
@ -40,7 +41,7 @@ func (this *QMFlowManager) Shutdown() {
|
|||
|
||||
// 感兴趣所有clock event
|
||||
func (this *QMFlowManager) InterestClockEvent() int {
|
||||
return 1 << CLOCK_EVENT_HOUR
|
||||
return 1 << common.ClockEventHour
|
||||
}
|
||||
|
||||
func (this *QMFlowManager) OnHourTimer() {
|
||||
|
@ -458,5 +459,5 @@ func (this *QMFlowManager) Save() {
|
|||
|
||||
func init() {
|
||||
module.RegisteModule(QMFlowMgr, time.Minute*3, 0)
|
||||
ClockMgrSington.RegisteSinker(QMFlowMgr)
|
||||
common.ClockMgrSingleton.RegisterSinker(QMFlowMgr)
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"mongo.games.com/game/common"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -244,7 +245,7 @@ func (this *PlayerRankSeason) rankLog(rankType int32) {
|
|||
}
|
||||
|
||||
type RankMatchMgr struct {
|
||||
BaseClockSinker
|
||||
common.BaseClockSinker
|
||||
failSeason []string
|
||||
seasons map[string]*RankSeasonId // 当前赛季 key平台id
|
||||
playerSeasons map[int32]*PlayerRankSeason // 玩家排位信息 key玩家id
|
||||
|
@ -638,7 +639,7 @@ func (r *RankMatchMgr) GetRankAwardList(rankType int32) []*rankmatch.AwardItem {
|
|||
//========================implement ClockSinker ==============================
|
||||
|
||||
func (r *RankMatchMgr) InterestClockEvent() int {
|
||||
return 1 << CLOCK_EVENT_DAY
|
||||
return 1 << common.ClockEventDay
|
||||
}
|
||||
|
||||
func (r *RankMatchMgr) OnDayTimer() {
|
||||
|
@ -934,6 +935,6 @@ func (r *RankMatchMgr) Release(platform string, snid int32) {
|
|||
|
||||
func init() {
|
||||
module.RegisteModule(RankMgrSingleton, time.Minute, 0)
|
||||
ClockMgrSington.RegisteSinker(RankMgrSingleton)
|
||||
common.ClockMgrSingleton.RegisterSinker(RankMgrSingleton)
|
||||
internal.RegisterPlayerLoad(RankMgrSingleton)
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
ClockMgrSington.RegisteSinker(SceneMgrSingleton)
|
||||
common.ClockMgrSingleton.RegisterSinker(SceneMgrSingleton)
|
||||
}
|
||||
|
||||
var SceneMgrSingleton = &SceneMgr{
|
||||
|
@ -31,8 +31,8 @@ var SceneMgrSingleton = &SceneMgr{
|
|||
|
||||
// SceneMgr 房间管理器
|
||||
type SceneMgr struct {
|
||||
BaseClockSinker // 驱动时间事件
|
||||
scenes map[int]*Scene // 房间id: Scene
|
||||
common.BaseClockSinker // 驱动时间事件
|
||||
scenes map[int]*Scene // 房间id: Scene
|
||||
|
||||
privateAutoId int // 私人房房间号
|
||||
matchAutoId int // 比赛场房间号
|
||||
|
@ -477,7 +477,7 @@ func (m *SceneMgr) SendGameDestroy(sceneId []int, isGrace bool) {
|
|||
|
||||
// InterestClockEvent 接收所有时间事件
|
||||
func (m *SceneMgr) InterestClockEvent() int {
|
||||
return 1 << CLOCK_EVENT_MINUTE
|
||||
return 1 << common.ClockEventMinute
|
||||
}
|
||||
|
||||
func (m *SceneMgr) OnMiniTimer() {
|
||||
|
|
|
@ -51,7 +51,7 @@ const (
|
|||
|
||||
func init() {
|
||||
module.RegisteModule(TournamentMgr, time.Second, 0)
|
||||
ClockMgrSington.RegisteSinker(TournamentMgr)
|
||||
common.ClockMgrSingleton.RegisterSinker(TournamentMgr)
|
||||
}
|
||||
|
||||
var TournamentMgr = NewTournament()
|
||||
|
@ -83,7 +83,7 @@ type PlayerRoundInfo struct {
|
|||
}
|
||||
|
||||
type Tournament struct {
|
||||
BaseClockSinker
|
||||
common.BaseClockSinker
|
||||
TypeList map[string]*webapiproto.GameMatchType // 比赛类型列表 平台id:比赛类型列表
|
||||
GameMatchDateList map[string]map[int32]*webapiproto.GameMatchDate // 比赛配置,platform:比赛场配置id:比赛配置
|
||||
singleSignupPlayers map[int32]*SignupInfo // 开启机器人时,报名的玩家,玩家Id:报名信息
|
||||
|
|
|
@ -17,7 +17,7 @@ type DayTimeChangeTransactHandler struct {
|
|||
|
||||
func (this *DayTimeChangeTransactHandler) OnExcute(tNode *transact.TransNode, ud interface{}) transact.TransExeResult {
|
||||
//logger.Logger.Trace("DayTimeChangeTransactHandler.OnExcute ")
|
||||
ClockMgrSington.Notifying = true
|
||||
common.ClockMgrSingleton.Notifying = true
|
||||
for sid, _ := range GameSessMgrSington.servers {
|
||||
tnp := &transact.TransNodeParam{
|
||||
Tt: common.TransType_DayTimeChange,
|
||||
|
@ -27,7 +27,7 @@ func (this *DayTimeChangeTransactHandler) OnExcute(tNode *transact.TransNode, ud
|
|||
Tct: transact.TransactCommitPolicy_SelfDecide,
|
||||
}
|
||||
//logger.Logger.Tracef("TransNode=%v", *tnp)
|
||||
_, wgDayTimeChangePack.LastMin, wgDayTimeChangePack.LastHour, wgDayTimeChangePack.LastDay, wgDayTimeChangePack.LastWeek, wgDayTimeChangePack.LastMonth = ClockMgrSington.GetLast()
|
||||
_, wgDayTimeChangePack.LastMin, wgDayTimeChangePack.LastHour, wgDayTimeChangePack.LastDay, wgDayTimeChangePack.LastWeek, wgDayTimeChangePack.LastMonth = common.ClockMgrSingleton.GetLast()
|
||||
tNode.StartChildTrans(tnp, wgDayTimeChangePack, DayTimeChangeTimeOut)
|
||||
}
|
||||
|
||||
|
@ -36,13 +36,13 @@ func (this *DayTimeChangeTransactHandler) OnExcute(tNode *transact.TransNode, ud
|
|||
|
||||
func (this *DayTimeChangeTransactHandler) OnCommit(tNode *transact.TransNode) transact.TransExeResult {
|
||||
//logger.Logger.Trace("DayTimeChangeTransactHandler.OnCommit ")
|
||||
ClockMgrSington.Notifying = false
|
||||
common.ClockMgrSingleton.Notifying = false
|
||||
return transact.TransExeResult_Success
|
||||
}
|
||||
|
||||
func (this *DayTimeChangeTransactHandler) OnRollBack(tNode *transact.TransNode) transact.TransExeResult {
|
||||
//logger.Logger.Trace("DayTimeChangeTransactHandler.OnRollBack ")
|
||||
ClockMgrSington.Notifying = false
|
||||
common.ClockMgrSingleton.Notifying = false
|
||||
return transact.TransExeResult_Success
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ func (this *DayTimeChangeTransactHandler) OnChildTransRep(tNode *transact.TransN
|
|||
}
|
||||
|
||||
type DayTimeChangeTransactSinker struct {
|
||||
BaseClockSinker
|
||||
common.BaseClockSinker
|
||||
}
|
||||
|
||||
func (this *DayTimeChangeTransactSinker) OnMiniTimer() {
|
||||
|
@ -70,6 +70,6 @@ func (this *DayTimeChangeTransactSinker) OnMiniTimer() {
|
|||
}
|
||||
|
||||
func init() {
|
||||
ClockMgrSington.RegisteSinker(&DayTimeChangeTransactSinker{})
|
||||
common.ClockMgrSingleton.RegisterSinker(&DayTimeChangeTransactSinker{})
|
||||
transact.RegisteHandler(common.TransType_DayTimeChange, &DayTimeChangeTransactHandler{})
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ var WelfareMgrSington = &WelfareMgr{
|
|||
}
|
||||
|
||||
type WelfareMgr struct {
|
||||
BaseClockSinker
|
||||
common.BaseClockSinker
|
||||
*model.ConfigMgr
|
||||
}
|
||||
|
||||
|
@ -2010,10 +2010,10 @@ func (this *WelfareMgr) OnDayTimer() {
|
|||
}
|
||||
|
||||
func (this *WelfareMgr) InterestClockEvent() int {
|
||||
return (1 << CLOCK_EVENT_MAX) - 1
|
||||
return (1 << common.ClockEventMax) - 1
|
||||
}
|
||||
|
||||
func init() {
|
||||
module.RegisteModule(WelfareMgrSington, time.Second, 0)
|
||||
ClockMgrSington.RegisteSinker(WelfareMgrSington)
|
||||
common.ClockMgrSingleton.RegisterSinker(WelfareMgrSington)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue