From df5b260f5f8fd7a6f10051b2da4bb510580d2be3 Mon Sep 17 00:00:00 2001 From: Ceikry Date: Tue, 6 Jun 2023 02:08:53 +0000 Subject: [PATCH] Clamp forcemovement values in packet to avoid divide-by-zero errors in the client --- .../src/main/core/game/world/update/flag/PlayerFlags530.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Server/src/main/core/game/world/update/flag/PlayerFlags530.kt b/Server/src/main/core/game/world/update/flag/PlayerFlags530.kt index 4fb0eddfc..b9135b782 100644 --- a/Server/src/main/core/game/world/update/flag/PlayerFlags530.kt +++ b/Server/src/main/core/game/world/update/flag/PlayerFlags530.kt @@ -12,6 +12,7 @@ import core.api.* import java.nio.charset.StandardCharsets import kotlin.reflect.* +import kotlin.math.max sealed class PlayerFlags530 (p: Int, o: Int, f: EntityFlag) : EFlagProvider (530, EFlagType.Player, p, o, f) { class Chat : PlayerFlags530 (0x80, 0, EntityFlag.Chat) { @@ -145,8 +146,8 @@ sealed class PlayerFlags530 (p: Int, o: Int, f: EntityFlag) : EFlagProvider (530 buffer.p1add (context.dest.getSceneX(l)) buffer.p1 (context.dest.getSceneY(l)) //arrival times (in client cycles) - buffer.ip2 (context.startArrive) //# of client cycles to start location - buffer.ip2 (context.startArrive + context.destArrive) //# of client cycles to end location + buffer.ip2 (max(1, context.startArrive)) //# of client cycles to start location + buffer.ip2 (max(2, context.startArrive + context.destArrive)) //# of client cycles to end location buffer.p1neg (context.direction.toInteger()) //direction of movement } }