mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-28 23:03:01 +05:00
safer ini reading
This commit is contained in:
parent
40726059f6
commit
f170201068
2 changed files with 16 additions and 10 deletions
|
@ -1064,7 +1064,7 @@ void DrawScriptSpritesAndRectangles( uint8_t arg )
|
|||
orgDrawScriptSpritesAndRectangles( arg );
|
||||
}
|
||||
|
||||
std::vector< std::pair<int32_t, bool> > doubleRearWheelsList;
|
||||
std::vector< std::pair<uint32_t, bool> > doubleRearWheelsList;
|
||||
void ReadDoubleRearWheels(const wchar_t* pPath)
|
||||
{
|
||||
const size_t SCRATCH_PAD_SIZE = 32767;
|
||||
|
@ -1073,17 +1073,23 @@ void ReadDoubleRearWheels(const wchar_t* pPath)
|
|||
GetPrivateProfileSectionW( L"DoubleRearWheels", reader.GetBuffer(), reader.GetSize(), pPath );
|
||||
while ( const wchar_t* str = reader.GetString() )
|
||||
{
|
||||
wchar_t textLine[32];
|
||||
wchar_t textLine[64];
|
||||
wchar_t* context = nullptr;
|
||||
wchar_t* token;
|
||||
|
||||
wcscpy_s( textLine, str );
|
||||
token = wcstok_s( textLine, L"=", &context );
|
||||
|
||||
int toList = _wtoi( token );
|
||||
if ( toList != 0 )
|
||||
|
||||
uint32_t toList = wcstoul( token, nullptr, 0 );
|
||||
if ( toList == 0 ) continue;
|
||||
|
||||
wchar_t* begin = wcstok_s( nullptr, L"=", &context );
|
||||
if ( begin == nullptr ) continue;
|
||||
|
||||
wchar_t* end = nullptr;
|
||||
bool value = wcstoul( begin, &end, 0 ) != 0;
|
||||
if ( begin != end )
|
||||
{
|
||||
bool value = _wtoi( wcstok_s( nullptr, L"=", &context ) ) != 0;
|
||||
doubleRearWheelsList.emplace_back( toList, value );
|
||||
}
|
||||
}
|
||||
|
@ -1097,7 +1103,7 @@ bool __stdcall CheckDoubleRWheelsList( void* modelInfo, uint8_t* handlingData )
|
|||
if ( modelInfo == lastModelInfo ) return lastResult;
|
||||
lastModelInfo = modelInfo;
|
||||
|
||||
ptrdiff_t modelID = std::distance( ms_modelInfoPtrs, std::find( ms_modelInfoPtrs, ms_modelInfoPtrs+m_numModelInfoPtrs, modelInfo ) );
|
||||
uint32_t modelID = std::distance( ms_modelInfoPtrs, std::find( ms_modelInfoPtrs, ms_modelInfoPtrs+m_numModelInfoPtrs, modelInfo ) );
|
||||
|
||||
auto it = std::find_if( doubleRearWheelsList.begin(), doubleRearWheelsList.end(), [modelID]( const auto& item ) {
|
||||
return item.first == modelID;
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
#include "TimerSA.h"
|
||||
#include "DelimStringReader.h"
|
||||
|
||||
std::vector<unsigned int> vecRotorExceptions;
|
||||
std::vector<uint32_t> vecRotorExceptions;
|
||||
|
||||
static bool ShouldIgnoreRotor( unsigned int id )
|
||||
static bool ShouldIgnoreRotor( uint32_t id )
|
||||
{
|
||||
return std::find( vecRotorExceptions.begin(), vecRotorExceptions.end(), id ) != vecRotorExceptions.end();
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ void ReadRotorFixExceptions(const wchar_t* pPath)
|
|||
GetPrivateProfileSectionW( L"RotorFixExceptions", reader.GetBuffer(), reader.GetSize(), pPath );
|
||||
while ( const wchar_t* str = reader.GetString() )
|
||||
{
|
||||
unsigned int toList = _wtoi( str );
|
||||
uint32_t toList = wcstoul( str, nullptr, 0 );
|
||||
if ( toList != 0 )
|
||||
vecRotorExceptions.push_back( toList );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue