增加地图广播限制速率
This commit is contained in:
@@ -53,7 +53,7 @@ func (h *Controller) MapList(data *maps.ListMapPlayerInboundInfo, c *player.Play
|
||||
result1 := maps.NewOutInfo()
|
||||
copier.CopyWithOption(result1, player.GetInfo(), copier.Option{DeepCopy: true})
|
||||
result.Player = append(result.Player, *result1)
|
||||
result.Player=LastFourElements(result.Player)
|
||||
result.Player = LastFourElements(result.Player)
|
||||
})
|
||||
|
||||
c.Canmon = true //可以刷怪
|
||||
@@ -66,5 +66,5 @@ func LastFourElements[T any](s []T) []T {
|
||||
return s
|
||||
}
|
||||
// 切片长度大于4时,返回最后4个元素(从n-4索引到末尾)
|
||||
return s[n-4:]
|
||||
}
|
||||
return s[n-30:]
|
||||
}
|
||||
|
||||
@@ -8,15 +8,17 @@ import (
|
||||
|
||||
func (h Controller) Walk(data *maps.WalkInInfo, c *player.Player) (result *maps.WalkOutInfo, err errorcode.ErrorCode) {
|
||||
result = &maps.WalkOutInfo{
|
||||
Flag: data.Flag,
|
||||
Point: data.Point,
|
||||
Path: data.Path,
|
||||
Flag: data.Flag,
|
||||
Point: data.Point,
|
||||
Path: data.Path,
|
||||
}
|
||||
|
||||
result.UserID = data.Head.UserID
|
||||
c.Info.Pos = data.Point
|
||||
//glog.Debug(context.Background(), err1)
|
||||
data.Broadcast(c.Info.MapID, *result) //走路的广播
|
||||
if !c.Info.Pos.BothLessThan50(data.Point) { //距离超过50才广播
|
||||
data.Broadcast(c.Info.MapID, *result) //走路的广播
|
||||
}
|
||||
|
||||
return nil, -1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user