Merge branch 'components_namespaces' into next

Conflicts:
	apps/openmw/mwrender/interior.cpp
	components/bsa/bsa_archive.cpp
actorid
Marc Zinnschlag 14 years ago
commit 8446619ac4

@ -155,7 +155,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
try try
{ {
mEnvironment.mFrameDuration = evt.timeSinceLastFrame; mEnvironment.mFrameDuration = evt.timeSinceLastFrame;
// //
mEnvironment.mWindowManager->onFrame(mEnvironment.mFrameDuration); mEnvironment.mWindowManager->onFrame(mEnvironment.mFrameDuration);
@ -252,13 +252,12 @@ void OMW::Engine::loadBSA()
for (Files::MultiDirCollection::TIter iter (bsa.begin()); iter!=bsa.end(); ++iter) for (Files::MultiDirCollection::TIter iter (bsa.begin()); iter!=bsa.end(); ++iter)
{ {
std::cout << "Adding " << iter->second.string() << std::endl; std::cout << "Adding " << iter->second.string() << std::endl;
addBSA (iter->second.string()); Bsa::addBSA (iter->second.string());
} }
std::string m = mDataDir.string(); std::string m = mDataDir.string();
std::cout << "Data dir" << m << "\n"; std::cout << "Data dir" << m << "\n";
addDir(m, mFSStrict); Bsa::addDir(m, mFSStrict);
} }
// add resources directory // add resources directory
@ -349,12 +348,12 @@ void OMW::Engine::go()
ogreCfg.insert(0, cfgUserDir); ogreCfg.insert(0, cfgUserDir);
//A local plugins.cfg will be used if it exist, otherwise look in the default path //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); 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 // This has to be added BEFORE MyGUI is initialized, as it needs
// to find core.xml here. // to find core.xml here.
@ -366,7 +365,7 @@ void OMW::Engine::go()
loadBSA(); loadBSA();
// Create physics. shapeLoader is deleted by the physic engine // 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); mPhysicEngine = new OEngine::Physic::PhysicEngine(shapeLoader);
// Create the world // Create the world

@ -84,7 +84,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 //If there is an openmw.cfg in the current path use that as global config
//Otherwise try getPath //Otherwise try getPath
std::string cfgFile = "openmw.cfg"; 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"); cfgFile = Files::getPath (Files::Path_ConfigGlobal, "openmw", "openmw.cfg");
} }

@ -42,7 +42,7 @@ namespace MWClass
ItemLevList::registerSelf(); ItemLevList::registerSelf();
Light::registerSelf(); Light::registerSelf();
Lockpick::registerSelf(); Lockpick::registerSelf();
Misc::registerSelf(); Miscellaneous::registerSelf();
Probe::registerSelf(); Probe::registerSelf();
Repair::registerSelf(); Repair::registerSelf();
Static::registerSelf(); Static::registerSelf();

@ -14,11 +14,11 @@
namespace MWClass 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 MWWorld::Environment& environment) const
{ {
ESMS::LiveCellRef<ESM::Misc, MWWorld::RefData> *ref = ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
ptr.get<ESM::Misc>(); ptr.get<ESM::Miscellaneous>();
assert (ref->base != NULL); assert (ref->base != NULL);
const std::string &model = ref->base->model; 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<ESM::Misc, MWWorld::RefData> *ref = ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
ptr.get<ESM::Misc>(); ptr.get<ESM::Miscellaneous>();
return ref->base->name; return ref->base->name;
} }
boost::shared_ptr<MWWorld::Action> Misc::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Miscellaneous::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
void Misc::insertIntoContainer (const MWWorld::Ptr& ptr, void Miscellaneous::insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const
{ {
insertIntoContainerStore (ptr, containerStore.miscItems); insertIntoContainerStore (ptr, containerStore.miscItems);
} }
std::string Misc::getScript (const MWWorld::Ptr& ptr) const std::string Miscellaneous::getScript (const MWWorld::Ptr& ptr) const
{ {
ESMS::LiveCellRef<ESM::Misc, MWWorld::RefData> *ref = ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
ptr.get<ESM::Misc>(); ptr.get<ESM::Miscellaneous>();
return ref->base->script; return ref->base->script;
} }
void Misc::registerSelf() void Miscellaneous::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Misc); boost::shared_ptr<Class> instance (new Miscellaneous);
registerClass (typeid (ESM::Misc).name(), instance); registerClass (typeid (ESM::Miscellaneous).name(), instance);
} }
} }

@ -5,7 +5,7 @@
namespace MWClass namespace MWClass
{ {
class Misc : public MWWorld::Class class Miscellaneous : public MWWorld::Class
{ {
public: public:

@ -124,7 +124,7 @@ void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec,
} }
mNpcPart = parent->createChildSceneNode(sceneNodeName); mNpcPart = parent->createChildSceneNode(sceneNodeName);
MeshPtr good2 = NIFLoader::load(mesh); MeshPtr good2 = NifOgre::NIFLoader::load(mesh);
MovableObject *ent = mScene.getMgr()->createEntity(mesh); MovableObject *ent = mScene.getMgr()->createEntity(mesh);
@ -213,7 +213,7 @@ void ExteriorCellRender::insertMesh(const std::string &mesh)
{ {
assert (mInsert); assert (mInsert);
NIFLoader::load(mesh); NifOgre::NIFLoader::load(mesh);
Entity *ent = mScene.getMgr()->createEntity(mesh); Entity *ent = mScene.getMgr()->createEntity(mesh);
if(!isStatic) if(!isStatic)

@ -106,7 +106,7 @@ void InteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec,
npcPart = parent->createChildSceneNode(sceneNodeName); npcPart = parent->createChildSceneNode(sceneNodeName);
//npcPart->showBoundingBox(true); //npcPart->showBoundingBox(true);
MeshPtr good2 = NIFLoader::load(mesh); MeshPtr good2 = NifOgre::NIFLoader::load(mesh);
MovableObject *ent = scene.getMgr()->createEntity(mesh); MovableObject *ent = scene.getMgr()->createEntity(mesh);
//ent->extr //ent->extr
@ -184,7 +184,7 @@ void InteriorCellRender::insertMesh(const std::string &mesh)
{ {
assert (insert); assert (insert);
NIFLoader::load(mesh); NifOgre::NIFLoader::load(mesh);
MovableObject *ent = scene.getMgr()->createEntity(mesh); MovableObject *ent = scene.getMgr()->createEntity(mesh);
insert->attachObject(ent); insert->attachObject(ent);

@ -16,7 +16,7 @@ namespace MWWorld
ESMS::CellRefList<ESM::Ingredient, D> ingreds; ESMS::CellRefList<ESM::Ingredient, D> ingreds;
ESMS::CellRefList<ESM::Light, D> lights; ESMS::CellRefList<ESM::Light, D> lights;
ESMS::CellRefList<ESM::Tool, D> lockpicks; ESMS::CellRefList<ESM::Tool, D> lockpicks;
ESMS::CellRefList<ESM::Misc, D> miscItems; ESMS::CellRefList<ESM::Miscellaneous, D> miscItems;
ESMS::CellRefList<ESM::Probe, D> probes; ESMS::CellRefList<ESM::Probe, D> probes;
ESMS::CellRefList<ESM::Repair, D> repairs; ESMS::CellRefList<ESM::Repair, D> repairs;
ESMS::CellRefList<ESM::Weapon, D> weapons; ESMS::CellRefList<ESM::Weapon, D> weapons;

@ -135,7 +135,7 @@ namespace MWWorld
if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = cell.lockpicks.find (name)) if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = cell.lockpicks.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Misc, RefData> *ref = cell.miscItems.find (name)) if (ESMS::LiveCellRef<ESM::Miscellaneous, RefData> *ref = cell.miscItems.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::NPC, RefData> *ref = cell.npcs.find (name)) if (ESMS::LiveCellRef<ESM::NPC, RefData> *ref = cell.npcs.find (name))
@ -198,7 +198,7 @@ namespace MWWorld
if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = searchViaHandle (handle, cell.lockpicks)) if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = searchViaHandle (handle, cell.lockpicks))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Misc, RefData> *ref = searchViaHandle (handle, cell.miscItems)) if (ESMS::LiveCellRef<ESM::Miscellaneous, RefData> *ref = searchViaHandle (handle, cell.miscItems))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::NPC, RefData> *ref = searchViaHandle (handle, cell.npcs)) if (ESMS::LiveCellRef<ESM::NPC, RefData> *ref = searchViaHandle (handle, cell.npcs))

@ -30,8 +30,12 @@
#include "bsa_file.hpp" #include "bsa_file.hpp"
#include <libs/mangle/stream/clients/ogre_datastream.hpp> #include <libs/mangle/stream/clients/ogre_datastream.hpp>
namespace
{
using namespace Ogre; using namespace Ogre;
using namespace Mangle::Stream; using namespace Mangle::Stream;
using namespace Bsa;
struct ciLessBoost : std::binary_function<std::string, std::string, bool> struct ciLessBoost : std::binary_function<std::string, std::string, bool>
{ {
@ -364,6 +368,11 @@ static void insertDirFactory()
} }
} }
}
namespace Bsa
{
// The function below is the only publicly exposed part of this file // The function below is the only publicly exposed part of this file
void addBSA(const std::string& name, const std::string& group) 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(). ResourceGroupManager::getSingleton().
addResourceLocation(name, "BSA", group); addResourceLocation(name, "BSA", group);
} }
void addDir(const std::string& name, const bool& fs, const std::string& group) void addDir(const std::string& name, const bool& fs, const std::string& group)
{ {
fsstrict = fs; fsstrict = fs;
insertDirFactory(); insertDirFactory();
ResourceGroupManager::getSingleton(). ResourceGroupManager::getSingleton().
addResourceLocation(name, "Dir", group); addResourceLocation(name, "Dir", group);
} }
}

@ -26,12 +26,17 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <algorithm> #include <algorithm>
#ifndef _BSA_ARCHIVE_H_ #ifndef BSA_BSA_ARCHIVE_H
#define _BSA_ARCHIVE_H_ #define BSA_BSA_ARCHIVE_H
namespace Bsa
{
/// Add the given BSA file as an input archive in the Ogre resource /// Add the given BSA file as an input archive in the Ogre resource
/// system. /// system.
void addBSA(const std::string& file, const std::string& group="General"); 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"); void addDir(const std::string& file, const bool& fs, const std::string& group="General");
}
#endif #endif

@ -32,6 +32,7 @@
using namespace std; using namespace std;
using namespace Mangle::Stream; using namespace Mangle::Stream;
using namespace Bsa;
/// Error handling /// Error handling
void BSAFile::fail(const string &msg) void BSAFile::fail(const string &msg)

@ -21,8 +21,8 @@
*/ */
#ifndef _BSA_FILE_H_ #ifndef BSA_BSA_FILE_H
#define _BSA_FILE_H_ #define BSA_BSA_FILE_H
#include <libs/mangle/stream/stream.hpp> #include <libs/mangle/stream/stream.hpp>
#include <libs/platform/stdint.h> #include <libs/platform/stdint.h>
@ -31,6 +31,9 @@
#include <vector> #include <vector>
#include <map> #include <map>
namespace Bsa
{
/** /**
This class is used to read "Bethesda Archive Files", or BSAs. This class is used to read "Bethesda Archive Files", or BSAs.
*/ */
@ -131,4 +134,6 @@ class BSAFile
{ return files; } { return files; }
}; };
}
#endif #endif

@ -11,6 +11,7 @@
#include <iostream> #include <iostream>
using namespace std; using namespace std;
using namespace Bsa;
BSAFile bsa; BSAFile bsa;

@ -11,6 +11,7 @@
using namespace std; using namespace std;
using namespace Mangle::Stream; using namespace Mangle::Stream;
using namespace Bsa;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {

@ -19,7 +19,7 @@ int main()
Root *root = new Root("","",""); Root *root = new Root("","","");
// Add the BSA // Add the BSA
addBSA("../../data/Morrowind.bsa"); Bsa::addBSA("../../data/Morrowind.bsa");
// Pick a sample file // Pick a sample file
String tex = "textures\\tx_natural_cavern_wall13.dds"; String tex = "textures\\tx_natural_cavern_wall13.dds";

@ -3,6 +3,8 @@
namespace ESM namespace ESM
{ {
using namespace Misc;
ESM_Context ESMReader::getContext() ESM_Context ESMReader::getContext()
{ {
// Update the file position before returning // Update the file position before returning

@ -3,7 +3,7 @@
namespace ESM namespace ESM
{ {
void Misc::load(ESMReader &esm) void Miscellaneous::load(ESMReader &esm)
{ {
model = esm.getHNString("MODL"); model = esm.getHNString("MODL");
name = esm.getHNOString("FNAM"); name = esm.getHNOString("FNAM");

@ -11,7 +11,7 @@ namespace ESM
* carried, bought and sold. It also includes keys. * carried, bought and sold. It also includes keys.
*/ */
struct Misc struct Miscellaneous
{ {
struct MCDTstruct struct MCDTstruct
{ {

@ -17,6 +17,7 @@
#include <iostream> #include <iostream>
#include <stdexcept> #include <stdexcept>
#include <algorithm>
namespace ESMS namespace ESMS
{ {
@ -99,7 +100,7 @@ namespace ESMS
CellRefList<ItemLevList, D> itemLists; CellRefList<ItemLevList, D> itemLists;
CellRefList<ESM::Light, D> lights; CellRefList<ESM::Light, D> lights;
CellRefList<Tool, D> lockpicks; CellRefList<Tool, D> lockpicks;
CellRefList<Misc, D> miscItems; CellRefList<Miscellaneous, D> miscItems;
CellRefList<NPC, D> npcs; CellRefList<NPC, D> npcs;
CellRefList<Probe, D> probes; CellRefList<Probe, D> probes;
CellRefList<Repair, D> repairs; CellRefList<Repair, D> repairs;
@ -187,7 +188,14 @@ namespace ESMS
// Get each reference in turn // Get each reference in turn
while(cell->getNextRef(esm, ref)) 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 /* 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 record itself in store.all, so that we don't need to look it

@ -52,7 +52,7 @@ namespace ESMS
RecListT<ItemLevList> itemLists; RecListT<ItemLevList> itemLists;
RecListT<Light> lights; RecListT<Light> lights;
RecListT<Tool> lockpicks; RecListT<Tool> lockpicks;
RecListT<Misc> miscItems; RecListT<Miscellaneous> miscItems;
RecListWithIDT<NPC> npcs; RecListWithIDT<NPC> npcs;
RecListT<LoadNPCC> npcChange; RecListT<LoadNPCC> npcChange;
RecListT<Probe> probes; RecListT<Probe> probes;

@ -4,9 +4,13 @@
#include <OgrePrerequisites.h> #include <OgrePrerequisites.h>
namespace Misc
{
bool isFile(const char *name) bool isFile(const char *name)
{ {
boost::filesystem::path cfg_file_path(name); boost::filesystem::path cfg_file_path(name);
return boost::filesystem::exists(cfg_file_path); return boost::filesystem::exists(cfg_file_path);
} }
}

@ -1,8 +1,11 @@
#ifndef __FILEOPS_H_ #ifndef MISC_FILEOPS_H
#define __FILEOPS_H_ #define MISC_FILEOPS_H
#include <string> #include <string>
namespace Misc
{
/// Check if a given path is an existing file (not a directory) /// Check if a given path is an existing file (not a directory)
bool isFile(const char *name); bool isFile(const char *name);
@ -10,4 +13,6 @@ bool isFile(const char *name);
std::string macBundlePath(); std::string macBundlePath();
#endif #endif
}
#endif #endif

@ -21,14 +21,17 @@
*/ */
#ifndef _SLICE_ARRAY_H_ #ifndef MISC_SLICE_ARRAY_H
#define _SLICE_ARRAY_H_ #define MISC_SLICE_ARRAY_H
// A simple array implementation containing a pointer and a // A simple array implementation containing a pointer and a
// length. Used for holding slices into a data buffer. // length. Used for holding slices into a data buffer.
#include <string.h> #include <string.h>
#include <string> #include <string>
namespace Misc
{
template <class T> template <class T>
struct SliceArray struct SliceArray
{ {
@ -74,4 +77,6 @@ typedef SliceArray<char> SString;
typedef SliceArray<int> IntArray; typedef SliceArray<int> IntArray;
typedef SliceArray<float> FloatArray; typedef SliceArray<float> FloatArray;
}
#endif #endif

@ -3,6 +3,9 @@
#include <string.h> #include <string.h>
#include <libs/platform/strings.h> #include <libs/platform/strings.h>
namespace Misc
{
bool begins(const char* str1, const char* str2) bool begins(const char* str1, const char* str2)
{ {
while(*str2) while(*str2)
@ -57,3 +60,5 @@ bool iends(const char* str1, const char* str2)
return strcasecmp(str2, str1+len1-len2) == 0; return strcasecmp(str2, str1+len1-len2) == 0;
} }
}

@ -1,5 +1,8 @@
#ifndef __STRINGOPS_H #ifndef MISC_STRINGOPS_H
#define __STRINGOPS_H #define MISC_STRINGOPS_H
namespace Misc
{
/// Returns true if str1 begins with substring str2 /// Returns true if str1 begins with substring str2
bool begins(const char* str1, const char* 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 /// Case insensitive, returns true if str1 ends with substring str2
bool iends(const char* str1, const char* str2); bool iends(const char* str1, const char* str2);
}
#endif #endif

@ -8,21 +8,21 @@ using namespace std;
int main() int main()
{ {
SString s, t; Misc::SString s, t;
s = SString("hello"); s = Misc::SString("hello");
cout << s.toString() << ", len=" << s.length << endl; cout << s.toString() << ", len=" << s.length << endl;
cout << (s=="hel") << (s=="hell") << (s=="hello") << endl; cout << (s=="hel") << (s=="hell") << (s=="hello") << endl;
t = s; t = s;
s = SString("othello"+2, 4); s = Misc::SString("othello"+2, 4);
cout << s.toString() << ", len=" << s.length << endl; cout << s.toString() << ", len=" << s.length << endl;
cout << (s=="hel") << (s=="hell") << (s=="hello") << 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}; const int arr[4] = {1,2,3,4};
IntArray ia(arr,4); Misc::IntArray ia(arr,4);
cout << ia.length << " " << ia.ptr[2] << endl; cout << ia.length << " " << ia.ptr[2] << endl;

@ -4,45 +4,45 @@
int main() int main()
{ {
assert(begins("abc", "a")); assert(Misc::begins("abc", "a"));
assert(begins("abc", "ab")); assert(Misc::begins("abc", "ab"));
assert(begins("abc", "abc")); assert(Misc::begins("abc", "abc"));
assert(begins("abcd", "abc")); assert(Misc::begins("abcd", "abc"));
assert(!begins("abc", "b")); assert(!Misc::begins("abc", "b"));
assert(!begins("abc", "bc")); assert(!Misc::begins("abc", "bc"));
assert(!begins("abc", "bcd")); assert(!Misc::begins("abc", "bcd"));
assert(!begins("abc", "abcd")); assert(!Misc::begins("abc", "abcd"));
assert(ibegins("Abc", "a")); assert(Misc::ibegins("Abc", "a"));
assert(ibegins("aBc", "ab")); assert(Misc::ibegins("aBc", "ab"));
assert(ibegins("abC", "abc")); assert(Misc::ibegins("abC", "abc"));
assert(ibegins("abcD", "abc")); assert(Misc::ibegins("abcD", "abc"));
assert(!ibegins("abc", "b")); assert(!Misc::ibegins("abc", "b"));
assert(!ibegins("abc", "bc")); assert(!Misc::ibegins("abc", "bc"));
assert(!ibegins("abc", "bcd")); assert(!Misc::ibegins("abc", "bcd"));
assert(!ibegins("abc", "abcd")); assert(!Misc::ibegins("abc", "abcd"));
assert(ends("abc", "c")); assert(Misc::ends("abc", "c"));
assert(ends("abc", "bc")); assert(Misc::ends("abc", "bc"));
assert(ends("abc", "abc")); assert(Misc::ends("abc", "abc"));
assert(ends("abcd", "abcd")); assert(Misc::ends("abcd", "abcd"));
assert(!ends("abc", "b")); assert(!Misc::ends("abc", "b"));
assert(!ends("abc", "ab")); assert(!Misc::ends("abc", "ab"));
assert(!ends("abc", "bcd")); assert(!Misc::ends("abc", "bcd"));
assert(!ends("abc", "abcd")); assert(!Misc::ends("abc", "abcd"));
assert(iends("Abc", "c")); assert(Misc::iends("Abc", "c"));
assert(iends("aBc", "bc")); assert(Misc::iends("aBc", "bc"));
assert(iends("abC", "abc")); assert(Misc::iends("abC", "abc"));
assert(iends("abcD", "abcd")); assert(Misc::iends("abcD", "abcd"));
assert(!iends("abc", "b")); assert(!Misc::iends("abc", "b"));
assert(!iends("abc", "ab")); assert(!Misc::iends("abc", "ab"));
assert(!iends("abc", "bcd")); assert(!Misc::iends("abc", "bcd"));
assert(!iends("abc", "abcd")); assert(!Misc::iends("abc", "abcd"));
return 0; return 0;
} }

@ -46,7 +46,7 @@ public:
class Named : public Controlled class Named : public Controlled
{ {
public: public:
SString name; Misc::SString name;
void read(NIFFile *nif) void read(NIFFile *nif)
{ {

@ -38,7 +38,7 @@ public:
// internal (data is inside the nif itself) texture? // internal (data is inside the nif itself) texture?
bool external; bool external;
SString filename; // In case of external textures Misc::SString filename; // In case of external textures
NiPixelDataPtr data; // In case of internal textures NiPixelDataPtr data; // In case of internal textures
/* Pixel layout /* Pixel layout
@ -89,7 +89,7 @@ public:
class ShapeData : public Record class ShapeData : public Record
{ {
public: public:
FloatArray vertices, normals, colors, uvlist; Misc::FloatArray vertices, normals, colors, uvlist;
const Vector *center; const Vector *center;
float radius; float radius;
@ -124,7 +124,7 @@ class NiTriShapeData : public ShapeData
{ {
public: public:
// Triangles, three vertex indices per triangle // Triangles, three vertex indices per triangle
SliceArray<short> triangles; Misc::SliceArray<short> triangles;
void read(NIFFile *nif) void read(NIFFile *nif)
{ {
@ -378,7 +378,7 @@ public:
{ {
const BoneTrafo *trafo; const BoneTrafo *trafo;
const Vector4 *unknown; const Vector4 *unknown;
SliceArray<VertWeight> weights; Misc::SliceArray<VertWeight> weights;
}; };
const BoneTrafo *trafo; const BoneTrafo *trafo;

@ -65,7 +65,7 @@ public:
struct TextKey struct TextKey
{ {
float time; float time;
SString text; Misc::SString text;
}; };
std::vector<TextKey> list; std::vector<TextKey> list;
@ -93,7 +93,7 @@ public:
"MRK" - marker, only visible in the editor, not rendered in-game "MRK" - marker, only visible in the editor, not rendered in-game
"NCO" - no collision "NCO" - no collision
*/ */
SString string; Misc::SString string;
void read(NIFFile *nif) void read(NIFFile *nif)
{ {

@ -36,6 +36,7 @@
#include <iostream> #include <iostream>
using namespace std; using namespace std;
using namespace Nif; using namespace Nif;
using namespace Misc;
/* This file implements functions from the NIFFile class. It is also /* This file implements functions from the NIFFile class. It is also
where we stash all the functions we couldn't add as inline where we stash all the functions we couldn't add as inline

@ -128,24 +128,24 @@ class NIFFile
char getByte() { return getType<char>(); } char getByte() { return getType<char>(); }
template<class X> template<class X>
SliceArray<X> getArrayLen(int num) Misc::SliceArray<X> getArrayLen(int num)
{ return SliceArray<X>((const X*)inp->getPtr(num*sizeof(X)),num); } { return Misc::SliceArray<X>((const X*)inp->getPtr(num*sizeof(X)),num); }
template<class X> template<class X>
SliceArray<X> getArray() Misc::SliceArray<X> getArray()
{ {
int len = getInt(); int len = getInt();
return getArrayLen<X>(len); return getArrayLen<X>(len);
} }
SString getString() { return getArray<char>(); } Misc::SString getString() { return getArray<char>(); }
const Vector *getVector() { return getPtr<Vector>(); } const Vector *getVector() { return getPtr<Vector>(); }
const Matrix *getMatrix() { return getPtr<Matrix>(); } const Matrix *getMatrix() { return getPtr<Matrix>(); }
const Transformation *getTrafo() { return getPtr<Transformation>(); } const Transformation *getTrafo() { return getPtr<Transformation>(); }
const Vector4 *getVector4() { return getPtr<Vector4>(); } const Vector4 *getVector4() { return getPtr<Vector4>(); }
FloatArray getFloatLen(int num) Misc::FloatArray getFloatLen(int num)
{ return getArrayLen<float>(num); } { return getArrayLen<float>(num); }
// For fixed-size strings where you already know the size // For fixed-size strings where you already know the size

@ -24,6 +24,8 @@
#ifndef _NIF_RECORD_H_ #ifndef _NIF_RECORD_H_
#define _NIF_RECORD_H_ #define _NIF_RECORD_H_
#include <components/misc/slice_array.hpp>
namespace Nif namespace Nif
{ {
@ -88,7 +90,7 @@ struct Record
{ {
// Record type and type name // Record type and type name
int recType; int recType;
SString recName; Misc::SString recName;
Record() : recType(RC_MISSING) {} Record() : recType(RC_MISSING) {}

@ -49,7 +49,7 @@ using namespace Ogre;
using namespace Nif; using namespace Nif;
using namespace Mangle::VFS; using namespace Mangle::VFS;
using namespace NifBullet;
//==================================================================================================== //====================================================================================================
Ogre::Matrix3 ManualBulletShapeLoader::getMatrix(Nif::Transformation* tr) Ogre::Matrix3 ManualBulletShapeLoader::getMatrix(Nif::Transformation* tr)

@ -58,6 +58,8 @@ namespace Mangle
} }
} }
namespace NifBullet
{
/** /**
*Load bulletShape from NIF files. *Load bulletShape from NIF files.
@ -126,4 +128,6 @@ private:
btCompoundShape* currentShape;//the shape curently under construction btCompoundShape* currentShape;//the shape curently under construction
}; };
}
#endif #endif

@ -90,11 +90,11 @@ int main()
//Ressources stuff //Ressources stuff
addBSA("Morrowind.bsa"); Bsa::addBSA("Morrowind.bsa");
//Ogre::ResourceGroupManager::getSingleton().createResourceGroup("general"); //Ogre::ResourceGroupManager::getSingleton().createResourceGroup("general");
Ogre::ResourcePtr ptr = BulletShapeManager::getSingleton().getByName(mesh,"General"); Ogre::ResourcePtr ptr = BulletShapeManager::getSingleton().getByName(mesh,"General");
ManualBulletShapeLoader* ShapeLoader = new ManualBulletShapeLoader(); NifBullet::ManualBulletShapeLoader* ShapeLoader = new NifBullet::ManualBulletShapeLoader();
ShapeLoader->load(mesh,"General"); ShapeLoader->load(mesh,"General");
//BulletShapeManager::getSingleton().unload(mesh); //BulletShapeManager::getSingleton().unload(mesh);

@ -50,6 +50,8 @@ using namespace std;
using namespace Ogre; using namespace Ogre;
using namespace Nif; using namespace Nif;
using namespace Mangle::VFS; using namespace Mangle::VFS;
using namespace Misc;
using namespace NifOgre;
NIFLoader& NIFLoader::getSingleton() NIFLoader& NIFLoader::getSingleton()
{ {

@ -49,6 +49,9 @@ namespace Mangle
} }
} }
namespace NifOgre
{
/** Manual resource loader for NIF meshes. This is the main class /** Manual resource loader for NIF meshes. This is the main class
responsible for translating the internal NIF mesh structure into responsible for translating the internal NIF mesh structure into
something Ogre can use. Later it will also handle the insertion of something Ogre can use. Later it will also handle the insertion of
@ -138,4 +141,6 @@ class NIFLoader : Ogre::ManualResourceLoader
Ogre::SkeletonPtr mSkel; Ogre::SkeletonPtr mSkel;
}; };
}
#endif #endif

@ -13,11 +13,11 @@ const char* mesh = "meshes\\f\\ex_ashl_a_banner_r.nif";
void C::doTest() void C::doTest()
{ {
// Add Morrowind.bsa resource location // Add Morrowind.bsa resource location
addBSA("../../data/Morrowind.bsa"); Bsa::addBSA("../../data/Morrowind.bsa");
// Insert the mesh // Insert the mesh
NIFLoader::load(mesh); NifOgre::NIFLoader::load(mesh);
NIFLoader::load(mesh); NifOgre::NIFLoader::load(mesh);
/* /*
SceneNode *node = mgr->getRootSceneNode()->createChildSceneNode("node"); SceneNode *node = mgr->getRootSceneNode()->createChildSceneNode("node");

@ -1,5 +1,8 @@
tables_gen.hpp: gen_iconv tables_gen.hpp: gen_iconv
gen_iconv > tables_gen.hpp ./gen_iconv > tables_gen.hpp
gen_iconv: gen_iconv.cpp gen_iconv: gen_iconv.cpp
g++ -Wall $^ -o $@ g++ -Wall $^ -o $@
clean:
rm -f ./gen_iconv

@ -74,13 +74,28 @@ int write_table(const std::string &charset, const std::string &tableName)
// Finish table // Finish table
cout << "};\n"; cout << "};\n";
return 0;
} }
int main() int main()
{ {
cout << hex; 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 // English
write_table("WINDOWS-1252", "windows_1252"); write_table("WINDOWS-1252", "windows_1252");
// Close namespace
cout << "\n}\n\n";
// Close header guard
cout << "#endif\n\n";
return 0; return 0;
} }

@ -1,3 +1,9 @@
#ifndef COMPONENTS_TOUTF8_TABLE_GEN_H
#define COMPONENTS_TOUTF8_TABLE_GEN_H
namespace ToUTF8
{
static char windows_1252[] = static char windows_1252[] =
{ {
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0,
@ -257,3 +263,8 @@ static char windows_1252[] =
0x2, 0xc3, 0xbe, 0x0, 0x0, 0x0, 0x2, 0xc3, 0xbe, 0x0, 0x0, 0x0,
0x2, 0xc3, 0xbf, 0x0, 0x0, 0x0 0x2, 0xc3, 0xbf, 0x0, 0x0, 0x0
}; };
}
#endif

@ -131,7 +131,7 @@ std::string ToUTF8::getUtf8(ToUTF8::FromType from)
// Pick translation array // Pick translation array
const char *arr; const char *arr;
if(from == ToUTF8::WINDOWS_1252) if(from == ToUTF8::WINDOWS_1252)
arr = windows_1252; arr = ToUTF8::windows_1252;
else else
assert(0); assert(0);

Loading…
Cancel
Save