# HG changeset patch # User koda # Date 1372466535 -7200 # Node ID c5d1c8259ef4808c8ff909abfd4ad44fc85956c3 # Parent e5dafb5843c69e52ee21af0a316e1a9a0956b0e2 break uDebug and uCommand depedency loop by putting stuff in uIO diff -r e5dafb5843c6 -r c5d1c8259ef4 hedgewars/CMakeLists.txt --- 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 diff -r e5dafb5843c6 -r c5d1c8259ef4 hedgewars/uCommands.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; diff -r e5dafb5843c6 -r c5d1c8259ef4 hedgewars/uDebug.pas --- 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); diff -r e5dafb5843c6 -r c5d1c8259ef4 hedgewars/uIO.pas --- 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);