From 819c146ad1d49ee4bfe8ebebdf19b52c96c2c4a6 Mon Sep 17 00:00:00 2001 From: athile Date: Sun, 27 Jun 2010 18:05:01 -0700 Subject: [PATCH 1/5] Project clean-up: move 'misc' into the platform lib, update CMake to build 'platform' as a lib, and various fixes for Visual Studio compiler warnings --- CMakeLists.txt | 8 +-- Docs/Doxyfile | 5 +- apps/openmw/engine.cpp | 4 +- components/esm/esm_reader.hpp | 4 +- components/nif/controlled.hpp | 21 ++++-- components/nif/controller.hpp | 27 +++++--- components/nif/data.hpp | 48 +++++++++----- components/nif/extra.hpp | 12 ++-- components/nif/nif_file.cpp | 4 +- components/nif/nif_file.hpp | 2 +- components/nif/node.hpp | 5 +- components/nif/property.hpp | 8 ++- libs/platform/CMakeLists.txt | 14 ++++ libs/platform/fileops.cpp | 11 ++++ libs/platform/fileops.hpp | 10 +++ libs/platform/slice_array.hpp | 75 ++++++++++++++++++++++ libs/platform/stringops.cpp | 63 ++++++++++++++++++ libs/platform/stringops.hpp | 19 ++++++ libs/platform/tests/.gitignore | 1 + libs/platform/tests/output/slice_test.out | 6 ++ libs/platform/tests/output/strops_test.out | 0 libs/platform/tests/slice_test.cpp | 30 +++++++++ libs/platform/tests/strops_test.cpp | 48 ++++++++++++++ libs/platform/tests/test.sh | 18 ++++++ 24 files changed, 391 insertions(+), 52 deletions(-) create mode 100755 libs/platform/CMakeLists.txt create mode 100644 libs/platform/fileops.cpp create mode 100644 libs/platform/fileops.hpp create mode 100644 libs/platform/slice_array.hpp create mode 100644 libs/platform/stringops.cpp create mode 100644 libs/platform/stringops.hpp create mode 100644 libs/platform/tests/.gitignore create mode 100644 libs/platform/tests/output/slice_test.out create mode 100644 libs/platform/tests/output/strops_test.out create mode 100644 libs/platform/tests/slice_test.cpp create mode 100644 libs/platform/tests/strops_test.cpp create mode 100755 libs/platform/tests/test.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 10abb8568..66254f4fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,17 +68,14 @@ set(INPUT_HEADER components/engine/input/oismanager.hpp components/engine/input/ components/engine/input/dispatcher.hpp components/engine/input/poller.hpp) source_group(input FILES ${INPUT} ${INPUT_HEADER}) -set(MISC components/misc/stringops.cpp components/misc/fileops.cpp) -set(MISC_HEADER components/misc/fileops.hpp components/misc/slice_array.hpp - components/misc/stringops.hpp) -source_group(misc FILES ${MISC} ${MISC_HEADER}) - set(COMPONENTS ${BSA} ${NIF} ${NIFOGRE} ${ESM_STORE} ${OGRE} ${INPUT} ${MISC}) set(COMPONENTS_HEADER ${BSA_HEADER} ${NIF_HEADER} ${NIFOGRE_HEADER} ${ESM_STORE_HEADER} ${ESM_HEADER} ${OGRE_HEADER} ${INPUT_HEADER} ${MISC_HEADER}) # source directory: libs +ADD_SUBDIRECTORY( libs/platform ) + set(MANGLE_VFS libs/mangle/vfs/servers/ogre_vfs.cpp) source_group(mangle_vfs FILES ${MANGLE_VFS}) @@ -148,6 +145,7 @@ target_link_libraries(openmw ${OGRE_LIBRARIES} ${OIS_LIBRARIES} ${Boost_LIBRARIES} + platform caelum) if (APPLE) diff --git a/Docs/Doxyfile b/Docs/Doxyfile index f1f5fda07..5adeea871 100644 --- a/Docs/Doxyfile +++ b/Docs/Doxyfile @@ -573,7 +573,10 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = .. +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/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 143f62792..6e6568ac8 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -7,7 +7,7 @@ #include "components/esm_store/cell_store.hpp" #include "components/bsa/bsa_archive.hpp" #include "components/engine/ogre/renderer.hpp" -#include "components/misc/fileops.hpp" +#include "libs/platform/fileops.hpp" #include "apps/openmw/mwrender/interior.hpp" #include "mwinput/inputmanager.hpp" @@ -104,7 +104,7 @@ void OMW::Engine::go() const char* plugCfg = "plugins.cfg"; - mOgre.configure(!isFile("ogre.cfg"), plugCfg, false); + mOgre.configure(!OMW::Platform::isFile("ogre.cfg"), plugCfg, false); addResourcesDirectory (mDataDir / "Meshes"); addResourcesDirectory (mDataDir / "Textures"); diff --git a/components/esm/esm_reader.hpp b/components/esm/esm_reader.hpp index c03f1d162..033675222 100644 --- a/components/esm/esm_reader.hpp +++ b/components/esm/esm_reader.hpp @@ -12,7 +12,7 @@ #include #include #include -#include "components/misc/stringops.hpp" +#include "libs/platform/stringops.hpp" #ifdef __APPLE__ // need our own implementation of strnlen @@ -218,6 +218,8 @@ public: /// parse the header. void openRaw(Mangle::Stream::StreamPtr _esm, const std::string &name) { + using namespace OMW::Platform; + close(); esm = _esm; c.filename = name; diff --git a/components/nif/controlled.hpp b/components/nif/controlled.hpp index 8396a0a7b..67f2dec36 100644 --- a/components/nif/controlled.hpp +++ b/components/nif/controlled.hpp @@ -30,8 +30,9 @@ namespace Nif { /// Anything that has a controller -struct Controlled : Extra +class Controlled : public Extra { +public: ControllerPtr controller; void read(NIFFile *nif) @@ -42,8 +43,9 @@ struct Controlled : Extra }; /// Has name, extra-data and controller -struct Named : Controlled +class Named : public Controlled { +public: SString name; void read(NIFFile *nif) @@ -54,8 +56,9 @@ struct Named : Controlled }; typedef Named NiSequenceStreamHelper; -struct NiParticleGrowFade : Controlled +class NiParticleGrowFade : public Controlled { +public: void read(NIFFile *nif) { Controlled::read(nif); @@ -65,8 +68,9 @@ struct NiParticleGrowFade : Controlled } }; -struct NiParticleColorModifier : Controlled +class NiParticleColorModifier : public Controlled { +public: NiColorDataPtr data; void read(NIFFile *nif) @@ -76,8 +80,9 @@ struct NiParticleColorModifier : Controlled } }; -struct NiGravity : Controlled +class NiGravity : public Controlled { +public: void read(NIFFile *nif) { Controlled::read(nif); @@ -88,8 +93,9 @@ struct NiGravity : Controlled }; // NiPinaColada -struct NiPlanarCollider : Controlled +class NiPlanarCollider : public Controlled { +public: void read(NIFFile *nif) { Controlled::read(nif); @@ -99,8 +105,9 @@ struct NiPlanarCollider : Controlled } }; -struct NiParticleRotation : Controlled +class NiParticleRotation : public Controlled { +public: void read(NIFFile *nif) { Controlled::read(nif); diff --git a/components/nif/controller.hpp b/components/nif/controller.hpp index 49a38cfaa..d6fb22255 100644 --- a/components/nif/controller.hpp +++ b/components/nif/controller.hpp @@ -31,8 +31,9 @@ namespace Nif { -struct Controller : Record +class Controller : public Record { +public: ControllerPtr next; int flags; float frequency, phase; @@ -54,8 +55,9 @@ struct Controller : Record } }; -struct NiBSPArrayController : Controller +class NiBSPArrayController : public Controller { +public: void read(NIFFile *nif) { Controller::read(nif); @@ -68,8 +70,9 @@ struct NiBSPArrayController : Controller }; typedef NiBSPArrayController NiParticleSystemController; -struct NiMaterialColorController : Controller +class NiMaterialColorController : public Controller { +public: NiPosDataPtr data; void read(NIFFile *nif) @@ -79,8 +82,9 @@ struct NiMaterialColorController : Controller } }; -struct NiPathController : Controller +class NiPathController : public Controller { +public: NiPosDataPtr posData; NiFloatDataPtr floatData; @@ -99,8 +103,9 @@ struct NiPathController : Controller } }; -struct NiUVController : Controller +class NiUVController : public Controller { +public: NiUVDataPtr data; void read(NIFFile *nif) @@ -112,8 +117,9 @@ struct NiUVController : Controller } }; -struct NiKeyframeController : Controller +class NiKeyframeController : public Controller { +public: NiKeyframeDataPtr data; void read(NIFFile *nif) @@ -123,8 +129,9 @@ struct NiKeyframeController : Controller } }; -struct NiAlphaController : Controller +class NiAlphaController : public Controller { +public: NiFloatDataPtr data; void read(NIFFile *nif) @@ -134,8 +141,9 @@ struct NiAlphaController : Controller } }; -struct NiGeomMorpherController : Controller +class NiGeomMorpherController : public Controller { +public: NiMorphDataPtr data; void read(NIFFile *nif) @@ -146,8 +154,9 @@ struct NiGeomMorpherController : Controller } }; -struct NiVisController : Controller +class NiVisController : public Controller { +public: NiVisDataPtr data; void read(NIFFile *nif) diff --git a/components/nif/data.hpp b/components/nif/data.hpp index 920c7cf45..18e78b7ab 100644 --- a/components/nif/data.hpp +++ b/components/nif/data.hpp @@ -29,8 +29,10 @@ namespace Nif { -struct NiSourceTexture : Named +class NiSourceTexture : public Named { +public: + // Is this an external (references a separate texture file) or // internal (data is inside the nif itself) texture? bool external; @@ -65,7 +67,7 @@ struct NiSourceTexture : Named { Named::read(nif); - external = nif->getByte(); + external = !!nif->getByte(); if(external) filename = nif->getString(); else @@ -83,8 +85,9 @@ struct NiSourceTexture : Named }; // Common ancestor for several data classes -struct ShapeData : Record +class ShapeData : public Record { +public: FloatArray vertices, normals, colors, uvlist; const Vector *center; float radius; @@ -116,8 +119,9 @@ struct ShapeData : Record } }; -struct NiTriShapeData : ShapeData +class NiTriShapeData : public ShapeData { +public: // Triangles, three vertex indices per triangle SliceArray triangles; @@ -150,8 +154,9 @@ struct NiTriShapeData : ShapeData } }; -struct NiAutoNormalParticlesData : ShapeData +class NiAutoNormalParticlesData : public ShapeData { +public: int activeCount; void read(NIFFile *nif) @@ -171,8 +176,9 @@ struct NiAutoNormalParticlesData : ShapeData } }; -struct NiRotatingParticlesData : NiAutoNormalParticlesData +class NiRotatingParticlesData : public NiAutoNormalParticlesData { +public: void read(NIFFile *nif) { NiAutoNormalParticlesData::read(nif); @@ -185,8 +191,9 @@ struct NiRotatingParticlesData : NiAutoNormalParticlesData } }; -struct NiPosData : Record +class NiPosData : public Record { +public: void read(NIFFile *nif) { int count = nif->getInt(); @@ -210,8 +217,9 @@ struct NiPosData : Record } }; -struct NiUVData : Record +class NiUVData : public Record { +public: void read(NIFFile *nif) { // TODO: This is claimed to be a "float animation key", which is @@ -235,8 +243,9 @@ struct NiUVData : Record } }; -struct NiFloatData : Record +class NiFloatData : public Record { +public: void read(NIFFile *nif) { int count = nif->getInt(); @@ -245,8 +254,9 @@ struct NiFloatData : Record } }; -struct NiPixelData : Record +class NiPixelData : public Record { +public: unsigned int rmask, gmask, bmask, amask; int bpp, mips; @@ -283,8 +293,9 @@ struct NiPixelData : Record } }; -struct NiColorData : Record +class NiColorData : public Record { +public: struct ColorData { float time; @@ -302,8 +313,9 @@ struct NiColorData : Record } }; -struct NiVisData : Record +class NiVisData : public Record { +public: void read(NIFFile *nif) { int count = nif->getInt(); @@ -319,8 +331,9 @@ struct NiVisData : Record } }; -struct NiSkinInstance : Record +class NiSkinInstance : public Record { +public: NiSkinDataPtr data; NodePtr root; NodeList bones; @@ -338,8 +351,9 @@ struct NiSkinInstance : Record void post(NIFFile *nif); }; -struct NiSkinData : Record +class NiSkinData : public Record { +public: // This is to make sure the structs are packed, ie. that the // compiler doesn't mess them up with extra alignment bytes. #pragma pack(push) @@ -395,8 +409,9 @@ struct NiSkinData : Record } }; -struct NiMorphData : Record +class NiMorphData : public Record { +public: void read(NIFFile *nif) { int morphCount = nif->getInt(); @@ -416,8 +431,9 @@ struct NiMorphData : Record } }; -struct NiKeyframeData : Record +class NiKeyframeData : public Record { +public: void read(NIFFile *nif) { // Rotations first diff --git a/components/nif/extra.hpp b/components/nif/extra.hpp index 788fe3113..25375c325 100644 --- a/components/nif/extra.hpp +++ b/components/nif/extra.hpp @@ -35,15 +35,17 @@ namespace Nif themselves decend from the Extra class, and all the extra data connected to an object form a linked list */ -struct Extra : Record +class Extra : public Record { +public: ExtraPtr extra; void read(NIFFile *nif) { extra.read(nif); } }; -struct NiVertWeightsExtraData : Extra +class NiVertWeightsExtraData : public Extra { +public: void read(NIFFile *nif) { Extra::read(nif); @@ -57,8 +59,9 @@ struct NiVertWeightsExtraData : Extra } }; -struct NiTextKeyExtraData : Extra +class NiTextKeyExtraData : public Extra { +public: struct TextKey { float time; @@ -83,8 +86,9 @@ struct NiTextKeyExtraData : Extra } }; -struct NiStringExtraData : Extra +class NiStringExtraData : public Extra { +public: /* Two known meanings: "MRK" - marker, only visible in the editor, not rendered in-game "NCO" - no collision diff --git a/components/nif/nif_file.cpp b/components/nif/nif_file.cpp index 12845e617..027f64760 100644 --- a/components/nif/nif_file.cpp +++ b/components/nif/nif_file.cpp @@ -23,7 +23,7 @@ #include "nif_file.hpp" #include "record.hpp" -#include "components/misc/stringops.hpp" +#include "libs/platform/stringops.hpp" #include "extra.hpp" #include "controlled.hpp" @@ -44,6 +44,8 @@ using namespace Nif; void NIFFile::parse() { + using namespace OMW::Platform; + // Check the header string const char* head = getString(40); if(!begins(head, "NetImmerse File Format")) diff --git a/components/nif/nif_file.hpp b/components/nif/nif_file.hpp index f6ee80a9e..858ccb36a 100644 --- a/components/nif/nif_file.hpp +++ b/components/nif/nif_file.hpp @@ -28,7 +28,7 @@ #include #include -#include "../misc/slice_array.hpp" +#include "libs/platform/slice_array.hpp" #include #include diff --git a/components/nif/node.hpp b/components/nif/node.hpp index 9e6b48885..f0ad54655 100644 --- a/components/nif/node.hpp +++ b/components/nif/node.hpp @@ -34,8 +34,9 @@ namespace Nif parent node (unless it's the root), and transformation (location and rotation) relative to it's parent. */ -struct Node : Named +class Node : public Named { +public: // Node flags. Interpretation depends somewhat on the type of node. int flags; const Transformation *trafo; @@ -55,7 +56,7 @@ struct Node : Named trafo = nif->getTrafo(); props.read(nif); - hasBounds = nif->getInt(); + hasBounds = !!nif->getInt(); if(hasBounds) { nif->getInt(); // always 1 diff --git a/components/nif/property.hpp b/components/nif/property.hpp index 3500a25b7..1a16854af 100644 --- a/components/nif/property.hpp +++ b/components/nif/property.hpp @@ -29,8 +29,9 @@ namespace Nif { -struct Property : Named +class Property : public Named { +public: // The meaning of these depends on the actual property type. int flags; @@ -41,8 +42,9 @@ struct Property : Named } }; -struct NiTexturingProperty : Property +class NiTexturingProperty : public Property { +public: // A sub-texture struct Texture { @@ -67,7 +69,7 @@ struct NiTexturingProperty : Property void read(NIFFile *nif) { - inUse = nif->getInt(); + inUse = !!nif->getInt(); if(!inUse) return; texture.read(nif); diff --git a/libs/platform/CMakeLists.txt b/libs/platform/CMakeLists.txt new file mode 100755 index 000000000..42d56e8a8 --- /dev/null +++ b/libs/platform/CMakeLists.txt @@ -0,0 +1,14 @@ +project(Platform) + +file(GLOB_RECURSE SOURCES src/*) +file(GLOB_RECURSE CAELUM_HDR include/*) + +set(SOURCES + fileops.cpp + fileops.hpp + slice_array.hpp + stdint.h + stringops.cpp + stringops.hpp + strings.h) +add_library(platform STATIC ${SOURCES}) \ No newline at end of file diff --git a/libs/platform/fileops.cpp b/libs/platform/fileops.cpp new file mode 100644 index 000000000..52609488b --- /dev/null +++ b/libs/platform/fileops.cpp @@ -0,0 +1,11 @@ +#include "fileops.hpp" +#include + +namespace OMW { namespace Platform { + + bool isFile(const char *name) + { + boost::filesystem::path cfg_file_path(name); + return boost::filesystem::exists(cfg_file_path); + } +}} diff --git a/libs/platform/fileops.hpp b/libs/platform/fileops.hpp new file mode 100644 index 000000000..65f4b2ac7 --- /dev/null +++ b/libs/platform/fileops.hpp @@ -0,0 +1,10 @@ +#ifndef __FILEOPS_H_ +#define __FILEOPS_H_ + +namespace OMW { namespace Platform { + + /// Check if a given path is an existing file (not a directory) + bool isFile(const char *name); +}} + +#endif diff --git a/libs/platform/slice_array.hpp b/libs/platform/slice_array.hpp new file mode 100644 index 000000000..4dde8143b --- /dev/null +++ b/libs/platform/slice_array.hpp @@ -0,0 +1,75 @@ +/* + OpenMW - The completely unofficial reimplementation of Morrowind + Copyright (C) 2008-2010 Nicolay Korslund + Email: < korslund@gmail.com > + WWW: http://openmw.sourceforge.net/ + + This file (slice_array.h) is part of the OpenMW package. + + OpenMW is distributed as free software: you can redistribute it + and/or modify it under the terms of the GNU General Public License + version 3, as published by the Free Software Foundation. + + 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 + version 3 along with this program. If not, see + http://www.gnu.org/licenses/ . + + */ + +#ifndef _SLICE_ARRAY_H_ +#define _SLICE_ARRAY_H_ + +// A simple array implementation containing a pointer and a +// length. Used for holding slices into a data buffer. +#include +template +struct SliceArray +{ + const T* ptr; + size_t length; + + /// Initialize to zero length + SliceArray() : ptr(0), length(0) {} + + /// Initialize from pointer + length + SliceArray(const T* _ptr, size_t _length) + : ptr(_ptr), length(_length) {} + + /// Initialize from null-terminated string + SliceArray(const char* str) + { + ptr = str; + length = strlen(str); + } + + bool operator==(SliceArray &t) + { + return + length == t.length && + (memcmp(ptr,t.ptr, length*sizeof(T)) == 0); + } + + /// Only use this for stings + bool operator==(const char* str) + { + return + str[length] == 0 && + (strncmp(ptr, str, length) == 0); + } + + /** This allocates a copy of the data. Only use this for debugging + and error messages. */ + std::string toString() + { return std::string(ptr,length); } +}; + +typedef SliceArray SString; +typedef SliceArray IntArray; +typedef SliceArray FloatArray; + +#endif diff --git a/libs/platform/stringops.cpp b/libs/platform/stringops.cpp new file mode 100644 index 000000000..16010aef7 --- /dev/null +++ b/libs/platform/stringops.cpp @@ -0,0 +1,63 @@ +#include "stringops.hpp" + +#include +#include "strings.h" + +namespace OMW { namespace Platform { + + bool begins(const char* str1, const char* str2) + { + while(*str2) + { + if(*str1 == 0 || *str1 != *str2) return false; + + str1++; + str2++; + } + return true; + } + + bool ends(const char* str1, const char* str2) + { + int len1 = strlen(str1); + int len2 = strlen(str2); + + if(len1 < len2) return false; + + return strcmp(str2, str1+len1-len2) == 0; + } + + // True if the given chars match, case insensitive + static bool icmp(char a, char b) + { + if(a >= 'A' && a <= 'Z') + a += 'a' - 'A'; + if(b >= 'A' && b <= 'Z') + b += 'a' - 'A'; + + return a == b; + } + + bool ibegins(const char* str1, const char* str2) + { + while(*str2) + { + if(*str1 == 0 || !icmp(*str1,*str2)) return false; + + str1++; + str2++; + } + return true; + } + + bool iends(const char* str1, const char* str2) + { + int len1 = strlen(str1); + int len2 = strlen(str2); + + if(len1 < len2) return false; + + return strcasecmp(str2, str1+len1-len2) == 0; + } + +}} diff --git a/libs/platform/stringops.hpp b/libs/platform/stringops.hpp new file mode 100644 index 000000000..8b53bd7e9 --- /dev/null +++ b/libs/platform/stringops.hpp @@ -0,0 +1,19 @@ +#ifndef __STRINGOPS_H +#define __STRINGOPS_H + +namespace OMW { namespace Platform { + + /// Returns true if str1 begins with substring str2 + bool begins(const char* str1, const char* str2); + + /// Returns true if str1 ends with substring str2 + bool ends(const char* str1, const char* str2); + + /// Case insensitive, returns true if str1 begins with substring str2 + 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/libs/platform/tests/.gitignore b/libs/platform/tests/.gitignore new file mode 100644 index 000000000..814490404 --- /dev/null +++ b/libs/platform/tests/.gitignore @@ -0,0 +1 @@ +*_test diff --git a/libs/platform/tests/output/slice_test.out b/libs/platform/tests/output/slice_test.out new file mode 100644 index 000000000..7b054082b --- /dev/null +++ b/libs/platform/tests/output/slice_test.out @@ -0,0 +1,6 @@ +hello, len=5 +001 +hell, len=4 +010 +01 +4 3 diff --git a/libs/platform/tests/output/strops_test.out b/libs/platform/tests/output/strops_test.out new file mode 100644 index 000000000..e69de29bb diff --git a/libs/platform/tests/slice_test.cpp b/libs/platform/tests/slice_test.cpp new file mode 100644 index 000000000..950194279 --- /dev/null +++ b/libs/platform/tests/slice_test.cpp @@ -0,0 +1,30 @@ +#include + +using namespace std; + +#include + +#include "../slice_array.hpp" + +int main() +{ + SString s, t; + s = SString("hello"); + cout << s.toString() << ", len=" << s.length << endl; + cout << (s=="hel") << (s=="hell") << (s=="hello") << endl; + t = s; + + s = 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; + + const int arr[4] = {1,2,3,4}; + + IntArray ia(arr,4); + + cout << ia.length << " " << ia.ptr[2] << endl; + + return 0; +} diff --git a/libs/platform/tests/strops_test.cpp b/libs/platform/tests/strops_test.cpp new file mode 100644 index 000000000..ca5bd55a9 --- /dev/null +++ b/libs/platform/tests/strops_test.cpp @@ -0,0 +1,48 @@ +#include + +#include "../stringops.hpp" + +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")); + + return 0; +} diff --git a/libs/platform/tests/test.sh b/libs/platform/tests/test.sh new file mode 100755 index 000000000..2d07708ad --- /dev/null +++ b/libs/platform/tests/test.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +make || exit + +mkdir -p output + +PROGS=*_test + +for a in $PROGS; do + if [ -f "output/$a.out" ]; then + echo "Running $a:" + ./$a | diff output/$a.out - + else + echo "Creating $a.out" + ./$a > "output/$a.out" + git add "output/$a.out" + fi +done From 67f89f27a256ae6a61aa188ed3d208419542942a Mon Sep 17 00:00:00 2001 From: athile Date: Sun, 27 Jun 2010 18:12:31 -0700 Subject: [PATCH 2/5] Properly removing the old 'misc' file and fixing a minor error in the platform CMake --- components/misc/fileops.cpp | 8 --- components/misc/fileops.hpp | 7 -- components/misc/slice_array.hpp | 75 -------------------- components/misc/stringops.cpp | 59 --------------- components/misc/stringops.hpp | 16 ----- components/misc/tests/.gitignore | 1 - components/misc/tests/Makefile | 12 ---- components/misc/tests/output/slice_test.out | 6 -- components/misc/tests/output/strops_test.out | 0 components/misc/tests/slice_test.cpp | 30 -------- components/misc/tests/strops_test.cpp | 48 ------------- components/misc/tests/test.sh | 18 ----- libs/platform/CMakeLists.txt | 3 - 13 files changed, 283 deletions(-) delete mode 100644 components/misc/fileops.cpp delete mode 100644 components/misc/fileops.hpp delete mode 100644 components/misc/slice_array.hpp delete mode 100644 components/misc/stringops.cpp delete mode 100644 components/misc/stringops.hpp delete mode 100644 components/misc/tests/.gitignore delete mode 100644 components/misc/tests/Makefile delete mode 100644 components/misc/tests/output/slice_test.out delete mode 100644 components/misc/tests/output/strops_test.out delete mode 100644 components/misc/tests/slice_test.cpp delete mode 100644 components/misc/tests/strops_test.cpp delete mode 100755 components/misc/tests/test.sh diff --git a/components/misc/fileops.cpp b/components/misc/fileops.cpp deleted file mode 100644 index bb859836b..000000000 --- a/components/misc/fileops.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "fileops.hpp" -#include - -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 deleted file mode 100644 index 6a5ad7c61..000000000 --- a/components/misc/fileops.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __FILEOPS_H_ -#define __FILEOPS_H_ - -/// Check if a given path is an existing file (not a directory) -bool isFile(const char *name); - -#endif diff --git a/components/misc/slice_array.hpp b/components/misc/slice_array.hpp deleted file mode 100644 index 4dde8143b..000000000 --- a/components/misc/slice_array.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - OpenMW - The completely unofficial reimplementation of Morrowind - Copyright (C) 2008-2010 Nicolay Korslund - Email: < korslund@gmail.com > - WWW: http://openmw.sourceforge.net/ - - This file (slice_array.h) is part of the OpenMW package. - - OpenMW is distributed as free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License - version 3, as published by the Free Software Foundation. - - 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 - version 3 along with this program. If not, see - http://www.gnu.org/licenses/ . - - */ - -#ifndef _SLICE_ARRAY_H_ -#define _SLICE_ARRAY_H_ - -// A simple array implementation containing a pointer and a -// length. Used for holding slices into a data buffer. -#include -template -struct SliceArray -{ - const T* ptr; - size_t length; - - /// Initialize to zero length - SliceArray() : ptr(0), length(0) {} - - /// Initialize from pointer + length - SliceArray(const T* _ptr, size_t _length) - : ptr(_ptr), length(_length) {} - - /// Initialize from null-terminated string - SliceArray(const char* str) - { - ptr = str; - length = strlen(str); - } - - bool operator==(SliceArray &t) - { - return - length == t.length && - (memcmp(ptr,t.ptr, length*sizeof(T)) == 0); - } - - /// Only use this for stings - bool operator==(const char* str) - { - return - str[length] == 0 && - (strncmp(ptr, str, length) == 0); - } - - /** This allocates a copy of the data. Only use this for debugging - and error messages. */ - std::string toString() - { return std::string(ptr,length); } -}; - -typedef SliceArray SString; -typedef SliceArray IntArray; -typedef SliceArray FloatArray; - -#endif diff --git a/components/misc/stringops.cpp b/components/misc/stringops.cpp deleted file mode 100644 index f6b63372c..000000000 --- a/components/misc/stringops.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "stringops.hpp" - -#include -#include - -bool begins(const char* str1, const char* str2) -{ - while(*str2) - { - if(*str1 == 0 || *str1 != *str2) return false; - - str1++; - str2++; - } - return true; -} - -bool ends(const char* str1, const char* str2) -{ - int len1 = strlen(str1); - int len2 = strlen(str2); - - if(len1 < len2) return false; - - return strcmp(str2, str1+len1-len2) == 0; -} - -// True if the given chars match, case insensitive -static bool icmp(char a, char b) -{ - if(a >= 'A' && a <= 'Z') - a += 'a' - 'A'; - if(b >= 'A' && b <= 'Z') - b += 'a' - 'A'; - - return a == b; -} - -bool ibegins(const char* str1, const char* str2) -{ - while(*str2) - { - if(*str1 == 0 || !icmp(*str1,*str2)) return false; - - str1++; - str2++; - } - return true; -} - -bool iends(const char* str1, const char* str2) -{ - int len1 = strlen(str1); - int len2 = strlen(str2); - - if(len1 < len2) return false; - - return strcasecmp(str2, str1+len1-len2) == 0; -} diff --git a/components/misc/stringops.hpp b/components/misc/stringops.hpp deleted file mode 100644 index e76b8a87a..000000000 --- a/components/misc/stringops.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __STRINGOPS_H -#define __STRINGOPS_H - -/// Returns true if str1 begins with substring str2 -bool begins(const char* str1, const char* str2); - -/// Returns true if str1 ends with substring str2 -bool ends(const char* str1, const char* str2); - -/// Case insensitive, returns true if str1 begins with substring str2 -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/.gitignore b/components/misc/tests/.gitignore deleted file mode 100644 index 814490404..000000000 --- a/components/misc/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*_test diff --git a/components/misc/tests/Makefile b/components/misc/tests/Makefile deleted file mode 100644 index dc1ded5ff..000000000 --- a/components/misc/tests/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -GCC=g++ - -all: strops_test slice_test - -slice_test: slice_test.cpp ../slice_array.hpp - $(GCC) $< -o $@ - -strops_test: strops_test.cpp ../stringops.hpp ../stringops.cpp - $(GCC) $< -o $@ ../stringops.cpp - -clean: - rm *_test diff --git a/components/misc/tests/output/slice_test.out b/components/misc/tests/output/slice_test.out deleted file mode 100644 index 7b054082b..000000000 --- a/components/misc/tests/output/slice_test.out +++ /dev/null @@ -1,6 +0,0 @@ -hello, len=5 -001 -hell, len=4 -010 -01 -4 3 diff --git a/components/misc/tests/output/strops_test.out b/components/misc/tests/output/strops_test.out deleted file mode 100644 index e69de29bb..000000000 diff --git a/components/misc/tests/slice_test.cpp b/components/misc/tests/slice_test.cpp deleted file mode 100644 index 950194279..000000000 --- a/components/misc/tests/slice_test.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include - -using namespace std; - -#include - -#include "../slice_array.hpp" - -int main() -{ - SString s, t; - s = SString("hello"); - cout << s.toString() << ", len=" << s.length << endl; - cout << (s=="hel") << (s=="hell") << (s=="hello") << endl; - t = s; - - s = 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; - - const int arr[4] = {1,2,3,4}; - - IntArray ia(arr,4); - - cout << ia.length << " " << ia.ptr[2] << endl; - - return 0; -} diff --git a/components/misc/tests/strops_test.cpp b/components/misc/tests/strops_test.cpp deleted file mode 100644 index ca5bd55a9..000000000 --- a/components/misc/tests/strops_test.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include - -#include "../stringops.hpp" - -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")); - - return 0; -} diff --git a/components/misc/tests/test.sh b/components/misc/tests/test.sh deleted file mode 100755 index 2d07708ad..000000000 --- a/components/misc/tests/test.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -make || exit - -mkdir -p output - -PROGS=*_test - -for a in $PROGS; do - if [ -f "output/$a.out" ]; then - echo "Running $a:" - ./$a | diff output/$a.out - - else - echo "Creating $a.out" - ./$a > "output/$a.out" - git add "output/$a.out" - fi -done diff --git a/libs/platform/CMakeLists.txt b/libs/platform/CMakeLists.txt index 42d56e8a8..672f815b0 100755 --- a/libs/platform/CMakeLists.txt +++ b/libs/platform/CMakeLists.txt @@ -1,8 +1,5 @@ project(Platform) -file(GLOB_RECURSE SOURCES src/*) -file(GLOB_RECURSE CAELUM_HDR include/*) - set(SOURCES fileops.cpp fileops.hpp From 97feee6cb628766073dc9c3e0f5c10df10f9d8bf Mon Sep 17 00:00:00 2001 From: athile Date: Mon, 28 Jun 2010 12:40:39 -0700 Subject: [PATCH 3/5] Move misc files back to components --- components/misc/fileops.cpp | 8 +++ components/misc/fileops.hpp | 7 +++ .../misc}/slice_array.hpp | 0 components/misc/stringops.cpp | 59 +++++++++++++++++ components/misc/stringops.hpp | 16 +++++ .../misc}/tests/.gitignore | 0 components/misc/tests/Makefile | 12 ++++ .../misc}/tests/output/slice_test.out | 0 .../misc}/tests/output/strops_test.out | 0 .../misc}/tests/slice_test.cpp | 0 .../misc}/tests/strops_test.cpp | 0 .../misc}/tests/test.sh | 0 libs/platform/CMakeLists.txt | 11 ---- libs/platform/fileops.cpp | 11 ---- libs/platform/fileops.hpp | 10 --- libs/platform/stringops.cpp | 63 ------------------- libs/platform/stringops.hpp | 19 ------ 17 files changed, 102 insertions(+), 114 deletions(-) create mode 100644 components/misc/fileops.cpp create mode 100644 components/misc/fileops.hpp rename {libs/platform => components/misc}/slice_array.hpp (100%) create mode 100644 components/misc/stringops.cpp create mode 100644 components/misc/stringops.hpp rename {libs/platform => components/misc}/tests/.gitignore (100%) create mode 100644 components/misc/tests/Makefile rename {libs/platform => components/misc}/tests/output/slice_test.out (100%) rename {libs/platform => components/misc}/tests/output/strops_test.out (100%) rename {libs/platform => components/misc}/tests/slice_test.cpp (100%) rename {libs/platform => components/misc}/tests/strops_test.cpp (100%) rename {libs/platform => components/misc}/tests/test.sh (100%) delete mode 100755 libs/platform/CMakeLists.txt delete mode 100644 libs/platform/fileops.cpp delete mode 100644 libs/platform/fileops.hpp delete mode 100644 libs/platform/stringops.cpp delete mode 100644 libs/platform/stringops.hpp diff --git a/components/misc/fileops.cpp b/components/misc/fileops.cpp new file mode 100644 index 000000000..bb859836b --- /dev/null +++ b/components/misc/fileops.cpp @@ -0,0 +1,8 @@ +#include "fileops.hpp" +#include + +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 new file mode 100644 index 000000000..6a5ad7c61 --- /dev/null +++ b/components/misc/fileops.hpp @@ -0,0 +1,7 @@ +#ifndef __FILEOPS_H_ +#define __FILEOPS_H_ + +/// Check if a given path is an existing file (not a directory) +bool isFile(const char *name); + +#endif diff --git a/libs/platform/slice_array.hpp b/components/misc/slice_array.hpp similarity index 100% rename from libs/platform/slice_array.hpp rename to components/misc/slice_array.hpp diff --git a/components/misc/stringops.cpp b/components/misc/stringops.cpp new file mode 100644 index 000000000..f6b63372c --- /dev/null +++ b/components/misc/stringops.cpp @@ -0,0 +1,59 @@ +#include "stringops.hpp" + +#include +#include + +bool begins(const char* str1, const char* str2) +{ + while(*str2) + { + if(*str1 == 0 || *str1 != *str2) return false; + + str1++; + str2++; + } + return true; +} + +bool ends(const char* str1, const char* str2) +{ + int len1 = strlen(str1); + int len2 = strlen(str2); + + if(len1 < len2) return false; + + return strcmp(str2, str1+len1-len2) == 0; +} + +// True if the given chars match, case insensitive +static bool icmp(char a, char b) +{ + if(a >= 'A' && a <= 'Z') + a += 'a' - 'A'; + if(b >= 'A' && b <= 'Z') + b += 'a' - 'A'; + + return a == b; +} + +bool ibegins(const char* str1, const char* str2) +{ + while(*str2) + { + if(*str1 == 0 || !icmp(*str1,*str2)) return false; + + str1++; + str2++; + } + return true; +} + +bool iends(const char* str1, const char* str2) +{ + int len1 = strlen(str1); + int len2 = strlen(str2); + + if(len1 < len2) return false; + + return strcasecmp(str2, str1+len1-len2) == 0; +} diff --git a/components/misc/stringops.hpp b/components/misc/stringops.hpp new file mode 100644 index 000000000..e76b8a87a --- /dev/null +++ b/components/misc/stringops.hpp @@ -0,0 +1,16 @@ +#ifndef __STRINGOPS_H +#define __STRINGOPS_H + +/// Returns true if str1 begins with substring str2 +bool begins(const char* str1, const char* str2); + +/// Returns true if str1 ends with substring str2 +bool ends(const char* str1, const char* str2); + +/// Case insensitive, returns true if str1 begins with substring str2 +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/libs/platform/tests/.gitignore b/components/misc/tests/.gitignore similarity index 100% rename from libs/platform/tests/.gitignore rename to components/misc/tests/.gitignore diff --git a/components/misc/tests/Makefile b/components/misc/tests/Makefile new file mode 100644 index 000000000..dc1ded5ff --- /dev/null +++ b/components/misc/tests/Makefile @@ -0,0 +1,12 @@ +GCC=g++ + +all: strops_test slice_test + +slice_test: slice_test.cpp ../slice_array.hpp + $(GCC) $< -o $@ + +strops_test: strops_test.cpp ../stringops.hpp ../stringops.cpp + $(GCC) $< -o $@ ../stringops.cpp + +clean: + rm *_test diff --git a/libs/platform/tests/output/slice_test.out b/components/misc/tests/output/slice_test.out similarity index 100% rename from libs/platform/tests/output/slice_test.out rename to components/misc/tests/output/slice_test.out diff --git a/libs/platform/tests/output/strops_test.out b/components/misc/tests/output/strops_test.out similarity index 100% rename from libs/platform/tests/output/strops_test.out rename to components/misc/tests/output/strops_test.out diff --git a/libs/platform/tests/slice_test.cpp b/components/misc/tests/slice_test.cpp similarity index 100% rename from libs/platform/tests/slice_test.cpp rename to components/misc/tests/slice_test.cpp diff --git a/libs/platform/tests/strops_test.cpp b/components/misc/tests/strops_test.cpp similarity index 100% rename from libs/platform/tests/strops_test.cpp rename to components/misc/tests/strops_test.cpp diff --git a/libs/platform/tests/test.sh b/components/misc/tests/test.sh similarity index 100% rename from libs/platform/tests/test.sh rename to components/misc/tests/test.sh diff --git a/libs/platform/CMakeLists.txt b/libs/platform/CMakeLists.txt deleted file mode 100755 index 672f815b0..000000000 --- a/libs/platform/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -project(Platform) - -set(SOURCES - fileops.cpp - fileops.hpp - slice_array.hpp - stdint.h - stringops.cpp - stringops.hpp - strings.h) -add_library(platform STATIC ${SOURCES}) \ No newline at end of file diff --git a/libs/platform/fileops.cpp b/libs/platform/fileops.cpp deleted file mode 100644 index 52609488b..000000000 --- a/libs/platform/fileops.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "fileops.hpp" -#include - -namespace OMW { namespace Platform { - - bool isFile(const char *name) - { - boost::filesystem::path cfg_file_path(name); - return boost::filesystem::exists(cfg_file_path); - } -}} diff --git a/libs/platform/fileops.hpp b/libs/platform/fileops.hpp deleted file mode 100644 index 65f4b2ac7..000000000 --- a/libs/platform/fileops.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __FILEOPS_H_ -#define __FILEOPS_H_ - -namespace OMW { namespace Platform { - - /// Check if a given path is an existing file (not a directory) - bool isFile(const char *name); -}} - -#endif diff --git a/libs/platform/stringops.cpp b/libs/platform/stringops.cpp deleted file mode 100644 index 16010aef7..000000000 --- a/libs/platform/stringops.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "stringops.hpp" - -#include -#include "strings.h" - -namespace OMW { namespace Platform { - - bool begins(const char* str1, const char* str2) - { - while(*str2) - { - if(*str1 == 0 || *str1 != *str2) return false; - - str1++; - str2++; - } - return true; - } - - bool ends(const char* str1, const char* str2) - { - int len1 = strlen(str1); - int len2 = strlen(str2); - - if(len1 < len2) return false; - - return strcmp(str2, str1+len1-len2) == 0; - } - - // True if the given chars match, case insensitive - static bool icmp(char a, char b) - { - if(a >= 'A' && a <= 'Z') - a += 'a' - 'A'; - if(b >= 'A' && b <= 'Z') - b += 'a' - 'A'; - - return a == b; - } - - bool ibegins(const char* str1, const char* str2) - { - while(*str2) - { - if(*str1 == 0 || !icmp(*str1,*str2)) return false; - - str1++; - str2++; - } - return true; - } - - bool iends(const char* str1, const char* str2) - { - int len1 = strlen(str1); - int len2 = strlen(str2); - - if(len1 < len2) return false; - - return strcasecmp(str2, str1+len1-len2) == 0; - } - -}} diff --git a/libs/platform/stringops.hpp b/libs/platform/stringops.hpp deleted file mode 100644 index 8b53bd7e9..000000000 --- a/libs/platform/stringops.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __STRINGOPS_H -#define __STRINGOPS_H - -namespace OMW { namespace Platform { - - /// Returns true if str1 begins with substring str2 - bool begins(const char* str1, const char* str2); - - /// Returns true if str1 ends with substring str2 - bool ends(const char* str1, const char* str2); - - /// Case insensitive, returns true if str1 begins with substring str2 - 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 From 59a2e8dcf7bd3cfb04ac284072ab7fb277f51c92 Mon Sep 17 00:00:00 2001 From: athile Date: Mon, 28 Jun 2010 12:44:55 -0700 Subject: [PATCH 4/5] Merge upstream --- .gitignore | 4 +- CMakeLists.txt | 86 +++++--- apps/openmw/engine.cpp | 4 +- apps/openmw/mwrender/sky.cpp | 186 +++++++++--------- apps/openmw/mwrender/sky.hpp | 0 components/esm/esm_reader.hpp | 6 +- components/nif/nif_file.cpp | 4 +- components/nif/nif_file.hpp | 3 +- extern/caelum/CMakeLists.txt | 114 +++++------ extern/caelum/include/Astronomy.h | 0 extern/caelum/include/Caelum.h | 0 extern/caelum/include/CaelumExceptions.h | 0 extern/caelum/include/CaelumPlugin.h | 0 extern/caelum/include/CaelumPrecompiled.h | 0 extern/caelum/include/CaelumPrerequisites.h | 0 .../caelum/include/CaelumScriptTranslator.h | 0 extern/caelum/include/CaelumSystem.h | 0 extern/caelum/include/CameraBoundElement.h | 0 extern/caelum/include/CloudSystem.h | 0 extern/caelum/include/DepthComposer.h | 0 extern/caelum/include/FastGpuParamRef.h | 0 extern/caelum/include/FlatCloudLayer.h | 0 extern/caelum/include/GroundFog.h | 0 extern/caelum/include/ImageStarfield.h | 0 extern/caelum/include/InternalUtilities.h | 0 extern/caelum/include/Moon.h | 0 extern/caelum/include/PointStarfield.h | 0 .../caelum/include/PrecipitationController.h | 0 extern/caelum/include/PrivatePtr.h | 0 extern/caelum/include/SkyDome.h | 0 extern/caelum/include/SkyLight.h | 0 extern/caelum/include/Sun.h | 0 extern/caelum/include/TypeDescriptor.h | 0 extern/caelum/include/UniversalClock.h | 0 extern/caelum/src/Astronomy.cpp | 0 extern/caelum/src/BrightStarCatalogue.cpp | 0 .../src/CaelumDefaultTypeDescriptorData.cpp | 0 extern/caelum/src/CaelumPlugin.cpp | 0 extern/caelum/src/CaelumPrecompiled.cpp | 0 extern/caelum/src/CaelumScriptTranslator.cpp | 0 extern/caelum/src/CameraBoundElement.cpp | 0 extern/caelum/src/CloudSystem.cpp | 0 extern/caelum/src/DepthComposer.cpp | 0 extern/caelum/src/FastGpuParamRef.cpp | 0 extern/caelum/src/FlatCloudLayer.cpp | 0 extern/caelum/src/GroundFog.cpp | 0 extern/caelum/src/ImageStarfield.cpp | 0 extern/caelum/src/InternalUtilities.cpp | 0 extern/caelum/src/Moon.cpp | 0 extern/caelum/src/PointStarfield.cpp | 0 extern/caelum/src/PrecipitationController.cpp | 0 extern/caelum/src/SkyDome.cpp | 0 extern/caelum/src/SkyLight.cpp | 0 extern/caelum/src/Sun.cpp | 0 extern/caelum/src/TypeDescriptor.cpp | 0 extern/caelum/src/UniversalClock.cpp | 0 libs/platform/strings.h | 2 + 57 files changed, 222 insertions(+), 187 deletions(-) mode change 100755 => 100644 apps/openmw/mwrender/sky.cpp mode change 100755 => 100644 apps/openmw/mwrender/sky.hpp mode change 100755 => 100644 extern/caelum/include/Astronomy.h mode change 100755 => 100644 extern/caelum/include/Caelum.h mode change 100755 => 100644 extern/caelum/include/CaelumExceptions.h mode change 100755 => 100644 extern/caelum/include/CaelumPlugin.h mode change 100755 => 100644 extern/caelum/include/CaelumPrecompiled.h mode change 100755 => 100644 extern/caelum/include/CaelumPrerequisites.h mode change 100755 => 100644 extern/caelum/include/CaelumScriptTranslator.h mode change 100755 => 100644 extern/caelum/include/CaelumSystem.h mode change 100755 => 100644 extern/caelum/include/CameraBoundElement.h mode change 100755 => 100644 extern/caelum/include/CloudSystem.h mode change 100755 => 100644 extern/caelum/include/DepthComposer.h mode change 100755 => 100644 extern/caelum/include/FastGpuParamRef.h mode change 100755 => 100644 extern/caelum/include/FlatCloudLayer.h mode change 100755 => 100644 extern/caelum/include/GroundFog.h mode change 100755 => 100644 extern/caelum/include/ImageStarfield.h mode change 100755 => 100644 extern/caelum/include/InternalUtilities.h mode change 100755 => 100644 extern/caelum/include/Moon.h mode change 100755 => 100644 extern/caelum/include/PointStarfield.h mode change 100755 => 100644 extern/caelum/include/PrecipitationController.h mode change 100755 => 100644 extern/caelum/include/PrivatePtr.h mode change 100755 => 100644 extern/caelum/include/SkyDome.h mode change 100755 => 100644 extern/caelum/include/SkyLight.h mode change 100755 => 100644 extern/caelum/include/Sun.h mode change 100755 => 100644 extern/caelum/include/TypeDescriptor.h mode change 100755 => 100644 extern/caelum/include/UniversalClock.h mode change 100755 => 100644 extern/caelum/src/Astronomy.cpp mode change 100755 => 100644 extern/caelum/src/BrightStarCatalogue.cpp mode change 100755 => 100644 extern/caelum/src/CaelumDefaultTypeDescriptorData.cpp mode change 100755 => 100644 extern/caelum/src/CaelumPlugin.cpp mode change 100755 => 100644 extern/caelum/src/CaelumPrecompiled.cpp mode change 100755 => 100644 extern/caelum/src/CaelumScriptTranslator.cpp mode change 100755 => 100644 extern/caelum/src/CameraBoundElement.cpp mode change 100755 => 100644 extern/caelum/src/CloudSystem.cpp mode change 100755 => 100644 extern/caelum/src/DepthComposer.cpp mode change 100755 => 100644 extern/caelum/src/FastGpuParamRef.cpp mode change 100755 => 100644 extern/caelum/src/FlatCloudLayer.cpp mode change 100755 => 100644 extern/caelum/src/GroundFog.cpp mode change 100755 => 100644 extern/caelum/src/ImageStarfield.cpp mode change 100755 => 100644 extern/caelum/src/InternalUtilities.cpp mode change 100755 => 100644 extern/caelum/src/Moon.cpp mode change 100755 => 100644 extern/caelum/src/PointStarfield.cpp mode change 100755 => 100644 extern/caelum/src/PrecipitationController.cpp mode change 100755 => 100644 extern/caelum/src/SkyDome.cpp mode change 100755 => 100644 extern/caelum/src/SkyLight.cpp mode change 100755 => 100644 extern/caelum/src/Sun.cpp mode change 100755 => 100644 extern/caelum/src/TypeDescriptor.cpp mode change 100755 => 100644 extern/caelum/src/UniversalClock.cpp diff --git a/.gitignore b/.gitignore index 322375a54..b345e9d61 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ screenshot*.png *.o +*.a *~ data CMakeFiles @@ -13,4 +14,5 @@ build plugins.cfg openmw.cfg Doxygen - +.thumbnails +resources diff --git a/CMakeLists.txt b/CMakeLists.txt index 66254f4fb..8e9073b7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,8 +8,12 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/) # source directory: apps -set(GAME apps/openmw/main.cpp apps/openmw/engine.cpp) -set(GAME_HEADER apps/openmw/mwinput/inputmanager.hpp apps/openmw/engine.hpp) +set(GAME + apps/openmw/main.cpp + apps/openmw/engine.cpp) +set(GAME_HEADER + apps/openmw/mwinput/inputmanager.hpp + apps/openmw/engine.hpp) source_group(game FILES ${GAME} ${GAME_HEADER}) set(GAMEREND @@ -26,7 +30,8 @@ set(GAMEREND_HEADER source_group(game_renderer FILES ${GAMEREND} ${GAMEREND_HEADER}) # set(GAMEINPUT) -set(GAMEINPUT_HEADER apps/openmw/mwinput/inputmanager.hpp) +set(GAMEINPUT_HEADER + apps/openmw/mwinput/inputmanager.hpp) source_group(game_input FILES ${GAMEINPUT} ${GAMEINPUT_HEADER}) set(APPS ${GAME} ${GAMEREND} ${GAMEINPUT}) @@ -34,48 +39,80 @@ set(APPS_HEADER ${GAME_HEADER} ${GAMEREND_HEADER} ${GAMEINPUT_HEADER}) # source directory: components -set(BSA components/bsa/bsa_archive.cpp components/bsa/bsa_file.cpp) -set(BSA_HEADER components/bsa/bsa_archive.hpp components/bsa/bsa_file.hpp) +set(BSA + components/bsa/bsa_archive.cpp + components/bsa/bsa_file.cpp) +set(BSA_HEADER + components/bsa/bsa_archive.hpp + components/bsa/bsa_file.hpp) source_group(bsa FILES ${BSA} ${BSA_HEADER}) -set(NIF components/nif/nif_file.cpp) -set(NIF_HEADER components/nif/controlled.hpp components/nif/effect.hpp - components/nif/nif_types.hpp components/nif/record.hpp - components/nif/controller.hpp components/nif/extra.hpp components/nif/node.hpp +set(NIF + components/nif/nif_file.cpp) +set(NIF_HEADER + components/nif/controlled.hpp + components/nif/effect.hpp + components/nif/nif_types.hpp + components/nif/record.hpp + components/nif/controller.hpp + components/nif/extra.hpp + components/nif/node.hpp components/nif/record_ptr.hpp - components/nif/data.hpp components/nif/nif_file.hpp components/nif/property.hpp) + components/nif/data.hpp + components/nif/nif_file.hpp + components/nif/property.hpp) source_group(nif FILES ${NIF} ${NIF_HEADER}) -set(NIFOGRE components/nifogre/ogre_nif_loader.cpp) -set(NIFOGRE_HEADER components/nifogre/ogre_nif_loader.hpp) +set(NIFOGRE + components/nifogre/ogre_nif_loader.cpp) +set(NIFOGRE_HEADER + components/nifogre/ogre_nif_loader.hpp) source_group(nifogre FILES ${NIFOGRE} ${NIFOGRE_HEADER}) -set(ESM_STORE components/esm_store/store.cpp components/esm_store/cell_store.cpp) -set(ESM_STORE_HEADER components/esm_store/cell_store.hpp - components/esm_store/reclists.hpp components/esm_store/store.hpp) +set(ESM_STORE + components/esm_store/store.cpp + components/esm_store/cell_store.cpp) +set(ESM_STORE_HEADER + components/esm_store/cell_store.hpp + components/esm_store/reclists.hpp + components/esm_store/store.hpp) source_group(esm_store FILES ${ESM_STORE} ${ESM_STORE_HEADER}) file(GLOB ESM_HEADER components/esm/*.hpp) source_group(esm_header FILES ${ESM_HEADER}) -set(OGRE components/engine/ogre/renderer.cpp) -set(OGRE_HEADER components/engine/ogre/renderer.hpp) +set(OGRE + components/engine/ogre/renderer.cpp) +set(OGRE_HEADER + components/engine/ogre/renderer.hpp) source_group(ogre FILES ${OGRE} ${OGRE_HEADER}) -set(INPUT components/engine/input/oismanager.cpp) -set(INPUT_HEADER components/engine/input/oismanager.hpp components/engine/input/listener.hpp - components/engine/input/func_binder.hpp components/engine/input/dispatch_map.hpp - components/engine/input/dispatcher.hpp components/engine/input/poller.hpp) +set(INPUT + components/engine/input/oismanager.cpp) +set(INPUT_HEADER + components/engine/input/oismanager.hpp + components/engine/input/listener.hpp + components/engine/input/func_binder.hpp + components/engine/input/dispatch_map.hpp + components/engine/input/dispatcher.hpp + components/engine/input/poller.hpp) source_group(input FILES ${INPUT} ${INPUT_HEADER}) +set(MISC + components/misc/stringops.cpp + components/misc/fileops.cpp) +set(MISC_HEADER + components/misc/fileops.hpp + components/misc/slice_array.hpp + components/misc/stringops.hpp) +source_group(misc FILES ${MISC} ${MISC_HEADER}) + set(COMPONENTS ${BSA} ${NIF} ${NIFOGRE} ${ESM_STORE} ${OGRE} ${INPUT} ${MISC}) set(COMPONENTS_HEADER ${BSA_HEADER} ${NIF_HEADER} ${NIFOGRE_HEADER} ${ESM_STORE_HEADER} ${ESM_HEADER} ${OGRE_HEADER} ${INPUT_HEADER} ${MISC_HEADER}) # source directory: libs -ADD_SUBDIRECTORY( libs/platform ) - set(MANGLE_VFS libs/mangle/vfs/servers/ogre_vfs.cpp) source_group(mangle_vfs FILES ${MANGLE_VFS}) @@ -97,7 +134,7 @@ find_package(OIS REQUIRED) include_directories("." ${OGRE_INCLUDE_DIR} ${OIS_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${PLATFORM_INCLUDE_DIR} - ${CMAKE_HOME_DIRECTORY}/extern/caelum/include ) + ${CMAKE_HOME_DIRECTORY}/extern/caelum/include) link_directories(${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR}) ADD_SUBDIRECTORY( extern/caelum ) @@ -145,7 +182,6 @@ target_link_libraries(openmw ${OGRE_LIBRARIES} ${OIS_LIBRARIES} ${Boost_LIBRARIES} - platform caelum) if (APPLE) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 6e6568ac8..143f62792 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -7,7 +7,7 @@ #include "components/esm_store/cell_store.hpp" #include "components/bsa/bsa_archive.hpp" #include "components/engine/ogre/renderer.hpp" -#include "libs/platform/fileops.hpp" +#include "components/misc/fileops.hpp" #include "apps/openmw/mwrender/interior.hpp" #include "mwinput/inputmanager.hpp" @@ -104,7 +104,7 @@ void OMW::Engine::go() const char* plugCfg = "plugins.cfg"; - mOgre.configure(!OMW::Platform::isFile("ogre.cfg"), plugCfg, false); + mOgre.configure(!isFile("ogre.cfg"), plugCfg, false); addResourcesDirectory (mDataDir / "Meshes"); addResourcesDirectory (mDataDir / "Textures"); diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp old mode 100755 new mode 100644 index bcd40457f..901ab405e --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -1,93 +1,93 @@ -#include "sky.hpp" -#include "Caelum.h" - -namespace MWRender -{ - // - // Implements a Caelum sky with default settings. - // - // Note: this is intended as a temporary solution to provide some form of - // sky rendering. This code will obviously need significant tailoring to - // support fidelity with Morrowind's rendering. Before doing major work - // on this class, more research should be done to determine whether - // Caelum or another plug-in such as SkyX would be best for the long-term. - // - class CaelumManager : public SkyManager - { - protected: - Caelum::CaelumSystem* mpCaelumSystem; - - public: - CaelumManager (Ogre::RenderWindow* pRenderWindow, - Ogre::Camera* pCamera); - virtual ~CaelumManager (); - }; - - CaelumManager::CaelumManager (Ogre::RenderWindow* pRenderWindow, - Ogre::Camera* pCamera) - : mpCaelumSystem (NULL) - { - using namespace Ogre; - using namespace Caelum; - - assert(pCamera); - assert(pRenderWindow); - - // Load the Caelum resources - // - ResourceGroupManager::getSingleton().addResourceLocation("resources\\caelum", "FileSystem", "Caelum"); - ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); - - // Load the Caelum resources - // - Ogre::SceneManager* pScene = pCamera->getSceneManager(); - Caelum::CaelumSystem::CaelumComponent componentMask = CaelumSystem::CAELUM_COMPONENTS_DEFAULT; - mpCaelumSystem = new Caelum::CaelumSystem (Root::getSingletonPtr(), pScene, componentMask); - - // Set time acceleration. - mpCaelumSystem->getUniversalClock()->setTimeScale(128); - - // Disable fog since OpenMW is handling OGRE fog elsewhere - mpCaelumSystem->setManageSceneFog(false); - - // Change the camera far distance to make sure the sky is not clipped - pCamera->setFarClipDistance(50000); - - // Register Caelum as an OGRE listener - pRenderWindow->addListener(mpCaelumSystem); - Root::getSingletonPtr()->addFrameListener(mpCaelumSystem); - } - - CaelumManager::~CaelumManager() - { - if (mpCaelumSystem) - mpCaelumSystem->shutdown (false); - } - - /// Creates and connects the sky rendering component to OGRE. - /// - /// \return NULL on failure. - /// - SkyManager* SkyManager::create (Ogre::RenderWindow* pRenderWindow, - Ogre::Camera* pCamera) - { - SkyManager* pSkyManager = NULL; - - try - { - pSkyManager = new CaelumManager(pRenderWindow, pCamera); - } - catch (Ogre::Exception& e) - { - std::cout << "\nOGRE Exception when attempting to add sky: " - << e.getFullDescription().c_str() << std::endl; - } - catch (std::exception& e) - { - std::cout << "\nException when attempting to add sky: " - << e.what() << std::endl; - } - - return pSkyManager; - } -} +#include "sky.hpp" +#include "Caelum.h" + +namespace MWRender +{ + // + // Implements a Caelum sky with default settings. + // + // Note: this is intended as a temporary solution to provide some form of + // sky rendering. This code will obviously need significant tailoring to + // support fidelity with Morrowind's rendering. Before doing major work + // on this class, more research should be done to determine whether + // Caelum or another plug-in such as SkyX would be best for the long-term. + // + class CaelumManager : public SkyManager + { + protected: + Caelum::CaelumSystem* mpCaelumSystem; + + public: + CaelumManager (Ogre::RenderWindow* pRenderWindow, + Ogre::Camera* pCamera); + virtual ~CaelumManager (); + }; + + CaelumManager::CaelumManager (Ogre::RenderWindow* pRenderWindow, + Ogre::Camera* pCamera) + : mpCaelumSystem (NULL) + { + using namespace Ogre; + using namespace Caelum; + + assert(pCamera); + assert(pRenderWindow); + + // Load the Caelum resources + // + ResourceGroupManager::getSingleton().addResourceLocation("resources/caelum", "FileSystem", "Caelum"); + ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); + + // Load the Caelum resources + // + Ogre::SceneManager* pScene = pCamera->getSceneManager(); + Caelum::CaelumSystem::CaelumComponent componentMask = CaelumSystem::CAELUM_COMPONENTS_DEFAULT; + mpCaelumSystem = new Caelum::CaelumSystem (Root::getSingletonPtr(), pScene, componentMask); + + // Set time acceleration. + mpCaelumSystem->getUniversalClock()->setTimeScale(128); + + // Disable fog since OpenMW is handling OGRE fog elsewhere + mpCaelumSystem->setManageSceneFog(false); + + // Change the camera far distance to make sure the sky is not clipped + pCamera->setFarClipDistance(50000); + + // Register Caelum as an OGRE listener + pRenderWindow->addListener(mpCaelumSystem); + Root::getSingletonPtr()->addFrameListener(mpCaelumSystem); + } + + CaelumManager::~CaelumManager() + { + if (mpCaelumSystem) + mpCaelumSystem->shutdown (false); + } + + /// Creates and connects the sky rendering component to OGRE. + /// + /// \return NULL on failure. + /// + SkyManager* SkyManager::create (Ogre::RenderWindow* pRenderWindow, + Ogre::Camera* pCamera) + { + SkyManager* pSkyManager = NULL; + + try + { + pSkyManager = new CaelumManager(pRenderWindow, pCamera); + } + catch (Ogre::Exception& e) + { + std::cout << "\nOGRE Exception when attempting to add sky: " + << e.getFullDescription().c_str() << std::endl; + } + catch (std::exception& e) + { + std::cout << "\nException when attempting to add sky: " + << e.what() << std::endl; + } + + return pSkyManager; + } +} diff --git a/apps/openmw/mwrender/sky.hpp b/apps/openmw/mwrender/sky.hpp old mode 100755 new mode 100644 diff --git a/components/esm/esm_reader.hpp b/components/esm/esm_reader.hpp index 033675222..7db21323f 100644 --- a/components/esm/esm_reader.hpp +++ b/components/esm/esm_reader.hpp @@ -12,7 +12,7 @@ #include #include #include -#include "libs/platform/stringops.hpp" +#include #ifdef __APPLE__ // need our own implementation of strnlen @@ -217,9 +217,7 @@ public: /// Raw opening. Opens the file and sets everything up but doesn't /// parse the header. void openRaw(Mangle::Stream::StreamPtr _esm, const std::string &name) - { - using namespace OMW::Platform; - + { close(); esm = _esm; c.filename = name; diff --git a/components/nif/nif_file.cpp b/components/nif/nif_file.cpp index 027f64760..12845e617 100644 --- a/components/nif/nif_file.cpp +++ b/components/nif/nif_file.cpp @@ -23,7 +23,7 @@ #include "nif_file.hpp" #include "record.hpp" -#include "libs/platform/stringops.hpp" +#include "components/misc/stringops.hpp" #include "extra.hpp" #include "controlled.hpp" @@ -44,8 +44,6 @@ using namespace Nif; void NIFFile::parse() { - using namespace OMW::Platform; - // Check the header string const char* head = getString(40); if(!begins(head, "NetImmerse File Format")) diff --git a/components/nif/nif_file.hpp b/components/nif/nif_file.hpp index 858ccb36a..72fb7c4b6 100644 --- a/components/nif/nif_file.hpp +++ b/components/nif/nif_file.hpp @@ -27,8 +27,7 @@ #include #include #include - -#include "libs/platform/slice_array.hpp" +#include #include #include diff --git a/extern/caelum/CMakeLists.txt b/extern/caelum/CMakeLists.txt index cdc63af33..4226d8d4a 100755 --- a/extern/caelum/CMakeLists.txt +++ b/extern/caelum/CMakeLists.txt @@ -1,57 +1,57 @@ -project(Caelum) - -ADD_DEFINITIONS(-DCAELUM_LIB) -INCLUDE_DIRECTORIES( ${CMAKE_HOME_DIRECTORY}/extern/caelum/include ) - -file(GLOB_RECURSE CAELUM_SRC src/*) -file(GLOB_RECURSE CAELUM_HDR include/*) - -set(SOURCES ${CAELUM_SRC} ${CAELUM_HDR}) -add_library(caelum STATIC ${SOURCES}) - -# -# Resources -# -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/AtmosphereDepth.png "${OpenMW_BINARY_DIR}/resources/caelum/AtmosphereDepth.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumGroundFog.cg "${OpenMW_BINARY_DIR}/resources/caelum/CaelumGroundFog.cg" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumLayeredClouds.cg "${OpenMW_BINARY_DIR}/resources/caelum/CaelumLayeredClouds.cg" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumPhaseMoon.cg "${OpenMW_BINARY_DIR}/resources/caelum/CaelumPhaseMoon.cg" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumPointStarfield.cg "${OpenMW_BINARY_DIR}/resources/caelum/CaelumPointStarfield.cg" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumSkyDome.cg "${OpenMW_BINARY_DIR}/resources/caelum/CaelumSkyDome.cg" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CloudCoverLookup.png "${OpenMW_BINARY_DIR}/resources/caelum/CloudCoverLookup.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/DepthComposer.cg "${OpenMW_BINARY_DIR}/resources/caelum/DepthComposer.cg" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/DepthComposer.compositor "${OpenMW_BINARY_DIR}/resources/caelum/DepthComposer.compositor" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/DepthComposer.material "${OpenMW_BINARY_DIR}/resources/caelum/DepthComposer.material" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/DepthRender.program "${OpenMW_BINARY_DIR}/resources/caelum/DepthRender.program" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/EarthClearSky2.png "${OpenMW_BINARY_DIR}/resources/caelum/EarthClearSky2.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/GroundFog.material "${OpenMW_BINARY_DIR}/resources/caelum/GroundFog.material" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/GroundFog.program "${OpenMW_BINARY_DIR}/resources/caelum/GroundFog.program" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Haze.program "${OpenMW_BINARY_DIR}/resources/caelum/Haze.program" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/LayeredClouds.material "${OpenMW_BINARY_DIR}/resources/caelum/LayeredClouds.material" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/MinimalCompositorVP.cg "${OpenMW_BINARY_DIR}/resources/caelum/MinimalCompositorVP.cg" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/MinimalCompositorVP.program "${OpenMW_BINARY_DIR}/resources/caelum/MinimalCompositorVP.program" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/moon.material "${OpenMW_BINARY_DIR}/resources/caelum/moon.material" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/moon_disc.dds "${OpenMW_BINARY_DIR}/resources/caelum/moon_disc.dds" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/noise1.dds "${OpenMW_BINARY_DIR}/resources/caelum/noise1.dds" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/noise2.dds "${OpenMW_BINARY_DIR}/resources/caelum/noise2.dds" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/noise3.dds "${OpenMW_BINARY_DIR}/resources/caelum/noise3.dds" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/noise4.dds "${OpenMW_BINARY_DIR}/resources/caelum/noise4.dds" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/PointStarfield.material "${OpenMW_BINARY_DIR}/resources/caelum/PointStarfield.material" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Precipitation.cg "${OpenMW_BINARY_DIR}/resources/caelum/Precipitation.cg" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Precipitation.compositor "${OpenMW_BINARY_DIR}/resources/caelum/Precipitation.compositor" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Precipitation.material "${OpenMW_BINARY_DIR}/resources/caelum/Precipitation.material" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_drizzle.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_drizzle.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_hail.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_hail.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_icecrystals.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_icecrystals.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_icepellets.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_icepellets.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_rain.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_rain.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_smallhail.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_smallhail.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_snow.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_snow.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_snowgrains.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_snowgrains.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/SkyDome.material "${OpenMW_BINARY_DIR}/resources/caelum/SkyDome.material" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/sphere.mesh "${OpenMW_BINARY_DIR}/resources/caelum/sphere.mesh" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Starfield.jpg "${OpenMW_BINARY_DIR}/resources/caelum/Starfield.jpg" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Starfield.material "${OpenMW_BINARY_DIR}/resources/caelum/Starfield.material" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Sun.material "${OpenMW_BINARY_DIR}/resources/caelum/Sun.material" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/SunGradient.png "${OpenMW_BINARY_DIR}/resources/caelum/SunGradient.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/sun_disc.png "${OpenMW_BINARY_DIR}/resources/caelum/sun_disc.png" COPYONLY) +project(Caelum) + +ADD_DEFINITIONS(-DCAELUM_LIB) +INCLUDE_DIRECTORIES( ${CMAKE_HOME_DIRECTORY}/extern/caelum/include ) + +file(GLOB_RECURSE CAELUM_SRC src/*) +file(GLOB_RECURSE CAELUM_HDR include/*) + +set(SOURCES ${CAELUM_SRC} ${CAELUM_HDR}) +add_library(caelum STATIC ${SOURCES}) + +# +# Resources +# +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/AtmosphereDepth.png "${OpenMW_BINARY_DIR}/resources/caelum/AtmosphereDepth.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumGroundFog.cg "${OpenMW_BINARY_DIR}/resources/caelum/CaelumGroundFog.cg" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumLayeredClouds.cg "${OpenMW_BINARY_DIR}/resources/caelum/CaelumLayeredClouds.cg" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumPhaseMoon.cg "${OpenMW_BINARY_DIR}/resources/caelum/CaelumPhaseMoon.cg" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumPointStarfield.cg "${OpenMW_BINARY_DIR}/resources/caelum/CaelumPointStarfield.cg" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumSkyDome.cg "${OpenMW_BINARY_DIR}/resources/caelum/CaelumSkyDome.cg" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CloudCoverLookup.png "${OpenMW_BINARY_DIR}/resources/caelum/CloudCoverLookup.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/DepthComposer.cg "${OpenMW_BINARY_DIR}/resources/caelum/DepthComposer.cg" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/DepthComposer.compositor "${OpenMW_BINARY_DIR}/resources/caelum/DepthComposer.compositor" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/DepthComposer.material "${OpenMW_BINARY_DIR}/resources/caelum/DepthComposer.material" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/DepthRender.program "${OpenMW_BINARY_DIR}/resources/caelum/DepthRender.program" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/EarthClearSky2.png "${OpenMW_BINARY_DIR}/resources/caelum/EarthClearSky2.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/GroundFog.material "${OpenMW_BINARY_DIR}/resources/caelum/GroundFog.material" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/GroundFog.program "${OpenMW_BINARY_DIR}/resources/caelum/GroundFog.program" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Haze.program "${OpenMW_BINARY_DIR}/resources/caelum/Haze.program" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/LayeredClouds.material "${OpenMW_BINARY_DIR}/resources/caelum/LayeredClouds.material" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/MinimalCompositorVP.cg "${OpenMW_BINARY_DIR}/resources/caelum/MinimalCompositorVP.cg" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/MinimalCompositorVP.program "${OpenMW_BINARY_DIR}/resources/caelum/MinimalCompositorVP.program" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/moon.material "${OpenMW_BINARY_DIR}/resources/caelum/moon.material" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/moon_disc.dds "${OpenMW_BINARY_DIR}/resources/caelum/moon_disc.dds" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/noise1.dds "${OpenMW_BINARY_DIR}/resources/caelum/noise1.dds" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/noise2.dds "${OpenMW_BINARY_DIR}/resources/caelum/noise2.dds" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/noise3.dds "${OpenMW_BINARY_DIR}/resources/caelum/noise3.dds" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/noise4.dds "${OpenMW_BINARY_DIR}/resources/caelum/noise4.dds" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/PointStarfield.material "${OpenMW_BINARY_DIR}/resources/caelum/PointStarfield.material" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Precipitation.cg "${OpenMW_BINARY_DIR}/resources/caelum/Precipitation.cg" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Precipitation.compositor "${OpenMW_BINARY_DIR}/resources/caelum/Precipitation.compositor" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Precipitation.material "${OpenMW_BINARY_DIR}/resources/caelum/Precipitation.material" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_drizzle.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_drizzle.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_hail.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_hail.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_icecrystals.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_icecrystals.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_icepellets.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_icepellets.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_rain.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_rain.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_smallhail.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_smallhail.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_snow.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_snow.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_snowgrains.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_snowgrains.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/SkyDome.material "${OpenMW_BINARY_DIR}/resources/caelum/SkyDome.material" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/sphere.mesh "${OpenMW_BINARY_DIR}/resources/caelum/sphere.mesh" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Starfield.jpg "${OpenMW_BINARY_DIR}/resources/caelum/Starfield.jpg" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Starfield.material "${OpenMW_BINARY_DIR}/resources/caelum/Starfield.material" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Sun.material "${OpenMW_BINARY_DIR}/resources/caelum/Sun.material" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/SunGradient.png "${OpenMW_BINARY_DIR}/resources/caelum/SunGradient.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/sun_disc.png "${OpenMW_BINARY_DIR}/resources/caelum/sun_disc.png" COPYONLY) diff --git a/extern/caelum/include/Astronomy.h b/extern/caelum/include/Astronomy.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/Caelum.h b/extern/caelum/include/Caelum.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/CaelumExceptions.h b/extern/caelum/include/CaelumExceptions.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/CaelumPlugin.h b/extern/caelum/include/CaelumPlugin.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/CaelumPrecompiled.h b/extern/caelum/include/CaelumPrecompiled.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/CaelumPrerequisites.h b/extern/caelum/include/CaelumPrerequisites.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/CaelumScriptTranslator.h b/extern/caelum/include/CaelumScriptTranslator.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/CaelumSystem.h b/extern/caelum/include/CaelumSystem.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/CameraBoundElement.h b/extern/caelum/include/CameraBoundElement.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/CloudSystem.h b/extern/caelum/include/CloudSystem.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/DepthComposer.h b/extern/caelum/include/DepthComposer.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/FastGpuParamRef.h b/extern/caelum/include/FastGpuParamRef.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/FlatCloudLayer.h b/extern/caelum/include/FlatCloudLayer.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/GroundFog.h b/extern/caelum/include/GroundFog.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/ImageStarfield.h b/extern/caelum/include/ImageStarfield.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/InternalUtilities.h b/extern/caelum/include/InternalUtilities.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/Moon.h b/extern/caelum/include/Moon.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/PointStarfield.h b/extern/caelum/include/PointStarfield.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/PrecipitationController.h b/extern/caelum/include/PrecipitationController.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/PrivatePtr.h b/extern/caelum/include/PrivatePtr.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/SkyDome.h b/extern/caelum/include/SkyDome.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/SkyLight.h b/extern/caelum/include/SkyLight.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/Sun.h b/extern/caelum/include/Sun.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/TypeDescriptor.h b/extern/caelum/include/TypeDescriptor.h old mode 100755 new mode 100644 diff --git a/extern/caelum/include/UniversalClock.h b/extern/caelum/include/UniversalClock.h old mode 100755 new mode 100644 diff --git a/extern/caelum/src/Astronomy.cpp b/extern/caelum/src/Astronomy.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/BrightStarCatalogue.cpp b/extern/caelum/src/BrightStarCatalogue.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/CaelumDefaultTypeDescriptorData.cpp b/extern/caelum/src/CaelumDefaultTypeDescriptorData.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/CaelumPlugin.cpp b/extern/caelum/src/CaelumPlugin.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/CaelumPrecompiled.cpp b/extern/caelum/src/CaelumPrecompiled.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/CaelumScriptTranslator.cpp b/extern/caelum/src/CaelumScriptTranslator.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/CameraBoundElement.cpp b/extern/caelum/src/CameraBoundElement.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/CloudSystem.cpp b/extern/caelum/src/CloudSystem.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/DepthComposer.cpp b/extern/caelum/src/DepthComposer.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/FastGpuParamRef.cpp b/extern/caelum/src/FastGpuParamRef.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/FlatCloudLayer.cpp b/extern/caelum/src/FlatCloudLayer.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/GroundFog.cpp b/extern/caelum/src/GroundFog.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/ImageStarfield.cpp b/extern/caelum/src/ImageStarfield.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/InternalUtilities.cpp b/extern/caelum/src/InternalUtilities.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/Moon.cpp b/extern/caelum/src/Moon.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/PointStarfield.cpp b/extern/caelum/src/PointStarfield.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/PrecipitationController.cpp b/extern/caelum/src/PrecipitationController.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/SkyDome.cpp b/extern/caelum/src/SkyDome.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/SkyLight.cpp b/extern/caelum/src/SkyLight.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/Sun.cpp b/extern/caelum/src/Sun.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/TypeDescriptor.cpp b/extern/caelum/src/TypeDescriptor.cpp old mode 100755 new mode 100644 diff --git a/extern/caelum/src/UniversalClock.cpp b/extern/caelum/src/UniversalClock.cpp old mode 100755 new mode 100644 diff --git a/libs/platform/strings.h b/libs/platform/strings.h index 1fb2822a6..0879ed87b 100644 --- a/libs/platform/strings.h +++ b/libs/platform/strings.h @@ -6,6 +6,8 @@ #pragma warning(disable: 4996) #define strcasecmp stricmp #define snprintf _snprintf +#else +#include #endif #endif From de7087caf46331b197233581d45b0fd4351746ea Mon Sep 17 00:00:00 2001 From: athile Date: Wed, 30 Jun 2010 11:32:40 -0700 Subject: [PATCH 5/5] Move prepareMaster logic into addMaster. Having these separate only introduces the possibility for a bug. --- apps/openmw/engine.cpp | 20 +++++++------------- apps/openmw/engine.hpp | 3 --- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 143f62792..f431e51bd 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -20,18 +20,6 @@ OMW::Engine::Engine() { } -// adjust name and load bsa - -void OMW::Engine::prepareMaster() -{ - std::string::size_type sep = mMaster.find_last_of ("."); - - if (sep==std::string::npos) - { - mMaster += ".esm"; - } -} - // Load all BSA files in data directory. void OMW::Engine::loadBSA() @@ -79,6 +67,13 @@ void OMW::Engine::addMaster (const std::string& master) { assert (mMaster.empty()); mMaster = master; + + // Append .esm if not already there + std::string::size_type sep = mMaster.find_last_of ("."); + if (sep == std::string::npos) + { + mMaster += ".esm"; + } } // Enables sky rendering @@ -109,7 +104,6 @@ void OMW::Engine::go() addResourcesDirectory (mDataDir / "Meshes"); addResourcesDirectory (mDataDir / "Textures"); - prepareMaster(); loadBSA(); boost::filesystem::path masterPath (mDataDir); diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 8143c3ab8..ae69f52b4 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -30,9 +30,6 @@ namespace OMW Engine (const Engine&); Engine& operator= (const Engine&); - /// adjust name and load bsa - void prepareMaster(); - /// add resources directory /// \note This function works recursively. void addResourcesDirectory (const boost::filesystem::path& path);