1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 12:32:36 +00:00

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

570 lines
16 KiB
C++
Raw Normal View History

#include "class.hpp"
#include <stdexcept>
#include <components/esm/defs.hpp>
#include <components/esm3/loadench.hpp>
#include <components/esm3/loadmgef.hpp>
#include <components/esm3/loadsoun.hpp>
#include <components/misc/resourcehelpers.hpp>
2013-08-08 22:34:53 -07:00
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
2013-08-11 00:35:19 -07:00
#include "../mwbase/world.hpp"
#include "../mwworld/esmstore.hpp"
2013-08-08 22:34:53 -07:00
#include "actiontake.hpp"
#include "containerstore.hpp"
2013-08-08 22:34:53 -07:00
#include "failedaction.hpp"
#include "inventorystore.hpp"
2010-08-03 18:20:15 +02:00
#include "nullaction.hpp"
#include "ptr.hpp"
#include "worldmodel.hpp"
#include "../mwgui/tooltips.hpp"
2013-08-08 22:34:53 -07:00
#include "../mwmechanics/npcstats.hpp"
namespace MWWorld
{
2022-04-04 02:44:53 +02:00
std::map<unsigned, Class*>& Class::getClasses()
{
static std::map<unsigned, Class*> values;
return values;
}
void Class::insertObjectRendering(
const Ptr& ptr, const std::string& mesh, MWRender::RenderingInterface& renderingInterface) const
{
}
2012-04-08 19:44:11 +02:00
void Class::insertObject(
const Ptr& ptr, const std::string& mesh, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const
2012-04-08 19:44:11 +02:00
{
}
void Class::insertObjectPhysics(
const Ptr& ptr, const std::string& mesh, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const
{
}
2022-05-12 17:29:12 +02:00
bool Class::consume(const MWWorld::Ptr& consumable, const MWWorld::Ptr& actor) const
{
return false;
}
void Class::skillUsageSucceeded(const MWWorld::Ptr& ptr, ESM::RefId skill, int usageType, float extraFactor) const
{
throw std::runtime_error("class does not represent an actor");
}
2015-12-18 15:58:23 +01:00
bool Class::canSell(const MWWorld::ConstPtr& item, int npcServices) const
{
return false;
}
2015-12-18 16:44:35 +01:00
int Class::getServices(const ConstPtr& actor) const
2013-05-11 18:38:27 +02:00
{
throw std::runtime_error("class does not have services");
}
MWMechanics::CreatureStats& Class::getCreatureStats(const Ptr& ptr) const
{
throw std::runtime_error("class does not have creature stats");
}
2010-08-19 12:49:13 +02:00
MWMechanics::NpcStats& Class::getNpcStats(const Ptr& ptr) const
{
throw std::runtime_error("class does not have NPC stats");
}
bool Class::hasItemHealth(const ConstPtr& ptr) const
2010-08-03 14:14:04 +02:00
{
return false;
}
int Class::getItemHealth(const ConstPtr& ptr) const
{
if (ptr.getCellRef().getCharge() == -1)
return getItemMaxHealth(ptr);
else
return ptr.getCellRef().getCharge();
}
float Class::getItemNormalizedHealth(const ConstPtr& ptr) const
{
if (getItemMaxHealth(ptr) == 0)
{
return 0.f;
}
else
{
return getItemHealth(ptr) / static_cast<float>(getItemMaxHealth(ptr));
}
}
int Class::getItemMaxHealth(const ConstPtr& ptr) const
2010-08-03 14:14:04 +02:00
{
throw std::runtime_error("class does not have item health");
}
bool Class::evaluateHit(const Ptr& ptr, Ptr& victim, osg::Vec3f& hitPosition) const
{
throw std::runtime_error("class cannot hit");
}
void Class::hit(const Ptr& ptr, float attackStrength, int type, const Ptr& victim, const osg::Vec3f& hitPosition,
bool success) const
2013-07-24 02:51:42 -07:00
{
throw std::runtime_error("class cannot hit");
2013-07-24 02:51:42 -07:00
}
2016-09-13 00:49:31 +09:00
void Class::onHit(const Ptr& ptr, float damage, bool ishealth, const Ptr& object, const Ptr& attacker,
const osg::Vec3f& hitPosition, bool successful, const MWMechanics::DamageSourceType sourceType) const
{
throw std::runtime_error("class cannot be hit");
}
std::unique_ptr<Action> Class::activate(const Ptr& ptr, const Ptr& actor) const
2010-08-03 18:20:15 +02:00
{
2022-05-29 13:24:48 +02:00
return std::make_unique<NullAction>();
2010-08-03 18:20:15 +02:00
}
std::unique_ptr<Action> Class::use(const Ptr& ptr, bool force) const
2010-08-03 18:20:15 +02:00
{
2022-05-29 13:24:48 +02:00
return std::make_unique<NullAction>();
2010-08-03 18:20:15 +02:00
}
ContainerStore& Class::getContainerStore(const Ptr& ptr) const
2010-08-04 14:37:23 +02:00
{
throw std::runtime_error("class does not have a container store");
}
InventoryStore& Class::getInventoryStore(const Ptr& ptr) const
{
throw std::runtime_error("class does not have an inventory store");
}
bool Class::hasInventoryStore(const ConstPtr& ptr) const
{
return false;
}
2015-12-18 16:50:32 +01:00
bool Class::canLock(const ConstPtr& ptr) const
{
2019-09-11 22:05:24 +02:00
return false;
}
void Class::setRemainingUsageTime(const Ptr& ptr, float duration) const
{
2013-10-16 15:14:35 -04:00
throw std::runtime_error("class does not support time-based uses");
}
float Class::getRemainingUsageTime(const ConstPtr& ptr) const
{
2013-12-16 13:31:03 +01:00
return -1;
}
ESM::RefId Class::getScript(const ConstPtr& ptr) const
{
return ESM::RefId();
2010-08-04 14:37:23 +02:00
}
float Class::getMaxSpeed(const Ptr& ptr) const
{
return 0;
}
2022-09-22 21:26:05 +03:00
float Class::getCurrentSpeed(const Ptr& ptr) const
2011-01-18 10:45:29 +01:00
{
return 0;
}
float Class::getJump(const Ptr& ptr) const
{
return 0;
}
int Class::getEnchantmentPoints(const MWWorld::ConstPtr& ptr) const
2013-03-16 19:00:14 +01:00
{
throw std::runtime_error("class does not support enchanting");
}
MWMechanics::Movement& Class::getMovementSettings(const Ptr& ptr) const
{
throw std::runtime_error("movement settings not supported by class");
}
2015-06-03 19:41:19 +02:00
osg::Vec3f Class::getRotationVector(const Ptr& ptr) const
{
2015-06-03 19:41:19 +02:00
return osg::Vec3f(0, 0, 0);
}
std::pair<std::vector<int>, bool> Class::getEquipmentSlots(const ConstPtr& ptr) const
{
return std::make_pair(std::vector<int>(), false);
}
2023-06-06 17:24:22 +02:00
ESM::RefId Class::getEquipmentSkill(const ConstPtr& ptr) const
{
2023-06-06 17:24:22 +02:00
return {};
}
int Class::getValue(const ConstPtr& ptr) const
{
throw std::logic_error("value not supported by this class");
}
2012-05-15 22:31:52 +02:00
float Class::getCapacity(const MWWorld::Ptr& ptr) const
2012-05-15 21:17:00 +02:00
{
2012-05-15 21:34:00 +02:00
throw std::runtime_error("capacity not supported by this class");
}
2015-12-18 16:00:50 +01:00
float Class::getWeight(const ConstPtr& ptr) const
2013-05-11 18:38:27 +02:00
{
throw std::runtime_error("weight not supported by this class");
}
2012-05-15 21:34:00 +02:00
float Class::getEncumbrance(const MWWorld::Ptr& ptr) const
{
throw std::runtime_error("encumbrance not supported by class");
2012-05-15 21:17:00 +02:00
}
2015-12-18 16:39:35 +01:00
bool Class::isEssential(const MWWorld::ConstPtr& ptr) const
2012-10-27 13:33:54 +02:00
{
return false;
}
2013-03-17 22:29:12 +01:00
float Class::getArmorRating(const MWWorld::Ptr& ptr) const
{
throw std::runtime_error("Class does not support armor rating");
}
const Class& Class::get(unsigned int key)
{
2022-04-04 02:44:53 +02:00
const auto& classes = getClasses();
auto iter = classes.find(key);
2022-04-04 02:44:53 +02:00
if (iter == classes.end())
throw std::logic_error("Class::get(): unknown class key: " + std::to_string(key));
return *iter->second;
}
2015-12-18 16:41:37 +01:00
bool Class::isPersistent(const ConstPtr& ptr) const
2013-05-16 18:50:26 +02:00
{
throw std::runtime_error("class does not support persistence");
}
2022-04-04 02:44:53 +02:00
void Class::registerClass(Class& instance)
{
2022-04-04 02:44:53 +02:00
getClasses().emplace(instance.getType(), &instance);
}
2012-03-13 18:05:38 +02:00
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
const ESM::RefId& Class::getUpSoundId(const ConstPtr& ptr) const
2012-03-13 18:05:38 +02:00
{
throw std::runtime_error("class does not have an up sound");
}
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
const ESM::RefId& Class::getDownSoundId(const ConstPtr& ptr) const
2012-03-13 18:05:38 +02:00
{
throw std::runtime_error("class does not have an down sound");
}
ESM::RefId Class::getSoundIdFromSndGen(const Ptr& ptr, std::string_view type) const
2013-07-17 23:58:21 -07:00
{
throw std::runtime_error("class does not support soundgen look up");
}
2022-08-22 16:55:53 +02:00
const std::string& Class::getInventoryIcon(const MWWorld::ConstPtr& ptr) const
{
throw std::runtime_error("class does not have any inventory icon");
}
2015-12-19 16:29:07 +01:00
MWGui::ToolTipInfo Class::getToolTipInfo(const ConstPtr& ptr, int count) const
{
throw std::runtime_error("class does not have a tool tip");
}
bool Class::showsInInventory(const ConstPtr& ptr) const
{
// NOTE: Don't show WerewolfRobe objects in the inventory, or allow them to be taken.
// Vanilla likely uses a hack like this since there's no other way to prevent it from
// being shown or taken.
return (ptr.getCellRef().getRefId() != "werewolfrobe");
}
2015-12-19 16:13:00 +01:00
bool Class::hasToolTip(const ConstPtr& ptr) const
{
return true;
}
2012-05-12 16:17:03 +02:00
ESM::RefId Class::getEnchantment(const ConstPtr& ptr) const
2012-05-12 16:17:03 +02:00
{
return ESM::RefId();
2012-05-12 16:17:03 +02:00
}
2012-05-21 10:58:04 +02:00
2015-12-18 16:46:02 +01:00
void Class::adjustScale(const MWWorld::ConstPtr& ptr, osg::Vec3f& scale, bool rendering) const {}
2012-05-21 10:58:04 +02:00
std::string_view Class::getModel(const MWWorld::ConstPtr& ptr) const
{
2022-08-11 22:51:55 +02:00
return {};
}
std::string Class::getCorrectedModel(const MWWorld::ConstPtr& ptr) const
{
std::string_view model = getModel(ptr);
if (!model.empty())
return Misc::ResourceHelpers::correctMeshPath(model);
return {};
}
bool Class::useAnim() const
{
return false;
}
void Class::getModelsToPreload(const ConstPtr& ptr, std::vector<std::string_view>& models) const
{
std::string_view model = getModel(ptr);
if (!model.empty())
models.push_back(model);
}
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
const ESM::RefId& Class::applyEnchantment(
const MWWorld::ConstPtr& ptr, const ESM::RefId& enchId, int enchCharge, const std::string& newName) const
2013-03-28 17:41:00 +01:00
{
throw std::runtime_error("class can't be enchanted");
}
std::pair<int, std::string_view> Class::canBeEquipped(const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const
2013-04-05 15:42:05 +02:00
{
return { 1, {} };
2013-04-05 15:42:05 +02:00
}
void Class::adjustPosition(const MWWorld::Ptr& ptr, bool force) const {}
std::unique_ptr<Action> Class::defaultItemActivate(const Ptr& ptr, const Ptr& actor) const
2013-08-08 22:34:53 -07:00
{
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
2022-05-29 13:24:48 +02:00
return std::make_unique<NullAction>();
2013-08-08 22:34:53 -07:00
if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
2013-08-08 22:34:53 -07:00
{
2023-04-20 21:07:53 +02:00
const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom("WolfItem", prng);
2013-08-11 00:35:19 -07:00
2022-05-29 13:24:48 +02:00
std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::FailedAction>("#{sWerewolfRefusal}");
2013-08-11 00:35:19 -07:00
if (sound)
action->setSound(sound->mId);
2013-08-08 22:34:53 -07:00
return action;
}
2022-05-29 13:24:48 +02:00
std::unique_ptr<MWWorld::Action> action = std::make_unique<ActionTake>(ptr);
2013-08-08 22:34:53 -07:00
action->setSound(getUpSoundId(ptr));
return action;
}
2015-12-18 16:24:24 +01:00
MWWorld::Ptr Class::copyToCellImpl(const ConstPtr& ptr, CellStore& cell) const
{
2015-12-18 16:24:24 +01:00
throw std::runtime_error("unable to copy class to cell");
}
MWWorld::Ptr Class::copyToCell(const ConstPtr& ptr, CellStore& cell, int count) const
{
Ptr newPtr = copyToCellImpl(ptr, cell);
newPtr.getCellRef().unsetRefNum(); // This RefNum is only valid within the original cell of the reference
2023-12-31 17:12:46 +00:00
newPtr.getCellRef().setCount(count);
newPtr.getRefData().setLuaScripts(nullptr);
MWBase::Environment::get().getWorldModel()->registerPtr(newPtr);
return newPtr;
}
MWWorld::Ptr Class::moveToCell(const Ptr& ptr, CellStore& cell) const
{
Ptr newPtr = copyToCellImpl(ptr, cell);
ptr.getRefData().setLuaScripts(nullptr);
MWBase::Environment::get().getWorldModel()->registerPtr(newPtr);
return newPtr;
}
Ptr Class::moveToCell(const Ptr& ptr, CellStore& cell, const ESM::Position& pos) const
2023-07-17 17:06:28 +02:00
{
Ptr newPtr = moveToCell(ptr, cell);
newPtr.getRefData().setPosition(pos);
newPtr.getCellRef().setPosition(pos);
return newPtr;
}
MWWorld::Ptr Class::copyToCell(const ConstPtr& ptr, CellStore& cell, const ESM::Position& pos, int count) const
{
Ptr newPtr = copyToCell(ptr, cell, count);
newPtr.getRefData().setPosition(pos);
2023-07-17 17:06:28 +02:00
newPtr.getCellRef().setPosition(pos);
return newPtr;
}
2015-12-18 16:15:40 +01:00
bool Class::isBipedal(const ConstPtr& ptr) const
{
return false;
}
bool Class::canFly(const ConstPtr& ptr) const
{
return false;
}
bool Class::canSwim(const ConstPtr& ptr) const
{
return false;
}
bool Class::canWalk(const ConstPtr& ptr) const
{
return false;
}
bool Class::isPureWaterCreature(const ConstPtr& ptr) const
{
2016-11-16 20:15:25 +01:00
return canSwim(ptr) && !isBipedal(ptr) && !canFly(ptr) && !canWalk(ptr);
}
bool Class::isPureFlyingCreature(const ConstPtr& ptr) const
2016-11-16 20:15:25 +01:00
{
return canFly(ptr) && !isBipedal(ptr) && !canSwim(ptr) && !canWalk(ptr);
}
bool Class::isPureLandCreature(const Ptr& ptr) const
{
return canWalk(ptr) && !isBipedal(ptr) && !canFly(ptr) && !canSwim(ptr);
}
bool Class::isMobile(const MWWorld::Ptr& ptr) const
{
return canSwim(ptr) || canWalk(ptr) || canFly(ptr);
}
2023-06-05 21:21:30 +02:00
float Class::getSkill(const MWWorld::Ptr& ptr, ESM::RefId id) const
{
throw std::runtime_error("class does not support skills");
}
2015-12-18 16:38:14 +01:00
int Class::getBloodTexture(const MWWorld::ConstPtr& ptr) const
2014-01-17 10:52:44 +01:00
{
throw std::runtime_error("class does not support gore");
}
void Class::readAdditionalState(const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const {}
void Class::writeAdditionalState(const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) const {}
2015-12-18 16:28:20 +01:00
int Class::getBaseGold(const MWWorld::ConstPtr& ptr) const
{
throw std::runtime_error("class does not support base gold");
}
2014-04-01 14:15:55 -04:00
bool Class::isClass(const MWWorld::ConstPtr& ptr, std::string_view className) const
2014-04-01 14:15:55 -04:00
{
return false;
}
2019-08-25 15:20:14 +02:00
MWWorld::DoorState Class::getDoorState(const MWWorld::ConstPtr& ptr) const
{
throw std::runtime_error("this is not a door");
}
2019-08-25 15:20:14 +02:00
void Class::setDoorState(const MWWorld::Ptr& ptr, MWWorld::DoorState state) const
{
throw std::runtime_error("this is not a door");
}
float Class::getNormalizedEncumbrance(const Ptr& ptr) const
{
float capacity = getCapacity(ptr);
2018-05-12 20:50:18 +03:00
float encumbrance = getEncumbrance(ptr);
if (encumbrance == 0)
return 0.f;
if (capacity == 0)
return 1.f;
2018-05-12 20:50:18 +03:00
return encumbrance / capacity;
}
ESM::RefId Class::getSound(const MWWorld::ConstPtr&) const
{
return ESM::RefId();
}
int Class::getBaseFightRating(const ConstPtr& ptr) const
{
throw std::runtime_error("class does not support fight rating");
}
2015-01-27 17:32:21 +01:00
ESM::RefId Class::getPrimaryFaction(const MWWorld::ConstPtr& ptr) const
2015-01-27 17:32:21 +01:00
{
return ESM::RefId();
2015-01-27 17:32:21 +01:00
}
int Class::getPrimaryFactionRank(const MWWorld::ConstPtr& ptr) const
2015-01-27 17:32:21 +01:00
{
return -1;
}
float Class::getEffectiveArmorRating(const ConstPtr& armor, const Ptr& actor) const
{
throw std::runtime_error("class does not support armor ratings");
}
osg::Vec4f Class::getEnchantmentColor(const MWWorld::ConstPtr& item) const
{
osg::Vec4f result(1, 1, 1, 1);
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
const ESM::RefId& enchantmentName = item.getClass().getEnchantment(item);
if (enchantmentName.empty())
return result;
const ESM::Enchantment* enchantment
2023-04-20 21:07:53 +02:00
= MWBase::Environment::get().getESMStore()->get<ESM::Enchantment>().search(enchantmentName);
if (!enchantment || enchantment->mEffects.mList.empty())
return result;
2023-04-20 21:07:53 +02:00
const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().search(
enchantment->mEffects.mList.front().mData.mEffectID);
if (!magicEffect)
return result;
result.x() = magicEffect->mData.mRed / 255.f;
result.y() = magicEffect->mData.mGreen / 255.f;
result.z() = magicEffect->mData.mBlue / 255.f;
return result;
}
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
void Class::setBaseAISetting(const ESM::RefId&, MWMechanics::AiSetting setting, int value) const
{
throw std::runtime_error("class does not have creature stats");
}
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
void Class::modifyBaseInventory(const ESM::RefId& actorId, const ESM::RefId& itemId, int amount) const
{
throw std::runtime_error("class does not have an inventory store");
}
float Class::getWalkSpeed(const Ptr& /*ptr*/) const
{
return 0;
}
float Class::getRunSpeed(const Ptr& /*ptr*/) const
{
return 0;
}
float Class::getSwimSpeed(const Ptr& /*ptr*/) const
{
return 0;
}
}