76int main(
int argc,
char* argv[])
78#if defined(GNUSTEP_BASE_LIBRARY) || defined(OOLITE_SDL_MAC)
81#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)
87#define OO_SHOW_MSG(ooMsg, ooMsgTitle, ooMsgFlags) MessageBox(NULL, ooMsg, ooMsgTitle, ooMsgFlags)
94#define MAX_PATH_LEN 256
95 char currentWorkingDir[MAX_PATH_LEN];
96 DWORD bufferSize = MAX_PATH_LEN;
98 QueryFullProcessImageName(GetCurrentProcess(), 0, currentWorkingDir, &bufferSize);
100 char* probeString = strrchr(currentWorkingDir,
'\\');
105 char* pathEnvVar =
"Path";
106 const char* systemPath = SDL_getenv(pathEnvVar);
109 systemPath = SDL_getenv(pathEnvVar);
111 size_t currentWorkingDirLen = strlen(currentWorkingDir);
112 size_t systemPathLen = strlen(systemPath);
115 char* finalPath = malloc(systemPathLen + currentWorkingDirLen + 2 *
sizeof(
char));
116 strcpy(finalPath, currentWorkingDir);
117 strcat(finalPath,
";");
118 strcat(finalPath, systemPath);
120 SDL_setenv_unsafe(
"GNUSTEP_PATH_HANDLING",
"windows", YES);
121 SDL_setenv_unsafe(pathEnvVar, finalPath, YES);
122 SDL_setenv_unsafe(
"GNUSTEP_SYSTEM_ROOT", currentWorkingDir, YES);
123 SDL_setenv_unsafe(
"GNUSTEP_LOCAL_ROOT", currentWorkingDir, YES);
124 SDL_setenv_unsafe(
"GNUSTEP_NETWORK_ROOT", currentWorkingDir, YES);
125 SDL_setenv_unsafe(
"GNUSTEP_USERS_ROOT", currentWorkingDir, YES);
126#if OO_GAME_DATA_TO_USER_FOLDER
127 SDL_setenv_unsafe(
"HOMEPATH", strcat(SDL_getenv(
"LOCALAPPDATA"),
"\\Oolite\\oolite.app"), YES);
129 SDL_setenv_unsafe(
"HOMEPATH", currentWorkingDir, YES);
132 SetCurrentDirectory(currentWorkingDir);
140 setlocale(LC_ALL,
"C");
144 char result[PATH_MAX];
145 ssize_t
count = readlink(
"/proc/self/exe", result, PATH_MAX - 1);
146 result[count] =
'\0';
147 char* last_slash = strrchr(result,
'/');
148 if (last_slash != NULL) {
155 char result[PATH_MAX];
156 uint32_t resultSize =
sizeof(result);
157 char resolved[PATH_MAX];
158 if (_NSGetExecutablePath(result, &resultSize) == 0 && realpath(result, resolved) != NULL) {
159 char* last_slash = strrchr(resolved,
'/');
160 if (last_slash != NULL) {
164 size_t length = strlen(resolved);
165 if (length >= 15 && strcmp(resolved + length - 15,
"/Contents/MacOS") == 0) {
170#define OO_SHOW_MSG(ooMsg, ooTitle, ooFlags) fprintf(stdout, "%s", ooMsg)
172#define TABS2 "\t\t\t"
173#define TABS3 "\t\t\t\t"
179 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
187 for (i = 1; i < argc; i++) {
188 if (strcmp(
"-load", argv[i]) == 0) {
191 NSString* argument = [NSString stringWithCString:argv[i]];
192 if (i < argc && [[argument lowercaseString] hasSuffix:
@".oolite-save"]) {
196 if (!strcmp(
"-help", argv[i]) || !strcmp(
"--help", argv[i])) {
197 char const* processName = [[[NSProcessInfo processInfo] processName] UTF8String];
199 snprintf(s,
sizeof(s),
"Usage: %s [options]\n\n"
200 "Options can be any of the following: \n\n"
201 "--compile-sysdesc" TABS2
"Compile system descriptions *\n"
202 "--export-sysdesc" TABS2
"Export system descriptions *\n"
204 "-hdr" TABS3
"Start up in HDR mode\n"
206 "-load [filepath]" TABS2
"Load commander from [filepath]\n" TABS3 TABS4
"(\"-load\" is optional)\n"
207 "-message [messageString]" TABS1
"Display [messageString] at startup\n"
208 "-nodust " TABS2 TABS4
"Do not draw space dust\n"
209 "-noshaders" TABS2 TABS4
"Start up with shaders disabled\n"
210 "-nosplash " TABS2 TABS4
"Force disable splash screen on startup\n"
211 "-nosound " TABS2 TABS4
"Start up with sound disabled\n"
212 "-novsync" TABS3
"Force disable V-Sync\n"
213 "--openstep" TABS2 TABS4
"When compiling or exporting\n" TABS3 TABS4
"system descriptions, use openstep\n" TABS3 TABS4
"format *\n"
214 "-showversion" TABS2 TABS4
"Display version at startup screen\n"
215 "-splash" TABS3 TABS4
"Force splash screen on startup\n"
216 "-verify-oxp [filepath] " TABS1
"Verify OXP at [filepath] *\n"
217 "--xml" TABS3 TABS4
"When compiling or exporting\n" TABS3 TABS4
"system descriptions, use xml\n" TABS3 TABS4
"format *\n"
219 "Options marked with \"*\" are available only in Test Release configuration.\n"
221 "Debug functionality enabled (Test Release): "
222#ifdef OO_DEBUG_MONITOR_ENABLED
235 OO_SHOW_MSG(s, processName, MB_OK);
236 OOLog(
@"process.args",
@"%s option detected, exiting after help page has been displayed.", argv[i]);
249 @catch (NSException* exception) {
250 OOLogERR(
kOOLogException,
@"Root exception handler hit - terminating. This is an internal error, please report it. Exception name: %@, reason: %@", [exception name], [exception reason]);
int main(int argc, const char *argv[])