本文整理匯總了C++中Com_Memcpy函數的典型用法代碼示例。如果您正苦於以下問題:C++ Com_Memcpy函數的具體用法?C++ Com_Memcpy怎麽用?C++ Com_Memcpy使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Com_Memcpy函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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 ];
//.........這裏部分代碼省略.........
示例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) );
}
示例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();
}
}
示例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) );
示例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++;
}
示例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)++;
}
}
示例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
示例8: RE_RenderScene
/*
@@@@@@@@@@@@@@@@@@@@@
RE_RenderScene
Draw a 3D view into a part of the window, then return
to 2D drawing.
Rendering a scene may require multiple views to be rendered
to 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];
//.........這裏部分代碼省略.........
示例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;
}
示例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 ) ||
//.........這裏部分代碼省略.........
示例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;
}
}
示例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;
}
示例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++)
{
//.........這裏部分代碼省略.........
示例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;
}
}
示例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)
//.........這裏部分代碼省略.........