This commit is contained in:
aozhiwei 2023-09-14 17:29:12 +08:00
parent c8db883ac3
commit 3d2b4cea64
4 changed files with 24 additions and 6 deletions

View File

@ -27,6 +27,12 @@ func (this *member) init(room *room, hum common.Player) {
func (this *member) unInit() {
this.teamEntry.DelInit()
delete(this.room.members, this.hum.GetAccountId())
if this.hum.GetRoom() == this.room {
this.hum.SetRoom(nil)
}
this.room = nil
this.team = nil
}
func (this *member) fillMFMember(pb *cs.MFMember) {

View File

@ -323,7 +323,7 @@ func (this *room) notifyGameStart() {
ele := q5.NewSliceElement(&startInfo.TeamList)
ele.TeamUuid = t.teamUuid
q5.NewSlice(&ele.Members, 0, 4)
t.members.ForEach_r(
t.members.ForEach(
func (data interface{}) bool {
m := data.(*member)
if m.state == MEMBER_READY_STATE {
@ -401,7 +401,10 @@ func (this *room) genTeamId() int32 {
func (this *room) removeMember(accountId string) {
m := this.getMember(accountId)
if m != nil {
t := m.team
m.unInit()
delete(this.members, accountId)
if t.getMemberNum() <= 0 {
t.unInit()
}
}
}

View File

@ -104,7 +104,7 @@ func (this *roomMgr) CMSearchRoom(hdr *f5.MsgHdr, msg *cs.CMSearchRoom) {
rspMsg := cs.SMSearchRoom{}
rspMsg.Rows = make([]*cs.MFRoom, constant.SEARCH_ROOM_PAGE_SIZE, constant.SEARCH_ROOM_PAGE_SIZE)
sinceId := msg.GetSinceId()
this.roomList.ForEach_r(
this.roomList.ForEach(
func (data interface{}) bool {
r := data.(room)
if r.roomIdx > sinceId && r.viewable() {

View File

@ -19,7 +19,13 @@ func (this *team) init(room *room, teamId int32, teamUuid string) {
}
func (this *team) unInit() {
this.members.ForEach(
func (data interface{}) bool {
m := data.(*member)
m.unInit()
return true
})
this.room = nil
}
func (this *team) addMember(m *member) {
@ -30,13 +36,16 @@ func (this *team) addMember(m *member) {
this.members.AddTail(&m.teamEntry)
}
func (this *team) removeMember(m *member) {
}
func (this *team) getMemberNum() int32 {
return this.members.Size()
}
func (this *team) hasAlreadMember() bool {
ok := false
this.members.ForEach_r(
this.members.ForEach(
func (data interface{}) bool {
m := data.(*member)
if m.state == MEMBER_READY_STATE {
@ -50,7 +59,7 @@ func (this *team) hasAlreadMember() bool {
func (this *team) getOwnerCandidate() *member {
var ownerCandidate *member
this.members.ForEach_r(
this.members.ForEach(
func (data interface{}) bool {
m := data.(*member)
if m.hum.IsOnline() {