<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>README.MACOSX.txt</filename>
    </added>
    <added>
      <filename>rts/System/Platform/Mac/BackgroundReader.mm</filename>
    </added>
    <added>
      <filename>rts/System/Platform/Mac/SDLMain.h</filename>
    </added>
    <added>
      <filename>rts/System/Platform/Mac/SDLMain.m</filename>
    </added>
    <added>
      <filename>rts/System/Platform/Mac/UserDefsHandler.h</filename>
    </added>
    <added>
      <filename>rts/System/Platform/Mac/UserDefsHandler.mm</filename>
    </added>
    <added>
      <filename>rts/build/xcode/IncludeLinks/AL</filename>
    </added>
    <added>
      <filename>rts/build/xcode/IncludeLinks/GL</filename>
    </added>
    <added>
      <filename>rts/build/xcode/Info-SpringRTS.plist</filename>
    </added>
    <added>
      <filename>rts/build/xcode/README.MACOSX.txt</filename>
    </added>
    <added>
      <filename>rts/build/xcode/README.SRCFILES.txt</filename>
    </added>
    <added>
      <filename>rts/build/xcode/SpringRTS.xcodeproj/Krysole.mode1</filename>
    </added>
    <added>
      <filename>rts/build/xcode/SpringRTS.xcodeproj/Krysole.pbxuser</filename>
    </added>
    <added>
      <filename>rts/build/xcode/SpringRTS.xcodeproj/project.pbxproj</filename>
    </added>
    <added>
      <filename>rts/build/xcode/SpringRTS_Prefix.pch</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -123,6 +123,8 @@ void CGroupHandler::FindDlls(void)
 	fs::path dir(&quot;aidll&quot;,fs::native);
 #ifdef _WIN32
 	match = find_files(dir,&quot;*.dll&quot;);
+#elif defined(__APPLE__)
+	match = find_files(dir,&quot;*.dylib&quot;);
 #else
 	match = find_files(dir,&quot;*.so&quot;);
 #endif</diff>
      <filename>rts/ExternalAI/GroupHandler.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -20,6 +20,8 @@ public:
 	{
 #ifdef WIN32
 		std::vector&lt;std::string&gt; f=CFileHandler::FindFiles(&quot;aidll\\globalai\\*.dll&quot;);
+#elif defined(__APPLE__)
+		std::vector&lt;std::string&gt; f=CFileHandler::FindFiles(&quot;aidll/globalai/*.dylib&quot;);
 #else
 		std::vector&lt;std::string&gt; f=CFileHandler::FindFiles(&quot;aidll/globalai/*.so&quot;);
 #endif</diff>
      <filename>rts/Game/StartScripts/GlobalAITestScript.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -29,6 +29,8 @@ public:
 #include &quot;FBO.h&quot;
 #ifdef _WIN32
 #include &quot;WinPBuffer.h&quot;
+#elif defined(__APPLE__)
+// No native apple PBuffer support yet...just stick with the FBOs for now.
 #else
 #include &quot;GLXPBuffer.h&quot;
 #endif
@@ -44,6 +46,8 @@ static inline IFramebuffer* instantiate_fb(const int shadowMapSize)
 		info-&gt;AddLine(&quot;Using WGLEW_ARB_pbuffer&quot;);
 		return new WinPBuffer(shadowMapSize);
 	}
+#elif defined(__APPLE__)
+	// No native apple PBuffer support yet...just stick with the FBOs for now.
 #else
 	else if (GLX_SGIX_pbuffer) {
 		info-&gt;AddLine(&quot;Using GLX_SGIX_pbuffer&quot;);</diff>
      <filename>rts/Rendering/GL/IFramebuffer.h</filename>
    </modified>
    <modified>
      <diff>@@ -191,7 +191,7 @@ using namespace nv_dds;
 ///////////////////////////////////////////////////////////////////////////////
 // static function pointers for uploading 3D textures and compressed 1D, 2D
 // and 3D textures.
-#ifndef MACOS
+#ifndef __APPLE__
 PFNGLTEXIMAGE3DEXTPROC CDDSImage::glTexImage3D = NULL;
 PFNGLCOMPRESSEDTEXIMAGE1DARBPROC CDDSImage::glCompressedTexImage1DARB = NULL;
 PFNGLCOMPRESSEDTEXIMAGE2DARBPROC CDDSImage::glCompressedTexImage2DARB = NULL;</diff>
      <filename>rts/Rendering/Textures/nv_dds.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -12,14 +12,14 @@
 #include &lt;deque&gt;
 #include &lt;assert.h&gt;
 
-/*#if defined(MACOS)
+#include &quot;Rendering/GL/myGL.h&quot;
+#if defined(__APPLE__)
 #include &lt;OpenGL/gl.h&gt;
 #include &lt;OpenGL/glext.h&gt;
-#else*/
-#include &quot;Rendering/GL/myGL.h&quot;
-//#include &lt;GL/gl.h&gt;
-//#include &lt;GL/glext.h&gt;
-//#endif
+#else
+#include &lt;GL/gl.h&gt;
+#include &lt;GL/glext.h&gt;
+#endif
 
 namespace nv_dds
 {
@@ -336,7 +336,7 @@ namespace nv_dds
 
             std::deque&lt;CTexture&gt; m_images;
 
-#ifndef MACOS
+#ifndef __APPLE__
             static PFNGLTEXIMAGE3DEXTPROC glTexImage3D;
             static PFNGLCOMPRESSEDTEXIMAGE1DARBPROC glCompressedTexImage1DARB;
             static PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glCompressedTexImage2DARB;</diff>
      <filename>rts/Rendering/Textures/nv_dds.h</filename>
    </modified>
    <modified>
      <diff>@@ -1,575 +1,575 @@
-
-#include &quot;StdAfx.h&quot;
-#include &quot;Rendering/GL/myGL.h&quot;
-#include &lt;GL/glu.h&gt;			// Header File For The GLu32 Library
-#include &lt;time.h&gt;
-#include &lt;string&gt;
-#include &lt;algorithm&gt;
-#include &lt;math.h&gt;
-#include &quot;Game/PreGame.h&quot;
-#include &quot;Game/Game.h&quot;
-#include &lt;float.h&gt;
-#include &quot;Rendering/glFont.h&quot;
-#include &quot;Rendering/Textures/TAPalette.h&quot;
-#include &quot;Game/UI/MouseHandler.h&quot;
-#include &quot;Platform/ConfigHandler.h&quot;
-#include &quot;Game/UI/InfoConsole.h&quot;
-#include &quot;Game/GameSetup.h&quot;
-#include &quot;Game/CameraController.h&quot;
-#include &quot;Net.h&quot;
-#include &quot;FileSystem/ArchiveScanner.h&quot;
-#include &quot;FileSystem/VFSHandler.h&quot;
-#include &quot;Platform/BaseCmd.h&quot;
-#include &quot;Game/GameVersion.h&quot;
-#include &quot;Platform/errorhandler.h&quot;
-#include &quot;creg/creg.h&quot;
-#include &quot;bitops.h&quot;
-#ifndef NO_LUA
-#include &quot;Script/LuaBinder.h&quot;
-#endif
-#include &lt;SDL.h&gt;
-#include &lt;SDL_main.h&gt;
-#include &quot;mmgr.h&quot;
-#include &quot;Game/UI/NewGuiDefine.h&quot;
-#ifdef NEW_GUI
-#include &quot;Game/UI/GUI/GUIcontroller.h&quot;
-#endif
-
-#ifdef _WIN32
-#include &quot;CrashRpt.h&quot;
-#include &quot;Platform/Win/win32.h&quot;
-#include &lt;winreg.h&gt;
-#include &lt;direct.h&gt;
-#include &lt;SDL_syswm.h&gt;
-#endif
-
-CGameController* activeController=0;
-bool globalQuit = false;
-Uint8 *keys; // Uint8[SDLK_LAST]
-bool fullscreen;
-
-#define XRES_DEFAULT 1024
-#define YRES_DEFAULT 768
-
-class SpringApp
-{
-public:
-	SpringApp ();
-	~SpringApp ();
-
-	int Run(int argc, char *argv[]);
-
-protected:
-	bool Initialize ();
-	void CheckCmdLineFile (int argc,char *argv[]);
-	bool ParseCmdLine();
-	void InitVFS ();
-	void CreateGameSetup ();
-	bool InitWindow (const char* title);
-	void InitOpenGL ();
-	bool SetSDLVideoMode();
-	void Shutdown ();
-	int Draw ();
-	void UpdateSDLKeys ();
-
-	BaseCmd *cmdline;
-	string demofile,startscript;
-	int screenWidth, screenHeight;
-	int screenFreq;
-
-	bool active;
-	bool FSAA;
-};
-
-SpringApp::SpringApp ()
-{
-	cmdline = 0;
-	screenWidth = screenHeight = 0;
-	screenFreq = 0;
-	keys = 0;
-
-	active = true;
-	fullscreen = true;
-	FSAA = false;
-}
-
-SpringApp::~SpringApp()
-{
-	if (cmdline) delete cmdline;
-	if (keys) delete[] keys;
-
-	creg::ClassBinder::FreeClasses ();
-}
-
-
-#ifdef _WIN32
-// Called when spring crashes
-bool crashCallback(void* crState)
-{
-	info-&gt;AddLine(&quot;Spring has crashed&quot;);
-
-	// Since we are going down, it's ok to delete the info console (it can't be mailed otherwise)
-	delete info;
-	bool wasRecording = false;
-	if (net-&gt;recordDemo) {
-		delete net-&gt;recordDemo;
-		wasRecording = true;
-	}
-
-	AddFile(&quot;infolog.txt&quot;, &quot;Spring information log&quot;);
-	AddFile(&quot;test.sdf&quot;, &quot;Spring game demo&quot;);
-
-	if (wasRecording)
-		AddFile(net-&gt;demoName.c_str(), &quot;Spring game demo&quot;);
-
-	return true;
-}
-#endif
-
-bool SpringApp::Initialize ()
-{
-	ParseCmdLine ();
-
-#ifdef WIN32
-	// Initialize crash reporting
-	Install( (LPGETLOGFILE) crashCallback, &quot;taspringcrash@clan-sy.com&quot;, &quot;TA Spring Crashreport&quot;);
-#endif
-
-	// Initialize class system
-	creg::ClassBinder::InitializeClasses ();
-
-#ifndef NO_LUA
-	// Initialize lua bindings
-	CLuaBinder lua;
-	if (!lua.LoadScript(&quot;testscript.lua&quot;)) 
-		handleerror(NULL, lua.lastError.c_str(), &quot;lua&quot;,MBF_OK|MBF_EXCL);
-#endif
-
-	InitVFS ();
-
-	if (!InitWindow (&quot;RtsSpring&quot;))
-	{
-		SDL_Quit ();
-		return false;
-	}
-	// Global structures
-	ENTER_SYNCED;
-	gs=new CGlobalSyncedStuff();
-	ENTER_UNSYNCED;
-	gu=new CGlobalUnsyncedStuff();
-
-	InitOpenGL();
-
-	palette.Init();
-
-	// Initialize keyboard
-	SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
-	SDL_SetModState (KMOD_NONE);
-	
-	keys = new Uint8[SDLK_LAST];
-	memset (keys,0,sizeof(Uint8)*SDLK_LAST);
-
-	// Initialize font
-	font = new CglFont(32,223);
-	LoadExtensions();
-	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-	SDL_GL_SwapBuffers();
-
-	CreateGameSetup ();
-
-	return true;
-}
-
-
-static bool MultisampleTest(void)
-{
-	if (!GL_ARB_multisample)
-		return false;
-	GLuint fsaa = configHandler.GetInt(&quot;FSAA&quot;,0);
-	if (!fsaa)
-		return false;
-	SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS,1);
-	GLuint fsaalevel = min(configHandler.GetInt(&quot;FSAALevel&quot;,2),(unsigned int)8);
-
-	make_even_number(fsaalevel);
-
-	SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES,fsaalevel);
-	return true;
-}
-
-static bool MultisampleVerify(void)
-{
-	GLint buffers, samples; 
-	glGetIntegerv(GL_SAMPLE_BUFFERS_ARB, &amp;buffers);
-	glGetIntegerv(GL_SAMPLES_ARB, &amp;samples);
-	if (buffers &amp;&amp; samples) {
-#ifdef DEBUG
-		char t[22];
-		SNPRINTF(t,22, &quot;FSAA level %d enabled&quot;,samples);
-		handleerror(0,t,&quot;SDL_GL&quot;,MBF_OK|MBF_INFO);
-#endif
-		return true;
-	}
-	return false;
-}
-
-
-bool SpringApp::InitWindow (const char* title)
-{
-	if ((SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1)) {
-		handleerror(NULL,&quot;Could not initialize SDL.&quot;,&quot;ERROR&quot;,MBF_OK|MBF_EXCL);
-		return false;
-	}
-
-	// Sets window manager properties
-	SDL_WM_SetIcon(SDL_LoadBMP(&quot;spring.bmp&quot;),NULL);
-	SDL_WM_SetCaption(title, title);
-
-	SetSDLVideoMode ();
-	return true;
-}
-
-bool SpringApp::SetSDLVideoMode ()
-{
-	int sdlflags = SDL_OPENGL | SDL_RESIZABLE;
-
-	conditionally_set_flag(sdlflags, SDL_FULLSCREEN, fullscreen);
-
-	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
-	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
-	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
-#ifdef __APPLE__
-	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32);
-#else
-	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
-#endif	
-	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
-
-	FSAA = MultisampleTest();
-
-	SDL_Surface *screen = SDL_SetVideoMode(screenWidth,screenHeight,0,sdlflags);
-	if (!screen) {
-		handleerror(NULL,&quot;Could not set video mode&quot;,&quot;ERROR&quot;,MBF_OK|MBF_EXCL);
-		return false;
-	}
-	if (FSAA)
-		FSAA = MultisampleVerify();
-	
-	return true;
-}
-
-
-void SpringApp::InitOpenGL ()
-{
-	// Setup viewport
-	glViewport (0, 0, screenWidth, screenHeight);
-	gluPerspective(45.0f,(GLfloat)screenWidth/(GLfloat)screenHeight,2.8f,MAX_VIEW_RANGE);
-	
-	// Initialize some GL states
-	glShadeModel(GL_SMOOTH);
-	glClearDepth(1.0f);
-	glEnable(GL_DEPTH_TEST);
-	glDepthFunc(GL_LEQUAL);
-
-	gu-&gt;screenx = screenWidth;
-	gu-&gt;screeny = screenHeight;
-}
-
-
-// Initialize the virtual file system
-void SpringApp::InitVFS()
-{
-	// Create the archive scanner and vfs handler
-	archiveScanner = new CArchiveScanner();
-	archiveScanner-&gt;ReadCacheData();
-	archiveScanner-&gt;Scan(&quot;./maps&quot;);
-	archiveScanner-&gt;Scan(&quot;./base&quot;);
-	archiveScanner-&gt;Scan(&quot;./mods&quot;);
-	archiveScanner-&gt;WriteCacheData();
-	hpiHandler = new CVFSHandler();
-}
-
-
-bool SpringApp::ParseCmdLine()
-{
-	cmdline-&gt;addoption('f',&quot;fullscreen&quot;,OPTPARM_NONE,&quot;&quot;,&quot;Run in fullscreen mode&quot;);
-	cmdline-&gt;addoption('w',&quot;window&quot;,OPTPARM_NONE,&quot;&quot;,&quot;Run in windowed mode&quot;);
-	cmdline-&gt;addoption('s',&quot;server&quot;,OPTPARM_NONE,&quot;&quot;,&quot;Run as a server&quot;);
-	cmdline-&gt;addoption('c',&quot;client&quot;,OPTPARM_NONE,&quot;&quot;,&quot;Run as a client&quot;);
-//	cmdline-&gt;addoption('g',&quot;runscript&quot;,OPTPARM_STRING,&quot;script.txt&quot;, &quot;Run with a game setup script&quot;);
-	cmdline-&gt;parse();
-
-#ifdef _DEBUG
-	fullscreen = false;
-#else
-	fullscreen = configHandler.GetInt(&quot;Fullscreen&quot;,1)!=0;
-#endif
-	Uint8 scrollWheelSpeed = configHandler.GetInt(&quot;ScrollWheelSpeed&quot;,25);
-
-	if (cmdline-&gt;result(&quot;help&quot;)) {
-		cmdline-&gt;usage(&quot;TA:Spring&quot;,VERSION_STRING);
-		return false;
-	} else if (cmdline-&gt;result(&quot;version&quot;)) {
-		std::cout &lt;&lt; &quot;TA:Spring &quot; &lt;&lt; VERSION_STRING &lt;&lt; std::endl;
-		return false;
-	} else if (cmdline-&gt;result(&quot;window&quot;))
-		fullscreen = false;
-	else if (cmdline-&gt;result(&quot;fullscreen&quot;))
-		fullscreen = true;
-
-	screenWidth = configHandler.GetInt(&quot;XResolution&quot;,XRES_DEFAULT);
-	screenHeight = configHandler.GetInt(&quot;YResolution&quot;,YRES_DEFAULT);
-	screenFreq = configHandler.GetInt(&quot;DisplayFrequency&quot;,0);
-
-	return true;
-}
-
-// See if a demo SDF file or a startscript is specified on the command line
-void SpringApp::CheckCmdLineFile(int argc, char *argv[])
-{
-	// Check if the commandline parameter is specifying a demo file
-#ifdef _WIN32
-	// find the correct dir
-	const char *arg0=argv[0];
-	int a,s = strlen(arg0);
-	for (a=s-1;a&gt;0;a--) 
-		if (arg0[a] == '\\') break;
-	if (a &gt; 0) {
-		string path(arg0, arg0+a);
-		if (path.at(0) == '&quot;')
-			path.append(1,'&quot;');
-		_chdir(path.c_str());
-	}
-#endif
-
-	for (int i = 1; i &lt; argc; i++) {
-		if (argv[i][0] != '-') {
-			string command(argv[i]);
-			int idx = command.rfind(&quot;sdf&quot;);
-			if (idx == command.size()-3) {
-				demofile = command;
-			} else {
-				startscript = command;
-			}
-		}
-	}
-}
-
-void SpringApp::CreateGameSetup ()
-{
-	ENTER_SYNCED;
-	if (!startscript.empty()) {
-		gameSetup=new CGameSetup();
-		if(!gameSetup-&gt;Init(startscript)){
-			delete gameSetup;
-			gameSetup=0;
-		}
-	}
-
-	ENTER_MIXED;
-
-	bool server = true;
-	if (!demofile.empty())
-		server = false;
-	else if(gameSetup)
-		server=gameSetup-&gt;myPlayer-gameSetup-&gt;numDemoPlayers == 0;
-	else
-		server=!cmdline-&gt;result(&quot;client&quot;) || cmdline-&gt;result(&quot;server&quot;);
-
-	if (!demofile.empty())
-		pregame = new CPreGame(false, demofile);
-	else
-		pregame = new CPreGame(server, &quot;&quot;);
-}
-
-int SpringApp::Draw ()
-{
-	if (FSAA)
-		glEnable(GL_MULTISAMPLE_ARB);
-
-	int ret = 1;
-	if(activeController) {
-		if(activeController-&gt;Update()==0) ret = 0;
-		else ret = activeController-&gt;Draw();
-	}
-
-	SDL_GL_SwapBuffers();
-	if (FSAA)
-		glDisable(GL_MULTISAMPLE_ARB);
-
-	return ret;
-}
-
-void SpringApp::UpdateSDLKeys ()
-{
-	int numkeys;
-	Uint8 *state;
-	state = SDL_GetKeyState(&amp;numkeys);
-	memcpy(keys, state, sizeof(Uint8) * numkeys);
-
-	SDLMod mods = SDL_GetModState();
-	keys[SDLK_LSHIFT] = mods&amp;KMOD_SHIFT?1:0;
-	keys[SDLK_LCTRL] = mods&amp;KMOD_CTRL?1:0;
-	keys[SDLK_LALT] = mods&amp;KMOD_ALT?1:0;
-	keys[SDLK_LMETA] = mods&amp;KMOD_META?1:0;
-}
-
-
-int SpringApp::Run (int argc, char *argv[])
-{
-	INIT_SYNCIFY;
-	CheckCmdLineFile (argc, argv);
-	cmdline = BaseCmd::initialize(argc,argv);
-
-	if (!Initialize ())
-		return -1;
-
-#ifdef WIN32
-	SDL_EventState (SDL_SYSWMEVENT, SDL_ENABLE);
-#endif
-
-	SDL_Event event;
-	bool done=false;
-
-	Uint8 scrollWheelSpeed = configHandler.GetInt(&quot;ScrollWheelSpeed&quot;,25);
-
-	while (!done) {
-		ENTER_UNSYNCED;
-		while (SDL_PollEvent(&amp;event)) {
-			switch (event.type) {
-				case SDL_VIDEORESIZE:
-					screenWidth = event.resize.w;
-					screenHeight = event.resize.h;
-					InitOpenGL();
-					break;
-				case SDL_QUIT:
-					done = true;
-					break;
-				case SDL_MOUSEMOTION:
-					if(mouse)
-						mouse-&gt;MouseMove(event.motion.x,event.motion.y);
-					break;
-				case SDL_MOUSEBUTTONDOWN:
-					if (mouse) {
-						if (event.button.button == SDL_BUTTON_WHEELUP)
-							mouse-&gt;currentCamController-&gt;MouseWheelMove(scrollWheelSpeed);
-						else if (event.button.button == SDL_BUTTON_WHEELDOWN)
-							mouse-&gt;currentCamController-&gt;MouseWheelMove(-scrollWheelSpeed);
-						else
-							mouse-&gt;MousePress(event.button.x,event.button.y,event.button.button);
-					}
-					break;
-				case SDL_MOUSEBUTTONUP:
-					if (mouse)
-						mouse-&gt;MouseRelease(event.button.x,event.button.y,event.button.button);
-					break;
-				case SDL_KEYDOWN:
-				{
-					int i = event.key.keysym.sym;
-				
-					UpdateSDLKeys ();
-
-					if(activeController) {
-						activeController-&gt;KeyPressed(i,1);
-#ifndef NEW_GUI
-						if(activeController-&gt;userWriting){ 
-							i = event.key.keysym.unicode;
-							if (i &gt;= SDLK_SPACE &amp;&amp; i &lt;= SDLK_DELETE)
-								if(activeController-&gt;ignoreNextChar || activeController-&gt;ignoreChar==char(i))
-									activeController-&gt;ignoreNextChar=false;
-								else
-									activeController-&gt;userInput+=char(i);
-						}
-#endif
-					}
-#ifdef NEW_GUI
-					i = event.key.keysym.unicode;
-					if (i &gt; SDLK_FIRST &amp;&amp; i &lt;= SDLK_DELETE) /* HACK */
-						GUIcontroller::Character(char(i));
-#endif
-					break;
-				}
-				case SDL_KEYUP:
-				{
-					int i = event.key.keysym.sym;
-
-					UpdateSDLKeys();
-
-					if (activeController)
-						activeController-&gt;KeyReleased(i);
-        			break;
-				}
-#ifdef WIN32
-				case SDL_SYSWMEVENT:
-				{
-					SDL_SysWMmsg *msg = event.syswm.msg;
-					if (msg-&gt;msg == 0x020B) { // WM_XBUTTONDOWN, beats me why it isn't defined by default
-						if (msg-&gt;wParam &amp; 0x20) // MK_XBUTTON1
-							mouse-&gt;MousePress (LOWORD(msg-&gt;lParam),HIWORD(msg-&gt;lParam), 4);
-						if (msg-&gt;wParam &amp; 0x40) // MK_XBUTTON2
-							mouse-&gt;MousePress (LOWORD(msg-&gt;lParam),HIWORD(msg-&gt;lParam), 5);
-					}
-					break;
-				}
-#endif
-			}
-		}
-		int ret = Draw();
-		if (globalQuit || (active &amp;&amp; !ret))
-			done=true;
-	}
-	ENTER_MIXED;
-
-	// Shutdown
-	Shutdown();
-	return 0;
-}
-
-void SpringApp::Shutdown()
-{
-	if (pregame)
-		delete pregame;			//in case we exit during init
-	if (game)
-		delete game;
-	if (gameSetup)
-		delete gameSetup;
-	delete font;
-	ConfigHandler::Deallocate();
-	UnloadExtensions();
-#ifndef DEBUG
-	SDL_WM_GrabInput(SDL_GRAB_OFF);
-#endif
-	SDL_Quit();
-	delete gs;
-	delete gu;
-	END_SYNCIFY;
-#ifdef USE_MMGR
-	m_dumpMemoryReport();
-#endif
-}
-
-// Application entry point
-
-#ifdef WIN32 /* SDL_main can't use envp in the main function */
-int main( int argc, char *argv[] )
-#else
-int main( int argc, char *argv[ ], char *envp[ ] )
-#endif
-{
-#ifndef _WIN32
-	chdir(SPRING_DATADIR);
-#endif
-
-// It's nice to be able to disable catching when you're debugging
-#ifndef NO_CATCH_EXCEPTIONS
-	try {
-		SpringApp app;
-		return app.Run (argc,argv);
-	} catch (const std::exception&amp; e) {
-		handleerror(NULL, e.what(), &quot;Fatal Error&quot;, MBF_OK | MBF_EXCL);
-		return 1;
-	}
-#else
-	return app.Run (argv, argv);
-#endif
-}
+
+#include &quot;StdAfx.h&quot;
+#include &quot;Rendering/GL/myGL.h&quot;
+#include &lt;GL/glu.h&gt;			// Header File For The GLu32 Library
+#include &lt;time.h&gt;
+#include &lt;string&gt;
+#include &lt;algorithm&gt;
+#include &lt;math.h&gt;
+#include &quot;Game/PreGame.h&quot;
+#include &quot;Game/Game.h&quot;
+#include &lt;float.h&gt;
+#include &quot;Rendering/glFont.h&quot;
+#include &quot;Rendering/Textures/TAPalette.h&quot;
+#include &quot;Game/UI/MouseHandler.h&quot;
+#include &quot;Platform/ConfigHandler.h&quot;
+#include &quot;Game/UI/InfoConsole.h&quot;
+#include &quot;Game/GameSetup.h&quot;
+#include &quot;Game/CameraController.h&quot;
+#include &quot;Net.h&quot;
+#include &quot;FileSystem/ArchiveScanner.h&quot;
+#include &quot;FileSystem/VFSHandler.h&quot;
+#include &quot;Platform/BaseCmd.h&quot;
+#include &quot;Game/GameVersion.h&quot;
+#include &quot;Platform/errorhandler.h&quot;
+#include &quot;creg/creg.h&quot;
+#include &quot;bitops.h&quot;
+#ifndef NO_LUA
+#include &quot;Script/LuaBinder.h&quot;
+#endif
+#include &lt;SDL.h&gt;
+#include &lt;SDL_main.h&gt;
+#include &quot;mmgr.h&quot;
+#include &quot;Game/UI/NewGuiDefine.h&quot;
+#ifdef NEW_GUI
+#include &quot;Game/UI/GUI/GUIcontroller.h&quot;
+#endif
+
+#ifdef _WIN32
+#include &quot;CrashRpt.h&quot;
+#include &quot;Platform/Win/win32.h&quot;
+#include &lt;winreg.h&gt;
+#include &lt;direct.h&gt;
+#include &lt;SDL_syswm.h&gt;
+#endif
+
+CGameController* activeController=0;
+bool globalQuit = false;
+Uint8 *keys; // Uint8[SDLK_LAST]
+bool fullscreen;
+
+#define XRES_DEFAULT 1024
+#define YRES_DEFAULT 768
+
+class SpringApp
+{
+public:
+	SpringApp ();
+	~SpringApp ();
+
+	int Run(int argc, char *argv[]);
+
+protected:
+	bool Initialize ();
+	void CheckCmdLineFile (int argc,char *argv[]);
+	bool ParseCmdLine();
+	void InitVFS ();
+	void CreateGameSetup ();
+	bool InitWindow (const char* title);
+	void InitOpenGL ();
+	bool SetSDLVideoMode();
+	void Shutdown ();
+	int Draw ();
+	void UpdateSDLKeys ();
+
+	BaseCmd *cmdline;
+	string demofile,startscript;
+	int screenWidth, screenHeight;
+	int screenFreq;
+
+	bool active;
+	bool FSAA;
+};
+
+SpringApp::SpringApp ()
+{
+	cmdline = 0;
+	screenWidth = screenHeight = 0;
+	screenFreq = 0;
+	keys = 0;
+
+	active = true;
+	fullscreen = true;
+	FSAA = false;
+}
+
+SpringApp::~SpringApp()
+{
+	if (cmdline) delete cmdline;
+	if (keys) delete[] keys;
+
+	creg::ClassBinder::FreeClasses ();
+}
+
+
+#ifdef _WIN32
+// Called when spring crashes
+bool crashCallback(void* crState)
+{
+	info-&gt;AddLine(&quot;Spring has crashed&quot;);
+
+	// Since we are going down, it's ok to delete the info console (it can't be mailed otherwise)
+	delete info;
+	bool wasRecording = false;
+	if (net-&gt;recordDemo) {
+		delete net-&gt;recordDemo;
+		wasRecording = true;
+	}
+
+	AddFile(&quot;infolog.txt&quot;, &quot;Spring information log&quot;);
+	AddFile(&quot;test.sdf&quot;, &quot;Spring game demo&quot;);
+
+	if (wasRecording)
+		AddFile(net-&gt;demoName.c_str(), &quot;Spring game demo&quot;);
+
+	return true;
+}
+#endif
+
+bool SpringApp::Initialize ()
+{
+	ParseCmdLine ();
+
+#ifdef WIN32
+	// Initialize crash reporting
+	Install( (LPGETLOGFILE) crashCallback, &quot;taspringcrash@clan-sy.com&quot;, &quot;TA Spring Crashreport&quot;);
+#endif
+
+	// Initialize class system
+	creg::ClassBinder::InitializeClasses ();
+
+#ifndef NO_LUA
+	// Initialize lua bindings
+	CLuaBinder lua;
+	if (!lua.LoadScript(&quot;testscript.lua&quot;)) 
+		handleerror(NULL, lua.lastError.c_str(), &quot;lua&quot;,MBF_OK|MBF_EXCL);
+#endif
+
+	InitVFS ();
+
+	if (!InitWindow (&quot;RtsSpring&quot;))
+	{
+		SDL_Quit ();
+		return false;
+	}
+	// Global structures
+	ENTER_SYNCED;
+	gs=new CGlobalSyncedStuff();
+	ENTER_UNSYNCED;
+	gu=new CGlobalUnsyncedStuff();
+
+	InitOpenGL();
+
+	palette.Init();
+
+	// Initialize keyboard
+	SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
+	SDL_SetModState (KMOD_NONE);
+	
+	keys = new Uint8[SDLK_LAST];
+	memset (keys,0,sizeof(Uint8)*SDLK_LAST);
+
+	// Initialize font
+	font = new CglFont(32,223);
+	LoadExtensions();
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+	SDL_GL_SwapBuffers();
+
+	CreateGameSetup ();
+
+	return true;
+}
+
+
+static bool MultisampleTest(void)
+{
+	if (!GL_ARB_multisample)
+		return false;
+	GLuint fsaa = configHandler.GetInt(&quot;FSAA&quot;,0);
+	if (!fsaa)
+		return false;
+	SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS,1);
+	GLuint fsaalevel = min(configHandler.GetInt(&quot;FSAALevel&quot;,2),(unsigned int)8);
+
+	make_even_number(fsaalevel);
+
+	SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES,fsaalevel);
+	return true;
+}
+
+static bool MultisampleVerify(void)
+{
+	GLint buffers, samples; 
+	glGetIntegerv(GL_SAMPLE_BUFFERS_ARB, &amp;buffers);
+	glGetIntegerv(GL_SAMPLES_ARB, &amp;samples);
+	if (buffers &amp;&amp; samples) {
+#ifdef DEBUG
+		char t[22];
+		SNPRINTF(t,22, &quot;FSAA level %d enabled&quot;,samples);
+		handleerror(0,t,&quot;SDL_GL&quot;,MBF_OK|MBF_INFO);
+#endif
+		return true;
+	}
+	return false;
+}
+
+
+bool SpringApp::InitWindow (const char* title)
+{
+	if ((SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1)) {
+		handleerror(NULL,&quot;Could not initialize SDL.&quot;,&quot;ERROR&quot;,MBF_OK|MBF_EXCL);
+		return false;
+	}
+
+	// Sets window manager properties
+	SDL_WM_SetIcon(SDL_LoadBMP(&quot;spring.bmp&quot;),NULL);
+	SDL_WM_SetCaption(title, title);
+
+	SetSDLVideoMode ();
+	return true;
+}
+
+bool SpringApp::SetSDLVideoMode ()
+{
+	int sdlflags = SDL_OPENGL | SDL_RESIZABLE;
+
+	conditionally_set_flag(sdlflags, SDL_FULLSCREEN, fullscreen);
+
+	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
+	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
+	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
+#ifdef __APPLE__
+	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32);
+#else
+	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
+#endif	
+	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
+
+	FSAA = MultisampleTest();
+
+	SDL_Surface *screen = SDL_SetVideoMode(screenWidth,screenHeight,0,sdlflags);
+	if (!screen) {
+		handleerror(NULL,&quot;Could not set video mode&quot;,&quot;ERROR&quot;,MBF_OK|MBF_EXCL);
+		return false;
+	}
+	if (FSAA)
+		FSAA = MultisampleVerify();
+	
+	return true;
+}
+
+
+void SpringApp::InitOpenGL ()
+{
+	// Setup viewport
+	glViewport (0, 0, screenWidth, screenHeight);
+	gluPerspective(45.0f,(GLfloat)screenWidth/(GLfloat)screenHeight,2.8f,MAX_VIEW_RANGE);
+	
+	// Initialize some GL states
+	glShadeModel(GL_SMOOTH);
+	glClearDepth(1.0f);
+	glEnable(GL_DEPTH_TEST);
+	glDepthFunc(GL_LEQUAL);
+
+	gu-&gt;screenx = screenWidth;
+	gu-&gt;screeny = screenHeight;
+}
+
+
+// Initialize the virtual file system
+void SpringApp::InitVFS()
+{
+	// Create the archive scanner and vfs handler
+	archiveScanner = new CArchiveScanner();
+	archiveScanner-&gt;ReadCacheData();
+	archiveScanner-&gt;Scan(&quot;./maps&quot;);
+	archiveScanner-&gt;Scan(&quot;./base&quot;);
+	archiveScanner-&gt;Scan(&quot;./mods&quot;);
+	archiveScanner-&gt;WriteCacheData();
+	hpiHandler = new CVFSHandler();
+}
+
+
+bool SpringApp::ParseCmdLine()
+{
+	cmdline-&gt;addoption('f',&quot;fullscreen&quot;,OPTPARM_NONE,&quot;&quot;,&quot;Run in fullscreen mode&quot;);
+	cmdline-&gt;addoption('w',&quot;window&quot;,OPTPARM_NONE,&quot;&quot;,&quot;Run in windowed mode&quot;);
+	cmdline-&gt;addoption('s',&quot;server&quot;,OPTPARM_NONE,&quot;&quot;,&quot;Run as a server&quot;);
+	cmdline-&gt;addoption('c',&quot;client&quot;,OPTPARM_NONE,&quot;&quot;,&quot;Run as a client&quot;);
+//	cmdline-&gt;addoption('g',&quot;runscript&quot;,OPTPARM_STRING,&quot;script.txt&quot;, &quot;Run with a game setup script&quot;);
+	cmdline-&gt;parse();
+
+#ifdef _DEBUG
+	fullscreen = false;
+#else
+	fullscreen = configHandler.GetInt(&quot;Fullscreen&quot;,1)!=0;
+#endif
+	Uint8 scrollWheelSpeed = configHandler.GetInt(&quot;ScrollWheelSpeed&quot;,25);
+
+	if (cmdline-&gt;result(&quot;help&quot;)) {
+		cmdline-&gt;usage(&quot;TA:Spring&quot;,VERSION_STRING);
+		return false;
+	} else if (cmdline-&gt;result(&quot;version&quot;)) {
+		std::cout &lt;&lt; &quot;TA:Spring &quot; &lt;&lt; VERSION_STRING &lt;&lt; std::endl;
+		return false;
+	} else if (cmdline-&gt;result(&quot;window&quot;))
+		fullscreen = false;
+	else if (cmdline-&gt;result(&quot;fullscreen&quot;))
+		fullscreen = true;
+
+	screenWidth = configHandler.GetInt(&quot;XResolution&quot;,XRES_DEFAULT);
+	screenHeight = configHandler.GetInt(&quot;YResolution&quot;,YRES_DEFAULT);
+	screenFreq = configHandler.GetInt(&quot;DisplayFrequency&quot;,0);
+
+	return true;
+}
+
+// See if a demo SDF file or a startscript is specified on the command line
+void SpringApp::CheckCmdLineFile(int argc, char *argv[])
+{
+	// Check if the commandline parameter is specifying a demo file
+#ifdef _WIN32
+	// find the correct dir
+	const char *arg0=argv[0];
+	int a,s = strlen(arg0);
+	for (a=s-1;a&gt;0;a--) 
+		if (arg0[a] == '\\') break;
+	if (a &gt; 0) {
+		string path(arg0, arg0+a);
+		if (path.at(0) == '&quot;')
+			path.append(1,'&quot;');
+		_chdir(path.c_str());
+	}
+#endif
+
+	for (int i = 1; i &lt; argc; i++) {
+		if (argv[i][0] != '-') {
+			string command(argv[i]);
+			int idx = command.rfind(&quot;sdf&quot;);
+			if (idx == command.size()-3) {
+				demofile = command;
+			} else {
+				startscript = command;
+			}
+		}
+	}
+}
+
+void SpringApp::CreateGameSetup ()
+{
+	ENTER_SYNCED;
+	if (!startscript.empty()) {
+		gameSetup=new CGameSetup();
+		if(!gameSetup-&gt;Init(startscript)){
+			delete gameSetup;
+			gameSetup=0;
+		}
+	}
+
+	ENTER_MIXED;
+
+	bool server = true;
+	if (!demofile.empty())
+		server = false;
+	else if(gameSetup)
+		server=gameSetup-&gt;myPlayer-gameSetup-&gt;numDemoPlayers == 0;
+	else
+		server=!cmdline-&gt;result(&quot;client&quot;) || cmdline-&gt;result(&quot;server&quot;);
+
+	if (!demofile.empty())
+		pregame = new CPreGame(false, demofile);
+	else
+		pregame = new CPreGame(server, &quot;&quot;);
+}
+
+int SpringApp::Draw ()
+{
+	if (FSAA)
+		glEnable(GL_MULTISAMPLE_ARB);
+
+	int ret = 1;
+	if(activeController) {
+		if(activeController-&gt;Update()==0) ret = 0;
+		else ret = activeController-&gt;Draw();
+	}
+
+	SDL_GL_SwapBuffers();
+	if (FSAA)
+		glDisable(GL_MULTISAMPLE_ARB);
+
+	return ret;
+}
+
+void SpringApp::UpdateSDLKeys ()
+{
+	int numkeys;
+	Uint8 *state;
+	state = SDL_GetKeyState(&amp;numkeys);
+	memcpy(keys, state, sizeof(Uint8) * numkeys);
+
+	SDLMod mods = SDL_GetModState();
+	keys[SDLK_LSHIFT] = mods&amp;KMOD_SHIFT?1:0;
+	keys[SDLK_LCTRL] = mods&amp;KMOD_CTRL?1:0;
+	keys[SDLK_LALT] = mods&amp;KMOD_ALT?1:0;
+	keys[SDLK_LMETA] = mods&amp;KMOD_META?1:0;
+}
+
+
+int SpringApp::Run (int argc, char *argv[])
+{
+	INIT_SYNCIFY;
+	CheckCmdLineFile (argc, argv);
+	cmdline = BaseCmd::initialize(argc,argv);
+
+	if (!Initialize ())
+		return -1;
+
+#ifdef WIN32
+	SDL_EventState (SDL_SYSWMEVENT, SDL_ENABLE);
+#endif
+
+	SDL_Event event;
+	bool done=false;
+
+	Uint8 scrollWheelSpeed = configHandler.GetInt(&quot;ScrollWheelSpeed&quot;,25);
+
+	while (!done) {
+		ENTER_UNSYNCED;
+		while (SDL_PollEvent(&amp;event)) {
+			switch (event.type) {
+				case SDL_VIDEORESIZE:
+					screenWidth = event.resize.w;
+					screenHeight = event.resize.h;
+					InitOpenGL();
+					break;
+				case SDL_QUIT:
+					done = true;
+					break;
+				case SDL_MOUSEMOTION:
+					if(mouse)
+						mouse-&gt;MouseMove(event.motion.x,event.motion.y);
+					break;
+				case SDL_MOUSEBUTTONDOWN:
+					if (mouse) {
+						if (event.button.button == SDL_BUTTON_WHEELUP)
+							mouse-&gt;currentCamController-&gt;MouseWheelMove(scrollWheelSpeed);
+						else if (event.button.button == SDL_BUTTON_WHEELDOWN)
+							mouse-&gt;currentCamController-&gt;MouseWheelMove(-scrollWheelSpeed);
+						else
+							mouse-&gt;MousePress(event.button.x,event.button.y,event.button.button);
+					}
+					break;
+				case SDL_MOUSEBUTTONUP:
+					if (mouse)
+						mouse-&gt;MouseRelease(event.button.x,event.button.y,event.button.button);
+					break;
+				case SDL_KEYDOWN:
+				{
+					int i = event.key.keysym.sym;
+				
+					UpdateSDLKeys ();
+
+					if(activeController) {
+						activeController-&gt;KeyPressed(i,1);
+#ifndef NEW_GUI
+						if(activeController-&gt;userWriting){ 
+							i = event.key.keysym.unicode;
+							if (i &gt;= SDLK_SPACE &amp;&amp; i &lt;= SDLK_DELETE)
+								if(activeController-&gt;ignoreNextChar || activeController-&gt;ignoreChar==char(i))
+									activeController-&gt;ignoreNextChar=false;
+								else
+									activeController-&gt;userInput+=char(i);
+						}
+#endif
+					}
+#ifdef NEW_GUI
+					i = event.key.keysym.unicode;
+					if (i &gt; SDLK_FIRST &amp;&amp; i &lt;= SDLK_DELETE) /* HACK */
+						GUIcontroller::Character(char(i));
+#endif
+					break;
+				}
+				case SDL_KEYUP:
+				{
+					int i = event.key.keysym.sym;
+
+					UpdateSDLKeys();
+
+					if (activeController)
+						activeController-&gt;KeyReleased(i);
+        			break;
+				}
+#ifdef WIN32
+				case SDL_SYSWMEVENT:
+				{
+					SDL_SysWMmsg *msg = event.syswm.msg;
+					if (msg-&gt;msg == 0x020B) { // WM_XBUTTONDOWN, beats me why it isn't defined by default
+						if (msg-&gt;wParam &amp; 0x20) // MK_XBUTTON1
+							mouse-&gt;MousePress (LOWORD(msg-&gt;lParam),HIWORD(msg-&gt;lParam), 4);
+						if (msg-&gt;wParam &amp; 0x40) // MK_XBUTTON2
+							mouse-&gt;MousePress (LOWORD(msg-&gt;lParam),HIWORD(msg-&gt;lParam), 5);
+					}
+					break;
+				}
+#endif
+			}
+		}
+		int ret = Draw();
+		if (globalQuit || (active &amp;&amp; !ret))
+			done=true;
+	}
+	ENTER_MIXED;
+
+	// Shutdown
+	Shutdown();
+	return 0;
+}
+
+void SpringApp::Shutdown()
+{
+	if (pregame)
+		delete pregame;			//in case we exit during init
+	if (game)
+		delete game;
+	if (gameSetup)
+		delete gameSetup;
+	delete font;
+	ConfigHandler::Deallocate();
+	UnloadExtensions();
+#ifndef DEBUG
+	SDL_WM_GrabInput(SDL_GRAB_OFF);
+#endif
+	SDL_Quit();
+	delete gs;
+	delete gu;
+	END_SYNCIFY;
+#ifdef USE_MMGR
+	m_dumpMemoryReport();
+#endif
+}
+
+// Application entry point
+
+#if defined(WIN32) || defined(__APPLE__) 
+int main( int argc, char *argv[] )
+#else
+int main( int argc, char *argv[ ], char *envp[ ] ) /* envp only on linux/bsd */
+#endif
+{
+#if !defined(_WIN32) &amp;&amp; !defined(__APPLE__)
+	chdir(SPRING_DATADIR);
+#endif
+
+// It's nice to be able to disable catching when you're debugging
+#ifndef NO_CATCH_EXCEPTIONS
+	try {
+		SpringApp app;
+		return app.Run (argc,argv);
+	} catch (const std::exception&amp; e) {
+		handleerror(NULL, e.what(), &quot;Fatal Error&quot;, MBF_OK | MBF_EXCL);
+		return 1;
+	}
+#else
+	return app.Run (argv, argv);
+#endif
+}</diff>
      <filename>rts/System/Main.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -8,6 +8,8 @@
 #include &lt;string&gt;
 #ifdef _WIN32
 #include &quot;Win/win32.h&quot;
+#elif defined(__APPLE__)
+class MacBackgroundReader;
 #elif defined(HAS_LIBAIO)
 #include &lt;libaio.h&gt;
 #endif
@@ -26,11 +28,16 @@ public:
 		int* reportReady;
 	};
 
+#if !defined(__APPLE)
 	std::deque&lt;FileToRead&gt; quedFiles;
 	FileToRead curFile;
+#endif /* !defined(__APPLE__) */
+
 #ifdef _WIN32
 	OVERLAPPED curReadInfo;
 	HANDLE curHandle;
+#elif defined(__APPLE__)
+	MacBackgroundReader *reader;
 #elif defined(HAS_LIBAIO)
 	io_context_t io_ctx;
 	int srcfd;</diff>
      <filename>rts/System/Platform/BackgroundReader.h</filename>
    </modified>
    <modified>
      <diff>@@ -7,6 +7,9 @@
 #include &quot;ConfigHandler.h&quot;
 #ifdef _WIN32
 #include &quot;Win/RegHandler.h&quot;
+#elif defined(__APPLE__)
+extern &quot;C&quot; void PreInitMac();
+#include &quot;Mac/UserDefsHandler.h&quot;
 #else
 #include &quot;Linux/DotfileHandler.h&quot;
 #endif
@@ -18,6 +21,9 @@ ConfigHandler&amp; ConfigHandler::GetInstance()
 	if (!instance) {
 #ifdef _WIN32
 		instance = new RegHandler(&quot;Software\\SJ\\spring&quot;);
+#elif defined(__APPLE__)
+		PreInitMac();
+		instance = new UserDefsHandler(); // Config path is based on bundle id
 #else
 		instance = new DotfileHandler(DOTCONFIGPATH);
 #endif</diff>
      <filename>rts/System/Platform/ConfigHandler.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,14 @@
  * byteorder.h
  * Handling of endian byte orders
  * Copyright (C) 2005 Christopher Han
+ *
+ * Mac   PPC: BIG    Endian
+ * Mac   X86: little Endian
+ *
+ * Win   X86: little Endian
+ *
+ * BSD   X86: BIG    Endian
+ * Linux X86: BIG    Endian
  */
 #ifndef BYTEORDER_H
 #define BYTEORDER_H
@@ -59,6 +67,18 @@ static inline float swabfloat(float w) {
 	return *(float*)&amp;l;
 }
 
+#elif defined(__APPLE__)
+// Should work for both x86 and ppc
+
+#include &quot;CoreFoundation/CFByteOrder.h&quot;
+
+#define swabword(w) (CFSwapInt16LittleToHost((uint32_t)w))
+#define swabdword(w) (CFSwapInt32LittleToHost((uint32_t)w))
+static inline float swabfloat(float w) {
+	int i = swabdword(*(int*)&amp;w);
+	return *(float*)&amp;i;
+}
+
 #else
 
 // empty versions for win32</diff>
      <filename>rts/System/Platform/byteorder.h</filename>
    </modified>
    <modified>
      <diff>@@ -24,6 +24,7 @@ def platform():
 		print &quot;Detected platform : darwin&quot;
 		print &quot;WARNING: support is incomplete&quot;
 		detected_platform='darwin'
+		print &quot;NOTE: xcode files are available in /trunk/rts/build/xcode&quot;
 	else:
 		print &quot;Platform not supported yet, please edit SConstruct file&quot;
 		detected_platform='unknown'</diff>
      <filename>rts/build/scons/detect.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>18d666b686f0940f85b6de0e2d04ba6de7ef98d9</id>
    </parent>
  </parents>
  <author>
    <name>krysole</name>
    <email>krysole@37977431-3df6-0310-b722-df95706aa16b</email>
  </author>
  <url>http://github.com/spring/spring/commit/001ece829f37e0063b5031aa76a0a2266b4f3ff1</url>
  <id>001ece829f37e0063b5031aa76a0a2266b4f3ff1</id>
  <committed-date>2006-02-25T22:08:48-08:00</committed-date>
  <authored-date>2006-02-25T22:08:48-08:00</authored-date>
  <message>Initial Mac Build, XCode files (no scons yet, also only gets to menu, hangs if you try to go further)

git-svn-id: https://spring.clan-sy.com/svn/spring/trunk@888 37977431-3df6-0310-b722-df95706aa16b</message>
  <tree>5dc372c8bb1a8b65c1f01d7d7171086ba374a9d9</tree>
  <committer>
    <name>krysole</name>
    <email>krysole@37977431-3df6-0310-b722-df95706aa16b</email>
  </committer>
</commit>
