1 (* |
1 (* |
2 * Hedgewars, a free turn based strategy game |
2 * Hedgewars, a free turn based strategy game |
3 * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com> |
3 * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
4 * |
4 * |
5 * This program is free software; you can redistribute it and/or modify |
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 |
6 * it under the terms of the GNU General Public License as published by |
7 * the Free Software Foundation; version 2 of the License |
7 * the Free Software Foundation; version 2 of the License |
8 * |
8 * |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. |
12 * GNU General Public License for more details. |
13 * |
13 * |
14 * You should have received a copy of the GNU General Public License |
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 |
15 * along with this program; if not, write to the Free Software |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
17 *) |
17 *) |
18 |
18 |
19 {$INCLUDE "options.inc"} |
19 {$INCLUDE "options.inc"} |
20 |
20 |
21 unit uConsole; |
21 unit uConsole; |
22 interface |
22 interface |
23 |
23 |
24 |
24 |
25 procedure WriteToConsole(s: shortstring); |
25 procedure WriteToConsole(s: shortstring); |
26 procedure WriteLnToConsole(s: shortstring); |
26 procedure WriteLnToConsole(s: shortstring); |
27 function ShortStringAsPChar(s: shortstring): PChar; |
|
28 |
27 |
29 var lastConsoleline : shortstring; |
28 var lastConsoleline : shortstring; |
30 |
29 |
31 implementation |
30 implementation |
32 uses Types, uUtils {$IFDEF ANDROID}, log in 'log.pas'{$ENDIF}; |
31 uses Types, uUtils {$IFDEF ANDROID}, log in 'log.pas'{$ENDIF}; |
47 |
46 |
48 procedure WriteLnToConsole(s: shortstring); |
47 procedure WriteLnToConsole(s: shortstring); |
49 begin |
48 begin |
50 {$IFNDEF NOCONSOLE} |
49 {$IFNDEF NOCONSOLE} |
51 WriteToConsole(s); |
50 WriteToConsole(s); |
52 lastConsoleline:= s; |
|
53 {$IFNDEF ANDROID} |
51 {$IFNDEF ANDROID} |
54 WriteLn(stderr, ''); |
52 WriteLn(stderr, ''); |
55 {$ENDIF} |
53 {$ENDIF} |
56 {$ENDIF} |
54 {$ENDIF} |
|
55 lastConsoleline:= s; |
57 end; |
56 end; |
58 |
57 {$IFDEF ANDROID} |
59 function ShortStringAsPChar(s: shortstring) : PChar; |
58 function ShortStringAsPChar(s: shortstring) : PChar; |
60 begin |
59 begin |
61 if Length(s) = High(s) then |
60 if Length(s) = High(s) then |
62 Dec(s[0]); |
61 Dec(s[0]); |
63 s[Ord(Length(s))+1] := #0; |
62 s[Ord(Length(s))+1] := #0; |
|
63 // returning pointer to stack, rly? |
64 ShortStringAsPChar:= @s[1]; |
64 ShortStringAsPChar:= @s[1]; |
65 end; |
65 end; |
66 |
66 {$ENDIF} |
67 |
67 |
68 end. |
68 end. |