Пример #1
0
void CInifile::save_as	(IWriter& writer)
{
    string4096		temp,val;
    for (RootIt r_it=DATA.begin(); r_it!=DATA.end(); ++r_it)
    {
        sprintf_s		(temp,sizeof(temp),"[%s]",*(*r_it)->Name);
        writer.w_string	(temp);
        for (SectCIt s_it=(*r_it)->Data.begin(); s_it!=(*r_it)->Data.end(); ++s_it)
        {
            const Item&	I = *s_it;
            if (*I.first)
            {
                if (*I.second) {
                    _decorate	(val,*I.second);
#ifdef DEBUG
                    if (*I.comment) {
                        // name, value and comment
                        sprintf_s	(temp,sizeof(temp),"%8s%-32s = %-32s ;%s"," ",*I.first,val,*I.comment);
                    } else
#endif
                    {
                        // only name and value
                        sprintf_s	(temp,sizeof(temp),"%8s%-32s = %-32s"," ",*I.first,val);
                    }
                } else {
#ifdef DEBUG
                    if (*I.comment) {
                        // name and comment
                        sprintf_s(temp,sizeof(temp),"%8s%-32s = ;%s"," ",*I.first,*I.comment);
                    } else
#endif
                    {
                        // only name
                        sprintf_s(temp,sizeof(temp),"%8s%-32s = "," ",*I.first);
                    }
                }
            } else {
                // no name, so no value
#ifdef DEBUG
                if (*I.comment)
                    sprintf_s		(temp,sizeof(temp),"%8s;%s"," ",*I.comment);
                else
#endif
                    temp[0]		= 0;
            }
            _TrimRight			(temp);
            if (temp[0])		writer.w_string	(temp);
        }
        writer.w_string			(" ");
    }
}
Пример #2
0
void	CUIMapList::SaveMapList()
{
	string_path					temp;
	FS.update_path				(temp,"$app_data_root$", MAP_ROTATION_LIST);

	if(m_pList2->GetSize()<=1){
		FS.file_delete(temp);
		return;
	}

	IWriter*	pW = FS.w_open	(temp);
	if (!pW){
		Msg("! Cant create map rotation file [%s]", temp);
		return;
	}
	
	string_path					map_name;
	for(u32 idx=0; idx<m_pList2->GetSize(); ++idx)
	{
		CUIListBoxItem* itm				= m_pList2->GetItemByIDX(idx);
		u32 _idx						= (u32)(__int64)(itm->GetData());
		const shared_str& _map_name		= GetMapNameInt(GetCurGameType(), _idx);

		sprintf_s							(map_name, "sv_addmap %s", _map_name.c_str() );

		pW->w_string					(map_name);
	}

	FS.w_close							(pW);
}
Пример #3
0
BOOL SceneBuilder::BuildLTX()
{
	bool bResult	= true;
	int objcount 	= Scene->ObjCount();
	if( objcount <= 0 ) return true;

	xr_string ltx_filename	= MakeLevelPath("level.ltx");

    if (FS.exist(ltx_filename.c_str()))
    	EFS.MarkFile(ltx_filename.c_str(),true);

	// -- defaults --           
    IWriter* F		= FS.w_open(ltx_filename.c_str());
    if (F){
    	F->w_string("[map_usage]");
        if(Scene->m_LevelOp.m_bDeathmatch)
        	F->w_string("deathmatch");
        if(Scene->m_LevelOp.m_bTeamDeathmatch)
        	F->w_string("teamdeathmatch");
        if(Scene->m_LevelOp.m_bArtefacthunt)
        	F->w_string("artefacthunt");

        F->w_string( ";");
        F->w_string( "; level script file");
        if(Scene->m_LevelOp.m_BOPText.size())
            F->w_stringZ( Scene->m_LevelOp.m_BOPText );

        FS.w_close	(F);
    }else{
    	bResult 	= false;
    }

	return bResult;
}
Пример #4
0
void SaveUVM			(LPCSTR fname, xr_vector<b_rc_face>& vm)
{
	IWriter* W			= FS.w_open(fname);
	string256 tmp;
	// vertices
	for (u32 v_idx=0; v_idx<vm.size(); v_idx++){
		b_rc_face& rcf	= vm[v_idx];
		sprintf			(tmp,"f %d %d [%3.2f,%3.2f]-[%3.2f,%3.2f]-[%3.2f,%3.2f]",rcf.dwMaterial,rcf.dwMaterialGame,
						rcf.t[0].x,rcf.t[0].y, rcf.t[1].x,rcf.t[1].y, rcf.t[2].x,rcf.t[2].y);
		W->w_string		(tmp);
	}
	FS.w_close	(W);
}
Пример #5
0
void write(IWriter	&w, const b_texture &b)
{
	w.w_string( b.name );
	w.w_u32( b.dwWidth );
	w.w_u32( b.dwHeight );
	w.w_s32( b.bHasAlpha );
	
	bool b_surface = !!b.pSurface;
	w.w_u8( u8( b_surface ) );
	if(b_surface)
	{
		u32 size = sizeof( u32 ) *  b.dwWidth * b.dwHeight;
		w.w( b.pSurface, size );
	}
}
Пример #6
0
void FlushLog			()
{
    if (!no_log) {
        logCS.Enter			();
        IWriter *f			= FS.w_open(logFName);
        if (f) {
            for (u32 it=0; it<LogFile.size(); it++)	{
                LPCSTR		s	= *(LogFile[it]);
                f->w_string	(s?s:"");
            }
            FS.w_close		(f);
        }
        logCS.Leave			();
    }
}
Пример #7
0
bool SSceneSummary::ExportSummaryInfo(LPCSTR fn)
{
	IWriter* F 				= FS.w_open(fn); 
    if (F){
        string256				tmp;
        // textures
        u32 total_mem_usage		= 0; 
        F->w_string				("[TEXTURES]");
        F->w_string				("texture name=format,width,height,alpha,mem usage (Kb),area,pixel density,objects (name[count*area]),detail name,detail scale,bump name");
        for (u32 stt=sttFirst; stt<sttLast; stt++){   
            u32 cur_mem_usage	= 0; 
            float cur_area		= 0; 
            xr_string pref	= "[";
            pref				+= get_token_name(summary_texture_type_tokens,stt);
            pref				+= "]";
            F->w_string			(pref.c_str());
            for (TISetIt it=textures.begin(); it!=textures.end(); it++){
                STextureInfo* info= (STextureInfo*)(&(*it));
                if (info->type==stt){ 
                    cur_area	+= info->effective_area;
                    info->Export(F,cur_mem_usage);
                }
            }
            total_mem_usage		+= cur_mem_usage;
            sprintf				(tmp,"%s mem usage - %d Kb",pref.c_str(),cur_mem_usage);
            F->w_string			(tmp);
            sprintf				(tmp,"%s effective area - %3.2f m^2",pref.c_str(),cur_area);
            F->w_string			(tmp);
        }
        sprintf					(tmp,"Total mem usage - %d Kb",total_mem_usage);
        F->w_string				(tmp);
        // objects
        F->w_string				("");
        sprintf					(tmp,"[OBJECTS]");	F->w_string(tmp);
        for (OISetIt o_it=objects.begin(); o_it!=objects.end(); o_it++){
            SObjectInfo* info= (SObjectInfo*)(&(*o_it));
            info->Export		(F);
        }
        FS.w_close				(F);
        return 					true;
    }else{
        return 					false;
    }
}
Пример #8
0
bool	CInifile::save_as( LPCSTR new_fname )
{
	// save if needed
    if (new_fname&&new_fname[0]){
        xr_free			(fName);
        fName			= xr_strdup(new_fname);
    }
    R_ASSERT			(fName&&fName[0]);
    IWriter* F			= FS.w_open_ex(fName);
    if (F){
        string512		temp,val;
        for (RootIt r_it=DATA.begin(); r_it!=DATA.end(); ++r_it)
		{
            sprintf_s		(temp,sizeof(temp),"[%s]",*(*r_it)->Name);
            F->w_string	(temp);
            for (SectCIt s_it=(*r_it)->Data.begin(); s_it!=(*r_it)->Data.end(); ++s_it)
            {
                const Item&	I = *s_it;
                if (*I.first) {
                    if (*I.second) {
                        _decorate	(val,*I.second);
#ifdef DEBUG
                        if (*I.comment) {
                            // name, value and comment
                            sprintf_s	(temp,sizeof(temp),"%8s%-32s = %-32s ;%s"," ",*I.first,val,*I.comment);
                        } else
#endif
						{
                            // only name and value
                            sprintf_s	(temp,sizeof(temp),"%8s%-32s = %-32s"," ",*I.first,val);
                        }
                    } else {
#ifdef DEBUG
                        if (*I.comment) {
                            // name and comment
                            sprintf_s(temp,sizeof(temp),"%8s%-32s = ;%s"," ",*I.first,*I.comment);
                        } else
#endif
						{
                            // only name
                            sprintf_s(temp,sizeof(temp),"%8s%-32s = "," ",*I.first);
                        }
                    }
                } else {
                    // no name, so no value
#ifdef DEBUG
                    if (*I.comment)
						sprintf_s		(temp,sizeof(temp),"%8s;%s"," ",*I.comment);
                    else
#endif
						temp[0]		= 0;
                }
                _TrimRight			(temp);
                if (temp[0])		F->w_string	(temp);
            }
            F->w_string		(" ");
        }
        FS.w_close			(F);
	    return true;
    }
    return false;
}