From 87472bf002128a1c3ee2fe1355535b9356c5188b Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 13 Sep 2014 11:44:24 +0300 Subject: [PATCH] Use the same binary architecture to restart from IWAD picker --- src/sdl/iwadpicker_cocoa.mm | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/sdl/iwadpicker_cocoa.mm b/src/sdl/iwadpicker_cocoa.mm index 92eb47e40..51e0ea0c8 100644 --- a/src/sdl/iwadpicker_cocoa.mm +++ b/src/sdl/iwadpicker_cocoa.mm @@ -376,6 +376,19 @@ static NSArray* GetKnownExtensions() EXTERN_CVAR(String, defaultiwad) +static NSString* GetArchitectureString() +{ +#ifdef __i386__ + return @"i386"; +#elif defined __x86_64__ + return @"x86_64"; +#elif defined __ppc__ + return @"ppc"; +#elif defined __ppc64__ + return @"ppc64"; +#endif +} + static void RestartWithParameters(const char* iwadPath, NSString* parameters) { assert(nil != parameters); @@ -393,8 +406,12 @@ static void RestartWithParameters(const char* iwadPath, NSString* parameters) assert(commandLineParametersCount > 0); NSString* executablePath = [NSString stringWithUTF8String:Args->GetArg(0)]; + NSString* architecture = GetArchitectureString(); - NSMutableArray* arguments = [NSMutableArray arrayWithCapacity:commandLineParametersCount + 3]; + NSMutableArray* arguments = [NSMutableArray arrayWithCapacity:commandLineParametersCount + 6]; + [arguments addObject:@"-arch"]; + [arguments addObject:architecture]; + [arguments addObject:executablePath]; [arguments addObject:@"-wad_picker_restart"]; [arguments addObject:@"-iwad"]; [arguments addObject:[NSString stringWithUTF8String:iwadPath]]; @@ -419,7 +436,7 @@ static void RestartWithParameters(const char* iwadPath, NSString* parameters) wordfree(&expansion); } - [NSTask launchedTaskWithLaunchPath:executablePath arguments:arguments]; + [NSTask launchedTaskWithLaunchPath:@"/usr/bin/arch" arguments:arguments]; _exit(0); // to avoid atexit()'s functions }