Read RotorFixExceptions using a WinAPI function

This commit is contained in:
Silent 2016-08-11 01:29:54 +02:00
parent 7584bed931
commit 55a480fed0

View file

@ -44,33 +44,28 @@ static RpMaterial* SetCompAlphaCB(RpMaterial* pMaterial, void* data)
void ReadRotorFixExceptions(const wchar_t* pPath) void ReadRotorFixExceptions(const wchar_t* pPath)
{ {
if ( FILE* hFile = _wfopen(pPath, L"r") ) const size_t SCRATCH_PAD_SIZE = 32767;
{ wchar_t* buf = new wchar_t[ SCRATCH_PAD_SIZE ];
char buf[1024];
bool bBeganParsing = false;
while ( fgets(buf, _countof(buf), hFile) ) GetPrivateProfileSectionW( L"RotorFixExceptions", buf, SCRATCH_PAD_SIZE, pPath );
for( wchar_t* raw = buf; *raw != '\0'; ++raw )
{ {
if ( bBeganParsing ) // Construct a std::wstring with the line
wchar_t fileID[128];
wchar_t* ptr = fileID;
do
{ {
if ( buf[0] != ';' ) *ptr++ = *raw++;
{ }
unsigned int nToList = atoi(buf); while ( *raw != '\0' && ptr < fileID + (_countof(fileID)-1) );
*ptr = '\0';
if ( nToList != 0 ) unsigned int toList = _wtoi( fileID );
vecRotorExceptions.insert(nToList); if ( toList != 0 )
} vecRotorExceptions.insert( toList );
}
else
{
if ( strstr(buf, "[RotorFixExceptions]") != nullptr )
bBeganParsing = true;
}
}
fclose(hFile);
} }
delete[] buf;
} }
void CVehicle::SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha) void CVehicle::SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha)