本文整理汇总了C++中IReader::open_chunk_iterator方法的典型用法代码示例。如果您正苦于以下问题:C++ IReader::open_chunk_iterator方法的具体用法?C++ IReader::open_chunk_iterator怎么用?C++ IReader::open_chunk_iterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReader
的用法示例。
在下文中一共展示了IReader::open_chunk_iterator方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void CGameGraphBuilder::load_graph_points (const float &start, const float &amount)
{
Progress (start);
Msg ("Loading graph points");
string_path spawn_file_name;
strconcat (sizeof(spawn_file_name),spawn_file_name,*m_level_name,"level.spawn");
IReader *reader = FS.r_open(spawn_file_name);
u32 id;
NET_Packet net_packet;
for (
IReader *chunk = reader->open_chunk_iterator(id);
chunk;
chunk = reader->open_chunk_iterator(id,chunk)
)
{
net_packet.B.count = chunk->length();
chunk->r (net_packet.B.data,net_packet.B.count);
load_graph_point (net_packet);
}
FS.r_close (reader);
Msg ("%d graph points loaded",graph().vertices().size());
Progress (start + amount);
}
示例2:
void CALifeSpawnRegistry::load_updates (IReader &stream)
{
u32 vertex_id;
for (IReader *chunk = stream.open_chunk_iterator(vertex_id); chunk; chunk = stream.open_chunk_iterator(vertex_id,chunk)) {
VERIFY (u32(ALife::_SPAWN_ID(-1)) > vertex_id);
const SPAWN_GRAPH::CVertex *vertex = m_spawns.vertex(ALife::_SPAWN_ID(vertex_id));
VERIFY (vertex);
vertex->data()->load_update (*chunk);
}
}
示例3:
void CPatrolPathStorage::load_raw (const CLevelGraph *level_graph, const CGameLevelCrossTable *cross, const CGameGraph *game_graph, IReader &stream)
{
IReader *chunk = stream.open_chunk(WAY_PATROLPATH_CHUNK);
if (!chunk)
return;
u32 chunk_iterator;
for (IReader *sub_chunk = chunk->open_chunk_iterator(chunk_iterator); sub_chunk; sub_chunk = chunk->open_chunk_iterator(chunk_iterator,sub_chunk)) {
R_ASSERT (sub_chunk->find_chunk(WAYOBJECT_CHUNK_VERSION));
R_ASSERT (sub_chunk->r_u16() == WAYOBJECT_VERSION);
R_ASSERT (sub_chunk->find_chunk(WAYOBJECT_CHUNK_NAME));
shared_str patrol_name;
sub_chunk->r_stringZ (patrol_name);
const_iterator I = m_registry.find(patrol_name);
VERIFY3 (I == m_registry.end(),"Duplicated patrol path found",*patrol_name);
m_registry.insert (
std::make_pair(
patrol_name,
&xr_new<CPatrolPath>(
patrol_name
)->load_raw(
level_graph,
cross,
game_graph,
*sub_chunk
)
)
);
}
chunk->close ();
}
示例4: CGameGraph
//.........这里部分代码省略.........
// updating cross-table
{
strcpy_s (caFileName,raw_cross_table_file_name);
CGameLevelCrossTable *tpCrossTable = new CGameLevelCrossTable(caFileName);
xr_vector<CGameLevelCrossTable::CCell> tCrossTableUpdate;
tCrossTableUpdate.resize(tpCrossTable->header().level_vertex_count());
for (int i=0; i<(int)tpCrossTable->header().level_vertex_count(); i++) {
tCrossTableUpdate[i] = tpCrossTable->vertex(i);
VERIFY (u32(tCrossTableUpdate[i].tGraphIndex) < tpCrossTable->header().game_vertex_count());
tCrossTableUpdate[i].tGraphIndex = tCrossTableUpdate[i].tGraphIndex + (GameGraph::_GRAPH_ID)dwOffset;
}
CGameLevelCrossTable::CHeader tCrossTableHeader;
tCrossTableHeader.dwVersion = XRAI_CURRENT_VERSION;
tCrossTableHeader.dwNodeCount = tpCrossTable->m_tCrossTableHeader.dwNodeCount;
tCrossTableHeader.dwGraphPointCount = tpCrossTable->m_tCrossTableHeader.dwGraphPointCount;
tCrossTableHeader.m_level_guid = tpCrossTable->m_tCrossTableHeader.m_level_guid;
tCrossTableHeader.m_game_guid = tGraphHeader.m_guid;
xr_delete (tpCrossTable);
m_cross_table.w(&tCrossTableHeader,sizeof(tCrossTableHeader));
for (int i=0; i<(int)tCrossTableHeader.dwNodeCount; i++)
m_cross_table.w(&(tCrossTableUpdate[i]),sizeof(tCrossTableUpdate[i]));
}
// fill vertex map
{
string_path fName;
strconcat (sizeof(fName),fName,S,"level.spawn");
IReader *F = FS.r_open(fName);
u32 id;
IReader *O = F->open_chunk_iterator(id);
for (int i=0; O; O = F->open_chunk_iterator(id,O)) {
NET_Packet P;
P.B.count = O->length();
O->r (P.B.data,P.B.count);
u16 ID;
P.r_begin (ID);
R_ASSERT (M_SPAWN==ID);
P.r_stringZ (fName);
CSE_Abstract *E = F_entity_Create(fName);
R_ASSERT3 (E,"Can't create entity.",fName);
// E->Spawn_Read (P);
CSE_ALifeGraphPoint *tpGraphPoint = smart_cast<CSE_ALifeGraphPoint*>(E);
if (tpGraphPoint) {
E->Spawn_Read (P);
Fvector tVector;
tVector = tpGraphPoint->o_Position;
GameGraph::_GRAPH_ID tGraphID = GameGraph::_GRAPH_ID(-1);
float fMinDistance = 1000000.f;
{
GRAPH_VERTEX_IT B = m_tpVertices.begin();
GRAPH_VERTEX_IT I = B;
GRAPH_VERTEX_IT E = m_tpVertices.end();
for ( ; I != E; I++) {
float fDistance = (*I).tLocalPoint.distance_to(tVector);
if (fDistance < fMinDistance) {
fMinDistance = fDistance;
tGraphID = GameGraph::_GRAPH_ID(I - B);
if (fMinDistance < EPS_L)
break;
}
}
示例5: Load
void CGameMtlLibrary::Load()
{
string_path name;
if (!FS.exist(name, _game_data_,GAMEMTL_FILENAME)){
Log ("! Can't find game material file: ",name);
return;
}
R_ASSERT (material_pairs.empty());
R_ASSERT (materials.empty());
destructor<IReader> F(FS.r_open(name));
IReader& fs = F();
R_ASSERT(fs.find_chunk(GAMEMTLS_CHUNK_VERSION));
u16 version = fs.r_u16();
if (GAMEMTL_CURRENT_VERSION!=version){
Log ("CGameMtlLibrary: invalid version. Library can't load.");
return;
}
R_ASSERT(fs.find_chunk(GAMEMTLS_CHUNK_AUTOINC));
material_index = fs.r_u32();
material_pair_index = fs.r_u32();
materials.clear ();
material_pairs.clear();
IReader* OBJ = fs.open_chunk(GAMEMTLS_CHUNK_MTLS);
if (OBJ) {
u32 count;
for (IReader* O = OBJ->open_chunk_iterator(count); O; O = OBJ->open_chunk_iterator(count,O)) {
SGameMtl* M = new SGameMtl();
M->Load (*O);
materials.push_back(M);
}
OBJ->close ();
}
OBJ = fs.open_chunk(GAMEMTLS_CHUNK_MTLS_PAIR);
if (OBJ){
u32 count;
for (IReader* O = OBJ->open_chunk_iterator(count); O; O = OBJ->open_chunk_iterator(count,O)) {
SGameMtlPair* M = new SGameMtlPair(this);
M->Load (*O);
material_pairs.push_back(M);
}
OBJ->close ();
}
#ifndef _EDITOR
material_count = (u32)materials.size();
material_pairs_rt.resize(material_count*material_count,0);
for (GameMtlPairIt p_it=material_pairs.begin(); material_pairs.end() != p_it; ++p_it){
SGameMtlPair* S = *p_it;
int idx0 = GetMaterialIdx(S->mtl0)*material_count+GetMaterialIdx(S->mtl1);
int idx1 = GetMaterialIdx(S->mtl1)*material_count+GetMaterialIdx(S->mtl0);
material_pairs_rt[idx0]=S;
material_pairs_rt[idx1]=S;
}
#endif
/*
for (GameMtlPairIt p_it=material_pairs.begin(); material_pairs.end() != p_it; ++p_it){
SGameMtlPair* S = *p_it;
for (int k=0; k<S->StepSounds.size(); k++){
Msg("%40s - 0x%x", S->StepSounds[k].handle->file_name(), S->StepSounds[k].g_type);
}
}
*/
}
示例6: Load_GameSpecific_After
BOOL CLevel::Load_GameSpecific_After()
{
// loading static particles
string_path fn_game;
if (FS.exist(fn_game, "$level$", "level.ps_static")) {
IReader *F = FS.r_open (fn_game);
CParticlesObject* pStaticParticles;
u32 chunk = 0;
string256 ref_name;
Fmatrix transform;
Fvector zero_vel={0.f,0.f,0.f};
for (IReader *OBJ = F->open_chunk_iterator(chunk); OBJ; OBJ = F->open_chunk_iterator(chunk,OBJ)) {
OBJ->r_stringZ (ref_name,sizeof(ref_name));
OBJ->r (&transform,sizeof(Fmatrix));transform.c.y+=0.01f;
pStaticParticles = CParticlesObject::Create(ref_name,FALSE,false);
pStaticParticles->UpdateParent (transform,zero_vel);
pStaticParticles->Play ();
m_StaticParticles.push_back (pStaticParticles);
}
FS.r_close (F);
}
if (!g_dedicated_server)
{
// loading static sounds
VERIFY (m_level_sound_manager);
m_level_sound_manager->Load ();
// loading sound environment
if ( FS.exist(fn_game, "$level$", "level.snd_env")) {
IReader *F = FS.r_open (fn_game);
::Sound->set_geometry_env(F);
FS.r_close (F);
}
// loading SOM
if (FS.exist(fn_game, "$level$", "level.som")) {
IReader *F = FS.r_open (fn_game);
::Sound->set_geometry_som(F);
FS.r_close (F);
}
// loading random (around player) sounds
if (pSettings->section_exist("sounds_random")){
CInifile::Sect& S = pSettings->r_section("sounds_random");
Sounds_Random.reserve (S.Data.size());
for (CInifile::SectCIt I=S.Data.begin(); S.Data.end()!=I; ++I)
{
Sounds_Random.push_back (ref_sound());
Sound->create (Sounds_Random.back(),*I->first,st_Effect,sg_SourceType);
}
Sounds_Random_dwNextTime= Device.TimerAsync () + 50000;
Sounds_Random_Enabled = FALSE;
}
// Сбрасываем состояния дождя при загрузке уровня во избежание пропажи звука. Real Wolf.
if (g_pGamePersistent->pEnvironment)
{
if (auto rain = g_pGamePersistent->pEnvironment->eff_Rain)
{
rain->InvalidateState();
}
}
}
if (!g_dedicated_server) {
// loading scripts
ai().script_engine().remove_script_process(ScriptEngine::eScriptProcessorLevel);
if (pLevel->section_exist("level_scripts") && pLevel->line_exist("level_scripts","script"))
ai().script_engine().add_script_process(ScriptEngine::eScriptProcessorLevel,xr_new<CScriptProcess>("level",pLevel->r_string("level_scripts","script")));
else
ai().script_engine().add_script_process(ScriptEngine::eScriptProcessorLevel,xr_new<CScriptProcess>("level",""));
}
BlockCheatLoad();
return TRUE;
}
示例7: Fvector
void xrServer::SLS_Default ()
{
if (game->custom_sls_default()) {
game->sls_default ();
return;
}
#ifdef USE_DESIGNER_KEY
bool _designer = !!strstr(Core.Params,"-designer");
CSE_ALifeCreatureActor *_actor = 0;
#endif
string256 fn_spawn;
if (FS.exist(fn_spawn, "$level$", "level.spawn")) {
IReader* SP = FS.r_open(fn_spawn);
NET_Packet P;
u32 S_id;
for (IReader *S = SP->open_chunk_iterator(S_id); S; S = SP->open_chunk_iterator(S_id,S)) {
P.B.count = S->length();
S->r (P.B.data,P.B.count);
u16 ID;
P.r_begin (ID);
R_ASSERT (M_SPAWN==ID);
ClientID clientID;clientID.set(0);
#ifdef USE_DESIGNER_KEY
CSE_Abstract *entity =
#endif
Process_spawn(P,clientID);
#ifdef USE_DESIGNER_KEY
if (_designer) {
CSE_ALifeCreatureActor *actor = smart_cast<CSE_ALifeCreatureActor*>(entity);
if (actor)
_actor = actor;
}
#endif
}
FS.r_close (SP);
}
#ifdef USE_DESIGNER_KEY
if (!_designer)
return;
if (_actor)
return;
_actor = smart_cast<CSE_ALifeCreatureActor*>(entity_Create("actor"));
_actor->o_Position = Fvector().set(0.f,0.f,0.f);
_actor->set_name_replace("designer");
_actor->s_flags.flags |= M_SPAWN_OBJECT_ASPLAYER;
NET_Packet packet;
packet.w_begin (M_SPAWN);
_actor->Spawn_Write (packet,TRUE);
u16 id;
packet.r_begin (id);
R_ASSERT (id == M_SPAWN);
ClientID clientID;
clientID.set (0);
Process_spawn (packet,clientID);
#endif
}