Merge remote-tracking branch 'upstream/master' into wizardhead

pull/136/head
pvdk 11 years ago
commit fb59112b74

@ -26,6 +26,7 @@ namespace CSMWorld
enum Display
{
Display_None, //Do not use
Display_String,
//CONCRETE TYPES STARTS HERE

@ -64,6 +64,7 @@ std::vector< CSMWorld::UniversalId > CSMWorld::TableMimeData::getData() const
return mUniversalId;
}
bool CSMWorld::TableMimeData::holdsType (CSMWorld::UniversalId::Type type) const
{
for (std::vector<UniversalId>::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it)
@ -121,165 +122,325 @@ bool CSMWorld::TableMimeData::fromDocument (const CSMDoc::Document& document) co
return &document == &mDocument;
}
CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::ColumnBase::Display type) const
CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::ColumnBase::Display type)
{
switch (type)
{
case CSMWorld::ColumnBase::Display_Race:
return CSMWorld::UniversalId::Type_Race;
break;
case CSMWorld::ColumnBase::Display_Skill:
return CSMWorld::UniversalId::Type_Skill;
break;
case CSMWorld::ColumnBase::Display_Class:
return CSMWorld::UniversalId::Type_Class;
break;
case CSMWorld::ColumnBase::Display_Faction:
return CSMWorld::UniversalId::Type_Faction;
break;
case CSMWorld::ColumnBase::Display_Sound:
return CSMWorld::UniversalId::Type_Sound;
break;
case CSMWorld::ColumnBase::Display_Region:
return CSMWorld::UniversalId::Type_Region;
break;
case CSMWorld::ColumnBase::Display_Birthsign:
return CSMWorld::UniversalId::Type_Birthsign;
break;
case CSMWorld::ColumnBase::Display_Spell:
return CSMWorld::UniversalId::Type_Spell;
break;
case CSMWorld::ColumnBase::Display_Cell:
return CSMWorld::UniversalId::Type_Cell;
break;
case CSMWorld::ColumnBase::Display_Referenceable:
return CSMWorld::UniversalId::Type_Referenceable;
break;
case CSMWorld::ColumnBase::Display_Activator:
return CSMWorld::UniversalId::Type_Activator;
break;
case CSMWorld::ColumnBase::Display_Potion:
return CSMWorld::UniversalId::Type_Potion;
break;
case CSMWorld::ColumnBase::Display_Apparatus:
return CSMWorld::UniversalId::Type_Apparatus;
break;
case CSMWorld::ColumnBase::Display_Armor:
return CSMWorld::UniversalId::Type_Armor;
break;
case CSMWorld::ColumnBase::Display_Book:
return CSMWorld::UniversalId::Type_Book;
break;
case CSMWorld::ColumnBase::Display_Clothing:
return CSMWorld::UniversalId::Type_Clothing;
break;
case CSMWorld::ColumnBase::Display_Container:
return CSMWorld::UniversalId::Type_Container;
break;
case CSMWorld::ColumnBase::Display_Creature:
return CSMWorld::UniversalId::Type_Creature;
break;
case CSMWorld::ColumnBase::Display_Door:
return CSMWorld::UniversalId::Type_Door;
break;
case CSMWorld::ColumnBase::Display_Ingredient:
return CSMWorld::UniversalId::Type_Ingredient;
break;
case CSMWorld::ColumnBase::Display_CreatureLevelledList:
return CSMWorld::UniversalId::Type_CreatureLevelledList;
break;
case CSMWorld::ColumnBase::Display_ItemLevelledList:
return CSMWorld::UniversalId::Type_ItemLevelledList;
break;
case CSMWorld::ColumnBase::Display_Light:
return CSMWorld::UniversalId::Type_Light;
break;
case CSMWorld::ColumnBase::Display_Lockpick:
return CSMWorld::UniversalId::Type_Lockpick;
break;
case CSMWorld::ColumnBase::Display_Miscellaneous:
return CSMWorld::UniversalId::Type_Miscellaneous;
break;
case CSMWorld::ColumnBase::Display_Npc:
return CSMWorld::UniversalId::Type_Npc;
break;
case CSMWorld::ColumnBase::Display_Probe:
return CSMWorld::UniversalId::Type_Probe;
break;
case CSMWorld::ColumnBase::Display_Repair:
return CSMWorld::UniversalId::Type_Repair;
break;
case CSMWorld::ColumnBase::Display_Static:
return CSMWorld::UniversalId::Type_Static;
break;
case CSMWorld::ColumnBase::Display_Weapon:
return CSMWorld::UniversalId::Type_Weapon;
break;
case CSMWorld::ColumnBase::Display_Reference:
return CSMWorld::UniversalId::Type_Reference;
break;
case CSMWorld::ColumnBase::Display_Filter:
return CSMWorld::UniversalId::Type_Filter;
break;
case CSMWorld::ColumnBase::Display_Topic:
return CSMWorld::UniversalId::Type_Topic;
break;
case CSMWorld::ColumnBase::Display_Journal:
return CSMWorld::UniversalId::Type_Journal;
break;
case CSMWorld::ColumnBase::Display_TopicInfo:
return CSMWorld::UniversalId::Type_TopicInfo;
break;
case CSMWorld::ColumnBase::Display_JournalInfo:
return CSMWorld::UniversalId::Type_JournalInfo;
break;
case CSMWorld::ColumnBase::Display_Scene:
return CSMWorld::UniversalId::Type_Scene;
break;
case CSMWorld::ColumnBase::Display_Script:
return CSMWorld::UniversalId::Type_Script;
break;
default:
return CSMWorld::UniversalId::Type_None;
break;
}
}
// kate: indent-mode cstyle; indent-width 4; replace-tabs on;
CSMWorld::ColumnBase::Display CSMWorld::TableMimeData::convertEnums (CSMWorld::UniversalId::Type type)
{
switch (type)
{
case CSMWorld::UniversalId::Type_Race:
return CSMWorld::ColumnBase::Display_Race;
case CSMWorld::UniversalId::Type_Skill:
return CSMWorld::ColumnBase::Display_Skill;
case CSMWorld::UniversalId::Type_Class:
return CSMWorld::ColumnBase::Display_Class;
case CSMWorld::UniversalId::Type_Faction:
return CSMWorld::ColumnBase::Display_Faction;
case CSMWorld::UniversalId::Type_Sound:
return CSMWorld::ColumnBase::Display_Sound;
case CSMWorld::UniversalId::Type_Region:
return CSMWorld::ColumnBase::Display_Region;
case CSMWorld::UniversalId::Type_Birthsign:
return CSMWorld::ColumnBase::Display_Birthsign;
case CSMWorld::UniversalId::Type_Spell:
return CSMWorld::ColumnBase::Display_Spell;
case CSMWorld::UniversalId::Type_Cell:
return CSMWorld::ColumnBase::Display_Cell;
case CSMWorld::UniversalId::Type_Referenceable:
return CSMWorld::ColumnBase::Display_Referenceable;
case CSMWorld::UniversalId::Type_Activator:
return CSMWorld::ColumnBase::Display_Activator;
case CSMWorld::UniversalId::Type_Potion:
return CSMWorld::ColumnBase::Display_Potion;
case CSMWorld::UniversalId::Type_Apparatus:
return CSMWorld::ColumnBase::Display_Apparatus;
case CSMWorld::UniversalId::Type_Armor:
return CSMWorld::ColumnBase::Display_Armor;
case CSMWorld::UniversalId::Type_Book:
return CSMWorld::ColumnBase::Display_Book;
case CSMWorld::UniversalId::Type_Clothing:
return CSMWorld::ColumnBase::Display_Clothing;
case CSMWorld::UniversalId::Type_Container:
return CSMWorld::ColumnBase::Display_Container;
case CSMWorld::UniversalId::Type_Creature:
return CSMWorld::ColumnBase::Display_Creature;
case CSMWorld::UniversalId::Type_Door:
return CSMWorld::ColumnBase::Display_Door;
case CSMWorld::UniversalId::Type_Ingredient:
return CSMWorld::ColumnBase::Display_Ingredient;
case CSMWorld::UniversalId::Type_CreatureLevelledList:
return CSMWorld::ColumnBase::Display_CreatureLevelledList;
case CSMWorld::UniversalId::Type_ItemLevelledList:
return CSMWorld::ColumnBase::Display_ItemLevelledList;
case CSMWorld::UniversalId::Type_Light:
return CSMWorld::ColumnBase::Display_Light;
case CSMWorld::UniversalId::Type_Lockpick:
return CSMWorld::ColumnBase::Display_Lockpick;
case CSMWorld::UniversalId::Type_Miscellaneous:
return CSMWorld::ColumnBase::Display_Miscellaneous;
case CSMWorld::UniversalId::Type_Npc:
return CSMWorld::ColumnBase::Display_Npc;
case CSMWorld::UniversalId::Type_Probe:
return CSMWorld::ColumnBase::Display_Probe;
case CSMWorld::UniversalId::Type_Repair:
return CSMWorld::ColumnBase::Display_Repair;
case CSMWorld::UniversalId::Type_Static:
return CSMWorld::ColumnBase::Display_Static;
case CSMWorld::UniversalId::Type_Weapon:
return CSMWorld::ColumnBase::Display_Weapon;
case CSMWorld::UniversalId::Type_Reference:
return CSMWorld::ColumnBase::Display_Reference;
case CSMWorld::UniversalId::Type_Filter:
return CSMWorld::ColumnBase::Display_Filter;
case CSMWorld::UniversalId::Type_Topic:
return CSMWorld::ColumnBase::Display_Topic;
case CSMWorld::UniversalId::Type_Journal:
return CSMWorld::ColumnBase::Display_Journal;
case CSMWorld::UniversalId::Type_TopicInfo:
return CSMWorld::ColumnBase::Display_TopicInfo;
case CSMWorld::UniversalId::Type_JournalInfo:
return CSMWorld::ColumnBase::Display_JournalInfo;
case CSMWorld::UniversalId::Type_Scene:
return CSMWorld::ColumnBase::Display_Scene;
case CSMWorld::UniversalId::Type_Script:
return CSMWorld::ColumnBase::Display_Script;
default:
return CSMWorld::ColumnBase::Display_None;
}
}

@ -50,12 +50,14 @@ namespace CSMWorld
UniversalId returnMatching(CSMWorld::ColumnBase::Display type) const;
static CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type);
static CSMWorld::ColumnBase::Display convertEnums(CSMWorld::UniversalId::Type type);
private:
std::vector<UniversalId> mUniversalId;
QStringList mObjectsFormats;
const CSMDoc::Document& mDocument;
CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type) const;
};
}
#endif // TABLEMIMEDATA_H

@ -2,6 +2,8 @@
#include "editwidget.hpp"
#include <QAbstractItemModel>
#include <QString>
#include <QApplication>
#include "../../model/world/data.hpp"
@ -56,3 +58,146 @@ void CSVFilter::EditWidget::filterRowsInserted (const QModelIndex& parent, int s
{
textChanged (text());
}
void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::string, std::vector< std::string > > >& filterSource,
Qt::DropAction action)
{
const unsigned count = filterSource.size();
bool multipleElements = false;
switch (count) //setting multipleElements;
{
case 0: //empty
return; //nothing to do here
case 1: //only single
multipleElements = false;
break;
default:
multipleElements = true;
break;
}
Qt::KeyboardModifiers key = QApplication::keyboardModifiers();
QString oldContent (text());
bool replaceMode = false;
std::string orAnd;
switch (key) //setting replaceMode and string used to glue expressions
{
case Qt::ShiftModifier:
orAnd = "!or(";
replaceMode = false;
break;
case Qt::ControlModifier:
orAnd = "!and(";
replaceMode = false;
break;
default:
replaceMode = true;
break;
}
if (oldContent.isEmpty() || !oldContent.contains (QRegExp ("^!.*$", Qt::CaseInsensitive))) //if line edit is empty or it does not contain one shot filter go into replace mode
{
replaceMode = true;
}
if (!replaceMode)
{
oldContent.remove ('!');
}
std::stringstream ss;
if (multipleElements)
{
if (replaceMode)
{
ss<<"!or(";
} else {
ss << orAnd << oldContent.toStdString() << ',';
}
for (unsigned i = 0; i < count; ++i)
{
ss<<generateFilter (filterSource[i]);
if (i+1 != count)
{
ss<<", ";
}
}
ss<<')';
} else {
if (!replaceMode)
{
ss << orAnd << oldContent.toStdString() <<',';
} else {
ss<<'!';
}
ss << generateFilter (filterSource[0]);
if (!replaceMode)
{
ss<<')';
}
}
if (ss.str().length() >4)
{
clear();
insert (QString::fromUtf8(ss.str().c_str()));
}
}
std::string CSVFilter::EditWidget::generateFilter (std::pair< std::string, std::vector< std::string > >& seekedString) const
{
const unsigned columns = seekedString.second.size();
bool multipleColumns = false;
switch (columns)
{
case 0: //empty
return ""; //no column to filter
case 1: //one column to look for
multipleColumns = false;
break;
default:
multipleColumns = true;
break;
}
std::stringstream ss;
if (multipleColumns)
{
ss<<"or(";
for (unsigned i = 0; i < columns; ++i)
{
ss<<"string("<<'"'<<seekedString.second[i]<<'"'<<','<<'"'<<seekedString.first<<'"'<<')';
if (i+1 != columns)
ss<<',';
}
ss<<')';
} else {
ss<<"string"<<'('<<'"'<<seekedString.second[0]<<"\","<<'"'<<seekedString.first<<"\")";
}
return ss.str();
}
void CSVFilter::EditWidget::useFilterRequest (const std::string& idOfFilter)
{
clear();
insert(QString::fromUtf8(idOfFilter.c_str()));
}

@ -5,6 +5,7 @@
#include <QLineEdit>
#include <QPalette>
#include <QtCore/qnamespace.h>
#include "../../model/filter/parser.hpp"
#include "../../model/filter/node.hpp"
@ -33,6 +34,9 @@ namespace CSVFilter
void filterChanged (boost::shared_ptr<CSMFilter::Node> filter);
private:
std::string generateFilter(std::pair<std::string, std::vector<std::string> >& seekedString) const;
private slots:
void textChanged (const QString& text);
@ -42,6 +46,11 @@ namespace CSVFilter
void filterRowsRemoved (const QModelIndex& parent, int start, int end);
void filterRowsInserted (const QModelIndex& parent, int start, int end);
void createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >& filterSource,
Qt::DropAction action);
void useFilterRequest(const std::string& idOfFilter);
};
}

@ -2,9 +2,12 @@
#include "filterbox.hpp"
#include <QHBoxLayout>
#include <QDragEnterEvent>
#include "recordfilterbox.hpp"
#include <apps/opencs/model/world/tablemimedata.hpp>
CSVFilter::FilterBox::FilterBox (CSMWorld::Data& data, QWidget *parent)
: QWidget (parent)
{
@ -21,4 +24,27 @@ CSVFilter::FilterBox::FilterBox (CSMWorld::Data& data, QWidget *parent)
connect (recordFilterBox,
SIGNAL (filterChanged (boost::shared_ptr<CSMFilter::Node>)),
this, SIGNAL (recordFilterChanged (boost::shared_ptr<CSMFilter::Node>)));
}
connect(this, SIGNAL(createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >&, Qt::DropAction)),
recordFilterBox, SIGNAL(createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >&, Qt::DropAction)));
connect(this, SIGNAL(useFilterRequest(const std::string&)), recordFilterBox, SIGNAL(useFilterRequest(const std::string&)));
setAcceptDrops(true);
}
void CSVFilter::FilterBox::dropEvent (QDropEvent* event)
{
std::vector<CSMWorld::UniversalId> data = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData())->getData();
emit recordDropped(data, event->proposedAction());
}
void CSVFilter::FilterBox::dragEnterEvent (QDragEnterEvent* event)
{
event->acceptProposedAction();
}
void CSVFilter::FilterBox::dragMoveEvent (QDragMoveEvent* event)
{
event->accept();
}

@ -1,9 +1,13 @@
#ifndef CSV_FILTER_FILTERBOX_H
#define CSV_FILTER_FILTERBOX_H
#include <vector>
#include <QWidget>
#include <QtCore/qnamespace.h>
#include "../../model/filter/node.hpp"
#include "../../model/world/universalid.hpp"
namespace CSMWorld
{
@ -16,6 +20,12 @@ namespace CSVFilter
{
Q_OBJECT
void dragEnterEvent (QDragEnterEvent* event);
void dropEvent (QDropEvent* event);
void dragMoveEvent(QDragMoveEvent *event);
public:
FilterBox (CSMWorld::Data& data, QWidget *parent = 0);
@ -23,8 +33,13 @@ namespace CSVFilter
signals:
void recordFilterChanged (boost::shared_ptr<CSMFilter::Node> filter);
void recordDropped (std::vector<CSMWorld::UniversalId>& types, Qt::DropAction action);
void createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >& filterSource,
Qt::DropAction action);
void useFilterRequest(const std::string& idOfFilter);
};
}
#endif

@ -24,4 +24,9 @@ CSVFilter::RecordFilterBox::RecordFilterBox (CSMWorld::Data& data, QWidget *pare
connect (
editWidget, SIGNAL (filterChanged (boost::shared_ptr<CSMFilter::Node>)),
this, SIGNAL (filterChanged (boost::shared_ptr<CSMFilter::Node>)));
connect(this, SIGNAL(createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >&, Qt::DropAction)),
editWidget, SLOT(createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >&, Qt::DropAction)));
connect(this, SIGNAL(useFilterRequest(const std::string&)), editWidget, SLOT(useFilterRequest(const std::string&)));
}

@ -4,6 +4,7 @@
#include <boost/shared_ptr.hpp>
#include <QWidget>
#include <QtCore/qnamespace.h>
#include <QHBoxLayout>
@ -27,6 +28,9 @@ namespace CSVFilter
signals:
void filterChanged (boost::shared_ptr<CSMFilter::Node> filter);
void createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >& filterSource,
Qt::DropAction action);
void useFilterRequest(const std::string& idOfFilter);
};
}

@ -4,6 +4,7 @@
#include <QHeaderView>
#include <QAction>
#include <QApplication>
#include <QMenu>
#include <QContextMenuEvent>
#include <QString>
@ -471,7 +472,20 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event)
drag->setMimeData (mime);
drag->setPixmap (QString::fromStdString (mime->getIcon()));
drag->exec();
Qt::DropActions action = Qt::IgnoreAction;
switch (QApplication::keyboardModifiers())
{
case Qt::ControlModifier:
action = Qt::CopyAction;
break;
case Qt::ShiftModifier:
action = Qt::MoveAction;
break;
}
drag->exec(action);
}
}
@ -485,6 +499,11 @@ void CSVWorld::Table::dropEvent(QDropEvent *event)
{
QModelIndex index = indexAt (event->pos());
if (!index.isValid())
{
return;
}
const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
if (mime->fromDocument (mDocument))
{
@ -496,7 +515,7 @@ void CSVWorld::Table::dropEvent(QDropEvent *event)
CSMWorld::UniversalId record (mime->returnMatching (display));
std::auto_ptr<CSMWorld::ModifyCommand> command (new CSMWorld::ModifyCommand
(*mProxyModel, index, QVariant (QString::fromStdString (record.getId()))));
(*mProxyModel, index, QVariant (QString::fromUtf8 (record.getId().c_str()))));
mUndoStack.push (command.release());
}
@ -507,3 +526,21 @@ void CSVWorld::Table::dragMoveEvent(QDragMoveEvent *event)
{
event->accept();
}
std::vector<std::string> CSVWorld::Table::getColumnsWithDisplay(CSMWorld::ColumnBase::Display display) const
{
const int count = mModel->columnCount();
std::vector<std::string> titles;
for (int i = 0; i < count; ++i)
{
CSMWorld::ColumnBase::Display columndisplay = static_cast<CSMWorld::ColumnBase::Display>
(mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt());
if (display == columndisplay)
{
titles.push_back(mModel->headerData (i, Qt::Horizontal).toString().toStdString());
}
}
return titles;
}

@ -8,6 +8,7 @@
#include <QtGui/qevent.h>
#include "../../model/filter/node.hpp"
#include "../../model/world/columnbase.hpp"
namespace CSMDoc {
class Document;
@ -63,10 +64,9 @@ namespace CSVWorld
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
public:
@ -82,6 +82,8 @@ namespace CSVWorld
void updateEditorSetting (const QString &settingName, const QString &settingValue);
std::vector<std::string> getColumnsWithDisplay(CSMWorld::ColumnBase::Display display) const;
signals:
void editRequest (int row);

@ -2,8 +2,10 @@
#include "tablesubview.hpp"
#include <QVBoxLayout>
#include <QEvent>
#include "../../model/doc/document.hpp"
#include "../../model/world/tablemimedata.hpp"
#include "../filter/filterbox.hpp"
#include "table.hpp"
@ -43,6 +45,9 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
mTable->tableSizeUpdate();
mTable->selectionSizeUpdate();
mTable->viewport()->installEventFilter(this);
mBottom->installEventFilter(this);
filterBox->installEventFilter(this);
if (mBottom->canCreateAndDelete())
{
@ -60,6 +65,14 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
connect (filterBox,
SIGNAL (recordFilterChanged (boost::shared_ptr<CSMFilter::Node>)),
mTable, SLOT (recordFilterChanged (boost::shared_ptr<CSMFilter::Node>)));
connect(filterBox, SIGNAL(recordDropped(std::vector<CSMWorld::UniversalId>&, Qt::DropAction)),
this, SLOT(createFilterRequest(std::vector<CSMWorld::UniversalId>&, Qt::DropAction)));
connect(this, SIGNAL(useFilterRequest(const std::string&)), filterBox, SIGNAL(useFilterRequest(const std::string&)));
connect(this, SIGNAL(createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >&, Qt::DropAction)),
filterBox, SIGNAL(createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >&, Qt::DropAction)));
}
void CSVWorld::TableSubView::setEditLock (bool locked)
@ -87,3 +100,33 @@ void CSVWorld::TableSubView::cloneRequest(const CSMWorld::UniversalId& toClone)
{
emit cloneRequest(toClone.getId(), toClone.getType());
}
void CSVWorld::TableSubView::createFilterRequest (std::vector< CSMWorld::UniversalId>& types, Qt::DropAction action)
{
std::vector<std::pair<std::string, std::vector<std::string> > > filterSource;
for (std::vector<CSMWorld::UniversalId>::iterator it = types.begin(); it != types.end(); ++it)
{
std::pair<std::string, std::vector<std::string> > pair( //splited long line
std::make_pair(it->getId(), mTable->getColumnsWithDisplay(CSMWorld::TableMimeData::convertEnums(it->getType()))));
filterSource.push_back(pair);
}
emit createFilterRequest(filterSource, action);
}
bool CSVWorld::TableSubView::eventFilter (QObject* object, QEvent* event)
{
if (event->type() == QEvent::Drop)
{
QDropEvent* drop = dynamic_cast<QDropEvent*>(event);
const CSMWorld::TableMimeData* data = dynamic_cast<const CSMWorld::TableMimeData*>(drop->mimeData());
bool handled = data->holdsType(CSMWorld::UniversalId::Type_Filter);
if (handled)
{
emit useFilterRequest(data->returnMatching(CSMWorld::UniversalId::Type_Filter).getId());
}
return handled;
}
return false;
}

@ -3,6 +3,8 @@
#include "../doc/subview.hpp"
#include <QtCore/qnamespace.h>
class QModelIndex;
namespace CSMWorld
@ -39,14 +41,22 @@ namespace CSVWorld
virtual void setStatusBar (bool show);
protected:
bool eventFilter(QObject* object, QEvent *event);
signals:
void cloneRequest(const std::string&,
const CSMWorld::UniversalId::Type);
void createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >& filterSource,
Qt::DropAction action);
void useFilterRequest(const std::string& idOfFilter);
private slots:
void editRequest (int row);
void cloneRequest (const CSMWorld::UniversalId& toClone);
void createFilterRequest(std::vector< CSMWorld::UniversalId >& types,
Qt::DropAction action);
};
}

@ -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
contentloader esmloader omwloader actiontrap cellreflist
)
add_openmw_dir (mwclass

@ -39,6 +39,12 @@ namespace ESM
struct Spell;
struct NPC;
struct CellId;
struct Armor;
struct Weapon;
struct Clothing;
struct Enchantment;
struct Book;
struct EffectList;
}
namespace MWRender

@ -128,6 +128,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Activator> *ref =
ptr.get<ESM::Activator>();
return MWWorld::Ptr(&cell.mActivators.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Activator>().insert(*ref), &cell);
}
}

@ -148,7 +148,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Apparatus> *ref =
ptr.get<ESM::Apparatus>();
return MWWorld::Ptr(&cell.mAppas.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Apparatus>().insert(*ref), &cell);
}
bool Apparatus::canSell (const MWWorld::Ptr& item, int npcServices) const

@ -333,11 +333,11 @@ namespace MWClass
if(weapon->getTypeName() == typeid(ESM::Weapon).name() &&
(weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::LongBladeTwoHand ||
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::BluntTwoClose ||
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::BluntTwoWide ||
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::BluntTwoClose ||
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::BluntTwoWide ||
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::SpearTwoWide ||
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::AxeTwoHand ||
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanBow ||
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::AxeTwoHand ||
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanBow ||
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanCrossbow))
{
return std::make_pair(3,"");
@ -363,7 +363,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Armor> *ref =
ptr.get<ESM::Armor>();
return MWWorld::Ptr(&cell.mArmors.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Armor>().insert(*ref), &cell);
}
int Armor::getEnchantmentPoints (const MWWorld::Ptr& ptr) const

@ -186,7 +186,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Book> *ref =
ptr.get<ESM::Book>();
return MWWorld::Ptr(&cell.mBooks.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Book>().insert(*ref), &cell);
}
int Book::getEnchantmentPoints (const MWWorld::Ptr& ptr) const

@ -276,7 +276,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>();
return MWWorld::Ptr(&cell.mClothes.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Clothing>().insert(*ref), &cell);
}
int Clothing::getEnchantmentPoints (const MWWorld::Ptr& ptr) const

@ -257,7 +257,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Container> *ref =
ptr.get<ESM::Container>();
return MWWorld::Ptr(&cell.mContainers.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Container>().insert(*ref), &cell);
}
void Container::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state)

@ -22,6 +22,7 @@
#include "../mwworld/customdata.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/physicssystem.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwrender/renderinginterface.hpp"
#include "../mwrender/actors.hpp"
@ -679,7 +680,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Creature> *ref =
ptr.get<ESM::Creature>();
return MWWorld::Ptr(&cell.mCreatures.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Creature>().insert(*ref), &cell);
}
bool Creature::isFlying(const MWWorld::Ptr &ptr) const

@ -3,6 +3,11 @@
#include "../mwworld/class.hpp"
namespace ESM
{
struct GameSetting;
}
namespace MWClass
{
class Creature : public MWWorld::Class

@ -258,6 +258,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Door> *ref =
ptr.get<ESM::Door>();
return MWWorld::Ptr(&cell.mDoors.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Door>().insert(*ref), &cell);
}
}

@ -1,6 +1,8 @@
#ifndef GAME_MWCLASS_DOOR_H
#define GAME_MWCLASS_DOOR_H
#include <components/esm/loaddoor.hpp>
#include "../mwworld/class.hpp"
namespace MWClass

@ -30,7 +30,7 @@ namespace MWClass
return ref->mBase->mId;
}
void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{
const std::string model = getModel(ptr);
@ -89,16 +89,16 @@ namespace MWClass
return ref->mBase->mData.mValue;
}
boost::shared_ptr<MWWorld::Action> Ingredient::use (const MWWorld::Ptr& ptr) const
{
boost::shared_ptr<MWWorld::Action> action (new MWWorld::ActionEat (ptr));
action->setSound ("Swallow");
return action;
return action;
}
void Ingredient::registerSelf()
{
boost::shared_ptr<Class> instance (new Ingredient);
@ -189,7 +189,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Ingredient> *ref =
ptr.get<ESM::Ingredient>();
return MWWorld::Ptr(&cell.mIngreds.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Ingredient>().insert(*ref), &cell);
}
bool Ingredient::canSell (const MWWorld::Ptr& item, int npcServices) const

@ -227,7 +227,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>();
return MWWorld::Ptr(&cell.mLights.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Light>().insert(*ref), &cell);
}
void Light::ensureCustomData (const MWWorld::Ptr& ptr) const

@ -169,7 +169,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Lockpick> *ref =
ptr.get<ESM::Lockpick>();
return MWWorld::Ptr(&cell.mLockpicks.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Lockpick>().insert(*ref), &cell);
}
bool Lockpick::canSell (const MWWorld::Ptr& item, int npcServices) const

@ -218,13 +218,13 @@ namespace MWClass
MWWorld::ManualRef newRef(store, base);
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
newRef.getPtr().get<ESM::Miscellaneous>();
newPtr = MWWorld::Ptr(&cell.mMiscItems.insert(*ref), &cell);
newPtr = MWWorld::Ptr(&cell.get<ESM::Miscellaneous>().insert(*ref), &cell);
newPtr.getCellRef().mGoldValue = goldAmount;
newPtr.getRefData().setCount(1);
} else {
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>();
newPtr = MWWorld::Ptr(&cell.mMiscItems.insert(*ref), &cell);
newPtr = MWWorld::Ptr(&cell.get<ESM::Miscellaneous>().insert(*ref), &cell);
}
return newPtr;
}

@ -30,6 +30,7 @@
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/customdata.hpp"
#include "../mwworld/physicssystem.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwrender/actors.hpp"
#include "../mwrender/renderinginterface.hpp"
@ -1252,7 +1253,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::NPC> *ref =
ptr.get<ESM::NPC>();
return MWWorld::Ptr(&cell.mNpcs.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::NPC>().insert(*ref), &cell);
}
int Npc::getSkill(const MWWorld::Ptr& ptr, int skill) const

@ -185,7 +185,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Potion> *ref =
ptr.get<ESM::Potion>();
return MWWorld::Ptr(&cell.mPotions.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Potion>().insert(*ref), &cell);
}
bool Potion::canSell (const MWWorld::Ptr& item, int npcServices) const

@ -168,7 +168,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Probe> *ref =
ptr.get<ESM::Probe>();
return MWWorld::Ptr(&cell.mProbes.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Probe>().insert(*ref), &cell);
}
bool Probe::canSell (const MWWorld::Ptr& item, int npcServices) const

@ -163,7 +163,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Repair> *ref =
ptr.get<ESM::Repair>();
return MWWorld::Ptr(&cell.mRepairs.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Repair>().insert(*ref), &cell);
}
boost::shared_ptr<MWWorld::Action> Repair::use (const MWWorld::Ptr& ptr) const

@ -5,6 +5,7 @@
#include "../mwworld/ptr.hpp"
#include "../mwworld/physicssystem.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp"
@ -25,7 +26,7 @@ namespace MWClass
if(!model.empty())
physics.addObject(ptr);
}
std::string Static::getModel(const MWWorld::Ptr &ptr) const
{
MWWorld::LiveCellRef<ESM::Static> *ref =
@ -57,6 +58,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Static> *ref =
ptr.get<ESM::Static>();
return MWWorld::Ptr(&cell.mStatics.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Static>().insert(*ref), &cell);
}
}

@ -426,7 +426,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>();
return MWWorld::Ptr(&cell.mWeapons.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Weapon>().insert(*ref), &cell);
}
int Weapon::getEnchantmentPoints (const MWWorld::Ptr& ptr) const

@ -13,6 +13,11 @@
#include "../mwscript/compilercontext.hpp"
namespace ESM
{
struct Dialogue;
}
namespace MWDialogue
{
class DialogueManager : public MWBase::DialogueManager

@ -8,8 +8,9 @@
#include "../mwbase/dialoguemanager.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/creaturestats.hpp"
@ -110,7 +111,7 @@ bool MWDialogue::Filter::testPlayer (const ESM::DialInfo& info) const
// check cell
if (!info.mCell.empty())
if (!Misc::StringUtils::ciEqual(player.getCell()->mCell->mName, info.mCell))
if (!Misc::StringUtils::ciEqual(player.getCell()->getCell()->mName, info.mCell))
return false;
return true;
@ -445,7 +446,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
case SelectWrapper::Function_NotCell:
return !Misc::StringUtils::ciEqual(mActor.getCell()->mCell->mName, select.getName());
return !Misc::StringUtils::ciEqual(mActor.getCell()->getCell()->mName, select.getName());
case SelectWrapper::Function_NotLocal:
{

@ -2,6 +2,8 @@
#include <boost/lexical_cast.hpp>
#include <components/esm/loadbook.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
@ -169,7 +171,7 @@ namespace MWGui
}
++i;
}
//If it is the last page, hide the button "Next Page"
if ( (mCurrentPage+1)*2 == mPages.size()
|| (mCurrentPage+1)*2 == mPages.size() + 1)
@ -194,7 +196,7 @@ namespace MWGui
if (button->getAlign().isRight())
button->setPosition(button->getPosition() + MyGUI::IntPoint(diff.width,0));
}
void BookWindow::nextPage()
{
if ((mCurrentPage+1)*2 < mPages.size())

@ -1,6 +1,9 @@
#ifndef CHARACTER_CREATION_HPP
#define CHARACTER_CREATION_HPP
#include <components/esm/loadskil.hpp>
#include <components/esm/loadclas.hpp>
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"

@ -8,6 +8,8 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/esmstore.hpp"
namespace MWGui
{
class ConsoleInterpreterContext : public MWScript::InterpreterContext

@ -8,6 +8,8 @@
#include "../mwworld/class.hpp"
#include "../mwworld/fallback.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/npcstats.hpp"

@ -7,7 +7,9 @@
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwrender/globalmap.hpp"
@ -356,7 +358,7 @@ namespace MWGui
ESM::Position markedPosition;
MWBase::Environment::get().getWorld()->getPlayer().getMarkedPosition(markedCell, markedPosition);
if (markedCell && markedCell->isExterior() == !mInterior
&& (!mInterior || Misc::StringUtils::ciEqual(markedCell->mCell->mName, mPrefix)))
&& (!mInterior || Misc::StringUtils::ciEqual(markedCell->getCell()->mName, mPrefix)))
{
MarkerPosition markerPos;
MyGUI::IntPoint widgetPos = getMarkerPosition(markedPosition.pos[0], markedPosition.pos[1], markerPos);

@ -1,5 +1,7 @@
#include "merchantrepair.hpp"
#include <components/esm/loadgmst.hpp>
#include <boost/lexical_cast.hpp>
#include "../mwbase/world.hpp"
@ -10,6 +12,7 @@
#include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/esmstore.hpp"
namespace MWGui
{

@ -1,5 +1,7 @@
#include "scrollwindow.hpp"
#include <components/esm/loadbook.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"

@ -1,5 +1,18 @@
#include "sortfilteritemmodel.hpp"
#include <components/esm/loadalch.hpp>
#include <components/esm/loadappa.hpp>
#include <components/esm/loadarmo.hpp>
#include <components/esm/loadbook.hpp>
#include <components/esm/loadclot.hpp>
#include <components/esm/loadingr.hpp>
#include <components/esm/loadlock.hpp>
#include <components/esm/loadligh.hpp>
#include <components/esm/loadmisc.hpp>
#include <components/esm/loadprob.hpp>
#include <components/esm/loadrepa.hpp>
#include <components/esm/loadweap.hpp>
#include "../mwworld/class.hpp"
namespace

@ -10,6 +10,8 @@
#include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/creaturestats.hpp"

@ -1,5 +1,7 @@
#include "tradeitemmodel.hpp"
#include <components/misc/stringops.hpp>
#include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/inventorystore.hpp"

@ -13,6 +13,8 @@
#include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
namespace MWGui
{
@ -109,7 +111,11 @@ namespace MWGui
int x,y;
MWBase::Environment::get().getWorld()->positionToIndex(mPtr.get<ESM::NPC>()->mBase->mTransport[i].mPos.pos[0],
mPtr.get<ESM::NPC>()->mBase->mTransport[i].mPos.pos[1],x,y);
if(cellname == "") {cellname = MWBase::Environment::get().getWorld()->getExterior(x,y)->mCell->mName; interior= false;}
if (cellname == "")
{
cellname = MWBase::Environment::get().getWorld()->getExterior(x,y)->getCell()->mName;
interior = false;
}
addDestination(cellname,mPtr.get<ESM::NPC>()->mBase->mTransport[i].mPos,interior);
}

@ -10,6 +10,7 @@
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/npcstats.hpp"
@ -129,7 +130,7 @@ namespace MWGui
MWWorld::Ptr player = world->getPlayerPtr();
if (mSleeping && player.getCell()->isExterior())
{
std::string regionstr = player.getCell()->mCell->mRegion;
std::string regionstr = player.getCell()->getCell()->mRegion;
if (!regionstr.empty())
{
const ESM::Region *region = world->getStore().get<ESM::Region>().find (regionstr);

@ -18,6 +18,7 @@
#include "../mwworld/class.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/cellstore.hpp"
#include "console.hpp"
#include "journalwindow.hpp"
@ -739,22 +740,22 @@ namespace MWGui
mMap->setCellName( name );
mHud->setCellName( name );
if (cell->mCell->isExterior())
if (cell->getCell()->isExterior())
{
if (!cell->mCell->mName.empty())
mMap->addVisitedLocation ("#{sCell=" + name + "}", cell->mCell->getGridX (), cell->mCell->getGridY ());
if (!cell->getCell()->mName.empty())
mMap->addVisitedLocation ("#{sCell=" + name + "}", cell->getCell()->getGridX (), cell->getCell()->getGridY ());
mMap->cellExplored(cell->mCell->getGridX(), cell->mCell->getGridY());
mMap->cellExplored (cell->getCell()->getGridX(), cell->getCell()->getGridY());
mMap->setCellPrefix("Cell");
mHud->setCellPrefix("Cell");
mMap->setActiveCell( cell->mCell->getGridX(), cell->mCell->getGridY() );
mHud->setActiveCell( cell->mCell->getGridX(), cell->mCell->getGridY() );
mMap->setActiveCell (cell->getCell()->getGridX(), cell->getCell()->getGridY());
mHud->setActiveCell (cell->getCell()->getGridX(), cell->getCell()->getGridY());
}
else
{
mMap->setCellPrefix( cell->mCell->mName );
mHud->setCellPrefix( cell->mCell->mName );
mMap->setCellPrefix (cell->getCell()->mName );
mHud->setCellPrefix (cell->getCell()->mName );
Ogre::Vector3 worldPos;
if (!MWBase::Environment::get().getWorld()->findInteriorPositionInWorldSpace(cell, worldPos))

@ -15,13 +15,16 @@
#include "../engine.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/statemanager.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/creaturestats.hpp"
using namespace ICS;
@ -169,7 +172,7 @@ namespace MWInput
switch (action)
{
case A_GameMenu:
if(!(MWBase::Environment::get().getStateManager()->getState() != MWBase::StateManager::State_Running
if(!(MWBase::Environment::get().getStateManager()->getState() != MWBase::StateManager::State_Running
&& MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_MainMenu))
toggleMainMenu ();
break;
@ -283,7 +286,7 @@ namespace MWInput
// Disable movement in Gui mode
if (MWBase::Environment::get().getWindowManager()->isGuiMode()
|| MWBase::Environment::get().getStateManager()->getState() != MWBase::StateManager::State_Running)
|| MWBase::Environment::get().getStateManager()->getState() != MWBase::StateManager::State_Running)
return;

@ -1,8 +1,14 @@
#include "activespells.hpp"
#include <components/misc/stringops.hpp>
#include <components/esm/loadmgef.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/esmstore.hpp"
namespace MWMechanics
{
void ActiveSpells::update() const
@ -40,7 +46,7 @@ namespace MWMechanics
void ActiveSpells::rebuildEffects() const
{
MWWorld::TimeStamp now = MWBase::Environment::get().getWorld()->getTimeStamp();
mEffects = MagicEffects();
for (TIterator iter (begin()); iter!=end(); ++iter)
@ -59,7 +65,7 @@ namespace MWMechanics
if (end>now)
mEffects.add(effectIt->mKey, MWMechanics::EffectParam(effectIt->mMagnitude));
}
}
}
}
ActiveSpells::ActiveSpells()

@ -1,14 +1,14 @@
#include "aiactivate.hpp"
#include <iostream>
#include "movement.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/action.hpp"
#include "../mwworld/cellstore.hpp"
#include "steering.hpp"
#include "movement.hpp"
namespace
{
@ -33,12 +33,12 @@ bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor,float duration)
MWBase::World *world = MWBase::Environment::get().getWorld();
ESM::Position pos = actor.getRefData().getPosition();
Movement &movement = actor.getClass().getMovementSettings(actor);
const ESM::Cell *cell = actor.getCell()->mCell;
const ESM::Cell *cell = actor.getCell()->getCell();
MWWorld::Ptr player = world->getPlayerPtr();
if(cell->mData.mX != player.getCell()->mCell->mData.mX)
if(cell->mData.mX != player.getCell()->getCell()->mData.mX)
{
int sideX = sgn(cell->mData.mX - player.getCell()->mCell->mData.mX);
int sideX = sgn(cell->mData.mX - player.getCell()->getCell()->mData.mX);
//check if actor is near the border of an inactive cell. If so, stop walking.
if(sideX * (pos.pos[0] - cell->mData.mX*ESM::Land::REAL_SIZE) >
sideX * (ESM::Land::REAL_SIZE/2.0f - 200.0f))
@ -47,9 +47,9 @@ bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor,float duration)
return false;
}
}
if(cell->mData.mY != player.getCell()->mCell->mData.mY)
if(cell->mData.mY != player.getCell()->getCell()->mData.mY)
{
int sideY = sgn(cell->mData.mY - player.getCell()->mCell->mData.mY);
int sideY = sgn(cell->mData.mY - player.getCell()->getCell()->mData.mY);
//check if actor is near the border of an inactive cell. If so, stop walking.
if(sideY * (pos.pos[1] - cell->mData.mY*ESM::Land::REAL_SIZE) >
sideY * (ESM::Land::REAL_SIZE/2.0f - 200.0f))

@ -7,6 +7,8 @@
#include "../mwworld/class.hpp"
#include "../mwworld/timestamp.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
@ -34,9 +36,9 @@ namespace
namespace MWMechanics
{
AiCombat::AiCombat(const MWWorld::Ptr& actor) :
mTarget(actor),
mTimerAttack(0),
mTimerReact(0),
mTarget(actor),
mTimerAttack(0),
mTimerReact(0),
mTimerCombatMove(0),
mFollowTarget(false),
mReadyToAttack(false),
@ -77,7 +79,7 @@ namespace MWMechanics
if (zTurn(actor, Ogre::Degree(mTargetAngle)))
mRotate = false;
}
mTimerAttack -= duration;
actor.getClass().getCreatureStats(actor).setAttackingOrSpell(mStrike);
@ -105,7 +107,7 @@ namespace MWMechanics
//Also it seems that this time is different for slash/thrust/chop
mTimerAttack = 0.35f * static_cast<float>(rand())/RAND_MAX;
mStrike = true;
//say a provoking combat phrase
if (actor.getClass().isNpc())
{
@ -126,7 +128,7 @@ namespace MWMechanics
mTimerAttack = -attackPeriod;
mStrike = false;
}
const MWWorld::Class &cls = actor.getClass();
const ESM::Weapon *weapon = NULL;
MWMechanics::WeaponType weaptype;
@ -138,14 +140,14 @@ namespace MWMechanics
{
MWMechanics::DrawState_ state = actor.getClass().getCreatureStats(actor).getDrawState();
if (state == MWMechanics::DrawState_Spell || state == MWMechanics::DrawState_Nothing)
actor.getClass().getNpcStats(actor).setDrawState(MWMechanics::DrawState_Weapon);
actor.getClass().getNpcStats(actor).setDrawState(MWMechanics::DrawState_Weapon);
//Get weapon speed and range
MWWorld::ContainerStoreIterator weaponSlot =
MWWorld::ContainerStoreIterator weaponSlot =
MWMechanics::getActiveWeapon(cls.getNpcStats(actor), cls.getInventoryStore(actor), &weaptype);
if (weaptype == WeapType_HandToHand)
{
const MWWorld::Store<ESM::GameSetting> &gmst =
const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
weapRange = gmst.find("fHandToHandReach")->getFloat();
}
@ -246,12 +248,12 @@ namespace MWMechanics
mPathFinder.checkPathCompleted(pos.pos[0],pos.pos[1],pos.pos[2]);
//try shortcut
if(vDir.length() < mPathFinder.getDistToNext(pos.pos[0],pos.pos[1],pos.pos[2]) && MWBase::Environment::get().getWorld()->getLOS(actor, mTarget))
if(vDir.length() < mPathFinder.getDistToNext(pos.pos[0],pos.pos[1],pos.pos[2]) && MWBase::Environment::get().getWorld()->getLOS(actor, mTarget))
mTargetAngle = Ogre::Radian( Ogre::Math::ACos(vDir.y / vDir.length()) * sgn(Ogre::Math::ASin(vDir.x / vDir.length())) ).valueDegrees();
else
mTargetAngle = mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1]);
mRotate = true;
mMovement.mPosition[1] = 1;
mReadyToAttack = false;
}
@ -305,13 +307,13 @@ namespace MWMechanics
float dist = Ogre::Math::Abs((newPathTarget - currPathTarget).length());
float targetPosThreshold;
bool isOutside = actor.getCell()->mCell->isExterior();
bool isOutside = actor.getCell()->getCell()->isExterior();
if (isOutside)
targetPosThreshold = 300;
else
targetPosThreshold = 100;
if(dist > targetPosThreshold)
if(dist > targetPosThreshold)
{
//construct new path only if target has moved away more than on <targetPosThreshold>
ESM::Position pos = actor.getRefData().getPosition();
@ -328,7 +330,7 @@ namespace MWMechanics
PathFinder newPathFinder;
newPathFinder.buildPath(start, dest, actor.getCell(), isOutside);
//TO EXPLORE:
//TO EXPLORE:
//maybe here is a mistake (?): PathFinder::getPathSize() returns number of grid points in the path,
//not the actual path length. Here we should know if the new path is actually more effective.
//if(pathFinder2.getPathSize() < mPathFinder.getPathSize())
@ -391,7 +393,7 @@ void chooseBestAttack(const ESM::Weapon* weapon, MWMechanics::Movement &movement
int thrust = (weapon->mData.mThrust[0] + weapon->mData.mThrust[1])/2;
float total = slash + chop + thrust;
float roll = static_cast<float>(rand())/RAND_MAX;
if(roll <= static_cast<float>(slash)/total)
{

@ -1,14 +1,15 @@
#include "aiescort.hpp"
#include "movement.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/timestamp.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/timestamp.hpp"
#include "steering.hpp"
#include "movement.hpp"
namespace
{
@ -86,25 +87,25 @@ namespace MWMechanics
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
ESM::Position pos = actor.getRefData().getPosition();
bool cellChange = actor.getCell()->mCell->mData.mX != mCellX || actor.getCell()->mCell->mData.mY != mCellY;
bool cellChange = actor.getCell()->getCell()->mData.mX != mCellX || actor.getCell()->getCell()->mData.mY != mCellY;
if(actor.getCell()->mCell->mData.mX != player.getCell()->mCell->mData.mX)
if(actor.getCell()->getCell()->mData.mX != player.getCell()->getCell()->mData.mX)
{
int sideX = sgn(actor.getCell()->mCell->mData.mX - player.getCell()->mCell->mData.mX);
int sideX = sgn(actor.getCell()->getCell()->mData.mX - player.getCell()->getCell()->mData.mX);
// Check if actor is near the border of an inactive cell. If so, pause walking.
if(sideX * (pos.pos[0] - actor.getCell()->mCell->mData.mX * ESM::Land::REAL_SIZE) > sideX * (ESM::Land::REAL_SIZE /
2.0 - 200))
if(sideX * (pos.pos[0] - actor.getCell()->getCell()->mData.mX * ESM::Land::REAL_SIZE) > sideX * (ESM::Land::REAL_SIZE /
2.0 - 200))
{
MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0;
return false;
}
}
if(actor.getCell()->mCell->mData.mY != player.getCell()->mCell->mData.mY)
if(actor.getCell()->getCell()->mData.mY != player.getCell()->getCell()->mData.mY)
{
int sideY = sgn(actor.getCell()->mCell->mData.mY - player.getCell()->mCell->mData.mY);
int sideY = sgn(actor.getCell()->getCell()->mData.mY - player.getCell()->getCell()->mData.mY);
// Check if actor is near the border of an inactive cell. If so, pause walking.
if(sideY*(pos.pos[1] - actor.getCell()->mCell->mData.mY * ESM::Land::REAL_SIZE) > sideY * (ESM::Land::REAL_SIZE /
2.0 - 200))
if(sideY*(pos.pos[1] - actor.getCell()->getCell()->mData.mY * ESM::Land::REAL_SIZE) > sideY * (ESM::Land::REAL_SIZE /
2.0 - 200))
{
MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0;
return false;
@ -114,8 +115,8 @@ namespace MWMechanics
if(!mPathFinder.isPathConstructed() || cellChange)
{
mCellX = actor.getCell()->mCell->mData.mX;
mCellY = actor.getCell()->mCell->mData.mY;
mCellX = actor.getCell()->getCell()->mData.mX;
mCellY = actor.getCell()->getCell()->mData.mY;
ESM::Pathgrid::Point dest;
dest.mX = mX;

@ -1,12 +1,14 @@
#include "aifollow.hpp"
#include <iostream>
#include <OgreMath.h>
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwworld/class.hpp"
#include "movement.hpp"
#include <OgreMath.h>
#include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
#include "movement.hpp"
#include "steering.hpp"
MWMechanics::AiFollow::AiFollow(const std::string &actorId,float duration, float x, float y, float z)
@ -33,16 +35,16 @@ bool MWMechanics::AiFollow::execute (const MWWorld::Ptr& actor,float duration)
if((pos.pos[0]-mX)*(pos.pos[0]-mX) +
(pos.pos[1]-mY)*(pos.pos[1]-mY) +
(pos.pos[2]-mZ)*(pos.pos[2]-mZ) < 100*100)
(pos.pos[2]-mZ)*(pos.pos[2]-mZ) < 100*100)
{
if(actor.getCell()->isExterior())
{
if(mCellId == "")
if(mCellId == "")
return true;
}
else
{
if(mCellId == actor.getCell()->mCell->mName)
if(mCellId == actor.getCell()->getCell()->mName)
return true;
}
}
@ -67,7 +69,7 @@ bool MWMechanics::AiFollow::execute (const MWWorld::Ptr& actor,float duration)
{
ESM::Pathgrid::Point lastPos = mPathFinder.getPath().back();
if((dest.mX - lastPos.mX)*(dest.mX - lastPos.mX)
if((dest.mX - lastPos.mX)*(dest.mX - lastPos.mX)
+(dest.mY - lastPos.mY)*(dest.mY - lastPos.mY)
+(dest.mZ - lastPos.mZ)*(dest.mZ - lastPos.mZ)
> 100*100)

@ -2,7 +2,9 @@
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
#include "steering.hpp"
#include "movement.hpp"
@ -36,12 +38,12 @@ namespace MWMechanics
MWBase::World *world = MWBase::Environment::get().getWorld();
ESM::Position pos = actor.getRefData().getPosition();
Movement &movement = actor.getClass().getMovementSettings(actor);
const ESM::Cell *cell = actor.getCell()->mCell;
const ESM::Cell *cell = actor.getCell()->getCell();
MWWorld::Ptr player = world->getPlayerPtr();
if(cell->mData.mX != player.getCell()->mCell->mData.mX)
if(cell->mData.mX != player.getCell()->getCell()->mData.mX)
{
int sideX = sgn(cell->mData.mX - player.getCell()->mCell->mData.mX);
int sideX = sgn(cell->mData.mX - player.getCell()->getCell()->mData.mX);
//check if actor is near the border of an inactive cell. If so, stop walking.
if(sideX * (pos.pos[0] - cell->mData.mX*ESM::Land::REAL_SIZE) >
sideX * (ESM::Land::REAL_SIZE/2.0f - 200.0f))
@ -50,9 +52,9 @@ namespace MWMechanics
return false;
}
}
if(cell->mData.mY != player.getCell()->mCell->mData.mY)
if(cell->mData.mY != player.getCell()->getCell()->mData.mY)
{
int sideY = sgn(cell->mData.mY - player.getCell()->mCell->mData.mY);
int sideY = sgn(cell->mData.mY - player.getCell()->getCell()->mData.mY);
//check if actor is near the border of an inactive cell. If so, stop walking.
if(sideY * (pos.pos[1] - cell->mData.mY*ESM::Land::REAL_SIZE) >
sideY * (ESM::Land::REAL_SIZE/2.0f - 200.0f))

@ -1,17 +1,19 @@
#include "aiwander.hpp"
#include "movement.hpp"
#include <OgreVector3.h>
#include "../mwworld/class.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/dialoguemanager.hpp"
#include "creaturestats.hpp"
#include <OgreVector3.h>
#include "../mwworld/class.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
#include "creaturestats.hpp"
#include "steering.hpp"
#include "movement.hpp"
namespace
{
@ -103,10 +105,10 @@ namespace MWMechanics
if(!mStoredAvailableNodes)
{
mStoredAvailableNodes = true;
mPathgrid = world->getStore().get<ESM::Pathgrid>().search(*actor.getCell()->mCell);
mPathgrid = world->getStore().get<ESM::Pathgrid>().search(*actor.getCell()->getCell());
mCellX = actor.getCell()->mCell->mData.mX;
mCellY = actor.getCell()->mCell->mData.mY;
mCellX = actor.getCell()->getCell()->mData.mX;
mCellY = actor.getCell()->getCell()->mData.mY;
if(!mPathgrid)
mDistance = 0;
@ -117,7 +119,7 @@ namespace MWMechanics
{
mXCell = 0;
mYCell = 0;
if(actor.getCell()->mCell->isExterior())
if(actor.getCell()->getCell()->isExterior())
{
mXCell = mCellX * ESM::Land::REAL_SIZE;
mYCell = mCellY * ESM::Land::REAL_SIZE;
@ -157,7 +159,7 @@ namespace MWMechanics
mDistance = 0;
// Don't try to move if you are in a new cell (ie: positioncell command called) but still play idles.
if(mDistance && (mCellX != actor.getCell()->mCell->mData.mX || mCellY != actor.getCell()->mCell->mData.mY))
if(mDistance && (mCellX != actor.getCell()->getCell()->mData.mX || mCellY != actor.getCell()->getCell()->mData.mY))
mDistance = 0;
if(mChooseAction)

@ -8,6 +8,11 @@
#include "../mwworld/ptr.hpp"
namespace ESM
{
struct Potion;
}
namespace MWMechanics
{
struct EffectKey;
@ -16,29 +21,29 @@ namespace MWMechanics
class Alchemy
{
public:
typedef std::vector<MWWorld::Ptr> TToolsContainer;
typedef TToolsContainer::const_iterator TToolsIterator;
typedef std::vector<MWWorld::Ptr> TIngredientsContainer;
typedef TIngredientsContainer::const_iterator TIngredientsIterator;
typedef std::vector<ESM::ENAMstruct> TEffectsContainer;
typedef TEffectsContainer::const_iterator TEffectsIterator;
enum Result
{
Result_Success,
Result_NoMortarAndPestle,
Result_LessThanTwoIngredients,
Result_NoName,
Result_NoEffects,
Result_RandomFailure
};
private:
MWWorld::Ptr mAlchemist;
TToolsContainer mTools;
TIngredientsContainer mIngredients;
@ -51,61 +56,61 @@ namespace MWMechanics
void applyTools (int flags, float& value) const;
void updateEffects();
const ESM::Potion *getRecord() const;
///< Return existing recrod for created potion (may return 0)
void removeIngredients();
///< Remove selected ingredients from alchemist's inventory, cleanup selected ingredients and
/// update effect list accordingly.
void addPotion (const std::string& name);
///< Add a potion to the alchemist's inventory.
void increaseSkill();
///< Increase alchemist's skill.
float getChance() const;
///< Return chance of success.
int countIngredients() const;
public:
void setAlchemist (const MWWorld::Ptr& npc);
///< Set alchemist and configure alchemy setup accordingly. \a npc may be empty to indicate that
/// there is no alchemist (alchemy session has ended).
TToolsIterator beginTools() const;
///< \attention Iterates over tool slots, not over tools. Some of the slots may be empty.
TToolsIterator endTools() const;
TIngredientsIterator beginIngredients() const;
///< \attention Iterates over ingredient slots, not over ingredients. Some of the slots may be empty.
TIngredientsIterator endIngredients() const;
void clear();
///< Remove alchemist, tools and ingredients.
int addIngredient (const MWWorld::Ptr& ingredient);
///< Add ingredient into the next free slot.
///
/// \return Slot index or -1, if adding failed because of no free slot or the ingredient type being
/// listed already.
void removeIngredient (int index);
///< Remove ingredient from slot (calling this function on an empty slot is a no-op).
TEffectsIterator beginEffects() const;
TEffectsIterator endEffects() const;
std::string getPotionName() const;
///< Return the name of the potion that would be created when calling create (if a record for such
/// a potion already exists) or return an empty string.
Result create (const std::string& name);
///< Try to create a potion from the ingredients, place it in the inventory of the alchemist and
/// adjust the skills of the alchemist accordingly.

@ -36,6 +36,7 @@
#include "../mwworld/class.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/esmstore.hpp"
namespace
{
@ -562,7 +563,7 @@ bool CharacterController::updateWeaponState()
getWeaponGroup(weaptype, weapgroup);
mAnimation->showWeapons(false);
mAnimation->setWeaponGroup(weapgroup);
mAnimation->play(weapgroup, Priority_Weapon,
MWRender::Animation::Group_UpperBody, true,
1.0f, "equip start", "equip stop", 0.0f, 0);
@ -751,7 +752,7 @@ bool CharacterController::updateWeaponState()
MWRender::Animation::Group_UpperBody, false,
weapSpeed, mAttackType+" start", mAttackType+" min attack",
0.0f, 0);
mUpperBodyState = UpperCharState_StartToMinAttack;
mUpperBodyState = UpperCharState_StartToMinAttack;
}
}
@ -855,7 +856,7 @@ bool CharacterController::updateWeaponState()
mUpperBodyState = UpperCharState_WeapEquiped;
//don't allow to continue playing hit animation on UpperBody after actor had attacked during it
if(mHitState == CharState_Hit)
if(mHitState == CharState_Hit)
{
mAnimation->changeGroups(mCurrentHit, MWRender::Animation::Group_LowerBody);
//commenting out following 2 lines will give a bit different combat dynamics(slower)
@ -932,7 +933,7 @@ bool CharacterController::updateWeaponState()
weapSpeed, start, stop, 0.0f, 0);
}
}
//if playing combat animation and lowerbody is not busy switch to whole body animation
if((weaptype != WeapType_None || UpperCharState_UnEquipingWeap) && animPlaying)
{
@ -1431,7 +1432,7 @@ void CharacterController::updateVisibility()
void CharacterController::determineAttackType()
{
float * move = mPtr.getClass().getMovementSettings(mPtr).mPosition;
if(mPtr.getClass().hasInventoryStore(mPtr))
{
if (move[0] && !move[1]) //sideway

@ -10,6 +10,7 @@
#include "../mwworld/class.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwbase/windowmanager.hpp"

@ -6,6 +6,7 @@
#include "../mwbase/world.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/spells.hpp"
#include "../mwmechanics/creaturestats.hpp"

@ -1,13 +1,15 @@
#include "pathfinding.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include <map>
#include "OgreMath.h"
#include "OgreVector3.h"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include <map>
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
namespace
{
@ -299,14 +301,14 @@ namespace MWMechanics
if(!allowShortcuts)
{
const ESM::Pathgrid *pathGrid =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search(*mCell->mCell);
MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search(*mCell->getCell());
float xCell = 0;
float yCell = 0;
if (mCell->isExterior())
{
xCell = mCell->mCell->mData.mX * ESM::Land::REAL_SIZE;
yCell = mCell->mCell->mData.mY * ESM::Land::REAL_SIZE;
xCell = mCell->getCell()->mData.mX * ESM::Land::REAL_SIZE;
yCell = mCell->getCell()->mData.mY * ESM::Land::REAL_SIZE;
}
int startNode = getClosestPoint(pathGrid, startPoint.mX - xCell, startPoint.mY - yCell,startPoint.mZ);
int endNode = getClosestPoint(pathGrid, endPoint.mX - xCell, endPoint.mY - yCell, endPoint.mZ);
@ -393,7 +395,7 @@ namespace MWMechanics
{
std::list<ESM::Pathgrid::Point>::const_iterator oldStart = path.begin();
std::list<ESM::Pathgrid::Point>::iterator iter = ++mPath.begin();
if( (*iter).mX == oldStart->mX
&& (*iter).mY == oldStart->mY
&& (*iter).mZ == oldStart->mZ

@ -1,8 +1,11 @@
#include "pickpocket.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "npcstats.hpp"
namespace MWMechanics

@ -10,6 +10,7 @@
#include "../mwworld/containerstore.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/npcstats.hpp"

@ -2,6 +2,7 @@
#include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"

@ -14,6 +14,7 @@
#include "../mwworld/actionteleport.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwrender/animation.hpp"
@ -503,7 +504,7 @@ namespace MWMechanics
MWBase::Environment::get().getWorld()->getPlayer().getMarkedPosition(markedCell, markedPosition);
if (markedCell)
{
MWWorld::ActionTeleport action(markedCell->isExterior() ? "" : markedCell->mCell->mName,
MWWorld::ActionTeleport action(markedCell->isExterior() ? "" : markedCell->getCell()->mName,
markedPosition);
action.execute(target);
}

@ -5,6 +5,16 @@
#include <OgreVector3.h>
#include <components/esm/loadskil.hpp>
namespace ESM
{
struct Spell;
struct Ingredient;
struct Potion;
struct EffectList;
}
namespace MWMechanics
{
class EffectKey;

@ -4,6 +4,8 @@
#include <map>
#include <string>
#include <components/misc/stringops.hpp>
#include "../mwworld/ptr.hpp"
#include "magiceffects.hpp"

@ -1,9 +1,11 @@
#include "activatoranimation.hpp"
#include "renderconst.hpp"
#include <components/esm/loadacti.hpp>
#include "../mwbase/world.hpp"
#include "renderconst.hpp"
namespace MWRender
{

@ -11,18 +11,26 @@
#include <OgreControllerManager.h>
#include <OgreStaticGeometry.h>
#include <components/esm/loadligh.hpp>
#include <components/esm/loadweap.hpp>
#include <components/esm/loadench.hpp>
#include <components/esm/loadstat.hpp>
#include <libs/openengine/ogre/lights.hpp>
#include <extern/shiny/Main/Factory.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/world.hpp"
#include <extern/shiny/Main/Factory.hpp>
#include "../mwmechanics/character.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/fallback.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "renderconst.hpp"
@ -334,7 +342,7 @@ void Animation::addExtraLight(Ogre::SceneManager *sceneMgr, NifOgre::ObjectScene
));
objlist->mControllers.push_back(Ogre::Controller<Ogre::Real>(src, dest, func));
bool interior = !(mPtr.isInCell() && mPtr.getCell()->mCell->isExterior());
bool interior = !(mPtr.isInCell() && mPtr.getCell()->getCell()->isExterior());
bool quadratic = fallback->getFallbackBool("LightAttenuation_OutQuadInLin") ?
!interior : fallback->getFallbackBool("LightAttenuation_UseQuadratic");
@ -1070,7 +1078,7 @@ bool Animation::allowSwitchViewMode() const
{
for (AnimStateMap::const_iterator stateiter = mStates.begin(); stateiter != mStates.end(); ++stateiter)
{
if(stateiter->second.mPriority > MWMechanics::Priority_Movement
if(stateiter->second.mPriority > MWMechanics::Priority_Movement
&& stateiter->second.mPriority < MWMechanics::Priority_Torch)
return false;
}

@ -8,6 +8,10 @@
#include "../mwworld/ptr.hpp"
namespace ESM
{
struct Light;
}
namespace MWRender
{

@ -4,12 +4,14 @@
#include <OgreSkeletonInstance.h>
#include <OgreBone.h>
#include "renderconst.hpp"
#include <components/esm/loadcrea.hpp>
#include "../mwbase/world.hpp"
#include "../mwworld/class.hpp"
#include "renderconst.hpp"
namespace MWRender
{

@ -13,12 +13,12 @@
#include <components/esm/loadstat.hpp>
#include <components/esm/loadpgrd.hpp>
#include "../mwworld/esmstore.hpp"
#include "../mwbase/world.hpp" // these includes can be removed once the static-hack is gone
#include "../mwbase/environment.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "renderconst.hpp"
@ -230,22 +230,22 @@ void Debugging::togglePathgrid()
void Debugging::enableCellPathgrid(MWWorld::CellStore *store)
{
const ESM::Pathgrid *pathgrid =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search(*store->mCell);
MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search(*store->getCell());
if (!pathgrid) return;
Vector3 cellPathGridPos(0, 0, 0);
if (store->mCell->isExterior())
if (store->getCell()->isExterior())
{
cellPathGridPos.x = store->mCell->mData.mX * ESM::Land::REAL_SIZE;
cellPathGridPos.y = store->mCell->mData.mY * ESM::Land::REAL_SIZE;
cellPathGridPos.x = store->getCell()->mData.mX * ESM::Land::REAL_SIZE;
cellPathGridPos.y = store->getCell()->mData.mY * ESM::Land::REAL_SIZE;
}
SceneNode *cellPathGrid = mPathGridRoot->createChildSceneNode(cellPathGridPos);
cellPathGrid->attachObject(createPathgridLines(pathgrid));
cellPathGrid->attachObject(createPathgridPoints(pathgrid));
if (store->mCell->isExterior())
if (store->getCell()->isExterior())
{
mExteriorPathgridNodes[std::make_pair(store->mCell->getGridX(), store->mCell->getGridY())] = cellPathGrid;
mExteriorPathgridNodes[std::make_pair(store->getCell()->getGridX(), store->getCell()->getGridY())] = cellPathGrid;
}
else
{
@ -256,10 +256,10 @@ void Debugging::enableCellPathgrid(MWWorld::CellStore *store)
void Debugging::disableCellPathgrid(MWWorld::CellStore *store)
{
if (store->mCell->isExterior())
if (store->getCell()->isExterior())
{
ExteriorPathgridNodes::iterator it =
mExteriorPathgridNodes.find(std::make_pair(store->mCell->getGridX(), store->mCell->getGridY()));
mExteriorPathgridNodes.find(std::make_pair(store->getCell()->getGridX(), store->getCell()->getGridY()));
if (it != mExteriorPathgridNodes.end())
{
destroyCellPathgridNode(it->second);

@ -7,12 +7,13 @@
#include <OgreCamera.h>
#include <OgreTextureManager.h>
#include "../mwworld/esmstore.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
#include "renderconst.hpp"
#include "renderingmanager.hpp"
@ -115,8 +116,8 @@ void LocalMap::requestMap(MWWorld::CellStore* cell, float zMin, float zMax)
mCameraRotNode->setOrientation(Quaternion::IDENTITY);
mCellCamera->setOrientation(Quaternion(Ogre::Math::Cos(Ogre::Degree(0)/2.f), 0, 0, -Ogre::Math::Sin(Ogre::Degree(0)/2.f)));
int x = cell->mCell->getGridX();
int y = cell->mCell->getGridY();
int x = cell->getCell()->getGridX();
int y = cell->getCell()->getGridY();
std::string name = "Cell_"+coordStr(x, y);
@ -182,7 +183,7 @@ void LocalMap::requestMap(MWWorld::CellStore* cell,
const int segsX = std::ceil( length.x / sSize );
const int segsY = std::ceil( length.y / sSize );
mInteriorName = cell->mCell->mName;
mInteriorName = cell->getCell()->mName;
for (int x=0; x<segsX; ++x)
{
@ -192,7 +193,7 @@ void LocalMap::requestMap(MWWorld::CellStore* cell,
Vector2 newcenter = start + 4096;
render(newcenter.x - center.x, newcenter.y - center.y, zMin, zMax, sSize, sSize,
cell->mCell->mName + "_" + coordStr(x,y));
cell->getCell()->mName + "_" + coordStr(x,y));
}
}
}

@ -11,11 +11,15 @@
#include <OgreParticleEmitter.h>
#include <OgreStaticGeometry.h>
#include <components/esm/loadligh.hpp>
#include <components/esm/loadstat.hpp>
#include <components/nifogre/ogrenifloader.hpp>
#include <components/settings/settings.hpp>
#include "../mwworld/ptr.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
#include "renderconst.hpp"
#include "animation.hpp"

@ -24,6 +24,7 @@
#include "../mwworld/esmstore.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwbase/world.hpp" // these includes can be removed once the static-hack is gone
#include "../mwbase/environment.hpp"
@ -422,9 +423,9 @@ void RenderingManager::postRenderTargetUpdate(const RenderTargetEvent &evt)
void RenderingManager::waterAdded (MWWorld::CellStore *store)
{
if(store->mCell->mData.mFlags & ESM::Cell::HasWater)
if (store->getCell()->mData.mFlags & ESM::Cell::HasWater)
{
mWater->changeCell(store->mCell);
mWater->changeCell (store->getCell());
mWater->setActive(true);
}
else
@ -501,9 +502,9 @@ bool RenderingManager::toggleRenderMode(int mode)
void RenderingManager::configureFog(MWWorld::CellStore &mCell)
{
Ogre::ColourValue color;
color.setAsABGR (mCell.mCell->mAmbi.mFog);
color.setAsABGR (mCell.getCell()->mAmbi.mFog);
configureFog(mCell.mCell->mAmbi.mFogDensity, color);
configureFog (mCell.getCell()->mAmbi.mFogDensity, color);
}
void RenderingManager::configureFog(const float density, const Ogre::ColourValue& colour)
@ -553,8 +554,8 @@ void RenderingManager::setAmbientMode()
void RenderingManager::configureAmbient(MWWorld::CellStore &mCell)
{
if (mCell.mCell->mData.mFlags & ESM::Cell::Interior)
mAmbientColor.setAsABGR (mCell.mCell->mAmbi.mAmbient);
if (mCell.getCell()->mData.mFlags & ESM::Cell::Interior)
mAmbientColor.setAsABGR (mCell.getCell()->mAmbi.mAmbient);
setAmbientMode();
// Create a "sun" that shines light downwards. It doesn't look
@ -564,10 +565,10 @@ void RenderingManager::configureAmbient(MWWorld::CellStore &mCell)
mSun = mRendering.getScene()->createLight();
mSun->setType(Ogre::Light::LT_DIRECTIONAL);
}
if (mCell.mCell->mData.mFlags & ESM::Cell::Interior)
if (mCell.getCell()->mData.mFlags & ESM::Cell::Interior)
{
Ogre::ColourValue colour;
colour.setAsABGR (mCell.mCell->mAmbi.mSunlight);
colour.setAsABGR (mCell.getCell()->mAmbi.mSunlight);
mSun->setDiffuseColour (colour);
mSun->setDirection(0,-1,0);
}
@ -650,12 +651,12 @@ void RenderingManager::setGlare(bool glare)
void RenderingManager::requestMap(MWWorld::CellStore* cell)
{
if (cell->mCell->isExterior())
if (cell->getCell()->isExterior())
{
assert(mTerrain);
Ogre::AxisAlignedBox dims = mObjects->getDimensions(cell);
Ogre::Vector2 center(cell->mCell->getGridX() + 0.5, cell->mCell->getGridY() + 0.5);
Ogre::Vector2 center (cell->getCell()->getGridX() + 0.5, cell->getCell()->getGridY() + 0.5);
dims.merge(mTerrain->getWorldBoundingBox(center));
if (dims.isFinite())

@ -13,6 +13,7 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/cellstore.hpp"
#include "interpretercontext.hpp"
@ -88,7 +89,7 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime)
{
bool interior =
!MWBase::Environment::get().getWorld()->getPlayerPtr().getCell()->mCell->isExterior();
!MWBase::Environment::get().getWorld()->getPlayerPtr().getCell()->getCell()->isExterior();
runtime.push (interior ? 1 : 0);
}
@ -103,7 +104,7 @@ namespace MWScript
std::string name = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop();
const ESM::Cell *cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell()->mCell;
const ESM::Cell *cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell()->getCell();
std::string current = cell->mName;
@ -131,8 +132,8 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime)
{
MWWorld::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell();
if (cell->mCell->hasWater())
runtime.push (cell->mWaterLevel);
if (cell->getCell()->hasWater())
runtime.push (cell->getWaterLevel());
else
runtime.push (-std::numeric_limits<float>().max());
}
@ -148,11 +149,11 @@ namespace MWScript
MWWorld::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell();
if (cell->mCell->isExterior())
if (cell->getCell()->isExterior())
throw std::runtime_error("Can't set water level in exterior cell");
cell->mWaterLevel = level;
MWBase::Environment::get().getWorld()->setWaterHeight(cell->mWaterLevel);
cell->setWaterLevel (level);
MWBase::Environment::get().getWorld()->setWaterHeight (cell->getWaterLevel());
}
};
@ -166,11 +167,11 @@ namespace MWScript
MWWorld::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell();
if (cell->mCell->isExterior())
if (cell->getCell()->isExterior())
throw std::runtime_error("Can't set water level in exterior cell");
cell->mWaterLevel +=level;
MWBase::Environment::get().getWorld()->setWaterHeight(cell->mWaterLevel);
cell->setWaterLevel (cell->getWaterLevel()+level);
MWBase::Environment::get().getWorld()->setWaterHeight(cell->getWaterLevel());
}
};

@ -14,6 +14,8 @@
#include <components/interpreter/runtime.hpp>
#include <components/interpreter/opcodes.hpp>
#include <components/esm/loadskil.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
@ -284,7 +286,7 @@ namespace MWScript
virtual void execute(Interpreter::Runtime &runtime)
{
MWWorld::Ptr ptr = R()(runtime);
const std::string &name = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop();

@ -13,12 +13,16 @@
#include <components/interpreter/runtime.hpp>
#include <components/interpreter/opcodes.hpp>
#include <components/esm/loadmgef.hpp>
#include <components/esm/loadcrea.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/scriptmanager.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/creaturestats.hpp"

@ -9,6 +9,7 @@
#include "../mwbase/statemanager.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
#include "sound_output.hpp"
#include "sound_decoder.hpp"
@ -480,7 +481,7 @@ namespace MWSound
static float sTimePassed = 0.0;
MWBase::World *world = MWBase::Environment::get().getWorld();
const MWWorld::Ptr player = world->getPlayerPtr();
const ESM::Cell *cell = player.getCell()->mCell;
const ESM::Cell *cell = player.getCell()->getCell();
sTimePassed += duration;
if(!cell->isExterior() || sTimePassed < sTimeToNextEnvSound)
@ -548,7 +549,7 @@ namespace MWSound
MWWorld::Ptr player =
MWBase::Environment::get().getWorld()->getPlayerPtr();
const ESM::Cell *cell = player.getCell()->mCell;
const ESM::Cell *cell = player.getCell()->getCell();
Environment env = Env_Normal;
if((cell->mData.mFlags&cell->HasWater) && mListenerPos.z < cell->mWater)

@ -23,6 +23,7 @@
#include "../mwworld/player.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwmechanics/npcstats.hpp"
@ -301,7 +302,7 @@ void MWState::StateManager::loadGame (const Character *character, const Slot *sl
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
ESM::CellId cellId = ptr.getCell()->mCell->getCellId();
ESM::CellId cellId = ptr.getCell()->getCell()->getCellId();
MWBase::Environment::get().getWorld()->changeToCell (cellId, ptr.getRefData().getPosition());
}

@ -3,6 +3,8 @@
#include <cstdlib>
#include <components/esm/loadskil.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
@ -19,10 +21,10 @@ namespace MWWorld
// apply to actor
std::string id = Class::get (getTarget()).getId (getTarget());
if (Class::get (actor).apply (actor, id, actor))
Class::get (actor).skillUsageSucceeded (actor, ESM::Skill::Alchemy, 1);
}
}
ActionEat::ActionEat (const MWWorld::Ptr& object) : Action (false, object) {}
}

@ -0,0 +1,54 @@
#ifndef GAME_MWWORLD_CELLREFLIST_H
#define GAME_MWWORLD_CELLREFLIST_H
#include <list>
#include "livecellref.hpp"
namespace MWWorld
{
/// \brief Collection of references of one type
template <typename X>
struct CellRefList
{
typedef LiveCellRef<X> LiveRef;
typedef std::list<LiveRef> List;
List mList;
/// Search for the given reference in the given reclist from
/// ESMStore. Insert the reference into the list if a match is
/// found. If not, throw an exception.
/// Moved to cpp file, as we require a custom compare operator for it,
/// and the build will fail with an ugly three-way cyclic header dependence
/// so we need to pass the instantiation of the method to the linker, when
/// all methods are known.
void load (ESM::CellRef &ref, bool deleted, const MWWorld::ESMStore &esmStore);
LiveRef *find (const std::string& name)
{
for (typename List::iterator iter (mList.begin()); iter!=mList.end(); ++iter)
if (iter->mData.getCount() > 0 && iter->mRef.mRefID == name)
return &*iter;
return 0;
}
LiveRef &insert (const LiveRef &item)
{
mList.push_back(item);
return mList.back();
}
LiveCellRef<X> *searchViaHandle (const std::string& handle)
{
for (typename List::iterator iter (mList.begin()); iter!=mList.end(); ++iter)
if (iter->mData.getCount()>0 && iter->mData.getBaseNode() &&
iter->mData.getHandle()==handle)
return &*iter;
return 0;
}
};
}
#endif

@ -11,6 +11,7 @@
#include "class.hpp"
#include "esmstore.hpp"
#include "containerstore.hpp"
#include "cellstore.hpp"
MWWorld::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell)
{
@ -65,8 +66,11 @@ MWWorld::Ptr MWWorld::Cells::getPtrAndCache (const std::string& name, CellStore&
return ptr;
}
void MWWorld::Cells::writeCell (ESM::ESMWriter& writer, const CellStore& cell) const
void MWWorld::Cells::writeCell (ESM::ESMWriter& writer, CellStore& cell) const
{
if (cell.getState()!=CellStore::State_Loaded)
cell.load (mStore, mReader);
ESM::CellState cellState;
cell.saveState (cellState);
@ -78,17 +82,6 @@ void MWWorld::Cells::writeCell (ESM::ESMWriter& writer, const CellStore& cell) c
writer.endRecord (ESM::REC_CSTA);
}
bool MWWorld::Cells::hasState (const CellStore& cellStore) const
{
if (cellStore.mState==CellStore::State_Loaded)
return true;
if (cellStore.mCell->mData.mFlags & ESM::Cell::Interior)
return cellStore.mCell->mData.mFlags & ESM::Cell::HasWater;
else
return false;
}
MWWorld::Cells::Cells (const MWWorld::ESMStore& store, std::vector<ESM::ESMReader>& reader)
: mStore (store), mReader (reader),
mIdCache (40, std::pair<std::string, CellStore *> ("", (CellStore*)0)), /// \todo make cache size configurable
@ -122,7 +115,7 @@ MWWorld::CellStore *MWWorld::Cells::getExterior (int x, int y)
std::make_pair (x, y), CellStore (cell))).first;
}
if (result->second.mState!=CellStore::State_Loaded)
if (result->second.getState()!=CellStore::State_Loaded)
{
// Multiple plugin support for landscape data is much easier than for references. The last plugin wins.
result->second.load (mStore, mReader);
@ -143,7 +136,7 @@ MWWorld::CellStore *MWWorld::Cells::getInterior (const std::string& name)
result = mInteriors.insert (std::make_pair (lowerName, CellStore (cell))).first;
}
if (result->second.mState!=CellStore::State_Loaded)
if (result->second.getState()!=CellStore::State_Loaded)
{
result->second.load (mStore, mReader);
}
@ -162,12 +155,12 @@ MWWorld::CellStore *MWWorld::Cells::getCell (const ESM::CellId& id)
MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, CellStore& cell,
bool searchInContainers)
{
if (cell.mState==CellStore::State_Unloaded)
if (cell.getState()==CellStore::State_Unloaded)
cell.preload (mStore, mReader);
if (cell.mState==CellStore::State_Preloaded)
if (cell.getState()==CellStore::State_Preloaded)
{
if (std::binary_search (cell.mIds.begin(), cell.mIds.end(), name))
if (cell.hasId (name))
{
cell.load (mStore, mReader);
}
@ -175,65 +168,10 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, CellStore& cell,
return Ptr();
}
if (MWWorld::LiveCellRef<ESM::Activator> *ref = cell.mActivators.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Potion> *ref = cell.mPotions.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Apparatus> *ref = cell.mAppas.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Armor> *ref = cell.mArmors.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Book> *ref = cell.mBooks.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Clothing> *ref = cell.mClothes.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Container> *ref = cell.mContainers.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Creature> *ref = cell.mCreatures.find (name))
return Ptr (ref, &cell);
Ptr ptr = cell.search (name);
if (MWWorld::LiveCellRef<ESM::Door> *ref = cell.mDoors.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Ingredient> *ref = cell.mIngreds.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::CreatureLevList> *ref = cell.mCreatureLists.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::ItemLevList> *ref = cell.mItemLists.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Light> *ref = cell.mLights.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Lockpick> *ref = cell.mLockpicks.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = cell.mMiscItems.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::NPC> *ref = cell.mNpcs.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Probe> *ref = cell.mProbes.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Repair> *ref = cell.mRepairs.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Static> *ref = cell.mStatics.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Weapon> *ref = cell.mWeapons.find (name))
return Ptr (ref, &cell);
if (!ptr.isEmpty())
return ptr;
if (searchInContainers)
return cell.searchInContainer (name);
@ -328,12 +266,12 @@ int MWWorld::Cells::countSavedGameRecords() const
for (std::map<std::string, CellStore>::const_iterator iter (mInteriors.begin());
iter!=mInteriors.end(); ++iter)
if (hasState (iter->second))
if (iter->second.hasState())
++count;
for (std::map<std::pair<int, int>, CellStore>::const_iterator iter (mExteriors.begin());
iter!=mExteriors.end(); ++iter)
if (hasState (iter->second))
if (iter->second.hasState())
++count;
return count;
@ -341,14 +279,14 @@ int MWWorld::Cells::countSavedGameRecords() const
void MWWorld::Cells::write (ESM::ESMWriter& writer) const
{
for (std::map<std::pair<int, int>, CellStore>::const_iterator iter (mExteriors.begin());
for (std::map<std::pair<int, int>, CellStore>::iterator iter (mExteriors.begin());
iter!=mExteriors.end(); ++iter)
if (hasState (iter->second))
if (iter->second.hasState())
writeCell (writer, iter->second);
for (std::map<std::string, CellStore>::const_iterator iter (mInteriors.begin());
for (std::map<std::string, CellStore>::iterator iter (mInteriors.begin());
iter!=mInteriors.end(); ++iter)
if (hasState (iter->second))
if (iter->second.hasState())
writeCell (writer, iter->second);
}
@ -375,7 +313,7 @@ bool MWWorld::Cells::readRecord (ESM::ESMReader& reader, int32_t type,
state.load (reader);
cellStore->loadState (state);
if (cellStore->mState!=CellStore::State_Loaded)
if (cellStore->getState()!=CellStore::State_Loaded)
cellStore->load (mStore, mReader);
cellStore->readReferences (reader, contentFileMap);

@ -12,6 +12,7 @@ namespace ESM
class ESMReader;
class ESMWriter;
struct CellId;
struct Cell;
}
namespace MWWorld
@ -23,8 +24,8 @@ namespace MWWorld
{
const MWWorld::ESMStore& mStore;
std::vector<ESM::ESMReader>& mReader;
std::map<std::string, CellStore> mInteriors;
std::map<std::pair<int, int>, CellStore> mExteriors;
mutable std::map<std::string, CellStore> mInteriors;
mutable std::map<std::pair<int, int>, CellStore> mExteriors;
std::vector<std::pair<std::string, CellStore *> > mIdCache;
std::size_t mIdCacheIndex;
@ -35,10 +36,7 @@ namespace MWWorld
Ptr getPtrAndCache (const std::string& name, CellStore& cellStore);
void writeCell (ESM::ESMWriter& writer, const CellStore& cell) const;
bool hasState (const CellStore& cellStore) const;
///< Check if cell has state that needs to be included in a saved game file.
void writeCell (ESM::ESMWriter& writer, CellStore& cell) const;
public:

@ -1,6 +1,7 @@
#include "cellstore.hpp"
#include <iostream>
#include <algorithm>
#include <components/esm/cellstate.hpp>
#include <components/esm/cellid.hpp>
@ -140,11 +141,216 @@ namespace MWWorld
}
CellStore::CellStore (const ESM::Cell *cell)
: mCell (cell), mState (State_Unloaded)
: mCell (cell), mState (State_Unloaded), mHasState (false)
{
mWaterLevel = cell->mWater;
}
const ESM::Cell *CellStore::getCell() const
{
return mCell;
}
CellStore::State CellStore::getState() const
{
return mState;
}
bool CellStore::hasState() const
{
return mHasState;
}
bool CellStore::hasId (const std::string& id) const
{
if (mState==State_Unloaded)
return false;
if (mState==State_Preloaded)
return std::binary_search (mIds.begin(), mIds.end(), id);
/// \todo address const-issues
return const_cast<CellStore *> (this)->search (id).isEmpty();
}
Ptr CellStore::search (const std::string& id)
{
bool oldState = mHasState;
mHasState = true;
if (LiveCellRef<ESM::Activator> *ref = mActivators.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Potion> *ref = mPotions.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Apparatus> *ref = mAppas.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Armor> *ref = mArmors.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Book> *ref = mBooks.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Clothing> *ref = mClothes.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Container> *ref = mContainers.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Creature> *ref = mCreatures.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Door> *ref = mDoors.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Ingredient> *ref = mIngreds.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::CreatureLevList> *ref = mCreatureLists.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::ItemLevList> *ref = mItemLists.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Light> *ref = mLights.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Lockpick> *ref = mLockpicks.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Miscellaneous> *ref = mMiscItems.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::NPC> *ref = mNpcs.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Probe> *ref = mProbes.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Repair> *ref = mRepairs.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Static> *ref = mStatics.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Weapon> *ref = mWeapons.find (id))
return Ptr (ref, this);
mHasState = oldState;
return Ptr();
}
Ptr CellStore::searchViaHandle (const std::string& handle)
{
bool oldState = mHasState;
mHasState = true;
if (LiveCellRef<ESM::Activator> *ref = mActivators.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Potion> *ref = mPotions.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Apparatus> *ref = mAppas.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Armor> *ref = mArmors.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Book> *ref = mBooks.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Clothing> *ref = mClothes.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Container> *ref = mContainers.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Creature> *ref = mCreatures.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Door> *ref = mDoors.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Ingredient> *ref = mIngreds.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::CreatureLevList> *ref = mCreatureLists.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::ItemLevList> *ref = mItemLists.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Light> *ref = mLights.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Lockpick> *ref = mLockpicks.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Miscellaneous> *ref = mMiscItems.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::NPC> *ref = mNpcs.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Probe> *ref = mProbes.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Repair> *ref = mRepairs.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Static> *ref = mStatics.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Weapon> *ref = mWeapons.searchViaHandle (handle))
return Ptr (ref, this);
mHasState = oldState;
return Ptr();
}
float CellStore::getWaterLevel() const
{
return mWaterLevel;
}
void CellStore::setWaterLevel (float level)
{
mWaterLevel = level;
mHasState = true;
}
int CellStore::count() const
{
return
mActivators.mList.size()
+ mPotions.mList.size()
+ mAppas.mList.size()
+ mArmors.mList.size()
+ mBooks.mList.size()
+ mClothes.mList.size()
+ mContainers.mList.size()
+ mDoors.mList.size()
+ mIngreds.mList.size()
+ mCreatureLists.mList.size()
+ mItemLists.mList.size()
+ mLights.mList.size()
+ mLockpicks.mList.size()
+ mMiscItems.mList.size()
+ mProbes.mList.size()
+ mRepairs.mList.size()
+ mStatics.mList.size()
+ mWeapons.mList.size()
+ mCreatures.mList.size()
+ mNpcs.mList.size();
}
void CellStore::load (const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm)
{
if (mState!=State_Loaded)
@ -242,28 +448,27 @@ namespace MWWorld
}
}
bool CellStore::isExterior() const
{
return mCell->isExterior();
}
Ptr CellStore::searchInContainer (const std::string& id)
{
{
Ptr ptr = searchInContainerList (mContainers, id);
bool oldState = mHasState;
if (!ptr.isEmpty())
return ptr;
}
mHasState = true;
{
Ptr ptr = searchInContainerList (mCreatures, id);
if (Ptr ptr = searchInContainerList (mContainers, id))
return ptr;
if (!ptr.isEmpty())
return ptr;
}
if (Ptr ptr = searchInContainerList (mCreatures, id))
return ptr;
{
Ptr ptr = searchInContainerList (mNpcs, id);
if (Ptr ptr = searchInContainerList (mNpcs, id))
return ptr;
if (!ptr.isEmpty())
return ptr;
}
mHasState = oldState;
return Ptr();
}
@ -305,6 +510,8 @@ namespace MWWorld
void CellStore::loadState (const ESM::CellState& state)
{
mHasState = true;
if (mCell->mData.mFlags & ESM::Cell::Interior && mCell->mData.mFlags & ESM::Cell::HasWater)
mWaterLevel = state.mWaterLevel;
@ -348,6 +555,8 @@ namespace MWWorld
void CellStore::readReferences (ESM::ESMReader& reader,
const std::map<int, int>& contentFileMap)
{
mHasState = true;
while (reader.isNextSub ("OBJE"))
{
unsigned int id = 0;
@ -461,4 +670,14 @@ namespace MWWorld
}
}
}
bool operator== (const CellStore& left, const CellStore& right)
{
return left.getCell()->getCellId()==right.getCell()->getCellId();
}
bool operator!= (const CellStore& left, const CellStore& right)
{
return !(left==right);
}
}

@ -1,11 +1,12 @@
#ifndef GAME_MWWORLD_CELLSTORE_H
#define GAME_MWWORLD_CELLSTORE_H
#include <deque>
#include <algorithm>
#include <stdexcept>
#include "livecellref.hpp"
#include "esmstore.hpp"
#include "cellreflist.hpp"
namespace ESM
{
@ -14,164 +15,301 @@ namespace ESM
namespace MWWorld
{
class Ptr;
/// A list of cell references
template <typename X>
struct CellRefList
{
typedef LiveCellRef<X> LiveRef;
typedef std::list<LiveRef> List;
List mList;
/// \brief Mutable state of a cell
class CellStore
{
public:
enum State
{
State_Unloaded, State_Preloaded, State_Loaded
};
private:
const ESM::Cell *mCell;
State mState;
bool mHasState;
std::vector<std::string> mIds;
float mWaterLevel;
CellRefList<ESM::Activator> mActivators;
CellRefList<ESM::Potion> mPotions;
CellRefList<ESM::Apparatus> mAppas;
CellRefList<ESM::Armor> mArmors;
CellRefList<ESM::Book> mBooks;
CellRefList<ESM::Clothing> mClothes;
CellRefList<ESM::Container> mContainers;
CellRefList<ESM::Creature> mCreatures;
CellRefList<ESM::Door> mDoors;
CellRefList<ESM::Ingredient> mIngreds;
CellRefList<ESM::CreatureLevList> mCreatureLists;
CellRefList<ESM::ItemLevList> mItemLists;
CellRefList<ESM::Light> mLights;
CellRefList<ESM::Lockpick> mLockpicks;
CellRefList<ESM::Miscellaneous> mMiscItems;
CellRefList<ESM::NPC> mNpcs;
CellRefList<ESM::Probe> mProbes;
CellRefList<ESM::Repair> mRepairs;
CellRefList<ESM::Static> mStatics;
CellRefList<ESM::Weapon> mWeapons;
public:
CellStore (const ESM::Cell *cell_);
const ESM::Cell *getCell() const;
State getState() const;
bool hasState() const;
///< Does this cell have state that needs to be stored in a saved game file?
bool hasId (const std::string& id) const;
///< May return true for deleted IDs when in preload state. Will return false, if cell is
/// unloaded.
Ptr search (const std::string& id);
///< Will return an empty Ptr if cell is not loaded. Does not check references in
/// containers.
Ptr searchViaHandle (const std::string& handle);
///< Will return an empty Ptr if cell is not loaded.
float getWaterLevel() const;
void setWaterLevel (float level);
int count() const;
///< Return total number of references, including deleted ones.
void load (const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
///< Load references from content file.
void preload (const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
///< Build ID list from content file.
/// Call functor (ref) for each reference. functor must return a bool. Returning
/// false will abort the iteration.
/// \return Iteration completed?
///
/// \note Creatures and NPCs are handled last.
template<class Functor>
bool forEach (Functor& functor)
{
mHasState = true;
return
forEachImp (functor, mActivators) &&
forEachImp (functor, mPotions) &&
forEachImp (functor, mAppas) &&
forEachImp (functor, mArmors) &&
forEachImp (functor, mBooks) &&
forEachImp (functor, mClothes) &&
forEachImp (functor, mContainers) &&
forEachImp (functor, mDoors) &&
forEachImp (functor, mIngreds) &&
forEachImp (functor, mItemLists) &&
forEachImp (functor, mLights) &&
forEachImp (functor, mLockpicks) &&
forEachImp (functor, mMiscItems) &&
forEachImp (functor, mProbes) &&
forEachImp (functor, mRepairs) &&
forEachImp (functor, mStatics) &&
forEachImp (functor, mWeapons) &&
forEachImp (functor, mCreatures) &&
forEachImp (functor, mNpcs) &&
forEachImp (functor, mCreatureLists);
}
bool isExterior() const;
Ptr searchInContainer (const std::string& id);
void loadState (const ESM::CellState& state);
void saveState (ESM::CellState& state) const;
void writeReferences (ESM::ESMWriter& writer) const;
void readReferences (ESM::ESMReader& reader, const std::map<int, int>& contentFileMap);
template <class T>
CellRefList<T>& get() {
throw std::runtime_error ("Storage for this type not exist in cells");
}
private:
template<class Functor, class List>
bool forEachImp (Functor& functor, List& list)
{
for (typename List::List::iterator iter (list.mList.begin()); iter!=list.mList.end();
++iter)
{
if (!iter->mData.getCount())
continue;
if (!functor (MWWorld::Ptr(&*iter, this)))
return false;
}
return true;
}
/// Run through references and store IDs
void listRefs(const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
void loadRefs(const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
void loadRef (ESM::CellRef& ref, bool deleted, const ESMStore& store);
///< Make case-adjustments to \a ref and insert it into the respective container.
///
/// Invalid \a ref objects are silently dropped.
};
// Search for the given reference in the given reclist from
// ESMStore. Insert the reference into the list if a match is
// found. If not, throw an exception.
// Moved to cpp file, as we require a custom compare operator for it,
// and the build will fail with an ugly three-way cyclic header dependence
// so we need to pass the instantiation of the method to the lnker, when
// all methods are known.
void load(ESM::CellRef &ref, bool deleted, const MWWorld::ESMStore &esmStore);
template<>
inline CellRefList<ESM::Activator>& CellStore::get<ESM::Activator>()
{
mHasState = true;
return mActivators;
}
LiveRef *find (const std::string& name)
template<>
inline CellRefList<ESM::Potion>& CellStore::get<ESM::Potion>()
{
for (typename std::list<LiveRef>::iterator iter (mList.begin()); iter!=mList.end(); ++iter)
{
if (iter->mData.getCount() > 0 && iter->mRef.mRefID == name)
return &*iter;
}
mHasState = true;
return mPotions;
}
return 0;
template<>
inline CellRefList<ESM::Apparatus>& CellStore::get<ESM::Apparatus>()
{
mHasState = true;
return mAppas;
}
LiveRef &insert(const LiveRef &item) {
mList.push_back(item);
return mList.back();
template<>
inline CellRefList<ESM::Armor>& CellStore::get<ESM::Armor>()
{
mHasState = true;
return mArmors;
}
};
/// A storage struct for one single cell reference.
class CellStore
{
public:
template<>
inline CellRefList<ESM::Book>& CellStore::get<ESM::Book>()
{
mHasState = true;
return mBooks;
}
enum State
template<>
inline CellRefList<ESM::Clothing>& CellStore::get<ESM::Clothing>()
{
State_Unloaded, State_Preloaded, State_Loaded
};
mHasState = true;
return mClothes;
}
template<>
inline CellRefList<ESM::Container>& CellStore::get<ESM::Container>()
{
mHasState = true;
return mContainers;
}
CellStore (const ESM::Cell *cell_);
const ESM::Cell *mCell;
State mState;
std::vector<std::string> mIds;
template<>
inline CellRefList<ESM::Creature>& CellStore::get<ESM::Creature>()
{
mHasState = true;
return mCreatures;
}
float mWaterLevel;
template<>
inline CellRefList<ESM::Door>& CellStore::get<ESM::Door>()
{
mHasState = true;
return mDoors;
}
template<>
inline CellRefList<ESM::Ingredient>& CellStore::get<ESM::Ingredient>()
{
mHasState = true;
return mIngreds;
}
template<>
inline CellRefList<ESM::CreatureLevList>& CellStore::get<ESM::CreatureLevList>()
{
mHasState = true;
return mCreatureLists;
}
template<>
inline CellRefList<ESM::ItemLevList>& CellStore::get<ESM::ItemLevList>()
{
mHasState = true;
return mItemLists;
}
template<>
inline CellRefList<ESM::Light>& CellStore::get<ESM::Light>()
{
mHasState = true;
return mLights;
}
template<>
inline CellRefList<ESM::Lockpick>& CellStore::get<ESM::Lockpick>()
{
mHasState = true;
return mLockpicks;
}
template<>
inline CellRefList<ESM::Miscellaneous>& CellStore::get<ESM::Miscellaneous>()
{
mHasState = true;
return mMiscItems;
}
template<>
inline CellRefList<ESM::NPC>& CellStore::get<ESM::NPC>()
{
mHasState = true;
return mNpcs;
}
template<>
inline CellRefList<ESM::Probe>& CellStore::get<ESM::Probe>()
{
mHasState = true;
return mProbes;
}
template<>
inline CellRefList<ESM::Repair>& CellStore::get<ESM::Repair>()
{
mHasState = true;
return mRepairs;
}
template<>
inline CellRefList<ESM::Static>& CellStore::get<ESM::Static>()
{
mHasState = true;
return mStatics;
}
template<>
inline CellRefList<ESM::Weapon>& CellStore::get<ESM::Weapon>()
{
mHasState = true;
return mWeapons;
}
// Lists for each individual object type
CellRefList<ESM::Activator> mActivators;
CellRefList<ESM::Potion> mPotions;
CellRefList<ESM::Apparatus> mAppas;
CellRefList<ESM::Armor> mArmors;
CellRefList<ESM::Book> mBooks;
CellRefList<ESM::Clothing> mClothes;
CellRefList<ESM::Container> mContainers;
CellRefList<ESM::Creature> mCreatures;
CellRefList<ESM::Door> mDoors;
CellRefList<ESM::Ingredient> mIngreds;
CellRefList<ESM::CreatureLevList> mCreatureLists;
CellRefList<ESM::ItemLevList> mItemLists;
CellRefList<ESM::Light> mLights;
CellRefList<ESM::Lockpick> mLockpicks;
CellRefList<ESM::Miscellaneous> mMiscItems;
CellRefList<ESM::NPC> mNpcs;
CellRefList<ESM::Probe> mProbes;
CellRefList<ESM::Repair> mRepairs;
CellRefList<ESM::Static> mStatics;
CellRefList<ESM::Weapon> mWeapons;
void load (const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
void preload (const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
/// Call functor (ref) for each reference. functor must return a bool. Returning
/// false will abort the iteration.
/// \return Iteration completed?
template<class Functor>
bool forEach (Functor& functor)
{
return
forEachImp (functor, mActivators) &&
forEachImp (functor, mPotions) &&
forEachImp (functor, mAppas) &&
forEachImp (functor, mArmors) &&
forEachImp (functor, mBooks) &&
forEachImp (functor, mClothes) &&
forEachImp (functor, mContainers) &&
forEachImp (functor, mCreatures) &&
forEachImp (functor, mDoors) &&
forEachImp (functor, mIngreds) &&
forEachImp (functor, mCreatureLists) &&
forEachImp (functor, mItemLists) &&
forEachImp (functor, mLights) &&
forEachImp (functor, mLockpicks) &&
forEachImp (functor, mMiscItems) &&
forEachImp (functor, mNpcs) &&
forEachImp (functor, mProbes) &&
forEachImp (functor, mRepairs) &&
forEachImp (functor, mStatics) &&
forEachImp (functor, mWeapons);
}
bool operator==(const CellStore &cell) {
return mCell->mName == cell.mCell->mName &&
mCell->mData.mX == cell.mCell->mData.mX &&
mCell->mData.mY == cell.mCell->mData.mY;
}
bool operator!=(const CellStore &cell) {
return !(*this == cell);
}
bool isExterior() const {
return mCell->isExterior();
}
Ptr searchInContainer (const std::string& id);
void loadState (const ESM::CellState& state);
void saveState (ESM::CellState& state) const;
void writeReferences (ESM::ESMWriter& writer) const;
void readReferences (ESM::ESMReader& reader, const std::map<int, int>& contentFileMap);
private:
template<class Functor, class List>
bool forEachImp (Functor& functor, List& list)
{
for (typename List::List::iterator iter (list.mList.begin()); iter!=list.mList.end();
++iter)
{
if (!iter->mData.getCount())
continue;
if (!functor (MWWorld::Ptr(&*iter, this)))
return false;
}
return true;
}
/// Run through references and store IDs
void listRefs(const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
void loadRefs(const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
void loadRef (ESM::CellRef& ref, bool deleted, const ESMStore& store);
///< Make case-adjustments to \a ref and insert it into the respective container.
///
/// Invalid \a ref objects are silently dropped.
};
bool operator== (const CellStore& left, const CellStore& right);
bool operator!= (const CellStore& left, const CellStore& right);
}
#endif

@ -3,6 +3,19 @@
#include <iterator>
#include <components/esm/loadalch.hpp>
#include <components/esm/loadappa.hpp>
#include <components/esm/loadarmo.hpp>
#include <components/esm/loadbook.hpp>
#include <components/esm/loadclot.hpp>
#include <components/esm/loadingr.hpp>
#include <components/esm/loadlock.hpp>
#include <components/esm/loadligh.hpp>
#include <components/esm/loadmisc.hpp>
#include <components/esm/loadprob.hpp>
#include <components/esm/loadrepa.hpp>
#include <components/esm/loadweap.hpp>
#include "ptr.hpp"
namespace ESM

@ -5,6 +5,11 @@
#include "../mwmechanics/magiceffects.hpp"
namespace ESM
{
struct MagicEffect;
}
namespace MWMechanics
{
class NpcStats;

@ -101,26 +101,26 @@ void MWWorld::LocalScripts::add (const std::string& scriptName, const Ptr& ptr)
void MWWorld::LocalScripts::addCell (CellStore *cell)
{
listCellScripts (*this, cell->mActivators, cell);
listCellScripts (*this, cell->mPotions, cell);
listCellScripts (*this, cell->mAppas, cell);
listCellScripts (*this, cell->mArmors, cell);
listCellScripts (*this, cell->mBooks, cell);
listCellScripts (*this, cell->mClothes, cell);
listCellScripts (*this, cell->mContainers, cell);
listCellScriptsCont (*this, cell->mContainers, cell);
listCellScripts (*this, cell->mCreatures, cell);
listCellScriptsCont (*this, cell->mCreatures, cell);
listCellScripts (*this, cell->mDoors, cell);
listCellScripts (*this, cell->mIngreds, cell);
listCellScripts (*this, cell->mLights, cell);
listCellScripts (*this, cell->mLockpicks, cell);
listCellScripts (*this, cell->mMiscItems, cell);
listCellScripts (*this, cell->mNpcs, cell);
listCellScriptsCont (*this, cell->mNpcs, cell);
listCellScripts (*this, cell->mProbes, cell);
listCellScripts (*this, cell->mRepairs, cell);
listCellScripts (*this, cell->mWeapons, cell);
listCellScripts (*this, cell->get<ESM::Activator>(), cell);
listCellScripts (*this, cell->get<ESM::Potion>(), cell);
listCellScripts (*this, cell->get<ESM::Apparatus>(), cell);
listCellScripts (*this, cell->get<ESM::Armor>(), cell);
listCellScripts (*this, cell->get<ESM::Book>(), cell);
listCellScripts (*this, cell->get<ESM::Clothing>(), cell);
listCellScripts (*this, cell->get<ESM::Container>(), cell);
listCellScriptsCont (*this, cell->get<ESM::Container>(), cell);
listCellScripts (*this, cell->get<ESM::Creature>(), cell);
listCellScriptsCont (*this, cell->get<ESM::Creature>(), cell);
listCellScripts (*this, cell->get<ESM::Door>(), cell);
listCellScripts (*this, cell->get<ESM::Ingredient>(), cell);
listCellScripts (*this, cell->get<ESM::Light>(), cell);
listCellScripts (*this, cell->get<ESM::Lockpick>(), cell);
listCellScripts (*this, cell->get<ESM::Miscellaneous>(), cell);
listCellScripts (*this, cell->get<ESM::NPC>(), cell);
listCellScriptsCont (*this, cell->get<ESM::NPC>(), cell);
listCellScripts (*this, cell->get<ESM::Probe>(), cell);
listCellScripts (*this, cell->get<ESM::Repair>(), cell);
listCellScripts (*this, cell->get<ESM::Weapon>(), cell);
}
void MWWorld::LocalScripts::clear()

@ -15,13 +15,15 @@
#include <components/nifbullet/bulletnifloader.hpp>
#include <components/esm/loadgmst.hpp>
#include "../mwbase/world.hpp" // FIXME
#include "../mwbase/environment.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include <components/esm/loadgmst.hpp>
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
#include "ptr.hpp"
#include "class.hpp"
@ -574,7 +576,7 @@ namespace MWWorld
for(;iter != mMovementQueue.end();iter++)
{
float waterlevel = -std::numeric_limits<float>::max();
const ESM::Cell *cell = iter->first.getCell()->mCell;
const ESM::Cell *cell = iter->first.getCell()->getCell();
if(cell->hasWater())
waterlevel = cell->mWater;

@ -7,19 +7,20 @@
#include <components/esm/esmwriter.hpp>
#include <components/esm/player.hpp>
#include <components/esm/defs.hpp>
#include <components/esm/loadbsgn.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwmechanics/movement.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "class.hpp"
#include "ptr.hpp"
#include "inventorystore.hpp"
#include "cellstore.hpp"
namespace MWWorld
{
@ -191,7 +192,7 @@ namespace MWWorld
ESM::Player player;
mPlayer.save (player.mObject);
player.mCellId = mCellStore->mCell->getCellId();
player.mCellId = mCellStore->getCell()->getCellId();
player.mBirthsign = mSign;
@ -203,7 +204,7 @@ namespace MWWorld
{
player.mHasMark = true;
player.mMarkedPosition = mMarkedPosition;
player.mMarkedCell = mMarkedCell->mCell->getCellId();
player.mMarkedCell = mMarkedCell->getCell()->getCellId();
}
else
player.mHasMark = false;

@ -55,3 +55,8 @@ MWWorld::ContainerStore *MWWorld::Ptr::getContainerStore() const
{
return mContainerStore;
}
MWWorld::Ptr::operator const void *()
{
return mRef;
}

@ -1,12 +1,18 @@
#ifndef GAME_MWWORLD_PTR_H
#define GAME_MWWORLD_PTR_H
#include "cellstore.hpp"
#include <cassert>
#include <string>
#include <sstream>
#include "cellreflist.hpp"
#include "livecellref.hpp"
namespace MWWorld
{
class ContainerStore;
class CellStore;
/// \brief Pointer to a LiveCellRef
@ -74,6 +80,9 @@ namespace MWWorld
ContainerStore *getContainerStore() const;
///< May return a 0-pointer, if reference is not in a container.
operator const void *();
///< Return a 0-pointer, if Ptr is empty; return a non-0-pointer, if Ptr is not empty
};
inline bool operator== (const Ptr& left, const Ptr& right)

@ -17,11 +17,68 @@
#include "localscripts.hpp"
#include "esmstore.hpp"
#include "class.hpp"
#include "cellfunctors.hpp"
#include "cellstore.hpp"
namespace
{
struct InsertFunctor
{
MWWorld::CellStore& mCell;
bool mRescale;
Loading::Listener& mLoadingListener;
MWWorld::PhysicsSystem& mPhysics;
MWRender::RenderingManager& mRendering;
InsertFunctor (MWWorld::CellStore& cell, bool rescale, Loading::Listener& loadingListener,
MWWorld::PhysicsSystem& physics, MWRender::RenderingManager& rendering);
bool operator() (const MWWorld::Ptr& ptr);
};
InsertFunctor::InsertFunctor (MWWorld::CellStore& cell, bool rescale,
Loading::Listener& loadingListener, MWWorld::PhysicsSystem& physics,
MWRender::RenderingManager& rendering)
: mCell (cell), mRescale (rescale), mLoadingListener (loadingListener),
mPhysics (physics), mRendering (rendering)
{}
bool InsertFunctor::InsertFunctor::operator() (const MWWorld::Ptr& ptr)
{
if (mRescale)
{
if (ptr.getCellRef().mScale<0.5)
ptr.getCellRef().mScale = 0.5;
else if (ptr.getCellRef().mScale>2)
ptr.getCellRef().mScale = 2;
}
if (ptr.getRefData().getCount() && ptr.getRefData().isEnabled())
{
try
{
mRendering.addObject (ptr);
ptr.getClass().insertObject (ptr, mPhysics);
float ax = Ogre::Radian(ptr.getRefData().getLocalRotation().rot[0]).valueDegrees();
float ay = Ogre::Radian(ptr.getRefData().getLocalRotation().rot[1]).valueDegrees();
float az = Ogre::Radian(ptr.getRefData().getLocalRotation().rot[2]).valueDegrees();
MWBase::Environment::get().getWorld()->localRotateObject (ptr, ax, ay, az);
MWBase::Environment::get().getWorld()->scaleObject (ptr, ptr.getCellRef().mScale);
ptr.getClass().adjustPosition (ptr);
}
catch (const std::exception& e)
{
std::string error ("error during rendering: ");
std::cerr << error + e.what() << std::endl;
}
}
mLoadingListener.increaseProgress (1);
return true;
}
template<typename T>
void insertCellRefList(MWRender::RenderingManager& rendering,
@ -97,15 +154,15 @@ namespace MWWorld
}
}
if ((*iter)->mCell->isExterior())
if ((*iter)->getCell()->isExterior())
{
ESM::Land* land =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>().search(
(*iter)->mCell->getGridX(),
(*iter)->mCell->getGridY()
(*iter)->getCell()->getGridX(),
(*iter)->getCell()->getGridY()
);
if (land)
mPhysics->removeHeightField( (*iter)->mCell->getGridX(), (*iter)->mCell->getGridY() );
mPhysics->removeHeightField ((*iter)->getCell()->getGridX(), (*iter)->getCell()->getGridY());
}
mRendering.removeCell(*iter);
@ -128,18 +185,18 @@ namespace MWWorld
float worldsize = ESM::Land::REAL_SIZE;
// Load terrain physics first...
if (cell->mCell->isExterior())
if (cell->getCell()->isExterior())
{
ESM::Land* land =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>().search(
cell->mCell->getGridX(),
cell->mCell->getGridY()
cell->getCell()->getGridX(),
cell->getCell()->getGridY()
);
if (land) {
mPhysics->addHeightField (
land->mLandData->mHeights,
cell->mCell->getGridX(),
cell->mCell->getGridY(),
cell->getCell()->getGridX(),
cell->getCell()->getGridY(),
0,
worldsize / (verts-1),
verts)
@ -218,10 +275,10 @@ namespace MWWorld
int numUnload = 0;
while (active!=mActiveCells.end())
{
if ((*active)->mCell->isExterior())
if ((*active)->getCell()->isExterior())
{
if (std::abs (X-(*active)->mCell->getGridX())<=1 &&
std::abs (Y-(*active)->mCell->getGridY())<=1)
if (std::abs (X-(*active)->getCell()->getGridX())<=1 &&
std::abs (Y-(*active)->getCell()->getGridY())<=1)
{
// keep cells within the new 3x3 grid
++active;
@ -235,10 +292,10 @@ namespace MWWorld
active = mActiveCells.begin();
while (active!=mActiveCells.end())
{
if ((*active)->mCell->isExterior())
if ((*active)->getCell()->isExterior())
{
if (std::abs (X-(*active)->mCell->getGridX())<=1 &&
std::abs (Y-(*active)->mCell->getGridY())<=1)
if (std::abs (X-(*active)->getCell()->getGridX())<=1 &&
std::abs (Y-(*active)->getCell()->getGridY())<=1)
{
// keep cells within the new 3x3 grid
++active;
@ -257,17 +314,17 @@ namespace MWWorld
while (iter!=mActiveCells.end())
{
assert ((*iter)->mCell->isExterior());
assert ((*iter)->getCell()->isExterior());
if (x==(*iter)->mCell->getGridX() &&
y==(*iter)->mCell->getGridY())
if (x==(*iter)->getCell()->getGridX() &&
y==(*iter)->getCell()->getGridY())
break;
++iter;
}
if (iter==mActiveCells.end())
refsToLoad += countRefs(*MWBase::Environment::get().getWorld()->getExterior(x, y));
refsToLoad += MWBase::Environment::get().getWorld()->getExterior(x, y)->count();
}
loadingListener->setProgressRange(refsToLoad);
@ -280,10 +337,10 @@ namespace MWWorld
while (iter!=mActiveCells.end())
{
assert ((*iter)->mCell->isExterior());
assert ((*iter)->getCell()->isExterior());
if (x==(*iter)->mCell->getGridX() &&
y==(*iter)->mCell->getGridY())
if (x==(*iter)->getCell()->getGridX() &&
y==(*iter)->getCell()->getGridY())
break;
++iter;
@ -302,10 +359,10 @@ namespace MWWorld
while (iter!=mActiveCells.end())
{
assert ((*iter)->mCell->isExterior());
assert ((*iter)->getCell()->isExterior());
if (X==(*iter)->mCell->getGridX() &&
Y==(*iter)->mCell->getGridY())
if (X==(*iter)->getCell()->getGridX() &&
Y==(*iter)->getCell()->getGridY())
break;
++iter;
@ -403,11 +460,11 @@ namespace MWWorld
++current;
}
int refsToLoad = countRefs(*cell);
int refsToLoad = cell->count();
loadingListener->setProgressRange(refsToLoad);
// Load cell.
std::cout << "cellName: " << cell->mCell->mName << std::endl;
std::cout << "cellName: " << cell->getCell()->mName << std::endl;
//Loading Interior loading text
@ -451,55 +508,10 @@ namespace MWWorld
mCellChanged = false;
}
int Scene::countRefs (const CellStore& cell)
{
return cell.mActivators.mList.size()
+ cell.mPotions.mList.size()
+ cell.mAppas.mList.size()
+ cell.mArmors.mList.size()
+ cell.mBooks.mList.size()
+ cell.mClothes.mList.size()
+ cell.mContainers.mList.size()
+ cell.mDoors.mList.size()
+ cell.mIngreds.mList.size()
+ cell.mCreatureLists.mList.size()
+ cell.mItemLists.mList.size()
+ cell.mLights.mList.size()
+ cell.mLockpicks.mList.size()
+ cell.mMiscItems.mList.size()
+ cell.mProbes.mList.size()
+ cell.mRepairs.mList.size()
+ cell.mStatics.mList.size()
+ cell.mWeapons.mList.size()
+ cell.mCreatures.mList.size()
+ cell.mNpcs.mList.size();
}
void Scene::insertCell (CellStore &cell, bool rescale, Loading::Listener* loadingListener)
{
// Loop through all references in the cell
insertCellRefList(mRendering, cell.mActivators, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mPotions, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mAppas, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mArmors, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mBooks, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mClothes, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mContainers, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mDoors, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mIngreds, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mItemLists, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mLights, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mLockpicks, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mMiscItems, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mProbes, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mRepairs, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mStatics, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mWeapons, cell, *mPhysics, rescale, loadingListener);
// Load NPCs and creatures _after_ everything else (important for adjustPosition to work correctly)
insertCellRefList(mRendering, cell.mCreatures, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mNpcs, cell, *mPhysics, rescale, loadingListener);
// Since this adds additional creatures, load afterwards, or they would be loaded twice
insertCellRefList(mRendering, cell.mCreatureLists, cell, *mPhysics, rescale, loadingListener);
InsertFunctor functor (cell, rescale, *loadingListener, *mPhysics, mRendering);
cell.forEach (functor);
}
void Scene::addObjectToScene (const Ptr& ptr)

@ -21,6 +21,11 @@ namespace Files
class Collections;
}
namespace Loading
{
class Listener;
}
namespace Render
{
class OgreRenderer;
@ -58,8 +63,6 @@ namespace MWWorld
void insertCell (CellStore &cell, bool rescale, Loading::Listener* loadingListener);
int countRefs (const CellStore& cell);
public:
Scene (MWRender::RenderingManager& rendering, PhysicsSystem *physics);

@ -9,6 +9,7 @@
#include "player.hpp"
#include "esmstore.hpp"
#include "fallback.hpp"
#include "cellstore.hpp"
using namespace Ogre;
using namespace MWWorld;
@ -664,7 +665,7 @@ void WeatherManager::changeWeather(const std::string& region, const unsigned int
mRegionOverrides[Misc::StringUtils::lowerCase(region)] = weather;
std::string playerRegion = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell()->mCell->mRegion;
std::string playerRegion = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell()->getCell()->mRegion;
if (Misc::StringUtils::ciEqual(region, playerRegion))
setWeather(weather);
}
@ -695,7 +696,7 @@ void WeatherManager::switchToNextWeather(bool instantly)
MWBase::World* world = MWBase::Environment::get().getWorld();
if (world->isCellExterior() || world->isCellQuasiExterior())
{
std::string regionstr = Misc::StringUtils::lowerCase(world->getPlayerPtr().getCell()->mCell->mRegion);
std::string regionstr = Misc::StringUtils::lowerCase(world->getPlayerPtr().getCell()->getCell()->mRegion);
if (mWeatherUpdateTime <= 0 || regionstr != mCurrentRegion)
{

@ -48,27 +48,6 @@
using namespace Ogre;
namespace
{
template<typename T>
MWWorld::LiveCellRef<T> *searchViaHandle (const std::string& handle,
MWWorld::CellRefList<T>& refList)
{
typedef typename MWWorld::CellRefList<T>::List::iterator iterator;
for (iterator iter (refList.mList.begin()); iter!=refList.mList.end(); ++iter)
{
if (iter->mData.getCount() > 0 && iter->mData.getBaseNode()){
if (iter->mData.getHandle()==handle)
{
return &*iter;
}
}
}
return 0;
}
}
namespace MWWorld
{
struct GameContentLoader : public ContentLoader
@ -103,52 +82,6 @@ namespace MWWorld
LoadersContainer mLoaders;
};
Ptr World::getPtrViaHandle (const std::string& handle, CellStore& cell)
{
if (MWWorld::LiveCellRef<ESM::Activator> *ref =
searchViaHandle (handle, cell.mActivators))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Potion> *ref = searchViaHandle (handle, cell.mPotions))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Apparatus> *ref = searchViaHandle (handle, cell.mAppas))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Armor> *ref = searchViaHandle (handle, cell.mArmors))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Book> *ref = searchViaHandle (handle, cell.mBooks))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Clothing> *ref = searchViaHandle (handle, cell.mClothes))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Container> *ref =
searchViaHandle (handle, cell.mContainers))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Creature> *ref =
searchViaHandle (handle, cell.mCreatures))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Door> *ref = searchViaHandle (handle, cell.mDoors))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Ingredient> *ref =
searchViaHandle (handle, cell.mIngreds))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Light> *ref = searchViaHandle (handle, cell.mLights))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Lockpick> *ref = searchViaHandle (handle, cell.mLockpicks))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = searchViaHandle (handle, cell.mMiscItems))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::NPC> *ref = searchViaHandle (handle, cell.mNpcs))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Probe> *ref = searchViaHandle (handle, cell.mProbes))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Repair> *ref = searchViaHandle (handle, cell.mRepairs))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Static> *ref = searchViaHandle (handle, cell.mStatics))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Weapon> *ref = searchViaHandle (handle, cell.mWeapons))
return Ptr (ref, &cell);
return Ptr();
}
int World::getDaysPerMonth (int month) const
{
switch (month)
@ -506,10 +439,10 @@ namespace MWWorld
if (!cell)
cell = mWorldScene->getCurrentCell();
if (!cell->mCell->isExterior() || !cell->mCell->mName.empty())
return cell->mCell->mName;
if (!cell->getCell()->isExterior() || !cell->getCell()->mName.empty())
return cell->getCell()->mName;
if (const ESM::Region* region = getStore().get<ESM::Region>().search (cell->mCell->mRegion))
if (const ESM::Region* region = getStore().get<ESM::Region>().search (cell->getCell()->mRegion))
return region->mName;
return getStore().get<ESM::GameSetting>().find ("sDefaultCellname")->mValue.getString();
@ -579,7 +512,7 @@ namespace MWWorld
iter!=mWorldScene->getActiveCells().end(); ++iter)
{
CellStore* cellstore = *iter;
Ptr ptr = getPtrViaHandle (handle, *cellstore);
Ptr ptr = cellstore->searchViaHandle (handle);
if (!ptr.isEmpty())
return ptr;
@ -946,11 +879,11 @@ namespace MWWorld
if (isPlayer)
{
if (!newCell.isExterior())
changeToInteriorCell(Misc::StringUtils::lowerCase(newCell.mCell->mName), pos);
changeToInteriorCell(Misc::StringUtils::lowerCase(newCell.getCell()->mName), pos);
else
{
int cellX = newCell.mCell->getGridX();
int cellY = newCell.mCell->getGridY();
int cellX = newCell.getCell()->getGridX();
int cellY = newCell.getCell()->getGridY();
mWorldScene->changeCell(cellX, cellY, pos, false);
}
addContainerScripts (getPlayerPtr(), &newCell);
@ -1465,7 +1398,7 @@ namespace MWWorld
CellStore *currentCell = mWorldScene->getCurrentCell();
if (currentCell)
{
return currentCell->mCell->isExterior();
return currentCell->getCell()->isExterior();
}
return false;
}
@ -1475,7 +1408,7 @@ namespace MWWorld
CellStore *currentCell = mWorldScene->getCurrentCell();
if (currentCell)
{
if (!(currentCell->mCell->mData.mFlags & ESM::Cell::QuasiEx))
if (!(currentCell->getCell()->mData.mFlags & ESM::Cell::QuasiEx))
return false;
else
return true;
@ -1505,7 +1438,7 @@ namespace MWWorld
Ogre::Vector2 World::getNorthVector (CellStore* cell)
{
MWWorld::CellRefList<ESM::Static>& statics = cell->mStatics;
MWWorld::CellRefList<ESM::Static>& statics = cell->get<ESM::Static>();
MWWorld::LiveCellRef<ESM::Static>* ref = statics.find("northmarker");
if (!ref)
return Vector2(0, 1);
@ -1517,7 +1450,7 @@ namespace MWWorld
void World::getDoorMarkers (CellStore* cell, std::vector<World::DoorMarker>& out)
{
MWWorld::CellRefList<ESM::Door>& doors = cell->mDoors;
MWWorld::CellRefList<ESM::Door>& doors = cell->get<ESM::Door>();
CellRefList<ESM::Door>::List& refList = doors.mList;
for (CellRefList<ESM::Door>::List::iterator it = refList.begin(); it != refList.end(); ++it)
{
@ -1757,10 +1690,10 @@ namespace MWWorld
bool
World::isUnderwater(const MWWorld::CellStore* cell, const Ogre::Vector3 &pos) const
{
if (!(cell->mCell->mData.mFlags & ESM::Cell::HasWater)) {
if (!(cell->getCell()->mData.mFlags & ESM::Cell::HasWater)) {
return false;
}
return pos.z < cell->mWaterLevel;
return pos.z < cell->getWaterLevel();
}
bool World::isOnGround(const MWWorld::Ptr &ptr) const
@ -1816,7 +1749,7 @@ namespace MWWorld
const OEngine::Physic::PhysicActor *physactor = mPhysEngine->getCharacter(refdata.getHandle());
if((!physactor->getOnGround()&&physactor->getCollisionMode()) || isUnderwater(currentCell, playerPos))
return 2;
if((currentCell->mCell->mData.mFlags&ESM::Cell::NoSleep) ||
if((currentCell->getCell()->mData.mFlags&ESM::Cell::NoSleep) ||
Class::get(player).getNpcStats(player).isWerewolf())
return 1;
@ -1900,7 +1833,7 @@ namespace MWWorld
const Scene::CellStoreCollection& collection = mWorldScene->getActiveCells();
for (Scene::CellStoreCollection::const_iterator cellIt = collection.begin(); cellIt != collection.end(); ++cellIt)
{
MWWorld::CellRefList<ESM::Container>& containers = (*cellIt)->mContainers;
MWWorld::CellRefList<ESM::Container>& containers = (*cellIt)->get<ESM::Container>();
CellRefList<ESM::Container>::List& refList = containers.mList;
for (CellRefList<ESM::Container>::List::iterator container = refList.begin(); container != refList.end(); ++container)
{
@ -1972,7 +1905,7 @@ namespace MWWorld
if (0 == cellStore) {
return false;
}
const DoorList &doors = cellStore->mDoors.mList;
const DoorList &doors = cellStore->get<ESM::Door>().mList;
for (DoorList::const_iterator it = doors.begin(); it != doors.end(); ++it) {
if (!it->mRef.mTeleport) {
continue;
@ -1994,7 +1927,7 @@ namespace MWWorld
if (0 != source) {
// Find door leading to our current teleport door
// and use it destination to position inside cell.
const DoorList &doors = source->mDoors.mList;
const DoorList &doors = source->get<ESM::Door>().mList;
for (DoorList::const_iterator jt = doors.begin(); jt != doors.end(); ++jt) {
if (it->mRef.mTeleport &&
Misc::StringUtils::ciEqual(name, jt->mRef.mDestCell))
@ -2402,7 +2335,7 @@ namespace MWWorld
{
if (cell->isExterior())
return false;
MWWorld::CellRefList<ESM::Door>& doors = cell->mDoors;
MWWorld::CellRefList<ESM::Door>& doors = cell->get<ESM::Door>();
CellRefList<ESM::Door>::List& refList = doors.mList;
// Check if any door in the cell leads to an exterior directly

@ -23,4 +23,15 @@ void ESM::CellId::save (ESMWriter &esm) const
if (mPaged)
esm.writeHNT ("CIDX", mIndex, 8);
}
}
bool ESM::operator== (const CellId& left, const CellId& right)
{
return left.mWorldspace==right.mWorldspace && left.mPaged==right.mPaged &&
(!left.mPaged || (left.mIndex.mX==right.mIndex.mX && left.mIndex.mY==right.mIndex.mY));
}
bool ESM::operator!= (const CellId& left, const CellId& right)
{
return !(left==right);
}

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

Loading…
Cancel
Save