1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-21 18:09:39 +00:00

Merge branch 'master' into container

Conflicts:
	apps/openmw/mwclass/container.cpp
	apps/openmw/mwclass/container.hpp
	apps/openmw/mwclass/creature.cpp
	apps/openmw/mwclass/creature.hpp
	apps/openmw/mwclass/npc.cpp
	apps/openmw/mwclass/npc.hpp
	apps/openmw/mwworld/class.cpp
	apps/openmw/mwworld/class.hpp
This commit is contained in:
Marc Zinnschlag 2010-08-06 14:37:53 +02:00
commit 10a63b10b5
45 changed files with 308 additions and 24 deletions

View file

@ -38,13 +38,18 @@ void OMW::Engine::executeLocalScripts()
mEnvironment.mWorld->getLocalScripts().begin()); mEnvironment.mWorld->getLocalScripts().begin());
iter!=mEnvironment.mWorld->getLocalScripts().end(); ++iter) iter!=mEnvironment.mWorld->getLocalScripts().end(); ++iter)
{ {
MWScript::InterpreterContext interpreterContext (mEnvironment, if (!mIgnoreLocalPtr.isEmpty() && mIgnoreLocalPtr!=iter->second)
&iter->second.getRefData().getLocals(), MWWorld::Ptr (iter->second)); {
mScriptManager->run (iter->first, interpreterContext); MWScript::InterpreterContext interpreterContext (mEnvironment,
&iter->second.getRefData().getLocals(), MWWorld::Ptr (iter->second));
mScriptManager->run (iter->first, interpreterContext);
if (mEnvironment.mWorld->hasCellChanged()) if (mEnvironment.mWorld->hasCellChanged())
break; break;
}
} }
mIgnoreLocalPtr = MWWorld::Ptr();
} }
bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
@ -74,22 +79,20 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
if (focusFrameCounter++ == focusUpdateFrame) if (focusFrameCounter++ == focusUpdateFrame)
{ {
std::pair<std::string, float> handle = mEnvironment.mWorld->getMWScene()->getFacedHandle(); std::string handle = mEnvironment.mWorld->getFacedHandle();
std::string name; std::string name;
if (!handle.first.empty()) if (!handle.empty())
{ {
// TODO compare handle.second with max activation range (from a GMST) MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle);
MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle.first);
if (!ptr.isEmpty()) if (!ptr.isEmpty())
name = MWWorld::Class::get (ptr).getName (ptr); name = MWWorld::Class::get (ptr).getName (ptr);
} }
if (!name.empty()) if (!name.empty())
std::cout << "Object: " << name << ", distance: " << handle.second << std::endl; std::cout << "Object: " << name << std::endl;
focusFrameCounter = 0; focusFrameCounter = 0;
} }
@ -255,7 +258,7 @@ void OMW::Engine::go()
// Sets up the input system // Sets up the input system
MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayerPos(), MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayerPos(),
*mEnvironment.mWindowManager, mDebug); *mEnvironment.mWindowManager, mDebug, *this);
focusFrameCounter = 0; focusFrameCounter = 0;
@ -268,3 +271,38 @@ void OMW::Engine::go()
std::cout << "Quitting peacefully.\n"; std::cout << "Quitting peacefully.\n";
} }
void OMW::Engine::activate()
{
std::string handle = mEnvironment.mWorld->getFacedHandle();
if (handle.empty())
return;
MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle);
if (ptr.isEmpty())
return;
MWScript::InterpreterContext interpreterContext (mEnvironment,
&ptr.getRefData().getLocals(), ptr);
boost::shared_ptr<MWWorld::Action> action =
MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayerPos().getPlayer(),
mEnvironment);
interpreterContext.activate (ptr, action);
std::string script = MWWorld::Class::get (ptr).getScript (ptr);
if (!script.empty())
{
mIgnoreLocalPtr = ptr;
mScriptManager->run (script, interpreterContext);
}
if (!interpreterContext.hasActivationBeenHandled())
{
interpreterContext.executeActivation();
}
}

View file

@ -11,6 +11,7 @@
#include <components/compiler/extensions.hpp> #include <components/compiler/extensions.hpp>
#include "mwworld/environment.hpp" #include "mwworld/environment.hpp"
#include "mwworld/ptr.hpp"
namespace Compiler namespace Compiler
{ {
@ -68,6 +69,8 @@ namespace OMW
int focusFrameCounter; int focusFrameCounter;
static const int focusUpdateFrame = 10; static const int focusUpdateFrame = 10;
MWWorld::Ptr mIgnoreLocalPtr;
// not implemented // not implemented
Engine (const Engine&); Engine (const Engine&);
Engine& operator= (const Engine&); Engine& operator= (const Engine&);
@ -111,12 +114,15 @@ namespace OMW
/// Enable verbose script output /// Enable verbose script output
void enableVerboseScripts(); void enableVerboseScripts();
/// Start as a new game. /// Start as a new game.
void setNewGame(); void setNewGame();
/// Initialise and enter main loop. /// Initialise and enter main loop.
void go(); void go();
/// Activate the focussed object.
void activate();
}; };
} }

View file

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name; return ref->base->name;
} }
std::string Activator::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData> *ref =
ptr.get<ESM::Activator>();
return ref->base->script;
}
void Activator::registerSelf() void Activator::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Activator); boost::shared_ptr<Class> instance (new Activator);

View file

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one); ///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string. /// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
}; };
} }

View file

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name; return ref->base->name;
} }
std::string Apparatus::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
ptr.get<ESM::Apparatus>();
return ref->base->script;
}
void Apparatus::registerSelf() void Apparatus::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Apparatus); boost::shared_ptr<Class> instance (new Apparatus);

View file

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one); ///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string. /// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
}; };
} }

View file

@ -30,6 +30,14 @@ namespace MWClass
return ref->base->data.health; return ref->base->data.health;
} }
std::string Armor::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
ptr.get<ESM::Armor>();
return ref->base->script;
}
void Armor::registerSelf() void Armor::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Armor); boost::shared_ptr<Class> instance (new Armor);

View file

@ -19,6 +19,9 @@ namespace MWClass
virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const; virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const;
///< Return item max health or throw an exception, if class does not have item health ///< Return item max health or throw an exception, if class does not have item health
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
}; };
} }

View file

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name; return ref->base->name;
} }
std::string Book::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
ptr.get<ESM::Book>();
return ref->base->script;
}
void Book::registerSelf() void Book::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Book); boost::shared_ptr<Class> instance (new Book);

View file

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one); ///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string. /// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
}; };
} }

View file

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name; return ref->base->name;
} }
std::string Clothing::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
ptr.get<ESM::Clothing>();
return ref->base->script;
}
void Clothing::registerSelf() void Clothing::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Clothing); boost::shared_ptr<Class> instance (new Clothing);

View file

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one); ///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string. /// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
}; };
} }

View file

@ -33,6 +33,14 @@ namespace MWClass
return *ptr.getRefData().getContainerStore(); return *ptr.getRefData().getContainerStore();
} }
std::string Container::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
ptr.get<ESM::Container>();
return ref->base->script;
}
void Container::registerSelf() void Container::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Container); boost::shared_ptr<Class> instance (new Container);

View file

@ -17,6 +17,9 @@ namespace MWClass
const MWWorld::Ptr& ptr) const; const MWWorld::Ptr& ptr) const;
///< Return container store ///< Return container store
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
}; };
} }

View file

@ -60,6 +60,14 @@ namespace MWClass
return *ptr.getRefData().getContainerStore(); return *ptr.getRefData().getContainerStore();
} }
std::string Creature::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
ptr.get<ESM::Creature>();
return ref->base->script;
}
void Creature::registerSelf() void Creature::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Creature); boost::shared_ptr<Class> instance (new Creature);

View file

@ -20,6 +20,9 @@ namespace MWClass
const MWWorld::Ptr& ptr) const; const MWWorld::Ptr& ptr) const;
///< Return container store ///< Return container store
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
}; };
} }

View file

@ -53,6 +53,14 @@ namespace MWClass
} }
} }
std::string Door::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
ptr.get<ESM::Door>();
return ref->base->script;
}
void Door::registerSelf() void Door::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Door); boost::shared_ptr<Class> instance (new Door);

View file

@ -17,6 +17,9 @@ namespace MWClass
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
///< Generate action for activation ///< Generate action for activation
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
}; };
} }

View file

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name; return ref->base->name;
} }
std::string Ingredient::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
ptr.get<ESM::Ingredient>();
return ref->base->script;
}
void Ingredient::registerSelf() void Ingredient::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Ingredient); boost::shared_ptr<Class> instance (new Ingredient);

View file

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one); ///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string. /// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
}; };
} }

View file

@ -20,6 +20,14 @@ namespace MWClass
return ref->base->name; return ref->base->name;
} }
std::string Light::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
ptr.get<ESM::Light>();
return ref->base->script;
}
void Light::registerSelf() void Light::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Light); boost::shared_ptr<Class> instance (new Light);

View file

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one); ///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string. /// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
}; };
} }

View file

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name; return ref->base->name;
} }
std::string Lockpick::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
ptr.get<ESM::Tool>();
return ref->base->script;
}
void Lockpick::registerSelf() void Lockpick::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Lockpick); boost::shared_ptr<Class> instance (new Lockpick);

View file

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one); ///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string. /// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
}; };
} }

View file

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name; return ref->base->name;
} }
std::string Misc::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Misc, MWWorld::RefData> *ref =
ptr.get<ESM::Misc>();
return ref->base->script;
}
void Misc::registerSelf() void Misc::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Misc); boost::shared_ptr<Class> instance (new Misc);

View file

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one); ///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string. /// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
}; };
} }

View file

@ -44,7 +44,8 @@ namespace MWClass
return *ptr.getRefData().getCreatureStats(); return *ptr.getRefData().getCreatureStats();
} }
MWWorld::ContainerStore<MWWorld::RefData>& Npc::getContainerStore (const MWWorld::Ptr& ptr) const MWWorld::ContainerStore<MWWorld::RefData>& Npc::getContainerStore (const MWWorld::Ptr& ptr)
const
{ {
if (!ptr.getRefData().getContainerStore().get()) if (!ptr.getRefData().getContainerStore().get())
{ {
@ -59,6 +60,14 @@ namespace MWClass
return *ptr.getRefData().getContainerStore(); return *ptr.getRefData().getContainerStore();
} }
std::string Npc::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
ptr.get<ESM::NPC>();
return ref->base->script;
}
void Npc::registerSelf() void Npc::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Npc); boost::shared_ptr<Class> instance (new Npc);

View file

@ -20,6 +20,9 @@ namespace MWClass
const MWWorld::Ptr& ptr) const; const MWWorld::Ptr& ptr) const;
///< Return container store ///< Return container store
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
}; };
} }

View file

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name; return ref->base->name;
} }
std::string Potion::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
ptr.get<ESM::Potion>();
return ref->base->script;
}
void Potion::registerSelf() void Potion::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Potion); boost::shared_ptr<Class> instance (new Potion);

View file

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one); ///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string. /// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
}; };
} }

View file

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name; return ref->base->name;
} }
std::string Probe::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
ptr.get<ESM::Probe>();
return ref->base->script;
}
void Probe::registerSelf() void Probe::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Probe); boost::shared_ptr<Class> instance (new Probe);

View file

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one); ///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string. /// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
}; };
} }

View file

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name; return ref->base->name;
} }
std::string Repair::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
ptr.get<ESM::Repair>();
return ref->base->script;
}
void Repair::registerSelf() void Repair::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Repair); boost::shared_ptr<Class> instance (new Repair);

View file

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one); ///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string. /// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
}; };
} }

View file

@ -30,6 +30,14 @@ namespace MWClass
return ref->base->data.health; return ref->base->data.health;
} }
std::string Weapon::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
ptr.get<ESM::Weapon>();
return ref->base->script;
}
void Weapon::registerSelf() void Weapon::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Weapon); boost::shared_ptr<Class> instance (new Weapon);

View file

@ -19,6 +19,9 @@ namespace MWClass
virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const; virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const;
///< Return item max health or throw an exception, if class does not have item health ///< Return item max health or throw an exception, if class does not have item health
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
}; };
} }

View file

@ -17,6 +17,8 @@
#include <libs/platform/strings.h> #include <libs/platform/strings.h>
#include "../mwrender/playerpos.hpp" #include "../mwrender/playerpos.hpp"
#include "../engine.hpp"
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <OgreRoot.h> #include <OgreRoot.h>
@ -58,6 +60,7 @@ namespace MWInput
OEngine::GUI::EventInjectorPtr guiEvents; OEngine::GUI::EventInjectorPtr guiEvents;
MWRender::PlayerPos &player; MWRender::PlayerPos &player;
MWGui::WindowManager &windows; MWGui::WindowManager &windows;
OMW::Engine& mEngine;
// Count screenshots. // Count screenshots.
int shotCount; int shotCount;
@ -137,7 +140,7 @@ namespace MWInput
void activate() void activate()
{ {
mEngine.activate();
} }
// Exit program now button (which is disabled in GUI mode) // Exit program now button (which is disabled in GUI mode)
@ -151,13 +154,15 @@ namespace MWInput
InputImpl(OEngine::Render::OgreRenderer &_ogre, InputImpl(OEngine::Render::OgreRenderer &_ogre,
MWRender::PlayerPos &_player, MWRender::PlayerPos &_player,
MWGui::WindowManager &_windows, MWGui::WindowManager &_windows,
bool debug) bool debug,
OMW::Engine& engine)
: ogre(_ogre), : ogre(_ogre),
exit(ogre.getWindow()), exit(ogre.getWindow()),
input(ogre.getWindow(), !debug), input(ogre.getWindow(), !debug),
poller(input), poller(input),
player(_player), player(_player),
windows(_windows), windows(_windows),
mEngine (engine),
shotCount(0) shotCount(0)
{ {
using namespace OEngine::Input; using namespace OEngine::Input;
@ -275,9 +280,10 @@ namespace MWInput
MWInputManager::MWInputManager(OEngine::Render::OgreRenderer &ogre, MWInputManager::MWInputManager(OEngine::Render::OgreRenderer &ogre,
MWRender::PlayerPos &player, MWRender::PlayerPos &player,
MWGui::WindowManager &windows, MWGui::WindowManager &windows,
bool debug) bool debug,
OMW::Engine& engine)
{ {
impl = new InputImpl(ogre,player,windows,debug); impl = new InputImpl(ogre,player,windows,debug, engine);
} }
MWInputManager::~MWInputManager() MWInputManager::~MWInputManager()

View file

@ -19,6 +19,11 @@ namespace MWGui
class WindowManager; class WindowManager;
} }
namespace OMW
{
class Engine;
}
namespace MWInput namespace MWInput
{ {
// Forward declaration of the real implementation. // Forward declaration of the real implementation.
@ -37,7 +42,8 @@ namespace MWInput
MWInputManager(OEngine::Render::OgreRenderer &_ogre, MWInputManager(OEngine::Render::OgreRenderer &_ogre,
MWRender::PlayerPos &_player, MWRender::PlayerPos &_player,
MWGui::WindowManager &_windows, MWGui::WindowManager &_windows,
bool debug); bool debug,
OMW::Engine& engine);
~MWInputManager(); ~MWInputManager();
}; };
} }

View file

@ -49,7 +49,7 @@ namespace MWMechanics
value = min + (mModified - mBase); value = min + (mModified - mBase);
diff = value - mModified; diff = value - mModified;
} }
else if (mBase>max-diff) else if (mBase+diff>max)
{ {
value = max + (mModified - mBase); value = max + (mModified - mBase);
diff = value - mModified; diff = value - mModified;

View file

@ -76,4 +76,5 @@ op 0x2000069-0x200006b: ModDynamic (health, magicka, fatigue)
op 0x200006c-0x200006e: ModDynamic (health, magicka, fatigue), explicit reference op 0x200006c-0x200006e: ModDynamic (health, magicka, fatigue), explicit reference
op 0x200006f-0x2000071: GetDynamic (health, magicka, fatigue) op 0x200006f-0x2000071: GetDynamic (health, magicka, fatigue)
op 0x2000072-0x2000074: GetDynamic (health, magicka, fatigue), explicit reference op 0x2000072-0x2000074: GetDynamic (health, magicka, fatigue), explicit reference
opcodes 0x2000075-0x3ffffff unused op 0x2000075: Activate
opcodes 0x2000076-0x3ffffff unused

View file

@ -38,19 +38,37 @@ namespace MWScript
} }
}; };
class OpActivate : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
InterpreterContext& context =
static_cast<InterpreterContext&> (runtime.getContext());
MWWorld::Ptr ptr = context.getReference();
context.executeActivation();
}
};
const int opcodeXBox = 0x200000c; const int opcodeXBox = 0x200000c;
const int opcodeOnActivate = 0x200000d; const int opcodeOnActivate = 0x200000d;
const int opcodeActivate = 0x2000075;
void registerExtensions (Compiler::Extensions& extensions) void registerExtensions (Compiler::Extensions& extensions)
{ {
extensions.registerFunction ("xbox", 'l', "", opcodeXBox); extensions.registerFunction ("xbox", 'l', "", opcodeXBox);
extensions.registerFunction ("onactivate", 'l', "", opcodeOnActivate); extensions.registerFunction ("onactivate", 'l', "", opcodeOnActivate);
extensions.registerInstruction ("activate", "", opcodeActivate);
} }
void installOpcodes (Interpreter::Interpreter& interpreter) void installOpcodes (Interpreter::Interpreter& interpreter)
{ {
interpreter.installSegment5 (opcodeXBox, new OpXBox); interpreter.installSegment5 (opcodeXBox, new OpXBox);
interpreter.installSegment5 (opcodeOnActivate, new OpOnActivate); interpreter.installSegment5 (opcodeOnActivate, new OpOnActivate);
interpreter.installSegment5 (opcodeActivate, new OpActivate);
} }
} }
} }

View file

@ -44,6 +44,11 @@ namespace MWWorld
ContainerStore<RefData>& Class::getContainerStore (const Ptr& ptr) const ContainerStore<RefData>& Class::getContainerStore (const Ptr& ptr) const
{ {
throw std::runtime_error ("class does not have a container store"); throw std::runtime_error ("class does not have a container store");
}
std::string Class::getScript (const Ptr& ptr) const
{
return "";
} }
const Class& Class::get (const std::string& key) const Class& Class::get (const std::string& key)

View file

@ -64,6 +64,10 @@ namespace MWWorld
///< Return container store or throw an exception, if class does not have a ///< Return container store or throw an exception, if class does not have a
/// container store (default implementation: throw an exceoption) /// container store (default implementation: throw an exceoption)
virtual std::string getScript (const Ptr& ptr) const;
///< Return name of the script attached to ptr (default implementation: return an empty
/// string).
static const Class& get (const std::string& key); static const Class& get (const std::string& key);
///< If there is no class for this \a key, an exception is thrown. ///< If there is no class for this \a key, an exception is thrown.

View file

@ -544,7 +544,7 @@ namespace MWWorld
insertInteriorScripts (*cell); insertInteriorScripts (*cell);
// adjust player // adjust player
mPlayerPos->setPos (position.pos[0], position.pos[1], position.pos[2]); mPlayerPos->setPos (position.pos[0], position.pos[1], position.pos[2], true);
mPlayerPos->setCell (cell); mPlayerPos->setCell (cell);
// TODO orientation // TODO orientation
@ -600,4 +600,15 @@ namespace MWWorld
{ {
mCellChanged = false; mCellChanged = false;
} }
std::string World::getFacedHandle()
{
std::pair<std::string, float> result = mScene.getFacedHandle();
if (result.first.empty() ||
result.second>getStore().gameSettings.find ("iMaxActivateDist")->i)
return "";
return result.first;
}
} }

View file

@ -83,8 +83,6 @@ namespace MWWorld
~World(); ~World();
MWRender::MWScene* getMWScene() { return &mScene; }
MWRender::PlayerPos& getPlayerPos(); MWRender::PlayerPos& getPlayerPos();
ESMS::ESMStore& getStore(); ESMS::ESMStore& getStore();
@ -133,6 +131,9 @@ namespace MWWorld
///< works only for interior cells currently. ///< works only for interior cells currently.
void markCellAsUnchanged(); void markCellAsUnchanged();
std::string getFacedHandle();
///< Return handle of the object the player is looking at
}; };
} }