From: Ketmar Dark Date: Thu, 31 Aug 2017 23:00:53 +0000 (+0300) Subject: show map loading update once per 300 msec; it nearly halves loading times for huge... X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=commitdiff_plain;h=464487c1d25e23004bbd30a1246f54561f584943 show map loading update once per 300 msec; it nearly halves loading times for huge maps --- diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 302b952..cc71ea1 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -3990,7 +3990,7 @@ begin end; end; - ProcessLoading(); + ProcessLoading(true); e_PollInput(); @@ -6758,7 +6758,7 @@ begin g_ActiveWindow := nil; - ProcessLoading; + ProcessLoading(true); end; procedure g_Game_StepLoading(); @@ -6770,7 +6770,7 @@ begin if (ShowCount > LOADING_SHOW_STEP) then begin ShowCount := 0; - ProcessLoading; + ProcessLoading(); end; end; end; diff --git a/src/game/g_map.pas b/src/game/g_map.pas index f2922d4..bd2b450 100644 --- a/src/game/g_map.pas +++ b/src/game/g_map.pas @@ -1505,6 +1505,7 @@ var rec, texrec: TDynRecord; pttit: PTRec; pannum, trignum, cnt, tgpid: Integer; + stt: UInt64; begin mapGrid.Free(); mapGrid := nil; @@ -1554,6 +1555,8 @@ begin e_LogWritefln('Loading map: %s', [mapResName], MSG_NOTIFY); g_Game_SetLoadingText(_lc[I_LOAD_MAP], 0, False); + stt := curTimeMicro(); + try mapReader := g_Map_ParseMap(Data, Len); except @@ -2004,6 +2007,9 @@ begin begin gMusic.SetByName(''); end; + + stt := curTimeMicro()-stt; + e_LogWritefln('map loaded in %s.%s milliseconds', [Integer(stt div 1000), Integer(stt mod 1000)]); finally sfsGCEnable(); // enable releasing unused volumes mapReader.Free(); diff --git a/src/game/g_net.pas b/src/game/g_net.pas index 576e877..b6a60c0 100644 --- a/src/game/g_net.pas +++ b/src/game/g_net.pas @@ -787,7 +787,7 @@ begin end; end; - ProcessLoading(); + ProcessLoading(true); e_PollInput(); @@ -952,7 +952,7 @@ begin end; end; - ProcessLoading(); + ProcessLoading(true); e_PollInput(); diff --git a/src/game/g_window.pas b/src/game/g_window.pas index 0ac570d..1b60950 100644 --- a/src/game/g_window.pas +++ b/src/game/g_window.pas @@ -28,7 +28,7 @@ function CreateGLWindow(Title: PChar): Boolean; procedure KillGLWindow(); procedure PushExitEvent(); function ProcessMessage(): Boolean; -procedure ProcessLoading(); +procedure ProcessLoading (forceUpdate: Boolean=false); procedure ReDrawWindow(); procedure SwapBuffers(); procedure Sleep(ms: LongWord); @@ -49,7 +49,7 @@ uses SDL2, GL, GLExt, e_graphics, e_log, g_main, g_console, SysUtils, e_input, g_options, g_game, g_basic, g_textures, e_sound, g_sound, g_menu, ENet, g_net, - g_map, g_gfx, g_monsters, g_holmes; + g_map, g_gfx, g_monsters, g_holmes, xprofiler; var h_Wnd: PSDL_Window; @@ -623,10 +623,15 @@ begin SDL_PushEvent(@ev); end; -procedure ProcessLoading(); + +var + prevLoadingUpdateTime: UInt64 = 0; + +procedure ProcessLoading (forceUpdate: Boolean=false); var ev: TSDL_Event; ID: DWORD; + stt: UInt64; begin FillChar(ev, SizeOf(ev), 0); //wNeedFree := False; @@ -646,24 +651,48 @@ begin if not wMinimized then begin - if g_Texture_Get('INTER', ID) then - e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight) + if forceUpdate then + begin + prevLoadingUpdateTime := curTimeMilli(); + end else - e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0); + begin + stt := curTimeMilli(); + if (stt < prevLoadingUpdateTime) or (stt-prevLoadingUpdateTime >= 400) then + begin + prevLoadingUpdateTime := stt; + forceUpdate := true; + end; + end; - DrawLoadingStat(); - SwapBuffers(); + if forceUpdate then + begin + if g_Texture_Get('INTER', ID) then + begin + e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight) + end + else + begin + e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0); + end; - ReShowCursor(); + DrawLoadingStat(); + SwapBuffers(); + + ReShowCursor(); + end; end; e_SoundUpdate(); if NetMode = NET_SERVER then - g_Net_Host_Update + begin + g_Net_Host_Update(); + end else - if (NetMode = NET_CLIENT) and (NetState <> NET_STATE_AUTH) then - g_Net_Client_UpdateWhileLoading; + begin + if (NetMode = NET_CLIENT) and (NetState <> NET_STATE_AUTH) then g_Net_Client_UpdateWhileLoading(); + end; wLoadingProgress := False; end;