示例#1
0
void CContextMenu::Load(CInifile* INI, LPCSTR SECT){
	CInifile::Sect& S = INI->r_section(SECT);
	for (CInifile::SectCIt I=S.Data.begin(); S.Data.end()!=I; ++I){
		char	Event[128],Param[128];
		Event[0]=0; Param[0]=0;
		sscanf		(*I->second,"%[^,],%s",Event,Param);
		MenuItem	Item;
		Item.Name	= xr_strdup(*I->first);
		Item.Event	= Engine.Event.Create(Event);
		Item.Param	= xr_strdup(Param);
		Items.push_back(Item);
	}
}
示例#2
0
文件: xrSaveOGF.cpp 项目: 2asoft/xray
u16		RegisterShader		(LPCSTR T) 
{
	for (u32 it=0; it<g_Shaders.size(); it++)
		if (0==stricmp(T,g_Shaders[it]))	return it;
	g_Shaders.push_back		(xr_strdup(T));
	return g_Shaders.size	()-1;
}
示例#3
0
bool CScriptStorage::parse_namespace(LPCSTR caNamespaceName, LPSTR b, LPSTR c)
{
	strcpy			(b,"");
	strcpy			(c,"");
	LPSTR			S2	= xr_strdup(caNamespaceName);
	LPSTR			S	= S2;
	for (int i=0;;++i) {
		if (!xr_strlen(S)) {
			script_log	(ScriptStorage::eLuaMessageTypeError,"the namespace name %s is incorrect!",caNamespaceName);
			xr_free		(S2);
			return		(false);
		}
		LPSTR			S1 = strchr(S,'.');
		if (S1)
			*S1				= 0;

		if (i)
			strcat		(b,"{");
		strcat			(b,S);
		strcat			(b,"=");
		if (i)
			strcat		(c,"}");
		if (S1)
			S			= ++S1;
		else
			break;
	}
	xr_free			(S2);
	return			(true);
}
示例#4
0
    void format_register(LPCSTR ext)
    {
    	if (ext&&ext[0]){
			for (u32 i=0; i<exts.size(); i++)
    			if (0==stricmp(exts[i],ext)) return;
    		exts.push_back(xr_strdup(ext));
        }
    }
示例#5
0
void CSoundStream::Load( LPCSTR name )
{
	if (name)	{
		xr_free	(fName);
		fName	= xr_strdup(name);
	}
	LoadADPCM	( );
	bNeedUpdate = true;
}
示例#6
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));
	}
}
示例#7
0
void ReplaceSpaceAndLowerCase(shared_str& s)
{
	if (*s){
		char* _s	= xr_strdup(*s);
		char* lp	= _s;
		while(lp[0]){if (lp[0]==' ') lp[0]='_'; lp++;}
		xr_strlwr	(_s);
		s			= _s;
		xr_free		(_s);
	}
}
示例#8
0
void	CResourceManager::ED_UpdateBlender	(LPCSTR Name, IBlender* data)
{
	LPSTR N = LPSTR(Name);
	map_Blender::iterator I = m_blenders.find	(N);
	if (I!=m_blenders.end())	{
		R_ASSERT	(data->getDescription().CLS == I->second->getDescription().CLS);
		xr_delete	(I->second);
		I->second	= data;
	} else {
		m_blenders.insert	(mk_pair(xr_strdup(Name),data));
	}
}
示例#9
0
    virtual void Execute(LPCSTR args)
    {
        /* if (g_pGameLevel) {
         Log ("! Please disconnect/unload first");
         return;
         }
         */
        string4096 op_server, op_client, op_demo;
        op_server[0] = 0;
        op_client[0] = 0;

        parse(op_server, args, "server"); // 1. server
        parse(op_client, args, "client"); // 2. client
        parse(op_demo, args, "demo"); // 3. demo

        strlwr(op_server);
        protect_Name_strlwr(op_client);

        if (!op_client[0] && strstr(op_server, "single"))
            xr_strcpy(op_client, "localhost");

        if ((0 == xr_strlen(op_client)) && (0 == xr_strlen(op_demo)))
        {
            Log("! Can't start game without client. Arguments: '%s'.", args);
            return;
        }
        if (g_pGameLevel)
            Engine.Event.Defer("KERNEL:disconnect");

        if (xr_strlen(op_demo))
        {
            Engine.Event.Defer("KERNEL:start_mp_demo", u64(xr_strdup(op_demo)), 0);
        }
        else
        {
            Engine.Event.Defer("KERNEL:start", u64(xr_strlen(op_server) ? xr_strdup(op_server) : 0), u64(xr_strdup(op_client)));
        }
    }
示例#10
0
void CLevel::MakeReconnect()
{
	if (!Engine.Event.Peek("KERNEL:disconnect"))
	{
		Engine.Event.Defer	("KERNEL:disconnect");
		char const * server_options = NULL;
		char const * client_options = NULL;
		if (m_caServerOptions.c_str())
		{
			server_options = xr_strdup(*m_caServerOptions);
		} else
		{
			server_options = xr_strdup("");
		}
		if (m_caClientOptions.c_str())
		{
			client_options = xr_strdup(*m_caClientOptions);
		} else
		{
			client_options = xr_strdup("");
		}
		Engine.Event.Defer	("KERNEL:start", size_t(server_options), size_t(client_options));
	}
}
示例#11
0
CInifile::CInifile(LPCSTR szFileName, BOOL ReadOnly, BOOL bLoad, BOOL SaveAtEnd)
{
	fName		= szFileName?xr_strdup(szFileName):0;
    bReadOnly	= ReadOnly;
    bSaveAtEnd	= SaveAtEnd;
	if (bLoad)
	{	
    	string_path	path,folder; 
		_splitpath	(fName, path, folder, 0, 0 );
        strcat		(path,folder);
		IReader* R 	= FS.r_open(szFileName);
        if (R){
			Load		(R,path);
			FS.r_close	(R);
        }
	}
}
示例#12
0
void	Surface_FormatExt(FREE_IMAGE_FORMAT f)
{
	LPCSTR n=FreeImage_GetFIFExtensionList(f);
    if (n){
        LPSTR base = xr_strdup(n);
        LPSTR ext = base;
        LPSTR cur = ext;
        for	(; ext[0]; ext++){
        if (ext[0]==','){
                ext[0] = 0;
                formats.format_register(cur);
                cur = ++ext;
            }
        }
        if (cur&&cur[0]) formats.format_register(cur);
        xr_free(base);
    }
}
示例#13
0
文件: HW.cpp 项目: denanden/xray-16
void fill_vid_mode_list(CHW* _hw)
{
    if(vid_mode_token != NULL)		return;
    xr_vector<LPCSTR>	_tmp;
    u32 cnt = _hw->pD3D->GetAdapterModeCount	(_hw->DevAdapter, _hw->Caps.fTarget);

    u32 i;
    for(i=0; i<cnt;++i)
    {
        D3DDISPLAYMODE	Mode;
        string32		str;

        _hw->pD3D->EnumAdapterModes(_hw->DevAdapter, _hw->Caps.fTarget, i, &Mode);
        if(Mode.Width < 800)		continue;

        xr_sprintf						(str,sizeof(str),"%dx%d", Mode.Width, Mode.Height);
    
        if(_tmp.end() != std::find_if(_tmp.begin(), _tmp.end(), _uniq_mode(str)))
            continue;

        _tmp.push_back				(NULL);
        _tmp.back()					= xr_strdup(str);
    }

    u32 _cnt						= _tmp.size()+1;

    vid_mode_token					= xr_alloc<xr_token>(_cnt);

    vid_mode_token[_cnt-1].id			= -1;
    vid_mode_token[_cnt-1].name		= NULL;

#ifdef DEBUG
    Msg("Available video modes[%d]:",_tmp.size());
#endif // DEBUG
    for(i=0; i<_tmp.size();++i)
    {
        vid_mode_token[i].id		= i;
        vid_mode_token[i].name		= _tmp[i];
#ifdef DEBUG
        Msg							("[%s]",_tmp[i]);
#endif // DEBUG
    }
}
示例#14
0
void CScriptProcess::run_scripts()
{
	LPSTR						S;
	for ( ; !m_scripts_to_run.empty(); ) {
		LPSTR					I = m_scripts_to_run.back().m_script_name;
		bool					do_string = m_scripts_to_run.back().m_do_string;
		bool					reload = m_scripts_to_run.back().m_reload;
		S						= xr_strdup(I);
		m_scripts_to_run.pop_back();

		CScriptThread			*script = xr_new<CScriptThread>(S,do_string,reload);
		xr_free					(S);

		if (script->active())
			m_scripts.push_back	(script);
		else
			xr_delete			(script);
	}
}
示例#15
0
void ProcessFolder(xr_vector<char*>& list, LPCSTR path)
{
	xr_vector<char*>*	i_list	= FS.file_list_open	("$target_folder$",path,FS_ListFiles|FS_RootOnly);
	if (!i_list){
		Log				("ERROR: Unable to open file list:", path);
		return;
	}
	xr_vector<char*>::iterator it	= i_list->begin();
	xr_vector<char*>::iterator itE	= i_list->end();
	for (;it!=itE;++it){ 
		xr_string		tmp_path	= xr_string(path)+xr_string(*it);
		if (!testSKIP(tmp_path.c_str())){
			list.push_back	(xr_strdup(tmp_path.c_str()));
//.			Msg				("+f: %s",tmp_path.c_str());
		}else{
			Msg				("-f: %s",tmp_path.c_str());
		}
	}
	FS.file_list_close	(i_list);
}
示例#16
0
void xrCompressor::GatherFiles(LPCSTR path)
{
	xr_vector<char*>*	i_list	= FS.file_list_open	("$target_folder$",path,FS_ListFiles|FS_RootOnly);
	if (!i_list){
		Msg				("! ERROR: Unable to open file list:%s", path);
		return;
	}
	xr_vector<char*>::iterator it	= i_list->begin();
	xr_vector<char*>::iterator itE	= i_list->end();
	for (;it!=itE;++it)
	{
		xr_string		tmp_path	= xr_string(path)+xr_string(*it);
		if (!testSKIP(tmp_path.c_str()))
		{
			files_list->push_back	(xr_strdup(tmp_path.c_str()));
		}else{
			Msg				("* -f: %s",tmp_path.c_str());
		}
	}
	FS.file_list_close	(i_list);
}
示例#17
0
void CCharacterInfo::load_shared	(LPCSTR)
{
    const ITEM_DATA& item_data = *id_to_index::GetById(m_ProfileId);

    CUIXml*		pXML		= item_data._xml;
    pXML->SetLocalRoot		(pXML->GetRoot());

    XML_NODE* item_node = pXML->NavigateToNode(id_to_index::tag_name, item_data.pos_in_file);
    R_ASSERT3(item_node, "profile id=", *item_data.id);

    pXML->SetLocalRoot(item_node);



    LPCSTR spec_char = pXML->Read("specific_character", 0, NULL);
    if(!spec_char)
    {
        data()->m_CharacterId	= NULL;

        LPCSTR char_class			= pXML->Read	("class",		0,	NULL);

        if(char_class)
        {
            char* buf_str = xr_strdup(char_class);
            xr_strlwr(buf_str);
            data()->m_Class				= buf_str;
            xr_free(buf_str);
        }
        else
            data()->m_Class				= NO_CHARACTER_CLASS;

        data()->m_Rank = pXML->ReadInt			("rank",		0,	NO_RANK);
        data()->m_Reputation = pXML->ReadInt	("reputation",	0,	NO_REPUTATION);
    }
    else
        data()->m_CharacterId = spec_char;
}
示例#18
0
文件: EngineAPI.cpp 项目: 2asoft/xray
void CEngineAPI::CreateRendererList()
{
	//	TODO: ask renderers if they are supported!
	if(vid_quality_token != NULL)		return;
	bool bSupports_r2 = false;
	bool bSupports_r2_5 = false;
	bool bSupports_r3 = false;

	LPCSTR			r2_name	= "xrRender_R2.dll";
	LPCSTR			r3_name	= "xrRender_R3.dll";

	if (strstr(Core.Params,"-perfhud_hack"))
	{
		bSupports_r2 = true;
		bSupports_r2_5 = true;
		bSupports_r3 = true;
	}
	else
	{
		// try to initialize R2
		Log				("Loading DLL:",	r2_name);
		hRender			= LoadLibrary		(r2_name);
		if (hRender)	
		{
			bSupports_r2 = true;
			SupportsAdvancedRendering *test_rendering = (SupportsAdvancedRendering*) GetProcAddress(hRender,"SupportsAdvancedRendering");	
			R_ASSERT(test_rendering);
			bSupports_r2_5 = test_rendering();
			FreeLibrary(hRender);
		}

		// try to initialize R3
		Log				("Loading DLL:",	r3_name);
		//	Hide "d3d10.dll not found" message box for XP
		SetErrorMode(SEM_FAILCRITICALERRORS);
		hRender			= LoadLibrary		(r3_name);
		//	Restore error handling
		SetErrorMode(0);
		if (hRender)	
		{
			SupportsDX10Rendering *test_dx10_rendering = (SupportsDX10Rendering*) GetProcAddress(hRender,"SupportsDX10Rendering");
			R_ASSERT(test_dx10_rendering);
			bSupports_r3 = test_dx10_rendering();
			FreeLibrary(hRender);
		}
	}

	hRender = 0;

	xr_vector<LPCSTR>			_tmp;
	u32 i						= 0;
	bool bBreakLoop = false;
	for(; i<5; ++i)
	{
		switch (i)
		{
		case 1:
			if (!bSupports_r2)
				bBreakLoop = true;
			break;
		case 3:		//"renderer_r2.5"
			if (!bSupports_r2_5)
				bBreakLoop = true;
			break;
		case 4:		//"renderer_r_dx10"
			if (!bSupports_r3)
				bBreakLoop = true;
			break;
		default:	;
		}

		if (bBreakLoop) break;

		_tmp.push_back				(NULL);
		LPCSTR val					= NULL;
		switch (i)
		{
		case 0: val ="renderer_r1";			break;
		case 1: val ="renderer_r2a";		break;
		case 2: val ="renderer_r2";			break;
		case 3: val ="renderer_r2.5";		break;
		case 4: val ="renderer_r3";			break; //  -)
		}
		if (bBreakLoop) break;
		_tmp.back()					= xr_strdup(val);
	}
	u32 _cnt								= _tmp.size()+1;
	vid_quality_token						= xr_alloc<xr_token>(_cnt);

	vid_quality_token[_cnt-1].id			= -1;
	vid_quality_token[_cnt-1].name			= NULL;

#ifdef DEBUG
	Msg("Available render modes[%d]:",_tmp.size());
#endif // DEBUG
	for(u32 i=0; i<_tmp.size();++i)
	{
		vid_quality_token[i].id				= i;
		vid_quality_token[i].name			= _tmp[i];
#ifdef DEBUG
		Msg							("[%s]",_tmp[i]);
#endif // DEBUG
	}

	/*
	if(vid_quality_token != NULL)		return;

	D3DCAPS9					caps;
	CHW							_HW;
	_HW.CreateD3D				();
	_HW.pD3D->GetDeviceCaps		(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,&caps);
	_HW.DestroyD3D				();
	u16		ps_ver_major		= u16 ( u32(u32(caps.PixelShaderVersion)&u32(0xf << 8ul))>>8 );

	xr_vector<LPCSTR>			_tmp;
	u32 i						= 0;
	for(; i<5; ++i)
	{
		bool bBreakLoop = false;
		switch (i)
		{
		case 3:		//"renderer_r2.5"
			if (ps_ver_major < 3)
				bBreakLoop = true;
			break;
		case 4:		//"renderer_r_dx10"
			bBreakLoop = true;
			break;
		default:	;
		}

		if (bBreakLoop) break;

		_tmp.push_back				(NULL);
		LPCSTR val					= NULL;
		switch (i)
		{
		case 0: val ="renderer_r1";			break;
		case 1: val ="renderer_r2a";		break;
		case 2: val ="renderer_r2";			break;
		case 3: val ="renderer_r2.5";		break;
		case 4: val ="renderer_r_dx10";		break; //  -)
		}
		_tmp.back()					= xr_strdup(val);
	}
	u32 _cnt								= _tmp.size()+1;
	vid_quality_token						= xr_alloc<xr_token>(_cnt);

	vid_quality_token[_cnt-1].id			= -1;
	vid_quality_token[_cnt-1].name			= NULL;

#ifdef DEBUG
	Msg("Available render modes[%d]:",_tmp.size());
#endif // DEBUG
	for(u32 i=0; i<_tmp.size();++i)
	{
		vid_quality_token[i].id				= i;
		vid_quality_token[i].name			= _tmp[i];
#ifdef DEBUG
		Msg							("[%s]",_tmp[i]);
#endif // DEBUG
	}
	*/
}
示例#19
0
void	CResourceManager::OnDeviceCreate	(IReader* F)
{
	if (!RDEVICE.b_is_Ready) return;

	string256	name;

#ifndef _EDITOR
	// scripting
	LS_Load					();
#endif
	IReader*	fs			= 0;
	// Load constants
 	fs	 		  			= F->open_chunk	(0);
	if (fs){
		while (!fs->eof())	{
			fs->r_stringZ	(name,sizeof(name));
			CConstant*	C	= _CreateConstant	(name);
			C->Load			(fs);
		}
		fs->close			();
	}

	// Load matrices
    fs						= F->open_chunk(1);
	if (fs){
		while (!fs->eof())	{
			fs->r_stringZ	(name,sizeof(name));
			CMatrix*	M	= _CreateMatrix	(name);
			M->Load			(fs);
		}
		fs->close			();
	}

	// Load blenders
    fs						= F->open_chunk	(2);
	if (fs){
		IReader*	chunk	= NULL;
		int			chunk_id= 0;

		while ((chunk=fs->open_chunk(chunk_id))!=NULL){
			CBlender_DESC	desc;
			chunk->r		(&desc,sizeof(desc));
			IBlender*		B = IBlender::Create(desc.CLS);
			if	(0==B)
			{
				Msg				("! Renderer doesn't support blender '%s'",desc.cName);
			}
			else
			{
				if	(B->getDescription().version != desc.version)
				{
					Msg			("! Version conflict in shader '%s'",desc.cName);
				}

				chunk->seek		(0);
				B->Load			(*chunk,desc.version);

				std::pair<map_BlenderIt, bool> I =  m_blenders.insert	(mk_pair(xr_strdup(desc.cName),B));
				R_ASSERT2		(I.second,"shader.xr - found duplicate name!!!");
			}
			chunk->close	();
			chunk_id		+= 1;
		}
		fs->close();
	}

	m_textures_description.Load				();
}
示例#20
0
void CLevel::ClientReceive()
{

	Demo_StartFrame();

	Demo_Update();

	m_dwRPC = 0;
	m_dwRPS = 0;

	for (NET_Packet* P = net_msg_Retreive(); P; P=net_msg_Retreive())
	{
		//-----------------------------------------------------
		m_dwRPC++;
		m_dwRPS += P->B.count;
		//-----------------------------------------------------
		u16			m_type;
		u16			ID;
		P->r_begin	(m_type);
		switch (m_type)
		{
		case M_MAP_SYNC:
			{
				shared_str map_name;
				P->r_stringZ(map_name);

				shared_str _name		= net_Hosts.size() ? net_Hosts.front().dpSessionName:"";

				if(_name.size() && _name!=map_name && OnClient())
				{
					Msg("!!! map sync failed. current is[%s] server is[%s]",m_name.c_str(), map_name.c_str());
					Engine.Event.Defer	("KERNEL:disconnect");
					Engine.Event.Defer	("KERNEL:start",m_caServerOptions.size() ? size_t( xr_strdup(*m_caServerOptions)) : 0, m_caClientOptions.size() ? size_t(xr_strdup(*m_caClientOptions)) : 0);
				}
			}break;
		case M_SPAWN:			
			{
				if (!m_bGameConfigStarted || !bReady) 
				{
					Msg ("Unconventional M_SPAWN received : cgf[%s] | bReady[%s]",
						(m_bGameConfigStarted) ? "true" : "false",
						(bReady) ? "true" : "false");
					break;
				}
				/*/
				cl_Process_Spawn(*P);
				/*/
				game_events->insert		(*P);
				if (g_bDebugEvents)		ProcessGameEvents();
				//*/
			}
			break;
		case M_EVENT:
			game_events->insert		(*P);
			if (g_bDebugEvents)		ProcessGameEvents();
			break;
		case M_EVENT_PACK:
			NET_Packet	tmpP;
			while (!P->r_eof())
			{
				tmpP.B.count = P->r_u8();
				P->r(&tmpP.B.data, tmpP.B.count);
				tmpP.timeReceive = P->timeReceive;

				game_events->insert		(tmpP);
				if (g_bDebugEvents)		ProcessGameEvents();
			};			
			break;
		case M_UPDATE:
			{
				game->net_import_update	(*P);
				//-------------------------------------------
				if (OnServer()) break;
				//-------------------------------------------
			};	// ни в коем случае нельзя здесь ставить break, т.к. в случае если все объекты не влазят в пакет M_UPDATE,
				// они досылаются через M_UPDATE_OBJECTS
		case M_UPDATE_OBJECTS:
			{
				Objects.net_Import		(P);

				if (OnClient()) UpdateDeltaUpd(timeServer());
				IClientStatistic pStat = Level().GetStatistic();
				u32 dTime = 0;
				
				if ((Level().timeServer() + pStat.getPing()) < P->timeReceive)
				{
					dTime = pStat.getPing();
				}
				else
					dTime = Level().timeServer() - P->timeReceive + pStat.getPing();

				u32 NumSteps = ph_world->CalcNumSteps(dTime);
				SetNumCrSteps(NumSteps);
			}break;
//		case M_UPDATE_OBJECTS:
//			{
//				Objects.net_Import		(P);
//			}break;
		//----------- for E3 -----------------------------
		case M_CL_UPDATE:
			{
				if (OnClient()) break;
				P->r_u16		(ID);
				u32 Ping = P->r_u32();
				CGameObject*	O	= smart_cast<CGameObject*>(Objects.net_Find		(ID));
				if (0 == O)		break;
				O->net_Import(*P);
		//---------------------------------------------------
				UpdateDeltaUpd(timeServer());
				if (pObjects4CrPr.empty() && pActors4CrPr.empty())
					break;
				if (O->CLS_ID != CLSID_OBJECT_ACTOR)
					break;

				u32 dTime = 0;
				if ((Level().timeServer() + Ping) < P->timeReceive)
				{
#ifdef DEBUG
//					Msg("! TimeServer[%d] < TimeReceive[%d]", Level().timeServer(), P->timeReceive);
#endif
					dTime = Ping;
				}
				else					
					dTime = Level().timeServer() - P->timeReceive + Ping;
				u32 NumSteps = ph_world->CalcNumSteps(dTime);
				SetNumCrSteps(NumSteps);

				O->CrPr_SetActivationStep(u32(ph_world->m_steps_num) - NumSteps);
				AddActor_To_Actors4CrPr(O);

			}break;
		case M_MOVE_PLAYERS:
			{
				u8 Count = P->r_u8();
				for (u8 i=0; i<Count; i++)
				{
					u16 ID = P->r_u16();					
					Fvector NewPos, NewDir;
					P->r_vec3(NewPos);
					P->r_vec3(NewDir);

					CActor*	OActor	= smart_cast<CActor*>(Objects.net_Find		(ID));
					if (0 == OActor)		break;
					OActor->MoveActor(NewPos, NewDir);
				};

				NET_Packet PRespond;
				PRespond.w_begin(M_MOVE_PLAYERS_RESPOND);
				Send(PRespond, net_flags(TRUE, TRUE));
			}break;
		//------------------------------------------------
		case M_CL_INPUT:
			{
				P->r_u16		(ID);
				CObject*	O	= Objects.net_Find		(ID);
				if (0 == O)		break;
				O->net_ImportInput(*P);
			}break;
		//---------------------------------------------------
		case 	M_SV_CONFIG_NEW_CLIENT:
			InitializeClientGame(*P);
			break;
		case M_SV_CONFIG_GAME:
			game->net_import_state	(*P);
			break;
		case M_SV_CONFIG_FINISHED:
			game_configured			= TRUE;
			Msg("- Game configuring : Finished ");
			break;		
		case M_MIGRATE_DEACTIVATE:	// TO:   Changing server, just deactivate
			{
				P->r_u16		(ID);
				CObject*	O	= Objects.net_Find		(ID);
				if (0 == O)		break;
				O->net_MigrateInactive	(*P);
				if (bDebug)		Log("! MIGRATE_DEACTIVATE",*O->cName());
			}
			break;
		case M_MIGRATE_ACTIVATE:	// TO:   Changing server, full state
			{
				P->r_u16		(ID);
				CObject*	O	= Objects.net_Find		(ID);
				if (0 == O)		break;
				O->net_MigrateActive	(*P);
				if (bDebug)		Log("! MIGRATE_ACTIVATE",*O->cName());
			}
			break;
		case M_CHAT:
			{
				char	buffer[256];
				P->r_stringZ(buffer);
				Msg		("- %s",buffer);
			}
			break;
		case M_GAMEMESSAGE:
			{
				if (!game) break;
				Game().OnGameMessage(*P);
			}break;
		case M_RELOAD_GAME:
		case M_LOAD_GAME:
		case M_CHANGE_LEVEL:
			{
				if(m_type==M_LOAD_GAME)
				{
					string256						saved_name;
					P->r_stringZ					(saved_name);
					if(xr_strlen(saved_name) && ai().get_alife())
					{
						CSavedGameWrapper			wrapper(saved_name);
						if (wrapper.level_id() == ai().level_graph().level_id()) 
						{
							Engine.Event.Defer	("Game:QuickLoad", size_t(xr_strdup(saved_name)), 0);

							break;
						}
					}
				}
				Engine.Event.Defer	("KERNEL:disconnect");
				Engine.Event.Defer	("KERNEL:start",size_t(xr_strdup(*m_caServerOptions)),size_t(xr_strdup(*m_caClientOptions)));
			}break;
		case M_SAVE_GAME:
			{
				ClientSave			();
			}break;
		case M_GAMESPY_CDKEY_VALIDATION_CHALLENGE:
			{
				OnGameSpyChallenge(P);
			}break;
		case M_AUTH_CHALLENGE:
			{
				OnBuildVersionChallenge();
			}break;
		case M_CLIENT_CONNECT_RESULT:
			{
				OnConnectResult(P);
			}break;
		case M_CHAT_MESSAGE:
			{
				if (!game) break;
				Game().OnChatMessage(P);
			}break;
		case M_CLIENT_WARN:
			{
				if (!game) break;
				Game().OnWarnMessage(P);
			}break;
		case M_REMOTE_CONTROL_AUTH:
		case M_REMOTE_CONTROL_CMD:
			{
				Game().OnRadminMessage(m_type, P);
			}break;
		case M_CHANGE_LEVEL_GAME:
			{
				Msg("- M_CHANGE_LEVEL_GAME Received");

				if (OnClient())
				{
					Engine.Event.Defer	("KERNEL:disconnect");
					Engine.Event.Defer	("KERNEL:start",m_caServerOptions.size() ? size_t( xr_strdup(*m_caServerOptions)) : 0,m_caClientOptions.size() ? size_t(xr_strdup(*m_caClientOptions)) : 0);
				}
				else
				{
					const char* m_SO = m_caServerOptions.c_str();
//					const char* m_CO = m_caClientOptions.c_str();

					m_SO = strchr(m_SO, '/'); if (m_SO) m_SO++;
					m_SO = strchr(m_SO, '/'); 

					string128 LevelName = "";
					string128 GameType = "";

					P->r_stringZ(LevelName);
					P->r_stringZ(GameType);

					string4096 NewServerOptions = "";
					sprintf_s(NewServerOptions, "%s/%s", LevelName, GameType);

					if (m_SO) strcat(NewServerOptions, m_SO);
					m_caServerOptions = NewServerOptions;

					Engine.Event.Defer	("KERNEL:disconnect");
					Engine.Event.Defer	("KERNEL:start",size_t(xr_strdup(*m_caServerOptions)),size_t(xr_strdup(*m_caClientOptions)));
				};
			}break;
		case M_CHANGE_SELF_NAME:
			{
				net_OnChangeSelfName(P);
			}break;
		case M_BULLET_CHECK_RESPOND:
			{
				if (!game) break;
				if (GameID() != GAME_SINGLE)
					Game().m_WeaponUsageStatistic->On_Check_Respond(P);
			}break;
		case M_STATISTIC_UPDATE:
			{
				if (!game) break;
				if (GameID() != GAME_SINGLE)
					Game().m_WeaponUsageStatistic->OnUpdateRequest(P);
			}break;
		case M_STATISTIC_UPDATE_RESPOND:
			{
				if (!game) break;
				if (GameID() != GAME_SINGLE)
					Game().m_WeaponUsageStatistic->OnUpdateRespond(P);
			}break;
		case M_BATTLEYE:
			{
#ifdef BATTLEYE
			battleye_system.ReadPacketClient( P );
#endif // BATTLEYE
			}break;
		}

		net_msg_Release();
	}	

//	if (!g_bDebugEvents) ProcessGameSpawns();
}
示例#21
0
void xrCompressor::ProcessLTX(CInifile& ltx)
{
	config_ltx	=&ltx;

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

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

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

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

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

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

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

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

	PerformWork	();

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

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

	exclude_exts.clear_and_free();
}
示例#22
0
void xrCompressor::CompressOne(LPCSTR path)
{
	filesTOTAL		++;

	if (testSKIP(path))	
	{
		filesSKIP	++;
		printf		(" - a SKIP");
		Msg			("%-80s   - SKIP",path);
		return;
	}

	string_path		fn;				
	strconcat		(sizeof(fn), fn, target_name.c_str(), "\\", path);

	if (::GetFileAttributes(fn)==u32(-1))
	{
		filesSKIP	++;
		printf		(" - CAN'T OPEN");
		Msg			("%-80s   - CAN'T OPEN",path);
		return;
	}

	IReader*		src				=	FS.r_open	(fn);
	if (0==src)
	{
		filesSKIP	++;
		printf		(" - CAN'T OPEN");
		Msg			("%-80s   - CAN'T OPEN",path);
		return;
	}

	bytesSRC						+=	src->length	();
	u32			c_crc32				=	crc32		(src->pointer(),src->length());
	u32			c_ptr				=	0;
	u32			c_size_real			=	0;
	u32			c_size_compressed	=	0;
	u32			a_tests				=	0;

	ALIAS*		A					=	testALIAS	(src,c_crc32,a_tests);
	printf							("%3da ",a_tests);
	if(A) 
	{
		filesALIAS			++;
		printf				("ALIAS");
		Msg					("%-80s   - ALIAS (%s)",path,A->path);

		// Alias found
		c_ptr				= A->c_ptr;
		c_size_real			= A->c_size_real;
		c_size_compressed	= A->c_size_compressed;
	} else 
	{
		if (testVFS(path))	
		{
			filesVFS			++;

			// Write into BaseFS
			c_ptr				= fs_pack_writer->tell	();
			c_size_real			= src->length();
			c_size_compressed	= src->length();
			fs_pack_writer->w	(src->pointer(),c_size_real);
			printf				("VFS");
			Msg					("%-80s   - VFS",path);
		} else 
		{ //if(testVFS(path))
			// Compress into BaseFS
			c_ptr				=	fs_pack_writer->tell();
			c_size_real			=	src->length();
			if (0!=c_size_real)
			{
				u32 c_size_max		=	rtc_csize		(src->length());
				u8*	c_data			=	xr_alloc<u8>	(c_size_max);

				t_compress.Begin	();

				c_size_compressed	= c_size_max;
				if (bFast)
				{		
					R_ASSERT(LZO_E_OK == lzo1x_1_compress	((u8*)src->pointer(),c_size_real,c_data,&c_size_compressed,c_heap));
				}else
				{
					R_ASSERT(LZO_E_OK == lzo1x_999_compress	((u8*)src->pointer(),c_size_real,c_data,&c_size_compressed,c_heap));
				}

				t_compress.End		();

				if ((c_size_compressed+16) >= c_size_real)
				{
					// Failed to compress - revert to VFS
					filesVFS			++;
					c_size_compressed	= c_size_real;
					fs_pack_writer->w	(src->pointer(),c_size_real);
					printf				("VFS (R)");
					Msg					("%-80s   - VFS (R)",path);
				} else 
				{
					// Compressed OK - optimize
					if (!bFast)
					{
						u8*		c_out	= xr_alloc<u8>	(c_size_real);
						u32		c_orig	= c_size_real;
						R_ASSERT		(LZO_E_OK	== lzo1x_optimize	(c_data,c_size_compressed,c_out,&c_orig, NULL));
						R_ASSERT		(c_orig		== c_size_real		);
						xr_free			(c_out);
					}//bFast
					fs_pack_writer->w	(c_data,c_size_compressed);
					printf				("%3.1f%%",	100.f*float(c_size_compressed)/float(src->length()));
					Msg					("%-80s   - OK (%3.1f%%)",path,100.f*float(c_size_compressed)/float(src->length()));
				}

				// cleanup
				xr_free		(c_data);
			}else
			{ //0!=c_size_real
				filesVFS				++;
				c_size_compressed		= c_size_real;
				printf					("VFS (R)");
				Msg						("%-80s   - EMPTY FILE",path);
			}
		}//test VFS
	} //(A)

	// Write description
	write_file_header		(path,c_crc32,c_ptr,c_size_real,c_size_compressed);

	if (0==A)	
	{
		// Register for future aliasing
		ALIAS				R;
		R.path				= xr_strdup	(fn);
		R.crc				= c_crc32;
		R.c_ptr				= c_ptr;
		R.c_size_real		= c_size_real;
		R.c_size_compressed	= c_size_compressed;
		aliases.insert		(mk_pair(R.c_size_real,R));
	}

	FS.r_close	(src);
}
示例#23
0
bool	CInifile::save_as( LPCSTR new_fname )
{
	// save if needed
    if (new_fname&&new_fname[0]){
        xr_free			(fName);
        fName			= xr_strdup(new_fname);
    }
    R_ASSERT			(fName&&fName[0]);
    IWriter* F			= FS.w_open_ex(fName);
    if (F){
        string512		temp,val;
        for (RootIt r_it=DATA.begin(); r_it!=DATA.end(); ++r_it)
		{
            sprintf_s		(temp,sizeof(temp),"[%s]",*(*r_it)->Name);
            F->w_string	(temp);
            for (SectCIt s_it=(*r_it)->Data.begin(); s_it!=(*r_it)->Data.end(); ++s_it)
            {
                const Item&	I = *s_it;
                if (*I.first) {
                    if (*I.second) {
                        _decorate	(val,*I.second);
#ifdef DEBUG
                        if (*I.comment) {
                            // name, value and comment
                            sprintf_s	(temp,sizeof(temp),"%8s%-32s = %-32s ;%s"," ",*I.first,val,*I.comment);
                        } else
#endif
						{
                            // only name and value
                            sprintf_s	(temp,sizeof(temp),"%8s%-32s = %-32s"," ",*I.first,val);
                        }
                    } else {
#ifdef DEBUG
                        if (*I.comment) {
                            // name and comment
                            sprintf_s(temp,sizeof(temp),"%8s%-32s = ;%s"," ",*I.first,*I.comment);
                        } else
#endif
						{
                            // only name
                            sprintf_s(temp,sizeof(temp),"%8s%-32s = "," ",*I.first);
                        }
                    }
                } else {
                    // no name, so no value
#ifdef DEBUG
                    if (*I.comment)
						sprintf_s		(temp,sizeof(temp),"%8s;%s"," ",*I.comment);
                    else
#endif
						temp[0]		= 0;
                }
                _TrimRight			(temp);
                if (temp[0])		F->w_string	(temp);
            }
            F->w_string		(" ");
        }
        FS.w_close			(F);
	    return true;
    }
    return false;
}
示例#24
0
void ProcessLTX(LPCSTR tgt_name, LPCSTR params, BOOL bFast)
{
	xr_string		ltx_name;
	LPCSTR ltx_nm	= strstr(params,".ltx");				VERIFY(ltx_nm!=0);
	string_path		ltx_fn;
	string_path		tmp;
	strncpy			(tmp,params,ltx_nm-params); tmp[ltx_nm-params]=0;
	_Trim			(tmp);
	strcat			(tmp,".ltx");
	strcpy			(ltx_fn,tmp);

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

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

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

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

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

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

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

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

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

	exclude_exts.clear_and_free();
}