本文整理汇总了C++中IReader类的典型用法代码示例。如果您正苦于以下问题:C++ IReader类的具体用法?C++ IReader怎么用?C++ IReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
u32 STextureParams::MemoryUsage(LPCSTR base_name)
{
u32 mem_usage = width*height*4;
if (flags.test(flGenerateMipMaps)) { mem_usage*=3ul; mem_usage/=2ul; }
switch (fmt){
case STextureParams::tfDXT1:
case STextureParams::tfADXT1: mem_usage/=6; break;
case STextureParams::tfDXT3:
case STextureParams::tfDXT5: mem_usage/=4; break;
case STextureParams::tf4444:
case STextureParams::tf1555:
case STextureParams::tf565: mem_usage/=2; break;
case STextureParams::tfRGBA: break;
}
xr_string fn;
FS.update_path (fn,_game_textures_,EFS.ChangeFileExt(base_name,".seq").c_str());
if (FS.exist(fn.c_str())){
string128 buffer;
IReader* F = FS.r_open(0,fn.c_str());
F->r_string (buffer,sizeof(buffer));
int cnt = 0;
while (!F->eof()){
F->r_string(buffer,sizeof(buffer));
cnt++;
}
FS.r_close (F);
mem_usage *= cnt?cnt:1;
}
return mem_usage;
}
示例2: Load
void PDomain::Load(IReader& F)
{
type = PDomainEnum(F.r_u32());
F.r_fvector3(v[0]);
F.r_fvector3(v[1]);
F.r_fvector3(v[2]);
}
示例3: strext
void CObjectAnimator::LoadMotions(LPCSTR fname)
{
string_path full_path;
if (!FS.exist( full_path, "$level$", fname ))
if (!FS.exist( full_path, "$game_anims$", fname ))
Debug.fatal(DEBUG_INFO,"Can't find motion file '%s'.",fname);
LPCSTR ext = strext(full_path);
if (ext){
Clear ();
if (0==xr_strcmp(ext,".anm")){
COMotion* M = xr_new<COMotion> ();
if (M->LoadMotion(full_path)) m_Motions.push_back(M);
else FATAL("ERROR: Can't load motion. Incorrect file version.");
}else if (0==xr_strcmp(ext,".anms")){
IReader* F = FS.r_open(full_path);
u32 dwMCnt = F->r_u32(); VERIFY(dwMCnt);
for (u32 i=0; i<dwMCnt; i++){
COMotion* M = xr_new<COMotion> ();
bool bRes = M->Load(*F);
if (!bRes) FATAL("ERROR: Can't load motion. Incorrect file version.");
m_Motions.push_back(M);
}
FS.r_close (F);
}
std::sort(m_Motions.begin(),m_Motions.end(),motion_sort_pred);
}
}
示例4: VERIFY
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);
}
}
示例5: Load
bool CGlow::Load(IReader& F)
{
u32 version = 0;
R_ASSERT(F.r_chunk(GLOW_CHUNK_VERSION,&version));
if((version!=0x0011)&&(version!=GLOW_VERSION)){
ELog.DlgMsg( mtError, "CGlow: Unsupported version.");
return false;
}
CCustomObject::Load(F);
if (F.find_chunk(GLOW_CHUNK_SHADER)){
F.r_stringZ (m_ShaderName);
}
R_ASSERT(F.find_chunk(GLOW_CHUNK_TEXTURE));
F.r_stringZ (m_TexName);
R_ASSERT(F.find_chunk(GLOW_CHUNK_PARAMS));
m_fRadius = F.r_float();
if (version==0x0011){
F.r_fvector3 (FPosition);
UpdateTransform();
}
if (F.find_chunk(GLOW_CHUNK_FLAGS))
m_Flags.assign (F.r_u16());
return true;
}
示例6: _Width
int ETextureThumbnail::MemoryUsage()
{
int mem_usage = _Width()*_Height()*4;
switch (m_TexParams.fmt){
case STextureParams::tfDXT1:
case STextureParams::tfADXT1: mem_usage/=6; break;
case STextureParams::tfDXT3:
case STextureParams::tfDXT5: mem_usage/=4; break;
case STextureParams::tf4444:
case STextureParams::tf1555:
case STextureParams::tf565: mem_usage/=2; break;
case STextureParams::tfRGBA: break;
}
string_path fn;
FS.update_path (fn,_game_textures_,EFS.ChangeFileExt(m_Name.c_str(),".seq").c_str());
if (FS.exist(fn))
{
string128 buffer;
IReader* F = FS.r_open(0,fn);
F->r_string (buffer,sizeof(buffer));
int cnt = 0;
while (!F->eof()){
F->r_string(buffer,sizeof(buffer));
cnt++;
}
FS.r_close (F);
mem_usage *= cnt?cnt:1;
}
return mem_usage;
}
示例7: Load
bool EParticlesObject::Load(IReader& F)
{
u32 version = 0;
R_ASSERT(F.r_chunk(CPSOBJECT_CHUNK_VERSION,&version));
if( version!=CPSOBJECT_VERSION ){
ELog.DlgMsg( mtError, "PSObject: Unsupported version.");
return false;
}
inherited::Load(F);
R_ASSERT(F.find_chunk(CPSOBJECT_CHUNK_REFERENCE));
F.r_stringZ(m_RefName);
if (!Compile(*m_RefName)){
ELog.DlgMsg( mtError, "EParticlesObject: '%s' not found in library", *m_RefName );
return false;
}
if (F.find_chunk(CPSOBJECT_CHUNK_PARAMS)){
//. if (m_Particles) m_Particles->m_RT_Flags.set(F.r_u32());
}
return true;
}
示例8: Msg
/*
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");
}
示例9: mods_load
void CEnvironment::mods_load()
{
Modifiers.clear_and_free();
string_path path;
if (FS.exist(path, "$level$", "level.env_mod"))
{
IReader* fs = FS.r_open(path);
u32 id = 0;
u32 ver = 0x0015;
u32 sz;
while (0 != (sz = fs->find_chunk(id)))
{
if (id == 0 && sz == sizeof(u32))
{
ver = fs->r_u32();
}
else
{
CEnvModifier E;
E.load(fs, ver);
Modifiers.push_back(E);
}
id++;
}
FS.r_close(fs);
}
load_level_specific_ambients();
}
示例10: sizeof
bool CALifeStorageManager::load (LPCSTR save_name_no_check)
{
LPCSTR game_saves_path = FS.get_path("$game_saves$")->m_Path;
string_path save_name;
strncpy_s (save_name, sizeof(save_name), save_name_no_check, sizeof(save_name)-5-xr_strlen(SAVE_EXTENSION)-xr_strlen(game_saves_path));
CTimer timer;
timer.Start ();
string_path save;
xr_strcpy (save,m_save_name);
if (!save_name) {
if (!xr_strlen(m_save_name))
R_ASSERT2 (false,"There is no file name specified!");
}
else
{
strconcat (sizeof(m_save_name), m_save_name, save_name, SAVE_EXTENSION);
}
string_path file_name;
FS.update_path (file_name,"$game_saves$",m_save_name);
xr_strcpy (g_last_saved_game, save_name);
xr_strcpy (g_bug_report_file, file_name);
IReader *stream;
stream = FS.r_open(file_name);
if (!stream) {
Msg ("* Cannot find saved game %s",file_name);
xr_strcpy (m_save_name,save);
return (false);
}
CHECK_OR_EXIT (CSavedGameWrapper::valid_saved_game(*stream),make_string("%s\nSaved game version mismatch or saved game is corrupted",file_name));
/*
string512 temp;
strconcat (sizeof(temp),temp,CStringTable().translate("st_loading_saved_game").c_str()," \"",save_name,SAVE_EXTENSION,"\"");
g_pGamePersistent->LoadTitle(temp);
*/
g_pGamePersistent->LoadTitle();
unload ();
reload (m_section);
u32 source_count = stream->r_u32();
void *source_data = xr_malloc(source_count);
rtc_decompress (source_data,source_count,stream->pointer(),stream->length() - 3*sizeof(u32));
FS.r_close (stream);
load (source_data, source_count, file_name);
xr_free (source_data);
groups().on_after_game_load ();
VERIFY (graph().actor());
Msg ("* Game %s is successfully loaded from file '%s' (%.3fs)",save_name, file_name,timer.GetElapsed_sec());
return (true);
}
示例11: load
void CActorCondition::load(IReader &input_packet)
{
inherited::load (input_packet);
load_data (m_fAlcohol, input_packet);
load_data (m_condition_flags, input_packet);
load_data (m_fSatiety, input_packet);
load_data (m_curr_medicine_influence.fHealth, input_packet);
load_data (m_curr_medicine_influence.fPower, input_packet);
load_data (m_curr_medicine_influence.fSatiety, input_packet);
load_data (m_curr_medicine_influence.fRadiation, input_packet);
load_data (m_curr_medicine_influence.fWoundsHeal, input_packet);
load_data (m_curr_medicine_influence.fMaxPowerUp, input_packet);
load_data (m_curr_medicine_influence.fAlcohol, input_packet);
load_data (m_curr_medicine_influence.fTimeTotal, input_packet);
load_data (m_curr_medicine_influence.fTimeCurrent, input_packet);
u8 cntr = input_packet.r_u8();
for(; cntr>0; cntr--)
{
SBooster B;
B.m_type = (EBoostParams)input_packet.r_u8();
B.fBoostValue = input_packet.r_float();
B.fBoostTime = input_packet.r_float();
m_booster_influences[B.m_type] = B;
BoostParameters(B);
}
}
示例12:
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 ();
}
示例13: decode
Image ImageFormat_JPEG::decode(IReader& reader) const
{
const int64 size = reader.size();
uint8* buffer = static_cast<uint8*>(::malloc(static_cast<size_t>(size)));
reader.read(buffer, size);
int width, height;
tjhandle tj = ::tjInitDecompress();
::tjDecompressHeader(tj, buffer, static_cast<unsigned long>(size), &width, &height);
Image image(width, height);
::tjDecompress(
tj,
buffer,
static_cast<unsigned long>(size),
image.dataAsUint8(),
image.width(),
image.stride(),
image.height(),
sizeof(Color),
0);
::tjDestroy(tj);
::free(buffer);
return image;
}
示例14: check_files
void recalculation::check_files( u32 check_sum )
{
string_path N,L;
FS.update_path ( L, "$level$", "level.details" );
FS.update_path ( N, "$level$", "recalculation_data_slots.details" );
if( ! FS.exist( L ) )
{
FS.file_delete( N );
return;
}
IReader* R = FS.r_open ( "$level$", "recalculation_data_slots.details" );
if( R )
{
u32 check;
R->r_chunk( 0, &check );
if( check != check_sum )
FS.file_delete( N );
else
recalculate = true;
FS.r_close( R ) ;
}
}
示例15: stream
void ppmd_initialize ()
{
if (trained_model)
trained_model->rewind ();
static bool initialized = false;
if (initialized)
return;
string_path file_name;
FS.update_path (file_name,"$game_config$","mp\\!PPMd.mdl");
if (FS.exist(file_name)) {
IReader *reader = FS.r_open(file_name);
R_ASSERT (reader);
u32 buffer_size = reader->length();
u8 *buffer = (u8*)xr_malloc(buffer_size);
reader->r (buffer,buffer_size);
FS.r_close (reader);
trained_model = new stream(buffer,buffer_size);
}
initialized = true;
if (StartSubAllocator(suballocator_size))
return;
exit (-1);
}