本文整理汇总了C++中serializer::Reader::RdSection方法的典型用法代码示例。如果您正苦于以下问题:C++ Reader::RdSection方法的具体用法?C++ Reader::RdSection怎么用?C++ Reader::RdSection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类serializer::Reader
的用法示例。
在下文中一共展示了Reader::RdSection方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RebuildSystemBodyIndex
Space::Space(Game *game, Serializer::Reader &rd)
: m_game(game)
, m_frameIndexValid(false)
, m_bodyIndexValid(false)
, m_sbodyIndexValid(false)
, m_background(Pi::renderer)
, m_bodyNearFinder(this)
#ifndef NDEBUG
, m_processingFinalizationQueue(false)
#endif
{
m_starSystem = StarSystem::Unserialize(rd);
m_background.Refresh(m_starSystem->GetSeed());
RebuildSystemBodyIndex();
Serializer::Reader section = rd.RdSection("Frames");
m_rootFrame.Reset(Frame::Unserialize(section, this, 0));
RebuildFrameIndex();
Uint32 nbodies = rd.Int32();
for (Uint32 i = 0; i < nbodies; i++)
m_bodies.push_back(Body::Unserialize(rd, this));
RebuildBodyIndex();
Frame::PostUnserializeFixup(m_rootFrame.Get(), this);
for (BodyIterator i = m_bodies.begin(); i != m_bodies.end(); ++i)
(*i)->PostLoadFixup(this);
}
示例2: Unserialize
void Pi::Unserialize(Serializer::Reader &rd)
{
Serializer::Reader section;
SetTimeAccel(0);
requestedTimeAccelIdx = 0;
Space::Clear();
if (Pi::player) {
Pi::player->MarkDead();
Space::bodies.remove(Pi::player);
delete Pi::player;
Pi::player = 0;
}
section = rd.RdSection("PiMisc");
gameTime = section.Double();
selectedSystem = StarSystem::Unserialize(section);
currentSystem = StarSystem::Unserialize(section);
section = rd.RdSection("Space");
Space::Unserialize(section);
section = rd.RdSection("Polit");
Polit::Unserialize(section);
section = rd.RdSection("SectorView");
sectorView->Load(section);
section = rd.RdSection("WorldView");
worldView->Load(section);
section = rd.RdSection("LuaModules");
PiLuaModules::Unserialize(section);
}
示例3:
Space::Space(Game *game, Serializer::Reader &rd) : m_game(game), m_frameIndexValid(false), m_bodyIndexValid(false), m_sbodyIndexValid(false)
{
m_starSystem = StarSystem::Unserialize(rd);
m_background.Refresh(m_starSystem->m_seed);
RebuildSBodyIndex();
Serializer::Reader section = rd.RdSection("Frames");
m_rootFrame.Reset(Frame::Unserialize(section, this, 0));
RebuildFrameIndex();
Uint32 nbodies = rd.Int32();
for (Uint32 i = 0; i < nbodies; i++)
m_bodies.push_back(Body::Unserialize(rd, this));
RebuildBodyIndex();
for (BodyIterator i = m_bodies.begin(); i != m_bodies.end(); ++i)
(*i)->PostLoadFixup(this);
Frame::PostUnserializeFixup(m_rootFrame.Get(), this);
}
示例4: rand
Space::Space(Game *game, RefCountedPtr<Galaxy> galaxy, Serializer::Reader &rd, double at_time)
: m_starSystemCache(galaxy->NewStarSystemSlaveCache())
, m_game(game)
, m_frameIndexValid(false)
, m_bodyIndexValid(false)
, m_sbodyIndexValid(false)
, m_bodyNearFinder(this)
#ifndef NDEBUG
, m_processingFinalizationQueue(false)
#endif
{
m_starSystem = StarSystem::Unserialize(galaxy, rd);
const SystemPath &path = m_starSystem->GetPath();
Uint32 _init[5] = { path.systemIndex, Uint32(path.sectorX), Uint32(path.sectorY), Uint32(path.sectorZ), UNIVERSE_SEED };
Random rand(_init, 5);
m_background.reset(new Background::Container(Pi::renderer, rand));
RebuildSystemBodyIndex();
CityOnPlanet::SetCityModelPatterns(m_starSystem->GetPath());
Serializer::Reader section = rd.RdSection("Frames");
m_rootFrame.reset(Frame::Unserialize(section, this, 0, at_time));
RebuildFrameIndex();
Uint32 nbodies = rd.Int32();
for (Uint32 i = 0; i < nbodies; i++)
m_bodies.push_back(Body::Unserialize(rd, this));
RebuildBodyIndex();
Frame::PostUnserializeFixup(m_rootFrame.get(), this);
for (Body* b : m_bodies)
b->PostLoadFixup(this);
GenSectorCache(galaxy, &path);
}
示例5: 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();
}
示例6: 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());
}