这篇教程C++ FS_FCloseFile函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中FS_FCloseFile函数的典型用法代码示例。如果您正苦于以下问题:C++ FS_FCloseFile函数的具体用法?C++ FS_FCloseFile怎么用?C++ FS_FCloseFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了FS_FCloseFile函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: QGL_EnableLoggingvoid QGL_EnableLogging( bool enable ) { static bool isEnabled; // return if we're already active if ( isEnabled && enable ) { // decrement log counter and stop if it has reached 0 Cvar_Set( "r_logFile", va( "%d", r_logFile->integer - 1 ) ); if ( r_logFile->integer ) { return; } enable = false; } // return if we're already disabled if ( !enable && !isEnabled ) { return; } isEnabled = enable; if ( enable ) { if ( !log_fp ) { struct tm* newtime; time_t aclock; time( &aclock ); newtime = localtime( &aclock ); log_fp = FS_FOpenFileWrite( "gl.log" ); QGL_Log( "%s/n", asctime( newtime ) ); }#define GLF_0( r, n ) qgl ## n = log ## n;#define GLF_V0( n ) qgl ## n = log ## n;#define GLF_1( r, n, t1, p1 ) qgl ## n = log ## n;#define GLF_V1( n, t1, p1 ) qgl ## n = log ## n;#define GLF_V2( n, t1, p1, t2, p2 ) qgl ## n = log ## n;#define GLF_3( r, n, t1, p1, t2, p2, t3, p3 ) qgl ## n = log ## n;#define GLF_V3( n, t1, p1, t2, p2, t3, p3 ) qgl ## n = log ## n;#define GLF_V4( n, t1, p1, t2, p2, t3, p3, t4, p4 ) qgl ## n = log ## n;#define GLF_V5( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5 ) qgl ## n = log ## n;#define GLF_V6( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6 ) qgl ## n = log ## n;#define GLF_V7( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7 ) qgl ## n = log ## n;#define GLF_V8( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, p8 ) qgl ## n = log ## n;#define GLF_V9( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, p8, t9, p9 ) qgl ## n = log ## n;#define GLF_V10( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, p8, t9, p9, t10, p10 ) qgl ## n = log ## n;#include "qgl_functions.h"#undef GLF_0#undef GLF_V0#undef GLF_1#undef GLF_V1#undef GLF_V2#undef GLF_3#undef GLF_V3#undef GLF_V4#undef GLF_V5#undef GLF_V6#undef GLF_V7#undef GLF_V8#undef GLF_V9#undef GLF_V10 } else { if ( log_fp ) { QGL_Log( "*** CLOSING LOG ***/n" ); FS_FCloseFile( log_fp ); log_fp = 0; }#define GLF_0( r, n ) qgl ## n = gl ## n;#define GLF_V0( n ) qgl ## n = gl ## n;#define GLF_1( r, n, t1, p1 ) qgl ## n = gl ## n;#define GLF_V1( n, t1, p1 ) qgl ## n = gl ## n;#define GLF_V2( n, t1, p1, t2, p2 ) qgl ## n = gl ## n;#define GLF_3( r, n, t1, p1, t2, p2, t3, p3 ) qgl ## n = gl ## n;#define GLF_V3( n, t1, p1, t2, p2, t3, p3 ) qgl ## n = gl ## n;#define GLF_V4( n, t1, p1, t2, p2, t3, p3, t4, p4 ) qgl ## n = gl ## n;#define GLF_V5( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5 ) qgl ## n = gl ## n;#define GLF_V6( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6 ) qgl ## n = gl ## n;#define GLF_V7( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7 ) qgl ## n = gl ## n;#define GLF_V8( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, p8 ) qgl ## n = gl ## n;#define GLF_V9( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, p8, t9, p9 ) qgl ## n = gl ## n;#define GLF_V10( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, p8, t9, p9, t10, p10 ) qgl ## n = gl ## n;#include "qgl_functions.h"#undef GLF_0#undef GLF_V0#undef GLF_1#undef GLF_V1#undef GLF_V2#undef GLF_3#undef GLF_V3#undef GLF_V4#undef GLF_V5#undef GLF_V6#undef GLF_V7#undef GLF_V8#undef GLF_V9#undef GLF_V10 }}
开发者ID:janisl,项目名称:jlquake,代码行数:100,
示例2: 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_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_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_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 ), 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//.........这里部分代码省略.........
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:101,
示例3: SV_SpawnServer/*================SV_SpawnServerChange the server to a new map, taking all connectedclients along with it.================*/void SV_SpawnServer (char *server, char *spawnpoint, server_state_t serverstate, qboolean attractloop, qboolean loadgame){ int i; unsigned checksum; if (attractloop) Cvar_Set ("paused", "0"); Com_Printf ("------- Server Initialization -------/n"); Com_DPrintf ("SpawnServer: %s/n",server); if (sv.demofile) FS_FCloseFile (sv.demofile); svs.spawncount++; // any partially connected client will be // restarted sv.state = ss_dead; Com_SetServerState (sv.state); // wipe the entire per-level structure memset (&sv, 0, sizeof(sv)); svs.realtime = 0; sv.loadgame = loadgame; sv.attractloop = attractloop; // save name for levels that don't set message strcpy (sv.configstrings[CS_NAME], server); if (Cvar_VariableValue ("deathmatch")) { sprintf(sv.configstrings[CS_AIRACCEL], "%g", sv_airaccelerate->value); pm_airaccelerate = sv_airaccelerate->value; } else { strcpy(sv.configstrings[CS_AIRACCEL], "0"); pm_airaccelerate = 0; } SZ_Init (&sv.multicast, sv.multicast_buf, sizeof(sv.multicast_buf)); strcpy (sv.name, server); // leave slots at start for clients only for (i=0 ; i<maxclients->value ; i++) { // needs to reconnect if (svs.clients[i].state > cs_connected) svs.clients[i].state = cs_connected; svs.clients[i].lastframe = -1; } sv.time = 1000; strcpy (sv.name, server); strcpy (sv.configstrings[CS_NAME], server); if (serverstate != ss_game) { sv.models[1] = CM_LoadMap ("", false, &checksum); // no real map } else { Com_sprintf (sv.configstrings[CS_MODELS+1],sizeof(sv.configstrings[CS_MODELS+1]), "maps/%s.bsp", server); sv.models[1] = CM_LoadMap (sv.configstrings[CS_MODELS+1], false, &checksum); } Com_sprintf (sv.configstrings[CS_MAPCHECKSUM],sizeof(sv.configstrings[CS_MAPCHECKSUM]), "%i", checksum); // // clear physics interaction links // SV_ClearWorld (); for (i=1 ; i< CM_NumInlineModels() ; i++) { Com_sprintf (sv.configstrings[CS_MODELS+1+i], sizeof(sv.configstrings[CS_MODELS+1+i]), "*%i", i); sv.models[i+1] = CM_InlineModel (sv.configstrings[CS_MODELS+1+i]); } // // spawn the rest of the entities on the map // // precache and static commands can be issued during // map initialization sv.state = ss_loading; Com_SetServerState (sv.state); // load and spawn all other entities//.........这里部分代码省略.........
开发者ID:AimHere,项目名称:thirty-flights-of-linux,代码行数:101,
示例4: 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,
示例5: CL_UISystemCalls/** * @brief The ui module is making a system call * @param[in] args * @return */intptr_t CL_UISystemCalls(intptr_t *args){ switch (args[0]) { case UI_ERROR: Com_Error(ERR_DROP, "%s", (char *)VMA(1)); case UI_PRINT: Com_Printf("%s", (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_LATCHEDVARIABLESTRINGBUFFER: Cvar_LatchedVariableStringBuffer(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_ADDCOMMAND: Cmd_AddCommand(VMA(1)); return 0; case UI_FS_FOPENFILE: return FS_FOpenFileByMode(VMA(1), VMA(2), (fsMode_t)args[3]); case UI_FS_READ: FS_Read(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_DELETEFILE: return FS_Delete(VMA(1)); case UI_FS_GETFILELIST: return FS_GetFileList(VMA(1), VMA(2), VMA(3), args[4]); 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; case UI_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene(VMA(1)); return 0; case UI_R_ADDPOLYTOSCENE: re.AddPolyToScene(args[1], args[2], VMA(3)); return 0; case UI_R_ADDPOLYSTOSCENE: re.AddPolysToScene(args[1], args[2], VMA(3), args[4]); return 0; case UI_R_ADDLIGHTTOSCENE: // new dlight code re.AddLightToScene(VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), args[7], args[8]);//.........这里部分代码省略.........
开发者ID:etlegacy,项目名称:etlegacy,代码行数:101,
示例6: S_CodecUtilClose/*=================S_CodecUtilClose=================*/void S_CodecUtilClose(snd_stream_t *stream){ FS_FCloseFile(stream->file); Z_Free(stream);}
开发者ID:ballju,项目名称:SpaceTrader-GPL-1.1.14,代码行数:10,
示例7: SV_WriteDownloadToClient//.........这里部分代码省略......... "The Team Arena mission pack can be found in your local game store.", cl->downloadName); } else { Com_sprintf(errorMessage, sizeof(errorMessage), "Cannot autodownload id pk3 file /"%s/"", cl->downloadName); } } else if ( !sv_allowDownload->integer ) { Com_Printf("clientDownload: %d : /"%s/" download disabled/n", (int) (cl - svs.clients), cl->downloadName); if (sv_pure->integer) { Com_sprintf(errorMessage, sizeof(errorMessage), "Could not download /"%s/" because autodownloading is disabled on the server./n/n" "You will need to get this file elsewhere before you " "can connect to this pure server./n", cl->downloadName); } else { Com_sprintf(errorMessage, sizeof(errorMessage), "Could not download /"%s/" because autodownloading is disabled on the server./n/n" "The server you are connecting to is not a pure server, " "set autodownload to No in your settings and you might be " "able to join the game anyway./n", cl->downloadName); } } else { // NOTE TTimo this is NOT supposed to happen unless bug in our filesystem scheme? // if the pk3 is referenced, it must have been found somewhere in the filesystem Com_Printf("clientDownload: %d : /"%s/" file not found on server/n", (int) (cl - svs.clients), cl->downloadName); Com_sprintf(errorMessage, sizeof(errorMessage), "File /"%s/" not found on server for autodownloading./n", cl->downloadName); } MSG_WriteByte( msg, svc_download ); MSG_WriteShort( msg, 0 ); // client is expecting block zero MSG_WriteLong( msg, -1 ); // illegal file size MSG_WriteString( msg, errorMessage ); *cl->downloadName = 0; if(cl->download) FS_FCloseFile(cl->download); return; } Com_Printf( "clientDownload: %d : beginning /"%s/"/n", (int) (cl - svs.clients), cl->downloadName ); // Init cl->downloadCurrentBlock = cl->downloadClientBlock = cl->downloadXmitBlock = 0; cl->downloadCount = 0; cl->downloadEOF = qfalse; } // Perform any reads that we need to while (cl->downloadCurrentBlock - cl->downloadClientBlock < MAX_DOWNLOAD_WINDOW && cl->downloadSize != cl->downloadCount) { curindex = (cl->downloadCurrentBlock % MAX_DOWNLOAD_WINDOW); if (!cl->downloadBlocks[curindex]) cl->downloadBlocks[curindex] = (unsigned char *)Z_Malloc( MAX_DOWNLOAD_BLKSIZE, TAG_DOWNLOAD, qtrue ); cl->downloadBlockSize[curindex] = FS_Read( cl->downloadBlocks[curindex], MAX_DOWNLOAD_BLKSIZE, cl->download ); if (cl->downloadBlockSize[curindex] < 0) { // EOF right now cl->downloadCount = cl->downloadSize; break; } cl->downloadCount += cl->downloadBlockSize[curindex]; // Load in next block
开发者ID:Avygeil,项目名称:NewJK,代码行数:67,
示例8: CL_ParseDownload//.........这里部分代码省略......... 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 ); downloadLogger.Debug("Starting new direct download of size %i for '%s'", clc.downloadSize, cls.downloadTempName); Cvar_SetValue( "cl_downloadSize", clc.downloadSize ); if ( clc.downloadSize < 0 ) { Com_Error( ERR_DROP, "%s", MSG_ReadString( msg ) ); } } size = MSG_ReadShort( msg ); if ( size < 0 || size > (int) sizeof( data ) ) { Com_Error( ERR_DROP, "CL_ParseDownload: Invalid size %d for download chunk.", size ); } downloadLogger.Debug("Received block of size %i", size); MSG_ReadData( msg, data, size ); if ( clc.downloadBlock != block ) { downloadLogger.Debug( "CL_ParseDownload: Expected block %i, got %i", 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 ) { downloadLogger.Debug("Received EOF, closing '%s'", cls.downloadTempName); // 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(); }}
开发者ID:ffpwserver,项目名称:Unvanquished,代码行数:101,
示例9: CL_UpdateLevelHunkUsage/** * @brief This updates the "hunkusage.dat" file with the current map and it's hunk usage count * * This is used for level loading, so we can show a percentage bar dependant on the amount * of hunk memory allocated so far * * This will be slightly inaccurate if some settings like sound quality are changed, but these * things should only account for a small variation (hopefully) */void CL_UpdateLevelHunkUsage(void){ int handle; const char *memlistfile = "hunkusage.dat"; char outstr[256]; int len, memusage; memusage = Cvar_VariableIntegerValue("com_hunkused"); len = FS_FOpenFileByMode(memlistfile, &handle, FS_READ); if (len >= 0) // the file exists, so read it in, strip out the current entry for this map, and save it out, so we can append the new value { char *buftrav, *outbuftrav; char *outbuf; char *token; char *buf; buf = (char *)Z_Malloc(len + 1); Com_Memset(buf, 0, len + 1); outbuf = (char *)Z_Malloc(len + 1); Com_Memset(outbuf, 0, len + 1); (void) FS_Read((void *)buf, len, handle); FS_FCloseFile(handle); // now parse the file, filtering out the current map buftrav = buf; outbuftrav = outbuf; outbuftrav[0] = '/0'; COM_BeginParseSession("CL_UpdateLevelHunkUsage"); while ((token = COM_Parse(&buftrav)) != NULL && token[0]) { if (!Q_stricmp(token, cl.mapname)) { // found a match token = COM_Parse(&buftrav); // read the size if (token && token[0]) { if (atoi(token) == memusage) // if it is the same, abort this process { Z_Free(buf); Z_Free(outbuf); return; } } } else // send it to the outbuf { Q_strcat(outbuftrav, len + 1, token); Q_strcat(outbuftrav, len + 1, " "); token = COM_Parse(&buftrav); // read the size if (token && token[0]) { Q_strcat(outbuftrav, len + 1, token); Q_strcat(outbuftrav, len + 1, "/n"); } else { //Com_Error does memory clean up //Z_Free(buf); //Z_Free(outbuf); Com_Error(ERR_DROP, "hunkusage.dat file is corrupt"); } } } handle = FS_FOpenFileWrite(memlistfile); if (handle < 0) { Com_Error(ERR_DROP, "cannot create %s", memlistfile); } // input file is parsed, now output to the new file len = strlen(outbuf); if (FS_Write((void *)outbuf, len, handle) != len) { Com_Error(ERR_DROP, "cannot write to %s", memlistfile); } FS_FCloseFile(handle); Z_Free(buf); Z_Free(outbuf); } // now append the current map to the current file (void) FS_FOpenFileByMode(memlistfile, &handle, FS_APPEND); if (handle < 0) { Com_Error(ERR_DROP, "cannot write to hunkusage.dat, check disk full"); } Com_sprintf(outstr, sizeof(outstr), "%s %i/n", cl.mapname, memusage); (void) FS_Write(outstr, strlen(outstr), handle);//.........这里部分代码省略.........
开发者ID:zturtleman,项目名称:etlegacy,代码行数:101,
示例10: S_StartBackgroundTrack/*======================S_StartBackgroundTrack======================*/void S_StartBackgroundTrack( const char *intro, const char *loop ){ int len; char dump[16]; char name[MAX_QPATH]; if ( !intro ) { intro = ""; } if ( !loop || !loop[0] ) { loop = intro; } Com_DPrintf( "S_StartBackgroundTrack( %s, %s )/n", intro, loop ); Q_strncpyz( name, intro, sizeof( name ) - 4 ); COM_DefaultExtension( name, sizeof( name ), ".wav" ); if ( !intro[0] ) { return; } Q_strncpyz( s_backgroundLoop, loop, sizeof( s_backgroundLoop ) ); // close the background track, but DON'T reset s_rawend // if restarting the same back ground track if ( s_backgroundFile ) { Sys_EndStreamedFile( s_backgroundFile ); FS_FCloseFile( s_backgroundFile ); s_backgroundFile = 0; } // // open up a wav file and get all the info // FS_FOpenFileRead( name, &s_backgroundFile, qtrue ); if ( !s_backgroundFile ) { Com_Printf( S_COLOR_YELLOW "WARNING: couldn't open music file %s/n", name ); return; } // skip the riff wav header FS_Read(dump, 12, s_backgroundFile); if ( !S_FindWavChunk( s_backgroundFile, "fmt " ) ) { Com_Printf( "No fmt chunk in %s/n", name ); FS_FCloseFile( s_backgroundFile ); s_backgroundFile = 0; return; } // save name for soundinfo s_backgroundInfo.format = FGetLittleShort( s_backgroundFile ); s_backgroundInfo.channels = FGetLittleShort( s_backgroundFile ); s_backgroundInfo.rate = FGetLittleLong( s_backgroundFile ); FGetLittleLong( s_backgroundFile ); FGetLittleShort( s_backgroundFile ); s_backgroundInfo.width = FGetLittleShort( s_backgroundFile ) / 8; if ( s_backgroundInfo.format != WAV_FORMAT_PCM ) { FS_FCloseFile( s_backgroundFile ); s_backgroundFile = 0; Com_Printf("Not a microsoft PCM format wav: %s/n", name); return; } if ( s_backgroundInfo.channels != 2 || s_backgroundInfo.rate != 22050 ) { Com_Printf(S_COLOR_YELLOW "WARNING: music file %s is not 22k stereo/n", name ); } if ( ( len = S_FindWavChunk( s_backgroundFile, "data" ) ) == 0 ) { FS_FCloseFile( s_backgroundFile ); s_backgroundFile = 0; Com_Printf("No data chunk in %s/n", name); return; } s_backgroundInfo.samples = len / (s_backgroundInfo.width * s_backgroundInfo.channels); s_backgroundSamples = s_backgroundInfo.samples; // // start the background streaming // Sys_BeginStreamedFile( s_backgroundFile, 0x10000 );}
开发者ID:zturtleman,项目名称:recoil,代码行数:100,
示例11: S_UpdateBackgroundTrack/*======================S_UpdateBackgroundTrack======================*/void S_UpdateBackgroundTrack( void ){ int bufferSamples; int fileSamples; byte raw[30000]; // just enough to fit in a mac stack frame int fileBytes; int r; static float musicVolume = 0.5f; if ( !s_backgroundFile ) { return; } // graeme see if this is OK musicVolume = (musicVolume + (s_musicVolume->value * 2))/4.0f; // don't bother playing anything if musicvolume is 0 if ( musicVolume <= 0 ) { return; } // see how many samples should be copied into the raw buffer if ( s_rawend < s_soundtime ) { s_rawend = s_soundtime; } while ( s_rawend < s_soundtime + MAX_RAW_SAMPLES ) { bufferSamples = MAX_RAW_SAMPLES - (s_rawend - s_soundtime); // decide how much data needs to be read from the file fileSamples = bufferSamples * s_backgroundInfo.rate / dma.speed; // don't try and read past the end of the file if ( fileSamples > s_backgroundSamples ) { fileSamples = s_backgroundSamples; } // our max buffer size fileBytes = fileSamples * (s_backgroundInfo.width * s_backgroundInfo.channels); if ( fileBytes > sizeof(raw) ) { fileBytes = sizeof(raw); fileSamples = fileBytes / (s_backgroundInfo.width * s_backgroundInfo.channels); } r = Sys_StreamedRead( raw, 1, fileBytes, s_backgroundFile ); if ( r != fileBytes ) { Com_Printf("StreamedRead failure on music track/n"); S_StopBackgroundTrack(); return; } // byte swap if needed S_ByteSwapRawSamples( fileSamples, s_backgroundInfo.width, s_backgroundInfo.channels, raw ); // add to raw buffer S_RawSamples( fileSamples, s_backgroundInfo.rate, s_backgroundInfo.width, s_backgroundInfo.channels, raw, musicVolume ); s_backgroundSamples -= fileSamples; if ( !s_backgroundSamples ) { // loop if (s_backgroundLoop[0]) { Sys_EndStreamedFile( s_backgroundFile ); FS_FCloseFile( s_backgroundFile ); s_backgroundFile = 0; S_StartBackgroundTrack( s_backgroundLoop, s_backgroundLoop ); if ( !s_backgroundFile ) { return; // loop failed to restart } } else { s_backgroundFile = 0; return; } } }}
开发者ID:zturtleman,项目名称:recoil,代码行数:93,
示例12: strlenstatic mufont_t *SCR_LoadMUFont( const char *name, size_t len ){ size_t filename_size; char *filename; qbyte *buf; char *ptr, *token, *start; int filenum; int length; mufont_t *font; struct shader_s *shader; int numchar; int x, y, w, h; filename_size = strlen( "fonts/" ) + len + strlen( ".tga" ) + 1; filename = Mem_TempMalloc( filename_size ); Q_snprintfz( filename, filename_size, "fonts/%s", name ); // load the shader COM_ReplaceExtension( filename, ".tga", filename_size ); shader = R_RegisterPic( filename ); if( !shader ) { Mem_TempFree( filename ); return NULL; } // load the font description COM_ReplaceExtension( filename, ".wfd", filename_size ); // load the file length = FS_FOpenFile( filename, &filenum, FS_READ ); if( length == -1 ) { Mem_TempFree( filename ); return NULL; } Mem_TempFree( filename ); buf = Mem_TempMalloc( length + 1 ); length = FS_Read( buf, length, filenum ); FS_FCloseFile( filenum ); if( !length ) { Mem_TempFree( buf ); return NULL; } // seems to be valid. Allocate it font = (mufont_t *)Font_Alloc( sizeof( mufont_t ) ); font->shader = shader; font->name = Font_Alloc( len + 1 ); Q_strncpyz( font->name, name, len + 1 ); // proceed ptr = ( char * )buf; // get texture width and height token = COM_Parse( &ptr ); if( !token[0] ) goto error; font->imagewidth = atoi( token ); token = COM_Parse( &ptr ); if( !token[0] ) goto error; font->imageheight = atoi( token ); font->numchars = MIN_FONT_CHARS; // get the number of chars start = ptr; while( ptr ) { // "<char>" "<x>" "<y>" "<width>" "<height>" token = COM_Parse( &ptr ); if( !token[0] ) break; numchar = atoi( token ); if( numchar <= 0 ) break; x = atoi( COM_Parse( &ptr ) ), y = atoi( COM_Parse( &ptr ) ); w = atoi( COM_Parse( &ptr ) ), h = atoi( COM_Parse( &ptr ) ); if( numchar < 32 || numchar >= MAX_FONT_CHARS ) continue; if( ( unsigned int )( numchar + 1 ) > font->numchars ) font->numchars = ( unsigned int )numchar + 1; } if( !font->numchars ) goto error; font->chars = Font_Alloc( font->numchars * sizeof( muchar_t ) ); // get the chars ptr = start; while( ptr )//.........这里部分代码省略.........
开发者ID:Racenet,项目名称:racesow,代码行数:101,
示例13: DL_Endvoid DL_End( CURLcode res, CURLMcode resm ){ CURLMsg *msg; int msgs; if( dl_verbose->integer == 0 && dl_showprogress->integer == 2 && !curlm ) Com_Printf( "/n" ); if( curlm ) { // res = final download result while( ( msg = curl_multi_info_read( curlm, &msgs ) ) ) { if( msg->msg != CURLMSG_DONE ) { if( dl_error[0] == '/0' ) Q_strncpyz( dl_error, "Download Interrupted.", sizeof(dl_error) ); } else if( msg->easy_handle == curl ) { if( msg->data.result != CURLE_OK ); res = msg->data.result; } else { Com_Printf( "Invalid cURL handle./n" ); } } curl_multi_cleanup( curlm ); curlm = NULL; } if( curl ) { curl_easy_cleanup( curl ); curl = NULL; } // get possible error messages if( !*dl_error && res != CURLE_OK ) Q_strncpyz( dl_error, curl_easy_strerror(res), sizeof(dl_error) ); if( !*dl_error && resm != CURLM_OK ) Q_strncpyz( dl_error, curl_multi_strerror(resm), sizeof(dl_error) ); if( !*dl_error && !f ) Q_strncpyz( dl_error, "File is not opened.", sizeof(dl_error) ); if (f) { FS_FCloseFile(f); f = 0; if (!*dl_error) { // download succeeded char dest[MAX_OSPATH]; Com_Printf("Download complete, restarting filesystem./n"); Q_strncpyz(dest, path, strlen(path)-3); // -4 +1 for the trailing /0 Q_strcat(dest, sizeof(dest), ".pk3"); if (!FS_FileExists(dest)) { FS_SV_Rename(path, dest); FS_Restart(clc.checksumFeed); if (dl_showmotd->integer && *motd) { Com_Printf("Server motd: %s/n", motd); } } else { // normally such errors should be caught upon starting the transfer. Anyway better do // it here again - the filesystem might have changed, plus this may help contain some // bugs / exploitable flaws in the code. Com_Printf("Failed to copy downloaded file to its location - file already exists./n"); FS_HomeRemove(path); } } else { FS_HomeRemove(path); } } Cvar_Set( "cl_downloadName", "" ); // hide the ui downloading screen Cvar_SetValue( "cl_downloadSize", 0 ); Cvar_SetValue( "cl_downloadCount", 0 ); Cvar_SetValue( "cl_downloadTime", 0 ); Cvar_Set( "cl_downloadMotd", "" ); if( *dl_error ) { if( clc.state == CA_CONNECTED ) Com_Error( ERR_DROP, "%s/n", dl_error ); // download error while connecting, can not continue loading else Com_Printf( "%s/n", dl_error ); // download error while in game, do not disconnect *dl_error = '/0'; } else { if (strlen(Cvar_VariableString("cl_downloadDemo"))) { Cbuf_AddText( va("demo %s/n", Cvar_VariableString("cl_downloadDemo") ) ); // download completed, request new gamestate to check possible new map if we are not already in game } else if( clc.state == CA_CONNECTED) CL_AddReliableCommand( "donedl", qfalse); // get new gamestate info from server }}
开发者ID:dourvaris,项目名称:iodfe,代码行数:97,
示例14: 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", 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_Read( 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_DELETEFILE: return FS_Delete( VMA( 1 ) ); case UI_FS_GETFILELIST: return FS_GetFileList( VMA( 1 ), VMA( 2 ), VMA( 3 ), args[4] ); 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:jonathangray,项目名称:rtcw-mp-openbsd,代码行数:101,
示例15: logfile_writestatic void logfile_write(print_type_t type, const char *s){ char text[MAXPRINTMSG]; char buf[MAX_QPATH]; char *p, *maxp; size_t len; ssize_t ret; int c; if (logfile_prefix->string[0]) { p = strchr(logfile_prefix->string, '@'); if (p) { // expand it in place, hacky switch (type) { case PRINT_TALK: *p = 'T'; break; case PRINT_DEVELOPER: *p = 'D'; break; case PRINT_WARNING: *p = 'W'; break; case PRINT_ERROR: *p = 'E'; break; case PRINT_NOTICE: *p = 'N'; break; default: *p = 'A'; break; } } len = format_local_time(buf, sizeof(buf), logfile_prefix->string); if (p) { *p = '@'; } } else { len = 0; } p = text; maxp = text + sizeof(text) - 1; while (*s) { if (com_logNewline) { if (len > 0 && p + len < maxp) { memcpy(p, buf, len); p += len; } com_logNewline = qfalse; } if (p == maxp) { break; } c = *s++; if (c == '/n') { com_logNewline = qtrue; } else { c = Q_charascii(c); } *p++ = c; } *p = 0; len = p - text; ret = FS_Write(text, len, com_logFile); if (ret != len) { // zero handle BEFORE doing anything else to avoid recursion qhandle_t tmp = com_logFile; com_logFile = 0; FS_FCloseFile(tmp); Com_EPrintf("Couldn't write console log: %s/n", Q_ErrorString(ret)); Cvar_Set("logfile", "0"); }}
开发者ID:jayschwa,项目名称:q2pro,代码行数:67,
示例16: CL_CgameSystemCalls/** * @brief The cgame module is making a system call * @param[in] args * @return */intptr_t CL_CgameSystemCalls(intptr_t *args){ switch (args[0]) { case CG_PRINT: Com_Printf("%s", (char *)VMA(1)); return 0; case CG_ERROR: Com_Error(ERR_DROP, "%s", (char *)VMA(1)); 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_CVAR_LATCHEDVARIABLESTRINGBUFFER: Cvar_LatchedVariableStringBuffer(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_FS_GETFILELIST: return FS_GetFileList(VMA(1), VMA(2), VMA(3), args[4]); case CG_FS_DELETEFILE: return FS_Delete(VMA(1)); case CG_SENDCONSOLECOMMAND: Cbuf_AddText(VMA(1)); return 0; case CG_ADDCOMMAND: Cmd_AddCommand(VMA(1)); return 0; case CG_REMOVECOMMAND: Cmd_RemoveCommandSafe(VMA(1)); return 0; case CG_SENDCLIENTCOMMAND: CL_AddReliableCommand(VMA(1)); return 0; case CG_UPDATESCREEN: 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_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_R_PROJECTDECAL: re.ProjectDecal(args[1], args[2], VMA(3), VMA(4), VMA(5), args[6], args[7]);//.........这里部分代码省略.........
开发者ID:zturtleman,项目名称:etlegacy,代码行数:101,
示例17: SV_FinalMessage/*=====================SV_DropClientCalled when the player is totally leaving the server, either willinglyor unwillingly. This is NOT called if the entire server is quitingor crashing -- SV_FinalMessage() will handle that=====================*/void SV_DropClient( client_t *drop, const char *reason ) { int i; challenge_t *challenge; const qboolean isBot = drop->netchan.remoteAddress.type == NA_BOT; if ( drop->state == CS_ZOMBIE ) { return; // already dropped } if ( !isBot ) { // see if we already have a challenge for this ip challenge = &svs.challenges[0]; for (i = 0 ; i < MAX_CHALLENGES ; i++, challenge++) { if(NET_CompareAdr(drop->netchan.remoteAddress, challenge->adr)) { Com_Memset(challenge, 0, sizeof(*challenge)); break; } } } // Kill any download SV_CloseDownload( drop ); // tell everyone why they got dropped SV_SendServerCommand( NULL, "print /"%s" S_COLOR_WHITE " %s/n/"", drop->name, reason ); if (drop->download) { FS_FCloseFile( drop->download ); drop->download = 0; } // call the prog function for removing a client // this will remove the body, among other things VM_Call( gvm, GAME_CLIENT_DISCONNECT, drop - svs.clients ); // add the disconnect command SV_SendServerCommand( drop, "disconnect /"%s/"", reason); if ( isBot ) { SV_BotFreeClient( drop - svs.clients ); } // nuke user info SV_SetUserinfo( drop - svs.clients, "" ); if ( isBot ) { // bots shouldn't go zombie, as there's no real net connection. drop->state = CS_FREE; } else { Com_DPrintf( "Going to CS_ZOMBIE for %s/n", drop->name ); drop->state = CS_ZOMBIE; // become free in a few seconds } // if this was the last client on the server, send a heartbeat // to the master so it is known the server is empty // send a heartbeat now so the master will get up to date info // if there is already a slot for this ip, reuse it for (i=0 ; i < sv_maxclients->integer ; i++ ) { if ( svs.clients[i].state >= CS_CONNECTED ) { break; } } if ( i == sv_maxclients->integer ) { SV_Heartbeat_f(); }}
开发者ID:burzumishi,项目名称:dragonballworld,代码行数:78,
示例18: _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,
示例19: SV_RehashBans_f/*==================SV_RehashBans_fLoad saved bans from file.==================*/static void SV_RehashBans_f(void){ int index, filelen; fileHandle_t readfrom; char *textbuf, *curpos, *maskpos, *newlinepos, *endpos; char filepath[MAX_QPATH]; // make sure server is running if ( !com_sv_running->integer ) { return; } serverBansCount = 0; if(!sv_banFile->string || !*sv_banFile->string) return; Com_sprintf(filepath, sizeof(filepath), "%s/%s", FS_GetCurrentGameDir(), sv_banFile->string); if((filelen = FS_SV_FOpenFileRead(filepath, &readfrom)) >= 0) { if(filelen < 2) { // Don't bother if file is too short. FS_FCloseFile(readfrom); return; } curpos = textbuf = Z_Malloc(filelen); filelen = FS_Read(textbuf, filelen, readfrom); FS_FCloseFile(readfrom); endpos = textbuf + filelen; for(index = 0; index < SERVER_MAXBANS && curpos + 2 < endpos; index++) { // find the end of the address string for(maskpos = curpos + 2; maskpos < endpos && *maskpos != ' '; maskpos++); if(maskpos + 1 >= endpos) break; *maskpos = '/0'; maskpos++; // find the end of the subnet specifier for(newlinepos = maskpos; newlinepos < endpos && *newlinepos != '/n'; newlinepos++); if(newlinepos >= endpos) break; *newlinepos = '/0'; if(NET_StringToAdr(curpos + 2, &serverBans[index].ip, NA_UNSPEC)) { serverBans[index].isexception = (curpos[0] != '0'); serverBans[index].subnet = atoi(maskpos); if(serverBans[index].ip.type == NA_IP && (serverBans[index].subnet < 1 || serverBans[index].subnet > 32)) { serverBans[index].subnet = 32; } else if(serverBans[index].ip.type == NA_IP6 && (serverBans[index].subnet < 1 || serverBans[index].subnet > 128)) { serverBans[index].subnet = 128; } } curpos = newlinepos + 1; } serverBansCount = index; Z_Free(textbuf); }}
开发者ID:CarlGammaSagan,项目名称:Quake-3-Android-Port-QIII4A,代码行数:86,
示例20: S_StreamClosestatic void S_StreamClose( openSound_t *open ) { if ( open->fileHandle > 0) { FS_FCloseFile( open->fileHandle ); open->fileHandle = 0; }}
开发者ID:entdark,项目名称:q3mme,代码行数:6,
示例21: 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_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: if(args[1] == 0 && (!strncmp(VMA(2), "snd_restart", 11) || !strncmp(VMA(2), "vid_restart", 11) || !strncmp(VMA(2), "quit", 5))) { Com_DPrintf (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_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) );//.........这里部分代码省略.........
开发者ID:shawnd,项目名称:urt-bumpy-engine,代码行数:101,
示例22: CL_ParseDownload//.........这里部分代码省略......... // we'll let the server disconnect us when it gets the bbl8r message if (cls.download.downloadFlags & (1 << DL_FLAG_DISCON)) { CL_AddReliableCommand("wwwdl bbl8r"); cls.download.bWWWDlDisconnected = qtrue; } return; } else { // server keeps sending that message till we acknowledge 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 cls.download.downloadSize = MSG_ReadLong(msg); Cvar_SetValue("cl_downloadSize", cls.download.downloadSize); if (cls.download.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 (cls.download.downloadBlock != block) { Com_DPrintf("CL_ParseDownload: Expected block %d, got %d/n", cls.download.downloadBlock, block); return; } // open the file if not opened yet if (!cls.download.download) { cls.download.download = FS_SV_FOpenFileWrite(cls.download.downloadTempName); if (!cls.download.download) { Com_Printf("Could not create %s/n", cls.download.downloadTempName); CL_AddReliableCommand("stopdl"); Com_NextDownload(); return; } } if (size) { FS_Write(data, size, cls.download.download); } CL_AddReliableCommand(va("nextdl %d", cls.download.downloadBlock)); cls.download.downloadBlock++; cls.download.downloadCount += size; // So UI gets access to it Cvar_SetValue("cl_downloadCount", cls.download.downloadCount); if (!size) // A zero length block means EOF { if (cls.download.download) { FS_FCloseFile(cls.download.download); cls.download.download = 0; // rename the file FS_SV_Rename(cls.download.downloadTempName, cls.download.downloadName); } *cls.download.downloadTempName = *cls.download.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 Com_NextDownload(); }}
开发者ID:dstaesse,项目名称:etlegacy,代码行数:101,
示例23: S_CodecUtilClose/*=================S_CodecUtilClose=================*/void S_CodecUtilClose(snd_stream_t **stream){ FS_FCloseFile((*stream)->file); Z_Free(*stream); *stream = NULL;}
开发者ID:LoudHoward,项目名称:Quake3,代码行数:11,
示例24: SV_AddBanToList//.........这里部分代码省略......... } if(serverBansCount > sizeof(serverBans) / sizeof(*serverBans)) { Com_Printf ("Error: Maximum number of bans/exceptions exceeded./n"); return; } banstring = Cmd_Argv(1); if(strchr(banstring, '.') || strchr(banstring, ':')) { // This is an ip address, not a client num. // Look for a CIDR-Notation suffix suffix = strchr(banstring, '/'); if(suffix) { *suffix = '/0'; suffix++; } if(!NET_StringToAdr(banstring, &ip, NA_UNSPEC)) { Com_Printf("Error: Invalid address %s/n", banstring); return; } } else { client_t *cl; // client num. if(!com_sv_running->integer) { Com_Printf("Server is not running./n"); return; } cl = SV_GetPlayerByNum(); if(!cl) { Com_Printf("Error: Playernum %s does not exist./n", Cmd_Argv(1)); return; } ip = cl->netchan.remoteAddress; if(argc == 3) suffix = Cmd_Argv(2); else suffix = NULL; } if(ip.type != NA_IP && ip.type != NA_IP6) { Com_Printf("Error: Can ban players connected via the internet only./n"); return; } if(suffix) { mask = atoi(suffix); if(ip.type == NA_IP) { if(mask < 0 || mask > 32) mask = 32; } else { if(mask < 0 || mask > 128) mask = 128; } } else if(ip.type == NA_IP) mask = 32; else mask = 128; serverBans[serverBansCount].ip = ip; serverBans[serverBansCount].subnet = mask; serverBans[serverBansCount].isexception = isexception; Com_Printf("Added %s: %s/%d/n", isexception ? "ban exception" : "ban", NET_AdrToString(ip), mask); // Write out the ban information. if((writeto = FS_FOpenFileAppend(SERVER_BANFILE))) { char writebuf[128]; Com_sprintf(writebuf, sizeof(writebuf), "%d %s %d/n", isexception, NET_AdrToString(ip), mask); FS_Write(writebuf, strlen(writebuf), writeto); FS_FCloseFile(writeto); } serverBansCount++;}
开发者ID:shawnd,项目名称:urt-bumpy-engine,代码行数:101,
示例25: variation/*====================CL_UpdateLevelHunkUsage This updates the "hunkusage.dat" file with the current map and it's hunk usage count This is used for level loading, so we can show a percentage bar dependant on the amount of hunk memory allocated so far This will be slightly inaccurate if some settings like sound quality are changed, but these things should only account for a small variation (hopefully)====================*/void CL_UpdateLevelHunkUsage( void ) { int handle; char *memlistfile = "hunkusage.dat"; char *buf, *outbuf; char *buftrav, *outbuftrav; char *token; char outstr[256]; int len, memusage; memusage = Cvar_VariableIntegerValue( "com_hunkused" ) + Cvar_VariableIntegerValue( "hunk_soundadjust" ); len = FS_FOpenFileByMode( memlistfile, &handle, FS_READ ); if ( len >= 0 ) { // the file exists, so read it in, strip out the current entry for this map, and save it out, so we can append the new value buf = (char *)Z_Malloc( len + 1 ); memset( buf, 0, len + 1 ); outbuf = (char *)Z_Malloc( len + 1 ); memset( outbuf, 0, len + 1 ); FS_Read( (void *)buf, len, handle ); FS_FCloseFile( handle ); // now parse the file, filtering out the current map buftrav = buf; outbuftrav = outbuf; outbuftrav[0] = '/0'; while ( ( token = COM_Parse( &buftrav ) ) && token[0] ) { if ( !Q_strcasecmp( token, cl.mapname ) ) { // found a match token = COM_Parse( &buftrav ); // read the size if ( token && token[0] ) { if ( atoi( token ) == memusage ) { // if it is the same, abort this process Z_Free( buf ); Z_Free( outbuf ); return; } } } else { // send it to the outbuf Q_strcat( outbuftrav, len + 1, token ); Q_strcat( outbuftrav, len + 1, " " ); token = COM_Parse( &buftrav ); // read the size if ( token && token[0] ) { Q_strcat( outbuftrav, len + 1, token ); Q_strcat( outbuftrav, len + 1, "/n" ); } else { Com_Error( ERR_DROP, "hunkusage.dat file is corrupt/n" ); } } }#ifdef __MACOS__ //DAJ MacOS file typing { extern _MSL_IMP_EXP_C long _fcreator, _ftype; _ftype = 'TEXT'; _fcreator = 'WlfS'; }#endif handle = FS_FOpenFileWrite( memlistfile ); if ( handle < 0 ) { Com_Error( ERR_DROP, "cannot create %s/n", memlistfile ); } // input file is parsed, now output to the new file len = strlen( outbuf ); if ( FS_Write( (void *)outbuf, len, handle ) != len ) { Com_Error( ERR_DROP, "cannot write to %s/n", memlistfile ); } FS_FCloseFile( handle ); Z_Free( buf ); Z_Free( outbuf ); } // now append the current map to the current file FS_FOpenFileByMode( memlistfile, &handle, FS_APPEND ); if ( handle < 0 ) { Com_Error( ERR_DROP, "cannot write to hunkusage.dat, check disk full/n" ); } Com_sprintf( outstr, sizeof( outstr ), "%s %i/n", cl.mapname, memusage ); FS_Write( outstr, strlen( outstr ), handle ); FS_FCloseFile( handle ); // now just open it and close it, so it gets copied to the pak dir len = FS_FOpenFileByMode( memlistfile, &handle, FS_READ ); if ( len >= 0 ) { FS_FCloseFile( handle ); }}
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:99,
示例26: demoCut//.........这里部分代码省略......... goto cuterror; } Com_sprintf(newName, sizeof(newName), "demos/%s_cut%s", oldName, ext); newHandle = FS_FOpenFileWrite(newName); if (!newHandle) { Com_Printf("Failed to open %s for target cutting./n", newName); return qfalse; } readGamestate++; break; case svc_snapshot: if (!demoCutParseSnapshot(&oldMsg, &demo.cut.Clc, &demo.cut.Cl)) { goto cuterror; } break; case svc_download: // read block number buf = MSG_ReadShort(&oldMsg); if (!buf) //0 block, read file size MSG_ReadLong(&oldMsg); // read block size buf = MSG_ReadShort(&oldMsg); // read the data block for (;buf>0;buf--) MSG_ReadByte(&oldMsg); break; case svc_setgame: i = 0; while (i < MAX_QPATH) { next = MSG_ReadByte(&oldMsg); if(next) { newGameDir[i] = next; } else { break; } i++; } newGameDir[i] = 0; // But here we stop, and don't do more. If this goes horribly wrong sometime, you might have to go and actually do something with this. break; case svc_mapchange: // nothing to parse. break; } } int firstServerCommand = demo.cut.Clc.lastExecutedServerCommand; // process any new server commands for (;demo.cut.Clc.lastExecutedServerCommand < demo.cut.Clc.serverCommandSequence; demo.cut.Clc.lastExecutedServerCommand++) { char *command = demo.cut.Clc.serverCommands[demo.cut.Clc.lastExecutedServerCommand & (MAX_RELIABLE_COMMANDS - 1)]; Cmd_TokenizeString(command); char *cmd = Cmd_Argv(0); if (cmd[0]) { firstServerCommand = demo.cut.Clc.lastExecutedServerCommand; } if (!strcmp(cmd, "cs")) { if (!demoCutConfigstringModified(&demo.cut.Cl)) { goto cuterror; } } } if (demo.cut.Cl.snap.serverTime > endTime) { goto cutcomplete; } else if (framesSaved > 0) { /* this msg is in range, write it */ if (framesSaved > max(10, demo.cut.Cl.snap.messageNum - demo.cut.Cl.snap.deltaNum)) { demoCutWriteDemoMessage(&oldMsg, newHandle, &demo.cut.Clc); } else { demoCutWriteDeltaSnapshot(firstServerCommand, newHandle, qfalse, &demo.cut.Clc, &demo.cut.Cl); } framesSaved++; } else if (demo.cut.Cl.snap.serverTime >= startTime) { demoCutWriteDemoHeader(newHandle, &demo.cut.Clc, &demo.cut.Cl); demoCutWriteDeltaSnapshot(firstServerCommand, newHandle, qtrue, &demo.cut.Clc, &demo.cut.Cl); // copy rest framesSaved = 1; } }cutcomplete: if (newHandle) { buf = -1; FS_Write(&buf, 4, newHandle); FS_Write(&buf, 4, newHandle); ret = qtrue; }cuterror: //remove previosly converted demo from the same cut if (newHandle) { memset(newName, 0, sizeof(newName)); if (demo.currentNum > 0) { Com_sprintf(newName, sizeof(newName), "mmedemos/%s.%d_cut.mme", oldName, demo.currentNum); } else { Com_sprintf(newName, sizeof(newName), "mmedemos/%s_cut.mme", oldName); } if (FS_FileExists(newName)) FS_FileErase(newName); } FS_FCloseFile(oldHandle); FS_FCloseFile(newHandle); return ret;}
开发者ID:deathsythe47,项目名称:jaMME,代码行数:101,
示例27: CL_ParseDownload/*=====================CL_ParseDownloadA download message has been received from the server=====================*/void CL_ParseDownload ( msg_t *msg ) { int size; unsigned char data[MAX_MSGLEN]; uint16_t block; if (!*clc.downloadTempName) { Com_Printf("Server sending download, but no download was requested/n"); CL_AddReliableCommand("stopdl", qfalse); return; } // read the data block = MSG_ReadShort ( msg ); if(!block && !clc.downloadBlock) { // 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 & 0xFFFF) != block) { Com_DPrintf( "CL_ParseDownload: Expected block %d, got %d/n", (clc.downloadBlock & 0xFFFF), block); return; } // open the file if not opened yet if (!clc.download) { clc.download = FS_SV_FOpenFileWrite( clc.downloadTempName ); if (!clc.download) { Com_Printf( "Could not create %s/n", clc.downloadTempName ); CL_AddReliableCommand("stopdl", qfalse); CL_NextDownload(); return; } } if (size) FS_Write( data, size, clc.download ); CL_AddReliableCommand(va("nextdl %d", clc.downloadBlock), qfalse); 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 ( clc.downloadTempName, clc.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 (); }}
开发者ID:Ced2911,项目名称:Ioquake3Xe,代码行数:95,
示例28: SV_AutoUpdateFromWeb/** SV_AutoUpdateFromWeb*/void SV_AutoUpdateFromWeb( qboolean checkOnly ){ static const char *autoUpdateBaseUrl = APP_UPDATE_URL APP_SERVER_UPDATE_DIRECTORY; char checksumString1[32], checksumString2[32]; unsigned int checksum; qboolean success; int length, filenum; qbyte *data; const char *token, *ptr; char path[MAX_QPATH]; int downloadCount = 0, downloadFailed = 0; char newVersionTag[MAX_QPATH]; qboolean newVersion = qfalse; if( !dedicated->integer ) return; assert( svs.mapcmd[0] ); if( !checkOnly ) SV_UpdateActivity(); Com_Printf( "/n" ); Com_Printf( "========== Starting Auto Update ===========/n" ); Com_Printf( "Checking for updates/n" ); // download the update file list success = SV_WebDownload( autoUpdateBaseUrl, APP_SERVER_UPDATE_FILE, qtrue, qtrue ); // set as last updated today if( !checkOnly ) Cvar_ForceSet( "sv_lastAutoUpdate", va( "%i", (int)Com_DaysSince1900() ) ); if( !success ) // no update to do goto done; // read the file list if( ( length = FS_FOpenBaseFile( APP_SERVER_UPDATE_FILE, &filenum, FS_READ ) ) == -1 ) { Com_Printf( "WARNING: Couldn't find %s/n", path ); goto done; } if( !length ) { FS_FCloseFile( filenum ); goto done; } data = Mem_TempMalloc( length + 1 ); FS_Read( data, length, filenum ); FS_FCloseFile( filenum ); FS_RemoveBaseFile( APP_SERVER_UPDATE_FILE ); ptr = (const char *)data; // first token is always the current release version token = COM_ParseExt( &ptr, qtrue ); if( !token[0] ) goto cancel; // compare versions Q_strncpyz( newVersionTag, token, sizeof( newVersionTag ) ); if( atof( newVersionTag ) > atof( va( "%4.3f", APP_VERSION ) ) ) newVersion = qtrue; while( ptr ) { // we got what should be a checksum token = COM_ParseExt( &ptr, qtrue ); if( !token[0] ) goto cancel; // copy checksum reported by server Q_strncpyz( checksumString1, token, sizeof( checksumString1 ) ); // get filename token = COM_ParseExt( &ptr, qtrue ); if( !token[0] ) goto cancel; // filename should never begin with a slash if( token[0] == '/' ) token++; Q_strncpyz( path, token, sizeof( path ) ); // we got what should be a file path if( !COM_ValidateRelativeFilename( path ) ) { Com_Printf( "WARNING: Invalid filename %s/n", path ); continue; } checksum = FS_ChecksumBaseFile( path ); Q_snprintfz( checksumString2, sizeof( checksumString2 ), "%u", checksum );//.........这里部分代码省略.........
开发者ID:j0ki,项目名称:racesow,代码行数:101,
注:本文中的FS_FCloseFile函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ FS_FOpenFile函数代码示例 C++ FS_CreatePath函数代码示例 |