forked from OpenRA/OpenRA
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.m
57 lines (50 loc) · 1.26 KB
/
main.m
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
//
// main.m
// OpenRA
//
// Created by Paul Chote on 15/11/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
extern char **environ;
int main(int argc, char *argv[])
{
/* When launching a mod, the arguments are of the form
* --launch <game dir> <mono path> <utility path> <support dir option> <mod option> */
if (argc > 1 && strcmp(argv[1], "--launch") == 0)
{
if (argc < 5)
exit(1);
/* Change into the game dir */
chdir(argv[3]);
/* Command line args for mono */
char *args[] = {
argv[4],
"--debug",
"OpenRA.Game.exe",
NULL
};
/* add game dir to DYLD_LIBRARY_PATH */
char *old = getenv("DYLD_LIBRARY_PATH");
if (old == NULL)
setenv("DYLD_LIBRARY_PATH", argv[3], 1);
else
{
char buf[512];
int len = strlen(argv[3]) + strlen(old) + 2;
if (len > 512)
{
NSLog(@"Insufficient DYLD_LIBRARY_PATH buffer length. Wanted %d, had 512", len);
exit(1);
}
sprintf(buf,"%s:%s",argv[3], old);
setenv("DYLD_LIBRARY_PATH", buf, 1);
}
if (strcmp(argv[2], "--hide-menubar") == 0)
[NSMenu setMenuBarVisible:NO];
/* Exec mono */
execve(args[0], args, environ);
}
else /* Else, start the launcher */
return NSApplicationMain(argc, (const char **) argv);
}