mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 14:22:26 +08:00
perf与性能优化
This commit is contained in:
@@ -23,13 +23,13 @@ func Run(ctx context.Context, configFile string) error {
|
||||
config.InitConfig(configFile)
|
||||
|
||||
// natsrpc client
|
||||
client, err := rpc.NewClient()
|
||||
discoveryClient, err := rpc.NewDiscoveryClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 注册到节点服务器
|
||||
rsp, err := client.Discovery.RegisterServer(context.TODO(), &api.RegisterServerReq{
|
||||
rsp, err := discoveryClient.RegisterServer(context.TODO(), &api.RegisterServerReq{
|
||||
ServerType: api.ANTICHEAT,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -40,7 +40,7 @@ func Run(ctx context.Context, configFile string) error {
|
||||
ticker := time.NewTicker(time.Second * 15)
|
||||
for {
|
||||
<-ticker.C
|
||||
_, err := client.Discovery.KeepaliveServer(context.TODO(), &api.KeepaliveServerReq{
|
||||
_, err := discoveryClient.KeepaliveServer(context.TODO(), &api.KeepaliveServerReq{
|
||||
ServerType: api.ANTICHEAT,
|
||||
AppId: APPID,
|
||||
})
|
||||
@@ -50,7 +50,7 @@ func Run(ctx context.Context, configFile string) error {
|
||||
}
|
||||
}()
|
||||
defer func() {
|
||||
_, _ = client.Discovery.CancelServer(context.TODO(), &api.CancelServerReq{
|
||||
_, _ = discoveryClient.CancelServer(context.TODO(), &api.CancelServerReq{
|
||||
ServerType: api.ANTICHEAT,
|
||||
AppId: APPID,
|
||||
})
|
||||
@@ -64,7 +64,7 @@ func Run(ctx context.Context, configFile string) error {
|
||||
|
||||
gdconf.InitGameDataConfig()
|
||||
|
||||
messageQueue := mq.NewMessageQueue(api.ANTICHEAT, APPID, client)
|
||||
messageQueue := mq.NewMessageQueue(api.ANTICHEAT, APPID, discoveryClient)
|
||||
defer messageQueue.Close()
|
||||
|
||||
handle.NewHandle(messageQueue)
|
||||
|
||||
@@ -22,6 +22,7 @@ const (
|
||||
JumpDistance = 500.0
|
||||
PointDistance = 10.0
|
||||
AttackCountLimitEntitySec = 10
|
||||
KickCheatPlayer = false
|
||||
)
|
||||
|
||||
type MoveVector struct {
|
||||
@@ -232,7 +233,6 @@ func (h *Handle) CombatInvocationsNotify(userId uint32, gateAppId string, payloa
|
||||
continue
|
||||
}
|
||||
moveSpeed := ctx.GetMoveSpeed()
|
||||
logger.Debug("player move speed: %v, uid: %v", moveSpeed, userId)
|
||||
if moveSpeed > MaxMoveSpeed {
|
||||
logger.Warn("player move overspeed, speed: %v, uid: %v", moveSpeed, userId)
|
||||
h.KickPlayer(userId, gateAppId)
|
||||
@@ -286,6 +286,9 @@ func GetDistance(v1 *proto.Vector, v2 *proto.Vector) float32 {
|
||||
}
|
||||
|
||||
func (h *Handle) KickPlayer(userId uint32, gateAppId string) {
|
||||
if !KickCheatPlayer {
|
||||
return
|
||||
}
|
||||
h.messageQueue.SendToGate(gateAppId, &mq.NetMsg{
|
||||
MsgType: mq.MsgTypeConnCtrl,
|
||||
EventId: mq.KickPlayerNotify,
|
||||
|
||||
Reference in New Issue
Block a user