author | unC0Rr |
Wed, 17 Nov 2010 17:45:55 +0300 | |
changeset 4359 | 83ef50815535 |
parent 4357 | a1fcfc341a52 |
child 4371 | ae172b2b03ed |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2947 | 2 |
* Hedgewars, a free turn based strategy game |
3 |
* Copyright (c) 2004-2008 Andrey Korotaev <unC0Rr@gmail.com> |
|
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 |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*) |
|
4 | 18 |
|
2630 | 19 |
{$INCLUDE "options.inc"} |
20 |
||
4 | 21 |
unit uMisc; |
22 |
interface |
|
2630 | 23 |
|
4357
a1fcfc341a52
Introduce unit uTypes in order to remove some cyclic unit dependencies
unC0Rr
parents:
4248
diff
changeset
|
24 |
uses SDLh, uConsts, uFloat, GLunit, Math, uTypes; |
2697 | 25 |
|
3611 | 26 |
|
2747 | 27 |
procedure SplitBySpace(var a, b: shortstring); |
2905 | 28 |
procedure SplitByChar(var a, b: ansistring; c: char); |
3611 | 29 |
function EnumToStr(const en : TGearType) : shortstring; overload; |
30 |
function EnumToStr(const en : TSound) : shortstring; overload; |
|
31 |
function EnumToStr(const en : TAmmoType) : shortstring; overload; |
|
3756 | 32 |
function EnumToStr(const en : THogEffect) : shortstring; overload; |
3169
c8c6ac44f51b
prophylactic removal of some Integer references, raise a few of the template islands up a bit so they work inverted without triggering border
nemo
parents:
3165
diff
changeset
|
33 |
procedure movecursor(dx, dy: LongInt); |
3929
9a4bbc1f67a2
Inline most of uFloat (saves ~7.5% opcount on a test game), inline a few very short candidates in uMisc, comment out some unused functions in uMisc
nemo
parents:
3914
diff
changeset
|
34 |
function hwSign(r: hwFloat): LongInt; inline; |
9a4bbc1f67a2
Inline most of uFloat (saves ~7.5% opcount on a test game), inline a few very short candidates in uMisc, comment out some unused functions in uMisc
nemo
parents:
3914
diff
changeset
|
35 |
function Min(a, b: LongInt): LongInt; inline; |
9a4bbc1f67a2
Inline most of uFloat (saves ~7.5% opcount on a test game), inline a few very short candidates in uMisc, comment out some unused functions in uMisc
nemo
parents:
3914
diff
changeset
|
36 |
function Max(a, b: LongInt): LongInt; inline; |
2905 | 37 |
procedure OutError(Msg: shortstring; isFatalError: boolean); |
3599 | 38 |
procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); inline; |
4 | 39 |
procedure SDLTry(Assert: boolean; isFatal: boolean); |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
40 |
function IntToStr(n: LongInt): shortstring; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
41 |
function FloatToStr(n: hwFloat): shortstring; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
42 |
function DxDy2Angle(const _dY, _dX: hwFloat): GLfloat; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
43 |
function DxDy2Angle32(const _dY, _dX: hwFloat): LongInt; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
44 |
function DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt; |
3929
9a4bbc1f67a2
Inline most of uFloat (saves ~7.5% opcount on a test game), inline a few very short candidates in uMisc, comment out some unused functions in uMisc
nemo
parents:
3914
diff
changeset
|
45 |
(* |
4 | 46 |
procedure AdjustColor(var Color: Longword); |
208 | 47 |
procedure SetKB(n: Longword); |
3929
9a4bbc1f67a2
Inline most of uFloat (saves ~7.5% opcount on a test game), inline a few very short candidates in uMisc, comment out some unused functions in uMisc
nemo
parents:
3914
diff
changeset
|
48 |
*) |
208 | 49 |
procedure SendKB; |
351 | 50 |
procedure SetLittle(var r: hwFloat); |
306 | 51 |
procedure SendStat(sit: TStatInfoType; s: shortstring); |
753 | 52 |
function Str2PChar(const s: shortstring): PChar; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
53 |
function NewTexture(width, height: Longword; buf: Pointer): PTexture; |
2290
bf87ca44782e
Selectively enable clamping - seeing if this helps avoid weird flake problems while still fixing vertical lines in waves and sky
nemo
parents:
2279
diff
changeset
|
54 |
function Surface2Tex(surf: PSDL_Surface; enableClamp: boolean): PTexture; |
759 | 55 |
procedure FreeTexture(tex: PTexture); |
3599 | 56 |
function toPowerOf2(i: Longword): Longword; inline; |
2670 | 57 |
function DecodeBase64(s: shortstring): shortstring; |
58 |
function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface; |
|
3971 | 59 |
function endian(independent: LongWord): LongWord; inline; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
60 |
{$IFDEF DEBUGFILE} |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
61 |
procedure AddFileLog(s: shortstring); |
3929
9a4bbc1f67a2
Inline most of uFloat (saves ~7.5% opcount on a test game), inline a few very short candidates in uMisc, comment out some unused functions in uMisc
nemo
parents:
3914
diff
changeset
|
62 |
(* function RectToStr(Rect: TSDL_Rect): shortstring; *) |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
63 |
{$ENDIF} |
2735 | 64 |
procedure MakeScreenshot(filename: shortstring); |
4 | 65 |
|
4359 | 66 |
procedure initModule; |
67 |
procedure freeModule; |
|
68 |
||
4 | 69 |
implementation |
4359 | 70 |
uses uConsole, uStore, uIO, typinfo, sysutils, uVariables; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
71 |
|
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
72 |
var KBnum: Longword; |
4 | 73 |
{$IFDEF DEBUGFILE} |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
74 |
f: textfile; |
4 | 75 |
{$ENDIF} |
76 |
||
2747 | 77 |
// should this include "strtolower()" for the split string? |
78 |
procedure SplitBySpace(var a, b: shortstring); |
|
79 |
var i, t: LongInt; |
|
80 |
begin |
|
81 |
i:= Pos(' ', a); |
|
82 |
if i > 0 then |
|
2947 | 83 |
begin |
84 |
for t:= 1 to Pred(i) do |
|
85 |
if (a[t] >= 'A')and(a[t] <= 'Z') then Inc(a[t], 32); |
|
86 |
b:= copy(a, i + 1, Length(a) - i); |
|
87 |
byte(a[0]):= Pred(i) |
|
88 |
end else b:= ''; |
|
2747 | 89 |
end; |
90 |
||
2905 | 91 |
procedure SplitByChar(var a, b: ansistring; c: char); |
2747 | 92 |
var i: LongInt; |
93 |
begin |
|
94 |
i:= Pos(c, a); |
|
95 |
if i > 0 then |
|
2947 | 96 |
begin |
97 |
b:= copy(a, i + 1, Length(a) - i); |
|
98 |
setlength(a, Pred(i)); |
|
99 |
end else b:= ''; |
|
2747 | 100 |
end; |
101 |
||
3337 | 102 |
function EnumToStr(const en : TGearType) : shortstring; overload; |
103 |
begin |
|
104 |
EnumToStr:= GetEnumName(TypeInfo(TGearType), ord(en)) |
|
105 |
end; |
|
106 |
||
107 |
function EnumToStr(const en : TSound) : shortstring; overload; |
|
108 |
begin |
|
109 |
EnumToStr:= GetEnumName(TypeInfo(TSound), ord(en)) |
|
110 |
end; |
|
111 |
||
112 |
function EnumToStr(const en : TAmmoType) : shortstring; overload; |
|
113 |
begin |
|
114 |
EnumToStr:= GetEnumName(TypeInfo(TAmmoType), ord(en)) |
|
115 |
end; |
|
116 |
||
3756 | 117 |
function EnumToStr(const en: THogEffect) : shortstring; overload; |
118 |
begin |
|
119 |
EnumToStr := GetEnumName(TypeInfo(THogEffect), ord(en)) |
|
120 |
end; |
|
121 |
||
3169
c8c6ac44f51b
prophylactic removal of some Integer references, raise a few of the template islands up a bit so they work inverted without triggering border
nemo
parents:
3165
diff
changeset
|
122 |
procedure movecursor(dx, dy: LongInt); |
2428 | 123 |
var x, y: LongInt; |
124 |
begin |
|
125 |
if (dx = 0) and (dy = 0) then exit; |
|
2671
7e0f88013fe8
smaller patches, one missing Sky-lowres, IMG_Init and Mix_Init (might require newer libraries), updates to SDL bindings, code cleanup, new compile flags
koda
parents:
2670
diff
changeset
|
126 |
|
2428 | 127 |
SDL_GetMouseState(@x, @y); |
128 |
Inc(x, dx); |
|
129 |
Inc(y, dy); |
|
130 |
SDL_WarpMouse(x, y); |
|
131 |
end; |
|
132 |
||
371 | 133 |
function hwSign(r: hwFloat): LongInt; |
4 | 134 |
begin |
2389 | 135 |
// yes, we have negative zero for a reason |
136 |
if r.isNegative then hwSign:= -1 else hwSign:= 1 |
|
4 | 137 |
end; |
138 |
||
371 | 139 |
function Min(a, b: LongInt): LongInt; |
4 | 140 |
begin |
351 | 141 |
if a < b then Min:= a else Min:= b |
4 | 142 |
end; |
143 |
||
371 | 144 |
function Max(a, b: LongInt): LongInt; |
4 | 145 |
begin |
351 | 146 |
if a > b then Max:= a else Max:= b |
4 | 147 |
end; |
148 |
||
2905 | 149 |
procedure OutError(Msg: shortstring; isFatalError: boolean); |
4 | 150 |
begin |
3407 | 151 |
// obsolete? written in WriteLnToConsole() anyway |
152 |
// {$IFDEF DEBUGFILE}AddFileLog(Msg);{$ENDIF} |
|
4046
cfdbddc4b385
making indentation consistent (noticed while debugging)
nemo
parents:
4003
diff
changeset
|
153 |
WriteLnToConsole(Msg); |
cfdbddc4b385
making indentation consistent (noticed while debugging)
nemo
parents:
4003
diff
changeset
|
154 |
if isFatalError then |
3407 | 155 |
begin |
4046
cfdbddc4b385
making indentation consistent (noticed while debugging)
nemo
parents:
4003
diff
changeset
|
156 |
SendIPC('E' + GetLastConsoleLine); |
cfdbddc4b385
making indentation consistent (noticed while debugging)
nemo
parents:
4003
diff
changeset
|
157 |
SDL_Quit; |
cfdbddc4b385
making indentation consistent (noticed while debugging)
nemo
parents:
4003
diff
changeset
|
158 |
halt(1) |
3407 | 159 |
end |
4 | 160 |
end; |
161 |
||
2905 | 162 |
procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); |
4 | 163 |
begin |
70 | 164 |
if not Assert then OutError(Msg, isFatal) |
4 | 165 |
end; |
166 |
||
167 |
procedure SDLTry(Assert: boolean; isFatal: boolean); |
|
168 |
begin |
|
169 |
if not Assert then OutError(SDL_GetError, isFatal) |
|
170 |
end; |
|
171 |
||
3929
9a4bbc1f67a2
Inline most of uFloat (saves ~7.5% opcount on a test game), inline a few very short candidates in uMisc, comment out some unused functions in uMisc
nemo
parents:
3914
diff
changeset
|
172 |
(* |
188 | 173 |
procedure AdjustColor(var Color: Longword); |
4 | 174 |
begin |
175 |
Color:= SDL_MapRGB(PixelFormat, (Color shr 16) and $FF, (Color shr 8) and $FF, Color and $FF) |
|
176 |
end; |
|
177 |
||
3929
9a4bbc1f67a2
Inline most of uFloat (saves ~7.5% opcount on a test game), inline a few very short candidates in uMisc, comment out some unused functions in uMisc
nemo
parents:
3914
diff
changeset
|
178 |
procedure SetKB(n: Longword); |
9a4bbc1f67a2
Inline most of uFloat (saves ~7.5% opcount on a test game), inline a few very short candidates in uMisc, comment out some unused functions in uMisc
nemo
parents:
3914
diff
changeset
|
179 |
begin |
9a4bbc1f67a2
Inline most of uFloat (saves ~7.5% opcount on a test game), inline a few very short candidates in uMisc, comment out some unused functions in uMisc
nemo
parents:
3914
diff
changeset
|
180 |
KBnum:= n |
9a4bbc1f67a2
Inline most of uFloat (saves ~7.5% opcount on a test game), inline a few very short candidates in uMisc, comment out some unused functions in uMisc
nemo
parents:
3914
diff
changeset
|
181 |
end; |
9a4bbc1f67a2
Inline most of uFloat (saves ~7.5% opcount on a test game), inline a few very short candidates in uMisc, comment out some unused functions in uMisc
nemo
parents:
3914
diff
changeset
|
182 |
*) |
9a4bbc1f67a2
Inline most of uFloat (saves ~7.5% opcount on a test game), inline a few very short candidates in uMisc, comment out some unused functions in uMisc
nemo
parents:
3914
diff
changeset
|
183 |
|
9a4bbc1f67a2
Inline most of uFloat (saves ~7.5% opcount on a test game), inline a few very short candidates in uMisc, comment out some unused functions in uMisc
nemo
parents:
3914
diff
changeset
|
184 |
|
316 | 185 |
function IntToStr(n: LongInt): shortstring; |
4 | 186 |
begin |
351 | 187 |
str(n, IntToStr) |
4 | 188 |
end; |
189 |
||
351 | 190 |
function FloatToStr(n: hwFloat): shortstring; |
4 | 191 |
begin |
1346 | 192 |
FloatToStr:= cstr(n) + '_' + inttostr(Lo(n.QWordValue)) |
4 | 193 |
end; |
194 |
||
2447
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
195 |
procedure SetTextureParameters(enableClamp: Boolean); |
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
196 |
begin |
3611 | 197 |
if enableClamp and ((cReducedQuality and rqClampLess) = 0) then |
2447
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
198 |
begin |
3594
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3593
diff
changeset
|
199 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3593
diff
changeset
|
200 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) |
2447
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
201 |
end; |
3594
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3593
diff
changeset
|
202 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3593
diff
changeset
|
203 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) |
2447
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
204 |
end; |
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
205 |
|
775 | 206 |
function DxDy2Angle(const _dY, _dX: hwFloat): GLfloat; |
207 |
var dY, dX: Extended; |
|
208 |
begin |
|
209 |
dY:= _dY.QWordValue / $100000000; |
|
210 |
if _dY.isNegative then dY:= - dY; |
|
211 |
dX:= _dX.QWordValue / $100000000; |
|
212 |
if _dX.isNegative then dX:= - dX; |
|
213 |
DxDy2Angle:= arctan2(dY, dX) * 180 / pi |
|
214 |
end; |
|
215 |
||
371 | 216 |
function DxDy2Angle32(const _dY, _dX: hwFloat): LongInt; |
100 | 217 |
const _16divPI: Extended = 16/pi; |
370
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
218 |
var dY, dX: Extended; |
100 | 219 |
begin |
370
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
220 |
dY:= _dY.QWordValue / $100000000; |
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
221 |
if _dY.isNegative then dY:= - dY; |
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
222 |
dX:= _dX.QWordValue / $100000000; |
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
223 |
if _dX.isNegative then dX:= - dX; |
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
224 |
DxDy2Angle32:= trunc(arctan2(dY, dX) * _16divPI) and $1f |
4 | 225 |
end; |
226 |
||
371 | 227 |
function DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt; |
100 | 228 |
const MaxAngleDivPI: Extended = cMaxAngle/pi; |
370
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
229 |
var dY, dX: Extended; |
100 | 230 |
begin |
370
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
231 |
dY:= _dY.QWordValue / $100000000; |
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
232 |
if _dY.isNegative then dY:= - dY; |
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
233 |
dX:= _dX.QWordValue / $100000000; |
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
234 |
if _dX.isNegative then dX:= - dX; |
438 | 235 |
DxDy2AttackAngle:= trunc(arctan2(dY, dX) * MaxAngleDivPI) |
100 | 236 |
end; |
4 | 237 |
|
208 | 238 |
procedure SendKB; |
239 |
var s: shortstring; |
|
240 |
begin |
|
241 |
if KBnum <> 0 then |
|
2947 | 242 |
begin |
243 |
s:= 'K' + inttostr(KBnum); |
|
244 |
SendIPCRaw(@s, Length(s) + 1) |
|
245 |
end |
|
208 | 246 |
end; |
247 |
||
351 | 248 |
procedure SetLittle(var r: hwFloat); |
300 | 249 |
begin |
553
5478386d935f
- Switch to bazooka (or whatever) after use of some weapon (fixes problem with bots)
unc0rr
parents:
543
diff
changeset
|
250 |
r:= SignAs(cLittle, r) |
300 | 251 |
end; |
252 |
||
337 | 253 |
procedure SendStat(sit: TStatInfoType; s: shortstring); |
3784
75aa91bea32b
Extend statistics collection (TeamKills, TurnSkips, TeamDamage)
burp
parents:
3779
diff
changeset
|
254 |
const stc: array [TStatInfoType] of char = 'rDkKHTPsSB'; |
2382 | 255 |
var buf: shortstring; |
337 | 256 |
begin |
2382 | 257 |
buf:= 'i' + stc[sit] + s; |
258 |
SendIPCRaw(@buf[0], length(buf) + 1) |
|
337 | 259 |
end; |
260 |
||
534 | 261 |
function Str2PChar(const s: shortstring): PChar; |
351 | 262 |
const CharArray: array[byte] of Char = ''; |
263 |
begin |
|
264 |
CharArray:= s; |
|
265 |
CharArray[Length(s)]:= #0; |
|
266 |
Str2PChar:= @CharArray |
|
267 |
end; |
|
268 |
||
771 | 269 |
function isPowerOf2(i: Longword): boolean; |
270 |
begin |
|
271 |
if i = 0 then exit(true); |
|
272 |
while (i and 1) = 0 do i:= i shr 1; |
|
273 |
isPowerOf2:= (i = 1) |
|
274 |
end; |
|
275 |
||
276 |
function toPowerOf2(i: Longword): Longword; |
|
277 |
begin |
|
278 |
toPowerOf2:= 1; |
|
279 |
while (toPowerOf2 < i) do toPowerOf2:= toPowerOf2 shl 1 |
|
280 |
end; |
|
281 |
||
1912
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
282 |
procedure ResetVertexArrays(texture: PTexture); |
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
283 |
begin |
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
284 |
with texture^ do |
2947 | 285 |
begin |
286 |
vb[0].X:= 0; |
|
287 |
vb[0].Y:= 0; |
|
288 |
vb[1].X:= w; |
|
289 |
vb[1].Y:= 0; |
|
290 |
vb[2].X:= w; |
|
291 |
vb[2].Y:= h; |
|
292 |
vb[3].X:= 0; |
|
293 |
vb[3].Y:= h; |
|
1912
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
294 |
|
2947 | 295 |
tb[0].X:= 0; |
296 |
tb[0].Y:= 0; |
|
297 |
tb[1].X:= rx; |
|
298 |
tb[1].Y:= 0; |
|
299 |
tb[2].X:= rx; |
|
300 |
tb[2].Y:= ry; |
|
301 |
tb[3].X:= 0; |
|
302 |
tb[3].Y:= ry |
|
303 |
end; |
|
1912
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
304 |
end; |
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
305 |
|
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
306 |
function NewTexture(width, height: Longword; buf: Pointer): PTexture; |
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
307 |
begin |
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
308 |
new(NewTexture); |
2715
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
309 |
NewTexture^.PrevTexture:= nil; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
310 |
NewTexture^.NextTexture:= nil; |
3537
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3534
diff
changeset
|
311 |
NewTexture^.Scale:= 1; |
2715
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
312 |
if TextureList <> nil then |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
313 |
begin |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
314 |
TextureList^.PrevTexture:= NewTexture; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
315 |
NewTexture^.NextTexture:= TextureList |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
316 |
end; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
317 |
TextureList:= NewTexture; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
318 |
|
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
319 |
NewTexture^.w:= width; |
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
320 |
NewTexture^.h:= height; |
1896 | 321 |
NewTexture^.rx:= 1.0; |
322 |
NewTexture^.ry:= 1.0; |
|
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
323 |
|
1912
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
324 |
ResetVertexArrays(NewTexture); |
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
325 |
|
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
326 |
glGenTextures(1, @NewTexture^.id); |
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
327 |
|
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
328 |
glBindTexture(GL_TEXTURE_2D, NewTexture^.id); |
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
329 |
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf); |
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
330 |
|
2447
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
331 |
SetTextureParameters(true); |
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
332 |
end; |
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
333 |
|
2290
bf87ca44782e
Selectively enable clamping - seeing if this helps avoid weird flake problems while still fixing vertical lines in waves and sky
nemo
parents:
2279
diff
changeset
|
334 |
function Surface2Tex(surf: PSDL_Surface; enableClamp: boolean): PTexture; |
2576
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
335 |
var tw, th, x, y: Longword; |
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
336 |
tmpp: pointer; |
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
337 |
fromP4, toP4: PLongWordArray; |
753 | 338 |
begin |
755 | 339 |
new(Surface2Tex); |
2715
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
340 |
Surface2Tex^.PrevTexture:= nil; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
341 |
Surface2Tex^.NextTexture:= nil; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
342 |
if TextureList <> nil then |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
343 |
begin |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
344 |
TextureList^.PrevTexture:= Surface2Tex; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
345 |
Surface2Tex^.NextTexture:= TextureList |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
346 |
end; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
347 |
TextureList:= Surface2Tex; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
348 |
|
755 | 349 |
Surface2Tex^.w:= surf^.w; |
350 |
Surface2Tex^.h:= surf^.h; |
|
351 |
||
2576
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
352 |
if (surf^.format^.BytesPerPixel <> 4) then |
3859 | 353 |
begin |
2947 | 354 |
TryDo(false, 'Surface2Tex failed, expecting 32 bit surface', true); |
355 |
Surface2Tex^.id:= 0; |
|
356 |
exit |
|
3859 | 357 |
end; |
2576
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
358 |
|
753 | 359 |
|
755 | 360 |
glGenTextures(1, @Surface2Tex^.id); |
753 | 361 |
|
755 | 362 |
glBindTexture(GL_TEXTURE_2D, Surface2Tex^.id); |
753 | 363 |
|
771 | 364 |
if SDL_MustLock(surf) then |
2947 | 365 |
SDLTry(SDL_LockSurface(surf) >= 0, true); |
771 | 366 |
|
2428 | 367 |
if (not SupportNPOTT) and (not (isPowerOf2(Surf^.w) and isPowerOf2(Surf^.h))) then |
3859 | 368 |
begin |
2947 | 369 |
tw:= toPowerOf2(Surf^.w); |
370 |
th:= toPowerOf2(Surf^.h); |
|
1896 | 371 |
|
2947 | 372 |
Surface2Tex^.rx:= Surf^.w / tw; |
373 |
Surface2Tex^.ry:= Surf^.h / th; |
|
2376 | 374 |
|
2947 | 375 |
GetMem(tmpp, tw * th * surf^.format^.BytesPerPixel); |
1896 | 376 |
|
3859 | 377 |
fromP4:= Surf^.pixels; |
378 |
toP4:= tmpp; |
|
771 | 379 |
|
3859 | 380 |
for y:= 0 to Pred(Surf^.h) do |
2947 | 381 |
begin |
3859 | 382 |
for x:= 0 to Pred(Surf^.w) do toP4^[x]:= fromP4^[x]; |
383 |
for x:= Surf^.w to Pred(tw) do toP4^[x]:= 0; |
|
384 |
toP4:= @(toP4^[tw]); |
|
385 |
fromP4:= @(fromP4^[Surf^.pitch div 4]) |
|
2947 | 386 |
end; |
1896 | 387 |
|
3859 | 388 |
for y:= Surf^.h to Pred(th) do |
2947 | 389 |
begin |
3859 | 390 |
for x:= 0 to Pred(tw) do toP4^[x]:= 0; |
391 |
toP4:= @(toP4^[tw]) |
|
2947 | 392 |
end; |
771 | 393 |
|
2947 | 394 |
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tw, th, 0, GL_RGBA, GL_UNSIGNED_BYTE, tmpp); |
2376 | 395 |
|
2947 | 396 |
FreeMem(tmpp, tw * th * surf^.format^.BytesPerPixel) |
3859 | 397 |
end |
2576
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
398 |
else |
3859 | 399 |
begin |
2947 | 400 |
Surface2Tex^.rx:= 1.0; |
401 |
Surface2Tex^.ry:= 1.0; |
|
402 |
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surf^.w, surf^.h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surf^.pixels); |
|
3859 | 403 |
end; |
753 | 404 |
|
1912
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
405 |
ResetVertexArrays(Surface2Tex); |
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
406 |
|
754 | 407 |
if SDL_MustLock(surf) then |
2947 | 408 |
SDL_UnlockSurface(surf); |
754 | 409 |
|
2447
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
410 |
SetTextureParameters(enableClamp); |
753 | 411 |
end; |
412 |
||
759 | 413 |
procedure FreeTexture(tex: PTexture); |
414 |
begin |
|
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3464
diff
changeset
|
415 |
if tex <> nil then |
2947 | 416 |
begin |
3697 | 417 |
if tex^.NextTexture <> nil then |
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3464
diff
changeset
|
418 |
tex^.NextTexture^.PrevTexture:= tex^.PrevTexture; |
3697 | 419 |
if tex^.PrevTexture <> nil then |
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3464
diff
changeset
|
420 |
tex^.PrevTexture^.NextTexture:= tex^.NextTexture |
3697 | 421 |
else |
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3464
diff
changeset
|
422 |
TextureList:= tex^.NextTexture; |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3464
diff
changeset
|
423 |
glDeleteTextures(1, @tex^.id); |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3464
diff
changeset
|
424 |
Dispose(tex); |
2947 | 425 |
end |
759 | 426 |
end; |
337 | 427 |
|
949 | 428 |
function DecodeBase64(s: shortstring): shortstring; |
429 |
const table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; |
|
430 |
var i, t, c: Longword; |
|
431 |
begin |
|
432 |
c:= 0; |
|
433 |
for i:= 1 to Length(s) do |
|
2947 | 434 |
begin |
435 |
t:= Pos(s[i], table); |
|
436 |
if s[i] = '=' then inc(c); |
|
437 |
if t > 0 then byte(s[i]):= t - 1 else byte(s[i]):= 0 |
|
438 |
end; |
|
949 | 439 |
|
440 |
i:= 1; |
|
441 |
t:= 1; |
|
442 |
while i <= length(s) do |
|
2947 | 443 |
begin |
444 |
DecodeBase64[t ]:= char((byte(s[i ]) shl 2) or (byte(s[i + 1]) shr 4)); |
|
445 |
DecodeBase64[t + 1]:= char((byte(s[i + 1]) shl 4) or (byte(s[i + 2]) shr 2)); |
|
446 |
DecodeBase64[t + 2]:= char((byte(s[i + 2]) shl 6) or (byte(s[i + 3]) )); |
|
447 |
inc(t, 3); |
|
448 |
inc(i, 4) |
|
449 |
end; |
|
949 | 450 |
|
451 |
if c < 3 then t:= t - c; |
|
452 |
||
453 |
byte(DecodeBase64[0]):= t - 1 |
|
454 |
end; |
|
455 |
||
2735 | 456 |
procedure MakeScreenshot(filename: shortstring); |
1080 | 457 |
var p: Pointer; |
2947 | 458 |
size: Longword; |
459 |
f: file; |
|
460 |
// Windows Bitmap Header |
|
461 |
head: array[0..53] of Byte = ( |
|
462 |
$42, $4D, // identifier ("BM") |
|
463 |
0, 0, 0, 0, // file size |
|
464 |
0, 0, 0, 0, // reserved |
|
465 |
54, 0, 0, 0, // starting offset |
|
466 |
40, 0, 0, 0, // header size |
|
467 |
0, 0, 0, 0, // width |
|
468 |
0, 0, 0, 0, // height |
|
469 |
1, 0, // color planes |
|
470 |
24, 0, // bit depth |
|
471 |
0, 0, 0, 0, // compression method (uncompressed) |
|
472 |
0, 0, 0, 0, // image size |
|
473 |
96, 0, 0, 0, // horizontal resolution |
|
474 |
96, 0, 0, 0, // vertical resolution |
|
475 |
0, 0, 0, 0, // number of colors (all) |
|
476 |
0, 0, 0, 0 // number of important colors |
|
477 |
); |
|
1080 | 478 |
begin |
3107 | 479 |
// flash |
480 |
ScreenFade:= sfFromWhite; |
|
481 |
ScreenFadeValue:= sfMax; |
|
482 |
ScreenFadeSpeed:= 5; |
|
483 |
||
1080 | 484 |
size:= cScreenWidth * cScreenHeight * 3; |
485 |
p:= GetMem(size); |
|
486 |
||
2735 | 487 |
// update header information and file name |
488 |
||
3350 | 489 |
filename:= ParamStr(1) + '/Screenshots/' + filename + '.bmp'; |
2735 | 490 |
|
491 |
head[$02]:= (size + 54) and $ff; |
|
492 |
head[$03]:= ((size + 54) shr 8) and $ff; |
|
493 |
head[$04]:= ((size + 54) shr 16) and $ff; |
|
494 |
head[$05]:= ((size + 54) shr 24) and $ff; |
|
495 |
head[$12]:= cScreenWidth and $ff; |
|
496 |
head[$13]:= (cScreenWidth shr 8) and $ff; |
|
497 |
head[$14]:= (cScreenWidth shr 16) and $ff; |
|
498 |
head[$15]:= (cScreenWidth shr 24) and $ff; |
|
499 |
head[$16]:= cScreenHeight and $ff; |
|
500 |
head[$17]:= (cScreenHeight shr 8) and $ff; |
|
501 |
head[$18]:= (cScreenHeight shr 16) and $ff; |
|
502 |
head[$19]:= (cScreenHeight shr 24) and $ff; |
|
503 |
head[$22]:= size and $ff; |
|
504 |
head[$23]:= (size shr 8) and $ff; |
|
505 |
head[$24]:= (size shr 16) and $ff; |
|
506 |
head[$25]:= (size shr 24) and $ff; |
|
2163
12730f5e79b9
koda's patch fixing some iphone port troubles (color, mouse)
unc0rr
parents:
2162
diff
changeset
|
507 |
|
12730f5e79b9
koda's patch fixing some iphone port troubles (color, mouse)
unc0rr
parents:
2162
diff
changeset
|
508 |
//remember that opengles operates on a single surface, so GL_FRONT *should* be implied |
3663
8c28abf427f5
reduce the number of keywords used and switch to BMP format for screenshots
koda
parents:
3650
diff
changeset
|
509 |
//glReadBuffer(GL_FRONT); |
1080 | 510 |
glReadPixels(0, 0, cScreenWidth, cScreenHeight, GL_BGR, GL_UNSIGNED_BYTE, p); |
511 |
||
512 |
{$I-} |
|
2735 | 513 |
Assign(f, filename); |
1080 | 514 |
Rewrite(f, 1); |
515 |
if IOResult = 0 then |
|
2947 | 516 |
begin |
517 |
BlockWrite(f, head, sizeof(head)); |
|
518 |
BlockWrite(f, p^, size); |
|
519 |
Close(f); |
|
520 |
end; |
|
1080 | 521 |
{$I+} |
522 |
||
523 |
FreeMem(p) |
|
524 |
end; |
|
525 |
||
949 | 526 |
{$IFDEF DEBUGFILE} |
527 |
procedure AddFileLog(s: shortstring); |
|
528 |
begin |
|
529 |
writeln(f, GameTicks: 6, ': ', s); |
|
530 |
flush(f) |
|
531 |
end; |
|
3929
9a4bbc1f67a2
Inline most of uFloat (saves ~7.5% opcount on a test game), inline a few very short candidates in uMisc, comment out some unused functions in uMisc
nemo
parents:
3914
diff
changeset
|
532 |
(* |
949 | 533 |
function RectToStr(Rect: TSDL_Rect): shortstring; |
534 |
begin |
|
535 |
RectToStr:= '(x: ' + inttostr(rect.x) + '; y: ' + inttostr(rect.y) + '; w: ' + inttostr(rect.w) + '; h: ' + inttostr(rect.h) + ')' |
|
536 |
end; |
|
3929
9a4bbc1f67a2
Inline most of uFloat (saves ~7.5% opcount on a test game), inline a few very short candidates in uMisc, comment out some unused functions in uMisc
nemo
parents:
3914
diff
changeset
|
537 |
*) |
2242 | 538 |
{$ENDIF} |
306 | 539 |
|
2619 | 540 |
function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface; |
541 |
{* for more information http://www.idevgames.com/forum/showpost.php?p=85864&postcount=7 *} |
|
542 |
var convertedSurf: PSDL_Surface = nil; |
|
543 |
begin |
|
2947 | 544 |
if (tmpsurf^.format^.bitsperpixel = 24) or ((tmpsurf^.format^.bitsperpixel = 32) and (tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) then |
545 |
begin |
|
546 |
convertedSurf:= SDL_ConvertSurface(tmpsurf, @conversionFormat, SDL_SWSURFACE); |
|
547 |
SDL_FreeSurface(tmpsurf); |
|
548 |
exit(convertedSurf); |
|
549 |
end; |
|
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
550 |
|
2947 | 551 |
exit(tmpsurf); |
2619 | 552 |
end; |
553 |
||
3971 | 554 |
function endian(independent: LongWord): LongWord; inline; |
2670 | 555 |
begin |
556 |
{$IFDEF ENDIAN_LITTLE} |
|
557 |
endian:= independent; |
|
558 |
{$ELSE} |
|
559 |
endian:= (((independent and $FF000000) shr 24) or |
|
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3355
diff
changeset
|
560 |
((independent and $00FF0000) shr 8) or |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3355
diff
changeset
|
561 |
((independent and $0000FF00) shl 8) or |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3355
diff
changeset
|
562 |
((independent and $000000FF) shl 24)) |
2670 | 563 |
{$ENDIF} |
564 |
end; |
|
2630 | 565 |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
566 |
|
3038 | 567 |
procedure initModule; |
3305 | 568 |
{$IFDEF DEBUGFILE}{$IFNDEF IPHONEOS}var i: LongInt;{$ENDIF}{$ENDIF} |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
569 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
570 |
KBnum := 0; |
3709 | 571 |
|
488 | 572 |
{$IFDEF DEBUGFILE} |
337 | 573 |
{$I-} |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
574 |
{$IFDEF IPHONEOS} |
3914 | 575 |
Assign(f,'../Documents/hw-' + cLogfileBase + '.log'); |
3377 | 576 |
Rewrite(f); |
2630 | 577 |
{$ELSE} |
3533
03892fb97ab3
fix build and permissions problems when launching hwengine from command line
koda
parents:
3513
diff
changeset
|
578 |
if (ParamStr(1) <> '') and (ParamStr(2) <> '') then |
3709 | 579 |
if (ParamCount <> 3) and (ParamCount <> cDefaultParamNum) then |
2947 | 580 |
begin |
3534 | 581 |
for i:= 0 to 7 do |
582 |
begin |
|
3932 | 583 |
assign(f, ExtractFileDir(ParamStr(2)) + '/' + cLogfileBase + inttostr(i) + '.log'); |
3534 | 584 |
rewrite(f); |
585 |
if IOResult = 0 then break; |
|
586 |
end; |
|
587 |
if IOResult <> 0 then f:= stderr; // if everything fails, write to stderr |
|
588 |
end |
|
589 |
else |
|
590 |
begin |
|
591 |
for i:= 0 to 7 do |
|
592 |
begin |
|
3914 | 593 |
assign(f, ParamStr(1) + '/Logs/' + cLogfileBase + inttostr(i) + '.log'); |
3534 | 594 |
rewrite(f); |
595 |
if IOResult = 0 then break; |
|
596 |
end; |
|
597 |
if IOResult <> 0 then f:= stderr; // if everything fails, write to stderr |
|
2947 | 598 |
end |
599 |
else |
|
600 |
f:= stderr; |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
601 |
{$ENDIF} |
337 | 602 |
{$I+} |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
603 |
{$ENDIF} |
3695
c11abf387a7d
reverted stereo craziness - the experimental3D branch has been created for a reason
koda
parents:
3693
diff
changeset
|
604 |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
605 |
end; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
606 |
|
3038 | 607 |
procedure freeModule; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
608 |
begin |
3626 | 609 |
recordFileName:= ''; |
2947 | 610 |
while TextureList <> nil do FreeTexture(TextureList); |
2154
3d2917be12c3
Change default output to stderr since /tmp doesn't exist under windows and is useless under iphoneos, add a couple of extra parameters
nemo
parents:
2152
diff
changeset
|
611 |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
612 |
{$IFDEF DEBUGFILE} |
2947 | 613 |
writeln(f, 'halt at ', GameTicks, ' ticks. TurnTimeLeft = ', TurnTimeLeft); |
614 |
flush(f); |
|
615 |
close(f); |
|
4 | 616 |
{$ENDIF} |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
617 |
end; |
4 | 618 |
|
619 |
end. |