1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 21:59:55 +00:00
openmw/components/esm3/savedgame.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
1.7 KiB
C++
Raw Normal View History

#include "savedgame.hpp"
#include "esmreader.hpp"
#include "esmwriter.hpp"
namespace ESM
{
void SavedGame::load(ESMReader& esm)
{
mPlayerName = esm.getHNString("PLNA");
esm.getHNOT(mPlayerLevel, "PLLE");
2022-09-22 18:26:05 +00:00
mPlayerClassId = esm.getHNORefId("PLCL");
mPlayerClassName = esm.getHNOString("PLCN");
2022-09-22 18:26:05 +00:00
2023-03-26 11:23:19 +00:00
if (esm.getFormatVersion() <= ESM::MaxSavedGameCellNameAsRefIdFormatVersion)
mPlayerCellName = esm.getHNRefId("PLCE").toString();
else
mPlayerCellName = esm.getHNString("PLCE");
esm.getHNTSized<16>(mInGameTime, "TSTM");
esm.getHNT(mTimePlayed, "TIME");
mDescription = esm.getHNString("DESC");
2022-09-22 18:26:05 +00:00
while (esm.isNextSub("DEPE"))
mContentFiles.push_back(esm.getHString());
2022-09-22 18:26:05 +00:00
2014-01-24 16:49:16 +00:00
esm.getSubNameIs("SCRN");
esm.getSubHeader();
mScreenshot.resize(esm.getSubSize());
Fix reference binding to null /usr/include/c++/10.2.0/bits/stl_vector.h:1046:34: runtime error: reference binding to null pointer of type 'value_type' #0 0x55e37f50008a in std::vector<char, std::allocator<char> >::operator[](unsigned long) /usr/include/c++/10.2.0/bits/stl_vector.h:1046 #1 0x55e37f50008a in ESM::SavedGame::load(ESM::ESMReader&) /home/elsid/dev/openmw/components/esm/savedgame.cpp:28 #2 0x55e37e726139 in MWState::Character::addSlot(boost::filesystem::path const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/elsid/dev/openmw/apps/openmw/mwstate/character.cpp:31 #3 0x55e37e742b39 in MWState::Character::Character(boost::filesystem::path const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/elsid/dev/openmw/apps/openmw/mwstate/character.cpp:88 #4 0x55e37e7006e1 in MWState::CharacterManager::CharacterManager(boost::filesystem::path const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/elsid/dev/openmw/apps/openmw/mwstate/charactermanager.cpp:25 #5 0x55e37e6d4140 in MWState::StateManager::StateManager(boost::filesystem::path const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/elsid/dev/openmw/apps/openmw/mwstate/statemanagerimp.cpp:90 #6 0x55e37e82595a in OMW::Engine::prepareEngine(Settings::Manager&) /home/elsid/dev/openmw/apps/openmw/engine.cpp:641 #7 0x55e37e8439fd in OMW::Engine::go() /home/elsid/dev/openmw/apps/openmw/engine.cpp:867 #8 0x55e37e782760 in runApplication(int, char**) /home/elsid/dev/openmw/apps/openmw/main.cpp:289 #9 0x55e37f6483c3 in wrapApplication(int (*)(int, char**), int, char**, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/elsid/dev/openmw/components/debug/debugging.cpp:200 #10 0x55e37ba8e3fe in main /home/elsid/dev/openmw/apps/openmw/main.cpp:301 #11 0x7f013e845151 in __libc_start_main (/usr/lib/libc.so.6+0x28151) #12 0x55e37baa0e3d in _start (/home/elsid/dev/openmw/build/gcc/ubsan/openmw+0x6c11e3d)
2021-01-09 20:38:56 +00:00
esm.getExact(mScreenshot.data(), mScreenshot.size());
}
2022-09-22 18:26:05 +00:00
void SavedGame::save(ESMWriter& esm) const
{
esm.writeHNString("PLNA", mPlayerName);
esm.writeHNT("PLLE", mPlayerLevel);
2022-09-22 18:26:05 +00:00
if (!mPlayerClassId.empty())
esm.writeHNRefId("PLCL", mPlayerClassId);
else
esm.writeHNString("PLCN", mPlayerClassName);
2022-09-22 18:26:05 +00:00
esm.writeHNString("PLCE", mPlayerCellName);
esm.writeHNT("TSTM", mInGameTime, 16);
esm.writeHNT("TIME", mTimePlayed);
esm.writeHNString("DESC", mDescription);
2022-09-22 18:26:05 +00:00
for (std::vector<std::string>::const_iterator iter(mContentFiles.begin()); iter != mContentFiles.end(); ++iter)
esm.writeHNString("DEPE", *iter);
2022-09-22 18:26:05 +00:00
2014-01-24 16:49:16 +00:00
esm.startSubRecord("SCRN");
esm.write(mScreenshot.data(), mScreenshot.size());
2014-01-24 16:49:16 +00:00
esm.endRecord("SCRN");
}
}