コード例 #1
0
ファイル: FS.cpp プロジェクト: BubbaXXX/xray-16
void* FileDownload(LPCSTR file_name, const int& file_handle, u32& file_size)
{
    void* buffer = Memory.mem_alloc(
        file_size
#ifdef DEBUG_MEMORY_NAME
        , "FILE in memory"
#endif // DEBUG_MEMORY_NAME
        );

    int r_bytes = _read(file_handle, buffer, file_size);
    R_ASSERT3(
        // !file_size ||
        // (r_bytes && (file_size >= (u32)r_bytes)),
        file_size == (u32)r_bytes,
        "can't read from file : ",
        file_name
        );

    // file_size = r_bytes;

    R_ASSERT3(
        !_close(file_handle),
        "can't close file : ",
        file_name
        );

    return (buffer);
}
コード例 #2
0
ファイル: Environment_misc.cpp プロジェクト: denanden/xray-16
//-----------------------------------------------------------------------------
// 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);
    }
}
コード例 #3
0
void
CPhysicsShellHolder::PHLoadState(IReader &P)
{
	
//	Flags8 lflags;
	CKinematics* K=smart_cast<CKinematics*>(Visual());
//	P.r_u8 (lflags.flags);
	if(K)
	{
		K->LL_SetBonesVisible(P.r_u64());
		K->LL_SetBoneRoot(P.r_u16());
	}

	Fvector min=P.r_vec3();
	Fvector max=P.r_vec3();
	
	VERIFY(!min.similar(max));

	u16 bones_number=P.r_u16();
		
    R_ASSERT3(bones_number <= 64, "CPhysicsShellHolder::PHLoadState", cNameVisual().c_str());

	for(u16 i=0;i<bones_number;i++)
	{
		SPHNetState state;
		state.net_Load(P,min,max);
		PHGetSyncItem(i)->set_State(state);
	}
}
コード例 #4
0
ファイル: GameObject.cpp プロジェクト: AntonioModer/xray-16
u32	CGameObject::ef_weapon_type			() const
{
	string16	temp; CLSID2TEXT(CLS_ID,temp);
	R_ASSERT3	(false,"Invalid weapon type request, virtual function is not properly overridden!",temp);
	return		(u32(-1));
//	return		(u32(0));
}
コード例 #5
0
ファイル: Environment.cpp プロジェクト: OLR-xray/OLR-3.0
void CEnvironment::SetWeather(shared_str name, bool forced)
{
//.	static BOOL bAlready = FALSE;
//.	if(bAlready)	return;
	if (name.size())	{
//.		bAlready = TRUE;
        EnvsMapIt it		= WeatherCycles.find(name);
		if (it == WeatherCycles.end())
		{
			Msg("! Invalid weather name: %s", name.c_str());
			return;
		}
        R_ASSERT3			(it!=WeatherCycles.end(),"Invalid weather name.",*name);
		CurrentCycleName	= it->first;
		if (forced)			{Invalidate();			}
		if (!bWFX){
			CurrentWeather		= &it->second;
			CurrentWeatherName	= it->first;
		}
		if (forced)			{SelectEnvs(fGameTime);	}
#ifdef WEATHER_LOGGING
		Msg					("Starting Cycle: %s [%s]",*name,forced?"forced":"deferred");
#endif
    }else{
#ifndef _EDITOR
		FATAL				("! Empty weather name");
#endif
    }
}
コード例 #6
0
ファイル: UIEventsWnd.cpp プロジェクト: OLR-xray/OLR-3.0
void CUIEventsWnd::Init				()
{
	CUIXml uiXml;
	bool xml_result					= uiXml.Init(CONFIG_PATH, UI_PATH, "pda_events.xml");
	R_ASSERT3						(xml_result, "xml file not found", "pda_events.xml");

	CUIXmlInit xml_init;
	xml_init.InitWindow				(uiXml, "main_wnd", 0, this);


	m_UILeftFrame					= xr_new<CUIFrameWindow>(); m_UILeftFrame->SetAutoDelete(true);
	AttachChild						(m_UILeftFrame);
	xml_init.InitFrameWindow		(uiXml, "main_wnd:left_frame", 0, m_UILeftFrame);


	m_UILeftHeader					= xr_new<CUIFrameLineWnd>(); m_UILeftHeader->SetAutoDelete(true);
	m_UILeftFrame->AttachChild		(m_UILeftHeader);
	xml_init.InitFrameLine			(uiXml, "main_wnd:left_frame:left_frame_header", 0, m_UILeftHeader);

//.	xml_init.InitAutoStaticGroup	(uiXml, "main_wnd:left_frame",m_UILeftFrame);

	m_UIAnimation					= xr_new<CUIAnimatedStatic>(); m_UIAnimation->SetAutoDelete(true);
	xml_init.InitAnimatedStatic		(uiXml, "main_wnd:left_frame:left_frame_header:anim_static", 0, m_UIAnimation);
	m_UILeftHeader->AttachChild		(m_UIAnimation);

	m_UIRightWnd					= xr_new<CUIWindow>(); m_UIRightWnd->SetAutoDelete(true);
	AttachChild						(m_UIRightWnd);
	xml_init.InitWindow				(uiXml, "main_wnd:right_frame", 0, m_UIRightWnd);

	m_UIMapWnd						= xr_new<CUIMapWnd>(); m_UIMapWnd->SetAutoDelete(false);
	m_UIMapWnd->Init				("pda_events.xml","main_wnd:right_frame:map_wnd");

	m_UITaskInfoWnd					= xr_new<CUITaskDescrWnd>(); m_UITaskInfoWnd->SetAutoDelete(false);
	m_UITaskInfoWnd->Init			(&uiXml,"main_wnd:right_frame:task_descr_view");
	

	m_ListWnd						= xr_new<CUIScrollView>(); m_ListWnd->SetAutoDelete(true);
	m_UILeftFrame->AttachChild		(m_ListWnd);
	xml_init.InitScrollView			(uiXml, "main_wnd:left_frame:list", 0, m_ListWnd);

	m_TaskFilter					= xr_new<CUITabControl>(); m_TaskFilter->SetAutoDelete(true);
	m_UILeftFrame->AttachChild		(m_TaskFilter);
	xml_init.InitTabControl			(uiXml, "main_wnd:left_frame:filter_tab", 0, m_TaskFilter);
	m_TaskFilter->SetWindowName		("filter_tab");
	Register						(m_TaskFilter);
    AddCallback						("filter_tab",TAB_CHANGED,CUIWndCallback::void_function(this,&CUIEventsWnd::OnFilterChanged));
/*
    m_primary_or_all_filter_btn		= xr_new<CUI3tButton>(); m_primary_or_all_filter_btn->SetAutoDelete(true);
	m_UILeftFrame->AttachChild		(m_primary_or_all_filter_btn);
	xml_init.Init3tButton			(uiXml, "main_wnd:left_frame:primary_or_all", 0, m_primary_or_all_filter_btn);

	Register						(m_primary_or_all_filter_btn);
	m_primary_or_all_filter_btn->	SetWindowName("btn_primary_or_all");
    AddCallback						("btn_primary_or_all",BUTTON_CLICKED,boost::bind(&CUIEventsWnd::OnFilterChanged,this,_1,_2));
*/
   m_currFilter						= eActiveTask;
   SetDescriptionMode				(true);

   m_ui_task_item_xml.Init			(CONFIG_PATH, UI_PATH, "job_item.xml");
}
コード例 #7
0
ファイル: alife_spawn_registry.cpp プロジェクト: 2asoft/xray
void CALifeSpawnRegistry::load				(IReader &file_stream, LPCSTR game_name)
{
	R_ASSERT					(FS.exist(game_name));

	IReader						*chunk, *chunk0;
	Msg							("* Loading spawn registry...");
	R_ASSERT2					(file_stream.find_chunk(SPAWN_CHUNK_DATA),"Cannot find chunk SPAWN_CHUNK_DATA!");
	chunk0						= file_stream.open_chunk(SPAWN_CHUNK_DATA);
	
	xrGUID						guid;
	chunk						= chunk0->open_chunk(0);
	VERIFY						(chunk);
	chunk->r_stringZ			(m_spawn_name);
	chunk->r					(&guid,sizeof(guid));
	chunk->close				();

	string_path					file_name;
	bool						file_exists = !!FS.exist(file_name, "$game_spawn$", *m_spawn_name, ".spawn");
	R_ASSERT3					(file_exists,"Can't find spawn file:",*m_spawn_name);
	
	VERIFY						(!m_file);
	m_file						= FS.r_open(file_name);
	load						(*m_file,&guid);

	chunk0->close				();
}
コード例 #8
0
void CLevelSpawnConstructor::load_objects						()
{
	// loading spawn points
	string_path					file_name;
	FS.update_path				(file_name,"$game_levels$",*m_level.name());
	strcat_s					(file_name,"\\level.spawn");
	IReader						*level_spawn = FS.r_open(file_name);
	u32							id;
	IReader						*chunk = level_spawn->open_chunk_iterator(id);
	for ( ; chunk; chunk = level_spawn->open_chunk_iterator(id,chunk)) {
		CSE_Abstract			*abstract = create_object(chunk);
		if (abstract->m_tClassID == CLSID_AI_GRAPH) {
			add_graph_point		(abstract);
			continue;
		}

//		if (abstract->m_tClassID == CLSID_AI_SPAWN_GROUP) {
//			add_spawn_group		(abstract);
//			continue;
//		}

		if (!abstract->m_gameType.MatchType(eGameIDSingle)) 
		{
			F_entity_Destroy	(abstract);
			continue;
		}

		CSE_ALifeObject			*alife_object = smart_cast<CSE_ALifeObject*>(abstract);
		if (!alife_object) {
			F_entity_Destroy	(abstract);
			continue;
		}

		CSE_ALifeCreatureActor	*actor = smart_cast<CSE_ALifeCreatureActor*>(alife_object);
		if (actor) {
			R_ASSERT3			(!m_actor,"Too many actors on the level ",*m_level.name());
			m_actor				= actor;
		}

		m_spawns.push_back		(alife_object);

		CSE_ALifeDynamicObject	*dynamic_object = smart_cast<CSE_ALifeDynamicObject*>(alife_object);
		if (dynamic_object) {
			add_story_object	(dynamic_object);
			add_space_restrictor(dynamic_object);
		}

		if (smart_cast<CSE_ALifeLevelChanger*>(abstract))
			add_level_changer	(abstract);

//		if (xr_strlen(alife_object->m_spawn_control))
//			add_group_object	(alife_object,alife_object->m_spawn_control);

		add_free_object			(alife_object);
	}
	
	FS.r_close					(level_spawn);

	R_ASSERT2					(!m_spawns.empty(),"There are no spawn-points!");
}
コード例 #9
0
ファイル: ParticlesPlayer.cpp プロジェクト: OLR-xray/XRay-NEW
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)));
    }
}
コード例 #10
0
void CSE_Abstract::Spawn_Write				(NET_Packet	&tNetPacket, BOOL bLocal)
{
	// generic
	tNetPacket.w_begin			(M_SPAWN);
	tNetPacket.w_stringZ		(s_name			);
	tNetPacket.w_stringZ		(s_name_replace ?	s_name_replace : "");
	tNetPacket.w_u8				(0);
	tNetPacket.w_u8				(s_RP			);
	tNetPacket.w_vec3			(o_Position		);
	tNetPacket.w_vec3			(o_Angle		);
	tNetPacket.w_u16			(RespawnTime	);
	tNetPacket.w_u16			(ID				);
	tNetPacket.w_u16			(ID_Parent		);
	tNetPacket.w_u16			(ID_Phantom		);

	s_flags.set					(M_SPAWN_VERSION,TRUE);
	if (bLocal)
		tNetPacket.w_u16		(u16(s_flags.flags|M_SPAWN_OBJECT_LOCAL) );
	else
		tNetPacket.w_u16		(u16(s_flags.flags&~(M_SPAWN_OBJECT_LOCAL|M_SPAWN_OBJECT_ASPLAYER)));
	
	tNetPacket.w_u16			(SPAWN_VERSION);

	tNetPacket.w_u16			(m_gameType.m_GameType.get());
	
	tNetPacket.w_u16			(script_server_object_version());


	//client object custom data serialization SAVE
	u16 client_data_size		= (u16)client_data.size(); //не может быть больше 256 байт
	tNetPacket.w_u16			(client_data_size);
//	Msg							("SERVER:saving:save:%d bytes:%d:%s",client_data_size,ID,s_name_replace ? s_name_replace : "");
	if (client_data_size > 0) {
		tNetPacket.w			(&*client_data.begin(),client_data_size);
	}

	tNetPacket.w_u16			(m_tSpawnID);
//	tNetPacket.w_float			(m_spawn_probability);
//	tNetPacket.w_u32			(m_spawn_flags.get());
//	tNetPacket.w_stringZ		(m_spawn_control);
//	tNetPacket.w_u32			(m_max_spawn_count);
//	tNetPacket.w_u64			(m_min_spawn_interval);
//	tNetPacket.w_u64			(m_max_spawn_interval);

#ifdef XRSE_FACTORY_EXPORTS
	CScriptValueContainer::assign();
#endif

	// write specific data
	u32	position				= tNetPacket.w_tell();
	tNetPacket.w_u16			(0);
	STATE_Write					(tNetPacket);
	u16 size					= u16(tNetPacket.w_tell() - position);
//#ifdef XRSE_FACTORY_EXPORTS
	R_ASSERT3					((m_tClassID == CLSID_SPECTATOR) || (size > sizeof(size)),
		"object isn't successfully saved, get your backup :(",name_replace());
//#endif
	tNetPacket.w_seek			(position,&size,sizeof(u16));
}
コード例 #11
0
ファイル: UITextureMaster.cpp プロジェクト: OLR-xray/XRay-NEW
void CUITextureMaster::GetTextureShader(LPCSTR texture_name, ref_shader& sh){
	xr_map<shared_str, TEX_INFO>::iterator	it;
	it = m_textures.find(texture_name);

	R_ASSERT3(it != m_textures.end(), "can't find texture", texture_name);

	sh.create("hud\\default", *((*it).second.file));	
}
コード例 #12
0
ファイル: FS.cpp プロジェクト: BubbaXXX/xray-16
CVirtualFileReader::CVirtualFileReader(const char* cFileName)
{
    // Open the file
    hSrcFile = CreateFile(cFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
    R_ASSERT3(hSrcFile != INVALID_HANDLE_VALUE, cFileName, Debug.error2string(GetLastError()));
    Size = (int)GetFileSize(hSrcFile, NULL);
    R_ASSERT3(Size, cFileName, Debug.error2string(GetLastError()));

    hSrcMap = CreateFileMapping(hSrcFile, 0, PAGE_READONLY, 0, 0, 0);
    R_ASSERT3(hSrcMap != INVALID_HANDLE_VALUE, cFileName, Debug.error2string(GetLastError()));

    data = (char*)MapViewOfFile(hSrcMap, FILE_MAP_READ, 0, 0, 0);
    R_ASSERT3(data, cFileName, Debug.error2string(GetLastError()));

#ifdef FS_DEBUG
    register_file_mapping(data, Size, cFileName);
#endif // DEBUG
}
コード例 #13
0
ファイル: UITextureMaster.cpp プロジェクト: OLR-xray/XRay-NEW
LPCSTR CUITextureMaster::GetTextureFileName(const char* texture_name){
	xr_map<shared_str, TEX_INFO>::iterator	it;
	it = m_textures.find(texture_name);

	if (it != m_textures.end())
		return *((*it).second.file);
	R_ASSERT3(false,"CUITextureMaster::GetTextureFileName Can't find texture", texture_name);
	return 0;
}
コード例 #14
0
ファイル: UITextureMaster.cpp プロジェクト: OLR-xray/XRay-NEW
float CUITextureMaster::GetTextureWidth(const char* texture_name){
	xr_map<shared_str, TEX_INFO>::iterator	it;
	it = m_textures.find(texture_name);

	if (it != m_textures.end())
		return (*it).second.rect.width();
	R_ASSERT3(false,"CUITextureMaster::GetTextureHeight Can't find texture", texture_name);
	return 0;
}
コード例 #15
0
ファイル: FS.cpp プロジェクト: 2asoft/xray
CVirtualFileRW::CVirtualFileRW(const char *cFileName) 
{
	// Open the file
	hSrcFile		= CreateFile(cFileName, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
	R_ASSERT3		(hSrcFile!=INVALID_HANDLE_VALUE,cFileName,xrDebug::ErrorToString(GetLastError()));
	Size			= (int)GetFileSize(hSrcFile, NULL);
	R_ASSERT3		(Size,cFileName,xrDebug::ErrorToString(GetLastError()));

	hSrcMap			= CreateFileMapping (hSrcFile, 0, PAGE_READWRITE, 0, 0, 0);
	R_ASSERT3		(hSrcMap!=INVALID_HANDLE_VALUE,cFileName,xrDebug::ErrorToString(GetLastError()));

	data			= (char*)MapViewOfFile (hSrcMap, FILE_MAP_ALL_ACCESS, 0, 0, 0);
	R_ASSERT3		(data,cFileName,xrDebug::ErrorToString(GetLastError()));

#ifdef DEBUG
	register_file_mapping	(data,Size,cFileName);
#endif // DEBUG
}
コード例 #16
0
ファイル: UIBagWnd.cpp プロジェクト: OLR-xray/OLR-3.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);
	}
}
コード例 #17
0
void CPHMovementControl::Load					(LPCSTR section){

	//capture
	
	//strcpy(m_capture_bone,pSettings->r_string(section,"capture_bone"));
	
	Fbox	bb;

	// m_PhysicMovementControl: BOX
	Fvector	vBOX1_center= pSettings->r_fvector3	(section,"ph_box1_center"	);
	Fvector	vBOX1_size	= pSettings->r_fvector3	(section,"ph_box1_size"		);
	bb.set	(vBOX1_center,vBOX1_center); bb.grow(vBOX1_size);
	SetBox		(1,bb);

	// m_PhysicMovementControl: BOX
	Fvector	vBOX0_center= pSettings->r_fvector3	(section,"ph_box0_center"	);
	Fvector	vBOX0_size	= pSettings->r_fvector3	(section,"ph_box0_size"		);
	bb.set	(vBOX0_center,vBOX0_center); bb.grow(vBOX0_size);
	SetBox		(0,bb);

	//// m_PhysicMovementControl: Foots
	//Fvector	vFOOT_center= pSettings->r_fvector3	(section,"ph_foot_center"	);
	//Fvector	vFOOT_size	= pSettings->r_fvector3	(section,"ph_foot_size"		);
	//bb.set	(vFOOT_center,vFOOT_center); bb.grow(vFOOT_size);
	//SetFoots	(vFOOT_center,vFOOT_size);

	// m_PhysicMovementControl: Crash speed and mass
	float	cs_min		= pSettings->r_float	(section,"ph_crash_speed_min"	);
	float	cs_max		= pSettings->r_float	(section,"ph_crash_speed_max"	);
	float	mass		= pSettings->r_float	(section,"ph_mass"				);
	xr_token retrictor_types[]={
		{ "actor",			CPHCharacter::rtActor},
		{ "medium_monster",	CPHCharacter::rtMonsterMedium},
		{ "stalker",		CPHCharacter::rtStalker	},
		{ "none",			CPHCharacter::rtNone	},
		{ 0,							0}
	};

	if(pSettings->line_exist(section,"actor_restrictor"))
		SetRestrictionType(CPHCharacter::ERestrictionType(pSettings->r_token(section,"actor_restrictor",retrictor_types)));
	fCollisionDamageFactor=READ_IF_EXISTS(pSettings,r_float,section,"ph_collision_damage_factor",fCollisionDamageFactor);
	R_ASSERT3(fCollisionDamageFactor<=1.f,"ph_collision_damage_factor >1.",section);
	SetCrashSpeeds	(cs_min,cs_max);
	SetMass		(mass);


	// m_PhysicMovementControl: Frictions
	//float af, gf, wf;
	//af					= pSettings->r_float	(section,"ph_friction_air"	);
	//gf					= pSettings->r_float	(section,"ph_friction_ground");
	//wf					= pSettings->r_float	(section,"ph_friction_wall"	);
	//SetFriction	(af,wf,gf);

	// BOX activate
//	ActivateBox	(0);
}
コード例 #18
0
void CParticlesObject::Init	(LPCSTR p_name, IRender_Sector* S, BOOL bAutoRemove)
{
	m_bLooped				= false;
	m_bStopping				= false;
	m_bAutoRemove			= bAutoRemove;
	float time_limit		= 0.0f;

	if(!g_dedicated_server)
	{
		// create visual
		renderable.visual		= Render->model_CreateParticles(p_name);
		VERIFY					(renderable.visual);
		IParticleCustom* V		= smart_cast<IParticleCustom*>(renderable.visual);  VERIFY(V);
		time_limit				= V->GetTimeLimit();
	}else
	{
		time_limit					= 1.0f;
	}

	if(time_limit > 0.f)
	{
		m_iLifeTime			= iFloor(time_limit*1000.f);
	}
	else
	{
		if(bAutoRemove)
		{
			R_ASSERT3			(!m_bAutoRemove,"Can't set auto-remove flag for looped particle system.",p_name);
		}
		else
		{
			m_iLifeTime = 0;
			m_bLooped = true;
		}
	}


	// spatial
	spatial.type			= 0;
	spatial.sector			= S;
	
	// sheduled
#ifdef LUAICP_COMPAT
	shedule.t_min				= pSettings->r_u8 ("particles_schedule", "t_min" );
	shedule.t_max				= pSettings->r_u8 ("particles_schedule", "t_max" );
	shedule.t_min				= shedule.t_min > 20 ? shedule.t_min : 20;  
	shedule.t_max				= shedule.t_max > 30 ? shedule.t_max : 30;
#else
	shedule.t_min			= 20;
	shedule.t_max			= 50;
#endif
	shedule_register		();

	dwLastTime				= Device.dwTimeGlobal;
	mt_dt					= 0;
}
コード例 #19
0
ファイル: Environment.cpp プロジェクト: OLR-xray/OLR-3.0
bool CEnvironment::SetWeatherFX(shared_str name)
{
	if (bWFX)				return false;
	if (name.size()){
		EnvsMapIt it		= WeatherFXs.find(name);
		R_ASSERT3			(it!=WeatherFXs.end(),"Invalid weather effect name.",*name);
		EnvVec* PrevWeather = CurrentWeather; VERIFY(PrevWeather);
		CurrentWeather		= &it->second;
		CurrentWeatherName	= it->first;

		float rewind_tm		= WFX_TRANS_TIME*fTimeFactor;
		float start_tm		= fGameTime+rewind_tm;
		float current_length;
		float current_weight;
		if (Current[0]->exec_time>Current[1]->exec_time){
			float x			= fGameTime>Current[0]->exec_time?fGameTime-Current[0]->exec_time:(DAY_LENGTH-Current[0]->exec_time)+fGameTime;
			current_length	= (DAY_LENGTH-Current[0]->exec_time)+Current[1]->exec_time;
			current_weight	= x/current_length; 
		}else{
			current_length	= Current[1]->exec_time-Current[0]->exec_time;
			current_weight	= (fGameTime-Current[0]->exec_time)/current_length; 
		}
		clamp				(current_weight,0.f,1.f);

		std::sort			(CurrentWeather->begin(),CurrentWeather->end(),sort_env_etl_pred);
		CEnvDescriptor* C0	= CurrentWeather->at(0);
		CEnvDescriptor* C1	= CurrentWeather->at(1);
		CEnvDescriptor* CE	= CurrentWeather->at(CurrentWeather->size()-2);
		CEnvDescriptor* CT	= CurrentWeather->at(CurrentWeather->size()-1);
		C0->copy			(*Current[0]);	C0->exec_time = NormalizeTime(fGameTime-((rewind_tm/(Current[1]->exec_time-fGameTime))*current_length-rewind_tm));
		C1->copy			(*Current[1]);	C1->exec_time = NormalizeTime(start_tm);
		for (EnvIt t_it=CurrentWeather->begin()+2; t_it!=CurrentWeather->end()-1; t_it++)
			(*t_it)->exec_time= NormalizeTime(start_tm+(*t_it)->exec_time_loaded);
		SelectEnv			(PrevWeather,WFX_end_desc[0],CE->exec_time);
		SelectEnv			(PrevWeather,WFX_end_desc[1],WFX_end_desc[0]->exec_time+0.5f);
		CT->copy			(*WFX_end_desc[0]);CT->exec_time = NormalizeTime(CE->exec_time+rewind_tm);
		wfx_time			= TimeDiff(fGameTime,CT->exec_time);
		bWFX				= true;

		// sort wfx envs
		std::sort			(CurrentWeather->begin(),CurrentWeather->end(),sort_env_pred);

		Current[0]			= C0;
		Current[1]			= C1;
#ifdef WEATHER_LOGGING
		Msg					("Starting WFX: '%s' - %3.2f sec",*name,wfx_time);
		for (EnvIt l_it=CurrentWeather->begin(); l_it!=CurrentWeather->end(); l_it++)
			Msg				(". Env: '%s' Tm: %3.2f",*(*l_it)->sect_name,(*l_it)->exec_time);
#endif
	}else{
#ifndef _EDITOR
		FATAL				("! Empty weather effect name");
#endif
	}
	return true;
}
コード例 #20
0
ファイル: UIOptionsManager.cpp プロジェクト: OLR-xray/OLR-3.0
void CUIOptionsManager::SaveValues(const char* group){
	groups_it it = m_groups.find(group);

	R_ASSERT3(m_groups.end() != it, "invalid group name",group);

	for (u32 i = 0; i < (*it).second.size(); i++){
		if ((*it).second[i]->IsChanged())
            (*it).second[i]->SaveValue();
	}
}
コード例 #21
0
ファイル: r2.cpp プロジェクト: OLR-xray/XRay-NEW
IRender_Visual*			CRender::model_CreateParticles	(LPCSTR name)
{
    PS::CPEDef*	SE			= PSLibrary.FindPED	(name);
    if (SE) return			Models->CreatePE	(SE);
    else {
        PS::CPGDef*	SG		= PSLibrary.FindPGD	(name);
        R_ASSERT3(SG,"Particle effect or group doesn't exist",name);
        return				Models->CreatePG	(SG);
    }
}
コード例 #22
0
void	CSoundRender_Target::attach()
{
	VERIFY			(0==wave);
	VERIFY			(pEmitter);
	ov_callbacks ovc= {ov_read_func,ov_seek_func,ov_close_func,ov_tell_func};
	wave			= FS.r_open		(pEmitter->source->pname.c_str()); 
	R_ASSERT3		(wave&&wave->length(),"Can't open wave file:",pEmitter->source->pname.c_str());
 	ov_open_callbacks(wave,&ovf,NULL,0,ovc);
	VERIFY			(0!=wave);
}
コード例 #23
0
ファイル: UIOptionsManager.cpp プロジェクト: OLR-xray/OLR-3.0
void CUIOptionsManager::SetCurrentValues(const char* group){
	groups_it it = m_groups.find(group);

	R_ASSERT3(m_groups.end() != it, "invalid group name",group);

	for (u32 i = 0; i < (*it).second.size(); i++){
		(*it).second[i]->SetCurrentValue();
//.		(*it).second[i]->SeveBackUpValue();
	}
}
コード例 #24
0
ファイル: PostprocessAnimator.cpp プロジェクト: 2asoft/xray
BOOL CPostprocessAnimator::Process(SPPInfo &PPInfo)
{
	if(m_bCyclic)
		fLifeTime				= 100000;

	CEffectorPP::Process		(PPInfo);
	

	if(m_start_time<0.0f)m_start_time=Device.fTimeGlobal;
	if(m_bCyclic &&((Device.fTimeGlobal-m_start_time)>f_length)) m_start_time+=f_length;

	Update					(Device.fTimeGlobal-m_start_time);

	VERIFY				(_valid(m_factor));
	VERIFY				(_valid(m_factor_speed));
	VERIFY				(_valid(m_dest_factor));
	if(m_bStop)
		m_factor			-=	Device.fTimeDelta*m_factor_speed;
	else
		m_factor			+= m_factor_speed*Device.fTimeDelta*(m_dest_factor-m_factor);

	clamp					(m_factor, 0.0001f, 1.0f);

	VERIFY				(_valid(m_factor));
	VERIFY				(_valid(m_factor_speed));

	m_EffectorParams.color_base		+= pp_identity.color_base;
	m_EffectorParams.color_gray		+= pp_identity.color_gray;
	m_EffectorParams.color_add		+= pp_identity.color_add;

	if(0==m_Params[pp_noise_i]->get_keys_count()){
		m_EffectorParams.noise.intensity = pp_identity.noise.intensity;
	}
	
	if(0==m_Params[pp_noise_g]->get_keys_count()){
		m_EffectorParams.noise.grain = pp_identity.noise.grain;
	}

	if(0==m_Params[pp_noise_f]->get_keys_count()){
		m_EffectorParams.noise.fps = pp_identity.noise.fps;
	}else
		m_EffectorParams.noise.fps		*= 100.0f;

	PPInfo.lerp				(pp_identity, m_EffectorParams, m_factor);

	if(PPInfo.noise.grain<=0.0f){
		R_ASSERT3(0,"noise.grain cant be zero! see postprocess",*m_Name);
	}

	if(fsimilar(m_factor,0.0001f,EPS_S))
		return FALSE;

	return TRUE;
}
コード例 #25
0
Fvector CPHMovementControl::PHCaptureGetNearestElemPos(const CPhysicsShellHolder* object)
{
	R_ASSERT3((object->m_pPhysicsShell != NULL), "NO Phisics Shell for object ", *object->cName());

	CPhysicsElement *ph_elem =  object->m_pPhysicsShell->NearestToPoint(vPosition);

	Fvector v;
	ph_elem->GetGlobalPositionDynamic(&v);	
	
	return v;
}
コード例 #26
0
ファイル: FS.cpp プロジェクト: BubbaXXX/xray-16
void* FileDownload(LPCSTR file_name, u32* buffer_size)
{
    int file_handle;
    R_ASSERT3(
        file_handle_internal(file_name, *buffer_size, file_handle),
        "can't open file : ",
        file_name
        );

    return (FileDownload(file_name, file_handle, *buffer_size));
}
コード例 #27
0
ファイル: alife_spawn_registry.cpp プロジェクト: 2asoft/xray
void CALifeSpawnRegistry::load				(LPCSTR spawn_name)
{
	Msg							("* Loading spawn registry...");
	m_spawn_name				= spawn_name;
	string_path					file_name;
	R_ASSERT3					(FS.exist(file_name, "$game_spawn$", *m_spawn_name, ".spawn"),"Can't find spawn file:",*m_spawn_name);
	
	VERIFY						(!m_file);
	m_file						= FS.r_open(file_name);
	load						(*m_file);
}
コード例 #28
0
void CGameSpawnConstructor::verify_spawns			(ALife::_SPAWN_ID spawn_id)
{
	xr_vector<ALife::_SPAWN_ID>::iterator	J = std::find(m_temp0.begin(),m_temp0.end(),spawn_id);
	R_ASSERT3								(J == m_temp0.end(),"RECURSIVE Spawn group chain found in spawn",m_spawn_graph->vertex(spawn_id)->data()->object().name_replace());
	m_temp0.push_back						(spawn_id);

	SPAWN_GRAPH::CVertex					*vertex = m_spawn_graph->vertex(spawn_id);
	SPAWN_GRAPH::const_iterator				I = vertex->edges().begin();
	SPAWN_GRAPH::const_iterator				E = vertex->edges().end();
	for ( ; I != E; ++I)
		verify_spawns						((*I).vertex_id());
}
コード例 #29
0
bool xrServer::Process_event_reject	(NET_Packet& P, const ClientID sender, const u32 time, const u16 id_parent, const u16 id_entity, bool send_message)
{
	// Parse message
	CSE_Abstract*		e_parent	= game->get_entity_from_eid	(id_parent);
	CSE_Abstract*		e_entity	= game->get_entity_from_eid	(id_entity);
	
#ifdef DEBUG
	Msg("sv reject. id_parent %s id_entity %s [%d]",ent_name_safe(id_parent).c_str(),ent_name_safe(id_entity).c_str(), Device.dwFrame);
#endif
	R_ASSERT			(e_parent && e_entity);
	game->OnDetach		(id_parent,id_entity);

	if (0xffff == e_entity->ID_Parent) 
	{
		Msg	("~ ERROR: can't detach independant object. entity[%s:%d], parent[%s:%d], section[%s]",
			e_entity->name_replace(),id_entity,e_parent->name_replace(),id_parent, *e_entity->s_name);
		if (game_lua())
			Msg("~ %s", get_lua_traceback(game_lua(), 2));

		return			(false);
	}

	// Rebuild parentness
	R_ASSERT3				(e_entity->ID_Parent == id_parent, e_entity->name_replace(), e_parent->name_replace());
	e_entity->ID_Parent		= 0xffff;
	xr_vector<u16>& C		= e_parent->children;

	xr_vector<u16>::iterator c	= std::find	(C.begin(),C.end(),id_entity);
	R_ASSERT3				(C.end()!=c,e_entity->name_replace(),e_parent->name_replace());
	C.erase					(c);

	// Signal to everyone (including sender)
	if (send_message)
	{
		DWORD MODE		= net_flags(TRUE,TRUE, FALSE, TRUE);
		SendBroadcast	(BroadcastCID,P,MODE);
	}
	
	return				(true);
}
コード例 #30
0
void CSpaceRestrictorWrapper::verify_connectivity	()
{
	{
		std::sort					(m_internal.begin(),m_internal.end());
		BORDER::iterator			I = std::unique(m_internal.begin(),m_internal.end());
		m_internal.erase			(I,m_internal.end());
	}

	u32								start_vertex_id = u32(-1);
	CLevelGraph::const_vertex_iterator	I = level_graph().begin();
	CLevelGraph::const_vertex_iterator	E = level_graph().end();
	for ( ; I != E; ++I)
		if (!inside(level_graph().vertex(I),true)) {
			start_vertex_id			= level_graph().vertex(I);
			break;
		}

	if (!level_graph().valid_vertex_id(start_vertex_id)) {
		Msg							("Warning : restrictor %s covers the whole AI map");
		return;
	}

	level_graph().set_mask			(m_border);
	
	xr_vector<u32>					nodes;
	
	graph_engine().search			(
		level_graph(),
		start_vertex_id,
		start_vertex_id,
		&nodes,
		GraphEngineSpace::CFlooder(
			GraphEngineSpace::_dist_type(6000),
			GraphEngineSpace::_iteration_type(-1),
			u32(-1)
		)
	);

	level_graph().clear_mask		(m_border);

	VERIFY							(nodes.size() + m_internal.size() <= level_graph().header().vertex_count());
	if (nodes.size() + m_internal.size() == level_graph().header().vertex_count())
		return;

	Msg								("! %d nodes are disconnected!",level_graph().header().vertex_count() - (nodes.size() + m_internal.size()));

	R_ASSERT3						(
		nodes.size() + m_internal.size() == level_graph().header().vertex_count(),
		"Restrictor separates AI map into several disconnected components",
		object().name_replace()
	);
}