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 ];
GetPrivateProfileSectionW( L"RotorFixExceptions", buf, SCRATCH_PAD_SIZE, pPath );
for( wchar_t* raw = buf; *raw != '\0'; ++raw )
{ {
char buf[1024]; // Construct a std::wstring with the line
bool bBeganParsing = false; wchar_t fileID[128];
wchar_t* ptr = fileID;
while ( fgets(buf, _countof(buf), hFile) ) do
{ {
if ( bBeganParsing ) *ptr++ = *raw++;
{
if ( buf[0] != ';' )
{
unsigned int nToList = atoi(buf);
if ( nToList != 0 )
vecRotorExceptions.insert(nToList);
}
}
else
{
if ( strstr(buf, "[RotorFixExceptions]") != nullptr )
bBeganParsing = true;
}
} }
while ( *raw != '\0' && ptr < fileID + (_countof(fileID)-1) );
*ptr = '\0';
fclose(hFile); unsigned int toList = _wtoi( fileID );
if ( toList != 0 )
vecRotorExceptions.insert( toList );
} }
delete[] buf;
} }
void CVehicle::SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha) void CVehicle::SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha)