diff --git a/CMakeLists.txt b/CMakeLists.txt index ff461fc43d..26af328414 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,8 @@ endif (WIN32) # Dependencies find_package(OGRE REQUIRED) -include_directories("." ${OGRE_INCLUDE_DIR} ${PLATFORM_INCLUDE_DIR}) +find_package(BOOST REQUIRED) +include_directories("." ${OGRE_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${PLATFORM_INCLUDE_DIR}) link_directories(${OGRE_LIB_DIR}) # Main executable diff --git a/README.md b/README.md new file mode 100644 index 0000000000..68a66baccd --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +OpenMW +====== + +From the [official website][]: + +> OpenMW is an attempt to reimplement the popular role playing game Morrowind. It aims to be a fully playable, open source implementation of the game. You must own Morrowind to use OpenMW. + +About This Project +------------------ + +This specific repository is a branch of OpenMW intended to keep pace with development of the project in order to provide a Mac build for interested parties to contribute. This is not an official, sanctioned branch of the OpenMW project. I will only be able to answer specific questions about getting this project running on Mac OS X, **no other platform**. I will not even be able to guarantee my changes maintain backwards compatibility against builds in other operating systems. You have been warned. + +Getting OpenMW Working +---------------------- + +1. Clone this repository. +2. Install `bjam` through MacPorts. +3. Download [boost][] 1.43 and install it with the following command: + + $ mkdir build && sudo bjam --build-dir=build --layout=versioned --toolset=darwin --architecture=combined --address-model=32 --link=shared,static install + +4. Download [Ogre][] 1.7.1 and build and Xcode project with CMake: + + $ mdkir build && cd build && BOOST_INCLUDEDIR=/usr/local/include/boost-1_43 BOOST_LIBRARYDIR=/usr/local/lib cmake -G Xcode .. + +5. Once the build completes, move `lib/Release/Ogre.framework` into `/Library/Frameworks`. + +6. Generate the Makefile for OpenMW as follows: + + $ mkdir build && cd build && BOOST_INCLUDEDIR=/usr/local/include/boost-1_43 BOOST_LIBRARYDIR=/usr/local/lib CMAKE_OSX_ARCHITECTURES=i386 cmake .. + +7. Move your Morrowind `Data Files` directory into `build`, renamed as `data`. + +[boost]: http://www.boost.org +[Ogre]: http://www.ogre3d.org +[official website]: http://openmw.com +[Will Thimbleby's Ogre Framework]: http://www.thimbleby.net/ogre/ \ No newline at end of file diff --git a/bsa/bsa_archive.cpp b/bsa/bsa_archive.cpp index 304dfd57af..a7450103af 100644 --- a/bsa/bsa_archive.cpp +++ b/bsa/bsa_archive.cpp @@ -131,6 +131,63 @@ public: // Check if the file exists. bool exists(const String& filename) { return arc.exists(filename.c_str()); } + + // Fill out all types of virtual members from Ogre framework + StringVectorPtr list(bool recursive = true) + { + StringVectorPtr ptr = StringVectorPtr(new StringVector()); + return ptr; + } + + StringVectorPtr find(const String& pattern, bool recursive = true) + { + StringVectorPtr ptr = StringVectorPtr(new StringVector()); + return ptr; + } + + FileInfoListPtr listFileInfo(bool recursive = true) + { + FileInfoListPtr ptr = FileInfoListPtr(new FileInfoList()); + return ptr; + } + + FileInfoListPtr findFileInfo(const String& pattern, bool recursive = true) + { + FileInfoListPtr ptr = FileInfoListPtr(new FileInfoList()); + + // Check if the file exists (only works for single files - wild + // cards and recursive search isn't implemented.) + if(exists(pattern)) { + FileInfo fi; + fi.archive = this; + fi.filename = pattern; + // It apparently doesn't matter that we return bogus + // information + fi.path = ""; + fi.compressedSize = fi.uncompressedSize = 0; + + ptr->push_back(fi); + } + + return ptr; + } + + DataStreamPtr open(const String& filename, bool recursive = true) const + { + // Get a non-const reference to arc. This is a hack and it's all + // OGRE's fault. You should NOT expect an open() command not to + // have any side effects on the archive, and hence this function + // should not have been declared const in the first place. + BSAFile *narc = (BSAFile*)&arc; + + // Open the file + StreamPtr strm = narc->getFile(filename.c_str()); + + // Wrap it into an Ogre::DataStream. + return DataStreamPtr(new Mangle2OgreStream(strm)); + } + + }; // An archive factory for BSA archives diff --git a/cmake/FindOGRE.cmake b/cmake/FindOGRE.cmake index 15526e4eda..5438ee100c 100644 --- a/cmake/FindOGRE.cmake +++ b/cmake/FindOGRE.cmake @@ -33,14 +33,30 @@ IF (WIN32) #Windows SET(OGRE_LIB_DIR $ENV{OGRE_SRC}/lib) SET(OGRE_LIBRARIES debug OgreMain_d optimized OgreMain) ENDIF (OGRESOURCE) -ELSE (WIN32) #Unix +ENDIF (WIN32) + +IF (UNIX AND NOT APPLE) CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR) FIND_PACKAGE(PkgConfig REQUIRED) PKG_SEARCH_MODULE(OGRE REQUIRED OGRE) SET(OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIRS}) SET(OGRE_LIB_DIR ${OGRE_LIBDIR}) SET(OGRE_LIBRARIES ${OGRE_LIBRARIES} CACHE STRING "") -ENDIF (WIN32) +ENDIF (UNIX AND NOT APPLE) + +IF (APPLE) + FIND_PATH(OGRE_INCLUDE_DIR Ogre.h + PATHS + /Library/Frameworks + /opt/local + ) + FIND_LIBRARY(OGRE_LIBRARIES + NAMES Ogre + PATHS + /Library/Frameworks + /opt/local + ) +ENDIF (APPLE) #Do some preparation SEPARATE_ARGUMENTS(OGRE_INCLUDE_DIR) diff --git a/esm/esm_reader.hpp b/esm/esm_reader.hpp index 0d895582d2..e95d996735 100644 --- a/esm/esm_reader.hpp +++ b/esm/esm_reader.hpp @@ -14,6 +14,12 @@ #include "../mangle/tools/str_exception.h" #include "../tools/stringops.h" +static size_t strnlen(const char *s, size_t n) +{ + const char *p = (const char *)memchr(s, 0, n); + return(p ? p-s : n); +} + namespace ESM { enum Version