这篇教程C++ trap_FS_FCloseFile函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中trap_FS_FCloseFile函数的典型用法代码示例。如果您正苦于以下问题:C++ trap_FS_FCloseFile函数的具体用法?C++ trap_FS_FCloseFile怎么用?C++ trap_FS_FCloseFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了trap_FS_FCloseFile函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: G_xpsave_writeconfig//.........这里部分代码省略......... trap_FS_Write("rating = ", 20, f); G_shrubbot_writeconfig_float(g_serverstat.rating, f); trap_FS_Write("rating_variance = ", 20, f); G_shrubbot_writeconfig_float(g_serverstat.rating_variance, f); trap_FS_Write("distance_rating = ", 20, f); G_shrubbot_writeconfig_float(g_serverstat.distance_rating, f); trap_FS_Write("distance_variance = ", 20, f); G_shrubbot_writeconfig_float(g_serverstat.distance_variance, f); trap_FS_Write("/n", 1, f); G_Printf("xpsave: wrote server rating: %f/n", g_serverstat.rating); for(i=0; g_mapstats[i]; i++) { trap_FS_Write("[mapstat]/n", 10, f); trap_FS_Write("name = ", 20, f); G_shrubbot_writeconfig_string(g_mapstats[i]->name, f); trap_FS_Write("rating = ", 20, f); G_shrubbot_writeconfig_float(g_mapstats[i]->rating, f); trap_FS_Write("rating_variance = ", 20, f); G_shrubbot_writeconfig_float(g_mapstats[i]->rating_variance, f); trap_FS_Write("spree_record = ", 20, f); G_shrubbot_writeconfig_int(g_mapstats[i]->spreeRecord, f); trap_FS_Write("spree_name = ", 20, f); G_shrubbot_writeconfig_string(g_mapstats[i]->spreeName, f); trap_FS_Write("/n", 1, f); } G_Printf("xpsave: wrote %d mapstats/n", i); for(i=0; g_xpsaves[i]; i++) { if(!g_xpsaves[i]->time) continue; age = t - g_xpsaves[i]->time; if(age > eff_XPSaveMaxAge) { continue; } trap_FS_Write("[xpsave]/n", 9, f); trap_FS_Write("guid = ", 20, f); G_shrubbot_writeconfig_string(g_xpsaves[i]->guid, f); trap_FS_Write("name = ", 20, f); G_shrubbot_writeconfig_string(g_xpsaves[i]->name, f); trap_FS_Write("time = ", 20, f); G_shrubbot_writeconfig_int(g_xpsaves[i]->time, f); if(age <= eff_XPSaveMaxAge_xp) { for(j=0; j<SK_NUM_SKILLS; j++) { if(g_xpsaves[i]->skill[j] == 0.0f) continue; trap_FS_Write(va("skill[%i] = ", j), 20, f); G_shrubbot_writeconfig_float( g_xpsaves[i]->skill[j], f); } } if(g_xpsaves[i]->kill_rating != 0.0f) { trap_FS_Write("kill_rating = ", 20, f); G_shrubbot_writeconfig_float(g_xpsaves[i]->kill_rating, f); } if(g_xpsaves[i]->kill_variance != SIGMA2_DELTA) { trap_FS_Write("kill_variance = ", 20, f); G_shrubbot_writeconfig_float(g_xpsaves[i]->kill_variance, f); } if(g_xpsaves[i]->rating != 0) { trap_FS_Write("rating = ", 20, f); G_shrubbot_writeconfig_float( g_xpsaves[i]->rating, f); } if(g_xpsaves[i]->rating_variance != SIGMA2_THETA) { trap_FS_Write("rating_variance = ", 20, f); G_shrubbot_writeconfig_float( g_xpsaves[i]->rating_variance, f); } if(g_xpsaves[i]->mutetime) { trap_FS_Write("mutetime = ", 20, f); G_shrubbot_writeconfig_int(g_xpsaves[i]->mutetime, f); } if(g_playerRating.integer & PLAYER_RATING_SKILLS) { for(j=0; j<SK_NUM_SKILLS; j++) { trap_FS_Write(va("pr_skill[%i] = ", j), 20, f); G_shrubbot_writeconfig_string( va("%i %f %i %f %i %f %i %f %i %f", g_xpsaves[i]->pr_skill_updates[j][0], g_xpsaves[i]->pr_skill[j][0], g_xpsaves[i]->pr_skill_updates[j][1], g_xpsaves[i]->pr_skill[j][1], g_xpsaves[i]->pr_skill_updates[j][2], g_xpsaves[i]->pr_skill[j][2], g_xpsaves[i]->pr_skill_updates[j][3], g_xpsaves[i]->pr_skill[j][3], g_xpsaves[i]->pr_skill_updates[j][4], g_xpsaves[i]->pr_skill[j][4]), f); } } trap_FS_Write("/n", 1, f); } G_Printf("xpsave: wrote %d xpsaves/n", i); trap_FS_FCloseFile(f);}
开发者ID:BulldogDrummond,项目名称:etpub,代码行数:101,
示例2: Load_Autosavesvoid Load_Autosaves(void){//load in our autosave from the .autosp char *s; int len; fileHandle_t f; char buf[MAX_AUTOSAVE_FILESIZE]; char loadPath[MAX_QPATH]; vec3_t positionData; int sizeData; //[RawMapName] //vmCvar_t mapname; //[/RawMapName] qboolean teleportPlayers = qfalse; G_Printf("^5Loading Autosave File Data..."); //[RawMapName] //trap_Cvar_Register( &mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM ); //Com_sprintf(loadPath, MAX_QPATH, "maps/%s.autosp", mapname.string); Com_sprintf(loadPath, sizeof(loadPath), "maps/%s.autosp", level.rawmapname); //[/RawMapName] len = trap_FS_FOpenFile( loadPath, &f, FS_READ ); if ( !f ) { G_Printf("^5No autosave file found./n"); return; } if ( !len ) { //empty file G_Printf("^5Empty autosave file!/n"); trap_FS_FCloseFile( f ); return; } trap_FS_Read( buf, len, f ); trap_FS_FCloseFile( f ); s = buf; while(*s != '/0' && s-buf < len) { if(*s == '/n') {//hop over newlines s++; continue; } sscanf(s, "%f %f %f %i %i", &positionData[0], &positionData[1], &positionData[2], &sizeData, &teleportPlayers); Create_Autosave( positionData, sizeData, teleportPlayers ); //advance to the end of the line while(*s != '/n' && *s != '/0' && s-buf < len) { s++; } } G_Printf("^5Done./n");}
开发者ID:jwginge,项目名称:ojpa,代码行数:62,
示例3: G_Script_ScriptLoad/*=============G_Script_ScriptLoad Loads the script for the current level into the buffer=============*/void G_Script_ScriptLoad(void) { char filename[MAX_QPATH]; vmCvar_t mapname; fileHandle_t f = 0; int len = 0; qboolean found = qfalse; trap_Cvar_Register(&g_scriptDebug, "g_scriptDebug", "0", 0); trap_Cvar_VariableStringBuffer("g_scriptName", filename, sizeof (filename)); if (filename[0] != '/0') { trap_Cvar_Register(&mapname, "g_scriptName", "", CVAR_CHEAT); } else { trap_Cvar_Register(&mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM); } // Nico, if API is used and if a mapscript was sent for this map don't load any local script if (g_useAPI.integer && level.useAPImapscript) { G_Printf("%s: using custom mapscript from API!/n", GAME_VERSION); return; } // Nico, API is not in use, check if this map a special mapscript in local mapscript directory if (!g_useAPI.integer && g_mapScriptDirectory.string[0]) { G_Printf("%s: checking for local custom mapscript.../n", GAME_VERSION); Q_strncpyz(filename, g_mapScriptDirectory.string, sizeof (filename)); Q_strcat(filename, sizeof (filename), "/"); Q_strcat(filename, sizeof (filename), mapname.string); Q_strcat(filename, sizeof (filename), ".script"); len = trap_FS_FOpenFile(filename, &f, FS_READ); if (len > 0) { found = qtrue; G_Printf("%s: found local file '%s'!/n", GAME_VERSION, filename); } else { G_Printf("%s: no local file found!/n", GAME_VERSION); } } // Nico, should we use default map script or custom one? if (!found) { Q_strncpyz(filename, "maps/", sizeof (filename)); Q_strcat(filename, sizeof (filename), mapname.string); Q_strcat(filename, sizeof (filename), ".script"); len = trap_FS_FOpenFile(filename, &f, FS_READ); G_Printf("%s: using default mapscript!/n", GAME_VERSION); } // make sure we clear out the temporary scriptname trap_Cvar_Set("g_scriptName", ""); if (len < 0) { return; } // END Mad Doc - TDF // Arnout: make sure we terminate the script with a '/0' to prevent parser from choking level.scriptEntity = NULL; level.scriptEntity = G_Alloc(len + 1); trap_FS_Read(level.scriptEntity, len, f); *(level.scriptEntity + len) = '/0'; // Gordon: and make sure ppl haven't put stuff with uppercase in the string table.. G_Script_EventStringInit(); trap_FS_FCloseFile(f);}
开发者ID:ETrun,项目名称:ETrun,代码行数:72,
示例4: CG_InitSiegeModevoid CG_InitSiegeMode(void){ char levelname[MAX_QPATH]; char btime[1024]; char teams[2048]; char teamInfo[MAX_SIEGE_INFO_SIZE]; int len = 0; int i = 0; int j = 0; siegeClass_t *cl; siegeTeam_t *sTeam; fileHandle_t f; char teamIcon[128]; if (cgs.gametype != GT_SIEGE) { goto failure; } Com_sprintf(levelname, sizeof(levelname), "%s/0", cgs.mapname); i = strlen(levelname)-1; while (i > 0 && levelname[i] && levelname[i] != '.') { i--; } if (!i) { goto failure; } levelname[i] = '/0'; //kill the ".bsp" Com_sprintf(levelname, sizeof(levelname), "%s.siege/0", levelname); if (!levelname || !levelname[0]) { goto failure; } len = trap_FS_FOpenFile(levelname, &f, FS_READ); if (!f || len >= MAX_SIEGE_INFO_SIZE) { goto failure; } trap_FS_Read(siege_info, len, f); trap_FS_FCloseFile(f); siege_valid = 1; if (BG_SiegeGetValueGroup(siege_info, "Teams", teams)) { char buf[1024]; //[SIEGECVARFIX] siege_Cvar_VariableStringBuffer("cg_siegeTeam1", buf, 1024); //trap_Cvar_VariableStringBuffer("cg_siegeTeam1", buf, 1024); //[SIEGECVARFIX] if (buf[0] && Q_stricmp(buf, "none")) { strcpy(team1, buf); } else { BG_SiegeGetPairedValue(teams, "team1", team1); } if (team1[0] == '@') { //it's a damn stringed reference. char b[256]; trap_SP_GetStringTextString(team1+1, b, 256); trap_Cvar_Set("cg_siegeTeam1Name", b); } else { trap_Cvar_Set("cg_siegeTeam1Name", team1); } //[SIEGECVARFIX] siege_Cvar_VariableStringBuffer("cg_siegeTeam2", buf, 1024); //trap_Cvar_VariableStringBuffer("cg_siegeTeam2", buf, 1024); //[/SIEGECVARFIX] if (buf[0] && Q_stricmp(buf, "none")) { strcpy(team2, buf); } else { BG_SiegeGetPairedValue(teams, "team2", team2); } if (team2[0] == '@') { //it's a damn stringed reference. char b[256]; trap_SP_GetStringTextString(team2+1, b, 256);//.........这里部分代码省略.........
开发者ID:ForcePush,项目名称:OJPRPFZ,代码行数:101,
示例5: CG_ParseBuildableAnimationFile/*======================CG_ParseBuildableAnimationFileRead a configuration file containing animation counts and ratesmodels/buildables/hivemind/animation.cfg, etc======================*/static qboolean CG_ParseBuildableAnimationFile( const char *filename, buildable_t buildable ){ char *text_p; int len; int i; char *token; float fps; char text[ 20000 ]; fileHandle_t f; animation_t *animations; animations = cg_buildables[ buildable ].animations; // load the file len = trap_FS_FOpenFile( filename, &f, FS_READ ); if( len <= 0 ) return qfalse; if( len >= sizeof( text ) - 1 ) { CG_Printf( "File %s too long/n", filename ); return qfalse; } trap_FS_Read( text, len, f ); text[ len ] = 0; trap_FS_FCloseFile( f ); // parse the text text_p = text; // read information for each frame for( i = BANIM_NONE + 1; i < MAX_BUILDABLE_ANIMATIONS; i++ ) { token = COM_Parse( &text_p ); if( !*token ) break; animations[ i ].firstFrame = atoi( token ); token = COM_Parse( &text_p ); if( !*token ) break; animations[ i ].numFrames = atoi( token ); animations[ i ].reversed = qfalse; animations[ i ].flipflop = qfalse; // if numFrames is negative the animation is reversed if( animations[ i ].numFrames < 0 ) { animations[ i ].numFrames = -animations[ i ].numFrames; animations[ i ].reversed = qtrue; } token = COM_Parse( &text_p ); if ( !*token ) break; animations[i].loopFrames = atoi( token ); token = COM_Parse( &text_p ); if( !*token ) break; fps = atof( token ); if( fps == 0 ) fps = 1; animations[ i ].frameLerp = 1000 / fps; animations[ i ].initialLerp = 1000 / fps; } if( i != MAX_BUILDABLE_ANIMATIONS ) { CG_Printf( "Error parsing animation file: %s/n", filename ); return qfalse; } return qtrue;}
开发者ID:AlienHoboken,项目名称:Tremulous-W-Server,代码行数:90,
示例6: UI_ParseAnimationFile/*======================UI_ParseAnimationFile======================*/static qboolean UI_ParseAnimationFile( const char *filename, playerInfo_t *pi ){ char *text_p, *prev; int len; int i; char *token; float fps; int skip; char text[ 20000 ]; fileHandle_t f; token = NULL; i = 0; fps = 0; prev = 0; memset( pi->animations, 0, sizeof( animation_t ) * MAX_ANIMATIONS ); // load the file len = trap_FS_FOpenFile( filename, &f, FS_READ ); if ( len <= 0 ) { return qfalse; } if ( len >= ( sizeof( text ) - 1 ) ) { Com_Printf( "File %s too long/n", filename ); return qfalse; } trap_FS_Read( text, len, f ); text[ len ] = 0; trap_FS_FCloseFile( f ); // parse the text text_p = text; skip = 0; // quite the compiler warning // NERVE - SMF - new!!!! AnimParseAnimConfig( pi, filename, text ); return qtrue; // -NERVE - SMF - This does not work with wolf's new animation system /* // read optional parameters while ( 1 ) { prev = text_p; // so we can unget token = COM_Parse( &text_p ); if ( !token ) { break; } if ( !Q_stricmp( token, "footsteps" ) ) { token = COM_Parse( &text_p ); if ( !token ) { break; } continue; } else if ( !Q_stricmp( token, "headoffset" ) ) { for ( i = 0 ; i < 3 ; i++ ) { token = COM_Parse( &text_p ); if ( !token ) { break; } } continue; } else if ( !Q_stricmp( token, "sex" ) ) { token = COM_Parse( &text_p ); if ( !token ) { break; } continue; } // if it is a number, start parsing animations if ( token[0] >= '0' && token[0] <= '9' ) { text_p = prev; // unget the token break; } Com_Printf( "unknown token '%s' is %s/n", token, filename ); } // read information for each frame for ( i = 0 ; i < MAX_ANIMATIONS ; i++ ) { token = COM_Parse( &text_p ); if ( !token ) { break; } animations[i].firstFrame = atoi( token ); // leg only frames are adjusted to not count the upper body only frames if ( i == LEGS_WALKCR ) {//.........这里部分代码省略.........
开发者ID:SHOVELL,项目名称:Unvanquished,代码行数:101,
示例7: G_ParseMapRotationFile/*===============G_ParseMapRotationFileLoad the map rotations from a map rotation file===============*/static qboolean G_ParseMapRotationFile( const char *fileName ){ char *text_p; int i, j; int len; char *token; char text[ 20000 ]; char mrName[ MAX_QPATH ]; qboolean mrNameSet = qfalse; fileHandle_t f; // load the file len = trap_FS_FOpenFile( fileName, &f, FS_READ ); if ( len < 0 ) { return qfalse; } if ( len == 0 || len >= sizeof( text ) - 1 ) { trap_FS_FCloseFile( f ); G_Printf( S_COLOR_RED "ERROR: map rotation file %s is %s/n", fileName, len == 0 ? "empty" : "too long" ); return qfalse; } trap_FS_Read( text, len, f ); text[ len ] = 0; trap_FS_FCloseFile( f ); // parse the text text_p = text; // read optional parameters while ( 1 ) { token = COM_Parse( &text_p ); if ( !*token ) { break; } if ( !Q_stricmp( token, "" ) ) { break; } if ( !Q_stricmp( token, "{" ) ) { if ( mrNameSet ) { //check for name space clashes if ( G_RotationExists( mrName ) ) { G_Printf( S_COLOR_RED "ERROR: a map rotation is already named %s/n", mrName ); return qfalse; } if ( mapRotations.numRotations == MAX_MAP_ROTATIONS ) { G_Printf( S_COLOR_RED "ERROR: maximum number of map rotations (%d) reached/n", MAX_MAP_ROTATIONS ); return qfalse; } Q_strncpyz( mapRotations.rotations[ mapRotations.numRotations ].name, mrName, MAX_QPATH ); if ( !G_ParseMapRotation( &mapRotations.rotations[ mapRotations.numRotations ], &text_p ) ) { G_Printf( S_COLOR_RED "ERROR: %s: failed to parse map rotation %s/n", fileName, mrName ); return qfalse; } mapRotations.numRotations++; //start parsing map rotations again mrNameSet = qfalse; continue; } else { G_Printf( S_COLOR_RED "ERROR: unnamed map rotation/n" ); return qfalse; } } if ( !mrNameSet ) { Q_strncpyz( mrName, token, sizeof( mrName ) ); mrNameSet = qtrue;//.........这里部分代码省略.........
开发者ID:SHOVELL,项目名称:Unvanquished,代码行数:101,
示例8: Script_ConditionalScript//.........这里部分代码省略......... else if (!Q_stricmp(cvar, "UIProfileValidName")) { char ui_profileStr[256]; char ui_profileCleanedStr[256]; DC->getCVarString("ui_profile", ui_profileStr, sizeof(ui_profileStr)); Q_strncpyz(ui_profileCleanedStr, ui_profileStr, sizeof(ui_profileCleanedStr)); Q_CleanStr(ui_profileCleanedStr); Q_CleanDirName(ui_profileCleanedStr); if (*ui_profileStr && *ui_profileCleanedStr) { Item_RunScript(item, bAbort, script1); } else { Item_RunScript(item, bAbort, script2); } } else if (!Q_stricmp(cvar, "UIProfileAlreadyExists")) { char ui_profileCleanedStr[256]; qboolean alreadyExists = qfalse; fileHandle_t f; DC->getCVarString("ui_profile", ui_profileCleanedStr, sizeof(ui_profileCleanedStr)); Q_CleanStr(ui_profileCleanedStr); Q_CleanDirName(ui_profileCleanedStr); if (trap_FS_FOpenFile(va("profiles/%s/profile.dat", ui_profileCleanedStr), &f, FS_READ) >= 0) { alreadyExists = qtrue; trap_FS_FCloseFile(f); } if (alreadyExists) { Item_RunScript(item, bAbort, script1); } else { Item_RunScript(item, bAbort, script2); } } else if (!Q_stricmp(cvar, "UIProfileAlreadyExists_Rename")) { char ui_profileCleanedStr[256]; qboolean alreadyExists = qfalse; fileHandle_t f; DC->getCVarString("ui_profile_renameto", ui_profileCleanedStr, sizeof(ui_profileCleanedStr)); Q_CleanStr(ui_profileCleanedStr); Q_CleanDirName(ui_profileCleanedStr); if (trap_FS_FOpenFile(va("profiles/%s/profile.dat", ui_profileCleanedStr), &f, FS_READ) >= 0) { alreadyExists = qtrue; trap_FS_FCloseFile(f); } if (alreadyExists) { Item_RunScript(item, bAbort, script1); } else
开发者ID:boutetnico,项目名称:etlegacy,代码行数:67,
示例9: CG_SaveRecamScriptFile/** CG_SaveRecamScriptFile*/void CG_SaveRecamScriptFile( const char *filename ) { cg_democam_t *cam; cg_subtitle_t *sub; int filehandle; char str[256]; if( !cg_cams_headnode && !cg_subs_headnode ) { CG_Printf( "CG_SaveRecamScriptFile: no cameras nor subtitles to save/n" ); return; } if( !filename ) { filename = demoscriptname; if( !filename ) { return; } } if( trap_FS_FOpenFile( filename, &filehandle, FS_WRITE ) == -1 ) { CG_Printf( "CG_SaveRecamScriptFile: Couldn't create the file %s/n", demoscriptname ); return; } Q_snprintfz( str, sizeof( str ), "// cam script file generated by %s/n", trap_Cvar_String( "gamename" ) ); trap_FS_Print( filehandle, str ); Q_snprintfz( str, sizeof( str ), "// demo start time: %" PRIi64 "/n", demo_initial_timestamp ); trap_FS_Print( filehandle, str ); cam = cg_cams_headnode; while( cam != NULL ) { Q_snprintfz( str, sizeof( str ), "%i %" PRIi64" %.2f %.2f %.2f %.2f %.2f %.2f %i %i/n", cam->type, cam->timeStamp, cam->origin[0], cam->origin[1], cam->origin[2], cam->angles[0], cam->angles[1], cam->angles[2], cam->trackEnt, cam->fov ); trap_FS_Print( filehandle, str ); cam = cam->next; } sub = cg_subs_headnode; while( sub != NULL ) { Q_snprintfz( str, sizeof( str ), "%s %" PRIi64 " %" PRIi64 " ", sub->highprint ? "print" : "subtitle", sub->timeStamp, sub->maxDuration ); trap_FS_Print( filehandle, str ); trap_FS_Print( filehandle, "/"" ); trap_FS_Print( filehandle, sub->text ? sub->text : "" ); trap_FS_Print( filehandle, "/"/n" ); sub = sub->next; } trap_FS_FCloseFile( filehandle ); CG_Printf( "cam file saved/n" );}
开发者ID:Picmip,项目名称:qfusion,代码行数:67,
示例10: trap_FS_FOpenFile/** S_ReadPlaylistFile*/static bgTrack_t *S_ReadPlaylistFile( const char *filename, bool shuffle, bool loop ){ int filenum, length; char *tmpname = 0; size_t tmpname_size = 0; char *data, *line, *entry; playlistItem_t items[MAX_PLAYLIST_ITEMS]; int i, numItems = 0; length = trap_FS_FOpenFile( filename, &filenum, FS_READ ); if( length < 0 ) return NULL; // load the playlist into memory data = S_Malloc( length + 1 ); trap_FS_Read( data, length, filenum ); trap_FS_FCloseFile( filenum ); srand( time( NULL ) ); while( *data ) { size_t s; entry = data; // read the whole line for( line = data; *line != '/0' && *line != '/n'; line++ ); // continue reading from the next character, if possible data = (*line == '/0' ? line : line + 1); *line = '/0'; // trim whitespaces, tabs, etc entry = Q_trim( entry ); // special M3U entry or comment if( !*entry || *entry == '#' ) continue; if( trap_FS_IsUrl( entry ) ) { items[numItems].track = S_AllocTrack( entry ); } else { // append the entry name to playlist path s = strlen( filename ) + 1 + strlen( entry ) + 1; if( s > tmpname_size ) { if( tmpname ) S_Free( tmpname ); tmpname_size = s; tmpname = S_Malloc( tmpname_size ); } Q_strncpyz( tmpname, filename, tmpname_size ); COM_StripFilename( tmpname ); Q_strncatz( tmpname, "/", tmpname_size ); Q_strncatz( tmpname, entry, tmpname_size ); COM_SanitizeFilePath( tmpname ); items[numItems].track = S_AllocTrack( tmpname ); } if( ++numItems == MAX_PLAYLIST_ITEMS ) break; } if( tmpname ) { S_Free( tmpname ); tmpname = NULL; } if( !numItems ) return NULL; // set the playing order for( i = 0; i < numItems; i++ ) items[i].order = (shuffle ? (rand() % numItems) : i); // sort the playlist R_SortPlaylistItems( numItems, items ); // link the playlist for( i = 1; i < numItems; i++ ) { items[i-1].track->next = items[i].track; items[i].track->prev = items[i-1].track; items[i].track->loop = loop; } items[numItems-1].track->next = items[0].track; items[0].track->prev = items[numItems-1].track; items[0].track->loop = loop;//.........这里部分代码省略.........
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:101,
示例11: CG_LoadRecamScriptFile/** CG_LoadRecamScriptFile*/bool CG_LoadRecamScriptFile( char *filename ) { int filelen, filehandle; uint8_t *buf = NULL; char *ptr, *token; int linecount; cg_democam_t *cam = NULL; if( !filename ) { CG_Printf( "CG_LoadRecamScriptFile: no filename/n" ); return false; } filelen = trap_FS_FOpenFile( filename, &filehandle, FS_READ ); if( !filehandle || filelen < 1 ) { trap_FS_FCloseFile( filehandle ); } else { buf = ( uint8_t * )CG_Malloc( filelen + 1 ); filelen = trap_FS_Read( buf, filelen, filehandle ); trap_FS_FCloseFile( filehandle ); } if( !buf ) { return false; } // parse the script linecount = 0; ptr = ( char * )buf; while( ptr ) { token = COM_ParseExt( &ptr, true ); if( !token[0] ) { break; } if( !Q_stricmp( token, "subtitle" ) || !Q_stricmp( token, "print" ) ) { cg_subtitle_t *sub; sub = CG_Democam_RegisterSubtitle(); sub->highprint = ( Q_stricmp( token, "print" ) == 0 ); token = COM_ParseExt( &ptr, true ); if( !token[0] ) { break; } sub->timeStamp = (unsigned int)atoi( token ); token = COM_ParseExt( &ptr, true ); if( !token[0] ) { break; } sub->maxDuration = (unsigned int)atoi( token ); sub->text = CG_CopyString( COM_ParseExt( &ptr, true ) ); linecount = 0; } else { switch( linecount ) { case 0: cam = CG_Democam_RegisterCam( atoi( token ) ); break; case 1: cam->timeStamp = (unsigned int)atoi( token ); break; case 2: cam->origin[0] = atof( token ); break; case 3: cam->origin[1] = atof( token ); break; case 4: cam->origin[2] = atof( token ); break; case 5: cam->angles[0] = atof( token ); break; case 6: cam->angles[1] = atof( token ); break; case 7: cam->angles[2] = atof( token ); break; case 8: cam->trackEnt = atoi( token ); break; case 9: cam->fov = atoi( token ); break; default: CG_Error( "CG_LoadRecamScriptFile: bad switch/n" ); } linecount++; if( linecount == 10 ) { linecount = 0; } } } CG_Free( buf );//.........这里部分代码省略.........
开发者ID:Picmip,项目名称:qfusion,代码行数:101,
示例12: G_ParseMapSettingsqboolean G_ParseMapSettings(int handle, config_t *config){ pc_token_t token; char serverinfo[MAX_INFO_STRING]; char *mapname; trap_GetServerinfo(serverinfo, sizeof(serverinfo)); mapname = Info_ValueForKey(serverinfo, "mapname"); if (!trap_PC_ReadToken(handle, &token)) { G_Printf("Malformed map config/n"); } G_Printf("Map settings for: %s/n", token.string); G_Printf("Current map: %s/n", mapname); if (!Q_stricmp(token.string, "default")) { G_Printf("Setting rules for map: %s/n", token.string); return G_ParseSettings(handle, qtrue, config); } else if (!Q_stricmp(token.string, mapname)) { fileHandle_t f; char *code, *signature; qboolean res; G_Printf("Setting rules for map: %s/n", token.string); res = G_ParseSettings(handle, qtrue, config); if (res && strlen(config->mapscripthash)) { char sdir[MAX_QPATH]; int flen = 0; trap_Cvar_VariableStringBuffer("g_mapScriptDirectory", sdir, sizeof(sdir)); flen = trap_FS_FOpenFile(va("%s/%s.script", sdir, mapname), &f, FS_READ); if (flen < 0) { // FIXME: handle this properly.. //return G_ConfigError(handle, "Cannot open mapscript file for hash verification: %s/%s.script", sdir, mapname); G_Printf("Cannot open mapscript file for hash verification: %s/%s.script", sdir, mapname); return res; } code = malloc(flen + 1); trap_FS_Read(code, flen, f); *(code + flen) = '/0'; trap_FS_FCloseFile(f); signature = G_SHA1(code); free(code); if (Q_stricmp(config->mapscripthash, signature)) { return G_ConfigError(handle, "Invalid mapscript hash for map: %s hash given in config: /"%s/" scripts actual hash /"%s/"", mapname, config->mapscripthash, signature); } G_Printf("Hash is valid for map: %s/n", mapname); } return res; } else { G_Printf("Ignoring rules for map: %s/n", token.string); return G_ParseSettings(handle, qfalse, config); }}
开发者ID:firebombzero,项目名称:etlegacy,代码行数:70,
示例13: CG_ParseTrailFile/*===============CG_ParseTrailFileLoad the trail systems from a trail file===============*/static bool CG_ParseTrailFile( const char *fileName ){ const char *text_p; int i; int len; char *token; char text[ 32000 ]; char tsName[ MAX_QPATH ]; bool tsNameSet = false; fileHandle_t f; // load the file len = trap_FS_FOpenFile( fileName, &f, fsMode_t::FS_READ ); if ( len <= 0 ) { return false; } if ( len == 0 || len + 1 >= (int) sizeof( text ) ) { trap_FS_FCloseFile( f ); Log::Warn( len ? "trail file %s is too long" : "trail file %s is empty", fileName ); return false; } trap_FS_Read( text, len, f ); text[ len ] = 0; trap_FS_FCloseFile( f ); // parse the text text_p = text; // read optional parameters while ( 1 ) { token = COM_Parse( &text_p ); if ( !*token ) { break; } if ( !Q_stricmp( token, "{" ) ) { if ( tsNameSet ) { //check for name space clashes for ( i = 0; i < numBaseTrailSystems; i++ ) { if ( !Q_stricmp( baseTrailSystems[ i ].name, tsName ) ) { Log::Warn( "a trail system is already named %s", tsName ); return false; } } Q_strncpyz( baseTrailSystems[ numBaseTrailSystems ].name, tsName, MAX_QPATH ); if ( !CG_ParseTrailSystem( &baseTrailSystems[ numBaseTrailSystems ], &text_p, tsName ) ) { Log::Warn( "%s: failed to parse trail system %s", fileName, tsName ); return false; } //start parsing trail systems again tsNameSet = false; if ( numBaseTrailSystems == MAX_BASETRAIL_SYSTEMS ) { Log::Warn( "maximum number of trail systems (%d) reached", MAX_BASETRAIL_SYSTEMS ); return false; } else { numBaseTrailSystems++; } continue; } else { Log::Warn( "unnamed trail system" ); return false; } } if ( !tsNameSet ) { Q_strncpyz( tsName, token, sizeof( tsName ) ); tsNameSet = true; }//.........这里部分代码省略.........
开发者ID:Unvanquished,项目名称:Unvanquished,代码行数:101,
示例14: UI_SaberLoadParmsvoid UI_SaberLoadParms( void ) { int len, totallen, saberExtFNLen, fileCnt, i; char *holdChar, *marker; char saberExtensionListBuf[2048]; // The list of file names read in fileHandle_t f; char buffer[MAX_MENUFILE]; //[DynamicMemory_Sabers]#ifdef DYNAMICMEMORY_SABERS int maxLen;#endif //[/DynamicMemory_Sabers] //ui.Printf( "UI Parsing *.sab saber definitions/n" ); ui_saber_parms_parsed = qtrue; UI_CacheSaberGlowGraphics();//[DynamicMemory_Sabers] moved down lower /* //set where to store the first one totallen = 0; marker = SaberParms; marker[0] = '/0'; */ //we werent initilizing saberExtFNLen, which is Bad //this is just a general bug fix, not for the purpose of [DynamicMemory_Sabers] saberExtFNLen = 0;///[DynamicMemory_Sabers] //now load in the extra .npc extensions fileCnt = trap_FS_GetFileList("ext_data/sabers", ".sab", saberExtensionListBuf, sizeof(saberExtensionListBuf) ); holdChar = saberExtensionListBuf;//[DynamicMemory_Sabers]#ifdef DYNAMICMEMORY_SABERS maxLen = 0; saberExtFNLen = -1; for ( i = 0; i < fileCnt; i++, holdChar += saberExtFNLen + 1 ) { saberExtFNLen = strlen( holdChar ); len = trap_FS_FOpenFile( va( "ext_data/sabers/%s", holdChar), &f, FS_READ ); if(!f) continue; trap_FS_FCloseFile(f); maxLen += len; } //what do we do if totallen is zero? will never happen, but COULD happen in theory... //trap_TrueMalloc(&SaberParms, totallen+1); //+1 for null char, needed? maxLen++; //for ending null char UI_AllocMem(&SaberParms, maxLen); if(!SaberParms) //ERR_FATAL or any level isnt used with Com_Error Com_Error(ERR_FATAL, "Saber parsing: Out of memory!"); holdChar = saberExtensionListBuf;#endif//[/DynamicMemory_Sabers]//[DynamicMemory_Sabers] moved to here //set where to store the first one totallen = 0; marker = SaberParms; marker[0] = '/0'; saberExtFNLen = -1;///[DynamicMemory_Sabers] for ( i = 0; i < fileCnt; i++, holdChar += saberExtFNLen + 1 ) { saberExtFNLen = strlen( holdChar ); len = trap_FS_FOpenFile( va( "ext_data/sabers/%s", holdChar), &f, FS_READ ); if (!f) { continue; } if ( len == -1 ) { Com_Printf( "UI_SaberLoadParms: error reading %s/n", holdChar ); } else { if (len > sizeof(buffer) ) { Com_Error( ERR_FATAL, "UI_SaberLoadParms: file %s too large to read (max=%d)", holdChar, sizeof(buffer) ); } trap_FS_Read( buffer, len, f ); trap_FS_FCloseFile( f ); buffer[len] = 0; if ( totallen && *(marker-1) == '}' ) {//don't let it end on a } because that should be a stand-alone token strcat( marker, " " ); totallen++; marker++; //.........这里部分代码省略.........
开发者ID:ForcePush,项目名称:OJPRPFZ,代码行数:101,
示例15: G_ParseMapRotationFile/*===============G_ParseMapRotationFileLoad the map rotations from a map rotation file===============*/static qboolean G_ParseMapRotationFile( const char *fileName ){ char *text_p; int i, j, k; int len; char *token; char text[ 20000 ]; char mrName[ MAX_QPATH ]; qboolean mrNameSet = qfalse; fileHandle_t f; // load the file len = trap_FS_FOpenFile( fileName, &f, FS_READ ); if( len < 0 ) return qfalse; if( len == 0 || len >= sizeof( text ) - 1 ) { trap_FS_FCloseFile( f ); G_Printf( S_COLOR_RED "ERROR: map rotation file %s is %s/n", fileName, len == 0 ? "empty" : "too long" ); return qfalse; } trap_FS_Read( text, len, f ); text[ len ] = 0; trap_FS_FCloseFile( f ); // parse the text text_p = text; // read optional parameters while( 1 ) { token = COM_Parse( &text_p ); if( !token ) break; if( !Q_stricmp( token, "" ) ) break; if( !Q_stricmp( token, "{" ) ) { if( mrNameSet ) { //check for name space clashes for( i = 0; i < mapRotations.numRotations; i++ ) { if( !Q_stricmp( mapRotations.rotations[ i ].name, mrName ) ) { G_Printf( S_COLOR_RED "ERROR: a map rotation is already named %s/n", mrName ); return qfalse; } } if( mapRotations.numRotations == MAX_MAP_ROTATIONS ) { G_Printf( S_COLOR_RED "ERROR: maximum number of map rotations (%d) reached/n", MAX_MAP_ROTATIONS ); return qfalse; } Q_strncpyz( mapRotations.rotations[ mapRotations.numRotations ].name, mrName, MAX_QPATH ); if( !G_ParseMapRotation( &mapRotations.rotations[ mapRotations.numRotations ], &text_p ) ) { G_Printf( S_COLOR_RED "ERROR: %s: failed to parse map rotation %s/n", fileName, mrName ); return qfalse; } mapRotations.numRotations++; //start parsing map rotations again mrNameSet = qfalse; continue; } else { G_Printf( S_COLOR_RED "ERROR: unnamed map rotation/n" ); return qfalse; } } if( !mrNameSet ) { Q_strncpyz( mrName, token, sizeof( mrName ) ); mrNameSet = qtrue; } else { G_Printf( S_COLOR_RED "ERROR: map rotation already named/n" );//.........这里部分代码省略.........
开发者ID:redrumrobot,项目名称:korx,代码行数:101,
示例16: CG_LoadLensFlareEntitiesvoid CG_LoadLensFlareEntities(void) { char name[256]; fileHandle_t f; int len; char* p;#if LFDEBUG CG_LoadingString("LF: CG_LoadLensFlareEntities()");#endif cgs.numLensFlareEntities = 0; memset(&cgs.lensFlareEntities, 0, sizeof(cgs.lensFlareEntities)); if (cgs.sunFlareEffect[0]) { lensFlareEntity_t* lfent; vec3_t angles; vec3_t sunDir; lfent = &cgs.sunFlare; lfent->lfeff = CG_FindLensFlareEffect(cgs.sunFlareEffect); if (!lfent->lfeff) { CG_Printf(S_COLOR_YELLOW "undefined sun flare effect '%s'/n", cgs.sunFlareEffect); } angles[YAW] = cgs.sunFlareYaw; angles[PITCH] = -cgs.sunFlarePitch; angles[ROLL] = 0; AngleVectors(angles, sunDir, NULL, NULL); VectorScale(sunDir, cgs.sunFlareDistance, lfent->origin); lfent->radius = 150; lfent->lightRadius = 100; lfent->angle = -1; CG_ComputeMaxVisAngle(lfent); CG_Printf("sun flare entity created/n"); } Com_sprintf(name, sizeof(name), "maps/%s.lfe", Info_ValueForKey(CG_ConfigString(CS_SERVERINFO), "mapname")); len = trap_FS_FOpenFile(name, &f, FS_READ); if (!f) { CG_Printf("'%s' not found/n", name); return; } if (len >= sizeof(lfbuf)) { CG_Printf(S_COLOR_YELLOW "file too large: '%s' > %d/n", name, sizeof(lfbuf)-1); return; } CG_Printf("reading '%s'.../n", name);#if LFDEBUG CG_LoadingString(va("%s", name));#endif trap_FS_Read(lfbuf, len, f); lfbuf[len] = 0; trap_FS_FCloseFile(f); COM_Compress(lfbuf); p = lfbuf; // parse all lens flare entities while (cgs.numLensFlareEntities < MAX_LIGHTS_PER_MAP && p) { if (!CG_ParseLensFlareEntity(&p, &cgs.lensFlareEntities[cgs.numLensFlareEntities])) { break; } cgs.numLensFlareEntities++; } CG_Printf("%d lens flare entities loaded/n", cgs.numLensFlareEntities);#if LFDEBUG CG_LoadingString("LF: CG_LoadLensFlareEntities() ready");#endif}
开发者ID:asl97,项目名称:ZEQ2-Lite-1,代码行数:76,
示例17: BotUtilizePersonality//.........这里部分代码省略......... Com_sprintf(bs->forceinfo, sizeof(bs->forceinfo), "%s/0", DEFAULT_FORCEPOWERS); } i = 0; while (i < MAX_CHAT_BUFFER_SIZE) { //clear out the chat buffer for this bot gBotChatBuffer[bs->client][i] = '/0'; i++; } if (bs->canChat) { if (!ReadChatGroups(bs, buf)) { bs->canChat = 0; } } if (GetValueGroup(buf, "BotWeaponWeights", group)) { if (GetPairedValue(group, "WP_STUN_BATON", readbuf)) { bs->botWeaponWeights[WP_STUN_BATON] = atoi(readbuf); bs->botWeaponWeights[WP_MELEE] = bs->botWeaponWeights[WP_STUN_BATON]; } if (GetPairedValue(group, "WP_SABER", readbuf)) { bs->botWeaponWeights[WP_SABER] = atoi(readbuf); } if (GetPairedValue(group, "WP_BRYAR_PISTOL", readbuf)) { bs->botWeaponWeights[WP_BRYAR_PISTOL] = atoi(readbuf); } if (GetPairedValue(group, "WP_BLASTER", readbuf)) { bs->botWeaponWeights[WP_BLASTER] = atoi(readbuf); } if (GetPairedValue(group, "WP_DISRUPTOR", readbuf)) { bs->botWeaponWeights[WP_DISRUPTOR] = atoi(readbuf); } if (GetPairedValue(group, "WP_BOWCASTER", readbuf)) { bs->botWeaponWeights[WP_BOWCASTER] = atoi(readbuf); } if (GetPairedValue(group, "WP_REPEATER", readbuf)) { bs->botWeaponWeights[WP_REPEATER] = atoi(readbuf); } if (GetPairedValue(group, "WP_DEMP2", readbuf)) { bs->botWeaponWeights[WP_DEMP2] = atoi(readbuf); } if (GetPairedValue(group, "WP_FLECHETTE", readbuf)) { bs->botWeaponWeights[WP_FLECHETTE] = atoi(readbuf); } if (GetPairedValue(group, "WP_ROCKET_LAUNCHER", readbuf)) { bs->botWeaponWeights[WP_ROCKET_LAUNCHER] = atoi(readbuf); } if (GetPairedValue(group, "WP_THERMAL", readbuf)) { bs->botWeaponWeights[WP_THERMAL] = atoi(readbuf); } if (GetPairedValue(group, "WP_TRIP_MINE", readbuf)) { bs->botWeaponWeights[WP_TRIP_MINE] = atoi(readbuf); } if (GetPairedValue(group, "WP_DET_PACK", readbuf)) { bs->botWeaponWeights[WP_DET_PACK] = atoi(readbuf); } } bs->lovednum = 0; if (GetValueGroup(buf, "EmotionalAttachments", group)) { ParseEmotionalAttachments(bs, group); } B_TempFree(131072); //buf B_TempFree(1024); //readbuf B_TempFree(65536); //group trap_FS_FCloseFile(f);}
开发者ID:deathsythe47,项目名称:jaMME,代码行数:101,
示例18: UI_ManageDeckLoadingstatic void UI_ManageDeckLoading( void ){ char fileRoute[MAX_QPATH]; char mapRoute[MAX_QPATH]; char info[MAX_TOKEN_CHARS]; fileHandle_t f; int file_len; char *textPtr; char buffer[20000]; char *token; //get the map name trap_GetConfigString( CS_SERVERINFO, info, sizeof( info ) ); Com_sprintf( mapRoute, sizeof( fileRoute ), "maps/%s", Info_ValueForKey( info, "mapname" ) ); //check for language UI_LanguageFilename( mapRoute, "turbolift", fileRoute ); file_len = trap_FS_FOpenFile( fileRoute, &f, FS_READ ); if ( file_len <= 1 ) { //Com_Printf( S_COLOR_YELLOW "WARNING: Attempted to load %s, but wasn't found./n", fileRoute ); UI_TurboliftMenu_LoadDecks(); return; } trap_FS_Read( buffer, file_len, f ); trap_FS_FCloseFile( f ); if ( !buffer[0] ) { Com_Printf( S_COLOR_RED "ERROR: Attempted to load %s, but no data was read./n", fileRoute ); UI_TurboliftMenu_LoadDecks(); return; } s_turbolift.numDecks = 0; memset( &s_turbolift.deckData, 0, sizeof( s_turbolift.deckData ) ); buffer[file_len] = '/0'; COM_BeginParseSession(); textPtr = buffer; //Com_Printf( S_COLOR_RED "Beginning Parse/n" ); //expected format is 'decknum' <space> 'deck Desc' while( 1 ) { token = COM_Parse( &textPtr ); if ( !token[0] ) break; //Com_Printf( S_COLOR_RED "First Token: %s/n", token ); //in case of Scooter's EF SP style DAT files, which require 'DECK' in front of the number if ( !Q_strncmp( token, "DECK", 4 ) ) token += 4; //grab the deck number s_turbolift.deckData[s_turbolift.numDecks].deckNum = atoi( token ); token = COM_ParseExt( &textPtr, qfalse ); if (!token[0]) continue; //Com_Printf( S_COLOR_RED "Second Token: %s/n", token ); Q_strncpyz( s_turbolift.deckData[s_turbolift.numDecks].deckDesc, token, sizeof( s_turbolift.deckData[s_turbolift.numDecks].deckDesc ) ); s_turbolift.numDecks++; //if this is an EF SP style script, there may be more data after these two. ignore them if ( COM_ParseExt( &textPtr, qfalse ) == NULL ) SkipRestOfLine( &textPtr ); } qsort( s_turbolift.deckData, s_turbolift.numDecks, sizeof( deckData_t ), SortDecks );}
开发者ID:gitter-badger,项目名称:rpgxEF,代码行数:81,
示例19: BG_RegisterRacechar* BG_RegisterRace( const char *name ) { char *text_p; char *token; int len; fileHandle_t f; char text[MAX_GROUP_FILE_SIZE]; gender_t theSex; memset (races, 0, sizeof(races)); memset (text, 0, sizeof(text)); // load and parse the skin file len = trap_FS_FOpenFile( name, &f, FS_READ ); if ( !f ) { // if we didn't get a races file, use an empty one. Com_sprintf(races, sizeof(races), "unknown"); return races; } if ( len >= sizeof( text ) - 1) { Com_Printf( S_COLOR_RED "file too large: %s is %i, max allowed is %i", name, len, sizeof( text ) ); trap_FS_FCloseFile( f ); return races; } trap_FS_Read( text, len, f ); trap_FS_FCloseFile( f ); theSex = G_ParseAnimationFileSex(name); if (theSex == GENDER_MALE) { strcat(races, "Male,"); } else if (theSex == GENDER_FEMALE) { strcat(races, "Female,"); } text_p = text; while ( *text_p ) { // get surface name token = COM_Parse( &text_p ); if ( !token[0] ) { break; } // if we about to break the races size list then dump us out if (strlen(races) + strlen(token) > 256) { break; } // add it into the race list strcat(races, token); // put a comma between the names strcat(races, ","); if ( *text_p == ',' ) { text_p++; } if (!Q_stricmp ("borg", token) ) { if (theSex == GENDER_MALE) { // add it into the race list strcat(races, "BorgMale,"); } else if (theSex == GENDER_FEMALE) { strcat(races, "BorgFemale,"); } else { } } } // just in case if (!races[0]) { Com_sprintf(races, sizeof(races), "unknown"); } else { //lose the last comma races[strlen(races)-1] = 0; } return races;}
开发者ID:gitter-badger,项目名称:rpgxEF,代码行数:82,
示例20: CG_LoadHolsterDatavoid CG_LoadHolsterData (clientInfo_t *ci){//adjusts the manual holster positional data based on the holster.cfg file associated with the model or simply //use the default values int i; fileHandle_t f; int fLen = 0; char fileBuffer[MAX_HOLSTER_INFO_SIZE]; char holsterTypeValue[MAX_QPATH]; char holsterTypeGroup[MAX_HOLSTER_INFO_SIZE]; char *s; vec3_t vectorData; InitHolsterData(ci); if ( !ci->skinName || !Q_stricmp( "default", ci->skinName ) ) {//try default holster.cfg first fLen = trap_FS_FOpenFile(va("models/players/%s/holster.cfg", ci->modelName), &f, FS_READ); if( !f ) {//no file, use kyle's then. fLen = trap_FS_FOpenFile("models/players/kyle/holster.cfg", &f, FS_READ); } } else {//use the holster.cfg associated with this skin fLen = trap_FS_FOpenFile(va("models/players/%s/holster_%s.cfg", ci->modelName, ci->skinName), &f, FS_READ); if ( !f ) {//fall back to default holster.cfg fLen = trap_FS_FOpenFile(va("models/players/%s/holster.cfg", ci->modelName), &f, FS_READ); } if( !f ) {//still no dice, use kyle's then. fLen = trap_FS_FOpenFile("models/players/kyle/holster.cfg", &f, FS_READ); } } if ( !f || !fLen ) {//couldn't open file or it was empty, just use the defaults return; } if( fLen >= MAX_HOLSTER_INFO_SIZE ) { CG_Printf("Error: holster.cfg for %s is over the holster.cfg filesize limit./n", ci->modelName); trap_FS_FCloseFile( f ); return; } trap_FS_Read(fileBuffer, fLen, f); trap_FS_FCloseFile( f ); s = fileBuffer; //parse file while( (s = BG_GetNextValueGroup(s, holsterTypeGroup)) != NULL ) { if( !BG_SiegeGetPairedValue(holsterTypeGroup, "holsterType", holsterTypeValue) ) {//couldn't find holster type in group CG_Printf("Error: The holster.cfg for %s appears to be missing a holsterType in one of its define groups./n", ci->modelName); continue; } i = GetIDForString(holsterTypeTable, holsterTypeValue); if( i == -1 ) {//bad holster type CG_Printf("Error: The holster.cfg for %s has a bad holsterType in one of the define groups./n", ci->modelName); continue; } if( BG_SiegeGetPairedValue(holsterTypeGroup, "boneIndex", holsterTypeValue) ) {//have bone index data for this holster type, use it if(!Q_stricmp(holsterTypeValue, "disabled") ) {//disable the rendering of this holster type on this model ci->holsterData[i].boneIndex = HOLSTER_NONE; } else { ci->holsterData[i].boneIndex = GetIDForString(holsterBoneTable, holsterTypeValue); } } if( BG_SiegeGetPairedValue(holsterTypeGroup, "posOffset", holsterTypeValue) ) {//parsing positional offset data sscanf (holsterTypeValue, "%f, %f, %f", &vectorData[0], &vectorData[1], &vectorData[2]); VectorCopy(vectorData, ci->holsterData[i].posOffset); //&ci->holsterData[i].posOffset[0], &ci->holsterData[i].posOffset[1], //&ci->holsterData[i].posOffset[2]); } if( BG_SiegeGetPairedValue(holsterTypeGroup, "angOffset", holsterTypeValue) ) {//parsing angular offset sscanf (holsterTypeValue, "%f, %f, %f", &vectorData[0], &vectorData[1], &vectorData[2]); VectorCopy(vectorData, ci->holsterData[i].angOffset);//.........这里部分代码省略.........
开发者ID:mehmehsomeone,项目名称:OpenRP,代码行数:101,
示例21: BG_ParseRankNamesqboolean BG_ParseRankNames( char* fileName, rankNames_t rankNames[] ) { fileHandle_t f; int file_len; char charText[20000]; char* textPtr; char* token; int i = 0; file_len = trap_FS_FOpenFile( fileName, &f, FS_READ ); if ( file_len<= 0 ) { return qfalse; } if ( file_len >= ( sizeof(charText) - 1) ) { Com_Printf( S_COLOR_RED "File length of %s is too long./n", fileName ); } memset( &charText, 0, sizeof( charText ) ); memset( rankNames, 0, sizeof( rankNames ) ); trap_FS_Read( charText, file_len, f ); charText[file_len] = 0; trap_FS_FCloseFile( f ); COM_BeginParseSession(); textPtr = charText; token = COM_Parse( &textPtr ); if ( !token[0] ) { Com_Printf( S_COLOR_RED "No data found in buffer: %s/n", fileName ); return qfalse; } if ( Q_stricmpn( token, "{", 1 ) ) { Com_Printf( S_COLOR_RED "No beginning { found in %s/n", fileName ); return qfalse; } //Parse out the default cell. Default has no names anyway, //but in case a n00bie modder put names in anyway. SkipBracedSection( &textPtr ); while( 1 ) { //lastPtr = textPtr; token = COM_Parse( &textPtr ); if( !token[0] ) { break; } if ( i >= MAX_RANKS ) { break; } //If we hit an open brace (ie, assuming we hit the start of a new rank cell) if ( !Q_stricmpn( token, "{", 1 ) ) { while ( 1 ) { token = COM_Parse( &textPtr ); if( !token[0] ) { break; } //We hit a MenuTexture entry, since this uses { symbols, we'll skip these to stop errors. if ( !Q_stricmpn( token, "MenuTexture", 11 ) ) { SkipRestOfLine( &textPtr ); continue; } if ( !Q_stricmpn( token, "ConsoleName", 11) ) { if ( COM_ParseString( &textPtr, &token ) ) { continue; } Q_strncpyz( rankNames[i].consoleName, token, sizeof( rankNames[i].consoleName ) ); continue; } else if ( !Q_stricmpn( token, "FormalName", 10) ) { if ( COM_ParseString( &textPtr, &token ) ) { continue; } Q_strncpyz( rankNames[i].formalName, token, sizeof( rankNames[i].formalName ) ); continue; } //We hit the end of the cell. else if ( !Q_stricmpn( token, "}", 1 ) ) { break; } } //Error check. If we didn't get both a formal and console name, pwn the caller. ;P if ( !rankNames[i].consoleName[0] || !rankNames[i].formalName[0] ) { Com_Printf( S_COLOR_RED "One or more rank names were not found in rank#: %i/n", i ); return qfalse;//.........这里部分代码省略.........
开发者ID:gitter-badger,项目名称:rpgxEF,代码行数:101,
示例22: UI_ParseAnimationFile/*======================UI_ParseAnimationFile======================*/static qbool UI_ParseAnimationFile( const char *filename, animation_t *animations ) { char *text_p, *prev; int len; int i; char *token; float fps; int skip; char text[20000]; fileHandle_t f; memset( animations, 0, sizeof( animation_t ) * MAX_ANIMATIONS ); // load the file len = trap_FS_FOpenFile( filename, &f, FS_READ ); if ( len <= 0 ) { return qfalse; } if ( len >= ( sizeof( text ) - 1 ) ) { Com_Printf( "File %s too long/n", filename ); trap_FS_FCloseFile( f ); return qfalse; } trap_FS_Read( text, len, f ); text[len] = 0; trap_FS_FCloseFile( f ); COM_Compress(text); // parse the text text_p = text; skip = 0; // quite the compiler warning // read optional parameters while ( 1 ) { prev = text_p; // so we can unget token = COM_Parse( &text_p ); if ( !token ) { break; } if ( !Q_stricmp( token, "footsteps" ) ) { token = COM_Parse( &text_p ); if ( !token ) { break; } continue; } else if ( !Q_stricmp( token, "headoffset" ) ) { for ( i = 0 ; i < 3 ; i++ ) { token = COM_Parse( &text_p ); if ( !token ) { break; } } continue; } else if ( !Q_stricmp( token, "sex" ) ) { token = COM_Parse( &text_p ); if ( !token ) { break; } continue; } // if it is a number, start parsing animations if ( token[0] >= '0' && token[0] <= '9' ) { text_p = prev; // unget the token break; } Com_Printf( "unknown token '%s' is %s/n", token, filename ); } // read information for each frame for ( i = 0 ; i < MAX_ANIMATIONS ; i++ ) { token = COM_Parse( &text_p ); if ( !token ) { break; } animations[i].firstFrame = atoi( token ); token = COM_Parse( &text_p ); if ( !token ) { break; } animations[i].numFrames = atoi( token ); token = COM_Parse( &text_p ); if ( !token ) { break; } animations[i].loopFrames = atoi( token ); token = COM_Parse( &text_p ); if ( !token ) { break; }//.........这里部分代码省略.........
开发者ID:LuckyBro,项目名称:sgfork,代码行数:101,
示例23: G_LogWeaponOutput//.........这里部分代码省略......... for (i=0; i<MAX_CLIENTS; i++) { if (G_WeaponLogClientTouch[i]) { // Ignore any entity/clients we don't care about! if ( g_entities[i].client ) { nameptr = g_entities[i].client->pers.netname; } else { nameptr = unknownname; } trap_FS_Write(nameptr, strlen(nameptr), weaponfile); for (j=0;j<MOD_MAX;j++) { Com_sprintf(string, sizeof(string), "/t%d", G_WeaponLogDamage[i][j]); trap_FS_Write(string, strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "/n"); trap_FS_Write(string, strlen(string), weaponfile); } } // Sum up the totals. Com_sprintf(string, sizeof(string), "/n***TOTAL:"); trap_FS_Write(string, strlen(string), weaponfile); for (j=0;j<MOD_MAX;j++) { Com_sprintf(string, sizeof(string), "/t%d", totaldamageMOD[j]); trap_FS_Write(string, strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "/n/n/n"); trap_FS_Write(string, strlen(string), weaponfile); // Damage type kills per character Com_sprintf(string, sizeof(string), "Damage-Typed Kills per Player:/n/n"); trap_FS_Write( string, strlen( string ), weaponfile); Com_sprintf(string, sizeof(string), "Player"); trap_FS_Write(string, strlen(string), weaponfile); for (j=0; j<MOD_MAX; j++) { Com_sprintf(string, sizeof(string), "/t%s", modNames[j]); trap_FS_Write(string, strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "/n"); trap_FS_Write(string, strlen(string), weaponfile); // Cycle through each player, give their name and the number of times they picked up each weapon. for (i=0; i<MAX_CLIENTS; i++) { if (G_WeaponLogClientTouch[i]) { // Ignore any entity/clients we don't care about! if ( g_entities[i].client ) { nameptr = g_entities[i].client->pers.netname; } else { nameptr = unknownname; } trap_FS_Write(nameptr, strlen(nameptr), weaponfile); for (j=0;j<MOD_MAX;j++) { Com_sprintf(string, sizeof(string), "/t%d", G_WeaponLogKills[i][j]); trap_FS_Write(string, strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "/n"); trap_FS_Write(string, strlen(string), weaponfile); } } // Sum up the totals. Com_sprintf(string, sizeof(string), "/n***TOTAL:"); trap_FS_Write(string, strlen(string), weaponfile); for (j=0;j<MOD_MAX;j++) { Com_sprintf(string, sizeof(string), "/t%d", totalkillsMOD[j]); trap_FS_Write(string, strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "/n/n/n"); trap_FS_Write(string, strlen(string), weaponfile); trap_FS_FCloseFile(weaponfile);#endif //LOGGING_WEAPONS}
开发者ID:Camron,项目名称:OpenJK,代码行数:101,
示例24: CG_InitBuildables/*===============CG_InitBuildablesInitialises the animation db===============*/void CG_InitBuildables( void ){ char filename[ MAX_QPATH ]; char soundfile[ MAX_QPATH ]; char *buildableName; char *modelFile; int i; int j; fileHandle_t f; memset( cg_buildables, 0, sizeof( cg_buildables ) ); //default sounds for( j = BANIM_NONE + 1; j < MAX_BUILDABLE_ANIMATIONS; j++ ) { strcpy( soundfile, cg_buildableSoundNames[ j - 1 ] ); Com_sprintf( filename, sizeof( filename ), "sound/buildables/alien/%s", soundfile ); defaultAlienSounds[ j ] = trap_S_RegisterSound( filename, qfalse ); Com_sprintf( filename, sizeof( filename ), "sound/buildables/human/%s", soundfile ); defaultHumanSounds[ j ] = trap_S_RegisterSound( filename, qfalse ); } cg.buildablesFraction = 0.0f; for( i = BA_NONE + 1; i < BA_NUM_BUILDABLES; i++ ) { buildableName = BG_FindNameForBuildable( i ); //animation.cfg Com_sprintf( filename, sizeof( filename ), "models/buildables/%s/animation.cfg", buildableName ); if ( !CG_ParseBuildableAnimationFile( filename, i ) ) Com_Printf( S_COLOR_YELLOW "WARNING: failed to load animation file %s/n", filename ); //sound.cfg Com_sprintf( filename, sizeof( filename ), "sound/buildables/%s/sound.cfg", buildableName ); if ( !CG_ParseBuildableSoundFile( filename, i ) ) Com_Printf( S_COLOR_YELLOW "WARNING: failed to load sound file %s/n", filename ); //models for( j = 0; j <= 3; j++ ) { if( ( modelFile = BG_FindModelsForBuildable( i, j ) ) ) cg_buildables[ i ].models[ j ] = trap_R_RegisterModel( modelFile ); } //sounds for( j = BANIM_NONE + 1; j < MAX_BUILDABLE_ANIMATIONS; j++ ) { strcpy( soundfile, cg_buildableSoundNames[ j - 1 ] ); Com_sprintf( filename, sizeof( filename ), "sound/buildables/%s/%s", buildableName, soundfile ); if( cg_buildables[ i ].sounds[ j ].enabled ) { if( trap_FS_FOpenFile( filename, &f, FS_READ ) > 0 ) { //file exists so close it trap_FS_FCloseFile( f ); cg_buildables[ i ].sounds[ j ].sound = trap_S_RegisterSound( filename, qfalse ); } else { //file doesn't exist - use default if( BG_FindTeamForBuildable( i ) == BIT_ALIENS ) cg_buildables[ i ].sounds[ j ].sound = defaultAlienSounds[ j ]; else cg_buildables[ i ].sounds[ j ].sound = defaultHumanSounds[ j ]; } } } cg.buildablesFraction = (float)i / (float)( BA_NUM_BUILDABLES - 1 ); trap_UpdateScreen( ); } cgs.media.teslaZapTS = CG_RegisterTrailSystem( "models/buildables/tesla/zap" );}
开发者ID:AlienHoboken,项目名称:Tremulous-W-Server,代码行数:86,
示例25: G_LoadRoffint G_LoadRoff( const char *fileName ){ char file[MAX_QPATH]; char data[ROFF_INFO_SIZE]; fileHandle_t f; roff_hdr2_t *header; int len, i, roff_id = 0; // Before even bothering with all of this, make sure we have a place to store it. if ( num_roffs >= MAX_ROFFS ) { Com_Printf( S_COLOR_RED"MAX_ROFFS count exceeded. Skipping load of .ROF '%s'/n", fileName ); return roff_id; } // The actual path sprintf( file, "%s/%s.rof", Q3_SCRIPT_DIR, fileName ); // See if I'm already precached for ( i = 0; i < num_roffs; i++ ) { if ( stricmp( file, roffs[i].fileName ) == 0 ) { // Good, just return me...avoid zero index return i + 1; } }#ifdef _DEBUG// Com_Printf( S_COLOR_GREEN"Caching ROF: '%s'/n", file );#endif // Read the file in one fell swoop len = trap_FS_FOpenFile(file, &f, FS_READ); if ( len <= 0 ) { Com_Printf( S_COLOR_RED"Could not open .ROF file '%s'/n", fileName ); return roff_id; } if ( len >= ROFF_INFO_SIZE ) { Com_Printf( S_COLOR_RED".ROF file '%s': Too large for file buffer./n", fileName ); return roff_id; } trap_FS_Read(data, len, f); //read data in buffer trap_FS_FCloseFile(f); //close file // Now let's check the header info... header = (roff_hdr2_t *)data; // ..and make sure it's reasonably valid if ( !G_ValidRoff( header )) { Com_Printf( S_COLOR_RED"Invalid roff format '%s'/n", fileName ); } else { G_InitRoff( file, data ); // Done loading this roff, so save off an id to it..increment first to avoid zero index roff_id = ++num_roffs; } //trap_FS_FCloseFile( data ); return roff_id;}
开发者ID:mehmehsomeone,项目名称:OpenRP,代码行数:71,
示例26: Save_Autosavesvoid Save_Autosaves(void){//save the autosaves fileHandle_t f; char lineBuf[MAX_QPATH]; char fileBuf[MAX_AUTOSAVE_FILESIZE]; char loadPath[MAX_QPATH]; int len; //[RawMapName] //vmCvar_t mapname; //[/RawMapName] gentity_t* autosavePoint; fileBuf[0] = '/0'; G_Printf("^5Saving Autosave File Data..."); //[RawMapName] //trap_Cvar_Register( &mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM ); //Com_sprintf(loadPath, MAX_QPATH, "maps/%s.autosp", mapname.string); Com_sprintf(loadPath, sizeof(loadPath), "maps/%s.autosp", level.rawmapname); //[/RawMapName] len = trap_FS_FOpenFile( loadPath, &f, FS_WRITE ); if ( !f ) { G_Printf("^5Couldn't create autosave file./n"); return; } //find all the manually created autosave points. autosavePoint = NULL; while ( (autosavePoint = G_Find (autosavePoint, FOFS(classname), "trigger_autosave")) != NULL ) { Com_sprintf(lineBuf, MAX_QPATH, "%f %f %f %i %i/n", autosavePoint->r.currentOrigin[0], autosavePoint->r.currentOrigin[1], autosavePoint->r.currentOrigin[2], (int) autosavePoint->r.maxs[0], (autosavePoint->spawnflags & AUTOSAVE_TELE) ); strcat(fileBuf, lineBuf); } //find all the manually added spawnpoints autosavePoint = NULL; while ( (autosavePoint = G_Find (autosavePoint, FOFS(classname), "info_player_deathmatch")) != NULL ) { if(!(autosavePoint->spawnflags & 1)) {//not a manually placed spawnpoint continue; } Com_sprintf(lineBuf, MAX_QPATH, "%f %f %f %i %i/n", autosavePoint->r.currentOrigin[0], autosavePoint->r.currentOrigin[1], autosavePoint->r.currentOrigin[2], -1, 0 ); strcat(fileBuf, lineBuf); } if(fileBuf[0] != '/0') {//actually written something trap_FS_Write( fileBuf, strlen(fileBuf), f ); } trap_FS_FCloseFile( f ); G_Printf("^5Done./n");}
开发者ID:jwginge,项目名称:ojpa,代码行数:62,
示例27: UI_CalcPostGameStats/*=======================UI_CalcPostGameStats=======================*/static void UI_CalcPostGameStats( void ){ char map[MAX_QPATH]; char fileName[MAX_QPATH]; char info[MAX_INFO_STRING]; fileHandle_t f; int size, game, time, adjustedTime; postGameInfo_t oldInfo; postGameInfo_t newInfo; qboolean newHigh = qfalse; trap_GetConfigString(CS_SERVERINFO, info, sizeof(info)); Q_strncpyz(map, Info_ValueForKey(info, "mapname"), sizeof(map)); game = atoi(Info_ValueForKey(info, "g_gametype")); // compose file name Com_sprintf(fileName, MAX_QPATH, "games/%s_%i.game", map, game); // see if we have one already memset(&oldInfo, 0, sizeof(postGameInfo_t)); if (trap_FS_FOpenFile(fileName, &f, FS_READ) >= 0) { // if so load it size = 0; trap_FS_Read(&size, sizeof(int), f); if (size == sizeof(postGameInfo_t)) { trap_FS_Read(&oldInfo, sizeof(postGameInfo_t), f); } trap_FS_FCloseFile(f); } newInfo.accuracy = atoi(UI_Argv(3)); newInfo.impressives = atoi(UI_Argv(4)); newInfo.excellents = atoi(UI_Argv(5)); newInfo.defends = atoi(UI_Argv(6)); newInfo.assists = atoi(UI_Argv(7)); newInfo.gauntlets = atoi(UI_Argv(8)); newInfo.baseScore = atoi(UI_Argv(9)); newInfo.perfects = atoi(UI_Argv(10)); newInfo.redScore = atoi(UI_Argv(11)); newInfo.blueScore = atoi(UI_Argv(12)); time = atoi(UI_Argv(13)); newInfo.captures = atoi(UI_Argv(14)); newInfo.time = (time - trap_Cvar_VariableValue("ui_matchStartTime")) / 1000; adjustedTime = uiInfo.mapList[ui_currentMap.integer].timeToBeat[game]; if (newInfo.time < adjustedTime) { newInfo.timeBonus = (adjustedTime - newInfo.time) * 10; } else { newInfo.timeBonus = 0; } if (newInfo.redScore > newInfo.blueScore && newInfo.blueScore <= 0) { newInfo.shutoutBonus = 100; } else { newInfo.shutoutBonus = 0; } newInfo.skillBonus = trap_Cvar_VariableValue("g_spSkill"); if (newInfo.skillBonus <= 0) { newInfo.skillBonus = 1; } newInfo.score = newInfo.baseScore + newInfo.shutoutBonus + newInfo.timeBonus; newInfo.score *= newInfo.skillBonus; // see if the score is higher for this one newHigh = (newInfo.redScore > newInfo.blueScore && newInfo.score > oldInfo.score); if (newHigh) { // if so write out the new one uiInfo.newHighScoreTime = uiInfo.uiDC.realTime + 20000; if (trap_FS_FOpenFile(fileName, &f, FS_WRITE) >= 0) { size = sizeof(postGameInfo_t); trap_FS_Write(&size, sizeof(int), f); trap_FS_Write(&newInfo, sizeof(postGameInfo_t), f); trap_FS_FCloseFile(f); } } if (newInfo.time < oldInfo.time) { uiInfo.newBestTime = uiInfo.uiDC.realTime + 20000; } // put back all the ui overrides trap_Cvar_Set("capturelimit", UI_Cvar_VariableString("ui_saveCaptureLimit")); trap_Cvar_Set("fraglimit", UI_Cvar_VariableString("ui_saveFragLimit")); trap_Cvar_Set("cg_drawTimer", UI_Cvar_VariableString("ui_drawTimer")); trap_Cvar_Set("g_doWarmup", UI_Cvar_VariableString("ui_doWarmup")); trap_Cvar_Set("g_Warmup", UI_Cvar_VariableString("ui_Warmup")); trap_Cvar_Set("sv_pure", UI_Cvar_VariableString("ui_pure")); trap_Cvar_Set("g_friendlyFire", UI_Cvar_VariableString("ui_friendlyFire")); UI_SetBestScores(&newInfo, qtrue); UI_ShowPostGame(newHigh);}
开发者ID:Zekom,项目名称:reaction,代码行数:98,
示例28: CG_ParseVoiceChats/*=================CG_ParseVoiceChats=================*/int CG_ParseVoiceChats(const char *filename, voiceChatList_t * voiceChatList, int maxVoiceChats){ int len, i; fileHandle_t f; char buf[MAX_VOICEFILESIZE]; char **p, *ptr; char *token; voiceChat_t *voiceChats; qboolean compress; sfxHandle_t sound; compress = qtrue; if(cg_buildScript.integer) { compress = qfalse; } len = trap_FS_FOpenFile(filename, &f, FS_READ); if(!f) { trap_Print(va(S_COLOR_RED "voice chat file not found: %s/n", filename)); return qfalse; } if(len >= MAX_VOICEFILESIZE) { trap_Print(va(S_COLOR_RED "voice chat file too large: %s is %i, max allowed is %i", filename, len, MAX_VOICEFILESIZE)); trap_FS_FCloseFile(f); return qfalse; } trap_FS_Read(buf, len, f); buf[len] = 0; trap_FS_FCloseFile(f); ptr = buf; p = &ptr; Com_sprintf(voiceChatList->name, sizeof(voiceChatList->name), "%s", filename); voiceChats = voiceChatList->voiceChats; for(i = 0; i < maxVoiceChats; i++) { voiceChats[i].id[0] = 0; } token = Com_ParseExt(p, qtrue); if(!token || token[0] == 0) { return qtrue; } if(!Q_stricmp(token, "female")) { voiceChatList->gender = GENDER_FEMALE; } else if(!Q_stricmp(token, "male")) { voiceChatList->gender = GENDER_MALE; } else if(!Q_stricmp(token, "neuter")) { voiceChatList->gender = GENDER_NEUTER; } else { trap_Print(va(S_COLOR_RED "expected gender not found in voice chat file: %s/n", filename)); return qfalse; } voiceChatList->numVoiceChats = 0; while(1) { token = Com_ParseExt(p, qtrue); if(!token || token[0] == 0) { return qtrue; } Com_sprintf(voiceChats[voiceChatList->numVoiceChats].id, sizeof(voiceChats[voiceChatList->numVoiceChats].id), "%s", token); token = Com_ParseExt(p, qtrue); if(Q_stricmp(token, "{")) { trap_Print(va(S_COLOR_RED "expected { found %s in voice chat file: %s/n", token, filename)); return qfalse; } voiceChats[voiceChatList->numVoiceChats].numSounds = 0; while(1) { token = Com_ParseExt(p, qtrue); if(!token || token[0] == 0) { return qtrue; } if(!Q_stricmp(token, "}")) break; sound = trap_S_RegisterSound(token);//.........这里部分代码省略.........
开发者ID:SinSiXX,项目名称:Rogue-Reborn,代码行数:101,
示例29: G_xpsave_readconfigvoid G_xpsave_readconfig() { g_xpsave_t *x = g_xpsaves[0]; g_mapstat_t *m = g_mapstats[0]; int xc = 0; int mc = 0; fileHandle_t f; int i, j; int len; char *cnf, *cnf2; char *t; qboolean xpsave_open; qboolean mapstat_open; qboolean serverstat_open; qboolean found_serverstat = qfalse; float skill; char buffer[MAX_STRING_CHARS]; if(!(g_XPSave.integer & XPSF_ENABLE)) return; if(!g_XPSaveFile.string[0]) return; len = trap_FS_FOpenFile(g_XPSaveFile.string, &f, FS_READ) ; if(len < 0) { G_Printf("readconfig: could not open xpsave file %s/n", g_XPSaveFile.string); return; } cnf = malloc(len+1); cnf2 = cnf; trap_FS_Read(cnf, len, f); *(cnf + len) = '/0'; trap_FS_FCloseFile(f); G_xpsave_cleanup(); t = COM_Parse(&cnf); xpsave_open = qfalse; mapstat_open = qfalse; serverstat_open = qfalse; while(*t) { if(!Q_stricmp(t, "[xpsave]") || !Q_stricmp(t, "[mapstat]") || !Q_stricmp(t, "[serverstat]") ) { if(xpsave_open) g_xpsaves[xc++] = x; if(mapstat_open) g_mapstats[mc++] = m; xpsave_open = qfalse; mapstat_open = qfalse; serverstat_open = qfalse; } if(xpsave_open) { if(!Q_stricmp(t, "guid")) { G_shrubbot_readconfig_string(&cnf, x->guid, sizeof(x->guid)); } else if(!Q_stricmp(t, "name")) { G_shrubbot_readconfig_string(&cnf, x->name, sizeof(x->name)); } else if(!Q_stricmp(t, "time")) { G_shrubbot_readconfig_int(&cnf, &x->time); } else if(!Q_stricmpn(t, "skill[", 6)) { for(i=0; i<SK_NUM_SKILLS; i++) { if(Q_stricmp(t, va("skill[%i]", i))) continue; G_shrubbot_readconfig_float(&cnf, &skill); x->skill[i] = skill; break; } } else if(!Q_stricmp(t, "kill_rating")) { G_shrubbot_readconfig_float(&cnf, &x->kill_rating); } else if(!Q_stricmp(t, "kill_variance")) { G_shrubbot_readconfig_float(&cnf, &x->kill_variance); } else if(!Q_stricmp(t, "rating")) { G_shrubbot_readconfig_float(&cnf, &x->rating); } else if(!Q_stricmp(t, "rating_variance")) { G_shrubbot_readconfig_float(&cnf, &x->rating_variance); } else if(!Q_stricmp(t, "mutetime")) { G_shrubbot_readconfig_int(&cnf, &x->mutetime); } else if(!Q_stricmpn(t, "pr_skill[", 9)) { for(i=0; i<SK_NUM_SKILLS; i++) { if(Q_stricmp(t, va("pr_skill[%i]", i))) continue; G_shrubbot_readconfig_string(&cnf, buffer, sizeof(buffer));//.........这里部分代码省略.........
开发者ID:BulldogDrummond,项目名称:etpub,代码行数:101,
注:本文中的trap_FS_FCloseFile函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ trap_FS_Read函数代码示例 C++ trap_Error函数代码示例 |