aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Durango/XML/ATGXmlParser.cpp
diff options
context:
space:
mode:
authorModMaker101 <119018978+ModMaker101@users.noreply.github.com>2026-03-08 19:08:36 -0400
committerGitHub <noreply@github.com>2026-03-08 18:08:36 -0500
commit28614b922fb77149a54da1a87bebfbc98736f296 (patch)
tree7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.Client/Durango/XML/ATGXmlParser.cpp
parent88798b501d0cf6287b6f87acb2592676e3cec58d (diff)
Modernize project codebase (#906)
* Fixed boats falling and a TP glitch #266 * Replaced every C-style cast with C++ ones * Replaced every C-style cast with C++ ones * Fixed boats falling and a TP glitch #266 * Updated NULL to nullptr and fixing some type issues * Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. * Fixing more conflicts * Replace int loops with size_t and start work on overrides * Add safety checks and fix a issue with vector going OOR
Diffstat (limited to 'Minecraft.Client/Durango/XML/ATGXmlParser.cpp')
-rw-r--r--Minecraft.Client/Durango/XML/ATGXmlParser.cpp61
1 files changed, 30 insertions, 31 deletions
diff --git a/Minecraft.Client/Durango/XML/ATGXmlParser.cpp b/Minecraft.Client/Durango/XML/ATGXmlParser.cpp
index 771ba268..89ca7714 100644
--- a/Minecraft.Client/Durango/XML/ATGXmlParser.cpp
+++ b/Minecraft.Client/Durango/XML/ATGXmlParser.cpp
@@ -27,7 +27,7 @@ XMLParser::XMLParser()
{
m_pWritePtr = m_pWriteBuf;
m_pReadPtr = m_pReadBuf;
- m_pISAXCallback = NULL;
+ m_pISAXCallback = nullptr;
m_hFile = INVALID_HANDLE_VALUE;
}
@@ -49,7 +49,7 @@ VOID XMLParser::FillBuffer()
m_pReadPtr = m_pReadBuf;
- if( m_hFile == NULL )
+ if( m_hFile == nullptr )
{
if( m_uInXMLBufferCharsLeft > XML_READ_BUFFER_SIZE )
NChars = XML_READ_BUFFER_SIZE;
@@ -62,15 +62,15 @@ VOID XMLParser::FillBuffer()
}
else
{
- if( !ReadFile( m_hFile, m_pReadBuf, XML_READ_BUFFER_SIZE, &NChars, NULL ))
+ if( !ReadFile( m_hFile, m_pReadBuf, XML_READ_BUFFER_SIZE, &NChars, nullptr ))
{
return;
}
}
m_dwCharsConsumed += NChars;
- int64_t iProgress = m_dwCharsTotal ? (( (int64_t)m_dwCharsConsumed * 1000 ) / (int64_t)m_dwCharsTotal) : 0;
- m_pISAXCallback->SetParseProgress( (DWORD)iProgress );
+ int64_t iProgress = m_dwCharsTotal ? (( static_cast<int64_t>(m_dwCharsConsumed) * 1000 ) / static_cast<int64_t>(m_dwCharsTotal)) : 0;
+ m_pISAXCallback->SetParseProgress( static_cast<DWORD>(iProgress) );
m_pReadBuf[ NChars ] = '\0';
m_pReadBuf[ NChars + 1] = '\0';
@@ -198,7 +198,7 @@ HRESULT XMLParser::ConvertEscape()
if( FAILED( hr = AdvanceName() ) )
return hr;
- EntityRefLen = (UINT)( m_pWritePtr - pEntityRefVal );
+ EntityRefLen = static_cast<UINT>(m_pWritePtr - pEntityRefVal);
m_pWritePtr = pEntityRefVal;
if ( EntityRefLen == 0 )
@@ -359,7 +359,7 @@ HRESULT XMLParser::AdvanceCharacter( BOOL bOkToFail )
// Read more from the file
FillBuffer();
- // We are at EOF if it is still NULL
+ // We are at EOF if it is still nullptr
if ( ( m_pReadPtr[0] == '\0' ) && ( m_pReadPtr[1] == '\0' ) )
{
if( !bOkToFail )
@@ -497,8 +497,8 @@ HRESULT XMLParser::AdvanceElement()
if( FAILED( hr = AdvanceName() ) )
return hr;
- if( FAILED( m_pISAXCallback->ElementEnd( pEntityRefVal,
- (UINT) ( m_pWritePtr - pEntityRefVal ) ) ) )
+ if (FAILED(m_pISAXCallback->ElementEnd( pEntityRefVal,
+ static_cast<UINT>(m_pWritePtr - pEntityRefVal) )))
return E_ABORT;
if( FAILED( hr = ConsumeSpace() ) )
@@ -541,7 +541,7 @@ HRESULT XMLParser::AdvanceElement()
if( FAILED( hr = AdvanceName() ) )
return hr;
- EntityRefLen = (UINT)( m_pWritePtr - pEntityRefVal );
+ EntityRefLen = static_cast<UINT>(m_pWritePtr - pEntityRefVal);
if( FAILED( hr = ConsumeSpace() ) )
return hr;
@@ -566,7 +566,7 @@ HRESULT XMLParser::AdvanceElement()
if( FAILED( hr = AdvanceName() ) )
return hr;
- Attributes[ NumAttrs ].NameLen = (UINT)( m_pWritePtr - Attributes[ NumAttrs ].strName );
+ Attributes[ NumAttrs ].NameLen = static_cast<UINT>(m_pWritePtr - Attributes[NumAttrs].strName);
if( FAILED( hr = ConsumeSpace() ) )
return hr;
@@ -588,8 +588,8 @@ HRESULT XMLParser::AdvanceElement()
if( FAILED( hr = AdvanceAttrVal() ) )
return hr;
- Attributes[ NumAttrs ].ValueLen = (UINT)( m_pWritePtr -
- Attributes[ NumAttrs ].strValue );
+ Attributes[ NumAttrs ].ValueLen = static_cast<UINT>(m_pWritePtr -
+ Attributes[NumAttrs].strValue);
++NumAttrs;
@@ -663,13 +663,13 @@ HRESULT XMLParser::AdvanceCDATA()
if( m_pWritePtr - m_pWriteBuf >= XML_WRITE_BUFFER_SIZE )
{
- if( FAILED( m_pISAXCallback->CDATAData( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), TRUE ) ) )
+ if( FAILED( m_pISAXCallback->CDATAData( m_pWriteBuf, static_cast<UINT>(m_pWritePtr - m_pWriteBuf), TRUE ) ) )
return E_ABORT;
m_pWritePtr = m_pWriteBuf;
}
}
- if( FAILED( m_pISAXCallback->CDATAData( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), FALSE ) ) )
+ if( FAILED( m_pISAXCallback->CDATAData( m_pWriteBuf, static_cast<UINT>(m_pWritePtr - m_pWriteBuf), FALSE ) ) )
return E_ABORT;
m_pWritePtr = m_pWriteBuf;
@@ -782,11 +782,10 @@ HRESULT XMLParser::MainParseLoop()
{
if( FAILED( AdvanceCharacter( TRUE ) ) )
{
- if ( ( (UINT) ( m_pWritePtr - m_pWriteBuf ) != 0 ) && ( !bWhiteSpaceOnly ) )
+ if ( ( static_cast<UINT>(m_pWritePtr - m_pWriteBuf) != 0 ) && ( !bWhiteSpaceOnly ) )
{
- if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), FALSE ) ) )
+ if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, static_cast<UINT>(m_pWritePtr - m_pWriteBuf), FALSE ) ) )
return E_ABORT;
-
bWhiteSpaceOnly = TRUE;
}
@@ -798,9 +797,10 @@ HRESULT XMLParser::MainParseLoop()
if( m_Ch == '<' )
{
- if( ( (UINT) ( m_pWritePtr - m_pWriteBuf ) != 0 ) && ( !bWhiteSpaceOnly ) )
+\
+ if( ( static_cast<UINT>(m_pWritePtr - m_pWriteBuf) != 0 ) && ( !bWhiteSpaceOnly ) )
{
- if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), FALSE ) ) )
+ if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, static_cast<UINT>(m_pWritePtr - m_pWriteBuf), FALSE ) ) )
return E_ABORT;
bWhiteSpaceOnly = TRUE;
@@ -838,8 +838,7 @@ HRESULT XMLParser::MainParseLoop()
if( !bWhiteSpaceOnly )
{
if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf,
- ( UINT ) ( m_pWritePtr - m_pWriteBuf ),
- TRUE ) ) )
+ static_cast<UINT>(m_pWritePtr - m_pWriteBuf), TRUE ) ) )
{
return E_ABORT;
}
@@ -861,7 +860,7 @@ HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename )
{
HRESULT hr;
- if( m_pISAXCallback == NULL )
+ if( m_pISAXCallback == nullptr )
return E_NOINTERFACE;
m_pISAXCallback->m_LineNum = 1;
@@ -872,16 +871,17 @@ HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename )
m_pReadPtr = m_pReadBuf;
m_pReadBuf[ 0 ] = '\0';
+
m_pReadBuf[ 1 ] = '\0';
- m_pInXMLBuffer = NULL;
+ m_pInXMLBuffer = nullptr;
m_uInXMLBufferCharsLeft = 0;
WCHAR wchFilename[ 64 ];
swprintf_s(wchFilename,64,L"%s",strFilename);
- m_hFile = CreateFile( wchFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL );
+ m_hFile = CreateFile(wchFilename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, nullptr);
if( m_hFile == INVALID_HANDLE_VALUE )
{
@@ -893,7 +893,7 @@ HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename )
{
LARGE_INTEGER iFileSize;
GetFileSizeEx( m_hFile, &iFileSize );
- m_dwCharsTotal = (DWORD)iFileSize.QuadPart;
+ m_dwCharsTotal = static_cast<DWORD>(iFileSize.QuadPart);
m_dwCharsConsumed = 0;
hr = MainParseLoop();
}
@@ -904,8 +904,7 @@ HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename )
m_hFile = INVALID_HANDLE_VALUE;
// we no longer own strFilename, so un-set it
- m_pISAXCallback->m_strFilename = NULL;
-
+ m_pISAXCallback->m_strFilename = nullptr;
return hr;
}
@@ -917,7 +916,7 @@ HRESULT XMLParser::ParseXMLBuffer( CONST CHAR *strBuffer, UINT uBufferSize )
{
HRESULT hr;
- if( m_pISAXCallback == NULL )
+ if( m_pISAXCallback == nullptr )
return E_NOINTERFACE;
m_pISAXCallback->m_LineNum = 1;
@@ -930,7 +929,7 @@ HRESULT XMLParser::ParseXMLBuffer( CONST CHAR *strBuffer, UINT uBufferSize )
m_pReadBuf[ 0 ] = '\0';
m_pReadBuf[ 1 ] = '\0';
- m_hFile = NULL;
+ m_hFile = nullptr;
m_pInXMLBuffer = strBuffer;
m_uInXMLBufferCharsLeft = uBufferSize;
m_dwCharsTotal = uBufferSize;
@@ -939,7 +938,7 @@ HRESULT XMLParser::ParseXMLBuffer( CONST CHAR *strBuffer, UINT uBufferSize )
hr = MainParseLoop();
// we no longer own strFilename, so un-set it
- m_pISAXCallback->m_strFilename = NULL;
+ m_pISAXCallback->m_strFilename = nullptr;
return hr;
}