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