784 |
if (!nosound_flag) |
if (!nosound_flag) |
785 |
sdl_flags |= SDL_INIT_AUDIO; |
sdl_flags |= SDL_INIT_AUDIO; |
786 |
|
|
787 |
#ifdef MACOSX |
if (SDL_Init(sdl_flags) < 0) { |
|
// In Mac OS X, applications are self-contained bundles, |
|
|
// e.g. directories like "Enigma.app". Resources are |
|
|
// placed in those bundles under "Enigma.app/Contents/Resources", |
|
|
// the main executable would be "Enigma.app/Contents/MacOS/enigma". |
|
|
// Here, we get the executable name, clip off the last bit, chdir into it, |
|
|
// then chdir to ../Resources. The original SDL implementation chdirs to |
|
|
// "../../..", i.e. the directory the bundle is placed in. This break |
|
|
// the self-containedness. |
|
|
char parentdir[1024]; |
|
|
char *c; |
|
|
|
|
|
strncpy ( parentdir, argv[0], sizeof(parentdir) ); |
|
|
c = (char*) parentdir; |
|
|
|
|
|
while (*c != '\0') /* go to end */ |
|
|
c++; |
|
|
|
|
|
while (*c != '/') /* back up to parent */ |
|
|
c--; |
|
|
|
|
|
*c++ = '\0'; /* cut off last part (binary name) */ |
|
|
|
|
|
chdir (parentdir); /* chdir to the binary app's parent */ |
|
|
chdir ("../Resources/"); /* chdir to the .app's parent */ |
|
|
#endif //MACOSX |
|
|
|
|
|
if (SDL_Init(sdl_flags) < 0) |
|
|
{ |
|
788 |
fprintf(stderr, "Couldn't init SDL: %s\n", SDL_GetError()); |
fprintf(stderr, "Couldn't init SDL: %s\n", SDL_GetError()); |
789 |
exit(1); |
exit(1); |
790 |
} |
} |
818 |
int |
int |
819 |
main(int argc, char** argv) |
main(int argc, char** argv) |
820 |
{ |
{ |
821 |
|
#ifdef MACOSX |
822 |
|
// In Mac OS X, applications are self-contained bundles, |
823 |
|
// e.g. directories like "Enigma.app". Resources are |
824 |
|
// placed in those bundles under "Enigma.app/Contents/Resources", |
825 |
|
// the main executable would be "Enigma.app/Contents/MacOS/enigma". |
826 |
|
// Here, we get the executable name, clip off the last bit, chdir into it, |
827 |
|
// then chdir to ../Resources. The original SDL implementation chdirs to |
828 |
|
// "../../..", i.e. the directory the bundle is placed in. This break |
829 |
|
// the self-containedness. |
830 |
|
char parentdir[1024]; |
831 |
|
char *c; |
832 |
|
|
833 |
|
strncpy ( parentdir, argv[0], sizeof(parentdir) ); |
834 |
|
c = (char*) parentdir; |
835 |
|
|
836 |
|
while (*c != '\0') /* go to end */ |
837 |
|
c++; |
838 |
|
|
839 |
|
while (*c != '/') /* back up to parent */ |
840 |
|
c--; |
841 |
|
|
842 |
|
*c++ = '\0'; /* cut off last part (binary name) */ |
843 |
|
|
844 |
|
chdir (parentdir); /* chdir to the binary app's parent */ |
845 |
|
chdir ("../Resources/"); /* chdir to the .app's parent */ |
846 |
|
#endif //MACOSX |
847 |
|
|
848 |
copy(argv+1, argv+argc, back_inserter(::args)); |
copy(argv+1, argv+argc, back_inserter(::args)); |
849 |
init(); |
init(); |
850 |
|
|