author | unc0rr |
Sat, 14 Dec 2013 01:03:10 +0400 | |
changeset 9794 | 05b9eedff805 |
parent 9080 | 9b42757d7e71 |
child 9958 | 5a222923c8f8 |
child 9998 | 736015b847e3 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
9080 | 3 |
* Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 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 |
|
4 | 8 |
* |
183 | 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. |
|
4 | 13 |
* |
183 | 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 |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
4 | 17 |
*) |
18 |
||
2630 | 19 |
{$INCLUDE "options.inc"} |
20 |
||
4 | 21 |
unit uConsole; |
22 |
interface |
|
23 |
||
785 | 24 |
|
4 | 25 |
procedure WriteToConsole(s: shortstring); |
8437 | 26 |
procedure WriteLnToConsole(s: shortstring); |
27 |
function ShortStringAsPChar(s: shortstring): PChar; |
|
28 |
||
29 |
var lastConsoleline : shortstring; |
|
30 |
||
31 |
implementation |
|
32 |
uses Types, uUtils {$IFDEF ANDROID}, log in 'log.pas'{$ENDIF}; |
|
33 |
||
34 |
||
35 |
procedure WriteToConsole(s: shortstring); |
|
4 | 36 |
begin |
3818
e668970413e6
add a noconsole symbol, update the project file for appstore distribution
koda
parents:
3777
diff
changeset
|
37 |
{$IFNDEF NOCONSOLE} |
8437 | 38 |
AddFileLog('[Con] ' + s); |
5661
45618bdce725
Fixed AddFileLog, there's now a log created in /sdcard/Android/data/org.hedgewars.mobile/cache/Data/
Xeli
parents:
5460
diff
changeset
|
39 |
{$IFDEF ANDROID} |
8437 | 40 |
//TODO integrate this function in the uMobile record |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6528
diff
changeset
|
41 |
Log.__android_log_write(Log.Android_LOG_DEBUG, 'HW_Engine', ShortStringAsPChar('[Con]' + s)); |
5286 | 42 |
{$ELSE} |
8437 | 43 |
Write(stderr, s); |
3818
e668970413e6
add a noconsole symbol, update the project file for appstore distribution
koda
parents:
3777
diff
changeset
|
44 |
{$ENDIF} |
5286 | 45 |
{$ENDIF} |
4 | 46 |
end; |
47 |
||
48 |
procedure WriteLnToConsole(s: shortstring); |
|
49 |
begin |
|
3825 | 50 |
{$IFNDEF NOCONSOLE} |
8437 | 51 |
WriteToConsole(s); |
52 |
lastConsoleline:= s; |
|
5286 | 53 |
{$IFNDEF ANDROID} |
8437 | 54 |
WriteLn(stderr, ''); |
3818
e668970413e6
add a noconsole symbol, update the project file for appstore distribution
koda
parents:
3777
diff
changeset
|
55 |
{$ENDIF} |
5286 | 56 |
{$ENDIF} |
4 | 57 |
end; |
58 |
||
6444 | 59 |
function ShortStringAsPChar(s: shortstring) : PChar; |
6027 | 60 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6528
diff
changeset
|
61 |
if Length(s) = High(s) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6528
diff
changeset
|
62 |
Dec(s[0]); |
6027 | 63 |
s[Ord(Length(s))+1] := #0; |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6982
diff
changeset
|
64 |
ShortStringAsPChar:= @s[1]; |
6027 | 65 |
end; |
4 | 66 |
|
67 |
||
68 |
end. |