the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at master 232 lines 6.1 kB view raw
1 2#pragma once 3#ifndef XMLMOJANGCALLBACK_H 4#define XMLMOJANGCALLBACK_H 5// xml reading 6 7using namespace ATG; 8 9class xmlMojangCallback : public ATG::ISAXCallback 10{ 11public: 12 virtual HRESULT StartDocument() { return S_OK; }; 13 virtual HRESULT EndDocument() { return S_OK; }; 14 15 virtual HRESULT ElementBegin( CONST WCHAR* strName, UINT NameLen, CONST XMLAttribute *pAttributes, UINT NumAttributes ) 16 { 17 WCHAR wTemp[35] = L""; 18 WCHAR wAttName[32] = L""; 19 WCHAR wNameXUID[32] = L""; 20 WCHAR wNameSkin[32] = L""; 21 WCHAR wNameCloak[32] = L""; 22 PlayerUID xuid=0LL; 23 24 25 if (NameLen >31) 26 return S_FALSE; 27 else 28 wcsncpy( wAttName, strName, NameLen); 29 30 if ( _wcsicmp(wAttName,L"root") == 0) 31 { 32 return S_OK; 33 } 34 else if ( _wcsicmp(wAttName,L"data") == 0) 35 { 36 for(UINT i = 0; i < NumAttributes; i++) 37 { 38 wcsncpy_s( wAttName, pAttributes[i].strName, pAttributes[i].NameLen); 39 if (_wcsicmp(wAttName,L"name")==0) 40 { 41 if (pAttributes[i].ValueLen <= 32) 42 wcsncpy_s( wNameXUID, pAttributes[i].strValue, pAttributes[i].ValueLen); 43 } 44 else if (_wcsicmp(wAttName,L"xuid")==0) 45 { 46 if (pAttributes[i].ValueLen <= 32) 47 { 48 ZeroMemory(wTemp,sizeof(WCHAR)*35); 49 wcsncpy_s( wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); 50 xuid=_wcstoui64(wTemp,NULL,10); 51 } 52 } 53 else if (_wcsicmp(wAttName,L"cape")==0) 54 { 55 if (pAttributes[i].ValueLen <= 32) 56 { 57 wcsncpy_s( wNameCloak, pAttributes[i].strValue, pAttributes[i].ValueLen); 58 } 59 } 60 else if (_wcsicmp(wAttName,L"skin")==0) 61 { 62 if (pAttributes[i].ValueLen <= 32) 63 { 64 wcsncpy_s( wNameSkin, pAttributes[i].strValue, pAttributes[i].ValueLen); 65 } 66 } 67 68 } 69 70 // if the xuid hasn't been defined, then we can't use the data 71 if(xuid!=0LL) 72 { 73 return CConsoleMinecraftApp::RegisterMojangData(wNameXUID , xuid, wNameSkin, wNameCloak ); 74 } 75 else return S_FALSE; 76 } 77 else 78 { 79 return S_FALSE; 80 } 81 }; 82 83 virtual HRESULT ElementContent( CONST WCHAR *strData, UINT DataLen, BOOL More ) { return S_OK; }; 84 85 virtual HRESULT ElementEnd( CONST WCHAR *strName, UINT NameLen ){ return S_OK; }; 86 87 virtual HRESULT CDATABegin( ) { return S_OK; }; 88 89 virtual HRESULT CDATAData( CONST WCHAR *strCDATA, UINT CDATALen, BOOL bMore ){ return S_OK; }; 90 91 virtual HRESULT CDATAEnd( ){ return S_OK; }; 92 93 virtual VOID Error( HRESULT hError, CONST CHAR *strMessage ) { app.DebugPrintf("Error when Parsing xuids.XML\n"); }; 94 95}; 96 97class xmlDLCInfoCallback : public ATG::ISAXCallback 98{ 99public: 100 virtual HRESULT StartDocument() { return S_OK; }; 101 virtual HRESULT EndDocument() { return S_OK; }; 102 103 virtual HRESULT ElementBegin( CONST WCHAR* strName, UINT NameLen, CONST XMLAttribute *pAttributes, UINT NumAttributes ) 104 { 105 WCHAR wTemp[35] = L""; 106 WCHAR wAttName[32] = L""; 107 WCHAR wNameBanner[32] = L""; 108 WCHAR wType[32] = L""; 109 WCHAR wFirstSkin[32] = L""; 110 WCHAR wDataFile[32] = L""; 111 ULONGLONG ullFull=0ll; 112 ULONGLONG ullTrial=0ll; 113 int iGender=0; 114 int iConfig=0; 115 116 if (NameLen >31) 117 return S_FALSE; 118 else 119 wcsncpy_s( wAttName, strName, NameLen); 120 121 if ( _wcsicmp(wAttName,L"root") == 0) 122 { 123 return S_OK; 124 } 125 else if ( _wcsicmp(wAttName,L"data") == 0) 126 { 127 for(UINT i = 0; i < NumAttributes; i++) 128 { 129 wcsncpy_s( wAttName, pAttributes[i].strName, pAttributes[i].NameLen); 130 if (_wcsicmp(wAttName,L"Banner")==0) 131 { 132 if (pAttributes[i].ValueLen <= 32) 133 { 134 wcsncpy_s( wNameBanner, pAttributes[i].strValue, pAttributes[i].ValueLen); 135 } 136 } 137 else if (_wcsicmp(wAttName,L"Full")==0) 138 { 139 if (pAttributes[i].ValueLen <= 32) 140 { 141 ZeroMemory(wTemp,sizeof(WCHAR)*35); 142 wcsncpy_s( wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); 143 ullFull=_wcstoui64(wTemp,NULL,16); 144 } 145 } 146 else if (_wcsicmp(wAttName,L"Trial")==0) 147 { 148 if (pAttributes[i].ValueLen <= 32) 149 { 150 ZeroMemory(wTemp,sizeof(WCHAR)*35); 151 wcsncpy_s( wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); 152 ullTrial=_wcstoui64(wTemp,NULL,16); 153 } 154 } 155 else if (_wcsicmp(wAttName,L"FirstSkin")==0) 156 { 157 if (pAttributes[i].ValueLen <= 32) 158 { 159 wcsncpy_s( wFirstSkin, pAttributes[i].strValue, pAttributes[i].ValueLen); 160 } 161 } 162 else if (_wcsicmp(wAttName,L"DataFile")==0) 163 { 164 if (pAttributes[i].ValueLen <= 32) 165 { 166 wcsncpy_s( wDataFile, pAttributes[i].strValue, pAttributes[i].ValueLen); 167 } 168 } 169 else if (_wcsicmp(wAttName,L"Type")==0) 170 { 171 if (pAttributes[i].ValueLen <= 32) 172 { 173 wcsncpy_s( wType, pAttributes[i].strValue, pAttributes[i].ValueLen); 174 } 175 } 176 else if (_wcsicmp(wAttName,L"Gender")==0) 177 { 178 if (_wcsicmp(wAttName,L"Male")==0) 179 { 180 iGender=1; 181 } 182 else if (_wcsicmp(wAttName,L"Female")==0) 183 { 184 iGender=2; 185 } 186 else 187 { 188 iGender=0; 189 } 190 } 191 else if(_wcsicmp(wAttName,L"Config")==0) 192 { 193 if (pAttributes[i].ValueLen <= 32) 194 { 195 iConfig=_wtoi(wTemp); 196 } 197 } 198 } 199 200 // if the xuid hasn't been defined, then we can't use the data 201 if(ullFull!=0LL) 202 { 203#ifdef _DEBUG 204 wprintf(L"Type - %ls, Name - %ls, ",wType, wNameBanner); 205#endif 206 app.DebugPrintf("Full = %lld, Trial %lld\n",ullFull,ullTrial); 207 208 return CConsoleMinecraftApp::RegisterDLCData(wType, wNameBanner , iGender, ullFull, ullTrial, wFirstSkin, iConfig, wDataFile ); 209 } 210 else return S_FALSE; 211 } 212 else 213 { 214 return S_FALSE; 215 } 216 }; 217 218 virtual HRESULT ElementContent( CONST WCHAR *strData, UINT DataLen, BOOL More ) { return S_OK; }; 219 220 virtual HRESULT ElementEnd( CONST WCHAR *strName, UINT NameLen ){ return S_OK; }; 221 222 virtual HRESULT CDATABegin( ) { return S_OK; }; 223 224 virtual HRESULT CDATAData( CONST WCHAR *strCDATA, UINT CDATALen, BOOL bMore ){ return S_OK; }; 225 226 virtual HRESULT CDATAEnd( ){ return S_OK; }; 227 228 virtual VOID Error( HRESULT hError, CONST CHAR *strMessage ) { app.DebugPrintf("Error when Parsing DLC.XML\n"); }; 229 230}; 231 232#endif