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