mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 12:09:43 +00:00
Bug #1224: Changed fix to potentially allow for language independent saves
This commit is contained in:
parent
ea357cfed0
commit
d7df9cae21
5 changed files with 45 additions and 9 deletions
|
@ -86,7 +86,21 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
std::stringstream title;
|
std::stringstream title;
|
||||||
title << it->getSignature().mPlayerName;
|
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());
|
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.mPlayerName = player.getClass().getName (player);
|
||||||
profile.mPlayerLevel = player.getClass().getNpcStats (player).getLevel();
|
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();
|
profile.mPlayerCell = world.getCellName();
|
||||||
|
|
||||||
|
|
|
@ -157,6 +157,14 @@ namespace MWWorld
|
||||||
return 0;
|
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. */
|
/** Returns a random record that starts with the named ID, or NULL if not found. */
|
||||||
const T *searchRandom(const std::string &id) const
|
const T *searchRandom(const std::string &id) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,7 +11,10 @@ void ESM::SavedGame::load (ESMReader &esm)
|
||||||
{
|
{
|
||||||
mPlayerName = esm.getHNString("PLNA");
|
mPlayerName = esm.getHNString("PLNA");
|
||||||
esm.getHNOT (mPlayerLevel, "PLLE");
|
esm.getHNOT (mPlayerLevel, "PLLE");
|
||||||
mPlayerClassName = esm.getHNString("PLCL");
|
|
||||||
|
mPlayerClassId = esm.getHNOString("PLCL");
|
||||||
|
mPlayerClassName = esm.getHNOString("PLCN");
|
||||||
|
|
||||||
mPlayerCell = esm.getHNString("PLCE");
|
mPlayerCell = esm.getHNString("PLCE");
|
||||||
esm.getHNT (mInGameTime, "TSTM", 16);
|
esm.getHNT (mInGameTime, "TSTM", 16);
|
||||||
esm.getHNT (mTimePlayed, "TIME");
|
esm.getHNT (mTimePlayed, "TIME");
|
||||||
|
@ -30,7 +33,12 @@ void ESM::SavedGame::save (ESMWriter &esm) const
|
||||||
{
|
{
|
||||||
esm.writeHNString ("PLNA", mPlayerName);
|
esm.writeHNString ("PLNA", mPlayerName);
|
||||||
esm.writeHNT ("PLLE", mPlayerLevel);
|
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.writeHNString ("PLCE", mPlayerCell);
|
||||||
esm.writeHNT ("TSTM", mInGameTime, 16);
|
esm.writeHNT ("TSTM", mInGameTime, 16);
|
||||||
esm.writeHNT ("TIME", mTimePlayed);
|
esm.writeHNT ("TIME", mTimePlayed);
|
||||||
|
|
|
@ -26,12 +26,13 @@ namespace ESM
|
||||||
std::vector<std::string> mContentFiles;
|
std::vector<std::string> mContentFiles;
|
||||||
std::string mPlayerName;
|
std::string mPlayerName;
|
||||||
int mPlayerLevel;
|
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.
|
// ID of class
|
||||||
// However, savegames from a different MW language are not compatible anyway.
|
std::string mPlayerClassId;
|
||||||
// And if only the ID was stored here, we would need to
|
// Name of the class. When using a custom class, the ID is not really meaningful prior
|
||||||
// peek into the savegame to look for a class record in case it is a custom class.
|
// to loading the savegame, so the name is stored separately.
|
||||||
std::string mPlayerClassName;
|
std::string mPlayerClassName;
|
||||||
|
|
||||||
std::string mPlayerCell;
|
std::string mPlayerCell;
|
||||||
TimeStamp mInGameTime;
|
TimeStamp mInGameTime;
|
||||||
double mTimePlayed;
|
double mTimePlayed;
|
||||||
|
|
Loading…
Reference in a new issue