From: Ketmar Dark Date: Fri, 18 May 2018 20:24:30 +0000 (+0300) Subject: non-headless game server should not crash on map view anymore X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=331297e82162a6acd3e9e07605368e329ce66105;p=d2df-sdl.git non-headless game server should not crash on map view anymore lol, there is no player in map view mode, and the corresponding map profiler is not created (but is used). --- diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 81eade6..b2c3dc0 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -3120,7 +3120,7 @@ var tagmask: Integer; pan: TPanel; begin - profileFrameDraw.sectionBegin(profname); + if (profileFrameDraw <> nil) then profileFrameDraw.sectionBegin(profname); if gdbg_map_use_accel_render then begin tagmask := panelTypeToTag(panType); @@ -3136,31 +3136,31 @@ var begin if doDraw then g_Map_DrawPanels(panType, hasAmbient, ambColor); end; - profileFrameDraw.sectionEnd(); + if (profileFrameDraw <> nil) then profileFrameDraw.sectionEnd(); end; procedure drawOther (profname: AnsiString; cb: TDrawCB); begin - profileFrameDraw.sectionBegin(profname); + if (profileFrameDraw <> nil) then profileFrameDraw.sectionBegin(profname); if assigned(cb) then cb(); - profileFrameDraw.sectionEnd(); + if (profileFrameDraw <> nil) then profileFrameDraw.sectionEnd(); end; begin - profileFrameDraw.sectionBegin('total'); + if (profileFrameDraw <> nil) then profileFrameDraw.sectionBegin('total'); // our accelerated renderer will collect all panels to gDrawPanelList // we can use panel tag to render level parts (see GridTagXXX in g_map.pas) - profileFrameDraw.sectionBegin('collect'); + if (profileFrameDraw <> nil) then profileFrameDraw.sectionBegin('collect'); if gdbg_map_use_accel_render then begin g_Map_CollectDrawPanels(sX, sY, sWidth, sHeight); end; - profileFrameDraw.sectionEnd(); + if (profileFrameDraw <> nil) then profileFrameDraw.sectionEnd(); - profileFrameDraw.sectionBegin('skyback'); + if (profileFrameDraw <> nil) then profileFrameDraw.sectionBegin('skyback'); g_Map_DrawBack(backXOfs, backYOfs); - profileFrameDraw.sectionEnd(); + if (profileFrameDraw <> nil) then profileFrameDraw.sectionEnd(); if setTransMatrix then begin @@ -3217,7 +3217,7 @@ begin g_Player_DrawHealth(); end; - profileFrameDraw.mainEnd(); // map rendering + if (profileFrameDraw <> nil) then profileFrameDraw.mainEnd(); // map rendering end; @@ -3257,7 +3257,7 @@ begin end; if (profileFrameDraw = nil) then profileFrameDraw := TProfiler.Create('RENDER', g_profile_history_size); - profileFrameDraw.mainBegin(g_profile_frame_draw); + if (profileFrameDraw <> nil) then profileFrameDraw.mainBegin(g_profile_frame_draw); gPlayerDrawn := p; @@ -3436,9 +3436,9 @@ var px: Integer = -1; py: Integer = -1; begin - if g_profile_frame_draw then px := px-drawProfiles(px, py, profileFrameDraw); - if g_profile_collision then begin px := px-drawProfiles(px, py, profMapCollision); py -= calcProfilesHeight(profMonsLOS); end; - if g_profile_los then begin px := px-drawProfiles(px, py, profMonsLOS); py -= calcProfilesHeight(profMonsLOS); end; + if g_profile_frame_draw and (profileFrameDraw <> nil) then px := px-drawProfiles(px, py, profileFrameDraw); + if g_profile_collision and (profMapCollision <> nil) then begin px := px-drawProfiles(px, py, profMapCollision); py -= calcProfilesHeight(profMonsLOS); end; + if g_profile_los and (profMonsLOS <> nil) then begin px := px-drawProfiles(px, py, profMonsLOS); py -= calcProfilesHeight(profMonsLOS); end; end; procedure g_Game_Draw(); diff --git a/src/game/g_map.pas b/src/game/g_map.pas index 3b2ad4c..4e347ef 100644 --- a/src/game/g_map.pas +++ b/src/game/g_map.pas @@ -545,9 +545,9 @@ var procedure g_Map_ProfilersBegin (); begin if (profMapCollision = nil) then profMapCollision := TProfiler.Create('COLSOLID', g_profile_history_size); - profMapCollision.mainBegin(g_profile_collision); + if (profMapCollision <> nil) then profMapCollision.mainBegin(g_profile_collision); // create sections - if g_profile_collision then + if g_profile_collision and (profMapCollision <> nil) then begin profMapCollision.sectionBegin('*solids'); profMapCollision.sectionEnd(); diff --git a/src/game/g_monsters.pas b/src/game/g_monsters.pas index 4cba5ac..e496521 100644 --- a/src/game/g_monsters.pas +++ b/src/game/g_monsters.pas @@ -322,8 +322,8 @@ uses procedure g_Mons_ProfilersBegin (); begin if (profMonsLOS = nil) then profMonsLOS := TProfiler.Create('LOS CALC', g_profile_history_size); - profMonsLOS.mainBegin(g_profile_los); - if g_profile_los then + if (profMonsLOS <> nil) then profMonsLOS.mainBegin(g_profile_los); + if g_profile_los and (profMonsLOS <> nil) then begin profMonsLOS.sectionBegin('loscalc'); profMonsLOS.sectionEnd(); @@ -332,17 +332,17 @@ end; procedure g_Mons_ProfilersEnd (); begin - if (profMonsLOS <> nil) and (g_profile_los) then profMapCollision.mainEnd(); + if (profMonsLOS <> nil) and (g_profile_los) then profMonsLOS.mainEnd(); end; procedure g_Mons_LOS_Start (); inline; begin - profMonsLOS.sectionBeginAccum('loscalc'); + if (profMonsLOS <> nil) then profMonsLOS.sectionBeginAccum('loscalc'); end; procedure g_Mons_LOS_End (); inline; begin - profMonsLOS.sectionEnd(); + if (profMonsLOS <> nil) then profMonsLOS.sectionEnd(); end;