author | unc0rr |
Sun, 27 Jun 2010 21:28:28 +0400 | |
changeset 3576 | d85bdd5dc835 |
parent 3537 | 8f5b3108f29c |
child 3593 | ae50f63e4fa9 |
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 |
|
3165
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3133
diff
changeset
|
24 |
uses SDLh, uConsts, uFloat, GLunit; |
2697 | 25 |
|
1054 | 26 |
var |
2947 | 27 |
isCursorVisible : boolean; |
28 |
isTerminated : boolean; |
|
29 |
isInLag : boolean; |
|
30 |
isPaused : boolean; |
|
31 |
isSoundEnabled : boolean; |
|
32 |
isMusicEnabled : boolean; |
|
33 |
isSEBackup : boolean; |
|
34 |
isInMultiShoot : boolean; |
|
35 |
isSpeed : boolean; |
|
3107 | 36 |
isFirstFrame : boolean; |
1560
e140bc57ff68
Quick replay round to spectators until current move
unc0rr
parents:
1530
diff
changeset
|
37 |
|
2947 | 38 |
fastUntilLag : boolean; |
1888
e76274ce7365
Add an ability to run engine without IPC connection.
unc0rr
parents:
1861
diff
changeset
|
39 |
|
2947 | 40 |
GameState : TGameState; |
41 |
GameType : TGameType; |
|
42 |
GameFlags : Longword; |
|
43 |
TrainingFlags : Longword; |
|
44 |
TurnTimeLeft : Longword; |
|
45 |
cSuddenDTurns : LongInt; |
|
46 |
cDamagePercent : LongInt; |
|
47 |
cMineDudPercent : LongWord; |
|
48 |
cTemplateFilter : LongInt; |
|
3133 | 49 |
cMapGen : LongInt; |
50 |
cMazeSize : LongInt; |
|
4 | 51 |
|
2947 | 52 |
cHedgehogTurnTime: Longword; |
53 |
cMinesTime : LongInt; |
|
54 |
cMaxAIThinkTime : Longword; |
|
74 | 55 |
|
2947 | 56 |
cCloudsNumber : LongInt; |
57 |
cScreenWidth : LongInt; |
|
58 |
cScreenHeight : LongInt; |
|
59 |
cInitWidth : LongInt; |
|
60 |
cInitHeight : LongInt; |
|
61 |
cVSyncInUse : boolean; |
|
62 |
cBits : LongInt; |
|
63 |
cBitsStr : string[2]; |
|
64 |
cTagsMask : byte; |
|
65 |
zoom : GLfloat; |
|
66 |
ZoomValue : GLfloat; |
|
4 | 67 |
|
2947 | 68 |
cWaterLine : LongInt; |
69 |
cGearScrEdgesDist: LongInt; |
|
70 |
cAltDamage : boolean; |
|
1054 | 71 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
72 |
GameTicks : LongWord; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
73 |
TrainingTimeInc : Longword; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
74 |
TrainingTimeInD : Longword; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
75 |
TrainingTimeInM : Longword; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
76 |
TrainingTimeMax : Longword; |
2666 | 77 |
|
2947 | 78 |
TimeTrialStartTime: Longword; |
79 |
TimeTrialStopTime : Longword; |
|
80 |
||
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
81 |
recordFileName : shortstring; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
82 |
cShowFPS : boolean; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
83 |
cCaseFactor : Longword; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
84 |
cLandAdditions : Longword; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
85 |
cExplosives : Longword; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
86 |
cFullScreen : boolean; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
87 |
cReducedQuality : boolean; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
88 |
cLocaleFName : shortstring; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
89 |
cSeed : shortstring; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
90 |
cInitVolume : LongInt; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
91 |
cVolumeDelta : LongInt; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
92 |
cTimerInterval : Longword; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
93 |
cHasFocus : boolean; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
94 |
cInactDelay : Longword; |
4 | 95 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
96 |
bBetweenTurns : boolean; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
97 |
cHealthDecrease : LongWord; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
98 |
bWaterRising : Boolean; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
539
diff
changeset
|
99 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
100 |
ShowCrosshair : boolean; |
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
|
101 |
CursorMovementX : LongInt; |
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
|
102 |
CursorMovementY : LongInt; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
103 |
cDrownSpeed : hwFloat; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
104 |
cMaxWindSpeed : hwFloat; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
105 |
cWindSpeed : hwFloat; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
106 |
cGravity : hwFloat; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
107 |
cDamageModifier : hwFloat; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
108 |
cLaserSighting : boolean; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
109 |
cVampiric : boolean; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
110 |
cArtillery : boolean; |
2947 | 111 |
WeaponTooltipTex : PTexture; |
112 |
cWeaponTooltips: boolean; |
|
4 | 113 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
114 |
flagMakeCapture : boolean; |
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
53
diff
changeset
|
115 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
116 |
InitStepsFlags : Longword; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
117 |
RealTicks : Longword; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
118 |
AttackBar : LongInt; |
836 | 119 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
120 |
WaterColorArray : array[0..3] of HwColor4f; |
4 | 121 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
122 |
CursorPoint : TPoint; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
123 |
TargetPoint : TPoint; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
124 |
|
2715
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
125 |
TextureList : PTexture; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
126 |
|
3107 | 127 |
ScreenFade : TScreenFade; |
3115 | 128 |
ScreenFadeValue : LongInt; |
129 |
ScreenFadeSpeed : LongInt; |
|
3107 | 130 |
|
2630 | 131 |
|
3038 | 132 |
procedure initModule; |
133 |
procedure freeModule; |
|
2747 | 134 |
procedure SplitBySpace(var a, b: shortstring); |
2905 | 135 |
procedure SplitByChar(var a, b: ansistring; c: char); |
3337 | 136 |
function EnumToStr(const en : TGearType) : shortstring; overload; |
137 |
function EnumToStr(const en : TSound) : shortstring; overload; |
|
138 |
function EnumToStr(const en : TAmmoType) : 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
|
139 |
procedure movecursor(dx, dy: LongInt); |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
140 |
function hwSign(r: hwFloat): LongInt; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
141 |
function Min(a, b: LongInt): LongInt; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
142 |
function Max(a, b: LongInt): LongInt; |
2905 | 143 |
procedure OutError(Msg: shortstring; isFatalError: boolean); |
144 |
procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); |
|
4 | 145 |
procedure SDLTry(Assert: boolean; isFatal: boolean); |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
146 |
function IntToStr(n: LongInt): shortstring; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
147 |
function FloatToStr(n: hwFloat): shortstring; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
148 |
function DxDy2Angle(const _dY, _dX: hwFloat): GLfloat; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
149 |
function DxDy2Angle32(const _dY, _dX: hwFloat): LongInt; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
150 |
function DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt; |
4 | 151 |
procedure AdjustColor(var Color: Longword); |
208 | 152 |
procedure SetKB(n: Longword); |
153 |
procedure SendKB; |
|
351 | 154 |
procedure SetLittle(var r: hwFloat); |
306 | 155 |
procedure SendStat(sit: TStatInfoType; s: shortstring); |
753 | 156 |
function Str2PChar(const s: shortstring): PChar; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
157 |
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
|
158 |
function Surface2Tex(surf: PSDL_Surface; enableClamp: boolean): PTexture; |
759 | 159 |
procedure FreeTexture(tex: PTexture); |
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
916
diff
changeset
|
160 |
function toPowerOf2(i: Longword): Longword; |
2670 | 161 |
function DecodeBase64(s: shortstring): shortstring; |
162 |
function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface; |
|
163 |
function endian(independent: LongWord): LongWord; |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
164 |
{$IFDEF DEBUGFILE} |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
165 |
procedure AddFileLog(s: shortstring); |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
166 |
function RectToStr(Rect: TSDL_Rect): shortstring; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
167 |
{$ENDIF} |
2163
12730f5e79b9
koda's patch fixing some iphone port troubles (color, mouse)
unc0rr
parents:
2162
diff
changeset
|
168 |
{$IFNDEF IPHONEOS} |
2735 | 169 |
procedure MakeScreenshot(filename: shortstring); |
2163
12730f5e79b9
koda's patch fixing some iphone port troubles (color, mouse)
unc0rr
parents:
2162
diff
changeset
|
170 |
{$ENDIF} |
4 | 171 |
|
172 |
implementation |
|
3533
03892fb97ab3
fix build and permissions problems when launching hwengine from command line
koda
parents:
3513
diff
changeset
|
173 |
uses Math, uConsole, uStore, uIO, uSound, typinfo, sysutils; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
174 |
|
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
175 |
var KBnum: Longword; |
4 | 176 |
{$IFDEF DEBUGFILE} |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
177 |
f: textfile; |
4 | 178 |
{$ENDIF} |
179 |
||
2747 | 180 |
// should this include "strtolower()" for the split string? |
181 |
procedure SplitBySpace(var a, b: shortstring); |
|
182 |
var i, t: LongInt; |
|
183 |
begin |
|
184 |
i:= Pos(' ', a); |
|
185 |
if i > 0 then |
|
2947 | 186 |
begin |
187 |
for t:= 1 to Pred(i) do |
|
188 |
if (a[t] >= 'A')and(a[t] <= 'Z') then Inc(a[t], 32); |
|
189 |
b:= copy(a, i + 1, Length(a) - i); |
|
190 |
byte(a[0]):= Pred(i) |
|
191 |
end else b:= ''; |
|
2747 | 192 |
end; |
193 |
||
2905 | 194 |
procedure SplitByChar(var a, b: ansistring; c: char); |
2747 | 195 |
var i: LongInt; |
196 |
begin |
|
197 |
i:= Pos(c, a); |
|
198 |
if i > 0 then |
|
2947 | 199 |
begin |
200 |
b:= copy(a, i + 1, Length(a) - i); |
|
201 |
setlength(a, Pred(i)); |
|
202 |
end else b:= ''; |
|
2747 | 203 |
end; |
204 |
||
3337 | 205 |
function EnumToStr(const en : TGearType) : shortstring; overload; |
206 |
begin |
|
207 |
EnumToStr:= GetEnumName(TypeInfo(TGearType), ord(en)) |
|
208 |
end; |
|
209 |
||
210 |
function EnumToStr(const en : TSound) : shortstring; overload; |
|
211 |
begin |
|
212 |
EnumToStr:= GetEnumName(TypeInfo(TSound), ord(en)) |
|
213 |
end; |
|
214 |
||
215 |
function EnumToStr(const en : TAmmoType) : shortstring; overload; |
|
216 |
begin |
|
217 |
EnumToStr:= GetEnumName(TypeInfo(TAmmoType), ord(en)) |
|
218 |
end; |
|
219 |
||
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
|
220 |
procedure movecursor(dx, dy: LongInt); |
2428 | 221 |
var x, y: LongInt; |
222 |
begin |
|
223 |
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
|
224 |
|
2428 | 225 |
SDL_GetMouseState(@x, @y); |
226 |
Inc(x, dx); |
|
227 |
Inc(y, dy); |
|
228 |
SDL_WarpMouse(x, y); |
|
229 |
end; |
|
230 |
||
371 | 231 |
function hwSign(r: hwFloat): LongInt; |
4 | 232 |
begin |
2389 | 233 |
// yes, we have negative zero for a reason |
234 |
if r.isNegative then hwSign:= -1 else hwSign:= 1 |
|
4 | 235 |
end; |
236 |
||
371 | 237 |
function Min(a, b: LongInt): LongInt; |
4 | 238 |
begin |
351 | 239 |
if a < b then Min:= a else Min:= b |
4 | 240 |
end; |
241 |
||
371 | 242 |
function Max(a, b: LongInt): LongInt; |
4 | 243 |
begin |
351 | 244 |
if a > b then Max:= a else Max:= b |
4 | 245 |
end; |
246 |
||
2905 | 247 |
procedure OutError(Msg: shortstring; isFatalError: boolean); |
4 | 248 |
begin |
3407 | 249 |
// obsolete? written in WriteLnToConsole() anyway |
250 |
// {$IFDEF DEBUGFILE}AddFileLog(Msg);{$ENDIF} |
|
53 | 251 |
WriteLnToConsole(Msg); |
4 | 252 |
if isFatalError then |
3407 | 253 |
begin |
254 |
SendIPC('E' + GetLastConsoleLine); |
|
255 |
SDL_Quit; |
|
256 |
halt(1) |
|
257 |
end |
|
4 | 258 |
end; |
259 |
||
2905 | 260 |
procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); |
4 | 261 |
begin |
70 | 262 |
if not Assert then OutError(Msg, isFatal) |
4 | 263 |
end; |
264 |
||
265 |
procedure SDLTry(Assert: boolean; isFatal: boolean); |
|
266 |
begin |
|
267 |
if not Assert then OutError(SDL_GetError, isFatal) |
|
268 |
end; |
|
269 |
||
188 | 270 |
procedure AdjustColor(var Color: Longword); |
4 | 271 |
begin |
272 |
Color:= SDL_MapRGB(PixelFormat, (Color shr 16) and $FF, (Color shr 8) and $FF, Color and $FF) |
|
273 |
end; |
|
274 |
||
316 | 275 |
function IntToStr(n: LongInt): shortstring; |
4 | 276 |
begin |
351 | 277 |
str(n, IntToStr) |
4 | 278 |
end; |
279 |
||
351 | 280 |
function FloatToStr(n: hwFloat): shortstring; |
4 | 281 |
begin |
1346 | 282 |
FloatToStr:= cstr(n) + '_' + inttostr(Lo(n.QWordValue)) |
4 | 283 |
end; |
284 |
||
2447
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
285 |
procedure SetTextureParameters(enableClamp: Boolean); |
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
286 |
begin |
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
287 |
if enableClamp and not cReducedQuality then |
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
288 |
begin |
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
289 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
290 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) |
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
291 |
end; |
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
292 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
293 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) |
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
294 |
end; |
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
295 |
|
775 | 296 |
function DxDy2Angle(const _dY, _dX: hwFloat): GLfloat; |
297 |
var dY, dX: Extended; |
|
298 |
begin |
|
299 |
dY:= _dY.QWordValue / $100000000; |
|
300 |
if _dY.isNegative then dY:= - dY; |
|
301 |
dX:= _dX.QWordValue / $100000000; |
|
302 |
if _dX.isNegative then dX:= - dX; |
|
303 |
DxDy2Angle:= arctan2(dY, dX) * 180 / pi |
|
304 |
end; |
|
305 |
||
371 | 306 |
function DxDy2Angle32(const _dY, _dX: hwFloat): LongInt; |
100 | 307 |
const _16divPI: Extended = 16/pi; |
370
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
308 |
var dY, dX: Extended; |
100 | 309 |
begin |
370
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
310 |
dY:= _dY.QWordValue / $100000000; |
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
311 |
if _dY.isNegative then dY:= - dY; |
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
312 |
dX:= _dX.QWordValue / $100000000; |
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
313 |
if _dX.isNegative then dX:= - dX; |
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
314 |
DxDy2Angle32:= trunc(arctan2(dY, dX) * _16divPI) and $1f |
4 | 315 |
end; |
316 |
||
371 | 317 |
function DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt; |
100 | 318 |
const MaxAngleDivPI: Extended = cMaxAngle/pi; |
370
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
319 |
var dY, dX: Extended; |
100 | 320 |
begin |
370
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
321 |
dY:= _dY.QWordValue / $100000000; |
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
322 |
if _dY.isNegative then dY:= - dY; |
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
323 |
dX:= _dX.QWordValue / $100000000; |
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
351
diff
changeset
|
324 |
if _dX.isNegative then dX:= - dX; |
438 | 325 |
DxDy2AttackAngle:= trunc(arctan2(dY, dX) * MaxAngleDivPI) |
100 | 326 |
end; |
4 | 327 |
|
208 | 328 |
procedure SetKB(n: Longword); |
329 |
begin |
|
330 |
KBnum:= n |
|
331 |
end; |
|
332 |
||
333 |
procedure SendKB; |
|
334 |
var s: shortstring; |
|
335 |
begin |
|
336 |
if KBnum <> 0 then |
|
2947 | 337 |
begin |
338 |
s:= 'K' + inttostr(KBnum); |
|
339 |
SendIPCRaw(@s, Length(s) + 1) |
|
340 |
end |
|
208 | 341 |
end; |
342 |
||
351 | 343 |
procedure SetLittle(var r: hwFloat); |
300 | 344 |
begin |
553
5478386d935f
- Switch to bazooka (or whatever) after use of some weapon (fixes problem with bots)
unc0rr
parents:
543
diff
changeset
|
345 |
r:= SignAs(cLittle, r) |
300 | 346 |
end; |
347 |
||
337 | 348 |
procedure SendStat(sit: TStatInfoType; s: shortstring); |
3381 | 349 |
const stc: array [TStatInfoType] of char = 'rDkKHT'; |
2382 | 350 |
var buf: shortstring; |
337 | 351 |
begin |
2382 | 352 |
buf:= 'i' + stc[sit] + s; |
353 |
SendIPCRaw(@buf[0], length(buf) + 1) |
|
337 | 354 |
end; |
355 |
||
534 | 356 |
function Str2PChar(const s: shortstring): PChar; |
351 | 357 |
const CharArray: array[byte] of Char = ''; |
358 |
begin |
|
359 |
CharArray:= s; |
|
360 |
CharArray[Length(s)]:= #0; |
|
361 |
Str2PChar:= @CharArray |
|
362 |
end; |
|
363 |
||
771 | 364 |
function isPowerOf2(i: Longword): boolean; |
365 |
begin |
|
366 |
if i = 0 then exit(true); |
|
367 |
while (i and 1) = 0 do i:= i shr 1; |
|
368 |
isPowerOf2:= (i = 1) |
|
369 |
end; |
|
370 |
||
371 |
function toPowerOf2(i: Longword): Longword; |
|
372 |
begin |
|
373 |
toPowerOf2:= 1; |
|
374 |
while (toPowerOf2 < i) do toPowerOf2:= toPowerOf2 shl 1 |
|
375 |
end; |
|
376 |
||
1912
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
377 |
procedure ResetVertexArrays(texture: PTexture); |
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
378 |
begin |
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
379 |
with texture^ do |
2947 | 380 |
begin |
381 |
vb[0].X:= 0; |
|
382 |
vb[0].Y:= 0; |
|
383 |
vb[1].X:= w; |
|
384 |
vb[1].Y:= 0; |
|
385 |
vb[2].X:= w; |
|
386 |
vb[2].Y:= h; |
|
387 |
vb[3].X:= 0; |
|
388 |
vb[3].Y:= h; |
|
1912
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
389 |
|
2947 | 390 |
tb[0].X:= 0; |
391 |
tb[0].Y:= 0; |
|
392 |
tb[1].X:= rx; |
|
393 |
tb[1].Y:= 0; |
|
394 |
tb[2].X:= rx; |
|
395 |
tb[2].Y:= ry; |
|
396 |
tb[3].X:= 0; |
|
397 |
tb[3].Y:= ry |
|
398 |
end; |
|
1912
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
399 |
end; |
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
400 |
|
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
401 |
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
|
402 |
begin |
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
403 |
new(NewTexture); |
2715
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
404 |
NewTexture^.PrevTexture:= nil; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
405 |
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
|
406 |
NewTexture^.Scale:= 1; |
2715
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
407 |
if TextureList <> nil then |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
408 |
begin |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
409 |
TextureList^.PrevTexture:= NewTexture; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
410 |
NewTexture^.NextTexture:= TextureList |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
411 |
end; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
412 |
TextureList:= NewTexture; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
413 |
|
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
414 |
NewTexture^.w:= width; |
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
415 |
NewTexture^.h:= height; |
1896 | 416 |
NewTexture^.rx:= 1.0; |
417 |
NewTexture^.ry:= 1.0; |
|
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
418 |
|
1912
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
419 |
ResetVertexArrays(NewTexture); |
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
420 |
|
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
421 |
glGenTextures(1, @NewTexture^.id); |
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
422 |
|
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
423 |
glBindTexture(GL_TEXTURE_2D, NewTexture^.id); |
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
424 |
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
|
425 |
|
2447
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
426 |
SetTextureParameters(true); |
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
427 |
end; |
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
428 |
|
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
|
429 |
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
|
430 |
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
|
431 |
tmpp: pointer; |
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
432 |
fromP4, toP4: PLongWordArray; |
753 | 433 |
begin |
755 | 434 |
new(Surface2Tex); |
2715
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
435 |
Surface2Tex^.PrevTexture:= nil; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
436 |
Surface2Tex^.NextTexture:= nil; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
437 |
if TextureList <> nil then |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
438 |
begin |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
439 |
TextureList^.PrevTexture:= Surface2Tex; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
440 |
Surface2Tex^.NextTexture:= TextureList |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
441 |
end; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
442 |
TextureList:= Surface2Tex; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
443 |
|
755 | 444 |
Surface2Tex^.w:= surf^.w; |
445 |
Surface2Tex^.h:= surf^.h; |
|
446 |
||
2576
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
447 |
if (surf^.format^.BytesPerPixel <> 4) then |
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
448 |
begin |
2947 | 449 |
TryDo(false, 'Surface2Tex failed, expecting 32 bit surface', true); |
450 |
Surface2Tex^.id:= 0; |
|
451 |
exit |
|
2576
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
452 |
end; |
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
453 |
|
753 | 454 |
|
755 | 455 |
glGenTextures(1, @Surface2Tex^.id); |
753 | 456 |
|
755 | 457 |
glBindTexture(GL_TEXTURE_2D, Surface2Tex^.id); |
753 | 458 |
|
771 | 459 |
if SDL_MustLock(surf) then |
2947 | 460 |
SDLTry(SDL_LockSurface(surf) >= 0, true); |
771 | 461 |
|
2428 | 462 |
if (not SupportNPOTT) and (not (isPowerOf2(Surf^.w) and isPowerOf2(Surf^.h))) then |
2576
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
463 |
begin |
2947 | 464 |
tw:= toPowerOf2(Surf^.w); |
465 |
th:= toPowerOf2(Surf^.h); |
|
1896 | 466 |
|
2947 | 467 |
Surface2Tex^.rx:= Surf^.w / tw; |
468 |
Surface2Tex^.ry:= Surf^.h / th; |
|
2376 | 469 |
|
2947 | 470 |
GetMem(tmpp, tw * th * surf^.format^.BytesPerPixel); |
1896 | 471 |
|
2947 | 472 |
fromP4:= Surf^.pixels; |
473 |
toP4:= tmpp; |
|
771 | 474 |
|
2947 | 475 |
for y:= 0 to Pred(Surf^.h) do |
476 |
begin |
|
477 |
for x:= 0 to Pred(Surf^.w) do toP4^[x]:= fromP4^[x]; |
|
478 |
for x:= Surf^.w to Pred(tw) do toP4^[x]:= 0; |
|
479 |
toP4:= @(toP4^[tw]); |
|
480 |
fromP4:= @(fromP4^[Surf^.pitch div 4]); |
|
481 |
end; |
|
1896 | 482 |
|
2947 | 483 |
for y:= Surf^.h to Pred(th) do |
484 |
begin |
|
485 |
for x:= 0 to Pred(tw) do toP4^[x]:= 0; |
|
486 |
toP4:= @(toP4^[tw]); |
|
487 |
end; |
|
771 | 488 |
|
2947 | 489 |
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tw, th, 0, GL_RGBA, GL_UNSIGNED_BYTE, tmpp); |
2376 | 490 |
|
2947 | 491 |
FreeMem(tmpp, tw * th * surf^.format^.BytesPerPixel) |
2576
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
492 |
end |
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
493 |
else |
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
494 |
begin |
2947 | 495 |
Surface2Tex^.rx:= 1.0; |
496 |
Surface2Tex^.ry:= 1.0; |
|
497 |
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surf^.w, surf^.h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surf^.pixels); |
|
2576
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
498 |
end; |
753 | 499 |
|
1912
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
500 |
ResetVertexArrays(Surface2Tex); |
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
501 |
|
754 | 502 |
if SDL_MustLock(surf) then |
2947 | 503 |
SDL_UnlockSurface(surf); |
754 | 504 |
|
2447
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
505 |
SetTextureParameters(enableClamp); |
753 | 506 |
end; |
507 |
||
759 | 508 |
procedure FreeTexture(tex: PTexture); |
509 |
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
|
510 |
if tex <> nil then |
2947 | 511 |
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
|
512 |
if tex^.NextTexture <> nil then |
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
|
513 |
tex^.NextTexture^.PrevTexture:= tex^.PrevTexture; |
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
|
514 |
if tex^.PrevTexture <> nil then |
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
|
515 |
tex^.PrevTexture^.NextTexture:= 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
|
516 |
else |
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
|
517 |
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
|
518 |
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
|
519 |
Dispose(tex); |
2947 | 520 |
end |
759 | 521 |
end; |
337 | 522 |
|
949 | 523 |
function DecodeBase64(s: shortstring): shortstring; |
524 |
const table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; |
|
525 |
var i, t, c: Longword; |
|
526 |
begin |
|
527 |
c:= 0; |
|
528 |
for i:= 1 to Length(s) do |
|
2947 | 529 |
begin |
530 |
t:= Pos(s[i], table); |
|
531 |
if s[i] = '=' then inc(c); |
|
532 |
if t > 0 then byte(s[i]):= t - 1 else byte(s[i]):= 0 |
|
533 |
end; |
|
949 | 534 |
|
535 |
i:= 1; |
|
536 |
t:= 1; |
|
537 |
while i <= length(s) do |
|
2947 | 538 |
begin |
539 |
DecodeBase64[t ]:= char((byte(s[i ]) shl 2) or (byte(s[i + 1]) shr 4)); |
|
540 |
DecodeBase64[t + 1]:= char((byte(s[i + 1]) shl 4) or (byte(s[i + 2]) shr 2)); |
|
541 |
DecodeBase64[t + 2]:= char((byte(s[i + 2]) shl 6) or (byte(s[i + 3]) )); |
|
542 |
inc(t, 3); |
|
543 |
inc(i, 4) |
|
544 |
end; |
|
949 | 545 |
|
546 |
if c < 3 then t:= t - c; |
|
547 |
||
548 |
byte(DecodeBase64[0]):= t - 1 |
|
549 |
end; |
|
550 |
||
2163
12730f5e79b9
koda's patch fixing some iphone port troubles (color, mouse)
unc0rr
parents:
2162
diff
changeset
|
551 |
{$IFNDEF IPHONEOS} |
2735 | 552 |
procedure MakeScreenshot(filename: shortstring); |
1080 | 553 |
var p: Pointer; |
2947 | 554 |
size: Longword; |
555 |
f: file; |
|
2735 | 556 |
{$IFNDEF WIN32} |
2947 | 557 |
// TGA Header |
558 |
head: array[0..8] of Word = (0, 2, 0, 0, 0, 0, 0, 0, 24); |
|
2735 | 559 |
{$ELSE} |
2947 | 560 |
// Windows Bitmap Header |
561 |
head: array[0..53] of Byte = ( |
|
562 |
$42, $4D, // identifier ("BM") |
|
563 |
0, 0, 0, 0, // file size |
|
564 |
0, 0, 0, 0, // reserved |
|
565 |
54, 0, 0, 0, // starting offset |
|
566 |
40, 0, 0, 0, // header size |
|
567 |
0, 0, 0, 0, // width |
|
568 |
0, 0, 0, 0, // height |
|
569 |
1, 0, // color planes |
|
570 |
24, 0, // bit depth |
|
571 |
0, 0, 0, 0, // compression method (uncompressed) |
|
572 |
0, 0, 0, 0, // image size |
|
573 |
96, 0, 0, 0, // horizontal resolution |
|
574 |
96, 0, 0, 0, // vertical resolution |
|
575 |
0, 0, 0, 0, // number of colors (all) |
|
576 |
0, 0, 0, 0 // number of important colors |
|
577 |
); |
|
2735 | 578 |
{$ENDIF} |
1080 | 579 |
begin |
2745 | 580 |
playSound(sndShutter); |
1080 | 581 |
|
3107 | 582 |
// flash |
583 |
ScreenFade:= sfFromWhite; |
|
584 |
ScreenFadeValue:= sfMax; |
|
585 |
ScreenFadeSpeed:= 5; |
|
586 |
||
1080 | 587 |
size:= cScreenWidth * cScreenHeight * 3; |
588 |
p:= GetMem(size); |
|
589 |
||
2735 | 590 |
// update header information and file name |
591 |
{$IFNDEF WIN32} |
|
3350 | 592 |
filename:= ParamStr(1) + '/Screenshots/' + filename + '.tga'; |
2735 | 593 |
|
594 |
head[6]:= cScreenWidth; |
|
595 |
head[7]:= cScreenHeight; |
|
596 |
{$ELSE} |
|
3350 | 597 |
filename:= ParamStr(1) + '/Screenshots/' + filename + '.bmp'; |
2735 | 598 |
|
599 |
head[$02]:= (size + 54) and $ff; |
|
600 |
head[$03]:= ((size + 54) shr 8) and $ff; |
|
601 |
head[$04]:= ((size + 54) shr 16) and $ff; |
|
602 |
head[$05]:= ((size + 54) shr 24) and $ff; |
|
603 |
head[$12]:= cScreenWidth and $ff; |
|
604 |
head[$13]:= (cScreenWidth shr 8) and $ff; |
|
605 |
head[$14]:= (cScreenWidth shr 16) and $ff; |
|
606 |
head[$15]:= (cScreenWidth shr 24) and $ff; |
|
607 |
head[$16]:= cScreenHeight and $ff; |
|
608 |
head[$17]:= (cScreenHeight shr 8) and $ff; |
|
609 |
head[$18]:= (cScreenHeight shr 16) and $ff; |
|
610 |
head[$19]:= (cScreenHeight shr 24) and $ff; |
|
611 |
head[$22]:= size and $ff; |
|
612 |
head[$23]:= (size shr 8) and $ff; |
|
613 |
head[$24]:= (size shr 16) and $ff; |
|
614 |
head[$25]:= (size shr 24) and $ff; |
|
615 |
{$ENDIF} |
|
2163
12730f5e79b9
koda's patch fixing some iphone port troubles (color, mouse)
unc0rr
parents:
2162
diff
changeset
|
616 |
|
12730f5e79b9
koda's patch fixing some iphone port troubles (color, mouse)
unc0rr
parents:
2162
diff
changeset
|
617 |
//remember that opengles operates on a single surface, so GL_FRONT *should* be implied |
1080 | 618 |
glReadBuffer(GL_FRONT); |
619 |
glReadPixels(0, 0, cScreenWidth, cScreenHeight, GL_BGR, GL_UNSIGNED_BYTE, p); |
|
620 |
||
621 |
{$I-} |
|
2735 | 622 |
Assign(f, filename); |
1080 | 623 |
Rewrite(f, 1); |
624 |
if IOResult = 0 then |
|
2947 | 625 |
begin |
626 |
BlockWrite(f, head, sizeof(head)); |
|
627 |
BlockWrite(f, p^, size); |
|
628 |
Close(f); |
|
629 |
end; |
|
1080 | 630 |
{$I+} |
631 |
||
632 |
FreeMem(p) |
|
633 |
end; |
|
2163
12730f5e79b9
koda's patch fixing some iphone port troubles (color, mouse)
unc0rr
parents:
2162
diff
changeset
|
634 |
{$ENDIF} |
1080 | 635 |
|
949 | 636 |
{$IFDEF DEBUGFILE} |
637 |
procedure AddFileLog(s: shortstring); |
|
638 |
begin |
|
639 |
writeln(f, GameTicks: 6, ': ', s); |
|
640 |
flush(f) |
|
641 |
end; |
|
642 |
||
643 |
function RectToStr(Rect: TSDL_Rect): shortstring; |
|
644 |
begin |
|
645 |
RectToStr:= '(x: ' + inttostr(rect.x) + '; y: ' + inttostr(rect.y) + '; w: ' + inttostr(rect.w) + '; h: ' + inttostr(rect.h) + ')' |
|
646 |
end; |
|
2242 | 647 |
{$ENDIF} |
306 | 648 |
|
2619 | 649 |
function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface; |
650 |
{* for more information http://www.idevgames.com/forum/showpost.php?p=85864&postcount=7 *} |
|
651 |
var convertedSurf: PSDL_Surface = nil; |
|
652 |
begin |
|
2947 | 653 |
if (tmpsurf^.format^.bitsperpixel = 24) or ((tmpsurf^.format^.bitsperpixel = 32) and (tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) then |
654 |
begin |
|
655 |
convertedSurf:= SDL_ConvertSurface(tmpsurf, @conversionFormat, SDL_SWSURFACE); |
|
656 |
SDL_FreeSurface(tmpsurf); |
|
657 |
exit(convertedSurf); |
|
658 |
end; |
|
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
659 |
|
2947 | 660 |
exit(tmpsurf); |
2619 | 661 |
end; |
662 |
||
2670 | 663 |
function endian(independent: LongWord): LongWord; |
664 |
begin |
|
665 |
{$IFDEF ENDIAN_LITTLE} |
|
666 |
endian:= independent; |
|
667 |
{$ELSE} |
|
668 |
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
|
669 |
((independent and $00FF0000) shr 8) or |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3355
diff
changeset
|
670 |
((independent and $0000FF00) shl 8) or |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3355
diff
changeset
|
671 |
((independent and $000000FF) shl 24)) |
2670 | 672 |
{$ENDIF} |
673 |
end; |
|
2630 | 674 |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
675 |
|
3038 | 676 |
procedure initModule; |
3305 | 677 |
{$IFDEF DEBUGFILE}{$IFNDEF IPHONEOS}var i: LongInt;{$ENDIF}{$ENDIF} |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
678 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
679 |
cDrownSpeed.QWordValue := 257698038; // 0.06 |
3355
dc9e61e67484
cWindSpeed recalculation assumed GetRandom returns a value between 0.0-1.0 while in fact is in the 0.0-0.5 range; Halve cMaxWindSpeed to compensate.
palewolf
parents:
3350
diff
changeset
|
680 |
cMaxWindSpeed.QWordValue:= 1073742; // 0.00025 |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
681 |
cWindSpeed.QWordValue := 429496; // 0.0001 |
3355
dc9e61e67484
cWindSpeed recalculation assumed GetRandom returns a value between 0.0-1.0 while in fact is in the 0.0-0.5 range; Halve cMaxWindSpeed to compensate.
palewolf
parents:
3350
diff
changeset
|
682 |
cGravity := cMaxWindSpeed * 2; |
2947 | 683 |
cDamageModifier := _1; |
684 |
TargetPoint := cTargetPointRef; |
|
685 |
TextureList := nil; |
|
686 |
||
687 |
// int, longint longword and byte |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
688 |
CursorMovementX := 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
689 |
CursorMovementY := 0; |
3066
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
690 |
GameTicks := 0; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
691 |
TrainingTimeInc := 10000; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
692 |
TrainingTimeInD := 500; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
693 |
TrainingTimeInM := 5000; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
694 |
TrainingTimeMax := 60000; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
695 |
TimeTrialStartTime := 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
696 |
TimeTrialStopTime := 0; |
3066
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
697 |
cWaterLine := LAND_HEIGHT; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
698 |
cGearScrEdgesDist := 240; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
699 |
cHealthDecrease := 0; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
700 |
|
3066
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
701 |
GameFlags := 0; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
702 |
TrainingFlags := 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
703 |
TurnTimeLeft := 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
704 |
cSuddenDTurns := 15; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
705 |
cDamagePercent := 100; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
706 |
cMineDudPercent := 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
707 |
cTemplateFilter := 0; |
3133 | 708 |
cMapGen := 0;//MAPGEN_REGULAR |
709 |
cMazeSize := 0; |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
710 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
711 |
cHedgehogTurnTime := 45000; |
3066
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
712 |
cMinesTime := 3000; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
713 |
cMaxAIThinkTime := 9000; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
714 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
715 |
cCloudsNumber := 9; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
716 |
cScreenWidth := 1024; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
717 |
cScreenHeight := 768; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
718 |
cInitWidth := cScreenWidth; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
719 |
cInitHeight := cScreenHeight; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
720 |
cBits := 32; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
721 |
cTagsMask := 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
722 |
KBnum := 0; |
3066
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
723 |
InitStepsFlags := 0; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
724 |
RealTicks := 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
725 |
AttackBar := 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP |
2947 | 726 |
|
727 |
// tgametype and glfloat and string |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
728 |
GameState := Low(TGameState); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
729 |
GameType := gmtLocal; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
730 |
zoom := 2.0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
731 |
ZoomValue := 2.0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
732 |
cBitsStr := '32'; |
3066
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
733 |
WeaponTooltipTex:= nil; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
734 |
|
2947 | 735 |
// booleans |
3066
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
736 |
cLaserSighting := false; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
737 |
cVampiric := false; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
738 |
cArtillery := false; |
3066
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
739 |
flagMakeCapture := false; |
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
740 |
bBetweenTurns := false; |
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
741 |
bWaterRising := false; |
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
742 |
isCursorVisible := false; |
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
743 |
isTerminated := false; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
744 |
isInLag := false; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
745 |
isPaused := false; |
3066
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
746 |
isMusicEnabled := false; |
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
747 |
isInMultiShoot := false; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
748 |
isSpeed := false; |
3066
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
749 |
fastUntilLag := false; |
3107 | 750 |
isFirstFrame := true; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
751 |
cVSyncInUse := true; |
3066
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
752 |
isSoundEnabled := true; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
753 |
isSEBackup := true; |
2947 | 754 |
|
755 |
// init flags |
|
3066
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
756 |
recordFileName := ''; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
757 |
cShowFPS := false; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
758 |
cCaseFactor := 5; {0..9} |
3066
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
759 |
cLandAdditions := 4; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
760 |
cExplosives := 2; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
761 |
cFullScreen := false; |
3066
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
762 |
cReducedQuality := false; |
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
763 |
cLocaleFName := 'en.txt'; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
764 |
cSeed := ''; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
765 |
cInitVolume := 50; |
3066
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
766 |
cVolumeDelta := 0; |
5c0efa437728
Enable birdy. Has egg bombing. Eggs should possibly have a dX component. No poison yet, no egg sprite.
nemo
parents:
3038
diff
changeset
|
767 |
cTimerInterval := 8; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
768 |
cHasFocus := true; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
769 |
cInactDelay := 1250; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
770 |
cAltDamage := true; |
3107 | 771 |
|
772 |
ScreenFade := sfNone; |
|
488 | 773 |
{$IFDEF DEBUGFILE} |
337 | 774 |
{$I-} |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
775 |
{$IFDEF IPHONEOS} |
3377 | 776 |
Assign(f,'../Documents/debug.txt'); |
777 |
Rewrite(f); |
|
2630 | 778 |
{$ELSE} |
3533
03892fb97ab3
fix build and permissions problems when launching hwengine from command line
koda
parents:
3513
diff
changeset
|
779 |
if (ParamStr(1) <> '') and (ParamStr(2) <> '') then |
3534 | 780 |
if (ParamCount <> 3) and (ParamCount <> 18) then |
2947 | 781 |
begin |
3534 | 782 |
for i:= 0 to 7 do |
783 |
begin |
|
784 |
assign(f, ExtractFileDir(ParamStr(2)) + '/debug' + inttostr(i) + '.txt'); |
|
785 |
rewrite(f); |
|
786 |
if IOResult = 0 then break; |
|
787 |
end; |
|
788 |
if IOResult <> 0 then f:= stderr; // if everything fails, write to stderr |
|
789 |
end |
|
790 |
else |
|
791 |
begin |
|
792 |
for i:= 0 to 7 do |
|
793 |
begin |
|
794 |
assign(f, ParamStr(1) + '/debug' + inttostr(i) + '.txt'); |
|
795 |
rewrite(f); |
|
796 |
if IOResult = 0 then break; |
|
797 |
end; |
|
798 |
if IOResult <> 0 then f:= stderr; // if everything fails, write to stderr |
|
2947 | 799 |
end |
800 |
else |
|
801 |
f:= stderr; |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
802 |
{$ENDIF} |
337 | 803 |
{$I+} |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
804 |
{$ENDIF} |
17 | 805 |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
806 |
end; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
807 |
|
3038 | 808 |
procedure freeModule; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
809 |
begin |
2947 | 810 |
//uRandom.DumpBuffer; |
811 |
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
|
812 |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
813 |
{$IFDEF DEBUGFILE} |
2947 | 814 |
writeln(f, 'halt at ', GameTicks, ' ticks. TurnTimeLeft = ', TurnTimeLeft); |
815 |
flush(f); |
|
816 |
close(f); |
|
4 | 817 |
{$ENDIF} |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
818 |
end; |
4 | 819 |
|
820 |
end. |