about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/engine/client/ec_client.c12
-rw-r--r--src/engine/e_system.c4
-rw-r--r--src/engine/server/es_server.c12
-rw-r--r--src/osxlaunch/main.m101
4 files changed, 28 insertions, 101 deletions
diff --git a/src/engine/client/ec_client.c b/src/engine/client/ec_client.c
index b9b1165c..e83975b1 100644
--- a/src/engine/client/ec_client.c
+++ b/src/engine/client/ec_client.c
@@ -1470,6 +1470,18 @@ void client_save_line(const char *line)
 
 int main(int argc, char **argv)
 {
+#if defined(CONF_PLATFORM_MACOSX)
+	char buffer[512];
+	unsigned pos = strrchr(argv[0], '/') - argv[0];
+
+	if(pos >= 512)
+		return -1;
+
+	strncpy(buffer, argv[0], 511);
+	buffer[pos] = 0;
+	chdir(buffer);
+#endif
+
 	/* init the engine */
 	dbg_msg("client", "starting...");
 	engine_init("Teewars");
diff --git a/src/engine/e_system.c b/src/engine/e_system.c
index fa4ba459..198b867d 100644
--- a/src/engine/e_system.c
+++ b/src/engine/e_system.c
@@ -760,9 +760,13 @@ int fs_storage_path(const char *appname, char *path, int max)
 	if(!home)
 		return 0;
 
+#if defined(CONF_PLATFORM_MACOSX)
+	snprintf(path, max, "%s/Library/Application Support/%s", home, appname);
+#else
 	snprintf(path, max, "%s/.%s", home, appname);
 	for(i = strlen(home)+2; path[i]; i++)
 		path[i] = tolower(path[i]);
+#endif
 	
 	return 1;
 #endif
diff --git a/src/engine/server/es_server.c b/src/engine/server/es_server.c
index 41306f07..adb09cb2 100644
--- a/src/engine/server/es_server.c
+++ b/src/engine/server/es_server.c
@@ -1119,6 +1119,18 @@ static void server_register_commands()
 
 int main(int argc, char **argv)
 {
+#if defined(CONF_PLATFORM_MACOSX)
+	char buffer[512];
+	unsigned pos = strrchr(argv[0], '/') - argv[0];
+
+	if(pos >= 512)
+		return -1;
+
+	strncpy(buffer, argv[0], 511);
+	buffer[pos] = 0;
+	chdir(buffer);
+#endif
+
 	/* init the engine */
 	dbg_msg("server", "starting...");
 	engine_init("Teewars");
diff --git a/src/osxlaunch/main.m b/src/osxlaunch/main.m
deleted file mode 100644
index 6b628a3b..00000000
--- a/src/osxlaunch/main.m
+++ /dev/null
@@ -1,101 +0,0 @@
-#import <Cocoa/Cocoa.h>
-#include <Carbon/Carbon.h>
-
-@interface ServerView : NSTextView
-{
-	NSTask *task;
-	NSFileHandle *file;
-}
-- (void)listenTo: (NSTask*)t;
-@end
-
-@implementation ServerView
-- (void)listenTo: (NSTask*)t;
-{
-	NSPipe *pipe;
-	task = t;
-    pipe = [NSPipe pipe];
-    [task setStandardOutput: pipe];
-    file = [pipe fileHandleForReading];
-
-	[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(outputNotification:) name: NSFileHandleReadCompletionNotification object: file];
-
-	[file readInBackgroundAndNotify];
-}
-
-- (void) outputNotification: (NSNotification *) notification
-{
-	NSData *data = [[[notification userInfo] objectForKey: NSFileHandleNotificationDataItem] retain];
-	NSString *string = [[NSString alloc] initWithData: data encoding: NSASCIIStringEncoding];
-
-	NSRange end = NSMakeRange([[self string] length], 0);
-
-	[self replaceCharactersInRange: end withString: string];
-	end.location += [string length];
-	[self scrollRangeToVisible: end];
-
-	[string release];
-	[file readInBackgroundAndNotify];
-}
-
--(void)windowWillClose:(NSNotification *)notification
-{
-	[task terminate];
-    [NSApp terminate:self];
-}
-@end
-
-int main(int argc, char **argv)
-{
-	UInt32 mod = GetCurrentKeyModifiers();
-
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSApp = [NSApplication sharedApplication];
-	NSBundle* mainBundle = [NSBundle mainBundle];
-	NSTask *task;
-    task = [[NSTask alloc] init];
-	[task setCurrentDirectoryPath: [mainBundle resourcePath]]; 
-
-	if(mod & optionKey)
-	{
-		// run server
-		NSWindow *window;
-		ServerView *view;
-		NSRect graphicsRect;
-
-		graphicsRect = NSMakeRect(100.0, 1000.0, 600.0, 400.0);
-
-		window = [[NSWindow alloc]
-			initWithContentRect: graphicsRect
-			styleMask: NSTitledWindowMask 
-			 | NSClosableWindowMask 
-			 | NSMiniaturizableWindowMask
-			backing: NSBackingStoreBuffered
-			defer: NO];
-
-		[window setTitle: @"Teewars Server"];
-
-		view = [[[ServerView alloc] initWithFrame: graphicsRect] autorelease];
-		[view setEditable: NO];
-
-		[window setContentView: view];
-		[window setDelegate: view];
-		[window makeKeyAndOrderFront: nil];
-
-		[view listenTo: task];
-		[task setLaunchPath: [mainBundle pathForAuxiliaryExecutable: @"teewars_srv"]];
-		[task launch];
-		[NSApp run];
-		[task terminate];
-	}
-	else
-	{
-		// run client
-		[task setLaunchPath: [mainBundle pathForAuxiliaryExecutable: @"teewars"]];
-		[task launch];
-	}
-
-    [NSApp release];
-    [pool release];
-    return(EXIT_SUCCESS);
-}