1
This commit is contained in:
parent
e32452b60b
commit
2ca100c006
@ -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 &&
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
2
third_party/q5
vendored
2
third_party/q5
vendored
@ -1 +1 @@
|
||||
Subproject commit 2ce4c46c710cce553a5a059dda83fdf72a038a46
|
||||
Subproject commit fe65489de27eef96e2c1879cb19dd84ee172be9c
|
Loading…
x
Reference in New Issue
Block a user