1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
|
/*
* PARSEC - Startup Code
*
* $Author: uberlinuxguy $ - $Date: 2004/09/15 12:25:25 $
*
* Orginally written by:
* Copyright (c) Markus Hadwiger <msh@parsec.org> 1996-2000
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// C library
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
// compilation flags/debug support
#include "config.h"
#include "debug.h"
// general definitions
#include "general.h"
#include "objstruc.h"
#include "od_class.h"
// global externals
#include "globals.h"
// subsystem headers
#include "aud_defs.h"
#include "inp_defs.h"
#include "net_defs.h"
#include "sys_defs.h"
#include "vid_defs.h"
// mathematics header
#include "utl_math.h"
// local module header
#include "g_boot.h"
// proprietary module headers
#include "con_aux.h"
#include "con_main.h"
#include "e_color.h"
#include "e_demo.h"
#include "e_events.h"
#include "e_mouse.h"
#include "e_replay.h"
#include "e_supp.h"
#include "g_stars.h"
#include "h_drwhud.h"
#include "h_frmplt.h"
#include "h_supp.h"
#include "h_text.h"
#include "inp_init.h"
#include "net_conn.h"
#include "obj_creg.h"
#include "obj_ctrl.h"
#include "part_sys.h"
#include "sys_bind.h"
#include "vid_init.h"
// flags
//#define NO_NET_GAME_POSSIBLE
#define PRERELEASE_MESSAGE
#define OPENSOURCE_RELEASE
//#define LINUXTAG99_MESSAGE
//#define MATROXTEST_MESSAGE
//#define SELFRUNNING_MESSAGE
//#define BRAUNSCHWEIG_MESSAGE
//#define LINUXTAG2K_MESSAGE
//#define REDHAT7DISTRI_MESSAGE
//#define LANTEST_MESSAGE
#define RANDOM_STARTUP_SHIPCLASS
//#define CHECK_HARD_DATE_LIMIT
// minimum amount of memory needed [bytes] ------------------------------------
//
#define MIN_MEM_NEEDED 15000000 //3072000 war mal :)
dword MemNeeded = MIN_MEM_NEEDED;
// save area for locations of pseudo and fixed stars --------------------------
//
pseudostar_s s_PseudoStars[ MAX_PSEUDO_STARS ];
fixedstar_s s_FixedStars[ MAX_FIXED_STARS ];
// display startup messages ---------------------------------------------------
//
void StartupMessages()
{
MSGOUT( "\n" );
MSGOUT( " OPENPARSEC build " CLIENT_BUILD_NUMBER "." );
MSGOUT( "---------------------------------------------------" );
MSGOUT( " http://www.openparsec.com " );
MSGOUT( "---------------------------------------------------" );
MSGOUT( "\n" );
#if defined( PRERELEASE_MESSAGE )
MSGOUT( " UNTESTED VERSION CURRENTLY UNDER DEVELOPMENT." );
MSGOUT( "\n" );
MSGOUT( "---------------------------------------------------" );
MSGOUT( "\n" );
#endif
}
// restore locations of pseudo and fixed stars, respectively ------------------
//
INLINE
void ReInitStars()
{
// init starting locations of fixed stars
for ( int fsindx = 0; fsindx < NumFixedStars; fsindx++ ) {
FixedStars[ fsindx ] = s_FixedStars[ fsindx ];
}
// init starting locations of pseudo stars
MakeIdMatrx( PseudoStarMovement );
for ( int psindx = 0; psindx < NumPseudoStars; psindx++ ) {
PseudoStars[ psindx ] = s_PseudoStars[ psindx ];
}
}
// init global variables to default values ------------------------------------
//
PRIVATE
void InitGlobals()
{
CurrentNumExtras = 0;
CurrentNumPrtExtras = 0;
CurYaw = BAMS_DEG0;
CurPitch = BAMS_DEG0;
CurRoll = BAMS_DEG0;
CurSlideHorz = GEOMV_0;
CurSlideVert = GEOMV_0;
LastPitch = BAMS_DEG0;
LastYaw = BAMS_DEG0;
LastRoll = BAMS_DEG0;
LastSlideHorz = GEOMV_0;
LastSlideVert = GEOMV_0;
LastSpeed = 0;
IdleDuration = 0;
CurActionWait = 0;
AutomaticPitch = BAMS_DEG0;
AutomaticYaw = BAMS_DEG0;
AutomaticRoll = BAMS_DEG0;
AutomaticSlideHorz = GEOMV_0;
AutomaticSlideVert = GEOMV_0;
AutomaticMovement = 0;
ReplayObjCamActive = FALSE;
AbsYaw = BAMS_DEG0;
AbsPitch = BAMS_DEG0;
AbsRoll = BAMS_DEG0;
FireDisable = 1;
FireRepeat = 1;
CurGun = 0;
MissileDisable = 1;
CurLauncher = 0;
ObjCameraActive = 0;
HelpActive = 0;
ConsoleSliding = 0;
KeybFlags->ConEnabled = 0;
TargetObjNumber = TARGETID_NO_TARGET;
TargetRemId = TARGETID_NO_TARGET;
TargetVisible = FALSE;
TargetLocked = FALSE;
MaxNumShots = 0;
NumShots = 0;
MaxNumMissiles = 0;
NumMissiles = 0;
SelectedLaser = 0;
SelectedMissile = 0;
CameraMoved = 0;
SetScreenBlue = 0;
SetScreenWhite = 0;
ResetMessageArea();
ReInitStars();
// HUD_InitDemoText();
}
// save locations of fixed and pseudo stars, respectively ---------------------
//
INLINE
void SaveStarLocations()
{
for ( int fsindx = 0; fsindx < NumFixedStars; fsindx++ ) {
s_FixedStars[ fsindx ] = FixedStars[ fsindx ];
}
for ( int psindx = 0; psindx < NumPseudoStars; psindx++ ) {
s_PseudoStars[ psindx ] = PseudoStars[ psindx ];
}
}
// init display for the first time --------------------------------------------
//
INLINE
void BootDisplay()
{
// set video mode specified by global vars
if ( TextModeActive && !DirectNetPlay ) {
VID_InitMode();
}
}
// init the local ship class that will be selected after startup --------------
//
INLINE
void InitLocalShipClass()
{
#ifdef RANDOM_STARTUP_SHIPCLASS
ASSERT( NumShipClasses >= 3 );
time_t curtime = time( NULL );
int randval = (int) curtime;
int shipno = randval % NumShipClasses;
LocalShipClass = ShipClasses[ shipno ];
#else
// done in G_GLOBAL.C
// LocalShipClass = SHIP_CLASS_1;
#endif
}
// alloc storage for MyShip ---------------------------------------------------
//
PRIVATE
void AllocMyShip()
{
ASSERT( MyShip == NULL );
ASSERT( MyShipMaxInstanceSize == 0 );
// need storage for additional instance data
MyShipMaxInstanceSize = sizeof( ShipObject ) + 16384;
// this will never be freed and the
// pointer must never be changed!!
MyShip = (ShipObject *) ALLOCMEM( MyShipMaxInstanceSize );
if ( MyShip == NULL )
OUTOFMEM( 0 );
// clear is mandatory
memset( MyShip, 0, MyShipMaxInstanceSize );
}
// command line option must override name set in init script ------------------
//
PRIVATE
void OverridePlayerName()
{
// override player name if set by command line option
if ( ForcedPlayerName[ 0 ] != 0 ) {
strncpy( LocalPlayerName, ForcedPlayerName, MAX_PLAYER_NAME );
LocalPlayerName[ MAX_PLAYER_NAME ] = 0;
}
}
// ----------------------------------------------------------------------------
//
PUBLIC int aud_do_open_menu_sound_on_aud_conf = FALSE;
// do necessary initializations that are only done once -----------------------
//
int GameBoot()
{
MSGOUT( "Booting game core." );
// dummy init
limit_timeval_cur = 1000000000;
// init color maps
InitColorMaps();
// alloc storage for MyShip
AllocMyShip();
// init object maintenance
InitObjCtrl();
// init fixed stars
InitFixedStars();
// init pseudo stars
InitPseudoStars();
// save star locations
SaveStarLocations();
// init geometry of screen displays
InitHudDisplay();
// init particle system
InitParticleSystem();
// init the event manager
EVT_InitManager();
// init input code
INP_InitSubsystem();
// init console
InitConsole(); // *MUST NOT* be called earlier!!!
// enable AUDs_OpenMenuSound call in AUD.CONF after console files have been loaded
aud_do_open_menu_sound_on_aud_conf = TRUE;
// command line option must override
// name set in init script
OverridePlayerName();
// stuff list of demos into table
DEMO_RegisterInitialDemos();
// may be chosen at random
InitLocalShipClass();
// init frame timer
SYSs_InitFrameTimer();
return TRUE;
}
// create objects always created on game mode entry by default ----------------
//
PRIVATE
void CreateDefaultObjects()
{
if ( !NetworkGameMask ) {
Xmatrx startm;
MakeIdMatrx( startm );
startm[ 1 ][ 3 ] = FLOAT_TO_GEOMV( -80.0 );
CreateObject( SHIP_CLASS_1, startm );
MakeIdMatrx( startm );
startm[ 1 ][ 3 ] = FLOAT_TO_GEOMV( +80.0 );
CreateObject( SHIP_CLASS_2, startm );
MakeIdMatrx( startm );
startm[ 1 ][ 3 ] = FLOAT_TO_GEOMV( 256.0 );
CreateObject( SHIP_CLASS_3, startm );
MakeIdMatrx( startm );
startm[ 1 ][ 3 ] = FLOAT_TO_GEOMV( 336.0 );
CreateObject( SHIP_CLASS_1, startm );
}
}
// handle network game entry --------------------------------------------------
//
PRIVATE
int HandleEntryMode()
{
int rc = TRUE;
// enter network game session if necessary
//FIXME: [2/7/2002] && ??????
if ( NetworkGameMask && AUX_PERFORM_AUTOMATIC_CONNECT ) {
if ( sys_BindType_PROTOCOL == BT_PROTOCOL_PEERTOPEER ) {
// automatically try to establish connection
if ( NET_AutomaticConnect() ) {
// always start network game in entry mode
EntryMode = TRUE;
return TRUE;
}
rc = FALSE;
} else {
MSGOUT( "automatic connect only valid in peer mode." );
}
}
// no entrymode since not connected
EntryMode = FALSE;
return rc;
}
// handle init of graphics mode -----------------------------------------------
//
INLINE
void HandleGraphicsModeSwitch()
{
// switch to mode specified in option vars (Op_xx)
VID_ApplyOptions();
}
// set network game flag appropriately ----------------------------------------
//
INLINE
void SetNetFlag( int use_net )
{
#ifndef NO_NET_GAME_POSSIBLE
// decide if network game or weapons testing mode
NetworkGameMask = NetAvailable ? use_net : NETWORK_GAME_OFF;
#else
NetworkGameMask = NETWORK_GAME_OFF;
#endif
}
// init necessary game functions (done every time game mode is entered) -------
//
int GameInit( int use_net )
{
// free objects and particles
KillAllObjects();
// reinit globals
InitGlobals();
// check files used by console
InitConsoleFileHandling();
// set net flag appropriately
SetNetFlag( use_net );
// handle network game entry
if ( !HandleEntryMode() )
return FALSE;
// handle init of graphics mode
HandleGraphicsModeSwitch();
// create default objects
CreateDefaultObjects();
// init game sound
//RAM AUDs_OpenMenuSound();
AUDs_OpenGameSound();
AUDs_OpenMenuSound();
return TRUE;
}
|