diff --git a/.gitignore b/.gitignore index 774478e2b..b17b5a584 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ build *~ Doxygen -prebuilt \ No newline at end of file +prebuilt +apps/openmw/config.hpp +Docs/mainpage.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e0c0c463..2ee5ac653 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,18 @@ IF (APPLE) set(APP_BUNDLE_DIR "${OpenMW_BINARY_DIR}/OpenMW.app") ENDIF (APPLE) +# Version + +set (OPENMW_VERSION_MAJOR 0) +set (OPENMW_VERSION_MINOR 12) +set (OPENMW_VERSION_RELEASE 0) + +set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") + +# doxygen main page + +configure_file ("${OpenMW_SOURCE_DIR}/Docs/mainpage.hpp.cmake" "${OpenMW_SOURCE_DIR}/Docs/mainpage.hpp") + # Sound source selection option(USE_AUDIERE "use Audiere for sound" OFF) option(USE_FFMPEG "use ffmpeg for sound" OFF) @@ -56,7 +68,7 @@ IF(EXISTS "${CMAKE_SOURCE_DIR}/prebuilt/vc100-mt-gd/ogre_1_7_1") set(AUDIERE_LIBRARY "${PREBUILT_DIR}/audiere-1.9.4/lib/audiere.lib") set(ENV{OPENALDIR} "${PREBUILT_DIR}/OpenAL 1.1 SDK") - + set(BULLET_ROOT "${PREBUILT_DIR}/bullet") ELSE() message (STATUS "OpenMW pre-built binaries not found. Using standard locations.") @@ -436,8 +448,7 @@ if(DPKG_PROGRAM) exec_program("git" ARGS "config --get user.email" OUTPUT_VARIABLE GIT_EMAIL) set(PACKAGE_MAINTAINER "${GIT_NAME} <${GIT_EMAIL}>") else() - #FIXME this should probably be read from some file like ${CMAKE_CURRENT_SOURCE_DIR}/VERSION or something that gets updated when changing version - set(VERSION_STRING "0.10.0") + set(VERSION_STRING "${OPENMW_VERSION}") set(PACKAGE_MAINTAINER "unknown") endif() diff --git a/Docs/Doxyfile b/Docs/Doxyfile index 0a1e0eae8..43c3312ad 100644 --- a/Docs/Doxyfile +++ b/Docs/Doxyfile @@ -576,6 +576,7 @@ WARN_LOGFILE = INPUT = apps \ components \ libs \ + Docs # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is diff --git a/Docs/DoxyfilePages b/Docs/DoxyfilePages index 943e2eef0..5ce82a7c2 100644 --- a/Docs/DoxyfilePages +++ b/Docs/DoxyfilePages @@ -576,6 +576,7 @@ WARN_LOGFILE = INPUT = apps \ components \ libs \ + Docs # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is diff --git a/Docs/mainpage.hpp.cmake b/Docs/mainpage.hpp.cmake new file mode 100644 index 000000000..f8cdf8a82 --- /dev/null +++ b/Docs/mainpage.hpp.cmake @@ -0,0 +1,5 @@ +/// \mainpage +/// +/// This is the source documentation for: +/// +/// OpenMW @OPENMW_VERSION@ diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 492c3869b..f8b4d7a59 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -1,5 +1,9 @@ project(OpenMW) +# config file + +configure_file ("${OpenMW_SOURCE_DIR}/config.hpp.cmake" "${OpenMW_SOURCE_DIR}/config.hpp") + # local files set(GAME @@ -7,7 +11,8 @@ set(GAME engine.cpp ) set(GAME_HEADER - engine.hpp) + engine.hpp + config.hpp) source_group(game FILES ${GAME} ${GAME_HEADER}) set(GAMEREND diff --git a/apps/openmw/config.hpp.cmake b/apps/openmw/config.hpp.cmake new file mode 100644 index 000000000..848fbe0eb --- /dev/null +++ b/apps/openmw/config.hpp.cmake @@ -0,0 +1,9 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#define OPENMW_VERSION_MAJOR @OPENMW_VERSION_MAJOR@ +#define OPENMW_VERSION_MINOR @OPENMW_VERSION_MINOR@ +#define OPENMW_VERSION_RELEASE @OPENMW_VERSION_RELEASE@ +#define OPENMW_VERSION "@OPENMW_VERSION@" + +#endif diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 5a05043ae..c344b55aa 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -155,7 +155,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) try { mEnvironment.mFrameDuration = evt.timeSinceLastFrame; - + // mEnvironment.mWindowManager->onFrame(mEnvironment.mFrameDuration); @@ -252,13 +252,12 @@ void OMW::Engine::loadBSA() for (Files::MultiDirCollection::TIter iter (bsa.begin()); iter!=bsa.end(); ++iter) { std::cout << "Adding " << iter->second.string() << std::endl; - addBSA (iter->second.string()); + Bsa::addBSA (iter->second.string()); } - std::string m = mDataDir.string(); - std::cout << "Data dir" << m << "\n"; - addDir(m, mFSStrict); - + std::string m = mDataDir.string(); + std::cout << "Data dir" << m << "\n"; + Bsa::addDir(m, mFSStrict); } // add resources directory @@ -349,12 +348,12 @@ void OMW::Engine::go() ogreCfg.insert(0, cfgUserDir); //A local plugins.cfg will be used if it exist, otherwise look in the default path - if(!isFile(plugCfg.c_str())) + if(!Misc::isFile(plugCfg.c_str())) { plugCfg.insert(0, cfgDir); } - mOgre.configure(!isFile(ogreCfg.c_str()), cfgUserDir, plugCfg, false); + mOgre.configure(!Misc::isFile(ogreCfg.c_str()), cfgUserDir, plugCfg, false); // This has to be added BEFORE MyGUI is initialized, as it needs // to find core.xml here. @@ -366,7 +365,7 @@ void OMW::Engine::go() loadBSA(); // Create physics. shapeLoader is deleted by the physic engine - ManualBulletShapeLoader* shapeLoader = new ManualBulletShapeLoader(); + NifBullet::ManualBulletShapeLoader* shapeLoader = new NifBullet::ManualBulletShapeLoader(); mPhysicEngine = new OEngine::Physic::PhysicEngine(shapeLoader); // Create the world diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index e117a0688..c3d0cc821 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -26,6 +26,8 @@ #endif +#include "config.hpp" + using namespace std; /// Parse command line options and openmw.cfg file (if one exists). Results are directly @@ -41,7 +43,8 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) "Syntax: openmw \nAllowed options"); desc.add_options() - ("help", "print help message") + ("help", "print help message and quit") + ("version", "print version information and quit") ("data", bpo::value >() ->default_value (std::vector(), "data") ->multitoken(), @@ -84,7 +87,7 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) //If there is an openmw.cfg in the current path use that as global config //Otherwise try getPath std::string cfgFile = "openmw.cfg"; - if(!isFile(cfgFile.c_str())) + if(!Misc::isFile(cfgFile.c_str())) { cfgFile = Files::getPath (Files::Path_ConfigGlobal, "openmw", "openmw.cfg"); } @@ -105,12 +108,23 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) if (globalConfigFile.is_open()) bpo::store ( bpo::parse_config_file (globalConfigFile, desc), variables); + bool run = true; + if (variables.count ("help")) { std::cout << desc << std::endl; - return false; + run = false; + } + + if (variables.count ("version")) + { + std::cout << "OpenMW version " << OPENMW_VERSION << std::endl; + run = false; } + if (!run) + return false; + // directory settings if (variables["fs-strict"].as()==true) engine.enableFSStrict(); diff --git a/apps/openmw/mwclass/classes.cpp b/apps/openmw/mwclass/classes.cpp index 745614852..e9538a6cb 100644 --- a/apps/openmw/mwclass/classes.cpp +++ b/apps/openmw/mwclass/classes.cpp @@ -42,7 +42,7 @@ namespace MWClass ItemLevList::registerSelf(); Light::registerSelf(); Lockpick::registerSelf(); - Misc::registerSelf(); + Miscellaneous::registerSelf(); Probe::registerSelf(); Repair::registerSelf(); Static::registerSelf(); diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index f9995b77f..2986c812d 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -14,11 +14,11 @@ namespace MWClass { - void Misc::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + void Miscellaneous::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, MWWorld::Environment& environment) const { - ESMS::LiveCellRef *ref = - ptr.get(); + ESMS::LiveCellRef *ref = + ptr.get(); assert (ref->base != NULL); const std::string &model = ref->base->model; @@ -31,39 +31,39 @@ namespace MWClass } } - std::string Misc::getName (const MWWorld::Ptr& ptr) const + std::string Miscellaneous::getName (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = - ptr.get(); + ESMS::LiveCellRef *ref = + ptr.get(); return ref->base->name; } - boost::shared_ptr Misc::activate (const MWWorld::Ptr& ptr, + boost::shared_ptr Miscellaneous::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const { return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); } - void Misc::insertIntoContainer (const MWWorld::Ptr& ptr, + void Miscellaneous::insertIntoContainer (const MWWorld::Ptr& ptr, MWWorld::ContainerStore& containerStore) const { insertIntoContainerStore (ptr, containerStore.miscItems); } - std::string Misc::getScript (const MWWorld::Ptr& ptr) const + std::string Miscellaneous::getScript (const MWWorld::Ptr& ptr) const { - ESMS::LiveCellRef *ref = - ptr.get(); + ESMS::LiveCellRef *ref = + ptr.get(); return ref->base->script; } - void Misc::registerSelf() + void Miscellaneous::registerSelf() { - boost::shared_ptr instance (new Misc); + boost::shared_ptr instance (new Miscellaneous); - registerClass (typeid (ESM::Misc).name(), instance); + registerClass (typeid (ESM::Miscellaneous).name(), instance); } } diff --git a/apps/openmw/mwclass/misc.hpp b/apps/openmw/mwclass/misc.hpp index 0da1f0d3a..81262cbee 100644 --- a/apps/openmw/mwclass/misc.hpp +++ b/apps/openmw/mwclass/misc.hpp @@ -5,7 +5,7 @@ namespace MWClass { - class Misc : public MWWorld::Class + class Miscellaneous : public MWWorld::Class { public: diff --git a/apps/openmw/mwrender/exterior.cpp b/apps/openmw/mwrender/exterior.cpp index 1cdc51c98..513fdac2a 100644 --- a/apps/openmw/mwrender/exterior.cpp +++ b/apps/openmw/mwrender/exterior.cpp @@ -124,7 +124,7 @@ void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, } mNpcPart = parent->createChildSceneNode(sceneNodeName); - MeshPtr good2 = NIFLoader::load(mesh); + MeshPtr good2 = NifOgre::NIFLoader::load(mesh); MovableObject *ent = mScene.getMgr()->createEntity(mesh); @@ -213,7 +213,7 @@ void ExteriorCellRender::insertMesh(const std::string &mesh) { assert (mInsert); - NIFLoader::load(mesh); + NifOgre::NIFLoader::load(mesh); Entity *ent = mScene.getMgr()->createEntity(mesh); if(!isStatic) diff --git a/apps/openmw/mwrender/interior.cpp b/apps/openmw/mwrender/interior.cpp index 7fe228f40..02bed0898 100644 --- a/apps/openmw/mwrender/interior.cpp +++ b/apps/openmw/mwrender/interior.cpp @@ -106,7 +106,7 @@ void InteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, npcPart = parent->createChildSceneNode(sceneNodeName); //npcPart->showBoundingBox(true); - MeshPtr good2 = NIFLoader::load(mesh); + MeshPtr good2 = NifOgre::NIFLoader::load(mesh); MovableObject *ent = scene.getMgr()->createEntity(mesh); //ent->extr @@ -184,7 +184,7 @@ void InteriorCellRender::insertMesh(const std::string &mesh) { assert (insert); - NIFLoader::load(mesh); + NifOgre::NIFLoader::load(mesh); MovableObject *ent = scene.getMgr()->createEntity(mesh); insert->attachObject(ent); diff --git a/apps/openmw/mwworld/containerstore.hpp b/apps/openmw/mwworld/containerstore.hpp index c05bfe156..971a79c15 100644 --- a/apps/openmw/mwworld/containerstore.hpp +++ b/apps/openmw/mwworld/containerstore.hpp @@ -16,7 +16,7 @@ namespace MWWorld ESMS::CellRefList ingreds; ESMS::CellRefList lights; ESMS::CellRefList lockpicks; - ESMS::CellRefList miscItems; + ESMS::CellRefList miscItems; ESMS::CellRefList probes; ESMS::CellRefList repairs; ESMS::CellRefList weapons; diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index f1563e621..3a4151e3a 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -135,7 +135,7 @@ namespace MWWorld if (ESMS::LiveCellRef *ref = cell.lockpicks.find (name)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = cell.miscItems.find (name)) + if (ESMS::LiveCellRef *ref = cell.miscItems.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.npcs.find (name)) @@ -198,7 +198,7 @@ namespace MWWorld if (ESMS::LiveCellRef *ref = searchViaHandle (handle, cell.lockpicks)) return Ptr (ref, &cell); - if (ESMS::LiveCellRef *ref = searchViaHandle (handle, cell.miscItems)) + if (ESMS::LiveCellRef *ref = searchViaHandle (handle, cell.miscItems)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = searchViaHandle (handle, cell.npcs)) diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index f29b8b237..2178be318 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -30,8 +30,12 @@ #include "bsa_file.hpp" #include +namespace +{ + using namespace Ogre; using namespace Mangle::Stream; +using namespace Bsa; struct ciLessBoost : std::binary_function { @@ -364,6 +368,11 @@ static void insertDirFactory() } } +} + +namespace Bsa +{ + // The function below is the only publicly exposed part of this file void addBSA(const std::string& name, const std::string& group) @@ -372,11 +381,14 @@ void addBSA(const std::string& name, const std::string& group) ResourceGroupManager::getSingleton(). addResourceLocation(name, "BSA", group); } + void addDir(const std::string& name, const bool& fs, const std::string& group) { - fsstrict = fs; + fsstrict = fs; insertDirFactory(); - ResourceGroupManager::getSingleton(). + ResourceGroupManager::getSingleton(). addResourceLocation(name, "Dir", group); } + +} diff --git a/components/bsa/bsa_archive.hpp b/components/bsa/bsa_archive.hpp index bf7e7ee51..18f7377ff 100644 --- a/components/bsa/bsa_archive.hpp +++ b/components/bsa/bsa_archive.hpp @@ -26,12 +26,17 @@ #include #include -#ifndef _BSA_ARCHIVE_H_ -#define _BSA_ARCHIVE_H_ +#ifndef BSA_BSA_ARCHIVE_H +#define BSA_BSA_ARCHIVE_H + +namespace Bsa +{ /// Add the given BSA file as an input archive in the Ogre resource /// system. void addBSA(const std::string& file, const std::string& group="General"); void addDir(const std::string& file, const bool& fs, const std::string& group="General"); +} + #endif diff --git a/components/bsa/bsa_file.cpp b/components/bsa/bsa_file.cpp index e37d38bb2..95358a362 100644 --- a/components/bsa/bsa_file.cpp +++ b/components/bsa/bsa_file.cpp @@ -32,6 +32,7 @@ using namespace std; using namespace Mangle::Stream; +using namespace Bsa; /// Error handling void BSAFile::fail(const string &msg) diff --git a/components/bsa/bsa_file.hpp b/components/bsa/bsa_file.hpp index 7ec101b43..f54a64d2a 100644 --- a/components/bsa/bsa_file.hpp +++ b/components/bsa/bsa_file.hpp @@ -21,8 +21,8 @@ */ -#ifndef _BSA_FILE_H_ -#define _BSA_FILE_H_ +#ifndef BSA_BSA_FILE_H +#define BSA_BSA_FILE_H #include #include @@ -31,6 +31,9 @@ #include #include +namespace Bsa +{ + /** This class is used to read "Bethesda Archive Files", or BSAs. */ @@ -131,4 +134,6 @@ class BSAFile { return files; } }; +} + #endif diff --git a/components/bsa/tests/bsa_file_test.cpp b/components/bsa/tests/bsa_file_test.cpp index ea3f9291c..07ee73d17 100644 --- a/components/bsa/tests/bsa_file_test.cpp +++ b/components/bsa/tests/bsa_file_test.cpp @@ -11,6 +11,7 @@ #include using namespace std; +using namespace Bsa; BSAFile bsa; diff --git a/components/bsa/tests/bsatool.cpp b/components/bsa/tests/bsatool.cpp index da96c2ed5..df37e3827 100644 --- a/components/bsa/tests/bsatool.cpp +++ b/components/bsa/tests/bsatool.cpp @@ -11,6 +11,7 @@ using namespace std; using namespace Mangle::Stream; +using namespace Bsa; int main(int argc, char** argv) { diff --git a/components/bsa/tests/ogre_archive_test.cpp b/components/bsa/tests/ogre_archive_test.cpp index 1a4334e60..9cd57240f 100644 --- a/components/bsa/tests/ogre_archive_test.cpp +++ b/components/bsa/tests/ogre_archive_test.cpp @@ -19,7 +19,7 @@ int main() Root *root = new Root("","",""); // Add the BSA - addBSA("../../data/Morrowind.bsa"); + Bsa::addBSA("../../data/Morrowind.bsa"); // Pick a sample file String tex = "textures\\tx_natural_cavern_wall13.dds"; diff --git a/components/esm/esm_reader.cpp b/components/esm/esm_reader.cpp index 00a34e2df..2c342178b 100644 --- a/components/esm/esm_reader.cpp +++ b/components/esm/esm_reader.cpp @@ -3,6 +3,8 @@ namespace ESM { +using namespace Misc; + ESM_Context ESMReader::getContext() { // Update the file position before returning diff --git a/components/esm/loadmisc.cpp b/components/esm/loadmisc.cpp index dc3d04f50..0206661c4 100644 --- a/components/esm/loadmisc.cpp +++ b/components/esm/loadmisc.cpp @@ -3,7 +3,7 @@ namespace ESM { -void Misc::load(ESMReader &esm) +void Miscellaneous::load(ESMReader &esm) { model = esm.getHNString("MODL"); name = esm.getHNOString("FNAM"); diff --git a/components/esm/loadmisc.hpp b/components/esm/loadmisc.hpp index 36400eb74..7e151f797 100644 --- a/components/esm/loadmisc.hpp +++ b/components/esm/loadmisc.hpp @@ -11,7 +11,7 @@ namespace ESM * carried, bought and sold. It also includes keys. */ -struct Misc +struct Miscellaneous { struct MCDTstruct { diff --git a/components/esm_store/cell_store.hpp b/components/esm_store/cell_store.hpp index 43860dff3..59464236f 100644 --- a/components/esm_store/cell_store.hpp +++ b/components/esm_store/cell_store.hpp @@ -17,6 +17,7 @@ #include #include +#include namespace ESMS { @@ -99,7 +100,7 @@ namespace ESMS CellRefList itemLists; CellRefList lights; CellRefList lockpicks; - CellRefList miscItems; + CellRefList miscItems; CellRefList npcs; CellRefList probes; CellRefList repairs; @@ -187,7 +188,14 @@ namespace ESMS // Get each reference in turn while(cell->getNextRef(esm, ref)) { - int rec = store.find(ref.refID); + std::string lowerCase; + + std::transform (ref.refID.begin(), ref.refID.end(), std::back_inserter (lowerCase), + (int(*)(int)) std::tolower); + + int rec = store.find(ref.refID); + + ref.refID = lowerCase; /* We can optimize this further by storing the pointer to the record itself in store.all, so that we don't need to look it diff --git a/components/esm_store/store.cpp b/components/esm_store/store.cpp index 9f301d163..2b5b977aa 100644 --- a/components/esm_store/store.cpp +++ b/components/esm_store/store.cpp @@ -85,7 +85,13 @@ void ESMStore::load(ESMReader &esm) dialogue = 0; // Insert the reference into the global lookup - if(!id.empty()) + if(!id.empty() && + (n.val==REC_ACTI || n.val==REC_ALCH || n.val==REC_APPA || n.val==REC_ARMO || + n.val==REC_BOOK || n.val==REC_CLOT || n.val==REC_CONT || n.val==REC_CREA || + n.val==REC_DOOR || n.val==REC_INGR || n.val==REC_LEVC || n.val==REC_LEVI || + n.val==REC_LIGH || n.val==REC_LOCK || n.val==REC_MISC || n.val==REC_NPC_ || + n.val==REC_PROB || n.val==REC_REPA || n.val==REC_STAT || n.val==REC_WEAP) + ) all[id] = n.val; } } diff --git a/components/esm_store/store.hpp b/components/esm_store/store.hpp index 2af6fab37..e3bbf9e82 100644 --- a/components/esm_store/store.hpp +++ b/components/esm_store/store.hpp @@ -52,7 +52,7 @@ namespace ESMS RecListT itemLists; RecListT lights; RecListT lockpicks; - RecListT miscItems; + RecListT miscItems; RecListWithIDT npcs; RecListT npcChange; RecListT probes; diff --git a/components/misc/fileops.cpp b/components/misc/fileops.cpp index b7b9a8d78..eb3b58d84 100644 --- a/components/misc/fileops.cpp +++ b/components/misc/fileops.cpp @@ -4,9 +4,13 @@ #include +namespace Misc +{ + bool isFile(const char *name) { boost::filesystem::path cfg_file_path(name); return boost::filesystem::exists(cfg_file_path); } +} diff --git a/components/misc/fileops.hpp b/components/misc/fileops.hpp index 004f01dd6..f4e7701bb 100644 --- a/components/misc/fileops.hpp +++ b/components/misc/fileops.hpp @@ -1,8 +1,11 @@ -#ifndef __FILEOPS_H_ -#define __FILEOPS_H_ +#ifndef MISC_FILEOPS_H +#define MISC_FILEOPS_H #include +namespace Misc +{ + /// Check if a given path is an existing file (not a directory) bool isFile(const char *name); @@ -10,4 +13,6 @@ bool isFile(const char *name); std::string macBundlePath(); #endif +} + #endif diff --git a/components/misc/slice_array.hpp b/components/misc/slice_array.hpp index f7e2ffeff..cd58e7bd6 100644 --- a/components/misc/slice_array.hpp +++ b/components/misc/slice_array.hpp @@ -21,14 +21,17 @@ */ -#ifndef _SLICE_ARRAY_H_ -#define _SLICE_ARRAY_H_ +#ifndef MISC_SLICE_ARRAY_H +#define MISC_SLICE_ARRAY_H // A simple array implementation containing a pointer and a // length. Used for holding slices into a data buffer. #include #include +namespace Misc +{ + template struct SliceArray { @@ -74,4 +77,6 @@ typedef SliceArray SString; typedef SliceArray IntArray; typedef SliceArray FloatArray; +} + #endif diff --git a/components/misc/stringops.cpp b/components/misc/stringops.cpp index f6b63372c..53eed1fdc 100644 --- a/components/misc/stringops.cpp +++ b/components/misc/stringops.cpp @@ -3,6 +3,9 @@ #include #include +namespace Misc +{ + bool begins(const char* str1, const char* str2) { while(*str2) @@ -57,3 +60,5 @@ bool iends(const char* str1, const char* str2) return strcasecmp(str2, str1+len1-len2) == 0; } + +} diff --git a/components/misc/stringops.hpp b/components/misc/stringops.hpp index e76b8a87a..a32104bf3 100644 --- a/components/misc/stringops.hpp +++ b/components/misc/stringops.hpp @@ -1,5 +1,8 @@ -#ifndef __STRINGOPS_H -#define __STRINGOPS_H +#ifndef MISC_STRINGOPS_H +#define MISC_STRINGOPS_H + +namespace Misc +{ /// Returns true if str1 begins with substring str2 bool begins(const char* str1, const char* str2); @@ -13,4 +16,6 @@ bool ibegins(const char* str1, const char* str2); /// Case insensitive, returns true if str1 ends with substring str2 bool iends(const char* str1, const char* str2); +} + #endif diff --git a/components/misc/tests/slice_test.cpp b/components/misc/tests/slice_test.cpp index 950194279..a0ea55311 100644 --- a/components/misc/tests/slice_test.cpp +++ b/components/misc/tests/slice_test.cpp @@ -8,21 +8,21 @@ using namespace std; int main() { - SString s, t; - s = SString("hello"); + Misc::SString s, t; + s = Misc::SString("hello"); cout << s.toString() << ", len=" << s.length << endl; cout << (s=="hel") << (s=="hell") << (s=="hello") << endl; t = s; - s = SString("othello"+2, 4); + s = Misc::SString("othello"+2, 4); cout << s.toString() << ", len=" << s.length << endl; cout << (s=="hel") << (s=="hell") << (s=="hello") << endl; - cout << (s==t) << (SString("hello")==t) << endl; + cout << (s==t) << (Misc::SString("hello")==t) << endl; const int arr[4] = {1,2,3,4}; - IntArray ia(arr,4); + Misc::IntArray ia(arr,4); cout << ia.length << " " << ia.ptr[2] << endl; diff --git a/components/misc/tests/strops_test.cpp b/components/misc/tests/strops_test.cpp index ca5bd55a9..2a1fdd77d 100644 --- a/components/misc/tests/strops_test.cpp +++ b/components/misc/tests/strops_test.cpp @@ -4,45 +4,45 @@ int main() { - assert(begins("abc", "a")); - assert(begins("abc", "ab")); - assert(begins("abc", "abc")); - assert(begins("abcd", "abc")); - - assert(!begins("abc", "b")); - assert(!begins("abc", "bc")); - assert(!begins("abc", "bcd")); - assert(!begins("abc", "abcd")); - - assert(ibegins("Abc", "a")); - assert(ibegins("aBc", "ab")); - assert(ibegins("abC", "abc")); - assert(ibegins("abcD", "abc")); - - assert(!ibegins("abc", "b")); - assert(!ibegins("abc", "bc")); - assert(!ibegins("abc", "bcd")); - assert(!ibegins("abc", "abcd")); - - assert(ends("abc", "c")); - assert(ends("abc", "bc")); - assert(ends("abc", "abc")); - assert(ends("abcd", "abcd")); - - assert(!ends("abc", "b")); - assert(!ends("abc", "ab")); - assert(!ends("abc", "bcd")); - assert(!ends("abc", "abcd")); - - assert(iends("Abc", "c")); - assert(iends("aBc", "bc")); - assert(iends("abC", "abc")); - assert(iends("abcD", "abcd")); - - assert(!iends("abc", "b")); - assert(!iends("abc", "ab")); - assert(!iends("abc", "bcd")); - assert(!iends("abc", "abcd")); + assert(Misc::begins("abc", "a")); + assert(Misc::begins("abc", "ab")); + assert(Misc::begins("abc", "abc")); + assert(Misc::begins("abcd", "abc")); + + assert(!Misc::begins("abc", "b")); + assert(!Misc::begins("abc", "bc")); + assert(!Misc::begins("abc", "bcd")); + assert(!Misc::begins("abc", "abcd")); + + assert(Misc::ibegins("Abc", "a")); + assert(Misc::ibegins("aBc", "ab")); + assert(Misc::ibegins("abC", "abc")); + assert(Misc::ibegins("abcD", "abc")); + + assert(!Misc::ibegins("abc", "b")); + assert(!Misc::ibegins("abc", "bc")); + assert(!Misc::ibegins("abc", "bcd")); + assert(!Misc::ibegins("abc", "abcd")); + + assert(Misc::ends("abc", "c")); + assert(Misc::ends("abc", "bc")); + assert(Misc::ends("abc", "abc")); + assert(Misc::ends("abcd", "abcd")); + + assert(!Misc::ends("abc", "b")); + assert(!Misc::ends("abc", "ab")); + assert(!Misc::ends("abc", "bcd")); + assert(!Misc::ends("abc", "abcd")); + + assert(Misc::iends("Abc", "c")); + assert(Misc::iends("aBc", "bc")); + assert(Misc::iends("abC", "abc")); + assert(Misc::iends("abcD", "abcd")); + + assert(!Misc::iends("abc", "b")); + assert(!Misc::iends("abc", "ab")); + assert(!Misc::iends("abc", "bcd")); + assert(!Misc::iends("abc", "abcd")); return 0; } diff --git a/components/nif/controlled.hpp b/components/nif/controlled.hpp index 67f2dec36..d59950132 100644 --- a/components/nif/controlled.hpp +++ b/components/nif/controlled.hpp @@ -46,7 +46,7 @@ public: class Named : public Controlled { public: - SString name; + Misc::SString name; void read(NIFFile *nif) { diff --git a/components/nif/data.hpp b/components/nif/data.hpp index c34cafe35..c483b4873 100644 --- a/components/nif/data.hpp +++ b/components/nif/data.hpp @@ -38,7 +38,7 @@ public: // internal (data is inside the nif itself) texture? bool external; - SString filename; // In case of external textures + Misc::SString filename; // In case of external textures NiPixelDataPtr data; // In case of internal textures /* Pixel layout @@ -89,7 +89,7 @@ public: class ShapeData : public Record { public: - FloatArray vertices, normals, colors, uvlist; + Misc::FloatArray vertices, normals, colors, uvlist; const Vector *center; float radius; @@ -124,7 +124,7 @@ class NiTriShapeData : public ShapeData { public: // Triangles, three vertex indices per triangle - SliceArray triangles; + Misc::SliceArray triangles; void read(NIFFile *nif) { @@ -378,7 +378,7 @@ public: { const BoneTrafo *trafo; const Vector4 *unknown; - SliceArray weights; + Misc::SliceArray weights; }; const BoneTrafo *trafo; diff --git a/components/nif/extra.hpp b/components/nif/extra.hpp index 25375c325..eec1aa7b4 100644 --- a/components/nif/extra.hpp +++ b/components/nif/extra.hpp @@ -65,7 +65,7 @@ public: struct TextKey { float time; - SString text; + Misc::SString text; }; std::vector list; @@ -93,7 +93,7 @@ public: "MRK" - marker, only visible in the editor, not rendered in-game "NCO" - no collision */ - SString string; + Misc::SString string; void read(NIFFile *nif) { diff --git a/components/nif/nif_file.cpp b/components/nif/nif_file.cpp index 3c7d7fb17..361e5f6e9 100644 --- a/components/nif/nif_file.cpp +++ b/components/nif/nif_file.cpp @@ -36,6 +36,7 @@ #include using namespace std; using namespace Nif; +using namespace Misc; /* This file implements functions from the NIFFile class. It is also where we stash all the functions we couldn't add as inline diff --git a/components/nif/nif_file.hpp b/components/nif/nif_file.hpp index ebf1fe4a4..951ae1f75 100644 --- a/components/nif/nif_file.hpp +++ b/components/nif/nif_file.hpp @@ -128,24 +128,24 @@ class NIFFile char getByte() { return getType(); } template - SliceArray getArrayLen(int num) - { return SliceArray((const X*)inp->getPtr(num*sizeof(X)),num); } + Misc::SliceArray getArrayLen(int num) + { return Misc::SliceArray((const X*)inp->getPtr(num*sizeof(X)),num); } template - SliceArray getArray() + Misc::SliceArray getArray() { int len = getInt(); return getArrayLen(len); } - SString getString() { return getArray(); } + Misc::SString getString() { return getArray(); } const Vector *getVector() { return getPtr(); } const Matrix *getMatrix() { return getPtr(); } const Transformation *getTrafo() { return getPtr(); } const Vector4 *getVector4() { return getPtr(); } - FloatArray getFloatLen(int num) + Misc::FloatArray getFloatLen(int num) { return getArrayLen(num); } // For fixed-size strings where you already know the size diff --git a/components/nif/record.hpp b/components/nif/record.hpp index 8b8910118..e94e3d0d3 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -24,6 +24,8 @@ #ifndef _NIF_RECORD_H_ #define _NIF_RECORD_H_ +#include + namespace Nif { @@ -88,7 +90,7 @@ struct Record { // Record type and type name int recType; - SString recName; + Misc::SString recName; Record() : recType(RC_MISSING) {} diff --git a/components/nifbullet/bullet_nif_loader.cpp b/components/nifbullet/bullet_nif_loader.cpp index 1ff78023d..94a3a5aac 100644 --- a/components/nifbullet/bullet_nif_loader.cpp +++ b/components/nifbullet/bullet_nif_loader.cpp @@ -49,7 +49,7 @@ using namespace Ogre; using namespace Nif; using namespace Mangle::VFS; - +using namespace NifBullet; //==================================================================================================== Ogre::Matrix3 ManualBulletShapeLoader::getMatrix(Nif::Transformation* tr) diff --git a/components/nifbullet/bullet_nif_loader.hpp b/components/nifbullet/bullet_nif_loader.hpp index d960c6629..360d9850b 100644 --- a/components/nifbullet/bullet_nif_loader.hpp +++ b/components/nifbullet/bullet_nif_loader.hpp @@ -58,6 +58,8 @@ namespace Mangle } } +namespace NifBullet +{ /** *Load bulletShape from NIF files. @@ -126,4 +128,6 @@ private: btCompoundShape* currentShape;//the shape curently under construction }; +} + #endif diff --git a/components/nifbullet/test/test.cpp b/components/nifbullet/test/test.cpp index b91c48666..261edf512 100644 --- a/components/nifbullet/test/test.cpp +++ b/components/nifbullet/test/test.cpp @@ -90,11 +90,11 @@ int main() //Ressources stuff - addBSA("Morrowind.bsa"); + Bsa::addBSA("Morrowind.bsa"); //Ogre::ResourceGroupManager::getSingleton().createResourceGroup("general"); Ogre::ResourcePtr ptr = BulletShapeManager::getSingleton().getByName(mesh,"General"); - ManualBulletShapeLoader* ShapeLoader = new ManualBulletShapeLoader(); + NifBullet::ManualBulletShapeLoader* ShapeLoader = new NifBullet::ManualBulletShapeLoader(); ShapeLoader->load(mesh,"General"); //BulletShapeManager::getSingleton().unload(mesh); diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index 318c39909..668fdcceb 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -50,6 +50,8 @@ using namespace std; using namespace Ogre; using namespace Nif; using namespace Mangle::VFS; +using namespace Misc; +using namespace NifOgre; NIFLoader& NIFLoader::getSingleton() { diff --git a/components/nifogre/ogre_nif_loader.hpp b/components/nifogre/ogre_nif_loader.hpp index ed0661293..bf8a94266 100644 --- a/components/nifogre/ogre_nif_loader.hpp +++ b/components/nifogre/ogre_nif_loader.hpp @@ -49,6 +49,9 @@ namespace Mangle } } +namespace NifOgre +{ + /** Manual resource loader for NIF meshes. This is the main class responsible for translating the internal NIF mesh structure into something Ogre can use. Later it will also handle the insertion of @@ -138,4 +141,6 @@ class NIFLoader : Ogre::ManualResourceLoader Ogre::SkeletonPtr mSkel; }; +} + #endif diff --git a/components/nifogre/tests/ogre_nif_test.cpp b/components/nifogre/tests/ogre_nif_test.cpp index 89f99e8ff..decd43df5 100644 --- a/components/nifogre/tests/ogre_nif_test.cpp +++ b/components/nifogre/tests/ogre_nif_test.cpp @@ -13,11 +13,11 @@ const char* mesh = "meshes\\f\\ex_ashl_a_banner_r.nif"; void C::doTest() { // Add Morrowind.bsa resource location - addBSA("../../data/Morrowind.bsa"); + Bsa::addBSA("../../data/Morrowind.bsa"); // Insert the mesh - NIFLoader::load(mesh); - NIFLoader::load(mesh); + NifOgre::NIFLoader::load(mesh); + NifOgre::NIFLoader::load(mesh); /* SceneNode *node = mgr->getRootSceneNode()->createChildSceneNode("node"); diff --git a/components/to_utf8/Makefile b/components/to_utf8/Makefile index a84cc240e..5234d455a 100644 --- a/components/to_utf8/Makefile +++ b/components/to_utf8/Makefile @@ -1,5 +1,8 @@ tables_gen.hpp: gen_iconv - gen_iconv > tables_gen.hpp + ./gen_iconv > tables_gen.hpp gen_iconv: gen_iconv.cpp g++ -Wall $^ -o $@ + +clean: + rm -f ./gen_iconv \ No newline at end of file diff --git a/components/to_utf8/gen_iconv.cpp b/components/to_utf8/gen_iconv.cpp index 42e997783..cf4d9ac3f 100644 --- a/components/to_utf8/gen_iconv.cpp +++ b/components/to_utf8/gen_iconv.cpp @@ -74,13 +74,28 @@ int write_table(const std::string &charset, const std::string &tableName) // Finish table cout << "};\n"; + + return 0; } int main() { cout << hex; + // Write header guard + cout << "#ifndef COMPONENTS_TOUTF8_TABLE_GEN_H\n#define COMPONENTS_TOUTF8_TABLE_GEN_H\n\n"; + + // Write namespace + cout << "namespace ToUTF8\n{\n\n"; + // English write_table("WINDOWS-1252", "windows_1252"); + + // Close namespace + cout << "\n}\n\n"; + + // Close header guard + cout << "#endif\n\n"; + return 0; } diff --git a/components/to_utf8/tables_gen.hpp b/components/to_utf8/tables_gen.hpp index 55a06cd94..a45d5d181 100644 --- a/components/to_utf8/tables_gen.hpp +++ b/components/to_utf8/tables_gen.hpp @@ -1,3 +1,9 @@ +#ifndef COMPONENTS_TOUTF8_TABLE_GEN_H +#define COMPONENTS_TOUTF8_TABLE_GEN_H + +namespace ToUTF8 +{ + static char windows_1252[] = { 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, @@ -257,3 +263,8 @@ static char windows_1252[] = 0x2, 0xc3, 0xbe, 0x0, 0x0, 0x0, 0x2, 0xc3, 0xbf, 0x0, 0x0, 0x0 }; + +} + +#endif + diff --git a/components/to_utf8/to_utf8.cpp b/components/to_utf8/to_utf8.cpp index 6f6933143..5f38313aa 100644 --- a/components/to_utf8/to_utf8.cpp +++ b/components/to_utf8/to_utf8.cpp @@ -131,7 +131,7 @@ std::string ToUTF8::getUtf8(ToUTF8::FromType from) // Pick translation array const char *arr; if(from == ToUTF8::WINDOWS_1252) - arr = windows_1252; + arr = ToUTF8::windows_1252; else assert(0);