author | sheepluva |
Tue, 09 Sep 2014 10:48:11 +0200 | |
changeset 10409 | 0972bf43e8fc |
parent 10108 | c68cf030eded |
child 10490 | b30b8d39d662 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
9998 | 3 |
* Copyright (c) 2004-2014 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 |
|
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:
10015
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 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); |
5286 | 52 |
{$IFNDEF ANDROID} |
8437 | 53 |
WriteLn(stderr, ''); |
3818
e668970413e6
add a noconsole symbol, update the project file for appstore distribution
koda
parents:
3777
diff
changeset
|
54 |
{$ENDIF} |
5286 | 55 |
{$ENDIF} |
9958 | 56 |
lastConsoleline:= s; |
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. |