|
|
|
@ -291,16 +291,47 @@ void MWState::StateManager::quickSave (std::string name)
|
|
|
|
|
saveGame(name, slot);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MWState::StateManager::loadGame (const Character *character, const Slot *slot)
|
|
|
|
|
void MWState::StateManager::loadGame(const std::string& filepath)
|
|
|
|
|
{
|
|
|
|
|
for (CharacterIterator it = mCharacterManager.begin(); it != mCharacterManager.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
const MWState::Character& character = *it;
|
|
|
|
|
for (MWState::Character::SlotIterator slotIt = character.begin(); slotIt != character.end(); ++slotIt)
|
|
|
|
|
{
|
|
|
|
|
const MWState::Slot& slot = *slotIt;
|
|
|
|
|
if (slot.mPath == boost::filesystem::path(filepath))
|
|
|
|
|
{
|
|
|
|
|
loadGame(&character, slot.mPath.string());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// have to peek into the save file to get the player name
|
|
|
|
|
ESM::ESMReader reader;
|
|
|
|
|
reader.open (filepath);
|
|
|
|
|
if (reader.getFormat()>ESM::Header::CurrentFormat)
|
|
|
|
|
return; // format is too new -> ignore
|
|
|
|
|
if (reader.getRecName()!=ESM::REC_SAVE)
|
|
|
|
|
return; // invalid save file -> ignore
|
|
|
|
|
reader.getRecHeader();
|
|
|
|
|
ESM::SavedGame profile;
|
|
|
|
|
profile.load (reader);
|
|
|
|
|
reader.close();
|
|
|
|
|
|
|
|
|
|
MWState::Character* character = mCharacterManager.getCurrentCharacter(true, profile.mPlayerName);
|
|
|
|
|
loadGame(character, filepath);
|
|
|
|
|
mTimePlayed = profile.mTimePlayed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MWState::StateManager::loadGame (const Character *character, const std::string& filepath)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
cleanup();
|
|
|
|
|
|
|
|
|
|
mTimePlayed = slot->mProfile.mTimePlayed;
|
|
|
|
|
|
|
|
|
|
ESM::ESMReader reader;
|
|
|
|
|
reader.open (slot->mPath.string());
|
|
|
|
|
reader.open (filepath);
|
|
|
|
|
|
|
|
|
|
std::map<int, int> contentFileMap = buildContentFileIndexMap (reader);
|
|
|
|
|
|
|
|
|
@ -319,9 +350,11 @@ void MWState::StateManager::loadGame (const Character *character, const Slot *sl
|
|
|
|
|
switch (n.val)
|
|
|
|
|
{
|
|
|
|
|
case ESM::REC_SAVE:
|
|
|
|
|
|
|
|
|
|
// don't need to read that here
|
|
|
|
|
reader.skipRecord();
|
|
|
|
|
{
|
|
|
|
|
ESM::SavedGame profile;
|
|
|
|
|
profile.load(reader);
|
|
|
|
|
mTimePlayed = profile.mTimePlayed;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ESM::REC_JOUR:
|
|
|
|
@ -391,7 +424,7 @@ void MWState::StateManager::loadGame (const Character *character, const Slot *sl
|
|
|
|
|
mState = State_Running;
|
|
|
|
|
|
|
|
|
|
Settings::Manager::setString ("character", "Saves",
|
|
|
|
|
slot->mPath.parent_path().filename().string());
|
|
|
|
|
character->getPath().filename().string());
|
|
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setNewGame(false);
|
|
|
|
|
MWBase::Environment::get().getWorld()->setupPlayer();
|
|
|
|
@ -431,7 +464,7 @@ void MWState::StateManager::quickLoad()
|
|
|
|
|
{
|
|
|
|
|
if (Character* mCurrentCharacter = getCurrentCharacter (false))
|
|
|
|
|
if (const MWState::Slot* slot = &*mCurrentCharacter->begin()) //Get newest save
|
|
|
|
|
loadGame (mCurrentCharacter, slot);
|
|
|
|
|
loadGame (mCurrentCharacter, slot->mPath.string());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MWState::StateManager::deleteGame(const MWState::Character *character, const MWState::Slot *slot)
|
|
|
|
@ -472,7 +505,7 @@ void MWState::StateManager::update (float duration)
|
|
|
|
|
//Load last saved game for current character
|
|
|
|
|
|
|
|
|
|
MWState::Slot lastSave = *curCharacter->begin();
|
|
|
|
|
loadGame(curCharacter, &lastSave);
|
|
|
|
|
loadGame(curCharacter, lastSave.mPath.string());
|
|
|
|
|
}
|
|
|
|
|
else if(iButton==1)
|
|
|
|
|
{
|
|
|
|
|