DEADSOFTWARE

Sweep-And-Prune broad phase implementation; not working yet
[d2df-sdl.git] / src / game / g_console.pas
index 595425e2e1874dcea996073729893484a8256891..c41cb23c8ab8c41de9c1eb5233f7135d73d0b933 100644 (file)
@@ -13,7 +13,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *)
-{$MODE DELPHI}
+{$INCLUDE ../shared/a_modes.inc}
 unit g_console;
 
 interface
@@ -388,6 +388,15 @@ begin
   AddCommand('d_player', DebugCommands);
   AddCommand('d_joy', DebugCommands);
 
+  AddCommand('dpp', ProfilerCommands);
+  AddCommand('dpu', ProfilerCommands);
+  AddCommand('dpc', ProfilerCommands);
+  AddCommand('r_gridrender', ProfilerCommands);
+  AddCommand('dbg_coldet_grid', ProfilerCommands);
+
+  AddCommand('sq_use_grid', ProfilerCommands);
+  AddCommand('sq_use_sap', ProfilerCommands);
+
   AddCommand('p1_name', GameCVars);
   AddCommand('p2_name', GameCVars);
   AddCommand('p1_color', GameCVars);
@@ -873,42 +882,26 @@ begin
   end;
 end;
 
-procedure g_Console_Add(L: String; Show: Boolean = False);
-{var
-  a: Integer;}
-begin
-  // Âûâîä ñòðîê ñ ïåðåíîñàìè ïî î÷åðåäè
-  {
-  while Pos(#10, L) > 0 do
-  begin
-    g_Console_Add(Copy(L, 1, Pos(#10, L) - 1), Show);
-    Delete(L, 1, Pos(#10, L));
-  end;
-  }
-
-  //SetLength(ConsoleHistory, Length(ConsoleHistory)+1);
-  //ConsoleHistory[High(ConsoleHistory)] := L;
-
-  cbufPut(L);
-  if (length(L) = 0) or ((L[length(L)] <> #10) and (L[length(L)] <> #13)) then cbufPut(#10);
-
-  (*
-  Show := Show and gAllowConsoleMessages;
+procedure g_Console_Add (L: string; Show: Boolean=false);
 
-  if Show and gShowMessages then
+  procedure conmsg (s: AnsiString);
+  var
+    a: Integer;
   begin
+    if length(s) = 0 then exit;
     for a := 0 to High(MsgArray) do
+    begin
       with MsgArray[a] do
+      begin
         if Time = 0 then
         begin
-          Msg := L;
+          Msg := s;
           Time := MsgTime;
-          Exit;
+          exit;
         end;
-
-    for a := 0 to High(MsgArray)-1 do
-      MsgArray[a] := MsgArray[a+1];
-
+      end;
+    end;
+    for a := 0 to High(MsgArray)-1 do MsgArray[a] := MsgArray[a+1];
     with MsgArray[High(MsgArray)] do
     begin
       Msg := L;
@@ -916,6 +909,31 @@ begin
     end;
   end;
 
+var
+  f: Integer;
+begin
+  // put it to console
+  cbufPut(L);
+  if (length(L) = 0) or ((L[length(L)] <> #10) and (L[length(L)] <> #13)) then cbufPut(#10);
+
+  // now show 'em out of console too
+  Show := Show and gAllowConsoleMessages;
+  if Show and gShowMessages then
+  begin
+    // Âûâîä ñòðîê ñ ïåðåíîñàìè ïî î÷åðåäè
+    while length(L) > 0 do
+    begin
+      f := Pos(#10, L);
+      if f <= 0 then f := length(L)+1;
+      conmsg(Copy(L, 1, f-1));
+      Delete(L, 1, f);
+    end;
+  end;
+
+  //SetLength(ConsoleHistory, Length(ConsoleHistory)+1);
+  //ConsoleHistory[High(ConsoleHistory)] := L;
+
+  (*
 {$IFDEF HEADLESS}
   e_WriteLog('CON: ' + L, MSG_NOTIFY);
 {$ENDIF}