增加地图广播限制速率

This commit is contained in:
1
2025-11-09 06:50:12 +00:00
parent de3fb29407
commit 742bcd8a3f
6 changed files with 39 additions and 11 deletions

View File

@@ -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