From: fgsfds Date: Sun, 15 Mar 2020 00:06:29 +0000 (+0300) Subject: net: only flush packets after an actual frame; remember old positions before net... X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=8b47238d90490db2f55e66c72fe784be7232cc5d;p=d2df-sdl.git net: only flush packets after an actual frame; remember old positions before net update on client --- diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 981082d..16dd284 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -84,6 +84,7 @@ procedure g_Game_Free (freeTextures: Boolean=true); procedure g_Game_LoadData(); procedure g_Game_FreeData(); procedure g_Game_Update(); +procedure g_Game_PreUpdate(); procedure g_Game_Draw(); procedure g_Game_Quit(); procedure g_Game_SetupScreenSize(); @@ -1716,6 +1717,17 @@ begin MC_SEND_CheatRequest(NET_CHEAT_READY); end; +procedure g_Game_PreUpdate(); +begin + // these are in separate PreUpdate functions because they can interact during Update() + // and are synced over the net + // we don't care that much about corpses and gibs + g_Player_PreUpdate(); + g_Monsters_PreUpdate(); + g_Items_PreUpdate(); + g_Weapon_PreUpdate(); +end; + procedure g_Game_Update(); var Msg: g_gui.TMessage; @@ -2162,13 +2174,6 @@ begin end; end; - // these are in separate PreUpdate functions because they can interact during Update() - // we don't care that much about corpses and gibs - g_Player_PreUpdate(); - g_Monsters_PreUpdate(); - g_Items_PreUpdate(); - g_Weapon_PreUpdate(); - // Îáíîâëÿåì âñå îñòàëüíîå: g_Map_Update(); g_Items_Update(); diff --git a/src/game/g_main.pas b/src/game/g_main.pas index 20419ec..af95f90 100644 --- a/src/game/g_main.pas +++ b/src/game/g_main.pas @@ -647,7 +647,16 @@ end; procedure Update (); begin + // remember old mobj positions, prepare for update + g_Game_PreUpdate(); + // server: receive client commands for new frame + // client: receive game state changes from server + if (NetMode = NET_SERVER) then g_Net_Host_Update() + else if (NetMode = NET_CLIENT) then g_Net_Client_Update(); + // think g_Game_Update(); + // server: send any accumulated outgoing data to clients + if NetMode = NET_SERVER then g_Net_Flush(); end; diff --git a/src/game/g_window.pas b/src/game/g_window.pas index 1eaf7b9..37d9791 100644 --- a/src/game/g_window.pas +++ b/src/game/g_window.pas @@ -145,15 +145,9 @@ begin begin flag := true; for i := 1 to t do - begin - if (NetMode = NET_SERVER) then g_Net_Host_Update() - else if (NetMode = NET_CLIENT) then g_Net_Client_Update(); Update(); - end; end; - if NetMode = NET_SERVER then g_Net_Flush(); - g_Map_ProfilersEnd(); g_Mons_ProfilersEnd();