From 2ca100c0060a67654208a3bf9d484c55072d3b12 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 13 Sep 2023 12:29:34 +0800 Subject: [PATCH] 1 --- server/hallserver/room/room.go | 59 ++++++++++++++++++++++++------- server/hallserver/room/roommgr.go | 2 +- server/hallserver/room/team.go | 18 +++++++--- third_party/q5 | 2 +- 4 files changed, 62 insertions(+), 19 deletions(-) diff --git a/server/hallserver/room/room.go b/server/hallserver/room/room.go index 08118c4f..1fca4410 100644 --- a/server/hallserver/room/room.go +++ b/server/hallserver/room/room.go @@ -10,19 +10,17 @@ import ( "github.com/golang/protobuf/proto" ) -type roomConfg struct { - mapId int32 - zoneId int32 - nodeId int32 - passwd string -} - type room struct { cs.MsgHandlerImpl roomId string roomIdx int64 entry q5.ListHead - config roomConfg + config struct { + mapId int32 + zoneId int32 + nodeId int32 + passwd string + } owner *member roomState int32 startTime int64 @@ -225,20 +223,20 @@ func (this *room) started() bool { func (this *room) doDisband(reason int32) { this.roomState = ROOM_DISBAND_STATE - this.disbandTime = q5.GetTickCount() + this.disbandTime = f5.GetApp().GetNowSeconds() this.disbandReason = reason } func (this *room) doStart(reason int32) { this.roomState = ROOM_STARTED_STATE - this.startTime = q5.GetTickCount() + this.startTime = f5.GetApp().GetNowSeconds() this.startReason = ROOM_AUTO_START_TYPE f5.GetTimer().SetIntervalExWp( 1000, func (e int32, args *q5.Args) { if e == q5.TIMER_EXEC_EVENT { - if q5.GetTickCount() - this.startTime < - int64(1000 * mt.Table.Config.Get().GetGameStartNotifyTime()) { + if f5.GetApp().GetNowSeconds() - this.startTime < + int64(mt.Table.Config.Get().GetGameStartNotifyTime()) { this.notifyGameStart() } } @@ -246,7 +244,7 @@ func (this *room) doStart(reason int32) { this.attacher) } -func (this *room) view() bool { +func (this *room) viewable() bool { return this.roomState == ROOM_INIT_STATE } @@ -256,6 +254,41 @@ func (this *room) notifyGameStart() { this.gameStartNotifyMsg.ZoneId = proto.Int32(this.config.zoneId) this.gameStartNotifyMsg.NodeId = proto.Int32(this.config.nodeId) this.gameStartNotifyMsg.TeamUuid = proto.String(q5.ToString(this.roomIdx)) + startInfo := struct { + ZoneId int32 `json:"zone_id"` + NodeId int32 `json:"node_id"` + RoomUuid string `json:"room_uuid"` + StartTime int32 `json:"start_time"` + TeamList [] struct { + TeamUuid string `json:"team_uuid"` + Members [] struct { + AccountId string `json:"account_id"` + } `json:"members"` + } `json:"team_list"` + }{ + ZoneId: this.config.zoneId, + NodeId: this.config.nodeId, + RoomUuid: q5.ToString(this.roomIdx), + StartTime: int32(this.startTime), + } + q5.NewSlice(&startInfo.TeamList, 0, 10) + this.gameStartNotifyMsg.CustomRoomPayload = proto.String(q5.EncodeJson(&startInfo)) + for _, t := range(this.teams) { + if t.hasAlreadMember() { + ele := q5.NewSliceElement(&startInfo.TeamList) + ele.TeamUuid = t.teamUuid + q5.NewSlice(&ele.Members, 0, 4) + t.members.ForEach_r( + func (data interface{}) bool { + m := data.(*member) + if m.state == MEMBER_READY_STATE { + ele2 := q5.NewSliceElement(&ele.Members) + ele2.AccountId = m.hum.GetAccountId() + } + return true + }) + } + } } for _, m := range(this.members) { if m.state == MEMBER_READY_STATE && diff --git a/server/hallserver/room/roommgr.go b/server/hallserver/room/roommgr.go index c6d26983..dd2e9ce7 100644 --- a/server/hallserver/room/roommgr.go +++ b/server/hallserver/room/roommgr.go @@ -107,7 +107,7 @@ func (this *roomMgr) CMSearchRoom(hdr *f5.MsgHdr, msg *cs.CMSearchRoom) { this.roomList.ForEach_r( func (data interface{}) bool { r := data.(room) - if r.roomIdx > sinceId && r.view() { + if r.roomIdx > sinceId && r.viewable() { pb := new(cs.MFRoom) r.fillMFRoom(pb) rspMsg.Rows = append(rspMsg.Rows, pb) diff --git a/server/hallserver/room/team.go b/server/hallserver/room/team.go index 17ecd913..6ed1f93e 100644 --- a/server/hallserver/room/team.go +++ b/server/hallserver/room/team.go @@ -2,10 +2,6 @@ package room import ( "q5" - //"f5" - //"cs" - //"main/common" - //"github.com/golang/protobuf/proto" ) type team struct { @@ -24,6 +20,20 @@ func (this *team) getMemberNum() int32 { return this.members.Size() } +func (this *team) hasAlreadMember() bool { + ok := false + this.members.ForEach_r( + func (data interface{}) bool { + m := data.(*member) + if m.state == MEMBER_READY_STATE { + ok = true + return false + } + return true + }) + return ok +} + func newTeam(leader *member) *team { t := new(team) t.members.Init(nil) diff --git a/third_party/q5 b/third_party/q5 index 2ce4c46c..fe65489d 160000 --- a/third_party/q5 +++ b/third_party/q5 @@ -1 +1 @@ -Subproject commit 2ce4c46c710cce553a5a059dda83fdf72a038a46 +Subproject commit fe65489de27eef96e2c1879cb19dd84ee172be9c