mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-01 00:39:43 +00:00
Fixes issue in MW script compilation that would silently produce the wrong bytecode
Fixes issue when fetching MyGui values that were stored as RefId but fetched as String Removed some uncessary copies, fixed issues with lowercase and uneeded changes
This commit is contained in:
parent
0f3499f504
commit
42e45723b7
12 changed files with 29 additions and 31 deletions
|
@ -660,8 +660,7 @@ namespace MWBase
|
|||
virtual DetourNavigator::Navigator* getNavigator() const = 0;
|
||||
|
||||
virtual void updateActorPath(const MWWorld::ConstPtr& actor, const std::deque<osg::Vec3f>& path,
|
||||
const DetourNavigator::AgentBounds& agentBounds, const osg::Vec3f& start, const osg::Vec3f& end) const
|
||||
= 0;
|
||||
const DetourNavigator::AgentBounds& agentBounds, const osg::Vec3f& start, const osg::Vec3f& end) const = 0;
|
||||
|
||||
virtual void removeActorPath(const MWWorld::ConstPtr& actor) const = 0;
|
||||
|
||||
|
@ -670,12 +669,10 @@ namespace MWBase
|
|||
virtual DetourNavigator::AgentBounds getPathfindingAgentBounds(const MWWorld::ConstPtr& actor) const = 0;
|
||||
|
||||
virtual bool hasCollisionWithDoor(
|
||||
const MWWorld::ConstPtr& door, const osg::Vec3f& position, const osg::Vec3f& destination) const
|
||||
= 0;
|
||||
const MWWorld::ConstPtr& door, const osg::Vec3f& position, const osg::Vec3f& destination) const = 0;
|
||||
|
||||
virtual bool isAreaOccupiedByOtherActor(const osg::Vec3f& position, const float radius,
|
||||
std::span<const MWWorld::ConstPtr> ignore, std::vector<MWWorld::Ptr>* occupyingActors = nullptr) const
|
||||
= 0;
|
||||
std::span<const MWWorld::ConstPtr> ignore, std::vector<MWWorld::Ptr>* occupyingActors = nullptr) const = 0;
|
||||
|
||||
virtual void reportStats(unsigned int frameNumber, osg::Stats& stats) const = 0;
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace MWGui
|
|||
size_t count = mBirthList->getItemCount();
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
{
|
||||
if (ESM::RefId::stringRefId(*mBirthList->getItemDataAt<std::string>(i)) == birthId)
|
||||
if (*mBirthList->getItemDataAt<ESM::RefId>(i) == birthId)
|
||||
{
|
||||
mBirthList->setIndexSelected(i);
|
||||
break;
|
||||
|
@ -133,7 +133,7 @@ namespace MWGui
|
|||
if (_index == MyGUI::ITEM_NONE)
|
||||
return;
|
||||
|
||||
const ESM::RefId birthId = ESM::RefId::stringRefId(*mBirthList->getItemDataAt<std::string>(_index));
|
||||
const ESM::RefId& birthId = *mBirthList->getItemDataAt<ESM::RefId>(_index);
|
||||
if (mCurrentBirthId == birthId)
|
||||
return;
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ namespace MWGui
|
|||
size_t count = mRaceList->getItemCount();
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
{
|
||||
if (ESM::RefId::stringRefId(*mRaceList->getItemDataAt<std::string>(i)) == raceId)
|
||||
if (*mRaceList->getItemDataAt<ESM::RefId>(i) == raceId)
|
||||
{
|
||||
mRaceList->setIndexSelected(i);
|
||||
break;
|
||||
|
@ -292,7 +292,7 @@ namespace MWGui
|
|||
if (_index == MyGUI::ITEM_NONE)
|
||||
return;
|
||||
|
||||
ESM::RefId raceId = ESM::RefId::stringRefId(*mRaceList->getItemDataAt<std::string>(_index));
|
||||
ESM::RefId& raceId = *mRaceList->getItemDataAt<ESM::RefId>(_index);
|
||||
if (mCurrentRaceId == raceId)
|
||||
return;
|
||||
|
||||
|
|
|
@ -1029,7 +1029,7 @@ namespace MWMechanics
|
|||
}
|
||||
}
|
||||
|
||||
auto sound = charClass.getSoundIdFromSndGen(mPtr, soundgen);
|
||||
const auto& sound = charClass.getSoundIdFromSndGen(mPtr, soundgen);
|
||||
if (!sound.empty())
|
||||
{
|
||||
MWBase::SoundManager* sndMgr = MWBase::Environment::get().getSoundManager();
|
||||
|
@ -2043,7 +2043,7 @@ namespace MWMechanics
|
|||
if (!godmode)
|
||||
{
|
||||
// reduce fatigue
|
||||
float fatigueLoss = 0;
|
||||
float fatigueLoss = 0.f;
|
||||
static const float fFatigueRunBase = gmst.find("fFatigueRunBase")->mValue.getFloat();
|
||||
static const float fFatigueRunMult = gmst.find("fFatigueRunMult")->mValue.getFloat();
|
||||
static const float fFatigueSwimWalkBase = gmst.find("fFatigueSwimWalkBase")->mValue.getFloat();
|
||||
|
@ -2159,7 +2159,6 @@ namespace MWMechanics
|
|||
if (mPtr.getClass().isNpc())
|
||||
{
|
||||
std::string_view sound;
|
||||
|
||||
osg::Vec3f pos(mPtr.getRefData().getPosition().asVec3());
|
||||
if (world->isUnderwater(mPtr.getCell(), pos) || world->isWalkingOnWater(mPtr))
|
||||
sound = "DefaultLandWater";
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace MWMechanics
|
|||
if (creature)
|
||||
allLevels = levItem->mFlags & ESM::CreatureLevList::AllLevels;
|
||||
|
||||
std::pair<int, const ESM::RefId*> highest = { -1, {} };
|
||||
std::pair<int, const ESM::RefId*> highest = { -1, nullptr };
|
||||
for (const auto& levelledItem : items)
|
||||
{
|
||||
if (playerLevel >= levelledItem.mLevel && (allLevels || levelledItem.mLevel == highestLevel))
|
||||
|
|
|
@ -524,7 +524,7 @@ namespace MWMechanics
|
|||
|
||||
float reaction = 0;
|
||||
int rank = 0;
|
||||
ESM::RefId npcFaction = ptr.getClass().getPrimaryFaction(ptr);
|
||||
const ESM::RefId& npcFaction = ptr.getClass().getPrimaryFaction(ptr);
|
||||
|
||||
if (playerStats.getFactionRanks().find(npcFaction) != playerStats.getFactionRanks().end())
|
||||
{
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace MWRender
|
|||
ESM::WeaponType::Class weapclass = MWMechanics::getWeaponType(type)->mWeaponClass;
|
||||
if (weapclass == ESM::WeaponType::Thrown)
|
||||
{
|
||||
auto soundid = weaponSlot->getClass().getUpSoundId(*weaponSlot);
|
||||
const auto& soundid = weaponSlot->getClass().getUpSoundId(*weaponSlot);
|
||||
if (!soundid.empty())
|
||||
{
|
||||
MWBase::SoundManager* sndMgr = MWBase::Environment::get().getSoundManager();
|
||||
|
|
|
@ -485,7 +485,7 @@ void MWWorld::ContainerStore::updateRechargingItems()
|
|||
mRechargingItems.clear();
|
||||
for (ContainerStoreIterator it = begin(); it != end(); ++it)
|
||||
{
|
||||
auto enchantmentId = it->getClass().getEnchantment(*it);
|
||||
const auto& enchantmentId = it->getClass().getEnchantment(*it);
|
||||
if (!enchantmentId.empty())
|
||||
{
|
||||
const ESM::Enchantment* enchantment
|
||||
|
|
|
@ -62,10 +62,11 @@ MWWorld::CellStore* MWWorld::WorldModel::getCellStore(const ESM::Cell* cell)
|
|||
{
|
||||
if (cell->mData.mFlags & ESM::Cell::Interior)
|
||||
{
|
||||
auto result = mInteriors.find(cell->mName);
|
||||
std::string lowerName(Misc::StringUtils::lowerCase(cell->mName));
|
||||
auto result = mInteriors.find(lowerName);
|
||||
|
||||
if (result == mInteriors.end())
|
||||
result = mInteriors.emplace(std::move(cell->mName), CellStore(cell, mStore, mReaders)).first;
|
||||
result = mInteriors.emplace(std::move(lowerName), CellStore(cell, mStore, mReaders)).first;
|
||||
|
||||
return &result->second;
|
||||
}
|
||||
|
@ -171,13 +172,14 @@ MWWorld::CellStore* MWWorld::WorldModel::getExterior(int x, int y)
|
|||
|
||||
MWWorld::CellStore* MWWorld::WorldModel::getInterior(std::string_view name)
|
||||
{
|
||||
auto result = mInteriors.find(std::string(name));
|
||||
std::string lowerName = Misc::StringUtils::lowerCase(name);
|
||||
auto result = mInteriors.find(lowerName);
|
||||
|
||||
if (result == mInteriors.end())
|
||||
{
|
||||
const ESM::Cell* cell = mStore.get<ESM::Cell>().find(ESM::RefId::stringRefId(name));
|
||||
|
||||
result = mInteriors.emplace(std::move(name), CellStore(cell, mStore, mReaders)).first;
|
||||
result = mInteriors.emplace(lowerName, CellStore(cell, mStore, mReaders)).first;
|
||||
}
|
||||
|
||||
if (result->second.getState() != CellStore::State_Loaded)
|
||||
|
|
|
@ -205,7 +205,7 @@ namespace Compiler
|
|||
mMemberOp = false;
|
||||
|
||||
std::string name2 = Misc::StringUtils::lowerCase(name);
|
||||
auto id = ESM::RefId::stringRefId(mExplicit);
|
||||
auto id = ESM::RefId::stringRefId(Misc::StringUtils::lowerCase(mExplicit));
|
||||
|
||||
std::pair<char, bool> type = getContext().getMemberType(name2, id);
|
||||
|
||||
|
@ -303,29 +303,31 @@ namespace Compiler
|
|||
{
|
||||
start();
|
||||
|
||||
char type = mLocals.getType(name);
|
||||
std::string name2 = Misc::StringUtils::lowerCase(name);
|
||||
|
||||
char type = mLocals.getType(name2);
|
||||
|
||||
if (type != ' ')
|
||||
{
|
||||
Generator::fetchLocal(mCode, type, mLocals.getIndex(name));
|
||||
Generator::fetchLocal(mCode, type, mLocals.getIndex(name2));
|
||||
mNextOperand = false;
|
||||
mOperands.push_back(type == 'f' ? 'f' : 'l');
|
||||
return true;
|
||||
}
|
||||
|
||||
type = getContext().getGlobalType(name);
|
||||
type = getContext().getGlobalType(name2);
|
||||
|
||||
if (type != ' ')
|
||||
{
|
||||
Generator::fetchGlobal(mCode, mLiterals, type, name);
|
||||
Generator::fetchGlobal(mCode, mLiterals, type, name2);
|
||||
mNextOperand = false;
|
||||
mOperands.push_back(type == 'f' ? 'f' : 'l');
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mExplicit.empty() && getContext().isId(ESM::RefId::stringRefId(name)))
|
||||
if (mExplicit.empty() && getContext().isId(ESM::RefId::stringRefId(name2)))
|
||||
{
|
||||
mExplicit = name;
|
||||
mExplicit = name2;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -333,7 +335,7 @@ namespace Compiler
|
|||
// Convert the string to a number even if it's impossible and use it as a number literal.
|
||||
// Can't use stof/atof or to_string out of locale concerns.
|
||||
float number;
|
||||
std::stringstream stream(name);
|
||||
std::stringstream stream(name2);
|
||||
stream >> number;
|
||||
stream.str(std::string());
|
||||
stream.clear();
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <sstream>
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
|
||||
#include "tokenloc.hpp"
|
||||
|
||||
|
|
|
@ -214,7 +214,6 @@ namespace Interpreter
|
|||
if (globals.empty())
|
||||
{
|
||||
globals = context.getGlobals();
|
||||
;
|
||||
sort(globals.begin(), globals.end(), longerStr);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue