您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ u16函数代码示例

51自学网 2021-06-03 09:02:44
  C++
这篇教程C++ u16函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中u16函数的典型用法代码示例。如果您正苦于以下问题:C++ u16函数的具体用法?C++ u16怎么用?C++ u16使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了u16函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: warning

BOOL CGameObject::net_Spawn		(CSE_Abstract*	DC){	VERIFY							(!m_spawned);	m_spawned						= true;	m_spawn_time					= Device.dwFrame;	m_ai_obstacle					= xr_new<ai_obstacle>(this);	CSE_Abstract					*E = (CSE_Abstract*)DC;	VERIFY							(E);	const CSE_Visual				*visual	= smart_cast<const CSE_Visual*>(E);	if (visual) {		cNameVisual_set				(visual_name(E));		if (visual->flags.test(CSE_Visual::flObstacle)) {			ISpatial				*self = smart_cast<ISpatial*>(this);			self->spatial.type		|=	STYPE_OBSTACLE;		}	}	// Naming	cName_set						(E->s_name);	cNameSect_set					(E->s_name);	if (E->name_replace()[0])		cName_set					(E->name_replace());	bool demo_spectator = false;		if (Level().IsDemoPlayStarted() && E->ID == u16(-1))	{		Msg("* Spawning demo spectator ...");		demo_spectator = true;	} else {		R_ASSERT(Level().Objects.net_Find(E->ID) == NULL);	}	setID							(E->ID);//	if (GameID() != eGameIDSingle)//		Msg ("CGameObject::net_Spawn -- object %s[%x] setID [%d]", *(E->s_name), this, E->ID);		// XForm	XFORM().setXYZ					(E->o_Angle);	Position().set					(E->o_Position);#ifdef DEBUG	if(ph_dbg_draw_mask1.test(ph_m1_DbgTrackObject)&&stricmp(PH_DBG_ObjectTrackName(),*cName())==0)	{		Msg("CGameObject::net_Spawn obj %s Position set from CSE_Abstract %f,%f,%f",PH_DBG_ObjectTrackName(),Position().x,Position().y,Position().z);	}#endif	VERIFY							(_valid(renderable.xform));	VERIFY							(!fis_zero(DET(renderable.xform)));	CSE_ALifeObject					*O = smart_cast<CSE_ALifeObject*>(E);	if (O && xr_strlen(O->m_ini_string)) {#pragma warning(push)#pragma warning(disable:4238)		m_ini_file					= xr_new<CInifile>(			&IReader				(				(void*)(*(O->m_ini_string)),				O->m_ini_string.size()			),			FS.get_path("$game_config$")->m_Path		);#pragma warning(pop)	}	m_story_id						= ALife::_STORY_ID(-1);	if (O)		m_story_id					= O->m_story_id;	// Net params	setLocal						(E->s_flags.is(M_SPAWN_OBJECT_LOCAL));	if (Level().IsDemoPlay()) //&& OnClient())	{		if (!demo_spectator)		{			setLocal(FALSE);		}	};	setReady						(TRUE);	if (!demo_spectator)		g_pGameLevel->Objects.net_Register	(this);	m_server_flags.one				();	if (O) {		m_server_flags					= O->m_flags;		if (O->m_flags.is(CSE_ALifeObject::flVisibleForAI))			spatial.type				|= STYPE_VISIBLEFORAI;		else			spatial.type				= (spatial.type | STYPE_VISIBLEFORAI) ^ STYPE_VISIBLEFORAI;	}	reload						(*cNameSect());	if(!g_dedicated_server)		CScriptBinder::reload	(*cNameSect());		reinit						();	if(!g_dedicated_server)		CScriptBinder::reinit	();#ifdef DEBUG	if(ph_dbg_draw_mask1.test(ph_m1_DbgTrackObject)&&stricmp(PH_DBG_ObjectTrackName(),*cName())==0)//.........这里部分代码省略.........
开发者ID:AntonioModer,项目名称:xray-16,代码行数:101,


示例2: VERIFY

BOOL R_constant_table::parseConstants(ID3D10ShaderReflectionConstantBuffer* pTable, u16 destination){	//VERIFY(_desc);	//ID3D10ShaderReflectionConstantBuffer *pTable = (ID3D10ShaderReflectionConstantBuffer *)_desc;	VERIFY(pTable);	D3D10_SHADER_BUFFER_DESC	TableDesc;	CHK_DX(pTable->GetDesc(&TableDesc));	//D3DXSHADER_CONSTANTTABLE* desc	= (D3DXSHADER_CONSTANTTABLE*) _desc;	//D3DXSHADER_CONSTANTINFO* it		= (D3DXSHADER_CONSTANTINFO*) (LPBYTE(desc)+desc->ConstantInfo);	//LPBYTE					 ptr	= LPBYTE(desc);	//for (u32 dwCount = desc->Constants; dwCount; dwCount--,it++)	for (u32 i = 0; i < TableDesc.Variables; ++i)	{		ID3D10ShaderReflectionVariable* pVar;		D3D10_SHADER_VARIABLE_DESC		VarDesc;		ID3D10ShaderReflectionType*		pType;		D3D10_SHADER_TYPE_DESC			TypeDesc;		pVar = pTable->GetVariableByIndex(i);		VERIFY(pVar);		pVar->GetDesc(&VarDesc);		pType = pVar->GetType();		VERIFY(pType);		pType->GetDesc(&TypeDesc);		// Name		//LPCSTR	name		=	LPCSTR(ptr+it->Name);		LPCSTR	name		=	VarDesc.Name;		// Type		//u16		type		=	RC_float;		u16		type = u16(-1);		switch(TypeDesc.Type)		{		case D3D10_SVT_FLOAT:			type = RC_float;			break;		case D3D10_SVT_BOOL:			type	= RC_bool;			break;		case D3D10_SVT_INT:			type	= RC_int;			break;		default:			fatal ("R_constant_table::parse: unexpected shader variable type.");		}		// Rindex,Rcount		//u16		r_index		=	it->RegisterIndex;		//	Used as byte offset in constant buffer		VERIFY(VarDesc.StartOffset<0x10000);		u16		r_index		=	u16(VarDesc.StartOffset);		u16		r_type		=	u16(-1);		// TypeInfo + class		//D3DXSHADER_TYPEINFO*	T	= (D3DXSHADER_TYPEINFO*)(ptr+it->TypeInfo);		BOOL bSkip					= FALSE;		//switch (T->Class)		switch (TypeDesc.Class)		{		case D3D10_SVC_SCALAR:			r_type = RC_1x1;			break;		case D3D10_SVC_VECTOR:			{				switch(TypeDesc.Columns)				{				case 4:					r_type = RC_1x4;					break;				case 3:					r_type = RC_1x3;				    break;				case 2:					r_type = RC_1x2;					break;				default:					fatal("Vector: 1 components is scalar - there is special case for this!!!!!");				    break;				}			}			break;		case D3D10_SVC_MATRIX_ROWS:			{				switch (TypeDesc.Columns)				{				case 4:					switch (TypeDesc.Rows)					{					case 2:						r_type = RC_2x4;						break;					case 3:						r_type = RC_3x4;						break;						/*						switch (it->RegisterCount)						{						case 2:	r_type	=	RC_2x4;	break;//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:xray,代码行数:101,


示例3: xps_measure_font_glyph

voidxps_measure_font_glyph(xps_context_t *ctx, xps_font_t *font, int gid, xps_glyph_metrics_t *mtx){    int head, format, loca, glyf;    int ofs, len;    int idx, i, n;    int hadv, vadv, vorg;    int vtop, ymax, desc;    int scale;    /* some insane defaults */    scale = 1000; /* units-per-em */    hadv = 500;    vadv = -1000;    vorg = 1000;    /*     * Horizontal metrics are easy.     */    ofs = xps_find_sfnt_table(font, "hhea", &len);    if (ofs < 0 || len < 2 * 18)    {        gs_warn("hhea table is too short");        return;    }    vorg = s16(font->data + ofs + 4); /* ascender is default vorg */    desc = s16(font->data + ofs + 6); /* descender */    if (desc < 0)        desc = -desc;    n = u16(font->data + ofs + 17 * 2);    ofs = xps_find_sfnt_table(font, "hmtx", &len);    if (ofs < 0)    {        gs_warn("cannot find hmtx table");        return;    }    idx = gid;    if (idx > n - 1)        idx = n - 1;    hadv = u16(font->data + ofs + idx * 4);    vadv = 0;    /*     * Vertical metrics are hairy (with missing tables).     */    head = xps_find_sfnt_table(font, "head", &len);    if (head > 0)    {        scale = u16(font->data + head + 18); /* units per em */    }    ofs = xps_find_sfnt_table(font, "OS/2", &len);    if (ofs > 0 && len > 70)    {        vorg = s16(font->data + ofs + 68); /* sTypoAscender */        desc = s16(font->data + ofs + 70); /* sTypoDescender */        if (desc < 0)            desc = -desc;    }    ofs = xps_find_sfnt_table(font, "vhea", &len);    if (ofs > 0 && len >= 2 * 18)    {        n = u16(font->data + ofs + 17 * 2);        ofs = xps_find_sfnt_table(font, "vmtx", &len);        if (ofs < 0)        {            gs_warn("cannot find vmtx table");            return;        }        idx = gid;        if (idx > n - 1)            idx = n - 1;        vadv = u16(font->data + ofs + idx * 4);        vtop = u16(font->data + ofs + idx * 4 + 2);        glyf = xps_find_sfnt_table(font, "glyf", &len);        loca = xps_find_sfnt_table(font, "loca", &len);        if (head > 0 && glyf > 0 && loca > 0)        {            format = u16(font->data + head + 50); /* indexToLocaFormat */            if (format == 0)                ofs = u16(font->data + loca + gid * 2) * 2;            else                ofs = u32(font->data + loca + gid * 4);            ymax = u16(font->data + glyf + ofs + 8); /* yMax *///.........这里部分代码省略.........
开发者ID:hackqiang,项目名称:gs,代码行数:101,


示例4:

CUIStalkerRankingInfoItem::CUIStalkerRankingInfoItem(CUIStalkersRankingWnd* w):m_StalkersRankingWnd(w),m_humanID(u16(-1)){}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:4,


示例5: Status

void CBuild::BuildSectors(){	Status("Determining sectors...");	Progress(0);	u32 SectorMax=0;	for (u32 I=0; I<g_tree.size(); I++)		if (g_tree[I]->Sector>SectorMax) SectorMax=g_tree[I]->Sector;	R_ASSERT(SectorMax<0xffff);	u32 SectorCount = SectorMax+1; 	g_sectors.resize(SectorCount);	ZeroMemory(&*g_sectors.begin(),(u32)g_sectors.size()*sizeof(void*));	clMsg("%d sectors accepted.",SectorCount);	Status("Spatializing geometry...");	for (u32 I=0; I<g_tree.size(); I++)	{		u32 Sector = g_tree[I]->Sector;		if (0==g_sectors[Sector]) g_sectors[Sector] = new CSector(Sector);	}	Status("Building hierrarhy...");	for (u32 I=0; I<g_sectors.size(); I++)	{		R_ASSERT(g_sectors[I]);		g_sectors[I]->BuildHierrarhy();		Progress(float(I)/float(g_sectors.size()));	}	Status("Assigning portals, occluders, glows, lights...");	// portals	for (u32 I=0; I<portals.size(); I++)	{		b_portal &P = portals[I];		R_ASSERT(u32(P.sector_front)<g_sectors.size());		R_ASSERT(u32(P.sector_back) <g_sectors.size());		g_sectors[u32(P.sector_front)]->add_portal	(u16(I));		g_sectors[u32(P.sector_back)]->add_portal		(u16(I));	}	// glows	for (u32 I=0; I<glows.size(); I++)	{		b_glow		&G = glows[I];		b_material	&M = materials()[G.dwMaterial];		R_ASSERT(M.sector<g_sectors.size());		g_sectors[M.sector]->add_glow			(u16(I));	}	// lights	for (u32 I=0; I<L_dynamic.size(); I++)	{		b_light_dynamic	&L = L_dynamic[I];		if (L.data.type == D3DLIGHT_DIRECTIONAL)		{			for (u32 j=0; j<g_sectors.size(); j++)			{				R_ASSERT(g_sectors[j]);				g_sectors[j]->add_light(u16(I));			}		} else {			if	(L.sectors.size()) {				for (u32 j=0; j<L.sectors.size(); j++)				{					R_ASSERT	(L.sectors[j]<g_sectors.size());					g_sectors	[L.sectors[j]]->add_light(u16(I));				}			} else {				clMsg("Fuck!!! Light at position %f,%f,%f non associated!!!",					L.data.position.x,L.data.position.y,L.data.position.z					);			}		}	}}
开发者ID:2asoft,项目名称:xray,代码行数:73,


示例6: xps_load_sfnt_name

/* * Get the windows truetype font file name - position 4 in the name table. */voidxps_load_sfnt_name(xps_font_t *font, char *namep){    byte *namedata;    int offset, length;    int format, count, stringoffset;    int found;    int i, k;    found = 0;    strcpy(namep, "Unknown");    offset = xps_find_sfnt_table(font, "name", &length);    if (offset < 0 || length < 6)    {        gs_warn("cannot find name table");        return;    }    namedata = font->data + offset;    format = u16(namedata + 0);    count = u16(namedata + 2);    stringoffset = u16(namedata + 4);    if (length < 6 + (count * 12))    {        gs_warn("name table too short");        return;    }    for (i = 0; i < count; i++)    {        byte *record = namedata + 6 + i * 12;        int pid = u16(record + 0);        int eid = u16(record + 2);        int langid = u16(record + 4);        int nameid = u16(record + 6);        length = u16(record + 8);        offset = u16(record + 10);        /* Full font name or postscript name */        if (nameid == 4 || nameid == 6)        {            if (pid == 1 && eid == 0 && langid == 0) /* mac roman, english */            {                if (found < 3)                {                    memcpy(namep, namedata + stringoffset + offset, length);                    namep[length] = 0;                    found = 3;                }            }            if (pid == 3 && eid == 1 && langid == 0x409) /* windows unicode ucs-2, US */            {                if (found < 2)                {                    unsigned char *s = namedata + stringoffset + offset;                    int n = length / 2;                    for (k = 0; k < n; k ++)                    {                        int c = u16(s + k * 2);                        namep[k] = isprint(c) ? c : '?';                    }                    namep[k] = 0;                    found = 2;                }            }            if (pid == 3 && eid == 10 && langid == 0x409) /* windows unicode ucs-4, US */            {                if (found < 1)                {                    unsigned char *s = namedata + stringoffset + offset;                    int n = length / 4;                    for (k = 0; k < n; k ++)                    {                        int c = u32(s + k * 4);                        namep[k] = isprint(c) ? c : '?';                    }                    namep[k] = 0;                    found = 1;                }            }        }    }}
开发者ID:hackqiang,项目名称:gs,代码行数:91,


示例7: Int

void CodeGen_X86::visit(const Cast *op) {    if (!op->type.is_vector()) {        // We only have peephole optimizations for vectors in here.        CodeGen_Posix::visit(op);        return;    }    vector<Expr> matches;    struct Pattern {        Target::Feature feature;        bool wide_op;        Type type;        int min_lanes;        string intrin;        Expr pattern;    };    static Pattern patterns[] = {        {   Target::FeatureEnd, true, Int(8, 16), 0, "llvm.x86.sse2.padds.b",            i8_sat(wild_i16x_ + wild_i16x_)        },        {   Target::FeatureEnd, true, Int(8, 16), 0, "llvm.x86.sse2.psubs.b",            i8_sat(wild_i16x_ - wild_i16x_)        },        {   Target::FeatureEnd, true, UInt(8, 16), 0, "llvm.x86.sse2.paddus.b",            u8_sat(wild_u16x_ + wild_u16x_)        },        {   Target::FeatureEnd, true, UInt(8, 16), 0, "llvm.x86.sse2.psubus.b",            u8(max(wild_i16x_ - wild_i16x_, 0))        },        {   Target::FeatureEnd, true, Int(16, 8), 0, "llvm.x86.sse2.padds.w",            i16_sat(wild_i32x_ + wild_i32x_)        },        {   Target::FeatureEnd, true, Int(16, 8), 0, "llvm.x86.sse2.psubs.w",            i16_sat(wild_i32x_ - wild_i32x_)        },        {   Target::FeatureEnd, true, UInt(16, 8), 0, "llvm.x86.sse2.paddus.w",            u16_sat(wild_u32x_ + wild_u32x_)        },        {   Target::FeatureEnd, true, UInt(16, 8), 0, "llvm.x86.sse2.psubus.w",            u16(max(wild_i32x_ - wild_i32x_, 0))        },        // Only use the avx2 version if we have > 8 lanes        {   Target::AVX2, true, Int(16, 16), 9, "llvm.x86.avx2.pmulh.w",            i16((wild_i32x_ * wild_i32x_) / 65536)        },        {   Target::AVX2, true, UInt(16, 16), 9, "llvm.x86.avx2.pmulhu.w",            u16((wild_u32x_ * wild_u32x_) / 65536)        },        {   Target::FeatureEnd, true, Int(16, 8), 0, "llvm.x86.sse2.pmulh.w",            i16((wild_i32x_ * wild_i32x_) / 65536)        },        {   Target::FeatureEnd, true, UInt(16, 8), 0, "llvm.x86.sse2.pmulhu.w",            u16((wild_u32x_ * wild_u32x_) / 65536)        },        {   Target::FeatureEnd, true, UInt(8, 16), 0, "llvm.x86.sse2.pavg.b",            u8(((wild_u16x_ + wild_u16x_) + 1) / 2)        },        {   Target::FeatureEnd, true, UInt(16, 8), 0, "llvm.x86.sse2.pavg.w",            u16(((wild_u32x_ + wild_u32x_) + 1) / 2)        },        {   Target::FeatureEnd, false, Int(16, 8), 0, "packssdwx8",            i16_sat(wild_i32x_)        },        {   Target::FeatureEnd, false, Int(8, 16), 0, "packsswbx16",            i8_sat(wild_i16x_)        },        {   Target::FeatureEnd, false, UInt(8, 16), 0, "packuswbx16",            u8_sat(wild_i16x_)        },        {   Target::SSE41, false, UInt(16, 8), 0, "packusdwx8",            u16_sat(wild_i32x_)        }    };    for (size_t i = 0; i < sizeof(patterns)/sizeof(patterns[0]); i++) {        const Pattern &pattern = patterns[i];        if (!target.has_feature(pattern.feature)) {            continue;        }        if (op->type.lanes() < pattern.min_lanes) {            continue;        }        if (expr_match(pattern.pattern, op, matches)) {            bool match = true;            if (pattern.wide_op) {                // Try to narrow the matches to the target type.                for (size_t i = 0; i < matches.size(); i++) {                    matches[i] = lossless_cast(op->type, matches[i]);                    if (!matches[i].defined()) match = false;                }            }            if (match) {//.........这里部分代码省略.........
开发者ID:cyanjc321,项目名称:Halide,代码行数:101,


示例8: color_rgba

//.........这里部分代码省略.........		s_combine_dbg_Accumulator.create	("effects//screen_set",		r2_RT_accum			);		g_combine_VP.create					(dwDecl,		RCache.Vertex.Buffer(), RCache.QuadIB);		g_combine.create					(FVF::F_TL,		RCache.Vertex.Buffer(), RCache.QuadIB);		g_combine_2UV.create				(FVF::F_TL2uv,	RCache.Vertex.Buffer(), RCache.QuadIB);		u32 fvf_aa_blur				= D3DFVF_XYZRHW|D3DFVF_TEX4|D3DFVF_TEXCOORDSIZE2(0)|D3DFVF_TEXCOORDSIZE2(1)|D3DFVF_TEXCOORDSIZE2(2)|D3DFVF_TEXCOORDSIZE2(3);		g_aa_blur.create			(fvf_aa_blur,	RCache.Vertex.Buffer(), RCache.QuadIB);		u32 fvf_aa_AA				= D3DFVF_XYZRHW|D3DFVF_TEX7|D3DFVF_TEXCOORDSIZE2(0)|D3DFVF_TEXCOORDSIZE2(1)|D3DFVF_TEXCOORDSIZE2(2)|D3DFVF_TEXCOORDSIZE2(3)|D3DFVF_TEXCOORDSIZE2(4)|D3DFVF_TEXCOORDSIZE4(5)|D3DFVF_TEXCOORDSIZE4(6);		g_aa_AA.create				(fvf_aa_AA,		RCache.Vertex.Buffer(), RCache.QuadIB);		t_envmap_0.create			(r2_T_envs0);		t_envmap_1.create			(r2_T_envs1);	}	// Build textures	{		// Build material(s)		{			// Surface			R_CHK						(D3DXCreateVolumeTexture(HW.pDevice,TEX_material_LdotN,TEX_material_LdotH,4,1,0,D3DFMT_A8L8,D3DPOOL_MANAGED,&t_material_surf));			t_material					= dxRenderDeviceRender::Instance().Resources->_CreateTexture(r2_material);			t_material->surface_set		(t_material_surf);			// Fill it (addr: x=dot(L,N),y=dot(L,H))			D3DLOCKED_BOX				R;			R_CHK						(t_material_surf->LockBox	(0,&R,0,0));			for (u32 slice=0; slice<4; slice++)			{				for (u32 y=0; y<TEX_material_LdotH; y++)				{					for (u32 x=0; x<TEX_material_LdotN; x++)					{						u16*	p	=	(u16*)		(LPBYTE (R.pBits) + slice*R.SlicePitch + y*R.RowPitch + x*2);						float	ld	=	float(x)	/ float	(TEX_material_LdotN-1);						float	ls	=	float(y)	/ float	(TEX_material_LdotH-1) + EPS_S;						ls			*=	powf(ld,1/32.f);						float	fd,fs;						switch	(slice)						{						case 0:	{ // looks like OrenNayar							fd	= powf(ld,0.75f);		// 0.75							fs	= powf(ls,16.f)*.5f;								}	break;						case 1:	{// looks like Blinn							fd	= powf(ld,0.90f);		// 0.90							fs	= powf(ls,24.f);								}	break;						case 2:	{ // looks like Phong							fd	= ld;					// 1.0							fs	= powf(ls*1.01f,128.f	);								}	break;						case 3:	{ // looks like Metal							float	s0	=	_abs	(1-_abs	(0.05f*_sin(33.f*ld)+ld-ls));							float	s1	=	_abs	(1-_abs	(0.05f*_cos(33.f*ld*ls)+ld-ls));							float	s2	=	_abs	(1-_abs	(ld-ls));							fd		=	ld;				// 1.0							fs		=	powf	(_max(_max(s0,s1),s2), 24.f);							fs		*=	powf	(ld,1/7.f);								}	break;						default:							fd	= fs = 0;						}						s32		_d	=	clampr	(iFloor	(fd*255.5f),	0,255);						s32		_s	=	clampr	(iFloor	(fs*255.5f),	0,255);
开发者ID:2asoft,项目名称:xray,代码行数:67,


示例9: do_sound_event

void do_sound_event(std::pair<u16, CSfxHandle>& sfxHandle, float& pitch, bool doPitchBend, u32 soundId, float weight,                    u32 flags, float falloff, float maxDist, float minVol, float maxVol,                    const zeus::CVector3f& posToCam, const zeus::CVector3f& pos, TAreaId aid, CStateManager& mgr) {  if (posToCam.magSquared() >= maxDist * maxDist)    return;  u16 useSfxId = CSfxManager::TranslateSFXID(u16(soundId));  u32 useFlags = 0x1; // Continuous parameter update  if ((flags & 0x8) != 0)    useFlags |= 0x8; // Doppler effect  bool useAcoustics = (flags & 0x80) == 0;  CAudioSys::C3DEmitterParmData parms;  parms.x0_pos = pos;  parms.xc_dir = zeus::skUp;  parms.x18_maxDist = maxDist;  parms.x1c_distComp = falloff;  parms.x20_flags = useFlags;  parms.x24_sfxId = useSfxId;  parms.x26_maxVol = maxVol;  parms.x27_minVol = minVol;  parms.x28_important = false;  parms.x29_prio = 0x7f;  if (mgr.GetActiveRandom()->Float() <= weight) {    if ((soundId & 0x80000000) != 0) {      if (!sfxHandle.second) {        CSfxHandle hnd;        if ((soundId & 0x40000000) != 0)          hnd = CSfxManager::SfxStart(useSfxId, 1.f, 0.f, true, 0x7f, true, aid);        else          hnd = CSfxManager::AddEmitter(parms, useAcoustics, 0x7f, true, aid);        if (hnd) {          sfxHandle.first = useSfxId;          sfxHandle.second = hnd;          if (doPitchBend)            CSfxManager::PitchBend(hnd, pitch);        }      } else {        if (sfxHandle.first == useSfxId) {          CSfxManager::UpdateEmitter(sfxHandle.second, parms.x0_pos, parms.xc_dir, parms.x26_maxVol);        } else if ((flags & 0x4) != 0) // Pausable        {          CSfxManager::RemoveEmitter(sfxHandle.second);          CSfxHandle hnd = CSfxManager::AddEmitter(parms, useAcoustics, 0x7f, true, aid);          if (hnd) {            sfxHandle.first = useSfxId;            sfxHandle.second = hnd;            if (doPitchBend)              CSfxManager::PitchBend(hnd, pitch);          }        }      }    } else {      CSfxHandle hnd;      if ((soundId & 0x40000000) != 0)        hnd = CSfxManager::SfxStart(useSfxId, 1.f, 0.f, true, 0x7f, false, aid);      else        hnd = CSfxManager::AddEmitter(parms, useAcoustics, 0x7f, false, aid);      if (doPitchBend)        CSfxManager::PitchBend(hnd, pitch);    }  }}
开发者ID:AxioDL,项目名称:urde,代码行数:64,


示例10: switch

void CActor::OnEvent		(NET_Packet& P, u16 type){	inherited::OnEvent			(P,type);	CInventoryOwner::OnEvent	(P,type);	u16 id;	switch (type)	{	case GE_TRADE_BUY:	case GE_OWNERSHIP_TAKE:		{			P.r_u16		(id);			CObject* O	= Level().Objects.net_Find	(id);			if (!O)			{				Msg("! Error: No object to take/buy [%d]", id);				break;			}			CGameObject* _GO = smart_cast<CGameObject*>(O);						CFoodItem* pFood = smart_cast<CFoodItem*>(O);			if(pFood)#if defined(INV_NEW_SLOTS_SYSTEM)			if (pFood->m_eItemPlace != eItemPlaceSlot)#endif				pFood->m_eItemPlace = eItemPlaceRuck;			if( inventory().CanTakeItem(smart_cast<CInventoryItem*>(_GO)) )			{				O->H_SetParent(smart_cast<CObject*>(this));				inventory().Take(_GO, false, true);				CUIGameSP* pGameSP = NULL;				CUI* ui = HUD().GetUI();				if( ui&&ui->UIGame() )				{					pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame());					if (Level().CurrentViewEntity() == this)							HUD().GetUI()->UIGame()->ReInitShownUI();				};								//добавить отсоединенный аддон в инвентарь				if(pGameSP)				{					if(pGameSP->MainInputReceiver() == pGameSP->InventoryMenu)					{						pGameSP->InventoryMenu->AddItemToBag(smart_cast<CInventoryItem*>(O));					}				}								SelectBestWeapon(O);			} 			else 			{				NET_Packet P;				u_EventGen(P,GE_OWNERSHIP_REJECT,ID());				P.w_u16(u16(O->ID()));				u_EventSend(P);			}		}		break;	case GE_TRADE_SELL:	case GE_OWNERSHIP_REJECT:		{			P.r_u16		(id);			CObject* O	= Level().Objects.net_Find	(id);			if (!O)			{				Msg("! Error: No object to reject/sell [%d]", id);				break;			}			bool just_before_destroy	= !P.r_eof() && P.r_u8();			O->SetTmpPreDestroy				(just_before_destroy);			if (inventory().DropItem(smart_cast<CGameObject*>(O)) && !O->getDestroy()) 			{				O->H_SetParent(0,just_before_destroy);//.				feel_touch_deny(O,2000);				Level().m_feel_deny.feel_touch_deny(O, 1000);			}			SelectBestWeapon(O);			if (Level().CurrentViewEntity() == this && HUD().GetUI() && HUD().GetUI()->UIGame())				HUD().GetUI()->UIGame()->ReInitShownUI();		}		break;	case GE_INV_ACTION:		{			s32 cmd;			P.r_s32		(cmd);			u32 flags;			P.r_u32		(flags);			s32 ZoomRndSeed = P.r_s32();			s32 ShotRndSeed = P.r_s32();												if (flags & CMD_START)			{//.........这里部分代码省略.........
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:101,


示例11: LPBYTE

BOOL	R_constant_table::parse	(void* _desc, u16 destination){	D3DXSHADER_CONSTANTTABLE* desc	= (D3DXSHADER_CONSTANTTABLE*) _desc;	D3DXSHADER_CONSTANTINFO* it		= (D3DXSHADER_CONSTANTINFO*) (LPBYTE(desc)+desc->ConstantInfo);	LPBYTE					 ptr	= LPBYTE(desc);	for (u32 dwCount = desc->Constants; dwCount; dwCount--,it++)	{		// Name		LPCSTR	name		=	LPCSTR(ptr+it->Name);		// Type		u16		type		=	RC_float;		if	(D3DXRS_BOOL == it->RegisterSet)	type	= RC_bool;		if	(D3DXRS_INT4 == it->RegisterSet)	type	= RC_int;		// Rindex,Rcount		u16		r_index		=	it->RegisterIndex;		u16		r_type		=	u16(-1);		// TypeInfo + class		D3DXSHADER_TYPEINFO*	T	= (D3DXSHADER_TYPEINFO*)(ptr+it->TypeInfo);		BOOL bSkip					= FALSE;		switch (T->Class)		{		case D3DXPC_SCALAR:			r_type		=	RC_1x1;		break;		case D3DXPC_VECTOR:			r_type		=	RC_1x4;		break;		case D3DXPC_MATRIX_ROWS:			{				switch (T->Columns)				{				case 4:					switch (T->Rows)					{					case 3:						switch (it->RegisterCount)						{						case 2:	r_type	=	RC_2x4;	break;						case 3: r_type	=	RC_3x4;	break;						default:							Msg("Invalid matrix dimension:%dx%d in constant %s", it->RegisterCount, T->Columns, name);							fatal		("MATRIX_ROWS: unsupported number of RegisterCount");							break;						}						break;					case 4:			r_type		=	RC_4x4;		VERIFY(4 == it->RegisterCount); break;					default:						fatal		("MATRIX_ROWS: unsupported number of Rows");						break;					}					break;				default:					fatal		("MATRIX_ROWS: unsupported number of Columns");					break;				}			}			break;		case D3DXPC_MATRIX_COLUMNS:			fatal		("Pclass MATRIX_COLUMNS unsupported");			break;		case D3DXPC_STRUCT:			fatal		("Pclass D3DXPC_STRUCT unsupported");			break;		case D3DXPC_OBJECT:			{				switch (T->Type)				{				case D3DXPT_SAMPLER:				case D3DXPT_SAMPLER1D:				case D3DXPT_SAMPLER2D:				case D3DXPT_SAMPLER3D:				case D3DXPT_SAMPLERCUBE:					{						// ***Register sampler***						// We have determined all valuable info, search if constant already created						ref_constant	C		=	get	(name);						if (!C)	{							C					= new R_constant();//.g_constant_allocator.create();							C->name				=	name;							C->destination		=	RC_dest_sampler;							C->type				=	RC_sampler;							R_constant_load& L	=	C->samp;							L.index				=	u16(r_index	+ ( (destination&1)? 0 : D3DVERTEXTEXTURESAMPLER0 ));							L.cls				=	RC_sampler	;							table.push_back		(C);						} else {							R_ASSERT			(C->destination	==	RC_dest_sampler);							R_ASSERT			(C->type		==	RC_sampler);							R_constant_load& L	=	C->samp;							R_ASSERT			(L.index		==	r_index);							R_ASSERT			(L.cls			==	RC_sampler);						}					}					break;				default:					fatal		("Pclass D3DXPC_OBJECT - object isn't of 'sampler' type");					break;				}			}			bSkip		= TRUE;			break;//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:xray,代码行数:101,


示例12: while

void			CLevel::ClearAllObjects				(){	bool ParentFound = true;		while (ParentFound)	{			ProcessGameEvents				();		u32 CLObjNum					= Level().Objects.o_count();		ParentFound						= false;		for (u32 i=0; i<CLObjNum; i++)		{			CObject* pObj				= Level().Objects.o_get_by_iterator(i);			if (!pObj->H_Parent()) 				continue;			//-----------------------------------------------------------			NET_Packet					GEN;			GEN.w_begin					(M_EVENT);			//------------------		---------------------------					GEN.w_u32					(Level().timeServer());			GEN.w_u16					(GE_OWNERSHIP_REJECT);			GEN.w_u16					(pObj->H_Parent()->ID());			GEN.w_u16					(u16(pObj->ID()));			game_events->insert			(GEN);			if (g_bDebugEvents)					ProcessGameEvents		();			//-------------------------------------------------------------			ParentFound					= true;			//-------------------------------------------------------------#ifdef DEBUG			Msg ("Rejection of %s[%d] from %s[%d]", *(pObj->cNameSect()), pObj->ID(), *(pObj->H_Parent()->cNameSect()), pObj->H_Parent()->ID());#endif		};	};	u32 CLObjNum = Level().Objects.o_count();	for (u32 i=0; i<CLObjNum; i++)	{		CObject* pObj = Level().Objects.o_get_by_iterator(i);		R_ASSERT(pObj->H_Parent()==NULL);		//-----------------------------------------------------------		NET_Packet			GEN;		GEN.w_begin			(M_EVENT);		//---------------------------------------------				GEN.w_u32			(Level().timeServer());		GEN.w_u16			(GE_DESTROY);		GEN.w_u16			(u16(pObj->ID()));		game_events->insert	(GEN);		if (g_bDebugEvents)	ProcessGameEvents();		//-------------------------------------------------------------		ParentFound = true;		//-------------------------------------------------------------#ifdef DEBUG		Msg ("Destruction of %s[%d]", *(pObj->cNameSect()), pObj->ID());#endif	};	ProcessGameEvents();};
开发者ID:svarog2741,项目名称:RayRoH-Project,代码行数:61,


示例13: op_invokestatic

/* * Execute the INVOKESTATIC instruction */void op_invokestatic() {    Ref entry = resolve(u16(1), ID_METHOD);    if (entry == NULL) { return; } // rollback, gc done    Ref owner = getRef(entry, ENTRY_OWNER);    executeMethod(owner, entry, 3);}
开发者ID:ahua,项目名称:java,代码行数:9,


示例14: alist_s16

static int16_t* alist_s16(struct hle_t* hle, uint16_t dmem){    return (int16_t*)u16(hle->alist_buffer, dmem);}
开发者ID:lordashram,项目名称:mupen64plus-libretro,代码行数:4,


示例15: r_string

u16 CInifile::r_u16(LPCSTR S, LPCSTR L){    LPCSTR		C = r_string(S,L);    return		u16(atoi(C));}
开发者ID:vasilenkomike,项目名称:xray,代码行数:5,


示例16: be16toh

uint16_t be16toh(uint16_t big16){	LittleEndian<uint16_t> u16(big16);	return u16.raw_value;}
开发者ID:BunnyPowah,项目名称:i2pd,代码行数:5,


示例17: xps_encode_font_char_imp

static intxps_encode_font_char_imp(xps_font_t *font, int code){    byte *table;    /* no cmap selected: return identity */    if (font->cmapsubtable <= 0)        return code;    table = font->data + font->cmapsubtable;    switch (u16(table))    {    case 0: /* Apple standard 1-to-1 mapping. */        return table[code + 6];    case 4: /* Microsoft/Adobe segmented mapping. */        {            int segCount2 = u16(table + 6);            byte *endCount = table + 14;            byte *startCount = endCount + segCount2 + 2;            byte *idDelta = startCount + segCount2;            byte *idRangeOffset = idDelta + segCount2;            int i2;            for (i2 = 0; i2 < segCount2 - 3; i2 += 2)            {                int delta, roff;                int start = u16(startCount + i2);                int glyph;                if ( code < start )                    return 0;                if ( code > u16(endCount + i2) )                    continue;                delta = s16(idDelta + i2);                roff = s16(idRangeOffset + i2);                if ( roff == 0 )                {                    return ( code + delta ) & 0xffff; /* mod 65536 */                    return 0;                }                glyph = u16(idRangeOffset + i2 + roff + ((code - start) << 1));                return (glyph == 0 ? 0 : glyph + delta);            }            /*             * The TrueType documentation says that the last range is             * always supposed to end with 0xffff, so this shouldn't             * happen; however, in some real fonts, it does.             */            return 0;        }    case 6: /* Single interval lookup. */        {            int firstCode = u16(table + 6);            int entryCount = u16(table + 8);            if ( code < firstCode || code >= firstCode + entryCount )                return 0;            return u16(table + 10 + ((code - firstCode) << 1));        }    case 10: /* Trimmed array (like 6) */        {            int startCharCode = u32(table + 12);            int numChars = u32(table + 16);            if ( code < startCharCode || code >= startCharCode + numChars )                return 0;            return u32(table + 20 + (code - startCharCode) * 4);        }    case 12: /* Segmented coverage. (like 4) */        {            int nGroups = u32(table + 12);            byte *group = table + 16;            int i;            for (i = 0; i < nGroups; i++)            {                int startCharCode = u32(group + 0);                int endCharCode = u32(group + 4);                int startGlyphID = u32(group + 8);                if ( code < startCharCode )                    return 0;                if ( code <= endCharCode )                    return startGlyphID + (code - startCharCode);                group += 12;            }            return 0;        }    case 2: /* High-byte mapping through table. */    case 8: /* Mixed 16-bit and 32-bit coverage (like 2) */    default:        gs_warn1("unknown cmap format: %d/n", u16(table));        return 0;    }//.........这里部分代码省略.........
开发者ID:hackqiang,项目名称:gs,代码行数:101,


示例18: htobe16

uint16_t htobe16(uint16_t int16){	BigEndian<uint16_t> u16(int16);	return u16.raw_value;}
开发者ID:BunnyPowah,项目名称:i2pd,代码行数:5,


示例19: xps_true_callback_glyph_name

static intxps_true_callback_glyph_name(gs_font *pfont, gs_glyph glyph, gs_const_string *pstr){    /* This function is copied verbatim from plfont.c */    int table_length;    int table_offset;    ulong format;    uint numGlyphs;    uint glyph_name_index;    const byte *postp; /* post table pointer */    /* guess if the font type is not truetype */    if ( pfont->FontType != ft_TrueType )    {        glyph -= 29;        if ( glyph >= 0 && glyph < 258 )        {            pstr->data = (byte*) pl_mac_names[glyph];            pstr->size = strlen((char*)pstr->data);            return 0;        }        else        {            return gs_throw1(-1, "glyph index %lu out of range", (ulong)glyph);        }    }    table_offset = xps_find_sfnt_table((xps_font_t*)pfont->client_data, "post", &table_length);    /* no post table */    if (table_offset < 0)        return gs_throw(-1, "no post table");    /* this shoudn't happen but... */    if ( table_length == 0 )        return gs_throw(-1, "zero-size post table");    ((gs_font_type42 *)pfont)->data.string_proc((gs_font_type42 *)pfont,                                                table_offset, table_length, &postp);    format = u32(postp);    /* Format 1.0 (mac encoding) is a simple table see the TT spec.     * We don't implement this because we don't see it in practice.     * Format 2.5 is deprecated.     * Format 3.0 means that there is no post data in the font file.     * We see this a lot but can't do much about it.     * The only format we support is 2.0.     */    if ( format != 0x20000 )    {        /* Invent a name if we don't know the table format. */        char buf[32];        gs_sprintf(buf, "glyph%d", (int)glyph);        pstr->data = (byte*)buf;        pstr->size = strlen((char*)pstr->data);        return 0;    }    /* skip over the post header */    numGlyphs = u16(postp + 32);    if ( glyph < 0 || glyph > numGlyphs - 1)    {        return gs_throw1(-1, "glyph index %lu out of range", (ulong)glyph);    }    /* glyph name index starts at post + 34 each entry is 2 bytes */    glyph_name_index = u16(postp + 34 + (glyph * 2));    /* this shouldn't happen */    if ( glyph_name_index < 0 && glyph_name_index > 0x7fff )        return gs_throw(-1, "post table format error");    /* mac easy */    if ( glyph_name_index < 258 )    {        // dmprintf2(pfont->memory, "glyph name (mac) %d = %s/n", glyph, pl_mac_names[glyph_name_index]);        pstr->data = (byte*) pl_mac_names[glyph_name_index];        pstr->size = strlen((char*)pstr->data);        return 0;    }    /* not mac */    else    {        byte *mydata;        /* and here's the tricky part */        const byte *pascal_stringp = postp + 34 + (numGlyphs * 2);        /* 0 - 257 lives in the mac table above */        glyph_name_index -= 258;        /* The string we want is the index'th pascal string,         * so we "hop" to each length byte "index" times. */        while (glyph_name_index > 0)        {            pascal_stringp += ((int)(*pascal_stringp)+1);            glyph_name_index--;//.........这里部分代码省略.........
开发者ID:computersforpeace,项目名称:ghostpdl,代码行数:101,


示例20: u16

//Constructor: RCC, GPIO, NVIC, EXITUltrasonic::Ultrasonic(GPIO_TypeDef *trigPort, u8 trigPin, GPIO_TypeDef *echoPort, u8 echoPin, float maxRange, u8 itGroup,u8 prePriority,u8 subPriority){	mTrigPort = trigPort;       //trig gpio port	mEchoPort = echoPort;       //echo gpio port	mTrigPin = u16(1<<trigPin); //trig gpio pin	mEchoPin = u16(1<<echoPin); //echo gpio pin	mMaxRange = maxRange;	mIsReady = true;		//Stpe 1: GPIO Initialize: RCC & GPIO Pin	u8 portSource;	if(mEchoPort==GPIOA)	     { RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); portSource = 0;}	else if(mEchoPort==GPIOB)  { RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE); portSource = 1;}	else if(mEchoPort==GPIOC)	 { RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE); portSource = 2;}	else if(mEchoPort==GPIOD)	 { RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE); portSource = 3;}	else if(mEchoPort==GPIOE)	 { RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE,ENABLE); portSource = 4;}	else if(mEchoPort==GPIOF)	 { RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOF,ENABLE); portSource = 5;}		if(mTrigPort==GPIOA)	     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);	else if(mTrigPort==GPIOB)  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);	else if(mTrigPort==GPIOC)	 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);	else if(mTrigPort==GPIOD)	 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE);	else if(mTrigPort==GPIOE)	 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE,ENABLE);	else if(mTrigPort==GPIOF)	 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOF,ENABLE);		RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);		GPIO_InitTypeDef GPIO_InitStructure;	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;	GPIO_InitStructure.GPIO_Pin = mTrigPin;	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;	GPIO_Init(mTrigPort,&GPIO_InitStructure);	GPIO_InitStructure.GPIO_Pin = mEchoPin;	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;	GPIO_Init(mEchoPort,&GPIO_InitStructure);		GPIO_ResetBits(mTrigPort,mTrigPin);	GPIO_ResetBits(mEchoPort,mEchoPin);		GPIO_EXTILineConfig(portSource,echoPin);	  //Step 2: NVIC Initialize	u32 priorityGroup[5] = {NVIC_PriorityGroup_0,NVIC_PriorityGroup_1,NVIC_PriorityGroup_2,NVIC_PriorityGroup_3,NVIC_PriorityGroup_4};	u8 EXTIx_IRQn;			//外部中断号		switch (echoPin)	{		case 0:			EXTIx_IRQn = EXTI0_IRQn; 		#ifdef USE_ULTRASONIC_EXTI0			pUltExt0 = this;		#endif		break;		case 1:			EXTIx_IRQn = EXTI1_IRQn; 		#ifdef USE_ULTRASONIC_EXTI1			pUltExt1 = this;		#endif		break;		case 2:			EXTIx_IRQn = EXTI2_IRQn; 		#ifdef USE_ULTRASONIC_EXTI2			pUltExt2 = this;		#endif		break;		case 3:			EXTIx_IRQn = EXTI3_IRQn; 		#ifdef USE_ULTRASONIC_EXTI3			pUltExt3 = this;		#endif		break;		case 4:			EXTIx_IRQn = EXTI4_IRQn; 		#ifdef USE_ULTRASONIC_EXTI4			pUltExt4 = this;		#endif		break;		case 5:		#ifdef USE_ULTRASONIC_EXTI5			pUltExt5 = this;		#endif			EXTIx_IRQn = EXTI9_5_IRQn; 		break;		case 6:		#ifdef USE_ULTRASONIC_EXTI6			pUltExt6 = this;		#endif			EXTIx_IRQn = EXTI9_5_IRQn; 		break;		case 7:		#ifdef USE_ULTRASONIC_EXTI7			pUltExt7 = this;		#endif			EXTIx_IRQn = EXTI9_5_IRQn; 		break;		case 8:			EXTIx_IRQn = EXTI9_5_IRQn; 		#ifdef USE_ULTRASONIC_EXTI8			pUltExt8 = this;		#endif//.........这里部分代码省略.........
开发者ID:Neutree,项目名称:AHRS,代码行数:101,


示例21: _max

void CSector::BuildHierrarhy	(){	Fvector		scene_size;	float		delimiter;	BOOL		bAnyNode		= FALSE;	// calc scene BB	Fbox&		scene_bb		= pBuild->scene_bb;	scene_bb.invalidate			();	for (int I=0; I<s32(g_tree.size()); I++)		scene_bb.merge			(g_tree[I]->bbox);	scene_bb.grow	(EPS_L);	// 	scene_bb.getsize(scene_size);	delimiter		=	_max(scene_size.x,_max(scene_size.y,scene_size.z));	delimiter		*=	2;	int		iLevel					= 2;	float	SizeLimit				= c_SS_maxsize/4.f;	if		(SizeLimit<4.f)			SizeLimit=4.f;	if		(delimiter<=SizeLimit)	delimiter*=2;		// just very small level	for (; SizeLimit<=delimiter; SizeLimit*=2)	{		int iSize			= g_tree.size();		for (int I=0; I<iSize; I++)		{			if (g_tree[I]->bConnected)		 continue;			if (g_tree[I]->Sector != SelfID) continue;			OGF_Node* pNode					= xr_new<OGF_Node>(iLevel,u16(SelfID));			pNode->AddChield				(I);			// Find best object to connect with			for (;;) 			{				// Find best object to connect with				int		best_id		= -1;				float	best_volume	= flt_max;				for (int J=0; J<iSize; J++)				{					OGF_Base* candidate = g_tree[J];					if ( candidate->bConnected)			continue;					if ( candidate->Sector != SelfID)	continue;					float V;					if (ValidateMerge(pNode->bbox,candidate->bbox,V,SizeLimit))					{						if (V<best_volume)	{							best_volume		= V;							best_id			= J;						}					}				}				// Analyze				if (best_id<0)		break;				pNode->AddChield	(best_id);			}			if (pNode->chields.size()>1)	{				pNode->CalcBounds		();				g_tree.push_back		(pNode);				bAnyNode				= TRUE;			} else {				g_tree[I]->bConnected	= false;				xr_delete				(pNode);			}		}				if (iSize != (int)g_tree.size()) iLevel++;	}	TreeRoot = 0;	if (bAnyNode) TreeRoot = g_tree.back();	else {		for (u32 I=0; I<g_tree.size(); I++)		{			if (g_tree[I]->bConnected)		 continue;			if (g_tree[I]->Sector != SelfID) continue;			R_ASSERT	(0==TreeRoot);			TreeRoot	= g_tree[I];		}	}	if (0==TreeRoot) {		clMsg("Can't build hierrarhy for sector #%d",SelfID);	}}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:90,


示例22: Fvector

class CScriptBinderObject;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Fvector	CScriptGameObject::Center(){	Fvector c;	m_game_object->Center(c);	return	c;}BIND_FUNCTION10	(&object(),	CScriptGameObject::Position,			CGameObject,	Position,			Fvector,						Fvector());BIND_FUNCTION10	(&object(),	CScriptGameObject::Direction,			CGameObject,	Direction,			Fvector,						Fvector());BIND_FUNCTION10	(&object(),	CScriptGameObject::Mass,		CPhysicsShellHolder,	GetMass,			float,							float(-1));BIND_FUNCTION10	(&object(),	CScriptGameObject::ID,					CGameObject,	ID,					u16,							u16(-1));BIND_FUNCTION10	(&object(),	CScriptGameObject::getVisible,			CGameObject,	getVisible,			BOOL,							FALSE);//BIND_FUNCTION01	(&object(),	CScriptGameObject::setVisible,			CGameObject,	setVisible,			BOOL,							BOOL);BIND_FUNCTION10	(&object(),	CScriptGameObject::getEnabled,			CGameObject,	getEnabled,			BOOL,							FALSE);//BIND_FUNCTION01	(&object(),	CScriptGameObject::setEnabled,			CGameObject,	setEnabled,			BOOL,							BOOL);BIND_FUNCTION10	(&object(),	CScriptGameObject::story_id,			CGameObject,	story_id,			ALife::_STORY_ID,				ALife::_STORY_ID(-1));BIND_FUNCTION10	(&object(),	CScriptGameObject::DeathTime,			CEntity,		GetLevelDeathTime,	u32,							0);BIND_FUNCTION10	(&object(),	CScriptGameObject::MaxHealth,			CEntity,		GetMaxHealth,		float,							-1);BIND_FUNCTION10	(&object(),	CScriptGameObject::Accuracy,			CInventoryOwner,GetWeaponAccuracy,	float,							-1);BIND_FUNCTION10	(&object(),	CScriptGameObject::Team,				CEntity,		g_Team,				int,							-1);BIND_FUNCTION10	(&object(),	CScriptGameObject::Squad,				CEntity,		g_Squad,			int,							-1);BIND_FUNCTION10	(&object(),	CScriptGameObject::Group,				CEntity,		g_Group,			int,							-1);BIND_FUNCTION10	(&object(),	CScriptGameObject::GetFOV,				CEntityAlive,	ffGetFov,			float,							-1);BIND_FUNCTION10	(&object(),	CScriptGameObject::GetRange,			CEntityAlive,	ffGetRange,			float,							-1);BIND_FUNCTION10	(&object(),	CScriptGameObject::GetHealth,			CEntityAlive,	conditions().GetHealth,			float,							-1);BIND_FUNCTION10	(&object(),	CScriptGameObject::GetPsyHealth,		CEntityAlive,	conditions().GetPsyHealth,		float,							-1);
开发者ID:AntonioModer,项目名称:xray-16,代码行数:31,


示例23: TRY

void xrMU_Reference::export_ogf(){	xr_vector<u32>		generated_ids;	// Export nodes	{		for (xrMU_Model::v_subdivs_it it=model->m_subdivs.begin(); it!=model->m_subdivs.end(); it++)		{			OGF_Reference*	pOGF	= xr_new<OGF_Reference> ();			b_material*		M		= &(pBuild->materials[it->material]);	// and it's material			R_ASSERT		(M);			// Common data			pOGF->Sector			= sector;			pOGF->material			= it->material;			// Collect textures			OGF_Texture				T;			TRY(T.name		= pBuild->textures[M->surfidx].name);			TRY(T.pSurface	= &(pBuild->textures[M->surfidx]));			TRY(pOGF->textures.push_back(T));			// Special			pOGF->model				= it->ogf;			pOGF->vb_id				= it->vb_id;			pOGF->vb_start			= it->vb_start;			pOGF->ib_id				= it->ib_id;			pOGF->ib_start			= it->ib_start;			pOGF->xform.set			(xform);			pOGF->c_scale			= c_scale;			pOGF->c_bias			= c_bias;			pOGF->sw_id				= it->sw_id;			pOGF->CalcBounds		();			generated_ids.push_back	((u32)g_tree.size());			g_tree.push_back		(pOGF);		}	}	// Now, let's fuck with LODs	if (u16(-1) == model->m_lod_ID)	return;	{		// Create Node and fill it with information		b_lod&		LOD		= pBuild->lods	[model->m_lod_ID];		OGF_LOD*	pNode	= xr_new<OGF_LOD> (1,sector);		pNode->lod_Material	= LOD.dwMaterial;		for (int lf=0; lf<8; lf++)		{			b_lod_face&		F = LOD.faces[lf];			OGF_LOD::_face& D = pNode->lod_faces[lf];			for (int lv=0; lv<4; lv++)			{				xform.transform_tiny(D.v[lv].v,F.v[lv]);				D.v[lv].t			= F.t[lv];				D.v[lv].c_rgb_hemi	= 0xffffffff;				D.v[lv].c_sun		= 0xff;			}		}		// Add all 'OGFs' with such LOD-id		for (u32 o=0; o<generated_ids.size(); o++)			pNode->AddChield(generated_ids[o]);		// Register node		R_ASSERT						(pNode->chields.size());		pNode->CalcBounds				();		g_tree.push_back				(pNode);		// Calculate colors		const float sm_range		= 5.f;		for (int lf=0; lf<8; lf++)		{			OGF_LOD::_face& F = pNode->lod_faces[lf];			for (int lv=0; lv<4; lv++)			{				Fvector	ptPos	= F.v[lv].v;				base_color_c	_C;				float 			_N	= 0;				for (u32 v_it=0; v_it<model->m_vertices.size(); v_it++)				{					// get base					Fvector			baseP;	xform.transform_tiny	(baseP,model->m_vertices[v_it]->P);					base_color_c	baseC;	color[v_it]._get(baseC);					base_color_c	vC;					float			oD	= ptPos.distance_to	(baseP);					float			oA  = 1/(1+100*oD*oD);					vC = 			(baseC);					vC.mul			(oA);					_C.add			(vC);					_N				+= oA;				}				float	s			= 1/(_N+EPS);				_C.mul				(s);				F.v[lv].c_rgb_hemi	= color_rgba(u8_clr(_C.rgb.x),u8_clr(_C.rgb.y),u8_clr(_C.rgb.z),u8_clr(_C.hemi));				F.v[lv].c_sun		= u8_clr	(_C.sun);			}//.........这里部分代码省略.........
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:101,


示例24: CurrentControlEntity

void CLevel::ClientSend(){	if (!GameID() == GAME_SINGLE || OnClient())	if (GameID() == GAME_SINGLE || OnClient())	{		if ( !net_HasBandwidth() ) return;	};#ifdef BATTLEYE	battleye_system.UpdateClient();#endif // BATTLEYE	NET_Packet				P;	u32						start	= 0;	//----------- for E3 -----------------------------//	if () 	{//		if (!(Game().local_player) || Game().local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD)) return;		if (CurrentControlEntity()) 		{			CObject* pObj = CurrentControlEntity();			if (!pObj->getDestroy() && pObj->net_Relevant())			{								P.w_begin		(M_CL_UPDATE);								P.w_u16			(u16(pObj->ID())	);				P.w_u32			(0);	//reserved place for client's ping				pObj->net_Export			(P);				if (P.B.count>9)								{					if (OnServer())					{						if (net_IsSyncronised() && IsDemoSave()) 						{							DemoCS.Enter();							Demo_StoreData(P.B.data, P.B.count, DATA_CLIENT_PACKET);							DemoCS.Leave();						}											}					else						Send	(P, net_flags(FALSE));				}							}					}			};	if (OnClient()) 	{		Flush_Send_Buffer();		return;	}	//-------------------------------------------------	while (1)	{		P.w_begin						(M_UPDATE);		start	= Objects.net_Export	(&P, start, max_objects_size);		if (P.B.count>2)		{			Device.Statistic->TEST3.Begin();				Send	(P, net_flags(FALSE));			Device.Statistic->TEST3.End();		}else			break;	}}
开发者ID:svarog2741,项目名称:RayRoH-Project,代码行数:69,


示例25: sizeof

void	CKinematics::Load(const char* N, IReader *data, u32 dwFlags){	//Msg				("skeleton: %s",N);	inherited::Load	(N, data, dwFlags);    pUserData		= NULL;    m_lod			= NULL;    // loading lods	IReader* LD 	= data->open_chunk(OGF_S_LODS);    if (LD)	{        string_path		short_name;        strcpy_s		(short_name,sizeof(short_name),N);        if (strext(short_name)) *strext(short_name)=0;        // From stream		{			string_path		lod_name;			LD->r_string	(lod_name, sizeof(lod_name));//.         strconcat		(sizeof(name_load),name_load, short_name, ":lod:", lod_name.c_str());            m_lod 			= ::Render->model_CreateChild(lod_name, NULL);            VERIFY3(m_lod,"Cant create LOD model for", N);//.			VERIFY2			(m_lod->Type==MT_HIERRARHY || m_lod->Type==MT_PROGRESSIVE || m_lod->Type==MT_NORMAL,lod_name.c_str());/*			strconcat		(name_load, short_name, ":lod:1");            m_lod 			= ::Render->model_CreateChild(name_load,LD);			VERIFY			(m_lod->Type==MT_SKELETON_GEOMDEF_PM || m_lod->Type==MT_SKELETON_GEOMDEF_ST);*/        }        LD->close	();    }#ifndef _EDITOR    	// User data	IReader* UD 	= data->open_chunk(OGF_S_USERDATA);    pUserData		= UD?xr_new<CInifile>(UD,FS.get_path("$game_config$")->m_Path):0;    if (UD)			UD->close();#endif	// Globals	bone_map_N		= xr_new<accel>		();	bone_map_P		= xr_new<accel>		();	bones			= xr_new<vecBones>	();	bone_instances	= NULL;	// Load bones#pragma todo("container is created in stack!")	xr_vector<shared_str>	L_parents;	R_ASSERT		(data->find_chunk(OGF_S_BONE_NAMES));    visimask.zero	();	int dwCount 	= data->r_u32();	// Msg				("!!! %d bones",dwCount);	// if (dwCount >= 64)	Msg			("!!! More than 64 bones is a crazy thing! (%d), %s",dwCount,N);	VERIFY3			(dwCount < 64, "More than 64 bones is a crazy thing!",N);	for (; dwCount; dwCount--)		{		string256	buf;		// Bone		u16			ID				= u16(bones->size());		data->r_stringZ				(buf,sizeof(buf));	strlwr(buf);		CBoneData* pBone 			= CreateBoneData(ID);		pBone->name					= shared_str(buf);		pBone->child_faces.resize	(children.size());		bones->push_back			(pBone);		bone_map_N->push_back		(mk_pair(pBone->name,ID));		bone_map_P->push_back		(mk_pair(pBone->name,ID));		// It's parent		data->r_stringZ				(buf,sizeof(buf));	strlwr(buf);		L_parents.push_back			(buf);		data->r						(&pBone->obb,sizeof(Fobb));        visimask.set				(u64(1)<<ID,TRUE);	}	std::sort	(bone_map_N->begin(),bone_map_N->end(),pred_sort_N);	std::sort	(bone_map_P->begin(),bone_map_P->end(),pred_sort_P);	// Attach bones to their parents	iRoot = BI_NONE;	for (u32 i=0; i<bones->size(); i++) {		shared_str	P 		= L_parents[i];		CBoneData* B	= (*bones)[i];		if (!P||!P[0]) {			// no parent - this is root bone			R_ASSERT	(BI_NONE==iRoot);			iRoot		= u16(i);			B->SetParentID(BI_NONE);			continue;		} else {			u16 ID		= LL_BoneID(P);			R_ASSERT	(ID!=BI_NONE);			(*bones)[ID]->children.push_back(B);			B->SetParentID(ID);		}	}	R_ASSERT	(BI_NONE != iRoot);//.........这里部分代码省略.........
开发者ID:NeoAnomaly,项目名称:xray,代码行数:101,


示例26: new_from_zip

  // return new out_buf else error text  std::string new_from_zip(const uint8_t* const in_buf,                           const size_t in_size,                           const size_t in_offset,                           uint8_t** out_buf,                           size_t* out_size) {    // pointer to the output buffer that will be created using new    *out_buf = NULL;    *out_size = 0;    // validate the buffer range    if (in_size < in_offset + 30) {      // nothing to do      return "zip region too small";    }    const uint8_t* const b = in_buf + in_offset;    const uint32_t compr_size=u32(b+18);    const uint32_t uncompr_size=u32(b+22);    const uint16_t name_len=u16(b+26);    const uint16_t extra_field_len=u16(b+28);    // validate name length    if (name_len == 0 || name_len > zip_name_len_max) {      return "invalid zip metadata";    }    // calculate offset to compressed data    uint32_t compressed_offset = in_offset + 30 + name_len + extra_field_len;    // offset must be inside the buffer    if (compressed_offset >= in_size) {      return "zip read request outside data range";    }    // size of compressed data    const uint32_t compressed_size = (compr_size == 0 ||               compressed_offset + compr_size > in_size)                           ? in_size - compressed_offset : compr_size;    // size of uncompressed data    const uint32_t potential_uncompressed_size =               (compr_size == 0 || compr_size > uncompressed_size_max)                                  ? uncompressed_size_max : uncompr_size;        // skip if uncompressed size is too small    if (potential_uncompressed_size < uncompressed_size_min) {      return "zip uncompress size too small";    }    // create the uncompressed buffer    *out_buf = new (std::nothrow) uint8_t[potential_uncompressed_size]();    if (*out_buf == NULL) {      // comment that the buffer acquisition request failed      hashdb::tprint(std::cout, "# bad memory allocation in zip uncompression");      return "bad memory allocation in zip uncompression";    }    // set up zlib data    z_stream zs;    memset(&zs, 0, sizeof(zs));    zs.next_in = const_cast<Bytef *>(reinterpret_cast<const Bytef *>(                                         in_buf + compressed_offset));    zs.avail_in = compressed_size;    zs.next_out = *out_buf;    zs.avail_out = potential_uncompressed_size;    // initialize zlib for this decompression    int r = inflateInit2(&zs, -15);    if (r == 0) {      // inflate      inflate(&zs, Z_SYNC_FLUSH);      // set out_size      *out_size = zs.total_out;      // close zlib      inflateEnd(&zs);      return "";    } else {      // inflate failed      delete[] *out_buf;      *out_buf = NULL;      return "zip zlib inflate failed";    }  }
开发者ID:NPS-DEEP,项目名称:hashdb,代码行数:91,



注:本文中的u16函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ u2_bc函数代码示例
C++ u函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。