From 8f7da49152deeda0f2b0e25dd9e6ffe9885e0f4f Mon Sep 17 00:00:00 2001 From: Koncord Date: Tue, 27 Jun 2017 22:25:29 +0800 Subject: [PATCH] [Client] Update DedicatedPlayer to C++11 --- apps/openmw/mwmp/DedicatedPlayer.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/apps/openmw/mwmp/DedicatedPlayer.cpp b/apps/openmw/mwmp/DedicatedPlayer.cpp index 30e8ad26e..9b40f9722 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.cpp +++ b/apps/openmw/mwmp/DedicatedPlayer.cpp @@ -101,22 +101,20 @@ void DedicatedPlayer::move(float dt) const int maxInterpolationDistance = 40; // Apply interpolation only if the position hasn't changed too much from last time - bool shouldInterpolate = abs(position.pos[0] - refPos.pos[0]) < maxInterpolationDistance && abs(position.pos[1] - refPos.pos[1]) < maxInterpolationDistance && abs(position.pos[2] - refPos.pos[2]) < maxInterpolationDistance; + bool shouldInterpolate = + abs(position.pos[0] - refPos.pos[0]) < maxInterpolationDistance && + abs(position.pos[1] - refPos.pos[1]) < maxInterpolationDistance && + abs(position.pos[2] - refPos.pos[2]) < maxInterpolationDistance; if (shouldInterpolate) { static const int timeMultiplier = 15; osg::Vec3f lerp = MechanicsHelper::getLinearInterpolation(refPos.asVec3(), position.asVec3(), dt * timeMultiplier); - refPos.pos[0] = lerp.x(); - refPos.pos[1] = lerp.y(); - refPos.pos[2] = lerp.z(); - world->moveObject(ptr, refPos.pos[0], refPos.pos[1], refPos.pos[2]); + world->moveObject(ptr, lerp.x(), lerp.y(), lerp.z()); } else - { world->moveObject(ptr, position.pos[0], position.pos[1], position.pos[2]); - } float oldZ = ptr.getRefData().getPosition().rot[2]; world->rotateObject(ptr, position.rot[0], 0, oldZ); @@ -137,9 +135,7 @@ void DedicatedPlayer::setAnimFlags() // Until we figure out a better workaround for disabling player gravity, // simply cast Levitate over and over on a player that's supposed to be flying if (!isFlying) - { ptr.getClass().getCreatureStats(ptr).getActiveSpells().purgeEffect(ESM::MagicEffect::Levitate); - } else if (isFlying && !world->isFlying(ptr)) { MWMechanics::CastSpell cast(ptr, ptr); @@ -190,12 +186,12 @@ void DedicatedPlayer::setEquipment() const int count = equipedItems[slot].count; ptr.getClass().getContainerStore(ptr).add(dedicItem, count, ptr); - for (MWWorld::ContainerStoreIterator it2 = invStore.begin(); it2 != invStore.end(); ++it2) + for (const auto &ptr : invStore) { - if (::Misc::StringUtils::ciEqual(it2->getCellRef().getRefId(), dedicItem)) // equip item + if (::Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), dedicItem)) // equip item { - std::shared_ptr action = it2->getClass().use(*it2); - action->execute(ptr); + std::shared_ptr action = ptr.getClass().use(ptr); + action->execute(this->ptr); break; } }