hedgewars/uDebug.pas
author unc0rr
Wed, 02 Feb 2011 11:28:38 +0300
changeset 4904 0eab727d4717
parent 4900 8ad0e23e6d63
child 4976 088d40d8aba2
permissions -rw-r--r--
Merge server refactor into default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4403
unc0rr
parents:
diff changeset
     1
{$INCLUDE "options.inc"}
unc0rr
parents:
diff changeset
     2
unc0rr
parents:
diff changeset
     3
unit uDebug;
unc0rr
parents:
diff changeset
     4
unc0rr
parents:
diff changeset
     5
interface
unc0rr
parents:
diff changeset
     6
unc0rr
parents:
diff changeset
     7
procedure OutError(Msg: shortstring; isFatalError: boolean);
unc0rr
parents:
diff changeset
     8
procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); inline;
unc0rr
parents:
diff changeset
     9
procedure SDLTry(Assert: boolean; isFatal: boolean);
unc0rr
parents:
diff changeset
    10
unc0rr
parents:
diff changeset
    11
implementation
unc0rr
parents:
diff changeset
    12
uses SDLh, uConsole, uCommands;
unc0rr
parents:
diff changeset
    13
unc0rr
parents:
diff changeset
    14
procedure OutError(Msg: shortstring; isFatalError: boolean);
unc0rr
parents:
diff changeset
    15
begin
unc0rr
parents:
diff changeset
    16
WriteLnToConsole(Msg);
unc0rr
parents:
diff changeset
    17
if isFatalError then
unc0rr
parents:
diff changeset
    18
    begin
unc0rr
parents:
diff changeset
    19
    ParseCommand('fatal ' + GetLastConsoleLine, true);
unc0rr
parents:
diff changeset
    20
    SDL_Quit;
unc0rr
parents:
diff changeset
    21
    halt(1)
unc0rr
parents:
diff changeset
    22
    end
unc0rr
parents:
diff changeset
    23
end;
unc0rr
parents:
diff changeset
    24
unc0rr
parents:
diff changeset
    25
procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean);
unc0rr
parents:
diff changeset
    26
begin
unc0rr
parents:
diff changeset
    27
if not Assert then OutError(Msg, isFatal)
unc0rr
parents:
diff changeset
    28
end;
unc0rr
parents:
diff changeset
    29
unc0rr
parents:
diff changeset
    30
procedure SDLTry(Assert: boolean; isFatal: boolean);
unc0rr
parents:
diff changeset
    31
begin
unc0rr
parents:
diff changeset
    32
if not Assert then OutError(SDL_GetError, isFatal)
unc0rr
parents:
diff changeset
    33
end;
unc0rr
parents:
diff changeset
    34
4900
8ad0e23e6d63 addfilelog <3 debugfile
koda
parents: 4403
diff changeset
    35
end.