From: Ketmar Dark Date: Fri, 18 Aug 2017 19:27:28 +0000 (+0300) Subject: removed some "try/finally" (sorry, it is FUCKIN' SLOW!) X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=8f86c573bafaf78c1f051ddb73da538ec544838e;p=d2df-sdl.git removed some "try/finally" (sorry, it is FUCKIN' SLOW!) --- diff --git a/src/game/g_map.pas b/src/game/g_map.pas index b5e457c..e439d17 100644 --- a/src/game/g_map.pas +++ b/src/game/g_map.pas @@ -2263,30 +2263,27 @@ function g_Map_CollidePanel(X, Y: Integer; Width, Height: Word; PanelType: Word; begin //TODO: detailed profile if (profMapCollision <> nil) then profMapCollision.sectionBeginAccum('wall coldet'); - try - if gdbg_map_use_accel_coldet then + if gdbg_map_use_accel_coldet then + begin + if gdbg_map_use_tree_coldet then begin - if gdbg_map_use_tree_coldet then + result := (mapTree.aabbQuery(X, Y, Width, Height, checker, (GridTagWallDoor or GridTagWater or GridTagAcid1 or GridTagAcid2 or GridTagStep or GridTagLift or GridTagBlockMon)) <> nil); + if (gdbg_map_dump_coldet_tree_queries) and (mapTree.nodesVisited <> 0) then begin - result := (mapTree.aabbQuery(X, Y, Width, Height, checker, (GridTagWallDoor or GridTagWater or GridTagAcid1 or GridTagAcid2 or GridTagStep or GridTagLift or GridTagBlockMon)) <> nil); - if (gdbg_map_dump_coldet_tree_queries) and (mapTree.nodesVisited <> 0) then - begin - //e_WriteLog(Format('map collision: %d nodes visited (%d deep)', [mapTree.nodesVisited, mapTree.nodesDeepVisited]), MSG_NOTIFY); - g_Console_Add(Format('map collision: %d nodes visited (%d deep)', [mapTree.nodesVisited, mapTree.nodesDeepVisited])); - end; - end - else - begin - result := gMapGrid.forEachInAABB(X, Y, Width, Height, checker, (GridTagWallDoor or GridTagWater or GridTagAcid1 or GridTagAcid2 or GridTagStep or GridTagLift or GridTagBlockMon)); + //e_WriteLog(Format('map collision: %d nodes visited (%d deep)', [mapTree.nodesVisited, mapTree.nodesDeepVisited]), MSG_NOTIFY); + g_Console_Add(Format('map collision: %d nodes visited (%d deep)', [mapTree.nodesVisited, mapTree.nodesDeepVisited])); end; end else begin - result := g_Map_CollidePanelOld(X, Y, Width, Height, PanelType, b1x3); + result := gMapGrid.forEachInAABB(X, Y, Width, Height, checker, (GridTagWallDoor or GridTagWater or GridTagAcid1 or GridTagAcid2 or GridTagStep or GridTagLift or GridTagBlockMon)); end; - finally - if (profMapCollision <> nil) then profMapCollision.sectionEnd(); + end + else + begin + result := g_Map_CollidePanelOld(X, Y, Width, Height, PanelType, b1x3); end; + if (profMapCollision <> nil) then profMapCollision.sectionEnd(); end; @@ -2340,27 +2337,24 @@ var begin //TODO: detailed profile? if (profMapCollision <> nil) then profMapCollision.sectionBeginAccum('liquid coldet'); - try - if gdbg_map_use_accel_coldet then + if gdbg_map_use_accel_coldet then + begin + texid := TEXTURE_NONE; + if gdbg_map_use_tree_coldet then begin - texid := TEXTURE_NONE; - if gdbg_map_use_tree_coldet then - begin - mapTree.aabbQuery(X, Y, Width, Height, checker, (GridTagWater or GridTagAcid1 or GridTagAcid2)); - end - else - begin - gMapGrid.forEachInAABB(X, Y, Width, Height, checker, (GridTagWater or GridTagAcid1 or GridTagAcid2)); - end; - result := texid; + mapTree.aabbQuery(X, Y, Width, Height, checker, (GridTagWater or GridTagAcid1 or GridTagAcid2)); end else begin - result := g_Map_CollideLiquid_TextureOld(X, Y, Width, Height); + gMapGrid.forEachInAABB(X, Y, Width, Height, checker, (GridTagWater or GridTagAcid1 or GridTagAcid2)); end; - finally - if (profMapCollision <> nil) then profMapCollision.sectionEnd(); + result := texid; + end + else + begin + result := g_Map_CollideLiquid_TextureOld(X, Y, Width, Height); end; + if (profMapCollision <> nil) then profMapCollision.sectionEnd(); end; procedure g_Map_EnableWall(ID: DWORD); diff --git a/src/game/z_aabbtree.pas b/src/game/z_aabbtree.pas index fcb8f68..5bdb226 100644 --- a/src/game/z_aabbtree.pas +++ b/src/game/z_aabbtree.pas @@ -1185,7 +1185,7 @@ var begin if not assigned(checker) then begin result := -1; exit; end; //if not assigned(visitor) then begin result := -1; exit; end; - try + //try {$IFDEF aabbtree_query_count} mNodesVisited := 0; mNodesDeepVisited := 0; @@ -1219,7 +1219,7 @@ begin {$IFDEF aabbtree_query_count}Inc(mNodesDeepVisited);{$ENDIF} if ((node.tag and tagmask) <> 0) and assigned(visitor) then begin - if (visitor(node.flesh, node.tag)) then begin result := nodeId; exit; end; + if (visitor(node.flesh, node.tag)) then begin result := nodeId; bigstack := nil; exit; end; end; end else @@ -1232,9 +1232,10 @@ begin end; result := -1; // oops - finally bigstack := nil; - end; + //finally + // bigstack := nil; + //end; end;