|
@@ -68,10 +68,10 @@ func GetRoomsByLevel(matchInfo *msg.MatchLudo, roomStatus msg.RoomStatus) []*msg
|
|
return result
|
|
return result
|
|
}
|
|
}
|
|
|
|
|
|
-func CreateRoom(matchInfo *msg.MatchLudo, userId string) *msg.RoomInfo {
|
|
|
|
|
|
+func CreateRoom(matchInfo *msg.MatchLudo, userId string) (*msg.RoomInfo, error) {
|
|
userInfo, err_info := redismgr.GetUserInfoFromRedis(userId)
|
|
userInfo, err_info := redismgr.GetUserInfoFromRedis(userId)
|
|
if err_info != nil {
|
|
if err_info != nil {
|
|
- return nil
|
|
|
|
|
|
+ return nil, errors.New("没在Redis找到该玩家 :" + userId)
|
|
}
|
|
}
|
|
// 生成房间ID(不加锁)
|
|
// 生成房间ID(不加锁)
|
|
roomId := generateRoomID()
|
|
roomId := generateRoomID()
|
|
@@ -96,10 +96,21 @@ func CreateRoom(matchInfo *msg.MatchLudo, userId string) *msg.RoomInfo {
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
+ user_agent := getAgentByUserId(userId)
|
|
|
|
+ if user_agent == nil {
|
|
|
|
+ return nil, errors.New("getAgentByUserId 失败 :" + userId)
|
|
|
|
+ }
|
|
|
|
+ user_agent.SetUserData(&msg.UserInfo{
|
|
|
|
+ UserId: userInfo.UserId,
|
|
|
|
+ Name: userInfo.Name,
|
|
|
|
+ MCoin: userInfo.MCoin,
|
|
|
|
+ MHead: userInfo.MHead,
|
|
|
|
+ RoomId: roomId,
|
|
|
|
+ })
|
|
gameConfig.mu.Lock()
|
|
gameConfig.mu.Lock()
|
|
defer gameConfig.mu.Unlock()
|
|
defer gameConfig.mu.Unlock()
|
|
gameConfig.RoomMap[newRoom.Id] = newRoom
|
|
gameConfig.RoomMap[newRoom.Id] = newRoom
|
|
- return newRoom
|
|
|
|
|
|
+ return newRoom, nil
|
|
}
|
|
}
|
|
|
|
|
|
func JoinRoom(room *msg.RoomInfo, matchInfo *msg.MatchLudo, userId string) (bool, error) {
|
|
func JoinRoom(room *msg.RoomInfo, matchInfo *msg.MatchLudo, userId string) (bool, error) {
|