disable createRecord(), Land constness hack, various fixes with Store<T> interface

This commit is contained in:
greye 2012-11-06 13:14:03 +04:00
parent ff8da265ed
commit e74b2c060d
8 changed files with 24 additions and 21 deletions

View file

@ -186,7 +186,7 @@ void BirthDialog::updateSpells()
for (; it != end; ++it) for (; it != end; ++it)
{ {
const std::string &spellId = *it; const std::string &spellId = *it;
const ESM::Spell *spell = store.spells.search(spellId); const ESM::Spell *spell = store.get<ESM::Spell>().search(spellId);
if (!spell) if (!spell)
continue; // Skip spells which cannot be found continue; // Skip spells which cannot be found
ESM::Spell::SpellType type = static_cast<ESM::Spell::SpellType>(spell->mData.mType); ESM::Spell::SpellType type = static_cast<ESM::Spell::SpellType>(spell->mData.mType);

View file

@ -188,8 +188,8 @@ void PickClassDialog::updateClasses()
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
int index = 0; int index = 0;
MWWorld::Store<ESM::Cell>::iterator it = store.get<ESM::Cell>().begin(); MWWorld::Store<ESM::Class>::iterator it = store.get<ESM::Class>().begin();
for (; it != store.get<ESM::Cell>().end(); ++it) for (; it != store.get<ESM::Class>().end(); ++it)
{ {
bool playable = (it->mData.mIsPlayable != 0); bool playable = (it->mData.mIsPlayable != 0);
if (!playable) // Only display playable classes if (!playable) // Only display playable classes

View file

@ -97,7 +97,7 @@ namespace MWGui
for (MWWorld::ESMStore::iterator it = store.begin(); it != store.end(); ++it) for (MWWorld::ESMStore::iterator it = store.begin(); it != store.end(); ++it)
{ {
iter->second->listIdentifier (mNames); it->second->listIdentifier (mNames);
} }
// sort // sort

View file

@ -229,7 +229,7 @@ void RaceDialog::updateRaces()
int index = 0; int index = 0;
MWWorld::Store<ESM::Race>::iterator it = races.begin() MWWorld::Store<ESM::Race>::iterator it = races.begin();
for (; it != races.end(); ++it) for (; it != races.end(); ++it)
{ {
bool playable = it->mData.mFlags & ESM::Race::Playable; bool playable = it->mData.mFlags & ESM::Race::Playable;

View file

@ -456,7 +456,8 @@ void StatsWindow::updateSkillArea()
FactionList::const_iterator end = mFactions.end(); FactionList::const_iterator end = mFactions.end();
for (FactionList::const_iterator it = mFactions.begin(); it != end; ++it) for (FactionList::const_iterator it = mFactions.begin(); it != end; ++it)
{ {
const ESM::Faction *faction = store.factions.find(it->first); const ESM::Faction *faction =
store.get<ESM::Faction>().find(it->first);
MyGUI::Widget* w = addItem(faction->mName, coord1, coord2); MyGUI::Widget* w = addItem(faction->mName, coord1, coord2);
std::string text; std::string text;
@ -507,7 +508,8 @@ void StatsWindow::updateSkillArea()
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
addGroup(mWindowManager.getGameSettingString("sBirthSign", "Sign"), coord1, coord2); addGroup(mWindowManager.getGameSettingString("sBirthSign", "Sign"), coord1, coord2);
const ESM::BirthSign *sign = store.birthSigns.find(mBirthSignId); const ESM::BirthSign *sign =
store.get<ESM::BirthSign>().find(mBirthSignId);
MyGUI::Widget* w = addItem(sign->mName, coord1, coord2); MyGUI::Widget* w = addItem(sign->mName, coord1, coord2);
ToolTips::createBirthsignToolTip(w, mBirthSignId); ToolTips::createBirthsignToolTip(w, mBirthSignId);

View file

@ -33,7 +33,7 @@ namespace MWRender
// get the size of the world // get the size of the world
MWWorld::Store<ESM::Cell>::iterator it = esmStore.get<ESM::Cell>().extBegin(); MWWorld::Store<ESM::Cell>::iterator it = esmStore.get<ESM::Cell>().extBegin();
for (; it != esmStore.get<ESM::Cell>().end(); ++it) for (; it != esmStore.get<ESM::Cell>().extEnd(); ++it)
{ {
if (it->getGridX() < mMinX) if (it->getGridX() < mMinX)
mMinX = it->getGridX(); mMinX = it->getGridX();

View file

@ -63,11 +63,11 @@ namespace MWWorld
return iter; return iter;
} }
SharedIterator operator==(const SharedIterator &x) const { bool operator==(const SharedIterator &x) const {
return mIter == x.mIter; return mIter == x.mIter;
} }
SharedIterator operator!=(const SharedIterator &x) const { bool operator!=(const SharedIterator &x) const {
return !(*this == x); return !(*this == x);
} }
@ -314,20 +314,20 @@ namespace MWWorld
return iterator(mStatic.end()); return iterator(mStatic.end());
} }
ESM::Land *search(int x, int y) { ESM::Land *search(int x, int y) const {
ESM::Land land; ESM::Land land;
land.mX = x, land.mY = y; land.mX = x, land.mY = y;
std::vector<ESM::Land *>::iterator it = std::vector<ESM::Land *>::const_iterator it =
std::lower_bound(mStatic.begin(), mStatic.end(), &land, Compare()); std::lower_bound(mStatic.begin(), mStatic.end(), &land, Compare());
if (it != mStatic.end() && (*it)->mX == x && (*it)->mY == y) { if (it != mStatic.end() && (*it)->mX == x && (*it)->mY == y) {
return *it; return const_cast<ESM::Land *>(*it);
} }
return 0; return 0;
} }
ESM::Land *find(int x, int y) { ESM::Land *find(int x, int y) const{
ESM::Land *ptr = search(x, y); ESM::Land *ptr = search(x, y);
if (ptr == 0) { if (ptr == 0) {
std::ostringstream msg; std::ostringstream msg;

View file

@ -775,6 +775,7 @@ namespace MWWorld
std::pair<std::string, const ESM::Potion *> World::createRecord (const ESM::Potion& record) std::pair<std::string, const ESM::Potion *> World::createRecord (const ESM::Potion& record)
{ {
/*
/// \todo Rewrite the ESMStore so that a dynamic 2nd ESMStore can be attached to it. /// \todo Rewrite the ESMStore so that a dynamic 2nd ESMStore can be attached to it.
/// This function should then insert the record into the 2nd store (the code for this /// This function should then insert the record into the 2nd store (the code for this
/// should also be moved to the ESMStore class). It might be a good idea to review /// should also be moved to the ESMStore class). It might be a good idea to review
@ -792,10 +793,10 @@ namespace MWWorld
mStore.all.insert (std::make_pair (stream.str(), ESM::REC_ALCH)); mStore.all.insert (std::make_pair (stream.str(), ESM::REC_ALCH));
return std::make_pair (stream.str(), created); return std::make_pair (stream.str(), created);
} */}
std::pair<std::string, const ESM::Class *> World::createRecord (const ESM::Class& record) std::pair<std::string, const ESM::Class *> World::createRecord (const ESM::Class& record)
{ {/*
/// \todo See function above. /// \todo See function above.
std::ostringstream stream; std::ostringstream stream;
stream << "$dynamic" << mNextDynamicRecord++; stream << "$dynamic" << mNextDynamicRecord++;
@ -806,10 +807,10 @@ namespace MWWorld
mStore.all.insert (std::make_pair (stream.str(), ESM::REC_CLAS)); mStore.all.insert (std::make_pair (stream.str(), ESM::REC_CLAS));
return std::make_pair (stream.str(), created); return std::make_pair (stream.str(), created);
} */}
std::pair<std::string, const ESM::Spell *> World::createRecord (const ESM::Spell& record) std::pair<std::string, const ESM::Spell *> World::createRecord (const ESM::Spell& record)
{ {/*
/// \todo See function above. /// \todo See function above.
std::ostringstream stream; std::ostringstream stream;
stream << "$dynamic" << mNextDynamicRecord++; stream << "$dynamic" << mNextDynamicRecord++;
@ -820,10 +821,10 @@ namespace MWWorld
mStore.all.insert (std::make_pair (stream.str(), ESM::REC_SPEL)); mStore.all.insert (std::make_pair (stream.str(), ESM::REC_SPEL));
return std::make_pair (stream.str(), created); return std::make_pair (stream.str(), created);
} */}
const ESM::Cell *World::createRecord (const ESM::Cell& record) const ESM::Cell *World::createRecord (const ESM::Cell& record)
{ {/*
if (record.mData.mFlags & ESM::Cell::Interior) if (record.mData.mFlags & ESM::Cell::Interior)
{ {
if (mStore.cells.searchInt (record.mName)) if (mStore.cells.searchInt (record.mName))
@ -843,7 +844,7 @@ namespace MWWorld
std::make_pair (std::make_pair (record.mData.mX, record.mData.mY), cell)); std::make_pair (std::make_pair (record.mData.mX, record.mData.mY), cell));
return cell; return cell;
} }
} */}
void World::playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode, void World::playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode,
int number) int number)