Bug #1224: Changed fix to potentially allow for language independent saves

actorid
scrawl 11 years ago
parent ea357cfed0
commit d7df9cae21

@ -86,7 +86,21 @@ namespace MWGui
{
std::stringstream title;
title << it->getSignature().mPlayerName;
title << " (Level " << it->getSignature().mPlayerLevel << " " << it->getSignature().mPlayerClassName << ")";
// For a custom class, we will not find it in the store (unless we loaded the savegame first).
// Fall back to name stored in savegame header in that case.
std::string className;
if (it->getSignature().mPlayerClassId.empty())
className = it->getSignature().mPlayerClassName;
else
{
// Find the localised name for this class from the store
const ESM::Class* class_ = MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(
it->getSignature().mPlayerClassId);
className = class_->mName;
}
title << " (Level " << it->getSignature().mPlayerLevel << " " << className << ")";
mCharacterSelection->addItem (title.str());

@ -155,7 +155,12 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
profile.mPlayerName = player.getClass().getName (player);
profile.mPlayerLevel = player.getClass().getNpcStats (player).getLevel();
profile.mPlayerClassName = world.getStore().get<ESM::Class>().find(player.get<ESM::NPC>()->mBase->mClass)->mName;
std::string classId = player.get<ESM::NPC>()->mBase->mClass;
if (world.getStore().get<ESM::Class>().isDynamic(classId))
profile.mPlayerClassName = world.getStore().get<ESM::Class>().find(classId)->mName;
else
profile.mPlayerClassId = classId;
profile.mPlayerCell = world.getCellName();

@ -157,6 +157,14 @@ namespace MWWorld
return 0;
}
/**
* Does the record with this ID come from the dynamic store?
*/
bool isDynamic(const std::string &id) const {
typename Dynamic::const_iterator dit = mDynamic.find(id);
return (dit != mDynamic.end());
}
/** Returns a random record that starts with the named ID, or NULL if not found. */
const T *searchRandom(const std::string &id) const
{

@ -11,7 +11,10 @@ void ESM::SavedGame::load (ESMReader &esm)
{
mPlayerName = esm.getHNString("PLNA");
esm.getHNOT (mPlayerLevel, "PLLE");
mPlayerClassName = esm.getHNString("PLCL");
mPlayerClassId = esm.getHNOString("PLCL");
mPlayerClassName = esm.getHNOString("PLCN");
mPlayerCell = esm.getHNString("PLCE");
esm.getHNT (mInGameTime, "TSTM", 16);
esm.getHNT (mTimePlayed, "TIME");
@ -30,7 +33,12 @@ void ESM::SavedGame::save (ESMWriter &esm) const
{
esm.writeHNString ("PLNA", mPlayerName);
esm.writeHNT ("PLLE", mPlayerLevel);
esm.writeHNString ("PLCL", mPlayerClassName);
if (!mPlayerClassId.empty())
esm.writeHNString ("PLCL", mPlayerClassId);
else
esm.writeHNString ("PLCN", mPlayerClassName);
esm.writeHNString ("PLCE", mPlayerCell);
esm.writeHNT ("TSTM", mInGameTime, 16);
esm.writeHNT ("TIME", mTimePlayed);

@ -26,12 +26,13 @@ namespace ESM
std::vector<std::string> mContentFiles;
std::string mPlayerName;
int mPlayerLevel;
// The (translated) name of the player class. So it will be displayed in the MW language
// the savegame was made in, not the currently running language of MW.
// However, savegames from a different MW language are not compatible anyway.
// And if only the ID was stored here, we would need to
// peek into the savegame to look for a class record in case it is a custom class.
// ID of class
std::string mPlayerClassId;
// Name of the class. When using a custom class, the ID is not really meaningful prior
// to loading the savegame, so the name is stored separately.
std::string mPlayerClassName;
std::string mPlayerCell;
TimeStamp mInGameTime;
double mTimePlayed;

Loading…
Cancel
Save