This commit is contained in:
aozhiwei 2024-02-01 16:51:11 +08:00
parent 7f802a1e75
commit 68da51ce1a
2 changed files with 50 additions and 2 deletions

View File

@ -293,7 +293,7 @@ func (this *room) fillMFCurrentRoom(hum common.Player, pb *cs.MFCurrentRoom) {
q5.AppendSlice(&pb.TeamList, pbT)
}
sort.Slice(pb.TeamList, func(i, j int) bool {
return *pb.TeamList[i].SortIdx < *pb.TeamList[j].SortIdx
return pb.TeamList[i].GetSortIdx() < pb.TeamList[j].GetSortIdx()
})
for _, t := range this.obTeamUuidHash {
pbT := &cs.MFTeam{}
@ -302,7 +302,7 @@ func (this *room) fillMFCurrentRoom(hum common.Player, pb *cs.MFCurrentRoom) {
q5.AppendSlice(&pb.TeamList, pbT)
}
sort.Slice(pb.ObserverTeamList, func(i, j int) bool {
return *pb.ObserverTeamList[i].SortIdx < *pb.ObserverTeamList[j].SortIdx
return pb.ObserverTeamList[i].GetSortIdx() < pb.ObserverTeamList[j].GetSortIdx()
})
}

View File

@ -264,4 +264,52 @@ func (this *roomMgr) CMLeaveObserver(hdr *f5.MsgHdr, msg *cs.CMLeaveObserver) {
}
func (this *roomMgr) CMSwitchTeam(hdr *f5.MsgHdr, msg *cs.CMSwitchTeam) {
hum := hdr.Context.(common.Player)
rspMsg := cs.SMSwitchTeam{}
roomPtr, ok := hum.GetRoom().(*room)
if !ok || roomPtr == nil {
rspMsg.Errcode = proto.Int32(1)
rspMsg.Errmsg = proto.String("room is empty")
hum.SendMsg(&rspMsg)
return
}
if !roomPtr.isOwner(hum) {
rspMsg.Errcode = proto.Int32(1)
rspMsg.Errmsg = proto.String("is not room owner")
hum.SendMsg(&rspMsg)
return
}
if msg.GetType() == 0 {
t := roomPtr.getObTeamById(msg.GetTeamId())
if t == nil {
rspMsg.Errcode = proto.Int32(1)
rspMsg.Errmsg = proto.String("team_id error")
hum.SendMsg(&rspMsg)
return
}
if roomPtr.isTeamFull() {
rspMsg.Errcode = proto.Int32(3)
rspMsg.Errmsg = proto.String("room team is full")
hum.SendMsg(&rspMsg)
return
}
roomPtr.removeObTeam(t)
roomPtr.addTeam(t)
} else {
t := roomPtr.getTeamById(msg.GetTeamId())
if t == nil {
rspMsg.Errcode = proto.Int32(1)
rspMsg.Errmsg = proto.String("team_id error")
hum.SendMsg(&rspMsg)
return
}
roomPtr.removeTeam(t)
roomPtr.addObTeam(t)
}
hum.SendMsg(&rspMsg)
roomPtr.notifyRoomInfo(hum)
}