Advertisement
jpenguin

main.patch

Jul 8th, 2014
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.80 KB | None | 0 0
  1. --- /src/lincity-ng/main.cpp    2013-12-22 12:57:28.000000000 -0800
  2. +++ /src/lincity-ng/main.cpp    2014-04-30 11:59:44.000000000 -0700
  3. @@ -58,6 +58,10 @@
  4.  tinygettext::DictionaryManager* dictionaryManager = 0;
  5.  bool restart = false;
  6.  
  7. +#ifdef __APPLE__
  8. +     extern char *getBundleSharePath(char *packageName);
  9. +#endif
  10. +
  11.  void initPhysfs(const char* argv0)
  12.  {
  13.      if(!PHYSFS_init(argv0)) {
  14. @@ -146,28 +150,54 @@
  15.          }
  16.      }
  17.  
  18. -#if defined(APPDATADIR) || defined(ENABLE_BINRELOC)
  19. -    std::string datadir;
  20. -#ifdef ENABLE_BINRELOC
  21. -    BrInitError error;
  22. -    if (br_init (&error) == 0 && error != BR_INIT_ERROR_DISABLED) {
  23. -        printf ("Warning: BinReloc failed to initialize (error code %d)\n",
  24. -                error);
  25. -        printf ("Will fallback to hardcoded default path.\n");
  26. -    }
  27. -
  28. -    char* brdatadir = br_find_data_dir("/usr/local/share");
  29. -    datadir = brdatadir;
  30. -    datadir += "/" PACKAGE_NAME;
  31. -    free(brdatadir);
  32. +#ifndef __APPLE__ 
  33. +   #if defined(APPDATADIR) || defined(ENABLE_BINRELOC)
  34. +       std::string datadir;
  35. +   #ifdef ENABLE_BINRELOC
  36. +       BrInitError error;
  37. +       if (br_init (&error) == 0 && error != BR_INIT_ERROR_DISABLED) {
  38. +           printf ("Warning: BinReloc failed to initialize (error code %d)\n",
  39. +                   error);
  40. +           printf ("Will fallback to hardcoded default path.\n");
  41. +       }
  42. +  
  43. +       char* brdatadir = br_find_data_dir("/usr/local/share");
  44. +       datadir = brdatadir;
  45. +       datadir += "/" PACKAGE_NAME;
  46. +       free(brdatadir);
  47. +   #else
  48. +       datadir = APPDATADIR;
  49. +   #endif
  50. +  
  51. +       if(!PHYSFS_addToSearchPath(datadir.c_str(), 1)) {
  52. +           std::cout << "Couldn't add '" << datadir
  53. +               << "' to physfs searchpath: " << PHYSFS_getLastError() << "\n";
  54. +       }
  55. +   #endif
  56.  #else
  57. -    datadir = APPDATADIR;
  58. -#endif
  59. -
  60. -    if(!PHYSFS_addToSearchPath(datadir.c_str(), 1)) {
  61. -        std::cout << "Couldn't add '" << datadir
  62. -            << "' to physfs searchpath: " << PHYSFS_getLastError() << "\n";
  63. -    }
  64. +   #if defined(APPDATADIR) || defined(ENABLE_BINRELOC) && __APPLE__
  65. +       std::string datadir;
  66. +   #ifdef ENABLE_BINRELOC
  67. +       BrInitError error;
  68. +       if (br_init (&error) == 0 && error != BR_INIT_ERROR_DISABLED) {
  69. +           printf ("Warning: BinReloc failed to initialize (error code %d)\n",
  70. +                   error);
  71. +           printf ("Will fallback to hardcoded default path.\n");
  72. +       }
  73. +  
  74. +       char* brdatadir = br_find_data_dir("/usr/local/share");
  75. +       datadir = brdatadir;
  76. +       datadir += "/" PACKAGE_NAME;
  77. +       free(brdatadir);
  78. +     #else
  79. +         datadir = APPDATADIR;
  80. +     #endif
  81. +        datadir = getBundleSharePath(PACKAGE_NAME);
  82. +         if(!PHYSFS_addToSearchPath(datadir.c_str(), 1)) {
  83. +             std::cout << "Couldn't add '" << datadir
  84. +                 << "' to physfs searchpath: " << PHYSFS_getLastError() << "\n";
  85. +       }
  86. +   #endif
  87.  #endif
  88.  
  89.      // allow symbolic links
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement