void Journal::write (ESM::ESMWriter& writer, Loading::Listener& progress) const { for (TQuestIter iter (mQuests.begin()); iter!=mQuests.end(); ++iter) { const Quest& quest = iter->second; ESM::QuestState state; quest.write (state); writer.startRecord (ESM::REC_QUES); state.save (writer); writer.endRecord (ESM::REC_QUES); progress.increaseProgress(); for (Topic::TEntryIter iter (quest.begin()); iter!=quest.end(); ++iter) { ESM::JournalEntry entry; entry.mType = ESM::JournalEntry::Type_Quest; entry.mTopic = quest.getTopic(); iter->write (entry); writer.startRecord (ESM::REC_JOUR); entry.save (writer); writer.endRecord (ESM::REC_JOUR); progress.increaseProgress(); } } for (TEntryIter iter (mJournal.begin()); iter!=mJournal.end(); ++iter) { ESM::JournalEntry entry; entry.mType = ESM::JournalEntry::Type_Journal; iter->write (entry); writer.startRecord (ESM::REC_JOUR); entry.save (writer); writer.endRecord (ESM::REC_JOUR); progress.increaseProgress(); } for (TTopicIter iter (mTopics.begin()); iter!=mTopics.end(); ++iter) { const Topic& topic = iter->second; for (Topic::TEntryIter iter (topic.begin()); iter!=topic.end(); ++iter) { ESM::JournalEntry entry; entry.mType = ESM::JournalEntry::Type_Topic; entry.mTopic = topic.getTopic(); iter->write (entry); writer.startRecord (ESM::REC_JOUR); entry.save (writer); writer.endRecord (ESM::REC_JOUR); progress.increaseProgress(); } } }
void Player::write (ESM::ESMWriter& writer, Loading::Listener& progress) const { ESM::Player player; mPlayer.save (player.mObject); player.mCellId = mCellStore->getCell()->getCellId(); player.mCurrentCrimeId = mCurrentCrimeId; player.mPaidCrimeId = mPaidCrimeId; player.mBirthsign = mSign; player.mLastKnownExteriorPosition[0] = mLastKnownExteriorPosition.x; player.mLastKnownExteriorPosition[1] = mLastKnownExteriorPosition.y; player.mLastKnownExteriorPosition[2] = mLastKnownExteriorPosition.z; if (mMarkedCell) { player.mHasMark = true; player.mMarkedPosition = mMarkedPosition; player.mMarkedCell = mMarkedCell->getCell()->getCellId(); } else player.mHasMark = false; player.mAutoMove = mAutoMove ? 1 : 0; writer.startRecord (ESM::REC_PLAY); player.save (writer); writer.endRecord (ESM::REC_PLAY); progress.increaseProgress(); }
void ProjectileManager::write(ESM::ESMWriter &writer, Loading::Listener &progress) const { for (std::vector<ProjectileState>::const_iterator it = mProjectiles.begin(); it != mProjectiles.end(); ++it) { writer.startRecord(ESM::REC_PROJ); ESM::ProjectileState state; state.mId = it->mId; state.mPosition = it->mNode->getPosition(); state.mOrientation = it->mNode->getOrientation(); state.mActorId = it->mActorId; state.mBowId = it->mBowId; state.mVelocity = it->mVelocity; state.save(writer); writer.endRecord(ESM::REC_PROJ); progress.increaseProgress(); } for (std::vector<MagicBoltState>::const_iterator it = mMagicBolts.begin(); it != mMagicBolts.end(); ++it) { writer.startRecord(ESM::REC_MPRJ); ESM::MagicBoltState state; state.mId = it->mId; state.mPosition = it->mNode->getPosition(); state.mOrientation = it->mNode->getOrientation(); state.mActorId = it->mActorId; state.mSpellId = it->mSpellId; state.mEffects = it->mEffects; state.mSound = it->mSoundId; state.mSourceName = it->mSourceName; state.mSpeed = it->mSpeed; state.mStack = it->mStack; state.save(writer); writer.endRecord(ESM::REC_MPRJ); progress.increaseProgress(); } }
void MWWorld::Cells::write (ESM::ESMWriter& writer, Loading::Listener& progress) const { for (std::map<std::pair<int, int>, CellStore>::iterator iter (mExteriors.begin()); iter!=mExteriors.end(); ++iter) if (iter->second.hasState()) { writeCell (writer, iter->second); progress.increaseProgress(); } for (std::map<std::string, CellStore>::iterator iter (mInteriors.begin()); iter!=mInteriors.end(); ++iter) if (iter->second.hasState()) { writeCell (writer, iter->second); progress.increaseProgress(); } }
void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position) { CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName); bool loadcell = (mCurrentCell == NULL); if(!loadcell) loadcell = *mCurrentCell != *cell; MWBase::Environment::get().getWindowManager()->fadeScreenOut(0.5); Loading::Listener* loadingListener = MWBase::Environment::get().getWindowManager()->getLoadingScreen(); std::string loadingInteriorText = "#{sLoadingMessage2}"; loadingListener->setLabel(loadingInteriorText); Loading::ScopedLoad load(loadingListener); mRendering.enableTerrain(false); if(!loadcell) { MWBase::World *world = MWBase::Environment::get().getWorld(); world->moveObject(world->getPlayerPtr(), position.pos[0], position.pos[1], position.pos[2]); float x = Ogre::Radian(position.rot[0]).valueDegrees(); float y = Ogre::Radian(position.rot[1]).valueDegrees(); float z = Ogre::Radian(position.rot[2]).valueDegrees(); world->rotateObject(world->getPlayerPtr(), x, y, z); world->getPlayerPtr().getClass().adjustPosition(world->getPlayerPtr(), true); MWBase::Environment::get().getWindowManager()->fadeScreenIn(0.5); return; } std::cout << "Changing to interior\n"; // remove active CellStoreCollection::iterator active = mActiveCells.begin(); // count number of cells to unload int numUnload = 0; while (active!=mActiveCells.end()) { ++active; ++numUnload; } // unload int current = 0; active = mActiveCells.begin(); while (active!=mActiveCells.end()) { unloadCell (active++); ++current; } int refsToLoad = cell->count(); loadingListener->setProgressRange(refsToLoad); // Load cell. std::cout << "cellName: " << cell->getCell()->mName << std::endl; //Loading Interior loading text loadCell (cell, loadingListener); mCurrentCell = cell; // adjust fog mRendering.configureFog(*mCurrentCell); // adjust player playerCellChange (mCurrentCell, position); // Sky system MWBase::Environment::get().getWorld()->adjustSky(); mCellChanged = true; MWBase::Environment::get().getWindowManager()->fadeScreenIn(0.5); }
void Scene::changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos) { Loading::Listener* loadingListener = MWBase::Environment::get().getWindowManager()->getLoadingScreen(); Loading::ScopedLoad load(loadingListener); mRendering.enableTerrain(true); std::string loadingExteriorText = "#{sLoadingMessage3}"; loadingListener->setLabel(loadingExteriorText); CellStoreCollection::iterator active = mActiveCells.begin(); // get the number of cells to unload int numUnload = 0; while (active!=mActiveCells.end()) { if ((*active)->getCell()->isExterior()) { if (std::abs (X-(*active)->getCell()->getGridX())<=1 && std::abs (Y-(*active)->getCell()->getGridY())<=1) { // keep cells within the new 3x3 grid ++active; continue; } } ++active; ++numUnload; } active = mActiveCells.begin(); while (active!=mActiveCells.end()) { if ((*active)->getCell()->isExterior()) { if (std::abs (X-(*active)->getCell()->getGridX())<=1 && std::abs (Y-(*active)->getCell()->getGridY())<=1) { // keep cells within the new 3x3 grid ++active; continue; } } unloadCell (active++); } int refsToLoad = 0; // get the number of refs to load for (int x=X-1; x<=X+1; ++x) for (int y=Y-1; y<=Y+1; ++y) { CellStoreCollection::iterator iter = mActiveCells.begin(); while (iter!=mActiveCells.end()) { assert ((*iter)->getCell()->isExterior()); if (x==(*iter)->getCell()->getGridX() && y==(*iter)->getCell()->getGridY()) break; ++iter; } if (iter==mActiveCells.end()) refsToLoad += MWBase::Environment::get().getWorld()->getExterior(x, y)->count(); } loadingListener->setProgressRange(refsToLoad); // Load cells for (int x=X-1; x<=X+1; ++x) for (int y=Y-1; y<=Y+1; ++y) { CellStoreCollection::iterator iter = mActiveCells.begin(); while (iter!=mActiveCells.end()) { assert ((*iter)->getCell()->isExterior()); if (x==(*iter)->getCell()->getGridX() && y==(*iter)->getCell()->getGridY()) break; ++iter; } if (iter==mActiveCells.end()) { CellStore *cell = MWBase::Environment::get().getWorld()->getExterior(x, y); loadCell (cell, loadingListener); } } // find current cell CellStoreCollection::iterator iter = mActiveCells.begin(); while (iter!=mActiveCells.end()) { assert ((*iter)->getCell()->isExterior()); if (X==(*iter)->getCell()->getGridX() && Y==(*iter)->getCell()->getGridY()) break; ++iter; } assert (iter!=mActiveCells.end()); mCurrentCell = *iter; // adjust player playerCellChange (mCurrentCell, position, adjustPlayerPos); // Sky system MWBase::Environment::get().getWorld()->adjustSky(); mCellChanged = true; }
void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position) { CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName); bool loadcell = (mCurrentCell == NULL); if(!loadcell) loadcell = *mCurrentCell != *cell; MWBase::Environment::get().getWindowManager()->fadeScreenOut(0.5); Loading::Listener* loadingListener = MWBase::Environment::get().getWindowManager()->getLoadingScreen(); std::string loadingInteriorText = "#{sLoadingMessage2}"; loadingListener->setLabel(loadingInteriorText); Loading::ScopedLoad load(loadingListener); mRendering.enableTerrain(false); if(!loadcell) { MWBase::World *world = MWBase::Environment::get().getWorld(); world->moveObject(world->getPlayerPtr(), position.pos[0], position.pos[1], position.pos[2]); float x = Ogre::Radian(position.rot[0]).valueDegrees(); float y = Ogre::Radian(position.rot[1]).valueDegrees(); float z = Ogre::Radian(position.rot[2]).valueDegrees(); world->rotateObject(world->getPlayerPtr(), x, y, z); world->getPlayerPtr().getClass().adjustPosition(world->getPlayerPtr(), true); MWBase::Environment::get().getWindowManager()->fadeScreenIn(0.5); return; } std::cout << "Changing to interior\n"; // unload int current = 0; CellStoreCollection::iterator active = mActiveCells.begin(); while (active!=mActiveCells.end()) { unloadCell (active++); ++current; } int refsToLoad = cell->count(); loadingListener->setProgressRange(refsToLoad); // Load cell. std::cout << "cellName: " << cell->getCell()->mName << std::endl; loadCell (cell, loadingListener); changePlayerCell(cell, position, true); // adjust fog mRendering.configureFog(*mCurrentCell); // Sky system MWBase::Environment::get().getWorld()->adjustSky(); mCellChanged = true; MWBase::Environment::get().getWindowManager()->fadeScreenIn(0.5); MWBase::Environment::get().getWindowManager()->changeCell(mCurrentCell); // Delay the map update until scripts have been given a chance to run. // If we don't do this, objects that should be disabled will still appear on the map. mNeedMapUpdate = true; }
void Scene::changeCellGrid (int X, int Y) { Loading::Listener* loadingListener = MWBase::Environment::get().getWindowManager()->getLoadingScreen(); Loading::ScopedLoad load(loadingListener); mRendering.enableTerrain(true); std::string loadingExteriorText = "#{sLoadingMessage3}"; loadingListener->setLabel(loadingExteriorText); const int halfGridSize = Settings::Manager::getInt("exterior grid size", "Cells")/2; CellStoreCollection::iterator active = mActiveCells.begin(); while (active!=mActiveCells.end()) { if ((*active)->getCell()->isExterior()) { if (std::abs (X-(*active)->getCell()->getGridX())<=halfGridSize && std::abs (Y-(*active)->getCell()->getGridY())<=halfGridSize) { // keep cells within the new grid ++active; continue; } } unloadCell (active++); } int refsToLoad = 0; // get the number of refs to load for (int x=X-halfGridSize; x<=X+halfGridSize; ++x) { for (int y=Y-halfGridSize; y<=Y+halfGridSize; ++y) { CellStoreCollection::iterator iter = mActiveCells.begin(); while (iter!=mActiveCells.end()) { assert ((*iter)->getCell()->isExterior()); if (x==(*iter)->getCell()->getGridX() && y==(*iter)->getCell()->getGridY()) break; ++iter; } if (iter==mActiveCells.end()) refsToLoad += MWBase::Environment::get().getWorld()->getExterior(x, y)->count(); } } loadingListener->setProgressRange(refsToLoad); // Load cells for (int x=X-halfGridSize; x<=X+halfGridSize; ++x) { for (int y=Y-halfGridSize; y<=Y+halfGridSize; ++y) { CellStoreCollection::iterator iter = mActiveCells.begin(); while (iter!=mActiveCells.end()) { assert ((*iter)->getCell()->isExterior()); if (x==(*iter)->getCell()->getGridX() && y==(*iter)->getCell()->getGridY()) break; ++iter; } if (iter==mActiveCells.end()) { CellStore *cell = MWBase::Environment::get().getWorld()->getExterior(x, y); loadCell (cell, loadingListener); } } } CellStore* current = MWBase::Environment::get().getWorld()->getExterior(X,Y); MWBase::Environment::get().getWindowManager()->changeCell(current); mCellChanged = true; // Delay the map update until scripts have been given a chance to run. // If we don't do this, objects that should be disabled will still appear on the map. mNeedMapUpdate = true; }