diff --git a/logic/controller/map.go b/logic/controller/map.go index 62e99780..588a0d2b 100644 --- a/logic/controller/map.go +++ b/logic/controller/map.go @@ -16,6 +16,10 @@ import ( func (h Controller) EnterMap(data *space.InInfo, c *player.Player) (result *info.SimpleInfo, err errorcode.ErrorCode) { //这个时候player应该是空的 + if c.Info.MapID != data.MapId { + atomic.StoreUint32(&c.Canmon, 2) + c.MapNPC.Reset(7 * time.Second) + } c.Info.MapID = data.MapId //登录地图 c.Info.Pos = data.Point @@ -25,7 +29,7 @@ func (h Controller) EnterMap(data *space.InInfo, c *player.Player) (result *info // copier.CopyWithOption(result, c.Info, copier.Option{DeepCopy: true}) - defer c.GetSpace().EnterMap(c) + c.GetSpace().EnterMap(c) return nil, -1 } @@ -45,16 +49,15 @@ func (h Controller) LeaveMap(data *space.LeaveMapInboundInfo, c *player.Player) result = &info.LeaveMapOutboundInfo{ UserID: c.Info.UserID, } - defer c.GetSpace().LeaveMap(c) //玩家离开地图 + c.GetSpace().LeaveMap(c) //玩家离开地图 // 如果有正在运行的刷怪协程,发送停止信号 //c.Info.MapID = 0 // 重置当前地图 - return + return nil, -1 } func (h Controller) GetMapPlayerList(data *space.ListMapPlayerInboundInfo, c *player.Player) (result *info.ListMapPlayerOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的 - atomic.StoreUint32(&c.Canmon, 2) - c.MapNPC.Reset(5 * time.Second) + result = &info.ListMapPlayerOutboundInfo{ Player: c.GetSpace().GetInfo(c), } diff --git a/logic/service/space/in_out.go b/logic/service/space/in_out.go index aa7806ae..7d111ea5 100644 --- a/logic/service/space/in_out.go +++ b/logic/service/space/in_out.go @@ -32,11 +32,10 @@ func (s *Space) Broadcast(c common.PlayerI, cmd uint32, data any) { func (s *Space) LeaveMap(c common.PlayerI) { info := &info.LeaveMapOutboundInfo{UserID: c.GetInfo().UserID} c.SendPackCmd(2002, info) - - s.Broadcast(c, 2002, info) - s.User.Delete(c.GetInfo().UserID) s.UserInfo.Delete(c.GetInfo().UserID) + s.Broadcast(c, 2002, info) + current, ok := maphot[s.Super] if ok && *current > 0 { atomic.AddInt32(maphot[s.Super], -1) @@ -54,11 +53,11 @@ func (s *Space) EnterMap(c common.PlayerI) { out := info.NewOutInfo() copier.CopyWithOption(out, c.GetInfo(), copier.Option{DeepCopy: true}) + c.SendPackCmd(2001, out) + s.Broadcast(c, 2001, out) s.User.Store(c.GetInfo().UserID, c) s.UserInfo.Store(c.GetInfo().UserID, *out) - c.SendPackCmd(2001, out) - s.Broadcast(c, 2001, out) _, ok := maphot[s.Super] if ok { atomic.AddInt32(maphot[s.Super], 1)