Merge pull request #161 from OpenMW/master

Add OpenMW commits up to 21 Feb 2017
This commit is contained in:
David Cernat 2017-02-21 07:02:59 +02:00 committed by GitHub
commit a1988ac6ef
31 changed files with 149 additions and 83 deletions

View file

@ -209,7 +209,6 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
: mWindow(NULL) : mWindow(NULL)
, mEncoding(ToUTF8::WINDOWS_1252) , mEncoding(ToUTF8::WINDOWS_1252)
, mEncoder(NULL) , mEncoder(NULL)
, mVerboseScripts (false)
, mSkipMenu (false) , mSkipMenu (false)
, mUseSound (true) , mUseSound (true)
, mCompileAll (false) , mCompileAll (false)
@ -305,11 +304,6 @@ void OMW::Engine::addContentFile(const std::string& file)
mContentFiles.push_back(file); mContentFiles.push_back(file);
} }
void OMW::Engine::setScriptsVerbosity(bool scriptsVerbosity)
{
mVerboseScripts = scriptsVerbosity;
}
void OMW::Engine::setSkipMenu (bool skipMenu, bool newGame) void OMW::Engine::setSkipMenu (bool skipMenu, bool newGame)
{ {
mSkipMenu = skipMenu; mSkipMenu = skipMenu;
@ -555,8 +549,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full); mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full);
mScriptContext->setExtensions (&mExtensions); mScriptContext->setExtensions (&mExtensions);
mEnvironment.setScriptManager (new MWScript::ScriptManager (mEnvironment.getWorld()->getStore(), mEnvironment.setScriptManager (new MWScript::ScriptManager (mEnvironment.getWorld()->getStore(), *mScriptContext, mWarningsMode,
mVerboseScripts, *mScriptContext, mWarningsMode,
mScriptBlacklistUse ? mScriptBlacklist : std::vector<std::string>())); mScriptBlacklistUse ? mScriptBlacklist : std::vector<std::string>()));
// Create game mechanics system // Create game mechanics system
@ -565,7 +558,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
// Create dialog system // Create dialog system
mEnvironment.setJournal (new MWDialogue::Journal); mEnvironment.setJournal (new MWDialogue::Journal);
mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions, mVerboseScripts, mTranslationDataStorage)); mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions, mTranslationDataStorage));
// scripts // scripts
if (mCompileAll) if (mCompileAll)

View file

@ -84,7 +84,6 @@ namespace OMW
osg::ref_ptr<osgViewer::ScreenCaptureHandler> mScreenCaptureHandler; osg::ref_ptr<osgViewer::ScreenCaptureHandler> mScreenCaptureHandler;
std::string mCellName; std::string mCellName;
std::vector<std::string> mContentFiles; std::vector<std::string> mContentFiles;
bool mVerboseScripts;
bool mSkipMenu; bool mSkipMenu;
bool mUseSound; bool mUseSound;
bool mCompileAll; bool mCompileAll;
@ -158,9 +157,6 @@ namespace OMW
*/ */
void addContentFile(const std::string& file); void addContentFile(const std::string& file);
/// Enable or disable verbose script output
void setScriptsVerbosity(bool scriptsVerbosity);
/// Disable or enable all sounds /// Disable or enable all sounds
void setSoundUsage(bool soundUsage); void setSoundUsage(bool soundUsage);

View file

@ -100,9 +100,6 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
("no-sound", bpo::value<bool>()->implicit_value(true) ("no-sound", bpo::value<bool>()->implicit_value(true)
->default_value(false), "disable all sounds") ->default_value(false), "disable all sounds")
("script-verbose", bpo::value<bool>()->implicit_value(true)
->default_value(false), "verbose script output")
("script-all", bpo::value<bool>()->implicit_value(true) ("script-all", bpo::value<bool>()->implicit_value(true)
->default_value(false), "compile all scripts (excluding dialogue scripts) at startup") ->default_value(false), "compile all scripts (excluding dialogue scripts) at startup")
@ -242,7 +239,6 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
// scripts // scripts
engine.setCompileAll(variables["script-all"].as<bool>()); engine.setCompileAll(variables["script-all"].as<bool>());
engine.setCompileAllDialogue(variables["script-all-dialogue"].as<bool>()); engine.setCompileAllDialogue(variables["script-all-dialogue"].as<bool>());
engine.setScriptsVerbosity(variables["script-verbose"].as<bool>());
engine.setScriptConsoleMode (variables["script-console"].as<bool>()); engine.setScriptConsoleMode (variables["script-console"].as<bool>());
engine.setStartupScript (variables["script-run"].as<Files::EscapeHashString>().toStdString()); engine.setStartupScript (variables["script-run"].as<Files::EscapeHashString>().toStdString());
engine.setWarningsMode (variables["script-warn"].as<int>()); engine.setWarningsMode (variables["script-warn"].as<int>());

View file

@ -38,7 +38,6 @@ namespace MWClass
{ {
if(!model.empty()) if(!model.empty())
physics.addObject(ptr, model); physics.addObject(ptr, model);
MWBase::Environment::get().getMechanicsManager()->add(ptr);
} }
std::string Activator::getModel(const MWWorld::ConstPtr &ptr) const std::string Activator::getModel(const MWWorld::ConstPtr &ptr) const
@ -52,6 +51,11 @@ namespace MWClass
return ""; return "";
} }
bool Activator::useAnim() const
{
return true;
}
std::string Activator::getName (const MWWorld::ConstPtr& ptr) const std::string Activator::getName (const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>(); const MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>();

View file

@ -39,6 +39,9 @@ namespace MWClass
static void registerSelf(); static void registerSelf();
virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; virtual std::string getModel(const MWWorld::ConstPtr &ptr) const;
virtual bool useAnim() const;
///< Whether or not to use animated variant of model (default false)
}; };
} }

View file

@ -34,7 +34,11 @@ namespace MWClass
if (getCreatureStats(ptr).isDead()) if (getCreatureStats(ptr).isDead())
MWBase::Environment::get().getWorld()->enableActorCollision(ptr, false); MWBase::Environment::get().getWorld()->enableActorCollision(ptr, false);
} }
MWBase::Environment::get().getMechanicsManager()->add(ptr); }
bool Actor::useAnim() const
{
return true;
} }
void Actor::block(const MWWorld::Ptr &ptr) const void Actor::block(const MWWorld::Ptr &ptr) const

View file

@ -26,6 +26,8 @@ namespace MWClass
virtual void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const; virtual void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const;
virtual bool useAnim() const;
virtual void block(const MWWorld::Ptr &ptr) const; virtual void block(const MWWorld::Ptr &ptr) const;
virtual osg::Vec3f getRotationVector(const MWWorld::Ptr& ptr) const; virtual osg::Vec3f getRotationVector(const MWWorld::Ptr& ptr) const;

View file

@ -100,7 +100,6 @@ namespace MWClass
{ {
if(!model.empty()) if(!model.empty())
physics.addObject(ptr, model); physics.addObject(ptr, model);
MWBase::Environment::get().getMechanicsManager()->add(ptr);
} }
std::string Container::getModel(const MWWorld::ConstPtr &ptr) const std::string Container::getModel(const MWWorld::ConstPtr &ptr) const
@ -114,6 +113,11 @@ namespace MWClass
return ""; return "";
} }
bool Container::useAnim() const
{
return true;
}
boost::shared_ptr<MWWorld::Action> Container::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Container::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const const MWWorld::Ptr& actor) const
{ {

View file

@ -70,6 +70,8 @@ namespace MWClass
virtual void restock (const MWWorld::Ptr &ptr) const; virtual void restock (const MWWorld::Ptr &ptr) const;
virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; virtual std::string getModel(const MWWorld::ConstPtr &ptr) const;
virtual bool useAnim() const;
}; };
} }

View file

@ -74,8 +74,11 @@ namespace MWClass
MWBase::Environment::get().getWorld()->activateDoor(ptr, customData.mDoorState); MWBase::Environment::get().getWorld()->activateDoor(ptr, customData.mDoorState);
} }
} }
}
MWBase::Environment::get().getMechanicsManager()->add(ptr); bool Door::useAnim() const
{
return true;
} }
std::string Door::getModel(const MWWorld::ConstPtr &ptr) const std::string Door::getModel(const MWWorld::ConstPtr &ptr) const

View file

@ -20,6 +20,8 @@ namespace MWClass
virtual void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const; virtual void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const;
virtual bool useAnim() const;
virtual std::string getName (const MWWorld::ConstPtr& ptr) const; virtual std::string getName (const MWWorld::ConstPtr& ptr) const;
///< \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.

View file

@ -51,8 +51,11 @@ namespace MWClass
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->mBase->mSound, 1.0, 1.0, MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->mBase->mSound, 1.0, 1.0,
MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_TypeSfx,
MWBase::SoundManager::Play_Loop); MWBase::SoundManager::Play_Loop);
}
MWBase::Environment::get().getMechanicsManager()->add(ptr); bool Light::useAnim() const
{
return true;
} }
std::string Light::getModel(const MWWorld::ConstPtr &ptr) const std::string Light::getModel(const MWWorld::ConstPtr &ptr) const

View file

@ -16,6 +16,8 @@ namespace MWClass
virtual void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const; virtual void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const;
virtual bool useAnim() const;
virtual std::string getName (const MWWorld::ConstPtr& ptr) const; virtual std::string getName (const MWWorld::ConstPtr& ptr) const;
///< \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.

View file

@ -48,7 +48,7 @@
namespace MWDialogue namespace MWDialogue
{ {
DialogueManager::DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose, Translation::Storage& translationDataStorage) : DialogueManager::DialogueManager (const Compiler::Extensions& extensions, Translation::Storage& translationDataStorage) :
mTranslationDataStorage(translationDataStorage) mTranslationDataStorage(translationDataStorage)
, mCompilerContext (MWScript::CompilerContext::Type_Dialogue) , mCompilerContext (MWScript::CompilerContext::Type_Dialogue)
, mErrorStream(std::cout.rdbuf()) , mErrorStream(std::cout.rdbuf())
@ -198,6 +198,8 @@ namespace MWDialogue
{ {
mErrorHandler.reset(); mErrorHandler.reset();
mErrorHandler.setContext("[dialogue script]");
std::istringstream input (cmd + "\n"); std::istringstream input (cmd + "\n");
Compiler::Scanner scanner (mErrorHandler, input, mCompilerContext.getExtensions()); Compiler::Scanner scanner (mErrorHandler, input, mCompilerContext.getExtensions());

View file

@ -58,7 +58,7 @@ namespace MWDialogue
public: public:
DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose, Translation::Storage& translationDataStorage); DialogueManager (const Compiler::Extensions& extensions, Translation::Storage& translationDataStorage);
virtual void clear(); virtual void clear();

View file

@ -1189,4 +1189,40 @@ namespace MWMechanics
return true; return true;
} }
std::string getSummonedCreature(int effectId)
{
static std::map<int, std::string> summonMap;
if (summonMap.empty())
{
summonMap[ESM::MagicEffect::SummonAncestralGhost] = "sMagicAncestralGhostID";
summonMap[ESM::MagicEffect::SummonBonelord] = "sMagicBonelordID";
summonMap[ESM::MagicEffect::SummonBonewalker] = "sMagicLeastBonewalkerID";
summonMap[ESM::MagicEffect::SummonCenturionSphere] = "sMagicCenturionSphereID";
summonMap[ESM::MagicEffect::SummonClannfear] = "sMagicClannfearID";
summonMap[ESM::MagicEffect::SummonDaedroth] = "sMagicDaedrothID";
summonMap[ESM::MagicEffect::SummonDremora] = "sMagicDremoraID";
summonMap[ESM::MagicEffect::SummonFabricant] = "sMagicFabricantID";
summonMap[ESM::MagicEffect::SummonFlameAtronach] = "sMagicFlameAtronachID";
summonMap[ESM::MagicEffect::SummonFrostAtronach] = "sMagicFrostAtronachID";
summonMap[ESM::MagicEffect::SummonGoldenSaint] = "sMagicGoldenSaintID";
summonMap[ESM::MagicEffect::SummonGreaterBonewalker] = "sMagicGreaterBonewalkerID";
summonMap[ESM::MagicEffect::SummonHunger] = "sMagicHungerID";
summonMap[ESM::MagicEffect::SummonScamp] = "sMagicScampID";
summonMap[ESM::MagicEffect::SummonSkeletalMinion] = "sMagicSkeletalMinionID";
summonMap[ESM::MagicEffect::SummonStormAtronach] = "sMagicStormAtronachID";
summonMap[ESM::MagicEffect::SummonWingedTwilight] = "sMagicWingedTwilightID";
summonMap[ESM::MagicEffect::SummonWolf] = "sMagicCreature01ID";
summonMap[ESM::MagicEffect::SummonBear] = "sMagicCreature02ID";
summonMap[ESM::MagicEffect::SummonBonewolf] = "sMagicCreature03ID";
summonMap[ESM::MagicEffect::SummonCreature04] = "sMagicCreature04ID";
summonMap[ESM::MagicEffect::SummonCreature05] = "sMagicCreature05ID";
}
std::map<int, std::string>::const_iterator it = summonMap.find(effectId);
if (it == summonMap.end())
return std::string();
else
return MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(it->second)->getString();
}
} }

View file

@ -67,6 +67,8 @@ namespace MWMechanics
/// @return Was the effect a tickable effect with a magnitude? /// @return Was the effect a tickable effect with a magnitude?
bool effectTick(CreatureStats& creatureStats, const MWWorld::Ptr& actor, const MWMechanics::EffectKey& effectKey, float magnitude); bool effectTick(CreatureStats& creatureStats, const MWWorld::Ptr& actor, const MWMechanics::EffectKey& effectKey, float magnitude);
std::string getSummonedCreature(int effectId);
class CastSpell class CastSpell
{ {
private: private:

View file

@ -40,32 +40,7 @@ namespace MWMechanics
void UpdateSummonedCreatures::process() void UpdateSummonedCreatures::process()
{ {
static std::map<int, std::string> summonMap;
if (summonMap.empty())
{
summonMap[ESM::MagicEffect::SummonAncestralGhost] = "sMagicAncestralGhostID";
summonMap[ESM::MagicEffect::SummonBonelord] = "sMagicBonelordID";
summonMap[ESM::MagicEffect::SummonBonewalker] = "sMagicLeastBonewalkerID";
summonMap[ESM::MagicEffect::SummonCenturionSphere] = "sMagicCenturionSphereID";
summonMap[ESM::MagicEffect::SummonClannfear] = "sMagicClannfearID";
summonMap[ESM::MagicEffect::SummonDaedroth] = "sMagicDaedrothID";
summonMap[ESM::MagicEffect::SummonDremora] = "sMagicDremoraID";
summonMap[ESM::MagicEffect::SummonFabricant] = "sMagicFabricantID";
summonMap[ESM::MagicEffect::SummonFlameAtronach] = "sMagicFlameAtronachID";
summonMap[ESM::MagicEffect::SummonFrostAtronach] = "sMagicFrostAtronachID";
summonMap[ESM::MagicEffect::SummonGoldenSaint] = "sMagicGoldenSaintID";
summonMap[ESM::MagicEffect::SummonGreaterBonewalker] = "sMagicGreaterBonewalkerID";
summonMap[ESM::MagicEffect::SummonHunger] = "sMagicHungerID";
summonMap[ESM::MagicEffect::SummonScamp] = "sMagicScampID";
summonMap[ESM::MagicEffect::SummonSkeletalMinion] = "sMagicSkeletalMinionID";
summonMap[ESM::MagicEffect::SummonStormAtronach] = "sMagicStormAtronachID";
summonMap[ESM::MagicEffect::SummonWingedTwilight] = "sMagicWingedTwilightID";
summonMap[ESM::MagicEffect::SummonWolf] = "sMagicCreature01ID";
summonMap[ESM::MagicEffect::SummonBear] = "sMagicCreature02ID";
summonMap[ESM::MagicEffect::SummonBonewolf] = "sMagicCreature03ID";
summonMap[ESM::MagicEffect::SummonCreature04] = "sMagicCreature04ID";
summonMap[ESM::MagicEffect::SummonCreature05] = "sMagicCreature05ID";
}
MWMechanics::CreatureStats& creatureStats = mActor.getClass().getCreatureStats(mActor); MWMechanics::CreatureStats& creatureStats = mActor.getClass().getCreatureStats(mActor);
@ -89,10 +64,7 @@ namespace MWMechanics
bool found = creatureMap.find(std::make_pair(it->first, it->second)) != creatureMap.end(); bool found = creatureMap.find(std::make_pair(it->first, it->second)) != creatureMap.end();
if (!found) if (!found)
{ {
const std::string& creatureGmst = summonMap[it->first]; std::string creatureID = getSummonedCreature(it->first);
std::string creatureID =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(creatureGmst)->getString();
if (!creatureID.empty()) if (!creatureID.empty())
{ {
int creatureActorId = -1; int creatureActorId = -1;

View file

@ -531,7 +531,7 @@ namespace MWPhysics
mShape = new btHeightfieldTerrainShape( mShape = new btHeightfieldTerrainShape(
sqrtVerts, sqrtVerts, heights, 1, sqrtVerts, sqrtVerts, heights, 1,
minh, maxh, 2, minh, maxh, 2,
PHY_FLOAT, true PHY_FLOAT, false
); );
mShape->setUseDiamondSubdivision(true); mShape->setUseDiamondSubdivision(true);
mShape->setLocalScaling(btVector3(triSize, triSize, 1)); mShape->setLocalScaling(btVector3(triSize, triSize, 1));

View file

@ -15,6 +15,7 @@
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/actionteleport.hpp"
#include "../mwmechanics/actorutil.hpp" #include "../mwmechanics/actorutil.hpp"
@ -46,10 +47,9 @@ namespace MWScript
ESM::Position pos; ESM::Position pos;
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
world->getPlayer().setTeleported(true);
if (world->findExteriorPosition(cell, pos)) if (world->findExteriorPosition(cell, pos))
{ {
world->changeToExteriorCell(pos, true); MWWorld::ActionTeleport("", pos, false).execute(world->getPlayerPtr());
world->fixPosition(world->getPlayerPtr()); world->fixPosition(world->getPlayerPtr());
} }
else else
@ -57,7 +57,7 @@ namespace MWScript
// Change to interior even if findInteriorPosition() // Change to interior even if findInteriorPosition()
// yields false. In this case position will be zero-point. // yields false. In this case position will be zero-point.
world->findInteriorPosition(cell, pos); world->findInteriorPosition(cell, pos);
world->changeToInteriorCell(cell, pos, true); MWWorld::ActionTeleport(cell, pos, false).execute(world->getPlayerPtr());
} }
} }
}; };
@ -76,13 +76,13 @@ namespace MWScript
ESM::Position pos; ESM::Position pos;
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
world->getPlayer().setTeleported(true);
world->indexToPosition (x, y, pos.pos[0], pos.pos[1], true); world->indexToPosition (x, y, pos.pos[0], pos.pos[1], true);
pos.pos[2] = 0; pos.pos[2] = 0;
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
world->changeToExteriorCell (pos, true); MWWorld::ActionTeleport("", pos, false).execute(world->getPlayerPtr());
world->fixPosition(world->getPlayerPtr()); world->fixPosition(world->getPlayerPtr());
} }
}; };

View file

@ -21,10 +21,10 @@
namespace MWScript namespace MWScript
{ {
ScriptManager::ScriptManager (const MWWorld::ESMStore& store, bool verbose, ScriptManager::ScriptManager (const MWWorld::ESMStore& store,
Compiler::Context& compilerContext, int warningsMode, Compiler::Context& compilerContext, int warningsMode,
const std::vector<std::string>& scriptBlacklist) const std::vector<std::string>& scriptBlacklist)
: mErrorHandler (std::cerr), mStore (store), mVerbose (verbose), : mErrorHandler (std::cerr), mStore (store),
mCompilerContext (compilerContext), mParser (mErrorHandler, mCompilerContext), mCompilerContext (compilerContext), mParser (mErrorHandler, mCompilerContext),
mOpcodesInstalled (false), mGlobalScripts (store) mOpcodesInstalled (false), mGlobalScripts (store)
{ {
@ -44,8 +44,7 @@ namespace MWScript
if (const ESM::Script *script = mStore.get<ESM::Script>().find (name)) if (const ESM::Script *script = mStore.get<ESM::Script>().find (name))
{ {
if (mVerbose) mErrorHandler.setContext(name);
std::cout << "compiling script: " << name << std::endl;
bool Success = true; bool Success = true;
try try
@ -74,8 +73,6 @@ namespace MWScript
{ {
std::cerr std::cerr
<< "compiling failed: " << name << std::endl; << "compiling failed: " << name << std::endl;
if (mVerbose)
std::cerr << script->mScriptText << std::endl << std::endl;
} }
if (Success) if (Success)
@ -172,13 +169,10 @@ namespace MWScript
if (const ESM::Script *script = mStore.get<ESM::Script>().search (name2)) if (const ESM::Script *script = mStore.get<ESM::Script>().search (name2))
{ {
if (mVerbose)
std::cout
<< "scanning script for local variable declarations: " << name2
<< std::endl;
Compiler::Locals locals; Compiler::Locals locals;
mErrorHandler.setContext(name2 + "[local variables]");
std::istringstream stream (script->mScriptText); std::istringstream stream (script->mScriptText);
Compiler::QuickFileParser parser (mErrorHandler, mCompilerContext, locals); Compiler::QuickFileParser parser (mErrorHandler, mCompilerContext, locals);
Compiler::Scanner scanner (mErrorHandler, stream, mCompilerContext.getExtensions()); Compiler::Scanner scanner (mErrorHandler, stream, mCompilerContext.getExtensions());

View file

@ -36,7 +36,6 @@ namespace MWScript
{ {
Compiler::StreamErrorHandler mErrorHandler; Compiler::StreamErrorHandler mErrorHandler;
const MWWorld::ESMStore& mStore; const MWWorld::ESMStore& mStore;
bool mVerbose;
Compiler::Context& mCompilerContext; Compiler::Context& mCompilerContext;
Compiler::FileParser mParser; Compiler::FileParser mParser;
Interpreter::Interpreter mInterpreter; Interpreter::Interpreter mInterpreter;
@ -52,7 +51,7 @@ namespace MWScript
public: public:
ScriptManager (const MWWorld::ESMStore& store, bool verbose, ScriptManager (const MWWorld::ESMStore& store,
Compiler::Context& compilerContext, int warningsMode, Compiler::Context& compilerContext, int warningsMode,
const std::vector<std::string>& scriptBlacklist); const std::vector<std::string>& scriptBlacklist);

View file

@ -4,6 +4,8 @@
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "player.hpp" #include "player.hpp"
@ -34,6 +36,7 @@ namespace MWWorld
void ActionTeleport::teleport(const Ptr &actor) void ActionTeleport::teleport(const Ptr &actor)
{ {
MWBase::World* world = MWBase::Environment::get().getWorld(); MWBase::World* world = MWBase::Environment::get().getWorld();
actor.getClass().getCreatureStats(actor).land();
if(actor == world->getPlayerPtr()) if(actor == world->getPlayerPtr())
{ {
world->getPlayer().setTeleported(true); world->getPlayer().setTeleported(true);

View file

@ -304,6 +304,11 @@ namespace MWWorld
return ""; return "";
} }
bool Class::useAnim() const
{
return false;
}
void Class::getModelsToPreload(const Ptr &ptr, std::vector<std::string> &models) const void Class::getModelsToPreload(const Ptr &ptr, std::vector<std::string> &models) const
{ {
std::string model = getModel(ptr); std::string model = getModel(ptr);

View file

@ -271,6 +271,9 @@ namespace MWWorld
virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; virtual std::string getModel(const MWWorld::ConstPtr &ptr) const;
virtual bool useAnim() const;
///< Whether or not to use animated variant of model (default false)
virtual void getModelsToPreload(const MWWorld::Ptr& ptr, std::vector<std::string>& models) const; virtual void getModelsToPreload(const MWWorld::Ptr& ptr, std::vector<std::string>& models) const;
///< Get a list of models to preload that this object may use (directly or indirectly). default implementation: list getModel(). ///< Get a list of models to preload that this object may use (directly or indirectly). default implementation: list getModel().

View file

@ -56,15 +56,23 @@ namespace
void addObject(const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics, void addObject(const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics,
MWRender::RenderingManager& rendering) MWRender::RenderingManager& rendering)
{ {
std::string model = Misc::ResourceHelpers::correctActorModelPath(ptr.getClass().getModel(ptr), rendering.getResourceSystem()->getVFS()); bool useAnim = ptr.getClass().useAnim();
std::string model = ptr.getClass().getModel(ptr);
if (useAnim)
model = Misc::ResourceHelpers::correctActorModelPath(model, rendering.getResourceSystem()->getVFS());
std::string id = ptr.getCellRef().getRefId(); std::string id = ptr.getCellRef().getRefId();
if (id == "prisonmarker" || id == "divinemarker" || id == "templemarker" || id == "northmarker") if (id == "prisonmarker" || id == "divinemarker" || id == "templemarker" || id == "northmarker")
model = ""; // marker objects that have a hardcoded function in the game logic, should be hidden from the player model = ""; // marker objects that have a hardcoded function in the game logic, should be hidden from the player
ptr.getClass().insertObjectRendering(ptr, model, rendering); ptr.getClass().insertObjectRendering(ptr, model, rendering);
setNodeRotation(ptr, rendering, false); setNodeRotation(ptr, rendering, false);
ptr.getClass().insertObject (ptr, model, physics); ptr.getClass().insertObject (ptr, model, physics);
if (useAnim)
MWBase::Environment::get().getMechanicsManager()->add(ptr);
if (ptr.getClass().isActor()) if (ptr.getClass().isActor())
rendering.addWaterRippleEmitter(ptr); rendering.addWaterRippleEmitter(ptr);
} }
@ -703,10 +711,14 @@ namespace MWWorld
Resource::SceneManager* mSceneManager; Resource::SceneManager* mSceneManager;
}; };
void Scene::preload(const std::string &mesh) void Scene::preload(const std::string &mesh, bool useAnim)
{ {
if (!mRendering.getResourceSystem()->getSceneManager()->checkLoaded(mesh, mRendering.getReferenceTime())) std::string mesh_ = mesh;
mRendering.getWorkQueue()->addWorkItem(new PreloadMeshItem(mesh, mRendering.getResourceSystem()->getSceneManager())); if (useAnim)
mesh_ = Misc::ResourceHelpers::correctActorModelPath(mesh_, mRendering.getResourceSystem()->getVFS());
if (!mRendering.getResourceSystem()->getSceneManager()->checkLoaded(mesh_, mRendering.getReferenceTime()))
mRendering.getWorkQueue()->addWorkItem(new PreloadMeshItem(mesh_, mRendering.getResourceSystem()->getSceneManager()));
} }
void Scene::preloadCells(float dt) void Scene::preloadCells(float dt)

View file

@ -133,7 +133,7 @@ namespace MWWorld
Ptr searchPtrViaActorId (int actorId); Ptr searchPtrViaActorId (int actorId);
void preload(const std::string& mesh); void preload(const std::string& mesh, bool useAnim=false);
}; };
} }

View file

@ -3481,10 +3481,16 @@ namespace MWWorld
{ {
if (obj.empty()) if (obj.empty())
return; return;
MWWorld::ManualRef ref(store, obj); try
std::string model = ref.getPtr().getClass().getModel(ref.getPtr()); {
if (!model.empty()) MWWorld::ManualRef ref(store, obj);
scene->preload(model); std::string model = ref.getPtr().getClass().getModel(ref.getPtr());
if (!model.empty())
scene->preload(model, ref.getPtr().getClass().useAnim());
}
catch(std::exception& e)
{
}
} }
void World::preloadEffects(const ESM::EffectList *effectList) void World::preloadEffects(const ESM::EffectList *effectList)
@ -3493,6 +3499,12 @@ namespace MWWorld
{ {
const ESM::MagicEffect *effect = mStore.get<ESM::MagicEffect>().find(it->mEffectID); const ESM::MagicEffect *effect = mStore.get<ESM::MagicEffect>().find(it->mEffectID);
if (MWMechanics::isSummoningEffect(it->mEffectID))
{
preload(mWorldScene, mStore, "VFX_Summon_Start");
preload(mWorldScene, mStore, MWMechanics::getSummonedCreature(it->mEffectID));
}
preload(mWorldScene, mStore, effect->mCasting); preload(mWorldScene, mStore, effect->mCasting);
preload(mWorldScene, mStore, effect->mHit); preload(mWorldScene, mStore, effect->mHit);

View file

@ -14,6 +14,9 @@ namespace Compiler
else else
mStream << "warning "; mStream << "warning ";
if (!mContext.empty())
mStream << mContext << " ";
mStream mStream
<< "line " << loc.mLine+1 << ", column " << loc.mColumn+1 << "line " << loc.mLine+1 << ", column " << loc.mColumn+1
<< " (" << loc.mLiteral << ")" << std::endl << " (" << loc.mLiteral << ")" << std::endl
@ -34,5 +37,10 @@ namespace Compiler
<< " " << message << std::endl; << " " << message << std::endl;
} }
void StreamErrorHandler::setContext(const std::string &context)
{
mContext = context;
}
StreamErrorHandler::StreamErrorHandler (std::ostream& ErrorStream) : mStream (ErrorStream) {} StreamErrorHandler::StreamErrorHandler (std::ostream& ErrorStream) : mStream (ErrorStream) {}
} }

View file

@ -13,6 +13,8 @@ namespace Compiler
{ {
std::ostream& mStream; std::ostream& mStream;
std::string mContext;
// not implemented // not implemented
StreamErrorHandler (const StreamErrorHandler&); StreamErrorHandler (const StreamErrorHandler&);
@ -26,6 +28,8 @@ namespace Compiler
public: public:
void setContext(const std::string& context);
// constructors // constructors
StreamErrorHandler (std::ostream& ErrorStream); StreamErrorHandler (std::ostream& ErrorStream);

View file

@ -374,7 +374,7 @@ namespace SceneUtil
bool sortLights (const LightManager::LightSourceViewBound* left, const LightManager::LightSourceViewBound* right) bool sortLights (const LightManager::LightSourceViewBound* left, const LightManager::LightSourceViewBound* right)
{ {
return left->mViewBound.center().length2() - left->mViewBound.radius2()/4.f < right->mViewBound.center().length2() - right->mViewBound.radius2()/4.f; return left->mViewBound.center().length2() - left->mViewBound.radius2()*81 < right->mViewBound.center().length2() - right->mViewBound.radius2()*81;
} }
void LightListCallback::operator()(osg::Node *node, osg::NodeVisitor *nv) void LightListCallback::operator()(osg::Node *node, osg::NodeVisitor *nv)