void CDownloadCommandNode::EnsureBlockNameParamsAreSet() { if( !mBlockNamesAdded ) { AddParam( new CStringValueNode( mParseTree, mProgressBlockName, GetLineNum() ) ); AddParam( new CStringValueNode( mParseTree, mCompletionBlockName, GetLineNum() ) ); mBlockNamesAdded = true; } }
/* ================ idDeclSkin::Parse ================ */ bool idDeclSkin::Parse( const char *text, const int textLength ) { idLexer src; idToken token, token2; src.LoadMemory( text, textLength, GetFileName(), GetLineNum() ); src.SetFlags( DECL_LEXER_FLAGS ); src.SkipUntilString( "{" ); associatedModels.Clear(); while (1) { if ( !src.ReadToken( &token ) || !token.Icmp( "}" ) ) { return false; } else if ( !src.ReadToken( &token2 ) ) { src.Warning( "Unexpected end of file" ); MakeDefault(); return false; } else if ( !token.Icmp( "model" ) ) { // The list of models associated with this skin is only to guide the // user selection in the editor. The skin will be applied for any model // the entity has, regardless on whether it is in this list, or not. associatedModels.Append( token2 ); } else { skinMapping_t map; if ( !token.Icmp( "*" ) ) { map.from = NULL; // wildcard } else { map.from = declManager->FindMaterial( token ); } map.to = declManager->FindMaterial( token2 ); mappings.Append( map ); } } }
/* ================ idDeclSkin::Parse ================ */ bool idDeclSkin::Parse( const char *text, const int textLength ) { idLexer src; idToken token, token2; src.LoadMemory( text, textLength, GetFileName(), GetLineNum() ); src.SetFlags( DECL_LEXER_FLAGS ); src.SkipUntilString( "{" ); associatedModels.Clear(); while( true ) { if( !src.ReadToken( &token ) ) { break; } if( !token.Icmp( "}" ) ) { break; } if( !src.ReadToken( &token2 ) ) { src.Warning( "Unexpected end of file" ); MakeDefault(); return false; } if( !token.Icmp( "model" ) ) { associatedModels.Append( token2 ); continue; } skinMapping_t map; if( !token.Icmp( "*" ) ) { // wildcard map.from = NULL; } else { map.from = declManager->FindMaterial( token ); } map.to = declManager->FindMaterial( token2 ); mappings.Append( map ); } return false; }
/* ================ idDeclVideo::Parse ================ */ bool idDeclVideo::Parse( const char *text, const int textLength ) { idLexer src; idToken token; src.LoadMemory( text, textLength, GetFileName(), GetLineNum() ); src.SetFlags( LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT | LEXFL_NOFATALERRORS ); src.SkipUntilString( "{" ); // scan through, identifying each individual parameter while( 1 ) { if ( !src.ReadToken( &token ) ) { break; } if ( token == "}" ) { break; } if ( !token.Icmp( "name") ) { src.ReadToken( &token ); videoName = token; continue; } if ( !token.Icmp( "preview") ) { src.ReadToken( &token ); preview = token; continue; } if ( !token.Icmp( "video") ) { src.ReadToken( &token ); video = token; declManager->FindMaterial( video ); continue; } if ( !token.Icmp( "info") ) { src.ReadToken( &token ); info = token; continue; } if ( !token.Icmp( "audio") ) { src.ReadToken( &token ); audio = token; declManager->FindSound(audio); continue; } } if ( src.HadError() ) { src.Warning( "Video decl '%s' had a parse error", GetName() ); return false; } return true; }
/* ================ idDeclEmail::Parse ================ */ bool idDeclEmail::Parse( const char *_text, const int textLength ) { idLexer src; idToken token; src.LoadMemory( _text, textLength, GetFileName(), GetLineNum() ); src.SetFlags( LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT | LEXFL_NOFATALERRORS ); src.SkipUntilString( "{" ); text = ""; // scan through, identifying each individual parameter while( true ) { if( !src.ReadToken( &token ) ) { break; } if( token == "}" ) { break; } if( !token.Icmp( "subject" ) ) { src.ReadToken( &token ); subject = token; continue; } if( !token.Icmp( "to" ) ) { src.ReadToken( &token ); to = token; continue; } if( !token.Icmp( "from" ) ) { src.ReadToken( &token ); from = token; continue; } if( !token.Icmp( "date" ) ) { src.ReadToken( &token ); date = token; continue; } if( !token.Icmp( "text" ) ) { src.ReadToken( &token ); if( token != "{" ) { src.Warning( "Email decl '%s' had a parse error", GetName() ); return false; } while( src.ReadToken( &token ) && token != "}" ) { text += token; } continue; } if( !token.Icmp( "image" ) ) { src.ReadToken( &token ); image = token; continue; } } if( src.HadError() ) { src.Warning( "Email decl '%s' had a parse error", GetName() ); return false; } return true; }
/* ================ idDeclParticle::Parse ================ */ bool idDeclParticle::Parse( const char *text, const int textLength ) { idLexer src; idToken token; src.LoadMemory( text, textLength, GetFileName(), GetLineNum() ); src.SetFlags( DECL_LEXER_FLAGS ); src.SkipUntilString( "{" ); depthHack = 0.0f; while (1) { if ( !src.ReadToken( &token ) ) { break; } if ( !token.Icmp( "}" ) ) { break; } if ( !token.Icmp( "{" ) ) { idParticleStage *stage = ParseParticleStage( src ); if ( !stage ) { src.Warning( "Particle stage parse failed" ); MakeDefault(); return false; } stages.Append( stage ); continue; } if ( !token.Icmp( "depthHack" ) ) { depthHack = src.ParseFloat(); continue; } src.Warning( "bad token %s", token.c_str() ); MakeDefault(); return false; } // // calculate the bounds // bounds.Clear(); for( int i = 0; i < stages.Num(); i++ ) { GetStageBounds( stages[i] ); bounds.AddBounds( stages[i]->bounds ); } if ( bounds.GetVolume() <= 0.1f ) { bounds = idBounds( vec3_origin ).Expand( 8.0f ); } return true; }
/* =============== idSoundShader::Parse this is called by the declManager =============== */ bool idSoundShader::Parse( const char *text, const int textLength, bool allowBinaryVersion ) { idLexer src; src.LoadMemory( text, textLength, GetFileName(), GetLineNum() ); src.SetFlags( DECL_LEXER_FLAGS ); src.SkipUntilString( "{" ); if ( !ParseShader( src ) ) { MakeDefault(); return false; } return true; }
/** * @brief 指定された行番号の行クラスへのイテレータを取得します(0ベース)。 */ LinePt CFootyDoc::GetLine(size_t nLine) { // 宣言 size_t i; // 番号走査用 LinePt iterNowLine; // 作業用のイテレータ // エラーチェック if (GetLineNum() <= nLine)return m_lsLines.end(); // 走査開始 iterNowLine=m_lsLines.begin(); for (i=0;i<nLine;i++)iterNowLine++; // 値を返却する return iterNowLine; }
/*------------------------------------------------------------------- CEthicLine::MoveEthicBack 倫理行のデータも含めて前の行へ移動します。もしもnPos分移動できない (終端についた)場合や失敗した場合はfalseが戻ります。 -------------------------------------------------------------------*/ bool CEthicLine::MoveEthicBack(size_t nPos){ /*ループしていく*/ for (size_t i=0;i<nPos;i++){ if (m_nNowEthicLine == 0){ if (GetLineNum() != 0){ MoveRealBack(1); m_nNowEthicLine = GetLinePointer()->GetEthicLine() - 1; } else return false; } else m_nNowEthicLine --; } return true; }
/* =============== idSoundShader::Parse this is called by the declManager =============== */ bool idSoundShader::Parse( const char *text, const int textLength ) { idLexer src; src.LoadMemory( text, textLength, GetFileName(), GetLineNum() ); src.SetFlags( DECL_LEXER_FLAGS ); src.SkipUntilString( "{" ); // deeper functions can set this, which will cause MakeDefault() to be called at the end errorDuringParse = false; if ( !ParseShader( src ) || errorDuringParse ) { MakeDefault(); return false; } return true; }
RVALUE FindWatSymbol( address *addr, syminfo *si, int getsrcinfo ) { DWORD symoff; DWORD line; BOOL ret; if( !GetSymbolName( addr, si->name, &symoff ) ) { return( NOT_FOUND ); } si->symoff = symoff; if( getsrcinfo ) { ret = GetLineNum( addr, si->filename, MAX_FILE_NAME, &line ); if( !ret ) return( NOT_FOUND ); si->linenum = line; } return( FOUND ); }
void compileError(const char *fmt, ... ) { va_list argptr; char msg[MAXERROR]; Int16 linenum,charnum; compile_error=TRUE; va_start(argptr,fmt); xvsnprintf(msg,(Int32)MAXERROR,fmt,argptr); va_end(argptr); linenum = GetLineNum()+1; charnum = GetCharNum(); xprintf("compile error: %s\n",msg); xprintf("near line: %d\n",linenum); }
/* ================ idDeclFX::Parse ================ */ bool idDeclFX::Parse( const char* text, const int textLength, bool allowBinaryVersion ) { idLexer src; idToken token; src.LoadMemory( text, textLength, GetFileName(), GetLineNum() ); src.SetFlags( DECL_LEXER_FLAGS ); src.SkipUntilString( "{" ); // scan through, identifying each individual parameter while( 1 ) { if( !src.ReadToken( &token ) ) { break; } if( token == "}" ) { break; } if( !token.Icmp( "bindto" ) ) { src.ReadToken( &token ); joint = token; continue; } if( !token.Icmp( "{" ) ) { idFXSingleAction action; ParseSingleFXAction( src, action ); events.Append( action ); continue; } } if( src.HadError() ) { src.Warning( "FX decl '%s' had a parse error", GetName() ); return false; } return true; }
/** * CEthicLine::MoveEthicNext * @brief 倫理行のデータも含めて指定した行数進みます。 * @param pLines 行リスト * @param nPos 進む数 * @return 失敗したらfalse、成功したらtrue */ bool CEthicLine::MoveEthicNext(LsLines *pLines,size_t nPos) { if (!pLines)return false; size_t nThisEthic = GetLinePointer()->GetEthicLine(); // ループしていく for (size_t i=0;i<nPos;i++){ if (m_nNowEthicLine == nThisEthic - 1){ // それが最終論理行のとき if (GetLineNum()+1 != pLines->size()){ // それが最終行でないとき MoveRealNext(pLines,1);// // 次の行へ nThisEthic = GetLinePointer()->GetEthicLine(); m_nNowEthicLine = 0; } else return false; } else m_nNowEthicLine++; } return true; }
/* ================ idDeclEntityDef::Parse ================ */ bool idDeclEntityDef::Parse( const char *text, const int textLength ) { idLexer src; idToken token, token2; src.LoadMemory( text, textLength, GetFileName(), GetLineNum() ); src.SetFlags( DECL_LEXER_FLAGS ); src.SkipUntilString( "{" ); while( 1 ) { if( !src.ReadToken( &token ) ) { break; } if( !token.Icmp( "}" ) ) { break; } if( token.type != TT_STRING ) { src.Warning( "Expected quoted string, but found '%s'", token.c_str() ); MakeDefault(); return false; } if( !src.ReadToken( &token2 ) ) { src.Warning( "Unexpected end of file" ); MakeDefault(); return false; } if( dict.FindKey( token ) ) { src.DWarning( "'%s' already defined", token.c_str() ); } dict.Set( token, token2 ); } // we always automatically set a "classname" key to our name dict.Set( "classname", GetName() ); // "inherit" keys will cause all values from another entityDef to be copied into this one // if they don't conflict. We can't have circular recursions, because each entityDef will // never be parsed mroe than once // find all of the dicts first, because copying inherited values will modify the dict idList<const idDeclEntityDef *> defList; while( 1 ) { const idKeyValue *kv; kv = dict.MatchPrefix( "inherit", NULL ); if( !kv ) { break; } const idDeclEntityDef *copy = static_cast<const idDeclEntityDef *>( declManager->FindType( DECL_ENTITYDEF, kv->GetValue(), false ) ); if( !copy ) { src.Warning( "Unknown entityDef '%s' inherited by '%s'", kv->GetValue().c_str(), GetName() ); } else { defList.Append( copy ); } // delete this key/value pair dict.Delete( kv->GetKey() ); } // now copy over the inherited key / value pairs for( int i = 0; i < defList.Num(); i++ ) { dict.SetDefaults( &defList[i]->dict ); } // precache all referenced media // do this as long as we arent in modview game->CacheDictionaryMedia( &dict ); return true; }
/* ================ idDeclPDA::Parse ================ */ bool idDeclPDA::Parse( const char *text, const int textLength ) { idLexer src; idToken token; src.LoadMemory( text, textLength, GetFileName(), GetLineNum() ); src.SetFlags( DECL_LEXER_FLAGS ); src.SkipUntilString( "{" ); // scan through, identifying each individual parameter while( true ) { if( !src.ReadToken( &token ) ) { break; } if( token == "}" ) { break; } if( !token.Icmp( "name" ) ) { src.ReadToken( &token ); pdaName = token; continue; } if( !token.Icmp( "fullname" ) ) { src.ReadToken( &token ); fullName = token; continue; } if( !token.Icmp( "icon" ) ) { src.ReadToken( &token ); icon = token; continue; } if( !token.Icmp( "id" ) ) { src.ReadToken( &token ); id = token; continue; } if( !token.Icmp( "post" ) ) { src.ReadToken( &token ); post = token; continue; } if( !token.Icmp( "title" ) ) { src.ReadToken( &token ); title = token; continue; } if( !token.Icmp( "security" ) ) { src.ReadToken( &token ); security = token; continue; } if( !token.Icmp( "pda_email" ) ) { src.ReadToken( &token ); emails.Append( token ); declManager->FindType( DECL_EMAIL, token ); continue; } if( !token.Icmp( "pda_audio" ) ) { src.ReadToken( &token ); audios.Append( token ); declManager->FindType( DECL_AUDIO, token ); continue; } if( !token.Icmp( "pda_video" ) ) { src.ReadToken( &token ); videos.Append( token ); declManager->FindType( DECL_VIDEO, token ); continue; } } if( src.HadError() ) { src.Warning( "PDA decl '%s' had a parse error", GetName() ); return false; } originalVideos = videos.Num(); originalEmails = emails.Num(); return true; }
static void fillExceptionDlg( HWND hwnd, ExceptDlgInfo *info ) { char buf[BUF_SIZE]; char fname[ FNAME_BUFLEN ]; DWORD line; ProcStats stats; HWND ctl; address addr; GetCurrAddr(&addr,info->regs); SetDlgCourierFont( hwnd, INT_TASK_NAME ); SetDlgCourierFont( hwnd, INT_TASK_PATH ); SetDlgCourierFont( hwnd, INT_FAULT_TYPE ); SetDlgCourierFont( hwnd, INT_CS_IP ); SetDlgCourierFont( hwnd, INT_SOURCE_INFO ); SetDlgCourierFont( hwnd, INT_SOURCE_INFO2 ); RCsprintf( buf, STR_EXCEPTION_ENCOUNTERED, AppName ); SetWindowText( hwnd, buf ); CopyRCString( STR_PROCESS_NAME, buf, BUF_SIZE ); SetDlgItemText( hwnd, INT_TASK_NAME_TEXT, buf ); if( !info->dbinfo->u.Exception.dwFirstChance ) { if( ConfigData.exception_action == INT_CHAIN_TO_NEXT ) { ConfigData.exception_action = INT_TERMINATE; } ctl = GetDlgItem( hwnd, INT_CHAIN_TO_NEXT ); EnableWindow( ctl, FALSE ); } CheckDlgButton( hwnd, ConfigData.exception_action, BST_CHECKED ); CopyRCString( STR_PROCESS_ID, buf, BUF_SIZE ); SetDlgItemText( hwnd, INT_TASK_PATH_TEXT, buf ); while( !GetProcessInfo( info->procinfo->procid, &stats ) ) { Sleep( 100 ); RefreshInfo(); } SetDlgItemText( hwnd, INT_TASK_NAME, stats.name ); sprintf( buf, "%08lX", info->procinfo->procid ); SetDlgItemText( hwnd, INT_TASK_PATH, buf ); FormatException( buf, info->dbinfo->u.Exception.ExceptionRecord.ExceptionCode ); SetDlgItemText( hwnd, INT_FAULT_TYPE, buf ); if( info->threadinfo != NULL ) { strcpy( buf, "Fault " ); MADRegSpecialName( MSR_IP, info->regs, MAF_FULL, BUF_SIZE - 7, buf+6 ); SetDlgItemText( hwnd, INT_IP_NAME, buf ); SetIp( hwnd, &addr ); } if( info->got_dbginfo && GetLineNum( &addr,fname, FNAME_BUFLEN, &line ) ) { RCsprintf( buf, STR_LINE_X_OF, line ); SetDlgItemText( hwnd, INT_SOURCE_INFO, buf ); SetDlgItemText( hwnd, INT_SOURCE_INFO2, fname ); } else { CopyRCString( STR_N_A, buf, BUF_SIZE ); SetDlgItemText( hwnd, INT_SOURCE_INFO, buf ); SetDlgItemText( hwnd, INT_SOURCE_INFO2, "" ); } }
/* ================ idDeclAF::Parse ================ */ bool idDeclAF::Parse( const char *text, const int textLength ) { int i, j; idLexer src; idToken token; src.LoadMemory( text, textLength, GetFileName(), GetLineNum() ); src.SetFlags( DECL_LEXER_FLAGS ); src.SkipUntilString( "{" ); while( src.ReadToken( &token ) ) { if ( !token.Icmp( "settings" ) ) { if ( !ParseSettings( src ) ) { return false; } } else if ( !token.Icmp( "body" ) ) { if ( !ParseBody( src ) ) { return false; } } else if ( !token.Icmp( "fixed" ) ) { if ( !ParseFixed( src ) ) { return false; } } else if ( !token.Icmp( "ballAndSocketJoint" ) ) { if ( !ParseBallAndSocketJoint( src ) ) { return false; } } else if ( !token.Icmp( "universalJoint" ) ) { if ( !ParseUniversalJoint( src ) ) { return false; } } else if ( !token.Icmp( "hinge" ) ) { if ( !ParseHinge( src ) ) { return false; } } else if ( !token.Icmp( "slider" ) ) { if ( !ParseSlider( src ) ) { return false; } } else if ( !token.Icmp( "spring" ) ) { if ( !ParseSpring( src ) ) { return false; } } else if ( token == "}" ) { break; } else { src.Error( "unknown keyword %s", token.c_str() ); return false; } } for ( i = 0; i < bodies.Num(); i++ ) { // check for multiple bodies with the same name for ( j = i+1; j < bodies.Num(); j++ ) { if ( bodies[i]->name == bodies[j]->name ) { src.Error( "two bodies with the same name \"%s\"", bodies[i]->name.c_str() ); } } } for ( i = 0; i < constraints.Num(); i++ ) { // check for multiple constraints with the same name for ( j = i+1; j < constraints.Num(); j++ ) { if ( constraints[i]->name == constraints[j]->name ) { src.Error( "two constraints with the same name \"%s\"", constraints[i]->name.c_str() ); } } // check if there are two valid bodies set if ( constraints[i]->body1 == "" ) { src.Error( "no valid body1 specified for constraint '%s'", constraints[i]->name.c_str() ); } if ( constraints[i]->body2 == "" ) { src.Error( "no valid body2 specified for constraint '%s'", constraints[i]->name.c_str() ); } } // make sure the body which modifies the origin comes first for ( i = 0; i < bodies.Num(); i++ ) { if ( bodies[i]->jointName == "origin" ) { if ( i != 0 ) { idDeclAF_Body *b = bodies[0]; bodies[0] = bodies[i]; bodies[i] = b; } break; } } return true; }
/* * logFaultInfo */ static void logFaultInfo( ExceptDlgInfo *info ) { char *str; char buf[150]; char addr_buf[64]; char fname[ FNAME_BUFLEN ]; DWORD type; DWORD line; msg_id gptype; ProcStats stats; logStrPrintf( "\n" ); logPrintf( STR_OFFENDING_PROC_ULINE ); logPrintf( STR_OFFENDING_PROC_INFO ); logPrintf( STR_OFFENDING_PROC_ULINE ); while( !GetProcessInfo( info->procinfo->procid, &stats ) ) { Sleep( 100 ); RefreshInfo(); } logPrintf( STR_OFFENDING_PROC_X, stats.name, info->procinfo->procid ); type = info->dbinfo->u.Exception.ExceptionRecord.ExceptionCode; FormatException( buf, type ); MADCliAddrToString( info->init_ip, MADTypeDefault( MTK_ADDRESS, MAF_FULL, NULL, &( info->init_ip ) ), MLK_CODE, addr_buf, 63 ); logPrintf( STR_ERR_OCCURRED_AT_X_Y, buf, addr_buf ); if( type == EXCEPTION_ACCESS_VIOLATION ) { if( info->dbinfo->u.Exception.ExceptionRecord.ExceptionInformation[0] ) { gptype = STR_LOG_INV_WRITE_TO; } else { gptype = STR_LOG_INV_READ_FROM; } logPrintf( gptype, info->dbinfo->u.Exception.ExceptionRecord.ExceptionInformation[1] ); } str = SrchMsg( info->action, Actions, NULL ); if( str != NULL ) { logStrPrintf( "%s\n", str ); } logPrintf( STR_MODULES_LOADED ); logModules( info->procinfo->procid, INDENT ); logRegisters( info ); logPrintf( STR_SOURCE_INFORMATION ); if( info->got_dbginfo && GetLineNum( &info->init_ip, fname, FNAME_BUFLEN, &line ) ) { logPrintf( STR_LOG_LINE_X_OF_FILE, INDENT, "", line, fname ); } else { logPrintf( STR_LOG_N_A, INDENT, "" ); } logPrintf( STR_DISASSEMBLY ); logDisasm( info ); logStack( info ); #ifndef CHICAGO if( LogData.log_mem_manager ) { logMemManInfo( info->procinfo->procid ); } #endif if( LogData.log_mem_dmp ) { logMemDmp( info ); } }
/* ================= idDeclTable2d::Parse ================= */ bool idDeclTable2d::Parse( const char* text, const int textLength, bool allowBinaryVersion ) { idLexer src; idToken token; src.LoadMemory( text, textLength, GetFileName(), GetLineNum() ); src.SetFlags( DECL_LEXER_FLAGS ); src.SkipUntilString( "{" ); values.Clear(); while ( 1 ) { if ( !src.ReadToken( &token ) ) { break; } if ( token == "}" ) { break; } if ( token.Icmp( "[" ) == 0 ) { tableEntry entry; bool errorFlag; entry.mInput = src.ParseFloat( &errorFlag ); if ( errorFlag ) { // we got something non-numeric MakeDefault(); return false; } src.ReadToken( &token ); if ( token != "," ) { // we got something non-numeric MakeDefault(); return false; } entry.mOutput = src.ParseFloat( &errorFlag ); if ( errorFlag ) { // we got something non-numeric MakeDefault(); return false; } src.ReadToken( &token ); if ( token != "]" ) { // we got something non-numeric MakeDefault(); return false; } values.Append( entry ); } else { src.Warning( "unknown token '%s'", token.c_str() ); MakeDefault(); return false; } } return true; }
/* ================= idDeclTable::Parse ================= */ bool idDeclTable::Parse( const char *text, const int textLength, bool allowBinaryVersion ) { idLexer src; idToken token; float v; src.LoadMemory( text, textLength, GetFileName(), GetLineNum() ); src.SetFlags( DECL_LEXER_FLAGS ); src.SkipUntilString( "{" ); snap = false; clamp = false; values.Clear(); while ( 1 ) { if ( !src.ReadToken( &token ) ) { break; } if ( token == "}" ) { break; } if ( token.Icmp( "snap" ) == 0 ) { snap = true; } else if ( token.Icmp( "clamp" ) == 0 ) { clamp = true; } else if ( token.Icmp( "{" ) == 0 ) { while ( 1 ) { bool errorFlag; v = src.ParseFloat( &errorFlag ); if ( errorFlag ) { // we got something non-numeric MakeDefault(); return false; } values.Append( v ); src.ReadToken( &token ); if ( token == "}" ) { break; } if ( token == "," ) { continue; } src.Warning( "expected comma or brace" ); MakeDefault(); return false; } } else { src.Warning( "unknown token '%s'", token.c_str() ); MakeDefault(); return false; } } // copy the 0 element to the end, so lerping doesn't // need to worry about the wrap case float val = values[0]; // template bug requires this to not be in the Append()? values.Append( val ); return true; }
/* ================ idDeclParticle::Parse ================ */ bool idDeclParticle::Parse( const char* text, const int textLength, bool allowBinaryVersion ) { if( cvarSystem->GetCVarBool( "fs_buildresources" ) ) { fileSystem->AddParticlePreload( GetName() ); } idLexer src; idToken token; unsigned int sourceChecksum = 0; idStrStatic< MAX_OSPATH > generatedFileName; if( allowBinaryVersion ) { // Try to load the generated version of it // If successful, // - Create an MD5 of the hash of the source // - Load the MD5 of the generated, if they differ, create a new generated generatedFileName = "generated/particles/"; generatedFileName.AppendPath( GetName() ); generatedFileName.SetFileExtension( ".bprt" ); idFileLocal file( fileSystem->OpenFileReadMemory( generatedFileName ) ); sourceChecksum = MD5_BlockChecksum( text, textLength ); if( binaryLoadParticles.GetBool() && LoadBinary( file, sourceChecksum ) ) { return true; } } src.LoadMemory( text, textLength, GetFileName(), GetLineNum() ); src.SetFlags( DECL_LEXER_FLAGS ); src.SkipUntilString( "{" ); depthHack = 0.0f; while( 1 ) { if( !src.ReadToken( &token ) ) { break; } if( !token.Icmp( "}" ) ) { break; } if( !token.Icmp( "{" ) ) { if( stages.Num() >= MAX_PARTICLE_STAGES ) { src.Error( "Too many particle stages" ); MakeDefault(); return false; } idParticleStage* stage = ParseParticleStage( src ); if( !stage ) { src.Warning( "Particle stage parse failed" ); MakeDefault(); return false; } stages.Append( stage ); continue; } if( !token.Icmp( "depthHack" ) ) { depthHack = src.ParseFloat(); continue; } src.Warning( "bad token %s", token.c_str() ); MakeDefault(); return false; } // don't calculate bounds or write binary files for defaulted ( non-existent ) particles in resource builds if( fileSystem->UsingResourceFiles() ) { bounds = idBounds( vec3_origin ).Expand( 8.0f ); return true; } // // calculate the bounds // bounds.Clear(); for( int i = 0; i < stages.Num(); i++ ) { GetStageBounds( stages[i] ); bounds.AddBounds( stages[i]->bounds ); } if( bounds.GetVolume() <= 0.1f ) { bounds = idBounds( vec3_origin ).Expand( 8.0f ); } if( allowBinaryVersion && binaryLoadParticles.GetBool() ) { idLib::Printf( "Writing %s\n", generatedFileName.c_str() ); idFileLocal outputFile( fileSystem->OpenFileWrite( generatedFileName, "fs_basepath" ) ); WriteBinary( outputFile, sourceChecksum ); } return true; }