/* ============ Cbuf_Execute ============ */ void Cbuf_Execute (void) { int i; char *text; char line[1024]; int quotes; while (cmd_text.cursize) { // 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') 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, alias) can insert data at the // beginning of the text buffer if (i == cmd_text.cursize) cmd_text.cursize = 0; else { i++; cmd_text.cursize -= i; Q_memcpy (text, text+i, cmd_text.cursize); } // execute the command line Cmd_ExecuteString (line); if (cmd_wait) { // skip out while text still remains in buffer, leaving it // for next frame cmd_wait = false; break; } } }
// When a command wants to issue other commands immediately, the text is // inserted at the beginning of the buffer, before any remaining unexecuted // commands. void Cbuf_InsertText(char *text) { int addLen = Q_strlen(text); int currLen = cmd_text.cursize; if (cmd_text.cursize + addLen >= cmd_text.maxsize) { Con_Printf(__FUNCTION__ ": overflow\n"); return; } #ifdef REHLDS_FIXES if (currLen) Q_memmove(cmd_text.data + addLen, cmd_text.data, currLen); Q_memcpy(cmd_text.data, text, addLen); cmd_text.cursize += addLen; #else char *temp = NULL; if (currLen) { temp = (char *)Z_Malloc(currLen); // TODO: Optimize: better use memmove without need for a temp buffer Q_memcpy(temp, cmd_text.data, currLen); SZ_Clear(&cmd_text); } Cbuf_AddText(text); if (currLen) { SZ_Write(&cmd_text, temp, currLen); Z_Free(temp); } #endif // REHLDS_FIXES }
void KeyValues::SetStringValue(char const *strValue) { if (m_iDataType == TYPE_STRING || m_iDataType == TYPE_WSTRING) delete [] m_pValue; if (!strValue) strValue = ""; int len = Q_strlen(strValue); m_sValue = new char[len + 1]; Q_memcpy(m_sValue, strValue, len + 1); m_iDataType = TYPE_STRING; }
void CDispMeshEvent::GetVirtualMesh( void *userData, virtualmeshlist_t *pList ) { Assert(userData==((void *)this)); pList->pVerts = m_verts.Base(); pList->indexCount = m_indexCount; pList->triangleCount = m_indexCount/3; pList->vertexCount = m_verts.Count(); pList->surfacePropsIndex = 0; // doesn't matter here, reset at runtime pList->pHull = NULL; int indexMax = ARRAYSIZE(pList->indices); int indexCount = min(m_indexCount, indexMax); Assert(m_indexCount < indexMax); Q_memcpy( pList->indices, m_pIndices, sizeof(*m_pIndices) * indexCount ); }
/* =========== Cache_Move =========== */ void Cache_Move ( cache_system_t *c) { cache_system_t *new_cs; // we are clearing up space at the bottom, so only allocate it late new_cs = Cache_TryAlloc (c->size, true); if (new_cs) { // Con_Printf ("cache_move ok\n"); Q_memcpy ( new_cs+1, c+1, c->size - sizeof(cache_system_t) ); new_cs->user = c->user; Q_memcpy (new_cs->name, c->name, sizeof(new_cs->name)); Cache_Free (c->user, false); //johnfitz -- added second argument new_cs->user->data = (void *)(new_cs+1); } else { // Con_Printf ("cache_move failed\n"); Cache_Free (c->user, true); // tough luck... //johnfitz -- added second argument } }
int MSG_ReadBuf(int len, void *data) { if(data == NULL || len < 1) { Sys_Error("MSG_ReadBuf: Bad arguments."); } if(global_msg_readcount+len > global_net_message.cursize) { global_msg_badread = 1; return(-1); } Q_memcpy(data, global_net_message.data, len); global_msg_readcount += len; return(1); }
/* ============ Cbuf_AddText Adds command text at the end of the buffer ============ */ void Cbuf_AddText( const char *text ) { int l; l = Q_strlen( text ); if( cmd_text.cursize + l >= cmd_text.maxsize ) { MsgDev( D_WARN, "Cbuf_AddText: overflow\n" ); return; } Q_memcpy( Cbuf_GetSpace( &cmd_text, l ), text, l ); }
/* ================== CL_ParseMovevars ================== */ void CL_ParseMovevars( sizebuf_t *msg ) { Delta_InitClient (); // finalize client delta's MSG_ReadDeltaMovevars( msg, &clgame.oldmovevars, &clgame.movevars ); // update sky if changed if( Q_strcmp( clgame.oldmovevars.skyName, clgame.movevars.skyName ) && cl.video_prepped ) R_SetupSky( clgame.movevars.skyName ); Q_memcpy( &clgame.oldmovevars, &clgame.movevars, sizeof( movevars_t )); // keep features an actual! clgame.oldmovevars.features = clgame.movevars.features = host.features; }
/* ================= Mod_LoadSpriteFrame ================= */ void * Mod_LoadSpriteFrame (void * pin, mspriteframe_t **ppframe) { dspriteframe_t *pinframe; mspriteframe_t *pspriteframe; int i, width, height, size, origin[2]; unsigned short *ppixout; byte *ppixin; pinframe = (dspriteframe_t *)pin; width = LittleLong (pinframe->width); height = LittleLong (pinframe->height); size = width * height; pspriteframe = Hunk_AllocName (sizeof (mspriteframe_t) + size*r_pixbytes, loadname); Q_memset (pspriteframe, 0, sizeof (mspriteframe_t) + size); *ppframe = pspriteframe; pspriteframe->width = width; pspriteframe->height = height; origin[0] = LittleLong (pinframe->origin[0]); origin[1] = LittleLong (pinframe->origin[1]); pspriteframe->up = origin[1]; pspriteframe->down = origin[1] - height; pspriteframe->left = origin[0]; pspriteframe->right = width + origin[0]; if (r_pixbytes == 1) { Q_memcpy (&pspriteframe->pixels[0], (byte *)(pinframe + 1), size); } else if (r_pixbytes == 2) { ppixin = (byte *)(pinframe + 1); ppixout = (unsigned short *)&pspriteframe->pixels[0]; for (i=0 ; i<size ; i++) ppixout[i] = d_8to16table[ppixin[i]]; } else { Sys_Error ("Mod_LoadSpriteFrame: driver set invalid r_pixbytes: %d\n", r_pixbytes); } return (void *)((byte *)pinframe + sizeof (dspriteframe_t) + size); }
/* =========== Cache_Move =========== */ void Cache_Move ( cache_system_t *c) { cache_system_t *newmem; // we are clearing up space at the bottom, so only allocate it late newmem = Cache_TryAlloc (c->size, true); if (newmem) { // Con_Printf ("cache_move ok\n"); Q_memcpy ( newmem+1, c+1, c->size - sizeof(cache_system_t) ); newmem->user = c->user; Q_memcpy (newmem->name, c->name, sizeof(newmem->name)); Cache_Free (c->user); newmem->user->data = (void *)(newmem+1); } else { // Con_Printf ("cache_move failed\n"); Cache_Free (c->user); // tough luck... } }
/* <2a451> ../engine/hashpak.c:217 */ qboolean HPAK_FindResource(hash_pack_directory_t *pDir, unsigned char *hash, struct resource_s *pResourceEntry) { for (int i = 0; i < pDir->nEntries; i++) { if (Q_memcmp(hash, pDir->p_rgEntries[i].resource.rgucMD5_hash, 16) == 0) { if (pResourceEntry) Q_memcpy(pResourceEntry, &pDir->p_rgEntries[i].resource, sizeof(resource_t)); return TRUE; } } return FALSE; }
/* DESCRIPTION: SV_Trace_Toss // LOCATION: sv_phys.c // PATH: PF_TraceToss_Shared // // Say I throw a grenade. Where will it go? This function finds out by // simulating ten seconds' worth of frames. */ trace_t * SV_Trace_Toss(trace_t * Outgoing_Trace, edict_t *tossent, edict_t *ignore) { int i; vec3_t var_378_end; vec3_t var_36C_move; trace_t var_360_trace; edict_t var_324_TempEdict; edict_t * var_328_TempEdictPtr; double var_380_host_frametime; var_380_host_frametime = host_frametime; host_frametime = .05; Q_memcpy(&var_324_TempEdict, tossent, sizeof(edict_t)); var_328_TempEdictPtr = &var_324_TempEdict; // while(1) //a sanity check to avoid tracing more than ten seconds was present in QW, I think it's a good idea. This may need to be adjusted to account for the alterable frametimes. for (i = 0; i < 200; i++) { SV_CheckVelocity(var_328_TempEdictPtr); SV_AddGravity(var_328_TempEdictPtr); VectorMA(var_328_TempEdictPtr->v.angles, host_frametime, var_328_TempEdictPtr->v.avelocity, var_328_TempEdictPtr->v.angles); VectorScale(var_328_TempEdictPtr->v.velocity, host_frametime, var_36C_move); VectorAdd(var_328_TempEdictPtr->v.origin, var_36C_move, var_378_end); var_360_trace = SV_Move(var_328_TempEdictPtr->v.origin, var_328_TempEdictPtr->v.mins, var_328_TempEdictPtr->v.maxs, var_378_end, 0, var_328_TempEdictPtr, 0); VectorCopy(var_360_trace.endpos, var_328_TempEdictPtr->v.origin); if(var_360_trace.pHit != NULL && var_360_trace.pHit != ignore) { break; } } host_frametime = var_380_host_frametime; Q_memcpy(Outgoing_Trace, &var_360_trace, sizeof(trace_t)); return(Outgoing_Trace); }
/* ==================== CL_DuplicateTexture Dupliacte texture with remap pixels ==================== */ void CL_DuplicateTexture( mstudiotexture_t *ptexture, int topcolor, int bottomcolor ) { gltexture_t *glt; texture_t *tx = NULL; char texname[128]; int i, index; size_t size; byte paletteBackup[768]; byte *raw, *pal; // save off the real texture index index = ptexture->index; glt = R_GetTexture( index ); Q_snprintf( texname, sizeof( texname ), "#%i_%s", RI.currententity->curstate.number, glt->name + 1 ); // search for pixels for( i = 0; i < RI.currentmodel->numtextures; i++ ) { tx = RI.currentmodel->textures[i]; if( tx->gl_texturenum == index ) break; // found } ASSERT( tx != NULL ); // backup original palette pal = (byte *)(tx + 1) + (tx->width * tx->height); Q_memcpy( paletteBackup, pal, 768 ); raw = CL_CreateRawTextureFromPixels( tx, &size, topcolor, bottomcolor ); ptexture->index = GL_LoadTexture( texname, raw, size, TF_FORCE_COLOR, NULL ); // do copy GL_SetTextureType( ptexture->index, TEX_REMAP ); // restore original palette Q_memcpy( pal, paletteBackup, 768 ); }
void CHLSL_Solver_Array::OnIdentifierAlloc( IdentifierLists_t &List ) { SimpleArray *pArray = new SimpleArray(); pArray->iNumComps = m_iNumComps; pArray->iSize_X = m_iSize_x; pArray->iSize_Y = m_iSize_y; pArray->iIndex = GetData().iNodeIndex; const int arraySize = m_iSize_x * m_iSize_y; pArray->vecData = new Vector4D[ arraySize ]; Q_memcpy( pArray->vecData, m_vecData, sizeof(Vector4D) * arraySize ); List.hList_Arrays.AddToTail( pArray ); }
/* =================== SV_UpdateMovevars check movevars for changes every frame send updates to client if changed =================== */ void SV_UpdateMovevars( qboolean initialize ) { if( !initialize && !physinfo->modified ) return; // check range if( sv_zmax->value < 256.0f ) Cvar_SetFloat( "sv_zmax", 256.0f ); if( sv_zmax->value > 32767.0f ) Cvar_SetFloat( "sv_zmax", 32767.0f ); svgame.movevars.gravity = sv_gravity->value; svgame.movevars.stopspeed = sv_stopspeed->value; svgame.movevars.maxspeed = sv_maxspeed->value; svgame.movevars.spectatormaxspeed = sv_spectatormaxspeed->value; svgame.movevars.accelerate = sv_accelerate->value; svgame.movevars.airaccelerate = sv_airaccelerate->value; svgame.movevars.wateraccelerate = sv_wateraccelerate->value; svgame.movevars.friction = sv_friction->value; svgame.movevars.edgefriction = sv_edgefriction->value; svgame.movevars.waterfriction = sv_waterfriction->value; svgame.movevars.bounce = sv_wallbounce->value; svgame.movevars.stepsize = sv_stepsize->value; svgame.movevars.maxvelocity = sv_maxvelocity->value; svgame.movevars.zmax = sv_zmax->value; svgame.movevars.waveHeight = sv_wateramp->value; Q_strncpy( svgame.movevars.skyName, sv_skyname->string, sizeof( svgame.movevars.skyName )); svgame.movevars.footsteps = sv_footsteps->integer; svgame.movevars.rollangle = sv_rollangle->value; svgame.movevars.rollspeed = sv_rollspeed->value; svgame.movevars.skycolor_r = sv_skycolor_r->value; svgame.movevars.skycolor_g = sv_skycolor_g->value; svgame.movevars.skycolor_b = sv_skycolor_b->value; svgame.movevars.skyvec_x = sv_skyvec_x->value; svgame.movevars.skyvec_y = sv_skyvec_y->value; svgame.movevars.skyvec_z = sv_skyvec_z->value; svgame.movevars.skydir_x = sv_skydir_x->value; svgame.movevars.skydir_y = sv_skydir_y->value; svgame.movevars.skydir_z = sv_skydir_z->value; svgame.movevars.skyangle = sv_skyangle->value; svgame.movevars.wateralpha = sv_wateralpha->value; svgame.movevars.features = host.features; // just in case. not really need if( initialize ) return; // too early if( MSG_WriteDeltaMovevars( &sv.reliable_datagram, &svgame.oldmovevars, &svgame.movevars )) Q_memcpy( &svgame.oldmovevars, &svgame.movevars, sizeof( movevars_t )); // oldstate changed physinfo->modified = false; }
CUtlString &CUtlString::operator+=( const char *rhs ) { const int lhsLength( Length() ); const int rhsLength( V_strlen( rhs ) ); const int requestedLength( lhsLength + rhsLength ); if (!requestedLength) { return *this; } AllocMemory( requestedLength ); Q_memcpy( m_pString + lhsLength, rhs, rhsLength ); return *this; }
void SEditModelRender::GetModelCenter( float *pFl3_ViewOffset ) { Q_memset( pFl3_ViewOffset, 0, sizeof(float) * 3 ); if ( IsModelReady() ) { MDLCACHE_CRITICAL_SECTION(); if ( pModelInstance->GetModelPtr() ) { const Vector &vecMin = pModelInstance->GetModelPtr()->hull_min(); const Vector &vecMax = pModelInstance->GetModelPtr()->hull_max(); Vector vecPos = ( vecMin + ( vecMax - vecMin ) * 0.5f ); if ( pFl3_ViewOffset ) Q_memcpy( pFl3_ViewOffset, vecPos.Base(), sizeof(float) * 3 ); } } }
/* ============= COM_MemFgets ============= */ char *COM_MemFgets( byte *pMemFile, int fileSize, int *filePos, char *pBuffer, int bufferSize ) { int i, last, stop; if( !pMemFile || !pBuffer || !filePos ) return NULL; if( *filePos >= fileSize ) return NULL; i = *filePos; last = fileSize; // fgets always NULL terminates, so only read bufferSize-1 characters if( last - *filePos > ( bufferSize - 1 )) last = *filePos + ( bufferSize - 1); stop = 0; // stop at the next newline (inclusive) or end of buffer while( i < last && !stop ) { if( pMemFile[i] == '\n' ) stop = 1; i++; } // if we actually advanced the pointer, copy it over if( i != *filePos ) { // we read in size bytes int size = i - *filePos; // copy it out Q_memcpy( pBuffer, pMemFile + *filePos, size ); // If the buffer isn't full, terminate (this is always true) if( size < bufferSize ) pBuffer[size] = 0; // update file pointer *filePos = i; return pBuffer; } return NULL; }
CUtlString &CUtlString::operator+=( const CUtlString &rhs ) { const int lhsLength( Length() ); const int rhsLength( rhs.Length() ); if (!rhsLength) { return *this; } const int requestedLength( lhsLength + rhsLength ); AllocMemory( requestedLength ); Q_memcpy( m_pString + lhsLength, rhs.m_pString, rhsLength ); return *this; }
/* <d321a> ../engine/net_ws.c:228 */ void SockadrToNetadr(const struct sockaddr *s, netadr_t *a) { if (s->sa_family == AF_INET) { a->type = NA_IP; *(int *)&a->ip = ((struct sockaddr_in *)s)->sin_addr.s_addr; a->port = ((struct sockaddr_in *)s)->sin_port; } #ifdef _WIN32 else if (s->sa_family == AF_IPX) { a->type = NA_IPX; Q_memcpy(a->ipx, s->sa_data, 10); a->port = *(unsigned short *)&s->sa_data[10]; } #endif // _WIN32 }
//----------------------------------------------------------------------------- // Purpose: Award an achievement to the current user //----------------------------------------------------------------------------- void CXboxSystem::AwardAchievement( uint nUserIdx, uint nAchievementId ) { AsyncResult_t *pResult = CreateAsyncResult( true ); XUSER_ACHIEVEMENT ach; ach.dwUserIndex = nUserIdx; ach.dwAchievementId = nAchievementId; pResult->pInputData = malloc( sizeof( ach ) ); Q_memcpy( pResult->pInputData, &ach, sizeof( ach ) ); DWORD ret = XUserWriteAchievements( 1, (XUSER_ACHIEVEMENT*)pResult->pInputData, &pResult->overlapped ); if ( ret != ERROR_IO_PENDING ) { Warning( "XUserWriteAchievments failed.\n" ); } }
void HPAK_AddToQueue( const char *name, resource_t *DirEnt, byte *data, file_t *f ) { hpak_t *ptr; ptr = Z_Malloc( sizeof( hpak_t )); ptr->name = copystring( name ); ptr->HpakResource = *DirEnt; ptr->size = DirEnt->nDownloadSize; ptr->data = Z_Malloc( ptr->size ); if( data ) Q_memcpy( ptr->data, data, ptr->size ); else if( f ) FS_Read( f, ptr->data, ptr->size ); else Host_Error( "HPAK_AddToQueue: data == NULL.\n" ); ptr->next = hpak_queue; hpak_queue = ptr; }
/* DESCRIPTION: COM_StripExtension // LOCATION: common.c // PATH: HPAK stuff // // Replaces the last dot with a null and copies it into the buffer. Apparently // "out" and "in" can be the same buffer. */ void COM_StripExtension(char *in, char *out) { char *s; int i; if(out == in) { s = strrchr(in, '.'); if(s != NULL) { *s = '\0'; } } else { s = strrchr(in, '.'); i = s - in; Q_memcpy(out, in, i); out[i] = '\0'; } }
void KeyValues::SetWString(const char *keyName, const wchar_t *value) { KeyValues *dat = FindKey(keyName, true); if (dat) { if (dat->m_iDataType == TYPE_STRING || dat->m_iDataType == TYPE_WSTRING) delete [] dat->m_pValue; if (!value) value = L""; int len = wcslen(value); dat->m_wsValue = new wchar_t[len + 1]; Q_memcpy(dat->m_wsValue, value, (len + 1) * sizeof(wchar_t)); dat->m_iDataType = TYPE_WSTRING; } }
/* <66786> ../engine/net_chan.c:1723 */ qboolean Netchan_CopyNormalFragments(netchan_t *chan) { fragbuf_t *p, *n; if (!chan->incomingready[FRAG_NORMAL_STREAM]) return FALSE; if (!chan->incomingbufs[FRAG_NORMAL_STREAM]) { Con_Printf("Netchan_CopyNormalFragments: Called with no fragments readied\n"); chan->incomingready[FRAG_NORMAL_STREAM] = FALSE; return FALSE; } p = chan->incomingbufs[FRAG_NORMAL_STREAM]; SZ_Clear(&net_message); MSG_BeginReading(); while (p) { n = p->next; SZ_Write(&net_message, p->frag_message.data, p->frag_message.cursize); Mem_Free(p); p = n; } if (*(uint32 *)net_message.data == MAKEID('B', 'Z', '2', '\0')) { char uncompressed[65536]; unsigned int uncompressedSize = 65536; BZ2_bzBuffToBuffDecompress(uncompressed, &uncompressedSize, (char*)net_message.data + 4, net_message.cursize - 4, 1, 0); Q_memcpy(net_message.data, uncompressed, uncompressedSize); net_message.cursize = uncompressedSize; } chan->incomingbufs[FRAG_NORMAL_STREAM] = NULL; chan->incomingready[FRAG_NORMAL_STREAM] = false; return TRUE; }
void KeyValues::SetString(const char *keyName, const char *value) { KeyValues *dat = FindKey(keyName, true); if (dat) { if (dat->m_iDataType == TYPE_STRING || dat->m_iDataType == TYPE_WSTRING) delete [] dat->m_pValue; if (!value) value = ""; int len = Q_strlen(value); dat->m_sValue = new char[len + 1]; Q_memcpy(dat->m_sValue, value, len + 1); dat->m_iDataType = TYPE_STRING; } }
/* ==================== StudioGetAnim ==================== */ static mstudioanim_t *Mod_StudioGetAnim( model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc ) { mstudioseqgroup_t *pseqgroup; fs_offset_t filesize; byte *buf; cache_user_t *paSequences; pseqgroup = (mstudioseqgroup_t *)((byte *)mod_studiohdr + mod_studiohdr->seqgroupindex) + pseqdesc->seqgroup; if( pseqdesc->seqgroup == 0 ) return (mstudioanim_t *)((byte *)mod_studiohdr + pseqdesc->animindex); paSequences = (cache_user_t *)m_pSubModel->submodels; if( paSequences == NULL ) { paSequences = (cache_user_t *)Mem_Alloc( com_studiocache, MAXSTUDIOGROUPS * sizeof( cache_user_t )); m_pSubModel->submodels = (void *)paSequences; } // check for already loaded if( !paSequences[pseqdesc->seqgroup].data ) { string filepath, modelname, modelpath; FS_FileBase( m_pSubModel->name, modelname ); FS_ExtractFilePath( m_pSubModel->name, modelpath ); Q_snprintf( filepath, sizeof( filepath ), "%s/%s%i%i.mdl", modelpath, modelname, pseqdesc->seqgroup / 10, pseqdesc->seqgroup % 10 ); buf = FS_LoadFile( filepath, &filesize, false ); if( !buf || !filesize ) Host_Error( "StudioGetAnim: can't load %s\n", filepath ); else if( IDSEQGRPHEADER != *(uint *)buf ) Host_Error( "StudioGetAnim: %s is corrupted\n", filepath ); MsgDev( D_INFO, "loading: %s\n", filepath ); paSequences[pseqdesc->seqgroup].data = Mem_Alloc( com_studiocache, filesize ); Q_memcpy( paSequences[pseqdesc->seqgroup].data, buf, (size_t)filesize ); Mem_Free( buf ); } return (mstudioanim_t *)((byte *)paSequences[pseqdesc->seqgroup].data + pseqdesc->animindex); }
//----------------------------------------------------------------------------- void CUtlString::SetDirect( const char *pValue, int nChars ) { if ( pValue && nChars > 0 ) { if ( pValue == m_pString ) { AssertMsg( nChars == Q_strlen(m_pString), "CUtlString::SetDirect does not support resizing strings in place." ); return; // Do nothing. Realloc in AllocMemory might move pValue's location resulting in a bad memcpy. } Assert( nChars <= Min<int>( strnlen(pValue, nChars) + 1, nChars ) ); AllocMemory( nChars ); Q_memcpy( m_pString, pValue, nChars ); } else { Purge(); } }
/* ================ Sys_SetClipboardData write screenshot into clipboard ================ */ void Sys_SetClipboardData( const byte *buffer, size_t size ) { EmptyClipboard(); if( OpenClipboard( NULL ) != 0 ) { HGLOBAL hResult = GlobalAlloc( GMEM_MOVEABLE, size ); byte *bufferCopy = (byte *)GlobalLock( hResult ); Q_memcpy( bufferCopy, buffer, size ); GlobalUnlock( hResult ); if( SetClipboardData( CF_DIB, hResult ) == NULL ) { MsgDev( D_ERROR, "unable to write screenshot\n" ); GlobalFree( hResult ); } CloseClipboard(); } }
int CServerRemoteAccess::ReadDataResponse_noVirt(void *data, int len) { int i = m_ResponsePackets.Head(); if (!m_ResponsePackets.IsValidIndex(i)) return 0; CUtlBuffer &response = m_ResponsePackets.Element(i).packet; int bytesToCopy = response.TellPut(); if (bytesToCopy > len) bytesToCopy = 0; if (bytesToCopy) Q_memcpy(data, response.Base(), bytesToCopy); m_iBytesSent += bytesToCopy; m_ResponsePackets.Remove(i); return bytesToCopy; }