X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=blobdiff_plain;f=radiant%2Fshaders.cpp;h=d6748c0704f8f803fd8df7cb4b225845b07e4097;hp=aec784adebadc81522c02d80538d1a2fff87a50d;hb=cd6613e5171544b68d4ae70546c90a15c99b22a5;hpb=cd7ff1a1798cfae5d14811a310f56d2f1908490b diff --git a/radiant/shaders.cpp b/radiant/shaders.cpp index aec784ad..d6748c07 100644 --- a/radiant/shaders.cpp +++ b/radiant/shaders.cpp @@ -27,45 +27,45 @@ #include "gtkdlgs.h" -void ViewShader(const char *pFile, const char *pName) -{ - char *pBuff = 0; - //int nSize = - vfsLoadFile(pFile, reinterpret_cast( &pBuff )); - if (pBuff == 0) { - globalErrorStream() << "Failed to load shader file " << pFile << "\n"; - return; - } - // look for the shader declaration - StringOutputStream strFind(string_length(pName)); - strFind << LowerCase(pName); - StringOutputStream strLook(string_length(pBuff)); - strFind << LowerCase(pBuff); - // offset used when jumping over commented out definitions - std::size_t nOffset = 0; - while (true) { - const char *substr = strstr(strFind.c_str() + nOffset, strFind.c_str()); - if (substr == 0) { - break; - } - std::size_t nStart = substr - strLook.c_str(); - // we have found something, maybe it's a commented out shader name? - char *strCheck = new char[string_length(strLook.c_str()) + 1]; - strcpy(strCheck, strLook.c_str()); - strCheck[nStart] = 0; - char *pCheck = strrchr(strCheck, '\n'); - // if there's a commentary sign in-between we'll continue - if (pCheck && strstr(pCheck, "//")) { - delete[] strCheck; - nOffset = nStart + 1; - continue; - } - delete[] strCheck; - nOffset = nStart; - break; - } - // now close the file - vfsFreeFile(pBuff); +void ViewShader( const char *pFile, const char *pName ){ + char* pBuff = 0; + //int nSize = + vfsLoadFile( pFile, reinterpret_cast( &pBuff ) ); + if ( pBuff == 0 ) { + globalErrorStream() << "Failed to load shader file " << pFile << "\n"; + return; + } + // look for the shader declaration + StringOutputStream strFind( string_length( pName ) ); + strFind << LowerCase( pName ); + StringOutputStream strLook( string_length( pBuff ) ); + strFind << LowerCase( pBuff ); + // offset used when jumping over commented out definitions + std::size_t nOffset = 0; + while ( true ) + { + const char* substr = strstr( strFind.c_str() + nOffset, strFind.c_str() ); + if ( substr == 0 ) { + break; + } + std::size_t nStart = substr - strLook.c_str(); + // we have found something, maybe it's a commented out shader name? + char *strCheck = new char[string_length( strLook.c_str() ) + 1]; + strcpy( strCheck, strLook.c_str() ); + strCheck[nStart] = 0; + char *pCheck = strrchr( strCheck, '\n' ); + // if there's a commentary sign in-between we'll continue + if ( pCheck && strstr( pCheck, "//" ) ) { + delete[] strCheck; + nOffset = nStart + 1; + continue; + } + delete[] strCheck; + nOffset = nStart; + break; + } + // now close the file + vfsFreeFile( pBuff ); - DoTextEditor(pFile, static_cast( nOffset )); + DoTextEditor( pFile, static_cast( nOffset ) ); }