mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2025-01-31 06:57:28 +05:00
DelimStringReader
This commit is contained in:
parent
d40fff0b05
commit
b2c9b188b3
4 changed files with 60 additions and 16 deletions
51
SilentPatch/DelimStringReader.h
Normal file
51
SilentPatch/DelimStringReader.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
#pragma once
|
||||
|
||||
template<typename T>
|
||||
class BasicDelimStringReader
|
||||
{
|
||||
public:
|
||||
BasicDelimStringReader( size_t size )
|
||||
: m_buffer( new T[size] ), m_size( size )
|
||||
{
|
||||
m_cursor = m_buffer;
|
||||
}
|
||||
|
||||
~BasicDelimStringReader()
|
||||
{
|
||||
delete[] m_buffer;
|
||||
}
|
||||
|
||||
inline T* GetBuffer() const
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
inline size_t GetSize() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
const T* GetString( size_t* size = nullptr )
|
||||
{
|
||||
if ( *m_cursor == '\0' )
|
||||
{
|
||||
if ( size != nullptr ) *size = 0;
|
||||
return nullptr;
|
||||
}
|
||||
const T* curString = m_cursor;
|
||||
size_t len = 0;
|
||||
|
||||
while ( *m_cursor++ != '\0' ) len++;
|
||||
|
||||
if ( size != nullptr ) *size = len;
|
||||
return curString;
|
||||
}
|
||||
|
||||
private:
|
||||
T* m_buffer;
|
||||
const T* m_cursor;
|
||||
size_t m_size;
|
||||
};
|
||||
|
||||
typedef BasicDelimStringReader<char> DelimStringReader;
|
||||
typedef BasicDelimStringReader<wchar_t> WideDelimStringReader;
|
|
@ -154,6 +154,7 @@ copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowvio
|
|||
</FxCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\SilentPatch\DelimStringReader.h" />
|
||||
<ClInclude Include="..\SilentPatch\FLAC\callback.h" />
|
||||
<ClInclude Include="..\SilentPatch\FLAC\export.h" />
|
||||
<ClInclude Include="..\SilentPatch\FLAC\format.h" />
|
||||
|
|
|
@ -137,6 +137,9 @@
|
|||
<ClInclude Include="..\SilentPatch\resource1.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\SilentPatch\DelimStringReader.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Shaders.rc">
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <vector>
|
||||
#include "VehicleSA.h"
|
||||
#include "TimerSA.h"
|
||||
#include "DelimStringReader.h"
|
||||
|
||||
std::vector<unsigned int> vecRotorExceptions;
|
||||
|
||||
|
@ -56,27 +57,15 @@ static RpMaterial* SetCompAlphaCB(RpMaterial* pMaterial, void* data)
|
|||
void ReadRotorFixExceptions(const wchar_t* pPath)
|
||||
{
|
||||
const size_t SCRATCH_PAD_SIZE = 32767;
|
||||
wchar_t* buf = new wchar_t[ SCRATCH_PAD_SIZE ];
|
||||
WideDelimStringReader reader( SCRATCH_PAD_SIZE );
|
||||
|
||||
GetPrivateProfileSectionW( L"RotorFixExceptions", buf, SCRATCH_PAD_SIZE, pPath );
|
||||
for( wchar_t* raw = buf; *raw != '\0'; ++raw )
|
||||
GetPrivateProfileSectionW( L"RotorFixExceptions", reader.GetBuffer(), reader.GetSize(), pPath );
|
||||
while ( const wchar_t* str = reader.GetString() )
|
||||
{
|
||||
// Construct a std::wstring with the line
|
||||
wchar_t fileID[128];
|
||||
wchar_t* ptr = fileID;
|
||||
do
|
||||
{
|
||||
*ptr++ = *raw++;
|
||||
}
|
||||
while ( *raw != '\0' && ptr < fileID + (_countof(fileID)-1) );
|
||||
*ptr = '\0';
|
||||
|
||||
unsigned int toList = _wtoi( fileID );
|
||||
unsigned int toList = _wtoi( str );
|
||||
if ( toList != 0 )
|
||||
vecRotorExceptions.push_back( toList );
|
||||
}
|
||||
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
void CVehicle::SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha)
|
||||
|
|
Loading…
Reference in a new issue