author | koda |
Tue, 22 Jun 2010 17:10:27 +0200 | |
changeset 3533 | 03892fb97ab3 |
parent 3513 | f589230fa21b |
child 3534 | 51521238724f |
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; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
406 |
if TextureList <> nil then |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
407 |
begin |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
408 |
TextureList^.PrevTexture:= NewTexture; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
409 |
NewTexture^.NextTexture:= TextureList |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
410 |
end; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
411 |
TextureList:= NewTexture; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
412 |
|
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
413 |
NewTexture^.w:= width; |
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
414 |
NewTexture^.h:= height; |
1896 | 415 |
NewTexture^.rx:= 1.0; |
416 |
NewTexture^.ry:= 1.0; |
|
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
417 |
|
1912
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
418 |
ResetVertexArrays(NewTexture); |
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
419 |
|
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
420 |
glGenTextures(1, @NewTexture^.id); |
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
421 |
|
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
422 |
glBindTexture(GL_TEXTURE_2D, NewTexture^.id); |
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
423 |
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
|
424 |
|
2447
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
425 |
SetTextureParameters(true); |
1180
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
426 |
end; |
e56317fdf78d
Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents:
1128
diff
changeset
|
427 |
|
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
|
428 |
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
|
429 |
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
|
430 |
tmpp: pointer; |
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
431 |
fromP4, toP4: PLongWordArray; |
753 | 432 |
begin |
755 | 433 |
new(Surface2Tex); |
2715
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
434 |
Surface2Tex^.PrevTexture:= nil; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
435 |
Surface2Tex^.NextTexture:= nil; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
436 |
if TextureList <> nil then |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
437 |
begin |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
438 |
TextureList^.PrevTexture:= Surface2Tex; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
439 |
Surface2Tex^.NextTexture:= TextureList |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
440 |
end; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
441 |
TextureList:= Surface2Tex; |
0e4e0db79e2a
Free up some unfreed memory. Needed for Koda's iphone lib work
nemo
parents:
2705
diff
changeset
|
442 |
|
755 | 443 |
Surface2Tex^.w:= surf^.w; |
444 |
Surface2Tex^.h:= surf^.h; |
|
445 |
||
2576
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
446 |
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
|
447 |
begin |
2947 | 448 |
TryDo(false, 'Surface2Tex failed, expecting 32 bit surface', true); |
449 |
Surface2Tex^.id:= 0; |
|
450 |
exit |
|
2576
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
451 |
end; |
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
452 |
|
753 | 453 |
|
755 | 454 |
glGenTextures(1, @Surface2Tex^.id); |
753 | 455 |
|
755 | 456 |
glBindTexture(GL_TEXTURE_2D, Surface2Tex^.id); |
753 | 457 |
|
771 | 458 |
if SDL_MustLock(surf) then |
2947 | 459 |
SDLTry(SDL_LockSurface(surf) >= 0, true); |
771 | 460 |
|
2428 | 461 |
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
|
462 |
begin |
2947 | 463 |
tw:= toPowerOf2(Surf^.w); |
464 |
th:= toPowerOf2(Surf^.h); |
|
1896 | 465 |
|
2947 | 466 |
Surface2Tex^.rx:= Surf^.w / tw; |
467 |
Surface2Tex^.ry:= Surf^.h / th; |
|
2376 | 468 |
|
2947 | 469 |
GetMem(tmpp, tw * th * surf^.format^.BytesPerPixel); |
1896 | 470 |
|
2947 | 471 |
fromP4:= Surf^.pixels; |
472 |
toP4:= tmpp; |
|
771 | 473 |
|
2947 | 474 |
for y:= 0 to Pred(Surf^.h) do |
475 |
begin |
|
476 |
for x:= 0 to Pred(Surf^.w) do toP4^[x]:= fromP4^[x]; |
|
477 |
for x:= Surf^.w to Pred(tw) do toP4^[x]:= 0; |
|
478 |
toP4:= @(toP4^[tw]); |
|
479 |
fromP4:= @(fromP4^[Surf^.pitch div 4]); |
|
480 |
end; |
|
1896 | 481 |
|
2947 | 482 |
for y:= Surf^.h to Pred(th) do |
483 |
begin |
|
484 |
for x:= 0 to Pred(tw) do toP4^[x]:= 0; |
|
485 |
toP4:= @(toP4^[tw]); |
|
486 |
end; |
|
771 | 487 |
|
2947 | 488 |
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tw, th, 0, GL_RGBA, GL_UNSIGNED_BYTE, tmpp); |
2376 | 489 |
|
2947 | 490 |
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
|
491 |
end |
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
492 |
else |
2eb7ce1c1f19
code cleanup for Surface2Tex (we don't have 3 bytes surfaces any more)
koda
parents:
2575
diff
changeset
|
493 |
begin |
2947 | 494 |
Surface2Tex^.rx:= 1.0; |
495 |
Surface2Tex^.ry:= 1.0; |
|
496 |
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
|
497 |
end; |
753 | 498 |
|
1912
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
499 |
ResetVertexArrays(Surface2Tex); |
c3d31fb59f0e
Save much CPU time by initializing vertex arrays in texture creation function
unc0rr
parents:
1911
diff
changeset
|
500 |
|
754 | 501 |
if SDL_MustLock(surf) then |
2947 | 502 |
SDL_UnlockSurface(surf); |
754 | 503 |
|
2447
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2428
diff
changeset
|
504 |
SetTextureParameters(enableClamp); |
753 | 505 |
end; |
506 |
||
759 | 507 |
procedure FreeTexture(tex: PTexture); |
508 |
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
|
509 |
if tex <> nil then |
2947 | 510 |
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
|
511 |
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
|
512 |
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
|
513 |
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
|
514 |
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
|
515 |
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
|
516 |
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
|
517 |
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
|
518 |
Dispose(tex); |
2947 | 519 |
end |
759 | 520 |
end; |
337 | 521 |
|
949 | 522 |
function DecodeBase64(s: shortstring): shortstring; |
523 |
const table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; |
|
524 |
var i, t, c: Longword; |
|
525 |
begin |
|
526 |
c:= 0; |
|
527 |
for i:= 1 to Length(s) do |
|
2947 | 528 |
begin |
529 |
t:= Pos(s[i], table); |
|
530 |
if s[i] = '=' then inc(c); |
|
531 |
if t > 0 then byte(s[i]):= t - 1 else byte(s[i]):= 0 |
|
532 |
end; |
|
949 | 533 |
|
534 |
i:= 1; |
|
535 |
t:= 1; |
|
536 |
while i <= length(s) do |
|
2947 | 537 |
begin |
538 |
DecodeBase64[t ]:= char((byte(s[i ]) shl 2) or (byte(s[i + 1]) shr 4)); |
|
539 |
DecodeBase64[t + 1]:= char((byte(s[i + 1]) shl 4) or (byte(s[i + 2]) shr 2)); |
|
540 |
DecodeBase64[t + 2]:= char((byte(s[i + 2]) shl 6) or (byte(s[i + 3]) )); |
|
541 |
inc(t, 3); |
|
542 |
inc(i, 4) |
|
543 |
end; |
|
949 | 544 |
|
545 |
if c < 3 then t:= t - c; |
|
546 |
||
547 |
byte(DecodeBase64[0]):= t - 1 |
|
548 |
end; |
|
549 |
||
2163
12730f5e79b9
koda's patch fixing some iphone port troubles (color, mouse)
unc0rr
parents:
2162
diff
changeset
|
550 |
{$IFNDEF IPHONEOS} |
2735 | 551 |
procedure MakeScreenshot(filename: shortstring); |
1080 | 552 |
var p: Pointer; |
2947 | 553 |
size: Longword; |
554 |
f: file; |
|
2735 | 555 |
{$IFNDEF WIN32} |
2947 | 556 |
// TGA Header |
557 |
head: array[0..8] of Word = (0, 2, 0, 0, 0, 0, 0, 0, 24); |
|
2735 | 558 |
{$ELSE} |
2947 | 559 |
// Windows Bitmap Header |
560 |
head: array[0..53] of Byte = ( |
|
561 |
$42, $4D, // identifier ("BM") |
|
562 |
0, 0, 0, 0, // file size |
|
563 |
0, 0, 0, 0, // reserved |
|
564 |
54, 0, 0, 0, // starting offset |
|
565 |
40, 0, 0, 0, // header size |
|
566 |
0, 0, 0, 0, // width |
|
567 |
0, 0, 0, 0, // height |
|
568 |
1, 0, // color planes |
|
569 |
24, 0, // bit depth |
|
570 |
0, 0, 0, 0, // compression method (uncompressed) |
|
571 |
0, 0, 0, 0, // image size |
|
572 |
96, 0, 0, 0, // horizontal resolution |
|
573 |
96, 0, 0, 0, // vertical resolution |
|
574 |
0, 0, 0, 0, // number of colors (all) |
|
575 |
0, 0, 0, 0 // number of important colors |
|
576 |
); |
|
2735 | 577 |
{$ENDIF} |
1080 | 578 |
begin |
2745 | 579 |
playSound(sndShutter); |
1080 | 580 |
|
3107 | 581 |
// flash |
582 |
ScreenFade:= sfFromWhite; |
|
583 |
ScreenFadeValue:= sfMax; |
|
584 |
ScreenFadeSpeed:= 5; |
|
585 |
||
1080 | 586 |
size:= cScreenWidth * cScreenHeight * 3; |
587 |
p:= GetMem(size); |
|
588 |
||
2735 | 589 |
// update header information and file name |
590 |
{$IFNDEF WIN32} |
|
3350 | 591 |
filename:= ParamStr(1) + '/Screenshots/' + filename + '.tga'; |
2735 | 592 |
|
593 |
head[6]:= cScreenWidth; |
|
594 |
head[7]:= cScreenHeight; |
|
595 |
{$ELSE} |
|
3350 | 596 |
filename:= ParamStr(1) + '/Screenshots/' + filename + '.bmp'; |
2735 | 597 |
|
598 |
head[$02]:= (size + 54) and $ff; |
|
599 |
head[$03]:= ((size + 54) shr 8) and $ff; |
|
600 |
head[$04]:= ((size + 54) shr 16) and $ff; |
|
601 |
head[$05]:= ((size + 54) shr 24) and $ff; |
|
602 |
head[$12]:= cScreenWidth and $ff; |
|
603 |
head[$13]:= (cScreenWidth shr 8) and $ff; |
|
604 |
head[$14]:= (cScreenWidth shr 16) and $ff; |
|
605 |
head[$15]:= (cScreenWidth shr 24) and $ff; |
|
606 |
head[$16]:= cScreenHeight and $ff; |
|
607 |
head[$17]:= (cScreenHeight shr 8) and $ff; |
|
608 |
head[$18]:= (cScreenHeight shr 16) and $ff; |
|
609 |
head[$19]:= (cScreenHeight shr 24) and $ff; |
|
610 |
head[$22]:= size and $ff; |
|
611 |
head[$23]:= (size shr 8) and $ff; |
|
612 |
head[$24]:= (size shr 16) and $ff; |
|
613 |
head[$25]:= (size shr 24) and $ff; |
|
614 |
{$ENDIF} |
|
2163
12730f5e79b9
koda's patch fixing some iphone port troubles (color, mouse)
unc0rr
parents:
2162
diff
changeset
|
615 |
|
12730f5e79b9
koda's patch fixing some iphone port troubles (color, mouse)
unc0rr
parents:
2162
diff
changeset
|
616 |
//remember that opengles operates on a single surface, so GL_FRONT *should* be implied |
1080 | 617 |
glReadBuffer(GL_FRONT); |
618 |
glReadPixels(0, 0, cScreenWidth, cScreenHeight, GL_BGR, GL_UNSIGNED_BYTE, p); |
|
619 |
||
620 |
{$I-} |
|
2735 | 621 |
Assign(f, filename); |
1080 | 622 |
Rewrite(f, 1); |
623 |
if IOResult = 0 then |
|
2947 | 624 |
begin |
625 |
BlockWrite(f, head, sizeof(head)); |
|
626 |
BlockWrite(f, p^, size); |
|
627 |
Close(f); |
|
628 |
end; |
|
1080 | 629 |
{$I+} |
630 |
||
631 |
FreeMem(p) |
|
632 |
end; |
|
2163
12730f5e79b9
koda's patch fixing some iphone port troubles (color, mouse)
unc0rr
parents:
2162
diff
changeset
|
633 |
{$ENDIF} |
1080 | 634 |
|
949 | 635 |
{$IFDEF DEBUGFILE} |
636 |
procedure AddFileLog(s: shortstring); |
|
637 |
begin |
|
638 |
writeln(f, GameTicks: 6, ': ', s); |
|
639 |
flush(f) |
|
640 |
end; |
|
641 |
||
642 |
function RectToStr(Rect: TSDL_Rect): shortstring; |
|
643 |
begin |
|
644 |
RectToStr:= '(x: ' + inttostr(rect.x) + '; y: ' + inttostr(rect.y) + '; w: ' + inttostr(rect.w) + '; h: ' + inttostr(rect.h) + ')' |
|
645 |
end; |
|
2242 | 646 |
{$ENDIF} |
306 | 647 |
|
2619 | 648 |
function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface; |
649 |
{* for more information http://www.idevgames.com/forum/showpost.php?p=85864&postcount=7 *} |
|
650 |
var convertedSurf: PSDL_Surface = nil; |
|
651 |
begin |
|
2947 | 652 |
if (tmpsurf^.format^.bitsperpixel = 24) or ((tmpsurf^.format^.bitsperpixel = 32) and (tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) then |
653 |
begin |
|
654 |
convertedSurf:= SDL_ConvertSurface(tmpsurf, @conversionFormat, SDL_SWSURFACE); |
|
655 |
SDL_FreeSurface(tmpsurf); |
|
656 |
exit(convertedSurf); |
|
657 |
end; |
|
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2699
diff
changeset
|
658 |
|
2947 | 659 |
exit(tmpsurf); |
2619 | 660 |
end; |
661 |
||
2670 | 662 |
function endian(independent: LongWord): LongWord; |
663 |
begin |
|
664 |
{$IFDEF ENDIAN_LITTLE} |
|
665 |
endian:= independent; |
|
666 |
{$ELSE} |
|
667 |
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
|
668 |
((independent and $00FF0000) shr 8) or |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3355
diff
changeset
|
669 |
((independent and $0000FF00) shl 8) or |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3355
diff
changeset
|
670 |
((independent and $000000FF) shl 24)) |
2670 | 671 |
{$ENDIF} |
672 |
end; |
|
2630 | 673 |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
674 |
|
3038 | 675 |
procedure initModule; |
3305 | 676 |
{$IFDEF DEBUGFILE}{$IFNDEF IPHONEOS}var i: LongInt;{$ENDIF}{$ENDIF} |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
677 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
678 |
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
|
679 |
cMaxWindSpeed.QWordValue:= 1073742; // 0.00025 |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
680 |
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
|
681 |
cGravity := cMaxWindSpeed * 2; |
2947 | 682 |
cDamageModifier := _1; |
683 |
TargetPoint := cTargetPointRef; |
|
684 |
TextureList := nil; |
|
685 |
||
686 |
// int, longint longword and byte |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
687 |
CursorMovementX := 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
688 |
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
|
689 |
GameTicks := 0; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
690 |
TrainingTimeInc := 10000; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
691 |
TrainingTimeInD := 500; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
692 |
TrainingTimeInM := 5000; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
693 |
TrainingTimeMax := 60000; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
694 |
TimeTrialStartTime := 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
695 |
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
|
696 |
cWaterLine := LAND_HEIGHT; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
697 |
cGearScrEdgesDist := 240; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
698 |
cHealthDecrease := 0; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
699 |
|
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
|
700 |
GameFlags := 0; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
701 |
TrainingFlags := 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
702 |
TurnTimeLeft := 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
703 |
cSuddenDTurns := 15; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
704 |
cDamagePercent := 100; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
705 |
cMineDudPercent := 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
706 |
cTemplateFilter := 0; |
3133 | 707 |
cMapGen := 0;//MAPGEN_REGULAR |
708 |
cMazeSize := 0; |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
709 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
710 |
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
|
711 |
cMinesTime := 3000; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
712 |
cMaxAIThinkTime := 9000; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
713 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
714 |
cCloudsNumber := 9; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
715 |
cScreenWidth := 1024; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
716 |
cScreenHeight := 768; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
717 |
cInitWidth := cScreenWidth; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
718 |
cInitHeight := cScreenHeight; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
719 |
cBits := 32; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
720 |
cTagsMask := 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
721 |
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
|
722 |
InitStepsFlags := 0; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
723 |
RealTicks := 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
724 |
AttackBar := 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP |
2947 | 725 |
|
726 |
// tgametype and glfloat and string |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
727 |
GameState := Low(TGameState); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
728 |
GameType := gmtLocal; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
729 |
zoom := 2.0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
730 |
ZoomValue := 2.0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
731 |
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
|
732 |
WeaponTooltipTex:= nil; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
733 |
|
2947 | 734 |
// 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
|
735 |
cLaserSighting := false; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
736 |
cVampiric := false; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
737 |
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
|
738 |
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
|
739 |
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
|
740 |
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
|
741 |
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
|
742 |
isTerminated := false; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
743 |
isInLag := false; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
744 |
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
|
745 |
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
|
746 |
isInMultiShoot := false; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
747 |
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
|
748 |
fastUntilLag := false; |
3107 | 749 |
isFirstFrame := true; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
750 |
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
|
751 |
isSoundEnabled := true; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
752 |
isSEBackup := true; |
2947 | 753 |
|
754 |
// 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
|
755 |
recordFileName := ''; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
756 |
cShowFPS := false; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
757 |
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
|
758 |
cLandAdditions := 4; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
759 |
cExplosives := 2; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
760 |
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
|
761 |
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
|
762 |
cLocaleFName := 'en.txt'; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
763 |
cSeed := ''; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
764 |
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
|
765 |
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
|
766 |
cTimerInterval := 8; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
767 |
cHasFocus := true; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
768 |
cInactDelay := 1250; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2947
diff
changeset
|
769 |
cAltDamage := true; |
3107 | 770 |
|
771 |
ScreenFade := sfNone; |
|
488 | 772 |
{$IFDEF DEBUGFILE} |
337 | 773 |
{$I-} |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
774 |
{$IFDEF IPHONEOS} |
3377 | 775 |
Assign(f,'../Documents/debug.txt'); |
776 |
Rewrite(f); |
|
2630 | 777 |
{$ELSE} |
3533
03892fb97ab3
fix build and permissions problems when launching hwengine from command line
koda
parents:
3513
diff
changeset
|
778 |
if (ParamStr(1) <> '') and (ParamStr(2) <> '') then |
2947 | 779 |
begin |
780 |
for i:= 0 to 7 do |
|
781 |
begin |
|
3533
03892fb97ab3
fix build and permissions problems when launching hwengine from command line
koda
parents:
3513
diff
changeset
|
782 |
assign(f, ExtractFileDir(ParamStr(2)) + '/debug' + inttostr(i) + '.txt'); |
2947 | 783 |
rewrite(f); |
784 |
if IOResult = 0 then break; |
|
785 |
end; |
|
786 |
if IOResult <> 0 then f:= stderr; // if everything fails, write to stderr |
|
787 |
end |
|
788 |
else |
|
789 |
f:= stderr; |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
790 |
{$ENDIF} |
337 | 791 |
{$I+} |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
792 |
{$ENDIF} |
17 | 793 |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
794 |
end; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
795 |
|
3038 | 796 |
procedure freeModule; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
797 |
begin |
2947 | 798 |
//uRandom.DumpBuffer; |
799 |
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
|
800 |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
801 |
{$IFDEF DEBUGFILE} |
2947 | 802 |
writeln(f, 'halt at ', GameTicks, ' ticks. TurnTimeLeft = ', TurnTimeLeft); |
803 |
flush(f); |
|
804 |
close(f); |
|
4 | 805 |
{$ENDIF} |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
806 |
end; |
4 | 807 |
|
808 |
end. |