2013-11-19 09:51:30 +00:00
|
|
|
#include "savedgame.hpp"
|
|
|
|
|
|
|
|
#include "esmreader.hpp"
|
|
|
|
#include "esmwriter.hpp"
|
|
|
|
|
2022-04-11 22:18:39 +00:00
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
|
2022-12-09 23:54:33 +00:00
|
|
|
int SavedGame::sCurrentFormat = 22;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2022-04-11 22:18:39 +00:00
|
|
|
void SavedGame::load(ESMReader& esm)
|
2013-11-19 09:51:30 +00:00
|
|
|
{
|
2013-12-03 13:30:18 +00:00
|
|
|
mPlayerName = esm.getHNString("PLNA");
|
|
|
|
esm.getHNOT(mPlayerLevel, "PLLE");
|
2022-09-22 18:26:05 +00:00
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 11:17:09 +00:00
|
|
|
mPlayerClassId = ESM::RefId::stringRefId(esm.getHNOString("PLCL"));
|
2014-03-27 21:32:42 +00:00
|
|
|
mPlayerClassName = esm.getHNOString("PLCN");
|
2022-09-22 18:26:05 +00:00
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 11:17:09 +00:00
|
|
|
mPlayerCell = ESM::RefId::stringRefId(esm.getHNString("PLCE"));
|
2022-04-10 11:35:00 +00:00
|
|
|
esm.getHNTSized<16>(mInGameTime, "TSTM");
|
2013-11-19 09:51:30 +00:00
|
|
|
esm.getHNT(mTimePlayed, "TIME");
|
2013-11-24 14:19:56 +00:00
|
|
|
mDescription = esm.getHNString("DESC");
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2013-11-19 09:51:30 +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());
|
2013-11-19 09:51:30 +00:00
|
|
|
}
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2022-04-11 22:18:39 +00:00
|
|
|
void SavedGame::save(ESMWriter& esm) const
|
2013-11-19 09:51:30 +00:00
|
|
|
{
|
2013-12-03 13:30:18 +00:00
|
|
|
esm.writeHNString("PLNA", mPlayerName);
|
|
|
|
esm.writeHNT("PLLE", mPlayerLevel);
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2014-03-27 21:32:42 +00:00
|
|
|
if (!mPlayerClassId.empty())
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 11:17:09 +00:00
|
|
|
esm.writeHNString("PLCL", mPlayerClassId.getRefIdString());
|
2014-03-27 21:32:42 +00:00
|
|
|
else
|
|
|
|
esm.writeHNString("PLCN", mPlayerClassName);
|
2022-09-22 18:26:05 +00:00
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 11:17:09 +00:00
|
|
|
esm.writeHNString("PLCE", mPlayerCell.getRefIdString());
|
2013-11-19 09:51:30 +00:00
|
|
|
esm.writeHNT("TSTM", mInGameTime, 16);
|
|
|
|
esm.writeHNT("TIME", mTimePlayed);
|
2013-11-26 08:56:08 +00:00
|
|
|
esm.writeHNString("DESC", mDescription);
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2013-11-19 09:51:30 +00:00
|
|
|
for (std::vector<std::string>::const_iterator iter(mContentFiles.begin()); iter != mContentFiles.end(); ++iter)
|
2013-11-30 10:05:07 +00:00
|
|
|
esm.writeHNString("DEPE", *iter);
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2014-01-24 16:49:16 +00:00
|
|
|
esm.startSubRecord("SCRN");
|
2022-09-02 04:04:02 +00:00
|
|
|
esm.write(mScreenshot.data(), mScreenshot.size());
|
2014-01-24 16:49:16 +00:00
|
|
|
esm.endRecord("SCRN");
|
2013-11-19 09:51:30 +00:00
|
|
|
}
|
2022-04-11 22:18:39 +00:00
|
|
|
|
|
|
|
}
|