the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 339 lines 8.7 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 xmlConfigCallback : 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 wType[32] = L""; 107 WCHAR wAttName[32] = L""; 108 WCHAR wValue[32] = L""; 109 int iValue=-1; 110 111 if (NameLen >31) 112 return S_FALSE; 113 else 114 wcsncpy_s( wAttName, strName, NameLen); 115 116 if ( _wcsicmp(wAttName,L"root") == 0) 117 { 118 return S_OK; 119 } 120 else if ( _wcsicmp(wAttName,L"data") == 0) 121 { 122 for(UINT i = 0; i < NumAttributes; i++) 123 { 124 wcsncpy_s( wAttName, pAttributes[i].strName, pAttributes[i].NameLen); 125 if (_wcsicmp(wAttName,L"Type")==0) 126 { 127 if (pAttributes[i].ValueLen <= 32) 128 { 129 wcsncpy_s( wType, pAttributes[i].strValue, pAttributes[i].ValueLen); 130 } 131 } 132 else if(_wcsicmp(wAttName,L"Value")==0) 133 { 134 if (pAttributes[i].ValueLen <= 32) 135 { 136 wcsncpy_s( wValue, pAttributes[i].strValue, pAttributes[i].ValueLen); 137 138#ifdef _XBOX 139 iValue=_wtoi(wValue); 140#else 141 iValue=wcstol(wValue, NULL, 10); 142#endif 143 } 144 } 145 } 146 147 // if the xuid hasn't been defined, then we can't use the data 148 if(iValue!=-1) 149 { 150 #ifdef _DEBUG 151 wprintf(L"Type - %s, Value - %d, ",wType, iValue); 152 #endif 153 154 return CConsoleMinecraftApp::RegisterConfigValues(wType, iValue ); 155 } 156 else 157 { 158 return S_FALSE; 159 } 160 } 161 else 162 { 163 return S_FALSE; 164 } 165 } 166 167 168 virtual HRESULT ElementContent( CONST WCHAR *strData, UINT DataLen, BOOL More ) { return S_OK; }; 169 170 virtual HRESULT ElementEnd( CONST WCHAR *strName, UINT NameLen ){ return S_OK; }; 171 172 virtual HRESULT CDATABegin( ) { return S_OK; }; 173 174 virtual HRESULT CDATAData( CONST WCHAR *strCDATA, UINT CDATALen, BOOL bMore ){ return S_OK; }; 175 176 virtual HRESULT CDATAEnd( ){ return S_OK; }; 177 178 virtual VOID Error( HRESULT hError, CONST CHAR *strMessage ) { app.DebugPrintf("Error when Parsing xuids.XML\n"); }; 179 180}; 181 182class xmlDLCInfoCallback : public ATG::ISAXCallback 183{ 184public: 185 virtual HRESULT StartDocument() { return S_OK; }; 186 virtual HRESULT EndDocument() { return S_OK; }; 187 188 virtual HRESULT ElementBegin( CONST WCHAR* strName, UINT NameLen, CONST XMLAttribute *pAttributes, UINT NumAttributes ) 189 { 190 WCHAR wTemp[35] = L""; 191 WCHAR wAttName[32] = L""; 192 WCHAR wNameBanner[32] = L""; 193 WCHAR wDataFile[32] = L""; 194 WCHAR wType[32] = L""; 195 WCHAR wFirstSkin[32] = L""; 196 WCHAR wConfig[32] = L""; 197 ULONGLONG ullFull=0ll; 198 ULONGLONG ullTrial=0ll; 199 unsigned int uiSortIndex=0L; 200 int iGender=0; 201 int iConfig=0; 202 203 if (NameLen >31) 204 return S_FALSE; 205 else 206 wcsncpy_s( wAttName, strName, NameLen); 207 208 if ( _wcsicmp(wAttName,L"root") == 0) 209 { 210 return S_OK; 211 } 212 else if ( _wcsicmp(wAttName,L"data") == 0) 213 { 214 for(UINT i = 0; i < NumAttributes; i++) 215 { 216 wcsncpy_s( wAttName, pAttributes[i].strName, pAttributes[i].NameLen); 217 if (_wcsicmp(wAttName,L"SortIndex")==0) 218 { 219 if (pAttributes[i].ValueLen <= 32) 220 { 221 ZeroMemory(wTemp,sizeof(WCHAR)*35); 222 wcsncpy_s( wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); 223 uiSortIndex=wcstoul(wTemp,NULL,16); 224 } 225 } 226 else if (_wcsicmp(wAttName,L"Banner")==0) 227 { 228 if (pAttributes[i].ValueLen <= 32) 229 { 230 wcsncpy_s( wNameBanner, pAttributes[i].strValue, pAttributes[i].ValueLen); 231 } 232 } 233 else if (_wcsicmp(wAttName,L"Full")==0) 234 { 235 if (pAttributes[i].ValueLen <= 32) 236 { 237 ZeroMemory(wTemp,sizeof(WCHAR)*35); 238 wcsncpy_s( wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); 239 ullFull=_wcstoui64(wTemp,NULL,16); 240 } 241 } 242 else if (_wcsicmp(wAttName,L"Trial")==0) 243 { 244 if (pAttributes[i].ValueLen <= 32) 245 { 246 ZeroMemory(wTemp,sizeof(WCHAR)*35); 247 wcsncpy_s( wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); 248 ullTrial=_wcstoui64(wTemp,NULL,16); 249 } 250 } 251 else if (_wcsicmp(wAttName,L"FirstSkin")==0) 252 { 253 if (pAttributes[i].ValueLen <= 32) 254 { 255 wcsncpy_s( wFirstSkin, pAttributes[i].strValue, pAttributes[i].ValueLen); 256 } 257 } 258 else if (_wcsicmp(wAttName,L"Type")==0) 259 { 260 if (pAttributes[i].ValueLen <= 32) 261 { 262 wcsncpy_s( wType, pAttributes[i].strValue, pAttributes[i].ValueLen); 263 } 264 } 265 else if (_wcsicmp(wAttName,L"Gender")==0) 266 { 267 if (_wcsicmp(wAttName,L"Male")==0) 268 { 269 iGender=1; 270 } 271 else if (_wcsicmp(wAttName,L"Female")==0) 272 { 273 iGender=2; 274 } 275 else 276 { 277 iGender=0; 278 } 279 } 280 else if(_wcsicmp(wAttName,L"Config")==0) 281 { 282 if (pAttributes[i].ValueLen <= 32) 283 { 284 wcsncpy_s( wConfig, pAttributes[i].strValue, pAttributes[i].ValueLen); 285 286#ifdef _XBOX 287 iConfig=_wtoi(wConfig); 288#else 289 iConfig=wcstol(wConfig, NULL, 10); 290#endif 291 } 292 } 293 else if (_wcsicmp(wAttName,L"DataFile")==0) 294 { 295 if (pAttributes[i].ValueLen <= 32) 296 { 297 wcsncpy_s( wDataFile, pAttributes[i].strValue, pAttributes[i].ValueLen); 298 } 299 } 300 301 } 302 303 // if the xuid hasn't been defined, then we can't use the data 304 if(ullFull!=0LL) 305 { 306#ifdef _DEBUG 307 wprintf(L"Type - %ls, Name - %ls, ",wType, wNameBanner); 308#endif 309 app.DebugPrintf("Full = %lld, Trial %lld\n",ullFull,ullTrial); 310 311 return CConsoleMinecraftApp::RegisterDLCData(wType, wNameBanner , iGender, ullFull, ullTrial, wFirstSkin, uiSortIndex, iConfig, wDataFile ); 312 } 313 else 314 { 315 return S_FALSE; 316 } 317 } 318 else 319 { 320 return S_FALSE; 321 } 322 }; 323 324 virtual HRESULT ElementContent( CONST WCHAR *strData, UINT DataLen, BOOL More ) { return S_OK; }; 325 326 virtual HRESULT ElementEnd( CONST WCHAR *strName, UINT NameLen ){ return S_OK; }; 327 328 virtual HRESULT CDATABegin( ) { return S_OK; }; 329 330 virtual HRESULT CDATAData( CONST WCHAR *strCDATA, UINT CDATALen, BOOL bMore ){ return S_OK; }; 331 332 virtual HRESULT CDATAEnd( ){ return S_OK; }; 333 334 virtual VOID Error( HRESULT hError, CONST CHAR *strMessage ) { app.DebugPrintf("Error when Parsing DLC.XML\n"); }; 335 336}; 337 338 339#endif