1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-26 12:41:34 +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:
Ragora 2014-09-11 19:33:45 -04:00
parent d64be1c092
commit ee6298f520
5 changed files with 51 additions and 2 deletions

View file

@ -220,6 +220,9 @@ namespace MWBase
virtual int getMonth() const = 0; virtual int getMonth() const = 0;
virtual int getYear() 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; virtual std::string getMonthName (int month = -1) const = 0;
///< Return name of month (-1: current month) ///< Return name of month (-1: current month)

View file

@ -2,6 +2,10 @@
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp" #include "../mwworld/containerstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
namespace MWGui namespace MWGui
{ {
@ -15,6 +19,9 @@ namespace MWGui
{ {
if (base.getClass().getEnchantment(base) != "") if (base.getClass().getEnchantment(base) != "")
mFlags |= Flag_Enchanted; mFlags |= Flag_Enchanted;
if (MWBase::Environment::get().getWorld()->isBoundItemID(base.getCellRef().getRefId()))
mFlags |= Flag_Bound;
} }
ItemStack::ItemStack() ItemStack::ItemStack()

View file

@ -26,7 +26,8 @@ namespace MWGui
enum Flags enum Flags
{ {
Flag_Enchanted = (1<<0) Flag_Enchanted = (1<<0),
Flag_Bound = (1<<1)
}; };
int mFlags; int mFlags;

View file

@ -191,6 +191,29 @@ namespace MWWorld
mGlobalVariables.fill (mStore); mGlobalVariables.fill (mStore);
mWorldScene = new Scene(*mRendering, mPhysics); 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 &currentSetting = *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) void World::startNewGame (bool bypass)
@ -879,6 +902,16 @@ namespace MWWorld
return mGlobalVariables["timescale"].getFloat(); 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) void World::changeToInteriorCell (const std::string& cellName, const ESM::Position& position)
{ {
mPhysics->clearQueuedMovement(); mPhysics->clearQueuedMovement();

View file

@ -99,6 +99,8 @@ namespace MWWorld
std::string mStartCell; std::string mStartCell;
std::map<std::string, bool> mBoundID;
void updateWeather(float duration); void updateWeather(float duration);
int getDaysPerMonth (int month) const; int getDaysPerMonth (int month) const;
@ -308,6 +310,9 @@ namespace MWWorld
virtual float getTimeScaleFactor() const; 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, virtual void changeToInteriorCell (const std::string& cellName,
const ESM::Position& position); const ESM::Position& position);
///< Move to interior cell. ///< Move to interior cell.