aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/PS3/XML/xmlFilesCallback.h
blob: b6c1bcf0446a0d58ba847f0aad387e8cf6287b93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
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