这篇教程C++ FS_Seek函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中FS_Seek函数的典型用法代码示例。如果您正苦于以下问题:C++ FS_Seek函数的具体用法?C++ FS_Seek怎么用?C++ FS_Seek使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了FS_Seek函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: FS_FOpenFile/** CM_LoadMapMessage*/char *CM_LoadMapMessage( char *name, char *message, int size ){ int file, len; qbyte h_v[8]; char *data, *entitystring; lump_t l; qboolean isworld; char key[MAX_KEY], value[MAX_VALUE], *token; const modelFormatDescr_t *descr; const bspFormatDesc_t *bspFormat = NULL; *message = '/0'; len = FS_FOpenFile( name, &file, FS_READ ); if( !file || len < 1 ) { if( file ) FS_FCloseFile( file ); return message; } FS_Read( h_v, 4 + sizeof( int ), file ); descr = Com_FindFormatDescriptor( cm_supportedformats, h_v, &bspFormat ); if( !descr ) { Com_Printf( "CM_LoadMapMessage: %s: unknown bsp format/n", name ); FS_FCloseFile( file ); return message; } FS_Seek( file, descr->headerLen + sizeof( int ) + sizeof( lump_t ) * bspFormat->entityLumpNum, FS_SEEK_SET ); FS_Read( &l.fileofs, sizeof( l.fileofs ), file ); l.fileofs = LittleLong( l.fileofs ); FS_Read( &l.filelen, sizeof( l.filelen ), file ); l.filelen = LittleLong( l.filelen ); if( !l.filelen ) { FS_FCloseFile( file ); return message; } FS_Seek( file, l.fileofs, FS_SEEK_SET ); entitystring = Mem_TempMalloc( l.filelen ); FS_Read( entitystring, l.filelen, file ); FS_FCloseFile( file ); for( data = entitystring; ( token = COM_Parse( &data ) ) && token[0] == '{'; ) { isworld = qtrue; while( 1 ) { token = COM_Parse( &data ); if( !token[0] || token[0] == '}' ) break; // end of entity Q_strncpyz( key, token, sizeof( key ) ); while( key[strlen( key )-1] == ' ' ) // remove trailing spaces key[strlen( key )-1] = 0; token = COM_Parse( &data ); if( !token[0] ) break; // error Q_strncpyz( value, token, sizeof( value ) ); // now that we have the key pair worked out... if( !strcmp( key, "classname" ) ) { if( strcmp( value, "worldspawn" ) ) isworld = qfalse; } else if( !strcmp( key, "message" ) ) { Q_strncpyz( message, token, size ); break; } } if( isworld ) break; } Mem_Free( entitystring ); return message;}
开发者ID:Kaperstone,项目名称:warsow,代码行数:95,
示例2: GPSLocateNvramLoadDefaultstatic kal_bool GPSLocateNvramLoadDefault(FS_HANDLE file_handle, kal_bool newCreate){ int result; unsigned int len; GPSLocateNvramDataStruct_t tmpCache; char default_passwd[GPSLOCATE_PRESAVED_PASSWORD_BUFFER_LEN]; int i; unsigned char* pBuff; if (newCreate == KAL_TRUE) { memset(&tmpCache, 0x00, sizeof(GPSLocateNvramDataStruct_t)); } else { //read from the original file FS_Seek(file_handle, 0, FS_FILE_BEGIN); result = FS_Read(file_handle, &tmpCache, sizeof(GPSLocateNvramDataStruct_t), &len); if (result != FS_NO_ERROR || len != sizeof(GPSLocateNvramDataStruct_t)) { //read fail return KAL_FALSE; } } //set version number tmpCache.Buff[0] = GPSLOCATE_NVRAM_VER_NO; //set default passord to all zero(ascii '0') for (i = 0; i < GPSLOCATE_PRESAVED_PASSWORD_BUFFER_LEN-1; i++) { default_passwd[i] = GPSLOCATE_NVRAMDATA_DEFAULT_PWD_CHAR; } default_passwd[GPSLOCATE_PRESAVED_PASSWORD_BUFFER_LEN-1] = 0x00; //find service password space in the data structure pBuff = tmpCache.Buff + GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_SERVICEPASSWORD); //set service password memcpy(pBuff, default_passwd, GPSLOCATE_PRESAVED_PASSWORD_BUFFER_LEN); //find user password space in the data structure pBuff = tmpCache.Buff + GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_USERPASSWORD); //set user password one by one for (i = 0; i < GPSLOCATE_USER_PASSWORD_MAX; i++) { memcpy(pBuff, default_passwd, GPSLOCATE_PRESAVED_PASSWORD_BUFFER_LEN); pBuff += GPSLOCATE_PRESAVED_PASSWORD_BUFFER_LEN; } //find service number space in the data structure pBuff = tmpCache.Buff + GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_SERVICENUMBER); //set service number to null memset(pBuff, 0, GPSLOCATE_PRESAVED_NUMBER_BUFFER_LEN); //find user number space in the data structure pBuff = tmpCache.Buff + GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_USERNUMBER); //set user number to null one by one for (i = 0; i < GPSLOCATE_USER_NUMBER_MAX; i++) { memset(pBuff, 0, GPSLOCATE_PRESAVED_NUMBER_BUFFER_LEN); pBuff += GPSLOCATE_PRESAVED_NUMBER_BUFFER_LEN; } //find timing number space in the data structure pBuff = tmpCache.Buff + GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_TIMINGNUMBER); //set timing number to null memset(pBuff, 0, GPSLOCATE_PRESAVED_NUMBER_BUFFER_LEN); tmpCache.Buff[GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_BSNUMBER)] = 1; tmpCache.Buff[GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_SETTINGS)] = GPSLOCATE_NVRAMDATA_DEFAULT_TMSETTING; tmpCache.Buff[GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_GPSONSETTING)] = 0; tmpCache.Buff[GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_HFREEONSETTING)] = 0; tmpCache.Buff[GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_GPRSUPLOADSETTING)] = 0; tmpCache.Buff[GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_DEFENCEONSETTING)] = 0; tmpCache.Buff[GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_MTCALLPROFILE)] = 0; tmpCache.Buff[GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_SOSPHONECALL)] = 1; //find gprs user space in the data structure pBuff = tmpCache.Buff + GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_GPRSUSER); //set service number to "PS" strcpy((char *)pBuff, "V300Q"); //find gprs password space in the data structure pBuff = tmpCache.Buff + GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_GPRSPASSWORD); //set gprs password memcpy(pBuff, default_passwd, GPSLOCATE_PRESAVED_PASSWORD_BUFFER_LEN); //find server address space in the data structure pBuff = tmpCache.Buff + GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_SERVERADDR); //set server address to zero memset(pBuff, 0, sizeof(GPSLocateServerAddr_t)); tmpCache.Buff[GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_POSMONITORONFF)] = 0; //find fixed position in the data structure pBuff = tmpCache.Buff + GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_FIXEDPOSITION); //set fixed position to zero memset(pBuff, 0, sizeof(GPS_PostionRange_t)); if (newCreate == KAL_TRUE) { //load default value for the follwoing item only when new creating tmpCache.Buff[GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_BEARERMODE)] = GPSLOCATE_NVRAMDATA_DEFAULT_BEARERMODE; } //find gprs apn in the data structure pBuff = tmpCache.Buff + GPSLocateNvramGetRecOffset(GPS_NVRAM_RECID_GPRSAPN); strcpy((char *)pBuff, "CMNET"); //find gprs apn user in the data structure//.........这里部分代码省略.........
开发者ID:robbie-cao,项目名称:tracker,代码行数:101,
示例3: CL_CgameSystemCalls/*====================CL_CgameSystemCallsThe 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_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_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_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; 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://.........这里部分代码省略.........
开发者ID:PropheteMath,项目名称:OpenArenaBB,代码行数:101,
示例4: CL_DemoReadMessage/*=================CL_DemoReadMessagereads demo data and write it to client=================*/qboolean CL_DemoReadMessage( byte *buffer, size_t *length ){ float f = 0.0f; int curpos = 0; float fElapsedTime = 0.0f; qboolean swallowmessages = true; byte *userbuf = NULL; size_t size; byte cmd; if( !cls.demofile ) { MsgDev( D_ERROR, "tried to read a demo message with no demo file/n" ); CL_DemoCompleted(); return false; } // HACKHACK: changedemo issues if( !cls.netchan.remote_address.type ) cls.netchan.remote_address.type = NA_LOOPBACK; if(( !cl.background && ( cl.refdef.paused || cls.key_dest != key_game )) || cls.key_dest == key_console ) { demo.starttime += host.frametime; return false; // paused } do { qboolean bSkipMessage = false; if( !cls.demofile ) break; curpos = FS_Tell( cls.demofile ); CL_ReadDemoCmdHeader( &cmd, &f ); fElapsedTime = CL_GetDemoPlaybackClock() - demo.starttime; bSkipMessage = (f >= fElapsedTime) ? true : false; if( cls.changelevel ) demo.framecount = 1; // HACKHACK: changelevel issues if( demo.framecount <= 10 && ( fElapsedTime - f ) > host.frametime ) demo.starttime = CL_GetDemoPlaybackClock(); // not ready for a message yet, put it back on the file. if( cmd != dem_norewind && cmd != dem_stop && bSkipMessage ) { // never skip first message if( demo.framecount != 0 ) { FS_Seek( cls.demofile, curpos, SEEK_SET ); return false; // not time yet. } } // COMMAND HANDLERS switch( cmd ) { case dem_jumptime: demo.starttime = CL_GetDemoPlaybackClock(); break; case dem_stop: CL_DemoMoveToNextSection(); break; case dem_userdata: FS_Read( cls.demofile, &size, sizeof( int )); userbuf = Mem_Alloc( cls.mempool, size ); FS_Read( cls.demofile, userbuf, size ); if( clgame.hInstance ) clgame.dllFuncs.pfnDemo_ReadBuffer( size, userbuf ); Mem_Free( userbuf ); userbuf = NULL; break; case dem_usercmd: CL_ReadDemoUserCmd( false ); break; default: swallowmessages = false; break; } } while( swallowmessages ); if( !cls.demofile ) return false; // if not on "LOADING" section, check a few things if( demo.entryIndex ) { // We are now on the second frame of a new section, // if so, reset start time (unless in a timedemo)//.........这里部分代码省略.........
开发者ID:nekonomicon,项目名称:xash3d,代码行数:101,
示例5: _GeoIP_seek_recordunsigned int _GeoIP_seek_record ( unsigned long ipnum ) { fileHandle_t file; int depth; unsigned int x; unsigned char stack_buffer[2 * MAX_RECORD_LENGTH]; const unsigned char *buf = stack_buffer; unsigned int offset = 0; const unsigned char * p; int j; FS_SV_FOpenFileRead("GeoIP.dat", &file); if(!file){ Com_Printf("File Read error./n"); return 0; }/* unsigned char *data; = malloc(1024*1024*2); if(!FS_Seek(file, 0, SEEK_SET)){ FS_Read(data , 1024*1024*2, file); }*/ unsigned int foffset; for (depth = 31; depth >= 0; depth--) { /* read from disk */ foffset = (long)RECORD_LENGTH * 2 *offset; if(!FS_Seek(file, foffset, FS_SEEK_SET)){ FS_Read(stack_buffer , RECORD_LENGTH * 2, file); } /* simply point to record in memory */// buf = data + (long)RECORD_LENGTH * 2 *offset; if (ipnum & (1 << depth)) { /* Take the right-hand branch */ if ( RECORD_LENGTH == 3 ) { /* Most common case is completely unrolled and uses constants. */ x = (buf[3*1 + 0] << (0*8)) + (buf[3*1 + 1] << (1*8)) + (buf[3*1 + 2] << (2*8)); } else { /* General case */ j = RECORD_LENGTH; p = &buf[2*j]; x = 0; do { x <<= 8; x += *(--p); } while ( --j ); } } else { /* Take the left-hand branch */ if ( RECORD_LENGTH == 3 ) { /* Most common case is completely unrolled and uses constants. */ x = (buf[3*0 + 0] << (0*8)) + (buf[3*0 + 1] << (1*8)) + (buf[3*0 + 2] << (2*8)); } else { /* General case */ j = RECORD_LENGTH; p = &buf[1*j]; x = 0; do { x <<= 8; x += *(--p); } while ( --j ); } } if (x >= BEGIN_OFFSET) { //gi->netmask = gl->netmask = 32 - depth; FS_FCloseFile(file); return x - BEGIN_OFFSET; } offset = x; } /* shouldn't reach here */ Com_PrintError("Traversing Database for ipnum = %lu - Perhaps database is corrupt?/n",ipnum); FS_FCloseFile(file); return 0;}
开发者ID:BraXi,项目名称:CoD4X18-Server,代码行数:84,
示例6: CL_PlayDemo_f/*====================CL_PlayDemo_fplaydemo <demoname>====================*/void CL_PlayDemo_f( void ){ string filename; string demoname; int i; if( Cmd_Argc() != 2 ) { Msg( "Usage: playdemo <demoname>/n" ); return; } if( cls.demoplayback ) { CL_StopPlayback(); } if( cls.demorecording ) { Msg( "Can't playback during demo record./n"); return; } Q_strncpy( demoname, Cmd_Argv( 1 ), sizeof( demoname ) - 1 ); Q_snprintf( filename, sizeof( filename ), "demos/%s.dem", demoname ); if( !FS_FileExists( filename, true )) { MsgDev( D_ERROR, "couldn't open %s/n", filename ); cls.demonum = -1; // stop demo loop return; } cls.demofile = FS_Open( filename, "rb", true ); Q_strncpy( cls.demoname, demoname, sizeof( cls.demoname )); Q_strncpy( menu.globals->demoname, demoname, sizeof( menu.globals->demoname )); // read in the m_DemoHeader FS_Read( cls.demofile, &demo.header, sizeof( demoheader_t )); if( demo.header.id != IDEMOHEADER ) { MsgDev( D_ERROR, "%s is not a demo file/n", filename ); FS_Close( cls.demofile ); cls.demofile = NULL; cls.demonum = -1; // stop demo loop return; } if( demo.header.net_protocol != PROTOCOL_VERSION || demo.header.dem_protocol != DEMO_PROTOCOL ) { MsgDev( D_ERROR, "demo protocol outdated/n" "Demo file protocols Network(%i), Demo(%i)/n" "Server protocol is at Network(%i), Demo(%i)/n", demo.header.net_protocol, demo.header.dem_protocol, PROTOCOL_VERSION, DEMO_PROTOCOL ); FS_Close( cls.demofile ); cls.demofile = NULL; cls.demonum = -1; // stop demo loop return; } // now read in the directory structure. FS_Seek( cls.demofile, demo.header.directory_offset, SEEK_SET ); FS_Read( cls.demofile, &demo.directory.numentries, sizeof( int )); if( demo.directory.numentries < 1 || demo.directory.numentries > 1024 ) { MsgDev( D_ERROR, "demo had bogus # of directory entries: %i/n", demo.directory.numentries ); FS_Close( cls.demofile ); cls.demofile = NULL; cls.demonum = -1; // stop demo loop cls.changedemo = false; return; } if( cls.changedemo ) { S_StopAllSounds(); SCR_BeginLoadingPlaque( false ); CL_ClearState (); CL_InitEdicts (); // re-arrange edicts } else { // NOTE: at this point demo is still valid CL_Disconnect(); Host_ShutdownServer();//.........这里部分代码省略.........
开发者ID:nekonomicon,项目名称:xash3d,代码行数:101,
示例7: CL_UISystemCalls/*====================CL_UISystemCallsThe ui module is making a system call====================*/int CL_UISystemCalls( int *args ) { switch( args[0] ) { case UI_ERROR: Com_Error( ERR_DROP, "%s", VMA(1) ); return 0; case UI_PRINT: Com_Printf( "%s", VMA(1) ); return 0; case UI_MILLISECONDS: return Sys_Milliseconds(); case UI_CVAR_REGISTER: Cvar_Register( VMA(1), VMA(2), VMA(3), args[4] ); return 0; case UI_CVAR_UPDATE: Cvar_Update( VMA(1) ); return 0; case UI_CVAR_SET: Cvar_Set( VMA(1), VMA(2) ); return 0; case UI_CVAR_VARIABLEVALUE: return FloatAsInt( Cvar_VariableValue( VMA(1) ) ); case UI_CVAR_VARIABLESTRINGBUFFER: Cvar_VariableStringBuffer( VMA(1), VMA(2), args[3] ); return 0; case UI_CVAR_SETVALUE: Cvar_SetValue( VMA(1), VMF(2) ); return 0; case UI_CVAR_RESET: Cvar_Reset( VMA(1) ); return 0; case UI_CVAR_CREATE: Cvar_Get( VMA(1), VMA(2), args[3] ); return 0; case UI_CVAR_INFOSTRINGBUFFER: Cvar_InfoStringBuffer( args[1], VMA(2), args[3] ); return 0; case UI_ARGC: return Cmd_Argc(); case UI_ARGV: Cmd_ArgvBuffer( args[1], VMA(2), args[3] ); return 0; case UI_CMD_EXECUTETEXT: Cbuf_ExecuteText( args[1], VMA(2) ); return 0; case UI_FS_FOPENFILE: return FS_FOpenFileByMode( VMA(1), VMA(2), args[3] ); case UI_FS_READ: FS_Read2( VMA(1), args[2], args[3] ); return 0; case UI_FS_WRITE: FS_Write( VMA(1), args[2], args[3] ); return 0; case UI_FS_FCLOSEFILE: FS_FCloseFile( args[1] ); return 0; case UI_FS_GETFILELIST: return FS_GetFileList( VMA(1), VMA(2), VMA(3), args[4] ); case UI_FS_SEEK: return FS_Seek( args[1], args[2], args[3] ); case UI_R_REGISTERMODEL: return re.RegisterModel( VMA(1) ); case UI_R_REGISTERSKIN: return re.RegisterSkin( VMA(1) ); case UI_R_REGISTERSHADERNOMIP: return re.RegisterShaderNoMip( VMA(1) ); case UI_R_CLEARSCENE: re.ClearScene(); return 0;//.........这里部分代码省略.........
开发者ID:DaveHogan,项目名称:FQuake3,代码行数:101,
示例8: CL_CgameSystemCalls//.........这里部分代码省略......... return 0; case CG_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene( VMA( 1 ) ); return 0;#if defined( USE_REFLIGHT ) case CG_R_ADDREFLIGHTSTOSCENE: re.AddRefLightToScene( VMA( 1 ) ); return 0;#endif case CG_R_ADDPOLYTOSCENE: re.AddPolyToScene( args[ 1 ], args[ 2 ], VMA( 3 ) ); return 0; case CG_R_ADDPOLYSTOSCENE: re.AddPolysToScene( args[ 1 ], args[ 2 ], VMA( 3 ), args[ 4 ] ); return 0; case CG_R_ADDPOLYBUFFERTOSCENE: re.AddPolyBufferToScene( VMA( 1 ) ); return 0; case CG_R_ADDLIGHTTOSCENE: re.AddLightToScene( VMA( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), VMF( 6 ), args[ 7 ], args[ 8 ] ); return 0; case CG_R_ADDADDITIVELIGHTTOSCENE: re.AddAdditiveLightToScene( VMA( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ) ); return 0; case CG_FS_SEEK: return FS_Seek( args[ 1 ], args[ 2 ], args[ 3 ] ); case CG_R_ADDCORONATOSCENE: re.AddCoronaToScene( VMA( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), args[ 6 ], args[ 7 ] ); return 0; case CG_R_SETFOG: re.SetFog( args[ 1 ], args[ 2 ], args[ 3 ], VMF( 4 ), VMF( 5 ), VMF( 6 ), VMF( 7 ) ); return 0; case CG_R_SETGLOBALFOG: re.SetGlobalFog( args[ 1 ], args[ 2 ], VMF( 3 ), VMF( 4 ), VMF( 5 ), VMF( 6 ) ); return 0; case CG_R_RENDERSCENE: re.RenderScene( VMA( 1 ) ); return 0; case CG_R_SAVEVIEWPARMS: re.SaveViewParms(); return 0; case CG_R_RESTOREVIEWPARMS: re.RestoreViewParms(); return 0; case CG_R_SETCOLOR: re.SetColor( VMA( 1 ) ); return 0; // Tremulous case CG_R_SETCLIPREGION: re.SetClipRegion( VMA( 1 ) );
开发者ID:justhacking,项目名称:Unvanquished,代码行数:67,
示例9: CL_ParseDemo// Do very shallow parse of the demo (could be extended) just to get times and snapshot countstatic void CL_ParseDemo(void){ int tstart = 0; int demofile = 0; // Reset our demo data memset(&di, 0, sizeof(di)); // Parse start di.gameStartTime = -1; di.gameEndTime = -1; FS_Seek(clc.demofile, 0, FS_SEEK_SET); tstart = Sys_Milliseconds(); while (qtrue) { int r; msg_t buf; msg_t *msg; byte bufData[MAX_MSGLEN]; int s; int cmd; di.demoPos = FS_FTell(clc.demofile); // get the sequence number r = FS_Read(&s, 4, clc.demofile); if (r != 4) { CL_DemoCompleted(); return; } clc.serverMessageSequence = LittleLong(s); // init the message MSG_Init(&buf, bufData, sizeof(bufData)); // get the length r = FS_Read(&buf.cursize, 4, clc.demofile); if (r != 4) { break; } buf.cursize = LittleLong(buf.cursize); if (buf.cursize == -1) { break; } if (buf.cursize > buf.maxsize) { Com_FuncPrinf("demoMsglen > MAX_MSGLEN"); break; } r = FS_Read(buf.data, buf.cursize, clc.demofile); if (r != buf.cursize) { Com_FuncPrinf("Demo file was truncated./n"); break; } clc.lastPacketTime = cls.realtime; buf.readcount = 0; // parse msg = &buf; MSG_Bitstream(msg); // get the reliable sequence acknowledge number clc.reliableAcknowledge = MSG_ReadLong(msg); if (clc.reliableAcknowledge < clc.reliableSequence - MAX_RELIABLE_COMMANDS) { clc.reliableAcknowledge = clc.reliableSequence; } // parse the message while (qtrue) { if (msg->readcount > msg->cursize) { Com_FuncDrop("read past end of server message"); return; } cmd = MSG_ReadByte(msg); if (cmd == svc_EOF) { break; } // other commands switch (cmd) {//.........这里部分代码省略.........
开发者ID:dstaesse,项目名称:etlegacy,代码行数:101,
示例10: Com_ErrorboolMd3Utils::getModelDimensions( fileHandle_t const& file, vec3_t& mins, vec3_t& maxs, int checkFrame ){ if( !file ) { Com_Error(ERR_FATAL, "Invalid filehandle passed to Md3Utils::getModelDimensions/n" ); return false; } // put it back to beginning of file (just in case) if( FS_Seek( file, 0, FS_SEEK_SET ) != 0 ) { Com_Error(ERR_FATAL, "Unable to set file pointer in file!/n" ); return false; } bool found = false; // get body bounding boxes md3Header_t header; md3Frame_t currentFrame; FS_Read2(&header, sizeof(header), file); int number = header.numFrames; if( checkFrame >= number ) { Com_Error(ERR_FATAL, "File only has %d frames, therefore unable to check frame %d/n", number, checkFrame ); return false; } else if( checkFrame == FRAMESIZE_FIRST ) checkFrame = 0; else if( checkFrame == FRAMESIZE_LAST ) checkFrame = number - 1; found = true; for( int i = 0; i < number; ++i ) { FS_Read2(¤tFrame, sizeof(currentFrame), file); if( checkFrame >= 0 && i == checkFrame ) { VectorCopy( currentFrame.bounds[0], mins ); VectorCopy( currentFrame.bounds[1], maxs ); break; } else // check for all { if( i == 0 ) { VectorCopy( currentFrame.bounds[0], mins ); VectorCopy( currentFrame.bounds[1], maxs ); } else { if( currentFrame.bounds[0][0] < mins[0] ) mins[0] = currentFrame.bounds[0][0]; if( currentFrame.bounds[0][1] < mins[1] ) mins[1] = currentFrame.bounds[0][1]; if( currentFrame.bounds[0][2] < mins[2] ) mins[2] = currentFrame.bounds[0][2]; if( currentFrame.bounds[1][0] > maxs[0] ) maxs[0] = currentFrame.bounds[1][0]; if( currentFrame.bounds[1][1] > maxs[1] ) maxs[1] = currentFrame.bounds[1][1]; if( currentFrame.bounds[1][2] > maxs[2] ) maxs[2] = currentFrame.bounds[1][2]; } } } return found;}
开发者ID:MilitaryForces,项目名称:MilitaryForces,代码行数:78,
示例11: CL_PeekSnapshotqboolean CL_PeekSnapshot(int snapshotNumber, snapshot_t *snapshot){ clSnapshot_t *clSnap; clSnapshot_t csn; int i, count; int origPosition; int cmd; //char *s; char buffer[16]; qboolean success = qfalse; int r; msg_t buf; byte bufData[MAX_MSGLEN]; int j; int lastPacketTimeOrig; int parseEntitiesNumOrig; int currentSnapNum; //int serverMessageSequence; clSnap = &csn; if (!clc.demoplaying) { return qfalse; } if (snapshotNumber <= cl.snap.messageNum) { success = CL_GetSnapshot(snapshotNumber, snapshot); if (!success) { Com_FuncPrinf("snapshot number outside of backup buffer/n"); return qfalse; } return qtrue; } if (snapshotNumber > cl.snap.messageNum + 1) { Com_FuncPrinf("FIXME CL_PeekSnapshot %d > cl.snap.messageNum + 1 (%d)/n", snapshotNumber, cl.snap.messageNum); return qfalse; // FIXME: } parseEntitiesNumOrig = cl.parseEntitiesNum; lastPacketTimeOrig = clc.lastPacketTime; // CL_ReadDemoMessage() origPosition = FS_FTell(clc.demofile); if (origPosition < 0) { // FS_FTell prints the warning ... return qfalse; } currentSnapNum = cl.snap.messageNum; for (j = 0; j < snapshotNumber - currentSnapNum; j++) { // get the sequence number memset(buffer, 0, sizeof(buffer)); r = FS_Read(&buffer, 4, clc.demofile); if (r != 4) { Com_FuncPrinf("couldn't read sequence number/n"); FS_Seek(clc.demofile, origPosition, FS_SEEK_SET); clc.lastPacketTime = lastPacketTimeOrig; cl.parseEntitiesNum = parseEntitiesNumOrig; return qfalse; } //serverMessageSequence = LittleLong(*((int *)buffer)); // init the message memset(&buf, 0, sizeof(msg_t)); MSG_Init(&buf, bufData, sizeof(bufData)); // get the length r = FS_Read(&buf.cursize, 4, clc.demofile); if (r != 4) { Com_FuncPrinf("couldn't get length/n"); FS_Seek(clc.demofile, origPosition, FS_SEEK_SET); clc.lastPacketTime = lastPacketTimeOrig; cl.parseEntitiesNum = parseEntitiesNumOrig; return qfalse; } buf.cursize = LittleLong(buf.cursize); if (buf.cursize == -1) { Com_FuncPrinf("buf.cursize == -1/n"); FS_Seek(clc.demofile, origPosition, FS_SEEK_SET); clc.lastPacketTime = lastPacketTimeOrig; cl.parseEntitiesNum = parseEntitiesNumOrig; return qfalse; } if (buf.cursize > buf.maxsize) { Com_FuncDrop("demoMsglen > MAX_MSGLEN"); return qfalse;//.........这里部分代码省略.........
开发者ID:dstaesse,项目名称:etlegacy,代码行数:101,
示例12: CL_ReadDemoMessage/*====================CL_ReadDemoMessageHandles playback of demos====================*/void CL_ReadDemoMessage(void){ int i; float f; if (!cls.demoplayback) return; // LordHavoc: pausedemo if (cls.demopaused) return; for (;;) { // decide if it is time to grab the next message // always grab until fully connected if (cls.signon == SIGNONS) { if (cls.timedemo) { cls.td_frames++; cls.td_onesecondframes++; // if this is the first official frame we can now grab the real // td_starttime so the bogus time on the first frame doesn't // count against the final report if (cls.td_frames == 0) { cls.td_starttime = realtime; cls.td_onesecondnexttime = cl.time + 1; cls.td_onesecondrealtime = realtime; cls.td_onesecondframes = 0; cls.td_onesecondminfps = 0; cls.td_onesecondmaxfps = 0; cls.td_onesecondavgfps = 0; cls.td_onesecondavgcount = 0; } if (cl.time >= cls.td_onesecondnexttime) { double fps = cls.td_onesecondframes / (realtime - cls.td_onesecondrealtime); if (cls.td_onesecondavgcount == 0) { cls.td_onesecondminfps = fps; cls.td_onesecondmaxfps = fps; } cls.td_onesecondrealtime = realtime; cls.td_onesecondminfps = min(cls.td_onesecondminfps, fps); cls.td_onesecondmaxfps = max(cls.td_onesecondmaxfps, fps); cls.td_onesecondavgfps += fps; cls.td_onesecondavgcount++; cls.td_onesecondframes = 0; cls.td_onesecondnexttime++; } } else if (cl.time <= cl.mtime[0]) { // don't need another message yet return; } } // get the next message FS_Read(cls.demofile, &cl_message.cursize, 4); cl_message.cursize = LittleLong(cl_message.cursize); if(cl_message.cursize & DEMOMSG_CLIENT_TO_SERVER) // This is a client->server message! Ignore for now! { // skip over demo packet FS_Seek(cls.demofile, 12 + (cl_message.cursize & (~DEMOMSG_CLIENT_TO_SERVER)), SEEK_CUR); continue; } if (cl_message.cursize > cl_message.maxsize) { Con_Printf("Demo message (%i) > cl_message.maxsize (%i)", cl_message.cursize, cl_message.maxsize); cl_message.cursize = 0; CL_Disconnect(); return; } VectorCopy(cl.mviewangles[0], cl.mviewangles[1]); for (i = 0;i < 3;i++) { FS_Read(cls.demofile, &f, 4); cl.mviewangles[0][i] = LittleFloat(f); } if (FS_Read(cls.demofile, cl_message.data, cl_message.cursize) == cl_message.cursize) { MSG_BeginReading(&cl_message); CL_ParseServerMessage(); if (cls.signon != SIGNONS) Cbuf_Execute(); // immediately execute svc_stufftext if in the demo before connect! // In case the demo contains a "svc_disconnect" message if (!cls.demoplayback)//.........这里部分代码省略.........
开发者ID:SMBXon,项目名称:darkplaces,代码行数:101,
示例13: aud_trim_open_req_hdlr/***************************************************************************** * FUNCTION * aud_trim_open_req_hdlr * DESCRIPTION * This function is used to open a trimming handler. * PARAMETERS * * RETURNS * void *****************************************************************************/void aud_trim_open_req_hdlr(ilm_struct *ilm_ptr){ /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ kal_uint32 file_len = 0; FSAL_Status fsal_result; kal_uint8* fsal_buf_p = NULL; media_open_func_ptr open_fct = NULL; kal_int32 result = MED_RES_FAIL; l4aud_trim_open_req_struct* msg_p = (l4aud_trim_open_req_struct*) ilm_ptr->local_para_ptr; /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ ASSERT(msg_p->file_name_in && msg_p->file_name_out && msg_p->handle_p); /* Check if trimming handler is already opened. Currently, we only support one instance. */ if (g_is_trim_opened) { result = MED_RES_BUSY; goto aud_trim_open_failed; } /* Initialize context */ g_is_trim_opened = KAL_TRUE; memset(&g_trim_ctx, 0, sizeof(aud_trim_context_t)); g_trim_ctx.file_output = -1; g_trim_ctx.src_mod_id = ilm_ptr->src_mod_id; /* Select a MHdl open function per media format */ g_trim_ctx.format = med_get_media_type(msg_p->file_name_in); switch (g_trim_ctx.format) { #ifdef DAF_DECODE case MED_TYPE_DAF: #endif /* DAF_DECODE */ open_fct = DAF_Open; break; default: /* Unsupport format */ ASSERT(0); } if (open_fct) { /* Create a FSAL handler */ if ((fsal_result = FSAL_Open(&g_trim_ctx.fsal_handle, msg_p->file_name_in, FSAL_READ_SHARED)) != FSAL_OK) { result = MED_RES_OPEN_FILE_FAIL; goto aud_trim_open_failed; } g_trim_ctx.is_fsal_opened = KAL_TRUE; fsal_buf_p = (kal_uint8*) get_ctrl_buffer(sizeof(kal_uint8) * AUD_PROC_BUF_SIZE); FSAL_SetBuffer(&g_trim_ctx.fsal_handle, AUD_PROC_BUF_SIZE, fsal_buf_p); /* Open a MHdl handler */ g_trim_ctx.mhdl_handle_p = open_fct(_aud_trim_event_callback_fct, &g_trim_ctx.fsal_handle, NULL); _AUD_TRIM_TRACE(g_trim_ctx.mhdl_handle_p, g_trim_ctx.format, fsal_buf_p); if (g_trim_ctx.mhdl_handle_p == NULL) { result = MED_RES_BAD_FORMAT; goto aud_trim_open_failed; } /* Create output file handle */ g_trim_ctx.file_output = FS_Open(msg_p->file_name_out, FS_READ_WRITE | FS_OPEN_SHARED | FS_NOBUSY_CHECK_MODE); if (g_trim_ctx.file_output >= 0) /* File already exists */ { /* Check if the size of file is 0 because MMI may create the file to be trimmed to in advance */ FS_GetFileSize(g_trim_ctx.file_output, &file_len); if (file_len != 0) { /* Seek to the beginning of the file to overwrite all the data */ FS_Seek(g_trim_ctx.file_output, 0, FS_FILE_BEGIN); } } else /* File does not exist */ { /* Create a new file */ g_trim_ctx.file_output = FS_Open(msg_p->file_name_out, FS_CREATE | FS_READ_WRITE | FS_OPEN_SHARED | FS_NOBUSY_CHECK_MODE); } _AUD_TRIM_TRACE(g_trim_ctx.file_output, file_len, -1);//.........这里部分代码省略.........
开发者ID:WayWingsDev,项目名称:testmywatch,代码行数:101,
示例14: HPAK_RemoveLumpvoid HPAK_RemoveLump( const char *name, resource_t *resource ){ string read_path; string save_path; file_t *f1, *f2; hpak_container_t hpak_read; hpak_container_t hpak_save; int i, j; if( !name || !name[0] || !resource ) return; HPAK_FlushHostQueue(); Q_strncpy( read_path, name, sizeof( read_path )); FS_StripExtension( read_path ); FS_DefaultExtension( read_path, ".hpk" ); f1 = FS_Open( read_path, "rb", false ); if( !f1 ) { MsgDev( D_ERROR, "HPAK_RemoveLump: %s couldn't open./n", read_path ); return; } Q_strncpy( save_path, read_path, sizeof( save_path )); FS_StripExtension( save_path ); FS_DefaultExtension( save_path, ".hp2" ); f2 = FS_Open( save_path, "w+b", false ); if( !f2 ) { MsgDev( D_ERROR, "HPAK_RemoveLump: %s couldn't open./n", save_path ); FS_Close( f1 ); return; } FS_Seek( f1, 0, SEEK_SET ); FS_Seek( f2, 0, SEEK_SET ); // header copy FS_Read( f1, &hash_pack_header, sizeof( hpak_header_t )); FS_Write( f2, &hash_pack_header, sizeof( hpak_header_t )); if( hash_pack_header.ident != IDCUSTOMHEADER || hash_pack_header.version != IDCUSTOM_VERSION ) { MsgDev( D_ERROR, "HPAK_RemoveLump: %s has invalid header./n", read_path ); FS_Close( f1 ); FS_Close( f2 ); FS_Delete( save_path ); // delete temp file return; } FS_Seek( f1, hash_pack_header.seek, SEEK_SET ); FS_Read( f1, &hpak_read.count, sizeof( hpak_read.count )); if( hpak_read.count < 1 || hpak_read.count > MAX_FILES_IN_WAD ) { MsgDev( D_ERROR, "HPAK_RemoveLump: %s has invalid number of lumps./n", read_path ); FS_Close( f1 ); FS_Close( f2 ); FS_Delete( save_path ); // delete temp file return; } if( hpak_read.count == 1 ) { MsgDev( D_ERROR, "HPAK_RemoveLump: %s only has one element, so it's not deleted./n", read_path ); FS_Close( f1 ); FS_Close( f2 ); FS_Delete( read_path ); FS_Delete( save_path ); return; } hpak_save.count = hpak_read.count - 1; hpak_read.dirs = Z_Malloc( sizeof( hpak_dir_t ) * hpak_read.count ); hpak_save.dirs = Z_Malloc( sizeof( hpak_dir_t ) * hpak_save.count ); FS_Read( f1, hpak_read.dirs, sizeof( hpak_dir_t ) * hpak_read.count ); if( !HPAK_FindResource( &hpak_read, resource->rgucMD5_hash, NULL )) { MsgDev( D_ERROR, "HPAK_RemoveLump: Couldn't find the lump %s in hpak %s.n", resource->szFileName, read_path ); Mem_Free( hpak_read.dirs ); Mem_Free( hpak_save.dirs ); FS_Close( f1 ); FS_Close( f2 ); FS_Delete( save_path ); return; } MsgDev( D_INFO, "Removing lump %s from %s./n", resource->szFileName, read_path ); // If there's a collision, we've just corrupted this hpak. for( i = 0, j = 0; i < hpak_read.count; i++ ) { if( !Q_memcmp( hpak_read.dirs[i].DirectoryResource.rgucMD5_hash, resource->rgucMD5_hash, 16 )) continue; hpak_save.dirs[j] = hpak_read.dirs[i];//.........这里部分代码省略.........
开发者ID:DavidKnight247,项目名称:xash3d,代码行数:101,
示例15: HPAK_CreatePakvoid HPAK_CreatePak( const char *filename, resource_t *DirEnt, byte *data, file_t *f ){ int filelocation; string pakname; char md5[16]; char *temp; MD5Context_t MD5_Hash; file_t *fout; if( !filename || !filename[0] ) { MsgDev( D_ERROR, "HPAK_CreatePak: NULL name/n" ); return; } if(( f != NULL && data != NULL ) || ( f == NULL && data == NULL )) { MsgDev( D_ERROR, "HPAK_CreatePak: too many sources, please leave one./n" ); return; } Q_strncpy( pakname, filename, sizeof( pakname )); FS_StripExtension( pakname ); FS_DefaultExtension( pakname, ".hpk" ); MsgDev( D_INFO, "creating HPAK %s./n", pakname ); fout = FS_Open( pakname, "wb", false ); if( !fout ) { MsgDev( D_ERROR, "HPAK_CreatePak: can't write %s./n", pakname ); return; } // let's hash it. Q_memset( &MD5_Hash, 0, sizeof( MD5Context_t )); MD5Init( &MD5_Hash ); if( data == NULL ) { // there are better ways filelocation = FS_Tell( f ); temp = Z_Malloc( DirEnt->nDownloadSize ); FS_Read( f, temp, DirEnt->nDownloadSize ); FS_Seek( f, filelocation, SEEK_SET ); MD5Update( &MD5_Hash, temp, DirEnt->nDownloadSize ); Mem_Free( temp ); } else { MD5Update( &MD5_Hash, data, DirEnt->nDownloadSize ); } MD5Final( md5, &MD5_Hash ); if( Q_memcmp( md5, DirEnt->rgucMD5_hash, 16 )) { MsgDev( D_ERROR, "HPAK_CreatePak: bad checksum for %s. Ignored/n", pakname ); return; } hash_pack_header.ident = IDCUSTOMHEADER; hash_pack_header.version = IDCUSTOM_VERSION; hash_pack_header.seek = 0; FS_Write( fout, &hash_pack_header, sizeof( hash_pack_header )); hash_pack_dir.count = 1; hash_pack_dir.dirs = Z_Malloc( sizeof( hpak_dir_t )); hash_pack_dir.dirs[0].DirectoryResource = *DirEnt; hash_pack_dir.dirs[0].seek = FS_Tell( fout ); hash_pack_dir.dirs[0].size = DirEnt->nDownloadSize; if( data == NULL ) { HPAK_FileCopy( fout, f, hash_pack_dir.dirs[0].size ); } else { FS_Write( fout, data, hash_pack_dir.dirs[0].size ); } filelocation = FS_Tell( fout ); FS_Write( fout, &hash_pack_dir.count, sizeof( hash_pack_dir.count )); FS_Write( fout, &hash_pack_dir.dirs[0], sizeof( hpak_dir_t )); Mem_Free( hash_pack_dir.dirs ); Q_memset( &hash_pack_dir, 0, sizeof( hpak_container_t )); hash_pack_header.seek = filelocation; FS_Seek( fout, 0, SEEK_SET ); FS_Write( fout, &hash_pack_header, sizeof( hpak_header_t )); FS_Close( fout );}
开发者ID:DavidKnight247,项目名称:xash3d,代码行数:94,
示例16: BAL_MainTaskEntry//.........这里部分代码省略......... #if APP_SUPPORT_LCD==0 //added for T_card update without LCD. Search TF card, if there is a file with the name "tflash_update.bin", then do the update.#ifdef MCD_TFCARD_SUPPORT { INT32 file = -1, card_ok = -1; UINT32 cur_data = AP_GetBuildDate(); UINT32 cur_time = AP_GetBuildTime(); boolean needupdate = FALSE; hal_HstSendEvent(BOOT_EVENT, 0x98880001); hal_HstSendEvent(BOOT_EVENT, cur_data); hal_HstSendEvent(BOOT_EVENT, cur_time); hal_HstSendEvent(BOOT_EVENT, 0x98880001); card_ok = FS_MountDevice(FS_DEV_TYPE_TFLASH); hal_HstSendEvent(BOOT_EVENT, card_ok); if(card_ok == ERR_SUCCESS) { FS_FILE_ATTR file_attr; TM_FILETIME sFileTime; TM_SYSTEMTIME sSysTm; UINT32 bin_createDate = 0; UINT32 bin_createTime = 0; UINT32 offset = 0; file = FS_Open(UPDATE_TFLASH_BIN_NAME, FS_O_RDWR, 0); hal_HstSendEvent(BOOT_EVENT, 0x09550000); hal_HstSendEvent(BOOT_EVENT, file); hal_HstSendEvent(BOOT_EVENT, 0x09550000); #if 1 FS_Seek(file, 0xc, FS_SEEK_SET); FS_Read(file, &offset, 4); FS_Seek(file, ((offset & 0x00ffffff)) - 0x10, FS_SEEK_SET); FS_Read(file, &bin_createDate, 4); FS_Read(file, &bin_createTime, 4); hal_HstSendEvent(BOOT_EVENT, 0x98880002); hal_HstSendEvent(BOOT_EVENT, bin_createDate); hal_HstSendEvent(BOOT_EVENT, bin_createTime); hal_HstSendEvent(BOOT_EVENT, 0x98880002);#else if(FS_GetFileAttrByHandle(file, &file_attr) == 0) { sFileTime.DateTime = file_attr.i_mtime; TM_FileTimeToSystemTime(sFileTime, &sSysTm); bin_createDate = ((sSysTm.uYear) * 10000 + ((sSysTm.uMonth) * 100) + sSysTm.uDay); bin_createTime = sSysTm.uHour * 10000 + sSysTm.uMinute * 100 + sSysTm.uSecond; hal_HstSendEvent(BOOT_EVENT, 0x98880002); hal_HstSendEvent(BOOT_EVENT, bin_createDate); hal_HstSendEvent(BOOT_EVENT, bin_createTime); hal_HstSendEvent(BOOT_EVENT, 0x98880002); }#endif //if((cur_data<bin_createDate) || //(cur_data==bin_createDate && cur_time<bin_createTime)) if((cur_data != bin_createDate) || (cur_time != bin_createTime)) //只要不是同一软件就允许升级 { needupdate = TRUE; }
开发者ID:BarryChen,项目名称:RDA,代码行数:66,
示例17: _main//.........这里部分代码省略......... //dbgprintf("ok/n"); while (1) { ret = mqueue_recv(QueueID, (void *)&CMessage, 0); if( ret != 0 ) { //dbgprintf("FFS:mqueue_recv(%d) FAILED:%d/n", QueueID, ret); continue; } //dbgprintf("FFS:Cmd:%d/n", CMessage->command ); switch( CMessage->command ) { case IOS_OPEN: { ret = FS_Open( CMessage->open.device, CMessage->open.mode );#ifdef DEBUG if( ret != FS_NO_DEVICE ) dbgprintf("FFS:IOS_Open(/"%s/", %d):%d/n", CMessage->open.device, CMessage->open.mode, ret );#endif mqueue_ack( (void *)CMessage, ret); } break; case IOS_CLOSE: {#ifdef DEBUG dbgprintf("FFS:IOS_Close(%d):", CMessage->fd);#endif ret = FS_Close( CMessage->fd );#ifdef DEBUG dbgprintf("%d/n", ret );#endif mqueue_ack( (void *)CMessage, ret); } break; case IOS_READ: {#ifdef DEBUG dbgprintf("FFS:IOS_Read(%d, 0x%p, %u):", CMessage->fd, CMessage->read.data, CMessage->read.length );#endif ret = FS_Read( CMessage->fd, CMessage->read.data, CMessage->read.length );#ifdef DEBUG dbgprintf("%d/n", ret );#endif mqueue_ack( (void *)CMessage, ret ); } break; case IOS_WRITE: {#ifdef DEBUG dbgprintf("FFS:IOS_Write(%d, 0x%p, %u)", CMessage->fd, CMessage->write.data, CMessage->write.length );#endif ret = FS_Write( CMessage->fd, CMessage->write.data, CMessage->write.length );#ifdef DEBUG dbgprintf(":%d/n", ret );#endif mqueue_ack( (void *)CMessage, ret ); } break; case IOS_SEEK: {#ifdef DEBUG dbgprintf("FFS:IOS_Seek(%d, %x, %d):", CMessage->fd, CMessage->seek.offset, CMessage->seek.origin );#endif ret = FS_Seek( CMessage->fd, CMessage->seek.offset, CMessage->seek.origin );#ifdef DEBUG dbgprintf("%d/n", ret );#endif mqueue_ack( (void *)CMessage, ret ); } break; case IOS_IOCTL: FFS_Ioctl(CMessage); break; case IOS_IOCTLV: FFS_Ioctlv(CMessage); break;#ifdef EDEBUG default: dbgprintf("FFS:unimplemented/invalid msg: %08x/n", CMessage->command); mqueue_ack( (void *)CMessage, -1017);#endif } } return 0;}
开发者ID:audiohacked,项目名称:sneek,代码行数:101,
示例18: CL_CgameSystemCallsintptr_t CL_CgameSystemCalls( intptr_t *args ){ if( cls.cgInterface == 2 && args[0] >= CG_R_SETCLIPREGION && args[0] < CG_MEMSET ) { if( args[0] < CG_S_STOPBACKGROUNDTRACK - 1 ) args[0] += 1; else if( args[0] < CG_S_STOPBACKGROUNDTRACK + 4 ) args[0] += CG_PARSE_ADD_GLOBAL_DEFINE - CG_S_STOPBACKGROUNDTRACK + 1; else if( args[0] < CG_PARSE_ADD_GLOBAL_DEFINE + 4 ) args[0] -= 4; else if( args[0] >= CG_PARSE_SOURCE_FILE_AND_LINE && args[0] <= CG_S_SOUNDDURATION ) args[0] = CG_PARSE_SOURCE_FILE_AND_LINE - 1337 - args[0] ; } switch( args[0] ) { case CG_PRINT: Com_Printf( "%s", (const char*)VMA(1) ); return 0; case CG_ERROR: if( probingCG ) { cls.cgInterface = 2; // this is a 1.1.0 cgame return 0; } Com_Error( ERR_DROP, "%s", (const char*)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_SetSafe( (const char*)VMA(1), (const char*)VMA(2) ); return 0; case CG_CVAR_VARIABLESTRINGBUFFER: Cvar_VariableStringBuffer( (const char*)VMA(1), (char*)VMA(2), args[3] ); 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_LITERAL_ARGS: Cmd_LiteralArgsBuffer( (char*)VMA(1), args[2] ); return 0; case CG_FS_FOPENFILE: return FS_FOpenFileByMode( (const char*)VMA(1), (fileHandle_t*)VMA(2), (FS_Mode)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_FS_SEEK: return FS_Seek( (fileHandle_t)args[1], args[2], (FS_Origin)args[3] ); case CG_FS_GETFILELIST: return FS_GetFileList( (const char*)VMA(1), (const char*)VMA(2), (char*)VMA(3), args[4] ); case CG_SENDCONSOLECOMMAND: Cbuf_AddText( (const char*)VMA(1) ); return 0; case CG_ADDCOMMAND: Cmd_AddCommand( (const char*)VMA(1), NULL ); return 0; case CG_REMOVECOMMAND: Cmd_RemoveCommandSafe( (const char*)VMA(1) ); return 0; case CG_SENDCLIENTCOMMAND: CL_AddReliableCommand((const char*)VMA(1), false); 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( (const char*)VMA(1) ); return 0; case CG_CM_NUMINLINEMODELS: return CM_NumInlineModels(); case CG_CM_INLINEMODEL: return CM_InlineModel( args[1] ); case CG_CM_TEMPBOXMODEL://.........这里部分代码省略.........
开发者ID:wtfbbqhax,项目名称:tremulous,代码行数:101,
示例19: CL_WriteDemoHeader/*====================CL_WriteDemoHeaderWrite demo header====================*/void CL_WriteDemoHeader( const char *name ){ fs_offset_t copysize; fs_offset_t savepos; fs_offset_t curpos; MsgDev( D_INFO, "recording to %s./n", name ); cls.demofile = FS_Open( name, "wb", false ); cls.demotime = 0.0; if( !cls.demofile ) { MsgDev( D_ERROR, "couldn't open %s./n", name ); return; } cls.demorecording = true; cls.demowaiting = true; // don't start saving messages until a non-delta compressed message is received Q_memset( &demo.header, 0, sizeof( demo.header )); demo.header.id = IDEMOHEADER; demo.header.dem_protocol = DEMO_PROTOCOL; demo.header.net_protocol = PROTOCOL_VERSION; Q_strncpy( demo.header.mapname, clgame.mapname, sizeof( demo.header.mapname )); Q_strncpy( demo.header.gamedir, FS_Gamedir(), sizeof( demo.header.gamedir )); // write header FS_Write( cls.demofile, &demo.header, sizeof( demo.header )); demo.directory.numentries = 2; demo.directory.entries = Mem_Alloc( cls.mempool, sizeof( demoentry_t ) * demo.directory.numentries ); // DIRECTORY ENTRY # 0 demo.entry = &demo.directory.entries[0]; // only one here. demo.entry->entrytype = DEMO_STARTUP; demo.entry->playback_time = 0.0f; // startup takes 0 time. demo.entry->offset = FS_Tell( cls.demofile ); // position for this chunk. // finish off the startup info. CL_WriteDemoCmdHeader( dem_stop, cls.demoheader ); // now copy the stuff we cached from the server. copysize = savepos = FS_Tell( cls.demoheader ); FS_Seek( cls.demoheader, 0, SEEK_SET ); FS_FileCopy( cls.demofile, cls.demoheader, copysize ); // jump back to end, in case we record another demo for this session. FS_Seek( cls.demoheader, savepos, SEEK_SET ); demo.starttime = CL_GetDemoRecordClock(); // setup the demo starttime demo.realstarttime = demo.starttime; demo.framecount = 0; // now move on to entry # 1, the first data chunk. curpos = FS_Tell( cls.demofile ); demo.entry->length = curpos - demo.entry->offset; // now we are writing the first real lump. demo.entry = &demo.directory.entries[1]; // first real data lump demo.entry->entrytype = DEMO_NORMAL; demo.entry->playback_time = 0.0f; // startup takes 0 time. demo.entry->offset = FS_Tell( cls.demofile ); // demo playback should read this as an incoming message. // write the client's realtime value out so we can synchronize the reads. CL_WriteDemoCmdHeader( dem_jumptime, cls.demofile ); if( clgame.hInstance ) clgame.dllFuncs.pfnReset(); Cbuf_InsertText( "fullupdate/n" ); Cbuf_Execute();}
开发者ID:nekonomicon,项目名称:xash3d,代码行数:83,
示例20: HPAK_AddLumpvoid HPAK_AddLump( qboolean add_to_queue, const char *name, resource_t *DirEnt, byte *data, file_t *f ){ int i, position, length; string pakname1, pakname2; char md5[16]; MD5Context_t MD5_Hash; hpak_container_t hpak1, hpak2; file_t *f1, *f2; hpak_dir_t *dirs; byte *temp; if( !name || !name[0] ) { MsgDev( D_ERROR, "HPAK_AddLump: NULL name/n" ); return; } if( !DirEnt ) { MsgDev( D_ERROR, "HPAK_AddLump: invalid lump/n" ); return; } if( data == NULL && f == NULL ) { MsgDev( D_ERROR, "HPAK_AddLump: missing lump data/n" ); return; } if( DirEnt->nDownloadSize < 1024 || DirEnt->nDownloadSize > 131072 ) { MsgDev( D_ERROR, "HPAK_AddLump: invalid size %s/n", Q_pretifymem( DirEnt->nDownloadSize, 2 )); return; } // hash it Q_memset( &MD5_Hash, 0, sizeof( MD5Context_t )); MD5Init( &MD5_Hash ); if( data == NULL ) { // there are better ways position = FS_Tell( f ); temp = Z_Malloc( DirEnt->nDownloadSize ); FS_Read( f, temp, DirEnt->nDownloadSize ); FS_Seek( f, position, SEEK_SET ); MD5Update( &MD5_Hash, temp, DirEnt->nDownloadSize ); Mem_Free( temp ); } else { MD5Update( &MD5_Hash, data, DirEnt->nDownloadSize ); } MD5Final( md5, &MD5_Hash ); if( Q_memcmp( md5, DirEnt->rgucMD5_hash, 0x10 )) { MsgDev( D_ERROR, "HPAK_AddLump: bad checksum for %s. Ignored/n", DirEnt->szFileName ); return; } if( add_to_queue ) { HPAK_AddToQueue( name, DirEnt, data, f ); return; } Q_strncpy( pakname1, name, sizeof( pakname1 )); FS_StripExtension( pakname1 ); FS_DefaultExtension( pakname1, ".hpk" ); f1 = FS_Open( pakname1, "rb", false ); if( !f1 ) { // create new pack HPAK_CreatePak( name, DirEnt, data, f ); return; } Q_strncpy( pakname2, pakname1, sizeof( pakname2 )); FS_StripExtension( pakname2 ); FS_DefaultExtension( pakname2, ".hp2" ); f2 = FS_Open( pakname2, "w+b", false ); if( !f2 ) { MsgDev( D_ERROR, "HPAK_AddLump: couldn't open %s./n", pakname2 ); FS_Close( f1 ); return; } // load headers FS_Read( f1, &hash_pack_header, sizeof( hpak_header_t )); if( hash_pack_header.version != IDCUSTOM_VERSION ) {//.........这里部分代码省略.........
开发者ID:DavidKnight247,项目名称:xash3d,代码行数:101,
示例21: CL_GetComment/* ================== CL_GetComment================== */ qboolean CL_GetComment( const char *demoname, char *comment ){ file_t *demfile; demoheader_t demohdr; demodirectory_t directory; demoentry_t entry; float playtime = 0.0f; int i; if( !comment ) return false; demfile = FS_Open( demoname, "rb", false ); if( !demfile ) { Q_strncpy( comment, "", MAX_STRING ); return false; } // read in the m_DemoHeader FS_Read( demfile, &demohdr, sizeof( demoheader_t )); if( demohdr.id != IDEMOHEADER ) { FS_Close( demfile ); Q_strncpy( comment, "<corrupted>", MAX_STRING ); return false; } if( demohdr.net_protocol != PROTOCOL_VERSION || demohdr.dem_protocol != DEMO_PROTOCOL ) { FS_Close( demfile ); Q_strncpy( comment, "<invalid protocol>", MAX_STRING ); return false; } // now read in the directory structure. FS_Seek( demfile, demohdr.directory_offset, SEEK_SET ); FS_Read( demfile, &directory.numentries, sizeof( int )); if( directory.numentries < 1 || directory.numentries > 1024 ) { FS_Close( demfile ); Q_strncpy( comment, "<corrupted>", MAX_STRING ); return false; } for( i = 0; i < directory.numentries; i++ ) { FS_Read( demfile, &entry, sizeof( demoentry_t )); playtime += entry.playback_time; } // split comment to sections Q_strncpy( comment, demohdr.mapname, CS_SIZE ); Q_strncpy( comment + CS_SIZE, "<No Title>", CS_SIZE ); // TODO: write titles or somewhat Q_strncpy( comment + CS_SIZE * 2, va( "%g sec", playtime ), CS_TIME ); // all done FS_Close( demfile ); return true;}
开发者ID:nekonomicon,项目名称:xash3d,代码行数:67,
示例22: HPAK_Validatestatic qboolean HPAK_Validate( const char *filename, qboolean quiet ){ file_t *f; hpak_dir_t *dataDir; hpak_header_t hdr; byte *dataPak; int i, num_lumps; MD5Context_t MD5_Hash; string pakname; resource_t *pRes; char md5[16]; if( quiet ) HPAK_FlushHostQueue(); // not an error - just flush queue if( !filename || !*filename ) return true; Q_strncpy( pakname, filename, sizeof( pakname )); FS_StripExtension( pakname ); FS_DefaultExtension( pakname, ".hpk" ); f = FS_Open( pakname, "rb", false ); if( !f ) { MsgDev( D_INFO, "Couldn't find %s./n", pakname ); return true; } if( !quiet ) MsgDev( D_INFO, "Validating %s/n", pakname ); FS_Read( f, &hdr, sizeof( hdr )); if( hdr.ident != IDCUSTOMHEADER || hdr.version != IDCUSTOM_VERSION ) { MsgDev( D_ERROR, "HPAK_ValidatePak: %s does not have a valid HPAK header./n", pakname ); FS_Close( f ); return false; } FS_Seek( f, hdr.seek, SEEK_SET ); FS_Read( f, &num_lumps, sizeof( num_lumps )); if( num_lumps < 1 || num_lumps > MAX_FILES_IN_WAD ) { MsgDev( D_ERROR, "HPAK_ValidatePak: %s has too many lumps %u./n", pakname, num_lumps ); FS_Close( f ); return false; } if( !quiet ) MsgDev( D_INFO, "# of Entries: %i/n", num_lumps ); dataDir = Z_Malloc( sizeof( hpak_dir_t ) * num_lumps ); FS_Read( f, dataDir, sizeof( hpak_dir_t ) * num_lumps ); if( !quiet ) MsgDev( D_INFO, "# Type Size FileName : MD5 Hash/n" ); for( i = 0; i < num_lumps; i++ ) { if( dataDir[i].size < 1 || dataDir[i].size > 131071 ) { // odd max size MsgDev( D_ERROR, "HPAK_ValidatePak: lump %i has invalid size %s/n", i, Q_pretifymem( dataDir[i].size, 2 )); Mem_Free( dataDir ); FS_Close(f); return false; } dataPak = Z_Malloc( dataDir[i].size ); FS_Seek( f, dataDir[i].seek, SEEK_SET ); FS_Read( f, dataPak, dataDir[i].size ); Q_memset( &MD5_Hash, 0, sizeof( MD5Context_t )); MD5Init( &MD5_Hash ); MD5Update( &MD5_Hash, dataPak, dataDir[i].size ); MD5Final( md5, &MD5_Hash ); pRes = &dataDir[i].DirectoryResource; MsgDev( D_INFO, "%i: %s %s %s: ", i, HPAK_TypeFromIndex( pRes->type ), Q_pretifymem( pRes->nDownloadSize, 2 ), pRes->szFileName ); if( Q_memcmp( md5, pRes->rgucMD5_hash, 0x10 )) { if( quiet ) { MsgDev( D_ERROR, "HPAK_ValidatePak: %s has invalid checksum./n", pakname ); Mem_Free( dataPak ); Mem_Free( dataDir ); FS_Close( f ); return false; } else MsgDev( D_INFO, "failed/n" ); } else { if( !quiet ) MsgDev( D_INFO, "OK/n" ); } // at this point, it's passed our checks. Mem_Free( dataPak );//.........这里部分代码省略.........
开发者ID:DavidKnight247,项目名称:xash3d,代码行数:101,
示例23: S_OGG_Callback_seek// fseek() replacementint S_OGG_Callback_seek(void *datasource, ogg_int64_t offset, int whence){ snd_stream_t *stream; int retVal = 0; // check if input is valid if(!datasource) { errno = EBADF; return -1; } // snd_stream_t in the generic pointer stream = (snd_stream_t *) datasource; // we must map the whence to its Q3 counterpart switch (whence) { case SEEK_SET: { // set the file position in the actual file with the Q3 function retVal = FS_Seek(stream->file, (long)offset, FS_SEEK_SET); // something has gone wrong, so we return here if(retVal < 0) { return retVal; } // keep track of file position stream->pos = (int)offset; break; } case SEEK_CUR: { // set the file position in the actual file with the Q3 function retVal = FS_Seek(stream->file, (long)offset, FS_SEEK_CUR); // something has gone wrong, so we return here if(retVal < 0) { return retVal; } // keep track of file position stream->pos += (int)offset; break; } case SEEK_END: { // Quake 3 seems to have trouble with FS_SEEK_END // so we use the file length and FS_SEEK_SET // set the file position in the actual file with the Q3 function retVal = FS_Seek(stream->file, (long)stream->length + (long)offset, FS_SEEK_SET); // something has gone wrong, so we return here if(retVal < 0) { return retVal; } // keep track of file position stream->pos = stream->length + (int)offset; break; } default: { // unknown whence, so we return an error errno = EINVAL; return -1; } } // stream->pos shouldn't be smaller than zero or bigger than the filesize stream->pos = (stream->pos < 0) ? 0 : stream->pos; stream->pos = (stream->pos > stream->length) ? stream->length : stream->pos; return 0;}
开发者ID:SinSiXX,项目名称:Rogue-Reborn,代码行数:84,
示例24: HPAK_ResourceForHashqboolean HPAK_ResourceForHash( const char *filename, char *inHash, resource_t *pRes ){ file_t *f; hpak_t *hpak; hpak_container_t hpakcontainer; hpak_header_t hdr; string pakname; int ret; if( !filename || !filename[0] ) return false; for( hpak = hpak_queue; hpak != NULL; hpak = hpak->next ) { if( !Q_stricmp( hpak->name, filename ) && !Q_memcmp( hpak->HpakResource.rgucMD5_hash, inHash, 0x10 )) { if( pRes != NULL ) *pRes = hpak->HpakResource; return true; } } Q_strncpy( pakname, filename, sizeof( pakname )); FS_StripExtension( pakname ); FS_DefaultExtension( pakname, ".hpk" ); f = FS_Open( pakname, "rb", false ); if( !f ) return false; FS_Read( f, &hdr, sizeof( hdr )); if( hdr.ident != IDCUSTOMHEADER ) { MsgDev( D_ERROR, "HPAK_ResourceForHash: %s it's not a HPK file./n", pakname ); FS_Close( f ); return false; } if( hdr.version != IDCUSTOM_VERSION ) { MsgDev( D_ERROR, "HPAK_ResourceForHash: %s has invalid version (%i should be %i)./n", pakname, hdr.version, IDCUSTOM_VERSION ); FS_Close( f ); return false; } FS_Seek( f, hdr.seek, SEEK_SET ); FS_Read( f, &hpakcontainer.count, sizeof( hpakcontainer.count )); if( hpakcontainer.count < 1 || hpakcontainer.count > MAX_FILES_IN_WAD ) { MsgDev( D_ERROR, "HPAK_ResourceForHash: %s has too many lumps %u./n", pakname, hpakcontainer.count ); FS_Close( f ); return false; } hpakcontainer.dirs = Z_Malloc( sizeof( hpak_dir_t ) * hpakcontainer.count ); FS_Read( f, hpakcontainer.dirs, sizeof( hpak_dir_t ) * hpakcontainer.count ); ret = HPAK_FindResource( &hpakcontainer, inHash, pRes ); Mem_Free( hpakcontainer.dirs ); FS_Close( f ); return(ret);}
开发者ID:DavidKnight247,项目名称:xash3d,代码行数:62,
示例25: Netchan_Transmit//.........这里部分代码省略......... // Is there something in the fragbuf? pbuf = chan->fragbufs[i]; fragment_size = 0; // Compiler warning. if (pbuf) { fragment_size = pbuf->frag_message.cursize; // Files set size a bit differently. if (pbuf->isfile && !pbuf->isbuffer) { fragment_size = pbuf->size; } } // Make sure we have enought space left if (send_from_frag[i] && pbuf && ((chan->reliable_length + fragment_size) < MAX_RELIABLE_PAYLOAD)) { chan->reliable_fragid[i] = MAKE_FRAGID(pbuf->bufferid, chan->fragbufcount[i]); // Which buffer are we sending? // If it's not in-memory, then we'll need to copy it in frame the file handle. if (pbuf->isfile && !pbuf->isbuffer) { char compressedfilename[MAX_PATH]; FileHandle_t hfile; if (pbuf->iscompressed) { Q_snprintf(compressedfilename, sizeof(compressedfilename), "%s.ztmp", pbuf->filename); hfile = FS_Open(compressedfilename, "rb"); } else { hfile = FS_Open(pbuf->filename, "rb"); } FS_Seek(hfile, pbuf->foffset, FILESYSTEM_SEEK_HEAD); FS_Read(&pbuf->frag_message.data[pbuf->frag_message.cursize], pbuf->size, 1, hfile); pbuf->frag_message.cursize += pbuf->size; FS_Close(hfile); } Q_memcpy(chan->reliable_buf + chan->reliable_length, pbuf->frag_message.data, pbuf->frag_message.cursize); chan->reliable_length += pbuf->frag_message.cursize; chan->frag_length[i] = pbuf->frag_message.cursize; // Unlink pbuf Netchan_UnlinkFragment(pbuf, &chan->fragbufs[i]); chan->reliable_fragment[i] = 1; // Offset the rest of the starting positions for (j = i + 1; j < MAX_STREAMS; j++) { chan->frag_startpos[j] += chan->frag_length[i]; } } } } // Prepare the packet header w1 = chan->outgoing_sequence | (send_reliable << 31); w2 = chan->incoming_sequence | (chan->incoming_reliable_sequence << 31); send_reliable_fragment = false; for (i = 0; i < MAX_STREAMS; i++)
开发者ID:Adidasman1,项目名称:rehlds,代码行数:67,
示例26: HPAK_GetDataPointerqboolean HPAK_GetDataPointer( const char *filename, resource_t *pResource, byte **buffer, int *size ){ file_t *f; int i, num_lumps; hpak_dir_t *direntries; byte *tmpbuf; string pakname; hpak_t *queue; hpak_header_t hdr; if( !filename || !filename[0] ) return false; if( buffer ) *buffer = NULL; if( size ) *size = 0; for( queue = hpak_queue; queue != NULL; queue = queue->next ) { if( !Q_stricmp(queue->name, filename ) && !Q_memcmp( queue->HpakResource.rgucMD5_hash, pResource->rgucMD5_hash, 16 )) { if( buffer ) { tmpbuf = Z_Malloc( queue->size ); Q_memcpy( tmpbuf, queue->data, queue->size ); *buffer = tmpbuf; } if( size ) *size = queue->size; return true; } } Q_strncpy( pakname, filename, sizeof( pakname )); FS_StripExtension( pakname ); FS_DefaultExtension( pakname, ".hpk" ); f = FS_Open( pakname, "rb", false ); if( !f ) return false; FS_Read( f, &hdr, sizeof( hdr )); if( hdr.ident != IDCUSTOMHEADER ) { MsgDev( D_ERROR, "HPAK_GetDataPointer: %s it's not a HPK file./n", pakname ); FS_Close( f ); return false; } if( hdr.version != IDCUSTOM_VERSION ) { MsgDev( D_ERROR, "HPAK_GetDataPointer: %s has invalid version (%i should be %i)./n", pakname, hdr.version, IDCUSTOM_VERSION ); FS_Close( f ); return false; } FS_Seek( f, hdr.seek, SEEK_SET ); FS_Read( f, &num_lumps, sizeof( num_lumps )); if( num_lumps < 1 || num_lumps > MAX_FILES_IN_WAD ) { MsgDev( D_ERROR, "HPAK_GetDataPointer: %s has too many lumps %u./n", filename, num_lumps ); FS_Close( f ); return false; } direntries = Z_Malloc( sizeof( hpak_dir_t ) * num_lumps ); FS_Read( f, direntries, sizeof( hpak_dir_t ) * num_lumps ); for( i = 0; i < num_lumps; i++ ) { if( !Q_memcmp( direntries[i].DirectoryResource.rgucMD5_hash, pResource->rgucMD5_hash, 16 )) { FS_Seek( f, direntries[i].seek, SEEK_SET ); if( buffer && direntries[i].size > 0 ) { tmpbuf = Z_Malloc( direntries[i].size ); FS_Read( f, tmpbuf, direntries[i].size ); *buffer = tmpbuf; } Mem_Free( direntries ); FS_Close( f ); return true; } } Mem_Free( direntries ); FS_Close( f ); return false;}
开发者ID:DavidKnight247,项目名称:xash3d,代码行数:92,
示例27: CL_UISystemCalls/*====================CL_UISystemCallsThe ui module is making a system call====================*/intptr_t CL_UISystemCalls( intptr_t *args ) { switch ( args[0] ) { case UI_ERROR: Com_Error( ERR_DROP, "%s", (const char*)VMA(1) ); return 0; case UI_PRINT: Com_Printf( "%s", (const char*)VMA(1) ); return 0; case UI_MILLISECONDS: return Sys_Milliseconds(); case UI_CVAR_REGISTER: Cvar_Register( VMA( 1 ), VMA( 2 ), VMA( 3 ), args[4] ); return 0; case UI_CVAR_UPDATE: Cvar_Update( VMA( 1 ) ); return 0; case UI_CVAR_SET: Cvar_SetSafe( VMA(1), VMA(2) ); return 0; case UI_CVAR_VARIABLEVALUE: return FloatAsInt( Cvar_VariableValue( VMA( 1 ) ) ); case UI_CVAR_VARIABLESTRINGBUFFER: Cvar_VariableStringBuffer( VMA( 1 ), VMA( 2 ), args[3] ); return 0; case UI_CVAR_SETVALUE: Cvar_SetValueSafe( VMA(1), VMF(2) ); return 0; case UI_CVAR_RESET: Cvar_Reset( VMA( 1 ) ); return 0; case UI_CVAR_CREATE: Cvar_Register( NULL, VMA(1), VMA(2), args[3] ); return 0; case UI_CVAR_INFOSTRINGBUFFER: Cvar_InfoStringBuffer( args[1], VMA( 2 ), args[3] ); return 0; case UI_ARGC: return Cmd_Argc(); case UI_ARGV: Cmd_ArgvBuffer( args[1], VMA( 2 ), args[3] ); return 0; case UI_CMD_EXECUTETEXT: if(args[1] == EXEC_NOW && (!strncmp(VMA(2), "snd_restart", 11) || !strncmp(VMA(2), "vid_restart", 11) || !strncmp(VMA(2), "quit", 5))) { Com_Printf (S_COLOR_YELLOW "turning EXEC_NOW '%.11s' into EXEC_INSERT/n", (const char*)VMA(2)); args[1] = EXEC_INSERT; } Cbuf_ExecuteText( args[1], VMA( 2 ) ); return 0; case UI_FS_FOPENFILE: return FS_FOpenFileByMode( VMA( 1 ), VMA( 2 ), args[3] ); case UI_FS_READ: FS_Read( VMA( 1 ), args[2], args[3] ); return 0;//----(SA) added case UI_FS_SEEK: FS_Seek( args[1], args[2], args[3] ); return 0;//----(SA) end case UI_FS_WRITE: FS_Write( VMA( 1 ), args[2], args[3] ); return 0; case UI_FS_FCLOSEFILE: FS_FCloseFile( args[1] ); return 0; case UI_FS_DELETEFILE: return FS_Delete( VMA( 1 ) ); case UI_FS_GETFILELIST: return FS_GetFileList( VMA( 1 ), VMA( 2 ), VMA( 3 ), args[4] );//.........这里部分代码省略.........
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:101,
示例28: CheckPendingDownloads/*====================CheckPendingDownloadschecks if there are free download slots to start new downloads in.To not start too many downloads at once, only one download is added at a time,up to a maximum number of cl_curl_maxdownloads are running.====================*/static void CheckPendingDownloads(void){ const char *h; char urlbuf[1024]; char vabuf[1024]; if(!curl_dll) return; if(numdownloads < cl_curl_maxdownloads.integer) { downloadinfo *di; for(di = downloads; di; di = di->next) { if(!di->started) { if(!di->buffer) { Con_Printf("Downloading %s -> %s", CleanURL(di->url, urlbuf, sizeof(urlbuf)), di->filename); di->stream = FS_OpenRealFile(di->filename, "ab", false); if(!di->stream) { Con_Printf("/nFAILED: Could not open output file %s/n", di->filename); Curl_EndDownload(di, CURL_DOWNLOAD_FAILED, CURLE_OK, NULL); return; } FS_Seek(di->stream, 0, SEEK_END); di->startpos = FS_Tell(di->stream); if(di->startpos > 0) Con_Printf(", resuming from position %ld", (long) di->startpos); Con_Print(".../n"); } else { Con_DPrintf("Downloading %s -> memory/n", CleanURL(di->url, urlbuf, sizeof(urlbuf))); di->startpos = 0; } di->curle = qcurl_easy_init(); di->slist = NULL; qcurl_easy_setopt(di->curle, CURLOPT_URL, di->url); if(cl_curl_useragent.integer) { const char *ua#ifdef HTTP_USER_AGENT = HTTP_USER_AGENT;#else = engineversion;#endif if(!ua) ua = ""; if(*cl_curl_useragent_append.string) ua = va(vabuf, sizeof(vabuf), "%s%s%s", ua, (ua[0] && ua[strlen(ua)-1] != ' ') ? " " : "", cl_curl_useragent_append.string); qcurl_easy_setopt(di->curle, CURLOPT_USERAGENT, ua); } else qcurl_easy_setopt(di->curle, CURLOPT_USERAGENT, ""); qcurl_easy_setopt(di->curle, CURLOPT_REFERER, di->referer); qcurl_easy_setopt(di->curle, CURLOPT_RESUME_FROM, (long) di->startpos); qcurl_easy_setopt(di->curle, CURLOPT_FOLLOWLOCATION, 1); qcurl_easy_setopt(di->curle, CURLOPT_WRITEFUNCTION, CURL_fwrite); qcurl_easy_setopt(di->curle, CURLOPT_LOW_SPEED_LIMIT, (long) 256); qcurl_easy_setopt(di->curle, CURLOPT_LOW_SPEED_TIME, (long) 45); qcurl_easy_setopt(di->curle, CURLOPT_WRITEDATA, (void *) di); qcurl_easy_setopt(di->curle, CURLOPT_PRIVATE, (void *) di); qcurl_easy_setopt(di->curle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS | CURLPROTO_FTP); if(qcurl_easy_setopt(di->curle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS | CURLPROTO_FTP) != CURLE_OK) { Con_Printf("^1WARNING:^7 for security reasons, please upgrade to libcurl 7.19.4 or above. In a later version of DarkPlaces, HTTP redirect support will be disabled for this libcurl version./n"); //qcurl_easy_setopt(di->curle, CURLOPT_FOLLOWLOCATION, 0); } if(di->post_content_type) { qcurl_easy_setopt(di->curle, CURLOPT_POST, 1); qcurl_easy_setopt(di->curle, CURLOPT_POSTFIELDS, di->postbuf); qcurl_easy_setopt(di->curle, CURLOPT_POSTFIELDSIZE, di->postbufsize); di->slist = qcurl_slist_append(di->slist, va(vabuf, sizeof(vabuf), "Content-Type: %s", di->post_content_type)); } // parse extra headers into slist // /n separated list! h = di->extraheaders; while(h) { const char *hh = strchr(h, '/n'); if(hh)//.........这里部分代码省略.........
开发者ID:CyberSys,项目名称:darkplaces,代码行数:101,
注:本文中的FS_Seek函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ FS_Write函数代码示例 C++ FS_SV_FOpenFileWrite函数代码示例 |