1
This commit is contained in:
parent
e0a9a2b673
commit
4928800fb0
@ -38,6 +38,10 @@ type room struct {
|
||||
|
||||
func (this *room) init(roomId string, roomIdx int64,
|
||||
owner common.Player, msg *cs.CMCreateRoom) {
|
||||
this.teamUuidHash = map[string]*team{}
|
||||
this.teamIdHash = map[int32]*team{}
|
||||
this.members = map[string]*member{}
|
||||
|
||||
this.roomId = roomId
|
||||
this.roomIdx = roomIdx
|
||||
this.entry.Init(this)
|
||||
@ -47,16 +51,8 @@ func (this *room) init(roomId string, roomIdx int64,
|
||||
this.config.passwd = msg.GetPasswd()
|
||||
this.config.maxTeamNum = constant.ROOM_MAX_TEAM_NUM
|
||||
this.owner = newMember(this, owner)
|
||||
this.members = map[string]*member{
|
||||
owner.GetAccountId(): this.owner,
|
||||
}
|
||||
t := newTeam(this, this.genTeamId(), msg.GetTeamUuid(), this.owner)
|
||||
this.teamUuidHash = map[string]*team {
|
||||
msg.GetTeamUuid(): t,
|
||||
}
|
||||
this.teamIdHash = map[int32]*team {
|
||||
t.teamId: t,
|
||||
}
|
||||
this.addMember(this.owner)
|
||||
this.addTeam(newTeam(this, this.genTeamId(), msg.GetTeamUuid(), this.owner))
|
||||
this.owner.hum.SetRoom(this)
|
||||
this.attacher = f5.GetTimer().NewTimerAttacher()
|
||||
this.startTimer = f5.GetTimer().SetTimeoutExWp(
|
||||
@ -125,12 +121,10 @@ func (this *room) join(hum common.Player, msg *cs.CMJoinRoom) bool {
|
||||
return false
|
||||
}
|
||||
m := newMember(this, hum)
|
||||
this.members[hum.GetAccountId()] = m
|
||||
this.addMember(m)
|
||||
t := this.getTeamByUuid(msg.GetTeamUuid())
|
||||
if t == nil {
|
||||
t = newTeam(this, this.genTeamId(), msg.GetTeamUuid(), m)
|
||||
this.teamUuidHash[msg.GetTeamUuid()] = t
|
||||
this.teamIdHash[t.teamId] = t
|
||||
this.addTeam(newTeam(this, this.genTeamId(), msg.GetTeamUuid(), m))
|
||||
} else {
|
||||
t.addMember(m)
|
||||
}
|
||||
@ -138,6 +132,15 @@ func (this *room) join(hum common.Player, msg *cs.CMJoinRoom) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (this *room) addMember(m *member) {
|
||||
this.members[m.hum.GetAccountId()] = m
|
||||
}
|
||||
|
||||
func (this *room) addTeam(t *team) {
|
||||
this.teamUuidHash[t.teamUuid] = t
|
||||
this.teamIdHash[t.teamId] = t
|
||||
}
|
||||
|
||||
func (this *room) fillMFRoom(pb *cs.MFRoom) {
|
||||
pb.RoomId = proto.String(this.roomId)
|
||||
pb.MapId = proto.Int32(this.config.mapId)
|
||||
|
Loading…
x
Reference in New Issue
Block a user