fix: 修复 room.Manager.GetRoom 函数的空指针问题

This commit is contained in:
kercylan98 2023-10-11 14:31:28 +08:00
parent fb60065ec1
commit 039500ba87
1 changed files with 5 additions and 2 deletions

View File

@ -208,8 +208,11 @@ func (slf *Manager[PID, P, R]) SetOwner(roomId int64, owner PID) {
} }
// GetRoom 获取房间 // GetRoom 获取房间
func (slf *Manager[PID, P, R]) GetRoom(guid int64) R { func (slf *Manager[PID, P, R]) GetRoom(guid int64) (r R) {
return slf.rooms.Get(guid).room if room := slf.rooms.Get(guid); room != nil {
r = room.room
}
return r
} }
// Exist 检查房间是否存在 // Exist 检查房间是否存在