forked from teamnwah/openmw-tes3coop
added foundation for esm record class hierarchy
This commit is contained in:
parent
b584215680
commit
a70c3876a2
9 changed files with 148 additions and 15 deletions
|
@ -2,33 +2,33 @@ project(OpenMW)
|
||||||
|
|
||||||
# local files
|
# local files
|
||||||
|
|
||||||
set(GAME
|
set(GAME
|
||||||
main.cpp
|
main.cpp
|
||||||
engine.cpp)
|
engine.cpp)
|
||||||
set(GAME_HEADER
|
set(GAME_HEADER
|
||||||
engine.hpp)
|
engine.hpp)
|
||||||
source_group(game FILES ${GAME} ${GAME_HEADER})
|
source_group(game FILES ${GAME} ${GAME_HEADER})
|
||||||
|
|
||||||
set(GAMEREND
|
set(GAMEREND
|
||||||
mwrender/mwscene.cpp
|
mwrender/mwscene.cpp
|
||||||
mwrender/cellimp.cpp
|
mwrender/cellimp.cpp
|
||||||
mwrender/interior.cpp
|
mwrender/interior.cpp
|
||||||
mwrender/sky.cpp)
|
mwrender/sky.cpp)
|
||||||
set(GAMEREND_HEADER
|
set(GAMEREND_HEADER
|
||||||
mwrender/cell.hpp
|
mwrender/cell.hpp
|
||||||
mwrender/cellimp.hpp
|
mwrender/cellimp.hpp
|
||||||
mwrender/mwscene.hpp
|
mwrender/mwscene.hpp
|
||||||
mwrender/interior.hpp
|
mwrender/interior.hpp
|
||||||
mwrender/playerpos.hpp
|
mwrender/playerpos.hpp
|
||||||
mwrender/sky.hpp)
|
mwrender/sky.hpp)
|
||||||
source_group(apps\\openmw\\mwrender FILES ${GAMEREND} ${GAMEREND_HEADER})
|
source_group(apps\\openmw\\mwrender FILES ${GAMEREND} ${GAMEREND_HEADER})
|
||||||
|
|
||||||
set(GAMEINPUT
|
set(GAMEINPUT
|
||||||
mwinput/inputmanager.cpp
|
mwinput/inputmanager.cpp
|
||||||
)
|
)
|
||||||
set(GAMEINPUT_HEADER
|
set(GAMEINPUT_HEADER
|
||||||
mwinput/inputmanager.hpp)
|
mwinput/inputmanager.hpp)
|
||||||
source_group(apps\\openmw\\mwinput FILES ${GAMEINPUT} ${GAMEINPUT_HEADER})
|
source_group(apps\\openmw\\mwinput FILES ${GAMEINPUT} ${GAMEINPUT_HEADER})
|
||||||
|
|
||||||
set(GAMEGUI_HEADER
|
set(GAMEGUI_HEADER
|
||||||
mwgui/mw_layouts.hpp
|
mwgui/mw_layouts.hpp
|
||||||
|
@ -54,7 +54,7 @@ set(GAMESCRIPT
|
||||||
mwscript/extensions.cpp
|
mwscript/extensions.cpp
|
||||||
mwscript/globalscripts.cpp
|
mwscript/globalscripts.cpp
|
||||||
)
|
)
|
||||||
set(GAMESCRIPT_HEADER
|
set(GAMESCRIPT_HEADER
|
||||||
mwscript/locals.hpp
|
mwscript/locals.hpp
|
||||||
mwscript/scriptmanager.hpp
|
mwscript/scriptmanager.hpp
|
||||||
mwscript/compilercontext.hpp
|
mwscript/compilercontext.hpp
|
||||||
|
@ -68,35 +68,41 @@ set(GAMESCRIPT_HEADER
|
||||||
mwscript/extensions.hpp
|
mwscript/extensions.hpp
|
||||||
mwscript/globalscripts.hpp
|
mwscript/globalscripts.hpp
|
||||||
)
|
)
|
||||||
source_group(apps\\openmw\\mwscript FILES ${GAMESCRIPT} ${GAMESCRIPT_HEADER})
|
source_group(apps\\openmw\\mwscript FILES ${GAMESCRIPT} ${GAMESCRIPT_HEADER})
|
||||||
|
|
||||||
set(GAMESOUND
|
set(GAMESOUND
|
||||||
mwsound/soundmanager.cpp)
|
mwsound/soundmanager.cpp)
|
||||||
set(GAMESOUND_HEADER
|
set(GAMESOUND_HEADER
|
||||||
mwsound/soundmanager.hpp)
|
mwsound/soundmanager.hpp)
|
||||||
source_group(apps\\openmw\\mwsound FILES ${GAMESOUND} ${GAMESOUND_HEADER})
|
source_group(apps\\openmw\\mwsound FILES ${GAMESOUND} ${GAMESOUND_HEADER})
|
||||||
|
|
||||||
set(GAMEWORLD
|
set(GAMEWORLD
|
||||||
mwworld/world.cpp
|
mwworld/world.cpp
|
||||||
mwworld/globals.cpp
|
mwworld/globals.cpp
|
||||||
|
mwworld/class.cpp
|
||||||
|
mwworld/classes.cpp
|
||||||
|
mwworld/activator.cpp
|
||||||
)
|
)
|
||||||
set(GAMEWORLD_HEADER
|
set(GAMEWORLD_HEADER
|
||||||
mwworld/refdata.hpp
|
mwworld/refdata.hpp
|
||||||
mwworld/world.hpp
|
mwworld/world.hpp
|
||||||
mwworld/ptr.hpp
|
mwworld/ptr.hpp
|
||||||
mwworld/environment.hpp
|
mwworld/environment.hpp
|
||||||
mwworld/globals.hpp
|
mwworld/globals.hpp
|
||||||
|
mwworld/class.hpp
|
||||||
|
mwworld/classes.hpp
|
||||||
|
mwworld/activator.hpp
|
||||||
)
|
)
|
||||||
source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${GAMEWORLD_HEADER})
|
source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${GAMEWORLD_HEADER})
|
||||||
|
|
||||||
set(GAMEMECHANICS
|
set(GAMEMECHANICS
|
||||||
mwmechanics/mechanicsmanager.cpp)
|
mwmechanics/mechanicsmanager.cpp)
|
||||||
set(GAMEMECHANICS_HEADER
|
set(GAMEMECHANICS_HEADER
|
||||||
mwmechanics/mechanicsmanager.hpp
|
mwmechanics/mechanicsmanager.hpp
|
||||||
mwmechanics/stat.hpp
|
mwmechanics/stat.hpp
|
||||||
mwmechanics/creaturestats.hpp
|
mwmechanics/creaturestats.hpp
|
||||||
)
|
)
|
||||||
source_group(apps\\openmw\\mwmechanics FILES ${GAMEMECHANICS} ${GAMEMECHANICS_HEADER})
|
source_group(apps\\openmw\\mwmechanics FILES ${GAMEMECHANICS} ${GAMEMECHANICS_HEADER})
|
||||||
|
|
||||||
set(OPENMW_CPP ${GAME} ${GAMEREND} ${GAMEINPUT} ${GAMESCRIPT} ${GAMESOUND} ${GAMEGUI} ${GAMEWORLD}
|
set(OPENMW_CPP ${GAME} ${GAMEREND} ${GAMEINPUT} ${GAMESCRIPT} ${GAMESOUND} ${GAMEGUI} ${GAMEWORLD}
|
||||||
${GAMEMECHANICS}
|
${GAMEMECHANICS}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "mwworld/world.hpp"
|
#include "mwworld/world.hpp"
|
||||||
#include "mwworld/ptr.hpp"
|
#include "mwworld/ptr.hpp"
|
||||||
#include "mwworld/environment.hpp"
|
#include "mwworld/environment.hpp"
|
||||||
|
#include "mwworld/classes.hpp"
|
||||||
|
|
||||||
#include "mwmechanics/mechanicsmanager.hpp"
|
#include "mwmechanics/mechanicsmanager.hpp"
|
||||||
|
|
||||||
|
@ -78,6 +79,7 @@ OMW::Engine::Engine()
|
||||||
, mScriptManager (0)
|
, mScriptManager (0)
|
||||||
, mScriptContext (0)
|
, mScriptContext (0)
|
||||||
{
|
{
|
||||||
|
MWWorld::registerClasses();
|
||||||
}
|
}
|
||||||
|
|
||||||
OMW::Engine::~Engine()
|
OMW::Engine::~Engine()
|
||||||
|
|
14
apps/openmw/mwworld/activator.cpp
Normal file
14
apps/openmw/mwworld/activator.cpp
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
#include "activator.hpp"
|
||||||
|
|
||||||
|
#include <components/esm/loadacti.hpp>
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
void Activator::registerSelf()
|
||||||
|
{
|
||||||
|
boost::shared_ptr<Class> instance (new Activator);
|
||||||
|
|
||||||
|
registerClass (typeid (ESM::Activator).name(), instance);
|
||||||
|
}
|
||||||
|
}
|
17
apps/openmw/mwworld/activator.hpp
Normal file
17
apps/openmw/mwworld/activator.hpp
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef GAME_MWWORLD_ACTIVATOR_H
|
||||||
|
#define GAME_MWWORLD_ACTIVATOR_H
|
||||||
|
|
||||||
|
#include "class.hpp"
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
class Activator : public Class
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
static void registerSelf();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
28
apps/openmw/mwworld/class.cpp
Normal file
28
apps/openmw/mwworld/class.cpp
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
|
||||||
|
#include "class.hpp"
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
std::map<std::string, boost::shared_ptr<Class> > Class::sClasses;
|
||||||
|
|
||||||
|
Class::Class() {}
|
||||||
|
|
||||||
|
Class::~Class() {}
|
||||||
|
|
||||||
|
const Class& Class::get (const std::string& key)
|
||||||
|
{
|
||||||
|
std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key);
|
||||||
|
|
||||||
|
if (iter==sClasses.end())
|
||||||
|
throw std::logic_error ("unknown class key: " + key);
|
||||||
|
|
||||||
|
return *iter->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Class::registerClass (const std::string& key, boost::shared_ptr<Class> instance)
|
||||||
|
{
|
||||||
|
sClasses.insert (std::make_pair (key, instance));
|
||||||
|
}
|
||||||
|
}
|
37
apps/openmw/mwworld/class.hpp
Normal file
37
apps/openmw/mwworld/class.hpp
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#ifndef GAME_MWWORLD_CLASS_H
|
||||||
|
#define GAME_MWWORLD_CLASS_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
/// \brief Base class for referenceable esm records
|
||||||
|
class Class
|
||||||
|
{
|
||||||
|
static std::map<std::string, boost::shared_ptr<Class> > sClasses;
|
||||||
|
|
||||||
|
// not implemented
|
||||||
|
Class (const Class&);
|
||||||
|
Class& operator= (const Class&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
Class();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual ~Class();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static const Class& get (const std::string& key);
|
||||||
|
///< If there is no class for this \a key, an exception is thrown.
|
||||||
|
|
||||||
|
static void registerClass (const std::string& key, boost::shared_ptr<Class> instance);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
12
apps/openmw/mwworld/classes.cpp
Normal file
12
apps/openmw/mwworld/classes.cpp
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
#include "classes.hpp"
|
||||||
|
|
||||||
|
#include "activator.hpp"
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
void registerClasses()
|
||||||
|
{
|
||||||
|
Activator::registerSelf();
|
||||||
|
}
|
||||||
|
}
|
10
apps/openmw/mwworld/classes.hpp
Normal file
10
apps/openmw/mwworld/classes.hpp
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef GAME_MWWORLD_CLASSES_H
|
||||||
|
#define GAME_MWWORLD_CLASSES_H
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
void registerClasses();
|
||||||
|
///< register all known classes
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -27,6 +27,7 @@ namespace MWWorld
|
||||||
ESM::CellRef *mCellRef;
|
ESM::CellRef *mCellRef;
|
||||||
RefData *mRefData;
|
RefData *mRefData;
|
||||||
CellStore *mCell;
|
CellStore *mCell;
|
||||||
|
std::string mTypeName;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -43,6 +44,11 @@ namespace MWWorld
|
||||||
return mPtr.type();
|
return mPtr.type();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& getTypeName() const
|
||||||
|
{
|
||||||
|
return mTypeName;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Ptr (ESMS::LiveCellRef<T, RefData> *liveCellRef, CellStore *cell)
|
Ptr (ESMS::LiveCellRef<T, RefData> *liveCellRef, CellStore *cell)
|
||||||
{
|
{
|
||||||
|
@ -50,6 +56,7 @@ namespace MWWorld
|
||||||
mCellRef = &liveCellRef->ref;
|
mCellRef = &liveCellRef->ref;
|
||||||
mRefData = &liveCellRef->mData;
|
mRefData = &liveCellRef->mData;
|
||||||
mCell = cell;
|
mCell = cell;
|
||||||
|
mTypeName = typeid (T).name();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
Loading…
Reference in a new issue