示例#1
0
void CBulletManager::Load		()
{
	m_fTracerWidth			= pSettings->r_float(BULLET_MANAGER_SECTION, "tracer_width");
	m_fTracerLengthMax		= pSettings->r_float(BULLET_MANAGER_SECTION, "tracer_length_max");
	m_fTracerLengthMin		= pSettings->r_float(BULLET_MANAGER_SECTION, "tracer_length_min");

	m_fGravityConst			= pSettings->r_float(BULLET_MANAGER_SECTION, "gravity_const");
	m_fAirResistanceK		= pSettings->r_float(BULLET_MANAGER_SECTION, "air_resistance_k");

	m_dwStepTime			= pSettings->r_u32	(BULLET_MANAGER_SECTION, "time_step");
	m_fMinBulletSpeed		= pSettings->r_float(BULLET_MANAGER_SECTION, "min_bullet_speed");
	m_fCollisionEnergyMin	= pSettings->r_float(BULLET_MANAGER_SECTION, "collision_energy_min");
	m_fCollisionEnergyMax	= pSettings->r_float(BULLET_MANAGER_SECTION, "collision_energy_max");

	m_fHPMaxDist			= pSettings->r_float(BULLET_MANAGER_SECTION, "hit_probability_max_dist");

	LPCSTR whine_sounds		= pSettings->r_string(BULLET_MANAGER_SECTION, "whine_sounds");
	int cnt					= _GetItemCount(whine_sounds);
	xr_string tmp;
	for (int k=0; k<cnt; ++k){
		m_WhineSounds.push_back	(ref_sound());
		m_WhineSounds.back().create(_GetItem(whine_sounds,k,tmp),st_Effect,sg_SourceType);
	}

	LPCSTR explode_particles= pSettings->r_string(BULLET_MANAGER_SECTION, "explode_particles");
	cnt						= _GetItemCount(explode_particles);
	for (int k=0; k<cnt; ++k)
		m_ExplodeParticles.push_back	(_GetItem(explode_particles,k,tmp));
}
示例#2
0
void player_hud_motion_container::load(IKinematicsAnimated* model, const shared_str& sect)
{
	CInifile::Sect& _sect		= pSettings->r_section(sect);
	CInifile::SectCIt _b		= _sect.Data.begin();
	CInifile::SectCIt _e		= _sect.Data.end();
	player_hud_motion* pm		= NULL;
	
	string512					buff;
	MotionID					motion_ID;

	for(;_b!=_e;++_b)
	{
		if(strstr(_b->first.c_str(), "anm_")==_b->first.c_str())
		{
			const shared_str& anm	= _b->second;
			m_anims.resize			(m_anims.size()+1);
			pm						= &m_anims.back();
			//base and alias name
			pm->m_alias_name		= _b->first;
			
			if(_GetItemCount(anm.c_str())==1)
			{
				pm->m_base_name			= anm;
				pm->m_additional_name	= anm;
			}else
			{
				R_ASSERT2(_GetItemCount(anm.c_str())==2, anm.c_str());
				string512				str_item;
				_GetItem(anm.c_str(),0,str_item);
				pm->m_base_name			= str_item;

				_GetItem(anm.c_str(),1,str_item);
				pm->m_additional_name	= str_item;
			}

			//and load all motions for it

			for(u32 i=0; i<=8; ++i)
			{
				if(i==0)
					xr_strcpy				(buff,pm->m_base_name.c_str());		
				else
					xr_sprintf				(buff,"%s%d",pm->m_base_name.c_str(),i);		

				motion_ID				= model->ID_Cycle_Safe(buff);
				if(motion_ID.valid())
				{
					pm->m_animations.resize			(pm->m_animations.size()+1);
					pm->m_animations.back().mid		= motion_ID;
					pm->m_animations.back().name	= buff;
#ifdef DEBUG
//					Msg(" alias=[%s] base=[%s] name=[%s]",pm->m_alias_name.c_str(), pm->m_base_name.c_str(), buff);
#endif // #ifdef DEBUG
				}
			}
			R_ASSERT2(pm->m_animations.size(),make_string("motion not found [%s]", pm->m_base_name.c_str()).c_str());
		}
	}
}
示例#3
0
void CShootingObject::LoadFireParams( LPCSTR section )
{
	string32	buffer;
	shared_str	s_sHitPower;
	shared_str	s_sHitPowerCritical;

	//базовая дисперсия оружия
	fireDispersionBase	= deg2rad( pSettings->r_float	(section,"fire_dispersion_base"	) );

	//сила выстрела и его мощьность
	s_sHitPower			= pSettings->r_string_wb(section, "hit_power" );//читаем строку силы хита пули оружия
	s_sHitPowerCritical	= pSettings->r_string_wb(section, "hit_power_critical" );
	fvHitPower[egdMaster]			= (float)atof(_GetItem(*s_sHitPower,0,buffer));//первый параметр - это хит для уровня игры мастер
	fvHitPowerCritical[egdMaster]	= (float)atof(_GetItem(*s_sHitPowerCritical,0,buffer));//первый параметр - это хит для уровня игры мастер

	fvHitPower[egdNovice] = fvHitPower[egdStalker] = fvHitPower[egdVeteran] = fvHitPower[egdMaster];//изначально параметры для других уровней сложности такие же
	fvHitPowerCritical[egdNovice] = fvHitPowerCritical[egdStalker] = fvHitPowerCritical[egdVeteran] = fvHitPowerCritical[egdMaster];//изначально параметры для других уровней сложности такие же

	int num_game_diff_param=_GetItemCount(*s_sHitPower);//узнаём колличество параметров для хитов
	if (num_game_diff_param>1)//если задан второй параметр хита
	{
		fvHitPower[egdVeteran]	= (float)atof(_GetItem(*s_sHitPower,1,buffer));//то вычитываем его для уровня ветерана
	}
	if (num_game_diff_param>2)//если задан третий параметр хита
	{
		fvHitPower[egdStalker]	= (float)atof(_GetItem(*s_sHitPower,2,buffer));//то вычитываем его для уровня сталкера
	}
	if (num_game_diff_param>3)//если задан четвёртый параметр хита
	{
		fvHitPower[egdNovice]	= (float)atof(_GetItem(*s_sHitPower,3,buffer));//то вычитываем его для уровня новичка
	}

	num_game_diff_param=_GetItemCount(*s_sHitPowerCritical);//узнаём колличество параметров
	if (num_game_diff_param>1)//если задан второй параметр хита
	{
		fvHitPowerCritical[egdVeteran]	= (float)atof(_GetItem(*s_sHitPowerCritical,1,buffer));//то вычитываем его для уровня ветерана
	}
	if (num_game_diff_param>2)//если задан третий параметр хита
	{
		fvHitPowerCritical[egdStalker]	= (float)atof(_GetItem(*s_sHitPowerCritical,2,buffer));//то вычитываем его для уровня сталкера
	}
	if (num_game_diff_param>3)//если задан четвёртый параметр хита
	{
		fvHitPowerCritical[egdNovice]	= (float)atof(_GetItem(*s_sHitPowerCritical,3,buffer));//то вычитываем его для уровня новичка
	}

	fHitImpulse			= pSettings->r_float	(section, "hit_impulse" );
	//максимальное расстояние полета пули
	fireDistance		= pSettings->r_float	(section, "fire_distance" );
	//начальная скорость пули
	m_fStartBulletSpeed = pSettings->r_float	(section, "bullet_speed" );
	m_bUseAimBullet		= pSettings->r_bool		(section, "use_aim_bullet" );
	if (m_bUseAimBullet)
	{
		m_fTimeToAim		= pSettings->r_float	(section, "time_to_aim" );
	}
}
示例#4
0
void CWeaponKnife::LoadFireParams(LPCSTR section)
{
	inherited::LoadFireParams(section);

	string32			buffer;
	shared_str			s_sHitPower_2;
	shared_str			s_sHitPowerCritical_2;

	fvHitPower_1		= fvHitPower;
	fvHitPowerCritical_1= fvHitPowerCritical;
	fHitImpulse_1		= fHitImpulse;
	m_eHitType_1		= ALife::g_tfString2HitType(pSettings->r_string(section, "hit_type"));

	//fHitPower_2			= pSettings->r_float	(section,strconcat(full_name, prefix, "hit_power_2"));
	s_sHitPower_2			= pSettings->r_string_wb	(section, "hit_power_2" );
	s_sHitPowerCritical_2	= pSettings->r_string_wb	(section, "hit_power_critical_2" );
	
	fvHitPower_2[egdMaster]			= (float)atof(_GetItem(*s_sHitPower_2,0,buffer));//первый параметр - это хит для уровня игры мастер
	fvHitPowerCritical_2[egdMaster]	= (float)atof(_GetItem(*s_sHitPowerCritical_2,0,buffer));//первый параметр - это хит для уровня игры мастер

	fvHitPower_2[egdNovice] = fvHitPower_2[egdStalker] = fvHitPower_2[egdVeteran] = fvHitPower_2[egdMaster];//изначально параметры для других уровней сложности такие же
	fvHitPowerCritical_2[egdNovice] = fvHitPowerCritical_2[egdStalker] = fvHitPowerCritical_2[egdVeteran] = fvHitPowerCritical_2[egdMaster];//изначально параметры для других уровней сложности такие же

	int num_game_diff_param=_GetItemCount(*s_sHitPower_2);//узнаём колличество параметров для хитов
	if (num_game_diff_param>1)//если задан второй параметр хита
	{
		fvHitPower_2[egdVeteran] = (float)atof(_GetItem(*s_sHitPower_2,1,buffer));//то вычитываем его для уровня ветерана
	}
	if (num_game_diff_param>2)//если задан третий параметр хита
	{
		fvHitPower_2[egdStalker] = (float)atof(_GetItem(*s_sHitPower_2,2,buffer));//то вычитываем его для уровня сталкера
	}
	if (num_game_diff_param>3)//если задан четвёртый параметр хита
	{
		fvHitPower_2[egdNovice]  = (float)atof(_GetItem(*s_sHitPower_2,3,buffer));//то вычитываем его для уровня новичка
	}

	num_game_diff_param=_GetItemCount(*s_sHitPowerCritical_2);//узнаём колличество параметров
	if (num_game_diff_param>1)//если задан второй параметр хита
	{
		fvHitPowerCritical_2[egdVeteran] = (float)atof(_GetItem(*s_sHitPowerCritical_2,1,buffer));//то вычитываем его для уровня ветерана
	}
	if (num_game_diff_param>2)//если задан третий параметр хита
	{
		fvHitPowerCritical_2[egdStalker] = (float)atof(_GetItem(*s_sHitPowerCritical_2,2,buffer));//то вычитываем его для уровня сталкера
	}
	if (num_game_diff_param>3)//если задан четвёртый параметр хита
	{
		fvHitPowerCritical_2[egdNovice]  = (float)atof(_GetItem(*s_sHitPowerCritical_2,3,buffer));//то вычитываем его для уровня новичка
	}

	fHitImpulse_2		= pSettings->r_float	(section, "hit_impulse_2" );
	m_eHitType_2		= ALife::g_tfString2HitType(pSettings->r_string(section, "hit_type_2"));
}
示例#5
0
/*
void CreateMarks(ShaderVec& lst, LPCSTR buf)
{
	string256	tmp;
	int cnt		=_GetItemCount(buf);	R_ASSERT(cnt<=GAMEMTL_SUBITEM_COUNT);
	ref_shader	s;
	for (int k=0; k<cnt; ++k)
	{
		s.create		("effects\\wallmark",_GetItem(buf,k,tmp));
		lst.push_back	(s);
	}
}
*/
void CreateMarks(IWallMarkArray *pMarks, LPCSTR buf)
{
	string256	tmp;
	int cnt		=_GetItemCount(buf);	R_ASSERT(cnt<=GAMEMTL_SUBITEM_COUNT);
	for (int k=0; k<cnt; ++k)
		pMarks->AppendMark(_GetItem(buf,k,tmp));
}
示例#6
0
void CreatePSs(PSVec& lst, LPCSTR buf)
{
	string256 tmp;
	int cnt=_GetItemCount(buf);	R_ASSERT(cnt<=GAMEMTL_SUBITEM_COUNT);
	for (int k=0; k<cnt; ++k)
		lst.push_back	(_GetItem(buf,k,tmp));
}
示例#7
0
TElTreeItem* CFolderHelper::FindObject(TElTree* tv, AnsiString full_name, TElTreeItem** last_valid_node, int* last_valid_idx)
{
	int cnt = _GetItemCount(full_name.c_str(),'\\'); cnt--;
    if (cnt<0) return 0;

    // find folder item
    int itm = 0;
    AnsiString fld;
    TElTreeItem* node = 0;
    TElTreeItem* last_node = 0;
    if (cnt){
        do{
            _GetItem(full_name.c_str(),itm++,fld,'\\',"",false);
            last_node = node;
            node = FindItemInFolder(TYPE_FOLDER,tv,node,fld);
        }while (node&&(itm<cnt));
    }

    if(cnt&&!node){
		if (last_valid_node) *last_valid_node=last_node;
        if (last_valid_idx) *last_valid_idx=--itm;
    }else{
    	// find object item if needed
        AnsiString obj;
        _GetItem(full_name.c_str(),cnt,obj,'\\',"",false);
        last_node = node;
        node = FindItemInFolder(TYPE_OBJECT,tv,node,obj);
        if (!node){
            if (last_valid_node) *last_valid_node=last_node;
            if (last_valid_idx) *last_valid_idx=itm;
        }
    }

    return node;
}
示例#8
0
void CUIGameCTA::LoadTeamDefaultPresetItems	(const shared_str& caSection)
{
    if (!pSettings->line_exist(caSection, "default_items")) return;
    if (!m_pCurBuyMenu) return;

    PlayerDefItems.clear();

    string256			ItemName;
    string4096			DefItems;
    // Читаем данные этого поля
    xr_strcpy(DefItems, pSettings->r_string(caSection, "default_items"));
    u32 count	= _GetItemCount(DefItems);
    // теперь для каждое имя оружия, разделенные запятыми, заносим в массив
    for (u32 i = 0; i < count; ++i)
    {
        _GetItem(DefItems, i, ItemName);

        u8 SlotID, ItemID;
        m_pCurBuyMenu->GetWeaponIndexByName(ItemName, SlotID, ItemID);
        if (SlotID == 0xff || ItemID == 0xff) continue;
//		s16 ID = GetBuyMenuItemIndex(SlotID, ItemID);
        s16 ID = GetBuyMenuItemIndex(0, ItemID);
        PlayerDefItems.push_back(ID);
    };
};
示例#9
0
template <class T> IC void CCar::fill_wheel_vector(LPCSTR S,xr_vector<T>& type_wheels)
{
	IKinematics* pKinematics	=smart_cast<IKinematics*>(Visual());
	string64					S1;
	int count =					_GetItemCount(S);
	for (int i=0 ;i<count; ++i) 
	{
		_GetItem					(S,i,S1);

		u16 bone_id	=				pKinematics->LL_BoneID(S1);

		type_wheels.push_back		(T());
		T& twheel				= type_wheels.back();


		BONE_P_PAIR_IT J		= bone_map.find(bone_id);
		if (J == bone_map.end()) 
		{
			bone_map.insert(mk_pair(bone_id,physicsBone()));


			SWheel& wheel			=	(m_wheels_map.insert(mk_pair(bone_id,SWheel(this)))).first->second;
			wheel.bone_id			=	bone_id;
			twheel.pwheel			=	&wheel;
			wheel						.Load(S1);
			twheel						.Load(S1);
		}
		else
		{
			twheel.pwheel			=	&(m_wheels_map.find(bone_id))->second;
			twheel						.Load(S1);
		}
	}
}
示例#10
0
void CScriptEngine::load_common_scripts()
{
#ifdef DBG_DISABLE_SCRIPTS
	return;
#endif
	string_path		S;
	FS.update_path	(S,"$game_config$","script.ltx");
	CInifile		*l_tpIniFile = new CInifile(S);
	R_ASSERT		(l_tpIniFile);
	if (!l_tpIniFile->section_exist("common")) {
		xr_delete			(l_tpIniFile);
		return;
	}

	if (l_tpIniFile->line_exist("common","script")) {
		LPCSTR			caScriptString = l_tpIniFile->r_string("common","script");
		u32				n = _GetItemCount(caScriptString);
		string256		I;
		for (u32 i=0; i<n; ++i) {
			process_file(_GetItem(caScriptString,i,I));
			if (object("_G",strcat(I,"_initialize"),LUA_TFUNCTION)) {
//				lua_dostring			(lua(),strcat(I,"()"));
				luabind::functor<void>	f;
				R_ASSERT				(functor(I,f));
				f						();
			}
		}
	}

	xr_delete			(l_tpIniFile);
}
示例#11
0
bool CWeapon::install_upgrade_ammo_class( LPCSTR section, bool test )
{
	LPCSTR str;

	bool result = process_if_exists( section, "ammo_mag_size", &CInifile::r_s32, iMagazineSize, test );

	//	ammo_class = ammo_5.45x39_fmj, ammo_5.45x39_ap  // name of the ltx-section of used ammo
	bool result2 = process_if_exists_set( section, "ammo_class", &CInifile::r_string, str, test );
	if ( result2 && !test )
	{
		m_ammoTypes.clear();
		string128 ammoItem;
		int count = _GetItemCount( str );
		for ( int i = 0; i < count; ++i )
		{
			_GetItem( str, i, ammoItem );
			m_ammoTypes.push_back( ammoItem );
		}
		m_ammoName = pSettings->r_string( *m_ammoTypes[0], "inv_name_short" );
		m_ammoType = 0;
	}
	result |= result2;

	return result;
}
示例#12
0
void CDamageManager::load_section(LPCSTR section,CInifile* ini)
{
	string32				buffer;
	CKinematics				*kinematics = smart_cast<CKinematics*>(m_object->Visual());
	CInifile::Sect			&damages = ini->r_section(section);
	for (CInifile::SectCIt i=damages.Data.begin(); damages.Data.end() != i; ++i) {
		if (xr_strcmp(*(*i).first,"default")) { // read all except default line
			VERIFY					(m_object);
			int						bone = kinematics->LL_BoneID(i->first);
			R_ASSERT2				(BI_NONE != bone, *(*i).first);
			CBoneInstance			&bone_instance = kinematics->LL_GetBoneInstance(u16(bone));
			bone_instance.set_param	(0,(float)atof(_GetItem(*(*i).second,0,buffer)));
			bone_instance.set_param	(1,(float)atoi(_GetItem(*(*i).second,1,buffer)));
			bone_instance.set_param	(2,(float)atof(_GetItem(*(*i).second,2,buffer)));
			if (_GetItemCount(*(*i).second) < 4)
			{
				bone_instance.set_param	(3,(float)atof(_GetItem(*(*i).second,0,buffer)));
			}
			else
			{
				bone_instance.set_param	(3,(float)atof(_GetItem(*(*i).second,3,buffer)));
			}
			if(0==bone && (fis_zero(bone_instance.get_param(0)) || fis_zero(bone_instance.get_param(2)) ) ){
				string256 error_str;
				sprintf_s(error_str,"hit_scale and wound_scale for root bone cannot be zero. see section [%s]",section);
				R_ASSERT2(0,error_str);
			}
		}
	}
}
示例#13
0
//-----------------------------------------------------------------------------
// Environment ambient
//-----------------------------------------------------------------------------
void CEnvAmbient::SSndChannel::load(CInifile& config, LPCSTR sect)
{
    m_load_section = sect;

    m_sound_dist.x = config.r_float(m_load_section, "min_distance");
    m_sound_dist.y = config.r_float(m_load_section, "max_distance");
    m_sound_period.x = config.r_s32(m_load_section, "period0");
    m_sound_period.y = config.r_s32(m_load_section, "period1");
    m_sound_period.z = config.r_s32(m_load_section, "period2");
    m_sound_period.w = config.r_s32(m_load_section, "period3");

    // m_sound_period = config.r_ivector4(sect,"sound_period");
    R_ASSERT(m_sound_period.x <= m_sound_period.y && m_sound_period.z <= m_sound_period.w);
    // m_sound_period.mul (1000);// now in ms
    // m_sound_dist = config.r_fvector2(sect,"sound_dist");
    R_ASSERT2(m_sound_dist.y > m_sound_dist.x, sect);

    LPCSTR snds = config.r_string(sect, "sounds");
    u32 cnt = _GetItemCount(snds);
    string_path tmp;
    R_ASSERT3(cnt, "sounds empty", sect);

    m_sounds.resize(cnt);

    for (u32 k = 0; k < cnt; ++k)
    {
        _GetItem(snds, k, tmp);
        m_sounds[k].create(tmp, st_Effect, sg_SourceType);
    }
}
示例#14
0
void Property::construct( shared_str const& property_id, Manager& manager_r )
{
	m_id._set( property_id );
	VERIFY2( pSettings->section_exist( m_id ), make_string( "Section of upgrade property [%s] does not exist!", m_id.c_str() ) );

	m_name = CStringTable().translate( pSettings->r_string( id(), "name" ) );
	m_icon._set( pSettings->r_string(id(), "icon") );

	// functor
	LPCSTR functor_str = pSettings->r_string( id(), "functor" );
	m_desc.parameter   = "";
	m_desc.parameter2 = id_str();
	R_ASSERT2(
		ai().script_engine().functor( functor_str, m_desc.functr ),
		make_string( "Failed to get upgrade property functor in section[%s], functor[%s]",
		id_str(), functor_str
		)
	);
	m_desc(); // test

	LPCSTR funct_params_str = pSettings->r_string( id(), "params" );
	PSTR	temp = (PSTR)_alloca( (xr_strlen(funct_params_str) + 1) * sizeof(char) );
	for ( int n = _GetItemCount( funct_params_str ), i = 0; i < n; ++i )
	{
		LPCSTR i_param = ( _GetItem( funct_params_str, i, temp ) );
		m_functor_params.push_back( i_param );
	}

}
示例#15
0
void TUI::OnReceiveMail(LPCSTR msg)
{
	int cnt = _GetItemCount(msg,' ');
    if (cnt){
        AnsiString M=AnsiString(msg).LowerCase();
        AnsiString p[2];
		_GetItem(msg,0,p[0],' ',"",false);
        if (cnt>1) _GetItems(msg,1,cnt,p[1],' ');
        if (p[0]=="exit"){
        	ELog.DlgMsg(mtInformation,"'%s EDITOR': Critical update!",AnsiString(UI->EditorName()).UpperCase().c_str());
            while (1){
            	if (ExecCommand(COMMAND_EXIT)){
	                ExecCommand(COMMAND_QUIT);
                    break;
                }
            }
        }else if (p[0]=="quit"){
        	ELog.Msg(mtInformation,"'%s EDITOR': Super critical update!",AnsiString(UI->EditorName()).UpperCase().c_str());
        	ExecCommand(COMMAND_SAVE_BACKUP);
        	ExecCommand(COMMAND_QUIT);
        }else if (p[0]=="info"){
        	if (cnt>1) ELog.DlgMsg(mtInformation,"'%s EDITOR': %s",AnsiString(UI->EditorName()).UpperCase().c_str(),p[1].c_str());
        }else if (p[0]=="error"){
        	if (cnt>1) ELog.DlgMsg(mtError,"'%s EDITOR': %s",AnsiString(UI->EditorName()).UpperCase().c_str(),p[1].c_str());
        }
    }
}
示例#16
0
void CScriptEngine::register_script_classes()
{
#ifdef DBG_DISABLE_SCRIPTS
    return;
#endif
    string_path					S;
    FS.update_path(S, "$game_config$", "script.ltx");
    CInifile					*l_tpIniFile = xr_new<CInifile>(S);
    R_ASSERT(l_tpIniFile);

    if (!l_tpIniFile->section_exist("common"))
    {
        xr_delete(l_tpIniFile);
        return;
    }

    m_class_registrators = READ_IF_EXISTS(l_tpIniFile, r_string, "common", "class_registrators", "");
    xr_delete(l_tpIniFile);

    u32							n = _GetItemCount(*m_class_registrators);
    string256					I;
    for (u32 i = 0; i < n; ++i)
    {
        _GetItem(*m_class_registrators, i, I);
        luabind::functor<void>	result;
        if (!functor(I, result))
        {
            script_log(eLuaMessageTypeError, "Cannot load class registrator %s!", I);
            continue;
        }
        result(const_cast<CObjectFactory*>(&object_factory()));
    }
}
示例#17
0
void CRestrictions::AddRestriction4rank(u32 rank, const shared_str& lst)
{// private
	VERIFY					(m_bInited);

	rank_rest_vec& rest		= m_restrictions[rank];
	
	if(rank!=_RANK_COUNT)
	{
		u32 src_idx			= (rank==0)?_RANK_COUNT:(rank-1);
		rest				= m_restrictions[ src_idx ];
	}

	string256				singleItem;
	u32 count				= _GetItemCount(lst.c_str());
	for (u32 j = 0; j < count; ++j)
	{
		_GetItem			(lst.c_str(), j, singleItem);
		RESTR r				= GetRestr(singleItem);
		restr_item* ritem	= find_restr_item_internal(rank, r.name);
		VERIFY2				((ritem || rank==_RANK_COUNT), singleItem);
		if(!ritem)
			rest.push_back	(mk_pair(r.name, r.n));
		else
			ritem->second	= r.n;
	}
}
示例#18
0
TElTreeItem* CFolderHelper::FindItem(TElTree* tv, AnsiString full_name, TElTreeItem** last_valid_node, int* last_valid_idx) 
{
    if (last_valid_node) *last_valid_node=0;
    if (last_valid_idx) *last_valid_idx=-1;
	if (!full_name.IsEmpty()){
        int cnt = _GetItemCount(full_name.c_str(),'\\');
        if (cnt<=0) return 0;

        // find folder item
        int itm = 0;
        AnsiString fld;
        TElTreeItem* node = 0;
        TElTreeItem* last_node = 0;
        do{
            _GetItem(full_name.c_str(),itm++,fld,'\\',"",false);
            last_node = node;
            node = FindItemInFolder(tv,node,fld);
        }while (node&&(itm<cnt));

        if(!node){
            if (last_valid_node) *last_valid_node=last_node;
            if (last_valid_idx) *last_valid_idx=--itm;
        }else{
            if (last_valid_node) *last_valid_node=node;
            if (last_valid_idx) *last_valid_idx=--itm;
        }
        return node;
    }else{
    	return 0;
    }
}
示例#19
0
void CSpaceRestriction::merge_free_in_retrictions	()
{
	START_PROFILE("Restricted Object/Merge Free In");
	string256								temp;
	for (u32 i=0, n=_GetItemCount(*m_in_restrictions); i<n ;++i) {
		SpaceRestrictionHolder::CBaseRestrictionPtr bridge = m_space_restriction_manager->restriction(shared_str(_GetItem(*m_in_restrictions,i,temp)));
		m_free_in_restrictions.push_back	(CFreeInRestriction(bridge,false));
	}

	RESTRICTIONS					temp_restrictions;
	for (bool ok = false; !ok; ) {
		ok							= true;
		temp_restrictions.clear		();
		
		FREE_IN_RESTRICTIONS::iterator	I = m_free_in_restrictions.begin(), J;
		FREE_IN_RESTRICTIONS::iterator	E = m_free_in_restrictions.end();
		for ( ; I != E; ++I) {
			for (J = I + 1; J != E; ++J)
				if (intersects((*I).m_restriction,(*J).m_restriction))
					temp_restrictions.push_back	((*J).m_restriction);

			if (!temp_restrictions.empty()) {
				J					= remove_if(m_free_in_restrictions.begin(),m_free_in_restrictions.end(),CRemoveMergedFreeInRestrictions(temp_restrictions));
				m_free_in_restrictions.erase	(J,m_free_in_restrictions.end());
				(*I).m_restriction	= merge((*I).m_restriction,temp_restrictions);
				ok					= false;
				break;
			}
		}
	}
	STOP_PROFILE;
}
示例#20
0
文件: ChoseForm.cpp 项目: 2asoft/xray
void __fastcall TfrmChoseItem::FormShow(TObject *Sender)
{
    tvItems->ShowCheckboxes 	= m_Flags.is(cfMultiSelect);
	int itm_cnt = _GetItemCount(m_LastSelection.c_str());
	if (m_Flags.is(cfMultiSelect)){
	    string256 T;
        for (int i=0; i<itm_cnt; i++){
            TElTreeItem* itm_node = FHelper.FindObject(tvItems,_GetItem(m_LastSelection.LowerCase().c_str(),i,T,',',"",false),0,0);//,bIgnoreExt);
	        TElTreeItem* fld_node = 0;
            if (itm_node){
				tvMulti->Items->AddObject(0,_GetItem(m_LastSelection.c_str(),i,T,',',"",false),(void*)TYPE_OBJECT);
            	itm_node->Checked = true;
                tvItems->EnsureVisible(itm_node);
                fld_node=itm_node->Parent;
                if (fld_node) fld_node->Expand(false);
            }
        }
    }else{
        TElTreeItem* itm_node = FHelper.FindItem(tvItems,m_LastSelection.LowerCase().c_str(),0,0);//,bIgnoreExt);
        TElTreeItem* fld_node = 0;
        if (itm_node){
            tvItems->Selected = itm_node;
            tvItems->EnsureVisible(itm_node);
            fld_node=itm_node->Parent;
            if (fld_node) fld_node->Expand(false);
        }else if (fld_node){
            tvItems->EnsureVisible(fld_node);
            fld_node->Expand(false);
            tvItems->Selected = fld_node;
        }
    }
    paMulti->Visible = m_Flags.is(cfMultiSelect);
	// check window position
	CheckWindowPos	(this);
}
示例#21
0
bool CWeaponMagazinedWGrenade::install_upgrade_ammo_class	( LPCSTR section, bool test )
{
	LPCSTR str;

	bool result = process_if_exists( section, "ammo_mag_size", &CInifile::r_s32, iMagazineSize2, test );
	iMagazineSize		= m_bGrenadeMode?1:iMagazineSize2;

	//	ammo_class = ammo_5.45x39_fmj, ammo_5.45x39_ap  // name of the ltx-section of used ammo
	bool result2 = process_if_exists_set( section, "ammo_class", &CInifile::r_string, str, test );
	if ( result2 && !test ) 
	{
		xr_vector<shared_str>& ammo_types	= m_bGrenadeMode ? m_ammoTypes2 : m_ammoTypes;
		ammo_types.clear					(); 
		for ( int i = 0, count = _GetItemCount( str ); i < count; ++i )	
		{
			string128						ammo_item;
			_GetItem						( str, i, ammo_item );
			ammo_types.push_back			( ammo_item );
		}

		shared_str& ammo_name				= m_bGrenadeMode ? m_ammoName2 : m_ammoName;
		ammo_name							= pSettings->r_string( *ammo_types[0], "inv_name_short" );		
		m_ammoType  = 0;
		m_ammoType2 = 0;
	}
	result |= result2;

	return result2;
}
示例#22
0
void CreateSounds(SoundVec& lst, LPCSTR buf)
{
	string128 tmp;
	int cnt			=	_GetItemCount(buf);	R_ASSERT(cnt<=GAMEMTL_SUBITEM_COUNT+2);
	lst.resize		(cnt);
	for (int k=0; k<cnt; ++k)
		lst[k].create	(_GetItem(buf,k,tmp),st_Effect,sg_SourceType);
}
IC	bool CSpaceRestrictionManager::restriction_presented	(shared_str restrictions, shared_str restriction) const
{
	string4096					m_temp;
	for (u32 i=0, n=_GetItemCount(*restrictions); i<n; ++i)
		if (!xr_strcmp(restriction,_GetItem(*restrictions,i,m_temp)))
			return				(true);
	return						(false);
}
示例#24
0
void CUIBagWnd::InitWpnSectStorage()
{
	WPN_SECT_NAMES		wpnOneType;
	string64			wpnSection;
	string1024			wpnNames, wpnSingleName;


	// Поле strSectionName должно содержать имя секции
	R_ASSERT			(m_sectionName != "");
	R_ASSERT3			(pSettings->section_exist(m_sectionName), "Section doesn't exist", m_sectionName.c_str());

	for (int i = 1; i < 20; ++i)
	{
		// Очищаем буфер
		wpnOneType.clear();

		// Имя поля
		sprintf_s			(wpnSection, "slot%i", i);
		if (!pSettings->line_exist(m_sectionName, wpnSection)) 
		{
			m_wpnSectStorage.push_back(wpnOneType);
			continue;
		}

		strcpy		(wpnNames, pSettings->r_string(m_sectionName, wpnSection));
		u32 count	= _GetItemCount(wpnNames);

		for (u32 j = 0; j < count; ++j)
		{
			_GetItem				(wpnNames, j, wpnSingleName);
			wpnOneType.push_back	(wpnSingleName);
		}

		if (!wpnOneType.empty()){
			m_wpnSectStorage.push_back(wpnOneType);
		}
	}

	wpnOneType.clear();

	CInifile::Sect &sect = pSettings->r_section(m_sectionPrice.c_str());

	for (CInifile::SectCIt it = sect.Data.begin(); it != sect.Data.end(); it++)
	{
		u8 group_id, index;
		GetWeaponIndexByName((*it).first.c_str(), group_id, index);

		if ((u8)(-1) == group_id || (u8)(-1) == index) // item not found
		{
			wpnOneType.push_back((*it).first.c_str());			//
		}	
	}
	if (!wpnOneType.empty()){
			m_wpnSectStorage.push_back(wpnOneType);
	}
}
示例#25
0
void _SequenceToList(LPSTRVec& lst, LPCSTR in, char separator)
{
	int t_cnt=_GetItemCount(in,separator);
	string1024 T;
	for (int i=0; i<t_cnt; i++){
		_GetItem(in,i,T,separator,0);
        _Trim(T);
        if (xr_strlen(T)) lst.push_back(xr_strdup(T));
	}
}
示例#26
0
文件: phantom.cpp 项目: 2asoft/xray
BOOL CPhantom::net_Spawn(CSE_Abstract* DC)
{
	CSE_ALifeCreaturePhantom*	OBJ	= smart_cast<CSE_ALifeCreaturePhantom*>(DC); VERIFY(OBJ);
	
	// select visual at first
	LPCSTR vis_name = OBJ->get_visual();
	if (!(vis_name&&vis_name[0])){
		LPCSTR visuals	= pSettings->r_string(cNameSect(),"visuals");
		u32 cnt			= _GetItemCount(visuals);
		string256 tmp;
		OBJ->set_visual	(_GetItem(visuals,Random.randI(cnt),tmp));
		// inform server
		NET_Packet		P;
		u_EventGen		(P, GE_CHANGE_VISUAL, OBJ->ID);
		P.w_stringZ		(tmp);
		u_EventSend		(P);
	}

	SwitchToState		(stBirth);			// initial state (changed on load method in inherited::)

	// inherited
	if (!inherited::net_Spawn(DC)) return FALSE;
	
	m_enemy			= Level().CurrentEntity();
	VERIFY			(m_enemy);

	// default init 
	m_fly_particles		= 0;
	SetfHealth			(0.001f);

	// orientate to enemy
	XFORM().k.sub	(m_enemy->Position(),Position()).normalize();
	XFORM().j.set	(0,1,0);
	XFORM().i.crossproduct	(XFORM().j,XFORM().k);
	XFORM().k.getHP	(vHP.x,vHP.y);

	// set animation
	IKinematicsAnimated *K			= smart_cast<IKinematicsAnimated*>(Visual());
	m_state_data[stBirth].motion	= K->ID_Cycle("birth_0");	
	m_state_data[stFly].motion		= K->ID_Cycle("fly_0");
	m_state_data[stContact].motion	= K->ID_Cycle("contact_0"); 
	m_state_data[stShoot].motion	= K->ID_Cycle("shoot_0");	

	VERIFY(K->LL_GetMotionDef(m_state_data[stBirth].motion)->flags&esmStopAtEnd);
	VERIFY(K->LL_GetMotionDef(m_state_data[stContact].motion)->flags&esmStopAtEnd);
	VERIFY(K->LL_GetMotionDef(m_state_data[stShoot].motion)->flags&esmStopAtEnd);

	// set state
	SwitchToState_internal(m_TgtState);

	setVisible		(m_CurState>stIdle?TRUE:FALSE);
	setEnabled		(TRUE);

	return			TRUE;
}
示例#27
0
void _SequenceToList(AStringVec& lst, LPCSTR in, char separator)
{
	lst.clear();
	int t_cnt=_GetItemCount(in,separator);
	AnsiString T;
	for (int i=0; i<t_cnt; i++){
		_GetItem(in,i,T,separator,0);
        _Trim(T);
        if (!T.IsEmpty()) lst.push_back(T);
	}
}
示例#28
0
void _SequenceToList(SStringVec& lst, LPCSTR in, char separator)
{
	lst.clear	();
	int t_cnt	= _GetItemCount(in,separator);
	xr_string	T;
	for (int i=0; i<t_cnt; i++){
		_GetItem(in,i,T,separator,0);
		_Trim	(T);
		if (T.size()) lst.push_back(T.c_str());
	}
}
示例#29
0
	virtual void Execute(LPCSTR args) 
	{
		string512				console_command;
		string256				key;
		int cnt					= _GetItemCount(args,' ');
		_GetItems				(args,0,cnt-1,console_command,' ');
		_GetItem				(args,cnt-1,key,' ');

		int dik					= keyname_to_dik(key);
		bindConsoleCmds.bind	(dik, console_command);
	}
示例#30
0
bool CFolderHelper::RenameItem(TElTree* tv, TElTreeItem* node, AnsiString& new_text, TOnItemRename OnRename)
{
    R_ASSERT(OnRename);
    if (new_text.IsEmpty()) return false;
    new_text = new_text.LowerCase();

    // find item with some name
    for (TElTreeItem* item=node->GetFirstSibling(); item; item=item->GetNextSibling()){
        if ((item->Text==new_text)&&(item!=node))
            return false;
    }
    AnsiString full_name;
    if (IsFolder(node)){
    	// is folder - rename all folder items
        for (TElTreeItem* item=node->GetFirstChild(); item&&(item->Level>node->Level); item=item->GetNext()){
            if (IsObject(item)){
                MakeName(item,0,full_name,false);
                VERIFY(node->Level<_GetItemCount(full_name.c_str(),'\\'));
                AnsiString new_full_name;
                _ReplaceItem(full_name.c_str(),node->Level,new_text.c_str(),new_full_name,'\\');
		        if (full_name!=new_full_name)
        	        OnRename(full_name.c_str(),new_full_name.c_str(),TYPE_OBJECT);
            }
        }
        AnsiString new_full_name;
        MakeName(node,0,full_name,true);
        _ReplaceItem(full_name.c_str(),node->Level,new_text.c_str(),new_full_name,'\\');
        if (full_name!=new_full_name)
			OnRename(full_name.c_str(),new_full_name.c_str(),TYPE_FOLDER);
    }else if (IsObject(node)){
    	// is object - rename only this item
        MakeName(node,0,full_name,false);
        VERIFY(node->Level<_GetItemCount(full_name.c_str(),'\\'));
        AnsiString new_full_name;
        _ReplaceItem(full_name.c_str(),node->Level,new_text.c_str(),new_full_name,'\\');
        if (full_name!=new_full_name)
			OnRename(full_name.c_str(),new_full_name.c_str(),TYPE_OBJECT);
    }
    tv->Selected=node;
    return true;
}