mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-01 10:15:38 +00:00
Added Flag_Bound flag for ItemStack to check against but the system behind it is probably not the best
This commit is contained in:
parent
d64be1c092
commit
ee6298f520
5 changed files with 51 additions and 2 deletions
|
@ -220,6 +220,9 @@ namespace MWBase
|
|||
virtual int getMonth() const = 0;
|
||||
virtual int getYear() const = 0;
|
||||
|
||||
virtual bool isBoundItemID(const std::string &id) = 0;
|
||||
/// \return Returns whether or not the id refers to a bound item.
|
||||
|
||||
virtual std::string getMonthName (int month = -1) const = 0;
|
||||
///< Return name of month (-1: current month)
|
||||
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/containerstore.hpp"
|
||||
#include "../mwworld/esmstore.hpp"
|
||||
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
@ -15,6 +19,9 @@ namespace MWGui
|
|||
{
|
||||
if (base.getClass().getEnchantment(base) != "")
|
||||
mFlags |= Flag_Enchanted;
|
||||
|
||||
if (MWBase::Environment::get().getWorld()->isBoundItemID(base.getCellRef().getRefId()))
|
||||
mFlags |= Flag_Bound;
|
||||
}
|
||||
|
||||
ItemStack::ItemStack()
|
||||
|
|
|
@ -26,7 +26,8 @@ namespace MWGui
|
|||
|
||||
enum Flags
|
||||
{
|
||||
Flag_Enchanted = (1<<0)
|
||||
Flag_Enchanted = (1<<0),
|
||||
Flag_Bound = (1<<1)
|
||||
};
|
||||
int mFlags;
|
||||
|
||||
|
|
|
@ -191,6 +191,29 @@ namespace MWWorld
|
|||
mGlobalVariables.fill (mStore);
|
||||
|
||||
mWorldScene = new Scene(*mRendering, mPhysics);
|
||||
|
||||
// Build a list of known bound item ID's
|
||||
const MWWorld::Store<ESM::GameSetting> &gameSettings = mStore.get<ESM::GameSetting>();
|
||||
|
||||
for (MWWorld::Store<ESM::GameSetting>::iterator currentIteration = gameSettings.begin(); currentIteration != gameSettings.end(); ++currentIteration)
|
||||
{
|
||||
const ESM::GameSetting ¤tSetting = *currentIteration;
|
||||
try
|
||||
{
|
||||
std::string currentGMSTID = currentSetting.mId;
|
||||
std::transform(currentGMSTID.begin(), currentGMSTID.end(), currentGMSTID.begin(), ::tolower);
|
||||
|
||||
// Don't bother checking this GMST if it's not a sMagicBound* one.
|
||||
if (currentGMSTID.find("smagicbound") != 0)
|
||||
continue;
|
||||
|
||||
std::string currentGMSTValue = currentSetting.getString();
|
||||
std::transform(currentGMSTValue.begin(), currentGMSTValue.end(), currentGMSTValue.begin(), ::tolower);
|
||||
|
||||
mBoundID[currentGMSTValue] = true;
|
||||
}
|
||||
catch(...){}
|
||||
}
|
||||
}
|
||||
|
||||
void World::startNewGame (bool bypass)
|
||||
|
@ -879,6 +902,16 @@ namespace MWWorld
|
|||
return mGlobalVariables["timescale"].getFloat();
|
||||
}
|
||||
|
||||
bool World::isBoundItemID(const std::string &id)
|
||||
{
|
||||
std::string id_temp = id;
|
||||
std::transform(id_temp.begin(), id_temp.end(), id_temp.begin(), ::tolower);
|
||||
|
||||
if (mBoundID.count(id_temp) != 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void World::changeToInteriorCell (const std::string& cellName, const ESM::Position& position)
|
||||
{
|
||||
mPhysics->clearQueuedMovement();
|
||||
|
@ -2501,7 +2534,7 @@ namespace MWWorld
|
|||
if (!selectedSpell.empty())
|
||||
{
|
||||
const ESM::Spell* spell = getStore().get<ESM::Spell>().search(selectedSpell);
|
||||
|
||||
|
||||
// A power can be used once per 24h
|
||||
if (spell->mData.mType == ESM::Spell::ST_Power)
|
||||
stats.getSpells().usePower(spell->mId);
|
||||
|
|
|
@ -99,6 +99,8 @@ namespace MWWorld
|
|||
|
||||
std::string mStartCell;
|
||||
|
||||
std::map<std::string, bool> mBoundID;
|
||||
|
||||
void updateWeather(float duration);
|
||||
int getDaysPerMonth (int month) const;
|
||||
|
||||
|
@ -308,6 +310,9 @@ namespace MWWorld
|
|||
|
||||
virtual float getTimeScaleFactor() const;
|
||||
|
||||
virtual bool isBoundItemID(const std::string &id);
|
||||
///< \return Whether or not the specified id refers to a bound item.
|
||||
|
||||
virtual void changeToInteriorCell (const std::string& cellName,
|
||||
const ESM::Position& position);
|
||||
///< Move to interior cell.
|
||||
|
|
Loading…
Reference in a new issue