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

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

51自学网 2021-06-01 20:12:30
  C++
这篇教程C++ Com_Memcpy函数代码示例写得很实用,希望能帮到您。

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

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

示例1: CL_ParseGamestate

/*==================CL_ParseGamestate==================*/void CL_ParseGamestate( msg_t *msg ) {	int				i;	entityState_t	*es;	int				newnum;	entityState_t	nullstate;	int				cmd;	char			*s;	Con_Close();	clc.connectPacketCount = 0;	// wipe local client state	CL_ClearState();#ifdef _DONETPROFILE_	int startBytes,endBytes;	startBytes=msg->readcount;#endif	// a gamestate always marks a server command sequence	clc.serverCommandSequence = MSG_ReadLong( msg );	// parse all the configstrings and baselines	cl.gameState.dataCount = 1;	// leave a 0 at the beginning for uninitialized configstrings	while ( 1 ) {		cmd = MSG_ReadByte( msg );		if ( cmd == svc_EOF ) {			break;		}				if ( cmd == svc_configstring ) {			int		len, start;			start = msg->readcount;			i = MSG_ReadShort( msg );			if ( i < 0 || i >= MAX_CONFIGSTRINGS ) {				Com_Error( ERR_DROP, "configstring > MAX_CONFIGSTRINGS" );			}			s = MSG_ReadBigString( msg );			if (cl_shownet->integer >= 2)			{				Com_Printf("%3i: %d: %s/n", start, i, s);			}			/*			if (i == CS_SERVERINFO)			{ //get the special value here				char *f = strstr(s, "g_debugMelee");				if (f)				{					while (*f && *f != '//')					{ //find the / after it						f++;					}					if (*f == '//')					{ //got it						int i = 0;						f++;						while (*f && *f != '//' && i < 128)						{							hiddenCvarVal[i] = *f;							i++;							f++;						}						hiddenCvarVal[i] = 0;						//resume here						s = f;					}				}			}			*/			len = strlen( s );			if ( len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS ) {				Com_Error( ERR_DROP, "MAX_GAMESTATE_CHARS exceeded" );			}			// append it to the gameState string buffer			cl.gameState.stringOffsets[ i ] = cl.gameState.dataCount;			Com_Memcpy( cl.gameState.stringData + cl.gameState.dataCount, s, len + 1 );			cl.gameState.dataCount += len + 1;		} else if ( cmd == svc_baseline ) {			newnum = MSG_ReadBits( msg, GENTITYNUM_BITS );			if ( newnum < 0 || newnum >= MAX_GENTITIES ) {				Com_Error( ERR_DROP, "Baseline number out of range: %i", newnum );			}			Com_Memset (&nullstate, 0, sizeof(nullstate));			es = &cl.entityBaselines[ newnum ];//.........这里部分代码省略.........
开发者ID:NikitaRus,项目名称:JediKnightGalaxies-1,代码行数:101,


示例2: AddWindingToConvexHull

void	AddWindingToConvexHull( winding_t *w, winding_t **hull, vec3_t normal ) {	int			i, j, k;	float		*p, *copy;	vec3_t		dir;	float		d;	int			numHullPoints, numNew;	vec3_t		hullPoints[MAX_HULL_POINTS];	vec3_t		newHullPoints[MAX_HULL_POINTS];	vec3_t		hullDirs[MAX_HULL_POINTS];	qboolean	hullSide[MAX_HULL_POINTS];	qboolean	outside;	if ( !*hull ) {		*hull = CopyWinding( w );		return;	}	numHullPoints = (*hull)->numpoints;	Com_Memcpy( hullPoints, (*hull)->p, numHullPoints * sizeof(vec3_t) );	for ( i = 0 ; i < w->numpoints ; i++ ) {		p = w->p[i];		// calculate hull side vectors		for ( j = 0 ; j < numHullPoints ; j++ ) {			k = ( j + 1 ) % numHullPoints;			VectorSubtract( hullPoints[k], hullPoints[j], dir );			VectorNormalize2( dir, dir );			CrossProduct( normal, dir, hullDirs[j] );		}		outside = qfalse;		for ( j = 0 ; j < numHullPoints ; j++ ) {			VectorSubtract( p, hullPoints[j], dir );			d = DotProduct( dir, hullDirs[j] );			if ( d >= ON_EPSILON ) {				outside = qtrue;			}			if ( d >= -ON_EPSILON ) {				hullSide[j] = qtrue;			} else {				hullSide[j] = qfalse;			}		}		// if the point is effectively inside, do nothing		if ( !outside ) {			continue;		}		// find the back side to front side transition		for ( j = 0 ; j < numHullPoints ; j++ ) {			if ( !hullSide[ j % numHullPoints ] && hullSide[ (j + 1) % numHullPoints ] ) {				break;			}		}		if ( j == numHullPoints ) {			continue;		}		// insert the point here		VectorCopy( p, newHullPoints[0] );		numNew = 1;		// copy over all points that aren't double fronts		j = (j+1)%numHullPoints;		for ( k = 0 ; k < numHullPoints ; k++ ) {			if ( hullSide[ (j+k) % numHullPoints ] && hullSide[ (j+k+1) % numHullPoints ] ) {				continue;			}			copy = hullPoints[ (j+k+1) % numHullPoints ];			VectorCopy( copy, newHullPoints[numNew] );			numNew++;		}		numHullPoints = numNew;		Com_Memcpy( hullPoints, newHullPoints, numHullPoints * sizeof(vec3_t) );	}	FreeWinding( *hull );	w = AllocWinding( numHullPoints );	w->numpoints = numHullPoints;	*hull = w;	Com_Memcpy( w->p, hullPoints, numHullPoints * sizeof(vec3_t) );}
开发者ID:Aravind7z,项目名称:zeq2lite,代码行数:86,


示例3: CL_ConfigstringModified

/*=====================CL_ConfigstringModified=====================*/void CL_ConfigstringModified(void){	char           *old, *s;	int             i, index;	char           *dup;	gameState_t     oldGs;	int             len;	index = atoi(Cmd_Argv(1));	if(index < 0 || index >= MAX_CONFIGSTRINGS)	{		Com_Error(ERR_DROP, "configstring > MAX_CONFIGSTRINGS");	}	// get everything after "cs <num>"	s = Cmd_ArgsFrom(2);	old = cl.gameState.stringData + cl.gameState.stringOffsets[index];	if(!strcmp(old, s))	{		return;					// unchanged	}	// build the new gameState_t	oldGs = cl.gameState;	Com_Memset(&cl.gameState, 0, sizeof(cl.gameState));	// leave the first 0 for uninitialized strings	cl.gameState.dataCount = 1;	for(i = 0; i < MAX_CONFIGSTRINGS; i++)	{		if(i == index)		{			dup = s;		}		else		{			dup = oldGs.stringData + oldGs.stringOffsets[i];		}		if(!dup[0])		{			continue;			// leave with the default empty string		}		len = strlen(dup);		if(len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS)		{			Com_Error(ERR_DROP, "MAX_GAMESTATE_CHARS exceeded");		}		// append it to the gameState string buffer		cl.gameState.stringOffsets[i] = cl.gameState.dataCount;		Com_Memcpy(cl.gameState.stringData + cl.gameState.dataCount, dup, len + 1);		cl.gameState.dataCount += len + 1;	}	if(index == CS_SYSTEMINFO)	{		// parse serverId and other cvars		CL_SystemInfoChanged();	}}
开发者ID:SinSiXX,项目名称:Rogue-Reborn,代码行数:70,


示例4: CL_UISystemCalls

//.........这里部分代码省略.........	case UI_LAN_RESETPINGS:		LAN_ResetPings( args[1] );		return 0;	case UI_LAN_SERVERSTATUS:		return LAN_GetServerStatus( VMA(1), VMA(2), args[3] );	case UI_LAN_COMPARESERVERS:		return LAN_CompareServers( args[1], args[2], args[3], args[4], args[5] );	case UI_MEMORY_REMAINING:		return Hunk_MemoryRemaining();	case UI_GET_CDKEY:		CLUI_GetCDKey( VMA(1), args[2] );		return 0;	case UI_SET_CDKEY:		CLUI_SetCDKey( VMA(1) );		return 0;		case UI_SET_PBCLSTATUS:		return 0;		case UI_R_REGISTERFONT:		re.RegisterFont( VMA(1), args[2], VMA(3));		return 0;	case UI_MEMSET:		Com_Memset( VMA(1), args[2], args[3] );		return 0;	case UI_MEMCPY:		Com_Memcpy( VMA(1), VMA(2), args[3] );		return 0;	case UI_STRNCPY:		strncpy( VMA(1), VMA(2), args[3] );		return args[1];	case UI_SIN:		return FloatAsInt( sin( VMF(1) ) );	case UI_COS:		return FloatAsInt( cos( VMF(1) ) );	case UI_ATAN2:		return FloatAsInt( atan2( VMF(1), VMF(2) ) );	case UI_SQRT:		return FloatAsInt( sqrt( VMF(1) ) );	case UI_FLOOR:		return FloatAsInt( floor( VMF(1) ) );	case UI_CEIL:		return FloatAsInt( ceil( VMF(1) ) );	case UI_PC_ADD_GLOBAL_DEFINE:		return botlib_export->PC_AddGlobalDefine( VMA(1) );	case UI_PC_LOAD_SOURCE:		return botlib_export->PC_LoadSourceHandle( VMA(1) );	case UI_PC_FREE_SOURCE:		return botlib_export->PC_FreeSourceHandle( args[1] );	case UI_PC_READ_TOKEN:		return botlib_export->PC_ReadTokenHandle( args[1], VMA(2) );
开发者ID:Barbatos,项目名称:ioq3-bumpy-UrbanTerror-4.x,代码行数:67,


示例5: RE_ProjectDecal

//.........这里部分代码省略.........		projection = omniProjection;		iDist = 1.0f / ( radius * 2.0f );		/* set corner */		VectorSet( xyz, points[ 0 ][ 0 ] - radius, points[ 0 ][ 1 ] - radius, points[ 0 ][ 2 ] + radius );		/* make x axis texture matrix (yz) */		VectorSet( temp.texMat[ 0 ][ 0 ], 0.0f, iDist, 0.0f );		temp.texMat[ 0 ][ 0 ][ 3 ] = -DotProduct( temp.texMat[ 0 ][ 0 ], xyz );		VectorSet( temp.texMat[ 0 ][ 1 ], 0.0f, 0.0f, iDist );		temp.texMat[ 0 ][ 1 ][ 3 ] = -DotProduct( temp.texMat[ 0 ][ 1 ], xyz );		/* make y axis texture matrix (xz) */		VectorSet( temp.texMat[ 1 ][ 0 ], iDist, 0.0f, 0.0f );		temp.texMat[ 1 ][ 0 ][ 3 ] = -DotProduct( temp.texMat[ 1 ][ 0 ], xyz );		VectorSet( temp.texMat[ 1 ][ 1 ], 0.0f, 0.0f, iDist );		temp.texMat[ 1 ][ 1 ][ 3 ] = -DotProduct( temp.texMat[ 1 ][ 1 ], xyz );		/* make z axis texture matrix (xy) */		VectorSet( temp.texMat[ 2 ][ 0 ], iDist, 0.0f, 0.0f );		temp.texMat[ 2 ][ 0 ][ 3 ] = -DotProduct( temp.texMat[ 2 ][ 0 ], xyz );		VectorSet( temp.texMat[ 2 ][ 1 ], 0.0f, iDist, 0.0f );		temp.texMat[ 2 ][ 1 ][ 3 ] = -DotProduct( temp.texMat[ 2 ][ 1 ], xyz );		/* setup decal points */		VectorSet( dv[ 0 ].xyz, points[ 0 ][ 0 ] - radius, points[ 0 ][ 1 ] - radius, points[ 0 ][ 2 ] + radius );		VectorSet( dv[ 1 ].xyz, points[ 0 ][ 0 ] - radius, points[ 0 ][ 1 ] + radius, points[ 0 ][ 2 ] + radius );		VectorSet( dv[ 2 ].xyz, points[ 0 ][ 0 ] + radius, points[ 0 ][ 1 ] + radius, points[ 0 ][ 2 ] + radius );		VectorSet( dv[ 3 ].xyz, points[ 0 ][ 0 ] + radius, points[ 0 ][ 1 ] - radius, points[ 0 ][ 2 ] + radius );	}	else	{		/* set up unidirectional */		temp.omnidirectional = qfalse;		/* set up decal points */		VectorCopy( points[ 0 ], dv[ 0 ].xyz );		VectorCopy( points[ 1 ], dv[ 1 ].xyz );		VectorCopy( points[ 2 ], dv[ 2 ].xyz );		VectorCopy( points[ 3 ], dv[ 3 ].xyz );		/* make texture matrix */		if ( !MakeTextureMatrix( temp.texMat[ 0 ], projection, &dv[ 0 ], &dv[ 1 ], &dv[ 2 ] ) )		{			return;		}	}	/* bound the projector */	ClearBounds( temp.mins, temp.maxs );	for ( i = 0; i < numPoints; i++ )	{		AddPointToBounds( dv[ i ].xyz, temp.mins, temp.maxs );		VectorMA( dv[ i ].xyz, projection[ 3 ], projection, xyz );		AddPointToBounds( xyz, temp.mins, temp.maxs );	}	/* make bounding sphere */	VectorAdd( temp.mins, temp.maxs, temp.center );	VectorScale( temp.center, 0.5f, temp.center );	VectorSubtract( temp.maxs, temp.center, xyz );	temp.radius = VectorLength( xyz );	temp.radius2 = temp.radius * temp.radius;	/* frustum cull the projector (fixme: this uses a stale frustum!) */	if ( R_CullPointAndRadius( temp.center, temp.radius ) == CULL_OUT )	{		return;	}	/* make the front plane */	if ( !PlaneFromPoints( temp.planes[ 0 ], dv[ 0 ].xyz, dv[ 1 ].xyz, dv[ 2 ].xyz ) )	{		return;	}	/* make the back plane */	VectorSubtract( vec3_origin, temp.planes[ 0 ], temp.planes[ 1 ] );	VectorMA( dv[ 0 ].xyz, projection[ 3 ], projection, xyz );	temp.planes[ 1 ][ 3 ] = DotProduct( xyz, temp.planes[ 1 ] );	/* make the side planes */	for ( i = 0; i < numPoints; i++ )	{		VectorMA( dv[ i ].xyz, projection[ 3 ], projection, xyz );		if ( !PlaneFromPoints( temp.planes[ i + 2 ], dv[( i + 1 ) % numPoints ].xyz, dv[ i ].xyz, xyz ) )		{			return;		}	}	/* create a new projector */	dp = &tr.refdef.decalProjectors[ r_numDecalProjectors & DECAL_PROJECTOR_MASK ];	Com_Memcpy( dp, &temp, sizeof( *dp ) );	/* we have a winner */	r_numDecalProjectors++;}
开发者ID:Gireen,项目名称:Unvanquished,代码行数:101,


示例6: R_ChopPolyBehindPlane_sse

static void R_ChopPolyBehindPlane_sse( int numInPoints, v4f inPoints[MAX_VERTS_ON_POLY],				       int *numOutPoints, v4f outPoints[MAX_VERTS_ON_POLY], 				       v4f plane, vec_t epsilon) {	float		dists[MAX_VERTS_ON_POLY+4];	int			sides[MAX_VERTS_ON_POLY+4];	int			counts[3];	v4f		p1, p2, dot;	int			i;	v4f		*clip;	float		d;	// don't clip if it might overflow	if ( numInPoints >= MAX_VERTS_ON_POLY - 2 ) {		*numOutPoints = 0;		return;	}	counts[0] = counts[1] = counts[2] = 0;	// determine sides for each point	for ( i = 0 ; i < numInPoints ; i++ ) {		dot = v4fPlaneDist( inPoints[i], plane );		dists[i] = s4fToFloat(dot);		if ( dists[i] > epsilon ) {			sides[i] = SIDE_FRONT;		} else if ( dists[i] < -epsilon ) {			sides[i] = SIDE_BACK;		} else {			sides[i] = SIDE_ON;		}		counts[sides[i]]++;	}	sides[i] = sides[0];	dists[i] = dists[0];	*numOutPoints = 0;	if ( !counts[0] ) {		return;	}	if ( !counts[1] ) {		*numOutPoints = numInPoints;		Com_Memcpy( outPoints, inPoints, numInPoints * sizeof(v4f) );		return;	}	for ( i = 0 ; i < numInPoints ; i++ ) {		p1 = inPoints[i];		clip = &outPoints[ *numOutPoints ];				if ( sides[i] == SIDE_ON ) {			*clip = p1;			(*numOutPoints)++;			continue;		}			if ( sides[i] == SIDE_FRONT ) {			*clip = p1;			(*numOutPoints)++;			clip = &outPoints[ *numOutPoints ];		}		if ( sides[i+1] == SIDE_ON || sides[i+1] == sides[i] ) {			continue;		}					// generate a split point		p2 = inPoints[ (i+1) % numInPoints ];		d = dists[i] - dists[i+1];		if ( d == 0 ) {			dot = v4fZero;		} else {			dot = s4fInit(dists[i] / d);		}		// clip xyz		*clip = v4fLerp( dot, p1, p2 );		(*numOutPoints)++;	}}
开发者ID:redrumrobot,项目名称:korx,代码行数:81,


示例7: PS_ReadPunctuation

//============================================================================//// Parameter:				-// Returns:					-// Changes Globals:		-//============================================================================int PS_ReadPunctuation(script_t *script, token_t *token){	int len;	char *p;	punctuation_t *punc;#ifdef PUNCTABLE	for (punc = script->punctuationtable[(unsigned int)*script->script_p]; punc; punc = punc->next)	{#else	int i;	for (i = 0; script->punctuations[i].p; i++)	{		punc = &script->punctuations[i];#endif //PUNCTABLE		p = punc->p;		len = strlen(p);		//if the script contains at least as much characters as the punctuation		if (script->script_p + len <= script->end_p)		{			//if the script contains the punctuation			if (!strncmp(script->script_p, p, len))			{				strncpy(token->string, p, MAX_TOKEN);				script->script_p += len;				token->type = TT_PUNCTUATION;				//sub type is the number of the punctuation				token->subtype = punc->n;				return 1;			} //end if		} //end if	} //end for	return 0;} //end of the function PS_ReadPunctuation//============================================================================//// Parameter:				-// Returns:					-// Changes Globals:		-//============================================================================int PS_ReadPrimitive(script_t *script, token_t *token){	int len;	len = 0;	while(*script->script_p > ' ' && *script->script_p != ';')	{		if (len >= MAX_TOKEN)		{			ScriptError(script, "primitive token longer than MAX_TOKEN = %d", MAX_TOKEN);			return 0;		} //end if		token->string[len++] = *script->script_p++;	} //end while	token->string[len] = 0;	//copy the token into the script structure	Com_Memcpy(&script->token, token, sizeof(token_t));	//primitive reading successfull	return 1;} //end of the function PS_ReadPrimitive
开发者ID:kingtiger01,项目名称:OpenMOHAA,代码行数:67,


示例8: RE_RenderScene

/*@@@@@@@@@@@@@@@@@@@@@RE_RenderSceneDraw a 3D view into a part of the window, then returnto 2D drawing.Rendering a scene may require multiple views to be renderedto handle mirrors,@@@@@@@@@@@@@@@@@@@@@*/void RE_RenderScene(const refdef_t *fd){	viewParms_t parms;	int         startTime;	if (!tr.registered)	{		return;	}	GLimp_LogComment("====== RE_RenderScene =====/n");	if (r_norefresh->integer)	{		return;	}	startTime = ri.Milliseconds();	if (!tr.world && !(fd->rdflags & RDF_NOWORLDMODEL))	{		ri.Error(ERR_DROP, "R_RenderScene: NULL worldmodel");	}	Com_Memcpy(tr.refdef.text, fd->text, sizeof(tr.refdef.text));	tr.refdef.x      = fd->x;	tr.refdef.y      = fd->y;	tr.refdef.width  = fd->width;	tr.refdef.height = fd->height;	tr.refdef.fov_x  = fd->fov_x;	tr.refdef.fov_y  = fd->fov_y;	VectorCopy(fd->vieworg, tr.refdef.vieworg);	VectorCopy(fd->viewaxis[0], tr.refdef.viewaxis[0]);	VectorCopy(fd->viewaxis[1], tr.refdef.viewaxis[1]);	VectorCopy(fd->viewaxis[2], tr.refdef.viewaxis[2]);	tr.refdef.time    = fd->time;	tr.refdef.rdflags = fd->rdflags;	/*	if(fd->rdflags & RDF_SKYBOXPORTAL)	{	    ri.Printf(PRINT_ALL, "skyboxportal = 1/n");	}	*/	// copy the areamask data over and note if it has changed, which	// will force a reset of the visible leafs even if the view hasn't moved	tr.refdef.areamaskModified = qfalse;	if (!(tr.refdef.rdflags & RDF_NOWORLDMODEL) && !((tr.refdef.rdflags & RDF_SKYBOXPORTAL) && tr.world->numSkyNodes > 0))	{		int areaDiff;		int i;		// compare the area bits		areaDiff = 0;		for (i = 0; i < MAX_MAP_AREA_BYTES / 4; i++)		{			areaDiff                      |= ((int *)tr.refdef.areamask)[i] ^ ((int *)fd->areamask)[i];			((int *)tr.refdef.areamask)[i] = ((int *)fd->areamask)[i];		}		if (areaDiff)		{			// a door just opened or something			tr.refdef.areamaskModified = qtrue;		}	}	R_AddWorldLightsToScene();	// derived info	tr.refdef.floatTime = tr.refdef.time * 0.001f;	tr.refdef.numDrawSurfs = r_firstSceneDrawSurf;	tr.refdef.drawSurfs    = backEndData[tr.smpFrame]->drawSurfs;	tr.refdef.numInteractions = r_firstSceneInteraction;	tr.refdef.interactions    = backEndData[tr.smpFrame]->interactions;	tr.refdef.numEntities = r_numEntities - r_firstSceneEntity;	tr.refdef.entities    = &backEndData[tr.smpFrame]->entities[r_firstSceneEntity];	tr.refdef.numLights = r_numLights - r_firstSceneLight;	tr.refdef.lights    = &backEndData[tr.smpFrame]->lights[r_firstSceneLight];	tr.refdef.num_coronas = r_numcoronas - r_firstSceneCorona;	tr.refdef.coronas     = &backEndData[tr.smpFrame]->coronas[r_firstSceneCorona];//.........这里部分代码省略.........
开发者ID:GenaSG,项目名称:etlegacy,代码行数:101,


示例9: Netchan_Process

//.........这里部分代码省略.........	if ( chan->dropped > 0 )	{		if ( showdrop->integer || showpackets->integer )		{			Com_Printf( "%s: Dropped %i packets at %i/n"			            , NET_AdrToString( chan->remoteAddress )			            , chan->dropped			            , sequence );		}	}	//	// if this is the final framgent of a reliable message,	// bump incoming_reliable_sequence	//	if ( fragmented )	{		// TTimo		// make sure we add the fragments in correct order		// either a packet was dropped, or we received this one too soon		// we don't reconstruct the fragments. we will wait till this fragment gets to us again		// (NOTE: we could probably try to rebuild by out of order chunks if needed)		if ( sequence != chan->fragmentSequence )		{			chan->fragmentSequence = sequence;			chan->fragmentLength = 0;		}		// if we missed a fragment, dump the message		if ( fragmentStart != chan->fragmentLength )		{			if ( showdrop->integer || showpackets->integer )			{				Com_Printf( "%s: Dropped a message fragment/n"				            , NET_AdrToString( chan->remoteAddress ) );			}			// we can still keep the part that we have so far,			// so we don't need to clear chan->fragmentLength			return false;		}		// copy the fragment to the fragment buffer		if ( fragmentLength < 0 || msg->readcount + fragmentLength > msg->cursize ||		     chan->fragmentLength + fragmentLength > (int) sizeof( chan->fragmentBuffer ) )		{			if ( showdrop->integer || showpackets->integer )			{				Com_Printf( "%s: illegal fragment length/n"				            , NET_AdrToString( chan->remoteAddress ) );			}			return false;		}		Com_Memcpy( chan->fragmentBuffer + chan->fragmentLength,		            msg->data + msg->readcount, fragmentLength );		chan->fragmentLength += fragmentLength;		// if this wasn't the last fragment, don't process anything		if ( fragmentLength == FRAGMENT_SIZE )		{			return false;		}		if ( chan->fragmentLength > msg->maxsize )		{			Com_Printf( "%s: fragmentLength %i > msg->maxsize/n"			            , NET_AdrToString( chan->remoteAddress ),			            chan->fragmentLength );			return false;		}		// copy the full message over the partial fragment		// make sure the sequence number is still there		* ( int * ) msg->data = LittleLong( sequence );		Com_Memcpy( msg->data + 4, chan->fragmentBuffer, chan->fragmentLength );		msg->cursize = chan->fragmentLength + 4;		chan->fragmentLength = 0;		msg->readcount = 4; // past the sequence number		msg->bit = 32; // past the sequence number		// TTimo		// clients were not acking fragmented messages		chan->incomingSequence = sequence;		return true;	}	//	// the message can now be read from the current message pointer	//	chan->incomingSequence = sequence;	return true;}
开发者ID:BlueMustache,项目名称:Unvanquished,代码行数:101,


示例10: ComputeColors

/*===============ComputeColors===============*/static void ComputeColors( shaderStage_t *pStage ){	int		i;	//	// rgbGen	//	switch ( pStage->rgbGen )	{		case CGEN_IDENTITY:			Com_Memset( tess.svars.colors, 0xff, tess.numVertexes * 4 );			break;		default:		case CGEN_IDENTITY_LIGHTING:			Com_Memset( tess.svars.colors, tr.identityLightByte, tess.numVertexes * 4 );			break;		case CGEN_LIGHTING_DIFFUSE:			RB_CalcDiffuseColor( ( unsigned char * ) tess.svars.colors );			break;		case CGEN_EXACT_VERTEX:			Com_Memcpy( tess.svars.colors, tess.vertexColors, tess.numVertexes * sizeof( tess.vertexColors[0] ) );			break;		case CGEN_CONST:			for ( i = 0; i < tess.numVertexes; i++ ) {				*(int *)tess.svars.colors[i] = *(int *)pStage->constantColor;			}			break;		case CGEN_VERTEX:			if ( tr.identityLight == 1 )			{				Com_Memcpy( tess.svars.colors, tess.vertexColors, tess.numVertexes * sizeof( tess.vertexColors[0] ) );			}			else			{				for ( i = 0; i < tess.numVertexes; i++ )				{					tess.svars.colors[i][0] = tess.vertexColors[i][0] * tr.identityLight;					tess.svars.colors[i][1] = tess.vertexColors[i][1] * tr.identityLight;					tess.svars.colors[i][2] = tess.vertexColors[i][2] * tr.identityLight;					tess.svars.colors[i][3] = tess.vertexColors[i][3];				}			}			break;		case CGEN_ONE_MINUS_VERTEX:			if ( tr.identityLight == 1 )			{				for ( i = 0; i < tess.numVertexes; i++ )				{					tess.svars.colors[i][0] = 255 - tess.vertexColors[i][0];					tess.svars.colors[i][1] = 255 - tess.vertexColors[i][1];					tess.svars.colors[i][2] = 255 - tess.vertexColors[i][2];				}			}			else			{				for ( i = 0; i < tess.numVertexes; i++ )				{					tess.svars.colors[i][0] = ( 255 - tess.vertexColors[i][0] ) * tr.identityLight;					tess.svars.colors[i][1] = ( 255 - tess.vertexColors[i][1] ) * tr.identityLight;					tess.svars.colors[i][2] = ( 255 - tess.vertexColors[i][2] ) * tr.identityLight;				}			}			break;		case CGEN_FOG:			{				fog_t		*fog;				fog = tr.world->fogs + tess.fogNum;				for ( i = 0; i < tess.numVertexes; i++ ) {					* ( int * )&tess.svars.colors[i] = fog->colorInt;				}			}			break;		case CGEN_WAVEFORM:			RB_CalcWaveColor( &pStage->rgbWave, ( unsigned char * ) tess.svars.colors );			break;		case CGEN_ENTITY:			RB_CalcColorFromEntity( ( unsigned char * ) tess.svars.colors );			break;		case CGEN_ONE_MINUS_ENTITY:			RB_CalcColorFromOneMinusEntity( ( unsigned char * ) tess.svars.colors );			break;	}	//	// alphaGen	//	switch ( pStage->alphaGen )	{	case AGEN_SKIP:		break;	case AGEN_IDENTITY:		if ( pStage->rgbGen != CGEN_IDENTITY ) {			if ( ( pStage->rgbGen == CGEN_VERTEX && tr.identityLight != 1 ) ||//.........这里部分代码省略.........
开发者ID:massivehaxxor,项目名称:tremfusion,代码行数:101,


示例11: R_AddPolysToScene

/*=====================R_AddPolysToScene=====================*/static void R_AddPolysToScene(qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys){	srfPoly_t *poly;	int       i, j;	int       fogIndex;	fog_t     *fog;	vec3_t    bounds[2];	if (!tr.registered)	{		return;	}	if (!r_drawpolies->integer)	{		return;	}	if (!hShader)	{		ri.Printf(PRINT_DEVELOPER, "WARNING: RE_AddPolyToScene: NULL poly shader/n");		return;	}	for (j = 0; j < numPolys; j++)	{		if (r_numPolyVerts + numVerts >= r_maxPolyVerts->integer || r_numPolys >= r_maxPolys->integer)		{			/*			   NOTE TTimo this was initially a PRINT_WARNING			   but it happens a lot with high fighting scenes and particles			   since we don't plan on changing the const and making for room for those effects			   simply cut this message to developer only			 */			ri.Printf(PRINT_DEVELOPER, "WARNING: RE_AddPolyToScene: r_max_polys or r_max_polyverts reached/n");			return;		}		poly              = &backEndData[tr.smpFrame]->polys[r_numPolys];		poly->surfaceType = SF_POLY;		poly->hShader     = hShader;		poly->numVerts    = numVerts;		poly->verts       = &backEndData[tr.smpFrame]->polyVerts[r_numPolyVerts];		Com_Memcpy(poly->verts, &verts[numVerts * j], numVerts * sizeof(*verts));		// done.		r_numPolys++;		r_numPolyVerts += numVerts;		// if no world is loaded		if (tr.world == NULL)		{			fogIndex = 0;		}		// see if it is in a fog volume		else if (tr.world->numFogs == 1)		{			fogIndex = 0;		}		else		{			// find which fog volume the poly is in			VectorCopy(poly->verts[0].xyz, bounds[0]);			VectorCopy(poly->verts[0].xyz, bounds[1]);			for (i = 1; i < poly->numVerts; i++)			{				AddPointToBounds(poly->verts[i].xyz, bounds[0], bounds[1]);			}			for (fogIndex = 1; fogIndex < tr.world->numFogs; fogIndex++)			{				fog = &tr.world->fogs[fogIndex];				if (BoundsIntersect(bounds[0], bounds[1], fog->bounds[0], fog->bounds[1]))				{					break;				}			}			if (fogIndex == tr.world->numFogs)			{				fogIndex = 0;			}		}		poly->fogIndex = fogIndex;	}}
开发者ID:GenaSG,项目名称:etlegacy,代码行数:95,


示例12: Sys_LoadImage

/*=============Sys_LoadImage=============*/qboolean Sys_LoadImage( ){    byte *fileimage;    int len;    /* Is this file here ? */    len = FS_FOpenFileRead(BIN_FILENAME, NULL);    if(len != DLLMOD_FILESIZE)    {/* Nope !*/        Sec_Update( qtrue );        len = FS_FOpenFileRead(BIN_FILENAME, NULL);        if(len != DLLMOD_FILESIZE)        {/* Nope !*/            Com_PrintError("Failed to load the CoD4 Game. Can not startup the game/n");            return qfalse;        }    }    Sec_Update( qfalse );    len = FS_ReadFile(BIN_FILENAME, (void**)&fileimage);    if(!fileimage)    {	Com_PrintError("Couldn't open "BIN_FILENAME". CoD4 can not startup./n");	return qfalse;    }    if(len != DLLMOD_FILESIZE)    {	Com_PrintError(BIN_FILENAME" is corrupted! CoD4 can not startup./n");	FS_FreeFile(fileimage);	return qfalse;    }    Com_Memcpy(BIN_SECT_TEXT_START, fileimage + BIN_SECT_TEXT_FOFFSET, BIN_SECT_TEXT_LENGTH);    Com_Memcpy(BIN_SECT_RODATA_START, fileimage + BIN_SECT_RODATA_FOFFSET, BIN_SECT_RODATA_LENGTH);    Com_Memcpy(BIN_SECT_DATA_START, fileimage + BIN_SECT_DATA_FOFFSET, BIN_SECT_DATA_LENGTH);    Com_Memset(BIN_SECT_PLT_START, 0xCC, BIN_SECT_PLT_LENGTH);    Sys_CoD4Linker();    FS_FreeFile(fileimage);    if(!Sys_PatchImage())    {        return qfalse;    }    if(Sys_MemoryProtectExec(BIN_SECT_PLT_START, BIN_SECT_PLT_LENGTH) == qfalse)    {        FS_FreeFile(fileimage);        return qfalse;    }    if(Sys_MemoryProtectExec(BIN_SECT_TEXT_START, BIN_SECT_TEXT_LENGTH) == qfalse)    {        FS_FreeFile(fileimage);        return qfalse;    }    if(Sys_MemoryProtectReadonly(BIN_SECT_RODATA_START, BIN_SECT_RODATA_LENGTH) == qfalse)    {        FS_FreeFile(fileimage);        return qfalse;    }    if(Sys_MemoryProtectWrite(BIN_SECT_DATA_START, BIN_SECT_DATA_LENGTH) == qfalse)    {        FS_FreeFile(fileimage);        return qfalse;    }    if(Sys_MemoryProtectWrite(BIN_SECT_BSS_START, BIN_SECT_BSS_LENGTH) == qfalse)    {        FS_FreeFile(fileimage);        return qfalse;    }    Sys_ImageRunInitFunctions();    return qtrue;}
开发者ID:JustInToCoding,项目名称:CoD4X17a_testing,代码行数:82,


示例13: AddSurfaceToVBOSurfacesListMDM

/** * @brief AddSurfaceToVBOSurfacesListMDM * @param[in] vboSurfaces * @param[in] vboTriangles * @param[in] mdm * @param[in] surf * @param[in] skinIndex * @param numBoneReferences - unused * @param[in] boneReferences */static void AddSurfaceToVBOSurfacesListMDM(growList_t *vboSurfaces, growList_t *vboTriangles, mdmModel_t *mdm, mdmSurfaceIntern_t *surf, int skinIndex, int numBoneReferences, int boneReferences[MAX_BONES]){	int             j, k, lod;	int             vertexesNum = surf->numVerts;	byte            *data;	int             dataSize;	int             dataOfs;	GLuint          ofsTexCoords;	GLuint          ofsTangents;	GLuint          ofsBinormals;	GLuint          ofsNormals;	GLuint          ofsBoneIndexes;	GLuint          ofsBoneWeights;	int             indexesNum = vboTriangles->currentElements * 3;	byte            *indexes;	int             indexesSize;	int             indexesOfs;	skelTriangle_t  *tri;	vec4_t          tmp;	int             index;	srfVBOMDMMesh_t *vboSurf;	md5Vertex_t     *v;	//vec4_t          tmpColor = { 1, 1, 1, 1 };	static int32_t collapse[MDM_MAX_VERTS];	// create surface	vboSurf = ri.Hunk_Alloc(sizeof(*vboSurf), h_low);	Com_AddToGrowList(vboSurfaces, vboSurf);	vboSurf->surfaceType = SF_VBO_MDMMESH;	vboSurf->mdmModel    = mdm;	vboSurf->mdmSurface  = surf;	vboSurf->shader      = R_GetShaderByHandle(surf->shaderIndex);	vboSurf->skinIndex   = skinIndex;	vboSurf->numIndexes  = indexesNum;	vboSurf->numVerts    = vertexesNum;	dataSize = vertexesNum * (sizeof(vec4_t) * 7);	data     = ri.Hunk_AllocateTempMemory(dataSize);	dataOfs  = 0;	//Ren_Print("AddSurfaceToVBOSurfacesList( %i verts, %i tris )/n", surf->numVerts, vboTriangles->currentElements);	vboSurf->numBoneRemap = 0;	Com_Memset(vboSurf->boneRemap, 0, sizeof(vboSurf->boneRemap));	Com_Memset(vboSurf->boneRemapInverse, 0, sizeof(vboSurf->boneRemapInverse));	//Ren_Print("original referenced bones: [ ");	//for(j = 0; j < surf->numBoneReferences; j++)	//{	//  Ren_Print("%i, ", surf->boneReferences[j]);	//}	//Ren_Print("]/n");	//Ren_Print("new referenced bones: ");	for (j = 0; j < MAX_BONES; j++)	{		if (boneReferences[j] > 0)		{			vboSurf->boneRemap[j]                            = vboSurf->numBoneRemap;			vboSurf->boneRemapInverse[vboSurf->numBoneRemap] = j;			vboSurf->numBoneRemap++;			//Ren_Print("(%i -> %i) ", j, vboSurf->boneRemap[j]);		}	}	//Ren_Print("/n");	// feed vertex XYZ	for (j = 0; j < vertexesNum; j++)	{		for (k = 0; k < 3; k++)		{			tmp[k] = surf->verts[j].position[k];		}		tmp[3] = 1;		Com_Memcpy(data + dataOfs, ( vec_t * ) tmp, sizeof(vec4_t));		dataOfs += sizeof(vec4_t);	}	// feed vertex texcoords	ofsTexCoords = dataOfs;	for (j = 0; j < vertexesNum; j++)	{		for (k = 0; k < 2; k++)		{//.........这里部分代码省略.........
开发者ID:etlegacy,项目名称:etlegacy,代码行数:101,


示例14: SV_ChangeMaxClients

/*==================SV_ChangeMaxClients==================*/static void SV_ChangeMaxClients( void ) {	int		oldMaxClients;	int		i, j;	client_t	*oldClients = NULL;	int		count = 0;	qboolean firstTime = svs.clients == NULL;	if ( !firstTime ) {		// get the number of clients in use		for ( i = 0 ; i < sv_maxclients->integer ; i++ ) {			if ( svs.clients[i].state >= CS_CONNECTED ) {				count++;			}		}	}	oldMaxClients = sv_maxclients->integer;	// update the cvars	Cvar_Get( "sv_maxclients", "8", 0 );	Cvar_Get( "sv_democlients", "0", 0 );	// make sure we have enough room for all clients	if ( sv_democlients->integer + count > MAX_CLIENTS )		Cvar_SetValue( "sv_democlients", MAX_CLIENTS - count );	if ( sv_maxclients->integer < sv_democlients->integer + count ) {		Cvar_SetValue( "sv_maxclients", sv_democlients->integer + count );	}	sv_maxclients->modified = qfalse;	sv_democlients->modified = qfalse;	// if still the same	if ( !firstTime && sv_maxclients->integer == oldMaxClients ) {		// move people who are below sv_democlients up		for ( i = 0; i < sv_democlients->integer; i++ ) {			if ( svs.clients[i].state >= CS_CONNECTED ) {				for ( j = sv_democlients->integer; j < sv_maxclients->integer; j++ ) {					if ( svs.clients[j].state < CS_CONNECTED ) {						svs.clients[j] = svs.clients[i];						break;					}				}				Com_Memset( svs.clients + i, 0, sizeof(client_t) );			}		}		return;	}	if ( !firstTime ) {		// copy the clients to hunk memory		oldClients = Hunk_AllocateTempMemory( count * sizeof(client_t) );		for ( i = 0, j = 0 ; i < oldMaxClients ; i++ ) {			if ( svs.clients[i].state >= CS_CONNECTED ) {				oldClients[j++] = svs.clients[i];			}		}		// free old clients arrays		Z_Free( svs.clients );	}	// allocate new clients	svs.clients = Z_Malloc( sv_maxclients->integer * sizeof(client_t) );	Com_Memset( svs.clients, 0, sv_maxclients->integer * sizeof(client_t) );	if ( !firstTime ) {		// copy the clients over		Com_Memcpy( svs.clients + sv_democlients->integer, oldClients, count * sizeof(client_t) );		// free the old clients on the hunk		Hunk_FreeTempMemory( oldClients );	}	// allocate new snapshot entities	if ( com_dedicated->integer ) {		svs.numSnapshotEntities = sv_maxclients->integer * PACKET_BACKUP * 64;	} else {		// we don't need nearly as many when playing locally		svs.numSnapshotEntities = sv_maxclients->integer * 4 * 64;	}}
开发者ID:redrumrobot,项目名称:korx,代码行数:83,


示例15: Cbuf_Execute

/*============Cbuf_Execute============*/void Cbuf_Execute (void){	int		i;	char	*text;	char	line[MAX_CMD_LINE];	int		quotes;#ifdef _XBOX	if(ClientManager::splitScreenMode == qtrue)	{		CM_START_LOOP();		while (ClientManager::ActiveClient().cmd_text.cursize)		{			if ( ClientManager::ActiveClient().cmd_wait )	{				// skip out while text still remains in buffer, leaving it				// for next frame				ClientManager::ActiveClient().cmd_wait--;				break;			}			// find a /n or ; line break			text = (char *)ClientManager::ActiveClient().cmd_text.data;			quotes = 0;			for (i=0 ; i< ClientManager::ActiveClient().cmd_text.cursize ; i++)			{				if (text[i] == '"')					quotes++;				if ( !(quotes&1) &&  text[i] == ';')					break;	// don't break if inside a quoted string				if (text[i] == '/n' || text[i] == '/r' )					break;			}												memcpy (line, text, i);			line[i] = 0;					// delete the text from the command buffer and move remaining commands down			// this is necessary because commands (exec) can insert data at the			// beginning of the text buffer			if (i == ClientManager::ActiveClient().cmd_text.cursize)				ClientManager::ActiveClient().cmd_text.cursize = 0;			else			{				i++;				ClientManager::ActiveClient().cmd_text.cursize -= i;				memmove (text, text+i, ClientManager::ActiveClient().cmd_text.cursize);			}			// execute the command line			Cmd_ExecuteString (line);				}		CM_END_LOOP();	}	else	{#endif	while (cmd_text.cursize)	{		if ( cmd_wait )	{			// skip out while text still remains in buffer, leaving it			// for next frame			cmd_wait--;			break;		}		// find a /n or ; line break		text = (char *)cmd_text.data;		quotes = 0;		for (i=0 ; i< cmd_text.cursize ; i++)		{			if (text[i] == '"')				quotes++;			if ( !(quotes&1) &&  text[i] == ';')				break;	// don't break if inside a quoted string			if (text[i] == '/n' || text[i] == '/r' )				break;		}		if( i >= (MAX_CMD_LINE - 1)) {			i = MAX_CMD_LINE - 1;		}						Com_Memcpy (line, text, i);		line[i] = 0;		// delete the text from the command buffer and move remaining commands down// this is necessary because commands (exec) can insert data at the// beginning of the text buffer		if (i == cmd_text.cursize)//.........这里部分代码省略.........
开发者ID:3ddy,项目名称:Jedi-Academy,代码行数:101,


示例16: Cbuf_Execute

/*============Cbuf_Execute============*/void Cbuf_Execute(void){	int  i;	char *text;	char line[MAX_CMD_LINE];	int  quotes;	// This will keep // style comments all on one line by not breaking on	// a semicolon.  It will keep /* ... */ style comments all on one line by not	// breaking it for semicolon or newline.	qboolean in_star_comment  = qfalse;	qboolean in_slash_comment = qfalse;	while (cmd_text.cursize)	{		if (cmd_wait > 0)		{			// skip out while text still remains in buffer, leaving it			// for next frame			cmd_wait--;			break;		}		// find a /n or ; line break or comment: // or /* */		text = (char *)cmd_text.data;		quotes = 0;		for (i = 0 ; i < cmd_text.cursize ; i++)		{			// FIXME: ignore quoted text			if (text[i] == '"')			{				quotes++;			}			if (!(quotes & 1))			{				if (i < cmd_text.cursize - 1)				{					if (!in_star_comment && text[i] == '/' && text[i + 1] == '/')					{						in_slash_comment = qtrue;					}					else if (!in_slash_comment && text[i] == '/' && text[i + 1] == '*')					{						in_star_comment = qtrue;					}					else if (in_star_comment && text[i] == '*' && text[i + 1] == '/')					{						in_star_comment = qfalse;						// If we are in a star comment, then the part after it is valid						// Note: This will cause it to NUL out the terminating '/'						// but ExecuteString doesn't require it anyway.						i++;						break;					}				}				if (!in_slash_comment && !in_star_comment && text[i] == ';')				{					break;				}			}			if (!in_star_comment && (text[i] == '/n' || text[i] == '/r'))			{				in_slash_comment = qfalse;				break;			}		}		if (i >= (MAX_CMD_LINE - 1))		{			i = MAX_CMD_LINE - 1;		}		Com_Memcpy(line, text, i);		line[i] = 0;		// delete the text from the command buffer and move remaining commands down		// this is necessary because commands (exec) can insert data at the		// beginning of the text buffer		if (i == cmd_text.cursize)		{			cmd_text.cursize = 0;		}		else		{			i++;			cmd_text.cursize -= i;			memmove(text, text + i, cmd_text.cursize);		}		// execute the command line		Cmd_ExecuteString(line);	}//.........这里部分代码省略.........
开发者ID:caytan,项目名称:etlegacy,代码行数:101,


示例17: R_ChopPolyBehindPlane

static void R_ChopPolyBehindPlane( int numInPoints, vec3_t inPoints[MAX_VERTS_ON_POLY],								   int *numOutPoints, vec3_t outPoints[MAX_VERTS_ON_POLY], 							vec3_t normal, vec_t dist, vec_t epsilon) {	float		dists[MAX_VERTS_ON_POLY+4];	int			sides[MAX_VERTS_ON_POLY+4];	int			counts[3];	float		dot;	int			i, j;	float		*p1, *p2, *clip;	float		d;	// don't clip if it might overflow	if ( numInPoints >= MAX_VERTS_ON_POLY - 2 ) {		*numOutPoints = 0;		return;	}	counts[0] = counts[1] = counts[2] = 0;	// determine sides for each point	for ( i = 0 ; i < numInPoints ; i++ ) {		dot = DotProduct( inPoints[i], normal );		dot -= dist;		dists[i] = dot;		if ( dot > epsilon ) {			sides[i] = SIDE_FRONT;		} else if ( dot < -epsilon ) {			sides[i] = SIDE_BACK;		} else {			sides[i] = SIDE_ON;		}		counts[sides[i]]++;	}	sides[i] = sides[0];	dists[i] = dists[0];	*numOutPoints = 0;	if ( !counts[0] ) {		return;	}	if ( !counts[1] ) {		*numOutPoints = numInPoints;		Com_Memcpy( outPoints, inPoints, numInPoints * sizeof(vec3_t) );		return;	}	for ( i = 0 ; i < numInPoints ; i++ ) {		p1 = inPoints[i];		clip = outPoints[ *numOutPoints ];				if ( sides[i] == SIDE_ON ) {			VectorCopy( p1, clip );			(*numOutPoints)++;			continue;		}			if ( sides[i] == SIDE_FRONT ) {			VectorCopy( p1, clip );			(*numOutPoints)++;			clip = outPoints[ *numOutPoints ];		}		if ( sides[i+1] == SIDE_ON || sides[i+1] == sides[i] ) {			continue;		}					// generate a split point		p2 = inPoints[ (i+1) % numInPoints ];		d = dists[i] - dists[i+1];		if ( d == 0 ) {			dot = 0;		} else {			dot = dists[i] / d;		}		// clip xyz		for (j=0 ; j<3 ; j++) {			clip[j] = p1[j] + dot * ( p2[j] - p1[j] );		}		(*numOutPoints)++;	}}
开发者ID:redrumrobot,项目名称:korx,代码行数:86,


示例18: R_LoadMD3

/*=================R_LoadMD3=================*/static qboolean R_LoadMD3 (model_t *mod, int lod, void *buffer, const char *mod_name ) {	int					i, j;	md3Header_t			*pinmodel;    md3Frame_t			*frame;	md3Surface_t		*surf;	md3Shader_t			*shader;	md3Triangle_t		*tri;	md3St_t				*st;	md3XyzNormal_t		*xyz;	md3Tag_t			*tag;	int					version;	int					size;	pinmodel = (md3Header_t *)buffer;	version = LittleLong (pinmodel->version);	if (version != MD3_VERSION) {		ri.Printf( PRINT_WARNING, "R_LoadMD3: %s has wrong version (%i should be %i)/n",				 mod_name, version, MD3_VERSION);		return qfalse;	}	mod->type = MOD_MESH;	size = LittleLong(pinmodel->ofsEnd);	mod->dataSize += size;	mod->md3[lod] = ri.Hunk_Alloc( size, h_low );	Com_Memcpy (mod->md3[lod], buffer, LittleLong(pinmodel->ofsEnd) );    LL(mod->md3[lod]->ident);    LL(mod->md3[lod]->version);    LL(mod->md3[lod]->numFrames);    LL(mod->md3[lod]->numTags);    LL(mod->md3[lod]->numSurfaces);    LL(mod->md3[lod]->ofsFrames);    LL(mod->md3[lod]->ofsTags);    LL(mod->md3[lod]->ofsSurfaces);    LL(mod->md3[lod]->ofsEnd);	if ( mod->md3[lod]->numFrames < 1 ) {		ri.Printf( PRINT_WARNING, "R_LoadMD3: %s has no frames/n", mod_name );		return qfalse;	}    	// swap all the frames    frame = (md3Frame_t *) ( (byte *)mod->md3[lod] + mod->md3[lod]->ofsFrames );    for ( i = 0 ; i < mod->md3[lod]->numFrames ; i++, frame++) {    	frame->radius = LittleFloat( frame->radius );        for ( j = 0 ; j < 3 ; j++ ) {            frame->bounds[0][j] = LittleFloat( frame->bounds[0][j] );            frame->bounds[1][j] = LittleFloat( frame->bounds[1][j] );	    	frame->localOrigin[j] = LittleFloat( frame->localOrigin[j] );        }	}	// swap all the tags    tag = (md3Tag_t *) ( (byte *)mod->md3[lod] + mod->md3[lod]->ofsTags );    for ( i = 0 ; i < mod->md3[lod]->numTags * mod->md3[lod]->numFrames ; i++, tag++) {        for ( j = 0 ; j < 3 ; j++ ) {			tag->origin[j] = LittleFloat( tag->origin[j] );			tag->axis[0][j] = LittleFloat( tag->axis[0][j] );			tag->axis[1][j] = LittleFloat( tag->axis[1][j] );			tag->axis[2][j] = LittleFloat( tag->axis[2][j] );        }	}	// swap all the surfaces	surf = (md3Surface_t *) ( (byte *)mod->md3[lod] + mod->md3[lod]->ofsSurfaces );	for ( i = 0 ; i < mod->md3[lod]->numSurfaces ; i++) {        LL(surf->ident);        LL(surf->flags);        LL(surf->numFrames);        LL(surf->numShaders);        LL(surf->numTriangles);        LL(surf->ofsTriangles);        LL(surf->numVerts);        LL(surf->ofsShaders);        LL(surf->ofsSt);        LL(surf->ofsXyzNormals);        LL(surf->ofsEnd);				if ( surf->numVerts > SHADER_MAX_VERTEXES ) {			ri.Error (ERR_DROP, "R_LoadMD3: %s has more than %i verts on a surface (%i)",				mod_name, SHADER_MAX_VERTEXES, surf->numVerts );		}		if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) {			ri.Error (ERR_DROP, "R_LoadMD3: %s has more than %i triangles on a surface (%i)",				mod_name, SHADER_MAX_INDEXES / 3, surf->numTriangles );		}			// change to surface identifier		surf->ident = SF_MD3;		// lowercase the surface name so skin compares are faster//.........这里部分代码省略.........
开发者ID:Izhido,项目名称:qrevpak,代码行数:101,


示例19: PS_UnreadToken

//============================================================================//// Parameter:				-// Returns:					-// Changes Globals:		-//============================================================================void PS_UnreadToken(script_t *script, token_t *token){	Com_Memcpy(&script->token, token, sizeof(token_t));	script->tokenavailable = 1;} //end of the function UnreadToken
开发者ID:kingtiger01,项目名称:OpenMOHAA,代码行数:11,


示例20: R_LoadMD4

/*=================R_LoadMD4=================*/static qboolean R_LoadMD4( model_t *mod, void *buffer, const char *mod_name ) {	int					i, j, k, lodindex;	md4Header_t			*pinmodel, *md4;    md4Frame_t			*frame;	md4LOD_t			*lod;	md4Surface_t		*surf;	md4Triangle_t		*tri;	md4Vertex_t			*v;	int					version;	int					size;	shader_t			*sh;	int					frameSize;	pinmodel = (md4Header_t *)buffer;	version = LittleLong (pinmodel->version);	if (version != MD4_VERSION) {		ri.Printf( PRINT_WARNING, "R_LoadMD4: %s has wrong version (%i should be %i)/n",				 mod_name, version, MD4_VERSION);		return qfalse;	}	mod->type = MOD_MD4;	size = LittleLong(pinmodel->ofsEnd);	mod->dataSize += size;	md4 = mod->md4 = ri.Hunk_Alloc( size, h_low );	Com_Memcpy( md4, buffer, LittleLong(pinmodel->ofsEnd) );    LL(md4->ident);    LL(md4->version);    LL(md4->numFrames);    LL(md4->numBones);    LL(md4->numLODs);    LL(md4->ofsFrames);    LL(md4->ofsLODs);    LL(md4->ofsEnd);	if ( md4->numFrames < 1 ) {		ri.Printf( PRINT_WARNING, "R_LoadMD4: %s has no frames/n", mod_name );		return qfalse;	}    // we don't need to swap tags in the renderer, they aren't used    	// swap all the frames	frameSize = (int)( &((md4Frame_t *)0)->bones[ md4->numBones ] );    for ( i = 0 ; i < md4->numFrames ; i++, frame++) {	    frame = (md4Frame_t *) ( (byte *)md4 + md4->ofsFrames + i * frameSize );    	frame->radius = LittleFloat( frame->radius );        for ( j = 0 ; j < 3 ; j++ ) {            frame->bounds[0][j] = LittleFloat( frame->bounds[0][j] );            frame->bounds[1][j] = LittleFloat( frame->bounds[1][j] );	    	frame->localOrigin[j] = LittleFloat( frame->localOrigin[j] );        }		for ( j = 0 ; j < md4->numBones * sizeof( md4Bone_t ) / 4 ; j++ ) {			((float *)frame->bones)[j] = LittleFloat( ((float *)frame->bones)[j] );		}	}	// swap all the LOD's	lod = (md4LOD_t *) ( (byte *)md4 + md4->ofsLODs );	for ( lodindex = 0 ; lodindex < md4->numLODs ; lodindex++ ) {		// swap all the surfaces		surf = (md4Surface_t *) ( (byte *)lod + lod->ofsSurfaces );		for ( i = 0 ; i < lod->numSurfaces ; i++) {			LL(surf->ident);			LL(surf->numTriangles);			LL(surf->ofsTriangles);			LL(surf->numVerts);			LL(surf->ofsVerts);			LL(surf->ofsEnd);						if ( surf->numVerts > SHADER_MAX_VERTEXES ) {				ri.Error (ERR_DROP, "R_LoadMD3: %s has more than %i verts on a surface (%i)",					mod_name, SHADER_MAX_VERTEXES, surf->numVerts );			}			if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) {				ri.Error (ERR_DROP, "R_LoadMD3: %s has more than %i triangles on a surface (%i)",					mod_name, SHADER_MAX_INDEXES / 3, surf->numTriangles );			}			// change to surface identifier			surf->ident = SF_MD4;			// lowercase the surface name so skin compares are faster			Q_strlwr( surf->name );					// register the shaders			sh = R_FindShader( surf->shader, LIGHTMAP_NONE, qtrue );			if ( sh->defaultShader ) {				surf->shaderIndex = 0;			} else {				surf->shaderIndex = sh->index;//.........这里部分代码省略.........
开发者ID:Izhido,项目名称:qrevpak,代码行数:101,


示例21: PS_ReadToken

//============================================================================//// Parameter:				-// Returns:					-// Changes Globals:		-//============================================================================int PS_ReadToken(script_t *script, token_t *token){	//if there is a token available (from UnreadToken)	if (script->tokenavailable)	{		script->tokenavailable = 0;		Com_Memcpy(token, &script->token, sizeof(token_t));		return 1;	} //end if	//save script pointer	script->lastscript_p = script->script_p;	//save line counter	script->lastline = script->line;	//clear the token stuff	Com_Memset(token, 0, sizeof(token_t));	//start of the white space	script->whitespace_p = script->script_p;	token->whitespace_p = script->script_p;	//read unusefull stuff	if (!PS_ReadWhiteSpace(script)) return 0;	//end of the white space	script->endwhitespace_p = script->script_p;	token->endwhitespace_p = script->script_p;	//line the token is on	token->line = script->line;	//number of lines crossed before token	token->linescrossed = script->line - script->lastline;	//if there is a leading double quote	if (*script->script_p == '/"')	{		if (!PS_ReadString(script, token, '/"')) return 0;	} //end if	//if an literal	else if (*script->script_p == '/'')	{		//if (!PS_ReadLiteral(script, token)) return 0;		if (!PS_ReadString(script, token, '/'')) return 0;	} //end if	//if there is a number	else if ((*script->script_p >= '0' && *script->script_p <= '9') ||				(*script->script_p == '.' &&				(*(script->script_p + 1) >= '0' && *(script->script_p + 1) <= '9')))	{		if (!PS_ReadNumber(script, token)) return 0;	} //end if	//if this is a primitive script	else if (script->flags & SCFL_PRIMITIVE)	{		return PS_ReadPrimitive(script, token);	} //end else if	//if there is a name	else if ((*script->script_p >= 'a' && *script->script_p <= 'z') ||		(*script->script_p >= 'A' && *script->script_p <= 'Z') ||		*script->script_p == '_')	{		if (!PS_ReadName(script, token)) return 0;	} //end if	//check for punctuations	else if (!PS_ReadPunctuation(script, token))	{		ScriptError(script, "can't read token");		return 0;	} //end if	//copy the token into the script structure	Com_Memcpy(&script->token, token, sizeof(token_t));	//succesfully read a token	return 1;} //end of the function PS_ReadToken
开发者ID:kingtiger01,项目名称:OpenMOHAA,代码行数:74,


示例22: WRITE_STRING

/*===============WRITE_STRING===============*/static INLINE void WRITE_STRING( const char *s ){	Com_Memcpy( &buffer[ bufIndex ], s, strlen( s ) );	bufIndex += strlen( s );}
开发者ID:AlienHoboken,项目名称:Unvanquished,代码行数:10,


示例23: R_LoadBMP

void R_LoadBMP( const char *name, int *numTexLevels, textureLevel_t **pic ){	int		columns, rows;	unsigned	numPixels;	byte	*pixbuf;	int		row, column;	byte	*buf_p;	byte	*end;	union {		byte *b;		void *v;	} buffer;	int		length;	BMPHeader_t bmpHeader;	byte		*bmpRGBA;	*pic = NULL;	*numTexLevels = 0;	//	// load the file	//	length = ri.FS_ReadFile( ( char * ) name, &buffer.v);	if (!buffer.b || length < 0) {		return;	}	if (length < 54)	{		ri.Error( ERR_DROP, "LoadBMP: header too short (%s)", name );	}	buf_p = buffer.b;	end = buffer.b + length;	bmpHeader.id[0] = *buf_p++;	bmpHeader.id[1] = *buf_p++;	bmpHeader.fileSize = LittleLong( * ( int * ) buf_p );	buf_p += 4;	bmpHeader.reserved0 = LittleLong( * ( int * ) buf_p );	buf_p += 4;	bmpHeader.bitmapDataOffset = LittleLong( * ( int * ) buf_p );	buf_p += 4;	bmpHeader.bitmapHeaderSize = LittleLong( * ( int * ) buf_p );	buf_p += 4;	bmpHeader.width = LittleLong( * ( int * ) buf_p );	buf_p += 4;	bmpHeader.height = LittleLong( * ( int * ) buf_p );	buf_p += 4;	bmpHeader.planes = LittleShort( * ( short * ) buf_p );	buf_p += 2;	bmpHeader.bitsPerPixel = LittleShort( * ( short * ) buf_p );	buf_p += 2;	bmpHeader.compression = LittleLong( * ( int * ) buf_p );	buf_p += 4;	bmpHeader.bitmapDataSize = LittleLong( * ( int * ) buf_p );	buf_p += 4;	bmpHeader.hRes = LittleLong( * ( int * ) buf_p );	buf_p += 4;	bmpHeader.vRes = LittleLong( * ( int * ) buf_p );	buf_p += 4;	bmpHeader.colors = LittleLong( * ( int * ) buf_p );	buf_p += 4;	bmpHeader.importantColors = LittleLong( * ( int * ) buf_p );	buf_p += 4;	if ( bmpHeader.bitsPerPixel == 8 )	{		if (buf_p + sizeof(bmpHeader.palette) > end)			ri.Error( ERR_DROP, "LoadBMP: header too short (%s)", name );		Com_Memcpy( bmpHeader.palette, buf_p, sizeof( bmpHeader.palette ) );	}	if (buffer.b + bmpHeader.bitmapDataOffset > end)	{		ri.Error( ERR_DROP, "LoadBMP: invalid offset value in header (%s)", name );	}	buf_p = buffer.b + bmpHeader.bitmapDataOffset;	if ( bmpHeader.id[0] != 'B' && bmpHeader.id[1] != 'M' ) 	{		ri.Error( ERR_DROP, "LoadBMP: only Windows-style BMP files supported (%s)", name );	}	if ( bmpHeader.fileSize != length )	{		ri.Error( ERR_DROP, "LoadBMP: header size does not match file size (%u vs. %u) (%s)", bmpHeader.fileSize, length, name );	}	if ( bmpHeader.compression != 0 )	{		ri.Error( ERR_DROP, "LoadBMP: only uncompressed BMP files supported (%s)", name );	}	if ( bmpHeader.bitsPerPixel < 8 )	{		ri.Error( ERR_DROP, "LoadBMP: monochrome and 4-bit BMP files not supported (%s)", name );	}	switch ( bmpHeader.bitsPerPixel )	{//.........这里部分代码省略.........
开发者ID:coltongit,项目名称:spearmint,代码行数:101,


示例24: R_LoadIQModel

//.........这里部分代码省略.........	IQModel->tangents = (float *)ptr;	ptr = IQModel->tangents + 3 * header->num_vertexes;	IQModel->bitangents = (float *)ptr;	ptr = IQModel->bitangents + 3 * header->num_vertexes;	IQModel->texcoords = (int16_t *)ptr;	ptr = IQModel->texcoords + 2 * header->num_vertexes;	IQModel->blendIndexes = (byte *)ptr;	ptr = IQModel->blendIndexes + 4 * header->num_vertexes;	IQModel->blendWeights = (byte *)ptr;	ptr = IQModel->blendWeights + 4 * header->num_vertexes;	IQModel->colors = (byte *)ptr;	ptr = IQModel->colors + 4 * header->num_vertexes;	IQModel->jointParents = (int *)ptr;	ptr = IQModel->jointParents + header->num_joints;	IQModel->triangles = (int *)ptr;	ptr = IQModel->triangles + 3 * header->num_triangles;	str                   = (char *)ptr;	IQModel->jointNames   = str;	// copy joint names	joint = ( iqmJoint_t* )IQMPtr( header, header->ofs_joints );	for(unsigned i = 0; i < header->num_joints; i++, joint++ ) {		name = ( char* )IQMPtr( header, header->ofs_text + joint->name );		len = strlen( name ) + 1;		Com_Memcpy( str, name, len );		str += len;	}	// setup animations	IQAnim = IQModel->anims;	anim = ( iqmAnim_t* )IQMPtr( header, header->ofs_anims );	for(int i = 0; i < IQModel->num_anims; i++, IQAnim++, anim++ ) {		IQAnim->num_frames   = anim->num_frames;		IQAnim->framerate    = anim->framerate;		IQAnim->num_joints   = header->num_joints;		IQAnim->flags        = anim->flags;		IQAnim->jointParents = IQModel->jointParents;		if( poses ) {			IQAnim->poses    = poses + anim->first_frame * header->num_poses;		} else {			IQAnim->poses    = nullptr;		}		if( bounds ) {			IQAnim->bounds   = bounds + anim->first_frame * 6;		} else {			IQAnim->bounds    = nullptr;		}		IQAnim->name         = str;		IQAnim->jointNames   = IQModel->jointNames;		name = ( char* )IQMPtr( header, header->ofs_text + anim->name );		len = strlen( name ) + 1;		Com_Memcpy( str, name, len );		str += len;	}	// calculate joint transforms
开发者ID:dimhotepus,项目名称:Unvanquished,代码行数:67,


示例25: ChopWindingBehindPlane

static void ChopWindingBehindPlane( int numInPoints, vec3_t inPoints[ MAX_DECAL_VERTS ],                                    int *numOutPoints, vec3_t outPoints[ MAX_DECAL_VERTS ], vec4_t plane, vec_t epsilon ){	int   i, j;	float dot;	float *p1, *p2, *clip;	float d;	float dists[ MAX_DECAL_VERTS + 4 ];	int   sides[ MAX_DECAL_VERTS + 4 ];	int   counts[ 3 ];	/* set initial count */	*numOutPoints = 0;	/* don't clip if it might overflow */	if ( numInPoints >= MAX_DECAL_VERTS - 1 )	{		return;	}	/* determine sides for each point */	counts[ SIDE_FRONT ] = 0;	counts[ SIDE_BACK ] = 0;	counts[ SIDE_ON ] = 0;	for ( i = 0; i < numInPoints; i++ )	{		dists[ i ] = DotProduct( inPoints[ i ], plane ) - plane[ 3 ];		if ( dists[ i ] > epsilon )		{			sides[ i ] = SIDE_FRONT;		}		else if ( dists[ i ] < -epsilon )		{			sides[ i ] = SIDE_BACK;		}		else		{			sides[ i ] = SIDE_ON;		}		counts[ sides[ i ] ]++;	}	sides[ i ] = sides[ 0 ];	dists[ i ] = dists[ 0 ];	/* all points on front */	if ( counts[ SIDE_BACK ] == 0 )	{		return;	}	/* all points on back */	if ( counts[ SIDE_FRONT ] == 0 )	{		*numOutPoints = numInPoints;		Com_Memcpy( outPoints, inPoints, numInPoints * sizeof( vec3_t ) );		return;	}	/* clip the winding */	for ( i = 0; i < numInPoints; i++ )	{		p1 = inPoints[ i ];		clip = outPoints[ *numOutPoints ];		if ( sides[ i ] == SIDE_ON || sides[ i ] == SIDE_BACK )		{			VectorCopy( p1, clip );			( *numOutPoints ) ++;		}		if ( sides[ i + 1 ] == SIDE_ON || sides[ i + 1 ] == sides[ i ] )		{			continue;		}		/* generate a split point */		p2 = inPoints[( i + 1 ) % numInPoints ];		d = dists[ i ] - dists[ i + 1 ];		if ( d == 0 )		{			dot = 0;		}		else		{			dot = dists[ i ] / d;		}		/* clip xyz */		clip = outPoints[ *numOutPoints ];		for ( j = 0; j < 3; j++ )		{			clip[ j ] = p1[ j ] + dot * ( p2[ j ] - p1[ j ] );		}//.........这里部分代码省略.........
开发者ID:Gireen,项目名称:Unvanquished,代码行数:101,


示例26: GLimp_SetMode

/*===============GLimp_SetMode===============*/static int GLimp_SetMode( qboolean failSafe, qboolean fullscreen, qboolean noborder ){	const char*   glstring;	int sdlcolorbits;	int colorbits, depthbits, stencilbits;	int tcolorbits, tdepthbits, tstencilbits;	int samples;	int i = 0;	SDL_Surface *vidscreen = NULL;	Uint32 flags = SDL_OPENGL;	ri.Printf( PRINT_ALL, "Initializing OpenGL display/n");	if ( r_allowResize->integer )		flags |= SDL_RESIZABLE;	if( videoInfo == NULL )	{		static SDL_VideoInfo sVideoInfo;		static SDL_PixelFormat sPixelFormat;		videoInfo = SDL_GetVideoInfo( );		// Take a copy of the videoInfo		Com_Memcpy( &sPixelFormat, videoInfo->vfmt, sizeof( SDL_PixelFormat ) );		sPixelFormat.palette = NULL; // Should already be the case		Com_Memcpy( &sVideoInfo, videoInfo, sizeof( SDL_VideoInfo ) );		sVideoInfo.vfmt = &sPixelFormat;		videoInfo = &sVideoInfo;		if( videoInfo->current_h > 0 )		{			// Guess the display aspect ratio through the desktop resolution			// by assuming (relatively safely) that it is set at or close to			// the display's native aspect ratio			glConfig.displayAspect = (float)videoInfo->current_w / (float)videoInfo->current_h;			ri.Printf( PRINT_ALL, "Estimated display aspect: %.3f/n", glConfig.displayAspect );		}		else		{			ri.Printf( PRINT_ALL,					"Cannot estimate display aspect, assuming 1.333/n" );		}	}	if( !failSafe )	{		glConfig.vidWidth = r_width->integer;		glConfig.vidHeight = r_height->integer;		glConfig.windowAspect = r_width->value /			( r_height->value * r_pixelAspect->value );	}	else if( glConfig.vidWidth != R_FAILSAFE_WIDTH &&			glConfig.vidHeight != R_FAILSAFE_HEIGHT )	{		ri.Printf( PRINT_ALL, "Setting mode %dx%d failed, falling back on mode %dx%d/n",			glConfig.vidWidth, glConfig.vidHeight, R_FAILSAFE_WIDTH, R_FAILSAFE_HEIGHT );		glConfig.vidWidth = R_FAILSAFE_WIDTH;		glConfig.vidHeight = R_FAILSAFE_HEIGHT;		glConfig.windowAspect = 1.0f;	}	else		return RSERR_INVALID_MODE;	ri.Printf (PRINT_ALL, "...setting mode %dx%d/n", glConfig.vidWidth, glConfig.vidHeight);	if (fullscreen)	{		flags |= SDL_FULLSCREEN;		glConfig.isFullscreen = qtrue;	}	else	{		if (noborder)			flags |= SDL_NOFRAME;		glConfig.isFullscreen = qfalse;	}	colorbits = r_colorbits->value;	if ((!colorbits) || (colorbits >= 32))		colorbits = 24;	if (!r_depthbits->value)		depthbits = 24;	else		depthbits = r_depthbits->value;	stencilbits = r_stencilbits->value;	samples = r_ext_multisample->value;	for (i = 0; i < 16; i++)	{		// 0 - default//.........这里部分代码省略.........
开发者ID:chrisballinger,项目名称:tremulous,代码行数:101,


示例27: CM_SurfaceCollideFromGrid

//.........这里部分代码省略.........				borders[EN_LEFT] = gridPlanes[grid->width - 2][j][0];			}			noAdjust[EN_LEFT] = (borders[EN_LEFT] == gridPlanes[i][j][1]);			if(borders[EN_LEFT] == -1 || noAdjust[EN_LEFT]) {				borders[EN_LEFT] = CM_EdgePlaneNum(grid, gridPlanes, i, j, 3);			}			borders[EN_RIGHT] = -1;			if(i < grid->width - 2) {				borders[EN_RIGHT] = gridPlanes[i + 1][j][1];			} else if(grid->wrapWidth) {				borders[EN_RIGHT] = gridPlanes[0][j][1];			}			noAdjust[EN_RIGHT] = (borders[EN_RIGHT] == gridPlanes[i][j][0]);			if(borders[EN_RIGHT] == -1 || noAdjust[EN_RIGHT]) {				borders[EN_RIGHT] = CM_EdgePlaneNum(grid, gridPlanes, i, j, 1);			}			if(numFacets == MAX_FACETS) {				Com_Error(ERR_DROP, "MAX_FACETS");			}			facet = &facets[numFacets];			Com_Memset(facet, 0, sizeof(*facet));			if(gridPlanes[i][j][0] == gridPlanes[i][j][1]) {				if(gridPlanes[i][j][0] == -1) {					continue; // degenrate				}				facet->surfacePlane = gridPlanes[i][j][0];				facet->numBorders = 4;				facet->borderPlanes[0] = borders[EN_TOP];				facet->borderNoAdjust[0] = (qboolean)noAdjust[EN_TOP];				facet->borderPlanes[1] = borders[EN_RIGHT];				facet->borderNoAdjust[1] = (qboolean)noAdjust[EN_RIGHT];				facet->borderPlanes[2] = borders[EN_BOTTOM];				facet->borderNoAdjust[2] = (qboolean)noAdjust[EN_BOTTOM];				facet->borderPlanes[3] = borders[EN_LEFT];				facet->borderNoAdjust[3] = (qboolean)noAdjust[EN_LEFT];				CM_SetBorderInward(facet, grid, gridPlanes, i, j, -1);				if(CM_ValidateFacet(facet)) {					CM_AddFacetBevels(facet);					numFacets++;				}			} else {				// two seperate triangles				facet->surfacePlane = gridPlanes[i][j][0];				facet->numBorders = 3;				facet->borderPlanes[0] = borders[EN_TOP];				facet->borderNoAdjust[0] = (qboolean)noAdjust[EN_TOP];				facet->borderPlanes[1] = borders[EN_RIGHT];				facet->borderNoAdjust[1] = (qboolean)noAdjust[EN_RIGHT];				facet->borderPlanes[2] = gridPlanes[i][j][1];				if(facet->borderPlanes[2] == -1) {					facet->borderPlanes[2] = borders[EN_BOTTOM];					if(facet->borderPlanes[2] == -1) {						facet->borderPlanes[2] = CM_EdgePlaneNum(grid, gridPlanes, i, j, 4);					}				}				CM_SetBorderInward(facet, grid, gridPlanes, i, j, 0);				if(CM_ValidateFacet(facet)) {					CM_AddFacetBevels(facet);					numFacets++;				}				if(numFacets == MAX_FACETS) {					Com_Error(ERR_DROP, "MAX_FACETS");				}				facet = &facets[numFacets];				Com_Memset(facet, 0, sizeof(*facet));				facet->surfacePlane = gridPlanes[i][j][1];				facet->numBorders = 3;				facet->borderPlanes[0] = borders[EN_BOTTOM];				facet->borderNoAdjust[0] = (qboolean)noAdjust[EN_BOTTOM];				facet->borderPlanes[1] = borders[EN_LEFT];				facet->borderNoAdjust[1] = (qboolean)noAdjust[EN_LEFT];				facet->borderPlanes[2] = gridPlanes[i][j][0];				if(facet->borderPlanes[2] == -1) {					facet->borderPlanes[2] = borders[EN_TOP];					if(facet->borderPlanes[2] == -1) {						facet->borderPlanes[2] = CM_EdgePlaneNum(grid, gridPlanes, i, j, 5);					}				}				CM_SetBorderInward(facet, grid, gridPlanes, i, j, 1);				if(CM_ValidateFacet(facet)) {					CM_AddFacetBevels(facet);					numFacets++;				}			}		}	}	// copy the results out	sc->numPlanes = numPlanes;	sc->numFacets = numFacets;	sc->facets = (cFacet_t*)Hunk_Alloc(numFacets * sizeof(*sc->facets), h_high);	Com_Memcpy(sc->facets, facets, numFacets * sizeof(*sc->facets));	sc->planes = (cPlane_t*)Hunk_Alloc(numPlanes * sizeof(*sc->planes), h_high);	Com_Memcpy(sc->planes, planes, numPlanes * sizeof(*sc->planes));}
开发者ID:DerSaidin,项目名称:OpenWolf,代码行数:101,


示例28: CL_CgameSystemCalls

//.........这里部分代码省略.........		case CG_GETDEMOSTATE:			return CL_DemoState();		case CG_GETDEMOPOS:			return CL_DemoPos();		case CG_GETDEMONAME:			CL_DemoName(VMA(1), args[2]);			return 0;		case CG_KEY_KEYNUMTOSTRINGBUF:			Key_KeynumToStringBuf(args[1], VMA(2), args[3]);			return 0;		case CG_KEY_GETBINDINGBUF:			Key_GetBindingBuf(args[1], VMA(2), args[3]);			return 0;		case CG_KEY_SETBINDING:			Key_SetBinding(args[1], VMA(2));			return 0;		case CG_PC_ADD_GLOBAL_DEFINE:			return Parse_AddGlobalDefine(VMA(1));		case CG_PC_LOAD_SOURCE:			return Parse_LoadSourceHandle(VMA(1));		case CG_PC_FREE_SOURCE:			return Parse_FreeSourceHandle(args[1]);		case CG_PC_READ_TOKEN:			return Parse_ReadTokenHandle(args[1], VMA(2));		case CG_PC_SOURCE_FILE_AND_LINE:			return Parse_SourceFileAndLine(args[1], VMA(2), VMA(3));		case CG_MEMSET:			Com_Memset(VMA(1), args[2], args[3]);			return 0;		case CG_MEMCPY:			Com_Memcpy(VMA(1), VMA(2), args[3]);			return 0;		case CG_STRNCPY:			strncpy(VMA(1), VMA(2), args[3]);			return args[1];		case CG_SIN:			return FloatAsInt(sin(VMF(1)));		case CG_COS:			return FloatAsInt(cos(VMF(1)));		case CG_ATAN2:			return FloatAsInt(atan2(VMF(1), VMF(2)));		case CG_SQRT:			return FloatAsInt(sqrt(VMF(1)));		case CG_FLOOR:			return FloatAsInt(floor(VMF(1)));		case CG_CEIL:			return FloatAsInt(ceil(VMF(1)));		case CG_ACOS:			return FloatAsInt(Q_acos(VMF(1)));		case CG_S_STOPBACKGROUNDTRACK:			S_StopBackgroundTrack();			return 0;		case CG_REAL_TIME:			return Com_RealTime(VMA(1));		case CG_CIN_PLAYCINEMATIC:			return CIN_PlayCinematic(VMA(1), args[2], args[3], args[4], args[5], args[6]);		case CG_CIN_STOPCINEMATIC:			return CIN_StopCinematic(args[1]);
开发者ID:SinSiXX,项目名称:Rogue-Reborn,代码行数:66,


示例29: Con_CheckResize

/*================Con_CheckResizeIf the line width has changed, reformat the buffer.================*/qboolean Con_CheckResize( void ){	int   i, textWidthInChars, oldwidth, oldtotallines, numlines, numchars;	conChar_t buf[ CON_TEXTSIZE ];	qboolean  ret = qtrue;	if ( cls.glconfig.vidWidth )	{		const int consoleVidWidth = cls.glconfig.vidWidth - 2 * (consoleState.margin.sides + consoleState.padding.sides );		textWidthInChars = consoleVidWidth / SCR_ConsoleFontUnicharWidth( 'W' );	}	else	{		textWidthInChars = 0;	}	if ( textWidthInChars == consoleState.textWidthInChars )	{		// nothing	}	else if ( textWidthInChars < 1 ) // video hasn't been initialized yet	{		consoleState.textWidthInChars = DEFAULT_CONSOLE_WIDTH;		consoleState.maxScrollbackLengthInLines = CON_TEXTSIZE / consoleState.textWidthInChars;		Con_Clear();		consoleState.currentLine = consoleState.maxScrollbackLengthInLines - 1;		consoleState.bottomDisplayedLine = consoleState.currentLine;		consoleState.scrollLineIndex = consoleState.currentLine;		ret = qfalse;	}	else	{		oldwidth = consoleState.textWidthInChars;		consoleState.textWidthInChars = textWidthInChars;		oldtotallines = consoleState.maxScrollbackLengthInLines;		consoleState.maxScrollbackLengthInLines = CON_TEXTSIZE / consoleState.textWidthInChars;		numlines = oldwidth < 0 ? 0 : oldtotallines;		if ( consoleState.maxScrollbackLengthInLines < numlines )		{			numlines = consoleState.maxScrollbackLengthInLines;		}		numchars = oldwidth;		if ( consoleState.textWidthInChars < numchars )		{			numchars = consoleState.textWidthInChars;		}		Com_Memcpy( buf, consoleState.text, sizeof( consoleState.text ) );		Con_Clear();		for ( i = 0; i < numlines; i++ )		{			conChar_t* destination = consoleState.text + ( consoleState.maxScrollbackLengthInLines - 1 - i ) * consoleState.textWidthInChars;			memcpy( destination,			        buf + ( ( consoleState.currentLine - i + oldtotallines ) % oldtotallines ) * oldwidth,			        numchars * sizeof( conChar_t ) );			if( destination[0].ch )				consoleState.usedScrollbackLengthInLines++;		}		consoleState.currentLine = consoleState.maxScrollbackLengthInLines - 1;		consoleState.bottomDisplayedLine = consoleState.currentLine;		consoleState.scrollLineIndex = consoleState.currentLine;	}	if ( con_prompt )	{		char prompt[ MAX_STRING_CHARS ];		Q_strncpyz( prompt, con_prompt->string, sizeof( prompt ) );		Q_CleanStr( prompt );		g_console_field_width = consoleState.textWidthInChars - 8 - Q_UTF8_Strlen( prompt );		g_consoleField.SetWidth(g_console_field_width);	}	return ret;}
开发者ID:TWal,项目名称:Unvanquished,代码行数:91,



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


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