Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 35 additions & 10 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ ifeq ($(GNUSTEP_HOST_OS),mingw32)
endif
GNUSTEP_OBJ_DIR_BASENAME := $(GNUSTEP_OBJ_DIR_NAME)

# decide whether we are building legacy or modern based on gcc version,
# which is available to all dev environments
GCCVERSION := $(shell gcc --version | grep ^gcc | sed 's/^.* //g')
ifeq ($(GCCVERSION),4.7.1)
$(info Compiling legacy build)
modern = no
else
$(info Compiling modern build)
modern = yes
endif

ifeq ($(GNUSTEP_HOST_OS),mingw32)
vpath %.rc src/SDL/OOResourcesWin

Expand All @@ -23,18 +34,33 @@ ifeq ($(GNUSTEP_HOST_OS),mingw32)
JS_IMPORT_LIBRARY = js32ECMAv5
endif

ADDITIONAL_INCLUDE_DIRS = -I$(WIN_DEPS_DIR)/include -I$(JS_INC_DIR) -Isrc/SDL -Isrc/Core -Isrc/BSDCompat -Isrc/Core/Scripting -Isrc/Core/Materials -Isrc/Core/Entities -Isrc/Core/OXPVerifier -Isrc/Core/Debug -Isrc/Core/Tables -Isrc/Core/MiniZip -Isrc/SDL/EXRSnapshotSupport
ADDITIONAL_OBJC_LIBS = -L$(WIN_DEPS_DIR)/lib -lglu32 -lopengl32 -lopenal32.dll -lpng14.dll -lmingw32 -lSDLmain -lSDL -lvorbisfile.dll -lvorbis.dll -lz -lgnustep-base -l$(JS_IMPORT_LIBRARY) -lshlwapi -ldwmapi -lwinmm -mwindows
ADDITIONAL_CFLAGS = -DWIN32 -DNEED_STRLCPY `sdl-config --cflags` -mtune=generic -DWINVER=0x0601 -D_WIN32_WINNT=0x0601
ifeq ($(modern),yes)
SPEECH_LIBRARY_NAME = espeak-ng
OPENAL_LIBRARY_NAME = openal
LIBPNG_LIBRARY_NAME = png
else
SPEECH_LIBRARY_NAME = espeak
OPENAL_LIBRARY_NAME = openal32
LIBPNG_LIBRARY_NAME = png14
endif

ADDITIONAL_INCLUDE_DIRS = -Isrc/SDL -Isrc/Core -Isrc/BSDCompat -Isrc/Core/Scripting -Isrc/Core/Materials -Isrc/Core/Entities -Isrc/Core/OXPVerifier -Isrc/Core/Debug -Isrc/Core/Tables -Isrc/Core/MiniZip -Isrc/SDL/EXRSnapshotSupport
ADDITIONAL_OBJC_LIBS = -lglu32 -lopengl32 -l$(OPENAL_LIBRARY_NAME).dll -l$(LIBPNG_LIBRARY_NAME).dll -lmingw32 -lSDLmain -lSDL -lvorbisfile.dll -lvorbis.dll -lz -lgnustep-base -l$(JS_IMPORT_LIBRARY) -lshlwapi -ldwmapi -lwinmm -mwindows
ADDITIONAL_CFLAGS = -DWIN32 -DNEED_STRLCPY `sdl-config --cflags` -mtune=generic -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 -DNTDDI_VERSION=0x0A00000F
# note the vpath stuff above isn't working for me, so adding src/SDL and src/Core explicitly
ADDITIONAL_OBJCFLAGS = -DLOADSAVEGUI -DWIN32 -DXP_WIN -Wno-import -std=gnu99 `sdl-config --cflags` -mtune=generic -DWINVER=0x0601 -D_WIN32_WINNT=0x0601
ADDITIONAL_OBJCFLAGS = -DLOADSAVEGUI -DWIN32 -DXP_WIN -Wno-import -std=gnu99 `sdl-config --cflags` -mtune=generic -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 -DNTDDI_VERSION=0x0A00000F
# oolite_LIB_DIRS += -L$(GNUSTEP_LOCAL_ROOT)/lib -L$(WIN_DEPS_DIR)/lib -L$(JS_LIB_DIR)

ifeq ($(ESPEAK),yes)
ADDITIONAL_OBJC_LIBS += -lespeak.dll
ADDITIONAL_OBJC_LIBS += -l$(SPEECH_LIBRARY_NAME).dll
ADDITIONAL_OBJCFLAGS +=-DHAVE_LIBESPEAK=1
GNUSTEP_OBJ_DIR_NAME := $(GNUSTEP_OBJ_DIR_NAME).spk
endif

ifneq ($(modern),yes)
ADDITIONAL_INCLUDE_DIRS += -I$(WIN_DEPS_DIR)/include -I$(JS_INC_DIR)
ADDITIONAL_OBJC_LIBS += -L$(WIN_DEPS_DIR)/lib
endif
else
LIBJS_DIR = deps/Linux-deps/x86_64/mozilla
LIBJS_INC_DIR = deps/Linux-deps/x86_64/mozilla/include
Expand Down Expand Up @@ -74,11 +100,10 @@ else
endif
endif

# Add flag if building with GNUStep and Clang
ifneq '' '$(GNUSTEP_HOST_OS)'
ifneq '' '$(findstring clang++,$(CXX))'
ADDITIONAL_OBJCFLAGS += -fobjc-runtime=gnustep-1.9
endif
# Add specific flag if building modern
ifeq ($(modern),yes)
ADDITIONAL_CFLAGS += -DOOLITE_MODERN_BUILD=1
ADDITIONAL_OBJCFLAGS += -DOOLITE_MODERN_BUILD=1
endif

OBJC_PROGRAM_NAME = oolite
Expand Down
21 changes: 17 additions & 4 deletions GNUmakefile.postamble
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,16 @@ after-all::
$(CP) $(CP_FLAGS) Schemata $(PROGDIR)/Resources
ifeq ($(ESPEAK),yes)
ifeq ($(GNUSTEP_HOST_OS),mingw32)
$(CP) $(CP_FLAGS) deps/Cross-platform-deps/espeak-data $(PROGDIR)/Resources
ifeq ($(modern),yes)
$(CP) $(CP_FLAGS) $(MINGW_PREFIX)/share/espeak-ng-data $(PROGDIR)/Resources
# replace f2 voice and set the default voice as well
$(RM) $(PROGDIR)/Resources/espeak-ng-data/voices/!v/f2
# copy required files from the existing cross-platform-deps repo
$(CP) $(CP_FLAGS) deps/Cross-platform-deps/espeak-data/voices/!v/f2 $(PROGDIR)/Resources/espeak-ng-data/voices/!v/f2
$(CP) $(CP_FLAGS) deps/Cross-platform-deps/espeak-data/voices/default $(PROGDIR)/Resources/espeak-ng-data/voices/default
else
$(CP) $(CP_FLAGS) deps/Cross-platform-deps/espeak-data $(PROGDIR)/Resources
endif
else
ifeq ($(use_deps),yes)
$(CP) $(CP_FLAGS) deps/Cross-platform-deps/espeak-data $(PROGDIR)/Resources
Expand All @@ -57,10 +66,14 @@ ifeq ($(strip),yes)
$(STRIP) $(PROGDIR)/$(DEST_BIN)
endif
ifeq ($(GNUSTEP_HOST_OS),mingw32)
ifeq ($(GNUSTEP_HOST_CPU),x86_64)
$(CP) $(CP_FLAGS) deps/Windows-deps/x86_64/DLLs/*.dll $(PROGDIR)
ifeq ($(modern),yes)
ldd $(PROGDIR)/oolite.exe | grep $(MINGW_PREFIX) | awk '{print $$3}' | xargs -I {} $(CP) $(CP_FLAGS) {} $(PROGDIR)
else
$(CP) $(CP_FLAGS) deps/Windows-deps/x86/DLLs/*.dll $(PROGDIR)
ifeq ($(GNUSTEP_HOST_CPU),x86_64)
$(CP) $(CP_FLAGS) deps/Windows-deps/x86_64/DLLs/*.dll $(PROGDIR)
else
$(CP) $(CP_FLAGS) deps/Windows-deps/x86/DLLs/*.dll $(PROGDIR)
endif
endif
ifeq ($(debug),yes)
$(RM) $(PROGDIR)/js32ECMAv5.dll
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ pkg-debclean:

# And here are our Windows packager targets
#
ifneq '' '$(MINGW_PREFIX)'
NSIS=$(MINGW_PREFIX)/bin/makensis
else
NSIS=/nsis/makensis.exe
endif
NSISVERSIONS=installers/win32/OoliteVersions.nsh

# Passing arguments cause problems with some versions of NSIS.
Expand Down
1 change: 1 addition & 0 deletions files.make
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ OOLITE_MISC_FILES = \
AIGraphViz.m \
GameController.m \
GameController+SDLFullScreen.m \
NSUserDefaults+Override.m \
OOJoystickManager.m \
OOJoystickProfile.m \
OOSDLJoystickManager.m \
Expand Down
2 changes: 1 addition & 1 deletion src/Cocoa/Info-Oolite.plist
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<key>CFBundleIconFile</key>
<string>oolite-icon</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<string>OoliteDefaults</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
2 changes: 1 addition & 1 deletion src/Core/GameController.m
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ - (NSURL *) snapshotsURLCreatingIfNeeded:(BOOL)create
NSFileManager *fmgr = [NSFileManager defaultManager];
if (![fmgr fileExistsAtPath:path])
{
[fmgr createDirectoryAtPath:path attributes:nil];
[fmgr oo_createDirectoryAtPath:path attributes:nil];
}
}
return url;
Expand Down
10 changes: 5 additions & 5 deletions src/Core/NSFileManagerOOExtensions.m
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ - (NSArray *) oo_directoryContentsAtPath:(NSString *)path

- (BOOL) oo_createDirectoryAtPath:(NSString *)path attributes:(NSDictionary *)attributes
{
#if OOLITE_WINDOWS
return [self createDirectoryAtPath:path attributes:attributes];
#else
#if OOLITE_WINDOWS && !OOLITE_MODERN_BUILD
return [self createDirectoryAtPath:path attributes:attributes];
#else
// has been in GNUStep since 2008, so it's probably safe to use now.
// .... why do I say things like that, of course it's not safe - CIM
return [self createDirectoryAtPath:path withIntermediateDirectories:YES attributes:attributes error:NULL];
#endif
#endif
}


Expand Down Expand Up @@ -217,7 +217,7 @@ - (BOOL) chdirToSnapshotPath
if (![self changeCurrentDirectoryPath: savedir])
{
// it probably doesn't exist.
if (![self createDirectoryAtPath: savedir attributes: nil])
if (![self oo_createDirectoryAtPath: savedir attributes: nil])
{
OOLog(@"savedSnapshot.defaultPath.create.failed", @"Unable to create directory %@", savedir);
return NO;
Expand Down
38 changes: 38 additions & 0 deletions src/Core/NSUserDefaults+Override.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*

NSUserDefaults+Override.h

Oolite
Copyright (C) 2004-2025 Giles C Williams and contributors

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.

*/

#import "OOCocoa.h"

#if OOLITE_MODERN_BUILD

#import <Foundation/NSUserDefaults.h>

@interface NSUserDefaults (Override)

- (BOOL) writeDictionary: (NSDictionary*)dict
toFile: (NSString*)file;

@end

#endif
76 changes: 76 additions & 0 deletions src/Core/NSUserDefaults+Override.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*

NSUserDefaults+Override.m

Oolite
Copyright (C) 2004-2025 Giles C Williams and contributors

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.

*/


#import "NSUserDefaults+Override.h"
#import <Foundation/NSData.h>
#import <Foundation/NSFileManager.h>
#import <Foundation/NSPropertyList.h>

#if OOLITE_MODERN_BUILD

@implementation NSUserDefaults (Override)

- (BOOL) writeDictionary: (NSDictionary*)dict
toFile: (NSString*)file
{
if ([file length] == 0)
{
NSLog(@"Defaults database filename is empty when writing");
}
else if (nil == dict)
{
NSFileManager *mgr = [NSFileManager defaultManager];

return [mgr removeFileAtPath: file handler: nil];
}
else
{
NSData *data;
NSString *err;

err = nil;
data = [NSPropertyListSerialization dataFromPropertyList: dict
format: NSPropertyListOpenStepFormat
errorDescription: &err];
if (data == nil)
{
NSLog(@"Failed to serialize defaults database for writing: %@", err);
}
else if ([data writeToFile: file atomically: YES] == NO)
{
NSLog(@"Failed to write defaults database to file: %@", file);
}
else
{
return YES;
}
}

return NO;
}

@end

#endif // OOLITE_MODERN_BUILD
53 changes: 27 additions & 26 deletions src/Core/OOCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,33 @@ - (id) copy;
typedef struct OOCacheImpl OOCacheImpl;
typedef struct OOCacheNode OOCacheNode;

struct OOCacheImpl
{
// Splay tree root
OOCacheNode *root;

// Ends of age list
OOCacheNode *oldest, *youngest;

unsigned count;
NSString *name;
};


struct OOCacheNode
{
// Payload
id<OOCacheComparable> key;
id value;

// Splay tree
OOCacheNode *leftChild, *rightChild;

// Age list
OOCacheNode *younger, *older;
};



enum { kCountUnknown = -1U };

Expand Down Expand Up @@ -389,32 +416,6 @@ - (void)loadFromArray:(NSArray *)array

/***** Most of the implementation. In C. Because I'm inconsistent and slightly m. *****/

struct OOCacheImpl
{
// Splay tree root
OOCacheNode *root;

// Ends of age list
OOCacheNode *oldest, *youngest;

unsigned count;
NSString *name;
};


struct OOCacheNode
{
// Payload
id<OOCacheComparable> key;
id value;

// Splay tree
OOCacheNode *leftChild, *rightChild;

// Age list
OOCacheNode *younger, *older;
};

static OOCacheNode *CacheNodeAllocate(id<OOCacheComparable> key, id value);
static void CacheNodeFree(OOCacheImpl *cache, OOCacheNode *node);
static id CacheNodeGetValue(OOCacheNode *node);
Expand Down
8 changes: 8 additions & 0 deletions src/Core/OOCocoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ MA 02110-1301, USA.
#ifdef GNUSTEP
#define OOLITE_GNUSTEP 1

#if (((GNUSTEP_BASE_MAJOR_VERSION == 1 && GNUSTEP_BASE_MINOR_VERSION >= 31) || (GNUSTEP_BASE_MAJOR_VERSION > 1)) && !OOLITE_MODERN_BUILD)
#error Oolite legacy build cannot be generated using GNUstep 1.31 or higher.
#endif

#if ((GNUSTEP_BASE_MAJOR_VERSION == 1 && GNUSTEP_BASE_MINOR_VERSION < 28) && OOLITE_MODERN_BUILD)
#error Oolite modern build cannot be generated using GNUstep earlier than 1.28.
#endif

#if (GNUSTEP_BASE_MAJOR_VERSION == 1 && GNUSTEP_BASE_MINOR_VERSION >= 20) || (GNUSTEP_BASE_MAJOR_VERSION > 1)
#define OOLITE_GNUSTEP_1_20 1
#else
Expand Down
1 change: 1 addition & 0 deletions src/Core/OOOXZManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ - (void) setProgressStatus:(NSString *)new
- (BOOL) updateManifests
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[self dataURL]]];
[request setHTTPShouldHandleCookies:NO];
if (_downloadStatus != OXZ_DOWNLOAD_NONE)
{
return NO;
Expand Down
Loading