author | koda |
Sat, 16 Jan 2010 17:30:37 +0000 | |
changeset 2698 | 90585aba87ad |
parent 2697 | 75880595a9f1 |
child 2699 | 249adefa9c1c |
permissions | -rw-r--r-- |
498 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
393 | 3 |
* Copyright (c) 2004-2007 Andrey Korotaev <unC0Rr@gmail.com> |
51 | 4 |
* |
183 | 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 |
|
51 | 8 |
* |
183 | 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. |
|
51 | 13 |
* |
183 | 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 |
|
51 | 17 |
*) |
18 |
||
2599 | 19 |
{$INCLUDE "options.inc"} |
2587
0dfa56a8513c
fix a segfault in the iphone simulator by moving options.inc at the beginning of the file
koda
parents:
2586
diff
changeset
|
20 |
|
2698 | 21 |
{$IFDEF IPHONEOS} |
22 |
unit hwengine; |
|
23 |
interface |
|
24 |
{$ELSE} |
|
51 | 25 |
program hwengine; |
2698 | 26 |
{$ENDIF} |
2690 | 27 |
uses SDLh in 'SDLh.pas', |
1524
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
28 |
uConsts in 'uConsts.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
29 |
uGame in 'uGame.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
30 |
uMisc in 'uMisc.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
31 |
uStore in 'uStore.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
32 |
uWorld in 'uWorld.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
33 |
uIO in 'uIO.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
34 |
uGears in 'uGears.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
35 |
uVisualGears in 'uVisualGears.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
36 |
uConsole in 'uConsole.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
37 |
uKeys in 'uKeys.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
38 |
uTeams in 'uTeams.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
39 |
uSound in 'uSound.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
40 |
uRandom in 'uRandom.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
41 |
uAI in 'uAI.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
42 |
uAIMisc in 'uAIMisc.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
43 |
uAIAmmoTests in 'uAIAmmoTests.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
44 |
uAIActions in 'uAIActions.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
45 |
uCollisions in 'uCollisions.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
46 |
uLand in 'uLand.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
47 |
uLandTemplates in 'uLandTemplates.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
48 |
uLandObjects in 'uLandObjects.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
49 |
uLandGraphics in 'uLandGraphics.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
50 |
uLocale in 'uLocale.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
51 |
uAmmos in 'uAmmos.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
52 |
uSHA in 'uSHA.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
53 |
uFloat in 'uFloat.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
54 |
uStats in 'uStats.pas', |
1807 | 55 |
uChat in 'uChat.pas', |
2690 | 56 |
uLandTexture in 'uLandTexture.pas' |
57 |
{$IFDEF IPHONEOS} |
|
58 |
, PascalExports in 'PascalExports.pas' |
|
59 |
{$ENDIF} |
|
60 |
; |
|
51 | 61 |
|
62 |
// also: GSHandlers.inc |
|
63 |
// CCHandlers.inc |
|
64 |
// HHHandlers.inc |
|
357 | 65 |
// SinTable.inc |
271 | 66 |
// proto.inc |
51 | 67 |
|
2698 | 68 |
{$IFDEF IPHONEOS} |
69 |
procedure DoTimer(Lag: LongInt); |
|
70 |
procedure OnDestroy; |
|
71 |
procedure MainLoop; |
|
72 |
procedure ShowMainWindow; |
|
73 |
procedure Game; cdecl; export; |
|
51 | 74 |
|
2698 | 75 |
implementation |
76 |
||
77 |
{$ELSE} |
|
51 | 78 |
procedure OnDestroy; forward; |
2698 | 79 |
{$ENDIF} |
51 | 80 |
|
81 |
//////////////////////////////// |
|
371 | 82 |
procedure DoTimer(Lag: LongInt); |
2243
b4764993f833
additional touch support and nemo's reduced land array size
koda
parents:
2191
diff
changeset
|
83 |
{$IFNDEF IPHONEOS} |
1080 | 84 |
var s: string; |
2243
b4764993f833
additional touch support and nemo's reduced land array size
koda
parents:
2191
diff
changeset
|
85 |
{$ENDIF} |
51 | 86 |
begin |
2698 | 87 |
inc(RealTicks, Lag); |
564 | 88 |
|
2698 | 89 |
case GameState of |
90 |
gsLandGen: begin |
|
91 |
GenMap; |
|
92 |
GameState:= gsStart; |
|
93 |
end; |
|
94 |
gsStart: begin |
|
95 |
if HasBorder then DisableSomeWeapons; |
|
96 |
AddClouds; |
|
97 |
AssignHHCoords; |
|
98 |
AddMiscGears; |
|
99 |
StoreLoad; |
|
100 |
InitWorld; |
|
101 |
ResetKbd; |
|
102 |
SoundLoad; |
|
103 |
if GameType = gmtSave then |
|
104 |
begin |
|
105 |
isSEBackup:= isSoundEnabled; |
|
106 |
isSoundEnabled:= false |
|
107 |
end; |
|
108 |
FinishProgress; |
|
109 |
PlayMusic; |
|
110 |
SetScale(zoom); |
|
111 |
GameState:= gsGame; |
|
1524
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
112 |
end; |
2698 | 113 |
gsConfirm, |
114 |
gsGame: begin |
|
115 |
DrawWorld(Lag); // never place between ProcessKbd and DoGameTick - bugs due to /put cmd and isCursorVisible |
|
116 |
ProcessKbd; |
|
117 |
DoGameTick(Lag); |
|
118 |
ProcessVisualGears(Lag); |
|
119 |
end; |
|
120 |
gsChat: begin |
|
121 |
DrawWorld(Lag); |
|
122 |
DoGameTick(Lag); |
|
123 |
ProcessVisualGears(Lag); |
|
124 |
end; |
|
125 |
gsExit: begin |
|
126 |
isTerminated:= true; |
|
127 |
end; |
|
128 |
end; |
|
564 | 129 |
|
2698 | 130 |
SDL_GL_SwapBuffers(); |
2171
8208946331ba
Smaxx refactor of LoadImage to use flags, iphone changes by koda (mostly use of rgba instead of rgb)
nemo
parents:
2162
diff
changeset
|
131 |
{$IFNDEF IPHONEOS} |
2698 | 132 |
// not going to make captures on the iPhone |
133 |
if flagMakeCapture then |
|
1524
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
134 |
begin |
2698 | 135 |
flagMakeCapture:= false; |
136 |
s:= 'hw_' + cSeed + '_' + inttostr(GameTicks) + '.tga'; |
|
137 |
WriteLnToConsole('Saving ' + s); |
|
138 |
MakeScreenshot(s); |
|
139 |
//SDL_SaveBMP_RW(SDLPrimSurface, SDL_RWFromFile(Str2PChar(s), 'wb'), 1) |
|
1524
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
140 |
end; |
2171
8208946331ba
Smaxx refactor of LoadImage to use flags, iphone changes by koda (mostly use of rgba instead of rgb)
nemo
parents:
2162
diff
changeset
|
141 |
{$ENDIF} |
51 | 142 |
end; |
143 |
||
144 |
//////////////////// |
|
79 | 145 |
procedure OnDestroy; |
51 | 146 |
begin |
2692
ce9992075118
better network support + initial work for returning to frontend
koda
parents:
2691
diff
changeset
|
147 |
WriteLnToConsole('Freeing resources...'); |
2688 | 148 |
if isSoundEnabled then ReleaseSound(); |
149 |
StoreRelease(); |
|
150 |
FreeLand(); |
|
2692
ce9992075118
better network support + initial work for returning to frontend
koda
parents:
2691
diff
changeset
|
151 |
ControllerClose(); |
2688 | 152 |
SendKB(); |
153 |
CloseIPC(); |
|
154 |
TTF_Quit(); |
|
155 |
SDL_Quit(); |
|
2698 | 156 |
exit(); |
51 | 157 |
end; |
158 |
||
159 |
/////////////////// |
|
2698 | 160 |
procedure MainLoop; |
51 | 161 |
var PrevTime, |
188 | 162 |
CurrTime: Longword; |
51 | 163 |
event: TSDL_Event; |
2698 | 164 |
begin |
165 |
||
166 |
PrevTime:= SDL_GetTicks; |
|
167 |
repeat |
|
168 |
{$IFNDEF IPHONEOS} |
|
169 |
// have to remove this cycle because otherwise it segfaults at exit |
|
170 |
while SDL_PollEvent(@event) <> 0 do |
|
171 |
begin |
|
172 |
case event.type_ of |
|
173 |
SDL_KEYDOWN: if GameState = gsChat then KeyPressChat(event.key.keysym.unicode); |
|
174 |
{$IFDEF SDL13} |
|
175 |
SDL_WINDOWEVENT: |
|
176 |
{$ELSE} |
|
177 |
SDL_ACTIVEEVENT: |
|
2569 | 178 |
{$ENDIF} |
2698 | 179 |
if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then |
180 |
cHasFocus:= event.active.gain = 1; |
|
181 |
//SDL_VIDEORESIZE: Resize(max(event.resize.w, 600), max(event.resize.h, 450)); |
|
182 |
SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then uKeys.wheelDown:= true; |
|
183 |
SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELUP then uKeys.wheelUp:= true; |
|
184 |
SDL_JOYAXISMOTION: ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value); |
|
185 |
SDL_JOYHATMOTION: ControllerHatEvent(event.jhat.which, event.jhat.hat, event.jhat.value); |
|
186 |
SDL_JOYBUTTONDOWN: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, true); |
|
187 |
SDL_JOYBUTTONUP: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, false); |
|
188 |
SDL_QUITEV: isTerminated:= true |
|
189 |
end; // end case event.type_ of |
|
190 |
end; // end while SDL_PollEvent(@event) <> 0 do |
|
2390 | 191 |
{$ENDIF} |
2698 | 192 |
CurrTime:= SDL_GetTicks; |
193 |
if PrevTime + cTimerInterval <= CurrTime then |
|
194 |
begin |
|
195 |
DoTimer(CurrTime - PrevTime); |
|
196 |
PrevTime:= CurrTime |
|
197 |
end else SDL_Delay(1); |
|
198 |
if isTerminated = false then IPCCheckSock(); |
|
199 |
until isTerminated; |
|
200 |
||
201 |
exit(); |
|
202 |
end; |
|
203 |
||
204 |
///////////////////////// |
|
205 |
procedure ShowMainWindow; |
|
206 |
begin |
|
207 |
if cFullScreen then ParseCommand('fullscr 1', true) |
|
208 |
else ParseCommand('fullscr 0', true); |
|
209 |
SDL_ShowCursor(0) |
|
210 |
end; |
|
2591
c6597b65caea
other controls implementation + sdlh revisited (once again)
koda
parents:
2590
diff
changeset
|
211 |
|
2698 | 212 |
/////////////// |
213 |
procedure Game;{$IFDEF IPHONEOS}cdecl; export;{$ENDIF} |
|
214 |
var p: TPathType; |
|
215 |
s: shortstring; |
|
216 |
begin |
|
217 |
{$IFDEF IPHONEOS} |
|
218 |
Randomize; |
|
2591
c6597b65caea
other controls implementation + sdlh revisited (once again)
koda
parents:
2590
diff
changeset
|
219 |
|
2698 | 220 |
val('320', cScreenWidth); |
221 |
val('480', cScreenHeight); |
|
222 |
cInitWidth:= cScreenWidth; |
|
223 |
cInitHeight:= cScreenHeight; |
|
224 |
cBitsStr:= '16'; |
|
225 |
val(cBitsStr, cBits); |
|
226 |
val('51432', ipcPort); |
|
227 |
cFullScreen:= true; |
|
228 |
isSoundEnabled:= false; |
|
229 |
cVSyncInUse:= true; |
|
230 |
cLocaleFName:= 'en.txt'; |
|
231 |
val('100', cInitVolume); |
|
232 |
val('8', cTimerInterval); |
|
233 |
PathPrefix:= 'Data'; |
|
234 |
cShowFPS:= true; |
|
235 |
cAltDamage:= false; |
|
236 |
UserNick:= 'Koda'; //DecodeBase64(ParamStr(15)); |
|
237 |
isMusicEnabled:= false; |
|
238 |
cReducedQuality:= false; |
|
2600 | 239 |
{$ENDIF} |
2698 | 240 |
|
241 |
for p:= Succ(Low(TPathType)) to High(TPathType) do |
|
242 |
if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]; |
|
243 |
||
244 |
WriteToConsole('Init SDL... '); |
|
245 |
SDLTry(SDL_Init(SDL_INIT_VIDEO) >= 0, true); |
|
246 |
WriteLnToConsole(msgOK); |
|
247 |
||
248 |
SDL_EnableUNICODE(1); |
|
249 |
||
250 |
WriteToConsole('Init SDL_ttf... '); |
|
251 |
SDLTry(TTF_Init <> -1, true); |
|
252 |
WriteLnToConsole(msgOK); |
|
253 |
||
254 |
ShowMainWindow; |
|
255 |
||
256 |
AddProgress; |
|
257 |
||
258 |
ControllerInit; // has to happen before InitKbdKeyTable to map keys |
|
259 |
InitKbdKeyTable; |
|
260 |
||
261 |
if recordFileName = '' then |
|
262 |
InitIPC; |
|
263 |
WriteLnToConsole(msgGettingConfig); |
|
264 |
||
265 |
if cLocaleFName <> 'en.txt' then |
|
266 |
LoadLocale(Pathz[ptLocale] + '/en.txt'); |
|
267 |
LoadLocale(Pathz[ptLocale] + '/' + cLocaleFName); |
|
268 |
||
269 |
if recordFileName = '' then |
|
270 |
SendIPCAndWaitReply('C') // ask for game config |
|
271 |
else |
|
272 |
LoadRecordFromFile(recordFileName); |
|
273 |
||
274 |
s:= 'eproto ' + inttostr(cNetProtoVersion); |
|
275 |
SendIPCRaw(@s[0], Length(s) + 1); // send proto version |
|
276 |
||
277 |
InitTeams; |
|
278 |
AssignStores; |
|
2590 | 279 |
|
2698 | 280 |
if isSoundEnabled then |
281 |
InitSound; |
|
282 |
||
283 |
isDeveloperMode:= false; |
|
284 |
||
285 |
TryDo(InitStepsFlags = cifAllInited, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true); |
|
286 |
||
287 |
MainLoop(); |
|
288 |
OnDestroy(); |
|
289 |
exit(); |
|
290 |
end; |
|
2590 | 291 |
|
2698 | 292 |
{$IFNDEF IPHONEOS} |
293 |
///////////////////////// |
|
294 |
procedure GenLandPreview; |
|
295 |
var Preview: TPreview; |
|
296 |
h: byte; |
|
297 |
begin |
|
298 |
InitIPC; |
|
299 |
IPCWaitPongEvent; |
|
300 |
TryDo(InitStepsFlags = cifRandomize, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true); |
|
301 |
||
302 |
Preview:= GenPreview; |
|
303 |
WriteLnToConsole('Sending preview...'); |
|
304 |
SendIPCRaw(@Preview, sizeof(Preview)); |
|
305 |
h:= MaxHedgehogs; |
|
306 |
SendIPCRaw(@h, sizeof(h)); |
|
307 |
WriteLnToConsole('Preview sent, disconnect'); |
|
308 |
CloseIPC(); |
|
309 |
end; |
|
310 |
||
311 |
//////////////////////////////// |
|
312 |
procedure Resize(w, h: LongInt); |
|
313 |
begin |
|
314 |
cScreenWidth:= w; |
|
315 |
cScreenHeight:= h; |
|
316 |
if cFullScreen then |
|
317 |
ParseCommand('/fullscr 1', true) |
|
318 |
else |
|
319 |
ParseCommand('/fullscr 0', true); |
|
51 | 320 |
end; |
321 |
||
2008 | 322 |
///////////////////// |
323 |
procedure DisplayUsage; |
|
2691 | 324 |
var i: LongInt; |
2008 | 325 |
begin |
326 |
WriteLn('Wrong argument format: correct configurations is'); |
|
327 |
WriteLn(); |
|
328 |
WriteLn(' hwengine <path to data folder> <path to replay file> [option]'); |
|
329 |
WriteLn(); |
|
330 |
WriteLn('where [option] must be specified either as'); |
|
2264 | 331 |
WriteLn(' --set-video [screen width] [screen height] [color dept]'); |
2008 | 332 |
WriteLn(' --set-audio [volume] [enable music] [enable sounds]'); |
333 |
WriteLn(' --set-other [language file] [full screen] [show FPS]'); |
|
334 |
WriteLn(' --set-multimedia [screen height] [screen width] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen]'); |
|
335 |
WriteLn(' --set-everything [screen height] [screen width] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality]'); |
|
336 |
WriteLn(); |
|
2015 | 337 |
WriteLn('Read documentation online at http://www.hedgewars.org/node/1465 for more information'); |
2691 | 338 |
Write('parsed command: '); |
2698 | 339 |
for i:=0 to ParamCount do |
340 |
Write(ParamStr(i) + ' '); |
|
2691 | 341 |
WriteLn(); |
2015 | 342 |
halt(1); |
2008 | 343 |
end; |
344 |
||
51 | 345 |
//////////////////// |
346 |
procedure GetParams; |
|
889 | 347 |
var |
267 | 348 |
{$IFDEF DEBUGFILE} |
371 | 349 |
i: LongInt; |
267 | 350 |
{$ENDIF} |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
81
diff
changeset
|
351 |
p: TPathType; |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
81
diff
changeset
|
352 |
begin |
267 | 353 |
|
2698 | 354 |
case ParamCount of |
355 |
17: begin |
|
356 |
val(ParamStr(2), cScreenWidth); |
|
357 |
val(ParamStr(3), cScreenHeight); |
|
2008 | 358 |
cInitWidth:= cScreenWidth; |
359 |
cInitHeight:= cScreenHeight; |
|
2698 | 360 |
cBitsStr:= ParamStr(4); |
2008 | 361 |
val(cBitsStr, cBits); |
2698 | 362 |
val(ParamStr(5), ipcPort); |
363 |
cFullScreen:= ParamStr(6) = '1'; |
|
364 |
isSoundEnabled:= ParamStr(7) = '1'; |
|
365 |
cVSyncInUse:= ParamStr(8) = '1'; |
|
366 |
cLocaleFName:= ParamStr(9); |
|
367 |
val(ParamStr(10), cInitVolume); |
|
368 |
val(ParamStr(11), cTimerInterval); |
|
369 |
PathPrefix:= ParamStr(12); |
|
370 |
cShowFPS:= ParamStr(13) = '1'; |
|
371 |
cAltDamage:= ParamStr(14) = '1'; |
|
372 |
UserNick:= DecodeBase64(ParamStr(15)); |
|
373 |
isMusicEnabled:= ParamStr(16) = '1'; |
|
374 |
cReducedQuality:= ParamStr(17) = '1'; |
|
375 |
end; |
|
376 |
3: begin |
|
377 |
val(ParamStr(2), ipcPort); |
|
378 |
GameType:= gmtLandPreview; |
|
379 |
if ParamStr(3) <> 'landpreview' then |
|
380 |
OutError(errmsgShouldntRun, true); |
|
381 |
end; |
|
382 |
2: begin |
|
383 |
PathPrefix:= ParamStr(1); |
|
384 |
recordFileName:= ParamStr(2); |
|
385 |
end; |
|
386 |
6: begin |
|
387 |
PathPrefix:= ParamStr(1); |
|
388 |
recordFileName:= ParamStr(2); |
|
389 |
||
390 |
if ParamStr(3) = '--set-video' then |
|
2008 | 391 |
begin |
2698 | 392 |
val(ParamStr(4), cScreenWidth); |
393 |
val(ParamStr(5), cScreenHeight); |
|
394 |
cInitWidth:= cScreenWidth; |
|
395 |
cInitHeight:= cScreenHeight; |
|
396 |
cBitsStr:= ParamStr(6); |
|
397 |
val(cBitsStr, cBits); |
|
2008 | 398 |
end |
399 |
else |
|
400 |
begin |
|
2698 | 401 |
if ParamStr(3) = '--set-audio' then |
402 |
begin |
|
403 |
val(ParamStr(4), cInitVolume); |
|
404 |
isMusicEnabled:= ParamStr(5) = '1'; |
|
405 |
isSoundEnabled:= ParamStr(6) = '1'; |
|
406 |
end |
|
407 |
else |
|
2008 | 408 |
begin |
2698 | 409 |
if ParamStr(3) = '--set-other' then |
410 |
begin |
|
411 |
cLocaleFName:= ParamStr(4); |
|
412 |
cFullScreen:= ParamStr(5) = '1'; |
|
413 |
cShowFPS:= ParamStr(6) = '1'; |
|
414 |
end |
|
415 |
else DisplayUsage; |
|
2008 | 416 |
end |
2698 | 417 |
end; |
2008 | 418 |
end; |
2698 | 419 |
11: begin |
420 |
PathPrefix:= ParamStr(1); |
|
421 |
recordFileName:= ParamStr(2); |
|
2376 | 422 |
|
2698 | 423 |
if ParamStr(3) = '--set-multimedia' then |
424 |
begin |
|
425 |
val(ParamStr(4), cScreenWidth); |
|
426 |
val(ParamStr(5), cScreenHeight); |
|
427 |
cInitWidth:= cScreenWidth; |
|
428 |
cInitHeight:= cScreenHeight; |
|
429 |
cBitsStr:= ParamStr(6); |
|
430 |
val(cBitsStr, cBits); |
|
431 |
val(ParamStr(7), cInitVolume); |
|
432 |
isMusicEnabled:= ParamStr(8) = '1'; |
|
433 |
isSoundEnabled:= ParamStr(9) = '1'; |
|
434 |
cLocaleFName:= ParamStr(10); |
|
435 |
cFullScreen:= ParamStr(11) = '1'; |
|
436 |
end |
|
437 |
else DisplayUsage; |
|
438 |
end; |
|
439 |
15: begin |
|
440 |
PathPrefix:= ParamStr(1); |
|
441 |
recordFileName:= ParamStr(2); |
|
442 |
if ParamStr(3) = '--set-everything' then |
|
443 |
begin |
|
444 |
val(ParamStr(4), cScreenWidth); |
|
445 |
val(ParamStr(5), cScreenHeight); |
|
446 |
cInitWidth:= cScreenWidth; |
|
447 |
cInitHeight:= cScreenHeight; |
|
448 |
cBitsStr:= ParamStr(6); |
|
449 |
val(cBitsStr, cBits); |
|
450 |
val(ParamStr(7), cInitVolume); |
|
451 |
isMusicEnabled:= ParamStr(8) = '1'; |
|
452 |
isSoundEnabled:= ParamStr(9) = '1'; |
|
453 |
cLocaleFName:= ParamStr(10); |
|
454 |
cFullScreen:= ParamStr(11) = '1'; |
|
455 |
cAltDamage:= ParamStr(12) = '1'; |
|
456 |
cShowFPS:= ParamStr(13) = '1'; |
|
457 |
val(ParamStr(14), cTimerInterval); |
|
458 |
cReducedQuality:= ParamStr(15) = '1'; |
|
459 |
end |
|
460 |
else DisplayUsage; |
|
461 |
end; |
|
2008 | 462 |
else DisplayUsage; |
463 |
end; |
|
2630 | 464 |
|
465 |
{$IFDEF DEBUGFILE} |
|
2698 | 466 |
AddFileLog('Prefix: "' + PathPrefix +'"'); |
467 |
for i:= 0 to ParamCount do |
|
468 |
AddFileLog(inttostr(i) + ': ' + ParamStr(i)); |
|
2630 | 469 |
{$IFDEF IPHONEOS} |
2690 | 470 |
WriteLnToConsole('Saving debug file at: ' + IPH_getDocumentsPath()); |
2630 | 471 |
{$ENDIF} |
472 |
{$ENDIF} |
|
51 | 473 |
end; |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
474 |
//////////////////////////////////////////////////////////////////////////////// |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
475 |
/////////////////////////////// m a i n //////////////////////////////////////// |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
476 |
//////////////////////////////////////////////////////////////////////////////// |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
477 |
|
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
478 |
begin |
2692
ce9992075118
better network support + initial work for returning to frontend
koda
parents:
2691
diff
changeset
|
479 |
WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')'); |
ce9992075118
better network support + initial work for returning to frontend
koda
parents:
2691
diff
changeset
|
480 |
GetParams; |
2105 | 481 |
|
2692
ce9992075118
better network support + initial work for returning to frontend
koda
parents:
2691
diff
changeset
|
482 |
Randomize; |
2008 | 483 |
|
2698 | 484 |
if GameType = gmtLandPreview then GenLandPreview |
485 |
else Game; |
|
2692
ce9992075118
better network support + initial work for returning to frontend
koda
parents:
2691
diff
changeset
|
486 |
// ExitCode := 100; |
2698 | 487 |
{$ENDIF} |
488 |
||
51 | 489 |
end. |
2008 | 490 |