本文整理汇总了C++中serializer::Reader::SetStreamVersion方法的典型用法代码示例。如果您正苦于以下问题:C++ Reader::SetStreamVersion方法的具体用法?C++ Reader::SetStreamVersion怎么用?C++ Reader::SetStreamVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类serializer::Reader
的用法示例。
在下文中一共展示了Reader::SetStreamVersion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SavedGameWrongVersionException
Game::Game(Serializer::Reader &rd) :
m_timeAccel(TIMEACCEL_PAUSED),
m_requestedTimeAccel(TIMEACCEL_PAUSED),
m_forceTimeAccel(false)
{
// signature check
for (Uint32 i = 0; i < strlen(s_saveStart)+1; i++)
if (rd.Byte() != s_saveStart[i]) throw SavedGameCorruptException();
// version check
rd.SetStreamVersion(rd.Int32());
Output("savefile version: %d\n", rd.StreamVersion());
if (rd.StreamVersion() != s_saveVersion) {
Output("can't load savefile, expected version: %d\n", s_saveVersion);
throw SavedGameWrongVersionException();
}
// XXX This must be done after loading sectors once we can change them in game
Pi::FlushCaches();
Serializer::Reader section;
// game state
section = rd.RdSection("Game");
m_time = section.Double();
m_state = State(section.Int32());
m_wantHyperspace = section.Bool();
m_hyperspaceProgress = section.Double();
m_hyperspaceDuration = section.Double();
m_hyperspaceEndTime = section.Double();
// space, all the bodies and things
section = rd.RdSection("Space");
m_space.reset(new Space(this, section, m_time));
m_player.reset(static_cast<Player*>(m_space->GetBodyByIndex(section.Int32())));
// space transition state
section = rd.RdSection("HyperspaceClouds");
// hyperspace clouds being brought over from the previous system
Uint32 nclouds = section.Int32();
for (Uint32 i = 0; i < nclouds; i++)
m_hyperspaceClouds.push_back(static_cast<HyperspaceCloud*>(Body::Unserialize(section, 0)));
// system political stuff
section = rd.RdSection("Polit");
Polit::Unserialize(section);
// views
LoadViews(rd);
// lua
section = rd.RdSection("LuaModules");
Pi::luaSerializer->Unserialize(section);
// signature check
for (Uint32 i = 0; i < strlen(s_saveEnd)+1; i++)
if (rd.Byte() != s_saveEnd[i]) throw SavedGameCorruptException();
}
示例2: SavedGameWrongVersionException
Game::Game(Serializer::Reader &rd) :
m_timeAccel(TIMEACCEL_PAUSED),
m_requestedTimeAccel(TIMEACCEL_PAUSED),
m_forceTimeAccel(false)
{
// signature check
for (Uint32 i = 0; i < strlen(s_saveStart)+1; i++)
if (rd.Byte() != s_saveStart[i]) throw SavedGameCorruptException();
// version check
rd.SetStreamVersion(rd.Int32());
Output("savefile version: %d\n", rd.StreamVersion());
if (rd.StreamVersion() != s_saveVersion) {
Output("can't load savefile, expected version: %d\n", s_saveVersion);
throw SavedGameWrongVersionException();
}
// XXX This must be done after loading sectors once we can change them in game
Pi::FlushCaches();
Serializer::Reader section;
// Preparing the Lua stuff
LuaRef::InitLoad();
Pi::luaSerializer->InitTableRefs();
// galaxy generator
section = rd.RdSection("GalaxyGen");
std::string genName = section.String();
GalaxyGenerator::Version genVersion = section.Int32();
if (genName != Pi::GetGalaxy()->GetGeneratorName() || genVersion != Pi::GetGalaxy()->GetGeneratorVersion()) {
if (!Pi::CreateGalaxy(genName, genVersion)) {
Output("can't load savefile, unsupported galaxy generator %s, version %d\n", genName.c_str(), genVersion);
throw SavedGameWrongVersionException();
}
}
// game state
section = rd.RdSection("Game");
m_time = section.Double();
m_state = State(section.Int32());
m_wantHyperspace = section.Bool();
m_hyperspaceProgress = section.Double();
m_hyperspaceDuration = section.Double();
m_hyperspaceEndTime = section.Double();
// space, all the bodies and things
section = rd.RdSection("Space");
m_space.reset(new Space(this, section, m_time));
m_player.reset(static_cast<Player*>(m_space->GetBodyByIndex(section.Int32())));
assert(!m_player->IsDead()); // Pioneer does not support necromancy
// space transition state
section = rd.RdSection("HyperspaceClouds");
// hyperspace clouds being brought over from the previous system
Uint32 nclouds = section.Int32();
for (Uint32 i = 0; i < nclouds; i++)
m_hyperspaceClouds.push_back(static_cast<HyperspaceCloud*>(Body::Unserialize(section, 0)));
// system political stuff
section = rd.RdSection("Polit");
Polit::Unserialize(section);
// views
LoadViews(rd);
// lua
section = rd.RdSection("LuaModules");
Pi::luaSerializer->Unserialize(section);
Pi::luaSerializer->UninitTableRefs();
LuaRef::UninitLoad();
// signature check
for (Uint32 i = 0; i < strlen(s_saveEnd)+1; i++)
if (rd.Byte() != s_saveEnd[i]) throw SavedGameCorruptException();
EmitPauseState(IsPaused());
}