author | Wuzzy <Wuzzy2@mail.ru> |
Tue, 27 Mar 2018 04:39:31 +0200 | |
changeset 13288 | f816b9e73fcb |
parent 13094 | c9cdbf630447 |
child 13317 | 092adcf707c5 |
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:
10104
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4976 | 17 |
*) |
18 |
||
4374 | 19 |
{$INCLUDE "options.inc"} |
4976 | 20 |
|
4374 | 21 |
unit uUtils; |
22 |
||
23 |
interface |
|
9295
f8819c3dde54
Remove some GLunit dependencies noticed on graph. uUtils was using it for GLfloat - but, the stuff it was returning to was usually converting to "real" anyway. uLand was including it unnecessarily. Minor refactor
nemo
parents:
9080
diff
changeset
|
24 |
uses uTypes, uFloat; |
4374 | 25 |
|
11829 | 26 |
// returns s with whitespaces (chars <= #32) removed form both ends |
27 |
function Trim(s: shortstring) : shortstring; |
|
28 |
||
4374 | 29 |
procedure SplitBySpace(var a, b: shortstring); |
7191
9419294e5f33
first attempt at implementing support for keys with modifiers
Xeli
parents:
7151
diff
changeset
|
30 |
procedure SplitByChar(var a, b: shortstring; c: char); |
10131
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10127
diff
changeset
|
31 |
procedure SplitByCharA(var a, b: ansistring; c: char); |
4374 | 32 |
|
11831
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
33 |
function ExtractFileDir(s: shortstring) : shortstring; |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
34 |
function ExtractFileName(s: shortstring) : shortstring; |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
35 |
|
4374 | 36 |
function EnumToStr(const en : TGearType) : shortstring; overload; |
4453 | 37 |
function EnumToStr(const en : TVisualGearType) : shortstring; overload; |
4374 | 38 |
function EnumToStr(const en : TSound) : shortstring; overload; |
39 |
function EnumToStr(const en : TAmmoType) : shortstring; overload; |
|
9642
8a691e0f117a
use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9377
diff
changeset
|
40 |
function EnumToStr(const en : TStatInfoType) : shortstring; overload; |
4374 | 41 |
function EnumToStr(const en : THogEffect) : shortstring; overload; |
5118 | 42 |
function EnumToStr(const en : TCapGroup) : shortstring; overload; |
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10131
diff
changeset
|
43 |
function EnumToStr(const en : TSprite) : shortstring; overload; |
10603
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10595
diff
changeset
|
44 |
function EnumToStr(const en : TMapGen) : shortstring; overload; |
11884
c6eafb6f2735
Add WorldEdge to Lua API to expose/change world edge type
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
45 |
function EnumToStr(const en : TWorldEdge) : shortstring; overload; |
4374 | 46 |
|
47 |
function Min(a, b: LongInt): LongInt; inline; |
|
10562 | 48 |
function MinD(a, b: double) : double; inline; |
4374 | 49 |
function Max(a, b: LongInt): LongInt; inline; |
50 |
||
51 |
function IntToStr(n: LongInt): shortstring; |
|
7151 | 52 |
function StrToInt(s: shortstring): LongInt; |
4374 | 53 |
function FloatToStr(n: hwFloat): shortstring; |
54 |
||
9295
f8819c3dde54
Remove some GLunit dependencies noticed on graph. uUtils was using it for GLfloat - but, the stuff it was returning to was usually converting to "real" anyway. uLand was including it unnecessarily. Minor refactor
nemo
parents:
9080
diff
changeset
|
55 |
function DxDy2Angle(const _dY, _dX: hwFloat): real; inline; |
4374 | 56 |
function DxDy2Angle32(const _dY, _dX: hwFloat): LongInt; |
57 |
function DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt; |
|
6894 | 58 |
function DxDy2AttackAnglef(const _dY, _dX: extended): LongInt; |
4374 | 59 |
|
60 |
procedure SetLittle(var r: hwFloat); |
|
61 |
||
62 |
function Str2PChar(const s: shortstring): PChar; |
|
63 |
function DecodeBase64(s: shortstring): shortstring; |
|
64 |
||
65 |
function isPowerOf2(i: Longword): boolean; |
|
66 |
function toPowerOf2(i: Longword): Longword; inline; |
|
67 |
||
68 |
function endian(independent: LongWord): LongWord; inline; |
|
69 |
||
10116
dd27562b6f21
rolling back my PChar stuff, because unC0Rr improves string handling pas2c instead <3
sheepluva
parents:
10108
diff
changeset
|
70 |
function CheckCJKFont(s: ansistring; font: THWFont): THWFont; |
4380 | 71 |
|
4374 | 72 |
procedure AddFileLog(s: shortstring); |
7180 | 73 |
procedure AddFileLogRaw(s: pchar); cdecl; |
4374 | 74 |
|
4900 | 75 |
function CheckNoTeamOrHH: boolean; inline; |
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4385
diff
changeset
|
76 |
|
4403 | 77 |
function GetLaunchX(at: TAmmoType; dir: LongInt; angle: LongInt): LongInt; |
78 |
function GetLaunchY(at: TAmmoType; angle: LongInt): LongInt; |
|
79 |
||
12740 | 80 |
function CalcWorldWrap(X, radius: LongInt): LongInt; |
81 |
||
11775 | 82 |
function read1stLn(filePath: shortstring): shortstring; |
11780
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
83 |
function readValueFromINI(key, filePath: shortstring): shortstring; |
11775 | 84 |
|
7151 | 85 |
{$IFNDEF PAS2C} |
86 |
procedure Write(var f: textfile; s: shortstring); |
|
87 |
procedure WriteLn(var f: textfile; s: shortstring); |
|
10080 | 88 |
function StrLength(s: PChar): Longword; |
10690 | 89 |
procedure SetLengthA(var s: ansistring; len: Longword); |
7151 | 90 |
{$ENDIF} |
91 |
||
8204 | 92 |
function isPhone: Boolean; inline; |
93 |
||
94 |
{$IFDEF IPHONEOS} |
|
95 |
procedure startLoadingIndicator; cdecl; external; |
|
96 |
procedure stopLoadingIndicator; cdecl; external; |
|
97 |
procedure saveFinishedSynching; cdecl; external; |
|
98 |
function isApplePhone: Boolean; cdecl; external; |
|
99 |
procedure AudioServicesPlaySystemSound(num: LongInt); cdecl; external; |
|
100 |
{$ENDIF} |
|
101 |
||
8498
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
102 |
function sanitizeForLog(s: shortstring): shortstring; |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
103 |
function sanitizeCharForLog(c: char): shortstring; |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
104 |
|
7896
67217e6108fd
another stake at variable pre-initialisation - we lost preview logging in the course
koda
parents:
7565
diff
changeset
|
105 |
procedure initModule(isNotPreview: boolean); |
4374 | 106 |
procedure freeModule; |
107 |
||
4385 | 108 |
|
4374 | 109 |
implementation |
11829 | 110 |
uses {$IFNDEF PAS2C}typinfo, {$ENDIF}Math, uConsts, uVariables, uPhysFSLayer, uDebug; |
4374 | 111 |
|
112 |
{$IFDEF DEBUGFILE} |
|
11637 | 113 |
var logFile: PFSFile; |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7194
diff
changeset
|
114 |
{$IFDEF USE_VIDEO_RECORDING} |
7180 | 115 |
logMutex: TRTLCriticalSection; // mutex for debug file |
4374 | 116 |
{$ENDIF} |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7194
diff
changeset
|
117 |
{$ENDIF} |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7896
diff
changeset
|
118 |
var CharArray: array[0..255] of Char; |
4374 | 119 |
|
11829 | 120 |
// All leading/tailing characters with ordinal values less than or equal to 32 (a space) are stripped. |
121 |
function Trim(s: shortstring) : shortstring; |
|
122 |
var len, left, right: integer; |
|
123 |
begin |
|
124 |
||
125 |
len:= Length(s); |
|
126 |
||
127 |
if len = 0 then |
|
128 |
exit(s); |
|
129 |
||
130 |
// find first non-whitespace |
|
131 |
left:= 1; |
|
132 |
while left <= len do |
|
133 |
begin |
|
134 |
if s[left] > #32 then |
|
135 |
break; |
|
136 |
inc(left); |
|
137 |
end; |
|
138 |
||
139 |
// find last non-whitespace |
|
140 |
right:= len; |
|
141 |
while right >= 1 do |
|
142 |
begin |
|
143 |
if s[right] > #32 then |
|
144 |
break; |
|
145 |
dec(right); |
|
146 |
end; |
|
147 |
||
148 |
// string is whitespace only |
|
149 |
if left > right then |
|
150 |
exit(''); |
|
151 |
||
152 |
// get string without surrounding whitespace |
|
153 |
len:= right - left + 1; |
|
154 |
||
155 |
Trim:= copy(s, left, len); |
|
156 |
||
157 |
end; |
|
158 |
||
11831
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
159 |
function GetLastSlashPos(var s: shortString) : integer; |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
160 |
var lslash: integer; |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
161 |
c: char; |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
162 |
begin |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
163 |
|
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
164 |
// find last slash |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
165 |
lslash:= Length(s); |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
166 |
while lslash >= 1 do |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
167 |
begin |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
168 |
c:= s[lslash]; |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
169 |
if (c = #47) or (c = #92) then |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
170 |
break; |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
171 |
dec(lslash); end; |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
172 |
|
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
173 |
GetLastSlashPos:= lslash; |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
174 |
end; |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
175 |
|
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
176 |
function ExtractFileDir(s: shortstring) : shortstring; |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
177 |
var lslash: byte; |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
178 |
begin |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
179 |
|
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
180 |
if Length(s) = 0 then |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
181 |
exit(s); |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
182 |
|
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
183 |
lslash:= GetLastSlashPos(s); |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
184 |
|
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
185 |
if lslash <= 1 then |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
186 |
exit(''); |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
187 |
|
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
188 |
s[0]:= char(lslash - 1); |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
189 |
|
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
190 |
ExtractFileDir:= s; |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
191 |
end; |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
192 |
|
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
193 |
function ExtractFileName(s: shortstring) : shortstring; |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
194 |
var lslash, len: byte; |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
195 |
begin |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
196 |
|
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
197 |
len:= Length(s); |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
198 |
|
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
199 |
if len = 0 then |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
200 |
exit(s); |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
201 |
|
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
202 |
lslash:= GetLastSlashPos(s); |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
203 |
|
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
204 |
if lslash < 1 then |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
205 |
exit(s); |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
206 |
|
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
207 |
if lslash = len then |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
208 |
exit(''); |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
209 |
|
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
210 |
len:= len - lslash; |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
211 |
ExtractFilename:= copy(s, lslash + 1, len); |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
212 |
end; |
7654e2357934
implement ExtraftFileDir and ExtractFileName in uUtils
sheepluva
parents:
11829
diff
changeset
|
213 |
|
7191
9419294e5f33
first attempt at implementing support for keys with modifiers
Xeli
parents:
7151
diff
changeset
|
214 |
procedure SplitBySpace(var a,b: shortstring); |
9419294e5f33
first attempt at implementing support for keys with modifiers
Xeli
parents:
7151
diff
changeset
|
215 |
begin |
9419294e5f33
first attempt at implementing support for keys with modifiers
Xeli
parents:
7151
diff
changeset
|
216 |
SplitByChar(a,b,' '); |
9419294e5f33
first attempt at implementing support for keys with modifiers
Xeli
parents:
7151
diff
changeset
|
217 |
end; |
9419294e5f33
first attempt at implementing support for keys with modifiers
Xeli
parents:
7151
diff
changeset
|
218 |
|
9419294e5f33
first attempt at implementing support for keys with modifiers
Xeli
parents:
7151
diff
changeset
|
219 |
procedure SplitByChar(var a, b: shortstring; c : char); |
13094
c9cdbf630447
Stop SplitByChar also lowercasing the entire string. Fixes bug 581.
Wuzzy <Wuzzy2@mail.ru>
parents:
12810
diff
changeset
|
220 |
var i: LongInt; |
4374 | 221 |
begin |
7191
9419294e5f33
first attempt at implementing support for keys with modifiers
Xeli
parents:
7151
diff
changeset
|
222 |
i:= Pos(c, a); |
4374 | 223 |
if i > 0 then |
224 |
begin |
|
225 |
b:= copy(a, i + 1, Length(a) - i); |
|
7074 | 226 |
a[0]:= char(Pred(i)) |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7896
diff
changeset
|
227 |
{$IFDEF PAS2C} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7896
diff
changeset
|
228 |
a[i] := 0; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7896
diff
changeset
|
229 |
{$ENDIF} |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6444
diff
changeset
|
230 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6444
diff
changeset
|
231 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6444
diff
changeset
|
232 |
b:= ''; |
4374 | 233 |
end; |
234 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7896
diff
changeset
|
235 |
{$IFNDEF PAS2C} |
10131
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10127
diff
changeset
|
236 |
procedure SetLengthA(var s: ansistring; len: Longword); |
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10127
diff
changeset
|
237 |
begin |
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10127
diff
changeset
|
238 |
SetLength(s, len) |
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10127
diff
changeset
|
239 |
end; |
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10127
diff
changeset
|
240 |
{$ENDIF} |
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10127
diff
changeset
|
241 |
|
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10127
diff
changeset
|
242 |
procedure SplitByCharA(var a, b: ansistring; c: char); |
4374 | 243 |
var i: LongInt; |
244 |
begin |
|
245 |
i:= Pos(c, a); |
|
246 |
if i > 0 then |
|
247 |
begin |
|
248 |
b:= copy(a, i + 1, Length(a) - i); |
|
10131
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10127
diff
changeset
|
249 |
SetLengthA(a, Pred(i)); |
4374 | 250 |
end else b:= ''; |
10131
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10127
diff
changeset
|
251 |
end; { SplitByCharA } |
4374 | 252 |
|
253 |
function EnumToStr(const en : TGearType) : shortstring; overload; |
|
254 |
begin |
|
255 |
EnumToStr:= GetEnumName(TypeInfo(TGearType), ord(en)) |
|
256 |
end; |
|
8838
aa2ffd427f6a
strip PAS2C, old WEB symbols and outdated pas2c sources from default branch, all c-related development is done on the webgl branch
koda
parents:
8575
diff
changeset
|
257 |
|
4453 | 258 |
function EnumToStr(const en : TVisualGearType) : shortstring; overload; |
259 |
begin |
|
260 |
EnumToStr:= GetEnumName(TypeInfo(TVisualGearType), ord(en)) |
|
261 |
end; |
|
4374 | 262 |
|
263 |
function EnumToStr(const en : TSound) : shortstring; overload; |
|
264 |
begin |
|
265 |
EnumToStr:= GetEnumName(TypeInfo(TSound), ord(en)) |
|
266 |
end; |
|
267 |
||
268 |
function EnumToStr(const en : TAmmoType) : shortstring; overload; |
|
269 |
begin |
|
270 |
EnumToStr:= GetEnumName(TypeInfo(TAmmoType), ord(en)) |
|
271 |
end; |
|
272 |
||
9642
8a691e0f117a
use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9377
diff
changeset
|
273 |
function EnumToStr(const en : TStatInfoType) : shortstring; overload; |
8a691e0f117a
use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9377
diff
changeset
|
274 |
begin |
8a691e0f117a
use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9377
diff
changeset
|
275 |
EnumToStr:= GetEnumName(TypeInfo(TStatInfoType), ord(en)) |
8a691e0f117a
use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9377
diff
changeset
|
276 |
end; |
8a691e0f117a
use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9377
diff
changeset
|
277 |
|
4374 | 278 |
function EnumToStr(const en: THogEffect) : shortstring; overload; |
279 |
begin |
|
5118 | 280 |
EnumToStr := GetEnumName(TypeInfo(THogEffect), ord(en)) |
281 |
end; |
|
282 |
||
283 |
function EnumToStr(const en: TCapGroup) : shortstring; overload; |
|
284 |
begin |
|
285 |
EnumToStr := GetEnumName(TypeInfo(TCapGroup), ord(en)) |
|
4374 | 286 |
end; |
8838
aa2ffd427f6a
strip PAS2C, old WEB symbols and outdated pas2c sources from default branch, all c-related development is done on the webgl branch
koda
parents:
8575
diff
changeset
|
287 |
|
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10131
diff
changeset
|
288 |
function EnumToStr(const en: TSprite) : shortstring; overload; |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10131
diff
changeset
|
289 |
begin |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10131
diff
changeset
|
290 |
EnumToStr := GetEnumName(TypeInfo(TSprite), ord(en)) |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10131
diff
changeset
|
291 |
end; |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10131
diff
changeset
|
292 |
|
10603
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10595
diff
changeset
|
293 |
function EnumToStr(const en: TMapGen) : shortstring; overload; |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10595
diff
changeset
|
294 |
begin |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10595
diff
changeset
|
295 |
EnumToStr := GetEnumName(TypeInfo(TMapGen), ord(en)) |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10595
diff
changeset
|
296 |
end; |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10595
diff
changeset
|
297 |
|
11884
c6eafb6f2735
Add WorldEdge to Lua API to expose/change world edge type
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
298 |
function EnumToStr(const en: TWorldEdge) : shortstring; overload; |
c6eafb6f2735
Add WorldEdge to Lua API to expose/change world edge type
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
299 |
begin |
c6eafb6f2735
Add WorldEdge to Lua API to expose/change world edge type
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
300 |
EnumToStr := GetEnumName(TypeInfo(TWorldEdge), ord(en)) |
c6eafb6f2735
Add WorldEdge to Lua API to expose/change world edge type
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
301 |
end; |
c6eafb6f2735
Add WorldEdge to Lua API to expose/change world edge type
Wuzzy <almikes@aol.com>
parents:
11831
diff
changeset
|
302 |
|
4374 | 303 |
|
304 |
function Min(a, b: LongInt): LongInt; |
|
305 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6444
diff
changeset
|
306 |
if a < b then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6444
diff
changeset
|
307 |
Min:= a |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6444
diff
changeset
|
308 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6444
diff
changeset
|
309 |
Min:= b |
4374 | 310 |
end; |
311 |
||
10562 | 312 |
function MinD(a, b: double): double; |
313 |
begin |
|
314 |
if a < b then |
|
315 |
MinD:= a |
|
316 |
else |
|
317 |
MinD:= b |
|
318 |
end; |
|
319 |
||
4374 | 320 |
function Max(a, b: LongInt): LongInt; |
321 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6444
diff
changeset
|
322 |
if a > b then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6444
diff
changeset
|
323 |
Max:= a |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6444
diff
changeset
|
324 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6444
diff
changeset
|
325 |
Max:= b |
4374 | 326 |
end; |
327 |
||
328 |
||
329 |
function IntToStr(n: LongInt): shortstring; |
|
330 |
begin |
|
331 |
str(n, IntToStr) |
|
332 |
end; |
|
333 |
||
8850
ae8a957c69fd
engine to c now compiles with some manual intervention (as of bug 596)
koda
parents:
8847
diff
changeset
|
334 |
function StrToInt(s: shortstring): LongInt; |
7151 | 335 |
begin |
8850
ae8a957c69fd
engine to c now compiles with some manual intervention (as of bug 596)
koda
parents:
8847
diff
changeset
|
336 |
val(s, StrToInt); |
7151 | 337 |
end; |
338 |
||
4374 | 339 |
function FloatToStr(n: hwFloat): shortstring; |
340 |
begin |
|
341 |
FloatToStr:= cstr(n) + '_' + inttostr(Lo(n.QWordValue)) |
|
342 |
end; |
|
343 |
||
344 |
||
9295
f8819c3dde54
Remove some GLunit dependencies noticed on graph. uUtils was using it for GLfloat - but, the stuff it was returning to was usually converting to "real" anyway. uLand was including it unnecessarily. Minor refactor
nemo
parents:
9080
diff
changeset
|
345 |
function DxDy2Angle(const _dY, _dX: hwFloat): real; inline; |
4374 | 346 |
var dY, dX: Extended; |
347 |
begin |
|
7547 | 348 |
dY:= hwFloat2Float(_dY); |
349 |
dX:= hwFloat2Float(_dX); |
|
4374 | 350 |
DxDy2Angle:= arctan2(dY, dX) * 180 / pi |
351 |
end; |
|
352 |
||
353 |
function DxDy2Angle32(const _dY, _dX: hwFloat): LongInt; |
|
354 |
const _16divPI: Extended = 16/pi; |
|
355 |
var dY, dX: Extended; |
|
356 |
begin |
|
7547 | 357 |
dY:= hwFloat2Float(_dY); |
358 |
dX:= hwFloat2Float(_dX); |
|
4374 | 359 |
DxDy2Angle32:= trunc(arctan2(dY, dX) * _16divPI) and $1f |
360 |
end; |
|
361 |
||
362 |
function DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt; |
|
363 |
const MaxAngleDivPI: Extended = cMaxAngle/pi; |
|
364 |
var dY, dX: Extended; |
|
365 |
begin |
|
7547 | 366 |
dY:= hwFloat2Float(_dY); |
367 |
dX:= hwFloat2Float(_dX); |
|
4374 | 368 |
DxDy2AttackAngle:= trunc(arctan2(dY, dX) * MaxAngleDivPI) |
369 |
end; |
|
370 |
||
6894 | 371 |
function DxDy2AttackAnglef(const _dY, _dX: extended): LongInt; inline; |
5151
cbadb9fa52fc
An experiment - make bazooka AI use float instead of hwFloat - should be as accurate, but faster.
nemo
parents:
5130
diff
changeset
|
372 |
begin |
6894 | 373 |
DxDy2AttackAnglef:= trunc(arctan2(_dY, _dX) * (cMaxAngle/pi)) |
5151
cbadb9fa52fc
An experiment - make bazooka AI use float instead of hwFloat - should be as accurate, but faster.
nemo
parents:
5130
diff
changeset
|
374 |
end; |
cbadb9fa52fc
An experiment - make bazooka AI use float instead of hwFloat - should be as accurate, but faster.
nemo
parents:
5130
diff
changeset
|
375 |
|
4374 | 376 |
|
377 |
procedure SetLittle(var r: hwFloat); |
|
378 |
begin |
|
379 |
r:= SignAs(cLittle, r) |
|
380 |
end; |
|
381 |
||
382 |
||
383 |
function isPowerOf2(i: Longword): boolean; |
|
384 |
begin |
|
4981
0c60ade27a0a
Optimize check (not like it is called much, just ffs; not tested)
unc0rr
parents:
4976
diff
changeset
|
385 |
isPowerOf2:= (i and (i - 1)) = 0 |
4374 | 386 |
end; |
387 |
||
388 |
function toPowerOf2(i: Longword): Longword; |
|
389 |
begin |
|
390 |
toPowerOf2:= 1; |
|
391 |
while (toPowerOf2 < i) do toPowerOf2:= toPowerOf2 shl 1 |
|
392 |
end; |
|
393 |
||
394 |
||
395 |
function DecodeBase64(s: shortstring): shortstring; |
|
396 |
const table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; |
|
10560 | 397 |
var i, t, c: LongInt; |
4374 | 398 |
begin |
399 |
c:= 0; |
|
400 |
for i:= 1 to Length(s) do |
|
401 |
begin |
|
402 |
t:= Pos(s[i], table); |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6444
diff
changeset
|
403 |
if s[i] = '=' then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6444
diff
changeset
|
404 |
inc(c); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6444
diff
changeset
|
405 |
if t > 0 then |
7074 | 406 |
s[i]:= char(t - 1) |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6444
diff
changeset
|
407 |
else |
7074 | 408 |
s[i]:= #0 |
4374 | 409 |
end; |
410 |
||
411 |
i:= 1; |
|
412 |
t:= 1; |
|
413 |
while i <= length(s) do |
|
414 |
begin |
|
415 |
DecodeBase64[t ]:= char((byte(s[i ]) shl 2) or (byte(s[i + 1]) shr 4)); |
|
416 |
DecodeBase64[t + 1]:= char((byte(s[i + 1]) shl 4) or (byte(s[i + 2]) shr 2)); |
|
417 |
DecodeBase64[t + 2]:= char((byte(s[i + 2]) shl 6) or (byte(s[i + 3]) )); |
|
418 |
inc(t, 3); |
|
419 |
inc(i, 4) |
|
420 |
end; |
|
421 |
||
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6444
diff
changeset
|
422 |
if c < 3 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6444
diff
changeset
|
423 |
t:= t - c; |
4374 | 424 |
|
7074 | 425 |
DecodeBase64[0]:= char(t - 1) |
4374 | 426 |
end; |
427 |
||
428 |
||
429 |
function Str2PChar(const s: shortstring): PChar; |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7896
diff
changeset
|
430 |
var i :Integer ; |
4374 | 431 |
begin |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7896
diff
changeset
|
432 |
for i:= 1 to Length(s) do |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7896
diff
changeset
|
433 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7896
diff
changeset
|
434 |
CharArray[i - 1] := s[i]; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7896
diff
changeset
|
435 |
end; |
10131
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10127
diff
changeset
|
436 |
CharArray[Length(s)]:= #0; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7896
diff
changeset
|
437 |
Str2PChar:= @(CharArray[0]); |
4374 | 438 |
end; |
439 |
||
440 |
||
441 |
function endian(independent: LongWord): LongWord; inline; |
|
442 |
begin |
|
443 |
{$IFDEF ENDIAN_LITTLE} |
|
444 |
endian:= independent; |
|
445 |
{$ELSE} |
|
446 |
endian:= (((independent and $FF000000) shr 24) or |
|
447 |
((independent and $00FF0000) shr 8) or |
|
448 |
((independent and $0000FF00) shl 8) or |
|
449 |
((independent and $000000FF) shl 24)) |
|
450 |
{$ENDIF} |
|
451 |
end; |
|
452 |
||
453 |
||
454 |
procedure AddFileLog(s: shortstring); |
|
455 |
begin |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7896
diff
changeset
|
456 |
// s:= s; |
4900 | 457 |
{$IFDEF DEBUGFILE} |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7896
diff
changeset
|
458 |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7194
diff
changeset
|
459 |
{$IFDEF USE_VIDEO_RECORDING} |
7180 | 460 |
EnterCriticalSection(logMutex); |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7194
diff
changeset
|
461 |
{$ENDIF} |
11748
eefa04b23c3b
fallback to stdout if no writable logfile available
sheepluva
parents:
11637
diff
changeset
|
462 |
if logFile <> nil then |
eefa04b23c3b
fallback to stdout if no writable logfile available
sheepluva
parents:
11637
diff
changeset
|
463 |
pfsWriteLn(logFile, inttostr(GameTicks) + ': ' + s) |
eefa04b23c3b
fallback to stdout if no writable logfile available
sheepluva
parents:
11637
diff
changeset
|
464 |
else |
eefa04b23c3b
fallback to stdout if no writable logfile available
sheepluva
parents:
11637
diff
changeset
|
465 |
WriteLn(stdout, inttostr(GameTicks) + ': ' + s); |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7896
diff
changeset
|
466 |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7194
diff
changeset
|
467 |
{$IFDEF USE_VIDEO_RECORDING} |
7180 | 468 |
LeaveCriticalSection(logMutex); |
4900 | 469 |
{$ENDIF} |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7896
diff
changeset
|
470 |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7194
diff
changeset
|
471 |
{$ENDIF} |
4374 | 472 |
end; |
473 |
||
7180 | 474 |
procedure AddFileLogRaw(s: pchar); cdecl; |
475 |
begin |
|
476 |
s:= s; |
|
9966 | 477 |
{$IFNDEF PAS2C} |
7180 | 478 |
{$IFDEF DEBUGFILE} |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7194
diff
changeset
|
479 |
{$IFDEF USE_VIDEO_RECORDING} |
7180 | 480 |
EnterCriticalSection(logMutex); |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7194
diff
changeset
|
481 |
{$ENDIF} |
11637 | 482 |
// TODO: uncomment next two lines |
483 |
// write(logFile, s); |
|
484 |
// flush(logFile); |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7194
diff
changeset
|
485 |
{$IFDEF USE_VIDEO_RECORDING} |
7180 | 486 |
LeaveCriticalSection(logMutex); |
487 |
{$ENDIF} |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7194
diff
changeset
|
488 |
{$ENDIF} |
9966 | 489 |
{$ENDIF} |
7180 | 490 |
end; |
4374 | 491 |
|
10116
dd27562b6f21
rolling back my PChar stuff, because unC0Rr improves string handling pas2c instead <3
sheepluva
parents:
10108
diff
changeset
|
492 |
function CheckCJKFont(s: ansistring; font: THWFont): THWFont; |
4380 | 493 |
var l, i : LongInt; |
494 |
u: WideChar; |
|
495 |
tmpstr: array[0..256] of WideChar; |
|
496 |
begin |
|
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:
6978
diff
changeset
|
497 |
CheckCJKFont:= font; |
4380 | 498 |
|
5639 | 499 |
{$IFNDEF MOBILE} |
4380 | 500 |
// remove chinese fonts for now |
10116
dd27562b6f21
rolling back my PChar stuff, because unC0Rr improves string handling pas2c instead <3
sheepluva
parents:
10108
diff
changeset
|
501 |
if (font >= CJKfnt16) or (length(s) = 0) then |
4380 | 502 |
{$ENDIF} |
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:
6978
diff
changeset
|
503 |
exit; |
4380 | 504 |
|
10131
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10127
diff
changeset
|
505 |
l:= Utf8ToUnicode(PWideChar(@tmpstr), PChar(s), min(length(tmpstr), length(s)))-1; |
4380 | 506 |
i:= 0; |
4737 | 507 |
|
4380 | 508 |
while i < l do |
509 |
begin |
|
510 |
u:= tmpstr[i]; |
|
4737 | 511 |
if (#$1100 <= u) and ( |
512 |
(u <= #$11FF ) or // Hangul Jamo |
|
513 |
((#$2E80 <= u) and (u <= #$2FDF)) or // CJK Radicals Supplement / Kangxi Radicals |
|
8575 | 514 |
((#$2FF0 <= u) and (u <= #$31FF)) or // Ideographic Description Characters / CJK Radicals Supplement / Hiragana / Hangul Compatibility Jamo / Katakana |
4380 | 515 |
((#$31C0 <= u) and (u <= #$31EF)) or // CJK Strokes |
8575 | 516 |
((#$3200 <= u) and (u <= #$4DBF)) or // Enclosed CJK Letters and Months / CJK Compatibility / CJK Unified Ideographs Extension A / Circled Katakana |
4380 | 517 |
((#$4E00 <= u) and (u <= #$9FFF)) or // CJK Unified Ideographs |
4737 | 518 |
((#$AC00 <= u) and (u <= #$D7AF)) or // Hangul Syllables |
4380 | 519 |
((#$F900 <= u) and (u <= #$FAFF)) or // CJK Compatibility Ideographs |
8575 | 520 |
((#$FE30 <= u) and (u <= #$FE4F)) or // CJK Compatibility Forms |
521 |
((#$FF66 <= u) and (u <= #$FF9D))) // halfwidth katakana |
|
10015 | 522 |
then |
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:
6978
diff
changeset
|
523 |
begin |
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:
6978
diff
changeset
|
524 |
CheckCJKFont:= THWFont( ord(font) + ((ord(High(THWFont))+1) div 2) ); |
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:
6978
diff
changeset
|
525 |
exit; |
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:
6978
diff
changeset
|
526 |
end; |
4380 | 527 |
inc(i) |
528 |
end; |
|
529 |
(* two more to check. pascal WideChar is only 16 bit though |
|
530 |
((#$20000 <= u) and (u >= #$2A6DF)) or // CJK Unified Ideographs Extension B |
|
531 |
((#$2F800 <= u) and (u >= #$2FA1F))) // CJK Compatibility Ideographs Supplement *) |
|
532 |
end; |
|
533 |
||
4385 | 534 |
|
535 |
function GetLaunchX(at: TAmmoType; dir: LongInt; angle: LongInt): LongInt; |
|
536 |
begin |
|
12626 | 537 |
at:= at; dir:= dir; angle:= angle; // parameter hint suppression because code below is currently disabled |
12322
b81a1d1497c4
Backed out changeset 98824a464230 (disable GetLaunchX/Y again)
Wuzzy <almikes@aol.com>
parents:
12202
diff
changeset
|
538 |
GetLaunchX:= 0 |
b81a1d1497c4
Backed out changeset 98824a464230 (disable GetLaunchX/Y again)
Wuzzy <almikes@aol.com>
parents:
12202
diff
changeset
|
539 |
(* |
4385 | 540 |
if (Ammoz[at].ejectX <> 0) or (Ammoz[at].ejectY <> 0) then |
541 |
GetLaunchX:= sign(dir) * (8 + hwRound(AngleSin(angle) * Ammoz[at].ejectX) + hwRound(AngleCos(angle) * Ammoz[at].ejectY)) |
|
542 |
else |
|
12322
b81a1d1497c4
Backed out changeset 98824a464230 (disable GetLaunchX/Y again)
Wuzzy <almikes@aol.com>
parents:
12202
diff
changeset
|
543 |
GetLaunchX:= 0 *) |
4385 | 544 |
end; |
545 |
||
546 |
function GetLaunchY(at: TAmmoType; angle: LongInt): LongInt; |
|
547 |
begin |
|
12626 | 548 |
at:= at; angle:= angle; // parameter hint suppression because code below is currently disabled |
12322
b81a1d1497c4
Backed out changeset 98824a464230 (disable GetLaunchX/Y again)
Wuzzy <almikes@aol.com>
parents:
12202
diff
changeset
|
549 |
GetLaunchY:= 0 |
b81a1d1497c4
Backed out changeset 98824a464230 (disable GetLaunchX/Y again)
Wuzzy <almikes@aol.com>
parents:
12202
diff
changeset
|
550 |
(* |
4385 | 551 |
if (Ammoz[at].ejectX <> 0) or (Ammoz[at].ejectY <> 0) then |
552 |
GetLaunchY:= hwRound(AngleSin(angle) * Ammoz[at].ejectY) - hwRound(AngleCos(angle) * Ammoz[at].ejectX) - 2 |
|
553 |
else |
|
12322
b81a1d1497c4
Backed out changeset 98824a464230 (disable GetLaunchX/Y again)
Wuzzy <almikes@aol.com>
parents:
12202
diff
changeset
|
554 |
GetLaunchY:= 0*) |
4385 | 555 |
end; |
556 |
||
12740 | 557 |
// Takes an X coordinate and corrects if according to the world edge rules |
558 |
// Wrap-around: X will be wrapped |
|
559 |
// Bouncy: X will be kept inside the legal land (taking radius into account) |
|
560 |
// Other world edges: Just returns X |
|
561 |
// radius is a radius (gear radius) tolerance for an appropriate distance from bouncy world edges. |
|
562 |
// Set radius to 0 if you don't care. |
|
563 |
function CalcWorldWrap(X, radius: LongInt): LongInt; |
|
564 |
begin |
|
565 |
if WorldEdge = weWrap then |
|
12794
28782e03b8f0
Fix CheckWorldWrap not correctly checking for bounce edge. Also fix teleport @ bounce edge
Wuzzy <Wuzzy2@mail.ru>
parents:
12749
diff
changeset
|
566 |
begin |
28782e03b8f0
Fix CheckWorldWrap not correctly checking for bounce edge. Also fix teleport @ bounce edge
Wuzzy <Wuzzy2@mail.ru>
parents:
12749
diff
changeset
|
567 |
if X < leftX then |
28782e03b8f0
Fix CheckWorldWrap not correctly checking for bounce edge. Also fix teleport @ bounce edge
Wuzzy <Wuzzy2@mail.ru>
parents:
12749
diff
changeset
|
568 |
X:= X + (rightX - leftX) |
28782e03b8f0
Fix CheckWorldWrap not correctly checking for bounce edge. Also fix teleport @ bounce edge
Wuzzy <Wuzzy2@mail.ru>
parents:
12749
diff
changeset
|
569 |
else if X > rightX then |
28782e03b8f0
Fix CheckWorldWrap not correctly checking for bounce edge. Also fix teleport @ bounce edge
Wuzzy <Wuzzy2@mail.ru>
parents:
12749
diff
changeset
|
570 |
X:= X - (rightX - leftX); |
28782e03b8f0
Fix CheckWorldWrap not correctly checking for bounce edge. Also fix teleport @ bounce edge
Wuzzy <Wuzzy2@mail.ru>
parents:
12749
diff
changeset
|
571 |
end |
12740 | 572 |
else if WorldEdge = weBounce then |
12794
28782e03b8f0
Fix CheckWorldWrap not correctly checking for bounce edge. Also fix teleport @ bounce edge
Wuzzy <Wuzzy2@mail.ru>
parents:
12749
diff
changeset
|
573 |
begin |
28782e03b8f0
Fix CheckWorldWrap not correctly checking for bounce edge. Also fix teleport @ bounce edge
Wuzzy <Wuzzy2@mail.ru>
parents:
12749
diff
changeset
|
574 |
if (X + radius) < leftX then |
28782e03b8f0
Fix CheckWorldWrap not correctly checking for bounce edge. Also fix teleport @ bounce edge
Wuzzy <Wuzzy2@mail.ru>
parents:
12749
diff
changeset
|
575 |
X:= leftX + radius |
28782e03b8f0
Fix CheckWorldWrap not correctly checking for bounce edge. Also fix teleport @ bounce edge
Wuzzy <Wuzzy2@mail.ru>
parents:
12749
diff
changeset
|
576 |
else if (X - radius) > rightX then |
28782e03b8f0
Fix CheckWorldWrap not correctly checking for bounce edge. Also fix teleport @ bounce edge
Wuzzy <Wuzzy2@mail.ru>
parents:
12749
diff
changeset
|
577 |
X:= rightX - radius; |
28782e03b8f0
Fix CheckWorldWrap not correctly checking for bounce edge. Also fix teleport @ bounce edge
Wuzzy <Wuzzy2@mail.ru>
parents:
12749
diff
changeset
|
578 |
end; |
12740 | 579 |
CalcWorldWrap:= X; |
580 |
end; |
|
581 |
||
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4385
diff
changeset
|
582 |
function CheckNoTeamOrHH: boolean; |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4385
diff
changeset
|
583 |
begin |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4385
diff
changeset
|
584 |
CheckNoTeamOrHH:= (CurrentTeam = nil) or (CurrentHedgehog^.Gear = nil); |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4385
diff
changeset
|
585 |
end; |
4385 | 586 |
|
7151 | 587 |
{$IFNDEF PAS2C} |
588 |
procedure Write(var f: textfile; s: shortstring); |
|
589 |
begin |
|
590 |
system.write(f, s) |
|
591 |
end; |
|
592 |
||
593 |
procedure WriteLn(var f: textfile; s: shortstring); |
|
594 |
begin |
|
595 |
system.writeln(f, s) |
|
596 |
end; |
|
10080 | 597 |
|
598 |
function StrLength(s: PChar): Longword; |
|
599 |
begin |
|
600 |
StrLength:= length(s) |
|
601 |
end; |
|
7151 | 602 |
{$ENDIF} |
603 |
||
8204 | 604 |
// this function is just to determine whether we are running on a limited screen device |
605 |
function isPhone: Boolean; inline; |
|
606 |
begin |
|
607 |
isPhone:= false; |
|
608 |
{$IFDEF IPHONEOS} |
|
609 |
isPhone:= isApplePhone(); |
|
610 |
{$ENDIF} |
|
611 |
{$IFDEF ANDROID} |
|
612 |
//nasty nasty hack. TODO: implement callback to java to have a unified way of determining if it is a tablet |
|
613 |
if (cScreenWidth < 1000) and (cScreenHeight < 500) then |
|
614 |
isPhone:= true; |
|
615 |
{$ENDIF} |
|
616 |
end; |
|
617 |
||
618 |
||
8498
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
619 |
function sanitizeForLog(s: shortstring): shortstring; |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
620 |
var i: byte; |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
621 |
r: shortstring; |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
622 |
begin |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
623 |
r[0]:= s[0]; |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
624 |
for i:= 1 to length(s) do |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
625 |
if (s[i] < #32) or (s[i] > #127) then |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
626 |
r[i]:= '?' |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
627 |
else |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
628 |
r[i]:= s[i]; |
10015 | 629 |
|
8498
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
630 |
sanitizeForLog:= r |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
631 |
end; |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
632 |
|
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
633 |
function sanitizeCharForLog(c: char): shortstring; |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
634 |
var r: shortstring; |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
635 |
begin |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
636 |
if (c < #32) or (c > #127) then |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
637 |
r:= '#' + inttostr(byte(c)) |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
638 |
else |
8841 | 639 |
begin |
640 |
// some magic for pas2c |
|
641 |
r[0]:= #1; |
|
642 |
r[1]:= c; |
|
643 |
end; |
|
644 |
||
8498
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
645 |
sanitizeCharForLog:= r |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
646 |
end; |
eecadca7db50
Bring back full log strings for commands, just a bit sanitized
unc0rr
parents:
8425
diff
changeset
|
647 |
|
11775 | 648 |
function read1stLn(filePath: shortstring): shortstring; |
649 |
var f: pfsFile; |
|
650 |
begin |
|
651 |
read1stLn:= ''; |
|
652 |
if pfsExists(filePath) then |
|
653 |
begin |
|
654 |
f:= pfsOpenRead(filePath); |
|
655 |
if (not pfsEOF(f)) and allOK then |
|
656 |
pfsReadLn(f, read1stLn); |
|
657 |
pfsClose(f); |
|
658 |
f:= nil; |
|
659 |
end; |
|
660 |
end; |
|
661 |
||
11780
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
662 |
function readValueFromINI(key, filePath: shortstring): shortstring; |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
663 |
var f: pfsFile; |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
664 |
s: shortstring; |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
665 |
i: LongInt; |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
666 |
begin |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
667 |
s:= ''; |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
668 |
readValueFromINI:= ''; |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
669 |
|
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
670 |
if pfsExists(filePath) then |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
671 |
begin |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
672 |
f:= pfsOpenRead(filePath); |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
673 |
|
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
674 |
while (not pfsEOF(f)) and allOK do |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
675 |
begin pfsReadLn(f, s); |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
676 |
if Length(s) = 0 then |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
677 |
continue; |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
678 |
if s[1] = ';' then |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
679 |
continue; |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
680 |
|
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
681 |
i:= Pos('=', s); |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
682 |
if Trim(Copy(s, 1, Pred(i))) = key then |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
683 |
begin |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
684 |
Delete(s, 1, i); |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
685 |
readValueFromINI:= s; |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
686 |
end; |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
687 |
end; |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
688 |
pfsClose(f); |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
689 |
f:= nil; |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
690 |
end; |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
691 |
end; |
ee85798d6974
aggregate music credits into a single file (individual files can still be used to override. useful for .hwp etc.)
sheepluva
parents:
11775
diff
changeset
|
692 |
|
7896
67217e6108fd
another stake at variable pre-initialisation - we lost preview logging in the course
koda
parents:
7565
diff
changeset
|
693 |
procedure initModule(isNotPreview: boolean); |
7027 | 694 |
{$IFDEF DEBUGFILE} |
695 |
var logfileBase: shortstring; |
|
8095 | 696 |
i: LongInt; |
7027 | 697 |
{$ENDIF} |
4374 | 698 |
begin |
699 |
{$IFDEF DEBUGFILE} |
|
7896
67217e6108fd
another stake at variable pre-initialisation - we lost preview logging in the course
koda
parents:
7565
diff
changeset
|
700 |
if isNotPreview then |
7386
e82a076df09b
Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
701 |
begin |
e82a076df09b
Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
702 |
if GameType = gmtRecord then |
e82a076df09b
Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
703 |
logfileBase:= 'rec' |
e82a076df09b
Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
704 |
else |
10505 | 705 |
{$IFDEF PAS2C} |
706 |
logfileBase:= 'game_pas2c'; |
|
707 |
{$ELSE} |
|
708 |
logfileBase:= 'game'; |
|
709 |
{$ENDIF} |
|
7386
e82a076df09b
Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
710 |
end |
7027 | 711 |
else |
10502
a888e649bea2
Fix difference in map generation between fpc and pas2c engine
unc0rr
parents:
10280
diff
changeset
|
712 |
{$IFDEF PAS2C} |
10503 | 713 |
logfileBase:= 'preview_pas2c'; |
10502
a888e649bea2
Fix difference in map generation between fpc and pas2c engine
unc0rr
parents:
10280
diff
changeset
|
714 |
{$ELSE} |
10504 | 715 |
logfileBase:= 'preview'; |
10502
a888e649bea2
Fix difference in map generation between fpc and pas2c engine
unc0rr
parents:
10280
diff
changeset
|
716 |
{$ENDIF} |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7194
diff
changeset
|
717 |
{$IFDEF USE_VIDEO_RECORDING} |
7180 | 718 |
InitCriticalSection(logMutex); |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7194
diff
changeset
|
719 |
{$ENDIF} |
11793
0327d20fa4a1
[BUG 66] - Create '/Logs' folder if not exists
antonc27 <antonc27@mail.ru>
parents:
11780
diff
changeset
|
720 |
if not pfsExists('/Logs') then |
0327d20fa4a1
[BUG 66] - Create '/Logs' folder if not exists
antonc27 <antonc27@mail.ru>
parents:
11780
diff
changeset
|
721 |
pfsMakeDir('/Logs'); |
11637 | 722 |
// if log is locked, write to the next one |
723 |
i:= 0; |
|
724 |
while(i < 7) do |
|
725 |
begin |
|
726 |
logFile:= pfsOpenWrite('/Logs/' + logfileBase + inttostr(i) + '.log'); |
|
727 |
if logFile <> nil then |
|
728 |
break; |
|
729 |
inc(i) |
|
730 |
end; |
|
11748
eefa04b23c3b
fallback to stdout if no writable logfile available
sheepluva
parents:
11637
diff
changeset
|
731 |
|
eefa04b23c3b
fallback to stdout if no writable logfile available
sheepluva
parents:
11637
diff
changeset
|
732 |
if logFile = nil then |
eefa04b23c3b
fallback to stdout if no writable logfile available
sheepluva
parents:
11637
diff
changeset
|
733 |
WriteLn(stdout, '[WARNING] Could not open log file for writing. Log will be written to stdout!'); |
4374 | 734 |
{$ENDIF} |
735 |
||
9300 | 736 |
//mobile stuff |
737 |
{$IFDEF IPHONEOS} |
|
738 |
mobileRecord.PerformRumble:= @AudioServicesPlaySystemSound; |
|
739 |
mobileRecord.GameLoading:= @startLoadingIndicator; |
|
740 |
mobileRecord.GameLoaded:= @stopLoadingIndicator; |
|
741 |
mobileRecord.SaveLoadingEnded:= @saveFinishedSynching; |
|
742 |
{$ELSE} |
|
743 |
mobileRecord.PerformRumble:= nil; |
|
744 |
mobileRecord.GameLoading:= nil; |
|
745 |
mobileRecord.GameLoaded:= nil; |
|
746 |
mobileRecord.SaveLoadingEnded:= nil; |
|
747 |
{$ENDIF} |
|
748 |
||
4374 | 749 |
end; |
750 |
||
751 |
procedure freeModule; |
|
752 |
begin |
|
753 |
{$IFDEF DEBUGFILE} |
|
11637 | 754 |
pfsWriteLn(logFile, 'halt at ' + inttostr(GameTicks) + ' ticks. TurnTimeLeft = ' + inttostr(TurnTimeLeft)); |
755 |
pfsFlush(logFile); |
|
756 |
pfsClose(logFile); |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7194
diff
changeset
|
757 |
{$IFDEF USE_VIDEO_RECORDING} |
7180 | 758 |
DoneCriticalSection(logMutex); |
4374 | 759 |
{$ENDIF} |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7194
diff
changeset
|
760 |
{$ENDIF} |
4374 | 761 |
end; |
762 |
||
4453 | 763 |
end. |