break uDebug and uCommand depedency loop by putting stuff in uIO
authorkoda
Sat, 29 Jun 2013 02:42:15 +0200
changeset 9301 c5d1c8259ef4
parent 9300 e5dafb5843c6
child 9302 1cf37fd7bc47
break uDebug and uCommand depedency loop by putting stuff in uIO
hedgewars/CMakeLists.txt
hedgewars/uCommands.pas
hedgewars/uDebug.pas
hedgewars/uIO.pas
--- a/hedgewars/CMakeLists.txt	Sat Jun 29 01:56:16 2013 +0200
+++ b/hedgewars/CMakeLists.txt	Sat Jun 29 02:42:15 2013 +0200
@@ -24,8 +24,8 @@
     uUtils.pas
     uMisc.pas
     uConsole.pas
+    uCommands.pas
     uDebug.pas
-    uCommands.pas
     uInputHandler.pas
     uTextures.pas
     uRenderUtils.pas
--- a/hedgewars/uCommands.pas	Sat Jun 29 01:56:16 2013 +0200
+++ b/hedgewars/uCommands.pas	Sat Jun 29 02:42:15 2013 +0200
@@ -36,7 +36,7 @@
 procedure StopMessages(Message: Longword);
 
 implementation
-uses uConsts, uVariables, uConsole, uUtils, uDebug, SDLh;
+uses uConsts, uVariables, uConsole, uUtils, SDLh;
 
 type  PVariable = ^TVariable;
     TVariable = record
@@ -52,12 +52,14 @@
 begin
 RegisterVariable(Name, p, Trusted, false);
 end;
+
 procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean; Rand: boolean);
-var
-    value: PVariable;
+var value: PVariable;
 begin
 New(value);
-TryDo(value <> nil, 'RegisterVariable: value = nil', true);
+if value = nil then
+    ParseCommand('fatal RegisterVariable: value = nil', true);
+
 FillChar(value^, sizeof(TVariable), 0);
 value^.Name:= Name;
 value^.Handler:= p;
--- a/hedgewars/uDebug.pas	Sat Jun 29 01:56:16 2013 +0200
+++ b/hedgewars/uDebug.pas	Sat Jun 29 02:42:15 2013 +0200
@@ -33,11 +33,7 @@
 begin
 WriteLnToConsole(Msg);
 if isFatalError then
-    begin
     ParseCommand('fatal ' + lastConsoleline, true);
-    SDL_Quit;
-    halt(1)
-    end
 end;
 
 procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean);
--- a/hedgewars/uIO.pas	Sat Jun 29 01:56:16 2013 +0200
+++ b/hedgewars/uIO.pas	Sat Jun 29 02:42:15 2013 +0200
@@ -411,6 +411,9 @@
 procedure chFatalError(var s: shortstring);
 begin
     SendIPC('E' + s);
+    // TODO: should we try to clean more stuff here?
+    SDL_Quit;
+    halt(2)
 end;
 
 procedure doPut(putX, putY: LongInt; fromAI: boolean);