From eb26b47b8ec3bad1f66ef704c8d9cdb9f586a918 Mon Sep 17 00:00:00 2001 From: huangxiaolei <1782360262@qq.com> Date: Sat, 10 Dec 2022 22:52:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B3=A8=E5=86=8C=E6=96=B0?= =?UTF-8?q?=E5=8F=B7bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gs/game/local_event_manager.go | 4 +++- gs/game/user_manager.go | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gs/game/local_event_manager.go b/gs/game/local_event_manager.go index 7c40a256..ff5753dc 100644 --- a/gs/game/local_event_manager.go +++ b/gs/game/local_event_manager.go @@ -33,7 +33,9 @@ func (l *LocalEventManager) LocalEventHandle(localEvent *LocalEvent) { switch localEvent.EventId { case LoadLoginUserFromDbFinish: playerLoginInfo := localEvent.Msg.(*PlayerLoginInfo) - USER_MANAGER.playerMap[playerLoginInfo.Player.PlayerID] = playerLoginInfo.Player + if playerLoginInfo.Player != nil { + USER_MANAGER.playerMap[playerLoginInfo.Player.PlayerID] = playerLoginInfo.Player + } GAME_MANAGER.OnLoginOk(playerLoginInfo.UserId, playerLoginInfo.Player, playerLoginInfo.ClientSeq) case CheckUserExistOnRegFromDbFinish: playerRegInfo := localEvent.Msg.(*PlayerRegInfo) diff --git a/gs/game/user_manager.go b/gs/game/user_manager.go index 3ad44d27..518f50fc 100644 --- a/gs/game/user_manager.go +++ b/gs/game/user_manager.go @@ -147,11 +147,11 @@ func (u *UserManager) OnlineUser(userId uint32, clientSeq uint32) (*model.Player } else { go func() { player = u.loadUserFromDb(userId) - if player == nil { + if player != nil { + u.ChangeUserDbState(player, model.DbNormal) + } else { logger.LOG.Error("can not find user from db, uid: %v", userId) - return } - u.ChangeUserDbState(player, model.DbNormal) LOCAL_EVENT_MANAGER.localEventChan <- &LocalEvent{ EventId: LoadLoginUserFromDbFinish, Msg: &PlayerLoginInfo{