本文整理汇总了C++中FS_Write函数的典型用法代码示例。如果您正苦于以下问题:C++ FS_Write函数的具体用法?C++ FS_Write怎么用?C++ FS_Write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FS_Write函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: R_CheckMP3s
//.........这里部分代码省略.........
fMaxVol = pSFX->fVolRange;
// free sfx->data...
//
{
// Hunk_FreeTempMemory( SFX.data ); // this will have been allocated inside S_LoadSound_Finalise()
//
// I want a big thankyou from the Mac guys for providing this define... :-) -ste
//
// #ifndef INT_MIN
// #define INT_MIN (-2147483647 - 1) /* minimum (signed) int value */
// #endif
//
pSFX->iLastTimeUsed = INT_MIN; // force this to be oldest sound file, therefore disposable...
pSFX->bInMemory = qtrue;
SND_FreeOldestSound(); // ... and do the disposal
// now set our temp SFX struct back to default name so nothing else accidentally uses it...
//
strcpy(pSFX->sSoundName, sReservedSFXEntrynameForMP3);
pSFX->bDefaultSound = qfalse;
}
// other stuff...
//
Z_Free(pbUnpackBuffer);
}
// well, time to update the file now...
//
fileHandle_t f = FS_FOpenFileWrite( sFilename );
if (f)
{
// write the file back out, but omitting the tag if there was one...
//
int iWritten = FS_Write(pbData, iSize-(pTAG?sizeof(*pTAG):0), f);
if (iWritten)
{
// make up a new tag if we didn't find one in the original file...
//
id3v1_1 TAG;
if (!pTAG)
{
pTAG = &TAG;
memset(&TAG,0,sizeof(TAG));
strncpy(pTAG->id,"TAG",3);
}
strncpy(pTAG->title, Filename_WithoutPath(Filename_WithoutExt(sFilename)), sizeof(pTAG->title));
strncpy(pTAG->artist, "Raven Software", sizeof(pTAG->artist) );
strncpy(pTAG->year, "2001", sizeof(pTAG->year) );
strncpy(pTAG->comment, va("%s %g",sKEY_MAXVOL,fMaxVol), sizeof(pTAG->comment) );
strncpy(pTAG->album, va("%s %d",sKEY_UNCOMP,iActualUnpackedSize),sizeof(pTAG->album) );
if (FS_Write( pTAG, sizeof(*pTAG), f )) // NZ = success
{
iFilesUpdated++;
}
else
{
Com_Printf("*********** Failed write to file!\n");
iErrors++;
}
}
else
{
Com_Printf("*********** Failed write to file!\n");
iErrors++;
}
FS_FCloseFile( f );
}
else
{
Com_Printf("*********** Failed to re-open for write!\n");
iErrors++;
}
}
else
{
Com_Error(ERR_DROP, "******* This MP3 should be deleted: %s\n",sFilename);
}
}
else
{
Com_Printf("*********** File was not a valid MP3!\n");
iErrors++;
}
}
else
{
Com_Printf(" ( OK )\n");
}
FS_FreeFile( pbData );
}
}
FS_FreeFileList( sysFiles );
FS_FreeFileList( dirFiles );
}
示例2: CL_CgameSystemCalls
int CL_CgameSystemCalls( int *args ) {
#ifndef __NO_JK2
if( Cvar_VariableIntegerValue("com_jk2") )
{
args[0] = (int)CL_ConvertJK2SysCall((cgameJK2Import_t)args[0]);
}
#endif
switch( args[0] ) {
case CG_PRINT:
Com_Printf( "%s", VMA(1) );
return 0;
case CG_ERROR:
Com_Error( ERR_DROP, S_COLOR_RED"%s", VMA(1) );
return 0;
case CG_MILLISECONDS:
return Sys_Milliseconds();
case CG_CVAR_REGISTER:
Cvar_Register( (vmCvar_t *) VMA(1), (const char *) VMA(2), (const char *) VMA(3), args[4] );
return 0;
case CG_CVAR_UPDATE:
Cvar_Update( (vmCvar_t *) VMA(1) );
return 0;
case CG_CVAR_SET:
Cvar_Set( (const char *) VMA(1), (const char *) VMA(2) );
return 0;
case CG_ARGC:
return Cmd_Argc();
case CG_ARGV:
Cmd_ArgvBuffer( args[1], (char *) VMA(2), args[3] );
return 0;
case CG_ARGS:
Cmd_ArgsBuffer( (char *) VMA(1), args[2] );
return 0;
case CG_FS_FOPENFILE:
return FS_FOpenFileByMode( (const char *) VMA(1), (int *) VMA(2), (fsMode_t) args[3] );
case CG_FS_READ:
FS_Read( VMA(1), args[2], args[3] );
return 0;
case CG_FS_WRITE:
FS_Write( VMA(1), args[2], args[3] );
return 0;
case CG_FS_FCLOSEFILE:
FS_FCloseFile( args[1] );
return 0;
case CG_SENDCONSOLECOMMAND:
Cbuf_AddText( (const char *) VMA(1) );
return 0;
case CG_ADDCOMMAND:
CL_AddCgameCommand( (const char *) VMA(1) );
return 0;
case CG_SENDCLIENTCOMMAND:
CL_AddReliableCommand( (const char *) VMA(1) );
return 0;
case CG_UPDATESCREEN:
// this is used during lengthy level loading, so pump message loop
Com_EventLoop(); // FIXME: if a server restarts here, BAD THINGS HAPPEN!
SCR_UpdateScreen();
return 0;
#ifdef _XBOX
case CG_RMG_INIT:
case CG_CM_REGISTER_TERRAIN:
case CG_RE_INIT_RENDERER_TERRAIN:
Com_Error( ERR_FATAL, "ERROR: Terrain unsupported on Xbox.\n" );
#else
case CG_RMG_INIT:
/*
if (!com_sv_running->integer)
{ // don't do this if we are connected locally
if (!TheRandomMissionManager)
{
TheRandomMissionManager = new CRMManager;
}
TheRandomMissionManager->SetLandScape( cmg.landScapes[args[1]] );
TheRandomMissionManager->LoadMission(qfalse);
TheRandomMissionManager->SpawnMission(qfalse);
cmg.landScapes[args[1]]->UpdatePatches();
}
*/ //this is SP.. I guess we're always the client and server.
// cl.mRMGChecksum = cm.landScapes[args[1]]->get_rand_seed();
RM_CreateRandomModels(args[1], (const char *)VMA(2));
//cmg.landScapes[args[1]]->rand_seed(cl.mRMGChecksum); // restore it, in case we do a vid restart
cmg.landScape->rand_seed(cmg.landScape->get_rand_seed());
// TheRandomMissionManager->CreateMap();
return 0;
case CG_CM_REGISTER_TERRAIN:
return CM_RegisterTerrain((const char *)VMA(1), false)->GetTerrainId();
case CG_RE_INIT_RENDERER_TERRAIN:
RE_InitRendererTerrain((const char *)VMA(1));
return 0;
#endif // _XBOX
case CG_CM_LOADMAP:
#ifdef _XBOX
CL_CM_LoadMap( (const char *) VMA(1) );
#else
CL_CM_LoadMap( (const char *) VMA(1), args[2] );
#endif
return 0;
//.........这里部分代码省略.........
示例3: CL_CgameSystemCalls
/*
====================
CL_CgameSystemCalls
The cgame module is making a system call
====================
*/
intptr_t CL_CgameSystemCalls( intptr_t *args ) {
switch( args[0] ) {
case CG_PRINT:
Com_Printf( "%s", (const char*)VMA(1) );
return 0;
case CG_ERROR:
Com_Error( ERR_DROP, "%s", (const char*)VMA(1) );
return 0;
case CG_MILLISECONDS:
return Sys_Milliseconds();
case CG_CVAR_REGISTER:
Cvar_Register( VMA(1), VMA(2), VMA(3), args[4] );
return 0;
case CG_CVAR_UPDATE:
Cvar_Update( VMA(1) );
return 0;
case CG_CVAR_SET:
Cvar_SetSafe( VMA(1), VMA(2) );
return 0;
case CG_CVAR_VARIABLESTRINGBUFFER:
Cvar_VariableStringBuffer( VMA(1), VMA(2), args[3] );
return 0;
case CG_ARGC:
return Cmd_Argc();
case CG_ARGV:
Cmd_ArgvBuffer( args[1], VMA(2), args[3] );
return 0;
case CG_ARGS:
Cmd_ArgsBuffer( VMA(1), args[2] );
return 0;
case CG_FS_FOPENFILE:
return FS_FOpenFileByMode( VMA(1), VMA(2), args[3] );
case CG_FS_READ:
FS_Read2( VMA(1), args[2], args[3] );
return 0;
case CG_FS_WRITE:
FS_Write( VMA(1), args[2], args[3] );
return 0;
case CG_FS_FCLOSEFILE:
FS_FCloseFile( args[1] );
return 0;
case CG_FS_SEEK:
return FS_Seek( args[1], args[2], args[3] );
case CG_SENDCONSOLECOMMAND:
Cbuf_AddText( VMA(1) );
return 0;
case CG_ADDCOMMAND:
CL_AddCgameCommand( VMA(1) );
return 0;
case CG_REMOVECOMMAND:
Cmd_RemoveCommandSafe( VMA(1) );
return 0;
case CG_SENDCLIENTCOMMAND:
CL_AddReliableCommand(VMA(1), qfalse);
return 0;
case CG_UPDATESCREEN:
// this is used during lengthy level loading, so pump message loop
// Com_EventLoop(); // FIXME: if a server restarts here, BAD THINGS HAPPEN!
// We can't call Com_EventLoop here, a restart will crash and this _does_ happen
// if there is a map change while we are downloading at pk3.
// ZOID
SCR_UpdateScreen();
return 0;
case CG_CM_LOADMAP:
CL_CM_LoadMap( VMA(1) );
return 0;
case CG_CM_NUMINLINEMODELS:
return CM_NumInlineModels();
case CG_CM_INLINEMODEL:
return CM_InlineModel( args[1] );
case CG_CM_TEMPBOXMODEL:
return CM_TempBoxModel( VMA(1), VMA(2), /*int capsule*/ qfalse );
case CG_CM_TEMPCAPSULEMODEL:
return CM_TempBoxModel( VMA(1), VMA(2), /*int capsule*/ qtrue );
case CG_CM_POINTCONTENTS:
return CM_PointContents( VMA(1), args[2] );
case CG_CM_TRANSFORMEDPOINTCONTENTS:
return CM_TransformedPointContents( VMA(1), args[2], VMA(3), VMA(4) );
case CG_CM_BOXTRACE:
CM_BoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qfalse );
return 0;
case CG_CM_CAPSULETRACE:
CM_BoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qtrue );
return 0;
case CG_CM_TRANSFORMEDBOXTRACE:
CM_TransformedBoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule*/ qfalse );
return 0;
case CG_CM_TRANSFORMEDCAPSULETRACE:
CM_TransformedBoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule*/ qtrue );
return 0;
case CG_CM_MARKFRAGMENTS:
return re.MarkFragments( args[1], VMA(2), VMA(3), args[4], VMA(5), args[6], VMA(7) );
case CG_S_STARTSOUND:
//.........这里部分代码省略.........
示例4: SCR_CaptureVideo_Ogg_EndVideo
static void SCR_CaptureVideo_Ogg_EndVideo(void)
{
LOAD_FORMATSPECIFIC_OGG();
ogg_page pg;
ogg_packet pt;
if(format->yuvi >= 0)
{
// send the previous (and last) frame
while(format->lastnum-- > 0)
{
qtheora_encode_YUVin(&format->ts, &format->yuv[format->yuvi]);
while(qtheora_encode_packetout(&format->ts, !format->lastnum, &pt))
qogg_stream_packetin(&format->to, &pt);
SCR_CaptureVideo_Ogg_Interleave();
}
}
if(cls.capturevideo.soundrate)
{
qvorbis_analysis_wrote(&format->vd, 0);
while(qvorbis_analysis_blockout(&format->vd, &format->vb) == 1)
{
qvorbis_analysis(&format->vb, NULL);
qvorbis_bitrate_addblock(&format->vb);
while(qvorbis_bitrate_flushpacket(&format->vd, &pt))
qogg_stream_packetin(&format->vo, &pt);
SCR_CaptureVideo_Ogg_Interleave();
}
}
SCR_CaptureVideo_Ogg_FlushInterleaving();
while(qogg_stream_pageout(&format->to, &pg) > 0)
{
FS_Write(cls.capturevideo.videofile, pg.header, pg.header_len);
FS_Write(cls.capturevideo.videofile, pg.body, pg.body_len);
}
if(cls.capturevideo.soundrate)
{
while(qogg_stream_pageout(&format->vo, &pg) > 0)
{
FS_Write(cls.capturevideo.videofile, pg.header, pg.header_len);
FS_Write(cls.capturevideo.videofile, pg.body, pg.body_len);
}
}
while (1) {
int result = qogg_stream_flush (&format->to, &pg);
if (result < 0)
fprintf (stderr, "Internal Ogg library error.\n"); // TODO Host_Error
if (result <= 0)
break;
FS_Write(cls.capturevideo.videofile, pg.header, pg.header_len);
FS_Write(cls.capturevideo.videofile, pg.body, pg.body_len);
}
if(cls.capturevideo.soundrate)
{
while (1) {
int result = qogg_stream_flush (&format->vo, &pg);
if (result < 0)
fprintf (stderr, "Internal Ogg library error.\n"); // TODO Host_Error
if (result <= 0)
break;
FS_Write(cls.capturevideo.videofile, pg.header, pg.header_len);
FS_Write(cls.capturevideo.videofile, pg.body, pg.body_len);
}
qogg_stream_clear(&format->vo);
qvorbis_block_clear(&format->vb);
qvorbis_dsp_clear(&format->vd);
}
qogg_stream_clear(&format->to);
qtheora_clear(&format->ts);
qvorbis_info_clear(&format->vi);
Mem_Free(format->yuv[0].y);
Mem_Free(format->yuv[0].u);
Mem_Free(format->yuv[0].v);
Mem_Free(format->yuv[1].y);
Mem_Free(format->yuv[1].u);
Mem_Free(format->yuv[1].v);
Mem_Free(format);
FS_Close(cls.capturevideo.videofile);
cls.capturevideo.videofile = NULL;
}
示例5: Cvar_WriteVariables
/*
============
Cvar_WriteVariables
Appends lines containing "set variable value" for all variables
with the archive flag set that are not in a transient state.
============
*/
void Cvar_WriteVariables( fileHandle_t f )
{
std::string text = Cvar::GetCvarConfigText();
FS_Write(text.c_str(), text.size(), f);
}
示例6: CL_CgameSystemCalls
/*
====================
CL_CgameSystemCalls
The cgame module is making a system call
====================
*/
intptr_t CL_CgameSystemCalls( intptr_t *args ) {
switch ( args[0] ) {
case CG_PRINT:
Com_Printf( "%s", VMA( 1 ) );
return 0;
case CG_ERROR:
Com_Error( ERR_DROP, "%s", VMA( 1 ) );
return 0;
case CG_MILLISECONDS:
return Sys_Milliseconds();
case CG_CVAR_REGISTER:
Cvar_Register( VMA( 1 ), VMA( 2 ), VMA( 3 ), args[4] );
return 0;
case CG_CVAR_UPDATE:
Cvar_Update( VMA( 1 ) );
return 0;
case CG_CVAR_SET:
Cvar_Set( VMA( 1 ), VMA( 2 ) );
return 0;
case CG_CVAR_VARIABLESTRINGBUFFER:
Cvar_VariableStringBuffer( VMA( 1 ), VMA( 2 ), args[3] );
return 0;
case CG_ARGC:
return Cmd_Argc();
case CG_ARGV:
Cmd_ArgvBuffer( args[1], VMA( 2 ), args[3] );
return 0;
case CG_ARGS:
Cmd_ArgsBuffer( VMA( 1 ), args[2] );
return 0;
case CG_FS_FOPENFILE:
return FS_FOpenFileByMode( VMA( 1 ), VMA( 2 ), args[3] );
case CG_FS_READ:
FS_Read( VMA( 1 ), args[2], args[3] );
return 0;
case CG_FS_WRITE:
return FS_Write( VMA( 1 ), args[2], args[3] );
case CG_FS_FCLOSEFILE:
FS_FCloseFile( args[1] );
return 0;
case CG_SENDCONSOLECOMMAND:
Cbuf_AddText( VMA( 1 ) );
return 0;
case CG_ADDCOMMAND:
CL_AddCgameCommand( VMA( 1 ) );
return 0;
case CG_REMOVECOMMAND:
Cmd_RemoveCommand( VMA( 1 ) );
return 0;
case CG_SENDCLIENTCOMMAND:
CL_AddReliableCommand( VMA( 1 ) );
return 0;
case CG_UPDATESCREEN:
// this is used during lengthy level loading, so pump message loop
// Com_EventLoop(); // FIXME: if a server restarts here, BAD THINGS HAPPEN!
// We can't call Com_EventLoop here, a restart will crash and this _does_ happen
// if there is a map change while we are downloading at pk3.
// ZOID
SCR_UpdateScreen();
return 0;
case CG_CM_LOADMAP:
CL_CM_LoadMap( VMA( 1 ) );
return 0;
case CG_CM_NUMINLINEMODELS:
return CM_NumInlineModels();
case CG_CM_INLINEMODEL:
return CM_InlineModel( args[1] );
case CG_CM_TEMPBOXMODEL:
return CM_TempBoxModel( VMA( 1 ), VMA( 2 ), qfalse );
case CG_CM_TEMPCAPSULEMODEL:
return CM_TempBoxModel( VMA( 1 ), VMA( 2 ), qtrue );
case CG_CM_POINTCONTENTS:
return CM_PointContents( VMA( 1 ), args[2] );
case CG_CM_TRANSFORMEDPOINTCONTENTS:
return CM_TransformedPointContents( VMA( 1 ), args[2], VMA( 3 ), VMA( 4 ) );
case CG_CM_BOXTRACE:
CM_BoxTrace( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMA( 4 ), VMA( 5 ), args[6], args[7], /*int capsule*/ qfalse );
return 0;
case CG_CM_TRANSFORMEDBOXTRACE:
CM_TransformedBoxTrace( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMA( 4 ), VMA( 5 ), args[6], args[7], VMA( 8 ), VMA( 9 ), /*int capsule*/ qfalse );
return 0;
case CG_CM_CAPSULETRACE:
CM_BoxTrace( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMA( 4 ), VMA( 5 ), args[6], args[7], /*int capsule*/ qtrue );
return 0;
case CG_CM_TRANSFORMEDCAPSULETRACE:
CM_TransformedBoxTrace( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMA( 4 ), VMA( 5 ), args[6], args[7], VMA( 8 ), VMA( 9 ), /*int capsule*/ qtrue );
return 0;
case CG_CM_MARKFRAGMENTS:
return re.MarkFragments( args[1], VMA( 2 ), VMA( 3 ), args[4], VMA( 5 ), args[6], VMA( 7 ) );
case CG_S_STARTSOUND:
S_StartSound( VMA( 1 ), args[2], args[3], args[4] );
return 0;
//----(SA) added
//.........这里部分代码省略.........
示例7: _WriteAt
/*********************************************************************
*
* _WriteAt
*/
static int _WriteAt (void * hFile, void *pBuffer, U32 Pos, U32 NumBytes) {
_InitIfRequired(); // Perform automatic initialisation so that explicit call to FS_Init is not required
FS_FSeek((FS_FILE*) hFile, Pos, FS_SEEK_SET);
return FS_Write((FS_FILE*) hFile, pBuffer, NumBytes);
}
示例8: CL_cURL_CallbackWrite
static size_t CL_cURL_CallbackWrite(void *buffer, size_t size, size_t nmemb,
void *stream)
{
FS_Write( buffer, size*nmemb, ((fileHandle_t*)stream)[0] );
return size*nmemb;
}
示例9: Cvar_WriteVariables
void Cvar_WriteVariables( fileHandle_t f ) {
#if 0
cvar_t *var;
char buffer[1024];
for (var = cvar_vars ; var ; var = var->next) {
if( Q_stricmp( var->name, "cl_cdkey" ) == 0 ) {
continue;
}
if( var->flags & CVAR_ARCHIVE ) {
// write the latched value, even if it hasn't taken effect yet
if ( var->latchedString ) {
Com_sprintf (buffer, sizeof(buffer), "seta %s \"%s\"\n", var->name, var->latchedString);
} else {
Com_sprintf (buffer, sizeof(buffer), "seta %s \"%s\"\n", var->name, var->string);
}
FS_Printf (f, "%s", buffer);
}
}
#else
cvar_t *var;
char buffer[MAX_STRING_CHARS] = {0};
int i=0, writeCount=0, totalCount=0, size=0;
cvarSerialise_t *list = NULL, *listPtr = NULL;
for ( var=cvar_vars; var; var=var->next ) {
char *value = var->latchedString ? var->latchedString : var->string;
if ( var->name && (var->flags & CVAR_ARCHIVE/*) && (Q_stricmp( var->resetString, value )*/ || (var->flags&CVAR_USER_CREATED)) ) {
if ( strlen( var->name ) + strlen( var->latchedString ? var->latchedString : var->string ) + 9 >= sizeof( buffer ) )
continue;
writeCount++;
}
totalCount++;
}
// allocate the working space for sorting
size = sizeof( cvarSerialise_t ) * writeCount;
list = (cvarSerialise_t *)Z_Malloc( size );
memset( list, 0, size );
for ( var=cvar_vars, listPtr=list; var; var=var->next ) {
char *value = var->latchedString ? var->latchedString : var->string;
if ( var->name && (var->flags & CVAR_ARCHIVE/*) && (Q_stricmp( var->resetString, value )*/ || (var->flags&CVAR_USER_CREATED)) ) {
if ( strlen( var->name ) + strlen( value ) + 9 >= sizeof( buffer ) ) {
Com_Printf( S_COLOR_YELLOW "WARNING: value of variable \"%s\" too long to write to file\n", var->name );
continue;
}
listPtr->name = var->name;
listPtr->value = value;
listPtr++;
}
}
qsort( list, writeCount, sizeof( cvarSerialise_t ), cvarSort );
for ( i=0, listPtr=list; i<writeCount; i++, listPtr++ ) {
Com_sprintf( buffer, sizeof( buffer ), "seta %s \"%s\"\n", listPtr->name, listPtr->value );
FS_Write( buffer, (int)strlen( buffer ), f );
}
Com_DPrintf( "Wrote %i/%i cvars to file\n", writeCount, totalCount );
Z_Free( list );
list = listPtr = NULL;
#endif
}
示例10: aud_trim_event_callback_hdlr
/*****************************************************************************
* FUNCTION
* aud_trim_event_callback_hdlr
* DESCRIPTION
* This function is used to handle the callback events from L1Audio.
* PARAMETERS
*
* RETURNS
* void
*****************************************************************************/
void aud_trim_event_callback_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint8* buf_p = NULL;
kal_uint32 buf_len; /* 2 bytes per unit */
kal_uint32 len; /* 1 byte per unit */
kal_int32 fs_result = FS_NO_ERROR;
kal_int32 med_result = MED_RES_OK;
l4aud_trim_event_ind_struct* ind_p = (l4aud_trim_event_ind_struct*) ilm_ptr->local_para_ptr;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* Validate event */
if ((ind_p->handle != (kal_uint32)g_trim_ctx.mhdl_handle_p) ||
(g_trim_ctx.state != AUD_TRIM_STATE_TRIM))
{
_AUD_TRIM_TRACE(ind_p->handle, g_trim_ctx.mhdl_handle_p, g_trim_ctx.state);
return;
}
_AUD_TRIM_TRACE(ind_p->handle, ind_p->event, -1);
switch (ind_p->event)
{
case MEDIA_DATA_NOTIFICATION:
{
/* Get read buffer from L1Audio */
g_trim_ctx.mhdl_handle_p->GetReadBuffer(g_trim_ctx.mhdl_handle_p, &buf_p, &buf_len);
if (buf_len > 0)
{
ASSERT(buf_p != NULL);
/* Write to file system */
fs_result = FS_Write(g_trim_ctx.file_output,
buf_p,
buf_len,
&len);
_AUD_TRIM_TRACE(fs_result, buf_len, len);
if (fs_result == FS_NO_ERROR)
{
/* Update file offset */
g_trim_ctx.file_length += len;
_AUD_TRIM_TRACE(g_trim_ctx.file_output, g_trim_ctx.file_length, -1);
/* Sleep MED for a moment such that MMI may have chance to cancel the trimming */
kal_sleep_task(2);
/* Notify L1Audio how many bytes are read. L1audio will fire another MEDIA_DATA_NOTIFICATION
* event if there is more data to be trimmed.
*/
g_trim_ctx.mhdl_handle_p->ReadDataDone(g_trim_ctx.mhdl_handle_p, buf_len);
}
else
{
/* Stop the trimming */
_aud_trim_stop();
/* Notify MMI with failure reason */
switch (fs_result)
{
case FS_DISK_FULL:
med_result = MED_RES_DISC_FULL;
break;
case FS_MSDC_WRITE_SECTOR_ERROR:
case FS_MEDIA_CHANGED:
med_result = MED_RES_NO_DISC;
break;
default:
med_result = MED_RES_ERROR;
break;
}
_aud_trim_send_result( med_result);
}
}
break;
}
case MEDIA_END:
/* End of trimming */
_aud_trim_send_result(MED_RES_END_OF_FILE);
break;
default:
//.........这里部分代码省略.........
示例11: CL_CgameSystemCalls
/*
====================
CL_CgameSystemCalls
The cgame module is making a system call
====================
*/
intptr_t CL_CgameSystemCalls( intptr_t *args ) {
switch( args[0] ) {
case CG_PRINT:
Com_Printf( "%s", VMA(1) );
return 0;
case CG_FATAL_ERROR:
Com_Error( ERR_DROP, "%s", VMA(1) );
return 0;
case CG_MILLISECONDS:
return Sys_Milliseconds();
case CG_CVAR_REGISTER:
Cvar_Register( VMA(1), VMA(2), VMA(3), args[4] );
return 0;
case CG_CVAR_UPDATE:
Cvar_Update( VMA(1) );
return 0;
case CG_CVAR_SET:
Cvar_Set( VMA(1), VMA(2) );
return 0;
case CG_CVAR_VARIABLESTRINGBUFFER:
Cvar_VariableStringBuffer( VMA(1), VMA(2), args[3] );
return 0;
case CG_ARGC:
return Cmd_Argc();
case CG_ARGV:
Cmd_ArgvBuffer( args[1], VMA(2), args[3] );
return 0;
case CG_ARGVI:
return atoi( Cmd_Argv( args[1] ) );
case CG_ARGS:
Cmd_ArgsBuffer( VMA(1), args[2] );
return 0;
case CG_CMD_EXECUTETEXT:
Cbuf_ExecuteText( args[1], VMA(2) );
return 0;
case CG_FS_FOPENFILE:
return FS_FOpenFileByMode( VMA(1), VMA(2), args[3] );
case CG_FS_READ:
FS_Read( VMA(1), args[2], args[3] );
return 0;
case CG_FS_WRITE:
FS_Write( VMA(1), args[2], args[3] );
return 0;
case CG_FS_FCLOSEFILE:
FS_FCloseFile( args[1] );
return 0;
case CG_SENDCONSOLECOMMAND:
Cbuf_AddText( VMA(1) );
return 0;
case CG_FORWARDCOMMAND:
VM_Call( uivm, UI_CONSOLE_COMMAND, cls.realtime );
return 0;
case CG_ADDCOMMAND:
CL_AddCgameCommand( VMA(1) );
return 0;
case CG_REMOVECOMMAND:
Cmd_RemoveCommand( VMA(1) );
return 0;
case CG_SENDCLIENTCOMMAND:
CL_AddReliableCommand( VMA(1) );
return 0;
case CG_UPDATESCREEN:
// this is used during lengthy level loading, so pump message loop
// Com_EventLoop(); // FIXME: if a server restarts here, BAD THINGS HAPPEN!
// We can't call Com_EventLoop here, a restart will crash and this _does_ happen
// if there is a map change while we are downloading at pk3.
// ZOID
SCR_UpdateScreen();
return 0;
case CG_CM_LOADMAP:
CL_CM_LoadMap( VMA(1) );
return 0;
case CG_CM_NUMINLINEMODELS:
return CM_NumInlineModels();
case CG_CM_INLINEMODEL:
return CM_InlineModel( args[1] );
case CG_CM_TEMPBOXMODEL:
return CM_TempBoxModel( VMA(1), VMA(2), /*int capsule*/ qfalse );
case CG_CM_TEMPCAPSULEMODEL:
return CM_TempBoxModel( VMA(1), VMA(2), /*int capsule*/ qtrue );
case CG_CM_POINTCONTENTS:
return CM_PointContents( VMA(1), args[2] );
case CG_CM_TRANSFORMEDPOINTCONTENTS:
return CM_TransformedPointContents( VMA(1), args[2], VMA(3), VMA(4) );
case CG_CM_BOXTRACE:
CM_BoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qfalse );
return 0;
case CG_CM_CAPSULETRACE:
CM_BoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qtrue );
return 0;
case CG_CM_TRANSFORMEDBOXTRACE:
CM_TransformedBoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule*/ qfalse );
return 0;
//.........这里部分代码省略.........
示例12: SV_GameSystemCalls
/*
====================
SV_GameSystemCalls
The module is making a system call
====================
*/
intptr_t SV_GameSystemCalls(intptr_t * args) {
switch (args[0]) {
case G_PRINT:
Com_Printf("%s", (char *)VMA(1));
return 0;
case G_ERROR:
Com_Error(ERR_DROP, "%s", (char *)VMA(1));
return 0;
case G_MILLISECONDS:
return Sys_Milliseconds();
case G_CVAR_REGISTER:
Cvar_Register((vmCvar_t*)VMA(1), (char*)VMA(2), (char*)VMA(3), args[4]);
return 0;
case G_CVAR_UPDATE:
Cvar_Update((vmCvar_t*)VMA(1));
return 0;
case G_CVAR_SET:
Cvar_Set((const char *)VMA(1), (const char *)VMA(2));
return 0;
case G_CVAR_VARIABLE_INTEGER_VALUE:
return Cvar_VariableIntegerValue((const char *)VMA(1));
case G_CVAR_VARIABLE_STRING_BUFFER:
Cvar_VariableStringBuffer((char *)VMA(1), (char*)VMA(2), args[3]);
return 0;
case G_CVAR_LATCHEDVARIABLESTRINGBUFFER:
Cvar_LatchedVariableStringBuffer((char *)VMA(1), (char*)VMA(2), args[3]);
return 0;
case G_ARGC:
return Cmd_Argc();
case G_ARGV:
Cmd_ArgvBuffer(args[1], (char*)VMA(2), args[3]);
return 0;
case G_SEND_CONSOLE_COMMAND:
Cbuf_ExecuteText(args[1], (char *)VMA(2));
return 0;
case G_FS_FOPEN_FILE:
return FS_FOpenFileByMode((char *)VMA(1), (fileHandle_t*)VMA(2), (fsMode_t)args[3]);
case G_FS_READ:
FS_Read2(VMA(1), args[2], args[3]);
return 0;
case G_FS_WRITE:
return FS_Write(VMA(1), args[2], args[3]);
case G_FS_RENAME:
FS_Rename((char *)VMA(1), (char *)VMA(2));
return 0;
case G_FS_FCLOSE_FILE:
FS_FCloseFile(args[1]);
return 0;
case G_FS_GETFILELIST:
return FS_GetFileList((char *)VMA(1), (char *)VMA(2), (char*)VMA(3), args[4]);
case G_LOCATE_GAME_DATA:
SV_LocateGameData((sharedEntity_t*)VMA(1), args[2], args[3], (playerState_t*)VMA(4), args[5]);
return 0;
case G_DROP_CLIENT:
SV_GameDropClient(args[1], (char*)VMA(2), args[3]);
return 0;
case G_SEND_SERVER_COMMAND:
SV_GameSendServerCommand(args[1], (char*)VMA(2));
return 0;
case G_LINKENTITY:
SV_LinkEntity((sharedEntity_t*)VMA(1));
return 0;
case G_UNLINKENTITY:
SV_UnlinkEntity((sharedEntity_t*)VMA(1));
return 0;
case G_ENTITIES_IN_BOX:
return SV_AreaEntities((float*)VMA(1), (float*)VMA(2), (int*)VMA(3), args[4]);
case G_ENTITY_CONTACT:
return SV_EntityContact((float*)VMA(1), (float*)VMA(2), (sharedEntity_t*)VMA(3), TT_AABB);
case G_ENTITY_CONTACTCAPSULE:
return SV_EntityContact((float*)VMA(1), (float*)VMA(2), (sharedEntity_t*)VMA(3), TT_CAPSULE);
case G_TRACE:
SV_Trace((trace_t*)VMA(1), (float*)VMA(2), (float*)VMA(3), (float*)VMA(4), (float*)VMA(5), args[6], args[7], TT_AABB);
return 0;
case G_TRACECAPSULE:
SV_Trace((trace_t*)VMA(1), (float*)VMA(2), (float*)VMA(3), (float*)VMA(4), (float*)VMA(5), args[6], args[7], TT_CAPSULE);
return 0;
case G_POINT_CONTENTS:
return SV_PointContents((float*)VMA(1), args[2]);
case G_SET_BRUSH_MODEL:
SV_SetBrushModel((sharedEntity_t*)VMA(1), (char*)VMA(2));
return 0;
case G_IN_PVS:
return SV_inPVS((float*)VMA(1), (float*)VMA(2));
case G_IN_PVS_IGNORE_PORTALS:
return SV_inPVSIgnorePortals((float*)VMA(1), (float*)VMA(2));
case G_SET_CONFIGSTRING:
SV_SetConfigstring(args[1], (char*)VMA(2));
return 0;
case G_GET_CONFIGSTRING:
SV_GetConfigstring(args[1], (char*)VMA(2), args[3]);
return 0;
case G_SET_CONFIGSTRING_RESTRICTIONS:
//.........这里部分代码省略.........
示例13: Com_Frame
//.........这里部分代码省略.........
timeBeforeClient = Sys_Milliseconds ();
}
CL_Frame (msec, fractionMsec);
if ( com_speeds->integer ) {
timeAfter = Sys_Milliseconds ();
}
}
//
// report timing information
//
if ( com_speeds->integer ) {
int all, sv, ev, cl;
all = timeAfter - timeBeforeServer;
sv = timeBeforeEvents - timeBeforeServer;
ev = timeBeforeServer - timeBeforeFirstEvents + timeBeforeClient - timeBeforeEvents;
cl = timeAfter - timeBeforeClient;
sv -= time_game;
cl -= time_frontend + time_backend;
Com_Printf("fr:%i all:%3i sv:%3i ev:%3i cl:%3i gm:%3i tr:%3i pvs:%3i rf:%3i bk:%3i\n",
com_frameNumber, all, sv, ev, cl, time_game, timeInTrace, timeInPVSCheck, time_frontend, time_backend);
// speedslog
if ( com_speedslog && com_speedslog->integer )
{
if(!speedslog)
{
speedslog = FS_FOpenFileWrite("speeds.log");
FS_Write("data={\n", strlen("data={\n"), speedslog);
bComma=false;
if ( com_speedslog->integer > 1 )
{
// force it to not buffer so we get valid
// data even if we are crashing
FS_ForceFlush(logfile);
}
}
if (speedslog)
{
char msg[MAXPRINTMSG];
if(bComma)
{
FS_Write(",\n", strlen(",\n"), speedslog);
bComma=false;
}
FS_Write("{", strlen("{"), speedslog);
Com_sprintf(msg,sizeof(msg),
"%8.4f,%8.4f,%8.4f,%8.4f,%8.4f,%8.4f,",corg[0],corg[1],corg[2],cangles[0],cangles[1],cangles[2]);
FS_Write(msg, strlen(msg), speedslog);
Com_sprintf(msg,sizeof(msg),
"%i,%3i,%3i,%3i,%3i,%3i,%3i,%3i,%3i,%3i}",
com_frameNumber, all, sv, ev, cl, time_game, timeInTrace, timeInPVSCheck, time_frontend, time_backend);
FS_Write(msg, strlen(msg), speedslog);
bComma=true;
}
}
timeInTrace = timeInPVSCheck = 0;
}
示例14: demoConvert
//.........这里部分代码省略.........
char *dst;
if (workFrame->commandUsed + len + 1 > sizeof( workFrame->commandData)) {
Com_Printf("Overflowed state command data.\n");
goto conversionerror;
}
dst = workFrame->commandData + workFrame->commandUsed;
*dst = clientNum;
Com_Memcpy( dst+1, s, len );
workFrame->commandUsed += len + 1;
}
break;
case svc_gamestate:
if (newHandle) {
FS_FCloseFile( newHandle );
newHandle = 0;
}
if (levelCount) {
Com_sprintf( newName, sizeof( newName ), "%s.%d.mme", newBaseName, levelCount );
} else {
Com_sprintf( newName, sizeof( newName ), "%s.mme", newBaseName );
}
fullTime = -1;
clientNum = -1;
oldTime = -1;
Com_Memset( convert, 0, sizeof( *convert ));
convert->frames[0].string.used = 1;
levelCount++;
newHandle = FS_FOpenFileWrite( newName );
if (!newHandle) {
Com_Printf("Failed to open %s for target conversion target.\n", newName);
goto conversionerror;
return;
} else {
FS_Write ( demoHeader, strlen( demoHeader ), newHandle );
}
Com_sprintf( newName, sizeof( newName ), "%s.txt", newBaseName );
workFrame = &convert->frames[ convert->frameIndex % DEMOCONVERTFRAMES ];
msgSequence = MSG_ReadLong( &oldMsg );
while( 1 ) {
cmd = MSG_ReadByte( &oldMsg );
if (cmd == svc_EOF)
break;
if ( cmd == svc_configstring) {
int num;
const char *s;
num = MSG_ReadShort( &oldMsg );
s = MSG_ReadBigString( &oldMsg );
demoFrameAddString( &workFrame->string, num, s );
} else if ( cmd == svc_baseline ) {
int num = MSG_ReadBits( &oldMsg, GENTITYNUM_BITS );
if ( num < 0 || num >= MAX_GENTITIES ) {
Com_Printf( "Baseline number out of range: %i.\n", num );
goto conversionerror;
}
MSG_ReadDeltaEntity( &oldMsg, &demoNullEntityState, &convert->entityBaselines[num], num );
} else {
Com_Printf( "Unknown block while converting demo gamestate.\n" );
goto conversionerror;
}
}
clientNum = MSG_ReadLong( &oldMsg );
/* Skip the checksum feed */
MSG_ReadLong( &oldMsg );
break;
case svc_snapshot:
nextTime = MSG_ReadLong( &oldMsg );
示例15: CL_ParseDownload
//.........这里部分代码省略.........
// we'll let the server disconnect us when it gets the bbl8r message
if (clc.downloadFlags & (1 << DL_FLAG_DISCON))
{
CL_AddReliableCommand("wwwdl bbl8r");
cls.bWWWDlDisconnected = qtrue;
}
return;
}
else
{
// server keeps sending that message till we ack it, eat and ignore
//MSG_ReadLong( msg );
MSG_ReadString(msg);
MSG_ReadLong(msg);
MSG_ReadLong(msg);
return;
}
}
if (!block)
{
// block zero is special, contains file size
clc.downloadSize = MSG_ReadLong(msg);
Cvar_SetValue("cl_downloadSize", clc.downloadSize);
if (clc.downloadSize < 0)
{
Com_Error(ERR_DROP, "%s", MSG_ReadString(msg));
return;
}
}
size = MSG_ReadShort(msg);
if (size < 0 || size > sizeof(data))
{
Com_Error(ERR_DROP, "CL_ParseDownload: Invalid size %d for download chunk.", size);
return;
}
MSG_ReadData(msg, data, size);
if (clc.downloadBlock != block)
{
Com_DPrintf("CL_ParseDownload: Expected block %d, got %d\n", clc.downloadBlock, block);
return;
}
// open the file if not opened yet
if (!clc.download)
{
clc.download = FS_SV_FOpenFileWrite(cls.downloadTempName);
if (!clc.download)
{
Com_Printf("Could not create %s\n", cls.downloadTempName);
CL_AddReliableCommand("stopdl");
CL_NextDownload();
return;
}
}
if (size)
{
FS_Write(data, size, clc.download);
}
CL_AddReliableCommand(va("nextdl %d", clc.downloadBlock));
clc.downloadBlock++;
clc.downloadCount += size;
// So UI gets access to it
Cvar_SetValue("cl_downloadCount", clc.downloadCount);
if (!size) // A zero length block means EOF
{
if (clc.download)
{
FS_FCloseFile(clc.download);
clc.download = 0;
// rename the file
FS_SV_Rename(cls.downloadTempName, cls.downloadName);
}
*cls.downloadTempName = *cls.downloadName = 0;
Cvar_Set("cl_downloadName", "");
// send intentions now
// We need this because without it, we would hold the last nextdl and then start
// loading right away. If we take a while to load, the server is happily trying
// to send us that last block over and over.
// Write it twice to help make sure we acknowledge the download
CL_WritePacket();
CL_WritePacket();
// get another file if needed
CL_NextDownload();
}
}