Oolite 1.91.0.7644-241112-7f5034b
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 529 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 EXPECT_NOT.

◆ init [1/2]

- (id) init

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

Definition at line 50 of file MyOpenGLView.m.

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

◆ 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 30 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 nil, and sSingleton.

◆ 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 char envVarString[2 * MAX_PATH_LEN];
83 DWORD bufferSize = MAX_PATH_LEN;
84
85 QueryFullProcessImageName(GetCurrentProcess(), 0, currentWorkingDir, &bufferSize);
86 // Strip the exe filenameb (from last backslash onwards), leave just the path
87 char *probeString = strrchr(currentWorkingDir, '\\');
88 if (probeString) *probeString = '\0'; // currentWorkingDir now contains the path we need
89
90 // Prepend system PATH env variable with our own executable's path
91 char finalPath[16 * MAX_PATH_LEN];
92 char *systemPath = SDL_getenv("PATH");
93 strcpy(finalPath, currentWorkingDir);
94 strcat(finalPath, ";");
95 strcat(finalPath, systemPath);
96
97 #define SETENVVAR(var, value) do {\
98 sprintf(envVarString, "%s=%s", (var), (value));\
99 SDL_putenv (envVarString);\
100 } while (0);
101
102 SETENVVAR("GNUSTEP_PATH_HANDLING", "windows");
103 SETENVVAR("PATH", finalPath);
104 SETENVVAR("GNUSTEP_SYSTEM_ROOT", currentWorkingDir);
105 SETENVVAR("GNUSTEP_LOCAL_ROOT", currentWorkingDir);
106 SETENVVAR("GNUSTEP_NETWORK_ROOT", currentWorkingDir);
107 SETENVVAR("GNUSTEP_USERS_ROOT", currentWorkingDir);
108 SETENVVAR("HOMEPATH", currentWorkingDir);
109
110 SetCurrentDirectory(currentWorkingDir);
111
112 /* Windows amibtiously starts apps with the C library locale set to the
113 system locale rather than the "C" locale as per spec. Fixing here so
114 numbers don't behave strangely.
115 */
116 setlocale(LC_ALL, "C");
117
118#else // Linux
119 #define OO_SHOW_MSG(ooMsg, ooTitle, ooFlags) fprintf(stdout, ooMsg)
120 #define TABS1 "\t\t"
121 #define TABS2 "\t\t\t"
122 #define TABS3 "\t\t\t\t"
123 #define TABS4 "\t"
124#endif
125
126 // Need this because we're not using the default run loop's autorelease
127 // pool.
128 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
130
131 @try
132 {
133 // dajt: allocate and set the NSApplication delegate manually because not
134 // using NIB to do this
135 controller = [[GameController alloc] init];
136
137 for (i = 1; i < argc; i++)
138 {
139 if (strcmp("-load", argv[i]) == 0)
140 {
141 i++;
142 if (i < argc)
143 [controller setPlayerFileToLoad: [NSString stringWithCString: argv[i]]];
144 }
145
146 if (!strcmp("-help", argv[i]) || !strcmp("--help", argv[i]))
147 {
148 char const *processName = [[[NSProcessInfo processInfo] processName] UTF8String];
149 char s[2048];
150 snprintf(s, sizeof(s), "Usage: %s [options]\n\n"
151 "Options can be any of the following: \n\n"
152 "--compile-sysdesc"TABS2"Compile system descriptions *\n"
153 "--export-sysdesc"TABS2"Export system descriptions *\n"
155 "-hdr"TABS3"Start up in HDR mode\n"
156#endif
157 "-load [filepath]"TABS2"Load commander from [filepath]\n"
158 "-message [messageString]"TABS1"Display [messageString] at startup\n"
159 "-noshaders"TABS2 TABS4"Start up with shaders disabled\n"
160 "-nosplash "TABS2 TABS4"Force disable splash screen on startup\n"
161 "-nosound "TABS2 TABS4"Start up with sound disabled\n"
162 "-novsync"TABS3"Force disable V-Sync\n"
163 "--openstep"TABS2 TABS4"When compiling or exporting\n"TABS3 TABS4"system descriptions, use openstep\n"TABS3 TABS4"format *\n"
164 "-showversion"TABS2 TABS4"Display version at startup screen\n"
165 "-splash"TABS3 TABS4"Force splash screen on startup\n"
166 "-verify-oxp [filepath] "TABS1"Verify OXP at [filepath] *\n"
167 "--xml"TABS3 TABS4"When compiling or exporting\n"TABS3 TABS4"system descriptions, use xml\n"TABS3 TABS4"format *\n"
168 "\n"
169 "Options marked with \"*\" are available only in Test Release configuration.\n\n", processName);
170 OO_SHOW_MSG(s, processName, MB_OK);
171 OOLog(@"process.args", @"%s option detected, exiting after help page has been displayed.", argv[i]);
172 return 0;
173 }
174 }
175
176 // Release anything allocated during the controller initialisation that
177 // is no longer required.
178 DESTROY(pool);
179
180 // Call applicationDidFinishLaunching because NSApp is not running in
181 // GNUstep port.
182 [controller applicationDidFinishLaunching: nil];
183 }
184 @catch (NSException *exception)
185 {
186 OOLogERR(kOOLogException, @"Root exception handler hit - terminating. This is an internal error, please report it. Exception name: %@, reason: %@", [exception name], [exception reason]);
187 return EXIT_FAILURE;
188 }
189#endif
190
191 // never reached
192 return 0;
193}
#define DESTROY(x)
Definition OOCocoa.h:77
NSString *const kOOLogException
Definition OOLogging.m:651
void OOLoggingInit(void)
Definition OOLogging.m:585

References GameController::applicationDidFinishLaunching:, DESTROY, kOOLogException, 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 10697 of file Universe.m.

10949{
10950 // Handle command line options to transform system_description array for easier localization
10951
10952 NSArray *arguments = nil;
10953 NSEnumerator *argEnum = nil;
10954 NSString *arg = nil;
10955 BOOL compileSysDesc = NO, exportSysDesc = NO, xml = NO;
10956
10957 arguments = [[NSProcessInfo processInfo] arguments];
10958
10959 for (argEnum = [arguments objectEnumerator]; (arg = [argEnum nextObject]); )
10960 {
10961 if ([arg isEqual:@"--compile-sysdesc"]) compileSysDesc = YES;
10962 else if ([arg isEqual:@"--export-sysdesc"]) exportSysDesc = YES;
10963 else if ([arg isEqual:@"--xml"]) xml = YES;
10964 else if ([arg isEqual:@"--openstep"]) xml = NO;
10965 }
10966
10967 if (compileSysDesc) CompileSystemDescriptions(xml);
10968 if (exportSysDesc) ExportSystemDescriptions(xml);
10969}
void CompileSystemDescriptions(BOOL asXML)
void ExportSystemDescriptions(BOOL asXML)

◆ 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 727 of file OOOXPVerifier.m.

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

◆ setGuiToIntroFirstGo:

- (void) setGuiToIntroFirstGo: (BOOL) justCobra

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

Definition at line 9211 of file PlayerEntity.m.

9964 :(BOOL)justCobra
9965{
9966 NSString *text = nil;
9967 GuiDisplayGen *gui = [UNIVERSE gui];
9968 OOGUIRow msgLine = 2;
9969
9970 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:NO];
9971 [[UNIVERSE gameView] clearMouse];
9972 [[UNIVERSE gameView] clearKeys];
9973
9974
9975 if (justCobra)
9976 {
9977 [UNIVERSE removeDemoShips];
9978 [[OOCacheManager sharedCache] flush]; // At first startup, a lot of stuff is cached
9979 }
9980
9981 if (justCobra)
9982 {
9983 [self setupStartScreenGui];
9984
9985 // check for error messages from Resource Manager
9986 //[ResourceManager paths]; done in Universe already
9987 NSString *errors = [ResourceManager errors];
9988 if (errors != nil)
9989 {
9990 OOGUIRow ms_start = msgLine;
9991 OOGUIRow i = msgLine = [gui addLongText:errors startingAtRow:ms_start align:GUI_ALIGN_LEFT];
9992 for (i-- ; i >= ms_start ; i--) [gui setColor:[OOColor redColor] forRow:i];
9993 msgLine++;
9994 }
9995
9996 // check for messages from OXPs
9997 NSArray *OXPsWithMessages = [ResourceManager OXPsWithMessagesFound];
9998 if ([OXPsWithMessages count] > 0)
9999 {
10000 NSString *messageToDisplay = @"";
10001
10002 // Show which OXPs were found with messages, but don't spam the screen if more than
10003 // a certain number of them exist
10004 if ([OXPsWithMessages count] < 5)
10005 {
10006 NSString *messageSourceList = [OXPsWithMessages componentsJoinedByString:@", "];
10007 messageToDisplay = OOExpandKey(@"oxp-containing-messages-list", messageSourceList);
10008 } else {
10009 messageToDisplay = OOExpandKey(@"oxp-containing-messages-found");
10010 }
10011
10012 OOGUIRow ms_start = msgLine;
10013 OOGUIRow i = msgLine = [gui addLongText:messageToDisplay startingAtRow:ms_start align:GUI_ALIGN_LEFT];
10014 for (i--; i >= ms_start; i--)
10015 {
10016 [gui setColor:[OOColor orangeColor] forRow:i];
10017 }
10018 msgLine++;
10019 }
10020
10021 // check for messages from the command line
10022 NSArray* arguments = [[NSProcessInfo processInfo] arguments];
10023 unsigned i;
10024 for (i = 0; i < [arguments count]; i++)
10025 {
10026 if (([[arguments objectAtIndex:i] isEqual:@"-message"])&&(i < [arguments count] - 1))
10027 {
10028 OOGUIRow ms_start = msgLine;
10029 NSString* message = [arguments oo_stringAtIndex:i + 1];
10030 OOGUIRow i = msgLine = [gui addLongText:message startingAtRow:ms_start align:GUI_ALIGN_CENTER];
10031 for (i-- ; i >= ms_start; i--)
10032 {
10033 [gui setColor:[OOColor magentaColor] forRow:i];
10034 }
10035 }
10036 if ([[arguments objectAtIndex:i] isEqual:@"-showversion"])
10037 {
10038 OOGUIRow ms_start = msgLine;
10039 NSString *version = [NSString stringWithFormat:@"Version %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]];
10040 OOGUIRow i = msgLine = [gui addLongText:version startingAtRow:ms_start align:GUI_ALIGN_CENTER];
10041 for (i-- ; i >= ms_start; i--)
10042 {
10043 [gui setColor:[OOColor magentaColor] forRow:i];
10044 }
10045 }
10046 }
10047 }
10048 else
10049 {
10050 [gui clear];
10051
10052 text = DESC(@"oolite-ship-library-title");
10053 [gui setTitle:text];
10054
10055 text = DESC(@"oolite-ship-library-exit");
10056 [gui setText:text forRow:27 align:GUI_ALIGN_CENTER];
10057 [gui setColor:[OOColor yellowColor] forRow:27];
10058 }
10059
10060 [gui setShowTextCursor:NO];
10061
10062 [UNIVERSE setupIntroFirstGo: justCobra];
10063
10064 if (gui != nil)
10065 {
10066 gui_screen = justCobra ? GUI_SCREEN_INTRO1 : GUI_SCREEN_SHIPLIBRARY;
10067 }
10068 if ([self status] == STATUS_START_GAME)
10069 {
10071 }
10072
10073 [self setShowDemoShips:YES];
10074 if (justCobra)
10075 {
10076 [gui setBackgroundTextureKey:@"intro"];
10077 }
10078 else
10079 {
10080 [gui setBackgroundTextureKey:@"shiplibrary"];
10081 }
10082 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
10083}
NSInteger OOGUIRow
unsigned count
#define OOExpandKey(key,...)
#define DESC(key)
Definition Universe.h:839
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()