增加地图广播限制速率
This commit is contained in:
@@ -2,6 +2,7 @@ package model
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"github.com/creasty/defaults"
|
||||
@@ -23,6 +24,23 @@ type Pos struct {
|
||||
Y uint32 `struc:"uint32" default:"0"`
|
||||
}
|
||||
|
||||
// 计算两个uint32的差值绝对值(转为int64避免溢出)
|
||||
func absDiff(a, b uint32) int64 {
|
||||
return int64(math.Abs(float64(int64(a) - int64(b))))
|
||||
}
|
||||
|
||||
// 判断两个Pos的X和Y差值的绝对值是否均小于50
|
||||
func bothDiffsLessThan50(pos1, pos2 Pos) bool {
|
||||
xDiff := absDiff(pos1.X, pos2.X)
|
||||
yDiff := absDiff(pos1.Y, pos2.Y)
|
||||
return xDiff < 50 && yDiff < 50
|
||||
}
|
||||
|
||||
func (p Pos) BothLessThan50(t Pos) bool {
|
||||
|
||||
return bothDiffsLessThan50(p, t)
|
||||
}
|
||||
|
||||
// PeopleItemInfo 穿戴装备信息结构(PeopleItemInfo)
|
||||
type PeopleItemInfo struct {
|
||||
ID uint32 `struc:"uint32"` // 装备id
|
||||
|
||||
Reference in New Issue
Block a user