本文整理汇总了C++中IReader::r_chunk_safe方法的典型用法代码示例。如果您正苦于以下问题:C++ IReader::r_chunk_safe方法的具体用法?C++ IReader::r_chunk_safe怎么用?C++ IReader::r_chunk_safe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReader
的用法示例。
在下文中一共展示了IReader::r_chunk_safe方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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++;
}
}
示例2:
dxRender_Visual* CModelPool::Instance_Load (const char* N, BOOL allow_register)
{
dxRender_Visual *V;
string_path fn;
string_path name;
// Add default ext if no ext at all
if (0==strext(N)) strconcat (sizeof(name),name,N,".ogf");
else strcpy_s (name,sizeof(name),N);
// Load data from MESHES or LEVEL
if (!FS.exist(N)) {
if (!FS.exist(fn, "$level$", name))
if (!FS.exist(fn, "$game_meshes$", name)){
#ifdef _EDITOR
Msg("! Can't find model file '%s'.",name);
return 0;
#else
xrDebug::Fatal(DEBUG_INFO,"Can't find model file '%s'.",name);
#endif
}
} else {
strcpy_s (fn,N);
}
// Actual loading
#ifdef DEBUG
if (bLogging) Msg ("- Uncached model loading: %s",fn);
#endif // DEBUG
IReader* data = FS.r_open(fn);
ogf_header H;
data->r_chunk_safe (OGF_HEADER,&H,sizeof(H));
V = Instance_Create (H.type);
V->Load (N,data,0);
FS.r_close (data);
g_pGamePersistent->RegisterModel(V);
// Registration
if (allow_register) Instance_Register(N,V);
return V;
}
示例3: sizeof
//-----------------------------------------------------------------------
BOOL motions_value::load (LPCSTR N, IReader *data, vecBones* bones)
{
m_id = N;
bool bRes = true;
// Load definitions
U16Vec rm_bones (bones->size(),BI_NONE);
IReader* MP = data->open_chunk(OGF_S_SMPARAMS);
if (MP)
{
u16 vers = MP->r_u16();
u16 part_bone_cnt = 0;
string128 buf;
R_ASSERT3 (vers<=xrOGF_SMParamsVersion,"Invalid OGF/OMF version:",N);
// partitions
u16 part_count;
part_count = MP->r_u16();
for (u16 part_i=0; part_i<part_count; part_i++)
{
CPartDef& PART = m_partition[part_i];
MP->r_stringZ (buf,sizeof(buf));
PART.Name = _strlwr(buf);
PART.bones.resize (MP->r_u16());
for (xr_vector<u32>::iterator b_it=PART.bones.begin(); b_it<PART.bones.end(); b_it++)
{
MP->r_stringZ (buf,sizeof(buf));
u16 m_idx = u16 (MP->r_u32());
*b_it = find_bone_id (bones,buf);
#ifdef _EDITOR
if (*b_it==BI_NONE )
{
bRes = false;
Msg ("! Can't find bone: '%s'", buf);
}
if (rm_bones.size() <= m_idx)
{
bRes = false;
Msg ("! Can't load: '%s' invalid bones count", N);
}
#else
VERIFY3 (*b_it!=BI_NONE,"Can't find bone:", buf);
#endif
if (bRes) rm_bones[m_idx] = u16(*b_it);
}
part_bone_cnt = u16(part_bone_cnt + (u16)PART.bones.size());
}
#ifdef _EDITOR
if (part_bone_cnt!=(u16)bones->size()){
bRes = false;
Msg("! Different bone count[%s] [Object: '%d' <-> Motions: '%d']", N, bones->size(),part_bone_cnt);
}
#else
VERIFY3(part_bone_cnt==(u16)bones->size(),"Different bone count '%s'",N);
#endif
if (bRes)
{
// motion defs (cycle&fx)
u16 mot_count = MP->r_u16();
m_mdefs.resize (mot_count);
for (u16 mot_i=0; mot_i<mot_count; mot_i++)
{
MP->r_stringZ (buf,sizeof(buf));
shared_str nm = _strlwr (buf);
u32 dwFlags = MP->r_u32 ();
CMotionDef& D = m_mdefs[mot_i];
D.Load (MP,dwFlags,vers);
//. m_mdefs.push_back (D);
if (dwFlags&esmFX)
m_fx.insert (mk_pair(nm,mot_i));
else
m_cycle.insert (mk_pair(nm,mot_i));
m_motion_map.insert (mk_pair(nm,mot_i));
}
}
MP->close();
}else
{
xrDebug::Fatal (DEBUG_INFO,"Old skinned model version unsupported! (%s)",N);
}
if (!bRes) return false;
// Load animation
IReader* MS = data->open_chunk(OGF_S_MOTIONS);
if (!MS) return false;
u32 dwCNT = 0;
MS->r_chunk_safe (0,&dwCNT,sizeof(dwCNT));
VERIFY (dwCNT<0x3FFF); // MotionID 2 bit - slot, 14 bit - motion index
//.........这里部分代码省略.........