Пример #1
0
void TDB_packer::_load_(const xr_string& fname)
{
    	lbIncludeFolders->Items->Clear		();
    	lbIncludeFiles->Items->Clear		();

     	CInifile ini						(fname.c_str());

        if(ini.section_exist("include_folders"))
        {
           CInifile::Sect S 		= ini.r_section("include_folders");
           CInifile::SectCIt it 		= S.Data.begin();
           CInifile::SectCIt it_e 	= S.Data.end();
           for( ;it!=it_e; ++it)
           {
           		WideString 					ws;
                ws 							= (*it).first.c_str();
               lbIncludeFolders->Items->Add	(ws);
           }
        }
        if(ini.section_exist("include_files"))
        {
           CInifile::Sect S 		= ini.r_section("include_files");
           CInifile::SectCIt it 	= S.Data.begin();
           CInifile::SectCIt it_e 	= S.Data.end();
           for( ;it!=it_e; ++it)
           {
           		WideString 					ws;
                ws 							= (*it).first.c_str();
               lbIncludeFiles->Items->Add	(ws);
           }
        }
        Caption	=	fname.c_str();
}
Пример #2
0
void CParticlesPlayer::LoadParticles(CKinematics* K)
{
    VERIFY				(K);

    m_Bones.clear();


    //считать список косточек и соответствующих
    //офсетов  куда можно вешать партиклы
    CInifile* ini		= K->LL_UserData();
    if(ini&&ini->section_exist("particle_bones")) {
        bone_mask		= 0;
        CInifile::Sect& data		= ini->r_section("particle_bones");
        for (CInifile::SectIt I=data.begin(); I!=data.end(); I++) {
            CInifile::Item& item	= *I;
            u16 index				= K->LL_BoneID(*item.first);
            R_ASSERT3(index != BI_NONE, "Particles bone not found", *item.first);
            Fvector					offs;
            sscanf					(*item.second,"%f,%f,%f",&offs.x,&offs.y,&offs.z);
            m_Bones.push_back		(SBoneInfo(index,offs));
            bone_mask				|= u64(1)<<u64(index);
        }
    }
    if(m_Bones.empty())
    {
        bone_mask			= u64(1)<<u64(0);
        m_Bones.push_back	(SBoneInfo(K->LL_GetBoneRoot(),Fvector().set(0,0,0)));
    }
}
Пример #3
0
void __fastcall TfrmBonePart::ebLoadFromClick(TObject *Sender)
{
//.
    xr_string temp_fn;
    if (EFS.GetOpenName	( _import_, temp_fn, false, NULL, 0))
    {
        ebClearClick	(Sender);
        CInifile ini	(temp_fn.c_str(), TRUE, TRUE, FALSE);
        string64		buff;
        for(int i=0; i<4; ++i)
        {
            sprintf	(buff,"part_%d",i);
            LPCSTR part_name = ini.r_string(buff, "partition_name");
            E[i]->Text = part_name;
            CInifile::Sect& S 	= ini.r_section(buff);
            CInifile::SectCIt it = S.Data.begin();
            CInifile::SectCIt e = S.Data.end();
            for (; it!=e; ++it)
            {
                if( 0!= stricmp(it->first.c_str(), "partition_name") )
                {
                    FHelper.AppendObject(T[i], it->first.c_str(), false, true);
                }
            }

        }
    }
}
Пример #4
0
void CMapListHelper::LoadMapInfo(LPCSTR map_cfg_fn, const xr_string& map_name, LPCSTR map_ver)
{
	CInifile	ini				(map_cfg_fn);

	shared_str _map_name		= map_name.substr(0,map_name.find('\\')).c_str();
	shared_str _map_ver			= map_ver;

	if(ini.section_exist("map_usage"))
	{
		if(ini.line_exist("map_usage","ver") && !map_ver)
			_map_ver				= ini.r_string("map_usage", "ver");

		CInifile::Sect S			= ini.r_section("map_usage");
		CInifile::SectCIt si		= S.Data.begin();
		CInifile::SectCIt si_e		= S.Data.end();
		for( ;si!=si_e; ++si)
		{
			const shared_str& game_type = (*si).first;
			
			if(game_type=="ver")		continue;

			SGameTypeMaps* M			= GetMapListInt(game_type);
			if(!M)
			{
				Msg						("--unknown game type-%s",game_type.c_str());
				m_storage.resize		(m_storage.size()+1);
				SGameTypeMaps&	Itm		= m_storage.back();
				Itm.m_game_type_name	= game_type;
				Itm.m_game_type_id		= ParseStringToGameType(game_type.c_str());
				M						= &m_storage.back();
			}
			
			SGameTypeMaps::SMapItm	Itm;
			Itm.map_name				= _map_name;
			Itm.map_ver					= _map_ver;
			
			if(M->m_map_names.end()!=std::find(M->m_map_names.begin(),M->m_map_names.end(),Itm))
			{
				Msg("! duplicate map found [%s] [%s]", _map_name.c_str(), _map_ver.c_str());
			}else
			{
#ifndef MASTER_GOLD
				Msg("added map [%s] [%s]", _map_name.c_str(), _map_ver.c_str());
#endif // #ifndef MASTER_GOLD
				M->m_map_names.push_back	(Itm);
			}
		}			
	}

}
Пример #5
0
bool IsFolderAccepted(CInifile& ltx, LPCSTR path, BOOL& recurse)
{
	// exclude folders
	if( ltx.section_exist("exclude_folders") )
	{
		CInifile::Sect& ef_sect	= ltx.r_section("exclude_folders");
		for (CInifile::SectCIt ef_it=ef_sect.Data.begin(); ef_it!=ef_sect.Data.end(); ef_it++){
			recurse	= CInifile::IsBOOL(ef_it->second.c_str());
			if (recurse)	{
				if (path==strstr(path,ef_it->first.c_str()))	return false;
			}else{
				if (0==xr_strcmp(path,ef_it->first.c_str()))	return false;
			}
		}
	}
	return true;
}
Пример #6
0
void CPurchaseList::process	(CInifile &ini_file, LPCSTR section, CInventoryOwner &owner)
{
	owner.sell_useless_items();

	m_deficits.clear		();

	const CGameObject		&game_object = smart_cast<const CGameObject &>(owner);
	CInifile::Sect			&S = ini_file.r_section(section);
	CInifile::SectCIt		I = S.Data.begin();
	CInifile::SectCIt		E = S.Data.end();
	for ( ; I != E; ++I) {
		VERIFY3				((*I).second.size(),"PurchaseList : cannot handle lines in section without values",section);

		string256			temp0, temp1;
		THROW3				(_GetItemCount(*(*I).second) == 2,"Invalid parameters in section",section);
		process				(
			game_object,
			(*I).first,
			atoi(_GetItem(*(*I).second,0,temp0)),
			(float)atof(_GetItem(*(*I).second,1,temp1))
		);
	}
}
Пример #7
0
void xrCompressor::ProcessLTX(CInifile& ltx)
{
	config_ltx	=&ltx;

	if (ltx.line_exist("options","exclude_exts"))
		_SequenceToList(exclude_exts, ltx.r_string("options","exclude_exts"));

	files_list				= xr_new< xr_vector<char*> >();
	folders_list			= xr_new< xr_vector<char*> >();

	if(ltx.section_exist("include_folders"))
	{
		CInifile::Sect& if_sect	= ltx.r_section("include_folders");

		for (CInifile::SectCIt if_it=if_sect.Data.begin(); if_it!=if_sect.Data.end(); ++if_it)
		{
			BOOL ifRecurse		= CInifile::IsBOOL(if_it->second.c_str());
			u32 folder_mask		= FS_ListFolders | (ifRecurse?0:FS_RootOnly);

			string_path path;
			LPCSTR _path		= 0==xr_strcmp(if_it->first.c_str(),".\\")?"":if_it->first.c_str();
			xr_strcpy			(path,_path);
			u32 path_len		= xr_strlen(path);
			if ((0!=path_len)&&(path[path_len-1]!='\\')) xr_strcat(path,"\\");

			Msg					("");
			Msg					("Processing folder: '%s'",path);
			BOOL efRecurse;
			BOOL val			= IsFolderAccepted(ltx,path,efRecurse);
			if (val || (!val&&!efRecurse))
			{ 
				if (val)		
					GatherFiles	(path);

				xr_vector<char*>*	i_fl_list	= FS.file_list_open	("$target_folder$",path,folder_mask);
				if (!i_fl_list)
				{
					Msg			("ERROR: Unable to open folder list:", path);
					continue;
				}

				xr_vector<char*>::iterator it	= i_fl_list->begin();
				xr_vector<char*>::iterator itE	= i_fl_list->end();
				for (;it!=itE;++it)
				{ 
					xr_string tmp_path	= xr_string(path)+xr_string(*it);
					bool val		= IsFolderAccepted(ltx,tmp_path.c_str(),efRecurse);
					if (val)
					{
						folders_list->push_back(xr_strdup(tmp_path.c_str()));
						Msg			("+F: %s",tmp_path.c_str());
						// collect files
						if (ifRecurse) 
							GatherFiles (tmp_path.c_str());
					}else
					{
						Msg			("-F: %s",tmp_path.c_str());
					}
				}
				FS.file_list_close	(i_fl_list);
			}else
			{
				Msg					("-F: %s",path);
			}
		}
	}//if(ltx.section_exist("include_folders"))
	
	if(ltx.section_exist("include_files"))
	{
		CInifile::Sect& if_sect	= ltx.r_section("include_files");
		for (CInifile::SectCIt if_it=if_sect.Data.begin(); if_it!=if_sect.Data.end(); ++if_it)
		{
		  files_list->push_back	(xr_strdup(if_it->first.c_str()));
		}	
	}

	PerformWork	();

	// free
	xr_vector<char*>::iterator it	= files_list->begin();
	xr_vector<char*>::iterator itE	= files_list->end();
	for (;it!=itE;++it) 
		xr_free(*it);
	xr_delete(files_list);

	it				= folders_list->begin();
	itE				= folders_list->end();
	for (;it!=itE;++it) 
		xr_free(*it);
	xr_delete(folders_list);

	exclude_exts.clear_and_free();
}
Пример #8
0
void ProcessLTX(LPCSTR tgt_name, LPCSTR params, BOOL bFast)
{
	xr_string		ltx_name;
	LPCSTR ltx_nm	= strstr(params,".ltx");				VERIFY(ltx_nm!=0);
	string_path		ltx_fn;
	string_path		tmp;
	strncpy			(tmp,params,ltx_nm-params); tmp[ltx_nm-params]=0;
	_Trim			(tmp);
	strcat			(tmp,".ltx");
	strcpy			(ltx_fn,tmp);

	// append ltx path (if exist)
	string_path		fn,dr,di;
	_splitpath		(ltx_fn,dr,di,0,0);
	strconcat		(sizeof(fn),fn,dr,di);  
	if (0!=fn[0])
		FS.append_path	("ltx_path",fn,0,false);
	
	if (!FS.exist(ltx_fn)&&!FS.exist(ltx_fn,"$app_root$",tmp)) 
		Debug.fatal	(DEBUG_INFO,"ERROR: Can't find ltx file: '%s'",ltx_fn);

	CInifile ltx	(ltx_fn);
	printf			("Processing LTX...\n");

	BOOL make_pack	= ltx.line_exist("options","make_pack") ? ltx.r_bool("options","make_pack") : true;
	LPCSTR copy_path= ltx.line_exist("options","copy_path") ? ltx.r_string("options","copy_path") : 0;
	if (ltx.line_exist("options","exclude_exts"))
		_SequenceToList(exclude_exts,ltx.r_string("options","exclude_exts"));

	xr_vector<char*> list;
	xr_vector<char*> fl_list;
	if(ltx.section_exist("include_folders"))
	{
	CInifile::Sect& if_sect	= ltx.r_section("include_folders");
	for (CInifile::SectCIt if_it=if_sect.Data.begin(); if_it!=if_sect.Data.end(); if_it++)
	{
		BOOL ifRecurse		= CInifile::IsBOOL(if_it->second.c_str());
		u32 folder_mask		= FS_ListFolders | (ifRecurse?0:FS_RootOnly);

		string_path path;
		LPCSTR _path		= 0==xr_strcmp(if_it->first.c_str(),".\\")?"":if_it->first.c_str();
		strcpy				(path,_path);
		u32 path_len		= xr_strlen(path);
		if ((0!=path_len)&&(path[path_len-1]!='\\')) strcat(path,"\\");

		Log					("");
		OUT_LOG				("Processing folder: '%s'",path);
		BOOL efRecurse;
		BOOL val			= IsFolderAccepted(ltx,path,efRecurse);
		if (val || (!val&&!efRecurse))
		{ 
			if (val)		ProcessFolder	(list,path);

			xr_vector<char*>*	i_fl_list	= FS.file_list_open	("$target_folder$",path,folder_mask);
			if (!i_fl_list)
			{
				Log			("ERROR: Unable to open folder list:", path);
				continue;
			}

			xr_vector<char*>::iterator it	= i_fl_list->begin();
			xr_vector<char*>::iterator itE	= i_fl_list->end();
			for (;it!=itE;++it){ 
				xr_string tmp_path	= xr_string(path)+xr_string(*it);
				bool val		= IsFolderAccepted(ltx,tmp_path.c_str(),efRecurse);
				if (val)
				{
					fl_list.push_back(xr_strdup(tmp_path.c_str()));
					Msg			("+F: %s",tmp_path.c_str());
					// collect files
					if (ifRecurse) 
						ProcessFolder (list,tmp_path.c_str());
				}else
				{
					Msg			("-F: %s",tmp_path.c_str());
				}
			}
			FS.file_list_close	(i_fl_list);
		}else
		{
			Msg					("-F: %s",path);
		}
	}
}//if(ltx.section_exist("include_folders"))
	// compress
	{
		if(ltx.section_exist("include_files"))
		{
		CInifile::Sect& if_sect	= ltx.r_section("include_files");
		for (CInifile::SectCIt if_it=if_sect.Data.begin(); if_it!=if_sect.Data.end(); if_it++)
			{
				  list.push_back	(xr_strdup(if_it->first.c_str()));
			}	
		}
	
	}
	CompressList	(tgt_name,&list,&fl_list,bFast,make_pack,copy_path);

	// free
	xr_vector<char*>::iterator it	= list.begin();
	xr_vector<char*>::iterator itE	= list.end();
	for (;it!=itE;++it) xr_free(*it);
	it				= fl_list.begin();
	itE				= fl_list.end();
	for (;it!=itE;++it) xr_free(*it);

	exclude_exts.clear_and_free();
}
Пример #9
0
void CCar::Init()
{

	CPHCollisionDamageReceiver::Init();

	//get reference wheel radius
	IKinematics* pKinematics=smart_cast<IKinematics*>(Visual());
	CInifile* ini = pKinematics->LL_UserData();
	R_ASSERT2(ini,"Car has no description !!! See ActorEditor Object - UserData");
	///SWheel& ref_wheel=m_wheels_map.find(pKinematics->LL_BoneID(ini->r_string("car_definition","reference_wheel")))->second;

	if(ini->section_exist("air_resistance"))
	{
		PPhysicsShell()->SetAirResistance(default_k_l*ini->r_float("air_resistance","linear_factor"),default_k_w*ini->r_float("air_resistance","angular_factor"));
	}
	if(ini->line_exist("car_definition","steer"))
	{
		
		
		m_bone_steer=pKinematics->LL_BoneID(ini->r_string("car_definition","steer"));
		VERIFY2(fsimilar(DET(pKinematics->LL_GetTransform(m_bone_steer)),1.f,EPS_L),"BBADD MTX");
		pKinematics->LL_GetBoneInstance(m_bone_steer).set_callback(bctPhysics,cb_Steer,this);
	}
	m_steer_angle=0.f;
	//ref_wheel.Init();
	m_ref_radius=ini->r_float("car_definition","reference_radius");//ref_wheel.radius;
	b_exploded						=false;
	b_engine_on						=false;
	b_clutch						=false;
	b_starting						=false;
	b_stalling						=false;
	b_transmission_switching		=false;
	m_root_transform.set(bone_map.find(pKinematics->LL_GetBoneRoot())->second.element->mXFORM);
	m_current_transmission_num=0;
	m_pPhysicsShell->set_DynamicScales(1.f,1.f);
	CDamagableItem::Init(GetfHealth(),3);
	float l_time_to_explosion=READ_IF_EXISTS(ini,r_float,"car_definition","time_to_explosion",120.f);
	CDelayedActionFuse::Initialize(l_time_to_explosion,CDamagableItem::DamageLevelToHealth(2));
	{
		xr_map<u16,SWheel>::iterator i,e;
		i=m_wheels_map.begin();
		e=m_wheels_map.end();
		for(;i!=e;++i)
		{
			i->second.Init();
			i->second.CDamagableHealthItem::Init(100.f,2);
		}
	}

	{
		xr_vector<SWheelDrive>::iterator i,e;
		i=m_driving_wheels.begin();
		e=m_driving_wheels.end();
		for(;i!=e;++i)
			i->Init();
	}

	{
		xr_vector<SWheelBreak>::iterator i,e;
		i=m_breaking_wheels.begin();
		e=m_breaking_wheels.end();
		for(;i!=e;++i)
			i->Init();
	}

	{
		xr_vector<SWheelSteer>::iterator i,e;
		i=m_steering_wheels.begin();
		e=m_steering_wheels.end();
		for(;i!=e;++i)
			i->Init();
	}

	{
		xr_vector<SExhaust>::iterator i,e;
		i=m_exhausts.begin();
		e=m_exhausts.end();
		for(;i!=e;++i)
			i->Init();
	}

	{
		xr_map<u16,SDoor>::iterator i,e;
		i=m_doors.begin();
		e=m_doors.end();
		for(;i!=e;++i)
		{
			i->second.Init();
			i->second.CDamagableHealthItem::Init(100,1);
		}
			
	}

	if(ini->section_exist("damage_items"))
	{
		CInifile::Sect& data		= ini->r_section("damage_items");
		for (CInifile::SectCIt		I=data.Data.begin(); I!=data.Data.end(); I++){
			const CInifile::Item& item	= *I;
			u16 index				= pKinematics->LL_BoneID(*item.first); 
			R_ASSERT3(index != BI_NONE, "Wrong bone name", *item.first);
			xr_map   <u16,SWheel>::iterator i=m_wheels_map.find(index);
			
			if(i!=m_wheels_map.end())
					i->second.CDamagableHealthItem::Init(float(atof(*item.second)),2);
			else 
			{
				xr_map   <u16,SDoor>::iterator i=m_doors.find(index);
				R_ASSERT3(i!=m_doors.end(),"only wheel and doors bones allowed for damage defs",*item.first);
				i->second.CDamagableHealthItem::Init(float(atof(*item.second)),1);
			}

		}
	}
	

	if(ini->section_exist("immunities"))
	{
		LoadImmunities("immunities",ini);
	}

	CDamageManager::reload("car_definition","damage",ini);
	
	HandBreak();
	Transmission(1);

}