forked from teamnwah/openmw-tes3coop
Mantis: #18 - Move components from global namespace into their own namespace.
Moving classes from components/misc into Misc namespace. Note: Misc namespace introduced conflict with ESM::Misc and MWClass::Misc classes, so both of them are renamed to ESM::Miscellaneous and MWClass::Miscellaneous. Signed-off-by: Lukasz Gromanowski <lgromanowski@gmail.com>
This commit is contained in:
parent
8a84201ba2
commit
90985e849e
24 changed files with 75 additions and 45 deletions
|
@ -338,12 +338,12 @@ void OMW::Engine::go()
|
|||
ogreCfg.insert(0, cfgUserDir);
|
||||
|
||||
//A local plugins.cfg will be used if it exist, otherwise look in the default path
|
||||
if(!isFile(plugCfg.c_str()))
|
||||
if(!Misc::isFile(plugCfg.c_str()))
|
||||
{
|
||||
plugCfg.insert(0, cfgDir);
|
||||
}
|
||||
|
||||
mOgre.configure(!isFile(ogreCfg.c_str()), cfgUserDir, plugCfg, false);
|
||||
mOgre.configure(!Misc::isFile(ogreCfg.c_str()), cfgUserDir, plugCfg, false);
|
||||
|
||||
addResourcesDirectory (mDataDir / "Meshes");
|
||||
addResourcesDirectory (mDataDir / "Textures");
|
||||
|
|
|
@ -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
|
||||
//Otherwise try getPath
|
||||
std::string cfgFile = "openmw.cfg";
|
||||
if(!isFile(cfgFile.c_str()))
|
||||
if(!Misc::isFile(cfgFile.c_str()))
|
||||
{
|
||||
cfgFile = Files::getPath (Files::Path_ConfigGlobal, "openmw", "openmw.cfg");
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace MWClass
|
|||
ItemLevList::registerSelf();
|
||||
Light::registerSelf();
|
||||
Lockpick::registerSelf();
|
||||
Misc::registerSelf();
|
||||
Miscellaneous::registerSelf();
|
||||
Probe::registerSelf();
|
||||
Repair::registerSelf();
|
||||
Static::registerSelf();
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
|
||||
namespace MWClass
|
||||
{
|
||||
void Misc::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
void Miscellaneous::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Misc, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Misc>();
|
||||
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Miscellaneous>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
@ -31,39 +31,39 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
std::string Misc::getName (const MWWorld::Ptr& ptr) const
|
||||
std::string Miscellaneous::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Misc, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Misc>();
|
||||
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Miscellaneous>();
|
||||
|
||||
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
|
||||
{
|
||||
return boost::shared_ptr<MWWorld::Action> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
}
|
||||
|
||||
void Misc::insertIntoContainer (const MWWorld::Ptr& ptr,
|
||||
void Miscellaneous::insertIntoContainer (const MWWorld::Ptr& ptr,
|
||||
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const
|
||||
{
|
||||
insertIntoContainerStore (ptr, containerStore.miscItems);
|
||||
}
|
||||
|
||||
std::string Misc::getScript (const MWWorld::Ptr& ptr) const
|
||||
std::string Miscellaneous::getScript (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Misc, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Misc>();
|
||||
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Miscellaneous>();
|
||||
|
||||
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
|
||||
{
|
||||
class Misc : public MWWorld::Class
|
||||
class Miscellaneous : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace MWWorld
|
|||
ESMS::CellRefList<ESM::Ingredient, D> ingreds;
|
||||
ESMS::CellRefList<ESM::Light, D> lights;
|
||||
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::Repair, D> repairs;
|
||||
ESMS::CellRefList<ESM::Weapon, D> weapons;
|
||||
|
|
|
@ -135,7 +135,7 @@ namespace MWWorld
|
|||
if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = cell.lockpicks.find (name))
|
||||
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);
|
||||
|
||||
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))
|
||||
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);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::NPC, RefData> *ref = searchViaHandle (handle, cell.npcs))
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
namespace ESM
|
||||
{
|
||||
|
||||
using namespace Misc;
|
||||
|
||||
ESM_Context ESMReader::getContext()
|
||||
{
|
||||
// Update the file position before returning
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace ESM
|
||||
{
|
||||
|
||||
void Misc::load(ESMReader &esm)
|
||||
void Miscellaneous::load(ESMReader &esm)
|
||||
{
|
||||
model = esm.getHNString("MODL");
|
||||
name = esm.getHNOString("FNAM");
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace ESM
|
|||
* carried, bought and sold. It also includes keys.
|
||||
*/
|
||||
|
||||
struct Misc
|
||||
struct Miscellaneous
|
||||
{
|
||||
struct MCDTstruct
|
||||
{
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace ESMS
|
|||
CellRefList<ItemLevList, D> itemLists;
|
||||
CellRefList<ESM::Light, D> lights;
|
||||
CellRefList<Tool, D> lockpicks;
|
||||
CellRefList<Misc, D> miscItems;
|
||||
CellRefList<Miscellaneous, D> miscItems;
|
||||
CellRefList<NPC, D> npcs;
|
||||
CellRefList<Probe, D> probes;
|
||||
CellRefList<Repair, D> repairs;
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace ESMS
|
|||
RecListT<ItemLevList> itemLists;
|
||||
RecListT<Light> lights;
|
||||
RecListT<Tool> lockpicks;
|
||||
RecListT<Misc> miscItems;
|
||||
RecListT<Miscellaneous> miscItems;
|
||||
RecListWithIDT<NPC> npcs;
|
||||
RecListT<LoadNPCC> npcChange;
|
||||
RecListT<Probe> probes;
|
||||
|
|
|
@ -4,9 +4,13 @@
|
|||
|
||||
#include <OgrePrerequisites.h>
|
||||
|
||||
namespace Misc
|
||||
{
|
||||
|
||||
bool isFile(const char *name)
|
||||
{
|
||||
boost::filesystem::path cfg_file_path(name);
|
||||
return boost::filesystem::exists(cfg_file_path);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
#ifndef __FILEOPS_H_
|
||||
#define __FILEOPS_H_
|
||||
#ifndef MISC_FILEOPS_H
|
||||
#define MISC_FILEOPS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Misc
|
||||
{
|
||||
|
||||
/// Check if a given path is an existing file (not a directory)
|
||||
bool isFile(const char *name);
|
||||
|
||||
|
@ -10,4 +13,6 @@ bool isFile(const char *name);
|
|||
std::string macBundlePath();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,14 +21,17 @@
|
|||
|
||||
*/
|
||||
|
||||
#ifndef _SLICE_ARRAY_H_
|
||||
#define _SLICE_ARRAY_H_
|
||||
#ifndef MISC_SLICE_ARRAY_H
|
||||
#define MISC_SLICE_ARRAY_H
|
||||
|
||||
// A simple array implementation containing a pointer and a
|
||||
// length. Used for holding slices into a data buffer.
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
namespace Misc
|
||||
{
|
||||
|
||||
template <class T>
|
||||
struct SliceArray
|
||||
{
|
||||
|
@ -74,4 +77,6 @@ typedef SliceArray<char> SString;
|
|||
typedef SliceArray<int> IntArray;
|
||||
typedef SliceArray<float> FloatArray;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
#include <string.h>
|
||||
#include <libs/platform/strings.h>
|
||||
|
||||
namespace Misc
|
||||
{
|
||||
|
||||
bool begins(const char* str1, const char* str2)
|
||||
{
|
||||
while(*str2)
|
||||
|
@ -57,3 +60,5 @@ bool iends(const char* str1, const char* str2)
|
|||
|
||||
return strcasecmp(str2, str1+len1-len2) == 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#ifndef __STRINGOPS_H
|
||||
#define __STRINGOPS_H
|
||||
#ifndef MISC_STRINGOPS_H
|
||||
#define MISC_STRINGOPS_H
|
||||
|
||||
namespace Misc
|
||||
{
|
||||
|
||||
/// Returns true if str1 begins with substring str2
|
||||
bool begins(const char* str1, const char* str2);
|
||||
|
@ -13,4 +16,6 @@ bool ibegins(const char* str1, const char* str2);
|
|||
/// Case insensitive, returns true if str1 ends with substring str2
|
||||
bool iends(const char* str1, const char* str2);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
class Named : public Controlled
|
||||
{
|
||||
public:
|
||||
SString name;
|
||||
Misc::SString name;
|
||||
|
||||
void read(NIFFile *nif)
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
// internal (data is inside the nif itself) texture?
|
||||
bool external;
|
||||
|
||||
SString filename; // In case of external textures
|
||||
Misc::SString filename; // In case of external textures
|
||||
NiPixelDataPtr data; // In case of internal textures
|
||||
|
||||
/* Pixel layout
|
||||
|
@ -88,7 +88,7 @@ public:
|
|||
class ShapeData : public Record
|
||||
{
|
||||
public:
|
||||
FloatArray vertices, normals, colors, uvlist;
|
||||
Misc::FloatArray vertices, normals, colors, uvlist;
|
||||
const Vector *center;
|
||||
float radius;
|
||||
|
||||
|
@ -123,7 +123,7 @@ class NiTriShapeData : public ShapeData
|
|||
{
|
||||
public:
|
||||
// Triangles, three vertex indices per triangle
|
||||
SliceArray<short> triangles;
|
||||
Misc::SliceArray<short> triangles;
|
||||
|
||||
void read(NIFFile *nif)
|
||||
{
|
||||
|
@ -377,7 +377,7 @@ public:
|
|||
{
|
||||
const BoneTrafo *trafo;
|
||||
const Vector4 *unknown;
|
||||
SliceArray<VertWeight> weights;
|
||||
Misc::SliceArray<VertWeight> weights;
|
||||
};
|
||||
|
||||
const BoneTrafo *trafo;
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
struct TextKey
|
||||
{
|
||||
float time;
|
||||
SString text;
|
||||
Misc::SString text;
|
||||
};
|
||||
|
||||
std::vector<TextKey> list;
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
"MRK" - marker, only visible in the editor, not rendered in-game
|
||||
"NCO" - no collision
|
||||
*/
|
||||
SString string;
|
||||
Misc::SString string;
|
||||
|
||||
void read(NIFFile *nif)
|
||||
{
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <iostream>
|
||||
using namespace std;
|
||||
using namespace Nif;
|
||||
using namespace Misc;
|
||||
|
||||
/* This file implements functions from the NIFFile class. It is also
|
||||
where we stash all the functions we couldn't add as inline
|
||||
|
|
|
@ -128,24 +128,24 @@ class NIFFile
|
|||
char getByte() { return getType<char>(); }
|
||||
|
||||
template<class X>
|
||||
SliceArray<X> getArrayLen(int num)
|
||||
{ return SliceArray<X>((const X*)inp->getPtr(num*sizeof(X)),num); }
|
||||
Misc::SliceArray<X> getArrayLen(int num)
|
||||
{ return Misc::SliceArray<X>((const X*)inp->getPtr(num*sizeof(X)),num); }
|
||||
|
||||
template<class X>
|
||||
SliceArray<X> getArray()
|
||||
Misc::SliceArray<X> getArray()
|
||||
{
|
||||
int len = getInt();
|
||||
return getArrayLen<X>(len);
|
||||
}
|
||||
|
||||
SString getString() { return getArray<char>(); }
|
||||
Misc::SString getString() { return getArray<char>(); }
|
||||
|
||||
const Vector *getVector() { return getPtr<Vector>(); }
|
||||
const Matrix *getMatrix() { return getPtr<Matrix>(); }
|
||||
const Transformation *getTrafo() { return getPtr<Transformation>(); }
|
||||
const Vector4 *getVector4() { return getPtr<Vector4>(); }
|
||||
|
||||
FloatArray getFloatLen(int num)
|
||||
Misc::FloatArray getFloatLen(int num)
|
||||
{ return getArrayLen<float>(num); }
|
||||
|
||||
// For fixed-size strings where you already know the size
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#ifndef _NIF_RECORD_H_
|
||||
#define _NIF_RECORD_H_
|
||||
|
||||
#include <components/misc/slice_array.hpp>
|
||||
|
||||
namespace Nif
|
||||
{
|
||||
|
||||
|
@ -88,7 +90,7 @@ struct Record
|
|||
{
|
||||
// Record type and type name
|
||||
int recType;
|
||||
SString recName;
|
||||
Misc::SString recName;
|
||||
|
||||
Record() : recType(RC_MISSING) {}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ using namespace std;
|
|||
using namespace Ogre;
|
||||
using namespace Nif;
|
||||
using namespace Mangle::VFS;
|
||||
using namespace Misc;
|
||||
|
||||
NIFLoader& NIFLoader::getSingleton()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue