コード例 #1
0
CALifeSimulator::CALifeSimulator		(xrServer *server, shared_str *command_line) :
	CALifeUpdateManager(server, alife_section),
	CALifeSimulatorBase			(server,alife_section)
{
	restart_all					();

	ai().set_alife				(this);

	setup_command_line			(command_line);

	typedef IGame_Persistent::params params;
	params						&p = g_pGamePersistent->m_game_params;
	
	R_ASSERT2					(
		xr_strlen(p.m_game_or_spawn) && 
		!xr_strcmp(p.m_alife,"alife") && 
		!xr_strcmp(p.m_game_type,"single"),
		"Invalid server options!"
	);
	
	string256					temp;
	xr_strcpy						(temp,p.m_game_or_spawn);
	xr_strcat						(temp,"/");
	xr_strcat						(temp,p.m_game_type);
	xr_strcat						(temp,"/");
	xr_strcat						(temp,p.m_alife);
	*command_line				= temp;
	
	LPCSTR						start_game_callback = pSettings->r_string(alife_section,"start_game_callback");
	luabind::functor<void>		functor;
	R_ASSERT2					(ai().script_engine().functor(start_game_callback,functor),"failed to get start game callback");
	functor						();

	load						(p.m_game_or_spawn,!xr_strcmp(p.m_new_or_load,"load") ? false : true, !xr_strcmp(p.m_new_or_load,"new"));
}
コード例 #2
0
void CSE_SmartCover::check_enterable_loopholes(shared_str const &description)
{
	string256					temp;
	xr_strcpy					(temp, "smart_covers.descriptions.");
	xr_strcat					(temp, m_description.c_str());
	xr_strcat					(temp, ".transitions");

	luabind::object				transitions;
	bool						result = 
		ai().script_engine().function_object(
		temp,
		transitions,
		LUA_TTABLE
		);
	VERIFY2						(result, make_string("bad or missing transitions table in smart_cover [%s]", temp));

	luabind::object::iterator	I = transitions.begin();
	luabind::object::iterator	E = transitions.end();
	for ( ; I != E; ++I) {
		luabind::object			table = *I;
		if (table.type() != LUA_TTABLE) {
			VERIFY	(table.type() != LUA_TNIL);
			continue;
		}

		shared_str				vertex_0 = smart_cover::parse_vertex(table, "vertex0", true);
		if (vertex_0 != smart_cover::transform_vertex("", true))
			continue;

		set_enterable			(smart_cover::parse_vertex(table, "vertex1", false));
	}
}
コード例 #3
0
ファイル: xr_dsa.cpp プロジェクト: 2asoft/xray-16
void print_big_number(BIGNUM* big_num, u32 max_columns = 8)
{
	u8			bin_buff[xr_dsa::public_key_length];//public_key_length is the max
	int			bin_size = 0;

	string4096	result_buffer;
	string16	tmp_buff;

	ZeroMemory	(bin_buff, sizeof(bin_buff));
	BN_bn2bin	(big_num, bin_buff);
	bin_size	= big_num->top * sizeof(unsigned long);

	result_buffer[0] = 0;
	xr_strcat(result_buffer, "\t");
	for (int i = 0; i < bin_size; ++i)
	{
		if (((i % max_columns) == 0) && (i > 0))
		{
			xr_strcat(result_buffer, "\n\t");
		}
		xr_sprintf(tmp_buff, "0x%02x, ", bin_buff[i]);
		xr_strcat(result_buffer, tmp_buff);
	}
	Msg(result_buffer);
};
コード例 #4
0
IC	void construct_id_string					(LPSTR result, const xr_vector<ALife::_OBJECT_ID> &restrictions)
{
	xr_strcpy			(result,"");
	string16		temp;
	u32				count = 0;
	xr_vector<ALife::_OBJECT_ID>::const_iterator	I = restrictions.begin();
	xr_vector<ALife::_OBJECT_ID>::const_iterator	E = restrictions.end();
	for ( ; I != E; ++I) {
		if (count)
			xr_strcat	(result,",");
		xr_sprintf		(temp,"%d",*I);
		xr_strcat		(result,temp);
		++count;
	}
}
コード例 #5
0
ファイル: FileSystem.cpp プロジェクト: Frankie-666/xray-16
LPCSTR EFS_Utils::AppendFolderToName(LPCSTR src_name, LPSTR dest_name, u32 const dest_name_size, int depth, BOOL full_name)
{
    shared_str tmp = src_name;
    LPCSTR s = src_name;
    LPSTR d = dest_name;
    int sv_depth = depth;
    for (; *s&&depth; s++, d++)
    {
        if (*s == '_') {
            depth--;
            *d = '\\';
        }
        else {
            *d = *s;
        }
    }
    if (full_name)
    {
        *d = 0;
        if (depth < sv_depth) xr_strcat(dest_name, dest_name_size, *tmp);
    }
    else
    {
        for (; *s; s++, d++) *d = *s;
        *d = 0;
    }
    return dest_name;
}
コード例 #6
0
void CUISkinSelectorWnd::UpdateSkins()
{
	for (int i = 0; i<6; i++)
	{
		if (!!m_shader)
            m_pImage[i]->InitTextureEx(m_skins[i + m_firstSkin].c_str(), m_shader.c_str());
		else
			m_pImage[i]->InitTexture(m_skins[i + m_firstSkin].c_str());

		if (m_iActiveIndex - m_firstSkin == i)
			m_pImage[i]->SetSelectedState(true);
		else
			m_pImage[i]->SetSelectedState(false);

		string16 buf;
		if (m_firstSkin + i < 10)
		{
			itoa((m_firstSkin + 1 + i)%10,buf,10);
			xr_strcat( buf, sizeof(buf), " " );
			m_pImage[i]->TextItemControl()->SetText(buf);
		}
		else
			m_pImage[i]->TextItemControl()->SetText("");

		xr_vector<int>::iterator it = std::find(m_skinsEnabled.begin(), m_skinsEnabled.end(), i + m_firstSkin);
		m_pImage[i]->Enable(it != m_skinsEnabled.end());
	}

//	m_pButtons[0]->Enable(m_firstSkin > 0);
//	m_pButtons[1]->Enable(m_firstSkin + 4 < (int)m_skins.size());
}
コード例 #7
0
BOOL is_combat_cover			(shared_str const &table_id)
{
	if (table_id.size() == 0)
		return					(FALSE);

	string256					temp;
	xr_strcpy					(temp, "smart_covers.descriptions.");
	xr_strcat					(temp, *table_id);

	luabind::object				table, value;
	bool						result = 
		ai().script_engine().function_object(
		temp,
		table,
		LUA_TTABLE
		);

	VERIFY2						(result, make_string("bad or missing description in smart_cover [%s]", table_id.c_str()));
	if (table.type() != LUA_TTABLE) {
		VERIFY					(table.type() != LUA_TNIL);
		return					(TRUE);
	}

	value						= table["is_combat_cover"];
	if (value.type() == LUA_TNIL) {
		Msg						("! is_combat_cover flag not found for smart_cover [%s], forcing to \"true\"", table_id.c_str());
		return					(TRUE);
	}

	return						(parse_bool(table, "is_combat_cover") ? TRUE : FALSE);
}
コード例 #8
0
ファイル: game_sv_base.cpp プロジェクト: AntonioModer/xray-16
void game_sv_GameState::GenerateNewName			(char const * old_name, char * dest, u32 const dest_size)
{
	u32 old_name_size = xr_strlen(old_name);
	R_ASSERT(old_name && old_name_size);

	static char const suffix_symbol = '#';

	char const * currc = old_name + old_name_size - 1;
	while (currc > old_name)
	{
		if (*currc == suffix_symbol)
			break;
		
		--currc;
	}
	if (*currc != suffix_symbol)
		currc = old_name + old_name_size - 1;
	
	int		curret_number = atoi(currc + 1);
	++curret_number;

	u32		name_length = static_cast<u32>(currc - old_name);
	char	new_suffix[16];
	

	strncpy_s	(dest, dest_size, old_name, name_length);
	xr_sprintf	(new_suffix, "%c%u", suffix_symbol, curret_number);
	xr_strcat	(dest, dest_size, new_suffix);
}
コード例 #9
0
ファイル: xr_ioc_cmd.cpp プロジェクト: BubbaXXX/xray-16
    virtual void Execute(LPCSTR args)
    {
        string_path cfg_full_name;
        xr_strcpy(cfg_full_name, (xr_strlen(args) > 0) ? args : Console->ConfigFile);

        bool b_abs_name = xr_strlen(cfg_full_name) > 2 && cfg_full_name[1] == ':';

        if (!b_abs_name)
            FS.update_path(cfg_full_name, "$app_data_root$", cfg_full_name);

        if (strext(cfg_full_name))
            *strext(cfg_full_name) = 0;
        xr_strcat(cfg_full_name, ".ltx");

        BOOL b_allow = TRUE;
        if (FS.exist(cfg_full_name))
            b_allow = SetFileAttributes(cfg_full_name, FILE_ATTRIBUTE_NORMAL);

        if (b_allow)
        {
            IWriter* F = FS.w_open(cfg_full_name);
            CConsole::vecCMD_IT it;
            for (it = Console->Commands.begin(); it != Console->Commands.end(); it++)
                it->second->Save(F);
            FS.w_close(F);
            Msg("Config-file [%s] saved successfully", cfg_full_name);
        }
        else
            Msg("!Cannot store config file [%s]", cfg_full_name);
    }
コード例 #10
0
IC	void construct_string					(LPSTR result, u32 const result_size, const xr_vector<ALife::_OBJECT_ID> &restrictions)
{
	u32		count = xr_strlen(result) ? _GetItemCount(result) : 0;
	xr_vector<ALife::_OBJECT_ID>::const_iterator	I = restrictions.begin();
	xr_vector<ALife::_OBJECT_ID>::const_iterator	E = restrictions.end();
	for ( ; I != E; ++I) {
		CSE_ALifeDynamicObject	*object = ai().alife().objects().object(*I);
		if (ai().game_graph().vertex(object->m_tGraphID)->level_id() != ai().level_graph().level_id())
			continue;

		if (count)
			xr_strcat(result,result_size,",");
		xr_strcat(result,result_size,object->name_replace());
		++count;
	}
}
コード例 #11
0
ファイル: CustomOutfit.cpp プロジェクト: AntonioModer/xray-16
void CCustomOutfit::ApplySkinModel(CActor* pActor, bool bDress, bool bHUDOnly)
{
	if(bDress)
	{
		if(!bHUDOnly && m_ActorVisual.size())
		{
			shared_str NewVisual = NULL;
			char* TeamSection = Game().getTeamSection(pActor->g_Team());
			if (TeamSection)
			{
				if (pSettings->line_exist(TeamSection, *cNameSect()))
				{
					NewVisual = pSettings->r_string(TeamSection, *cNameSect());
					string256 SkinName;

					xr_strcpy(SkinName, pSettings->r_string("mp_skins_path", "skin_path"));
					xr_strcat(SkinName, *NewVisual);
					xr_strcat(SkinName, ".ogf");
					NewVisual._set(SkinName);
				}
			}
			if (!NewVisual.size())
				NewVisual = m_ActorVisual;

			pActor->ChangeVisual(NewVisual);
		}


		if (pActor == Level().CurrentViewEntity())	
			g_player_hud->load(pSettings->r_string(cNameSect(),"player_hud_section"));
	}else
	{
		if (!bHUDOnly && m_ActorVisual.size())
		{
			shared_str DefVisual	= pActor->GetDefaultVisualOutfit();
			if (DefVisual.size())
			{
				pActor->ChangeVisual(DefVisual);
			};
		}

		if (pActor == Level().CurrentViewEntity())	
			g_player_hud->load_default();
	}

}
コード例 #12
0
ファイル: UILogsWnd.cpp プロジェクト: AntonioModer/xray-16
void CUILogsWnd::Init()
{
	m_uiXml.Load( CONFIG_PATH, UI_PATH, PDA_LOGS_XML );

	CUIXmlInit::InitWindow( m_uiXml, "main_wnd", 0, this );

//	m_background		= UIHelper::CreateFrameLine( m_uiXml, "background", this );
	m_background				= UIHelper::CreateFrameWindow(m_uiXml, "background", this);
	m_center_background			= UIHelper::CreateFrameWindow(m_uiXml, "center_background", this);
	
	//m_actor_ch_info = xr_new<CUICharacterInfo>();
	//m_actor_ch_info->SetAutoDelete( true );
	//AttachChild( m_actor_ch_info );
	//m_actor_ch_info->InitCharacterInfo( &m_uiXml, "actor_ch_info" );

//	m_center_background	= UIHelper::CreateStatic( m_uiXml, "center_background", this );
	m_center_caption	= UIHelper::CreateTextWnd( m_uiXml, "center_caption", this );

	string256 buf;
	xr_strcpy( buf, sizeof(buf), m_center_caption->GetText() );
	xr_strcat( buf, sizeof(buf), CStringTable().translate("ui_logs_center_caption").c_str() );
	m_center_caption->SetText( buf );

	CUIFixedScrollBar* tmp_scroll = xr_new<CUIFixedScrollBar>();
	m_list = xr_new<CUIScrollView>(tmp_scroll);
	m_list->SetAutoDelete( true );
	AttachChild( m_list );
	CUIXmlInit::InitScrollView( m_uiXml, "logs_list", 0, m_list);
//	m_list->SetWindowName("---logs_list");
//	m_logs_list->m_sort_function = fastdelegate::MakeDelegate( this, &CUIRankingWnd::SortingLessFunction );

	m_filter_news = UIHelper::CreateCheck( m_uiXml, "filter_news", this );
	m_filter_talk = UIHelper::CreateCheck( m_uiXml, "filter_talk", this );
	m_filter_news->SetCheck( true );
	m_filter_talk->SetCheck( true );

//	m_date_caption = UIHelper::CreateTextWnd( m_uiXml, "date_caption", this );
//	m_date         = UIHelper::CreateTextWnd( m_uiXml, "date", this );

	m_period_caption = UIHelper::CreateTextWnd( m_uiXml, "period_caption", this );
	m_period         = UIHelper::CreateTextWnd( m_uiXml, "period", this );

	m_prev_period = UIHelper::Create3tButton( m_uiXml, "btn_prev_period", this );
	m_next_period = UIHelper::Create3tButton( m_uiXml, "btn_next_period", this );

	Register( m_filter_news );
	Register( m_filter_talk );
	Register( m_prev_period );
	Register( m_next_period );

	AddCallback( m_filter_news, BUTTON_CLICKED, CUIWndCallback::void_function( this, &CUILogsWnd::UpdateChecks ) );
	AddCallback( m_filter_talk, BUTTON_CLICKED, CUIWndCallback::void_function( this, &CUILogsWnd::UpdateChecks ) );
	AddCallback( m_prev_period, BUTTON_CLICKED, CUIWndCallback::void_function( this, &CUILogsWnd::PrevPeriod ) );
	AddCallback( m_next_period, BUTTON_CLICKED, CUIWndCallback::void_function( this, &CUILogsWnd::NextPeriod ) );

	m_start_game_time = Level().GetStartGameTime();
	m_start_game_time = GetShiftPeriod( m_start_game_time, 0 );
}
コード例 #13
0
ファイル: MainMenu.cpp プロジェクト: AntonioModer/xray-16
void	CMainMenu::OnLoadError				(LPCSTR module)
{
	LPCSTR str=CStringTable().translate("ui_st_error_loading").c_str();
	string1024 Text;
	strconcat(sizeof(Text),Text,str," ");
	xr_strcat(Text,sizeof(Text),module);
	m_pMB_ErrDlgs[LoadingError]->SetText(Text);
	SetErrorDialog(CMainMenu::LoadingError);
}
コード例 #14
0
void CScriptCallStack::Add(const char *szDesc, const char *szFile, int nLine)
{
	m_lines.push_back(nLine);

	SPath	sp;
	sp.path[0] = 0;
	m_files.push_back(sp);
	xr_strcat(m_files.back().path, szFile );
}
コード例 #15
0
IC	void CRestrictedObject::construct_restriction_string(LPSTR temp_restrictions, u32 const temp_restrictions_size, const xr_vector<ALife::_OBJECT_ID> &restrictions, shared_str current_restrictions, const P &p)
{
	u32							count = 0;
	*temp_restrictions			= 0;
	xr_vector<ALife::_OBJECT_ID>::const_iterator	I = restrictions.begin();
	xr_vector<ALife::_OBJECT_ID>::const_iterator	E = restrictions.end();
	for ( ; I != E; ++I) {
		CObject					*object = Level().Objects.net_Find(*I);
		if (!object || !!strstr(*current_restrictions,*object->cName()) == value)
			continue;

		p						(this,object->ID());

		if (count)
			xr_strcat(temp_restrictions,temp_restrictions_size,",");

		xr_strcat(temp_restrictions,temp_restrictions_size,*object->cName());

		count++;
	}
}
コード例 #16
0
ファイル: UIMapList.cpp プロジェクト: BeaconDev/xray-16
void CUIMapList::StartDedicatedServer(){

	string_path ModuleFileName;		
	GetModuleFileName(NULL, ModuleFileName, sizeof(ModuleFileName));

	char* ModuleName	= NULL;
	GetFullPathName		(ModuleFileName, sizeof(g_sLaunchWorkingFolder), g_sLaunchWorkingFolder, &ModuleName);
	//removing module name from WorkingDirectory that contain full path...
	ModuleName[0]		= 0;
			
	xr_strcpy			(g_sLaunchOnExit_app, g_sLaunchWorkingFolder);
	xr_strcat			(g_sLaunchOnExit_app, "dedicated\\xrEngine.exe");

	xr_strcpy			(g_sLaunchOnExit_params, g_sLaunchOnExit_app);
	xr_strcat			(g_sLaunchOnExit_params, " -i -fsltx ..\\fsgame.ltx -nosound -");
	xr_strcat			(g_sLaunchOnExit_params, GetCommandLine(""));
	Msg					("Going to quit before starting dedicated server");
	Msg					("Working folder is:%s", g_sLaunchWorkingFolder);
	Msg					("%s %s",g_sLaunchOnExit_app, g_sLaunchOnExit_params);
	Console->Execute	("quit");
}
コード例 #17
0
ファイル: MainMenu.cpp プロジェクト: AntonioModer/xray-16
void CMainMenu::ReadTextureInfo()
{
	FS_FileSet fset;
	FS.file_list(fset, "$game_config$", FS_ListFiles,"ui\\textures_descr\\*.xml");
	FS_FileSetIt fit	= fset.begin();
	FS_FileSetIt fit_e	= fset.end();

	for( ;fit!=fit_e; ++fit)
	{
    	string_path	fn1, fn2,fn3;
        _splitpath	((*fit).name.c_str(),fn1,fn2,fn3,0);
		xr_strcat(fn3,".xml");

		CUITextureMaster::ParseShTexInfo(fn3);
	}

}
コード例 #18
0
ファイル: xr_ioc_cmd.cpp プロジェクト: BubbaXXX/xray-16
void CCC_LoadCFG::Execute(LPCSTR args)
{
    Msg("Executing config-script \"%s\"...", args);
    string_path cfg_name;

    xr_strcpy(cfg_name, args);
    if (strext(cfg_name)) *strext(cfg_name) = 0;
    xr_strcat(cfg_name, ".ltx");

    string_path cfg_full_name;

    FS.update_path(cfg_full_name, "$app_data_root$", cfg_name);

    if (NULL == FS.exist(cfg_full_name))
        FS.update_path(cfg_full_name, "$fs_root$", cfg_name);

    if (NULL == FS.exist(cfg_full_name))
        xr_strcpy(cfg_full_name, cfg_name);

    IReader* F = FS.r_open(cfg_full_name);

    string1024 str;
    if (F != NULL)
    {
        while (!F->eof())
        {
            F->r_string(str, sizeof(str));
            if (allow(str))
                Console->Execute(str);
        }
        FS.r_close(F);
        Msg("[%s] successfully loaded.", cfg_full_name);
    }
    else
    {
        Msg("! Cannot open script file [%s]", cfg_full_name);
    }
}
コード例 #19
0
ファイル: script_engine.cpp プロジェクト: denanden/xray-16
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 = xr_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));
            xr_strcat(I, "_initialize");
            if (object("_G", I, LUA_TFUNCTION))
            {
                //				lua_dostring			(lua(),xr_strcat(I,"()"));
                luabind::functor<void>	f;
                R_ASSERT(functor(I, f));
                f();
            }
        }
    }

    xr_delete(l_tpIniFile);
}
コード例 #20
0
void message_filter::dbg_print_msg(NET_Packet & packet, msg_type_subtype_t const & msg_type)
{
	string256	tmp_string;
	switch (msg_type.msg_type)
	{
	case M_EVENT:
		{
			switch (msg_type.msg_subtype)
			{
			case GE_DESTROY:
				{
					xr_sprintf(tmp_string, "--- CL_EVENT [%7u][%5u]: GE_DESTROY", msg_type.msg_receive_time, msg_type.dest_obj_id);
				}break;
			case GE_OWNERSHIP_TAKE:
				{
					u16 tmp_id_what;
					packet.r_u16(tmp_id_what);
					xr_sprintf(tmp_string, "--- CL_EVENT [%7u][%5u]: GE_OWNERSHIP_TAKE    [%d]", msg_type.msg_receive_time, msg_type.dest_obj_id, tmp_id_what);
				}break;
			case GE_OWNERSHIP_REJECT:
				{
					u16 tmp_id_what;
					packet.r_u16(tmp_id_what);
					xr_sprintf(tmp_string, "--- CL_EVENT [%7u][%5u]: GE_OWNERSHIP_REJECT  [%d]", msg_type.msg_receive_time, msg_type.dest_obj_id, tmp_id_what);
				}break;
			default:
				{
					xr_sprintf(tmp_string, "--- CL_EVENT [%7u][%5u]: EVENT_ID=[%d]", msg_type.msg_receive_time, msg_type.dest_obj_id, msg_type.msg_subtype);
				};
			}; //switch (mtype.msg_subtype)
		}break;
	case M_EVENT_PACK:
		{
			FATAL("can't print M_EVENT_PACK message");
		}break;
	case M_GAMEMESSAGE:
		{
			switch (msg_type.msg_subtype)
			{
			case GAME_EVENT_PLAYER_KILLED:
				{
					xr_sprintf(tmp_string, "--- GM_EVENT [%7u]: GAME_EVENT_PLAYER_KILLED", msg_type.msg_receive_time);
				}break;
			case GAME_EVENT_ROUND_STARTED:
				{
					xr_sprintf(tmp_string, "--- GM_EVENT [%7u]: GAME_EVENT_ROUND_STARTED", msg_type.msg_receive_time);
				}break;
			case GAME_EVENT_ARTEFACT_TAKEN:
				{
					xr_sprintf(tmp_string, "--- GM_EVENT [%7u]: GAME_EVENT_ARTEFACT_TAKEN", msg_type.msg_receive_time);	
				}break;
			default:
				{
					xr_sprintf(tmp_string, "--- GM_EVENT [%7u]: GAME_EVENT_ID=[%d]", msg_type.msg_receive_time, msg_type.msg_subtype);	
				};
			}
		}break;
	case M_CHAT_MESSAGE:
		{
		}break;
	case M_SPAWN:
		{
			xr_sprintf(tmp_string, "--- M_SPAWN                [%7u]", msg_type.msg_receive_time);
		}break;
	case M_SV_CONFIG_NEW_CLIENT:
		{
			xr_sprintf(tmp_string, "--- M_SV_CONFIG_NEW_CLIENT [%7u]", msg_type.msg_receive_time);
		}break;
	case M_SV_CONFIG_GAME:
		{
			xr_sprintf(tmp_string, "--- M_SV_CONFIG_GAME       [%7u]", msg_type.msg_receive_time);
		}break;
	case M_SV_CONFIG_FINISHED:
		{
			xr_sprintf(tmp_string, "--- M_SV_CONFIG_FINISHED   [%7u]", msg_type.msg_receive_time);
		}break;
	default:
		{
			xr_sprintf(tmp_string, "--- MESSAGE_ID[%u]         [%7u]", msg_type.msg_type, msg_type.msg_receive_time);
		};
	}; //switch (m_type)
	if (!xr_strcmp(tmp_string, m_last_string))
	{
		++m_strrepeat_count;
		return;
	} 
	Msg(tmp_string);
	xr_strcpy(m_last_string, tmp_string);
	if (m_msg_log_file)
	{
		if (m_strrepeat_count)
		{
			m_msg_log_file->w_printf(". %d\n", m_strrepeat_count);
		}
		xr_strcat(tmp_string, "\n");
		m_msg_log_file->w_stringZ(tmp_string);
		m_msg_log_file->flush();
	}
	m_strrepeat_count = 0;
}
コード例 #21
0
ファイル: xrDebug.cpp プロジェクト: AntonioModer/xray-16
LONG WINAPI UnhandledFilter	( struct _EXCEPTION_POINTERS *pExceptionInfo )
{
	LONG retval		= EXCEPTION_CONTINUE_SEARCH;
	bException		= TRUE;

	// firstly see if dbghelp.dll is around and has the function we need
	// look next to the EXE first, as the one in System32 might be old 
	// (e.g. Windows 2000)
	HMODULE hDll	= NULL;
	string_path		szDbgHelpPath;

	if (GetModuleFileName( NULL, szDbgHelpPath, _MAX_PATH ))
	{
		char *pSlash = strchr( szDbgHelpPath, '\\' );
		if (pSlash)
		{
			xr_strcpy	(pSlash+1, "DBGHELP.DLL" );
			hDll = ::LoadLibrary( szDbgHelpPath );
		}
	}

	if (hDll==NULL)
	{
		// load any version we can
		hDll = ::LoadLibrary( "DBGHELP.DLL" );
	}

	LPCTSTR szResult = NULL;

	if (hDll)
	{
		MINIDUMPWRITEDUMP pDump = (MINIDUMPWRITEDUMP)::GetProcAddress( hDll, "MiniDumpWriteDump" );
		if (pDump)
		{
			string_path	szDumpPath;
			string_path	szScratch;
			string64	t_stemp;

			// work out a good place for the dump file
			timestamp	(t_stemp);
			xr_strcpy		( szDumpPath, "logs\\"				);
			xr_strcat		( szDumpPath, Core.ApplicationName	);
			xr_strcat		( szDumpPath, "_"					);
			xr_strcat		( szDumpPath, Core.UserName			);
			xr_strcat		( szDumpPath, "_"					);
			xr_strcat		( szDumpPath, t_stemp				);
			xr_strcat		( szDumpPath, ".mdmp"				);

			// create the file
			HANDLE hFile = ::CreateFile( szDumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
			if (INVALID_HANDLE_VALUE==hFile)	
			{
				// try to place into current directory
				MoveMemory	(szDumpPath,szDumpPath+5,strlen(szDumpPath));
				hFile		= ::CreateFile( szDumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
			}
			if (hFile!=INVALID_HANDLE_VALUE)
			{
				_MINIDUMP_EXCEPTION_INFORMATION ExInfo;

				ExInfo.ThreadId				= ::GetCurrentThreadId();
				ExInfo.ExceptionPointers	= pExceptionInfo;
				ExInfo.ClientPointers		= NULL;

				// write the dump
				MINIDUMP_TYPE	dump_flags	= MINIDUMP_TYPE(MiniDumpNormal | MiniDumpFilterMemory | MiniDumpScanMemory );

				BOOL bOK = pDump( GetCurrentProcess(), GetCurrentProcessId(), hFile, dump_flags, &ExInfo, NULL, NULL );
				if (bOK)
				{
					xr_sprintf( szScratch, "Saved dump file to '%s'", szDumpPath );
					szResult = szScratch;
					retval = EXCEPTION_EXECUTE_HANDLER;
				}
				else
				{
					xr_sprintf( szScratch, "Failed to save dump file to '%s' (error %d)", szDumpPath, GetLastError() );
					szResult = szScratch;
				}
				::CloseHandle(hFile);
			}
			else
			{
				xr_sprintf( szScratch, "Failed to create dump file '%s' (error %d)", szDumpPath, GetLastError() );
				szResult = szScratch;
			}
		}
		else
		{
			szResult = "DBGHELP.DLL too old";
		}
	}
	else
	{
		szResult = "DBGHELP.DLL not found";
	}

	string1024		reason;
	xr_sprintf			(reason,"*** Internal Error ***\n%s",szResult);
    bool ref		= false;
	Debug.backend	(reason,0,0,0,0,0,0,ref);

	return retval;
}
コード例 #22
0
ファイル: uber_deffer.cpp プロジェクト: 2asoft/xray-16
void uber_shadow(CBlender_Compile& C, LPCSTR _vspec)
{
	// Uber-parse
	string256		fname,fnameA,fnameB;
	xr_strcpy			(fname,*C.L_textures[0]);	//. andy if (strext(fname)) *strext(fname)=0;
	fix_texture_name(fname);
	ref_texture		_t;		_t.create			(fname);
	bool			bump	= _t.bump_exist		();

	// detect lmap
	bool			lmap	= true;
	if	(C.L_textures.size()<3)	lmap = false;
	else 
	{
		pcstr		tex		= C.L_textures[2].c_str();
		if (tex[0]=='l' && tex[1]=='m' && tex[2]=='a' && tex[3]=='p')	lmap = true	;
		else															lmap = false;
	}


	string256		vs,dt;
	xr_strcpy		(dt,sizeof(dt),C.detail_texture?C.detail_texture:"");

	// detect detail bump
	string256		texDetailBump = {'\0'};
	string256		texDetailBumpX = {'\0'};
	bool			bHasDetailBump = false;
	if (C.bDetail_Bump)
	{
		LPCSTR detail_bump_texture = DEV->m_textures_description.GetBumpName(dt).c_str();
		//	Detect and use detail bump
		if ( detail_bump_texture )
		{
			bHasDetailBump = true;
			xr_strcpy		( texDetailBump, sizeof(texDetailBump), detail_bump_texture);
			xr_strcpy		( texDetailBumpX, sizeof(texDetailBumpX), detail_bump_texture);
			xr_strcat			( texDetailBumpX, "#");
		}
	}


	if	(!bump)		
	{
		fnameA[0] = fnameB[0] = 0;
	} 
	else 
	{
		xr_strcpy			(fnameA,_t.bump_get().c_str());
		strconcat		(sizeof(fnameB),fnameB,fnameA,"#");
	}

	if (bump && RImplementation.o.dx11_enable_tessellation && C.TessMethod!=0)
	{
		char hs[256], ds[256];// = "DX11\\tess", ds[256] = "DX11\\tess";
		char params[256] = "(";
		
		if (C.TessMethod == CBlender_Compile::TESS_PN || C.TessMethod == CBlender_Compile::TESS_PN_HM)
		{
			RImplementation.addShaderOption("TESS_PN", "1");
			xr_strcat(params, "TESS_PN,");
		}

		if (C.TessMethod == CBlender_Compile::TESS_HM || C.TessMethod == CBlender_Compile::TESS_PN_HM)
		{
			RImplementation.addShaderOption("TESS_HM", "1");
			xr_strcat(params, "TESS_HM,");
		}

		if (lmap)
		{
			RImplementation.addShaderOption("USE_LM_HEMI", "1");
			xr_strcat(params, "USE_LM_HEMI,");
		}

		if (C.bDetail_Diffuse)
		{
			RImplementation.addShaderOption("USE_TDETAIL", "1");
			xr_strcat(params, "USE_TDETAIL,");
		}

		if (C.bDetail_Bump)
		{
			RImplementation.addShaderOption("USE_TDETAIL_BUMP", "1");
			xr_strcat(params, "USE_TDETAIL_BUMP,");
		}
		
		xr_strcat(params, ")");

		strconcat(sizeof(vs),vs,"deffer_", _vspec, "_bump", params);
		strconcat(sizeof(hs),hs,"DX11\\tess", params);
		strconcat(sizeof(ds),ds,"DX11\\tess_shadow", params);
	
		C.r_TessPass	(vs, hs, ds, "null", "dumb", FALSE,TRUE,TRUE,FALSE);
		RImplementation.clearAllShaderOptions();
		C.r_dx10Texture		("s_base",		C.L_textures[0]);
		C.r_dx10Texture		("s_bumpX",		fnameB);	// should be before base bump
		C.r_dx10Texture		("s_bump",		fnameA);
		if (bHasDetailBump)
		{
			C.r_dx10Texture	("s_detailBump",	texDetailBump);
			C.r_dx10Texture	("s_detailBumpX",	texDetailBumpX);
		}
		u32 stage = C.r_dx10Sampler("smp_bump_ds");
		if (stage != -1)
		{
			C.i_dx10Address(stage, D3DTADDRESS_WRAP);
			C.i_dx10FilterAnizo(stage, TRUE);
		}
		if (ps_r2_ls_flags_ext.test(R2FLAGEXT_WIREFRAME))
			C.R().SetRS(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
	}
	else
		C.r_Pass	("shadow_direct_base","dumb",	FALSE,TRUE,TRUE,FALSE);
}
コード例 #23
0
ファイル: xrCompress.cpp プロジェクト: AntonioModer/xray-16
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();
}
コード例 #24
0
ファイル: uber_deffer.cpp プロジェクト: 2asoft/xray-16
void	uber_deffer	(CBlender_Compile& C, bool hq, LPCSTR _vspec, LPCSTR _pspec, BOOL _aref, LPCSTR _detail_replace, bool DO_NOT_FINISH)
{
	// Uber-parse
	string256		fname,fnameA,fnameB;
	xr_strcpy			(fname,*C.L_textures[0]);	//. andy if (strext(fname)) *strext(fname)=0;
	fix_texture_name(fname);
	ref_texture		_t;		_t.create			(fname);
	bool			bump	= _t.bump_exist		();

	// detect lmap
	bool			lmap	= true;
	if	(C.L_textures.size()<3)	lmap = false;
	else 
	{
		pcstr		tex		= C.L_textures[2].c_str();
		if (tex[0]=='l' && tex[1]=='m' && tex[2]=='a' && tex[3]=='p')	lmap = true	;
		else															lmap = false;
	}


	string256		ps,vs,dt;
	strconcat		(sizeof(vs),vs,"deffer_", _vspec, lmap?"_lmh":""	);
	strconcat		(sizeof(ps),ps,"deffer_", _pspec, lmap?"_lmh":""	);
	xr_strcpy		(dt,sizeof(dt),_detail_replace?_detail_replace:( C.detail_texture?C.detail_texture:"" ) );

	// detect detail bump
	string256		texDetailBump = {'\0'};
	string256		texDetailBumpX = {'\0'};
	bool			bHasDetailBump = false;
	if (C.bDetail_Bump)
	{
		LPCSTR detail_bump_texture = DEV->m_textures_description.GetBumpName(dt).c_str();
		//	Detect and use detail bump
		if ( detail_bump_texture )
		{
			bHasDetailBump = true;
			xr_strcpy		( texDetailBump, sizeof(texDetailBump), detail_bump_texture);
			xr_strcpy		( texDetailBumpX, sizeof(texDetailBumpX), detail_bump_texture);
			xr_strcat			( texDetailBumpX, "#");
		}
	}

	if	(_aref)		
	{ 
		xr_strcat(ps,"_aref");	
	}

	if	(!bump)		
	{
		fnameA[0] = fnameB[0] = 0;
		xr_strcat			(vs,"_flat");
		xr_strcat			(ps,"_flat");
		if (hq && (C.bDetail_Diffuse || C.bDetail_Bump) )	
		{
			xr_strcat		(vs,"_d");
			xr_strcat		(ps,"_d");
		}
	} 
	else 
	{
		xr_strcpy			(fnameA,_t.bump_get().c_str());
		strconcat		(sizeof(fnameB),fnameB,fnameA,"#");
		xr_strcat			(vs,"_bump");
		if (hq && C.bUseSteepParallax)
		{
			xr_strcat			(ps,"_steep");
		}
		else
		{
			xr_strcat			(ps,"_bump");
		}
		if (hq && (C.bDetail_Diffuse || C.bDetail_Bump) )
		{
			xr_strcat		(vs,"_d"	);
			if (bHasDetailBump)
				xr_strcat		(ps,"_db"	);	//	bump & detail & hq
			else
				xr_strcat		(ps,"_d"	);
		}
	}

	// HQ
	if (bump && hq)
	{
		xr_strcat			(vs,"-hq");
		xr_strcat			(ps,"-hq");
	}

	// Uber-construct
#if defined(USE_DX10) || defined(USE_DX11)
#	ifdef USE_DX11
	if (bump && hq && RImplementation.o.dx11_enable_tessellation && C.TessMethod!=0)
	{
		char hs[256], ds[256];// = "DX11\\tess", ds[256] = "DX11\\tess";
		char params[256] = "(";
		
		if (C.TessMethod == CBlender_Compile::TESS_PN || C.TessMethod == CBlender_Compile::TESS_PN_HM)
		{
			RImplementation.addShaderOption("TESS_PN", "1");
			xr_strcat(params, "TESS_PN,");
		}

		if (C.TessMethod == CBlender_Compile::TESS_HM || C.TessMethod == CBlender_Compile::TESS_PN_HM)
		{
			RImplementation.addShaderOption("TESS_HM", "1");
			xr_strcat(params, "TESS_HM,");
		}

		if (lmap)
		{
			RImplementation.addShaderOption("USE_LM_HEMI", "1");
			xr_strcat(params, "USE_LM_HEMI,");
		}

		if (C.bDetail_Diffuse)
		{
			RImplementation.addShaderOption("USE_TDETAIL", "1");
			xr_strcat(params, "USE_TDETAIL,");
		}

		if (C.bDetail_Bump)
		{
			RImplementation.addShaderOption("USE_TDETAIL_BUMP", "1");
			xr_strcat(params, "USE_TDETAIL_BUMP,");
		}
		
		xr_strcat(params, ")");

		strconcat(sizeof(vs),vs,"deffer_", _vspec, "_bump", params);
		strconcat(sizeof(ps),ps,"deffer_", _pspec, _aref?"_aref":"", "_bump", params);
		strconcat(sizeof(hs),hs,"DX11\\tess", params);
		strconcat(sizeof(ds),ds,"DX11\\tess", params);
	
		VERIFY(strstr(vs, "bump")!=0);
		VERIFY(strstr(ps, "bump")!=0);
		C.r_TessPass	(vs, hs, ds, "null", ps, FALSE);
		RImplementation.clearAllShaderOptions();
		u32 stage = C.r_dx10Sampler("smp_bump_ds");
		if (stage != -1)
		{
			C.i_dx10Address(stage, D3DTADDRESS_WRAP);
			C.i_dx10FilterAnizo(stage, TRUE);
		}
		if (ps_r2_ls_flags_ext.test(R2FLAGEXT_WIREFRAME))
			C.R().SetRS(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
		C.r_dx10Texture		("s_tbump",		fnameA);
		C.r_dx10Texture		("s_tbumpX",		fnameB);	// should be before base bump
		if (bHasDetailBump)
		{
			C.r_dx10Texture	("s_tdetailBumpX",	texDetailBumpX);
		}
	}
	else
#	endif
		C.r_Pass		(vs,ps,	FALSE);
	//C.r_Sampler		("s_base",		C.L_textures[0],	false,	D3DTADDRESS_WRAP,	D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR,	D3DTEXF_ANISOTROPIC);
	//C.r_Sampler		("s_bumpX",		fnameB,				false,	D3DTADDRESS_WRAP,	D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR,	D3DTEXF_ANISOTROPIC);	// should be before base bump
	//C.r_Sampler		("s_bump",		fnameA,				false,	D3DTADDRESS_WRAP,	D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR,	D3DTEXF_ANISOTROPIC);
	//C.r_Sampler		("s_bumpD",		dt,					false,	D3DTADDRESS_WRAP,	D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR,	D3DTEXF_ANISOTROPIC);
	//C.r_Sampler		("s_detail",	dt,					false,	D3DTADDRESS_WRAP,	D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR,	D3DTEXF_ANISOTROPIC);
	C.r_dx10Texture		("s_base",		C.L_textures[0]);
	C.r_dx10Texture		("s_bumpX",		fnameB);	// should be before base bump
	C.r_dx10Texture		("s_bump",		fnameA);
	C.r_dx10Texture		("s_bumpD",		dt);
	C.r_dx10Texture		("s_detail",	dt);
	if (bHasDetailBump)
	{
		C.r_dx10Texture	("s_detailBump",	texDetailBump);
		C.r_dx10Texture	("s_detailBumpX",	texDetailBumpX);
	}
	C.r_dx10Sampler		("smp_base");
	if (lmap)
	{
		//C.r_Sampler("s_hemi",	C.L_textures[2],	false,	D3DTADDRESS_CLAMP,	D3DTEXF_LINEAR,		D3DTEXF_NONE,	D3DTEXF_LINEAR);
		C.r_dx10Texture	("s_hemi",	C.L_textures[2]);
		C.r_dx10Sampler	("smp_rtlinear");
	}
#else	//	USE_DX10
	C.r_Pass		(vs,ps,	FALSE);
	VERIFY(C.L_textures[0].size());
	if(bump)
	{
		VERIFY2(xr_strlen(fnameB), C.L_textures[0].c_str());
		VERIFY2(xr_strlen(fnameA), C.L_textures[0].c_str());
	}
	if(bHasDetailBump)
	{
		VERIFY2(xr_strlen(texDetailBump), C.L_textures[0].c_str());
		VERIFY2(xr_strlen(texDetailBumpX), C.L_textures[0].c_str());
	}
	C.r_Sampler		("s_base",		C.L_textures[0],	false,	D3DTADDRESS_WRAP,	D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR,	D3DTEXF_ANISOTROPIC);
	C.r_Sampler		("s_bumpX",		fnameB,				false,	D3DTADDRESS_WRAP,	D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR,	D3DTEXF_ANISOTROPIC);	// should be before base bump
	C.r_Sampler		("s_bump",		fnameA,				false,	D3DTADDRESS_WRAP,	D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR,	D3DTEXF_ANISOTROPIC);
	C.r_Sampler		("s_bumpD",		dt,					false,	D3DTADDRESS_WRAP,	D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR,	D3DTEXF_ANISOTROPIC);
	C.r_Sampler		("s_detail",	dt,					false,	D3DTADDRESS_WRAP,	D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR,	D3DTEXF_ANISOTROPIC);
	if (bHasDetailBump)
	{
		C.r_Sampler		("s_detailBump", texDetailBump,	false,	D3DTADDRESS_WRAP,	D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR,	D3DTEXF_ANISOTROPIC);
		C.r_Sampler		("s_detailBumpX",texDetailBumpX,false,	D3DTADDRESS_WRAP,	D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR,	D3DTEXF_ANISOTROPIC);
	}
	if (lmap)C.r_Sampler("s_hemi",	C.L_textures[2],	false,	D3DTADDRESS_CLAMP,	D3DTEXF_LINEAR,		D3DTEXF_NONE,	D3DTEXF_LINEAR);
#endif	//	USE_DX10

	if (!DO_NOT_FINISH)		C.r_End	();
}
コード例 #25
0
ファイル: UIGameCustom.cpp プロジェクト: BeaconDev/xray-16
void CMapListHelper::Load()
{
	string_path					fn;
	FS.update_path				(fn, "$game_config$", "mp\\map_list.ltx");
	CInifile map_list_cfg		(fn);

	//read weathers set
	CInifile::Sect w			= map_list_cfg.r_section("weather");
	CInifile::SectCIt wi		= w.Data.begin();
	CInifile::SectCIt wi_e		= w.Data.end();
	for( ;wi!=wi_e; ++wi)
	{
		m_weathers.resize		(m_weathers.size()+1);
		SGameWeathers& gw		= m_weathers.back();
		gw.m_weather_name		= (*wi).first;
		gw.m_start_time			= (*wi).second;
	}

	// scan for additional maps
	FS_FileSet			fset;
	FS.file_list		(fset,"$game_levels$",FS_ListFiles,"*level.ltx");

	FS_FileSetIt fit	= fset.begin();
	FS_FileSetIt fit_e	= fset.end();

	for( ;fit!=fit_e; ++fit)
	{
		string_path					map_cfg_fn;
		FS.update_path				(map_cfg_fn, "$game_levels$", (*fit).name.c_str());
		LoadMapInfo					(map_cfg_fn, (*fit).name);
	}
	//scan all not laoded archieves
	LPCSTR tmp_entrypoint			= "temporary_gamedata\\";
	FS_Path* game_levels			= FS.get_path("$game_levels$");
	xr_string prev_root				= game_levels->m_Root;
	game_levels->_set_root			(tmp_entrypoint);

	CLocatorAPI::archives_it it		= FS.m_archives.begin();
	CLocatorAPI::archives_it it_e	= FS.m_archives.end();

	for(;it!=it_e;++it)
	{
		CLocatorAPI::archive& A		= *it;
		if(A.hSrcFile)				continue;

		LPCSTR ln					= A.header->r_string("header", "level_name");
		LPCSTR lv					= A.header->r_string("header", "level_ver");
		FS.LoadArchive				(A, tmp_entrypoint);

		string_path					map_cfg_fn;
		FS.update_path				(map_cfg_fn, "$game_levels$", ln);

		
		xr_strcat					(map_cfg_fn,"\\level.ltx");
		LoadMapInfo					(map_cfg_fn, ln, lv);
		FS.unload_archive			(A);
	}
	game_levels->_set_root			(prev_root.c_str());


	R_ASSERT2	(m_storage.size(), "unable to fill map list");
	R_ASSERT2	(m_weathers.size(), "unable to fill weathers list");
}
コード例 #26
0
void xrLoad(LPCSTR name, bool draft_mode)
{
	FS.get_path					("$level$")->_set	((LPSTR)name);
	string256					N;
	if (!draft_mode)	{
		// shaders
		string_path				N;
		FS.update_path			(N,"$game_data$","shaders_xrlc.xr");
		g_shaders_xrlc			= xr_new<Shader_xrLC_LIB> ();
		g_shaders_xrlc->Load	(N);

		// Load CFORM
		{
			strconcat			(sizeof(N),N,name,"build.cform");
			IReader*			fs = FS.r_open(N);
			R_ASSERT			(fs->find_chunk(0));

			hdrCFORM			H;
			fs->r				(&H,sizeof(hdrCFORM));
			R_ASSERT			(CFORM_CURRENT_VERSION==H.version);

			Fvector*	verts	= (Fvector*)fs->pointer();
			CDB::TRI*	tris	= (CDB::TRI*)(verts+H.vertcount);
			Level.build			( verts, H.vertcount, tris, H.facecount );
			Level.syncronize	();
			Msg("* Level CFORM: %dK",Level.memory()/1024);

			g_rc_faces.resize	(H.facecount);
			R_ASSERT(fs->find_chunk(1));
			fs->r				(&*g_rc_faces.begin(),g_rc_faces.size()*sizeof(b_rc_face));

			LevelBB.set			(H.aabb);
			FS.r_close			(fs);
		}

		// Load level data
		{
			strconcat			(sizeof(N),N,name,"build.prj");
			IReader*	fs		= FS.r_open (N);
			IReader*	F;

			// Version
			u32 version;
			fs->r_chunk			(EB_Version,&version);
			R_ASSERT			(XRCL_CURRENT_VERSION >= 17);
			R_ASSERT			(XRCL_CURRENT_VERSION <= 18);

			// Header
			b_params			Params;
			fs->r_chunk			(EB_Parameters,&Params);

			// Load level data
			transfer("materials",	g_materials,			*fs,		EB_Materials);
			transfer("shaders_xrlc",g_shader_compile,		*fs,		EB_Shaders_Compile);

			// process textures
			Status			("Processing textures...");
			{
				Surface_Init		();
				F = fs->open_chunk	(EB_Textures);
				u32 tex_count		= F->length()/sizeof(b_texture);
				for (u32 t=0; t<tex_count; t++)
				{
					Progress		(float(t)/float(tex_count));

					b_texture		TEX;
					F->r			(&TEX,sizeof(TEX));

					b_BuildTexture	BT;
					CopyMemory		(&BT,&TEX,sizeof(TEX));

					// load thumbnail
					string128		&N = BT.name;
					LPSTR			extension = strext(N);
					if (extension)
						*extension	= 0;

					xr_strlwr		(N);

					if (0==xr_strcmp(N,"level_lods"))	{
						// HACK for merged lod textures
						BT.dwWidth	= 1024;
						BT.dwHeight	= 1024;
						BT.bHasAlpha= TRUE;
						BT.pSurface	= 0;
					} else {
						xr_strcat		(N,".thm");
						IReader* THM	= FS.r_open("$game_textures$",N);
//						if (!THM)		continue;
						
						R_ASSERT2		(THM,	N);

						// version
						u32 version				= 0;
						R_ASSERT				(THM->r_chunk(THM_CHUNK_VERSION,&version));
						// if( version!=THM_CURRENT_VERSION )	FATAL	("Unsupported version of THM file.");

						// analyze thumbnail information
						R_ASSERT(THM->find_chunk(THM_CHUNK_TEXTUREPARAM));
						THM->r                  (&BT.THM.fmt,sizeof(STextureParams::ETFormat));
						BT.THM.flags.assign		(THM->r_u32());
						BT.THM.border_color		= THM->r_u32();
						BT.THM.fade_color		= THM->r_u32();
						BT.THM.fade_amount		= THM->r_u32();
						BT.THM.mip_filter		= THM->r_u32();
						BT.THM.width			= THM->r_u32();
						BT.THM.height           = THM->r_u32();
						BOOL			bLOD=FALSE;
						if (N[0]=='l' && N[1]=='o' && N[2]=='d' && N[3]=='\\') bLOD = TRUE;

						// load surface if it has an alpha channel or has "implicit lighting" flag
						BT.dwWidth				= BT.THM.width;
						BT.dwHeight				= BT.THM.height;
						BT.bHasAlpha			= BT.THM.HasAlphaChannel();
						BT.pSurface				= 0;
						if (!bLOD) 
						{
							if (BT.bHasAlpha || BT.THM.flags.test(STextureParams::flImplicitLighted))
							{
								clMsg		("- loading: %s",N);
								u32			w=0, h=0;
								BT.pSurface = Surface_Load(N,w,h); 
								R_ASSERT2	(BT.pSurface,"Can't load surface");
								if ((w != BT.dwWidth) || (h != BT.dwHeight))
									Msg		("! THM doesn't correspond to the texture: %dx%d -> %dx%d", BT.dwWidth, BT.dwHeight, w, h);
								BT.Vflip	();
							} else {
								// Free surface memory
							}
						}
					}

					// save all the stuff we've created
					g_textures.push_back	(BT);
				}
			}
		}
	}
	
//	// Load emitters
//	{
//		strconcat			(N,name,"level.game");
//		IReader				*F = FS.r_open(N);
//		IReader				*O = 0;
//		if (0!=(O = F->open_chunk	(AIPOINT_CHUNK))) {
//			for (int id=0; O->find_chunk(id); id++) {
//				Emitters.push_back(Fvector());
//				O->r_fvector3	(Emitters.back());
//			}
//			O->close();
//		}
//	}
//
	// Load lights
	{
		strconcat				(sizeof(N),N,name,"build.prj");

		IReader*	F			= FS.r_open(N);
		R_ASSERT2				(F,"There is no file 'build.prj'!");
		IReader					&fs= *F;

		// Version
		u32 version;
		fs.r_chunk				(EB_Version,&version);
		R_ASSERT				(XRCL_CURRENT_VERSION >= 17);
		R_ASSERT				(XRCL_CURRENT_VERSION <= 18);

		// Header
		b_params				Params;
		fs.r_chunk				(EB_Parameters,&Params);

		// Lights (Static)
		{
			F = fs.open_chunk(EB_Light_static);
			b_light_static	temp;
			u32 cnt		= F->length()/sizeof(temp);
			for				(u32 i=0; i<cnt; i++)
			{
				R_Light		RL;
				F->r		(&temp,sizeof(temp));
				Flight&		L = temp.data;
				if (_abs(L.range) > 10000.f) {
					Msg		("! BAD light range : %f",L.range);
					L.range	= L.range > 0.f ? 10000.f : -10000.f;
				}

				// type
				if			(L.type == D3DLIGHT_DIRECTIONAL)	RL.type	= LT_DIRECT;
				else											RL.type = LT_POINT;

				// generic properties
				RL.position.set				(L.position);
				RL.direction.normalize_safe	(L.direction);
				RL.range				=	L.range*1.1f;
				RL.range2				=	RL.range*RL.range;
				RL.attenuation0			=	L.attenuation0;
				RL.attenuation1			=	L.attenuation1;
				RL.attenuation2			=	L.attenuation2;

				RL.amount				=	L.diffuse.magnitude_rgb	();
				RL.tri[0].set			(0,0,0);
				RL.tri[1].set			(0,0,0);
				RL.tri[2].set			(0,0,0);

				// place into layer
				if (0==temp.controller_ID)	g_lights.push_back		(RL);
			}
			F->close		();
		}
	}

	// Init params
//	g_params.Init		();
	
	// Load initial map from the Level Editor
	{
		string_path			file_name;
		strconcat			(sizeof(file_name),file_name,name,"build.aimap");
		IReader				*F = FS.r_open(file_name);
		R_ASSERT2			(F, file_name);

		R_ASSERT			(F->open_chunk(E_AIMAP_CHUNK_VERSION));
		R_ASSERT			(F->r_u16() == E_AIMAP_VERSION);

		R_ASSERT			(F->open_chunk(E_AIMAP_CHUNK_BOX));
		F->r				(&LevelBB,sizeof(LevelBB));

		R_ASSERT			(F->open_chunk(E_AIMAP_CHUNK_PARAMS));
		F->r				(&g_params,sizeof(g_params));

		R_ASSERT			(F->open_chunk(E_AIMAP_CHUNK_NODES));
		u32					N = F->r_u32();
		R_ASSERT2			(N < ((u32(1) << u32(MAX_NODE_BIT_COUNT)) - 2),"Too many nodes!");
		g_nodes.resize		(N);

		hdrNODES			H;
		H.version			= XRAI_CURRENT_VERSION;
		H.count				= N+1;
		H.size				= g_params.fPatchSize;
		H.size_y			= 1.f;
		H.aabb				= LevelBB;
		
		typedef BYTE NodeLink[3];
		for (u32 i=0; i<N; i++) {
			NodeLink			id;
			u16 				pl;
			SNodePositionOld 	_np;
			NodePosition 		np;
			
			for (int j=0; j<4; ++j) {
				F->r			(&id,3);
				g_nodes[i].n[j]	= (*LPDWORD(&id)) & 0x00ffffff;
			}

			pl				= F->r_u16();
			pvDecompress	(g_nodes[i].Plane.n,pl);
			F->r			(&_np,sizeof(_np));
			CNodePositionConverter(_np,H,np);
			g_nodes[i].Pos	= vertex_position(np,LevelBB,g_params);

			g_nodes[i].Plane.build(g_nodes[i].Pos,g_nodes[i].Plane.n);
		}

		F->close			();

		if (!strstr(Core.Params,"-keep_temp_files"))
			DeleteFile		(file_name);
	}
}
コード例 #27
0
ファイル: FileSystem.cpp プロジェクト: Frankie-666/xray-16
bool EFS_Utils::GetOpenNameInternal(LPCSTR initial, LPSTR buffer, int sz_buf, bool bMulti, LPCSTR offset, int start_flt_ext)
{
    VERIFY(buffer && (sz_buf > 0));
    FS_Path& P = *FS.get_path(initial);
    string1024 flt;
    MakeFilter(flt, P.m_FilterCaption ? P.m_FilterCaption : "", P.m_DefExt);

    OPENFILENAME ofn;
    Memory.mem_fill(&ofn, 0, sizeof(ofn));

    if (xr_strlen(buffer))
    {
        string_path dr;
        if (!(buffer[0] == '\\' && buffer[1] == '\\'))  // if !network
        {
            _splitpath(buffer, dr, 0, 0, 0);

            if (0 == dr[0])
            {
                string_path bb;
                P._update(bb, buffer);
                xr_strcpy(buffer, sz_buf, bb);
            }
        }
    }
    ofn.lStructSize = sizeof(OPENFILENAME);
    ofn.hwndOwner = GetForegroundWindow();
    ofn.lpstrDefExt = P.m_DefExt;
    ofn.lpstrFile = buffer;
    ofn.nMaxFile = sz_buf;
    ofn.lpstrFilter = flt;
    ofn.nFilterIndex = start_flt_ext + 2;
    ofn.lpstrTitle = "Open a File";
    string512 path;
    xr_strcpy(path, (offset&&offset[0]) ? offset : P.m_Path);
    ofn.lpstrInitialDir = path;
    ofn.Flags = OFN_PATHMUSTEXIST |
                OFN_FILEMUSTEXIST |
                OFN_HIDEREADONLY |
                OFN_FILEMUSTEXIST |
                OFN_NOCHANGEDIR |
                (bMulti ? OFN_ALLOWMULTISELECT | OFN_EXPLORER : 0);

    ofn.FlagsEx = OFN_EX_NOPLACESBAR;

    /*
     unsigned int dwVersion = GetVersion();
     unsigned int dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
     if ( dwWindowsMajorVersion == 6 )
     {
     ofn.Flags |= OFN_ENABLEHOOK;
     ofn.lpfnHook = OFNHookProcOldStyle;
     }
     */

    bool bRes = !!GetOpenFileName(&ofn);
    if (!bRes)
    {
        u32 err = CommDlgExtendedError();
        switch (err)
        {
        case FNERR_BUFFERTOOSMALL:
            Log("Too many files selected.");
            break;
        }
    }
    if (bRes && bMulti)
    {
        Log("buff=", buffer);
        int cnt = _GetItemCount(buffer, 0x0);
        if (cnt > 1)
        {
            char dir[255 * 255];
            char buf[255 * 255];
            char fns[255 * 255];

            xr_strcpy(dir, buffer);
            xr_strcpy(fns, dir);
            xr_strcat(fns, "\\");
            xr_strcat(fns, _GetItem(buffer, 1, buf, 0x0));

            for (int i = 2; i < cnt; i++)
            {
                xr_strcat(fns, ",");
                xr_strcat(fns, dir);
                xr_strcat(fns, "\\");
                xr_strcat(fns, _GetItem(buffer, i, buf, 0x0));
            }
            xr_strcpy(buffer, sz_buf, fns);
        }
    }
    strlwr(buffer);
    return bRes;
}
コード例 #28
0
void game_cl_Deathmatch::OnVoteStart(NET_Packet& P)
{
	CStringTable st;
	inherited::OnVoteStart(P);

	string1024	Command = "";
	string64	Player = "";
	P.r_stringZ(Command);
	P.r_stringZ(Player);
	m_dwVoteEndTime = Level().timeServer() + P.r_u32();
	
	if(m_game_ui)
	{
		string4096 CmdName = "";
		string1024 NewCmd; xr_strcpy(NewCmd, Command);
		string1024 CmdParams[MAX_VOTE_PARAMS] = {"", "", "", "", ""};
		sscanf	(Command,"%s %s %s %s %s %s", CmdName, CmdParams[0], CmdParams[1], CmdParams[2], CmdParams[3], CmdParams[4]);

		if (!xr_strcmp(CmdName, "restart"))
		{
			xr_sprintf(NewCmd, "%s", 
				*st.translate("mp_restart")
				);
		}
		else if (!xr_strcmp(CmdName, "restart_fast"))
		{
			xr_sprintf(NewCmd, "%s", 
				*st.translate("mp_restart_fast")
				);
		}
		else if (!xr_strcmp(CmdName, "kick"))
		{
			xr_sprintf(NewCmd, "%s %s", 
				*st.translate("mp_kick"), 
				CmdParams[0]
				);
			for (int i=1; i<MAX_VOTE_PARAMS; i++)
			{
				if (xr_strlen(CmdParams[i]))
				{
					xr_strcat(NewCmd, " ");
					xr_strcat(NewCmd, CmdParams[i]);
				}
			}
		}
		else if (!xr_strcmp(CmdName, "ban"))
		{
			xr_sprintf(NewCmd, "%s %s", 
				*st.translate("mp_ban"), 
				CmdParams[0]
				);
			for (int i=1; i<MAX_VOTE_PARAMS; i++)
			{
				if (xr_strlen(CmdParams[i]))
				{
					xr_strcat(NewCmd, " ");
					xr_strcat(NewCmd, CmdParams[i]);
				}
			}
		}
		else if (!xr_strcmp(CmdName, "changemap"))
		{
			xr_sprintf(NewCmd, "%s %s", 
				*st.translate("mp_change_map"), 
				*st.translate(CmdParams[0])
				);
		}
		else if (!xr_strcmp(CmdName, "changeweather"))
		{
			xr_sprintf(NewCmd, "%s %s", 
				*st.translate("mp_change_weather"), 
				*st.translate(CmdParams[0])
				);
		}

		
		string1024 VoteStr;
		xr_sprintf(VoteStr, *st.translate("mp_voting_started"), NewCmd, Player);		
		


		m_game_ui->SetVoteMessage(VoteStr);
		m_game_ui->SetVoteTimeResultMsg("");
		if (!m_pVoteRespondWindow)
            m_pVoteRespondWindow = xr_new<CUIVote>();
		m_pVoteRespondWindow->SetVoting(VoteStr);
	};
};
コード例 #29
0
void CActor::g_SetAnimation( u32 mstate_rl )
{


	if (!g_Alive()) {
		if (m_current_legs||m_current_torso){
			SActorState*				ST = 0;
			if (mstate_rl&mcCrouch)		ST = &m_anims->m_crouch;
			else						ST = &m_anims->m_normal;
			mstate_real					= 0;
			m_current_legs.invalidate	();
			m_current_torso.invalidate	();

			//smart_cast<IKinematicsAnimated*>(Visual())->PlayCycle(m_anims->m_dead_stop);
		}

		return;
	}
	STorsoWpn::eMovingState	moving_idx 		= STorsoWpn::eIdle;
	SActorState*					ST 		= 0;
	SAnimState*						AS 		= 0;
	
	if		(mstate_rl&mcCrouch)	
		ST 		= &m_anims->m_crouch;
	else if	(mstate_rl&mcClimb)		
		ST 		= &m_anims->m_climb;
	else							
		ST 		= &m_anims->m_normal;

	bool bAccelerated = isActorAccelerated(mstate_rl, IsZoomAimingMode());
	if ( bAccelerated )
	{
		AS							= &ST->m_run;
	}else{
		AS							= &ST->m_walk;
	}
	if(mstate_rl&mcAnyMove)
	{
		if( bAccelerated )
			moving_idx				= STorsoWpn::eRun;
		else
			moving_idx				= STorsoWpn::eWalk;
	}
	// анимации
	MotionID 						M_legs;
	MotionID 						M_torso;
	MotionID 						M_head;

	//если мы просто стоим на месте
	bool is_standing = false;

	// Legs
	if		(mstate_rl&mcLanding)	M_legs	= ST->landing[0];
	else if (mstate_rl&mcLanding2)	M_legs	= ST->landing[1];
	else if ((mstate_rl&mcTurn)&&
			!(mstate_rl&mcClimb))	M_legs	= ST->legs_turn;
	else if (mstate_rl&mcFall)		M_legs	= ST->jump_idle;
	else if (mstate_rl&mcJump)		M_legs	= ST->jump_begin;
	else if (mstate_rl&mcFwd)		M_legs	= AS->legs_fwd;
	else if (mstate_rl&mcBack)		M_legs	= AS->legs_back;
	else if (mstate_rl&mcLStrafe)	M_legs	= AS->legs_ls;
	else if (mstate_rl&mcRStrafe)	M_legs	= AS->legs_rs;
	else is_standing = true;

	if(mstate_rl&mcSprint)
	{
		g_SetSprintAnimation			(mstate_rl,M_head,M_torso,M_legs);
		moving_idx						= STorsoWpn::eSprint;
	}

	if (this == Level().CurrentViewEntity())
	{	
		if ((mstate_rl&mcSprint) != (mstate_old&mcSprint))
		{
			g_player_hud->OnMovementChanged(mcSprint);
		}else
		if ((mstate_rl&mcAnyMove) != (mstate_old&mcAnyMove))
		{
			g_player_hud->OnMovementChanged(mcAnyMove);
		}
	};

	//-----------------------------------------------------------------------
	// Torso
	if(mstate_rl&mcClimb)
	{
		if		(mstate_rl&mcFwd)		M_torso	= AS->legs_fwd;
		else if (mstate_rl&mcBack)		M_torso	= AS->legs_back;
		else if (mstate_rl&mcLStrafe)	M_torso	= AS->legs_ls;
		else if (mstate_rl&mcRStrafe)	M_torso	= AS->legs_rs;
	}
	
	if(!M_torso)
	{
		CInventoryItem* _i = inventory().ActiveItem();
		CHudItem		*H = smart_cast<CHudItem*>(_i);
		CWeapon			*W = smart_cast<CWeapon*>(_i);
		CMissile		*M = smart_cast<CMissile*>(_i);
		CArtefact		*A = smart_cast<CArtefact*>(_i);
					
		if (H) {
			VERIFY(H->animation_slot() <= _total_anim_slots_);
			STorsoWpn* TW			= &ST->m_torso[H->animation_slot() - 1];
			if (!b_DropActivated&&!fis_zero(f_DropPower))
			{
				M_torso					= TW->drop;
				if (!M_torso)	
				{
					Msg("! drop animation for %s", *(H->object().cName()));
					M_torso = ST->m_torso_idle;
				};
				m_bAnimTorsoPlayed		= TRUE;
			}
			else
			{
				if (!m_bAnimTorsoPlayed) 
				{
					if (W) 
					{
						bool K	=inventory().GetActiveSlot() == KNIFE_SLOT;
						bool R3 = W->IsTriStateReload();
						
						if(K)
						{
							switch (W->GetState())
							{
							case CWeapon::eIdle:		M_torso	= TW->moving[moving_idx];		break;
							
							case CWeapon::eFire:	
								if(is_standing)
														M_torso = M_legs = M_head = TW->all_attack_0;
								else
														M_torso	= TW->attack_zoom;
								break;

							case CWeapon::eFire2:
								if(is_standing)
														M_torso = M_legs = M_head = TW->all_attack_1;
								else
														M_torso	= TW->fire_idle;
								break;

							case CWeapon::eReload:		M_torso	= TW->reload;					break;
							case CWeapon::eShowing:		M_torso	= TW->draw;						break;
							case CWeapon::eHiding:		M_torso	= TW->holster;					break;
							default				 :  	M_torso	= TW->moving[moving_idx];		break;
							}
						}
						else
						{
							switch (W->GetState())
							{
							case CWeapon::eIdle:		M_torso	= W->IsZoomed()?TW->zoom:TW->moving[moving_idx];	break;
							case CWeapon::eFire:		M_torso	= W->IsZoomed()?TW->attack_zoom:TW->attack;				break;
							case CWeapon::eFire2:		M_torso	= W->IsZoomed()?TW->attack_zoom:TW->attack;				break;
							case CWeapon::eReload:	
								if(!R3)
									M_torso	= TW->reload;
								else
								{
									CWeapon::EWeaponSubStates sub_st = W->GetReloadState();
									switch (sub_st)
									{
										case CWeapon::eSubstateReloadBegin:			M_torso	= TW->reload;	break;
										case CWeapon::eSubstateReloadInProcess:		M_torso	= TW->reload_1; break;
										case CWeapon::eSubstateReloadEnd:			M_torso	= TW->reload_2; break;
										default:									M_torso	= TW->reload;	break;
									}
								}break;

							case CWeapon::eShowing:	M_torso	= TW->draw;					break;
							case CWeapon::eHiding:	M_torso	= TW->holster;				break;
							default				 :  M_torso	= TW->moving[moving_idx];	break;
							}
						}
					}
					else if (M) 
					{
						if(is_standing)
						{
							switch (M->GetState())
							{
							case CMissile::eShowing		:		M_torso	= TW->draw;			break;
							case CMissile::eHiding		:		M_torso	= TW->holster;		break;
							case CMissile::eIdle		:		M_torso	= TW->moving[moving_idx];		break;
							case CMissile::eThrowStart	:		M_torso = M_legs = M_head = TW->all_attack_0;	break;
							case CMissile::eReady		:		M_torso = M_legs = M_head = TW->all_attack_1;	break;
							case CMissile::eThrow		:		M_torso = M_legs = M_head = TW->all_attack_2;	break;
							case CMissile::eThrowEnd	:		M_torso = M_legs = M_head = TW->all_attack_2;	break;
							default						:		M_torso	= TW->draw;			break; 
							}
						}
						else
						{
							switch (M->GetState())
							{
							case CMissile::eShowing		:		M_torso	= TW->draw;						break;
							case CMissile::eHiding		:		M_torso	= TW->holster;					break;
							case CMissile::eIdle		:		M_torso	= TW->moving[moving_idx];		break;
							case CMissile::eThrowStart	:		M_torso	= TW->attack_zoom;				break;
							case CMissile::eReady		:		M_torso	= TW->fire_idle;				break;
							case CMissile::eThrow		:		M_torso	= TW->fire_end;					break;
							case CMissile::eThrowEnd	:		M_torso	= TW->fire_end;					break;
							default						:		M_torso	= TW->draw;						break; 
							}
						}
					}
					else if (A)
					{
							switch(A->GetState())
							{
								case CArtefact::eIdle		: M_torso	= TW->moving[moving_idx];	break; 
								case CArtefact::eShowing	: M_torso	= TW->draw;					break; 
								case CArtefact::eHiding		: M_torso	= TW->holster;				break; 
								case CArtefact::eActivating : M_torso	= TW->zoom;					break; 
								default						: M_torso	= TW->moving[moving_idx];
							}
					
					}
				}
			}
		}
	}
	MotionID		mid = smart_cast<IKinematicsAnimated*>(Visual())->ID_Cycle("norm_idle_0");

	if (!M_legs)
	{
		if((mstate_rl&mcCrouch)&&!isActorAccelerated(mstate_rl, IsZoomAimingMode()))//!(mstate_rl&mcAccel))
		{
			M_legs=smart_cast<IKinematicsAnimated*>(Visual())->ID_Cycle("cr_idle_1");
		}
		else 
			M_legs	= ST->legs_idle;
	}
	if (!M_head)					
		M_head	= ST->m_head_idle;

	if (!M_torso)
	{
		if (m_bAnimTorsoPlayed)		
			M_torso	= m_current_torso;
		else						
			M_torso = ST->m_torso_idle;
	}
	
	// есть анимация для всего - запустим / иначе запустим анимацию по частям
	if (m_current_torso!=M_torso)
	{
		if (m_bAnimTorsoPlayed)		
			m_current_torso_blend = smart_cast<IKinematicsAnimated*>(Visual())->PlayCycle(M_torso,TRUE,AnimTorsoPlayCallBack,this);
		else						
			m_current_torso_blend = smart_cast<IKinematicsAnimated*>(Visual())->PlayCycle(M_torso);

		m_current_torso=M_torso;
	}
	
	if(m_current_head!=M_head)
	{
		if(M_head)
			smart_cast<IKinematicsAnimated*>(Visual())->PlayCycle(M_head);

		m_current_head=M_head;
	}

	if (m_current_legs!=M_legs)
	{
		float pos					= 0.f;
		VERIFY						(!m_current_legs_blend || !fis_zero(m_current_legs_blend->timeTotal));
		if ((mstate_real&mcAnyMove)&&(mstate_old&mcAnyMove)&&m_current_legs_blend)
			pos						= fmod(m_current_legs_blend->timeCurrent,m_current_legs_blend->timeTotal)/m_current_legs_blend->timeTotal;


		IKinematicsAnimated* ka		= smart_cast<IKinematicsAnimated*>(Visual());
		m_current_legs_blend		= PlayMotionByParts(ka, M_legs, TRUE, legs_play_callback, this);
//		m_current_legs_blend		= smart_cast<IKinematicsAnimated*>(Visual())->PlayCycle(M_legs,TRUE,legs_play_callback,this);


		if ((!(mstate_old&mcAnyMove))&&(mstate_real&mcAnyMove))
		{
			pos						= 0.5f;//0.5f*Random.randI(2);
		}
		if (m_current_legs_blend)
			m_current_legs_blend->timeCurrent = m_current_legs_blend->timeTotal*pos;

		m_current_legs				= M_legs;

		CStepManager::on_animation_start(M_legs, m_current_legs_blend);
	}



#ifdef DEBUG
	if(bDebug && g_ShowAnimationInfo)
	{
		UI().Font().pFontStat->OutSetI	(0,0);
		UI().Font().pFontStat->OutNext("[%s]",mov_state[moving_idx]);
		IKinematicsAnimated* KA = smart_cast<IKinematicsAnimated*>(Visual());
		if(M_torso)
			UI().Font().pFontStat->OutNext("torso [%s]",KA->LL_MotionDefName_dbg(M_torso).first);
		if(M_head)
			UI().Font().pFontStat->OutNext("head [%s]",KA->LL_MotionDefName_dbg(M_head).first);
		if(M_legs)
			UI().Font().pFontStat->OutNext("legs [%s]",KA->LL_MotionDefName_dbg(M_legs).first);
	}
#endif

#ifdef DEBUG
	if ((Level().CurrentControlEntity() == this) && g_ShowAnimationInfo) {
		string128 buf;
		xr_strcpy(buf,"");
		if (isActorAccelerated(mstate_rl, IsZoomAimingMode()))		xr_strcat(buf,"Accel ");
		if (mstate_rl&mcCrouch)		xr_strcat(buf,"Crouch ");
		if (mstate_rl&mcFwd)		xr_strcat(buf,"Fwd ");
		if (mstate_rl&mcBack)		xr_strcat(buf,"Back ");
		if (mstate_rl&mcLStrafe)	xr_strcat(buf,"LStrafe ");
		if (mstate_rl&mcRStrafe)	xr_strcat(buf,"RStrafe ");
		if (mstate_rl&mcJump)		xr_strcat(buf,"Jump ");
		if (mstate_rl&mcFall)		xr_strcat(buf,"Fall ");
		if (mstate_rl&mcTurn)		xr_strcat(buf,"Turn ");
		if (mstate_rl&mcLanding)	xr_strcat(buf,"Landing ");
		if (mstate_rl&mcLLookout)	xr_strcat(buf,"LLookout ");
		if (mstate_rl&mcRLookout)	xr_strcat(buf,"RLookout ");
		if (m_bJumpKeyPressed)		xr_strcat(buf,"+Jumping ");
		UI().Font().pFontStat->OutNext	("MSTATE:     [%s]",buf);
/*
		switch (m_PhysicMovementControl->Environment())
		{
		case CPHMovementControl::peOnGround:	xr_strcpy(buf,"ground");			break;
		case CPHMovementControl::peInAir:		xr_strcpy(buf,"air");				break;
		case CPHMovementControl::peAtWall:		xr_strcpy(buf,"wall");				break;
		}
		UI().Font().pFontStat->OutNext	(buf);
		UI().Font().pFontStat->OutNext	("Accel     [%3.2f, %3.2f, %3.2f]",VPUSH(NET_SavedAccel));
		UI().Font().pFontStat->OutNext	("V         [%3.2f, %3.2f, %3.2f]",VPUSH(m_PhysicMovementControl->GetVelocity()));
		UI().Font().pFontStat->OutNext	("vertex ID   %d",ai_location().level_vertex_id());
		
		Game().m_WeaponUsageStatistic->Draw();
		*/
	};
#endif

	if (!m_current_torso_blend)
		return;

	IKinematicsAnimated		*skeleton_animated = smart_cast<IKinematicsAnimated*>(Visual());

	CMotionDef				*motion0 = skeleton_animated->LL_GetMotionDef(m_current_torso);
	VERIFY					(motion0);
	if (!(motion0->flags & esmSyncPart))
		return;

	if (!m_current_legs_blend)
		return;

	CMotionDef				*motion1 = skeleton_animated->LL_GetMotionDef(m_current_legs);
	VERIFY					(motion1);
	if (!(motion1->flags & esmSyncPart))
		return;


	m_current_torso_blend->timeCurrent	= m_current_legs_blend->timeCurrent/m_current_legs_blend->timeTotal*m_current_torso_blend->timeTotal;
}