update sdlmain files to 1.2.14
authorkoda
Tue, 20 Oct 2009 11:49:10 +0000
changeset 2565 54296af65fe9
parent 2562 0421e9f59774
child 2567 02ff5f9510b5
update sdlmain files to 1.2.14 add a check when GL_MAX_TEXTURE_SIZE fails
hedgewars/SDLMain.h
hedgewars/SDLMain.m
hedgewars/uStore.pas
--- a/hedgewars/SDLMain.h	Mon Oct 19 13:01:38 2009 +0000
+++ b/hedgewars/SDLMain.h	Tue Oct 20 11:49:10 2009 +0000
@@ -5,7 +5,12 @@
     Feel free to customize this file to suit your needs
 */
 
+#ifndef _SDLMain_h_
+#define _SDLMain_h_
+
 #import <Cocoa/Cocoa.h>
 
 @interface SDLMain : NSObject
 @end
+
+#endif /* _SDLMain_h_ */
--- a/hedgewars/SDLMain.m	Mon Oct 19 13:01:38 2009 +0000
+++ b/hedgewars/SDLMain.m	Tue Oct 20 11:49:10 2009 +0000
@@ -5,10 +5,10 @@
     Feel free to customize this file to suit your needs
 */
 
-#import "SDL.h"
-#import "SDLMain.h"
-#import <sys/param.h> /* for MAXPATHLEN */
-#import <unistd.h>
+#include "SDL.h"
+#include "SDLMain.h"
+#include <sys/param.h> /* for MAXPATHLEN */
+#include <unistd.h>
 
 /* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
  but the method still is there and works. To avoid warnings, we declare
@@ -43,11 +43,11 @@
 
 static NSString *getApplicationName(void)
 {
-    NSDictionary *dict;
+    const NSDictionary *dict;
     NSString *appName = 0;
 
     /* Determine the application name */
-    dict = (NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
+    dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
     if (dict)
         appName = [dict objectForKey: @"CFBundleName"];
     
@@ -64,10 +64,10 @@
 @end
 #endif
 
-@interface SDLApplication : NSApplication
+@interface NSApplication (SDLApplication)
 @end
 
-@implementation SDLApplication
+@implementation NSApplication (SDLApplication)
 /* Invoked from the Quit menu item */
 - (void)terminate:(id)sender
 {
@@ -87,15 +87,14 @@
     if (shouldChdir)
     {
         char parentdir[MAXPATHLEN];
-		CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
-		CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
-		if (CFURLGetFileSystemRepresentation(url2, true, (UInt8 *)parentdir, MAXPATHLEN)) {
-	        assert ( chdir (parentdir) == 0 );   /* chdir to the binary app's parent */
-		}
-		CFRelease(url);
-		CFRelease(url2);
-	}
-
+        CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
+        CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
+        if (CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, MAXPATHLEN)) {
+            chdir(parentdir);   /* chdir to the binary app's parent */
+        }
+        CFRelease(url);
+        CFRelease(url2);
+    }
 }
 
 #if SDL_USE_NIB_FILE
@@ -120,7 +119,6 @@
         if ([menuItem hasSubmenu])
             [self fixMenu:[menuItem submenu] withAppName:appName];
     }
-    [ aMenu sizeToFit ];
 }
 
 #else
@@ -203,7 +201,7 @@
     SDLMain				*sdlMain;
 
     /* Ensure the application object is initialised */
-    [SDLApplication sharedApplication];
+    [NSApplication sharedApplication];
     
 #ifdef SDL_USE_CPS
     {
@@ -212,7 +210,7 @@
         if (!CPSGetCurrentProcess(&PSN))
             if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
                 if (!CPSSetFrontProcess(&PSN))
-                    [SDLApplication sharedApplication];
+                    [NSApplication sharedApplication];
     }
 #endif /* SDL_USE_CPS */
 
@@ -319,7 +317,7 @@
     NSString *result;
 
     bufferSize = selfLen + aStringLen - aRange.length;
-    buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar));
+    buffer = (unichar *)NSAllocateMemoryPages(bufferSize*sizeof(unichar));
     
     /* Get first part into buffer */
     localRange.location = 0;
@@ -374,7 +372,6 @@
     }
 
 #if SDL_USE_NIB_FILE
-    [SDLApplication poseAsClass:[NSApplication class]];
     NSApplicationMain (argc, argv);
 #else
     CustomApplicationMain (argc, argv);
--- a/hedgewars/uStore.pas	Mon Oct 19 13:01:38 2009 +0000
+++ b/hedgewars/uStore.pas	Tue Oct 20 11:49:10 2009 +0000
@@ -988,6 +988,10 @@
 procedure SetupOpenGL;
 begin
 glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize);
+
+//workaround for wan the previous call fails
+if MaxTextureSize = 0 then MaxTextureSize:= 1024;
+
 {$IFDEF DEBUGFILE}
 AddFileLog('GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize));
 {$ENDIF}