本文整理汇总了C++中IReader::close方法的典型用法代码示例。如果您正苦于以下问题:C++ IReader::close方法的具体用法?C++ IReader::close怎么用?C++ IReader::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReader
的用法示例。
在下文中一共展示了IReader::close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadClips
void TClipMaker::LoadClips()
{
bool bRes=true;
if (EFS.GetOpenName("$clips$",m_ClipFName)){
Clear ();
IReader* F = FS.r_open(m_ClipFName.c_str()); VERIFY(F);
m_ClipFName = EFS.ExcludeBasePath(m_ClipFName.c_str(),FS.get_path("$clips$")->m_Path);
if (F->find_chunk(CHUNK_ZOOM)){
m_Zoom = F->r_float();
}
IReader* C = F->open_chunk(CHUNK_CLIPS);
if(C){
IReader* M = C->open_chunk(0);
for (int count=1; M; count++) {
CUIClip* clip = xr_new<CUIClip>(this,count);
if (!clip->Load(*M)){
ELog.Msg(mtError,"Unsupported clip version. Load failed.");
xr_delete(clip);
bRes = false;
}
M->close();
if (!bRes) break;
clips.push_back(clip);
M = C->open_chunk(count);
}
C->close ();
UpdateClips ();
}
FS.r_close(F);
}
}
示例2: Load
void ELightAnimLibrary::Load()
{
string_path fn;
FS.update_path(fn,_game_data_,"lanims.xr");
IReader* fs=FS.r_open(fn);
if (fs){
u16 version = 0;
if (fs->find_chunk(CHUNK_VERSION)){
version = fs->r_u16();
}
IReader* OBJ = fs->open_chunk(CHUNK_ITEM_LIST);
if (OBJ){
IReader* O = OBJ->open_chunk(0);
for (int count=1; O; count++) {
CLAItem* I = xr_new<CLAItem>();
I->Load(*O);
if (version==0){
for (CLAItem::KeyPairIt it=I->Keys.begin(); it!=I->Keys.end(); it++)
it->second = subst_alpha(bgr2rgb(it->second),color_get_A(it->second));
}
Items.push_back(I);
O->close();
O = OBJ->open_chunk(count);
}
OBJ->close();
}
FS.r_close(fs);
}
}
示例3: header
void CALifeSpawnRegistry::load (IReader &file_stream, xrGUID *save_guid)
{
IReader *chunk;
chunk = file_stream.open_chunk(0);
m_header.load (*chunk);
chunk->close ();
R_ASSERT2 (!save_guid || (*save_guid == header().guid()) || ignore_save_incompatibility(),"Saved game doesn't correspond to the spawn : DELETE SAVED GAME!");
chunk = file_stream.open_chunk(1);
m_spawns.load (*chunk);
chunk->close ();
#if 0
SPAWN_GRAPH::vertex_iterator I = m_spawns.vertices().begin();
SPAWN_GRAPH::vertex_iterator E = m_spawns.vertices().end();
for ( ; I != E; ++I) {
luabind::wrap_base *base = smart_cast<luabind::wrap_base*>(&(*I).second->data()->object());
if (!base)
continue;
if (xr_strcmp((*I).second->data()->object().name_replace(),"rostok_stalker_outfit"))
continue;
dummy *_dummy = (dummy*)((void*)base->m_self.m_impl);
lua_State **_state = &_dummy->state;
Msg ("0x%08x",*(int*)&_state);
break;
}
#endif
chunk = file_stream.open_chunk(2);
load_data (m_artefact_spawn_positions,*chunk);
chunk->close ();
chunk = file_stream.open_chunk(3);
R_ASSERT2 (chunk,"Spawn version mismatch - REBUILD SPAWN!");
ai().patrol_path_storage (*chunk);
chunk->close ();
VERIFY (!m_chunk);
m_chunk = file_stream.open_chunk(4);
R_ASSERT2 (m_chunk,"Spawn version mismatch - REBUILD SPAWN!");
VERIFY (!m_game_graph);
m_game_graph = new CGameGraph(*m_chunk);
ai().game_graph (m_game_graph);
R_ASSERT2 ((header().graph_guid() == ai().game_graph().header().guid()) || ignore_save_incompatibility(),"Spawn doesn't correspond to the graph : REBUILD SPAWN!");
build_story_spawns ();
build_root_spawns ();
Msg ("* %d spawn points are successfully loaded",m_spawns.vertex_count());
}
示例4:
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 ();
}
示例5: Load
bool ESceneLightTools::Load(IReader& F)
{
u16 version = 0;
if(F.r_chunk(CHUNK_VERSION,&version))
if( version!=LIGHT_TOOLS_VERSION ){
ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc());
return false;
}
if (!inherited::Load(F)) return false;
if (F.find_chunk(CHUNK_FLAGS))
m_Flags.assign (F.r_u32());
if (F.find_chunk(CHUNK_SUN_SHADOW)){
F.r_u8 ();
F.r_fvector2 (m_SunShadowDir);
}
if (F.find_chunk(CHUNK_LCONTROLS_LAST))
lcontrol_last_idx = F.r_u32();
IReader* R = F.open_chunk(CHUNK_LCONTROLS);
if (R){
while (!R->eof()){
shared_str l_name;
R->r_stringZ(l_name);
u32 l_idx = R->r_u32();
AppendLightControl(l_name.c_str(),&l_idx);
}
R->close ();
}
return true;
}
示例6:
/*
void dump (CDetailManager::vis_list& lst)
{
for (int i=0; i<lst.size(); i++)
{
Msg("%8x / %8x / %8x", lst[i]._M_start, lst[i]._M_finish, lst[i]._M_end_of_storage._M_data);
}
}
*/
void CDetailManager::Load ()
{
// Open file stream
if (!FS.exist("$level$","level.details"))
{
dtFS = NULL;
return;
}
string256 fn;
FS.update_path (fn,"$level$","level.details");
dtFS = FS.r_open(fn);
// Header
dtFS->r_chunk_safe (0,&dtH,sizeof(dtH));
R_ASSERT (dtH.version == DETAIL_VERSION);
u32 m_count = dtH.object_count;
// Models
IReader* m_fs = dtFS->open_chunk(1);
for (u32 m_id = 0; m_id < m_count; m_id++)
{
CDetail* dt = xr_new<CDetail> ();
IReader* S = m_fs->open_chunk(m_id);
dt->Load (S);
objects.push_back (dt);
S->close ();
}
m_fs->close ();
// Get pointer to database (slots)
IReader* m_slots = dtFS->open_chunk(2);
dtSlots = (DetailSlot*)m_slots->pointer();
m_slots->close ();
// Initialize 'vis' and 'cache'
for (u32 i=0; i<3; ++i) visible[i].resize(objects.size());
cache_Initialize ();
// Make dither matrix
bwdithermap (2,dither);
// Hardware specific optimizations
if (UseVS()) hw_Load ();
else soft_Load ();
// swing desc
// normal
swing_desc[0].amp1 = pSettings->r_float("details","swing_normal_amp1");
swing_desc[0].amp2 = pSettings->r_float("details","swing_normal_amp2");
swing_desc[0].rot1 = pSettings->r_float("details","swing_normal_rot1");
swing_desc[0].rot2 = pSettings->r_float("details","swing_normal_rot2");
swing_desc[0].speed = pSettings->r_float("details","swing_normal_speed");
// fast
swing_desc[1].amp1 = pSettings->r_float("details","swing_fast_amp1");
swing_desc[1].amp2 = pSettings->r_float("details","swing_fast_amp2");
swing_desc[1].rot1 = pSettings->r_float("details","swing_fast_rot1");
swing_desc[1].rot2 = pSettings->r_float("details","swing_fast_rot2");
swing_desc[1].speed = pSettings->r_float("details","swing_fast_speed");
}
示例7: Load
void FHierrarhyVisual::Load(const char* N, IReader *data, u32 dwFlags)
{
dxRender_Visual::Load(N,data,dwFlags);
if (data->find_chunk(OGF_CHILDREN_L))
{
// From Link
u32 cnt = data->r_u32 ();
children.resize (cnt);
for (u32 i=0; i<cnt; i++) {
#ifdef _EDITOR
THROW;
#else
u32 ID = data->r_u32();
children[i] = (dxRender_Visual*)::Render->getVisual(ID);
#endif
}
bDontDelete = TRUE;
}
else
{
if (data->find_chunk(OGF_CHILDREN))
{
// From stream
IReader* OBJ = data->open_chunk(OGF_CHILDREN);
if (OBJ){
IReader* O = OBJ->open_chunk(0);
for (int count=1; O; count++) {
string_path name_load,short_name,num;
xr_strcpy (short_name,N);
if (strext(short_name)) *strext(short_name)=0;
strconcat (sizeof(name_load),name_load,short_name,":",itoa(count,num,10));
children.push_back ((dxRender_Visual*)::Render->model_CreateChild(name_load,O));
O->close ();
O = OBJ->open_chunk (count);
}
OBJ->close();
}
bDontDelete = FALSE;
}
else
{
FATAL ("Invalid visual");
}
}
}
示例8: Load
bool CPSLibrary::Load(const char* nm)
{
IReader* F = FS.r_open(nm);
bool bRes = true;
R_ASSERT(F->find_chunk(PS_CHUNK_VERSION));
u16 ver = F->r_u16();
if (ver!=PS_VERSION) return false;
// second generation
IReader* OBJ;
OBJ = F->open_chunk(PS_CHUNK_SECONDGEN);
if (OBJ){
IReader* O = OBJ->open_chunk(0);
for (int count=1; O; count++) {
PS::CPEDef* def = xr_new<PS::CPEDef>();
if (def->Load(*O)) m_PEDs.push_back(def);
else{ bRes = false; xr_delete(def); }
O->close();
if (!bRes) break;
O = OBJ->open_chunk(count);
}
OBJ->close();
}
// second generation
OBJ = F->open_chunk(PS_CHUNK_THIRDGEN);
if (OBJ){
IReader* O = OBJ->open_chunk(0);
for (int count=1; O; count++) {
PS::CPGDef* def = xr_new<PS::CPGDef>();
if (def->Load(*O)) m_PGDs.push_back(def);
else{ bRes = false; xr_delete(def); }
O->close();
if (!bRes) break;
O = OBJ->open_chunk(count);
}
OBJ->close();
}
// final
FS.r_close (F);
std::sort (m_PEDs.begin(),m_PEDs.end(),ped_sort_pred);
std::sort (m_PGDs.begin(),m_PGDs.end(),pgd_sort_pred);
return bRes;
}
示例9: triangle
void CHOM::Load ()
{
// Find and open file
string_path fName;
FS.update_path (fName,"$level$","level.hom");
if (!FS.exist(fName))
{
Msg (" WARNING: Occlusion map '%s' not found.",fName);
return;
}
Msg ("* Loading HOM: %s",fName);
IReader* fs = FS.r_open(fName);
IReader* S = fs->open_chunk(1);
// Load tris and merge them
CDB::Collector CL;
while (!S->eof())
{
HOM_poly P;
S->r (&P,sizeof(P));
CL.add_face_packed_D (P.v1,P.v2,P.v3,P.flags,0.01f);
}
// Determine adjacency
xr_vector<u32> adjacency;
CL.calc_adjacency (adjacency);
// Create RASTER-triangles
m_pTris = xr_alloc<occTri> (u32(CL.getTS()));
for (u32 it=0; it<CL.getTS(); it++)
{
CDB::TRI& clT = CL.getT()[it];
occTri& rT = m_pTris[it];
Fvector& v0 = CL.getV()[clT.verts[0]];
Fvector& v1 = CL.getV()[clT.verts[1]];
Fvector& v2 = CL.getV()[clT.verts[2]];
rT.adjacent[0] = (0xffffffff==adjacency[3*it+0])?((occTri*) (-1)):(m_pTris+adjacency[3*it+0]);
rT.adjacent[1] = (0xffffffff==adjacency[3*it+1])?((occTri*) (-1)):(m_pTris+adjacency[3*it+1]);
rT.adjacent[2] = (0xffffffff==adjacency[3*it+2])?((occTri*) (-1)):(m_pTris+adjacency[3*it+2]);
rT.flags = clT.dummy;
rT.area = Area (v0,v1,v2);
if (rT.area<EPS_L) {
Msg ("! Invalid HOM triangle (%f,%f,%f)-(%f,%f,%f)-(%f,%f,%f)",VPUSH(v0),VPUSH(v1),VPUSH(v2));
}
rT.plane.build (v0,v1,v2);
rT.skip = 0;
rT.center.add(v0,v1).add(v2).div(3.f);
}
// Create AABB-tree
m_pModel = xr_new<CDB::MODEL> ();
m_pModel->build (CL.getV(),int(CL.getVS()),CL.getT(),int(CL.getTS()));
bEnabled = TRUE;
S->close ();
FS.r_close (fs);
}
示例10: transfer
void transfer(const char *name, xr_vector<T> &dest, IReader& F, u32 chunk)
{
IReader* O = F.open_chunk(chunk);
u32 count = O?(O->length()/sizeof(T)):0;
clMsg ("* %16s: %d",name,count);
if (count)
{
dest.reserve(count);
dest.insert (dest.begin(), (T*)O->pointer(), (T*)O->pointer() + count);
}
if (O) O->close ();
}
示例11: LoadColorIndices
bool EDetailManager::LoadColorIndices(IReader& F)
{
VERIFY (objects.empty());
VERIFY (m_ColorIndices.empty());
bool bRes = true;
// objects
IReader* OBJ = F.open_chunk(DETMGR_CHUNK_OBJECTS);
if (OBJ){
IReader* O = OBJ->open_chunk(0);
for (int count=1; O; count++) {
EDetail* DO = xr_new<EDetail>();
if (DO->Load(*O)) objects.push_back(DO);
else bRes = false;
O->close();
O = OBJ->open_chunk(count);
}
OBJ->close();
}
// color index map
R_ASSERT (F.find_chunk(DETMGR_CHUNK_COLOR_INDEX));
int cnt = F.r_u8();
string256 buf;
u32 index;
int ref_cnt;
for (int k=0; k<cnt; k++){
index = F.r_u32();
ref_cnt = F.r_u8();
for (int j=0; j<ref_cnt; j++){
F.r_stringZ (buf,sizeof(buf));
EDetail* DO = FindDOByName(buf);
if (DO) m_ColorIndices[index].push_back(DO);
else bRes=false;
}
}
InvalidateCache ();
return bRes;
}
示例12: LoadSelection
bool EScene::LoadSelection( LPCSTR fname )
{
u32 version = 0;
VERIFY( fname );
xr_string full_name;
full_name = fname;
ELog.Msg( mtInformation, "EScene: loading part %s...", fname );
bool res = true;
if (FS.exist(full_name.c_str())){
SelectObjects( false );
IReader* F = FS.r_open(full_name.c_str());
// Version
R_ASSERT(F->r_chunk(CHUNK_VERSION, &version));
if (version!=CURRENT_FILE_VERSION){
ELog.DlgMsg( mtError, "EScene: unsupported file version. Can't load Level.");
UI->UpdateScene();
FS.r_close(F);
return false;
}
// Objects
if (!ReadObjectsStream(*F,CHUNK_OBJECT_LIST,OnLoadSelectionAppendObject,0))
{
ELog.DlgMsg(mtError,"EScene. Failed to load selection.");
res = false;
}
SceneToolsMapPairIt _I = m_SceneTools.begin();
SceneToolsMapPairIt _E = m_SceneTools.end();
for (; _I!=_E; _I++)
if (_I->second&&_I->second->IsEnabled()&&_I->second->IsEditable()){
IReader* chunk = F->open_chunk(CHUNK_TOOLS_DATA+_I->first);
if (chunk){
_I->second->LoadSelection(*chunk);
chunk->close ();
}
}
// Synchronize
SynchronizeObjects();
FS.r_close(F);
}
return res;
}
示例13: ReadObjectStream
bool EScene::ReadObjectStream(IReader& F, CCustomObject*& O)
{
ObjClassID clsid =OBJCLASS_DUMMY;
R_ASSERT (F.find_chunk(CHUNK_OBJECT_CLASS));
clsid = ObjClassID(F.r_u32());
O = GetOTool(clsid)->CreateObject(0,0);
IReader* S = F.open_chunk(CHUNK_OBJECT_BODY);
R_ASSERT (S);
bool bRes = O->LoadStream(*S);
S->close ();
if (!bRes)
xr_delete (O);
return bRes;
}
示例14: LoadObject
bool CEditableObject::LoadObject(const char* fname)
{
if (FS.exist(fname)){
int age = FS.get_file_age (fname); VERIFY3(age>0,"Invalid file age:",fname);
IReader* F = FS.r_open (fname); R_ASSERT(F);
IReader* OBJ = F->open_chunk (EOBJ_CHUNK_OBJECT_BODY);
R_ASSERT2 (OBJ,"Corrupted file.");
bool bRes = Load(*OBJ);
OBJ->close();
FS.r_close(F);
if (bRes){
m_LoadName = fname;
m_ObjectVersion = age;
}
return bRes;
}
return false;
}
示例15: LoadVisuals
void CRender::LoadVisuals(IReader *fs)
{
IReader* chunk = 0;
u32 index = 0;
dxRender_Visual* V = 0;
ogf_header H;
while ((chunk=fs->open_chunk(index))!=0)
{
chunk->r_chunk_safe (OGF_HEADER,&H,sizeof(H));
V = Models->Instance_Create (H.type);
V->Load(0,chunk,0);
Visuals.push_back(V);
chunk->close();
index++;
}
}