applying new interface vol.9, inconsistent

actorid
greye 12 years ago
parent 932a9dc6f9
commit ff8da265ed

@ -26,7 +26,7 @@ namespace MWScript
void GlobalScripts::addScript (const std::string& name) void GlobalScripts::addScript (const std::string& name)
{ {
if (mScripts.find (name)==mScripts.end()) if (mScripts.find (name)==mScripts.end())
if (const ESM::Script *script = mStore.scripts.find (name)) if (const ESM::Script *script = mStore.get<ESM::Script>().find (name))
{ {
Locals locals; Locals locals;

@ -31,7 +31,7 @@ namespace MWScript
bool Success = true; bool Success = true;
if (const ESM::Script *script = mStore.scripts.find (name)) if (const ESM::Script *script = mStore.get<ESM::Script>().find (name))
{ {
if (mVerbose) if (mVerbose)
std::cout << "compiling script: " << name << std::endl; std::cout << "compiling script: " << name << std::endl;
@ -125,15 +125,14 @@ namespace MWScript
std::pair<int, int> ScriptManager::compileAll() std::pair<int, int> ScriptManager::compileAll()
{ {
typedef MWWorld::ScriptListT<ESM::Script>::MapType Container;
const Container& scripts = mStore.scripts.list;
int count = 0; int count = 0;
int success = 0; int success = 0;
for (Container::const_iterator iter (scripts.begin()); iter!=scripts.end(); ++iter, ++count) const MWWorld::Store<ESM::Script>& scripts = mStore.get<ESM::Script>();
if (compile (iter->first)) MWWorld::Store<ESM::Script>::iterator it = scripts.begin();
for (; it != scripts.end(); ++iter, ++count)
if (compile (it->mId))
++success; ++success;
return std::make_pair (count, success); return std::make_pair (count, success);
@ -170,7 +169,7 @@ namespace MWScript
int ScriptManager::getLocalIndex (const std::string& scriptId, const std::string& variable, int ScriptManager::getLocalIndex (const std::string& scriptId, const std::string& variable,
char type) char type)
{ {
const ESM::Script *script = mStore.scripts.find (scriptId); const ESM::Script *script = mStore.get<ESM::Script>().find (scriptId);
int offset = 0; int offset = 0;
int size = 0; int size = 0;

@ -42,8 +42,11 @@ namespace MWWorld
&& !npcStats.hasBeenUsed (ref->mBase->mId)) && !npcStats.hasBeenUsed (ref->mBase->mId))
{ {
MWWorld::LiveCellRef<ESM::NPC> *playerRef = player.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC> *playerRef = player.get<ESM::NPC>();
const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find (
playerRef->mBase->mClass); const ESM::Class *class_ =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find (
playerRef->mBase->mClass
);
npcStats.increaseSkill (ref->mBase->mData.mSkillID, *class_, true); npcStats.increaseSkill (ref->mBase->mData.mSkillID, *class_, true);

@ -97,7 +97,7 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getExterior (int x, int y)
if (result==mExteriors.end()) if (result==mExteriors.end())
{ {
const ESM::Cell *cell = mStore.cells.searchExt (x, y); const ESM::Cell *cell = mStore.get<ESM::Cell>().search(x, y);
if (!cell) if (!cell)
{ {
@ -132,7 +132,7 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getInterior (const std::string& name)
if (result==mInteriors.end()) if (result==mInteriors.end())
{ {
const ESM::Cell *cell = mStore.cells.findInt (name); const ESM::Cell *cell = mStore.get<ESM::Cell>().find(name);
result = mInteriors.insert (std::make_pair (name, Ptr::CellStore (cell))).first; result = mInteriors.insert (std::make_pair (name, Ptr::CellStore (cell))).first;
} }
@ -264,10 +264,12 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name)
} }
// Now try the other cells // Now try the other cells
for (MWWorld::CellList::IntCells::const_iterator iter = mStore.cells.intCells.begin(); const MWWorld::Store<ESM::Cell> &cells = mStore.get<ESM::Cell>();
iter!=mStore.cells.intCells.end(); ++iter) MWWorld::Store<ESM::Cell>::iterator iter;
for (iter = cells.intBegin(); iter != cells.intEnd(); ++iter)
{ {
Ptr::CellStore *cellStore = getCellStore (iter->second); Ptr::CellStore *cellStore = getCellStore (*iter);
Ptr ptr = getPtrAndCache (name, *cellStore); Ptr ptr = getPtrAndCache (name, *cellStore);
@ -275,10 +277,9 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name)
return ptr; return ptr;
} }
for (MWWorld::CellList::ExtCells::const_iterator iter = mStore.cells.extCells.begin(); for (iter = cells.extBegin(); iter != cells.extEnd(); ++it)
iter!=mStore.cells.extCells.end(); ++iter)
{ {
Ptr::CellStore *cellStore = getCellStore (iter->second); Ptr::CellStore *cellStore = getCellStore (*iter);
Ptr ptr = getPtrAndCache (name, *cellStore); Ptr ptr = getPtrAndCache (name, *cellStore);

@ -74,9 +74,12 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& ptr)
{ {
int type = getType(ptr); int type = getType(ptr);
const MWWorld::ESMStore &esmStore =
MWBase::Environment::get().getWorld()->getStore();
// gold needs special handling: when it is inserted into a container, the base object automatically becomes Gold_001 // gold needs special handling: when it is inserted into a container, the base object automatically becomes Gold_001
// this ensures that gold piles of different sizes stack with each other (also, several scripts rely on Gold_001 for detecting player gold) // this ensures that gold piles of different sizes stack with each other (also, several scripts rely on Gold_001 for detecting player gold)
if (MWWorld::Class::get(ptr).getName(ptr) == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) if (MWWorld::Class::get(ptr).getName(ptr) == esmStore.get<ESM::GameSetting>().find("sGold")->getString())
{ {
MWWorld::LiveCellRef<ESM::Miscellaneous> *gold = MWWorld::LiveCellRef<ESM::Miscellaneous> *gold =
ptr.get<ESM::Miscellaneous>(); ptr.get<ESM::Miscellaneous>();
@ -87,7 +90,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& ptr)
|| compare_string_ci(gold->mRef.mRefID, "gold_025") || compare_string_ci(gold->mRef.mRefID, "gold_025")
|| compare_string_ci(gold->mRef.mRefID, "gold_100")) || compare_string_ci(gold->mRef.mRefID, "gold_100"))
{ {
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), "Gold_001"); MWWorld::ManualRef ref(esmStore, "Gold_001");
int count = (ptr.getRefData().getCount() == 1) ? gold->mBase->mData.mValue : ptr.getRefData().getCount(); int count = (ptr.getRefData().getCount() == 1) ? gold->mBase->mData.mValue : ptr.getRefData().getCount();
ref.getPtr().getRefData().setCount(count); ref.getPtr().getRefData().setCount(count);

@ -230,7 +230,7 @@ const MWMechanics::MagicEffects& MWWorld::InventoryStore::getMagicEffects()
if (!enchantmentId.empty()) if (!enchantmentId.empty())
{ {
const ESM::Enchantment& enchantment = const ESM::Enchantment& enchantment =
*MWBase::Environment::get().getWorld()->getStore().enchants.find (enchantmentId); *MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find (enchantmentId);
if (enchantment.mData.mType==ESM::Enchantment::ConstantEffect) if (enchantment.mData.mType==ESM::Enchantment::ConstantEffect)
mMagicEffects.add (enchantment.mEffects); mMagicEffects.add (enchantment.mEffects);

@ -61,7 +61,7 @@ std::pair<std::string, MWWorld::Ptr> MWWorld::LocalScripts::getNext()
void MWWorld::LocalScripts::add (const std::string& scriptName, const Ptr& ptr) void MWWorld::LocalScripts::add (const std::string& scriptName, const Ptr& ptr)
{ {
if (const ESM::Script *script = mStore.scripts.find (scriptName)) if (const ESM::Script *script = mStore.get<ESM::Script>().find (scriptName))
{ {
ptr.getRefData().setLocals (*script); ptr.getRefData().setLocals (*script);

@ -27,7 +27,7 @@ namespace MWWorld
playerPos[0] = playerPos[1] = playerPos[2] = 0; playerPos[0] = playerPos[1] = playerPos[2] = 0;
/// \todo Do not make a copy of classes defined in esm/p records. /// \todo Do not make a copy of classes defined in esm/p records.
mClass = new ESM::Class (*world.getStore().classes.find (player->mClass)); mClass = new ESM::Class (*world.getStore().get<ESM::Class>().find (player->mClass));
} }
Player::~Player() Player::~Player()

@ -83,7 +83,7 @@ namespace MWWorld
if ((*iter)->mCell->isExterior()) if ((*iter)->mCell->isExterior())
{ {
ESM::Land* land = ESM::Land* land =
MWBase::Environment::get().getWorld()->getStore().lands.search( MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>().search(
(*iter)->mCell->getGridX(), (*iter)->mCell->getGridX(),
(*iter)->mCell->getGridY() (*iter)->mCell->getGridY()
); );
@ -118,7 +118,7 @@ namespace MWWorld
if (cell->mCell->isExterior()) if (cell->mCell->isExterior())
{ {
ESM::Land* land = ESM::Land* land =
MWBase::Environment::get().getWorld()->getStore().lands.search( MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>().search(
cell->mCell->getGridX(), cell->mCell->getGridX(),
cell->mCell->getGridY() cell->mCell->getGridY()
); );

@ -490,7 +490,7 @@ namespace MWWorld
} }
/// \todo implement appropriate index /// \todo implement appropriate index
const ESM::Cell *searchExteriorByName(const std::string &id) const { const ESM::Cell *searchExtByName(const std::string &id) const {
std::vector<ESM::Cell *>::const_iterator it = mSharedExt.begin(); std::vector<ESM::Cell *>::const_iterator it = mSharedExt.begin();
for (; it != mSharedExt.end(); ++it) { for (; it != mSharedExt.end(); ++it) {
if (StringUtils::ciEqual((*it)->mName, id)) { if (StringUtils::ciEqual((*it)->mName, id)) {
@ -501,7 +501,7 @@ namespace MWWorld
} }
/// \todo implement appropriate index /// \todo implement appropriate index
const ESM::Cell *searchExteriorByRegion(const std::string &id) const { const ESM::Cell *searchExtByRegion(const std::string &id) const {
std::vector<ESM::Cell *>::const_iterator it = mSharedExt.begin(); std::vector<ESM::Cell *>::const_iterator it = mSharedExt.begin();
for (; it != mSharedExt.end(); ++it) { for (; it != mSharedExt.end(); ++it) {
if (StringUtils::ciEqual((*it)->mRegion, id)) { if (StringUtils::ciEqual((*it)->mRegion, id)) {

@ -511,7 +511,8 @@ void WeatherManager::update(float duration)
else else
{ {
// get weather probabilities for the current region // get weather probabilities for the current region
const ESM::Region *region = MWBase::Environment::get().getWorld()->getStore().regions.search (regionstr); const ESM::Region *region =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Region>().search (regionstr);
if (region != 0) if (region != 0)
{ {

@ -186,7 +186,7 @@ namespace MWWorld
mEsm.open (masterPath.string()); mEsm.open (masterPath.string());
mStore.load (mEsm); mStore.load (mEsm);
mPlayer = new MWWorld::Player (mStore.npcs.find ("player"), *this); mPlayer = new MWWorld::Player (mStore.get<ESM::NPC>().find ("player"), *this);
mRendering->attachCameraTo(mPlayer->getPlayer()); mRendering->attachCameraTo(mPlayer->getPlayer());
std::string playerCollisionFile = "meshes\\base_anim.nif"; //This is used to make a collision shape for our player std::string playerCollisionFile = "meshes\\base_anim.nif"; //This is used to make a collision shape for our player
@ -224,21 +224,19 @@ namespace MWWorld
const ESM::Cell *World::getExterior (const std::string& cellName) const const ESM::Cell *World::getExterior (const std::string& cellName) const
{ {
// first try named cells // first try named cells
if (const ESM::Cell *cell = mStore.cells.searchExtByName (cellName)) const ESM::Cell *cell = mStore.get<ESM::Cell>().searchExtByName (cellName);
if (cell != 0) {
return cell; return cell;
}
// didn't work -> now check for regions // didn't work -> now check for regions
std::string cellName2 = MWWorld::RecListT<ESM::Region>::toLower (cellName); const MWWorld::Store<ESM::Region> &regions = mStore.get<ESM::Region>();
MWWorld::Store<ESM::Region>::iterator it = regions.begin();
for (MWWorld::RecListT<ESM::Region>::MapType::const_iterator iter (mStore.regions.list.begin()); for (; it != regions.end(); ++it)
iter!=mStore.regions.list.end(); ++iter)
{ {
if (MWWorld::RecListT<ESM::Region>::toLower (iter->second.mName)==cellName2) if (MWWorld::StringUtils::ciEqual(cellName, it->mName))
{ {
if (const ESM::Cell *cell = mStore.cells.searchExtByRegion (iter->first)) return mStore.get<ESM::Cell>().searchExtByRegion(it->mId);
return cell;
break;
} }
} }
@ -536,7 +534,7 @@ namespace MWWorld
std::pair<std::string, float> result = mPhysics->getFacedHandle (*this); std::pair<std::string, float> result = mPhysics->getFacedHandle (*this);
if (result.first.empty() || if (result.first.empty() ||
result.second>getStore().gameSettings.find ("iMaxActivateDist")->getInt()) result.second>getStore().get<ESM::GameSetting>().find ("iMaxActivateDist")->getInt())
return ""; return "";
return result.first; return result.first;
@ -1103,13 +1101,12 @@ namespace MWWorld
// door leads to exterior, use cell name (if any), otherwise translated region name // door leads to exterior, use cell name (if any), otherwise translated region name
int x,y; int x,y;
positionToIndex (ref.mRef.mDoorDest.pos[0], ref.mRef.mDoorDest.pos[1], x, y); positionToIndex (ref.mRef.mDoorDest.pos[0], ref.mRef.mDoorDest.pos[1], x, y);
const ESM::Cell* cell = mStore.cells.findExt(x,y); const ESM::Cell* cell = mStore.get<ESM::Cell>().find(x,y);
if (cell->mName != "") if (cell->mName != "")
dest = cell->mName; dest = cell->mName;
else else
{ {
const ESM::Region* region = mStore.regions.search(cell->mRegion); dest = mStore.get<ESM::Region>().find(cell->mRegion)->mName;
dest = region->mName;
} }
} }

Loading…
Cancel
Save