本文整理汇总了C++中Q_memcpy函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_memcpy函数的具体用法?C++ Q_memcpy怎么用?C++ Q_memcpy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Q_memcpy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Cbuf_Execute
/*
============
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;
}
}
}
示例2: Cbuf_InsertText
// 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
}
示例3: Q_strlen
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;
}
示例4: Assert
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 );
}
示例5: Cache_Move
/*
===========
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
}
}
示例6: MSG_ReadBuf
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);
}
示例7: Cbuf_AddText
/*
============
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 );
}
示例8: CL_ParseMovevars
/*
==================
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;
}
示例9: Mod_LoadSpriteFrame
/*
=================
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);
}
示例10: Cache_Move
/*
===========
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...
}
}
示例11: HPAK_FindResource
/* <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;
}
示例12: SV_Trace_Toss
/* 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);
}
示例13: CL_DuplicateTexture
/*
====================
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 );
}
示例14: SimpleArray
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 );
}
示例15: SV_UpdateMovevars
/*
===================
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;
}