1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 19:19:56 +00:00

Merge remote-tracking branch 'scrawl/master'

This commit is contained in:
Marc Zinnschlag 2014-11-29 20:54:04 +01:00
commit 003675318d
18 changed files with 88 additions and 46 deletions

View file

@ -79,8 +79,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
{ {
try try
{ {
float frametime = std::min(evt.timeSinceLastFrame, 0.2f); float frametime = evt.timeSinceLastFrame;
mEnvironment.setFrameDuration (frametime); mEnvironment.setFrameDuration (frametime);
// update input // update input
@ -478,9 +477,15 @@ void OMW::Engine::go()
} }
// Start the main rendering loop // Start the main rendering loop
Ogre::Timer timer;
while (!MWBase::Environment::get().getStateManager()->hasQuitRequest()) while (!MWBase::Environment::get().getStateManager()->hasQuitRequest())
Ogre::Root::getSingleton().renderOneFrame(); {
float dt = timer.getMilliseconds()/1000.f;
dt = std::min(dt, 0.2f);
timer.reset();
Ogre::Root::getSingleton().renderOneFrame(dt);
}
// Save user settings // Save user settings
settings.saveUser(settingspath); settings.saveUser(settingspath);

View file

@ -162,6 +162,9 @@ namespace MWGui
void RaceDialog::close() void RaceDialog::close()
{ {
mPreviewImage->setImageTexture("");
const std::string textureName = "CharacterHeadPreview";
MyGUI::RenderManager::getInstance().destroyTexture(MyGUI::RenderManager::getInstance().getTexture(textureName));
mPreview.reset(NULL); mPreview.reset(NULL);
} }

View file

@ -190,14 +190,12 @@ namespace MWInput
int action = channel->getNumber(); int action = channel->getNumber();
if (action == A_Use) if (mControlSwitch["playercontrols"])
{ {
mPlayer->getPlayer().getClass().getCreatureStats(mPlayer->getPlayer()).setAttackingOrSpell(currentValue); if (action == A_Use)
} mPlayer->getPlayer().getClass().getCreatureStats(mPlayer->getPlayer()).setAttackingOrSpell(currentValue);
else if (action == A_Jump)
if (action == A_Jump) mAttemptJump = (currentValue == 1.0 && previousValue == 0.0);
{
mAttemptJump = (currentValue == 1.0 && previousValue == 0.0);
} }
if (currentValue == 1) if (currentValue == 1)
@ -603,7 +601,7 @@ namespace MWInput
MyGUI::InputManager::getInstance().injectMouseMove( int(mMouseX), int(mMouseY), mMouseWheel); MyGUI::InputManager::getInstance().injectMouseMove( int(mMouseX), int(mMouseY), mMouseWheel);
} }
if (mMouseLookEnabled) if (mMouseLookEnabled && !mControlsDisabled)
{ {
resetIdleTime(); resetIdleTime();
@ -622,7 +620,7 @@ namespace MWInput
mPlayer->pitch(y); mPlayer->pitch(y);
} }
if (arg.zrel && mControlSwitch["playerviewswitch"]) //Check to make sure you are allowed to zoomout and there is a change if (arg.zrel && mControlSwitch["playerviewswitch"] && mControlSwitch["playercontrols"]) //Check to make sure you are allowed to zoomout and there is a change
{ {
MWBase::Environment::get().getWorld()->changeVanityModeScale(arg.zrel); MWBase::Environment::get().getWorld()->changeVanityModeScale(arg.zrel);
MWBase::Environment::get().getWorld()->setCameraDistance(arg.zrel, true, true); MWBase::Environment::get().getWorld()->setCameraDistance(arg.zrel, true, true);
@ -680,7 +678,7 @@ namespace MWInput
if (MWBase::Environment::get().getWindowManager()->isGuiMode()) return; if (MWBase::Environment::get().getWindowManager()->isGuiMode()) return;
// Not allowed before the magic window is accessible // Not allowed before the magic window is accessible
if (!mControlSwitch["playermagic"]) if (!mControlSwitch["playermagic"] || !mControlSwitch["playercontrols"])
return; return;
// Not allowed if no spell selected // Not allowed if no spell selected
@ -701,7 +699,7 @@ namespace MWInput
if (MWBase::Environment::get().getWindowManager()->isGuiMode()) return; if (MWBase::Environment::get().getWindowManager()->isGuiMode()) return;
// Not allowed before the inventory window is accessible // Not allowed before the inventory window is accessible
if (!mControlSwitch["playerfighting"]) if (!mControlSwitch["playerfighting"] || !mControlSwitch["playercontrols"])
return; return;
MWMechanics::DrawState_ state = mPlayer->getDrawState(); MWMechanics::DrawState_ state = mPlayer->getDrawState();
@ -713,6 +711,9 @@ namespace MWInput
void InputManager::rest() void InputManager::rest()
{ {
if (!mControlSwitch["playercontrols"])
return;
if (!MWBase::Environment::get().getWindowManager()->getRestEnabled () || MWBase::Environment::get().getWindowManager()->isGuiMode ()) if (!MWBase::Environment::get().getWindowManager()->getRestEnabled () || MWBase::Environment::get().getWindowManager()->isGuiMode ())
return; return;
@ -734,6 +735,9 @@ namespace MWInput
void InputManager::toggleInventory() void InputManager::toggleInventory()
{ {
if (!mControlSwitch["playercontrols"])
return;
if (MyGUI::InputManager::getInstance ().isModalAny()) if (MyGUI::InputManager::getInstance ().isModalAny())
return; return;
@ -770,6 +774,8 @@ namespace MWInput
void InputManager::toggleJournal() void InputManager::toggleJournal()
{ {
if (!mControlSwitch["playercontrols"])
return;
if (MyGUI::InputManager::getInstance ().isModalAny()) if (MyGUI::InputManager::getInstance ().isModalAny())
return; return;
@ -787,6 +793,8 @@ namespace MWInput
void InputManager::quickKey (int index) void InputManager::quickKey (int index)
{ {
if (!mControlSwitch["playercontrols"])
return;
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
if (player.getClass().getNpcStats(player).isWerewolf()) if (player.getClass().getNpcStats(player).isWerewolf())
{ {

View file

@ -396,11 +396,7 @@ namespace MWMechanics
{ {
CreatureStats& creatureStats = ptr.getClass().getCreatureStats (ptr); CreatureStats& creatureStats = ptr.getClass().getCreatureStats (ptr);
int strength = creatureStats.getAttribute(ESM::Attribute::Strength).getModified();
int intelligence = creatureStats.getAttribute(ESM::Attribute::Intelligence).getModified(); int intelligence = creatureStats.getAttribute(ESM::Attribute::Intelligence).getModified();
int willpower = creatureStats.getAttribute(ESM::Attribute::Willpower).getModified();
int agility = creatureStats.getAttribute(ESM::Attribute::Agility).getModified();
int endurance = creatureStats.getAttribute(ESM::Attribute::Endurance).getModified();
float base = 1.f; float base = 1.f;
if (ptr.getCellRef().getRefId() == "player") if (ptr.getCellRef().getRefId() == "player")
@ -415,11 +411,6 @@ namespace MWMechanics
float diff = (static_cast<int>(magickaFactor*intelligence)) - magicka.getBase(); float diff = (static_cast<int>(magickaFactor*intelligence)) - magicka.getBase();
magicka.modify(diff); magicka.modify(diff);
creatureStats.setMagicka(magicka); creatureStats.setMagicka(magicka);
DynamicStat<float> fatigue = creatureStats.getFatigue();
diff = (strength+willpower+agility+endurance) - fatigue.getBase();
fatigue.modify(diff);
creatureStats.setFatigue(fatigue);
} }
void Actors::restoreDynamicStats (const MWWorld::Ptr& ptr, bool sleep) void Actors::restoreDynamicStats (const MWWorld::Ptr& ptr, bool sleep)

View file

@ -1645,6 +1645,8 @@ void CharacterController::playGroup(const std::string &groupname, int mode, int
} }
else if(mode == 0) else if(mode == 0)
{ {
if (!mAnimQueue.empty())
mAnimation->stopLooping(mAnimQueue.front().first);
mAnimQueue.resize(1); mAnimQueue.resize(1);
mAnimQueue.push_back(std::make_pair(groupname, count-1)); mAnimQueue.push_back(std::make_pair(groupname, count-1));
} }

View file

@ -20,7 +20,7 @@ namespace MWMechanics
mAttacked (false), mAttacked (false),
mAttackingOrSpell(false), mAttackingOrSpell(false),
mIsWerewolf(false), mIsWerewolf(false),
mFallHeight(0), mRecalcDynamicStats(false), mKnockdown(false), mKnockdownOneFrame(false), mFallHeight(0), mRecalcMagicka(false), mKnockdown(false), mKnockdownOneFrame(false),
mKnockdownOverOneFrame(false), mHitRecovery(false), mBlock(false), mKnockdownOverOneFrame(false), mHitRecovery(false), mBlock(false),
mMovementFlags(0), mDrawState (DrawState_Nothing), mAttackStrength(0.f), mMovementFlags(0), mDrawState (DrawState_Nothing), mAttackStrength(0.f),
mLastRestock(0,0), mGoldPool(0), mActorId(-1), mLastRestock(0,0), mGoldPool(0), mActorId(-1),
@ -147,10 +147,22 @@ namespace MWMechanics
if (value != currentValue) if (value != currentValue)
{ {
if (index != ESM::Attribute::Luck if (index == ESM::Attribute::Intelligence)
&& index != ESM::Attribute::Personality mRecalcMagicka = true;
&& index != ESM::Attribute::Speed) else if (index == ESM::Attribute::Strength ||
mRecalcDynamicStats = true; index == ESM::Attribute::Willpower ||
index == ESM::Attribute::Agility ||
index == ESM::Attribute::Endurance)
{
int strength = getAttribute(ESM::Attribute::Strength).getModified();
int willpower = getAttribute(ESM::Attribute::Willpower).getModified();
int agility = getAttribute(ESM::Attribute::Agility).getModified();
int endurance = getAttribute(ESM::Attribute::Endurance).getModified();
DynamicStat<float> fatigue = getFatigue();
float diff = (strength+willpower+agility+endurance) - fatigue.getBase();
fatigue.modify(diff);
setFatigue(fatigue);
}
} }
if(!mIsWerewolf) if(!mIsWerewolf)
@ -200,7 +212,7 @@ namespace MWMechanics
{ {
if (effects.get(ESM::MagicEffect::FortifyMaximumMagicka).getModifier() if (effects.get(ESM::MagicEffect::FortifyMaximumMagicka).getModifier()
!= mMagicEffects.get(ESM::MagicEffect::FortifyMaximumMagicka).getModifier()) != mMagicEffects.get(ESM::MagicEffect::FortifyMaximumMagicka).getModifier())
mRecalcDynamicStats = true; mRecalcMagicka = true;
mMagicEffects.setModifiers(effects); mMagicEffects.setModifiers(effects);
} }
@ -361,9 +373,9 @@ namespace MWMechanics
bool CreatureStats::needToRecalcDynamicStats() bool CreatureStats::needToRecalcDynamicStats()
{ {
if (mRecalcDynamicStats) if (mRecalcMagicka)
{ {
mRecalcDynamicStats = false; mRecalcMagicka = false;
return true; return true;
} }
return false; return false;
@ -371,7 +383,7 @@ namespace MWMechanics
void CreatureStats::setNeedRecalcDynamicStats(bool val) void CreatureStats::setNeedRecalcDynamicStats(bool val)
{ {
mRecalcDynamicStats = val; mRecalcMagicka = val;
} }
void CreatureStats::setKnockedDown(bool value) void CreatureStats::setKnockedDown(bool value)
@ -498,7 +510,7 @@ namespace MWMechanics
state.mAttackStrength = mAttackStrength; state.mAttackStrength = mAttackStrength;
state.mFallHeight = mFallHeight; // TODO: vertical velocity (move from PhysicActor to CreatureStats?) state.mFallHeight = mFallHeight; // TODO: vertical velocity (move from PhysicActor to CreatureStats?)
state.mLastHitObject = mLastHitObject; state.mLastHitObject = mLastHitObject;
state.mRecalcDynamicStats = mRecalcDynamicStats; state.mRecalcDynamicStats = mRecalcMagicka;
state.mDrawState = mDrawState; state.mDrawState = mDrawState;
state.mLevel = mLevel; state.mLevel = mLevel;
state.mActorId = mActorId; state.mActorId = mActorId;
@ -546,7 +558,7 @@ namespace MWMechanics
mAttackStrength = state.mAttackStrength; mAttackStrength = state.mAttackStrength;
mFallHeight = state.mFallHeight; mFallHeight = state.mFallHeight;
mLastHitObject = state.mLastHitObject; mLastHitObject = state.mLastHitObject;
mRecalcDynamicStats = state.mRecalcDynamicStats; mRecalcMagicka = state.mRecalcDynamicStats;
mDrawState = DrawState_(state.mDrawState); mDrawState = DrawState_(state.mDrawState);
mLevel = state.mLevel; mLevel = state.mLevel;
mActorId = state.mActorId; mActorId = state.mActorId;

View file

@ -53,8 +53,7 @@ namespace MWMechanics
std::string mLastHitObject; // The last object to hit this actor std::string mLastHitObject; // The last object to hit this actor
// Do we need to recalculate stats derived from attributes or other factors? bool mRecalcMagicka;
bool mRecalcDynamicStats;
// For merchants: the last time items were restocked and gold pool refilled. // For merchants: the last time items were restocked and gold pool refilled.
MWWorld::TimeStamp mLastRestock; MWWorld::TimeStamp mLastRestock;

View file

@ -842,6 +842,17 @@ void Animation::changeGroups(const std::string &groupname, int groups)
return; return;
} }
} }
void Animation::stopLooping(const std::string& groupname)
{
AnimStateMap::iterator stateiter = mStates.find(groupname);
if(stateiter != mStates.end())
{
stateiter->second.mLoopCount = 0;
return;
}
}
void Animation::play(const std::string &groupname, int priority, int groups, bool autodisable, float speedmult, const std::string &start, const std::string &stop, float startpoint, size_t loops) void Animation::play(const std::string &groupname, int priority, int groups, bool autodisable, float speedmult, const std::string &start, const std::string &stop, float startpoint, size_t loops)
{ {
if(!mSkelBase || mAnimSources.empty()) if(!mSkelBase || mAnimSources.empty())

View file

@ -260,6 +260,10 @@ public:
float speedmult, const std::string &start, const std::string &stop, float speedmult, const std::string &start, const std::string &stop,
float startpoint, size_t loops); float startpoint, size_t loops);
/** If the given animation group is currently playing, set its remaining loop count to '0'.
*/
void stopLooping(const std::string& groupName);
/** Adjust the speed multiplier of an already playing animation. /** Adjust the speed multiplier of an already playing animation.
*/ */
void adjustSpeedMult (const std::string& groupname, float speedmult); void adjustSpeedMult (const std::string& groupname, float speedmult);

View file

@ -55,6 +55,7 @@ void WeaponAnimation::attachArrow(MWWorld::Ptr actor)
return; return;
std::string model = ammo->getClass().getModel(*ammo); std::string model = ammo->getClass().getModel(*ammo);
assert(weapon->mSkelBase && "Need a skeleton to attach the arrow to");
mAmmunition = NifOgre::Loader::createObjects(weapon->mSkelBase, "ArrowBone", weapon->mSkelBase->getParentSceneNode(), model); mAmmunition = NifOgre::Loader::createObjects(weapon->mSkelBase, "ArrowBone", weapon->mSkelBase->getParentSceneNode(), model);
configureAddedObject(mAmmunition, *ammo, MWWorld::InventoryStore::Slot_Ammunition); configureAddedObject(mAmmunition, *ammo, MWWorld::InventoryStore::Slot_Ammunition);
} }

View file

@ -55,7 +55,7 @@ namespace MWScript
throw std::runtime_error ("animation mode out of range"); throw std::runtime_error ("animation mode out of range");
} }
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup (ptr, group, mode, 1); MWBase::Environment::get().getMechanicsManager()->playAnimationGroup (ptr, group, mode, std::numeric_limits<int>::max());
} }
}; };

View file

@ -964,6 +964,9 @@ namespace MWScript
msg << "Grid: " << cell->getCell()->getGridX() << " " << cell->getCell()->getGridY() << std::endl; msg << "Grid: " << cell->getCell()->getGridX() << " " << cell->getCell()->getGridY() << std::endl;
Ogre::Vector3 pos (ptr.getRefData().getPosition().pos); Ogre::Vector3 pos (ptr.getRefData().getPosition().pos);
msg << "Coordinates: " << pos << std::endl; msg << "Coordinates: " << pos << std::endl;
msg << "Model: " << ptr.getClass().getModel(ptr) << std::endl;
if (!ptr.getClass().getScript(ptr).empty())
msg << "Script: " << ptr.getClass().getScript(ptr) << std::endl;
} }
std::string notes = runtime.getStringLiteral (runtime[0].mInteger); std::string notes = runtime.getStringLiteral (runtime[0].mInteger);

View file

@ -278,7 +278,9 @@ namespace MWScript
MWMechanics::DynamicStat<float> stat (ptr.getClass().getCreatureStats (ptr) MWMechanics::DynamicStat<float> stat (ptr.getClass().getCreatureStats (ptr)
.getDynamic (mIndex)); .getDynamic (mIndex));
stat.setCurrent (diff + current, true); // for fatigue, a negative current value is allowed and means the actor will be knocked down
bool allowDecreaseBelowZero = (mIndex == 2);
stat.setCurrent (diff + current, allowDecreaseBelowZero);
ptr.getClass().getCreatureStats (ptr).setDynamic (mIndex, stat); ptr.getClass().getCreatureStats (ptr).setDynamic (mIndex, stat);
} }

View file

@ -62,7 +62,7 @@ void Wizard::ComponentSelectionPage::initializePage()
if (field(QLatin1String("installation.new")).toBool() == true) if (field(QLatin1String("installation.new")).toBool() == true)
{ {
morrowindItem->setFlags(morrowindItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable); morrowindItem->setFlags(morrowindItem->flags() & ~Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
morrowindItem->setData(Qt::CheckStateRole, Qt::Checked); morrowindItem->setData(Qt::CheckStateRole, Qt::Checked);
componentsList->addItem(morrowindItem); componentsList->addItem(morrowindItem);
@ -77,7 +77,7 @@ void Wizard::ComponentSelectionPage::initializePage()
if (mWizard->mInstallations[path].hasMorrowind) { if (mWizard->mInstallations[path].hasMorrowind) {
morrowindItem->setText(tr("Morrowind\t\t(installed)")); morrowindItem->setText(tr("Morrowind\t\t(installed)"));
morrowindItem->setFlags(morrowindItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable); morrowindItem->setFlags(morrowindItem->flags() & ~Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
morrowindItem->setData(Qt::CheckStateRole, Qt::Unchecked); morrowindItem->setData(Qt::CheckStateRole, Qt::Unchecked);
} else { } else {
morrowindItem->setText(tr("Morrowind")); morrowindItem->setText(tr("Morrowind"));
@ -88,7 +88,7 @@ void Wizard::ComponentSelectionPage::initializePage()
if (mWizard->mInstallations[path].hasTribunal) { if (mWizard->mInstallations[path].hasTribunal) {
tribunalItem->setText(tr("Tribunal\t\t(installed)")); tribunalItem->setText(tr("Tribunal\t\t(installed)"));
tribunalItem->setFlags(tribunalItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable); tribunalItem->setFlags(tribunalItem->flags() & ~Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
tribunalItem->setData(Qt::CheckStateRole, Qt::Unchecked); tribunalItem->setData(Qt::CheckStateRole, Qt::Unchecked);
} else { } else {
tribunalItem->setText(tr("Tribunal")); tribunalItem->setText(tr("Tribunal"));
@ -99,7 +99,7 @@ void Wizard::ComponentSelectionPage::initializePage()
if (mWizard->mInstallations[path].hasBloodmoon) { if (mWizard->mInstallations[path].hasBloodmoon) {
bloodmoonItem->setText(tr("Bloodmoon\t\t(installed)")); bloodmoonItem->setText(tr("Bloodmoon\t\t(installed)"));
bloodmoonItem->setFlags(bloodmoonItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable); bloodmoonItem->setFlags(bloodmoonItem->flags() & ~Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
bloodmoonItem->setData(Qt::CheckStateRole, Qt::Unchecked); bloodmoonItem->setData(Qt::CheckStateRole, Qt::Unchecked);
} else { } else {
bloodmoonItem->setText(tr("Bloodmoon")); bloodmoonItem->setText(tr("Bloodmoon"));

View file

@ -133,8 +133,6 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource)
mResourceName = mShape->getName(); mResourceName = mShape->getName();
mShape->mCollide = false; mShape->mCollide = false;
mBoundingBox = NULL; mBoundingBox = NULL;
mShape->mBoxTranslation = Ogre::Vector3(0,0,0);
mShape->mBoxRotation = Ogre::Quaternion::IDENTITY;
mStaticMesh = NULL; mStaticMesh = NULL;
mCompoundShape = NULL; mCompoundShape = NULL;

View file

@ -111,7 +111,7 @@ bool NIFSkeletonLoader::needSkeleton(const Nif::Node *node)
/* We need to be a little aggressive here, since some NIFs have a crap-ton /* We need to be a little aggressive here, since some NIFs have a crap-ton
* of nodes and Ogre only supports 256 bones. We will skip a skeleton if: * of nodes and Ogre only supports 256 bones. We will skip a skeleton if:
* There are no bones used for skinning, there are no keyframe controllers, there * There are no bones used for skinning, there are no keyframe controllers, there
* are no nodes named "AttachLight", and the tree consists of NiNode, * are no nodes named "AttachLight" or "ArrowBone", and the tree consists of NiNode,
* NiTriShape, and RootCollisionNode types only. * NiTriShape, and RootCollisionNode types only.
*/ */
if(node->boneTrafo) if(node->boneTrafo)
@ -126,7 +126,7 @@ bool NIFSkeletonLoader::needSkeleton(const Nif::Node *node)
} while(!(ctrl=ctrl->next).empty()); } while(!(ctrl=ctrl->next).empty());
} }
if (node->name == "AttachLight") if (node->name == "AttachLight" || node->name == "ArrowBone")
return true; return true;
if(node->recType == Nif::RC_NiNode || node->recType == Nif::RC_RootCollisionNode) if(node->recType == Nif::RC_NiNode || node->recType == Nif::RC_RootCollisionNode)

View file

@ -54,6 +54,8 @@ namespace sh
OgrePlatform::~OgrePlatform () OgrePlatform::~OgrePlatform ()
{ {
Ogre::MaterialManager::getSingleton().removeListener(this);
delete sSerializer; delete sSerializer;
} }

View file

@ -514,6 +514,7 @@ namespace Physic
assert (mRaycastingObjectMap.find(name) == mRaycastingObjectMap.end()); assert (mRaycastingObjectMap.find(name) == mRaycastingObjectMap.end());
mRaycastingObjectMap[name] = body; mRaycastingObjectMap[name] = body;
mDynamicsWorld->addRigidBody(body,CollisionType_Raycasting,CollisionType_Raycasting|CollisionType_Projectile); mDynamicsWorld->addRigidBody(body,CollisionType_Raycasting,CollisionType_Raycasting|CollisionType_Projectile);
body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_DISABLE_VISUALIZE_OBJECT);
} }
return body; return body;