1
This commit is contained in:
parent
00475bc084
commit
97a0ede5c1
@ -30,3 +30,4 @@ const (
|
|||||||
const SEARCH_ROOM_PAGE_SIZE = 20
|
const SEARCH_ROOM_PAGE_SIZE = 20
|
||||||
const ROOM_MAX_PLAYER_NUM = 40
|
const ROOM_MAX_PLAYER_NUM = 40
|
||||||
const ROOM_MAX_TEAM_NUM = 10
|
const ROOM_MAX_TEAM_NUM = 10
|
||||||
|
const ROOM_MAX_TEAM_MEMBER_NUM = 4
|
||||||
|
@ -36,4 +36,10 @@ enum SMMessageId_e
|
|||||||
_SMStartGame = 111;
|
_SMStartGame = 111;
|
||||||
_SMSetPrepare = 112;
|
_SMSetPrepare = 112;
|
||||||
_SMKickout = 113;
|
_SMKickout = 113;
|
||||||
|
|
||||||
|
_SMRoomMemberChagnedNotify = 1001;
|
||||||
|
_SMRoomKickoutNotify = 1002;
|
||||||
|
_SMRoomLeaveNotify = 1003;
|
||||||
|
_SMRoomDisbandNotify = 1004;
|
||||||
|
_SMRoomChangedNotify = 1005;
|
||||||
}
|
}
|
||||||
|
@ -268,3 +268,33 @@ message CMSetPrepare
|
|||||||
message CMKickout
|
message CMKickout
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//房间成员信息变更通知
|
||||||
|
message SMRoomMemberChangeNotify
|
||||||
|
{
|
||||||
|
optional MFMember member = 1; //成员信息
|
||||||
|
}
|
||||||
|
|
||||||
|
//房间踢人通知
|
||||||
|
message SMRoomKickoutNotify
|
||||||
|
{
|
||||||
|
repeated string account_ids = 1; //成员account_id列表
|
||||||
|
}
|
||||||
|
|
||||||
|
//房间玩家离开通知
|
||||||
|
message SMRoomLeaveNotify
|
||||||
|
{
|
||||||
|
repeated string account_ids = 1; //成员account_id列表
|
||||||
|
}
|
||||||
|
|
||||||
|
//房间解散通知
|
||||||
|
message SMRoomDisbandNotify
|
||||||
|
{
|
||||||
|
optional string room_id = 1; //房间id
|
||||||
|
}
|
||||||
|
|
||||||
|
//房间信息变更通知
|
||||||
|
message SMRoomChangeNotify
|
||||||
|
{
|
||||||
|
optional MFRoom room = 1; //房间信息
|
||||||
|
}
|
||||||
|
5
server/hallserver/room/constant.go
Normal file
5
server/hallserver/room/constant.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package room
|
||||||
|
|
||||||
|
const (
|
||||||
|
MEMBER_READY_STATE = 1
|
||||||
|
)
|
@ -49,9 +49,20 @@ func (this *room) getMember(accountId string) *member {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *room) getTeam(teamUuid string) *team {
|
||||||
|
t, ok := this.teams[teamUuid]
|
||||||
|
if ok {
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (this *room) canJoin(member common.Player, passwd string) bool {
|
func (this *room) canJoin(member common.Player, passwd string) bool {
|
||||||
if member.GetRoom() != nil {
|
if member.GetRoom() != nil {
|
||||||
return false
|
return false
|
||||||
|
}
|
||||||
|
if len(this.teams) >= constant.ROOM_MAX_TEAM_NUM {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
if this.getMember(member.GetAccountId()) != nil {
|
if this.getMember(member.GetAccountId()) != nil {
|
||||||
return false
|
return false
|
||||||
@ -59,15 +70,26 @@ func (this *room) canJoin(member common.Player, passwd string) bool {
|
|||||||
if this.config.passwd != passwd {
|
if this.config.passwd != passwd {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
t := this.getTeam(member.GetTeamUuid())
|
||||||
|
if t != nil && t.getMemberNum() >= constant.ROOM_MAX_TEAM_MEMBER_NUM {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *room) join(member common.Player, passwd string) bool {
|
func (this *room) join(hum common.Player, passwd string) bool {
|
||||||
if !this.canJoin(member, passwd) {
|
if !this.canJoin(hum, passwd) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
this.members[member.GetAccountId()] = newMember(member)
|
m := newMember(hum)
|
||||||
member.SetRoom(this)
|
this.members[hum.GetAccountId()] = m
|
||||||
|
t := this.getTeam(hum.GetTeamUuid())
|
||||||
|
if t == nil {
|
||||||
|
t = newTeam(m)
|
||||||
|
this.teams[hum.GetTeamUuid()] = t
|
||||||
|
}
|
||||||
|
t.addMember(m)
|
||||||
|
hum.SetRoom(this)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,8 +119,11 @@ func (this *room) CMDisbandRoom(hdr *f5.MsgHdr, msg *cs.CMDisbandRoom) {
|
|||||||
|
|
||||||
func (this *room) CMLeaveRoom(hdr *f5.MsgHdr, msg *cs.CMLeaveRoom) {
|
func (this *room) CMLeaveRoom(hdr *f5.MsgHdr, msg *cs.CMLeaveRoom) {
|
||||||
hum := hdr.Context.(common.Player)
|
hum := hdr.Context.(common.Player)
|
||||||
rspMsg := cs.SMLeaveRoom{}
|
m := this.getMember(hum.GetAccountId())
|
||||||
hum.SendMsg(&rspMsg)
|
if m != nil {
|
||||||
|
notifyMsg := &cs.SMRoomLeaveNotify{}
|
||||||
|
this.broadcastMsg(notifyMsg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *room) CMModifyRoom(hdr *f5.MsgHdr, msg *cs.CMModifyRoom) {
|
func (this *room) CMModifyRoom(hdr *f5.MsgHdr, msg *cs.CMModifyRoom) {
|
||||||
@ -114,14 +139,28 @@ func (this *room) CMStartGame(hdr *f5.MsgHdr, msg *cs.CMStartGame) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *room) CMSetPrepare(hdr *f5.MsgHdr, msg *cs.CMSetPrepare) {
|
func (this *room) CMSetPrepare(hdr *f5.MsgHdr, msg *cs.CMSetPrepare) {
|
||||||
/*hum := hdr.Context.(common.Player)
|
hum := hdr.Context.(common.Player)
|
||||||
rspMsg := cs.SMSetPrepare{}
|
m := this.getMember(hum.GetAccountId())
|
||||||
hum.SendMsg(&rspMsg)*/
|
if m != nil {
|
||||||
|
m.state = MEMBER_READY_STATE
|
||||||
|
notifyMsg := &cs.SMRoomMemberChangeNotify{}
|
||||||
|
notifyMsg.Member = new(cs.MFMember)
|
||||||
|
m.fillMFMember(notifyMsg.Member)
|
||||||
|
this.broadcastMsg(notifyMsg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *room) CMKickout(hdr *f5.MsgHdr, msg *cs.CMKickout) {
|
func (this *room) CMKickout(hdr *f5.MsgHdr, msg *cs.CMKickout) {
|
||||||
/*
|
|
||||||
hum := hdr.Context.(common.Player)
|
hum := hdr.Context.(common.Player)
|
||||||
rspMsg := cs.SMkickout{}
|
m := this.getMember(hum.GetAccountId())
|
||||||
hum.SendMsg(&rspMsg)*/
|
if m != nil {
|
||||||
|
notifyMsg := &cs.SMRoomKickoutNotify{}
|
||||||
|
this.broadcastMsg(notifyMsg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *room) broadcastMsg(msg proto.Message) {
|
||||||
|
for _, m := range(this.members) {
|
||||||
|
m.hum.SendMsg(msg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,12 @@ func (this *roomMgr) CMJoinRoom(hdr *f5.MsgHdr, msg *cs.CMJoinRoom) {
|
|||||||
hum.SendMsg(&rspMsg)
|
hum.SendMsg(&rspMsg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if hum.GetTeamUuid() == "" {
|
||||||
|
rspMsg.Errcode = proto.Int32(4)
|
||||||
|
rspMsg.Errmsg = proto.String("team_uuid is empty")
|
||||||
|
hum.SendMsg(&rspMsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
r := this.getRoom(msg.GetRoomId())
|
r := this.getRoom(msg.GetRoomId())
|
||||||
if r == nil {
|
if r == nil {
|
||||||
rspMsg.Errcode = proto.Int32(2)
|
rspMsg.Errcode = proto.Int32(2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user