the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
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 WCHAR wUID[64] = L"";
198 WCHAR wName[64] = L"";
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,10);
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 <= 64)
236 {
237 ZeroMemory(wUID,sizeof(WCHAR)*64);
238 wcsncpy_s( wUID, pAttributes[i].strValue, pAttributes[i].ValueLen);
239 }
240 }
241 else if (_wcsicmp(wAttName,L"Name")==0)
242 {
243 if (pAttributes[i].ValueLen <= 64)
244 {
245 ZeroMemory(wName,sizeof(WCHAR)*64);
246 wcsncpy_s( wName, pAttributes[i].strValue, pAttributes[i].ValueLen);
247 }
248 }
249 else if (_wcsicmp(wAttName,L"FirstSkin")==0)
250 {
251 if (pAttributes[i].ValueLen <= 32)
252 {
253 wcsncpy_s( wFirstSkin, pAttributes[i].strValue, pAttributes[i].ValueLen);
254 }
255 }
256 else if (_wcsicmp(wAttName,L"Type")==0)
257 {
258 if (pAttributes[i].ValueLen <= 32)
259 {
260 wcsncpy_s( wType, pAttributes[i].strValue, pAttributes[i].ValueLen);
261 }
262 }
263 else if(_wcsicmp(wAttName,L"Config")==0)
264 {
265 if (pAttributes[i].ValueLen <= 32)
266 {
267 wcsncpy_s( wConfig, pAttributes[i].strValue, pAttributes[i].ValueLen);
268
269#ifdef _XBOX
270 iConfig=_wtoi(wConfig);
271#else
272 iConfig=wcstol(wConfig, NULL, 10);
273#endif
274 }
275 }
276 else if (_wcsicmp(wAttName,L"DataFile")==0)
277 {
278 if (pAttributes[i].ValueLen <= 32)
279 {
280 wcsncpy_s( wDataFile, pAttributes[i].strValue, pAttributes[i].ValueLen);
281 }
282 }
283
284 }
285
286 // if the xuid hasn't been defined, then we can't use the data
287 if(wUID[0]!=0)
288 {
289#ifdef _DEBUG
290 wprintf(L"Type - %ls, Name - %ls, ",wType, wNameBanner);
291#endif
292
293 eDLCContentType eDLCType=e_DLC_NotDefined;
294 if(wType[0]!=0)
295 {
296 if(wcscmp(wType,L"Skin")==0)
297 {
298 eDLCType=e_DLC_SkinPack;
299 }
300 else if(wcscmp(wType,L"MashUpPack")==0)
301 {
302 eDLCType=e_DLC_MashupPacks;
303 }
304 else if(wcscmp(wType,L"TexturePack")==0)
305 {
306 eDLCType=e_DLC_TexturePacks;
307 }
308 }
309 return CConsoleMinecraftApp::RegisterDLCData(eDLCType, wNameBanner , wUID, wName, wFirstSkin, iConfig, uiSortIndex );
310 }
311 else
312 {
313 return S_FALSE;
314 }
315 }
316 else
317 {
318 return S_FALSE;
319 }
320 };
321
322 virtual HRESULT ElementContent( CONST WCHAR *strData, UINT DataLen, BOOL More ) { return S_OK; };
323
324 virtual HRESULT ElementEnd( CONST WCHAR *strName, UINT NameLen ){ return S_OK; };
325
326 virtual HRESULT CDATABegin( ) { return S_OK; };
327
328 virtual HRESULT CDATAData( CONST WCHAR *strCDATA, UINT CDATALen, BOOL bMore ){ return S_OK; };
329
330 virtual HRESULT CDATAEnd( ){ return S_OK; };
331
332 virtual VOID Error( HRESULT hError, CONST CHAR *strMessage ) { app.DebugPrintf("Error when Parsing DLC.XML\n"); };
333
334};
335
336
337#endif