From 3c7a85fe9456b2bc31f3d29198bf2ec060e176f3 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 17 Jun 2007 15:48:57 +0000 Subject: (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible. -Codechange: add support for personal directories on Windows. -Fix [FS#153, FS#193, FS#502, FS#816, FS#854]: fix issues related to fixed names, fixed places of files/directories and application bundles. --- src/video/cocoa_v.mm | 17 +++++++++++++++++ src/video/dedicated_v.cpp | 5 +++-- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'src/video') diff --git a/src/video/cocoa_v.mm b/src/video/cocoa_v.mm index bc4358912..950aa2b28 100644 --- a/src/video/cocoa_v.mm +++ b/src/video/cocoa_v.mm @@ -74,6 +74,7 @@ extern "C" void HideMenuBar(); #include "cocoa_keys.h" #include "../blitter/blitter.hpp" #include "../renderer/renderer.hpp" +#include "../fileio.h" #undef Point #undef Rect @@ -2059,6 +2060,22 @@ void CocoaDialog(const char* title, const char* message, const char* buttonLabel _cocoa_video_dialog = false; } +/* This is needed since OS X application bundles do not have a + * current directory and the data files are 'somewhere' in the bundle */ +void cocoaSetApplicationBundleDir() +{ + char tmp[MAXPATHLEN]; + CFURLRef url = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); + if (CFURLGetFileSystemRepresentation(url, true, (unsigned char*)tmp, MAXPATHLEN)) { + AppendPathSeparator(tmp, lengthof(tmp)); + _searchpaths[SP_APPLICATION_BUNDLE_DIR] = strdup(tmp); + } else { + _searchpaths[SP_APPLICATION_BUNDLE_DIR] = NULL; + } + + CFRelease(url); +} + /* These are called from main() to prevent a _NSAutoreleaseNoPool error when * exiting before the cocoa video driver has been loaded */ diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp index 4aa6b9f20..596e55497 100644 --- a/src/video/dedicated_v.cpp +++ b/src/video/dedicated_v.cpp @@ -13,6 +13,7 @@ #include "../console.h" #include "../variables.h" #include "../genworld.h" +#include "../fileio.h" #include "../blitter/blitter.hpp" #include "dedicated_v.h" @@ -115,7 +116,7 @@ static void CloseWindowsConsoleThread() static void *_dedicated_video_mem; -extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm); +extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm, Subdirectory subdir); extern void SwitchMode(int new_mode); @@ -260,7 +261,7 @@ static void DedicatedVideoMainLoop() _switch_mode = SM_NONE; /* First we need to test if the savegame can be loaded, else we will end up playing the * intro game... */ - if (!SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_NORMAL)) { + if (!SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_NORMAL, BASE_DIR)) { /* Loading failed, pop out.. */ DEBUG(net, 0, "Loading requested map failed, aborting"); _networking = false; -- cgit v1.2.3-70-g09d2