From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.Client/PS3/XML/ATGXmlParser.h | 156 +++++++++++++++++++ Minecraft.Client/PS3/XML/xmlFilesCallback.h | 232 ++++++++++++++++++++++++++++ 2 files changed, 388 insertions(+) create mode 100644 Minecraft.Client/PS3/XML/ATGXmlParser.h create mode 100644 Minecraft.Client/PS3/XML/xmlFilesCallback.h (limited to 'Minecraft.Client/PS3/XML') diff --git a/Minecraft.Client/PS3/XML/ATGXmlParser.h b/Minecraft.Client/PS3/XML/ATGXmlParser.h new file mode 100644 index 00000000..75142e3e --- /dev/null +++ b/Minecraft.Client/PS3/XML/ATGXmlParser.h @@ -0,0 +1,156 @@ +// 4J-PB - +// The ATG Framework is a common set of C++ class libraries that is used by the samples in the XDK, and was developed by the Advanced Technology Group (ATG). +// The ATG Framework offers a clean and consistent format for the samples. These classes define functions used by all the samples. +// The ATG Framework together with the samples demonstrates best practices and innovative techniques for Xbox 360. There are many useful sections of code in the samples. +// You are encouraged to incorporate this code into your titles. + +//------------------------------------------------------------------------------------- +// AtgXmlParser.h +// +// XMLParser and SAX interface declaration +// +// Xbox Advanced Technology Group +// Copyright (C) Microsoft Corporation. All rights reserved. +//------------------------------------------------------------------------------------- + +#pragma once +#ifndef ATGXMLPARSER_H +#define ATGXMLPARSER_H + +namespace ATG +{ + +//----------------------------------------------------------------------------- +// error returns from XMLParse +//----------------------------------------------------------------------------- +#define _ATGFAC 0x61B +#define E_COULD_NOT_OPEN_FILE MAKE_HRESULT(1, _ATGFAC, 0x0001 ) +#define E_INVALID_XML_SYNTAX MAKE_HRESULT(1, _ATGFAC, 0x0002 ) + + +CONST UINT XML_MAX_ATTRIBUTES_PER_ELEMENT = 32; +CONST UINT XML_MAX_NAME_LENGTH = 128; +CONST UINT XML_READ_BUFFER_SIZE = 2048; +CONST UINT XML_WRITE_BUFFER_SIZE = 2048; + +// No tag can be longer than XML_WRITE_BUFFER_SIZE - an error will be returned if +// it is + +//------------------------------------------------------------------------------------- +struct XMLAttribute +{ + WCHAR* strName; + UINT NameLen; + WCHAR* strValue; + UINT ValueLen; +}; + +//------------------------------------------------------------------------------------- +class ISAXCallback +{ +friend class XMLParser; +public: + ISAXCallback() {}; + virtual ~ISAXCallback() {}; + + virtual HRESULT StartDocument() = 0; + virtual HRESULT EndDocument() = 0; + + virtual HRESULT ElementBegin( CONST WCHAR* strName, UINT NameLen, + CONST XMLAttribute *pAttributes, UINT NumAttributes ) = 0; + virtual HRESULT ElementContent( CONST WCHAR *strData, UINT DataLen, BOOL More ) = 0; + virtual HRESULT ElementEnd( CONST WCHAR *strName, UINT NameLen ) = 0; + + virtual HRESULT CDATABegin( ) = 0; + virtual HRESULT CDATAData( CONST WCHAR *strCDATA, UINT CDATALen, BOOL bMore ) = 0; + virtual HRESULT CDATAEnd( ) = 0; + + virtual VOID Error( HRESULT hError, CONST CHAR *strMessage ) = 0; + + virtual VOID SetParseProgress( DWORD dwProgress ) { } + + const CHAR* GetFilename() { return m_strFilename; } + UINT GetLineNumber() { return m_LineNum; } + UINT GetLinePosition() { return m_LinePos; } + +private: + CONST CHAR *m_strFilename; + UINT m_LineNum; + UINT m_LinePos; +}; + + +//------------------------------------------------------------------------------------- +class XMLParser +{ +public: + XMLParser(); + ~XMLParser(); + + // Register an interface inheiriting from ISAXCallback + VOID RegisterSAXCallbackInterface( ISAXCallback *pISAXCallback ); + + // Get the registered interface + ISAXCallback* GetSAXCallbackInterface(); + + // ParseXMLFile returns one of the following: + // E_COULD_NOT_OPEN_FILE - couldn't open the file + // E_INVALID_XML_SYNTAX - bad XML syntax according to this parser + // E_NOINTERFACE - RegisterSAXCallbackInterface not called + // E_ABORT - callback returned a fail code + // S_OK - file parsed and completed + + HRESULT ParseXMLFile( CONST CHAR *strFilename ); + + // Parses from a buffer- if you pass a WCHAR buffer (and cast it), it will + // correctly detect it and use unicode instead. Return codes are the + // same as for ParseXMLFile + + HRESULT ParseXMLBuffer( CONST CHAR* strBuffer, UINT uBufferSize ); + +private: + HRESULT MainParseLoop(); + + HRESULT AdvanceCharacter( BOOL bOkToFail = FALSE ); + VOID SkipNextAdvance(); + + HRESULT ConsumeSpace(); + HRESULT ConvertEscape(); + HRESULT AdvanceElement(); + HRESULT AdvanceName(); + HRESULT AdvanceAttrVal(); + HRESULT AdvanceCDATA(); + HRESULT AdvanceComment(); + + VOID FillBuffer(); + +#ifdef _Printf_format_string_ // VC++ 2008 and later support this annotation + VOID Error( HRESULT hRet, _In_z_ _Printf_format_string_ CONST CHAR* strFormat, ... ); +#else + VOID Error( HRESULT hRet, CONST CHAR* strFormat, ... ); +#endif + + ISAXCallback* m_pISAXCallback; + + HANDLE m_hFile; + CONST CHAR* m_pInXMLBuffer; + UINT m_uInXMLBufferCharsLeft; + DWORD m_dwCharsTotal; + DWORD m_dwCharsConsumed; + + BYTE m_pReadBuf[ XML_READ_BUFFER_SIZE + 2 ]; // room for a trailing NULL + WCHAR m_pWriteBuf[ XML_WRITE_BUFFER_SIZE ]; + + BYTE* m_pReadPtr; + WCHAR* m_pWritePtr; // write pointer within m_pBuf + + BOOL m_bUnicode; // TRUE = 16-bits, FALSE = 8-bits + BOOL m_bReverseBytes; // TRUE = reverse bytes, FALSE = don't reverse + + BOOL m_bSkipNextAdvance; + WCHAR m_Ch; // Current character being parsed +}; + +} // namespace ATG + +#endif diff --git a/Minecraft.Client/PS3/XML/xmlFilesCallback.h b/Minecraft.Client/PS3/XML/xmlFilesCallback.h new file mode 100644 index 00000000..b6c1bcf0 --- /dev/null +++ b/Minecraft.Client/PS3/XML/xmlFilesCallback.h @@ -0,0 +1,232 @@ + +#pragma once +#ifndef XMLMOJANGCALLBACK_H +#define XMLMOJANGCALLBACK_H +// xml reading + +using namespace ATG; + +class xmlMojangCallback : public ATG::ISAXCallback +{ +public: + virtual HRESULT StartDocument() { return S_OK; }; + virtual HRESULT EndDocument() { return S_OK; }; + + virtual HRESULT ElementBegin( CONST WCHAR* strName, UINT NameLen, CONST XMLAttribute *pAttributes, UINT NumAttributes ) + { + WCHAR wTemp[35] = L""; + WCHAR wAttName[32] = L""; + WCHAR wNameXUID[32] = L""; + WCHAR wNameSkin[32] = L""; + WCHAR wNameCloak[32] = L""; + PlayerUID xuid=0LL; + + + if (NameLen >31) + return S_FALSE; + else + wcsncpy( wAttName, strName, NameLen); + + if ( _wcsicmp(wAttName,L"root") == 0) + { + return S_OK; + } + else if ( _wcsicmp(wAttName,L"data") == 0) + { + for(UINT i = 0; i < NumAttributes; i++) + { + wcsncpy_s( wAttName, pAttributes[i].strName, pAttributes[i].NameLen); + if (_wcsicmp(wAttName,L"name")==0) + { + if (pAttributes[i].ValueLen <= 32) + wcsncpy_s( wNameXUID, pAttributes[i].strValue, pAttributes[i].ValueLen); + } + else if (_wcsicmp(wAttName,L"xuid")==0) + { + if (pAttributes[i].ValueLen <= 32) + { + ZeroMemory(wTemp,sizeof(WCHAR)*35); + wcsncpy_s( wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); + xuid=_wcstoui64(wTemp,NULL,10); + } + } + else if (_wcsicmp(wAttName,L"cape")==0) + { + if (pAttributes[i].ValueLen <= 32) + { + wcsncpy_s( wNameCloak, pAttributes[i].strValue, pAttributes[i].ValueLen); + } + } + else if (_wcsicmp(wAttName,L"skin")==0) + { + if (pAttributes[i].ValueLen <= 32) + { + wcsncpy_s( wNameSkin, pAttributes[i].strValue, pAttributes[i].ValueLen); + } + } + + } + + // if the xuid hasn't been defined, then we can't use the data + if(xuid!=0LL) + { + return CConsoleMinecraftApp::RegisterMojangData(wNameXUID , xuid, wNameSkin, wNameCloak ); + } + else return S_FALSE; + } + else + { + return S_FALSE; + } + }; + + virtual HRESULT ElementContent( CONST WCHAR *strData, UINT DataLen, BOOL More ) { return S_OK; }; + + virtual HRESULT ElementEnd( CONST WCHAR *strName, UINT NameLen ){ return S_OK; }; + + virtual HRESULT CDATABegin( ) { return S_OK; }; + + virtual HRESULT CDATAData( CONST WCHAR *strCDATA, UINT CDATALen, BOOL bMore ){ return S_OK; }; + + virtual HRESULT CDATAEnd( ){ return S_OK; }; + + virtual VOID Error( HRESULT hError, CONST CHAR *strMessage ) { app.DebugPrintf("Error when Parsing xuids.XML\n"); }; + +}; + +class xmlDLCInfoCallback : public ATG::ISAXCallback +{ +public: + virtual HRESULT StartDocument() { return S_OK; }; + virtual HRESULT EndDocument() { return S_OK; }; + + virtual HRESULT ElementBegin( CONST WCHAR* strName, UINT NameLen, CONST XMLAttribute *pAttributes, UINT NumAttributes ) + { + WCHAR wTemp[35] = L""; + WCHAR wAttName[32] = L""; + WCHAR wNameBanner[32] = L""; + WCHAR wType[32] = L""; + WCHAR wFirstSkin[32] = L""; + WCHAR wDataFile[32] = L""; + ULONGLONG ullFull=0ll; + ULONGLONG ullTrial=0ll; + int iGender=0; + int iConfig=0; + + if (NameLen >31) + return S_FALSE; + else + wcsncpy_s( wAttName, strName, NameLen); + + if ( _wcsicmp(wAttName,L"root") == 0) + { + return S_OK; + } + else if ( _wcsicmp(wAttName,L"data") == 0) + { + for(UINT i = 0; i < NumAttributes; i++) + { + wcsncpy_s( wAttName, pAttributes[i].strName, pAttributes[i].NameLen); + if (_wcsicmp(wAttName,L"Banner")==0) + { + if (pAttributes[i].ValueLen <= 32) + { + wcsncpy_s( wNameBanner, pAttributes[i].strValue, pAttributes[i].ValueLen); + } + } + else if (_wcsicmp(wAttName,L"Full")==0) + { + if (pAttributes[i].ValueLen <= 32) + { + ZeroMemory(wTemp,sizeof(WCHAR)*35); + wcsncpy_s( wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); + ullFull=_wcstoui64(wTemp,NULL,16); + } + } + else if (_wcsicmp(wAttName,L"Trial")==0) + { + if (pAttributes[i].ValueLen <= 32) + { + ZeroMemory(wTemp,sizeof(WCHAR)*35); + wcsncpy_s( wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); + ullTrial=_wcstoui64(wTemp,NULL,16); + } + } + else if (_wcsicmp(wAttName,L"FirstSkin")==0) + { + if (pAttributes[i].ValueLen <= 32) + { + wcsncpy_s( wFirstSkin, pAttributes[i].strValue, pAttributes[i].ValueLen); + } + } + else if (_wcsicmp(wAttName,L"DataFile")==0) + { + if (pAttributes[i].ValueLen <= 32) + { + wcsncpy_s( wDataFile, pAttributes[i].strValue, pAttributes[i].ValueLen); + } + } + else if (_wcsicmp(wAttName,L"Type")==0) + { + if (pAttributes[i].ValueLen <= 32) + { + wcsncpy_s( wType, pAttributes[i].strValue, pAttributes[i].ValueLen); + } + } + else if (_wcsicmp(wAttName,L"Gender")==0) + { + if (_wcsicmp(wAttName,L"Male")==0) + { + iGender=1; + } + else if (_wcsicmp(wAttName,L"Female")==0) + { + iGender=2; + } + else + { + iGender=0; + } + } + else if(_wcsicmp(wAttName,L"Config")==0) + { + if (pAttributes[i].ValueLen <= 32) + { + iConfig=_wtoi(wTemp); + } + } + } + + // if the xuid hasn't been defined, then we can't use the data + if(ullFull!=0LL) + { +#ifdef _DEBUG + wprintf(L"Type - %ls, Name - %ls, ",wType, wNameBanner); +#endif + app.DebugPrintf("Full = %lld, Trial %lld\n",ullFull,ullTrial); + + return CConsoleMinecraftApp::RegisterDLCData(wType, wNameBanner , iGender, ullFull, ullTrial, wFirstSkin, iConfig, wDataFile ); + } + else return S_FALSE; + } + else + { + return S_FALSE; + } + }; + + virtual HRESULT ElementContent( CONST WCHAR *strData, UINT DataLen, BOOL More ) { return S_OK; }; + + virtual HRESULT ElementEnd( CONST WCHAR *strName, UINT NameLen ){ return S_OK; }; + + virtual HRESULT CDATABegin( ) { return S_OK; }; + + virtual HRESULT CDATAData( CONST WCHAR *strCDATA, UINT CDATALen, BOOL bMore ){ return S_OK; }; + + virtual HRESULT CDATAEnd( ){ return S_OK; }; + + virtual VOID Error( HRESULT hError, CONST CHAR *strMessage ) { app.DebugPrintf("Error when Parsing DLC.XML\n"); }; + +}; + +#endif \ No newline at end of file -- cgit v1.2.3