这篇教程C++ Com_Memset函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中Com_Memset函数的典型用法代码示例。如果您正苦于以下问题:C++ Com_Memset函数的具体用法?C++ Com_Memset怎么用?C++ Com_Memset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了Com_Memset函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: sizeof/*=================R_CreateSurfaceGridMesh=================*/static srfGridMesh_t *R_CreateSurfaceGridMesh( int width, int height, srfVert_t ctrl[ MAX_GRID_SIZE ][ MAX_GRID_SIZE ], float errorTable[ 2 ][ MAX_GRID_SIZE ], int numTriangles, srfTriangle_t triangles[ SHADER_MAX_TRIANGLES ] ){ int i, j, size; srfVert_t *vert; vec3_t tmpVec; srfGridMesh_t *grid; // copy the results out to a grid size = sizeof( *grid ); if ( r_stitchCurves->integer ) { grid = (srfGridMesh_t*)/*ri.Hunk_Alloc */ Com_Allocate( size ); Com_Memset( grid, 0, size ); grid->widthLodError = (float*)/*ri.Hunk_Alloc */ Com_Allocate( width * 4 ); Com_Memcpy( grid->widthLodError, errorTable[ 0 ], width * 4 ); grid->heightLodError = (float*)/*ri.Hunk_Alloc */ Com_Allocate( height * 4 ); Com_Memcpy( grid->heightLodError, errorTable[ 1 ], height * 4 ); grid->numTriangles = numTriangles; grid->triangles = (srfTriangle_t*) Com_Allocate( grid->numTriangles * sizeof( srfTriangle_t ) ); Com_Memcpy( grid->triangles, triangles, numTriangles * sizeof( srfTriangle_t ) ); grid->numVerts = ( width * height ); grid->verts = (srfVert_t*) Com_Allocate( grid->numVerts * sizeof( srfVert_t ) ); } else { grid = (srfGridMesh_t*) ri.Hunk_Alloc( size, ha_pref::h_low ); Com_Memset( grid, 0, size ); grid->widthLodError = (float*) ri.Hunk_Alloc( width * 4, ha_pref::h_low ); Com_Memcpy( grid->widthLodError, errorTable[ 0 ], width * 4 ); grid->heightLodError = (float*) ri.Hunk_Alloc( height * 4, ha_pref::h_low ); Com_Memcpy( grid->heightLodError, errorTable[ 1 ], height * 4 ); grid->numTriangles = numTriangles; grid->triangles = (srfTriangle_t*) ri.Hunk_Alloc( grid->numTriangles * sizeof( srfTriangle_t ), ha_pref::h_low ); Com_Memcpy( grid->triangles, triangles, numTriangles * sizeof( srfTriangle_t ) ); grid->numVerts = ( width * height ); grid->verts = (srfVert_t*) ri.Hunk_Alloc( grid->numVerts * sizeof( srfVert_t ), ha_pref::h_low ); } grid->width = width; grid->height = height; grid->surfaceType = surfaceType_t::SF_GRID; ClearBounds( grid->bounds[ 0 ], grid->bounds[ 1 ] ); for ( i = 0; i < width; i++ ) { for ( j = 0; j < height; j++ ) { vert = &grid->verts[ j * width + i ]; *vert = ctrl[ j ][ i ]; AddPointToBounds( vert->xyz, grid->bounds[ 0 ], grid->bounds[ 1 ] ); } } // compute local origin and bounds VectorAdd( grid->bounds[ 0 ], grid->bounds[ 1 ], grid->origin ); VectorScale( grid->origin, 0.5f, grid->origin ); VectorSubtract( grid->bounds[ 0 ], grid->origin, tmpVec ); grid->radius = VectorLength( tmpVec ); VectorCopy( grid->origin, grid->lodOrigin ); grid->lodRadius = grid->radius; // return grid;}
开发者ID:ChunHungLiu,项目名称:Unvanquished,代码行数:81,
示例2: edge/*=================RB_ShadowTessEndtriangleFromEdge[ v1 ][ v2 ] set triangle from edge( v1, v2, tri ) if ( facing[ triangleFromEdge[ v1 ][ v2 ] ] && !facing[ triangleFromEdge[ v2 ][ v1 ] ) { }=================*/void RB_ShadowTessEnd( void ) { int i; int numTris; vec3_t lightDir; GLboolean rgba[4]; // we can only do this if we have enough space in the vertex buffers if ( tess.numVertexes >= SHADER_MAX_VERTEXES / 2 ) { return; } if ( glConfig.stencilBits < 4 ) { return; } VectorCopy( backEnd.currentEntity->lightDir, lightDir ); // project vertexes away from light direction for ( i = 0 ; i < tess.numVertexes ; i++ ) { VectorMA( tess.xyz[i], -512, lightDir, tess.xyz[i+tess.numVertexes] ); } // decide which triangles face the light Com_Memset( numEdgeDefs, 0, 4 * tess.numVertexes ); numTris = tess.numIndexes / 3; for ( i = 0 ; i < numTris ; i++ ) { int i1, i2, i3; vec3_t d1, d2, normal; float *v1, *v2, *v3; float d; i1 = tess.indexes[ i*3 + 0 ]; i2 = tess.indexes[ i*3 + 1 ]; i3 = tess.indexes[ i*3 + 2 ]; v1 = tess.xyz[ i1 ]; v2 = tess.xyz[ i2 ]; v3 = tess.xyz[ i3 ]; VectorSubtract( v2, v1, d1 ); VectorSubtract( v3, v1, d2 ); CrossProduct( d1, d2, normal ); d = DotProduct( normal, lightDir ); if ( d > 0 ) { facing[ i ] = 1; } else { facing[ i ] = 0; } // create the edges R_AddEdgeDef( i1, i2, facing[ i ] ); R_AddEdgeDef( i2, i3, facing[ i ] ); R_AddEdgeDef( i3, i1, facing[ i ] ); } // draw the silhouette edges GL_Bind( tr.whiteImage ); qglEnable( GL_CULL_FACE ); GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); qglColor3f( 0.2f, 0.2f, 0.2f ); // don't write to the color buffer qglGetBooleanv(GL_COLOR_WRITEMASK, rgba); qglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); qglEnable( GL_STENCIL_TEST ); qglStencilFunc( GL_ALWAYS, 1, 255 ); // mirrors have the culling order reversed if ( backEnd.viewParms.isMirror ) { qglCullFace( GL_FRONT ); qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR ); R_RenderShadowEdges(); qglCullFace( GL_BACK ); qglStencilOp( GL_KEEP, GL_KEEP, GL_DECR ); R_RenderShadowEdges(); } else { qglCullFace( GL_BACK ); qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR ); R_RenderShadowEdges();//.........这里部分代码省略.........
开发者ID:OnlyTheGhosts,项目名称:Mirai_Ran,代码行数:101,
示例3: CL_WritePacket/*===================CL_WritePacketCreate and send the command packet to the serverIncluding both the reliable commands and the usercmdsDuring normal gameplay, a client packet will contain something like:4 sequence number2 qport4 serverid4 acknowledged sequence number4 clc.serverCommandSequence<optional reliable commands>1 clc_move or clc_moveNoDelta1 command count<count * usercmds>===================*/void CL_WritePacket( void ) { msg_t buf; byte data[MAX_MSGLEN]; int i, j; usercmd_t *cmd, *oldcmd; usercmd_t nullcmd; int packetNum; int oldPacketNum; int count, key; // don't send anything if playing back a demo if ( clc.demoplaying || clc.state == CA_CINEMATIC ) { return; } Com_Memset( &nullcmd, 0, sizeof(nullcmd) ); oldcmd = &nullcmd; MSG_Init( &buf, data, sizeof(data) ); MSG_Bitstream( &buf ); // write the current serverId so the server // can tell if this is from the current gameState MSG_WriteLong( &buf, cl.serverId ); // write the last message we received, which can // be used for delta compression, and is also used // to tell if we dropped a gamestate MSG_WriteLong( &buf, clc.serverMessageSequence ); // write the last reliable message we received MSG_WriteLong( &buf, clc.serverCommandSequence ); // write any unacknowledged clientCommands for ( i = clc.reliableAcknowledge + 1 ; i <= clc.reliableSequence ; i++ ) { MSG_WriteByte( &buf, clc_clientCommand ); MSG_WriteLong( &buf, i ); MSG_WriteString( &buf, clc.reliableCommands[ i & (MAX_RELIABLE_COMMANDS-1) ] ); } // we want to send all the usercmds that were generated in the last // few packet, so even if a couple packets are dropped in a row, // all the cmds will make it to the server if ( cl_packetdup->integer < 0 ) { Cvar_Set( "cl_packetdup", "0" ); } else if ( cl_packetdup->integer > 5 ) { Cvar_Set( "cl_packetdup", "5" ); } oldPacketNum = (clc.netchan.outgoingSequence - 1 - cl_packetdup->integer) & PACKET_MASK; count = cl.cmdNumber - cl.outPackets[ oldPacketNum ].p_cmdNumber; if ( count > MAX_PACKET_USERCMDS ) { count = MAX_PACKET_USERCMDS; Com_Printf("MAX_PACKET_USERCMDS/n"); }#ifdef USE_VOIP if (clc.voipOutgoingDataSize > 0) { if((clc.voipFlags & VOIP_SPATIAL) || Com_IsVoipTarget(clc.voipTargets, sizeof(clc.voipTargets), -1)) { MSG_WriteByte (&buf, clc_voipOpus); MSG_WriteByte (&buf, clc.voipOutgoingGeneration); MSG_WriteLong (&buf, clc.voipOutgoingSequence); MSG_WriteByte (&buf, clc.voipOutgoingDataFrames); MSG_WriteData (&buf, clc.voipTargets, sizeof(clc.voipTargets)); MSG_WriteByte(&buf, clc.voipFlags); MSG_WriteShort (&buf, clc.voipOutgoingDataSize); MSG_WriteData (&buf, clc.voipOutgoingData, clc.voipOutgoingDataSize); // If we're recording a demo, we have to fake a server packet with // this VoIP data so it gets to disk; the server doesn't send it // back to us, and we might as well eliminate concerns about dropped // and misordered packets here. if(clc.demorecording && !clc.demowaiting) { const int voipSize = clc.voipOutgoingDataSize; msg_t fakemsg; byte fakedata[MAX_MSGLEN]; MSG_Init (&fakemsg, fakedata, sizeof (fakedata));//.........这里部分代码省略.........
开发者ID:jusavard,项目名称:ioq3,代码行数:101,
示例4: DrawSkyBoxstatic void DrawSkyBox( shader_t *shader ){ int i; sky_min = 0; sky_max = 1; Com_Memset( s_skyTexCoords, 0, sizeof( s_skyTexCoords ) ); for (i=0 ; i<6 ; i++) { int sky_mins_subd[2], sky_maxs_subd[2]; int s, t; sky_mins[0][i] = floor( sky_mins[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_mins[1][i] = floor( sky_mins[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_maxs[0][i] = ceil( sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_maxs[1][i] = ceil( sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; if ( ( sky_mins[0][i] >= sky_maxs[0][i] ) || ( sky_mins[1][i] >= sky_maxs[1][i] ) ) { continue; } sky_mins_subd[0] = sky_mins[0][i] * HALF_SKY_SUBDIVISIONS; sky_mins_subd[1] = sky_mins[1][i] * HALF_SKY_SUBDIVISIONS; sky_maxs_subd[0] = sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS; sky_maxs_subd[1] = sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS; if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS; else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS ) sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS; if ( sky_mins_subd[1] < -HALF_SKY_SUBDIVISIONS ) sky_mins_subd[1] = -HALF_SKY_SUBDIVISIONS; else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS ) sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS; if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS; else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS; if ( sky_maxs_subd[1] < -HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[1] = -HALF_SKY_SUBDIVISIONS; else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS; // // iterate through the subdivisions // for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ ) { for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ ) { MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, i, s_skyTexCoords[t][s], s_skyPoints[t][s] ); } } DrawSkySide( shader->sky.outerbox[i], sky_mins_subd, sky_maxs_subd ); }}
开发者ID:5Quintessential,项目名称:jedioutcast,代码行数:69,
示例5: CL_CgameSystemCalls//.........这里部分代码省略......... return 0; case CG_GETGAMESTATE: CL_GetGameState( VMA(1) ); return 0; case CG_GETCURRENTSNAPSHOTNUMBER: CL_GetCurrentSnapshotNumber( VMA(1), VMA(2) ); return 0; case CG_GETSNAPSHOT: return CL_GetSnapshot( args[1], VMA(2) ); case CG_GETSERVERCOMMAND: return CL_GetServerCommand( args[1] ); case CG_GETCURRENTCMDNUMBER: return CL_GetCurrentCmdNumber(); case CG_GETUSERCMD: return CL_GetUserCmd( args[1], VMA(2) ); case CG_SETUSERCMDVALUE: CL_SetUserCmdValue( args[1], VMF(2) ); return 0; case CG_MEMORY_REMAINING: return Hunk_MemoryRemaining(); case CG_KEY_ISDOWN: return Key_IsDown( args[1] ); case CG_KEY_GETCATCHER: return Key_GetCatcher(); case CG_KEY_SETCATCHER: Key_SetCatcher( args[1] ); return 0; case CG_KEY_GETKEY: return Key_GetKey( VMA(1) ); 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_FMOD: return FloatAsInt( fmod( VMF(1),VMF(2) ) ); case CG_POW: return FloatAsInt( pow( VMF(1),VMF(2) ) ); case CG_ATAN: return FloatAsInt( atan( VMF(1) ) ); case CG_TAN: return FloatAsInt( tan( VMF(1)) ); case CG_PC_ADD_GLOBAL_DEFINE: return botlib_export->PC_AddGlobalDefine( VMA(1) ); case CG_PC_LOAD_SOURCE: return botlib_export->PC_LoadSourceHandle( VMA(1) ); case CG_PC_FREE_SOURCE: return botlib_export->PC_FreeSourceHandle( args[1] ); case CG_PC_READ_TOKEN:
开发者ID:ballju,项目名称:SpaceTrader-GPL-1.1.14,代码行数:67,
示例6: CL_ParseGamestatestatic 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(); // 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; i = MSG_ReadShort( msg ); if ( i < 0 || i >= MAX_CONFIGSTRINGS ) { Com_Error( ERR_DROP, "configstring > MAX_CONFIGSTRINGS" ); } s = MSG_ReadBigString( msg ); 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 ]; MSG_ReadDeltaEntity( msg, &nullstate, es, newnum ); } else { Com_Error( ERR_DROP, "CL_ParseGamestate: bad command byte" ); } } clc.clientNum = MSG_ReadLong(msg); // read the checksum feed clc.checksumFeed = MSG_ReadLong( msg );#if defined(USE_CURL) // Parse values for cURL downloads CL_ParseServerInfo();#endif // parse serverId and other cvars CL_SystemInfoChanged(); // reinitialize the filesystem if the game directory has changed FS_ConditionalRestart( clc.checksumFeed ); // This used to call CL_StartHunkUsers, but now we enter the download state before loading the cgame CL_InitDownloads(); // make sure the game starts Cvar_Set( "cl_paused", "0" );}
开发者ID:DaTa-,项目名称:cnq3x,代码行数:80,
示例7: returnconst void *R_MME_CaptureShotCmd( const void *data ) { const captureCommand_t *cmd = (const captureCommand_t *)data; if (!cmd->name[0]) return (const void *)(cmd + 1); shotData.take = qtrue; shotData.fps = cmd->fps; shotData.dofFocus = cmd->focus; shotData.dofRadius = cmd->radius; if (strcmp( cmd->name, shotData.main.name) || mme_screenShotFormat->modified || mme_screenShotAlpha->modified ) { /* Also reset the the other data */ blurData.control.totalIndex = 0; if ( workAlign ) Com_Memset( workAlign, 0, workUsed ); Com_sprintf( shotData.main.name, sizeof( shotData.main.name ), "%s", cmd->name ); Com_sprintf( shotData.depth.name, sizeof( shotData.depth.name ), "%s.depth", cmd->name ); Com_sprintf( shotData.stencil.name, sizeof( shotData.stencil.name ), "%s.stencil", cmd->name ); mme_screenShotFormat->modified = qfalse; mme_screenShotAlpha->modified = qfalse; if (!Q_stricmp(mme_screenShotFormat->string, "jpg")) { shotData.main.format = mmeShotFormatJPG; } else if (!Q_stricmp(mme_screenShotFormat->string, "tga")) { shotData.main.format = mmeShotFormatTGA; } else if (!Q_stricmp(mme_screenShotFormat->string, "png")) { shotData.main.format = mmeShotFormatPNG; } else if (!Q_stricmp(mme_screenShotFormat->string, "avi")) { shotData.main.format = mmeShotFormatAVI; } else if (!Q_stricmp(mme_screenShotFormat->string, "pipe")) { shotData.main.format = mmeShotFormatPIPE; } else { shotData.main.format = mmeShotFormatTGA; } //grayscale works fine only with compressed avi :( if ((shotData.main.format != mmeShotFormatAVI && shotData.main.format != mmeShotFormatPIPE) || !mme_aviFormat->integer) { shotData.depth.format = mmeShotFormatPNG; shotData.stencil.format = mmeShotFormatPNG; } else if (shotData.main.format == mmeShotFormatAVI) { shotData.depth.format = mmeShotFormatAVI; shotData.stencil.format = mmeShotFormatAVI; } else if (shotData.main.format == mmeShotFormatPIPE) { shotData.depth.format = mmeShotFormatPIPE; shotData.stencil.format = mmeShotFormatPIPE; } if ((shotData.main.format == mmeShotFormatAVI && !mme_aviFormat->integer) || shotData.main.format == mmeShotFormatPIPE) { shotData.main.type = mmeShotTypeBGR; } else { shotData.main.type = mmeShotTypeRGB; } if ( mme_screenShotAlpha->integer ) { if ( shotData.main.format == mmeShotFormatPNG ) shotData.main.type = mmeShotTypeRGBA; else if ( shotData.main.format == mmeShotFormatTGA ) shotData.main.type = mmeShotTypeRGBA; } shotData.main.counter = -1; shotData.depth.type = mmeShotTypeGray; shotData.depth.counter = -1; shotData.stencil.type = mmeShotTypeGray; shotData.stencil.counter = -1; } return (const void *)(cmd + 1); }
开发者ID:entdark,项目名称:q3mme,代码行数:67,
示例8: qglGetIntegerv/*==================RB_TakeVideoFrameCmd==================*/const void *RB_TakeVideoFrameCmd( const void *data ){ const videoFrameCommand_t *cmd; byte *cBuf; size_t memcount, linelen; int padwidth, avipadwidth, padlen, avipadlen; GLint packAlign; cmd = (const videoFrameCommand_t *)data; qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign); linelen = cmd->width * 3; // Alignment stuff for glReadPixels padwidth = PAD(linelen, packAlign); padlen = padwidth - linelen; // AVI line padding avipadwidth = PAD(linelen, AVI_LINE_PADDING); avipadlen = avipadwidth - linelen; cBuf = PADP(cmd->captureBuffer, packAlign); qglReadPixels(0, 0, cmd->width, cmd->height, GL_RGB, GL_UNSIGNED_BYTE, cBuf); memcount = padwidth * cmd->height; // gamma correct if(glConfig.deviceSupportsGamma) R_GammaCorrect(cBuf, memcount); if(cmd->motionJpeg) { memcount = RE_SaveJPGToBuffer(cmd->encodeBuffer, linelen * cmd->height, r_aviMotionJpegQuality->integer, cmd->width, cmd->height, cBuf, padlen); ri.CL_WriteAVIVideoFrame(cmd->encodeBuffer, memcount); } else { byte *lineend, *memend; byte *srcptr, *destptr; srcptr = cBuf; destptr = cmd->encodeBuffer; memend = srcptr + memcount; // swap R and B and remove line paddings while(srcptr < memend) { lineend = srcptr + linelen; while(srcptr < lineend) { *destptr++ = srcptr[2]; *destptr++ = srcptr[1]; *destptr++ = srcptr[0]; srcptr += 3; } Com_Memset(destptr, '/0', avipadlen); destptr += avipadlen; srcptr += padlen; } ri.CL_WriteAVIVideoFrame(cmd->encodeBuffer, avipadwidth * cmd->height); } return (const void *)(cmd + 1); }
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:76,
示例9: SV_CheckDRDoS/*=================SV_CheckDRDoSDRDoS stands for "Distributed Reflected Denial of Service".See here: http://www.lemuria.org/security/application-drdos.htmlReturns qfalse if we're good. qtrue return value means we need to block.If the address isn't NA_IP, it's automatically denied.=================*/qboolean SV_CheckDRDoS(netadr_t from){ netadr_t exactFrom; int i; floodBan_t *ban; int oldestBan; int oldestBanTime; int globalCount; int specificCount; receipt_t *receipt; int oldest; int oldestTime; static int lastGlobalLogTime = 0; // Usually the network is smart enough to not allow incoming UDP packets // with a source address being a spoofed LAN address. Even if that's not // the case, sending packets to other hosts in the LAN is not a big deal. // NA_LOOPBACK qualifies as a LAN address. if (Sys_IsLANAddress(from)) { return qfalse; } exactFrom = from; if (from.type == NA_IP) { from.ip[3] = 0; // xx.xx.xx.0 } else { // So we got a connectionless packet but it's not IPv4, so // what is it? I don't care, it doesn't matter, we'll just block it. // This probably won't even happen. return qtrue; } // This quick exit strategy while we're being bombarded by getinfo/getstatus requests // directed at a specific IP address doesn't really impact server performance. // The code below does its duty very quickly if we're handling a flood packet. ban = &svs.infoFloodBans[0]; oldestBan = 0; oldestBanTime = 0x7fffffff; for (i = 0; i < MAX_INFO_FLOOD_BANS; i++, ban++) { if (svs.time - ban->time < 120000 && // Two minute ban. NET_CompareBaseAdr(from, ban->adr)) { ban->count++; if (!ban->flood && ((svs.time - ban->time) >= 3000) && ban->count <= 5) { Com_DPrintf("Unban info flood protect for address %s, they're not flooding/n", NET_AdrToString(exactFrom)); Com_Memset(ban, 0, sizeof(floodBan_t)); oldestBan = i; break; } if (ban->count >= 180) { Com_DPrintf("Renewing info flood ban for address %s, received %i getinfo/getstatus requests in %i milliseconds/n", NET_AdrToString(exactFrom), ban->count, svs.time - ban->time); ban->time = svs.time; ban->count = 0; ban->flood = qtrue; } return qtrue; } if (ban->time < oldestBanTime) { oldestBanTime = ban->time; oldestBan = i; } } // Count receipts in last 2 seconds. globalCount = 0; specificCount = 0; receipt = &svs.infoReceipts[0]; oldest = 0; oldestTime = 0x7fffffff; for (i = 0; i < MAX_INFO_RECEIPTS; i++, receipt++) { if (receipt->time + 2000 > svs.time) { if (receipt->time) { // When the server starts, all receipt times are at zero. Furthermore, // svs.time is close to zero. We check that the receipt time is already // set so that during the first two seconds after server starts, queries // from the master servers don't get ignored. As a consequence a potentially // unlimited number of getinfo+getstatus responses may be sent during the // first frame of a server's life. globalCount++; } if (NET_CompareBaseAdr(from, receipt->adr)) { specificCount++; } } if (receipt->time < oldestTime) { oldestTime = receipt->time; oldest = i; } }//.........这里部分代码省略.........
开发者ID:promolic1,项目名称:iourt-fru,代码行数:101,
示例10: GLimp_SetMode/*===============GLimp_SetMode===============*/static rserr_t GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder){ const char *glstring; int perChannelColorBits; int colorBits, depthBits, stencilBits; //int samples; int i = 0; Uint32 flags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL; SDL_DisplayMode desktopMode; int display = 0; int x = SDL_WINDOWPOS_UNDEFINED, y = SDL_WINDOWPOS_UNDEFINED; Com_Printf( "Initializing OpenGL display/n"); if ( r_allowResize->integer && !fullscreen ) flags |= SDL_WINDOW_RESIZABLE; // If a window exists, note its display index if( screen != NULL ) display = SDL_GetWindowDisplayIndex( screen ); if( SDL_GetDesktopDisplayMode( display, &desktopMode ) == 0 ) { displayAspect = (float)desktopMode.w / (float)desktopMode.h; Com_Printf( "Display aspect: %.3f/n", displayAspect ); } else { Com_Memset( &desktopMode, 0, sizeof( SDL_DisplayMode ) ); Com_Printf( "Cannot determine display aspect, assuming 1.333/n" ); } Com_Printf( "...setting mode %d:", mode ); if (mode == -2) { // use desktop video resolution if( desktopMode.h > 0 ) { glConfig.vidWidth = desktopMode.w; glConfig.vidHeight = desktopMode.h; } else { glConfig.vidWidth = 640; glConfig.vidHeight = 480; Com_Printf( "Cannot determine display resolution, assuming 640x480/n" ); } //glConfig.windowAspect = (float)glConfig.vidWidth / (float)glConfig.vidHeight; } else if ( !R_GetModeInfo( &glConfig.vidWidth, &glConfig.vidHeight, /*&glConfig.windowAspect,*/ mode ) ) { Com_Printf( " invalid mode/n" ); return RSERR_INVALID_MODE; } Com_Printf( " %d %d/n", glConfig.vidWidth, glConfig.vidHeight); // Center window if( r_centerWindow->integer && !fullscreen ) { x = ( desktopMode.w / 2 ) - ( glConfig.vidWidth / 2 ); y = ( desktopMode.h / 2 ) - ( glConfig.vidHeight / 2 ); } // Destroy existing state if it exists if( opengl_context != NULL ) { SDL_GL_DeleteContext( opengl_context ); opengl_context = NULL; } if( screen != NULL ) { SDL_GetWindowPosition( screen, &x, &y ); ri->Printf( PRINT_DEVELOPER, "Existing window at %dx%d before being destroyed/n", x, y ); SDL_DestroyWindow( screen ); screen = NULL; } if( fullscreen ) { flags |= SDL_WINDOW_FULLSCREEN; glConfig.isFullscreen = qtrue; } else { if( noborder ) flags |= SDL_WINDOW_BORDERLESS; glConfig.isFullscreen = qfalse; }//.........这里部分代码省略.........
开发者ID:BSzili,项目名称:OpenJK,代码行数:101,
示例11: R_LoadMD5//.........这里部分代码省略......... for (j = 0, tri = surf->triangles; j < surf->numTriangles; j++, tri++) { skelTriangle_t *sortTri = Com_Allocate(sizeof(*sortTri)); for (k = 0; k < 3; k++) { sortTri->indexes[k] = tri->indexes[k]; sortTri->vertexes[k] = &surf->verts[tri->indexes[k]]; } sortTri->referenced = qfalse; Com_AddToGrowList(&sortedTriangles, sortTri); } //qsort(sortedTriangles.elements, sortedTriangles.currentElements, sizeof(void *), CompareTrianglesByBoneReferences);#if 0 for (j = 0; j < sortedTriangles.currentElements; j++) { int b[MAX_WEIGHTS * 3]; skelTriangle_t *sortTri = Com_GrowListElement(&sortedTriangles, j); for (k = 0; k < 3; k++) { v = sortTri->vertexes[k]; for (l = 0; l < MAX_WEIGHTS; l++) { b[k * 3 + l] = (l < v->numWeights) ? v->weights[l]->boneIndex : 9999; } qsort(b, MAX_WEIGHTS * 3, sizeof(int), CompareBoneIndices); //Ren_Print("bone indices: %i %i %i %i/n", b[k * 3 + 0], b[k * 3 + 1], b[k * 3 + 2], b[k * 3 + 3]); } }#endif numRemaining = sortedTriangles.currentElements; while (numRemaining) { numBoneReferences = 0; Com_Memset(boneReferences, 0, sizeof(boneReferences)); Com_InitGrowList(&vboTriangles, 1000); for (j = 0; j < sortedTriangles.currentElements; j++) { skelTriangle_t *sortTri = Com_GrowListElement(&sortedTriangles, j); if (sortTri->referenced) { continue; } if (AddTriangleToVBOTriangleList(&vboTriangles, sortTri, &numBoneReferences, boneReferences)) { sortTri->referenced = qtrue; } } if (!vboTriangles.currentElements) { Ren_Warning("R_LoadMD5: could not add triangles to a remaining VBO surfaces for model '%s'/n", modName); Com_DestroyGrowList(&vboTriangles); break; } AddSurfaceToVBOSurfacesList(&vboSurfaces, &vboTriangles, md5, surf, i, numBoneReferences, boneReferences); numRemaining -= vboTriangles.currentElements; Com_DestroyGrowList(&vboTriangles); } for (j = 0; j < sortedTriangles.currentElements; j++) { skelTriangle_t *sortTri = Com_GrowListElement(&sortedTriangles, j); Com_Dealloc(sortTri); } Com_DestroyGrowList(&sortedTriangles); } // move VBO surfaces list to hunk md5->numVBOSurfaces = vboSurfaces.currentElements; md5->vboSurfaces = ri.Hunk_Alloc(md5->numVBOSurfaces * sizeof(*md5->vboSurfaces), h_low); for (i = 0; i < md5->numVBOSurfaces; i++) { md5->vboSurfaces[i] = ( srfVBOMD5Mesh_t * ) Com_GrowListElement(&vboSurfaces, i); } Com_DestroyGrowList(&vboSurfaces); return qtrue;}
开发者ID:dustinduse,项目名称:etlegacy,代码行数:101,
示例12: R_Init/*===============R_Init===============*/void R_Init( void ) { int err; int i; byte *ptr; ri.Printf( PRINT_ALL, "----- R_Init -----/n" ); // clear all our internal state Com_Memset( &tr, 0, sizeof( tr ) ); Com_Memset( &backEnd, 0, sizeof( backEnd ) ); Com_Memset( &tess, 0, sizeof( tess ) );// Swap_Init(); if ( (intptr_t)tess.xyz & 15 ) { Com_Printf( "WARNING: tess.xyz not 16 byte aligned/n" ); } Com_Memset( tess.constantColor255, 255, sizeof( tess.constantColor255 ) ); // // init function tables // for ( i = 0; i < FUNCTABLE_SIZE; i++ ) { tr.sinTable[i] = sin( DEG2RAD( i * 360.0f / ( ( float ) ( FUNCTABLE_SIZE - 1 ) ) ) ); tr.squareTable[i] = ( i < FUNCTABLE_SIZE/2 ) ? 1.0f : -1.0f; tr.sawToothTable[i] = (float)i / FUNCTABLE_SIZE; tr.inverseSawToothTable[i] = 1.0f - tr.sawToothTable[i]; if ( i < FUNCTABLE_SIZE / 2 ) { if ( i < FUNCTABLE_SIZE / 4 ) { tr.triangleTable[i] = ( float ) i / ( FUNCTABLE_SIZE / 4 ); } else { tr.triangleTable[i] = 1.0f - tr.triangleTable[i-FUNCTABLE_SIZE / 4]; } } else { tr.triangleTable[i] = -tr.triangleTable[i-FUNCTABLE_SIZE/2]; } } R_InitFogTable(); R_NoiseInit(); R_Register(); max_polys = r_maxpolys->integer; if (max_polys < MAX_POLYS) max_polys = MAX_POLYS; max_polyverts = r_maxpolyverts->integer; if (max_polyverts < MAX_POLYVERTS) max_polyverts = MAX_POLYVERTS; ptr = ri.Hunk_Alloc( sizeof( *backEndData[0] ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low); backEndData[0] = (backEndData_t *) ptr; backEndData[0]->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData[0] )); backEndData[0]->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData[0] ) + sizeof(srfPoly_t) * max_polys); if ( r_smp->integer ) { ptr = ri.Hunk_Alloc( sizeof( *backEndData[1] ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low); backEndData[1] = (backEndData_t *) ptr; backEndData[1]->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData[1] )); backEndData[1]->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData[1] ) + sizeof(srfPoly_t) * max_polys); } else { backEndData[1] = NULL; } R_ToggleSmpFrame(); InitOpenGL(); R_InitImages(); R_InitShaders(); R_InitSkins(); R_ModelInit(); R_InitFreeType(); err = qglGetError(); if ( err != GL_NO_ERROR ) ri.Printf (PRINT_ALL, "glGetError() = 0x%x/n", err); ri.Printf( PRINT_ALL, "----- finished R_Init -----/n" );}
开发者ID:AlienHoboken,项目名称:Tremulous-Z-Server,代码行数:98,
示例13: 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:redsaurus,项目名称:jaMME,代码行数:101,
示例14: Com_sprintf//.........这里部分代码省略......... for ( i = 0 ; i < ( sizeof( vmHeader_t ) - sizeof( int ) ) / 4 ; i++ ) { ((int *)header.h)[i] = LittleLong( ((int *)header.h)[i] ); } // validate if ( header.h->bssLength < 0 || header.h->dataLength < 0 || header.h->litLength < 0 || header.h->codeLength <= 0 ) { VM_Free(vm); FS_FreeFile(header.v); Com_Printf(S_COLOR_YELLOW "Warning: %s has bad header/n", filename); return NULL; } } else { VM_Free( vm ); FS_FreeFile(header.v); Com_Printf(S_COLOR_YELLOW "Warning: %s does not have a recognisable " "magic number in its header/n", filename); return NULL; } // round up to next power of 2 so all data operations can // be mask protected dataLength = header.h->dataLength + header.h->litLength + header.h->bssLength; for ( i = 0 ; dataLength > ( 1 << i ) ; i++ ) { } dataLength = 1 << i; if(alloc) { // allocate zero filled space for initialized and uninitialized data vm->dataBase = Hunk_Alloc(dataLength, h_high); vm->dataMask = dataLength - 1; } else { // clear the data, but make sure we're not clearing more than allocated if(vm->dataMask + 1 != dataLength) { VM_Free(vm); FS_FreeFile(header.v); Com_Printf(S_COLOR_YELLOW "Warning: Data region size of %s not matching after " "VM_Restart()/n", filename); return NULL; } Com_Memset(vm->dataBase, 0, dataLength); } // copy the intialized data Com_Memcpy( vm->dataBase, (byte *)header.h + header.h->dataOffset, header.h->dataLength + header.h->litLength ); // byte swap the longs for ( i = 0 ; i < header.h->dataLength ; i += 4 ) { *(int *)(vm->dataBase + i) = LittleLong( *(int *)(vm->dataBase + i ) ); } if(header.h->vmMagic == VM_MAGIC_VER2) { int previousNumJumpTableTargets = vm->numJumpTableTargets; header.h->jtrgLength &= ~0x03; vm->numJumpTableTargets = header.h->jtrgLength >> 2; Com_Printf("Loading %d jump table targets/n", vm->numJumpTableTargets); if(alloc) { vm->jumpTableTargets = Hunk_Alloc(header.h->jtrgLength, h_high); } else { if(vm->numJumpTableTargets != previousNumJumpTableTargets) { VM_Free(vm); FS_FreeFile(header.v); Com_Printf(S_COLOR_YELLOW "Warning: Jump table size of %s not matching after " "VM_Restart()/n", filename); return NULL; } Com_Memset(vm->jumpTableTargets, 0, header.h->jtrgLength); } Com_Memcpy(vm->jumpTableTargets, (byte *) header.h + header.h->dataOffset + header.h->dataLength + header.h->litLength, header.h->jtrgLength); // byte swap the longs for ( i = 0 ; i < header.h->jtrgLength ; i += 4 ) { *(int *)(vm->jumpTableTargets + i) = LittleLong( *(int *)(vm->jumpTableTargets + i ) ); } }
开发者ID:kboxsoft,项目名称:ioq3-ios,代码行数:101,
示例15: Sys_ClearExecBuffer/*==============Sys_ClearExecBuffer==============*/static void Sys_ClearExecBuffer( void ){ execBufferPointer = execBuffer; Com_Memset( execArgv, 0, sizeof( execArgv ) ); execArgc = 0;}
开发者ID:zturtleman,项目名称:iortcw,代码行数:11,
示例16: AAS_ClientMovementPrediction//===========================================================================// predicts the movement// assumes regular bounding box sizes// NOTE: out of water jumping is not included// NOTE: grappling hook is not included//// Parameter: origin : origin to start with// presencetype : presence type to start with// velocity : velocity to start with// cmdmove : client command movement// cmdframes : number of frame cmdmove is valid// maxframes : maximum number of predicted frames// frametime : duration of one predicted frame// stopevent : events that stop the prediction// stopareanum : stop as soon as entered this area// Returns: aas_clientmove_t// Changes Globals: -//===========================================================================int AAS_ClientMovementPrediction(struct aas_clientmove_s *move, int entnum, vec3_t origin, int presencetype, int onground, vec3_t velocity, vec3_t cmdmove, int cmdframes, int maxframes, float frametime, int stopevent, int stopareanum, vec3_t mins, vec3_t maxs, int visualize){ float phys_friction, phys_stopspeed, phys_gravity, phys_waterfriction; float phys_watergravity; float phys_walkaccelerate, phys_airaccelerate, phys_swimaccelerate; float phys_maxwalkvelocity, phys_maxcrouchvelocity, phys_maxswimvelocity; float phys_maxstep, phys_maxsteepness, phys_jumpvel, friction; float gravity, delta, maxvel, wishspeed, accelerate; //float velchange, newvel; int n, i, j, pc, step, swimming, ax, crouch, event, jump_frame, areanum; int areas[20], numareas; vec3_t points[20]; vec3_t org, end, feet, start, stepend, lastorg, wishdir; vec3_t frame_test_vel, old_frame_test_vel, left_test_vel; vec3_t up = {0, 0, 1}; aas_plane_t *plane, *plane2; aas_trace_t trace, steptrace; if (frametime <= 0) frametime = 0.1f; // phys_friction = aassettings.phys_friction; phys_stopspeed = aassettings.phys_stopspeed; phys_gravity = aassettings.phys_gravity; phys_waterfriction = aassettings.phys_waterfriction; phys_watergravity = aassettings.phys_watergravity; phys_maxwalkvelocity = aassettings.phys_maxwalkvelocity;// * frametime; phys_maxcrouchvelocity = aassettings.phys_maxcrouchvelocity;// * frametime; phys_maxswimvelocity = aassettings.phys_maxswimvelocity;// * frametime; phys_walkaccelerate = aassettings.phys_walkaccelerate; phys_airaccelerate = aassettings.phys_airaccelerate; phys_swimaccelerate = aassettings.phys_swimaccelerate; phys_maxstep = aassettings.phys_maxstep; phys_maxsteepness = aassettings.phys_maxsteepness; phys_jumpvel = aassettings.phys_jumpvel * frametime; // Com_Memset(move, 0, sizeof(aas_clientmove_t)); Com_Memset(&trace, 0, sizeof(aas_trace_t)); //start at the current origin VectorCopy(origin, org); org[2] += 0.25; //velocity to test for the first frame VectorScale(velocity, frametime, frame_test_vel); // jump_frame = -1; //predict a maximum of 'maxframes' ahead for (n = 0; n < maxframes; n++) { swimming = AAS_Swimming(org); //get gravity depending on swimming or not gravity = swimming ? phys_watergravity : phys_gravity; //apply gravity at the START of the frame frame_test_vel[2] = frame_test_vel[2] - (gravity * 0.1 * frametime); //if on the ground or swimming if (onground || swimming) { friction = swimming ? phys_friction : phys_waterfriction; //apply friction VectorScale(frame_test_vel, 1/frametime, frame_test_vel); AAS_ApplyFriction(frame_test_vel, friction, phys_stopspeed, frametime); VectorScale(frame_test_vel, frametime, frame_test_vel); } //end if crouch = qfalse; //apply command movement if (n < cmdframes) { ax = 0; maxvel = phys_maxwalkvelocity; accelerate = phys_airaccelerate; VectorCopy(cmdmove, wishdir); if (onground) { if (cmdmove[2] < -300) { crouch = qtrue; maxvel = phys_maxcrouchvelocity;//.........这里部分代码省略.........
开发者ID:artemalive,项目名称:Quake-III-Arena,代码行数:101,
示例17: RE_RenderScene//.........这里部分代码省略......... 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; // 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) ) { 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; } } // derived info tr.refdef.floatTime = tr.refdef.time * 0.001f; tr.refdef.numDrawSurfs = r_firstSceneDrawSurf; tr.refdef.drawSurfs = backEndData[tr.smpFrame]->drawSurfs; tr.refdef.num_entities = r_numentities - r_firstSceneEntity; tr.refdef.entities = &backEndData[tr.smpFrame]->entities[r_firstSceneEntity]; tr.refdef.num_dlights = r_numdlights - r_firstSceneDlight; tr.refdef.dlights = &backEndData[tr.smpFrame]->dlights[r_firstSceneDlight]; tr.refdef.numPolys = r_numpolys - r_firstScenePoly; tr.refdef.polys = &backEndData[tr.smpFrame]->polys[r_firstScenePoly]; // turn off dynamic lighting globally by clearing all the // dlights if it needs to be disabled or if vertex lighting is enabled if ( r_dynamiclight->integer == 0 || r_vertexLight->integer == 1 || glConfig.hardwareType == GLHW_PERMEDIA2 ) { tr.refdef.num_dlights = 0; } // a single frame may have multiple scenes draw inside it -- // a 3D game view, 3D status bar renderings, 3D menus, etc. // They need to be distinguished by the light flare code, because // the visibility state for a given surface may be different in // each scene / view. tr.frameSceneNum++; tr.sceneCount++; // setup view parms for the initial view // // set up viewport // The refdef takes 0-at-the-top y coordinates, so // convert to GL's 0-at-the-bottom space // Com_Memset( &parms, 0, sizeof( parms ) ); parms.viewportX = tr.refdef.x; parms.viewportY = glConfig.vidHeight - ( tr.refdef.y + tr.refdef.height ); parms.viewportWidth = tr.refdef.width; parms.viewportHeight = tr.refdef.height; parms.isPortal = qfalse; parms.fovX = tr.refdef.fov_x; parms.fovY = tr.refdef.fov_y; parms.stereoFrame = tr.refdef.stereoFrame; VectorCopy( fd->vieworg, parms.or.origin ); VectorCopy( fd->viewaxis[0], parms.or.axis[0] ); VectorCopy( fd->viewaxis[1], parms.or.axis[1] ); VectorCopy( fd->viewaxis[2], parms.or.axis[2] ); VectorCopy( fd->vieworg, parms.pvsOrigin ); R_RenderView( &parms ); // the next scene rendered in this frame will tack on after this one r_firstSceneDrawSurf = tr.refdef.numDrawSurfs; r_firstSceneEntity = r_numentities; r_firstSceneDlight = r_numdlights; r_firstScenePoly = r_numpolys; tr.frontEndMsec += ri.Milliseconds() - startTime;}
开发者ID:Mixone-FinallyHere,项目名称:SmokinGuns,代码行数:101,
示例18: Com_sprintf//============================================================================//// Parameter: -// Returns: -// Changes Globals: -//============================================================================script_t *LoadScriptFile(const char *filename){#ifdef BOTLIB fileHandle_t fp; char pathname[MAX_QPATH];#else FILE *fp;#endif int length; void *buffer; script_t *script;#ifdef BOTLIB if (strlen(basefolder)) Com_sprintf(pathname, sizeof(pathname), "%s/%s", basefolder, filename); else Com_sprintf(pathname, sizeof(pathname), "%s", filename); length = botimport.FS_FOpenFile( pathname, &fp, FS_READ ); if (!fp) return NULL;#else fp = fopen(filename, "rb"); if (!fp) return NULL; length = FileLength(fp);#endif buffer = GetClearedMemory(sizeof(script_t) + length + 1); script = (script_t *) buffer; Com_Memset(script, 0, sizeof(script_t)); strcpy(script->filename, filename); script->buffer = (char *) buffer + sizeof(script_t); script->buffer[length] = 0; script->length = length; //pointer in script buffer script->script_p = script->buffer; //pointer in script buffer before reading token script->lastscript_p = script->buffer; //pointer to end of script buffer script->end_p = &script->buffer[length]; //set if there's a token available in script->token script->tokenavailable = 0; // script->line = 1; script->lastline = 1; // SetScriptPunctuations(script, NULL); //#ifdef BOTLIB botimport.FS_Read(script->buffer, length, fp); botimport.FS_FCloseFile(fp);#else if (fread(script->buffer, length, 1, fp) != 1) { FreeMemory(buffer); script = NULL; } //end if fclose(fp);#endif // script->length = COM_Compress(script->buffer); return script;} //end of the function LoadScriptFile
开发者ID:Avatarchik,项目名称:Quake-III-Arena-D3D11,代码行数:69,
示例19: CL_UISystemCalls//.........这里部分代码省略......... return LAN_ServerIsVisible( args[1], args[2] ); case UI_LAN_UPDATEVISIBLEPINGS: return LAN_UpdateVisiblePings( args[1] ); 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: return re.RegisterFont( VMA(1), args[2], VMA(3) ); 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 PASSFLOAT( sin( VMF(1) ) ); case UI_COS: return PASSFLOAT( cos( VMF(1) ) ); case UI_ATAN2: return PASSFLOAT( atan2( VMF(1), VMF(2) ) ); case UI_SQRT: return PASSFLOAT( sqrt( VMF(1) ) ); case UI_FLOOR: return PASSFLOAT( floor( VMF(1) ) ); case UI_CEIL: return PASSFLOAT( ceil( VMF(1) ) ); case UI_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case UI_S_STARTBACKGROUNDTRACK:
开发者ID:DaTa-,项目名称:cnq3x,代码行数:67,
示例20: 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:Avatarchik,项目名称:Quake-III-Arena-D3D11,代码行数:74,
示例21: DrawSkyBoxstatic void DrawSkyBox( shader_t *shader ){ int i; sky_min = 0; sky_max = 1; Com_Memset( s_skyTexCoords, 0, sizeof( s_skyTexCoords ) ); // set up for drawing tess.multiDrawPrimitives = 0; tess.numIndexes = 0; tess.numVertexes = 0; tess.attribsSet = 0; GL_State( GLS_DEFAULT ); for ( i = 0; i < 6; i++ ) { int sky_mins_subd[ 2 ], sky_maxs_subd[ 2 ]; int s, t; sky_mins[ 0 ][ i ] = floor( sky_mins[ 0 ][ i ] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_mins[ 1 ][ i ] = floor( sky_mins[ 1 ][ i ] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_maxs[ 0 ][ i ] = ceil( sky_maxs[ 0 ][ i ] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_maxs[ 1 ][ i ] = ceil( sky_maxs[ 1 ][ i ] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; if ( ( sky_mins[ 0 ][ i ] >= sky_maxs[ 0 ][ i ] ) || ( sky_mins[ 1 ][ i ] >= sky_maxs[ 1 ][ i ] ) ) { continue; } sky_mins_subd[ 0 ] = sky_mins[ 0 ][ i ] * HALF_SKY_SUBDIVISIONS; sky_mins_subd[ 1 ] = sky_mins[ 1 ][ i ] * HALF_SKY_SUBDIVISIONS; sky_maxs_subd[ 0 ] = sky_maxs[ 0 ][ i ] * HALF_SKY_SUBDIVISIONS; sky_maxs_subd[ 1 ] = sky_maxs[ 1 ][ i ] * HALF_SKY_SUBDIVISIONS; if ( sky_mins_subd[ 0 ] < -HALF_SKY_SUBDIVISIONS ) { sky_mins_subd[ 0 ] = -HALF_SKY_SUBDIVISIONS; } else if ( sky_mins_subd[ 0 ] > HALF_SKY_SUBDIVISIONS ) { sky_mins_subd[ 0 ] = HALF_SKY_SUBDIVISIONS; } if ( sky_mins_subd[ 1 ] < -HALF_SKY_SUBDIVISIONS ) { sky_mins_subd[ 1 ] = -HALF_SKY_SUBDIVISIONS; } else if ( sky_mins_subd[ 1 ] > HALF_SKY_SUBDIVISIONS ) { sky_mins_subd[ 1 ] = HALF_SKY_SUBDIVISIONS; } if ( sky_maxs_subd[ 0 ] < -HALF_SKY_SUBDIVISIONS ) { sky_maxs_subd[ 0 ] = -HALF_SKY_SUBDIVISIONS; } else if ( sky_maxs_subd[ 0 ] > HALF_SKY_SUBDIVISIONS ) { sky_maxs_subd[ 0 ] = HALF_SKY_SUBDIVISIONS; } if ( sky_maxs_subd[ 1 ] < -HALF_SKY_SUBDIVISIONS ) { sky_maxs_subd[ 1 ] = -HALF_SKY_SUBDIVISIONS; } else if ( sky_maxs_subd[ 1 ] > HALF_SKY_SUBDIVISIONS ) { sky_maxs_subd[ 1 ] = HALF_SKY_SUBDIVISIONS; } // iterate through the subdivisions for ( t = sky_mins_subd[ 1 ] + HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[ 1 ] + HALF_SKY_SUBDIVISIONS; t++ ) { for ( s = sky_mins_subd[ 0 ] + HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[ 0 ] + HALF_SKY_SUBDIVISIONS; s++ ) { MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, i, s_skyTexCoords[ t ][ s ], s_skyPoints[ t ][ s ] ); } } //DrawSkySide(shader->sky.outerbox[sky_texorder[i]], sky_mins_subd, sky_maxs_subd); // only add indexes for first stage FillCloudySkySide( sky_mins_subd, sky_maxs_subd, qtrue ); } Tess_UpdateVBOs( tess.attribsSet ); Tess_DrawElements();}
开发者ID:elbeardmorez,项目名称:Unvanquished,代码行数:93,
示例22: SV_UserMove/*==================SV_UserMoveThe message usually contains all the movement commandsthat were in the last three packets, so that the informationin dropped packets can be recovered.On very fast clients, there may be multiple usercmd packed intoeach of the backup packets.==================*/static void SV_UserMove( client_t *cl, msg_t *msg, qboolean delta ) { int i, key; int cmdCount; usercmd_t nullcmd; usercmd_t cmds[MAX_PACKET_USERCMDS]; usercmd_t *cmd, *oldcmd; if ( delta ) { cl->deltaMessage = cl->messageAcknowledge; } else { cl->deltaMessage = -1; } cmdCount = MSG_ReadByte( msg ); if ( cmdCount < 1 ) { Com_Printf( "cmdCount < 1/n" ); return; } if ( cmdCount > MAX_PACKET_USERCMDS ) { Com_Printf( "cmdCount > MAX_PACKET_USERCMDS/n" ); return; } // use the checksum feed in the key key = sv.checksumFeed; // also use the message acknowledge key ^= cl->messageAcknowledge; // also use the last acknowledged server command in the key key ^= Com_HashKey(cl->reliableCommands[ cl->reliableAcknowledge & (MAX_RELIABLE_COMMANDS-1) ], 32); Com_Memset( &nullcmd, 0, sizeof(nullcmd) ); oldcmd = &nullcmd; for ( i = 0 ; i < cmdCount ; i++ ) { cmd = &cmds[i]; MSG_ReadDeltaUsercmdKey( msg, key, oldcmd, cmd ); oldcmd = cmd; } // save time for ping calculation // With sv_pingFix enabled we store the time of the first acknowledge, instead of the last. And we use a time value that is not limited by sv_fps. if ( !sv_pingFix->integer || cl->frames[ cl->messageAcknowledge & PACKET_MASK ].messageAcked == -1 ) cl->frames[ cl->messageAcknowledge & PACKET_MASK ].messageAcked = (sv_pingFix->integer ? Sys_Milliseconds() : svs.time); // if this is the first usercmd we have received // this gamestate, put the client into the world if ( cl->state == CS_PRIMED ) { SV_SendServerCommand(cl, "print /"^1[ ^7This server is running JK2MV ^1v^7" JK2MV_VERSION " ^1| ^7http://jk2mv.org ^1]/n/""); SV_ClientEnterWorld( cl, &cmds[0] ); // the moves can be processed normaly } // if (sv_pure->integer != 0 && cl->pureAuthentic == 0) { SV_DropClient( cl, "Cannot validate pure client!"); return; } if ( cl->state != CS_ACTIVE ) { cl->deltaMessage = -1; return; } // usually, the first couple commands will be duplicates // of ones we have previously received, but the servertimes // in the commands will cause them to be immediately discarded for ( i = 0 ; i < cmdCount ; i++ ) { // if this is a cmd from before a map_restart ignore it if ( cmds[i].serverTime > cmds[cmdCount-1].serverTime ) { continue; } // extremely lagged or cmd from before a map_restart //if ( cmds[i].serverTime > sv.time + 3000 ) { // continue; //} // don't execute if this is an old cmd which is already executed // these old cmds are included when cl_packetdup > 0 if ( cmds[i].serverTime <= cl->lastUsercmd.serverTime ) { continue; } SV_ClientThink (cl - svs.clients, &cmds[ i ]); }}
开发者ID:ouned,项目名称:jk2mv,代码行数:96,
示例23: CL_GetServerCommand//.........这里部分代码省略......... cmd = Cmd_Argv(0); argc = Cmd_Argc(); if ( !strcmp( cmd, "disconnect" ) ) { // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=552 // allow server to indicate why they were disconnected if ( argc >= 2 ) Com_Error (ERR_SERVERDISCONNECT, va( "Server Disconnected - %s", Cmd_Argv( 1 ) ) ); else Com_Error (ERR_SERVERDISCONNECT,"Server disconnected/n"); } if ( !strcmp( cmd, "bcs0" ) ) { Com_sprintf( bigConfigString, BIG_INFO_STRING, "cs %s /"%s", Cmd_Argv(1), Cmd_Argv(2) ); return qfalse; } if ( !strcmp( cmd, "bcs1" ) ) { s = Cmd_Argv(2); if( strlen(bigConfigString) + strlen(s) >= BIG_INFO_STRING ) { Com_Error( ERR_DROP, "bcs exceeded BIG_INFO_STRING" ); } strcat( bigConfigString, s ); return qfalse; } if ( !strcmp( cmd, "bcs2" ) ) { s = Cmd_Argv(2); if( strlen(bigConfigString) + strlen(s) + 1 >= BIG_INFO_STRING ) { Com_Error( ERR_DROP, "bcs exceeded BIG_INFO_STRING" ); } strcat( bigConfigString, s ); strcat( bigConfigString, "/"" ); s = bigConfigString; goto rescan; } if ( !strcmp( cmd, "cs" ) ) { CL_ConfigstringModified(); // reparse the string, because CL_ConfigstringModified may have done another Cmd_TokenizeString() Cmd_TokenizeString( s ); return qtrue; } if ( !strcmp( cmd, "up" ) ) { if( serverCommandNumber <= clc.lastSnapServerCmdNum ) return qtrue; CL_TableUpdateRow(); return qtrue; } if ( !strcmp( cmd, "de" ) ) { if( serverCommandNumber <= clc.lastSnapServerCmdNum ) return qtrue; CL_TableDeleteRow(); return qtrue; } if ( !strcmp( cmd, "in" ) ) { if( serverCommandNumber <= clc.lastSnapServerCmdNum ) return qtrue; CL_TableInsertRow(); return qtrue; } if ( !strcmp( cmd, "map_restart" ) ) { // clear notify lines and outgoing commands before passing // the restart to the cgame Con_ClearNotify(); Com_Memset( cl.cmds, 0, sizeof( cl.cmds ) ); return qtrue; } // the clientLevelShot command is used during development // to generate 128*128 screenshots from the intermission // point of levels for the menu system to use // we pass it along to the cgame to make apropriate adjustments, // but we also clear the console and notify lines here if ( !strcmp( cmd, "clientLevelShot" ) ) { // don't do it if we aren't running the server locally, // otherwise malicious remote servers could overwrite // the existing thumbnails if ( !com_sv_running->integer ) { return qfalse; } // close the console Con_Close(); // take a special screenshot next frame Cbuf_AddText( "wait ; wait ; wait ; wait ; screenshot levelshot/n" ); return qtrue; } // we may want to put a "connect to other server" command here // cgame can now act on the command return qtrue;}
开发者ID:ballju,项目名称:SpaceTrader-GPL-1.1.14,代码行数:101,
示例24: SV_FinalMessage/*=====================SV_DropClientCalled when the player is totally leaving the server, either willinglyor unwillingly. This is NOT called if the entire server is quitingor crashing -- SV_FinalMessage() will handle that=====================*/void SV_DropClient( client_t *drop, const char *reason ) { int i; challenge_t *challenge; if ( drop->state == CS_ZOMBIE ) { return; // already dropped } if (drop->netchan.remoteAddress.type != NA_BOT) { // see if we already have a challenge for this ip challenge = &svs.challenges[0]; for (i = 0; i < MAX_CHALLENGES; i++, challenge++) { if (NET_CompareAdr(drop->netchan.remoteAddress, challenge->adr)) { Com_Memset(challenge, 0, sizeof(*challenge)); break; } } } if ( !drop->gentity || !(drop->gentity->r.svFlags & SVF_BOT) ) { // see if we already have a challenge for this ip challenge = &svs.challenges[0]; for (i = 0 ; i < MAX_CHALLENGES ; i++, challenge++) { if ( NET_CompareAdr( drop->netchan.remoteAddress, challenge->adr ) ) { challenge->connected = qfalse; break; } } } // Kill any download SV_CloseDownload( drop ); // tell everyone why they got dropped SV_SendServerCommand( NULL, "print /"%s" S_COLOR_WHITE " %s/n/"", drop->name, reason ); Com_DPrintf( "Going to CS_ZOMBIE for %s/n", drop->name ); drop->state = CS_ZOMBIE; // become free in a few seconds // call the prog function for removing a client // this will remove the body, among other things VM_Call( gvm, GAME_CLIENT_DISCONNECT, drop - svs.clients ); // add the disconnect command SV_SendServerCommand( drop, "disconnect" ); if ( drop->netchan.remoteAddress.type == NA_BOT ) { SV_BotFreeClient( drop - svs.clients ); } // nuke user info SV_SetUserinfo( drop - svs.clients, "" ); // if this was the last client on the server, send a heartbeat // to the master so it is known the server is empty // send a heartbeat now so the master will get up to date info // if there is already a slot for this ip, reuse it int players = 0; for (i = 0; i < sv_maxclients->integer; i++) { if (svs.clients[i].state >= CS_CONNECTED && svs.clients[i].netchan.remoteAddress.type != NA_BOT) { players++; } } for (i=0 ; i < sv_maxclients->integer ; i++ ) { if ( svs.clients[i].state >= CS_CONNECTED ) { break; } } if ( i == sv_maxclients->integer ) { SV_Heartbeat_f(); }}
开发者ID:ouned,项目名称:jk2mv,代码行数:84,
示例25: CL_ParseGamestate/*==================CL_ParseGamestate==================*/void CL_ParseGamestate( msg_t *msg ) { int i; entityState_t *es; int newnum; entityState_t nullstate; int cmd; char *s; char oldGame[MAX_QPATH]; Con_Close(); clc.connectPacketCount = 0; // wipe local client state CL_ClearState(); // 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 ); #ifdef ELITEFORCE if ( ( msg->compat && cmd <= 0 ) || cmd == svc_EOF ) #else if ( cmd == svc_EOF ) #endif break; if ( cmd == svc_configstring ) { int len; i = MSG_ReadShort( msg ); if ( i < 0 || i >= MAX_CONFIGSTRINGS ) { Com_Error( ERR_DROP, "configstring > MAX_CONFIGSTRINGS" ); } s = MSG_ReadBigString( msg ); 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 ]; MSG_ReadDeltaEntity( msg, &nullstate, es, newnum ); } else { Com_Error( ERR_DROP, "CL_ParseGamestate: bad command byte" ); } } #ifdef ELITEFORCE if(!msg->compat) #endif clc.clientNum = MSG_ReadLong(msg); // read the checksum feed #ifdef ELITEFORCE if(!clc.demoplaying || !msg->compat) #endif clc.checksumFeed = MSG_ReadLong( msg ); // save old gamedir Cvar_VariableStringBuffer("fs_game", oldGame, sizeof(oldGame)); // parse useful values out of CS_SERVERINFO CL_ParseServerInfo(); // parse serverId and other cvars CL_SystemInfoChanged(); // stop recording now so the demo won't have an unnecessary level load at the end. if(cl_autoRecordDemo->integer && clc.demorecording) CL_StopRecord_f(); // reinitialize the filesystem if the game directory has changed if(!cl_oldGameSet && (Cvar_Flags("fs_game") & CVAR_MODIFIED)) { cl_oldGameSet = qtrue; Q_strncpyz(cl_oldGame, oldGame, sizeof(cl_oldGame)); } FS_ConditionalRestart(clc.checksumFeed, qfalse);//.........这里部分代码省略.........
开发者ID:thefounder,项目名称:ioefgladiator,代码行数:101,
示例26: SV_SendClientGameState/*================SV_SendClientGameStateSends the first message from the server to a connected client.This will be sent on the initial connection and upon each new map load.It will be resent if the client acknowledges a later message but hasthe wrong gamestate.================*/void SV_SendClientGameState( client_t *client ) { int start; entityState_t *base, nullstate; msg_t msg; byte msgBuffer[MAX_MSGLEN]; // MW - my attempt to fix illegible server message errors caused by // packet fragmentation of initial snapshot. while(client->state&&client->netchan.unsentFragments) { // send additional message fragments if the last message // was too large to send at once Com_Printf ("[ISM]SV_SendClientGameState() [2] for %s, writing out old fragments/n", client->name); SV_Netchan_TransmitNextFragment(&client->netchan); } Com_DPrintf ("SV_SendClientGameState() for %s/n", client->name); Com_DPrintf( "Going from CS_CONNECTED to CS_PRIMED for %s/n", client->name ); if (client->state == CS_CONNECTED) client->state = CS_PRIMED; client->pureAuthentic = 0; // when we receive the first packet from the client, we will // notice that it is from a different serverid and that the // gamestate message was not just sent, forcing a retransmit client->gamestateMessageNum = client->netchan.outgoingSequence; MSG_Init( &msg, msgBuffer, sizeof( msgBuffer ) ); // NOTE, MRE: all server->client messages now acknowledge // let the client know which reliable clientCommands we have received MSG_WriteLong( &msg, client->lastClientCommand ); // send any server commands waiting to be sent first. // we have to do this cause we send the client->reliableSequence // with a gamestate and it sets the clc.serverCommandSequence at // the client side SV_UpdateServerCommandsToClient( client, &msg ); // send the gamestate MSG_WriteByte( &msg, svc_gamestate ); MSG_WriteLong( &msg, client->reliableSequence ); // write the configstrings for ( start = 0 ; start < MAX_CONFIGSTRINGS ; start++ ) { if (sv.configstrings[start][0]) { MSG_WriteByte( &msg, svc_configstring ); MSG_WriteShort( &msg, start ); MSG_WriteBigString( &msg, sv.configstrings[start] ); } } // write the baselines Com_Memset( &nullstate, 0, sizeof( nullstate ) ); for ( start = 0 ; start < MAX_GENTITIES; start++ ) { base = &sv.svEntities[start].baseline; if ( !base->number ) { continue; } MSG_WriteByte( &msg, svc_baseline ); MSG_WriteDeltaEntity( &msg, &nullstate, base, qtrue ); } MSG_WriteByte( &msg, svc_EOF ); MSG_WriteLong( &msg, client - svs.clients); // write the checksum feed MSG_WriteLong( &msg, sv.checksumFeed); // deliver this to the client SV_SendMessageToClient( &msg, client );}
开发者ID:ouned,项目名称:jk2mv,代码行数:85,
示例27: S_Base_Init/*================S_Init================*/qboolean S_Base_Init( soundInterface_t *si ) { qboolean r; if( !si ) { return qfalse; }#ifndef NO_DMAHD s_khz = Cvar_Get ("s_khz", "44", CVAR_ARCHIVE);#else s_khz = Cvar_Get ("s_khz", "22", CVAR_ARCHIVE);#endif s_mixahead = Cvar_Get ("s_mixahead", "0.2", CVAR_ARCHIVE); s_mixPreStep = Cvar_Get ("s_mixPreStep", "0.05", CVAR_ARCHIVE); s_show = Cvar_Get ("s_show", "0", CVAR_CHEAT); s_testsound = Cvar_Get ("s_testsound", "0", CVAR_CHEAT); s_dev = Cvar_Get ("s_dev", "", CVAR_ARCHIVE); s_alttabmute = Cvar_Get ("s_alttabmute", "1", CVAR_ARCHIVE); Cmd_AddCommand( "s_devlist", S_dmaHD_devlist ); r = SNDDMA_Init(); if ( r ) { s_soundStarted = 1; s_soundMuted = 1;// s_numSfx = 0; Com_Memset(sfxHash, 0, sizeof(sfx_t *)*LOOP_HASH); s_soundtime = 0; s_paintedtime = 0; S_Base_StopAllSounds( ); } else { return qfalse; } si->Shutdown = S_Base_Shutdown; si->StartSound = S_Base_StartSound; si->StartLocalSound = S_Base_StartLocalSound; si->StartBackgroundTrack = S_Base_StartBackgroundTrack; si->StopBackgroundTrack = S_Base_StopBackgroundTrack; si->RawSamples = S_Base_RawSamples; si->StopAllSounds = S_Base_StopAllSounds; si->ClearLoopingSounds = S_Base_ClearLoopingSounds; si->AddLoopingSound = S_Base_AddLoopingSound; si->AddRealLoopingSound = S_Base_AddRealLoopingSound; si->StopLoopingSound = S_Base_StopLoopingSound; si->Respatialize = S_Base_Respatialize; si->UpdateEntityPosition = S_Base_UpdateEntityPosition; si->Update = S_Base_Update; si->DisableSounds = S_Base_DisableSounds; si->BeginRegistration = S_Base_BeginRegistration; si->RegisterSound = S_Base_RegisterSound; si->ClearSoundBuffer = S_Base_ClearSoundBuffer; si->SoundInfo = S_Base_SoundInfo; si->SoundList = S_Base_SoundList;#ifndef NO_DMAHD if (dmaHD_Enabled()) return dmaHD_Init(si);#endif return qtrue;}
开发者ID:JERUKA9,项目名称:ioq3-for-UrbanTerror-4,代码行数:70,
示例28: SV_DirectConnect//.........这里部分代码省略......... } challengeptr = &svs.challenges[i]; if (challengeptr->wasrefused) { // Return silently, so that error messages written by the server keep being displayed. return; } ping = svs.time - svs.challenges[i].pingTime; // never reject a LAN client based on ping if ( !Sys_IsLANAddress( from ) ) { if ( ( sv_minPing->value && ping < sv_minPing->value ) && !svs.hibernation.enabled ) { // don't let them keep trying until they get a big delay NET_OutOfBandPrint( NS_SERVER, from, "print/nServer is for high pings only/n" ); Com_DPrintf ("Client %i rejected on a too low ping/n", i); challengeptr->wasrefused = qtrue; return; } if ( ( sv_maxPing->value && ping > sv_maxPing->value ) && !svs.hibernation.enabled ) { NET_OutOfBandPrint( NS_SERVER, from, "print/nServer is for low pings only/n" ); Com_DPrintf ("Client %i rejected on a too high ping/n", i); challengeptr->wasrefused = qtrue; return; } } Com_Printf("Client %i connecting with %i challenge ping/n", i, ping); challengeptr->connected = qtrue; } newcl = &temp; Com_Memset (newcl, 0, sizeof(client_t)); // if there is already a slot for this ip, reuse it for (i=0,cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++) { if ( cl->state == CS_FREE ) { continue; } if ( NET_CompareBaseAdr( from, cl->netchan.remoteAddress ) && ( cl->netchan.qport == qport || from.port == cl->netchan.remoteAddress.port ) ) { Com_Printf ("%s:reconnect/n", NET_AdrToString (from)); newcl = cl; // disconnect the client from the game first so any flags the // player might have are dropped VM_Call( gvm, GAME_CLIENT_DISCONNECT, newcl - svs.clients ); // goto gotnewcl; } } // find a client slot // if "sv_privateClients" is set > 0, then that number // of client slots will be reserved for connections that // have "password" set to the value of "sv_privatePassword" // Info requests will report the maxclients as if the private // slots didn't exist, to prevent people from trying to connect // to a full server. // This is to allow us to reserve a couple slots here on our // servers so we can play without having to kick people. // check for privateClient password password = Info_ValueForKey( userinfo, "password" ); if ( *password && !strcmp( password, sv_privatePassword->string ) ) {
开发者ID:ouned,项目名称:jk2mv,代码行数:67,
示例29: CL_ParseSnapshot/*================CL_ParseSnapshotIf the snapshot is parsed properly, it will be copied tocl.snap and saved in cl.snapshots[]. If the snapshot is invalidfor any reason, no changes to the state will be made at all.================*/void CL_ParseSnapshot( msg_t *msg ) { int len; clSnapshot_t *old; clSnapshot_t newSnap; int deltaNum; int oldMessageNum; int i, packetNum; // get the reliable sequence acknowledge number // NOTE: now sent with all server to client messages //clc.reliableAcknowledge = MSG_ReadLong( msg ); // read in the new snapshot to a temporary buffer // we will only copy to cl.snap if it is valid Com_Memset (&newSnap, 0, sizeof(newSnap)); // we will have read any new server commands in this // message before we got to svc_snapshot newSnap.serverCommandNum = clc.serverCommandSequence; newSnap.serverTime = MSG_ReadLong( msg ); // if we were just unpaused, we can only *now* really let the // change come into effect or the client hangs. cl_paused->modified = 0; newSnap.messageNum = clc.serverMessageSequence; deltaNum = MSG_ReadByte( msg ); if ( !deltaNum ) { newSnap.deltaNum = -1; } else { newSnap.deltaNum = newSnap.messageNum - deltaNum; } newSnap.snapFlags = MSG_ReadByte( msg ); // If the frame is delta compressed from data that we // no longer have available, we must suck up the rest of // the frame, but not use it, then ask for a non-compressed // message if ( newSnap.deltaNum <= 0 ) { newSnap.valid = qtrue; // uncompressed frame old = NULL; clc.demowaiting = qfalse; // we can start recording now } else { old = &cl.snapshots[newSnap.deltaNum & PACKET_MASK]; if ( !old->valid ) { // should never happen Com_Printf ("Delta from invalid frame (not supposed to happen!)./n"); } else if ( old->messageNum != newSnap.deltaNum ) { // The frame that the server did the delta from // is too old, so we can't reconstruct it properly. Com_Printf ("Delta frame too old./n"); } else if ( cl.parseEntitiesNum - old->parseEntitiesNum > MAX_PARSE_ENTITIES-128 ) { Com_Printf ("Delta parseEntitiesNum too old./n"); } else { newSnap.valid = qtrue; // valid delta parse } } // read areamask len = MSG_ReadByte( msg ); if(len > sizeof(newSnap.areamask)) { Com_Error (ERR_DROP,"CL_ParseSnapshot: Invalid size %d for areamask", len); return; } MSG_ReadData( msg, &newSnap.areamask, len); // read playerinfo SHOWNET( msg, "playerstate" ); if ( old ) { MSG_ReadDeltaPlayerstate( msg, &old->ps, &newSnap.ps ); } else { MSG_ReadDeltaPlayerstate( msg, NULL, &newSnap.ps ); } // read packet entities SHOWNET( msg, "packet entities" ); CL_ParsePacketEntities( msg, old, &newSnap ); // if not valid, dump the entire thing now that it has // been properly read if ( !newSnap.valid ) { return; } // clear the valid flags of any snapshots between the last // received and this one, so if there was a dropped packet//.........这里部分代码省略.........
开发者ID:undeadzy,项目名称:ioquake3_sql_log,代码行数:101,
示例30: demoStopvoid demoStop( void ) { if (demo.play.handle) { demoPlayStop( demo.play.handle ); } Com_Memset( &demo.play, 0, sizeof( demo.play ));}
开发者ID:mightycow,项目名称:q3mme,代码行数:6,
注:本文中的Com_Memset函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ Com_Milliseconds函数代码示例 C++ Com_Memcpy函数代码示例 |