/* ================= UI_CreateGame_GetMapsList ================= */ static void UI_CreateGame_GetMapsList( void ) { char *afile; if( !CHECK_MAP_LIST( FALSE ) || (afile = (char *)LOAD_FILE( "maps.lst", NULL )) == NULL ) { uiCreateGame.done.generic.flags |= QMF_GRAYED; uiCreateGame.mapsList.itemNames = (const char **)uiCreateGame.mapsDescriptionPtr; Con_Printf( "Cmd_GetMapsList: can't open maps.lst\n" ); return; } char *pfile = afile; char token[1024]; int numMaps = 0; while(( pfile = COM_ParseFile( pfile, token )) != NULL ) { if( numMaps >= UI_MAXGAMES ) break; StringConcat( uiCreateGame.mapName[numMaps], token, sizeof( uiCreateGame.mapName[0] )); StringConcat( uiCreateGame.mapsDescription[numMaps], token, MAPNAME_LENGTH ); StringConcat( uiCreateGame.mapsDescription[numMaps], uiEmptyString, MAPNAME_LENGTH ); if(( pfile = COM_ParseFile( pfile, token )) == NULL ) break; // unexpected end of file StringConcat( uiCreateGame.mapsDescription[numMaps], token, TITLE_LENGTH ); StringConcat( uiCreateGame.mapsDescription[numMaps], uiEmptyString, TITLE_LENGTH ); uiCreateGame.mapsDescriptionPtr[numMaps] = uiCreateGame.mapsDescription[numMaps]; numMaps++; } if( !numMaps ) uiCreateGame.done.generic.flags |= QMF_GRAYED; for( ; numMaps < UI_MAXGAMES; numMaps++ ) uiCreateGame.mapsDescriptionPtr[numMaps] = NULL; uiCreateGame.mapsList.itemNames = (const char **)uiCreateGame.mapsDescriptionPtr; FREE_FILE( afile ); }
/* ====================== CSCR_ParseHeader Check version and seek to first cvar name ====================== */ qboolean CSCR_ParseHeader( parserstate_t *ps ) { if( !CSCR_ExpectString( ps, "VERSION", false, true ) ) return false; // Parse in the version # // Get the first token. ps->buf = COM_ParseFile( ps->buf, ps->token ); if( Q_atof( ps->token ) != 1 ) { MsgDev( D_ERROR, "File %s has wrong version %s!\n", ps->filename, ps->token ); return false; } if( !CSCR_ExpectString( ps, "DESCRIPTION", false, true ) ) return false; ps->buf = COM_ParseFile( ps->buf, ps->token ); if( Q_stricmp( ps->token, "INFO_OPTIONS") && Q_stricmp( ps->token, "SERVER_OPTIONS" ) ) { MsgDev( D_ERROR, "DESCRIPTION must be INFO_OPTIONS or SERVER_OPTIONS\n"); return false; } if( !CSCR_ExpectString( ps, "{", false, true ) ) return false; return true; }
static void UI_LoadBackgroundMapList( void ) { if( !g_engfuncs.pfnFileExists( "scripts/chapterbackgrounds.txt", TRUE )) return; char *afile = (char *)LOAD_FILE( "scripts/chapterbackgrounds.txt", NULL ); char *pfile = afile; char token[1024]; uiStatic.bgmapcount = 0; if( !afile ) { Con_Printf( "UI_LoadBackgroundMapList: chapterbackgrounds.txt not found\n" ); return; } while(( pfile = COM_ParseFile( pfile, token )) != NULL ) { // skip the numbers (old format list) if( isdigit( token[0] )) continue; strncpy( uiStatic.bgmaps[uiStatic.bgmapcount], token, sizeof( uiStatic.bgmaps[0] )); if( ++uiStatic.bgmapcount > UI_MAX_BGMAPS ) break; // list is full } FREE_FILE( afile ); }
void Delta_InitFields( void ) { char *afile, *pfile; string encodeDll, encodeFunc, token; delta_info_t *dt; afile = FS_LoadFile( DELTA_PATH, NULL, false ); if( !afile ) { static string errormsg; Q_snprintf( errormsg, sizeof( errormsg ), "DELTA_Load: couldn't load file %s\n", DELTA_PATH ); Sys_Error( errormsg ); } pfile = afile; while(( pfile = COM_ParseFile( pfile, token )) != NULL ) { dt = Delta_FindStruct( token ); if( dt == NULL ) { Sys_Error( "delta.lst: unknown struct %s\n", token ); } pfile = COM_ParseFile( pfile, encodeDll ); if( !Q_stricmp( encodeDll, "none" )) Q_strcpy( encodeFunc, "null" ); else pfile = COM_ParseFile( pfile, encodeFunc ); // jump to '{' pfile = COM_ParseFile( pfile, token ); if( token[0] != '{' ) { Sys_Error( "delta.lst: missing '{' in section %s\n", dt->pName ); } Delta_ParseTable( &pfile, dt, encodeDll, encodeFunc ); } Mem_Free( afile ); // adding some requrid fields fields that user may forget or don't know how to specified Delta_AddField( "event_t", "velocity[0]", DT_SIGNED | DT_FLOAT, 16, 8.0f, 1.0f ); Delta_AddField( "event_t", "velocity[1]", DT_SIGNED | DT_FLOAT, 16, 8.0f, 1.0f ); Delta_AddField( "event_t", "velocity[2]", DT_SIGNED | DT_FLOAT, 16, 8.0f, 1.0f ); }
void UI_ApplyCustomColors( void ) { char *afile = (char *)LOAD_FILE( "gfx/shell/colors.lst", NULL ); char *pfile = afile; char token[1024]; if( !afile ) { // not error, not warning, just notify Con_Printf( "UI_SetColors: colors.lst not found\n" ); return; } while(( pfile = COM_ParseFile( pfile, token )) != NULL ) { if( !stricmp( token, "HELP_COLOR" )) { UI_ParseColor( pfile, &uiColorHelp ); } else if( !stricmp( token, "PROMPT_BG_COLOR" )) { UI_ParseColor( pfile, &uiPromptBgColor ); } else if( !stricmp( token, "PROMPT_TEXT_COLOR" )) { UI_ParseColor( pfile, &uiPromptTextColor ); } else if( !stricmp( token, "PROMPT_FOCUS_COLOR" )) { UI_ParseColor( pfile, &uiPromptFocusColor ); } else if( !stricmp( token, "INPUT_TEXT_COLOR" )) { UI_ParseColor( pfile, &uiInputTextColor ); } else if( !stricmp( token, "INPUT_BG_COLOR" )) { UI_ParseColor( pfile, &uiInputBgColor ); } else if( !stricmp( token, "INPUT_FG_COLOR" )) { UI_ParseColor( pfile, &uiInputFgColor ); } else if( !stricmp( token, "CON_TEXT_COLOR" )) { UI_ParseColor( pfile, &uiColorConsole ); } } int r, g, b; UnpackRGB( r, g, b, uiColorConsole ); ConsoleSetColor( r, g, b ); FREE_FILE( afile ); }
void Delta_ParseTable( char **delta_script, delta_info_t *dt, const char *encodeDll, const char *encodeFunc ) { string token; delta_t *pField; const delta_field_t *pInfo; // allocate the delta-structures if( !dt->pFields ) dt->pFields = (delta_t *)Z_Malloc( dt->maxFields * sizeof( delta_t )); pField = dt->pFields; pInfo = dt->pInfo; dt->numFields = 0; // assume we have handled '{' while(( *delta_script = COM_ParseFile( *delta_script, token )) != NULL ) { ASSERT( dt->numFields <= dt->maxFields ); if( !Q_strcmp( token, "DEFINE_DELTA" )) { if( Delta_ParseField( delta_script, pInfo, &pField[dt->numFields], false )) dt->numFields++; } else if( !Q_strcmp( token, "DEFINE_DELTA_POST" )) { if( Delta_ParseField( delta_script, pInfo, &pField[dt->numFields], true )) dt->numFields++; } else if( token[0] == '}' ) { // end of the section break; } } // copy function name Q_strncpy( dt->funcName, encodeFunc, sizeof( dt->funcName )); if( !Q_stricmp( encodeDll, "none" )) dt->customEncode = CUSTOM_NONE; else if( !Q_stricmp( encodeDll, "gamedll" )) dt->customEncode = CUSTOM_SERVER_ENCODE; else if( !Q_stricmp( encodeDll, "clientdll" )) dt->customEncode = CUSTOM_CLIENT_ENCODE; // adjust to fit memory size if( dt->numFields < dt->maxFields ) { dt->pFields = Z_Realloc( dt->pFields, dt->numFields * sizeof( delta_t )); } dt->bInitialized = true; // table is ok }
static void UI_Controls_ResetKeysList( void ) { char *afile = (char *)LOAD_FILE( "gfx/shell/kb_def.lst", NULL ); char *pfile = afile; char token[1024]; if( !afile ) { Con_Printf( "UI_Parse_KeysList: kb_act.lst not found\n" ); return; } while(( pfile = COM_ParseFile( pfile, token )) != NULL ) { char key[32]; strncpy( key, token, sizeof( key )); pfile = COM_ParseFile( pfile, token ); if( !pfile ) break; // technically an error char cmd[128]; if( key[0] == '\\' && key[1] == '\\' ) { key[0] = '\\'; key[1] = '\0'; } UI_UnbindCommand( token ); sprintf( cmd, "bind \"%s\" \"%s\"\n", key, token ); CLIENT_COMMAND( TRUE, cmd ); } FREE_FILE( afile ); UI_Controls_RestartMenu (); }
void UI_ParseColor( char *&pfile, int *outColor ) { int i, color[3]; char token[1024]; memset( color, 0xFF, sizeof( color )); for( i = 0; i < 3; i++ ) { pfile = COM_ParseFile( pfile, token ); if( !pfile ) break; color[i] = atoi( token ); } *outColor = PackRGB( color[0], color[1], color[2] ); }
/* =================== CSCR_ExpectString Return true if next token is pExpext and skip it =================== */ qboolean CSCR_ExpectString( parserstate_t *ps, const char *pExpect, qboolean skip, qboolean error ) { char *tmp = COM_ParseFile( ps->buf, ps->token ); if( !Q_stricmp( ps->token, pExpect ) ) { ps->buf = tmp; return true; } if( skip ) ps->buf = tmp; if( error ) MsgDev( D_ERROR, "Syntax error in %s: got \"%s\" instead of \"%s\"\n", ps->filename, ps->token, pExpect ); return false; }
/* ============ Cmd_TokenizeString Parses the given string into command line tokens. The text is copied to a seperate buffer and 0 characters are inserted in the apropriate place, The argv array will point into this temporary buffer. ============ */ void Cmd_TokenizeString( char *text ) { char cmd_token[MAX_CMD_BUFFER]; int i; // clear the args from the last string for( i = 0; i < cmd_argc; i++ ) Z_Free( cmd_argv[i] ); cmd_argc = 0; // clear previous args cmd_args = NULL; if( !text ) return; while( 1 ) { // skip whitespace up to a /n while( *text && ((byte)*text) <= ' ' && *text != '\n' ) text++; if( *text == '\n' ) { // a newline seperates commands in the buffer text++; break; } if( !*text ) return; if( cmd_argc == 1 ) cmd_args = text; text = COM_ParseFile( text, cmd_token ); if( !text ) return; if( cmd_argc < MAX_CMD_TOKENS ) { cmd_argv[cmd_argc] = copystring( cmd_token ); cmd_argc++; } } }
void SCR_CheckStartupVids( void ) { int c = 0; char *afile, *pfile; string token; if( Sys_CheckParm( "-nointro" ) || host.developer >= 2 || cls.demonum != -1 ) { // don't run movies where we in developer-mode cls.movienum = -1; return; } if( !FS_FileExists( "media/StartupVids.txt", false )) SCR_CreateStartupVids(); afile = FS_LoadFile( "media/StartupVids.txt", NULL, false ); if( !afile ) return; // something bad happens pfile = afile; while(( pfile = COM_ParseFile( pfile, token )) != NULL ) { Q_strncpy( cls.movies[c], token, sizeof( cls.movies[0] )); if( ++c > MAX_MOVIES - 1 ) { MsgDev( D_WARN, "Host_StartMovies: max %i movies in StartupVids\n", MAX_MOVIES ); break; } } Mem_Free( afile ); // run cinematic if( !SV_Active() && cls.movienum != -1 && cls.state != ca_cinematic ) { cls.movienum = 0; SCR_NextMovie (); } else cls.movienum = -1; }
/* =============== CL_ReadPointFile_f =============== */ void CL_ReadPointFile_f( void ) { char *afile, *pfile; vec3_t org; int count; particle_t *p; char filename[64]; string token; Q_snprintf( filename, sizeof( filename ), "maps/%s.pts", clgame.mapname ); afile = FS_LoadFile( filename, NULL, false ); if( !afile ) { MsgDev( D_ERROR, "couldn't open %s\n", filename ); return; } Msg( "Reading %s...\n", filename ); count = 0; pfile = afile; while( 1 ) { pfile = COM_ParseFile( pfile, token ); if( !pfile ) break; org[0] = Q_atof( token ); pfile = COM_ParseFile( pfile, token ); if( !pfile ) break; org[1] = Q_atof( token ); pfile = COM_ParseFile( pfile, token ); if( !pfile ) break; org[2] = Q_atof( token ); count++; if( !cl_free_particles ) { MsgDev( D_ERROR, "CL_ReadPointFile: not enough free particles!\n" ); break; } // NOTE: can't use CL_AllocateParticles because running from the console p = cl_free_particles; cl_free_particles = p->next; p->next = cl_active_particles; cl_active_particles = p; p->ramp = 0; p->die = 99999; p->color = (-count) & 15; p->type = pt_static; VectorClear( p->vel ); VectorCopy( org, p->org ); } Mem_Free( afile ); if( count ) Msg( "%i points read\n", count ); else Msg( "map %s has no leaks!\n", clgame.mapname ); }
qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir ) { byte buf[MAX_SYSPATH]; char *buffer; string result; int i, size; search_t *t; file_t *f; if( FS_FileSize( "maps.lst", onlyingamedir ) > 0 && !fRefresh ) { MsgDev( D_NOTE, "maps.lst is exist: %s\n", onlyingamedir ? "basedir" : "gamedir" ); return true; // exist } t = FS_Search( "maps/*.bsp", false, onlyingamedir ); if( !t ) { if( onlyingamedir ) { // mod doesn't contain any maps (probably this is a bot) return Cmd_CheckMapsList_R( fRefresh, false ); } return false; } buffer = Mem_Alloc( host.mempool, t->numfilenames * 2 * sizeof( result )); for( i = 0; i < t->numfilenames; i++ ) { char *ents = NULL, *pfile; int ver = -1, lumpofs = 0, lumplen = 0; string mapname, message, entfilename; const char *ext = FS_FileExtension( t->filenames[i] ); if( Q_stricmp( ext, "bsp" )) continue; f = FS_Open( t->filenames[i], "rb", onlyingamedir ); FS_FileBase( t->filenames[i], mapname ); if( f ) { int num_spawnpoints = 0; dheader_t *header; Q_memset( buf, 0, MAX_SYSPATH ); FS_Read( f, buf, MAX_SYSPATH ); ver = *(uint *)buf; switch( ver ) { case Q1BSP_VERSION: case HLBSP_VERSION: case XTBSP_VERSION: header = (dheader_t *)buf; if( header->lumps[LUMP_ENTITIES].fileofs <= 1024 ) { lumpofs = header->lumps[LUMP_PLANES].fileofs; lumplen = header->lumps[LUMP_PLANES].filelen; } else { lumpofs = header->lumps[LUMP_ENTITIES].fileofs; lumplen = header->lumps[LUMP_ENTITIES].filelen; } break; } Q_strncpy( entfilename, t->filenames[i], sizeof( entfilename )); FS_StripExtension( entfilename ); FS_DefaultExtension( entfilename, ".ent" ); ents = FS_LoadFile( entfilename, NULL, true ); if( !ents && lumplen >= 10 ) { FS_Seek( f, lumpofs, SEEK_SET ); ents = (char *)Mem_Alloc( host.mempool, lumplen + 1 ); FS_Read( f, ents, lumplen ); } if( ents ) { // if there are entities to parse, a missing message key just // means there is no title, so clear the message string now char token[2048]; qboolean worldspawn = true; Q_strncpy( message, "No Title", MAX_STRING ); pfile = ents; while(( pfile = COM_ParseFile( pfile, token )) != NULL ) { if( token[0] == '}' && worldspawn ) worldspawn = false; else if( !Q_strcmp( token, "message" ) && worldspawn ) { // get the message contents pfile = COM_ParseFile( pfile, message ); } else if( !Q_strcmp( token, "classname" )) { pfile = COM_ParseFile( pfile, token ); if( !Q_strcmp( token, GI->mp_entity )) num_spawnpoints++; } if( num_spawnpoints ) break; // valid map } Mem_Free( ents ); } if( f ) FS_Close( f ); if( num_spawnpoints ) { // format: mapname "maptitle"\n Q_sprintf( result, "%s \"%s\"\n", mapname, message ); Q_strcat( buffer, result ); // add new string } } } if( t ) Mem_Free( t ); // free search result size = Q_strlen( buffer ); if( !size ) { if( buffer ) Mem_Free( buffer ); if( onlyingamedir ) return Cmd_CheckMapsList_R( fRefresh, false ); return false; } // write generated maps.lst if( FS_WriteFile( "maps.lst", buffer, Q_strlen( buffer ))) { if( buffer ) Mem_Free( buffer ); return true; } return false; }
/* ===================================== Cmd_GetMapList Prints or complete map filename ===================================== */ qboolean Cmd_GetMapList( const char *s, char *completedname, int length ) { search_t *t; file_t *f; string message; string matchbuf; byte buf[MAX_SYSPATH]; // 1 kb int i, nummaps; t = FS_Search( va( "maps/%s*.bsp", s ), true, con_gamemaps->integer ); if( !t ) return false; FS_FileBase( t->filenames[0], matchbuf ); Q_strncpy( completedname, matchbuf, length ); if( t->numfilenames == 1 ) return true; for( i = 0, nummaps = 0; i < t->numfilenames; i++ ) { char entfilename[CS_SIZE]; int ver = -1, mapver = -1, lumpofs = 0, lumplen = 0; const char *ext = FS_FileExtension( t->filenames[i] ); char *ents = NULL, *pfile; qboolean paranoia = false; qboolean gearbox = false; if( Q_stricmp( ext, "bsp" )) continue; Q_strncpy( message, "^1error^7", sizeof( message )); f = FS_Open( t->filenames[i], "rb", con_gamemaps->integer ); if( f ) { dheader_t *header; dextrahdr_t *hdrext; Q_memset( buf, 0, sizeof( buf )); FS_Read( f, buf, sizeof( buf )); header = (dheader_t *)buf; ver = header->version; switch( ver ) { case Q1BSP_VERSION: case HLBSP_VERSION: case XTBSP_VERSION: if( header->lumps[LUMP_ENTITIES].fileofs <= 1024 && !(header->lumps[LUMP_ENTITIES].filelen % sizeof(dplane_t))) { lumpofs = header->lumps[LUMP_PLANES].fileofs; lumplen = header->lumps[LUMP_PLANES].filelen; gearbox = true; } else { lumpofs = header->lumps[LUMP_ENTITIES].fileofs; lumplen = header->lumps[LUMP_ENTITIES].filelen; gearbox = false; } break; } if( ver == XTBSP_VERSION ) hdrext = (dextrahdr_t *)((byte *)buf + sizeof( dheader31_t )); else hdrext = (dextrahdr_t *)((byte *)buf + sizeof( dheader_t )); if( hdrext->id == IDEXTRAHEADER && hdrext->version == EXTRA_VERSION ) paranoia = true; Q_strncpy( entfilename, t->filenames[i], sizeof( entfilename )); FS_StripExtension( entfilename ); FS_DefaultExtension( entfilename, ".ent" ); ents = FS_LoadFile( entfilename, NULL, true ); if( !ents && lumplen >= 10 ) { FS_Seek( f, lumpofs, SEEK_SET ); ents = (char *)Mem_Alloc( host.mempool, lumplen + 1 ); FS_Read( f, ents, lumplen ); } if( ents ) { // if there are entities to parse, a missing message key just // means there is no title, so clear the message string now char token[2048]; message[0] = 0; pfile = ents; while(( pfile = COM_ParseFile( pfile, token )) != NULL ) { if( !Q_strcmp( token, "{" )) continue; else if(!Q_strcmp( token, "}" )) break; else if(!Q_strcmp( token, "message" )) { // get the message contents pfile = COM_ParseFile( pfile, message ); } else if(!Q_strcmp( token, "mapversion" )) { // get the message contents pfile = COM_ParseFile( pfile, token ); mapver = Q_atoi( token ); } } Mem_Free( ents ); } } if( f ) FS_Close(f); FS_FileBase( t->filenames[i], matchbuf ); switch( ver ) { case Q1BSP_VERSION: if( mapver == 220 ) Q_strncpy( buf, "Half-Life Alpha", sizeof( buf )); else Q_strncpy( buf, "Quake", sizeof( buf )); break; case HLBSP_VERSION: if( gearbox ) Q_strncpy( buf, "Blue-Shift", sizeof( buf )); else if( paranoia ) Q_strncpy( buf, "Paranoia 2", sizeof( buf )); else Q_strncpy( buf, "Half-Life", sizeof( buf )); break; case XTBSP_VERSION: if( paranoia ) Q_strncpy( buf, "Paranoia 2", sizeof( buf )); else Q_strncpy( buf, "Xash3D", sizeof( buf )); break; default: Q_strncpy( buf, "??", sizeof( buf )); break; } Msg( "%16s (%s) ^3%s^7\n", matchbuf, buf, message ); nummaps++; } Msg( "\n^3 %i maps found.\n", nummaps ); Mem_Free( t ); // cut shortestMatch to the amount common with s for( i = 0; matchbuf[i]; i++ ) { if( Q_tolower( completedname[i] ) != Q_tolower( matchbuf[i] )) completedname[i] = 0; } return true; }
void R_ParseTexFilters( const char *filename ) { char *afile, *pfile; string token, texname; dfilter_t *tf; int i; afile = (char *)FS_LoadFile( filename, NULL, false ); if( !afile ) return; pfile = afile; // format: 'texturename' 'filtername' 'factor' 'bias' 'blendmode' 'grayscale' while(( pfile = COM_ParseFile( pfile, token )) != NULL ) { imgfilter_t filter; Q_memset( &filter, 0, sizeof( filter )); Q_strncpy( texname, token, sizeof( texname )); // parse filter pfile = COM_ParseFile( pfile, token ); if( !Q_stricmp( token, "blur" )) filter.filter = BLUR_FILTER; else if( !Q_stricmp( token, "blur2" )) filter.filter = BLUR_FILTER2; else if( !Q_stricmp( token, "edge" )) filter.filter = EDGE_FILTER; else if( !Q_stricmp( token, "emboss" )) filter.filter = EMBOSS_FILTER; // reading factor pfile = COM_ParseFile( pfile, token ); filter.factor = Q_atof( token ); // reading bias pfile = COM_ParseFile( pfile, token ); filter.bias = Q_atof( token ); // reading blendFunc pfile = COM_ParseFile( pfile, token ); if( !Q_stricmp( token, "modulate" ) || !Q_stricmp( token, "GL_MODULATE" )) filter.blendFunc = GL_MODULATE; else if( !Q_stricmp( token, "replace" ) || !Q_stricmp( token, "GL_REPLACE" )) filter.blendFunc = GL_REPLACE; else if( !Q_stricmp( token, "add" ) || !Q_stricmp( token, "GL_ADD" )) filter.blendFunc = GL_ADD; else if( !Q_stricmp( token, "decal" ) || !Q_stricmp( token, "GL_DECAL" )) filter.blendFunc = GL_DECAL; else if( !Q_stricmp( token, "blend" ) || !Q_stricmp( token, "GL_BLEND" )) filter.blendFunc = GL_BLEND; else if( !Q_stricmp( token, "add_signed" ) || !Q_stricmp( token, "GL_ADD_SIGNED" )) filter.blendFunc = GL_ADD_SIGNED; else MsgDev( D_WARN, "unknown blendFunc '%s' specified for texture '%s'\n", texname, token ); // reading flags pfile = COM_ParseFile( pfile, token ); filter.flags = Q_atoi( token ); // make sure what factor is not zeroed if( filter.factor == 0.0f ) { MsgDev( D_WARN, "texfilter for texture %s has factor 0! Ignored\n", texname ); continue; } // check if already existed for( i = 0; i < num_texfilters; i++ ) { tf = tex_filters[i]; if( !Q_stricmp( tf->texname, texname )) { MsgDev( D_WARN, "texture %s has specified multiple filters! Ignored\n", texname ); break; } } if( i != num_texfilters ) continue; // already specified // allocate new texfilter tf = Z_Malloc( sizeof( dfilter_t )); tex_filters[num_texfilters++] = tf; Q_strncpy( tf->texname, texname, sizeof( tf->texname )); tf->filter = filter; } MsgDev( D_INFO, "%i texture filters parsed\n", num_texfilters ); Mem_Free( afile ); }
//============================================ CParticleSystem :: CParticleSystem( cl_entity_t *ent, const char *szFilename, int attachment, float lifetime ) { int iParticles = 100; // default m_iKillCondition = CONTENTS_NONE; m_iEntAttachment = attachment; m_pActiveParticle = NULL; m_pMainParticle = NULL; m_fLifeTime = lifetime; m_pNextSystem = NULL; m_iLightingModel = 0; m_pFirstType = NULL; m_pEntity = ent; enable = true; entityMatrix.Identity(); if( !c_bCosTableInit ) { for( int i = 0; i < 360 + 90; i++ ) c_fCosTable[i] = cos( i * M_PI / 180.0f ); c_bCosTableInit = true; } char *afile = (char *)gEngfuncs.COM_LoadFile( (char *)szFilename, 5, NULL ); char szToken[1024]; char *pfile = afile; if( !pfile ) { ALERT( at_error, "couldn't load %s.\n", szFilename ); return; } else { pfile = COM_ParseFile( pfile, szToken ); while( pfile ) { if( !Q_stricmp( szToken, "particles" )) { pfile = COM_ParseFile( pfile, szToken ); iParticles = Q_atoi( szToken ); } else if( !Q_stricmp( szToken, "maintype" )) { pfile = COM_ParseFile( pfile, szToken ); m_pMainType = AddPlaceholderType( szToken ); } else if( !Q_stricmp( szToken, "attachment" )) { pfile = COM_ParseFile( pfile, szToken ); m_iEntAttachment = Q_atoi( szToken ); } else if( !Q_stricmp( szToken, "lightmodel" )) { pfile = COM_ParseFile( pfile, szToken ); m_iLightingModel = Q_atoi( szToken ); } else if( !Q_stricmp( szToken, "killcondition" )) { pfile = COM_ParseFile( pfile, szToken ); if( !Q_stricmp( szToken, "empty" )) { m_iKillCondition = CONTENTS_EMPTY; } else if( !Q_stricmp( szToken, "water" )) { m_iKillCondition = CONTENTS_WATER; } else if( !Q_stricmp( szToken, "solid" )) { m_iKillCondition = CONTENTS_SOLID; } } else if( !Q_stricmp( szToken, "{" )) { // parse new type this->ParseType( pfile ); } pfile = COM_ParseFile( pfile, szToken ); } } gEngfuncs.COM_FreeFile( afile ); AllocateParticles( iParticles ); }
void R_ParseDetailTextures( const char *filename ) { char *afile, *pfile; string token, texname, detail_texname; float xScale, yScale; texture_t *tex; int i; if( r_detailtextures->integer >= 2 && !FS_FileExists( filename, false )) { // use built-in generator for detail textures R_CreateDetailTexturesList( filename ); } afile = FS_LoadFile( filename, NULL, false ); if( !afile ) return; pfile = afile; // format: 'texturename' 'detailtexture' 'xScale' 'yScale' while(( pfile = COM_ParseFile( pfile, token )) != NULL ) { texname[0] = '\0'; // read texname if( token[0] == '{' ) { // NOTE: COM_ParseFile handled some symbols seperately // this code will be fix it pfile = COM_ParseFile( pfile, token ); Q_strncat( texname, "{", sizeof( texname )); Q_strncat( texname, token, sizeof( texname )); } else Q_strncpy( texname, token, sizeof( texname )); // read detailtexture name pfile = COM_ParseFile( pfile, token ); Q_snprintf( detail_texname, sizeof( detail_texname ), "gfx/%s.tga", token ); // read scales pfile = COM_ParseFile( pfile, token ); xScale = Q_atof( token ); pfile = COM_ParseFile( pfile, token ); yScale = Q_atof( token ); if( xScale <= 0.0f || yScale <= 0.0f ) continue; // search for existing texture and uploading detail texture for( i = 0; i < cl.worldmodel->numtextures; i++ ) { tex = cl.worldmodel->textures[i]; if( Q_stricmp( tex->name, texname )) continue; tex->dt_texturenum = GL_LoadTexture( detail_texname, NULL, 0, TF_FORCE_COLOR ); // texture is loaded if( tex->dt_texturenum ) { gltexture_t *glt; GL_SetTextureType( tex->dt_texturenum, TEX_DETAIL ); glt = R_GetTexture( tex->gl_texturenum ); glt->xscale = xScale; glt->yscale = yScale; } break; } } Mem_Free( afile ); }
/* ====================== CSCR_WriteGameCVars Print all cvars declared in script to gamesettings.cfg file ====================== */ int CSCR_WriteGameCVars( file_t *cfg, const char *scriptfilename ) { int count = 0; fs_offset_t length = 0; char *start; parserstate_t state = {0}; qboolean success = false; state.filename = scriptfilename; state.buf = (char*)FS_LoadFile( scriptfilename, &length, true ); start = state.buf; if( state.buf == 0 || length == 0 ) { if( start ) Mem_Free( start ); return 0; } MsgDev( D_INFO, "Reading config script file %s\n", scriptfilename ); if( !CSCR_ParseHeader( &state ) ) { MsgDev( D_ERROR, "Failed to parse header!\n" ); goto finish; } FS_Printf( cfg, "// declared in %s:\n", scriptfilename ); while( !CSCR_ExpectString( &state, "}", false, false ) ) { scrvardef_t var = { 0 }; if( CSCR_ParseSingleCvar( &state, &var ) ) { convar_t *cvar = Cvar_FindVar( var.name ); if( cvar && !( cvar->flags & ( CVAR_SERVERNOTIFY | CVAR_ARCHIVE ) ) ) { // cvars will be placed in gamesettings.cfg and restored on map start if( var.flags & CVAR_USERINFO ) FS_Printf( cfg, "// %s ( %s )\nsetu %s \"%s\"\n", var.desc, var.value, var.name, cvar->string ); else FS_Printf( cfg, "// %s ( %s )\nset %s \"%s\"\n", var.desc, var.value, var.name, cvar->string ); } count++; } else break; if( count > 1024 ) break; } if( COM_ParseFile( state.buf, state.token ) ) MsgDev( D_ERROR, "Got extra tokens!\n" ); else success = true; finish: if( !success ) { state.token[ sizeof( state.token ) - 1 ] = 0; if( start && state.buf ) MsgDev( D_ERROR, "Parse error in %s, byte %d, token %s\n", scriptfilename, (int)( state.buf - start ), state.token ); else MsgDev( D_ERROR, "Parse error in %s, token %s\n", scriptfilename, state.token ); } if( start ) Mem_Free( start ); return count; }
/* ====================== CSCR_LoadDefaultCVars Register all cvars declared in config file and set default values ====================== */ int CSCR_LoadDefaultCVars( const char *scriptfilename ) { int count = 0; fs_offset_t length = 0; char *start; parserstate_t state = {0}; qboolean success = false; state.filename = scriptfilename; state.buf = (char*)FS_LoadFile( scriptfilename, &length, true ); start = state.buf; if( state.buf == 0 || length == 0) { if( start ) Mem_Free( start ); return 0; } MsgDev( D_INFO, "Reading config script file %s\n", scriptfilename ); if( !CSCR_ParseHeader( &state ) ) { MsgDev( D_ERROR, "Failed to parse header!\n" ); goto finish; } while( !CSCR_ExpectString( &state, "}", false, false ) ) { scrvardef_t var = { 0 }; // Create a new object if( CSCR_ParseSingleCvar( &state, &var ) ) { Cvar_Get( var.name, var.value, var.flags, var.desc ); count++; } else break; if( count > 1024 ) break; } if( COM_ParseFile( state.buf, state.token ) ) MsgDev( D_ERROR, "Got extra tokens!\n" ); else success = true; finish: if( !success ) { state.token[ sizeof( state.token ) - 1 ] = 0; if( start && state.buf ) MsgDev( D_ERROR, "Parse error in %s, byte %d, token %s\n", scriptfilename, (int)( state.buf - start ), state.token ); else MsgDev( D_ERROR, "Parse error in %s, token %s\n", scriptfilename, state.token ); } if( start ) Mem_Free( start ); return count; }
qboolean Delta_ParseField( char **delta_script, const delta_field_t *pInfo, delta_t *pField, qboolean bPost ) { string token; delta_field_t *pFieldInfo; char *oldpos; *delta_script = COM_ParseFile( *delta_script, token ); if( Q_strcmp( token, "(" )) { MsgDev( D_ERROR, "Delta_ParseField: expected '(', found '%s' instead\n", token ); return false; } // read the variable name if(( *delta_script = COM_ParseFile( *delta_script, token )) == NULL ) { MsgDev( D_ERROR, "Delta_ParseField: missing field name\n" ); return false; } pFieldInfo = Delta_FindFieldInfo( pInfo, token ); if( !pFieldInfo ) { MsgDev( D_ERROR, "Delta_ParseField: unable to find field %s\n", token ); return false; } *delta_script = COM_ParseFile( *delta_script, token ); if( Q_strcmp( token, "," )) { MsgDev( D_ERROR, "Delta_ParseField: expected ',', found '%s' instead\n", token ); return false; } // copy base info to new field pField->name = pFieldInfo->name; pField->offset = pFieldInfo->offset; pField->size = pFieldInfo->size; pField->flags = 0; // read delta-flags while(( *delta_script = COM_ParseFile( *delta_script, token )) != NULL ) { if( !Q_strcmp( token, "," )) break; // end of flags argument if( !Q_strcmp( token, "|" )) continue; if( !Q_strcmp( token, "DT_BYTE" )) pField->flags |= DT_BYTE; else if( !Q_strcmp( token, "DT_SHORT" )) pField->flags |= DT_SHORT; else if( !Q_strcmp( token, "DT_FLOAT" )) pField->flags |= DT_FLOAT; else if( !Q_strcmp( token, "DT_INTEGER" )) pField->flags |= DT_INTEGER; else if( !Q_strcmp( token, "DT_ANGLE" )) pField->flags |= DT_ANGLE; else if( !Q_strcmp( token, "DT_TIMEWINDOW_8" )) pField->flags |= DT_TIMEWINDOW_8; else if( !Q_strcmp( token, "DT_TIMEWINDOW_BIG" )) pField->flags |= DT_TIMEWINDOW_BIG; else if( !Q_strcmp( token, "DT_STRING" )) pField->flags |= DT_STRING; else if( !Q_strcmp( token, "DT_SIGNED" )) pField->flags |= DT_SIGNED; } if( Q_strcmp( token, "," )) { MsgDev( D_ERROR, "Delta_ParseField: expected ',', found '%s' instead\n", token ); return false; } // read delta-bits if(( *delta_script = COM_ParseFile( *delta_script, token )) == NULL ) { MsgDev( D_ERROR, "Delta_ReadField: %s field bits argument is missing\n", pField->name ); return false; } pField->bits = Q_atoi( token ); *delta_script = COM_ParseFile( *delta_script, token ); if( Q_strcmp( token, "," )) { MsgDev( D_ERROR, "Delta_ReadField: expected ',', found '%s' instead\n", token ); return false; } // read delta-multiplier if(( *delta_script = COM_ParseFile( *delta_script, token )) == NULL ) { MsgDev( D_ERROR, "Delta_ReadField: %s missing 'multiplier' argument\n", pField->name ); return false; } pField->multiplier = Q_atof( token ); if( bPost ) { *delta_script = COM_ParseFile( *delta_script, token ); if( Q_strcmp( token, "," )) { MsgDev( D_ERROR, "Delta_ReadField: expected ',', found '%s' instead\n", token ); return false; } // read delta-postmultiplier if(( *delta_script = COM_ParseFile( *delta_script, token )) == NULL ) { MsgDev( D_ERROR, "Delta_ReadField: %s missing 'post_multiply' argument\n", pField->name ); return false; } pField->post_multiplier = Q_atof( token ); } else { // to avoid division by zero pField->post_multiplier = 1.0f; } // closing brace... *delta_script = COM_ParseFile( *delta_script, token ); if( Q_strcmp( token, ")" )) { MsgDev( D_ERROR, "Delta_ParseField: expected ')', found '%s' instead\n", token ); return false; } // ... and trying to parse optional ',' post-symbol oldpos = *delta_script; *delta_script = COM_ParseFile( *delta_script, token ); if( token[0] != ',' ) *delta_script = oldpos; // not a ',' return true; }
// creates a new CParticletype from the given file // NB: this changes the value of pfile. CParticleType *CParticleSystem :: ParseType( char *&pfile ) { CParticleType *pType = new CParticleType(); // parse the .aur file char szToken[1024]; pfile = COM_ParseFile( pfile, szToken ); while( Q_stricmp( szToken, "}" )) { if( !pfile ) break; if( !Q_stricmp( szToken, "name" )) { pfile = COM_ParseFile( pfile, szToken ); Q_strncpy( pType->m_szName, szToken, sizeof( pType->m_szName )); CParticleType *pTemp = GetType( szToken ); if( pTemp ) { // there's already a type with this name if( pTemp->m_bIsDefined ) ALERT( at_warning, "Particle type %s is defined more than once!\n", szToken ); // copy all our data into the existing type, throw away the type we were making *pTemp = *pType; delete pType; pType = pTemp; pType->m_bIsDefined = true; // record the fact that it's defined, so we won't need to add it to the list } } else if( !Q_stricmp( szToken, "gravity" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_Gravity = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "windyaw" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_WindYaw = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "windstrength" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_WindStrength = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "sprite" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_hSprite = SPR_Load( szToken ); } else if( !Q_stricmp( szToken, "startalpha" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_StartAlpha = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "endalpha" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_EndAlpha = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "startred" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_StartRed = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "endred" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_EndRed = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "startgreen" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_StartGreen = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "endgreen" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_EndGreen = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "startblue" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_StartBlue = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "endblue" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_EndBlue = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "startsize" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_StartSize = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "sizedelta" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_SizeDelta = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "endsize" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_EndSize = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "startangle" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_StartAngle = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "angledelta" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_AngleDelta = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "startframe" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_StartFrame = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "endframe" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_EndFrame = RandomRange( szToken ); pType->m_bEndFrame = true; } else if( !Q_stricmp( szToken, "framerate" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_FrameRate = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "lifetime" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_Life = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "spraytype" )) { pfile = COM_ParseFile( pfile, szToken ); CParticleType *pTemp = GetType( szToken ); if( pTemp ) pType->m_pSprayType = pTemp; else pType->m_pSprayType = AddPlaceholderType( szToken ); } else if( !Q_stricmp( szToken, "overlaytype" )) { pfile = COM_ParseFile( pfile, szToken ); CParticleType *pTemp = GetType( szToken ); if( pTemp ) pType->m_pOverlayType = pTemp; else pType->m_pOverlayType = AddPlaceholderType( szToken ); } else if( !Q_stricmp( szToken, "sprayrate" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_SprayRate = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "sprayforce" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_SprayForce = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "spraypitch" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_SprayPitch = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "sprayyaw" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_SprayYaw = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "drag" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_Drag = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "bounce" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_Bounce = RandomRange( szToken ); if( pType->m_Bounce.m_flMin != 0 || pType->m_Bounce.m_flMax != 0 ) pType->m_bBouncing = true; } else if( !Q_stricmp( szToken, "bouncefriction" )) { pfile = COM_ParseFile( pfile, szToken ); pType->m_BounceFriction = RandomRange( szToken ); } else if( !Q_stricmp( szToken, "rendermode" )) { pfile = COM_ParseFile( pfile, szToken ); if( !Q_stricmp( szToken, "additive" )) { pType->m_iRenderMode = kRenderTransAdd; } else if( !Q_stricmp( szToken, "solid" )) { pType->m_iRenderMode = kRenderTransAlpha; } else if( !Q_stricmp( szToken, "texture" )) { pType->m_iRenderMode = kRenderTransTexture; } else if( !Q_stricmp( szToken, "color" )) { pType->m_iRenderMode = kRenderTransColor; } } else if( !Q_stricmp( szToken, "drawcondition" )) { pfile = COM_ParseFile( pfile, szToken ); if( !Q_stricmp( szToken, "empty" )) { pType->m_iDrawCond = CONTENTS_EMPTY; } else if( !Q_stricmp( szToken, "water" )) { pType->m_iDrawCond = CONTENTS_WATER; } else if( !Q_stricmp( szToken, "solid" )) { pType->m_iDrawCond = CONTENTS_SOLID; } else if( !Q_stricmp( szToken, "special" ) || !Q_stricmp( szToken, "special1" )) { pType->m_iDrawCond = CONTENT_SPECIAL1; } else if( !Q_stricmp( szToken, "special2" )) { pType->m_iDrawCond = CONTENT_SPECIAL2; } else if( !Q_stricmp( szToken, "special3" )) { pType->m_iDrawCond = CONTENT_SPECIAL3; } else if( !Q_stricmp( szToken, "spotlight" )) { pType->m_iDrawCond = CONTENT_SPOTLIGHT; } } // get the next token pfile = COM_ParseFile( pfile, szToken ); } if( !pType->m_bIsDefined ) { // if this is a newly-defined type, we need to add it to the list pType->m_pNext = m_pFirstType; m_pFirstType = pType; pType->m_bIsDefined = true; } return pType; }
static void UI_Controls_ParseKeysList( void ) { char *afile = (char *)LOAD_FILE( "gfx/shell/kb_act.lst", NULL ); char *pfile = afile; char token[1024]; int i = 0; if( !afile ) { for( ; i < MAX_KEYS; i++ ) uiControls.keysDescriptionPtr[i] = NULL; uiControls.keysList.itemNames = (const char **)uiControls.keysDescriptionPtr; Con_Printf( "UI_Parse_KeysList: kb_act.lst not found\n" ); return; } while(( pfile = COM_ParseFile( pfile, token )) != NULL ) { char str[128]; if( !stricmp( token, "blank" )) { // seperator pfile = COM_ParseFile( pfile, token ); if( !pfile ) break; // technically an error sprintf( str, "^6%s^7", token ); // enable uiPromptTextColor StringConcat( uiControls.keysDescription[i], str, strlen( str ) + 1 ); StringConcat( uiControls.keysDescription[i], uiEmptyString, 256 ); // empty uiControls.keysDescriptionPtr[i] = uiControls.keysDescription[i]; strcpy( uiControls.keysBind[i], "" ); strcpy( uiControls.firstKey[i], "" ); strcpy( uiControls.secondKey[i], "" ); i++; } else { // key definition int keys[2]; UI_Controls_GetKeyBindings( token, keys ); strncpy( uiControls.keysBind[i], token, sizeof( uiControls.keysBind[i] )); pfile = COM_ParseFile( pfile, token ); if( !pfile ) break; // technically an error sprintf( str, "^6%s^7", token ); // enable uiPromptTextColor if( keys[0] == -1 ) strcpy( uiControls.firstKey[i], "" ); else strncpy( uiControls.firstKey[i], KEY_KeynumToString( keys[0] ), sizeof( uiControls.firstKey[i] )); if( keys[1] == -1 ) strcpy( uiControls.secondKey[i], "" ); else strncpy( uiControls.secondKey[i], KEY_KeynumToString( keys[1] ), sizeof( uiControls.secondKey[i] )); StringConcat( uiControls.keysDescription[i], str, CMD_LENGTH ); StringConcat( uiControls.keysDescription[i], uiEmptyString, CMD_LENGTH ); // HACKHACK this color should be get from kb_keys.lst if( !strnicmp( uiControls.firstKey[i], "MOUSE", 5 )) sprintf( str, "^5%s^7", uiControls.firstKey[i] ); // cyan else sprintf( str, "^3%s^7", uiControls.firstKey[i] ); // yellow StringConcat( uiControls.keysDescription[i], str, KEY1_LENGTH ); StringConcat( uiControls.keysDescription[i], uiEmptyString, KEY1_LENGTH ); // HACKHACK this color should be get from kb_keys.lst if( !strnicmp( uiControls.secondKey[i], "MOUSE", 5 )) sprintf( str, "^5%s^7", uiControls.secondKey[i] );// cyan else sprintf( str, "^3%s^7", uiControls.secondKey[i] ); // yellow StringConcat( uiControls.keysDescription[i], str, KEY2_LENGTH ); StringConcat( uiControls.keysDescription[i], uiEmptyString, KEY2_LENGTH ); uiControls.keysDescriptionPtr[i] = uiControls.keysDescription[i]; i++; } } FREE_FILE( afile ); for( ; i < MAX_KEYS; i++ ) uiControls.keysDescriptionPtr[i] = NULL; uiControls.keysList.itemNames = (const char **)uiControls.keysDescriptionPtr; }
bool FS_ParseLiblistGam(const char *filename, const char *gamedir, gameinfo_t *GameInfo) { char *pfile; string token; if(!GameInfo) return false; char *afile = mpFileSystem->LoadFile(filename, NULL, false); if(!afile) return false; // setup default values GameInfo->max_edicts = 900; // default value if not specified GameInfo->max_tents = 500; GameInfo->max_beams = 128; GameInfo->soundclip_dist = 1536; GameInfo->max_particles = 4096; GameInfo->version = 1.0f; GameInfo->falldir[0] = '\0'; GameInfo->title = "New Game"; GameInfo->gamedir = gamedir; GameInfo->basedir = SI.ModuleName; GameInfo->sp_entity = "info_player_start"; GameInfo->mp_entity = "info_player_deathmatch"; GameInfo->game_dll = "dlls/hl.dll"; GameInfo->startmap = "newmap"; GameInfo->dll_path = "cl_dlls"; GameInfo->iconpath = "game.ico"; VectorSet(GameInfo->client_mins[0], 0, 0, 0 ); VectorSet(GameInfo->client_maxs[0], 0, 0, 0 ); VectorSet(GameInfo->client_mins[1], -16, -16, -36); VectorSet(GameInfo->client_maxs[1], 16, 16, 36); VectorSet(GameInfo->client_mins[2], -32, -32, -32); VectorSet(GameInfo->client_maxs[2], 32, 32, 32); VectorSet(GameInfo->client_mins[3], -16, -16, -18); VectorSet(GameInfo->client_maxs[3], 16, 16, 18); pfile = afile; while((pfile = COM_ParseFile(pfile, token)) != NULL) { if(token == "game") pfile = COM_ParseFile(pfile, GameInfo->msTitle); if(token == "gamedir") pfile = COM_ParseFile(pfile, GameInfo->msGameDir); if(token == "fallback_dir") pfile = COM_ParseFile(pfile, GameInfo->msFallDir); else if(token == "startmap") { pfile = COM_ParseFile(pfile, GameInfo->msStartMap); FS_StripExtension(GameInfo->msStartMap); // HQ2:Amen has extension .bsp } else if(token == "trainmap" || token == "trainingmap") { pfile = COM_ParseFile(pfile, GameInfo->msTrainMap); FS_StripExtension(GameInfo->msTrainMap); // HQ2:Amen has extension .bsp } else if(token == "url_info") pfile = COM_ParseFile(pfile, GameInfo->msGameURL); else if(token == "url_dl") pfile = COM_ParseFile(pfile, GameInfo->msUpdateURL); else if(token == "gamedll") { pfile = COM_ParseFile(pfile, GameInfo->msGameDLL); COM_FixSlashes(GameInfo->msGameDLL); } else if(token == "icon") { pfile = COM_ParseFile(pfile, GameInfo->msIconPath); COM_FixSlashes(GameInfo->msIconPath); FS_DefaultExtension(GameInfo->msIconPath, ".ico"); } else if(token == "type") { pfile = COM_ParseFile(pfile, token); if(token == "singleplayer_only") { GameInfo->gamemode = 1; strncpy(GameInfo->type, "Single", sizeof(GameInfo->type)); } else if(token == "multiplayer_only") { GameInfo->gamemode = 2; strncpy(GameInfo->type, "Multiplayer", sizeof(GameInfo->type)); } else { // pass type without changes GameInfo->gamemode = 0; strncpy(GameInfo->type, token, sizeof(GameInfo->type)); }; } else if(token == "version") { pfile = COM_ParseFile(pfile, token); GameInfo->version = Q_atof(token); } else if(token == "size") { pfile = COM_ParseFile(pfile, token); GameInfo->size = Q_atoi(token); } else if(token == "mpentity") pfile = COM_ParseFile(pfile, GameInfo->mp_entity); else if(token == "secure") { pfile = COM_ParseFile(pfile, token); GameInfo->secure = Q_atoi(token); } else if(token == "nomodels") { pfile = COM_ParseFile(pfile, token); GameInfo->nomodels = Q_atoi(token); }; }; if(!mpFileSystem->IsSysFolderExists(va("%s\\%s", host.rootdir, GameInfo->gamedir))) GameInfo->msGameDir = gamedir; if(!mpFileSystem->IsSysFolderExists(va("%s\\%s", host.rootdir, GameInfo->falldir))) GameInfo->msFallDir = ""; if(afile != NULL) Mem_Free(afile); return true; };
/* ========================= CSCR_ParseSingleCvar ========================= */ qboolean CSCR_ParseSingleCvar( parserstate_t *ps, scrvardef_t *result ) { // read the name ps->buf = COM_ParseFile( ps->buf, result->name ); if( !CSCR_ExpectString( ps, "{", false, true ) ) return false; // read description ps->buf = COM_ParseFile( ps->buf, result->desc ); if( !CSCR_ExpectString( ps, "{", false, true ) ) return false; result->type = CSCR_ParseType( ps ); switch( result->type ) { case T_BOOL: // bool only has description if( !CSCR_ExpectString( ps, "}", false, true ) ) return false; break; case T_NUMBER: // min ps->buf = COM_ParseFile( ps->buf, ps->token ); result->fMin = Q_atof( ps->token ); // max ps->buf = COM_ParseFile( ps->buf, ps->token ); result->fMax = Q_atof( ps->token ); if( !CSCR_ExpectString( ps, "}", false, true ) ) return false; break; case T_STRING: if( !CSCR_ExpectString( ps, "}", false, true ) ) return false; break; case T_LIST: while( !CSCR_ExpectString( ps, "}", true, false ) ) { // Read token for each item here } break; default: return false; } if( !CSCR_ExpectString( ps, "{", false, true ) ) return false; // default value ps->buf = COM_ParseFile( ps->buf, result->value ); if( !CSCR_ExpectString( ps, "}", false, true ) ) return false; if( CSCR_ExpectString( ps, "SetInfo", false, false ) ) result->flags |= CVAR_USERINFO; if( !CSCR_ExpectString( ps, "}", false, true ) ) return false; return true; }