DEADSOFTWARE

net: cancel interpolation of teleported players
[d2df-sdl.git] / src / game / g_netmsg.pas
index 92c45168c620f9c1f450c3e5ffc650f1b20ad359..17942e24e65b63be12b38c02f369ee7a0d9f0e6d 100644 (file)
@@ -495,7 +495,7 @@ begin
   else
   begin
     plr.Respawn(False);
-    if gLMSRespawn = LMS_RESPAWN_WARMUP then
+    if gLMSRespawn > LMS_RESPAWN_NONE then
       MH_SEND_GameEvent(NET_EV_LMS_WARMUP, gLMSRespawnTime - gTime, 'N', C.ID);
   end;
 end;
@@ -595,7 +595,7 @@ begin
     begin
       if Pl.FSpectator then
       begin
-        if (gGameSettings.MaxLives = 0) or (gLMSRespawn = LMS_RESPAWN_WARMUP) then
+        if (gGameSettings.MaxLives = 0) or (gLMSRespawn > LMS_RESPAWN_NONE) then
           Pl.Respawn(False)
         else
           MH_SEND_GameEvent(NET_EV_LMS_NOSPAWN, Pl.UID);
@@ -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);
@@ -1768,8 +1769,6 @@ begin
 
   gTime := EvTime;
 
-  e_LogWritefln('EVENT %d %d', [EvType, EvNum]);
-
   if (g_Res_received_map_start <> 0) then
   begin
     if (g_Res_received_map_start < 0) then exit;
@@ -2266,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
@@ -2277,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();
@@ -2346,12 +2347,12 @@ begin
     FSpectator := M.ReadByte() <> 0;
     if FSpectator then
     begin
-      if Pl = gPlayer1 then
+      if UID = NetPlrUID1 then
       begin
         gSpectLatchPID1 := UID;
         gPlayer1 := nil;
       end;
-      if Pl = gPlayer2 then
+      if UID = NetPlrUID2 then
       begin
         gSpectLatchPID2 := UID;
         gPlayer2 := nil;