Oolite 1.91.0.7745-260117-205bce7
Loading...
Searching...
No Matches
Command Line Interface

Functions

int main (int argc, const char *argv[])
(id) - OOOpenALController::init
(void) - Universe(OOPrivate)::runLocalizationTools
int main (int argc, char *argv[])
(id) - MyOpenGLView::init
(void) - PlayerEntity::setGuiToIntroFirstGo:
(void) - OOOpenGLExtensionManager(OOPrivate)::checkShadersSupported
(BOOL) + OOOXPVerifier::runVerificationIfRequested

Detailed Description

The command line is parsed and interpreted at various locations in the code. Here are the known functions that participate on cli arguments.

Function Documentation

◆ checkShadersSupported

- (void) checkShadersSupported

Scans the command line for -noshaders or –noshaders arguments.

Extends class OOOpenGLExtensionManager.

Definition at line 555 of file OOOpenGLExtensionManager.m.

556{
557 shadersAvailable = NO;
558 shadersForceDisabled = NO;
559
560 /* Some cards claim to support shaders but do so extremely
561 * badly. These are listed in gpu-settings.plist where we know
562 * about them; for those we don't being able to run with
563 * -noshaders may help get the game up and running at a frame rate
564 * where thegraphics settings can be changed. - CIM */
565 NSArray *arguments = [[NSProcessInfo processInfo] arguments];
566 NSEnumerator *argEnum = nil;
567 NSString *arg = nil;
568 // scan for shader overrides: -noshaders || --noshaders
569 for (argEnum = [arguments objectEnumerator]; (arg = [argEnum nextObject]); )
570 {
571 if ([arg isEqual:@"-noshaders"] || [arg isEqual:@"--noshaders"])
572 {
573 shadersForceDisabled = YES;
574 OOLog(kOOLogOpenGLShaderSupport, @"%@", @"Shaders will not be used (disabled on command line).");
575 return;
576 }
577 }
578
579 NSString * const requiredExtension[] =
580 {
581 @"GL_ARB_shading_language_100",
582 @"GL_ARB_fragment_shader",
583 @"GL_ARB_vertex_shader",
584 @"GL_ARB_multitexture",
585 @"GL_ARB_shader_objects",
586 nil // sentinel - don't remove!
587 };
588 NSString * const *required = NULL;
589
590 for (required = requiredExtension; *required != nil; ++required)
591 {
592 if (![self haveExtension:*required])
593 {
594 OOLog(kOOLogOpenGLShaderSupport, @"Shaders will not be used (OpenGL extension %@ is not available).", *required);
595 return;
596 }
597 }
598
599#if OOLITE_WINDOWS
600 glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress("glGetObjectParameterivARB");
601 glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)wglGetProcAddress("glCreateShaderObjectARB");
602 glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)wglGetProcAddress("glGetInfoLogARB");
603 glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)wglGetProcAddress("glCreateProgramObjectARB");
604 glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)wglGetProcAddress("glAttachObjectARB");
605 glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)wglGetProcAddress("glDeleteObjectARB");
606 glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)wglGetProcAddress("glLinkProgramARB");
607 glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)wglGetProcAddress("glCompileShaderARB");
608 glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)wglGetProcAddress("glShaderSourceARB");
609 glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)wglGetProcAddress("glUseProgramObjectARB");
610 glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)wglGetProcAddress("glActiveTextureARB");
611 glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)wglGetProcAddress("glGetUniformLocationARB");
612 glUniform1iARB = (PFNGLUNIFORM1IARBPROC)wglGetProcAddress("glUniform1iARB");
613 glUniform1fARB = (PFNGLUNIFORM1FARBPROC)wglGetProcAddress("glUniform1fARB");
614 glUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC)wglGetProcAddress("glUniformMatrix3fvARB");
615 glUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC)wglGetProcAddress("glUniformMatrix4fvARB");
616 glUniform4fvARB = (PFNGLUNIFORM4FVARBPROC)wglGetProcAddress("glUniform4fvARB");
617 glUniform2fvARB = (PFNGLUNIFORM2FVARBPROC)wglGetProcAddress("glUniform2fvARB");
618 glBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC)wglGetProcAddress("glBindAttribLocationARB");
619 glEnableVertexAttribArrayARB = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC)wglGetProcAddress("glEnableVertexAttribArrayARB");
620 glVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC)wglGetProcAddress("glVertexAttribPointerARB");
621 glDisableVertexAttribArrayARB = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)wglGetProcAddress("glDisableVertexAttribArrayARB");
622 glValidateProgramARB = (PFNGLVALIDATEPROGRAMARBPROC)wglGetProcAddress("glValidateProgramARB");
623#endif
624
625 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &textureImageUnitCount);
626
627 shadersAvailable = YES;
628}
#define OOLog(class, format,...)
Definition OOLogging.h:88
static NSString *const kOOLogOpenGLShaderSupport
return nil

References checkShadersSupported, kOOLogOpenGLShaderSupport, nil, and OOLog.

Referenced by checkShadersSupported.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init [1/2]

- (id) init

Scans the command line for -nosplash, –nosplash, -splash, –splash- -novsync and –novsync arguments.

Definition at line 174 of file MyOpenGLView.m.

175{
176 self = [super init];
177
178 Uint32 colorkey;
179 SDL_Surface *icon=NULL;
180 NSString *imagesDir;
181 NSString *cmdLineArgsStr = @"Startup command: ";
182
183 // SDL splash screen settings
184
185 NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
186 showSplashScreen = [prefs oo_boolForKey:@"splash-screen" defaultValue:YES];
187 BOOL vSyncPreference = [prefs oo_boolForKey:@"v-sync" defaultValue:YES];
188 int bitsPerColorComponent = [prefs oo_boolForKey:@"hdr" defaultValue:NO] ? 16 : 8;
189 int vSyncValue;
190
191 NSArray *arguments = nil;
192 NSEnumerator *argEnum = nil;
193 NSString *arg = nil;
194 BOOL noSplashArgFound = NO;
195
196 [self initKeyMappingData];
197
198 // preload the printscreen key into our translation array because SDLK_PRINTSCREEN isn't available
200
201 arguments = [[NSProcessInfo processInfo] arguments];
202
203 // scan for splash screen overrides: -nosplash || --nosplash , -splash || --splash
204 // scan for V-sync disabling overrides: -novsync || --novsync
205 for (argEnum = [arguments objectEnumerator]; (arg = [argEnum nextObject]); )
206 {
207 if ([arg isEqual:@"-nosplash"] || [arg isEqual:@"--nosplash"])
208 {
209 showSplashScreen = NO;
210 noSplashArgFound = YES; // -nosplash always trumps -splash
211 }
212 else if (([arg isEqual:@"-splash"] || [arg isEqual:@"--splash"]) && !noSplashArgFound)
213 {
214 showSplashScreen = YES;
215 }
216
217 // if V-sync is disabled at the command line, override the defaults file
218 if ([arg isEqual:@"-novsync"] || [arg isEqual:@"--novsync"]) vSyncPreference = NO;
219
220 if ([arg isEqual: @"-hdr"]) bitsPerColorComponent = 16;
221
222 // build the startup command string so that we can log it
223 cmdLineArgsStr = [cmdLineArgsStr stringByAppendingFormat:@"%@ ", arg];
224 }
225
226 OOLog(@"process.args", @"%@", cmdLineArgsStr);
227
228 matrixManager = [[OOOpenGLMatrixManager alloc] init];
229
230 // TODO: This code up to and including stickHandler really ought
231 // not to be in this class.
232 OOLog(@"sdl.init", @"%@", @"initialising SDL");
233 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0)
234 {
235 OOLog(@"sdl.init.failed", @"Unable to init SDL: %s\n", SDL_GetError());
236 [self dealloc];
237 return nil;
238 }
239
240 SDL_putenv ("SDL_VIDEO_WINDOW_POS=center");
241
243 // end TODO
244
245 [OOSound setUp];
246 if (![OOSound isSoundOK]) OOLog(@"sound.init", @"%@", @"Sound system disabled.");
247
248 // Generate the window caption, containing the version number and the date the executable was compiled.
249 static char windowCaption[128];
250 NSString *versionString = [NSString stringWithFormat:@"Oolite v%@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]];
251
252 strcpy (windowCaption, [versionString UTF8String]);
253 strcat (windowCaption, " - "__DATE__);
254 SDL_WM_SetCaption (windowCaption, "Oolite"); // Set window title.
255
256#if OOLITE_WINDOWS
257 // needed for enabling system window manager events, which is needed for handling window movement messages
258 SDL_EventState (SDL_SYSWMEVENT, SDL_ENABLE);
259
260 //capture the window handle for later
261 static SDL_SysWMinfo wInfo;
262 SDL_VERSION(&wInfo.version);
263 SDL_GetWMInfo(&wInfo);
264 SDL_Window = wInfo.window;
265
266 // This must be inited after SDL_Window has been set - we need the main window handle in order to get monitor info
267 if (![self getCurrentMonitorInfo:&monitorInfo])
268 {
269 OOLogWARN(@"display.initGL.monitorInfoWarning", @"Could not get current monitor information.");
270 }
271
272 atDesktopResolution = YES;
273
274#if USE_UNDOCUMENTED_DARKMODE_API
275 // dark mode stuff - this is mainly for the winodw titlebar's context menu
276 HMODULE hUxTheme = LoadLibraryExW(L"uxtheme.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
277 if (hUxTheme)
278 {
279 // hack alert! ordinal 135 is undocumented and could change in a future version of Windows
280 pfnSetPreferredAppMode SetPreferredAppMode = (pfnSetPreferredAppMode)GetProcAddress(hUxTheme, MAKEINTRESOURCEA(135));
281 if (SetPreferredAppMode) SetPreferredAppMode(AllowDark);
282 FreeLibrary(hUxTheme);
283 }
284#endif
285#endif //OOLITE_WINDOWS
286
287 grabMouseStatus = NO;
288
289 imagesDir = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Images"];
290 icon = SDL_LoadBMP([[imagesDir stringByAppendingPathComponent:@"WMicon.bmp"] UTF8String]);
291
292 if (icon != NULL)
293 {
294 colorkey = SDL_MapRGB(icon->format, 128, 0, 128);
295 SDL_SetColorKey(icon, SDL_SRCCOLORKEY, colorkey);
296 SDL_WM_SetIcon(icon, NULL);
297 }
298 SDL_FreeSurface(icon);
299
300 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, bitsPerColorComponent);
301 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, bitsPerColorComponent);
302 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, bitsPerColorComponent);
303 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, bitsPerColorComponent);
304 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
305 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
306
307 _colorSaturation = 1.0f;
308
309 _hdrOutput = NO;
310#if OOLITE_WINDOWS
311 _hdrMaxBrightness = [prefs oo_floatForKey:@"hdr-max-brightness" defaultValue:1000.0f];
312 _hdrPaperWhiteBrightness = [prefs oo_floatForKey:@"hdr-paperwhite-brightness" defaultValue:200.0f];
313 _hdrToneMapper = OOHDRToneMapperFromString([prefs oo_stringForKey:@"hdr-tone-mapper" defaultValue:@"OOHDR_TONEMAPPER_ACES_APPROX"]);
314 if (bitsPerColorComponent == 16)
315 {
316 // SDL.dll built specifically for Oolite required
317 SDL_GL_SetAttribute(SDL_GL_PIXEL_TYPE_FLOAT, 1);
318 _hdrOutput = YES;
319 }
320#endif
321
322 _sdrToneMapper = OOSDRToneMapperFromString([prefs oo_stringForKey:@"sdr-tone-mapper" defaultValue:@"OOSDR_TONEMAPPER_ACES"]);
323
324 // V-sync settings - we set here, but can only verify after SDL_SetVideoMode has been called.
325 SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, vSyncPreference); // V-sync on by default.
326 OOLog(@"display.initGL", @"V-Sync %@requested.", vSyncPreference ? @"" : @"not ");
327
328 /* Multisampling significantly improves graphics quality with
329 * basically no extra programming effort on our part, especially
330 * for curved surfaces like the planet, but is also expensive - in
331 * the worst case the entire scene must be rendered four
332 * times. For now it can be a hidden setting. If early testing
333 * doesn't give any problems (other than speed on low-end graphics
334 * cards) a game options entry might be useful. - CIM, 24 Aug 2013*/
335 if ([prefs oo_boolForKey:@"anti-aliasing" defaultValue:NO])
336 {
337 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
338 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
339 }
340
341 OOLog(@"display.mode.list", @"%@", @"CREATING MODE LIST");
342 [self populateFullScreenModelist];
343 currentSize = 0;
344
345 // Find what the full screen and windowed settings are.
346 fullScreen = NO;
347 [self loadFullscreenSettings];
348 [self loadWindowSize];
349
350 // Set up the drawing surface's dimensions.
351 firstScreen= (fullScreen) ? [self modeAsSize: currentSize] : currentWindowSize;
352 viewSize = firstScreen; // viewSize must be set prior to splash screen initialization
353
354 OOLog(@"display.initGL", @"Trying %d-bpcc, 24-bit depth buffer", bitsPerColorComponent);
355 [self createSurface];
356
357 if (surface == NULL)
358 {
359 // Retry with hardcoded 8 bits per color component
360 OOLog(@"display.initGL", @"%@", @"Trying 8-bpcc, 32-bit depth buffer");
361 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
362 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
363 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
364 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
365 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32);
366 [self createSurface];
367
368 if (surface == NULL)
369 {
370 // Still not working? One last go...
371 // Retry, allowing 16-bit contexts.
372 OOLog(@"display.initGL", @"%@", @"Trying 5-bpcc, 16-bit depth buffer");
373 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
374 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
375 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
376 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
377 // and if it's this bad, forget even trying to multisample!
378 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
379 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
380
381 [self createSurface];
382
383 if (surface == NULL)
384 {
385 char * errStr = SDL_GetError();
386 OOLogERR(@"display.mode.error", @"Could not create display surface: %s", errStr);
387#if OOLITE_WINDOWS
389 {
390 [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"splash-screen"];
391 [[NSUserDefaults standardUserDefaults] synchronize];
392 OOLogWARN(@"display.mode.conflict",@"Possible incompatibility between the splash screen and video drivers detected.");
393 OOLogWARN(@"display.mode.conflict",@"Oolite will start without showing the splash screen from now on. Override with 'oolite.exe -splash'");
394 }
395#endif
396 exit(1);
397 }
398 }
399 }
400
401 int testAttrib = -1;
402 OOLog(@"display.initGL", @"%@", @"Achieved color / depth buffer sizes (bits):");
403 SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &testAttrib);
404 OOLog(@"display.initGL", @"Red: %d", testAttrib);
405 SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &testAttrib);
406 OOLog(@"display.initGL", @"Green: %d", testAttrib);
407 SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &testAttrib);
408 OOLog(@"display.initGL", @"Blue: %d", testAttrib);
409 SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &testAttrib);
410 OOLog(@"display.initGL", @"Alpha: %d", testAttrib);
411 SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &testAttrib);
412 OOLog(@"display.initGL", @"Depth Buffer: %d", testAttrib);
413#if OOLITE_WINDOWS
414 SDL_GL_GetAttribute(SDL_GL_PIXEL_TYPE_FLOAT, &testAttrib);
415 OOLog(@"display.initGL", @"Pixel type is float : %d", testAttrib);
416
417 OOLog(@"display.initGL", @"Pixel format index: %d", GetPixelFormat(GetDC(SDL_Window)));
418#endif
419
420 // Verify V-sync successfully set - report it if not
421 if (vSyncPreference && SDL_GL_GetAttribute(SDL_GL_SWAP_CONTROL, &vSyncValue) == -1)
422 {
423 OOLogWARN(@"display.initGL", @"Could not enable V-Sync. Please check that your graphics driver supports the %@_swap_control extension.",
424 OOLITE_WINDOWS ? @"WGL_EXT" : @"[GLX_SGI/GLX_MESA]");
425 }
426
427 bounds.size.width = surface->w;
428 bounds.size.height = surface->h;
429
430 [self autoShowMouse];
431
432 virtualJoystickPosition = NSMakePoint(0.0,0.0);
433 mouseWarped = NO;
434
435 _mouseVirtualStickSensitivityFactor = OOClamp_0_1_f([prefs oo_floatForKey:@"mouse-flight-sensitivity" defaultValue:0.95f]);
436 // ensure no chance of a divide by zero later on
438
439 typedString = [[NSMutableString alloc] initWithString:@""];
442
443 timeIntervalAtLastClick = timeSinceLastMouseWheel = [NSDate timeIntervalSinceReferenceDate];
444
445 _mouseWheelDelta = 0.0f;
446
448
449 return self;
450}
#define OOLITE_WINDOWS
Definition OOCocoa.h:259
OOSDRToneMapper OOSDRToneMapperFromString(NSString *string)
OOHDRToneMapper OOHDRToneMapperFromString(NSString *string)
#define OOLogWARN(class, format,...)
Definition OOLogging.h:113
#define OOLogERR(class, format,...)
Definition OOLogging.h:112
@ gvPrintScreenKey
@ gvStringInputNo
BOOL m_glContextInitialized
BOOL showSplashScreen
BOOL allowingStringInput
float _mouseVirtualStickSensitivityFactor
SDL_Surface * surface
float _mouseWheelDelta
NSSize currentWindowSize
NSMutableString * typedString
int scancode2Unicode[NUM_KEYS]
float _colorSaturation
NSPoint virtualJoystickPosition
NSTimeInterval timeSinceLastMouseWheel
OOOpenGLMatrixManager * matrixManager
NSSize firstScreen
NSTimeInterval timeIntervalAtLastClick
BOOL setStickHandlerClass:(Class aClass)
BOOL setUp()
Definition OOALSound.m:46

References _colorSaturation, _hdrOutput, _mouseVirtualStickSensitivityFactor, _mouseWheelDelta, _sdrToneMapper, allowingStringInput, autoShowMouse, bounds, createSurface, currentSize, currentWindowSize, dealloc, firstScreen, fullScreen, grabMouseStatus, gvPrintScreenKey, gvStringInputNo, init, initKeyMappingData, isAlphabetKeyDown, loadFullscreenSettings, loadWindowSize, m_glContextInitialized, matrixManager, mouseWarped, nil, OOHDRToneMapperFromString(), OOLITE_WINDOWS, OOLog, OOLogERR, OOLogWARN, OOSDRToneMapperFromString(), populateFullScreenModelist, scancode2Unicode, OOJoystickManager::setStickHandlerClass:, OOSound::setUp, showSplashScreen, surface, timeIntervalAtLastClick, timeSinceLastMouseWheel, typedString, viewSize, and virtualJoystickPosition.

Referenced by GameController::beginSplashScreen, and init.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init [2/2]

- (id) init

Scans the command line for -nosound or –nosound arguments.

Returns
returns the instance to OOOpenALController if sound shall be played and can be played, otherwise null

Definition at line 45 of file OOOpenALController.m.

46{
47 self = [super init];
48 if (self != nil)
49 {
50 NSArray *arguments = nil;
51 NSEnumerator *argEnum = nil;
52 NSString *arg = nil;
53
54 arguments = [[NSProcessInfo processInfo] arguments];
55 for (argEnum = [arguments objectEnumerator]; (arg = [argEnum nextObject]); )
56 {
57 if ([arg isEqual:@"-nosound"] || [arg isEqual:@"--nosound"])
58 {
59 [self release];
60 return nil;
61 }
62 }
63
64 ALuint error;
65 device = alcOpenDevice(NULL); // default device
66 if (!device)
67 {
68 OOLog(kOOLogSoundInitError, @"%@", @"Failed to open default sound device");
69 [self release];
70 return nil;
71 }
72 context = alcCreateContext(device,NULL); // default context
73 if (!alcMakeContextCurrent(context))
74 {
75 OOLog(kOOLogSoundInitError, @"%@", @"Failed to create default sound context");
76 [self release];
77 return nil;
78 }
79 if ((error = alGetError()) != AL_NO_ERROR)
80 {
81 OOLog(kOOLogSoundInitError,@"Error %d creating sound context",error);
82 }
83 OOAL(alDistanceModel(AL_NONE));
84 }
85 return self;
86}
static NSString *const kOOLogSoundInitError
#define OOAL(cmd)
Definition OOOpenAL.h:40

References context, device, init, kOOLogSoundInitError, nil, OOAL, and OOLog.

Referenced by init.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main() [1/2]

int main ( int argc,
char * argv[] )

Entry point for Linux and Windows systems. Initializes logging. If -load is passed, the argument after that is loaded as savegame.

Parameters
argcthe number of command line arguments
argvthe string array values of the command line arguments
Returns
returns 0 on success, or EXITFAILURE when an exception is caught

Definition at line 62 of file main.m.

63{
64#ifdef GNUSTEP
65 int i;
66
67#if (GNUSTEP_BASE_MAJOR_VERSION == 1 && (GNUSTEP_BASE_MINOR_VERSION == 24 && GNUSTEP_BASE_SUBMINOR_VERSION >= 9) || (GNUSTEP_BASE_MINOR_VERSION > 24)) || (GNUSTEP_BASE_MAJOR_VERSION > 1)
68 [NSDate class]; // See github issue #202
69#endif
70
71#if OOLITE_WINDOWS
72
73 #define OO_SHOW_MSG(ooMsg, ooMsgTitle, ooMsgFlags) MessageBox(NULL, ooMsg, ooMsgTitle, ooMsgFlags)
74 #define TABS1 "\t"
75 #define TABS2 "\t\t"
76 #define TABS3 "\t\t\t"
77 #define TABS4 ""
78
79 // Detect current working directory and set up GNUstep environment variables
80 #define MAX_PATH_LEN 256
81 char currentWorkingDir[MAX_PATH_LEN];
82 DWORD bufferSize = MAX_PATH_LEN;
83
84 QueryFullProcessImageName(GetCurrentProcess(), 0, currentWorkingDir, &bufferSize);
85 // Strip the exe filenameb (from last backslash onwards), leave just the path
86 char *probeString = strrchr(currentWorkingDir, '\\');
87 if (probeString) *probeString = '\0'; // currentWorkingDir now contains the path we need
88
89 // Prepend system PATH env variable with our own executable's path
90 char pathEnvVar[] = "PATH";
91 char *systemPath = SDL_getenv(pathEnvVar);
92 size_t currentWorkingDirLen = strlen(currentWorkingDir);
93 size_t systemPathLen = strlen(systemPath);
94 // the max possible length of the string below is systemPath plus the path
95 // we have determined for us, plus one char for the ";" and one char for the null terminator
96 char *finalPath = malloc(systemPathLen + currentWorkingDirLen + 2 * sizeof(char));
97 // the max possible length of the string below is systemPath plus the path we have
98 // determined for us, plus one char for the ";", plus the string "PATH", plus one char for the
99 // "=" of the final string that will be passed on to SDL_putenv and one char for the null terminator
100 char *envVarString = malloc(systemPathLen + currentWorkingDirLen + strlen(pathEnvVar) + 3 * sizeof(char));
101 strcpy(finalPath, currentWorkingDir);
102 strcat(finalPath, ";");
103 strcat(finalPath, systemPath);
104
105 #define SETENVVAR(var, value) do {\
106 sprintf(envVarString, "%s=%s", (var), (value));\
107 SDL_putenv (envVarString);\
108 } while (0);
109
110 SETENVVAR("GNUSTEP_PATH_HANDLING", "windows");
111 SETENVVAR(pathEnvVar, finalPath);
112 SETENVVAR("GNUSTEP_SYSTEM_ROOT", currentWorkingDir);
113 SETENVVAR("GNUSTEP_LOCAL_ROOT", currentWorkingDir);
114 SETENVVAR("GNUSTEP_NETWORK_ROOT", currentWorkingDir);
115 SETENVVAR("GNUSTEP_USERS_ROOT", currentWorkingDir);
116#if OO_GAME_DATA_TO_USER_FOLDER
117 SETENVVAR("HOMEPATH", strcat(SDL_getenv("LOCALAPPDATA"), "\\Oolite\\oolite.app"));
118#else
119 SETENVVAR("HOMEPATH", currentWorkingDir);
120#endif
121
122 SetCurrentDirectory(currentWorkingDir);
123
124 free(envVarString);
125 free(finalPath);
126
127 /* Windows amibtiously starts apps with the C library locale set to the
128 system locale rather than the "C" locale as per spec. Fixing here so
129 numbers don't behave strangely.
130 */
131 setlocale(LC_ALL, "C");
132
133#else // Linux
134 #define OO_SHOW_MSG(ooMsg, ooTitle, ooFlags) fprintf(stdout, "%s", ooMsg)
135 #define TABS1 "\t\t"
136 #define TABS2 "\t\t\t"
137 #define TABS3 "\t\t\t\t"
138 #define TABS4 "\t"
139#endif
140
141 // Need this because we're not using the default run loop's autorelease
142 // pool.
143 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
145
146 @try
147 {
148 // dajt: allocate and set the NSApplication delegate manually because not
149 // using NIB to do this
150 controller = [[GameController alloc] init];
151
152 for (i = 1; i < argc; i++)
153 {
154 if (strcmp("-load", argv[i]) == 0)
155 {
156 i++;
157 if (i < argc)
158 [controller setPlayerFileToLoad: [NSString stringWithCString: argv[i]]];
159 }
160
161 if (!strcmp("-help", argv[i]) || !strcmp("--help", argv[i]))
162 {
163 char const *processName = [[[NSProcessInfo processInfo] processName] UTF8String];
164 char s[2048];
165 snprintf(s, sizeof(s), "Usage: %s [options]\n\n"
166 "Options can be any of the following: \n\n"
167 "--compile-sysdesc"TABS2"Compile system descriptions *\n"
168 "--export-sysdesc"TABS2"Export system descriptions *\n"
170 "-hdr"TABS3"Start up in HDR mode\n"
171#endif
172 "-load [filepath]"TABS2"Load commander from [filepath]\n"
173 "-message [messageString]"TABS1"Display [messageString] at startup\n"
174 "-nodust "TABS2 TABS4"Do not draw space dust\n"
175 "-noshaders"TABS2 TABS4"Start up with shaders disabled\n"
176 "-nosplash "TABS2 TABS4"Force disable splash screen on startup\n"
177 "-nosound "TABS2 TABS4"Start up with sound disabled\n"
178 "-novsync"TABS3"Force disable V-Sync\n"
179 "--openstep"TABS2 TABS4"When compiling or exporting\n"TABS3 TABS4"system descriptions, use openstep\n"TABS3 TABS4"format *\n"
180 "-showversion"TABS2 TABS4"Display version at startup screen\n"
181 "-splash"TABS3 TABS4"Force splash screen on startup\n"
182 "-verify-oxp [filepath] "TABS1"Verify OXP at [filepath] *\n"
183 "--xml"TABS3 TABS4"When compiling or exporting\n"TABS3 TABS4"system descriptions, use xml\n"TABS3 TABS4"format *\n"
184 "\n"
185 "Options marked with \"*\" are available only in Test Release configuration.\n"
186 "Built with "
188 "Clang version " STRINGIFY(__clang_major__) "." STRINGIFY(__clang_minor__) "." STRINGIFY(__clang_patchlevel__)
189#else
190 "GCC version " STRINGIFY(__GNUC__) "." STRINGIFY(__GNUC_MINOR__) "." STRINGIFY(__GNUC_PATCHLEVEL__)
191#endif
192 "\n\n", processName
193 );
194 OO_SHOW_MSG(s, processName, MB_OK);
195 OOLog(@"process.args", @"%s option detected, exiting after help page has been displayed.", argv[i]);
196 return 0;
197 }
198 }
199
200 // Release anything allocated during the controller initialisation that
201 // is no longer required.
202 DESTROY(pool);
203
204 // Call applicationDidFinishLaunching because NSApp is not running in
205 // GNUstep port.
206 [controller applicationDidFinishLaunching: nil];
207 }
208 @catch (NSException *exception)
209 {
210 OOLogERR(kOOLogException, @"Root exception handler hit - terminating. This is an internal error, please report it. Exception name: %@, reason: %@", [exception name], [exception reason]);
211 return EXIT_FAILURE;
212 }
213#endif
214
215 // never reached
216 return 0;
217}
#define OOLITE_HAVE_CLANG
Definition OOCocoa.h:114
#define DESTROY(x)
Definition OOCocoa.h:85
NSString *const kOOLogException
Definition OOLogging.m:651
void OOLoggingInit(void)
Definition OOLogging.m:585

References GameController::applicationDidFinishLaunching:, DESTROY, kOOLogException, OOLITE_HAVE_CLANG, OOLITE_WINDOWS, OOLog, OOLogERR, OOLoggingInit(), and GameController::setPlayerFileToLoad:.

Here is the call graph for this function:

◆ main() [2/2]

int main ( int argc,
const char * argv[] )

Entry point for MacOS. Initializes logging and runs NSApplicationMain.

Parameters
argcthe number of command line arguments
argvthe string array values of the command line arguments
Returns
whatever NSApplicationMain returns

Definition at line 18 of file main.m.

19{
21 return NSApplicationMain(argc, argv);
22}

References OOLoggingInit().

Here is the call graph for this function:

◆ runLocalizationTools

- (void) runLocalizationTools

Scans the command line for –complie-sysdesc, –export-sysdec, –xml and –penstep arguments.

Extends class Universe.

Definition at line 10987 of file Universe.m.

10988{
10989 // Handle command line options to transform system_description array for easier localization
10990
10991 NSArray *arguments = nil;
10992 NSEnumerator *argEnum = nil;
10993 NSString *arg = nil;
10994 BOOL compileSysDesc = NO, exportSysDesc = NO, xml = NO;
10995
10996 arguments = [[NSProcessInfo processInfo] arguments];
10997
10998 for (argEnum = [arguments objectEnumerator]; (arg = [argEnum nextObject]); )
10999 {
11000 if ([arg isEqual:@"--compile-sysdesc"]) compileSysDesc = YES;
11001 else if ([arg isEqual:@"--export-sysdesc"]) exportSysDesc = YES;
11002 else if ([arg isEqual:@"--xml"]) xml = YES;
11003 else if ([arg isEqual:@"--openstep"]) xml = NO;
11004 }
11005
11006 if (compileSysDesc) CompileSystemDescriptions(xml);
11007 if (exportSysDesc) ExportSystemDescriptions(xml);
11008}
void CompileSystemDescriptions(BOOL asXML)
void ExportSystemDescriptions(BOOL asXML)

References CompileSystemDescriptions(), ExportSystemDescriptions(), nil, and runLocalizationTools.

Referenced by Universe::initWithGameView:, and runLocalizationTools.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runVerificationIfRequested

+ (BOOL) runVerificationIfRequested

Scans the command line for -verify-oxp or –verify-oxp, followed by a path to the oxp to verify.

Returns
YES or NO

Definition at line 96 of file OOOXPVerifier.m.

97{
98 NSArray *arguments = nil;
99 NSEnumerator *argEnum = nil;
100 NSString *arg = nil;
101 NSString *foundPath = nil;
102 BOOL exists, isDirectory;
103 OOOXPVerifier *verifier = nil;
104 NSAutoreleasePool *pool = nil;
105
106 pool = [[NSAutoreleasePool alloc] init];
107
108 arguments = [[NSProcessInfo processInfo] arguments];
109
110 // Scan for -verify-oxp or --verify-oxp followed by relative path
111 for (argEnum = [arguments objectEnumerator]; (arg = [argEnum nextObject]); )
112 {
113 if ([arg isEqual:@"-verify-oxp"] || [arg isEqual:@"--verify-oxp"])
114 {
115 foundPath = [argEnum nextObject];
116 if (foundPath == nil)
117 {
118 OOLog(@"verifyOXP.noPath", @"***** ERROR: %@ passed without path argument; nothing to verify.", arg);
119 [pool release];
120 return YES;
121 }
122 foundPath = [foundPath stringByExpandingTildeInPath];
123 break;
124 }
125 }
126
127 if (foundPath == nil)
128 {
129 [pool release];
130 return NO;
131 }
132
133 // We got a path; does it point to a directory?
134 exists = [[NSFileManager defaultManager] fileExistsAtPath:foundPath isDirectory:&isDirectory];
135 if (!exists)
136 {
137 OOLog(@"verifyOXP.badPath", @"***** ERROR: no OXP exists at path \"%@\"; nothing to verify.", foundPath);
138 }
139 else if (!isDirectory)
140 {
141 OOLog(@"verifyOXP.badPath", @"***** ERROR: \"%@\" is a file, not an OXP directory; nothing to verify.", foundPath);
142 }
143 else
144 {
145 verifier = [[OOOXPVerifier alloc] initWithPath:foundPath];
146 [pool release];
147 pool = [[NSAutoreleasePool alloc] init];
148 [verifier run];
149 [verifier release];
150 }
151 [pool release];
152
153 // Whether or not we got a valid path, -verify-oxp was passed.
154 return YES;
155}

References nil, OOLog, run, and runVerificationIfRequested.

Referenced by runVerificationIfRequested.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGuiToIntroFirstGo:

- (void) setGuiToIntroFirstGo: (BOOL) justCobra

Scans the command line for -message or -showversion arguments.

Definition at line 10003 of file PlayerEntity.m.

10003 :(BOOL)justCobra
10004{
10005 NSString *text = nil;
10006 GuiDisplayGen *gui = [UNIVERSE gui];
10007 OOGUIRow msgLine = 2;
10008
10009 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:NO];
10010 [[UNIVERSE gameView] clearMouse];
10011 [[UNIVERSE gameView] clearKeys];
10012
10013
10014 if (justCobra)
10015 {
10016 [UNIVERSE removeDemoShips];
10017 [[OOCacheManager sharedCache] flush]; // At first startup, a lot of stuff is cached
10018 }
10019
10020 if (justCobra)
10021 {
10022 [self setupStartScreenGui];
10023
10024 // check for error messages from Resource Manager
10025 //[ResourceManager paths]; done in Universe already
10026 NSString *errors = [ResourceManager errors];
10027 if (errors != nil)
10028 {
10029 OOGUIRow ms_start = msgLine;
10030 OOGUIRow i = msgLine = [gui addLongText:errors startingAtRow:ms_start align:GUI_ALIGN_LEFT];
10031 for (i-- ; i >= ms_start ; i--) [gui setColor:[OOColor redColor] forRow:i];
10032 msgLine++;
10033 }
10034
10035 // check for messages from OXPs
10036 NSArray *OXPsWithMessages = [ResourceManager OXPsWithMessagesFound];
10037 if ([OXPsWithMessages count] > 0)
10038 {
10039 NSString *messageToDisplay = @"";
10040
10041 // Show which OXPs were found with messages, but don't spam the screen if more than
10042 // a certain number of them exist
10043 if ([OXPsWithMessages count] < 5)
10044 {
10045 NSString *messageSourceList = [OXPsWithMessages componentsJoinedByString:@", "];
10046 messageToDisplay = OOExpandKey(@"oxp-containing-messages-list", messageSourceList);
10047 } else {
10048 messageToDisplay = OOExpandKey(@"oxp-containing-messages-found");
10049 }
10050
10051 OOGUIRow ms_start = msgLine;
10052 OOGUIRow i = msgLine = [gui addLongText:messageToDisplay startingAtRow:ms_start align:GUI_ALIGN_LEFT];
10053 for (i--; i >= ms_start; i--)
10054 {
10055 [gui setColor:[OOColor orangeColor] forRow:i];
10056 }
10057 msgLine++;
10058 }
10059
10060 // check for messages from the command line
10061 NSArray* arguments = [[NSProcessInfo processInfo] arguments];
10062 unsigned i;
10063 for (i = 0; i < [arguments count]; i++)
10064 {
10065 if (([[arguments objectAtIndex:i] isEqual:@"-message"])&&(i < [arguments count] - 1))
10066 {
10067 OOGUIRow ms_start = msgLine;
10068 NSString* message = [arguments oo_stringAtIndex:i + 1];
10069 OOGUIRow i = msgLine = [gui addLongText:message startingAtRow:ms_start align:GUI_ALIGN_CENTER];
10070 for (i-- ; i >= ms_start; i--)
10071 {
10072 [gui setColor:[OOColor magentaColor] forRow:i];
10073 }
10074 }
10075 if ([[arguments objectAtIndex:i] isEqual:@"-showversion"])
10076 {
10077 OOGUIRow ms_start = msgLine;
10078 NSString *version = [NSString stringWithFormat:@"Version %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]];
10079 OOGUIRow i = msgLine = [gui addLongText:version startingAtRow:ms_start align:GUI_ALIGN_CENTER];
10080 for (i-- ; i >= ms_start; i--)
10081 {
10082 [gui setColor:[OOColor magentaColor] forRow:i];
10083 }
10084 }
10085 }
10086 }
10087 else
10088 {
10089 [gui clear];
10090
10091 text = DESC(@"oolite-ship-library-title");
10092 [gui setTitle:text];
10093
10094 text = DESC(@"oolite-ship-library-exit");
10095 [gui setText:text forRow:27 align:GUI_ALIGN_CENTER];
10096 [gui setColor:[OOColor yellowColor] forRow:27];
10097 }
10098
10099 [gui setShowTextCursor:NO];
10100
10101 [UNIVERSE setupIntroFirstGo: justCobra];
10102
10103 if (gui != nil)
10104 {
10105 gui_screen = justCobra ? GUI_SCREEN_INTRO1 : GUI_SCREEN_SHIPLIBRARY;
10106 }
10107 if ([self status] == STATUS_START_GAME)
10108 {
10110 }
10111
10112 [self setShowDemoShips:YES];
10113 if (justCobra)
10114 {
10115 [gui setBackgroundTextureKey:@"intro"];
10116 }
10117 else
10118 {
10119 [gui setBackgroundTextureKey:@"shiplibrary"];
10120 }
10121 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
10122}
NSInteger OOGUIRow
unsigned count
#define OOExpandKey(key,...)
#define DESC(key)
Definition Universe.h:850
OOEntityStatus status()
Definition Entity.m:793
BOOL setBackgroundTextureKey:(NSString *key)
OOGUIRow addLongText:startingAtRow:align:(NSString *str,[startingAtRow] OOGUIRow row,[align] OOGUIAlignment alignment)
void setText:forRow:align:(NSString *str,[forRow] OOGUIRow row,[align] OOGUIAlignment alignment)
void setColor:forRow:(OOColor *color,[forRow] OOGUIRow row)
void setTitle:(NSString *str)
void setShowTextCursor:(BOOL yesno)
OOCacheManager * sharedCache()
OOColor * orangeColor()
Definition OOColor.m:304
OOColor * yellowColor()
Definition OOColor.m:292
OOColor * magentaColor()
Definition OOColor.m:298
OOMusicController * sharedController()
OOGUIScreenID gui_screen
NSArray * OXPsWithMessagesFound()

References GuiDisplayGen::addLongText:startingAtRow:align:, GuiDisplayGen::clear, count, DESC, ResourceManager::errors, OOCacheManager::flush, gui_screen, OOColor::magentaColor, nil, OOExpandKey, OOColor::orangeColor, ResourceManager::OXPsWithMessagesFound, OOMusicController::playThemeMusic, OOColor::redColor, GuiDisplayGen::setBackgroundTextureKey:, GuiDisplayGen::setColor:forRow:, setShowDemoShips:, GuiDisplayGen::setShowTextCursor:, GuiDisplayGen::setText:forRow:align:, GuiDisplayGen::setTitle:, setupStartScreenGui, OOCacheManager::sharedCache, OOMusicController::sharedController, Entity::status, and OOColor::yellowColor.

Referenced by PlayerEntity(LoadSave)::commanderSelector, PlayerEntity(OOControlsPrivate)::pollDemoControls:, Universe::reinitAndShowDemo:, and update:.

Here is the call graph for this function:
Here is the caller graph for this function: