From 26c0265257cea7f80b2b1a7cbe11c46aa0533949 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Tue, 17 Mar 2020 23:08:15 +0300 Subject: [PATCH] net: cancel interpolation of teleported players --- src/game/g_netmsg.pas | 9 ++++++--- src/game/g_player.pas | 7 ++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas index 5e95a6a..17942e2 100644 --- a/src/game/g_netmsg.pas +++ b/src/game/g_netmsg.pas @@ -1110,9 +1110,10 @@ begin if IsKeyPressed(KEY_UP) then kByte := kByte or NET_KEY_UP; if IsKeyPressed(KEY_DOWN) then kByte := kByte or NET_KEY_DOWN; if IsKeyPressed(KEY_JUMP) then kByte := kByte or NET_KEY_JUMP; - if JustTeleported then kByte := kByte or NET_KEY_FORCEDIR; end; + if JustTeleported then kByte := kByte or NET_KEY_FORCEDIR; + NetOut.Write(kByte); if Direction = TDirection.D_LEFT then NetOut.Write(Byte(0)) else NetOut.Write(Byte(1)); NetOut.Write(GameX); @@ -2264,7 +2265,7 @@ begin ReleaseKeys; - if (kByte = NET_KEY_CHAT) then + if LongBool(kByte and NET_KEY_CHAT) then PressKey(KEY_CHAT, 10000) else begin @@ -2275,7 +2276,9 @@ begin if LongBool(kByte and NET_KEY_JUMP) then PressKey(KEY_JUMP, 10000); end; - if ((Pl <> gPlayer1) and (Pl <> gPlayer2)) or LongBool(kByte and NET_KEY_FORCEDIR) then + JustTeleported := LongBool(kByte and NET_KEY_FORCEDIR); + + if ((Pl <> gPlayer1) and (Pl <> gPlayer2)) or JustTeleported then SetDirection(TDirection(Dir)); GameVelX := M.ReadLongInt(); diff --git a/src/game/g_player.pas b/src/game/g_player.pas index a66b064..0b72fc9 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -5779,10 +5779,15 @@ var begin FXTo := XTo; FYTo := YTo; - if NetInterpLevel < 1 then + if FJustTeleported or (NetInterpLevel < 1) then begin FObj.X := XTo; FObj.Y := YTo; + if FJustTeleported then + begin + FObj.oldX := FObj.X; + FObj.oldY := FObj.Y; + end; end else begin -- 2.29.2