From a314c42d6ce496dbe66720d236e465cebaa5a3a0 Mon Sep 17 00:00:00 2001 From: by <123456@qq.com> Date: Sat, 14 Sep 2024 15:53:03 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=A8=83=E5=A8=83=E6=9C=BA=E8=B0=83?= =?UTF-8?q?=E8=BD=AC=E6=96=B9=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machine/action/action_server.go | 36 +++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/machine/action/action_server.go b/machine/action/action_server.go index 024cb99..c5120c1 100644 --- a/machine/action/action_server.go +++ b/machine/action/action_server.go @@ -67,7 +67,7 @@ func processConnMessageQueue(queue *ConnMessageQueue) { } } -// 移动 +// 移动 1-前 2-后 3-左 4-右 5-投币 func SMDollMachinePerateHandler(session *netlib.Session, packetId int, data interface{}) error { fmt.Println("SMDollMachinePerateHandler %v", data) msg, ok := data.(*machine.SMDollMachineoPerate) @@ -86,15 +86,6 @@ func SMDollMachinePerateHandler(session *netlib.Session, packetId int, data inte switch msg.Perate { case 1: - //向前移动 - f1 := []func(){ - func() { machinedoll.Backward(conn) }, - } - f2 := []func(){ - func() { machinedoll.BackwardStop(conn) }, - } - Process(conn, f1, f2) - case 2: //向后移动 f1 := []func(){ func() { machinedoll.Forward(conn) }, @@ -103,16 +94,16 @@ func SMDollMachinePerateHandler(session *netlib.Session, packetId int, data inte func() { machinedoll.ForwardStop(conn) }, } Process(conn, f1, f2) - case 3: - //向左移动 + case 2: + //向前移动 f1 := []func(){ - func() { machinedoll.Left(conn) }, + func() { machinedoll.Backward(conn) }, } f2 := []func(){ - func() { machinedoll.LeftStop(conn) }, + func() { machinedoll.BackwardStop(conn) }, } Process(conn, f1, f2) - case 4: + case 3: //向右移动 f1 := []func(){ func() { machinedoll.Right(conn) }, @@ -121,6 +112,16 @@ func SMDollMachinePerateHandler(session *netlib.Session, packetId int, data inte func() { machinedoll.RightStop(conn) }, } Process(conn, f1, f2) + case 4: + //向左移动 + f1 := []func(){ + func() { machinedoll.Left(conn) }, + } + f2 := []func(){ + func() { machinedoll.LeftStop(conn) }, + } + Process(conn, f1, f2) + case 5: //投币 conn := machinedoll.MachineMgr.CreateConn(int(msg.GetId())) @@ -284,6 +285,7 @@ func SMGameLinkSucceedHandler(session *netlib.Session, packetId int, data interf msg.Data = append(msg.Data, info) } session.Send(int(machine.DollMachinePacketID_PACKET_MSDollMachineList), msg) + machinedoll.MachineMgr.BeatStatus = true fmt.Println("向游戏服务器发送娃娃机连接信息:%v", msg) return nil } @@ -333,6 +335,10 @@ func SMGameLinkSucceedHandler(session *netlib.Session, packetId int, data interf */ func SMDollMachineHeartBeatHandler(session *netlib.Session, packetId int, data interface{}) error { //fmt.Println("收到返回的心跳包") + machinedoll.MachineMgr.BeatCount-- + if machinedoll.MachineMgr.BeatCount < 0 { + machinedoll.MachineMgr.BeatCount = 0 + } return nil } func init() { From 72edbbdd4b5866ea1b0c496ae0925f1998dddb8f Mon Sep 17 00:00:00 2001 From: by <123456@qq.com> Date: Sat, 14 Sep 2024 15:54:38 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=A8=83=E5=A8=83=E6=9C=BA=E8=B0=83?= =?UTF-8?q?=E8=BD=AC=E6=96=B9=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machine/action/action_server.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/machine/action/action_server.go b/machine/action/action_server.go index c5120c1..92d3990 100644 --- a/machine/action/action_server.go +++ b/machine/action/action_server.go @@ -285,7 +285,6 @@ func SMGameLinkSucceedHandler(session *netlib.Session, packetId int, data interf msg.Data = append(msg.Data, info) } session.Send(int(machine.DollMachinePacketID_PACKET_MSDollMachineList), msg) - machinedoll.MachineMgr.BeatStatus = true fmt.Println("向游戏服务器发送娃娃机连接信息:%v", msg) return nil } @@ -335,10 +334,6 @@ func SMGameLinkSucceedHandler(session *netlib.Session, packetId int, data interf */ func SMDollMachineHeartBeatHandler(session *netlib.Session, packetId int, data interface{}) error { //fmt.Println("收到返回的心跳包") - machinedoll.MachineMgr.BeatCount-- - if machinedoll.MachineMgr.BeatCount < 0 { - machinedoll.MachineMgr.BeatCount = 0 - } return nil } func init() { From 7668ddcd93e3823819631cb70103aa7b853a6e88 Mon Sep 17 00:00:00 2001 From: by <123456@qq.com> Date: Sat, 14 Sep 2024 15:55:37 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=A8=83=E5=A8=83=E6=9C=BA=E8=B0=83?= =?UTF-8?q?=E8=BD=AC=E6=96=B9=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machine/machinedoll/machinemgr.go | 42 ------------------------------- 1 file changed, 42 deletions(-) diff --git a/machine/machinedoll/machinemgr.go b/machine/machinedoll/machinemgr.go index b4cbf18..61f7c51 100644 --- a/machine/machinedoll/machinemgr.go +++ b/machine/machinedoll/machinemgr.go @@ -133,48 +133,6 @@ func (this *MachineManager) Update() { pack := &machine.MSDollMachineHeartBeat{} pack.TimeStamp = time.Now().UnixMilli() SendToGameServer(int(machine.DollMachinePacketID_Packet_MSDollMachineHeartBeat), pack) - /* var delConn []*Conn - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - for _, v := range this.ConnMap { - _, err := v.Write([]byte("heartbeat")) - if err != nil { - delConn = append(delConn, v) - v.Close() - fmt.Println("断开连接:%v", v.Addr) - this.UpdateToGameServer(v, 0) - } - } - return nil - }), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) { - for _, v := range delConn { - delete(this.ConnMap, v.Id) - this.DelConnMap[v.Id] = v.Addr - } - - // 重连 - var delIds []*Conn - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - for id, addr := range this.DelConnMap { - conn, err := net.DialTimeout("tcp", addr, 5*time.Second) - if err != nil { - continue - } - fmt.Println("娃娃机重连成功!addr = %v", addr) - delIds = append(delIds, &Conn{ - Id: id, - Conn: conn, - Addr: addr, - }) - } - return nil - }), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) { - for _, v := range delIds { - this.ConnMap[v.Id] = v - delete(this.DelConnMap, v.Id) - this.UpdateToGameServer(v, 1) - } - })).StartByFixExecutor(this.ModuleName()) - })).StartByFixExecutor(this.ModuleName())*/ } func (this *MachineManager) Shutdown() { From f83b22688c6f02a65c5a1594e1a1f942560faf72 Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Sat, 14 Sep 2024 16:22:06 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E9=87=8D=E8=BF=9E=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E6=AF=94=E8=B5=9B=E6=B2=A1=E6=9C=89=E5=BC=80=E5=A7=8B=E5=B0=B1?= =?UTF-8?q?=E9=80=80=E8=B5=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- worldsrv/loginstatemgr.go | 13 +- worldsrv/player.go | 1 + worldsrv/playermgr.go | 287 -------------------------------------- 3 files changed, 11 insertions(+), 290 deletions(-) diff --git a/worldsrv/loginstatemgr.go b/worldsrv/loginstatemgr.go index 38c666b..4fb7610 100644 --- a/worldsrv/loginstatemgr.go +++ b/worldsrv/loginstatemgr.go @@ -307,13 +307,20 @@ func (this *LoginStateMgr) Init() { func (this *LoginStateMgr) Update() { // 定时清理已经登出的账号数据 curTs := time.Now().Unix() - for name, s := range this.statesByPlayer { + var delAcc []*AccLoginState + for _, s := range this.statesByPlayer { + if s == nil { + continue + } if len(s.lss) == 0 && curTs-s.lastLogoutTs > int64(model.GameParamData.LoginStateCacheSec) { - if s != nil && s.acc != nil { - this.DeleteAccount(name, s) + if s.acc != nil { + delAcc = append(delAcc, s) } } } + for _, s := range delAcc { + this.DeleteAccount(s.acc.AccountId.Hex(), s) + } } func (this *LoginStateMgr) Shutdown() { diff --git a/worldsrv/player.go b/worldsrv/player.go index 39e4967..2461b9b 100644 --- a/worldsrv/player.go +++ b/worldsrv/player.go @@ -437,6 +437,7 @@ func (this *Player) OnRehold() { FriendUnreadMgrSington.CheckSendFriendUnreadData(this.Platform, this.SnId) if !this.IsRob { + TournamentMgr.Quit(this.Platform, this.SnId) // 比赛没有开始,退赛 this.SendJackPotInit() PlayerOnlineSington.Check = true diff --git a/worldsrv/playermgr.go b/worldsrv/playermgr.go index 73b463b..bd705fd 100644 --- a/worldsrv/playermgr.go +++ b/worldsrv/playermgr.go @@ -644,293 +644,6 @@ func (this *PlayerMgr) EndPlayerLoading(accid string) int64 { return 0 } -//func PlayerRankGe(p1, p2 *Player, n int) bool { -// switch n { -// case 0: -// if p1.TotalCoin == p2.TotalCoin { -// return p1.SnId < p2.SnId -// } else { -// return p1.TotalCoin > p2.TotalCoin -// } -// case 1: -// if p1.CoinPayTotal == p2.CoinPayTotal { -// return p1.SnId < p2.SnId -// } else { -// return p1.CoinPayTotal > p2.CoinPayTotal -// } -// case 2: -// if p1.CoinExchangeTotal == p2.CoinExchangeTotal { -// return p1.SnId < p2.SnId -// } else { -// return p1.CoinExchangeTotal > p2.CoinExchangeTotal -// } -// case 3: -// a := p1.Coin + p1.SafeBoxCoin - p1.CoinPayTotal -// b := p2.Coin + p2.SafeBoxCoin - p2.CoinPayTotal -// if a == b { -// return p1.SnId < p2.SnId -// } else { -// return a > b -// } -// -// } -// return false -//} - -// func (this *PlayerMgr) GetRank() map[string][]*model.Rank { -// ret := make(map[string][]*model.Rank) -// ls := make(map[string]*list.List) -// -// platforms := PlatformMgrSingleton.Platforms -// for p := range platforms { -// ret[p] = make([]*model.Rank, 0) -// ls[p] = list.New() -// } -// -// for _, player := range this.players { -// if player.IsRob { -// continue -// } -// -// p := player.PlayerData.Platform -// if _, ok := platforms[p]; !ok { -// continue -// } -// -// l := ls[p] -// for n := l.Front(); n != nil; n = n.Next() { -// if np, ok := n.Value.(*Player); ok { -// if PlayerRankGe(player, np) { -// l.InsertBefore(player, n) -// goto CHECK -// } -// } -// //else { -// // logger.Logger.Warnf("PlayerMgr.GetRank n.Value.(*Player) fail") -// // continue -// //} -// } -// -// l.PushBack(player) -// CHECK: -// if l.Len() > model.MAX_RANK_COUNT { -// l.Remove(l.Back()) -// } -// } -// -// for p := range platforms { -// l := ls[p] -// for n := l.Front(); n != nil; n = n.Next() { -// if np, ok := n.Value.(*Player); ok { -// ret[p] = append(ret[p], &model.Rank{ -// SnId: np.PlayerData.SnId, -// Name: np.PlayerData.Name, -// Head: np.PlayerData.Head, -// VIP: np.PlayerData.VIP, -// TotalCoin: np.PlayerData.TotalCoin, -// }) -// } -// } -// } -// -// return ret -// } - -//func (this *PlayerMgr) GetAssetRank(platform string) []*model.Rank { -// ret := make([]*model.Rank, 0, model.MAX_RANK_COUNT) -// l := list.New() -// -// for _, player := range this.players { -// if player.IsRob { -// continue -// } -// -// if player.PlayerData.Platform != platform { -// continue -// } -// -// for n := l.Front(); n != nil; n = n.Next() { -// if np, ok := n.Value.(*Player); ok { -// if PlayerRankGe(player, np, 0) { -// l.InsertBefore(player, n) -// goto CHECK -// } -// } -// } -// -// l.PushBack(player) -// CHECK: -// if l.Len() > model.MAX_RANK_COUNT { -// l.Remove(l.Back()) -// } -// } -// -// for n := l.Front(); n != nil; n = n.Next() { -// if np, ok := n.Value.(*Player); ok { -// ret = append(ret, &model.Rank{ -// SnId: np.PlayerData.SnId, -// Name: np.PlayerData.Name, -// Head: np.PlayerData.Head, -// VIP: np.PlayerData.VIP, -// TotalCoin: np.PlayerData.TotalCoin, -// }) -// } -// } -// -// return ret -//} - -//func (this *PlayerMgr) GetRechargeLists(platform string) []*model.Rank { -// ret := make([]*model.Rank, 0, model.MAX_RANK_COUNT) -// l := list.New() -// -// for _, player := range this.players { -// if player.IsRob { -// continue -// } -// -// if player.PlayerData.Platform != platform { -// continue -// } -// -// for n := l.Front(); n != nil; n = n.Next() { -// if np, ok := n.Value.(*Player); ok { -// if PlayerRankGe(player, np, 1) { -// l.InsertBefore(player, n) -// goto CHECK -// } -// } -// } -// -// l.PushBack(player) -// CHECK: -// if l.Len() > model.MAX_RANK_COUNT { -// l.Remove(l.Back()) -// } -// } -// -// for n := l.Front(); n != nil; n = n.Next() { -// if np, ok := n.Value.(*Player); ok { -// ret = append(ret, &model.Rank{ -// SnId: np.PlayerData.SnId, -// Name: np.PlayerData.Name, -// Head: np.PlayerData.Head, -// VIP: np.PlayerData.VIP, -// TotalCoin: np.PlayerData.CoinPayTotal, -// }) -// } -// } -// -// return ret -//} - -//func (this *PlayerMgr) GetExchangeLists(platform string) []*model.Rank { -// ret := make([]*model.Rank, 0, model.MAX_RANK_COUNT) -// l := list.New() -// -// for _, player := range this.players { -// if player.IsRob { -// continue -// } -// -// if player.PlayerData.Platform != platform { -// continue -// } -// -// for n := l.Front(); n != nil; n = n.Next() { -// if np, ok := n.Value.(*Player); ok { -// if PlayerRankGe(player, np, 2) { -// l.InsertBefore(player, n) -// goto CHECK -// } -// } -// } -// -// l.PushBack(player) -// CHECK: -// if l.Len() > model.MAX_RANK_COUNT { -// l.Remove(l.Back()) -// } -// } -// -// for n := l.Front(); n != nil; n = n.Next() { -// if np, ok := n.Value.(*Player); ok { -// ret = append(ret, &model.Rank{ -// SnId: np.PlayerData.SnId, -// Name: np.PlayerData.Name, -// Head: np.PlayerData.Head, -// VIP: np.PlayerData.VIP, -// TotalCoin: np.PlayerData.CoinExchangeTotal, -// }) -// } -// } -// -// return ret -//} - -//func (this *PlayerMgr) GetProfitLists(platform string) []*model.Rank { -// ret := make([]*model.Rank, 0, model.MAX_RANK_COUNT) -// l := list.New() -// -// for _, player := range this.players { -// if player.IsRob { -// continue -// } -// -// if player.PlayerData.Platform != platform { -// continue -// } -// -// for n := l.Front(); n != nil; n = n.Next() { -// if np, ok := n.Value.(*Player); ok { -// if PlayerRankGe(player, np, 3) { -// l.InsertBefore(player, n) -// goto CHECK -// } -// } -// } -// -// l.PushBack(player) -// CHECK: -// if l.Len() > model.MAX_RANK_COUNT { -// l.Remove(l.Back()) -// } -// } -// -// for n := l.Front(); n != nil; n = n.Next() { -// if np, ok := n.Value.(*Player); ok { -// ret = append(ret, &model.Rank{ -// SnId: np.PlayerData.SnId, -// Name: np.PlayerData.Name, -// Head: np.PlayerData.Head, -// VIP: np.PlayerData.VIP, -// //TotalCoin: np.PlayerData.ProfitCoin, -// }) -// } -// } -// -// return ret -//} - -//func (this *PlayerMgr) DeletePlayerByPlatform(platform string) { -// var dels []*Player -// for _, p := range this.players { -// if p != nil && p.Platform == platform { -// p.Kickout(common.KickReason_Disconnection) -// dels = append(dels, p) -// } -// } -// -// for _, p := range dels { -// if p != nil { -// p.isDelete = true -// if p.scene == nil { -// this.DelPlayer(p.SnId) -// } -// } -// } -//} - func (this *PlayerMgr) StatsOnline() model.PlayerOLStats { stats := model.PlayerOLStats{ PlatformStats: make(map[string]*model.PlayerStats), From e6105b40b0d31d79c3ca1ae3c574501bbf40c85b Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Sat, 14 Sep 2024 17:21:28 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E9=87=8D=E8=BF=9E=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E6=AF=94=E8=B5=9B=E6=B2=A1=E6=9C=89=E5=BC=80=E5=A7=8B=E5=B0=B1?= =?UTF-8?q?=E9=80=80=E8=B5=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- worldsrv/action_login.go | 3 ++- worldsrv/tournament.go | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/worldsrv/action_login.go b/worldsrv/action_login.go index bb29260..c12ddcc 100644 --- a/worldsrv/action_login.go +++ b/worldsrv/action_login.go @@ -212,7 +212,8 @@ func (this *CSLoginHandler) Process(s *netlib.Session, packetid int, data interf // lss 其它连接 lss := LoginStateMgrSington.LoginFinish(csl.GetUsername(), csl.GetPlatform(), sid, ls.acc, tagkey) player := PlayerMgrSington.GetPlayerBySnId(ls.acc.SnId) - if len(lss) > 0 && (player != nil && (player.scene != nil || player.thrscene != 0)) { + waitMatch, _ := TournamentMgr.IsMatchWaiting(player.Platform, player.SnId) + if len(lss) > 0 && (player != nil && (player.scene != nil || player.thrscene != 0 || waitMatch || TournamentMgr.IsMatching(player.SnId))) { sendSCLogin(login_proto.OpResultCode_OPRC_LoginOtherPlace) sendSCDisconnect(common.KickReason_Logining) return nil diff --git a/worldsrv/tournament.go b/worldsrv/tournament.go index ad3eee2..91fd410 100644 --- a/worldsrv/tournament.go +++ b/worldsrv/tournament.go @@ -507,8 +507,17 @@ func (this *Tournament) IsMatchWaiting(platform string, snId int32) (bool, int32 // 未使用机器人 for k, v := range this.signupPlayers[platform] { if v.signup != nil { - _, ok := v.signup[snId] - return ok, k + if _, ok := v.signup[snId]; ok { + return ok, k + } + } + } + + for k, v := range this.matches { + for _, vv := range v { + if _, ok := vv.TmPlayer[snId]; ok { + return true, k + } } } From 6240e08abea4e9b36d7c8b292f0ab2d04a9abd8f Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Sat, 14 Sep 2024 17:43:23 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E7=AB=9E=E6=8A=80=E9=A6=86=E5=AF=B9?= =?UTF-8?q?=E5=B1=80=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gamesrv/tienlen/scenedata_tienlen.go | 1 + model/customlog.go | 1 + 2 files changed, 2 insertions(+) diff --git a/gamesrv/tienlen/scenedata_tienlen.go b/gamesrv/tienlen/scenedata_tienlen.go index cdcb4f3..e06b45f 100644 --- a/gamesrv/tienlen/scenedata_tienlen.go +++ b/gamesrv/tienlen/scenedata_tienlen.go @@ -2130,6 +2130,7 @@ func (this *TienLenSceneData) SaveCustomLog() { StartTs: this.GameStartTime.Unix(), EndTs: time.Now().Unix(), State: state, + Creator: this.GetCreator(), } for snid := range this.BilledList { var items []*model.Item diff --git a/model/customlog.go b/model/customlog.go index 317c469..1b1f66b 100644 --- a/model/customlog.go +++ b/model/customlog.go @@ -28,6 +28,7 @@ type CustomLog struct { CostType int32 // 付费方式 1AA 2房主 Voice int32 // 是否开启语音 1开启 RoomId int32 // 房间id + Creator int32 // 创建者id SnId []PlayerInfo // 所有玩家 List []RoundInfo // 对局记录 StartTs, EndTs int64 // 开始,结束时间