author | Wuzzy <Wuzzy2@mail.ru> |
Mon, 03 Sep 2018 22:14:46 +0200 | |
changeset 13760 | 6908d1e65cdc |
parent 13503 | 4f00b08d6f1e |
permissions | -rw-r--r-- |
4976 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
4976 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9998
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4976 | 17 |
*) |
18 |
||
4403 | 19 |
{$INCLUDE "options.inc"} |
20 |
||
21 |
unit uDebug; |
|
22 |
||
23 |
interface |
|
24 |
||
25 |
procedure OutError(Msg: shortstring; isFatalError: boolean); |
|
11537 | 26 |
//procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); inline; |
27 |
function checkFails(Assert: boolean; Msg: shortstring; isFatal: boolean): boolean; |
|
11512 | 28 |
function SDLCheck(Assert: boolean; Msg: shortstring; isFatal: boolean): boolean; |
29 |
||
30 |
var |
|
31 |
allOK: boolean; |
|
4403 | 32 |
|
33 |
implementation |
|
10306 | 34 |
uses SDLh, uConsole, uCommands, uConsts; |
4403 | 35 |
|
36 |
procedure OutError(Msg: shortstring; isFatalError: boolean); |
|
37 |
begin |
|
38 |
WriteLnToConsole(Msg); |
|
39 |
if isFatalError then |
|
10306 | 40 |
begin |
8437 | 41 |
ParseCommand('fatal ' + lastConsoleline, true); |
10306 | 42 |
// hint for the 'coverity' source analyzer |
43 |
// this halt is never actually reached because ParseCommands will halt first |
|
44 |
halt(HaltFatalError); |
|
45 |
end; |
|
4403 | 46 |
end; |
47 |
||
48 |
procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); |
|
49 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
4976
diff
changeset
|
50 |
if not Assert then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
4976
diff
changeset
|
51 |
OutError(Msg, isFatal) |
4403 | 52 |
end; |
53 |
||
11537 | 54 |
function checkFails(Assert: boolean; Msg: shortstring; isFatal: boolean): boolean; |
55 |
begin |
|
56 |
if not Assert then |
|
13083
dd904dd9c587
Fix frontend error dialog always displaying "failed" as last engine message after engine crash
Wuzzy <Wuzzy2@mail.ru>
parents:
11537
diff
changeset
|
57 |
begin |
dd904dd9c587
Fix frontend error dialog always displaying "failed" as last engine message after engine crash
Wuzzy <Wuzzy2@mail.ru>
parents:
11537
diff
changeset
|
58 |
lastConsoleLine:= Msg; |
13503
4f00b08d6f1e
Propagate fatal errors to OutError if checkFails called
Wuzzy <Wuzzy2@mail.ru>
parents:
13489
diff
changeset
|
59 |
OutError(Msg, isFatal); |
13083
dd904dd9c587
Fix frontend error dialog always displaying "failed" as last engine message after engine crash
Wuzzy <Wuzzy2@mail.ru>
parents:
11537
diff
changeset
|
60 |
end; |
11537 | 61 |
|
62 |
allOK:= allOK and (Assert or (not isFatal)); |
|
63 |
checkFails:= (not Assert) and isFatal |
|
64 |
end; |
|
65 |
||
11512 | 66 |
function SDLCheck(Assert: boolean; Msg: shortstring; isFatal: boolean): boolean; |
7134 | 67 |
var s: shortstring; |
4403 | 68 |
begin |
11512 | 69 |
if not Assert then |
7134 | 70 |
begin |
11512 | 71 |
s:= SDL_GetError(); |
13489
480ea997036b
Send proper failure error message when image loading has failed
Wuzzy <Wuzzy2@mail.ru>
parents:
13083
diff
changeset
|
72 |
OutError(Msg + ': ' + s, isFatal) |
11512 | 73 |
end; |
74 |
||
75 |
allOK:= allOK and (Assert or (not isFatal)); |
|
76 |
SDLCheck:= (not Assert) and isFatal |
|
4403 | 77 |
end; |
78 |
||
4900 | 79 |
end. |