1
This commit is contained in:
parent
e80dd01574
commit
62ef4c3a26
@ -11,6 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Room interface {
|
type Room interface {
|
||||||
|
GetRoomState() int32
|
||||||
OnPlayerOffline(Player)
|
OnPlayerOffline(Player)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,6 +308,10 @@ func (this *room) viewable() bool {
|
|||||||
return this.roomState == ROOM_INIT_STATE
|
return this.roomState == ROOM_INIT_STATE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *room) GetRoomState() int32 {
|
||||||
|
return this.roomState
|
||||||
|
}
|
||||||
|
|
||||||
func (this *room) notifyGameStart() {
|
func (this *room) notifyGameStart() {
|
||||||
if this.gameStartNotifyMsg == nil {
|
if this.gameStartNotifyMsg == nil {
|
||||||
this.gameStartNotifyMsg = &cs.SMRoomGameStartNotify{}
|
this.gameStartNotifyMsg = &cs.SMRoomGameStartNotify{}
|
||||||
|
@ -54,7 +54,7 @@ func (this *roomMgr) ProcessCMMsg(handler *cs.CsNetMsgHandler, hdr *f5.MsgHdr) {
|
|||||||
func (this *roomMgr) CMCreateRoom(hdr *f5.MsgHdr, msg *cs.CMCreateRoom) {
|
func (this *roomMgr) CMCreateRoom(hdr *f5.MsgHdr, msg *cs.CMCreateRoom) {
|
||||||
hum := hdr.Context.(common.Player)
|
hum := hdr.Context.(common.Player)
|
||||||
rspMsg := &cs.SMCreateRoom{}
|
rspMsg := &cs.SMCreateRoom{}
|
||||||
if hum.GetRoom() != nil {
|
if hum.GetRoom() != nil && hum.GetRoom().GetRoomState() == ROOM_INIT_STATE {
|
||||||
rspMsg.Errcode = proto.Int32(1)
|
rspMsg.Errcode = proto.Int32(1)
|
||||||
rspMsg.Errmsg = proto.String("already room")
|
rspMsg.Errmsg = proto.String("already room")
|
||||||
hum.SendMsg(rspMsg)
|
hum.SendMsg(rspMsg)
|
||||||
@ -63,6 +63,7 @@ func (this *roomMgr) CMCreateRoom(hdr *f5.MsgHdr, msg *cs.CMCreateRoom) {
|
|||||||
m := new(room)
|
m := new(room)
|
||||||
m.init(q5.ToString(this.genRoomId()), this.genRoomIdx(), msg.GetMapId(), hum, msg.GetPasswd())
|
m.init(q5.ToString(this.genRoomId()), this.genRoomIdx(), msg.GetMapId(), hum, msg.GetPasswd())
|
||||||
this.idHash[m.roomId] = m
|
this.idHash[m.roomId] = m
|
||||||
|
this.roomList.AddTail(&m.entry)
|
||||||
|
|
||||||
rspMsg.RoomId = proto.String(m.roomId)
|
rspMsg.RoomId = proto.String(m.roomId)
|
||||||
hum.SendMsg(rspMsg)
|
hum.SendMsg(rspMsg)
|
||||||
@ -102,11 +103,11 @@ func (this *roomMgr) CMJoinRoom(hdr *f5.MsgHdr, msg *cs.CMJoinRoom) {
|
|||||||
func (this *roomMgr) CMSearchRoom(hdr *f5.MsgHdr, msg *cs.CMSearchRoom) {
|
func (this *roomMgr) CMSearchRoom(hdr *f5.MsgHdr, msg *cs.CMSearchRoom) {
|
||||||
hum := hdr.Context.(common.Player)
|
hum := hdr.Context.(common.Player)
|
||||||
rspMsg := cs.SMSearchRoom{}
|
rspMsg := cs.SMSearchRoom{}
|
||||||
rspMsg.Rows = make([]*cs.MFRoom, constant.SEARCH_ROOM_PAGE_SIZE, constant.SEARCH_ROOM_PAGE_SIZE)
|
rspMsg.Rows = make([]*cs.MFRoom, 0, constant.SEARCH_ROOM_PAGE_SIZE)
|
||||||
sinceId := msg.GetSinceId()
|
sinceId := msg.GetSinceId()
|
||||||
this.roomList.ForEach(
|
this.roomList.ForEach(
|
||||||
func (data interface{}) bool {
|
func (data interface{}) bool {
|
||||||
r := data.(room)
|
r := data.(*room)
|
||||||
if r.roomIdx > sinceId && r.viewable() {
|
if r.roomIdx > sinceId && r.viewable() {
|
||||||
pb := new(cs.MFRoom)
|
pb := new(cs.MFRoom)
|
||||||
r.fillMFRoom(pb)
|
r.fillMFRoom(pb)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user