Merge remote-tracking branch 'upstream/master'

deque
mrcheko 11 years ago
commit 559c772906

@ -12,7 +12,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/)
message(STATUS "Configuring OpenMW...")
set(OPENMW_VERSION_MAJOR 0)
set(OPENMW_VERSION_MINOR 29)
set(OPENMW_VERSION_MINOR 30)
set(OPENMW_VERSION_RELEASE 0)
set(OPENMW_VERSION_COMMITHASH "")
@ -36,18 +36,8 @@ if(EXISTS ${PROJECT_SOURCE_DIR}/.git)
string(REGEX REPLACE "^openmw-[0-9]+\\.([0-9]+).*" "\\1" GIT_VERSION_MINOR "${VERSION}")
string(REGEX REPLACE "^openmw-[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" GIT_VERSION_RELEASE "${VERSION}")
set(GIT_VERSION "${GIT_VERSION_MAJOR}.${GIT_VERSION_MINOR}.${GIT_VERSION_RELEASE}")
if(NOT ${OPENMW_VERSION} STREQUAL ${GIT_VERSION})
message(FATAL_ERROR "Silly Zini forgot to update the version again...")
else(NOT ${OPENMW_VERSION} STREQUAL ${GIT_VERSION})
set(OPENMW_VERSION_MAJOR ${GIT_VERSION_MAJOR})
set(OPENMW_VERSION_MINOR ${GIT_VERSION_MINOR})
set(OPENMW_VERSION_RELEASE ${GIT_VERSION_RELEASE})
set(OPENMW_VERSION_COMMITHASH "${COMMITHASH}")
set(OPENMW_VERSION_TAGHASH "${TAGHASH}")
endif(NOT ${OPENMW_VERSION} STREQUAL ${GIT_VERSION})
set(OPENMW_VERSION_COMMITHASH "${COMMITHASH}")
set(OPENMW_VERSION_TAGHASH "${TAGHASH}")
message(STATUS "OpenMW version ${OPENMW_VERSION}")
else(MATCH)
@ -129,6 +119,7 @@ set(OENGINE_OGRE
)
set(OENGINE_GUI
${LIBDIR}/openengine/gui/loglistener.cpp
${LIBDIR}/openengine/gui/manager.cpp
${LIBDIR}/openengine/gui/layout.hpp
)
@ -234,6 +225,9 @@ endif ()
set(BOOST_COMPONENTS system filesystem program_options)
if(WIN32)
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} locale)
endif(WIN32)
IF(BOOST_STATIC)
set(Boost_USE_STATIC_LIBS ON)

@ -651,7 +651,7 @@ void Record<ESM::Dialogue>::print()
// Sadly, there are no DialInfos, because the loader dumps as it
// loads, rather than loading and then dumping. :-( Anyone mind if
// I change this?
std::vector<ESM::DialInfo>::iterator iit;
ESM::Dialogue::InfoContainer::iterator iit;
for (iit = mData.mInfo.begin(); iit != mData.mInfo.end(); iit++)
std::cout << "INFO!" << iit->mId << std::endl;
}

@ -41,11 +41,11 @@ Launcher::MainDialog::MainDialog(QWidget *parent)
// Check if the font is installed
if (!fonts.contains("EB Garamond")) {
QString font = QString::fromStdString(mCfgMgr.getGlobalDataPath().string()) + QString("resources/mygui/EBGaramond-Regular.ttf");
QString font = QString::fromUtf8(mCfgMgr.getGlobalDataPath().string().c_str()) + QString("resources/mygui/EBGaramond-Regular.ttf");
file.setFileName(font);
if (!file.exists()) {
font = QString::fromStdString(mCfgMgr.getLocalPath().string()) + QString("resources/mygui/EBGaramond-Regular.ttf");
font = QString::fromUtf8(mCfgMgr.getLocalPath().string().c_str()) + QString("resources/mygui/EBGaramond-Regular.ttf");
}
fontDatabase.addApplicationFont(font);
@ -243,7 +243,7 @@ bool Launcher::MainDialog::showFirstRunDialog()
}
// Create the file if it doesn't already exist, else the importer will fail
QString path = QString::fromStdString(mCfgMgr.getUserConfigPath().string()) + QString("openmw.cfg");
QString path = QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str()) + QString("openmw.cfg");
QFile file(path);
if (!file.exists()) {
@ -358,7 +358,7 @@ bool Launcher::MainDialog::setupLauncherSettings()
{
mLauncherSettings.setMultiValueEnabled(true);
QString userPath = QString::fromStdString(mCfgMgr.getUserConfigPath().string());
QString userPath = QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str());
QStringList paths;
paths.append(QString("launcher.cfg"));
@ -464,8 +464,8 @@ bool Launcher::expansions(Launcher::UnshieldThread& cd)
bool Launcher::MainDialog::setupGameSettings()
{
QString userPath = QString::fromStdString(mCfgMgr.getUserConfigPath().string());
QString globalPath = QString::fromStdString(mCfgMgr.getGlobalPath().string());
QString userPath = QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str());
QString globalPath = QString::fromUtf8(mCfgMgr.getGlobalPath().string().c_str());
// Load the user config file first, separately
// So we can write it properly, uncontaminated
@ -594,7 +594,7 @@ bool Launcher::MainDialog::setupGameSettings()
while(expansions(cd));
selectedFile = QString::fromStdString(cd.GetMWEsmPath());
selectedFile = QString::fromUtf8(cd.GetMWEsmPath().c_str());
}
#endif // WIN32
@ -615,8 +615,8 @@ bool Launcher::MainDialog::setupGraphicsSettings()
{
mGraphicsSettings.setMultiValueEnabled(false);
QString userPath = QString::fromStdString(mCfgMgr.getUserConfigPath().string());
QString globalPath = QString::fromStdString(mCfgMgr.getGlobalPath().string());
QString userPath = QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str());
QString globalPath = QString::fromUtf8(mCfgMgr.getGlobalPath().string().c_str());
QFile localDefault(QString("settings-default.cfg"));
QFile globalDefault(globalPath + QString("settings-default.cfg"));
@ -702,7 +702,7 @@ bool Launcher::MainDialog::writeSettings()
mGraphicsPage->saveSettings();
mDataFilesPage->saveSettings();
QString userPath = QString::fromStdString(mCfgMgr.getUserConfigPath().string());
QString userPath = QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str());
QDir dir(userPath);
if (!dir.exists()) {

@ -45,7 +45,8 @@ void Launcher::GameSettings::validatePaths()
Files::PathContainer dataDirs;
foreach (const QString &path, paths) {
dataDirs.push_back(Files::PathContainer::value_type(path.toStdString()));
QByteArray bytes = path.toUtf8();
dataDirs.push_back(Files::PathContainer::value_type(std::string(bytes.constData(), bytes.length())));
}
// Parse the data dirs to convert the tokenized paths
@ -53,7 +54,7 @@ void Launcher::GameSettings::validatePaths()
mDataDirs.clear();
for (Files::PathContainer::iterator it = dataDirs.begin(); it != dataDirs.end(); ++it) {
QString path = QString::fromStdString(it->string());
QString path = QString::fromUtf8(it->string().c_str());
path.remove(QChar('\"'));
QDir dir(path);
@ -68,12 +69,13 @@ void Launcher::GameSettings::validatePaths()
return;
dataDirs.clear();
dataDirs.push_back(Files::PathContainer::value_type(local.toStdString()));
QByteArray bytes = local.toUtf8();
dataDirs.push_back(Files::PathContainer::value_type(std::string(bytes.constData(), bytes.length())));
mCfgMgr.processPaths(dataDirs);
if (!dataDirs.empty()) {
QString path = QString::fromStdString(dataDirs.front().string());
QString path = QString::fromUtf8(dataDirs.front().string().c_str());
path.remove(QChar('\"'));
QDir dir(path);

@ -1,6 +1,6 @@
#include "unshieldthread.hpp"
#include <fstream>
#include <boost/filesystem/fstream.hpp>
#include <components/misc/stringops.hpp>
namespace bfs = boost::filesystem;
@ -49,7 +49,7 @@ namespace
std::string read_to_string(const bfs::path& path)
{
std::ifstream strstream(path.c_str(), std::ios::in | std::ios::binary);
bfs::ifstream strstream(path, std::ios::in | std::ios::binary);
std::string str;
strstream.seekg(0, std::ios::end);
@ -201,7 +201,7 @@ namespace
add_setting("Archives", "Archive 1", "Bloodmoon.bsa", ini);
}
std::ofstream inistream(ini_path.c_str());
bfs::ofstream inistream((ini_path));
inistream << ini;
inistream.close();
}

@ -1,6 +1,5 @@
#include "importer.hpp"
#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/stream.hpp>
#include <iostream>
#include <string>
#include <map>
@ -9,6 +8,10 @@
#include <sstream>
#include <components/misc/stringops.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/fstream.hpp>
namespace bfs = boost::filesystem;
MwIniImporter::MwIniImporter()
: mVerbose(false)
@ -661,7 +664,7 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(const std::string& filenam
std::string section("");
MwIniImporter::multistrmap map;
boost::iostreams::stream<boost::iostreams::file_source>file(filename.c_str());
bfs::ifstream file((bfs::path(filename)));
ToUTF8::Utf8Encoder encoder(mEncoding);
std::string line;
@ -674,6 +677,10 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(const std::string& filenam
line = line.substr(0, line.length()-1);
}
if(line.empty()) {
continue;
}
if(line[0] == '[') {
int pos = line.find(']');
if(pos < 2) {
@ -690,10 +697,6 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(const std::string& filenam
line = line.substr(0,comment_pos);
}
if(line.empty()) {
continue;
}
int pos = line.find("=");
if(pos < 1) {
continue;
@ -720,7 +723,7 @@ MwIniImporter::multistrmap MwIniImporter::loadCfgFile(const std::string& filenam
std::cout << "load cfg file: " << filename << std::endl;
MwIniImporter::multistrmap map;
boost::iostreams::stream<boost::iostreams::file_source>file(filename.c_str());
bfs::ifstream file((bfs::path(filename)));
std::string line;
while (std::getline(file, line)) {
@ -858,7 +861,7 @@ void MwIniImporter::importGameFiles(multistrmap &cfg, const multistrmap &ini) co
}
}
void MwIniImporter::writeToFile(boost::iostreams::stream<boost::iostreams::file_sink> &out, const multistrmap &cfg) {
void MwIniImporter::writeToFile(std::ostream &out, const multistrmap &cfg) {
for(multistrmap::const_iterator it=cfg.begin(); it != cfg.end(); ++it) {
for(std::vector<std::string>::const_iterator entry=it->second.begin(); entry != it->second.end(); ++entry) {

@ -1,12 +1,11 @@
#ifndef MWINIIMPORTER_IMPORTER
#define MWINIIMPORTER_IMPORTER 1
#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/stream.hpp>
#include <string>
#include <map>
#include <vector>
#include <exception>
#include <iosfwd>
#include <components/to_utf8/to_utf8.hpp>
@ -24,7 +23,7 @@ class MwIniImporter {
void mergeFallback(multistrmap &cfg, const multistrmap &ini) const;
void importGameFiles(multistrmap &cfg, const multistrmap &ini) const;
void importArchives(multistrmap &cfg, const multistrmap &ini) const;
static void writeToFile(boost::iostreams::stream<boost::iostreams::file_sink> &out, const multistrmap &cfg);
static void writeToFile(std::ostream &out, const multistrmap &cfg);
private:
static void insertMultistrmap(multistrmap &cfg, const std::string& key, const std::string& value);

@ -1,14 +1,59 @@
#include "importer.hpp"
#include <iostream>
#include <string>
#include <iostream>
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/fstream.hpp>
namespace bpo = boost::program_options;
namespace bfs = boost::filesystem;
#ifndef _WIN32
int main(int argc, char *argv[]) {
#else
// Include on Windows only
#include <boost/locale.hpp>
class utf8argv
{
public:
utf8argv(int argc, wchar_t *wargv[])
{
args.reserve(argc);
argv = new const char *[argc];
for (int i = 0; i < argc; ++i) {
args.push_back(boost::locale::conv::utf_to_utf<char>(wargv[i]));
argv[i] = args.back().c_str();
}
}
~utf8argv() { delete[] argv; }
char **get() const { return const_cast<char **>(argv); }
private:
const char **argv;
std::vector<std::string> args;
};
/* The only way to pass Unicode on Winodws with CLI is to use wide
characters interface which presents UTF-16 encoding. The rest of
OpenMW application stack assumes UTF-8 encoding, therefore this
conversion.
For boost::filesystem::path::imbue see components/files/windowspath.cpp
*/
int wmain(int argc, wchar_t *wargv[]) {
utf8argv converter(argc, wargv);
char **argv = converter.get();
boost::filesystem::path::imbue(boost::locale::generator().generate(""));
#endif
bpo::options_description desc("Syntax: mwiniimporter <options> inifile configfile\nAllowed options");
bpo::positional_options_description p_desc;
desc.add_options()
@ -94,7 +139,7 @@ int main(int argc, char *argv[]) {
}
std::cout << "write to: " << outputFile << std::endl;
boost::iostreams::stream<boost::iostreams::file_sink> file(outputFile);
bfs::ofstream file((bfs::path(outputFile)));
importer.writeToFile(file, cfg);
return 0;

@ -145,6 +145,10 @@ if(WIN32)
endif(WIN32)
set(BOOST_COMPONENTS system filesystem program_options thread wave)
if(WIN32)
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} locale)
endif(WIN32)
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork REQUIRED)

@ -27,7 +27,9 @@ void CSMDoc::OpenSaveStage::perform (int stage, Messages& messages)
{
mState.start (mDocument, mProjectFile);
mState.getStream().open ((mProjectFile ? mState.getPath() : mState.getTmpPath()).string().c_str());
mState.getStream().open (
mProjectFile ? mState.getPath() : mState.getTmpPath(),
std::ios::binary);
if (!mState.getStream().is_open())
throw std::runtime_error ("failed to open stream for saving");
@ -260,4 +262,4 @@ void CSMDoc::FinalSavingStage::perform (int stage, Messages& messages)
mDocument.getUndoStack().setClean();
}
}
}

@ -47,7 +47,7 @@ const boost::filesystem::path& CSMDoc::SavingState::getTmpPath() const
return mTmpPath;
}
std::ofstream& CSMDoc::SavingState::getStream()
boost::filesystem::ofstream& CSMDoc::SavingState::getStream()
{
return mStream;
}
@ -60,4 +60,4 @@ ESM::ESMWriter& CSMDoc::SavingState::getWriter()
bool CSMDoc::SavingState::isProjectFile() const
{
return mProjectFile;
}
}

@ -4,6 +4,7 @@
#include <fstream>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/fstream.hpp>
#include <components/esm/esmwriter.hpp>
@ -20,7 +21,7 @@ namespace CSMDoc
boost::filesystem::path mPath;
boost::filesystem::path mTmpPath;
ToUTF8::Utf8Encoder mEncoder;
std::ofstream mStream;
boost::filesystem::ofstream mStream;
ESM::ESMWriter mWriter;
boost::filesystem::path mProjectPath;
bool mProjectFile;
@ -39,7 +40,7 @@ namespace CSMDoc
const boost::filesystem::path& getTmpPath() const;
std::ofstream& getStream();
boost::filesystem::ofstream& getStream();
ESM::ESMWriter& getWriter();
@ -50,4 +51,4 @@ namespace CSMDoc
}
#endif
#endif

@ -86,8 +86,11 @@ namespace CSVRender
}
std::stringstream windowHandle;
#ifdef WIN32
windowHandle << Ogre::StringConverter::toString((unsigned long)(this->winId()));
#else
windowHandle << this->winId();
#endif
std::stringstream windowTitle;
static int count=0;
windowTitle << ++count;

@ -57,7 +57,7 @@ add_openmw_dir (mwworld
cells localscripts customdata weather inventorystore ptr actionopen actionread
actionequip timestamp actionalchemy cellstore actionapply actioneat
esmstore store recordcmp fallback actionrepair actionsoulgem livecellref actiondoor
contentloader esmloader omwloader actiontrap cellreflist
contentloader esmloader omwloader actiontrap cellreflist projectilemanager
)
add_openmw_dir (mwclass
@ -83,6 +83,10 @@ add_openmw_dir (mwbase
# Main executable
set(BOOST_COMPONENTS system filesystem program_options thread wave)
if(WIN32)
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} locale)
endif(WIN32)
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
IF(OGRE_STATIC)

@ -66,9 +66,13 @@ void OMW::Engine::executeLocalScripts()
bool OMW::Engine::frameStarted (const Ogre::FrameEvent& evt)
{
bool paused = MWBase::Environment::get().getWindowManager()->isGuiMode();
MWBase::Environment::get().getWorld()->frameStarted(evt.timeSinceLastFrame, paused);
MWBase::Environment::get().getWindowManager ()->frameStarted(evt.timeSinceLastFrame);
if (MWBase::Environment::get().getStateManager()->getState()!=
MWBase::StateManager::State_NoGame)
{
bool paused = MWBase::Environment::get().getWindowManager()->isGuiMode();
MWBase::Environment::get().getWorld()->frameStarted(evt.timeSinceLastFrame, paused);
MWBase::Environment::get().getWindowManager ()->frameStarted(evt.timeSinceLastFrame);
}
return true;
}
@ -110,8 +114,12 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
// update actors
MWBase::Environment::get().getMechanicsManager()->update(frametime,
paused);
if (MWBase::Environment::get().getStateManager()->getState()!=
MWBase::StateManager::State_NoGame)
{
MWBase::Environment::get().getMechanicsManager()->update(frametime,
paused);
}
if (MWBase::Environment::get().getStateManager()->getState()==
MWBase::StateManager::State_Running)
@ -122,16 +130,24 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
}
// update world
MWBase::Environment::get().getWorld()->update(frametime, paused);
if (MWBase::Environment::get().getStateManager()->getState()!=
MWBase::StateManager::State_NoGame)
{
MWBase::Environment::get().getWorld()->update(frametime, paused);
}
// update GUI
Ogre::RenderWindow* window = mOgre->getWindow();
unsigned int tri, batch;
MWBase::Environment::get().getWorld()->getTriangleBatchCount(tri, batch);
MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), tri, batch);
if (MWBase::Environment::get().getStateManager()->getState()!=
MWBase::StateManager::State_NoGame)
{
Ogre::RenderWindow* window = mOgre->getWindow();
unsigned int tri, batch;
MWBase::Environment::get().getWorld()->getTriangleBatchCount(tri, batch);
MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), tri, batch);
MWBase::Environment::get().getWindowManager()->onFrame(frametime);
MWBase::Environment::get().getWindowManager()->update();
MWBase::Environment::get().getWindowManager()->onFrame(frametime);
MWBase::Environment::get().getWindowManager()->update();
}
}
catch (const std::exception& e)
{
@ -220,7 +236,7 @@ void OMW::Engine::addArchive (const std::string& archive) {
// Set resource dir
void OMW::Engine::setResourceDir (const boost::filesystem::path& parResDir)
{
mResDir = boost::filesystem::system_complete(parResDir);
mResDir = parResDir;
}
// Set start cell name (only interiors for now)
@ -364,7 +380,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
// Create the world
mEnvironment.setWorld( new MWWorld::World (*mOgre, mFileCollections, mContentFiles,
mResDir, mCfgMgr.getCachePath(), mEncoder, mFallbackMap,
mActivationDistanceOverride, mCellName));
mActivationDistanceOverride, mCellName, mStartupScript));
MWBase::Environment::get().getWorld()->setupPlayer();
input->setPlayer(&mEnvironment.getWorld()->getPlayer());
@ -393,10 +409,6 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
mEnvironment.setJournal (new MWDialogue::Journal);
mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions, mVerboseScripts, mTranslationDataStorage));
mEnvironment.getWorld()->renderPlayer();
mechanics->buildPlayer();
window->updatePlayer();
mOgre->getRoot()->addFrameListener (this);
// scripts
@ -450,10 +462,9 @@ void OMW::Engine::go()
catch (...) {}
}
else
{
MWBase::Environment::get().getStateManager()->newGame (true);
if (!mStartupScript.empty())
MWBase::Environment::get().getWindowManager()->executeInConsole (mStartupScript);
}
// Start the main rendering loop
while (!mEnvironment.get().getStateManager()->hasQuitRequest())
@ -481,11 +492,11 @@ void OMW::Engine::activate()
MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr);
boost::shared_ptr<MWWorld::Action> action =
MWWorld::Class::get (ptr).activate (ptr, MWBase::Environment::get().getWorld()->getPlayerPtr());
ptr.getClass().activate (ptr, MWBase::Environment::get().getWorld()->getPlayerPtr());
interpreterContext.activate (ptr, action);
std::string script = MWWorld::Class::get (ptr).getScript (ptr);
std::string script = ptr.getClass().getScript (ptr);
MWBase::Environment::get().getWorld()->breakInvisibility(MWBase::Environment::get().getWorld()->getPlayerPtr());

@ -37,7 +37,7 @@ namespace MWBase
typedef std::deque<MWDialogue::StampedJournalEntry> TEntryContainer;
typedef TEntryContainer::const_iterator TEntryIter;
typedef std::map<std::string, MWDialogue::Quest> TQuestContainer; // topc, quest
typedef std::map<std::string, MWDialogue::Quest> TQuestContainer; // topic, quest
typedef TQuestContainer::const_iterator TQuestIter;
typedef std::map<std::string, MWDialogue::Topic> TTopicContainer; // topic-id, topic-content
typedef TTopicContainer::const_iterator TTopicIter;

@ -110,18 +110,25 @@ namespace MWBase
///< Play a sound, independently of 3D-position
///< @param offset Value from [0,1] meaning from which fraction the sound the playback starts.
virtual SoundPtr playSound3D(const MWWorld::Ptr &reference, const std::string& soundId,
float volume, float pitch, PlayType type=Play_TypeSfx,
PlayMode mode=Play_Normal, float offset=0) = 0;
///< Play a sound from an object
virtual MWBase::SoundPtr playSound3D(const MWWorld::Ptr &reference, const std::string& soundId,
float volume, float pitch, PlayType type=Play_TypeSfx,
PlayMode mode=Play_Normal, float offset=0) = 0;
///< Play a 3D sound attached to an MWWorld::Ptr. Will be updated automatically with the Ptr's position, unless Play_NoTrack is specified.
///< @param offset Value from [0,1] meaning from which fraction the sound the playback starts.
virtual MWBase::SoundPtr playManualSound3D(const Ogre::Vector3& initialPos, const std::string& soundId,
float volume, float pitch, PlayType type, PlayMode mode, float offset=0) = 0;
///< Play a 3D sound at \a initialPos. If the sound should be moving, it must be updated manually using Sound::setPosition.
virtual void stopSound3D(const MWWorld::Ptr &reference, const std::string& soundId) = 0;
///< Stop the given object from playing the given sound,
virtual void stopSound3D(const MWWorld::Ptr &reference) = 0;
///< Stop the given object from playing all sounds.
virtual void stopSound(MWBase::SoundPtr sound) = 0;
///< Stop the given sound handle
virtual void stopSound(const MWWorld::CellStore *cell) = 0;
///< Stop all sounds for the given cell.

@ -193,9 +193,9 @@ namespace MWBase
virtual void setDragDrop(bool dragDrop) = 0;
virtual bool getWorldMouseOver() = 0;
virtual void toggleFogOfWar() = 0;
virtual bool toggleFogOfWar() = 0;
virtual void toggleFullHelp() = 0;
virtual bool toggleFullHelp() = 0;
///< show extra info in item tooltips (owner, script)
virtual bool getFullHelp() const = 0;

@ -126,7 +126,7 @@ namespace MWBase
virtual void setWaterHeight(const float height) = 0;
virtual void toggleWater() = 0;
virtual bool toggleWater() = 0;
virtual void adjustSky() = 0;
@ -255,7 +255,8 @@ namespace MWBase
virtual void changeToExteriorCell (const ESM::Position& position) = 0;
///< Move to exterior cell.
virtual void changeToCell (const ESM::CellId& cellId, const ESM::Position& position) = 0;
virtual void changeToCell (const ESM::CellId& cellId, const ESM::Position& position, bool detectWorldSpaceChange=true) = 0;
///< @param detectWorldSpaceChange if true, clean up worldspace-specific data when the world space changes
virtual const ESM::Cell *getExterior (const std::string& cellName) const = 0;
///< Return a cell matching the given name or a 0-pointer, if there is no such cell.
@ -354,15 +355,14 @@ namespace MWBase
virtual void update (float duration, bool paused) = 0;
virtual bool placeObject (const MWWorld::Ptr& object, float cursorX, float cursorY, int amount) = 0;
virtual MWWorld::Ptr placeObject (const MWWorld::Ptr& object, float cursorX, float cursorY, int amount) = 0;
///< copy and place an object into the gameworld at the specified cursor position
/// @param object
/// @param cursor X (relative 0-1)
/// @param cursor Y (relative 0-1)
/// @param number of objects to place
/// @return true if the object was placed, or false if it was rejected because the position is too far away
virtual void dropObjectOnGround (const MWWorld::Ptr& actor, const MWWorld::Ptr& object, int amount) = 0;
virtual MWWorld::Ptr dropObjectOnGround (const MWWorld::Ptr& actor, const MWWorld::Ptr& object, int amount) = 0;
///< copy and place an object into the gameworld at the given actor's position
/// @param actor giving the dropped object position
/// @param object
@ -468,7 +468,8 @@ namespace MWBase
virtual void castSpell (const MWWorld::Ptr& actor) = 0;
virtual void launchMagicBolt (const std::string& id, bool stack, const ESM::EffectList& effects,
virtual void launchMagicBolt (const std::string& model, const std::string& sound, const std::string& spellId,
float speed, bool stack, const ESM::EffectList& effects,
const MWWorld::Ptr& actor, const std::string& sourceName) = 0;
virtual void launchProjectile (MWWorld::Ptr actor, MWWorld::Ptr projectile,
const Ogre::Vector3& worldPos, const Ogre::Quaternion& orient, MWWorld::Ptr bow, float speed) = 0;
@ -514,7 +515,7 @@ namespace MWBase
/// Spawn a blood effect for \a ptr at \a worldPosition
virtual void spawnBloodEffect (const MWWorld::Ptr& ptr, const Ogre::Vector3& worldPosition) = 0;
virtual void explodeSpell (const Ogre::Vector3& origin, const MWWorld::Ptr& object, const ESM::EffectList& effects,
virtual void explodeSpell (const Ogre::Vector3& origin, const ESM::EffectList& effects,
const MWWorld::Ptr& caster, const std::string& id, const std::string& sourceName) = 0;
};
}

@ -108,7 +108,7 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Activator::activate(const MWWorld::Ptr &ptr, const MWWorld::Ptr &actor) const
{
if(get(actor).isNpc() && get(actor).getNpcStats(actor).isWerewolf())
if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
{
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfActivator");

@ -295,7 +295,7 @@ namespace MWClass
return std::make_pair(0, "#{sInventoryMessage1}");
// slots that this item can be equipped in
std::pair<std::vector<int>, bool> slots_ = MWWorld::Class::get(ptr).getEquipmentSlots(ptr);
std::pair<std::vector<int>, bool> slots_ = ptr.getClass().getEquipmentSlots(ptr);
if (slots_.first.empty())
return std::make_pair(0, "");

@ -61,7 +61,7 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Book::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
if(get(actor).isNpc() && get(actor).getNpcStats(actor).isWerewolf())
if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
{
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfItem");

@ -233,7 +233,7 @@ namespace MWClass
std::pair<int, std::string> Clothing::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
{
// slots that this item can be equipped in
std::pair<std::vector<int>, bool> slots_ = MWWorld::Class::get(ptr).getEquipmentSlots(ptr);
std::pair<std::vector<int>, bool> slots_ = ptr.getClass().getEquipmentSlots(ptr);
if (slots_.first.empty())
return std::make_pair(0, "");

@ -60,6 +60,24 @@ namespace MWClass
}
}
void Container::respawn(const MWWorld::Ptr &ptr) const
{
MWWorld::LiveCellRef<ESM::Container> *ref =
ptr.get<ESM::Container>();
if (ref->mBase->mFlags & ESM::Container::Respawn)
{
ptr.getRefData().setCustomData(NULL);
}
}
void Container::restock(const MWWorld::Ptr& ptr) const
{
MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>();
const ESM::InventoryList& list = ref->mBase->mInventory;
MWWorld::ContainerStore& store = getContainerStore(ptr);
store.restock(list, ptr, ptr.getCellRef().mOwner, ptr.getCellRef().mFaction);
}
void Container::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{
const std::string model = getModel(ptr);
@ -94,7 +112,7 @@ namespace MWClass
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction ());
if(get(actor).isNpc() && get(actor).getNpcStats(actor).isWerewolf())
if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
{
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfContainer");
@ -109,7 +127,7 @@ namespace MWClass
const std::string trapActivationSound = "Disarm Trap Fail";
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
MWWorld::InventoryStore& invStore = MWWorld::Class::get(player).getInventoryStore(player);
MWWorld::InventoryStore& invStore = player.getClass().getInventoryStore(player);
bool needKey = ptr.getCellRef().mLockLevel > 0;
bool hasKey = false;
@ -125,7 +143,7 @@ namespace MWClass
if (refId == keyId)
{
hasKey = true;
keyName = MWWorld::Class::get(*it).getName(*it);
keyName = it->getClass().getName(*it);
}
}

@ -64,6 +64,10 @@ namespace MWClass
static void registerSelf();
virtual void respawn (const MWWorld::Ptr& ptr) const;
virtual void restock (const MWWorld::Ptr &ptr) const;
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
};
}

@ -123,9 +123,6 @@ namespace MWClass
else
data->mContainerStore = new MWWorld::ContainerStore();
// Relates to NPC gold reset delay
data->mCreatureStats.setTradeTime(MWWorld::TimeStamp(0.0, 0));
data->mCreatureStats.setGoldPool(ref->mBase->mData.mGold);
// store
@ -280,7 +277,7 @@ namespace MWClass
if (!weapon.isEmpty())
{
const bool weaphashealth = get(weapon).hasItemHealth(weapon);
const bool weaphashealth = weapon.getClass().hasItemHealth(weapon);
const unsigned char *attack = NULL;
if(type == ESM::Weapon::AT_Chop)
attack = weapon.get<ESM::Weapon>()->mBase->mData.mChop;
@ -357,7 +354,7 @@ namespace MWClass
}
if(!object.isEmpty())
getCreatureStats(ptr).setLastHitObject(MWWorld::Class::get(object).getId(object));
getCreatureStats(ptr).setLastHitObject(object.getClass().getId(object));
if(!attacker.isEmpty() && attacker.getRefData().getHandle() == "player")
{
@ -447,7 +444,7 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Creature::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
if(get(actor).isNpc() && get(actor).getNpcStats(actor).isWerewolf())
if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
{
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfCreature");
@ -822,6 +819,34 @@ namespace MWClass
return ptr.get<ESM::Creature>()->mBase->mData.mGold;
}
void Creature::respawn(const MWWorld::Ptr &ptr) const
{
if (ptr.get<ESM::Creature>()->mBase->mFlags & ESM::Creature::Respawn)
{
// Note we do not respawn moved references in the cell they were moved to. Instead they are respawned in the original cell.
// This also means we cannot respawn dynamically placed references with no content file connection.
if (ptr.getCellRef().mRefNum.mContentFile != -1)
{
if (ptr.getRefData().getCount() == 0)
ptr.getRefData().setCount(1);
// Reset to original position
ESM::Position& pos = ptr.getRefData().getPosition();
pos = ptr.getCellRef().mPos;
ptr.getRefData().setCustomData(NULL);
}
}
}
void Creature::restock(const MWWorld::Ptr& ptr) const
{
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
const ESM::InventoryList& list = ref->mBase->mInventory;
MWWorld::ContainerStore& store = getContainerStore(ptr);
store.restock(list, ptr, ptr.getCellRef().mRefID, ptr.getCellRef().mFaction);
}
const ESM::GameSetting* Creature::fMinWalkSpeedCreature;
const ESM::GameSetting* Creature::fMaxWalkSpeedCreature;
const ESM::GameSetting *Creature::fEncumberedMoveEffect;

@ -143,6 +143,10 @@ namespace MWClass
///< Write additional state from \a ptr into \a state.
virtual int getBaseGold(const MWWorld::Ptr& ptr) const;
virtual void respawn (const MWWorld::Ptr& ptr) const;
virtual void restock (const MWWorld::Ptr &ptr) const;
};
}

@ -14,6 +14,7 @@ namespace
{
// actorId of the creature we spawned
int mSpawnActorId;
bool mSpawn; // Should a new creature be spawned?
virtual MWWorld::CustomData *clone() const;
};
@ -31,6 +32,14 @@ namespace MWClass
return "";
}
void CreatureLevList::respawn(const MWWorld::Ptr &ptr) const
{
ensureCustomData(ptr);
CreatureLevListCustomData& customData = dynamic_cast<CreatureLevListCustomData&> (*ptr.getRefData().getCustomData());
customData.mSpawn = true;
}
void CreatureLevList::registerSelf()
{
boost::shared_ptr<Class> instance (new CreatureLevList);
@ -43,9 +52,8 @@ namespace MWClass
ensureCustomData(ptr);
CreatureLevListCustomData& customData = dynamic_cast<CreatureLevListCustomData&> (*ptr.getRefData().getCustomData());
if (customData.mSpawnActorId != -1)
return; // TODO: handle respawning
if (!customData.mSpawn)
return;
MWWorld::LiveCellRef<ESM::CreatureLevList> *ref =
ptr.get<ESM::CreatureLevList>();
@ -54,11 +62,21 @@ namespace MWClass
if (!id.empty())
{
// Delete the previous creature
if (customData.mSpawnActorId != -1)
{
MWWorld::Ptr creature = MWBase::Environment::get().getWorld()->searchPtrViaActorId(customData.mSpawnActorId);
if (!creature.isEmpty())
MWBase::Environment::get().getWorld()->deleteObject(creature);
customData.mSpawnActorId = -1;
}
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
MWWorld::ManualRef ref(store, id);
ref.getPtr().getCellRef().mPos = ptr.getCellRef().mPos;
MWWorld::Ptr placed = MWBase::Environment::get().getWorld()->safePlaceObject(ref.getPtr(), ptr.getCell() , ptr.getCellRef().mPos);
customData.mSpawnActorId = placed.getClass().getCreatureStats(placed).getActorId();
customData.mSpawn = false;
}
}
@ -68,6 +86,7 @@ namespace MWClass
{
std::auto_ptr<CreatureLevListCustomData> data (new CreatureLevListCustomData);
data->mSpawnActorId = -1;
data->mSpawn = true;
ptr.getRefData().setCustomData(data.release());
}
@ -81,6 +100,7 @@ namespace MWClass
ensureCustomData(ptr);
CreatureLevListCustomData& customData = dynamic_cast<CreatureLevListCustomData&> (*ptr.getRefData().getCustomData());
customData.mSpawnActorId = state2.mSpawnActorId;
customData.mSpawn = state2.mSpawn;
}
void CreatureLevList::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
@ -91,5 +111,6 @@ namespace MWClass
ensureCustomData(ptr);
CreatureLevListCustomData& customData = dynamic_cast<CreatureLevListCustomData&> (*ptr.getRefData().getCustomData());
state2.mSpawnActorId = customData.mSpawnActorId;
state2.mSpawn = customData.mSpawn;
}
}

@ -27,6 +27,8 @@ namespace MWClass
virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
const;
///< Write additional state from \a ptr into \a state.
virtual void respawn (const MWWorld::Ptr& ptr) const;
};
}

@ -99,7 +99,7 @@ namespace MWClass
const std::string lockedSound = "LockedDoor";
const std::string trapActivationSound = "Disarm Trap Fail";
MWWorld::ContainerStore &invStore = get(actor).getContainerStore(actor);
MWWorld::ContainerStore &invStore = actor.getClass().getContainerStore(actor);
bool needKey = ptr.getCellRef().mLockLevel > 0;
bool hasKey = false;
@ -115,7 +115,7 @@ namespace MWClass
if (refId == keyId)
{
hasKey = true;
keyName = get(*it).getName(*it);
keyName = it->getClass().getName(*it);
}
}

@ -153,7 +153,7 @@ namespace MWClass
}
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(player).getNpcStats (player);
MWMechanics::NpcStats& npcStats = player.getClass().getNpcStats (player);
int alchemySkill = npcStats.getSkill (ESM::Skill::Alchemy).getBase();
static const float fWortChanceValue =

@ -250,7 +250,7 @@ namespace MWClass
std::pair<int, std::string> Light::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
{
MWWorld::InventoryStore& invStore = MWWorld::Class::get(npc).getInventoryStore(npc);
MWWorld::InventoryStore& invStore = npc.getClass().getInventoryStore(npc);
MWWorld::ContainerStoreIterator weapon = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
if(weapon == invStore.end())

@ -484,10 +484,10 @@ namespace MWClass
if(victim.isEmpty()) // Didn't hit anything
return;
const MWWorld::Class &othercls = MWWorld::Class::get(victim);
const MWWorld::Class &othercls = victim.getClass();
if(!othercls.isActor()) // Can't hit non-actors
return;
MWMechanics::CreatureStats &otherstats = victim.getClass().getCreatureStats(victim);
MWMechanics::CreatureStats &otherstats = othercls.getCreatureStats(victim);
if(otherstats.isDead()) // Can't hit dead actors
return;
@ -496,7 +496,7 @@ namespace MWClass
int weapskill = ESM::Skill::HandToHand;
if(!weapon.isEmpty())
weapskill = get(weapon).getEquipmentSkill(weapon);
weapskill = weapon.getClass().getEquipmentSkill(weapon);
float hitchance = MWMechanics::getHitChance(ptr, victim, ptr.getClass().getSkill(ptr, weapskill));
@ -511,7 +511,7 @@ namespace MWClass
MWMechanics::NpcStats &stats = getNpcStats(ptr);
if(!weapon.isEmpty())
{
const bool weaphashealth = get(weapon).hasItemHealth(weapon);
const bool weaphashealth = weapon.getClass().hasItemHealth(weapon);
const unsigned char *attack = NULL;
if(type == ESM::Weapon::AT_Chop)
attack = weapon.get<ESM::Weapon>()->mBase->mData.mChop;
@ -621,7 +621,8 @@ namespace MWClass
// Attacking peaceful NPCs is a crime
// anything below 80 is considered peaceful (see Actors::updateActor)
if (!attacker.isEmpty() && ptr.getClass().getCreatureStats(ptr).getAiSetting(MWMechanics::CreatureStats::AI_Fight).getModified() < 80)
if (!attacker.isEmpty() && !ptr.getClass().getCreatureStats(ptr).isHostile() &&
ptr.getClass().getCreatureStats(ptr).getAiSetting(MWMechanics::CreatureStats::AI_Fight).getModified() < 80)
MWBase::Environment::get().getMechanicsManager()->commitCrime(attacker, ptr, MWBase::MechanicsManager::OT_Assault);
getCreatureStats(ptr).setAttacked(true);
@ -636,7 +637,7 @@ namespace MWClass
}
if(!object.isEmpty())
getCreatureStats(ptr).setLastHitObject(get(object).getId(object));
getCreatureStats(ptr).setLastHitObject(object.getClass().getId(object));
if(!attacker.isEmpty() && attacker.getRefData().getHandle() == "player")
{
@ -715,9 +716,9 @@ namespace MWClass
inv.unequipItem(armor, ptr);
if (ptr.getRefData().getHandle() == "player")
skillUsageSucceeded(ptr, get(armor).getEquipmentSkill(armor), 0);
skillUsageSucceeded(ptr, armor.getClass().getEquipmentSkill(armor), 0);
switch(get(armor).getEquipmentSkill(armor))
switch(armor.getClass().getEquipmentSkill(armor))
{
case ESM::Skill::LightArmor:
sndMgr->playSound3D(ptr, "Light Armor Hit", 1.0f, 1.0f);
@ -801,7 +802,7 @@ namespace MWClass
if(ptr.getRefData().getHandle() == "player")
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionTalk(actor));
if(get(actor).isNpc() && get(actor).getNpcStats(actor).isWerewolf())
if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
{
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfNPC");
@ -813,7 +814,7 @@ namespace MWClass
}
if(getCreatureStats(ptr).isDead())
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr, true));
if(get(ptr).getCreatureStats(ptr).isHostile())
if(ptr.getClass().getCreatureStats(ptr).isHostile())
return boost::shared_ptr<MWWorld::Action>(new MWWorld::FailedAction("#{sActorInCombat}"));
if(getCreatureStats(actor).getStance(MWMechanics::CreatureStats::Stance_Sneak))
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); // stealing
@ -942,7 +943,7 @@ namespace MWClass
if (fallHeight >= fallDistanceMin)
{
const float acrobaticsSkill = MWWorld::Class::get(ptr).getNpcStats (ptr).getSkill(ESM::Skill::Acrobatics).getModified();
const float acrobaticsSkill = ptr.getClass().getNpcStats (ptr).getSkill(ESM::Skill::Acrobatics).getModified();
const NpcCustomData *npcdata = static_cast<const NpcCustomData*>(ptr.getRefData().getCustomData());
const float jumpSpellBonus = npcdata->mNpcStats.getMagicEffects().get(ESM::MagicEffect::Jump).mMagnitude;
const float fallAcroBase = gmst.find("fFallAcroBase")->getFloat();
@ -1106,7 +1107,7 @@ namespace MWClass
{
MWWorld::LiveCellRef<ESM::Armor> *ref = it->get<ESM::Armor>();
int armorSkillType = MWWorld::Class::get(*it).getEquipmentSkill(*it);
int armorSkillType = it->getClass().getEquipmentSkill(*it);
int armorSkill = stats.getSkill(armorSkillType).getModified();
if(ref->mBase->mData.mWeight == 0)
@ -1176,7 +1177,7 @@ namespace MWClass
if(boots == inv.end() || boots->getTypeName() != typeid(ESM::Armor).name())
return "FootBareLeft";
switch(Class::get(*boots).getEquipmentSkill(*boots))
switch(boots->getClass().getEquipmentSkill(*boots))
{
case ESM::Skill::LightArmor:
return "FootLightLeft";
@ -1203,7 +1204,7 @@ namespace MWClass
if(boots == inv.end() || boots->getTypeName() != typeid(ESM::Armor).name())
return "FootBareRight";
switch(Class::get(*boots).getEquipmentSkill(*boots))
switch(boots->getClass().getEquipmentSkill(*boots))
{
case ESM::Skill::LightArmor:
return "FootLightRight";
@ -1309,6 +1310,34 @@ namespace MWClass
return Misc::StringUtils::ciEqual(ptr.get<ESM::NPC>()->mBase->mClass, className);
}
void Npc::respawn(const MWWorld::Ptr &ptr) const
{
if (ptr.get<ESM::NPC>()->mBase->mFlags & ESM::NPC::Respawn)
{
// Note we do not respawn moved references in the cell they were moved to. Instead they are respawned in the original cell.
// This also means we cannot respawn dynamically placed references with no content file connection.
if (ptr.getCellRef().mRefNum.mContentFile != -1)
{
if (ptr.getRefData().getCount() == 0)
ptr.getRefData().setCount(1);
// Reset to original position
ESM::Position& pos = ptr.getRefData().getPosition();
pos = ptr.getCellRef().mPos;
ptr.getRefData().setCustomData(NULL);
}
}
}
void Npc::restock(const MWWorld::Ptr& ptr) const
{
MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();
const ESM::InventoryList& list = ref->mBase->mInventory;
MWWorld::ContainerStore& store = getContainerStore(ptr);
store.restock(list, ptr, ptr.getCellRef().mRefID, ptr.getCellRef().mFaction);
}
const ESM::GameSetting *Npc::fMinWalkSpeed;
const ESM::GameSetting *Npc::fMaxWalkSpeed;
const ESM::GameSetting *Npc::fEncumberedMoveEffect;

@ -178,6 +178,10 @@ namespace MWClass
virtual bool canWalk (const MWWorld::Ptr &ptr) const {
return true;
}
virtual void respawn (const MWWorld::Ptr& ptr) const;
virtual void restock (const MWWorld::Ptr& ptr) const;
};
}

@ -133,7 +133,7 @@ namespace MWClass
// hide effects the player doesnt know about
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(player).getNpcStats (player);
MWMechanics::NpcStats& npcStats = player.getClass().getNpcStats (player);
int alchemySkill = npcStats.getSkill (ESM::Skill::Alchemy).getBase();
int i=0;
static const float fWortChanceValue =

@ -392,7 +392,7 @@ namespace MWClass
if (ptr.getCellRef().mCharge == 0)
return std::make_pair(0, "#{sInventoryMessage1}");
std::pair<std::vector<int>, bool> slots_ = MWWorld::Class::get(ptr).getEquipmentSlots(ptr);
std::pair<std::vector<int>, bool> slots_ = ptr.getClass().getEquipmentSlots(ptr);
if (slots_.first.empty())
return std::make_pair (0, "");

@ -134,13 +134,13 @@ namespace MWDialogue
mActor = actor;
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (actor).getCreatureStats (actor);
MWMechanics::CreatureStats& creatureStats = actor.getClass().getCreatureStats (actor);
mTalkedTo = creatureStats.hasTalkedToPlayer();
mActorKnownTopics.clear();
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
win->startDialogue(actor, MWWorld::Class::get (actor).getName (actor));
win->startDialogue(actor, actor.getClass().getName (actor));
//setup the list of topics known by the actor. Topics who are also on the knownTopics list will be added to the GUI
updateTopics();
@ -194,7 +194,7 @@ namespace MWDialogue
Compiler::Locals locals;
std::string actorScript = MWWorld::Class::get (mActor).getScript (mActor);
std::string actorScript = mActor.getClass().getScript (mActor);
if (!actorScript.empty())
{
@ -286,7 +286,18 @@ namespace MWDialogue
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor);
win->addResponse (Interpreter::fixDefinesDialog(info->mResponse, interpreterContext), title);
MWBase::Environment::get().getJournal()->addTopic (topic, info->mId, mActor.getClass().getName(mActor));
// Make sure the returned DialInfo is from the Dialogue we supplied. If could also be from the Info refusal group,
// in which case it should not be added to the journal.
for (ESM::Dialogue::InfoContainer::const_iterator iter = dialogue.mInfo.begin();
iter!=dialogue.mInfo.end(); ++iter)
{
if (iter->mId == info->mId)
{
MWBase::Environment::get().getJournal()->addTopic (topic, info->mId, mActor.getClass().getName(mActor));
break;
}
}
executeScript (info->mResultScript);
@ -424,7 +435,7 @@ namespace MWDialogue
// Apply disposition change to NPC's base disposition
if (mActor.getClass().isNpc())
{
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(mActor).getNpcStats(mActor);
MWMechanics::NpcStats& npcStats = mActor.getClass().getNpcStats(mActor);
npcStats.setBaseDisposition(npcStats.getBaseDisposition() + mPermanentDispositionChange);
}
mPermanentDispositionChange = 0;
@ -453,7 +464,19 @@ namespace MWDialogue
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor);
MWBase::Environment::get().getWindowManager()->getDialogueWindow()->addResponse (Interpreter::fixDefinesDialog(text, interpreterContext));
MWBase::Environment::get().getJournal()->addTopic (mLastTopic, info->mId, mActor.getClass().getName(mActor));
// Make sure the returned DialInfo is from the Dialogue we supplied. If could also be from the Info refusal group,
// in which case it should not be added to the journal.
for (ESM::Dialogue::InfoContainer::const_iterator iter = mDialogueMap[mLastTopic].mInfo.begin();
iter!=mDialogueMap[mLastTopic].mInfo.end(); ++iter)
{
if (iter->mId == info->mId)
{
MWBase::Environment::get().getJournal()->addTopic (mLastTopic, info->mId, mActor.getClass().getName(mActor));
break;
}
}
executeScript (info->mResultScript);
}
}

@ -25,7 +25,7 @@ bool MWDialogue::Filter::testActor (const ESM::DialInfo& info) const
// actor id
if (!info.mActor.empty())
{
if ( !Misc::StringUtils::ciEqual(info.mActor, MWWorld::Class::get (mActor).getId (mActor)))
if ( !Misc::StringUtils::ciEqual(info.mActor, mActor.getClass().getId (mActor)))
return false;
}
else if (isCreature)
@ -64,7 +64,7 @@ bool MWDialogue::Filter::testActor (const ESM::DialInfo& info) const
if (isCreature)
return false;
MWMechanics::NpcStats& stats = MWWorld::Class::get (mActor).getNpcStats (mActor);
MWMechanics::NpcStats& stats = mActor.getClass().getNpcStats (mActor);
std::map<std::string, int>::iterator iter = stats.getFactionRanks().find ( Misc::StringUtils::lowerCase (info.mFaction));
if (iter==stats.getFactionRanks().end())
@ -98,7 +98,7 @@ bool MWDialogue::Filter::testPlayer (const ESM::DialInfo& info) const
// check player faction
if (!info.mPcFaction.empty())
{
MWMechanics::NpcStats& stats = MWWorld::Class::get (player).getNpcStats (player);
MWMechanics::NpcStats& stats = player.getClass().getNpcStats (player);
std::map<std::string,int>::iterator iter = stats.getFactionRanks().find (Misc::StringUtils::lowerCase (info.mPcFaction));
if(iter==stats.getFactionRanks().end())
@ -182,7 +182,7 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c
case SelectWrapper::Function_Local:
{
std::string scriptName = MWWorld::Class::get (mActor).getScript (mActor);
std::string scriptName = mActor.getClass().getScript (mActor);
if (scriptName.empty())
return false; // no script
@ -220,8 +220,8 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
float ratio = MWWorld::Class::get (player).getCreatureStats (player).getHealth().getCurrent() /
MWWorld::Class::get (player).getCreatureStats (player).getHealth().getModified();
float ratio = player.getClass().getCreatureStats (player).getHealth().getCurrent() /
player.getClass().getCreatureStats (player).getHealth().getModified();
return select.selectCompare (static_cast<int>(ratio*100));
}
@ -230,7 +230,7 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
float value = MWWorld::Class::get (player).getCreatureStats (player).
float value = player.getClass().getCreatureStats (player).
getDynamic (select.getArgument()).getCurrent();
return select.selectCompare (value);
@ -238,8 +238,8 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c
case SelectWrapper::Function_HealthPercent:
{
float ratio = MWWorld::Class::get (mActor).getCreatureStats (mActor).getHealth().getCurrent() /
MWWorld::Class::get (mActor).getCreatureStats (mActor).getHealth().getModified();
float ratio = mActor.getClass().getCreatureStats (mActor).getHealth().getCurrent() /
mActor.getClass().getCreatureStats (mActor).getHealth().getModified();
return select.selectCompare (ratio);
}
@ -262,7 +262,7 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
case SelectWrapper::Function_Item:
{
MWWorld::ContainerStore& store = MWWorld::Class::get (player).getContainerStore (player);
MWWorld::ContainerStore& store = player.getClass().getContainerStore (player);
int sum = 0;
@ -285,29 +285,29 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
case SelectWrapper::Function_AiSetting:
return MWWorld::Class::get (mActor).getCreatureStats (mActor).getAiSetting (
return mActor.getClass().getCreatureStats (mActor).getAiSetting (
(MWMechanics::CreatureStats::AiSetting)select.getArgument()).getModified();
case SelectWrapper::Function_PcAttribute:
return MWWorld::Class::get (player).getCreatureStats (player).
return player.getClass().getCreatureStats (player).
getAttribute (select.getArgument()).getModified();
case SelectWrapper::Function_PcSkill:
return static_cast<int> (MWWorld::Class::get (player).
return static_cast<int> (player.getClass().
getNpcStats (player).getSkill (select.getArgument()).getModified());
case SelectWrapper::Function_FriendlyHit:
{
int hits = MWWorld::Class::get (mActor).getCreatureStats (mActor).getFriendlyHits();
int hits = mActor.getClass().getCreatureStats (mActor).getFriendlyHits();
return hits>4 ? 4 : hits;
}
case SelectWrapper::Function_PcLevel:
return MWWorld::Class::get (player).getCreatureStats (player).getLevel();
return player.getClass().getCreatureStats (player).getLevel();
case SelectWrapper::Function_PcGender:
@ -315,7 +315,7 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
case SelectWrapper::Function_PcClothingModifier:
{
MWWorld::InventoryStore& store = MWWorld::Class::get (player).getInventoryStore (player);
MWWorld::InventoryStore& store = player.getClass().getInventoryStore (player);
int value = 0;
@ -324,7 +324,7 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
MWWorld::ContainerStoreIterator slot = store.getSlot (i);
if (slot!=store.end())
value += MWWorld::Class::get (*slot).getValue (*slot);
value += slot->getClass().getValue (*slot);
}
return value;
@ -332,15 +332,15 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
case SelectWrapper::Function_PcCrimeLevel:
return MWWorld::Class::get (player).getNpcStats (player).getBounty();
return player.getClass().getNpcStats (player).getBounty();
case SelectWrapper::Function_RankRequirement:
{
if (MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().empty())
if (mActor.getClass().getNpcStats (mActor).getFactionRanks().empty())
return 0;
std::string faction =
MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin()->first;
mActor.getClass().getNpcStats (mActor).getFactionRanks().begin()->first;
int rank = getFactionRank (player, faction);
@ -360,11 +360,11 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
case SelectWrapper::Function_Level:
return MWWorld::Class::get (mActor).getCreatureStats (mActor).getLevel();
return mActor.getClass().getCreatureStats (mActor).getLevel();
case SelectWrapper::Function_PCReputation:
return MWWorld::Class::get (player).getNpcStats (player).getReputation();
return player.getClass().getNpcStats (player).getReputation();
case SelectWrapper::Function_Weather:
@ -372,15 +372,15 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
case SelectWrapper::Function_Reputation:
return MWWorld::Class::get (mActor).getNpcStats (mActor).getReputation();
return mActor.getClass().getNpcStats (mActor).getReputation();
case SelectWrapper::Function_FactionRankDiff:
{
if (MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().empty())
if (mActor.getClass().getNpcStats (mActor).getFactionRanks().empty())
return 0;
std::pair<std::string, int> faction =
*MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin();
*mActor.getClass().getNpcStats (mActor).getFactionRanks().begin();
int rank = getFactionRank (player, faction.first);
@ -389,25 +389,25 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
case SelectWrapper::Function_WerewolfKills:
return MWWorld::Class::get (player).getNpcStats (player).getWerewolfKills();
return player.getClass().getNpcStats (player).getWerewolfKills();
case SelectWrapper::Function_RankLow:
case SelectWrapper::Function_RankHigh:
{
bool low = select.getFunction()==SelectWrapper::Function_RankLow;
if (MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().empty())
if (mActor.getClass().getNpcStats (mActor).getFactionRanks().empty())
return 0;
std::string factionId =
MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin()->first;
mActor.getClass().getNpcStats (mActor).getFactionRanks().begin()->first;
int value = 0;
const ESM::Faction& faction =
*MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find (factionId);
MWMechanics::NpcStats& playerStats = MWWorld::Class::get (player).getNpcStats (player);
MWMechanics::NpcStats& playerStats = player.getClass().getNpcStats (player);
for (std::vector<ESM::Faction::Reaction>::const_iterator iter (faction.mReactions.begin());
iter!=faction.mReactions.end(); ++iter)
@ -436,7 +436,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
case SelectWrapper::Function_NotId:
return !Misc::StringUtils::ciEqual(MWWorld::Class::get (mActor).getId (mActor), select.getName());
return !Misc::StringUtils::ciEqual(mActor.getClass().getId (mActor), select.getName());
case SelectWrapper::Function_NotFaction:
@ -456,7 +456,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
case SelectWrapper::Function_NotLocal:
{
std::string scriptName = MWWorld::Class::get (mActor).getScript (mActor);
std::string scriptName = mActor.getClass().getScript (mActor);
if (scriptName.empty())
// This actor has no attached script, so there is no local variable
@ -489,36 +489,36 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
case SelectWrapper::Function_SameFaction:
return MWWorld::Class::get (mActor).getNpcStats (mActor).isSameFaction (
MWWorld::Class::get (player).getNpcStats (player));
return mActor.getClass().getNpcStats (mActor).isSameFaction (
player.getClass().getNpcStats (player));
case SelectWrapper::Function_PcCommonDisease:
return MWWorld::Class::get (player).getCreatureStats (player).hasCommonDisease();
return player.getClass().getCreatureStats (player).hasCommonDisease();
case SelectWrapper::Function_PcBlightDisease:
return MWWorld::Class::get (player).getCreatureStats (player).hasBlightDisease();
return player.getClass().getCreatureStats (player).hasBlightDisease();
case SelectWrapper::Function_PcCorprus:
return MWWorld::Class::get (player).getCreatureStats (player).
return player.getClass().getCreatureStats (player).
getMagicEffects().get (ESM::MagicEffect::Corprus).mMagnitude!=0;
case SelectWrapper::Function_PcExpelled:
{
if (MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().empty())
if (mActor.getClass().getNpcStats (mActor).getFactionRanks().empty())
return false;
std::string faction =
MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin()->first;
mActor.getClass().getNpcStats (mActor).getFactionRanks().begin()->first;
return player.getClass().getNpcStats(player).getExpelled(faction);
}
case SelectWrapper::Function_PcVampire:
return MWWorld::Class::get (player).getCreatureStats(player).getMagicEffects().
return player.getClass().getCreatureStats(player).getMagicEffects().
get(ESM::MagicEffect::Vampirism).mMagnitude > 0;
case SelectWrapper::Function_TalkedToPc:
@ -527,7 +527,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
case SelectWrapper::Function_Alarmed:
return MWWorld::Class::get (mActor).getCreatureStats (mActor).isAlarmed();
return mActor.getClass().getCreatureStats (mActor).isAlarmed();
case SelectWrapper::Function_Detected:
@ -535,11 +535,11 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
case SelectWrapper::Function_Attacked:
return MWWorld::Class::get (mActor).getCreatureStats (mActor).getAttacked();
return mActor.getClass().getCreatureStats (mActor).getAttacked();
case SelectWrapper::Function_ShouldAttack:
return MWWorld::Class::get (mActor).getCreatureStats (mActor).isHostile();
return mActor.getClass().getCreatureStats (mActor).isHostile();
case SelectWrapper::Function_CreatureTargetted:
@ -547,7 +547,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
case SelectWrapper::Function_Werewolf:
return MWWorld::Class::get (mActor).getNpcStats (mActor).isWerewolf();
return mActor.getClass().getNpcStats (mActor).isWerewolf();
default:
@ -557,7 +557,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
int MWDialogue::Filter::getFactionRank (const MWWorld::Ptr& actor, const std::string& factionId) const
{
MWMechanics::NpcStats& stats = MWWorld::Class::get (actor).getNpcStats (actor);
MWMechanics::NpcStats& stats = actor.getClass().getNpcStats (actor);
std::map<std::string, int>::const_iterator iter = stats.getFactionRanks().find (factionId);
@ -573,13 +573,13 @@ bool MWDialogue::Filter::hasFactionRankSkillRequirements (const MWWorld::Ptr& ac
if (rank<0 || rank>=10)
throw std::runtime_error ("rank index out of range");
if (!MWWorld::Class::get (actor).getNpcStats (actor).hasSkillsForRank (factionId, rank))
if (!actor.getClass().getNpcStats (actor).hasSkillsForRank (factionId, rank))
return false;
const ESM::Faction& faction =
*MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find (factionId);
MWMechanics::CreatureStats& stats = MWWorld::Class::get (actor).getCreatureStats (actor);
MWMechanics::CreatureStats& stats = actor.getClass().getCreatureStats (actor);
return stats.getAttribute (faction.mData.mAttribute[0]).getBase()>=faction.mData.mRankData[rank].mAttribute1 &&
stats.getAttribute (faction.mData.mAttribute[1]).getBase()>=faction.mData.mRankData[rank].mAttribute2;
@ -591,7 +591,7 @@ bool MWDialogue::Filter::hasFactionRankReputationRequirements (const MWWorld::Pt
if (rank<0 || rank>=10)
throw std::runtime_error ("rank index out of range");
MWMechanics::NpcStats& stats = MWWorld::Class::get (actor).getNpcStats (actor);
MWMechanics::NpcStats& stats = actor.getClass().getNpcStats (actor);
const ESM::Faction& faction =
*MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find (factionId);
@ -621,7 +621,7 @@ std::vector<const ESM::DialInfo *> MWDialogue::Filter::list (const ESM::Dialogue
bool infoRefusal = false;
// Iterate over topic responses to find a matching one
for (std::vector<ESM::DialInfo>::const_iterator iter = dialogue.mInfo.begin();
for (ESM::Dialogue::InfoContainer::const_iterator iter = dialogue.mInfo.begin();
iter!=dialogue.mInfo.end(); ++iter)
{
if (testActor (*iter) && testPlayer (*iter) && testSelectStructs (*iter))
@ -646,7 +646,7 @@ std::vector<const ESM::DialInfo *> MWDialogue::Filter::list (const ESM::Dialogue
const ESM::Dialogue& infoRefusalDialogue = *dialogues.find ("Info Refusal");
for (std::vector<ESM::DialInfo>::const_iterator iter = infoRefusalDialogue.mInfo.begin();
for (ESM::Dialogue::InfoContainer::const_iterator iter = infoRefusalDialogue.mInfo.begin();
iter!=infoRefusalDialogue.mInfo.end(); ++iter)
if (testActor (*iter) && testPlayer (*iter) && testSelectStructs (*iter) && testDisposition(*iter, invertDisposition)) {
infos.push_back(&*iter);
@ -660,7 +660,7 @@ std::vector<const ESM::DialInfo *> MWDialogue::Filter::list (const ESM::Dialogue
bool MWDialogue::Filter::responseAvailable (const ESM::Dialogue& dialogue) const
{
for (std::vector<ESM::DialInfo>::const_iterator iter = dialogue.mInfo.begin();
for (ESM::Dialogue::InfoContainer::const_iterator iter = dialogue.mInfo.begin();
iter!=dialogue.mInfo.end(); ++iter)
{
if (testActor (*iter) && testPlayer (*iter) && testSelectStructs (*iter))

@ -55,6 +55,7 @@ namespace MWDialogue
std::vector<const ESM::DialInfo *> list (const ESM::Dialogue& dialogue,
bool fallbackToInfoRefusal, bool searchAll, bool invertDisposition=false) const;
///< \note If fallbackToInfoRefusal is used, the returned DialInfo might not be from the supplied ESM::Dialogue.
const ESM::DialInfo* search (const ESM::Dialogue& dialogue, const bool fallbackToInfoRefusal) const;
///< Get a matching response for the requested dialogue.

@ -20,7 +20,7 @@ namespace MWDialogue
const ESM::Dialogue *dialogue =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (topic);
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
for (ESM::Dialogue::InfoContainer::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter)
if (iter->mId == mInfoId)
{
@ -73,7 +73,7 @@ namespace MWDialogue
const ESM::Dialogue *dialogue =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (topic);
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
for (ESM::Dialogue::InfoContainer::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter)
if (iter->mData.mDisposition==index) /// \todo cleanup info structure
{

@ -56,7 +56,7 @@ namespace MWDialogue
if (infoId.empty())
return true;
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
for (ESM::Dialogue::InfoContainer::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter)
if (iter->mId == infoId)
return true;

@ -27,7 +27,7 @@ namespace MWDialogue
const ESM::Dialogue *dialogue =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (mTopic);
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
for (ESM::Dialogue::InfoContainer::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter)
if (iter->mQuestStatus==ESM::DialInfo::QS_Name)
return iter->mResponse;
@ -45,8 +45,7 @@ namespace MWDialogue
const ESM::Dialogue *dialogue =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (mTopic);
bool found=false;
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
for (ESM::Dialogue::InfoContainer::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter)
if (iter->mData.mDisposition==index && iter->mQuestStatus!=ESM::DialInfo::QS_Name)
{
@ -54,15 +53,10 @@ namespace MWDialogue
mFinished = true;
else if (iter->mQuestStatus==ESM::DialInfo::QS_Restart)
mFinished = false;
found = true;
// Don't return here. Quest status may actually be in a different info record, since we don't merge these (yet?)
}
if (found)
mIndex = index;
else
throw std::runtime_error ("unknown journal index for topic " + mTopic);
// The index must be set even if no related journal entry was found
mIndex = index;
}
bool Quest::isFinished() const
@ -77,7 +71,7 @@ namespace MWDialogue
const ESM::Dialogue *dialogue =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (entry.mTopic);
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
for (ESM::Dialogue::InfoContainer::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter)
if (iter->mId == entry.mInfoId)
{

@ -19,7 +19,7 @@ namespace
std::string getIconPath(MWWorld::Ptr ptr)
{
std::string path = std::string("icons\\");
path += MWWorld::Class::get(ptr).getInventoryIcon(ptr);
path += ptr.getClass().getInventoryIcon(ptr);
int pos = path.rfind(".");
path.erase(pos);
path.append(".dds");
@ -174,7 +174,7 @@ namespace MWGui
{
update();
std::string sound = MWWorld::Class::get(item).getUpSoundId(item);
std::string sound = item.getClass().getUpSoundId(item);
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
}
}

@ -93,7 +93,10 @@ struct TypesetBookImpl : TypesetBook
typedef std::vector <Section> Sections;
// Holds "top" and "bottom" vertical coordinates in the source text.
// A page is basically a "window" into a portion of the source text, similar to a ScrollView.
typedef std::pair <int, int> Page;
typedef std::vector <Page> Pages;
Pages mPages;
@ -374,6 +377,29 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
else
{
//split section
int sectionHeightLeft = sectionHeight;
while (sectionHeightLeft > mPageHeight)
{
spaceLeft = mPageHeight - (curPageStop - curPageStart);
// Adjust to the top of the first line that does not fit on the current page anymore
int splitPos = curPageStop;
for (Lines::iterator j = i->mLines.begin (); j != i->mLines.end (); ++j)
{
if (j->mRect.bottom > curPageStart + mPageHeight)
{
splitPos = j->mRect.top;
break;
}
}
mBook->mPages.push_back (Page (curPageStart, splitPos));
curPageStart = splitPos;
curPageStop = splitPos;
sectionHeightLeft = (i->mRect.bottom - splitPos);
}
curPageStop = i->mRect.bottom;
}
}

@ -47,7 +47,7 @@ namespace
void updatePlayerHealth()
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(player).getNpcStats(player);
MWMechanics::NpcStats& npcStats = player.getClass().getNpcStats(player);
npcStats.updateHealth();
}
}
@ -220,7 +220,7 @@ namespace MWGui
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
const MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
const MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
mReviewDialog->setHealth ( stats.getHealth() );
mReviewDialog->setMagicka( stats.getMagicka() );

@ -61,7 +61,7 @@ void CompanionWindow::onItemSelected(int index)
if (count > 1 && !shift)
{
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
dialog->open(MWWorld::Class::get(object).getName(object), "#{sTake}", count);
dialog->open(object.getClass().getName(object), "#{sTake}", count);
dialog->eventOkClicked.clear();
dialog->eventOkClicked += MyGUI::newDelegate(this, &CompanionWindow::dragItem);
}
@ -92,7 +92,7 @@ void CompanionWindow::open(const MWWorld::Ptr& npc)
mSortModel = new SortFilterItemModel(mModel);
mItemView->setModel(mSortModel);
setTitle(MWWorld::Class::get(npc).getName(npc));
setTitle(npc.getClass().getName(npc));
}
void CompanionWindow::onFrame()
@ -104,22 +104,22 @@ void CompanionWindow::updateEncumbranceBar()
{
if (mPtr.isEmpty())
return;
float capacity = MWWorld::Class::get(mPtr).getCapacity(mPtr);
float encumbrance = MWWorld::Class::get(mPtr).getEncumbrance(mPtr);
float capacity = mPtr.getClass().getCapacity(mPtr);
float encumbrance = mPtr.getClass().getEncumbrance(mPtr);
mEncumbranceBar->setValue(encumbrance, capacity);
if (mPtr.getTypeName() != typeid(ESM::NPC).name())
mProfitLabel->setCaption("");
else
{
MWMechanics::NpcStats& stats = MWWorld::Class::get(mPtr).getNpcStats(mPtr);
MWMechanics::NpcStats& stats = mPtr.getClass().getNpcStats(mPtr);
mProfitLabel->setCaptionWithReplacing("#{sProfitValue} " + boost::lexical_cast<std::string>(stats.getProfit()));
}
}
void CompanionWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
{
if (mPtr.getTypeName() == typeid(ESM::NPC).name() && MWWorld::Class::get(mPtr).getNpcStats(mPtr).getProfit() < 0)
if (mPtr.getTypeName() == typeid(ESM::NPC).name() && mPtr.getClass().getNpcStats(mPtr).getProfit() < 0)
{
std::vector<std::string> buttons;
buttons.push_back("#{sCompanionWarningButtonOne}");
@ -135,8 +135,8 @@ void CompanionWindow::onMessageBoxButtonClicked(int button)
{
if (button == 0)
{
mPtr.getRefData().getLocals().setVarByInt(MWWorld::Class::get(mPtr).getScript(mPtr),
"minimumProfit", MWWorld::Class::get(mPtr).getNpcStats(mPtr).getProfit());
mPtr.getRefData().getLocals().setVarByInt(mPtr.getClass().getScript(mPtr),
"minimumProfit", mPtr.getClass().getNpcStats(mPtr).getProfit());
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Companion);
MWBase::Environment::get().getDialogueManager()->startDialogue (mPtr);

@ -1,5 +1,8 @@
#include "console.hpp"
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <components/compiler/exception.hpp>
#include <components/compiler/extensions0.hpp>
@ -194,7 +197,8 @@ namespace MWGui
void Console::executeFile (const std::string& path)
{
std::ifstream stream (path.c_str());
namespace bfs = boost::filesystem;
bfs::ifstream stream ((bfs::path(path)));
if (!stream.is_open())
printError ("failed to open file: " + path);

@ -37,7 +37,7 @@ namespace MWGui
mIsOnDragAndDrop = true;
mDragAndDropWidget->setVisible(true);
std::string sound = MWWorld::Class::get(mItem.mBase).getUpSoundId(mItem.mBase);
std::string sound = mItem.mBase.getClass().getUpSoundId(mItem.mBase);
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
if (mSourceSortModel)
@ -47,7 +47,7 @@ namespace MWGui
}
std::string path = std::string("icons\\");
path += MWWorld::Class::get(mItem.mBase).getInventoryIcon(mItem.mBase);
path += mItem.mBase.getClass().getInventoryIcon(mItem.mBase);
MyGUI::ImageBox* baseWidget = mDragAndDropWidget->createWidget<MyGUI::ImageBox>
("ImageBox", MyGUI::IntCoord(0, 0, 42, 42), MyGUI::Align::Default);
mDraggedWidget = baseWidget;
@ -76,7 +76,7 @@ namespace MWGui
void DragAndDrop::drop(ItemModel *targetModel, ItemView *targetView)
{
std::string sound = MWWorld::Class::get(mItem.mBase).getDownSoundId(mItem.mBase);
std::string sound = mItem.mBase.getClass().getDownSoundId(mItem.mBase);
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
mDragAndDropWidget->setVisible(false);
@ -91,7 +91,8 @@ namespace MWGui
mSourceModel->update();
finish();
targetView->update();
if (targetView)
targetView->update();
// We need to update the view since an other item could be auto-equipped.
mSourceView->update();
@ -154,7 +155,7 @@ namespace MWGui
if (count > 1 && !shift)
{
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
dialog->open(MWWorld::Class::get(object).getName(object), "#{sTake}", count);
dialog->open(object.getClass().getName(object), "#{sTake}", count);
dialog->eventOkClicked.clear();
dialog->eventOkClicked += MyGUI::newDelegate(this, &ContainerWindow::dragItem);
}
@ -176,8 +177,8 @@ namespace MWGui
{
// check that we don't exceed container capacity
MWWorld::Ptr item = mDragAndDrop->mItem.mBase;
float weight = MWWorld::Class::get(item).getWeight(item) * mDragAndDrop->mDraggedCount;
if (MWWorld::Class::get(mPtr).getCapacity(mPtr) < MWWorld::Class::get(mPtr).getEncumbrance(mPtr) + weight)
float weight = item.getClass().getWeight(item) * mDragAndDrop->mDraggedCount;
if (mPtr.getClass().getCapacity(mPtr) < mPtr.getClass().getEncumbrance(mPtr) + weight)
{
MWBase::Environment::get().getWindowManager()->messageBox("#{sContentsMessage3}");
return;
@ -226,7 +227,7 @@ namespace MWGui
// Careful here. setTitle may cause size updates, causing itemview redraw, so make sure to do it last
// or we end up using a possibly invalid model.
setTitle(MWWorld::Class::get(container).getName(container));
setTitle(container.getClass().getName(container));
}
void ContainerWindow::onKeyPressed(MyGUI::Widget *_sender, MyGUI::KeyCode _key, MyGUI::Char _char)
@ -283,7 +284,7 @@ namespace MWGui
{
// play the sound of the first object
MWWorld::Ptr item = mModel->getItem(i).mBase;
std::string sound = MWWorld::Class::get(item).getUpSoundId(item);
std::string sound = item.getClass().getUpSoundId(item);
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
}
@ -305,7 +306,7 @@ namespace MWGui
{
onTakeAllButtonClicked(mTakeButton);
if (MWWorld::Class::get(mPtr).isPersistent(mPtr))
if (mPtr.getClass().isPersistent(mPtr))
MWBase::Environment::get().getWindowManager()->messageBox("#{sDisposeCorpseFail}");
else
MWBase::Environment::get().getWorld()->deleteObject(mPtr);

@ -85,7 +85,7 @@ void ContainerItemModel::removeItem (const ItemStack& item, size_t count)
for (std::vector<MWWorld::Ptr>::iterator source = mItemSources.begin(); source != mItemSources.end(); ++source)
{
MWWorld::ContainerStore& store = MWWorld::Class::get(*source).getContainerStore(*source);
MWWorld::ContainerStore& store = source->getClass().getContainerStore(*source);
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
{
@ -120,7 +120,7 @@ void ContainerItemModel::update()
mItems.clear();
for (std::vector<MWWorld::Ptr>::iterator source = mItemSources.begin(); source != mItemSources.end(); ++source)
{
MWWorld::ContainerStore& store = MWWorld::Class::get(*source).getContainerStore(*source);
MWWorld::ContainerStore& store = source->getClass().getContainerStore(*source);
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
{

@ -363,6 +363,8 @@ namespace MWGui
mTopicsList->setEnabled(true);
setTitle(npcName);
clearChoices();
mTopicsList->clear();
for (std::vector<DialogueText*>::iterator it = mHistoryContents.begin(); it != mHistoryContents.end(); ++it)
@ -384,8 +386,8 @@ namespace MWGui
mTopicLinks.clear();
mKeywordSearch.clear();
bool isCompanion = !MWWorld::Class::get(mPtr).getScript(mPtr).empty()
&& mPtr.getRefData().getLocals().getIntVar(MWWorld::Class::get(mPtr).getScript(mPtr), "companion");
bool isCompanion = !mPtr.getClass().getScript(mPtr).empty()
&& mPtr.getRefData().getLocals().getIntVar(mPtr.getClass().getScript(mPtr), "companion");
bool anyService = mServices > 0 || isCompanion || mPtr.getTypeName() == typeid(ESM::NPC).name();

@ -119,7 +119,7 @@ namespace MWGui
MyGUI::ImageBox* image = mSoulBox->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 32, 32), MyGUI::Align::Default);
std::string path = std::string("icons\\");
path += MWWorld::Class::get(soulgem).getInventoryIcon(soulgem);
path += soulgem.getClass().getInventoryIcon(soulgem);
int pos = path.rfind(".");
path.erase(pos);
path.append(".dds");
@ -164,7 +164,7 @@ namespace MWGui
MyGUI::ImageBox* image = mItemBox->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 32, 32), MyGUI::Align::Default);
std::string path = std::string("icons\\");
path += MWWorld::Class::get(item).getInventoryIcon(item);
path += item.getClass().getInventoryIcon(item);
int pos = path.rfind(".");
path.erase(pos);
path.append(".dds");
@ -207,7 +207,7 @@ namespace MWGui
MyGUI::ImageBox* image = mSoulBox->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 32, 32), MyGUI::Align::Default);
std::string path = std::string("icons\\");
path += MWWorld::Class::get(item).getInventoryIcon(item);
path += item.getClass().getInventoryIcon(item);
int pos = path.rfind(".");
path.erase(pos);
path.append(".dds");

@ -17,9 +17,47 @@
#include "itemmodel.hpp"
#include "container.hpp"
#include "itemmodel.hpp"
namespace MWGui
{
/**
* Makes it possible to use ItemModel::moveItem to move an item from an inventory to the world.
*/
class WorldItemModel : public ItemModel
{
public:
WorldItemModel(float left, float top) : mLeft(left), mTop(top) {}
virtual ~WorldItemModel() {}
virtual MWWorld::Ptr copyItem (const ItemStack& item, size_t count, bool setNewOwner=false)
{
MWBase::World* world = MWBase::Environment::get().getWorld();
MWWorld::Ptr dropped;
if (world->canPlaceObject(mLeft, mTop))
dropped = world->placeObject(item.mBase, mLeft, mTop, count);
else
dropped = world->dropObjectOnGround(world->getPlayerPtr(), item.mBase, count);
if (setNewOwner)
dropped.getCellRef().mOwner = "";
return dropped;
}
virtual void removeItem (const ItemStack& item, size_t count) { throw std::runtime_error("removeItem not implemented"); }
virtual ModelIndex getIndex (ItemStack item) { throw std::runtime_error("getIndex not implemented"); }
virtual void update() {}
virtual size_t getItemCount() { return 0; }
virtual ItemStack getItem (ModelIndex index) { throw std::runtime_error("getItem not implemented"); }
private:
// Where to drop the item
float mLeft;
float mTop;
};
HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
: Layout("openmw_hud.layout")
, mHealth(NULL)
@ -229,10 +267,6 @@ namespace MWGui
if (mDragAndDrop->mIsOnDragAndDrop)
{
// drop item into the gameworld
MWWorld::Ptr object = mDragAndDrop->mItem.mBase;
MWBase::World* world = MWBase::Environment::get().getWorld();
MWBase::Environment::get().getWorld()->breakInvisibility(
MWBase::Environment::get().getWorld()->getPlayerPtr());
@ -241,20 +275,10 @@ namespace MWGui
float mouseX = cursorPosition.left / float(viewSize.width);
float mouseY = cursorPosition.top / float(viewSize.height);
if (world->canPlaceObject(mouseX, mouseY))
world->placeObject(object, mouseX, mouseY, mDragAndDrop->mDraggedCount);
else
world->dropObjectOnGround(world->getPlayerPtr(), object, mDragAndDrop->mDraggedCount);
WorldItemModel drop (mouseX, mouseY);
mDragAndDrop->drop(&drop, NULL);
MWBase::Environment::get().getWindowManager()->changePointer("arrow");
std::string sound = MWWorld::Class::get(object).getDownSoundId(object);
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
// remove object from the container it was coming from
mDragAndDrop->mSourceModel->removeItem(mDragAndDrop->mItem, mDragAndDrop->mDraggedCount);
mDragAndDrop->finish();
mDragAndDrop->mSourceModel->update();
}
else
{
@ -324,7 +348,7 @@ namespace MWGui
void HUD::onWeaponClicked(MyGUI::Widget* _sender)
{
const MWWorld::Ptr& player = MWBase::Environment::get().getWorld()->getPlayerPtr();
if (MWWorld::Class::get(player).getNpcStats(player).isWerewolf())
if (player.getClass().getNpcStats(player).isWerewolf())
{
MWBase::Environment::get().getWindowManager()->messageBox("#{sWerewolfRefusal}");
return;
@ -336,7 +360,7 @@ namespace MWGui
void HUD::onMagicClicked(MyGUI::Widget* _sender)
{
const MWWorld::Ptr& player = MWBase::Environment::get().getWorld()->getPlayerPtr();
if (MWWorld::Class::get(player).getNpcStats(player).isWerewolf())
if (player.getClass().getNpcStats(player).isWerewolf())
{
MWBase::Environment::get().getWindowManager()->messageBox("#{sWerewolfRefusal}");
return;
@ -419,7 +443,7 @@ namespace MWGui
void HUD::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent)
{
std::string itemName = MWWorld::Class::get(item).getName(item);
std::string itemName = item.getClass().getName(item);
if (itemName != mSpellName && mSpellVisible)
{
mWeaponSpellTimer = 5.0f;
@ -442,7 +466,7 @@ namespace MWGui
, MyGUI::Align::Stretch);
std::string path = std::string("icons\\");
path+=MWWorld::Class::get(item).getInventoryIcon(item);
path+=item.getClass().getInventoryIcon(item);
Widgets::fixTexturePath(path);
itemBox->setImageTexture(path);
itemBox->setNeedMouseFocus(false);
@ -450,7 +474,7 @@ namespace MWGui
void HUD::setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent)
{
std::string itemName = MWWorld::Class::get(item).getName(item);
std::string itemName = item.getClass().getName(item);
if (itemName != mWeaponName && mWeaponVisible)
{
mWeaponSpellTimer = 5.0f;
@ -469,10 +493,10 @@ namespace MWGui
MyGUI::Gui::getInstance().destroyWidget(mWeapImage->getChildAt(0));
std::string path = std::string("icons\\");
path+=MWWorld::Class::get(item).getInventoryIcon(item);
path+=item.getClass().getInventoryIcon(item);
Widgets::fixTexturePath(path);
if (MWWorld::Class::get(item).getEnchantment(item) != "")
if (item.getClass().getEnchantment(item) != "")
{
mWeapImage->setImageTexture("textures\\menu_icon_magic_mini.dds");
MyGUI::ImageBox* itemBox = mWeapImage->createWidgetReal<MyGUI::ImageBox>("ImageBox", MyGUI::FloatCoord(0,0,1,1)
@ -521,7 +545,7 @@ namespace MWGui
MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr();
if (MWWorld::Class::get(player).getNpcStats(player).isWerewolf())
if (player.getClass().getNpcStats(player).isWerewolf())
mWeapImage->setImageTexture("icons\\k\\tx_werewolf_hand.dds");
else
mWeapImage->setImageTexture("icons\\k\\stealth_handtohand.dds");
@ -604,12 +628,15 @@ namespace MWGui
effectsDx = (viewSize.width - mMinimapBoxBaseRight) - (viewSize.width - mEffectBoxBaseRight);
mMapVisible = mMinimapBox->getVisible ();
if (!mMapVisible)
mCellNameBox->setVisible(false);
mEffectBox->setPosition((viewSize.width - mEffectBoxBaseRight) - mEffectBox->getWidth() + effectsDx, mEffectBox->getTop());
}
void HUD::updateEnemyHealthBar()
{
MWMechanics::CreatureStats& stats = MWWorld::Class::get(mEnemy).getCreatureStats(mEnemy);
MWMechanics::CreatureStats& stats = mEnemy.getClass().getCreatureStats(mEnemy);
mEnemyHealth->setProgressRange(100);
// Health is usually cast to int before displaying. Actors die whenever they are < 1 health.
// Therefore any value < 1 should show as an empty health bar. We do the same in statswindow :)

@ -50,7 +50,7 @@ MWWorld::Ptr InventoryItemModel::copyItem (const ItemStack& item, size_t count,
void InventoryItemModel::removeItem (const ItemStack& item, size_t count)
{
MWWorld::ContainerStore& store = MWWorld::Class::get(mActor).getContainerStore(mActor);
MWWorld::ContainerStore& store = mActor.getClass().getContainerStore(mActor);
int removed = store.remove(item.mBase, count, mActor);
if (removed == 0)
@ -77,7 +77,7 @@ MWWorld::Ptr InventoryItemModel::moveItem(const ItemStack &item, size_t count, I
void InventoryItemModel::update()
{
MWWorld::ContainerStore& store = MWWorld::Class::get(mActor).getContainerStore(mActor);
MWWorld::ContainerStore& store = mActor.getClass().getContainerStore(mActor);
mItems.clear();

@ -162,7 +162,7 @@ namespace MWGui
}
const ItemStack& item = mTradeModel->getItem(index);
std::string sound = MWWorld::Class::get(item.mBase).getDownSoundId(item.mBase);
std::string sound = item.mBase.getClass().getDownSoundId(item.mBase);
MWWorld::Ptr object = item.mBase;
int count = item.mCount;
@ -176,35 +176,6 @@ namespace MWGui
return;
}
if (item.mType == ItemStack::Type_Equipped)
{
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
MWWorld::Ptr newStack = *invStore.unequipItem(item.mBase, mPtr);
// The unequipped item was re-stacked. We have to update the index
// since the item pointed does not exist anymore.
if (item.mBase != newStack)
{
// newIndex will store the index of the ItemStack the item was stacked on
int newIndex = -1;
for (size_t i=0; i < mTradeModel->getItemCount(); ++i)
{
if (mTradeModel->getItem(i).mBase == newStack)
{
newIndex = i;
break;
}
}
if (newIndex == -1)
throw std::runtime_error("Can't find restacked item");
index = newIndex;
object = mTradeModel->getItem(index).mBase;
}
}
bool shift = MyGUI::InputManager::getInstance().isShiftPressed();
if (MyGUI::InputManager::getInstance().isControlPressed())
count = 1;
@ -213,7 +184,7 @@ namespace MWGui
{
// check if merchant accepts item
int services = MWBase::Environment::get().getWindowManager()->getTradeWindow()->getMerchantServices();
if (!MWWorld::Class::get(object).canSell(object, services))
if (!object.getClass().canSell(object, services))
{
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
MWBase::Environment::get().getWindowManager()->
@ -226,7 +197,7 @@ namespace MWGui
{
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
std::string message = mTrading ? "#{sQuanityMenuMessage01}" : "#{sTake}";
dialog->open(MWWorld::Class::get(object).getName(object), message, count);
dialog->open(object.getClass().getName(object), message, count);
dialog->eventOkClicked.clear();
if (mTrading)
dialog->eventOkClicked += MyGUI::newDelegate(this, &InventoryWindow::sellItem);
@ -247,15 +218,48 @@ namespace MWGui
notifyContentChanged();
}
void InventoryWindow::ensureSelectedItemUnequipped()
{
const ItemStack& item = mTradeModel->getItem(mSelectedItem);
if (item.mType == ItemStack::Type_Equipped)
{
MWWorld::InventoryStore& invStore = mPtr.getClass().getInventoryStore(mPtr);
MWWorld::Ptr newStack = *invStore.unequipItem(item.mBase, mPtr);
// The unequipped item was re-stacked. We have to update the index
// since the item pointed does not exist anymore.
if (item.mBase != newStack)
{
// newIndex will store the index of the ItemStack the item was stacked on
int newIndex = -1;
for (size_t i=0; i < mTradeModel->getItemCount(); ++i)
{
if (mTradeModel->getItem(i).mBase == newStack)
{
newIndex = i;
break;
}
}
if (newIndex == -1)
throw std::runtime_error("Can't find restacked item");
mSelectedItem = newIndex;
}
}
}
void InventoryWindow::dragItem(MyGUI::Widget* sender, int count)
{
ensureSelectedItemUnequipped();
mDragAndDrop->startDrag(mSelectedItem, mSortModel, mTradeModel, mItemView, count);
}
void InventoryWindow::sellItem(MyGUI::Widget* sender, int count)
{
ensureSelectedItemUnequipped();
const ItemStack& item = mTradeModel->getItem(mSelectedItem);
std::string sound = MWWorld::Class::get(item.mBase).getDownSoundId(item.mBase);
std::string sound = item.mBase.getClass().getDownSoundId(item.mBase);
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
if (item.mType == ItemStack::Type_Barter)
@ -378,7 +382,7 @@ namespace MWGui
if (script.empty() || ptr.getRefData().getLocals().getIntVar(script, "pcskipequip") == 0)
{
boost::shared_ptr<MWWorld::Action> action = MWWorld::Class::get(ptr).use(ptr);
boost::shared_ptr<MWWorld::Action> action = ptr.getClass().use(ptr);
action->execute (MWBase::Environment::get().getWorld()->getPlayerPtr());
@ -443,7 +447,7 @@ namespace MWGui
if (slot == -1)
return MWWorld::Ptr();
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
MWWorld::InventoryStore& invStore = mPtr.getClass().getInventoryStore(mPtr);
if(invStore.getSlot(slot) != invStore.end())
{
MWWorld::Ptr item = *invStore.getSlot(slot);
@ -462,8 +466,8 @@ namespace MWGui
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
float capacity = MWWorld::Class::get(player).getCapacity(player);
float encumbrance = MWWorld::Class::get(player).getEncumbrance(player);
float capacity = player.getClass().getCapacity(player);
float encumbrance = player.getClass().getEncumbrance(player);
mEncumbranceBar->setValue(encumbrance, capacity);
}
@ -494,9 +498,9 @@ namespace MWGui
mAvatarImage->setImageTile(MyGUI::IntSize(std::min(512, size.width), std::min(1024, size.height)));
mArmorRating->setCaptionWithReplacing ("#{sArmor}: "
+ boost::lexical_cast<std::string>(static_cast<int>(MWWorld::Class::get(mPtr).getArmorRating(mPtr))));
+ boost::lexical_cast<std::string>(static_cast<int>(mPtr.getClass().getArmorRating(mPtr))));
if (mArmorRating->getTextSize().width > mArmorRating->getSize().width)
mArmorRating->setCaptionWithReplacing (boost::lexical_cast<std::string>(static_cast<int>(MWWorld::Class::get(mPtr).getArmorRating(mPtr))));
mArmorRating->setCaptionWithReplacing (boost::lexical_cast<std::string>(static_cast<int>(mPtr.getClass().getArmorRating(mPtr))));
}
}
@ -530,7 +534,7 @@ namespace MWGui
&& (type != typeid(ESM::Potion).name()))
return;
if (MWWorld::Class::get(object).getName(object) == "") // objects without name presented to user can never be picked up
if (object.getClass().getName(object) == "") // objects without name presented to user can never be picked up
return;
int count = object.getRefData().getCount();

@ -102,6 +102,9 @@ namespace MWGui
void notifyContentChanged();
void adjustPanes();
/// Unequips mSelectedItem, if it is equipped, and then updates mSelectedItem in case it was re-stacked
void ensureSelectedItemUnequipped();
};
}

@ -13,7 +13,7 @@ namespace MWGui
, mType(Type_Normal)
, mBase(base)
{
if (MWWorld::Class::get(base).getEnchantment(base) != "")
if (base.getClass().getEnchantment(base) != "")
mFlags |= Flag_Enchanted;
}

@ -81,7 +81,7 @@ void ItemView::update()
/// \todo performance improvement: don't create/destroy all the widgets everytime the container window changes size, only reposition them
std::string path = std::string("icons\\");
path += MWWorld::Class::get(item.mBase).getInventoryIcon(item.mBase);
path += item.mBase.getClass().getInventoryIcon(item.mBase);
// background widget (for the "equipped" frame and magic item background image)
bool isMagic = (item.mFlags & ItemStack::Flag_Enchanted);

@ -61,8 +61,8 @@ namespace MWGui
void LevelupDialog::setAttributeValues()
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get(player).getCreatureStats (player);
MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player);
MWMechanics::CreatureStats& creatureStats = player.getClass().getCreatureStats (player);
MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats (player);
for (int i=0; i<8; ++i)
{
@ -117,8 +117,8 @@ namespace MWGui
{
MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr();
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get(player).getCreatureStats (player);
MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player);
MWMechanics::CreatureStats& creatureStats = player.getClass().getCreatureStats (player);
MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats (player);
mSpentAttributes.clear();
resetCoins();
@ -172,7 +172,7 @@ namespace MWGui
void LevelupDialog::onOkButtonClicked (MyGUI::Widget* sender)
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player);
MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats (player);
if (mSpentAttributes.size() < 3)
MWBase::Environment::get().getWindowManager ()->messageBox("#{sNotifyMessage36}");

@ -26,7 +26,7 @@ namespace MWGui
if (mClient == 0)
mClient = this;
mScrollView = mClient->createWidgetReal<MWGui::Widgets::MWScrollView>(
mScrollView = mClient->createWidgetReal<MyGUI::ScrollView>(
"MW_ScrollView", MyGUI::FloatCoord(0.0, 0.0, 1.0, 1.0),
MyGUI::Align::Top | MyGUI::Align::Left | MyGUI::Align::Stretch, getName() + "_ScrollView");
}
@ -51,7 +51,7 @@ namespace MWGui
const int _scrollBarWidth = 20; // fetch this from skin?
const int scrollBarWidth = scrollbarShown ? _scrollBarWidth : 0;
const int spacing = 3;
size_t scrollbarPosition = mScrollView->getScrollPosition();
size_t viewPosition = -mScrollView->getViewOffset().top;
while (mScrollView->getChildCount())
{
@ -96,10 +96,10 @@ namespace MWGui
if (!scrollbarShown && mItemHeight > mClient->getSize().height)
redraw(true);
size_t scrollbarRange = mScrollView->getScrollRange();
if(scrollbarPosition > scrollbarRange)
scrollbarPosition = scrollbarRange;
mScrollView->setScrollPosition(scrollbarPosition);
size_t viewRange = mScrollView->getCanvasSize().height;
if(viewPosition > viewRange)
viewPosition = viewRange;
mScrollView->setViewOffset(MyGUI::IntPoint(0, -viewPosition));
}
bool MWList::hasItem(const std::string& name)
@ -151,19 +151,5 @@ namespace MWGui
return mScrollView->findWidget (getName() + "_item_" + name);
}
size_t MWScrollView::getScrollPosition()
{
return getVScroll()->getScrollPosition();
}
void MWScrollView::setScrollPosition(size_t position)
{
getVScroll()->setScrollPosition(position);
}
size_t MWScrollView::getScrollRange()
{
return getVScroll()->getScrollRange();
}
}
}

@ -7,18 +7,6 @@ namespace MWGui
{
namespace Widgets
{
/**
* \brief a custom ScrollView which has access to scrollbar properties
*/
class MWScrollView : public MyGUI::ScrollView
{
MYGUI_RTTI_DERIVED(MWScrollView)
public:
size_t getScrollPosition();
void setScrollPosition(size_t);
size_t getScrollRange();
};
/**
* \brief a very simple list widget that supports word-wrapping entries
* \note if the width or height of the list changes, you must call adjustSize() method
@ -70,7 +58,7 @@ namespace MWGui
void onItemSelected(MyGUI::Widget* _sender);
private:
MWGui::Widgets::MWScrollView* mScrollView;
MyGUI::ScrollView* mScrollView;
MyGUI::Widget* mClient;
std::vector<std::string> mItems;

@ -89,10 +89,11 @@ namespace MWGui
mChanged = true;
}
void LocalMapBase::toggleFogOfWar()
bool LocalMapBase::toggleFogOfWar()
{
mFogOfWar = !mFogOfWar;
applyFogOfWar();
return mFogOfWar;
}
void LocalMapBase::applyFogOfWar()

@ -35,7 +35,7 @@ namespace MWGui
void setPlayerDir(const float x, const float y);
void setPlayerPos(const float x, const float y);
void toggleFogOfWar();
bool toggleFogOfWar();
struct MarkerPosition
{

@ -39,19 +39,19 @@ void MerchantRepair::startRepair(const MWWorld::Ptr &actor)
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId);
MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player);
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
int categories = MWWorld::ContainerStore::Type_Weapon | MWWorld::ContainerStore::Type_Armor;
for (MWWorld::ContainerStoreIterator iter (store.begin(categories));
iter!=store.end(); ++iter)
{
if (MWWorld::Class::get(*iter).hasItemHealth(*iter))
if (iter->getClass().hasItemHealth(*iter))
{
int maxDurability = MWWorld::Class::get(*iter).getItemMaxHealth(*iter);
int maxDurability = iter->getClass().getItemMaxHealth(*iter);
int durability = (iter->getCellRef().mCharge == -1) ? maxDurability : iter->getCellRef().mCharge;
if (maxDurability == durability)
continue;
int basePrice = MWWorld::Class::get(*iter).getValue(*iter);
int basePrice = iter->getClass().getValue(*iter);
float fRepairMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
.find("fRepairMult")->getFloat();
@ -64,7 +64,7 @@ void MerchantRepair::startRepair(const MWWorld::Ptr &actor)
int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mActor, x, true);
std::string name = MWWorld::Class::get(*iter).getName(*iter)
std::string name = iter->getClass().getName(*iter)
+ " - " + boost::lexical_cast<std::string>(price)
+ MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
.find("sgp")->getString();;
@ -114,7 +114,7 @@ void MerchantRepair::onRepairButtonClick(MyGUI::Widget *sender)
{
// repair
MWWorld::Ptr item = *sender->getUserData<MWWorld::Ptr>();
item.getCellRef().mCharge = MWWorld::Class::get(item).getItemMaxHealth(item);
item.getCellRef().mCharge = item.getClass().getItemMaxHealth(item);
MWBase::Environment::get().getSoundManager()->playSound("Repair",1,1);

@ -166,7 +166,7 @@ namespace MWGui
frame->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
MyGUI::ImageBox* image = frame->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
std::string path = std::string("icons\\");
path += MWWorld::Class::get(item).getInventoryIcon(item);
path += item.getClass().getInventoryIcon(item);
int pos = path.rfind(".");
path.erase(pos);
path.append(".dds");
@ -200,7 +200,7 @@ namespace MWGui
MyGUI::ImageBox* image = frame->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
std::string path = std::string("icons\\");
path += MWWorld::Class::get(item).getInventoryIcon(item);
path += item.getClass().getInventoryIcon(item);
int pos = path.rfind(".");
path.erase(pos);
path.append(".dds");
@ -265,7 +265,7 @@ namespace MWGui
QuickKeyType type = *button->getUserData<QuickKeyType>();
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
if (type == Type_Item || type == Type_MagicItem)
{
@ -290,7 +290,7 @@ namespace MWGui
{
// No replacement was found
MWBase::Environment::get().getWindowManager ()->messageBox (
"#{sQuickMenu5} " + MWWorld::Class::get(item).getName(item));
"#{sQuickMenu5} " + item.getClass().getName(item));
return;
}
}
@ -330,7 +330,7 @@ namespace MWGui
assert(it != store.end());
// equip, if it can be equipped
if (!MWWorld::Class::get(item).getEquipmentSlots(item).first.empty())
if (!item.getClass().getEquipmentSlots(item).first.empty())
{
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->useItem(item);
}
@ -522,8 +522,8 @@ namespace MWGui
const int spellHeight = 18;
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
MWMechanics::Spells& spells = stats.getSpells();
/// \todo lots of copy&pasted code from SpellWindow
@ -566,7 +566,7 @@ namespace MWGui
std::vector<MWWorld::Ptr> items;
for (MWWorld::ContainerStoreIterator it(store.begin()); it != store.end(); ++it)
{
std::string enchantId = MWWorld::Class::get(*it).getEnchantment(*it);
std::string enchantId = it->getClass().getEnchantment(*it);
if (enchantId != "")
{
// only add items with "Cast once" or "Cast on use"
@ -645,7 +645,7 @@ namespace MWGui
MyGUI::Button* t = mMagicList->createWidget<MyGUI::Button>(equipped ? "SpellText" : "SpellTextUnequipped",
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
t->setCaption(MWWorld::Class::get(item).getName(item));
t->setCaption(item.getClass().getName(item));
t->setTextAlign(MyGUI::Align::Left);
t->setUserData(item);
t->setUserString("ToolTipType", "ItemPtr");

@ -41,7 +41,7 @@ void Recharge::open()
void Recharge::start (const MWWorld::Ptr &item)
{
std::string path = std::string("icons\\");
path += MWWorld::Class::get(item).getInventoryIcon(item);
path += item.getClass().getInventoryIcon(item);
int pos = path.rfind(".");
path.erase(pos);
path.append(".dds");
@ -85,7 +85,7 @@ void Recharge::updateView()
int currentY = 0;
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player);
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
for (MWWorld::ContainerStoreIterator iter (store.begin());
iter!=store.end(); ++iter)
{
@ -99,14 +99,14 @@ void Recharge::updateView()
MyGUI::TextBox* text = mView->createWidget<MyGUI::TextBox> (
"SandText", MyGUI::IntCoord(8, currentY, mView->getWidth()-8, 18), MyGUI::Align::Default);
text->setCaption(MWWorld::Class::get(*iter).getName(*iter));
text->setCaption(iter->getClass().getName(*iter));
text->setNeedMouseFocus(false);
currentY += 19;
MyGUI::ImageBox* icon = mView->createWidget<MyGUI::ImageBox> (
"ImageBox", MyGUI::IntCoord(16, currentY, 32, 32), MyGUI::Align::Default);
std::string path = std::string("icons\\");
path += MWWorld::Class::get(*iter).getInventoryIcon(*iter);
path += iter->getClass().getInventoryIcon(*iter);
int pos = path.rfind(".");
path.erase(pos);
path.append(".dds");

@ -40,7 +40,7 @@ void Repair::startRepairItem(const MWWorld::Ptr &item)
mRepair.setTool(item);
std::string path = std::string("icons\\");
path += MWWorld::Class::get(item).getInventoryIcon(item);
path += item.getClass().getInventoryIcon(item);
int pos = path.rfind(".");
path.erase(pos);
path.append(".dds");
@ -90,28 +90,28 @@ void Repair::updateRepairView()
int currentY = 0;
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player);
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
int categories = MWWorld::ContainerStore::Type_Weapon | MWWorld::ContainerStore::Type_Armor;
for (MWWorld::ContainerStoreIterator iter (store.begin(categories));
iter!=store.end(); ++iter)
{
if (MWWorld::Class::get(*iter).hasItemHealth(*iter))
if (iter->getClass().hasItemHealth(*iter))
{
int maxDurability = MWWorld::Class::get(*iter).getItemMaxHealth(*iter);
int maxDurability = iter->getClass().getItemMaxHealth(*iter);
int durability = (iter->getCellRef().mCharge == -1) ? maxDurability : iter->getCellRef().mCharge;
if (maxDurability == durability)
continue;
MyGUI::TextBox* text = mRepairView->createWidget<MyGUI::TextBox> (
"SandText", MyGUI::IntCoord(8, currentY, mRepairView->getWidth()-8, 18), MyGUI::Align::Default);
text->setCaption(MWWorld::Class::get(*iter).getName(*iter));
text->setCaption(iter->getClass().getName(*iter));
text->setNeedMouseFocus(false);
currentY += 19;
MyGUI::ImageBox* icon = mRepairView->createWidget<MyGUI::ImageBox> (
"ImageBox", MyGUI::IntCoord(16, currentY, 32, 32), MyGUI::Align::Default);
std::string path = std::string("icons\\");
path += MWWorld::Class::get(*iter).getInventoryIcon(*iter);
path += iter->getClass().getInventoryIcon(*iter);
int pos = path.rfind(".");
path.erase(pos);
path.append(".dds");

@ -222,12 +222,6 @@ namespace MWGui
MWBase::Environment::get().getStateManager()->loadGame (mCurrentCharacter, mCurrentSlot);
}
}
if (MWBase::Environment::get().getStateManager()->getState()==
MWBase::StateManager::State_NoGame)
{
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
}
}
void SaveGameDialog::onOkButtonClicked(MyGUI::Widget *sender)

@ -47,8 +47,8 @@ namespace
if (left.mBase.getTypeName() == right.mBase.getTypeName())
{
int cmp = MWWorld::Class::get(left.mBase).getName(left.mBase).compare(
MWWorld::Class::get(right.mBase).getName(right.mBase));
int cmp = left.mBase.getClass().getName(left.mBase).compare(
right.mBase.getClass().getName(right.mBase));
return cmp < 0;
}
else

@ -83,7 +83,7 @@ namespace MWGui
mPtr = actor;
clearSpells();
MWMechanics::Spells& merchantSpells = MWWorld::Class::get (actor).getCreatureStats (actor).getSpells();
MWMechanics::Spells& merchantSpells = actor.getClass().getCreatureStats (actor).getSpells();
for (MWMechanics::Spells::TIterator iter = merchantSpells.begin(); iter!=merchantSpells.end(); ++iter)
{
@ -107,7 +107,7 @@ namespace MWGui
bool SpellBuyingWindow::playerHasSpell(const std::string &id)
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWMechanics::Spells& playerSpells = MWWorld::Class::get (player).getCreatureStats (player).getSpells();
MWMechanics::Spells& playerSpells = player.getClass().getCreatureStats (player).getSpells();
for (MWMechanics::Spells::TIterator it = playerSpells.begin(); it != playerSpells.end(); ++it)
{
if (Misc::StringUtils::ciEqual(id, it->first))
@ -121,7 +121,7 @@ namespace MWGui
int price = *_sender->getUserData<int>();
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
MWMechanics::Spells& spells = stats.getSpells();
spells.add (mSpellsWidgetMap.find(_sender)->second);
player.getClass().getContainerStore(player).remove(MWWorld::ContainerStore::sGoldId, price, player);

@ -353,7 +353,7 @@ namespace MWGui
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->createRecord(mSpell);
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
MWMechanics::Spells& spells = stats.getSpells();
spells.add (spell->mId);
@ -445,7 +445,7 @@ namespace MWGui
// get the list of magic effects that are known to the player
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
MWMechanics::Spells& spells = stats.getSpells();
std::vector<short> knownEffects;

@ -40,14 +40,14 @@ namespace MWGui
// TODO: Tracking add/remove/expire would be better than force updating every frame
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
const MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
const MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
EffectSourceVisitor visitor;
// permanent item enchantments & permanent spells
visitor.mIsPermanent = true;
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
store.visitEffectSources(visitor);
stats.getSpells().visitEffectSources(visitor);

@ -84,8 +84,8 @@ namespace MWGui
// retrieve all player spells, divide them into Powers and Spells and sort them
std::vector<std::string> spellList;
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
MWMechanics::Spells& spells = stats.getSpells();
for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it)
@ -122,7 +122,7 @@ namespace MWGui
std::vector<MWWorld::Ptr> items;
for (MWWorld::ContainerStoreIterator it(store.begin()); it != store.end(); ++it)
{
std::string enchantId = MWWorld::Class::get(*it).getEnchantment(*it);
std::string enchantId = it->getClass().getEnchantment(*it);
if (enchantId != "")
{
// only add items with "Cast once" or "Cast on use"
@ -203,7 +203,7 @@ namespace MWGui
MWWorld::Ptr item = *it;
const ESM::Enchantment* enchant =
esmStore.get<ESM::Enchantment>().find(MWWorld::Class::get(item).getEnchantment(item));
esmStore.get<ESM::Enchantment>().find(item.getClass().getEnchantment(item));
// check if the item is currently equipped (will display in a different color)
bool equipped = false;
@ -218,7 +218,7 @@ namespace MWGui
MyGUI::Button* t = mSpellView->createWidget<MyGUI::Button>(equipped ? "SpellText" : "SpellTextUnequipped",
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
t->setCaption(MWWorld::Class::get(item).getName(item));
t->setCaption(item.getClass().getName(item));
t->setTextAlign(MyGUI::Align::Left);
t->setUserData(item);
t->setUserString("ToolTipType", "ItemPtr");
@ -300,7 +300,7 @@ namespace MWGui
void SpellWindow::onEnchantedItemSelected(MyGUI::Widget* _sender)
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
MWWorld::Ptr item = *_sender->getUserData<MWWorld::Ptr>();
// retrieve ContainerStoreIterator to the item
@ -316,7 +316,7 @@ namespace MWGui
// equip, if it can be equipped and is not already equipped
if (_sender->getUserString("Equipped") == "false"
&& !MWWorld::Class::get(item).getEquipmentSlots(item).first.empty())
&& !item.getClass().getEquipmentSlots(item).first.empty())
{
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->useItem(item);
}
@ -330,7 +330,7 @@ namespace MWGui
{
std::string spellId = _sender->getUserString("Spell");
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
if (MyGUI::InputManager::getInstance().isShiftPressed())
{
@ -384,7 +384,7 @@ namespace MWGui
void SpellWindow::onDeleteSpellAccept()
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
MWMechanics::Spells& spells = stats.getSpells();
if (MWBase::Environment::get().getWindowManager()->getSelectedSpell() == mSpellToDelete)

@ -228,7 +228,7 @@ namespace MWGui
NoDrop::onFrame(dt);
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
const MWMechanics::NpcStats &PCstats = MWWorld::Class::get(player).getNpcStats(player);
const MWMechanics::NpcStats &PCstats = player.getClass().getNpcStats(player);
// level progress
MyGUI::Widget* levelWidget;
@ -459,7 +459,7 @@ namespace MWGui
addSeparator(coord1, coord2);
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
const MWMechanics::NpcStats &PCstats = MWWorld::Class::get(player).getNpcStats(player);
const MWMechanics::NpcStats &PCstats = player.getClass().getNpcStats(player);
const std::set<std::string> &expelled = PCstats.getExpelled();
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sFaction", "Faction"), coord1, coord2);

@ -89,7 +89,7 @@ namespace MWGui
if (mFocusObject.isEmpty ())
return;
const MWWorld::Class& objectclass = MWWorld::Class::get (mFocusObject);
const MWWorld::Class& objectclass = mFocusObject.getClass();
MyGUI::IntSize tooltipSize;
if ((!objectclass.hasToolTip(mFocusObject))&&(MWBase::Environment::get().getWindowManager()->getMode() == GM_Console))
@ -305,7 +305,7 @@ namespace MWGui
MyGUI::IntSize tooltipSize;
const MWWorld::Class& object = MWWorld::Class::get (mFocusObject);
const MWWorld::Class& object = mFocusObject.getClass();
if (!object.hasToolTip(mFocusObject))
{
mDynamicToolTipBox->setVisible(false);
@ -547,9 +547,10 @@ namespace MWGui
return " (" + boost::lexical_cast<std::string>(value) + ")";
}
void ToolTips::toggleFullHelp()
bool ToolTips::toggleFullHelp()
{
mFullHelp = !mFullHelp;
return mFullHelp;
}
bool ToolTips::getFullHelp() const

@ -45,7 +45,7 @@ namespace MWGui
void setEnabled(bool enabled);
void toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
bool toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
bool getFullHelp() const;
void setDelay(float delay);

@ -138,7 +138,7 @@ namespace MWGui
int services = 0;
if (!mMerchant.isEmpty())
services = MWWorld::Class::get(mMerchant).getServices(mMerchant);
services = mMerchant.getClass().getServices(mMerchant);
mItems.clear();
// add regular items
@ -150,7 +150,7 @@ namespace MWGui
MWWorld::Ptr base = item.mBase;
if(Misc::StringUtils::ciEqual(base.getCellRef().mRefID, MWWorld::ContainerStore::sGoldId))
continue;
if(!MWWorld::Class::get(base).canSell(base, services))
if(!base.getClass().canSell(base, services))
continue;
// Bound items may not be bought
@ -164,7 +164,7 @@ namespace MWGui
if(mMerchant.getClass().hasInventoryStore(mMerchant))
{
bool isEquipped = false;
MWWorld::InventoryStore& store = MWWorld::Class::get(mMerchant).getInventoryStore(mMerchant);
MWWorld::InventoryStore& store = mMerchant.getClass().getInventoryStore(mMerchant);
for (int slot=0; slot<MWWorld::InventoryStore::Slots; ++slot)
{
MWWorld::ContainerStoreIterator equipped = store.getSlot(slot);

@ -84,7 +84,7 @@ namespace MWGui
mCurrentBalance = 0;
mCurrentMerchantOffer = 0;
checkTradeTime();
restock();
std::vector<MWWorld::Ptr> itemSources;
MWBase::Environment::get().getWorld()->getContainersOwnedBy(actor, itemSources);
@ -102,7 +102,7 @@ namespace MWGui
// Careful here. setTitle may cause size updates, causing itemview redraw, so make sure to do it last
// or we end up using a possibly invalid model.
setTitle(MWWorld::Class::get(actor).getName(actor));
setTitle(actor.getClass().getName(actor));
onFilterChanged(mFilterAll);
}
@ -133,7 +133,7 @@ namespace MWGui
int TradeWindow::getMerchantServices()
{
return MWWorld::Class::get(mPtr).getServices(mPtr);
return mPtr.getClass().getServices(mPtr);
}
void TradeWindow::onItemSelected (int index)
@ -150,7 +150,7 @@ namespace MWGui
{
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
std::string message = "#{sQuanityMenuMessage02}";
dialog->open(MWWorld::Class::get(object).getName(object), message, count);
dialog->open(object.getClass().getName(object), message, count);
dialog->eventOkClicked.clear();
dialog->eventOkClicked += MyGUI::newDelegate(this, &TradeWindow::sellItem);
mItemToSell = mSortModel->mapToSource(index);
@ -165,7 +165,7 @@ namespace MWGui
void TradeWindow::sellItem(MyGUI::Widget* sender, int count)
{
const ItemStack& item = mTradeModel->getItem(mItemToSell);
std::string sound = MWWorld::Class::get(item.mBase).getDownSoundId(item.mBase);
std::string sound = item.mBase.getClass().getDownSoundId(item.mBase);
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
TradeItemModel* playerTradeModel = MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel();
@ -208,7 +208,7 @@ namespace MWGui
void TradeWindow::addOrRemoveGold(int amount, const MWWorld::Ptr& actor)
{
MWWorld::ContainerStore& store = MWWorld::Class::get(actor).getContainerStore(actor);
MWWorld::ContainerStore& store = actor.getClass().getContainerStore(actor);
if (amount > 0)
{
@ -364,8 +364,6 @@ namespace MWGui
mPtr.getClass().getCreatureStats(mPtr).getGoldPool() - mCurrentBalance );
}
updateTradeTime();
MWBase::Environment::get().getWindowManager()->getDialogueWindow()->addResponse(
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sBarterDialog5")->getString());
@ -444,7 +442,7 @@ namespace MWGui
void TradeWindow::sellToNpc(const MWWorld::Ptr& item, int count, bool boughtItem)
{
int diff = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count, boughtItem);
int diff = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, item.getClass().getValue(item) * count, boughtItem);
mCurrentBalance += diff;
mCurrentMerchantOffer += diff;
@ -454,7 +452,7 @@ namespace MWGui
void TradeWindow::buyFromNpc(const MWWorld::Ptr& item, int count, bool soldItem)
{
int diff = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count, !soldItem);
int diff = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, item.getClass().getValue(item) * count, !soldItem);
mCurrentBalance -= diff;
mCurrentMerchantOffer -= diff;
@ -475,30 +473,26 @@ namespace MWGui
return merchantGold;
}
// Relates to NPC gold reset delay
void TradeWindow::checkTradeTime()
void TradeWindow::restock()
{
MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr);
double delay = boost::lexical_cast<double>(MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fBarterGoldResetDelay")->getInt());
float delay = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fBarterGoldResetDelay")->getFloat();
// if time stamp longer than gold reset delay, reset gold.
if (MWBase::Environment::get().getWorld()->getTimeStamp() >= sellerStats.getTradeTime() + delay)
if (MWBase::Environment::get().getWorld()->getTimeStamp() >= sellerStats.getLastRestockTime() + delay)
{
sellerStats.setGoldPool(mPtr.getClass().getBaseGold(mPtr));
}
}
void TradeWindow::updateTradeTime()
{
MWWorld::ContainerStore store = mPtr.getClass().getContainerStore(mPtr);
MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr);
double delay = boost::lexical_cast<double>(MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fBarterGoldResetDelay")->getInt());
mPtr.getClass().restock(mPtr);
// If trade timestamp is within reset delay don't set
if ( ! (MWBase::Environment::get().getWorld()->getTimeStamp() >= sellerStats.getTradeTime() &&
MWBase::Environment::get().getWorld()->getTimeStamp() < sellerStats.getTradeTime() + delay) )
{
sellerStats.setTradeTime(MWBase::Environment::get().getWorld()->getTimeStamp());
// Also restock any containers owned by this merchant, which are also available to buy in the trade window
std::vector<MWWorld::Ptr> itemSources;
MWBase::Environment::get().getWorld()->getContainersOwnedBy(mPtr, itemSources);
for (std::vector<MWWorld::Ptr>::iterator it = itemSources.begin(); it != itemSources.end(); ++it)
{
it->getClass().restock(*it);
}
sellerStats.setLastRestockTime(MWBase::Environment::get().getWorld()->getTimeStamp());
}
}
}

@ -101,9 +101,7 @@ namespace MWGui
int getMerchantGold();
// Relates to NPC gold reset delay
void checkTradeTime();
void updateTradeTime();
void restock();
};
}

@ -44,7 +44,7 @@ namespace MWGui
mPlayerGold->setCaptionWithReplacing("#{sGold}: " + boost::lexical_cast<std::string>(playerGold));
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(actor).getNpcStats (actor);
MWMechanics::NpcStats& npcStats = actor.getClass().getNpcStats (actor);
// NPC can train you in his best 3 skills
std::vector< std::pair<int, int> > bestSkills;
@ -73,7 +73,7 @@ namespace MWGui
MyGUI::EnumeratorWidgetPtr widgets = mTrainingOptions->getEnumerator ();
MyGUI::Gui::getInstance ().destroyWidgets (widgets);
MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player);
MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats (player);
const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
@ -115,7 +115,7 @@ namespace MWGui
int skillId = *sender->getUserData<int>();
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player);
MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats (player);
const MWWorld::ESMStore &store =
MWBase::Environment::get().getWorld()->getStore();
@ -123,7 +123,7 @@ namespace MWGui
int price = pcStats.getSkill (skillId).getBase() * store.get<ESM::GameSetting>().find("iTrainingMod")->getInt ();
price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true);
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(mPtr).getNpcStats (mPtr);
MWMechanics::NpcStats& npcStats = mPtr.getClass().getNpcStats (mPtr);
if (npcStats.getSkill (skillId).getBase () <= pcStats.getSkill (skillId).getBase ())
{
MWBase::Environment::get().getWindowManager()->messageBox ("#{sServiceTrainingWords}");

@ -161,7 +161,7 @@ namespace MWGui
MWBase::Environment::get().getWorld()->changeToExteriorCell(pos);
}
MWWorld::Class::get(player).adjustPosition(player);
player.getClass().adjustPosition(player);
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Travel);
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Dialogue);
MWBase::Environment::get().getWorld ()->getFader ()->fadeOut(0);

@ -171,11 +171,11 @@ namespace MWGui
void WaitDialog::setCanRest (bool canRest)
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
bool full = (stats.getFatigue().getCurrent() >= stats.getFatigue().getModified())
&& (stats.getHealth().getCurrent() >= stats.getHealth().getModified())
&& (stats.getMagicka().getCurrent() >= stats.getMagicka().getModified());
MWMechanics::NpcStats& npcstats = MWWorld::Class::get(player).getNpcStats(player);
MWMechanics::NpcStats& npcstats = player.getClass().getNpcStats(player);
bool werewolf = npcstats.isWerewolf();
mUntilHealedButton->setVisible(canRest && !full);
@ -231,7 +231,7 @@ namespace MWGui
mWaiting = false;
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
const MWMechanics::NpcStats &pcstats = MWWorld::Class::get(player).getNpcStats(player);
const MWMechanics::NpcStats &pcstats = player.getClass().getNpcStats(player);
// trigger levelup if possible
const MWWorld::Store<ESM::GameSetting> &gmst =

@ -158,7 +158,6 @@ namespace MWGui
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::AutoSizedButton>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::ImageButton>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::ExposedWindow>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWScrollView>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWScrollBar>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<VideoWidget>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<BackgroundImage>("Widget");
@ -299,6 +298,7 @@ namespace MWGui
delete mCharGen;
mCharGen = new CharacterCreation();
mGuiModes.clear();
MWBase::Environment::get().getInputManager()->changeInputMode(false);
mHud->unsetSelectedWeapon();
mHud->unsetSelectedSpell();
unsetForceHide(GW_ALL);
@ -814,10 +814,10 @@ namespace MWGui
mHud->setMinimapVisible (visible);
}
void WindowManager::toggleFogOfWar()
bool WindowManager::toggleFogOfWar()
{
mMap->toggleFogOfWar();
mHud->toggleFogOfWar();
return mHud->toggleFogOfWar();
}
void WindowManager::setFocusObject(const MWWorld::Ptr& focus)
@ -830,9 +830,9 @@ namespace MWGui
mToolTips->setFocusObjectScreenCoords(min_x, min_y, max_x, max_y);
}
void WindowManager::toggleFullHelp()
bool WindowManager::toggleFullHelp()
{
mToolTips->toggleFullHelp();
return mToolTips->toggleFullHelp();
}
bool WindowManager::getFullHelp() const
@ -1027,20 +1027,20 @@ namespace MWGui
{
mSelectedSpell = "";
const ESM::Enchantment* ench = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>()
.find(MWWorld::Class::get(item).getEnchantment(item));
.find(item.getClass().getEnchantment(item));
int chargePercent = (item.getCellRef().mEnchantmentCharge == -1) ? 100
: (item.getCellRef().mEnchantmentCharge / static_cast<float>(ench->mData.mCharge) * 100);
mHud->setSelectedEnchantItem(item, chargePercent);
mSpellWindow->setTitle(MWWorld::Class::get(item).getName(item));
mSpellWindow->setTitle(item.getClass().getName(item));
}
void WindowManager::setSelectedWeapon(const MWWorld::Ptr& item)
{
int durabilityPercent = (item.getCellRef().mCharge == -1) ? 100
: (item.getCellRef().mCharge / static_cast<float>(MWWorld::Class::get(item).getItemMaxHealth(item)) * 100);
: (item.getCellRef().mCharge / static_cast<float>(item.getClass().getItemMaxHealth(item)) * 100);
mHud->setSelectedWeapon(item, durabilityPercent);
mInventoryWindow->setTitle(MWWorld::Class::get(item).getName(item));
mInventoryWindow->setTitle(item.getClass().getName(item));
}
void WindowManager::unsetSelectedSpell()
@ -1413,6 +1413,7 @@ namespace MWGui
mConsole->resetReference();
mGuiModes.clear();
MWBase::Environment::get().getInputManager()->changeInputMode(false);
updateVisible();
}

@ -188,8 +188,8 @@ namespace MWGui
virtual void setDragDrop(bool dragDrop);
virtual bool getWorldMouseOver();
virtual void toggleFogOfWar();
virtual void toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
virtual bool toggleFogOfWar();
virtual bool toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
virtual bool getFullHelp() const;
virtual void setActiveMap(int x, int y, bool interior);

@ -172,7 +172,7 @@ namespace MWInput
if (action == A_Use)
{
MWWorld::Class::get(mPlayer->getPlayer()).getCreatureStats(mPlayer->getPlayer()).setAttackingOrSpell(currentValue);
mPlayer->getPlayer().getClass().getCreatureStats(mPlayer->getPlayer()).setAttackingOrSpell(currentValue);
}
if (currentValue == 1)
@ -359,7 +359,7 @@ namespace MWInput
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
mOverencumberedMessageDelay -= dt;
if (MWWorld::Class::get(player).getEncumbrance(player) >= MWWorld::Class::get(player).getCapacity(player))
if (player.getClass().getEncumbrance(player) >= player.getClass().getCapacity(player))
{
mPlayer->setAutoMove (false);
if (mOverencumberedMessageDelay <= 0)
@ -664,7 +664,7 @@ namespace MWInput
return;
// Not allowed if no spell selected
MWWorld::InventoryStore& inventory = MWWorld::Class::get(mPlayer->getPlayer()).getInventoryStore(mPlayer->getPlayer());
MWWorld::InventoryStore& inventory = mPlayer->getPlayer().getClass().getInventoryStore(mPlayer->getPlayer());
if (MWBase::Environment::get().getWindowManager()->getSelectedSpell().empty() &&
inventory.getSelectedEnchantItem() == inventory.end())
return;

@ -187,7 +187,7 @@ namespace MWMechanics
void Actors::engageCombat (const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2, bool againstPlayer)
{
CreatureStats& creatureStats = MWWorld::Class::get(actor1).getCreatureStats(actor1);
CreatureStats& creatureStats = actor1.getClass().getCreatureStats(actor1);
if (againstPlayer && creatureStats.isHostile()) return; // already fighting against player
@ -244,13 +244,13 @@ namespace MWMechanics
void Actors::adjustMagicEffects (const MWWorld::Ptr& creature)
{
CreatureStats& creatureStats = MWWorld::Class::get (creature).getCreatureStats (creature);
CreatureStats& creatureStats = creature.getClass().getCreatureStats (creature);
MagicEffects now = creatureStats.getSpells().getMagicEffects();
if (creature.getTypeName()==typeid (ESM::NPC).name())
{
MWWorld::InventoryStore& store = MWWorld::Class::get (creature).getInventoryStore (creature);
MWWorld::InventoryStore& store = creature.getClass().getInventoryStore (creature);
now += store.getMagicEffects();
}
@ -265,7 +265,7 @@ namespace MWMechanics
void Actors::calculateDynamicStats (const MWWorld::Ptr& ptr)
{
CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
CreatureStats& creatureStats = ptr.getClass().getCreatureStats (ptr);
int strength = creatureStats.getAttribute(ESM::Attribute::Strength).getBase();
int intelligence = creatureStats.getAttribute(ESM::Attribute::Intelligence).getBase();
@ -333,7 +333,7 @@ namespace MWMechanics
void Actors::calculateCreatureStatModifiers (const MWWorld::Ptr& ptr, float duration)
{
CreatureStats &creatureStats = MWWorld::Class::get(ptr).getCreatureStats(ptr);
CreatureStats &creatureStats = ptr.getClass().getCreatureStats(ptr);
const MagicEffects &effects = creatureStats.getMagicEffects();
// attributes
@ -551,7 +551,7 @@ namespace MWMechanics
MWMechanics::CreatureStats& summonedCreatureStats = ref.getPtr().getClass().getCreatureStats(ref.getPtr());
// Make the summoned creature follow its master and help in fights
AiFollow package(ptr);
AiFollow package(ptr.getRefData().getHandle());
summonedCreatureStats.getAiSequence().stack(package, ref.getPtr());
int creatureActorId = summonedCreatureStats.getActorId();
@ -600,7 +600,7 @@ namespace MWMechanics
void Actors::calculateNpcStatModifiers (const MWWorld::Ptr& ptr)
{
NpcStats &npcStats = MWWorld::Class::get(ptr).getNpcStats(ptr);
NpcStats &npcStats = ptr.getClass().getNpcStats(ptr);
const MagicEffects &effects = npcStats.getMagicEffects();
// skills
@ -656,7 +656,7 @@ namespace MWMechanics
{
bool isPlayer = ptr.getRefData().getHandle()=="player";
MWWorld::InventoryStore &inventoryStore = MWWorld::Class::get(ptr).getInventoryStore(ptr);
MWWorld::InventoryStore &inventoryStore = ptr.getClass().getInventoryStore(ptr);
MWWorld::ContainerStoreIterator heldIter =
inventoryStore.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
/**
@ -678,7 +678,7 @@ namespace MWMechanics
{
if (torch != inventoryStore.end())
{
if (!MWWorld::Class::get (ptr).getCreatureStats (ptr).isHostile())
if (!ptr.getClass().getCreatureStats (ptr).isHostile())
{
// For non-hostile NPCs, unequip whatever is in the left slot in favor of a light.
if (heldIter != inventoryStore.end() && heldIter->getTypeName() != typeid(ESM::Light).name())
@ -755,8 +755,8 @@ namespace MWMechanics
if (ptr != player && ptr.getClass().isNpc())
{
// get stats of witness
CreatureStats& creatureStats = MWWorld::Class::get(ptr).getCreatureStats(ptr);
NpcStats& npcStats = MWWorld::Class::get(ptr).getNpcStats(ptr);
CreatureStats& creatureStats = ptr.getClass().getCreatureStats(ptr);
NpcStats& npcStats = ptr.getClass().getNpcStats(ptr);
if (ptr.getClass().isClass(ptr, "Guard") && creatureStats.getAiSequence().getTypeId() != AiPackage::TypeIdPursue && !creatureStats.isHostile())
{
@ -796,7 +796,7 @@ namespace MWMechanics
// Update witness crime id
npcStats.setCrimeId(-1);
}
else if (!creatureStats.isHostile())
else if (!creatureStats.isHostile() && creatureStats.getAiSequence().getTypeId() != AiPackage::TypeIdPursue)
{
if (ptr.getClass().isClass(ptr, "Guard"))
creatureStats.getAiSequence().stack(AiPursue(player), ptr);
@ -824,7 +824,7 @@ namespace MWMechanics
void Actors::addActor (const MWWorld::Ptr& ptr, bool updateImmediately)
{
// erase previous death events since we are currently only tracking them while in an active cell
MWWorld::Class::get(ptr).getCreatureStats(ptr).clearHasDied();
ptr.getClass().getCreatureStats(ptr).clearHasDied();
removeActor(ptr);
@ -964,7 +964,7 @@ namespace MWMechanics
// Kill dead actors, update some variables
for(PtrControllerMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter)
{
const MWWorld::Class &cls = MWWorld::Class::get(iter->first);
const MWWorld::Class &cls = iter->first.getClass();
CreatureStats &stats = cls.getCreatureStats(iter->first);
//KnockedOutOneFrameLogic
@ -1137,7 +1137,7 @@ namespace MWMechanics
std::list<MWWorld::Ptr> list;
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();iter++)
{
const MWWorld::Class &cls = MWWorld::Class::get(iter->first);
const MWWorld::Class &cls = iter->first.getClass();
CreatureStats &stats = cls.getCreatureStats(iter->first);
if(!stats.isDead() && stats.getAiSequence().getTypeId() == AiPackage::TypeIdFollow)
{
@ -1158,7 +1158,7 @@ namespace MWMechanics
neighbors); //only care about those within the alarm disance
for(std::vector<MWWorld::Ptr>::iterator iter(neighbors.begin());iter != neighbors.end();iter++)
{
const MWWorld::Class &cls = MWWorld::Class::get(*iter);
const MWWorld::Class &cls = iter->getClass();
CreatureStats &stats = cls.getCreatureStats(*iter);
if(!stats.isDead() && stats.getAiSequence().getTypeId() == AiPackage::TypeIdCombat)
{

@ -32,7 +32,7 @@ bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor,float duration)
if(distance(dest, pos.pos[0], pos.pos[1], pos.pos[2]) < 200) { //Stop when you get close
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(mObjectId,false);
MWWorld::Class::get(target).activate(target,actor).get()->execute(actor); //Arrest player
target.getClass().activate(target,actor).get()->execute(actor); //Arrest player
return true;
}
else {

@ -63,7 +63,7 @@ bool MWMechanics::AiAvoidDoor::execute (const MWWorld::Ptr& actor,float duration
MWBase::Environment::get().getMechanicsManager()->getActorsInRange(Ogre::Vector3(pos.pos[0],pos.pos[1],pos.pos[2]),100,actors);
for(std::vector<MWWorld::Ptr>::iterator it = actors.begin(); it != actors.end(); it++) {
if(*it != MWBase::Environment::get().getWorld()->getPlayerPtr()) { //Not the player
MWMechanics::AiSequence& seq = MWWorld::Class::get(*it).getCreatureStats(*it).getAiSequence();
MWMechanics::AiSequence& seq = it->getClass().getCreatureStats(*it).getAiSequence();
if(seq.getTypeId() != MWMechanics::AiPackage::TypeIdAvoidDoor) { //Only add it once
seq.stack(MWMechanics::AiAvoidDoor(mDoorPtr),*it);
}

@ -8,8 +8,6 @@
#include "../mwworld/class.hpp"
#include "../mwworld/timestamp.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "steering.hpp"
#include "movement.hpp"
@ -21,8 +19,8 @@
namespace MWMechanics
{
AiEscort::AiEscort(const MWWorld::Ptr& actor, int duration, float x, float y, float z)
: mActorId(actor.getClass().getCreatureStats(actor).getActorId()), mX(x), mY(y), mZ(z), mDuration(duration)
AiEscort::AiEscort(const std::string &actorId, int duration, float x, float y, float z)
: mActorId(actorId), mX(x), mY(y), mZ(z), mDuration(duration)
, mCellX(std::numeric_limits<int>::max())
, mCellY(std::numeric_limits<int>::max())
{
@ -40,8 +38,8 @@ namespace MWMechanics
}
}
AiEscort::AiEscort(const MWWorld::Ptr& actor, const std::string &cellId,int duration, float x, float y, float z)
: mActorId(actor.getClass().getCreatureStats(actor).getActorId()), mCellId(cellId), mX(x), mY(y), mZ(z), mDuration(duration)
AiEscort::AiEscort(const std::string &actorId, const std::string &cellId,int duration, float x, float y, float z)
: mActorId(actorId), mCellId(cellId), mX(x), mY(y), mZ(z), mDuration(duration)
, mCellX(std::numeric_limits<int>::max())
, mCellY(std::numeric_limits<int>::max())
{
@ -77,14 +75,7 @@ namespace MWMechanics
return true;
}
const MWWorld::Ptr follower = MWBase::Environment::get().getWorld()->searchPtrViaActorId(mActorId);
if (follower.isEmpty())
{
// The follower disappeared
MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0;
return true;
}
const MWWorld::Ptr follower = MWBase::Environment::get().getWorld()->getPtr(mActorId, false);
const float* const leaderPos = actor.getRefData().getPosition().pos;
const float* const followerPos = follower.getRefData().getPosition().pos;
double differenceBetween[3];
@ -98,7 +89,7 @@ namespace MWMechanics
if(distanceBetweenResult <= mMaxDist * mMaxDist)
{
if(pathTo(actor,ESM::Pathgrid::Point(mX,mY,mZ),duration)) //Returns true on path complete
if(pathTo(actor,ESM::Pathgrid::Point(mX,mY,mZ),duration)) //Returns true on path complete
return true;
mMaxDist = 470;
}
@ -106,7 +97,7 @@ namespace MWMechanics
{
// Stop moving if the player is to far away
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(actor, "idle3", 0, 1);
MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0;
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
mMaxDist = 330;
}

@ -15,11 +15,11 @@ namespace MWMechanics
/// Implementation of AiEscort
/** The Actor will escort the specified actor to the world position x, y, z until they reach their position, or they run out of time
\implement AiEscort **/
AiEscort(const MWWorld::Ptr& actor,int duration, float x, float y, float z);
AiEscort(const std::string &actorId,int duration, float x, float y, float z);
/// Implementation of AiEscortCell
/** The Actor will escort the specified actor to the cell position x, y, z until they reach their position, or they run out of time
\implement AiEscortCell **/
AiEscort(const MWWorld::Ptr& actor,const std::string &cellId,int duration, float x, float y, float z);
AiEscort(const std::string &actorId,const std::string &cellId,int duration, float x, float y, float z);
virtual AiEscort *clone() const;
@ -28,7 +28,7 @@ namespace MWMechanics
virtual int getTypeId() const;
private:
int mActorId;
std::string mActorId;
std::string mCellId;
float mX;
float mY;

@ -11,26 +11,23 @@
#include "steering.hpp"
MWMechanics::AiFollow::AiFollow(const MWWorld::Ptr& actor,float duration, float x, float y, float z)
: mAlwaysFollow(false), mDuration(duration), mX(x), mY(y), mZ(z), mCellId(""), AiPackage()
MWMechanics::AiFollow::AiFollow(const std::string &actorId,float duration, float x, float y, float z)
: mAlwaysFollow(false), mDuration(duration), mX(x), mY(y), mZ(z), mActorId(actorId), mCellId(""), AiPackage()
{
mActorId = actor.getClass().getCreatureStats(actor).getActorId();
}
MWMechanics::AiFollow::AiFollow(const MWWorld::Ptr& actor,const std::string &cellId,float duration, float x, float y, float z)
: mAlwaysFollow(false), mDuration(duration), mX(x), mY(y), mZ(z), mCellId(cellId), AiPackage()
MWMechanics::AiFollow::AiFollow(const std::string &actorId,const std::string &cellId,float duration, float x, float y, float z)
: mAlwaysFollow(false), mDuration(duration), mX(x), mY(y), mZ(z), mActorId(actorId), mCellId(cellId), AiPackage()
{
mActorId = actor.getClass().getCreatureStats(actor).getActorId();
}
MWMechanics::AiFollow::AiFollow(const MWWorld::Ptr& actor)
: mAlwaysFollow(true), mDuration(0), mX(0), mY(0), mZ(0), mCellId(""), AiPackage()
MWMechanics::AiFollow::AiFollow(const std::string &actorId)
: mAlwaysFollow(true), mDuration(0), mX(0), mY(0), mZ(0), mActorId(actorId), mCellId(""), AiPackage()
{
mActorId = actor.getClass().getCreatureStats(actor).getActorId();
}
bool MWMechanics::AiFollow::execute (const MWWorld::Ptr& actor,float duration)
{
const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtrViaActorId(mActorId); //The target to follow
const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(mActorId, false); //The target to follow
if(target == MWWorld::Ptr()) return true; //Target doesn't exist
@ -78,8 +75,7 @@ bool MWMechanics::AiFollow::execute (const MWWorld::Ptr& actor,float duration)
std::string MWMechanics::AiFollow::getFollowedActor()
{
const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtrViaActorId(mActorId); //The target to follow
return target.getCellRef().mRefID;
return mActorId;
}
MWMechanics::AiFollow *MWMechanics::AiFollow::clone() const

@ -10,16 +10,16 @@ namespace MWMechanics
{
/// \brief AiPackage for an actor to follow another actor/the PC
/** The AI will follow the target until a condition (time, or position) are set. Both can be disabled to cause the actor to follow the other indefinitely
**/
class AiFollow : public AiPackage
{
**/
class AiFollow : public AiPackage
{
public:
/// Follow Actor for duration or until you arrive at a world position
AiFollow(const MWWorld::Ptr& actor,float duration, float X, float Y, float Z);
AiFollow(const std::string &ActorId,float duration, float X, float Y, float Z);
/// Follow Actor for duration or until you arrive at a position in a cell
AiFollow(const MWWorld::Ptr& actor,const std::string &CellId,float duration, float X, float Y, float Z);
AiFollow(const std::string &ActorId,const std::string &CellId,float duration, float X, float Y, float Z);
/// Follow Actor indefinitively
AiFollow(const MWWorld::Ptr& actor);
AiFollow(const std::string &ActorId);
virtual AiFollow *clone() const;
@ -38,8 +38,8 @@ namespace MWMechanics
float mX;
float mY;
float mZ;
int mActorId; // The actor we should follow
std::string mCellId;
};
}
#endif
std::string mActorId;
std::string mCellId;
};
}
#endif

@ -266,8 +266,7 @@ void AiSequence::fill(const ESM::AIPackageList &list)
else if (it->mType == ESM::AI_Escort)
{
ESM::AITarget data = it->mTarget;
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(data.mId.toString(), false);
package = new MWMechanics::AiEscort(target, data.mDuration, data.mX, data.mY, data.mZ);
package = new MWMechanics::AiEscort(data.mId.toString(), data.mDuration, data.mX, data.mY, data.mZ);
}
else if (it->mType == ESM::AI_Travel)
{
@ -282,8 +281,7 @@ void AiSequence::fill(const ESM::AIPackageList &list)
else //if (it->mType == ESM::AI_Follow)
{
ESM::AITarget data = it->mTarget;
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(data.mId.toString(), false);
package = new MWMechanics::AiFollow(target, data.mDuration, data.mX, data.mY, data.mZ);
package = new MWMechanics::AiFollow(data.mId.toString(), data.mDuration, data.mX, data.mY, data.mZ);
}
mPackages.push_back(package);
}

@ -572,7 +572,7 @@ namespace MWMechanics
void AiWander::stopWalking(const MWWorld::Ptr& actor)
{
mPathFinder.clearPath();
MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0;
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
}
void AiWander::playIdle(const MWWorld::Ptr& actor, unsigned short idleSelect)

@ -292,13 +292,13 @@ void MWMechanics::Alchemy::addPotion (const std::string& name)
void MWMechanics::Alchemy::increaseSkill()
{
MWWorld::Class::get (mAlchemist).skillUsageSucceeded (mAlchemist, ESM::Skill::Alchemy, 0);
mAlchemist.getClass().skillUsageSucceeded (mAlchemist, ESM::Skill::Alchemy, 0);
}
float MWMechanics::Alchemy::getChance() const
{
const CreatureStats& creatureStats = MWWorld::Class::get (mAlchemist).getCreatureStats (mAlchemist);
const NpcStats& npcStats = MWWorld::Class::get (mAlchemist).getNpcStats (mAlchemist);
const CreatureStats& creatureStats = mAlchemist.getClass().getCreatureStats (mAlchemist);
const NpcStats& npcStats = mAlchemist.getClass().getNpcStats (mAlchemist);
return
(npcStats.getSkill (ESM::Skill::Alchemy).getModified() +
@ -331,7 +331,7 @@ void MWMechanics::Alchemy::setAlchemist (const MWWorld::Ptr& npc)
mEffects.clear();
MWWorld::ContainerStore& store = MWWorld::Class::get (npc).getContainerStore (npc);
MWWorld::ContainerStore& store = npc.getClass().getContainerStore (npc);
for (MWWorld::ContainerStoreIterator iter (store.begin (MWWorld::ContainerStore::Type_Apparatus));
iter!=store.end(); ++iter)

@ -459,7 +459,7 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
if(!mAnimation)
return;
const MWWorld::Class &cls = MWWorld::Class::get(mPtr);
const MWWorld::Class &cls = mPtr.getClass();
if(cls.isActor())
{
/* Accumulate along X/Y only for now, until we can figure out how we should
@ -549,7 +549,7 @@ bool CharacterController::updateCreatureState()
bool CharacterController::updateWeaponState()
{
const MWWorld::Class &cls = MWWorld::Class::get(mPtr);
const MWWorld::Class &cls = mPtr.getClass();
CreatureStats &stats = cls.getCreatureStats(mPtr);
WeaponType weaptype = WeapType_None;
MWWorld::InventoryStore &inv = cls.getInventoryStore(mPtr);
@ -601,8 +601,8 @@ bool CharacterController::updateWeaponState()
if(weapon != inv.end() && !(weaptype == WeapType_None && mWeaponType == WeapType_Spell))
{
std::string soundid = (weaptype == WeapType_None) ?
MWWorld::Class::get(*weapon).getDownSoundId(*weapon) :
MWWorld::Class::get(*weapon).getUpSoundId(*weapon);
weapon->getClass().getDownSoundId(*weapon) :
weapon->getClass().getUpSoundId(*weapon);
if(!soundid.empty())
{
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
@ -983,7 +983,7 @@ bool CharacterController::updateWeaponState()
void CharacterController::update(float duration)
{
MWBase::World *world = MWBase::Environment::get().getWorld();
const MWWorld::Class &cls = MWWorld::Class::get(mPtr);
const MWWorld::Class &cls = mPtr.getClass();
Ogre::Vector3 movement(0.0f);
updateVisibility();

@ -22,7 +22,7 @@ namespace MWMechanics
mFallHeight(0), mRecalcDynamicStats(false), mKnockdown(false), mKnockdownOneFrame(false),
mKnockdownOverOneFrame(false), mHitRecovery(false), mBlock(false),
mMovementFlags(0), mDrawState (DrawState_Nothing), mAttackStrength(0.f),
mTradeTime(0,0), mGoldPool(0), mActorId(-1)
mLastRestock(0,0), mGoldPool(0), mActorId(-1)
{
for (int i=0; i<4; ++i)
mAiSettings[i] = 0;
@ -475,7 +475,7 @@ namespace MWMechanics
for (int i=0; i<3; ++i)
mDynamic[i].writeState (state.mDynamic[i]);
state.mTradeTime = mTradeTime.toEsm();
state.mTradeTime = mLastRestock.toEsm();
state.mGoldPool = mGoldPool;
state.mDead = mDead;
@ -513,7 +513,7 @@ namespace MWMechanics
for (int i=0; i<3; ++i)
mDynamic[i].readState (state.mDynamic[i]);
mTradeTime = MWWorld::TimeStamp(state.mTradeTime);
mLastRestock = MWWorld::TimeStamp(state.mTradeTime);
mGoldPool = state.mGoldPool;
mFallHeight = state.mFallHeight;
@ -544,15 +544,14 @@ namespace MWMechanics
mActiveSpells.readState(state.mActiveSpells);
}
// Relates to NPC gold reset delay
void CreatureStats::setTradeTime(MWWorld::TimeStamp tradeTime)
void CreatureStats::setLastRestockTime(MWWorld::TimeStamp tradeTime)
{
mTradeTime = tradeTime;
mLastRestock = tradeTime;
}
MWWorld::TimeStamp CreatureStats::getTradeTime() const
MWWorld::TimeStamp CreatureStats::getLastRestockTime() const
{
return mTradeTime;
return mLastRestock;
}
void CreatureStats::setGoldPool(int pool)

@ -56,9 +56,12 @@ namespace MWMechanics
// Do we need to recalculate stats derived from attributes or other factors?
bool mRecalcDynamicStats;
MWWorld::TimeStamp mTradeTime; // Relates to NPC gold reset delay
// For merchants: the last time items were restocked and gold pool refilled.
MWWorld::TimeStamp mLastRestock;
// The pool of merchant gold (not in inventory)
int mGoldPool;
int mGoldPool; // the pool of merchant gold not in inventory
int mActorId;
protected:
@ -241,9 +244,8 @@ namespace MWMechanics
static void writeActorIdCounter (ESM::ESMWriter& esm);
static void readActorIdCounter (ESM::ESMReader& esm);
// Relates to NPC gold reset delay
void setTradeTime(MWWorld::TimeStamp tradeTime);
MWWorld::TimeStamp getTradeTime() const;
void setLastRestockTime(MWWorld::TimeStamp tradeTime);
MWWorld::TimeStamp getLastRestockTime() const;
void setGoldPool(int pool);
int getGoldPool() const;

@ -52,7 +52,7 @@ namespace MWMechanics
bool Enchanting::create()
{
const MWWorld::Ptr& player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player);
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
ESM::Enchantment enchantment;
enchantment.mData.mCharge = getGemCharge();
@ -67,7 +67,7 @@ namespace MWMechanics
if(getEnchantChance()<std::rand()/static_cast<double> (RAND_MAX)*100)
return false;
MWWorld::Class::get (mEnchanter).skillUsageSucceeded (mEnchanter, ESM::Skill::Enchant, 2);
mEnchanter.getClass().skillUsageSucceeded (mEnchanter, ESM::Skill::Enchant, 2);
}
if(mCastStyle==ESM::Enchantment::ConstantEffect)
@ -84,7 +84,7 @@ namespace MWMechanics
// Apply the enchantment
const ESM::Enchantment *enchantmentPtr = MWBase::Environment::get().getWorld()->createRecord (enchantment);
MWWorld::Class::get(newItemPtr).applyEnchantment(newItemPtr, enchantmentPtr->mId, getGemCharge(), mNewItemName);
newItemPtr.getClass().applyEnchantment(newItemPtr, enchantmentPtr->mId, getGemCharge(), mNewItemName);
// Add the new item to player inventory and remove the old one
store.remove(mOldItemPtr, 1, player);
@ -212,7 +212,7 @@ namespace MWMechanics
const float enchantCost = getEnchantPoints();
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWMechanics::NpcStats &stats = MWWorld::Class::get(player).getNpcStats(player);
MWMechanics::NpcStats &stats = player.getClass().getNpcStats(player);
int eSkill = stats.getSkill(ESM::Skill::Enchant).getModified();
/*
@ -277,7 +277,7 @@ namespace MWMechanics
float Enchanting::getEnchantChance() const
{
const NpcStats& npcStats = MWWorld::Class::get (mEnchanter).getNpcStats (mEnchanter);
const NpcStats& npcStats = mEnchanter.getClass().getNpcStats (mEnchanter);
float chance1 = (npcStats.getSkill (ESM::Skill::Enchant).getModified() +
(0.25 * npcStats.getAttribute (ESM::Attribute::Intelligence).getModified())
@ -295,7 +295,7 @@ namespace MWMechanics
void Enchanting::payForEnchantment() const
{
const MWWorld::Ptr& player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player);
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
store.remove(MWWorld::ContainerStore::sGoldId, getEnchantPrice(), player);
}

@ -49,8 +49,8 @@ namespace MWMechanics
{
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr);
MWMechanics::CreatureStats& creatureStats = ptr.getClass().getCreatureStats (ptr);
MWMechanics::NpcStats& npcStats = ptr.getClass().getNpcStats (ptr);
const ESM::NPC *player = ptr.get<ESM::NPC>()->mBase;
@ -215,7 +215,7 @@ namespace MWMechanics
void MechanicsManager::add(const MWWorld::Ptr& ptr)
{
if(MWWorld::Class::get(ptr).isActor())
if(ptr.getClass().isActor())
mActors.addActor(ptr);
else
mObjects.addObject(ptr);
@ -234,7 +234,7 @@ namespace MWMechanics
if(old == mWatched)
mWatched = ptr;
if(MWWorld::Class::get(ptr).isActor())
if(ptr.getClass().isActor())
mActors.updateActor(old, ptr);
else
mObjects.updateObject(old, ptr);
@ -475,13 +475,13 @@ namespace MWMechanics
int MechanicsManager::getDerivedDisposition(const MWWorld::Ptr& ptr)
{
const MWMechanics::NpcStats& npcSkill = MWWorld::Class::get(ptr).getNpcStats(ptr);
const MWMechanics::NpcStats& npcSkill = ptr.getClass().getNpcStats(ptr);
float x = npcSkill.getBaseDisposition();
MWWorld::LiveCellRef<ESM::NPC>* npc = ptr.get<ESM::NPC>();
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWWorld::LiveCellRef<ESM::NPC>* player = playerPtr.get<ESM::NPC>();
const MWMechanics::NpcStats &playerStats = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr);
const MWMechanics::NpcStats &playerStats = playerPtr.getClass().getNpcStats(playerPtr);
if (Misc::StringUtils::ciEqual(npc->mBase->mRace, player->mBase->mRace))
x += MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispRaceMod")->getFloat();
@ -547,10 +547,10 @@ namespace MWMechanics
if (ptr.getTypeName() == typeid(ESM::Creature).name())
return basePrice;
const MWMechanics::NpcStats &sellerStats = MWWorld::Class::get(ptr).getNpcStats(ptr);
const MWMechanics::NpcStats &sellerStats = ptr.getClass().getNpcStats(ptr);
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
const MWMechanics::NpcStats &playerStats = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr);
const MWMechanics::NpcStats &playerStats = playerPtr.getClass().getNpcStats(playerPtr);
// I suppose the temporary disposition change _has_ to be considered here,
// otherwise one would get different prices when exiting and re-entering the dialogue window...
@ -592,10 +592,10 @@ namespace MWMechanics
const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(npc).getNpcStats(npc);
MWMechanics::NpcStats& npcStats = npc.getClass().getNpcStats(npc);
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
const MWMechanics::NpcStats &playerStats = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr);
const MWMechanics::NpcStats &playerStats = playerPtr.getClass().getNpcStats(playerPtr);
float persTerm = playerStats.getAttribute(ESM::Attribute::Personality).getModified()
/ gmst.find("fPersonalityMod")->getFloat();
@ -741,27 +741,27 @@ namespace MWMechanics
void MechanicsManager::forceStateUpdate(const MWWorld::Ptr &ptr)
{
if(MWWorld::Class::get(ptr).isActor())
if(ptr.getClass().isActor())
mActors.forceStateUpdate(ptr);
}
void MechanicsManager::playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number)
{
if(MWWorld::Class::get(ptr).isActor())
if(ptr.getClass().isActor())
mActors.playAnimationGroup(ptr, groupName, mode, number);
else
mObjects.playAnimationGroup(ptr, groupName, mode, number);
}
void MechanicsManager::skipAnimation(const MWWorld::Ptr& ptr)
{
if(MWWorld::Class::get(ptr).isActor())
if(ptr.getClass().isActor())
mActors.skipAnimation(ptr);
else
mObjects.skipAnimation(ptr);
}
bool MechanicsManager::checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string &groupName)
{
if(MWWorld::Class::get(ptr).isActor())
if(ptr.getClass().isActor())
return mActors.checkAnimationPlaying(ptr, groupName);
else
return false;

@ -31,8 +31,8 @@ void Repair::repair(const MWWorld::Ptr &itemToRepair)
int uses = (mTool.getCellRef().mCharge != -1) ? mTool.getCellRef().mCharge : ref->mBase->mData.mUses;
mTool.getCellRef().mCharge = uses-1;
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(player).getNpcStats(player);
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
MWMechanics::NpcStats& npcStats = player.getClass().getNpcStats(player);
float fatigueTerm = stats.getFatigueTerm();
int pcStrength = stats.getAttribute(ESM::Attribute::Strength).getModified();
@ -55,15 +55,15 @@ void Repair::repair(const MWWorld::Ptr &itemToRepair)
// repair by 'y' points
itemToRepair.getCellRef().mCharge += y;
itemToRepair.getCellRef().mCharge = std::min(itemToRepair.getCellRef().mCharge,
MWWorld::Class::get(itemToRepair).getItemMaxHealth(itemToRepair));
itemToRepair.getClass().getItemMaxHealth(itemToRepair));
// set the OnPCRepair variable on the item's script
std::string script = MWWorld::Class::get(itemToRepair).getScript(itemToRepair);
std::string script = itemToRepair.getClass().getScript(itemToRepair);
if(script != "")
itemToRepair.getRefData().getLocals().setVarByInt(script, "onpcrepair", 1);
// increase skill
MWWorld::Class::get(player).skillUsageSucceeded(player, ESM::Skill::Armorer, 0);
player.getClass().skillUsageSucceeded(player, ESM::Skill::Armorer, 0);
MWBase::Environment::get().getSoundManager()->playSound("Repair",1,1);
MWBase::Environment::get().getWindowManager()->messageBox("#{sRepairSuccess}");
@ -78,14 +78,14 @@ void Repair::repair(const MWWorld::Ptr &itemToRepair)
if (mTool.getCellRef().mCharge == 0)
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player);
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
store.remove(mTool, 1, player);
std::string message = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
.find("sNotifyMessage51")->getString();
MWBase::Environment::get().getWindowManager()->messageBox((boost::format(message) % MWWorld::Class::get(mTool).getName(mTool)).str());
MWBase::Environment::get().getWindowManager()->messageBox((boost::format(message) % mTool.getClass().getName(mTool)).str());
// try to find a new tool of the same ID
for (MWWorld::ContainerStoreIterator iter (store.begin());

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save