the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "StatsCounter.h"
3#include "..\Minecraft.World\Stat.h"
4#include "..\Minecraft.World\Stats.h"
5#include "..\Minecraft.World\Achievement.h"
6#include "..\Minecraft.World\Achievements.h"
7#include "..\Minecraft.Client\LocalPlayer.h"
8
9#include "..\Minecraft.World\net.minecraft.world.level.tile.h"
10#include "..\Minecraft.World\net.minecraft.world.item.h"
11
12#include "..\Minecraft.Client\Common\Leaderboards\LeaderboardManager.h"
13
14Stat** StatsCounter::LARGE_STATS[] = {
15 &Stats::walkOneM,
16 &Stats::swimOneM,
17 &Stats::fallOneM,
18 &Stats::climbOneM,
19 &Stats::minecartOneM,
20 &Stats::boatOneM,
21 &Stats::pigOneM,
22 &Stats::timePlayed
23};
24
25unordered_map<Stat*, int> StatsCounter::statBoards;
26
27StatsCounter::StatsCounter()
28{
29 requiresSave = false;
30 saveCounter = 0;
31 modifiedBoards = 0;
32 flushCounter = 0;
33}
34
35void StatsCounter::award(Stat* stat, unsigned int difficulty, unsigned int count)
36{
37#ifndef _DURANGO
38 if( stat->isAchievement() )
39 difficulty = 0;
40
41 StatsMap::iterator val = stats.find(stat);
42 if( val == stats.end() )
43 {
44 StatContainer newVal;
45 newVal.stats[difficulty] = count;
46 stats.insert( make_pair(stat, newVal) );
47 }
48 else
49 {
50 val->second.stats[difficulty] += count;
51
52 if (stat != GenericStats::timePlayed())
53 app.DebugPrintf("");
54
55 //If value has wrapped, cap it to UINT_MAX
56 if( val->second.stats[difficulty] < (val->second.stats[difficulty]-count) )
57 val->second.stats[difficulty] = UINT_MAX;
58
59 //If value is larger than USHRT_MAX and is not designated as large, cap it to USHRT_MAX
60 if( val->second.stats[difficulty] > USHRT_MAX && !isLargeStat(stat) )
61 val->second.stats[difficulty] = USHRT_MAX;
62 }
63
64 requiresSave = true;
65
66 //If this stat is on a leaderboard, mark that leaderboard as needing updated
67 unordered_map<Stat*, int>::iterator leaderboardEntry = statBoards.find(stat);
68 if( leaderboardEntry != statBoards.end() )
69 {
70 app.DebugPrintf("[StatsCounter] award(): %X\n", leaderboardEntry->second << difficulty);
71 modifiedBoards |= (leaderboardEntry->second << difficulty);
72 if( flushCounter == 0 )
73 flushCounter = FLUSH_DELAY;
74 }
75#endif
76}
77
78bool StatsCounter::hasTaken(Achievement *ach)
79{
80 return stats.find(ach) != stats.end();
81}
82
83bool StatsCounter::canTake(Achievement *ach)
84{
85 //4J Gordon: Remove achievement dependencies, always able to take
86 return true;
87}
88
89unsigned int StatsCounter::getValue(Stat *stat, unsigned int difficulty)
90{
91 StatsMap::iterator val = stats.find(stat);
92 if( val != stats.end() )
93 return val->second.stats[difficulty];
94 return 0;
95}
96
97unsigned int StatsCounter::getTotalValue(Stat *stat)
98{
99 StatsMap::iterator val = stats.find(stat);
100 if( val != stats.end() )
101 return val->second.stats[0] + val->second.stats[1] + val->second.stats[2] + val->second.stats[3];
102 return 0;
103}
104
105void StatsCounter::tick(int player)
106{
107 if( saveCounter > 0 )
108 --saveCounter;
109
110 if( requiresSave && saveCounter == 0 )
111 save(player);
112
113 // 4J-JEV, we don't want to write leaderboards in the middle of a game.
114 // EDIT: Yes we do, people were not ending their games properly and not updating scores.
115// #ifndef __PS3__
116 if( flushCounter > 0 )
117 {
118 --flushCounter;
119 if( flushCounter == 0 )
120 flushLeaderboards();
121 }
122// #endif
123}
124
125void StatsCounter::clear()
126{
127 // clear out the stats when someone signs out
128 stats.clear();
129}
130
131void StatsCounter::parse(void* data)
132{
133#ifndef _DURANGO
134 // 4J-PB - If this is the trial game, let's just make sure all the stats are empty
135 // 4J-PB - removing - someone can have the full game, and then remove it and go back to the trial
136// if(!ProfileManager.IsFullVersion())
137// {
138// stats.clear();
139// return;
140// }
141 //Check that we don't already have any stats
142 assert( stats.size() == 0 );
143
144 //Pointer to current position in stat array
145 PBYTE pbData=(PBYTE)data;
146 pbData+=sizeof(GAME_SETTINGS);
147 unsigned short* statData = (unsigned short*)pbData;//data + (STAT_DATA_OFFSET/sizeof(unsigned short));
148
149 //Value being read
150 StatContainer newVal;
151
152 //For each stat
153 vector<Stat *>::iterator end = Stats::all->end();
154 for( vector<Stat *>::iterator iter = Stats::all->begin() ; iter != end ; ++iter )
155 {
156 if( !(*iter)->isAchievement() )
157 {
158 if( !isLargeStat(*iter) )
159 {
160 if( statData[0] != 0 || statData[1] != 0 || statData[2] != 0 || statData[3] != 0 )
161 {
162 newVal.stats[0] = statData[0];
163 newVal.stats[1] = statData[1];
164 newVal.stats[2] = statData[2];
165 newVal.stats[3] = statData[3];
166 stats.insert( make_pair(*iter, newVal) );
167 }
168 statData += 4;
169 }
170 else
171 {
172 unsigned int* largeStatData = (unsigned int*)statData;
173 if( largeStatData[0] != 0 || largeStatData[1] != 0 || largeStatData[2] != 0 || largeStatData[3] != 0 )
174 {
175 newVal.stats[0] = largeStatData[0];
176 newVal.stats[1] = largeStatData[1];
177 newVal.stats[2] = largeStatData[2];
178 newVal.stats[3] = largeStatData[3];
179 stats.insert( make_pair(*iter, newVal) );
180 }
181 largeStatData += 4;
182 statData = (unsigned short*)largeStatData;
183 }
184 }
185 else
186 {
187 if( statData[0] != 0 )
188 {
189 newVal.stats[0] = statData[0];
190 newVal.stats[1] = 0;
191 newVal.stats[2] = 0;
192 newVal.stats[3] = 0;
193 stats.insert( make_pair(*iter, newVal) );
194 }
195 ++statData;
196 }
197 }
198
199 dumpStatsToTTY();
200#endif
201}
202
203void StatsCounter::save(int player, bool force)
204{
205#ifndef _DURANGO
206 // 4J-PB - If this is the trial game, don't save any stats
207 if(!ProfileManager.IsFullVersion())
208 {
209 return;
210 }
211
212 //Check we're going to have enough room to store all possible stats
213 unsigned int uiTotalStatsSize = (Stats::all->size() * 4 * sizeof(unsigned short)) - (Achievements::achievements->size() * 3 * sizeof(unsigned short)) + (LARGE_STATS_COUNT*4*(sizeof(unsigned int)-sizeof(unsigned short)));
214 assert( uiTotalStatsSize <= (CConsoleMinecraftApp::GAME_DEFINED_PROFILE_DATA_BYTES-sizeof(GAME_SETTINGS)) );
215
216 //Retrieve the data pointer from the profile
217#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__ )
218 PBYTE pbData = (PBYTE)StorageManager.GetGameDefinedProfileData(player);
219#else
220 PBYTE pbData = (PBYTE)ProfileManager.GetGameDefinedProfileData(player);
221#endif
222 pbData+=sizeof(GAME_SETTINGS);
223
224 //Pointer to current position in stat array
225 //unsigned short* statData = (unsigned short*)data + (STAT_DATA_OFFSET/sizeof(unsigned short));
226 unsigned short* statData = (unsigned short*)pbData;
227
228 //Reset all the data to 0 (we're going to replace it with the map data)
229 memset(statData, 0, CConsoleMinecraftApp::GAME_DEFINED_PROFILE_DATA_BYTES-sizeof(GAME_SETTINGS));
230
231 //For each stat
232 StatsMap::iterator val;
233 vector<Stat *>::iterator end = Stats::all->end();
234 for( vector<Stat *>::iterator iter = Stats::all->begin() ; iter != end ; ++iter )
235 {
236 //If the stat is in the map write out it's value
237 val = stats.find(*iter);
238 if( !(*iter)->isAchievement() )
239 {
240 if( !isLargeStat(*iter) )
241 {
242 if( val != stats.end() )
243 {
244 statData[0] = val->second.stats[0];
245 statData[1] = val->second.stats[1];
246 statData[2] = val->second.stats[2];
247 statData[3] = val->second.stats[3];
248 }
249 statData += 4;
250 }
251 else
252 {
253 unsigned int* largeStatData = (unsigned int*)statData;
254 if( val != stats.end() )
255 {
256 largeStatData[0] = val->second.stats[0];
257 largeStatData[1] = val->second.stats[1];
258 largeStatData[2] = val->second.stats[2];
259 largeStatData[3] = val->second.stats[3];
260 }
261 largeStatData += 4;
262 statData = (unsigned short*)largeStatData;
263 }
264 }
265 else
266 {
267 if( val != stats.end() )
268 {
269 statData[0] = val->second.stats[0];
270 }
271 ++statData;
272 }
273 }
274
275#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__ )
276 StorageManager.WriteToProfile(player, true, force);
277#else
278 ProfileManager.WriteToProfile(player, true, force);
279#endif
280
281 saveCounter = SAVE_DELAY;
282#endif
283}
284
285#ifdef _XBOX
286void StatsCounter::setLeaderboardProperty(XUSER_PROPERTY* prop, DWORD id, unsigned int value)
287{
288 app.DebugPrintf("Setting property id: %d to value %d\n", id, value);
289 prop->dwPropertyId = id;
290 prop->value.type = XUSER_DATA_TYPE_INT32;
291 prop->value.nData = (int)(value&0x7FFFFFFF); // Just making sure we clamp the unsigned int to the max val for a signed int
292}
293
294void StatsCounter::setLeaderboardRating(XUSER_PROPERTY* prop, LONGLONG value)
295{
296 prop->dwPropertyId = PROPERTY_RATING;
297 prop->value.type = XUSER_DATA_TYPE_INT64;
298 prop->value.i64Data = value;
299}
300#endif
301
302void StatsCounter::flushLeaderboards()
303{
304#ifndef _DURANGO
305 if( LeaderboardManager::Instance()->OpenSession() )
306 {
307 writeStats();
308 LeaderboardManager::Instance()->FlushStats();
309 }
310 else
311 {
312 app.DebugPrintf("Failed to open a session in order to write to leaderboard\n");
313
314 // 4J-JEV: If user was not signed in it would hit this.
315 //assert(false);// && "Failed to open a session in order to write to leaderboard");
316 }
317
318 modifiedBoards = 0;
319#endif
320}
321
322void StatsCounter::saveLeaderboards()
323{
324#ifndef _DURANGO
325 // 4J-PB - If this is the trial game, no writing leaderboards
326 if(!ProfileManager.IsFullVersion())
327 {
328 return;
329 }
330
331 if( LeaderboardManager::Instance()->OpenSession() )
332 {
333 writeStats();
334 LeaderboardManager::Instance()->CloseSession();
335 }
336 else
337 {
338 app.DebugPrintf("Failed to open a session in order to write to leaderboard\n");
339
340 // 4J-JEV: If user was not signed in it would hit this.
341 //assert(false);// && "Failed to open a session in order to write to leaderboard");
342 }
343
344 modifiedBoards = 0;
345#endif
346}
347
348void StatsCounter::writeStats()
349{
350#ifndef _DURANGO
351 // 4J-PB - If this is the trial game, no writing
352 if(!ProfileManager.IsFullVersion())
353 {
354 return;
355 }
356 //unsigned int locale = XGetLocale();
357
358 int viewCount = 0;
359 int iPad = ProfileManager.GetLockedProfile();
360
361#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__)
362 LeaderboardManager::RegisterScore *scores = new LeaderboardManager::RegisterScore[24];
363
364 if( modifiedBoards & LEADERBOARD_KILLS_EASY )
365 {
366 scores[viewCount].m_iPad = iPad;
367
368 app.DebugPrintf("Updating leaderboard view LEADERBOARD_KILLS_EASY\n");
369 scores[viewCount].m_difficulty = 1;
370
371 scores[viewCount].m_commentData.m_statsType = LeaderboardManager::eStatsType_Kills;
372
373 scores[viewCount].m_commentData.m_kills.m_zombie = getValue(Stats::killsZombie, eDifficulty_Easy);
374 scores[viewCount].m_commentData.m_kills.m_skeleton = getValue(Stats::killsSkeleton, eDifficulty_Easy);
375 scores[viewCount].m_commentData.m_kills.m_creeper = getValue(Stats::killsCreeper, eDifficulty_Easy);
376 scores[viewCount].m_commentData.m_kills.m_spider = getValue(Stats::killsSpider, eDifficulty_Easy);
377 scores[viewCount].m_commentData.m_kills.m_spiderJockey = getValue(Stats::killsSpiderJockey, eDifficulty_Easy);
378 //scores[viewCount].m_commentData.m_kills.m_zombiePigman = getValue(Stats::killsZombiePigman, eDifficulty_Easy);
379 scores[viewCount].m_commentData.m_kills.m_zombiePigman = getValue(Stats::killsNetherZombiePigman, eDifficulty_Easy);
380 scores[viewCount].m_commentData.m_kills.m_slime = getValue(Stats::killsSlime, eDifficulty_Easy);
381
382 scores[viewCount].m_score = scores[viewCount].m_commentData.m_kills.m_zombie
383 + scores[viewCount].m_commentData.m_kills.m_skeleton
384 + scores[viewCount].m_commentData.m_kills.m_creeper
385 + scores[viewCount].m_commentData.m_kills.m_spider
386 + scores[viewCount].m_commentData.m_kills.m_spiderJockey
387 // + getValue(Stats::killsZombiePigman, eDifficulty_Easy);
388 + scores[viewCount].m_commentData.m_kills.m_zombiePigman
389 + scores[viewCount].m_commentData.m_kills.m_slime;
390
391 viewCount++;
392 }
393
394 if( modifiedBoards & LEADERBOARD_KILLS_NORMAL )
395 {
396 scores[viewCount].m_iPad = iPad;
397
398 app.DebugPrintf("Updating leaderboard view LEADERBOARD_KILLS_NORMAL\n");
399 scores[viewCount].m_difficulty = 2;
400
401 scores[viewCount].m_commentData.m_statsType = LeaderboardManager::eStatsType_Kills;
402
403 scores[viewCount].m_commentData.m_kills.m_zombie = getValue(Stats::killsZombie, eDifficulty_Normal);
404 scores[viewCount].m_commentData.m_kills.m_skeleton = getValue(Stats::killsSkeleton, eDifficulty_Normal);
405 scores[viewCount].m_commentData.m_kills.m_creeper = getValue(Stats::killsCreeper, eDifficulty_Normal);
406 scores[viewCount].m_commentData.m_kills.m_spider = getValue(Stats::killsSpider, eDifficulty_Normal);
407 scores[viewCount].m_commentData.m_kills.m_spiderJockey = getValue(Stats::killsSpiderJockey, eDifficulty_Normal);
408 //scores[viewCount].m_commentData.m_kills.m_zombiePigman = getValue(Stats::killsZombiePigman, eDifficulty_Normal);
409 scores[viewCount].m_commentData.m_kills.m_zombiePigman = getValue(Stats::killsNetherZombiePigman, eDifficulty_Normal);
410 scores[viewCount].m_commentData.m_kills.m_slime = getValue(Stats::killsSlime, eDifficulty_Normal);
411
412 scores[viewCount].m_score = scores[viewCount].m_commentData.m_kills.m_zombie
413 + scores[viewCount].m_commentData.m_kills.m_skeleton
414 + scores[viewCount].m_commentData.m_kills.m_creeper
415 + scores[viewCount].m_commentData.m_kills.m_spider
416 + scores[viewCount].m_commentData.m_kills.m_spiderJockey
417 // + getValue(Stats::killsZombiePigman, eDifficulty_Normal);
418 + scores[viewCount].m_commentData.m_kills.m_zombiePigman
419 + scores[viewCount].m_commentData.m_kills.m_slime;
420
421 viewCount++;
422 }
423
424 if( modifiedBoards & LEADERBOARD_KILLS_HARD )
425 {
426 scores[viewCount].m_iPad = iPad;
427
428 app.DebugPrintf("Updating leaderboard view LEADERBOARD_KILLS_HARD\n");
429 scores[viewCount].m_difficulty = 3;
430
431 scores[viewCount].m_commentData.m_statsType = LeaderboardManager::eStatsType_Kills;
432
433 scores[viewCount].m_commentData.m_kills.m_zombie = getValue(Stats::killsZombie, eDifficulty_Hard);
434 scores[viewCount].m_commentData.m_kills.m_skeleton = getValue(Stats::killsSkeleton, eDifficulty_Hard);
435 scores[viewCount].m_commentData.m_kills.m_creeper = getValue(Stats::killsCreeper, eDifficulty_Hard);
436 scores[viewCount].m_commentData.m_kills.m_spider = getValue(Stats::killsSpider, eDifficulty_Hard);
437 scores[viewCount].m_commentData.m_kills.m_spiderJockey = getValue(Stats::killsSpiderJockey, eDifficulty_Hard);
438 //scores[viewCount].m_commentData.m_kills.m_zombiePigman = getValue(Stats::killsZombiePigman, eDifficulty_Hard);
439 scores[viewCount].m_commentData.m_kills.m_zombiePigman = getValue(Stats::killsNetherZombiePigman, eDifficulty_Hard);
440 scores[viewCount].m_commentData.m_kills.m_slime = getValue(Stats::killsSlime, eDifficulty_Hard);
441
442 scores[viewCount].m_score = scores[viewCount].m_commentData.m_kills.m_zombie
443 + scores[viewCount].m_commentData.m_kills.m_skeleton
444 + scores[viewCount].m_commentData.m_kills.m_creeper
445 + scores[viewCount].m_commentData.m_kills.m_spider
446 + scores[viewCount].m_commentData.m_kills.m_spiderJockey
447 // + getValue(Stats::killsZombiePigman, eDifficulty_Hard);
448 + scores[viewCount].m_commentData.m_kills.m_zombiePigman
449 + scores[viewCount].m_commentData.m_kills.m_slime;
450
451 viewCount++;
452 }
453
454 if( modifiedBoards & LEADERBOARD_MININGBLOCKS_PEACEFUL )
455 {
456 scores[viewCount].m_iPad = iPad;
457
458 app.DebugPrintf("Updating leaderboard view LEADERBOARD_MININGBLOCKS_PEACEFUL\n");
459 scores[viewCount].m_difficulty = 0;
460
461 scores[viewCount].m_commentData.m_statsType = LeaderboardManager::eStatsType_Mining;
462
463 scores[viewCount].m_commentData.m_mining.m_dirt = getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Peaceful);
464 scores[viewCount].m_commentData.m_mining.m_cobblestone = getValue(Stats::blocksMined[Tile::cobblestone->id], eDifficulty_Peaceful);
465 scores[viewCount].m_commentData.m_mining.m_sand = getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Peaceful);
466 scores[viewCount].m_commentData.m_mining.m_stone = getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Peaceful);
467 scores[viewCount].m_commentData.m_mining.m_gravel = getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Peaceful);
468 scores[viewCount].m_commentData.m_mining.m_clay = getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Peaceful);
469 scores[viewCount].m_commentData.m_mining.m_obsidian = getValue(Stats::blocksMined[Tile::obsidian->id], eDifficulty_Peaceful);
470
471 scores[viewCount].m_score = scores[viewCount].m_commentData.m_mining.m_dirt
472 + scores[viewCount].m_commentData.m_mining.m_cobblestone
473 + scores[viewCount].m_commentData.m_mining.m_sand
474 + scores[viewCount].m_commentData.m_mining.m_stone
475 + scores[viewCount].m_commentData.m_mining.m_gravel
476 + scores[viewCount].m_commentData.m_mining.m_clay
477 + scores[viewCount].m_commentData.m_mining.m_obsidian;
478
479 viewCount++;
480 }
481
482 if( modifiedBoards & LEADERBOARD_MININGBLOCKS_EASY )
483 {
484 scores[viewCount].m_iPad = iPad;
485
486 app.DebugPrintf("Updating leaderboard view LEADERBOARD_MININGBLOCKS_EASY\n");
487 scores[viewCount].m_difficulty = 1;
488
489 scores[viewCount].m_commentData.m_statsType = LeaderboardManager::eStatsType_Mining;
490
491 scores[viewCount].m_commentData.m_mining.m_dirt = getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Easy);
492 scores[viewCount].m_commentData.m_mining.m_cobblestone = getValue(Stats::blocksMined[Tile::cobblestone->id], eDifficulty_Easy);
493 scores[viewCount].m_commentData.m_mining.m_sand = getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Easy);
494 scores[viewCount].m_commentData.m_mining.m_stone = getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Easy);
495 scores[viewCount].m_commentData.m_mining.m_gravel = getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Easy);
496 scores[viewCount].m_commentData.m_mining.m_clay = getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Easy);
497 scores[viewCount].m_commentData.m_mining.m_obsidian = getValue(Stats::blocksMined[Tile::obsidian->id], eDifficulty_Easy);
498
499 scores[viewCount].m_score = scores[viewCount].m_commentData.m_mining.m_dirt
500 + scores[viewCount].m_commentData.m_mining.m_cobblestone
501 + scores[viewCount].m_commentData.m_mining.m_sand
502 + scores[viewCount].m_commentData.m_mining.m_stone
503 + scores[viewCount].m_commentData.m_mining.m_gravel
504 + scores[viewCount].m_commentData.m_mining.m_clay
505 + scores[viewCount].m_commentData.m_mining.m_obsidian;
506
507 viewCount++;
508 }
509
510 if( modifiedBoards & LEADERBOARD_MININGBLOCKS_NORMAL )
511 {
512 scores[viewCount].m_iPad = iPad;
513
514 app.DebugPrintf("Updating leaderboard view LEADERBOARD_MININGBLOCKS_NORMAL\n");
515 scores[viewCount].m_difficulty = 2;
516
517 scores[viewCount].m_commentData.m_statsType = LeaderboardManager::eStatsType_Mining;
518
519 scores[viewCount].m_commentData.m_mining.m_dirt = getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Normal);
520 scores[viewCount].m_commentData.m_mining.m_cobblestone = getValue(Stats::blocksMined[Tile::cobblestone->id], eDifficulty_Normal);
521 scores[viewCount].m_commentData.m_mining.m_sand = getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Normal);
522 scores[viewCount].m_commentData.m_mining.m_stone = getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Normal);
523 scores[viewCount].m_commentData.m_mining.m_gravel = getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Normal);
524 scores[viewCount].m_commentData.m_mining.m_clay = getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Normal);
525 scores[viewCount].m_commentData.m_mining.m_obsidian = getValue(Stats::blocksMined[Tile::obsidian->id], eDifficulty_Normal);
526
527 scores[viewCount].m_score = scores[viewCount].m_commentData.m_mining.m_dirt
528 + scores[viewCount].m_commentData.m_mining.m_cobblestone
529 + scores[viewCount].m_commentData.m_mining.m_sand
530 + scores[viewCount].m_commentData.m_mining.m_stone
531 + scores[viewCount].m_commentData.m_mining.m_gravel
532 + scores[viewCount].m_commentData.m_mining.m_clay
533 + scores[viewCount].m_commentData.m_mining.m_obsidian;
534
535 viewCount++;
536 }
537
538 if( modifiedBoards & LEADERBOARD_MININGBLOCKS_HARD )
539 {
540 scores[viewCount].m_iPad = iPad;
541
542 app.DebugPrintf("Updating leaderboard view LEADERBOARD_MININGBLOCKS_HARD\n");
543 scores[viewCount].m_difficulty = 3;
544
545 scores[viewCount].m_commentData.m_statsType = LeaderboardManager::eStatsType_Mining;
546
547 scores[viewCount].m_commentData.m_mining.m_dirt = getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Hard);
548 scores[viewCount].m_commentData.m_mining.m_cobblestone = getValue(Stats::blocksMined[Tile::cobblestone->id], eDifficulty_Hard);
549 scores[viewCount].m_commentData.m_mining.m_sand = getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Hard);
550 scores[viewCount].m_commentData.m_mining.m_stone = getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Hard);
551 scores[viewCount].m_commentData.m_mining.m_gravel = getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Hard);
552 scores[viewCount].m_commentData.m_mining.m_clay = getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Hard);
553 scores[viewCount].m_commentData.m_mining.m_obsidian = getValue(Stats::blocksMined[Tile::obsidian->id], eDifficulty_Hard);
554
555 scores[viewCount].m_score = scores[viewCount].m_commentData.m_mining.m_dirt
556 + scores[viewCount].m_commentData.m_mining.m_cobblestone
557 + scores[viewCount].m_commentData.m_mining.m_sand
558 + scores[viewCount].m_commentData.m_mining.m_stone
559 + scores[viewCount].m_commentData.m_mining.m_gravel
560 + scores[viewCount].m_commentData.m_mining.m_clay
561 + scores[viewCount].m_commentData.m_mining.m_obsidian;
562
563 viewCount++;
564 }
565
566 if( modifiedBoards & LEADERBOARD_FARMING_PEACEFUL )
567 {
568 scores[viewCount].m_iPad = iPad;
569
570 app.DebugPrintf("Updating leaderboard view LEADERBOARD_FARMING_PEACEFUL\n");
571 scores[viewCount].m_difficulty = 0;
572
573 scores[viewCount].m_commentData.m_statsType = LeaderboardManager::eStatsType_Farming;
574
575 scores[viewCount].m_commentData.m_farming.m_eggs = getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Peaceful);
576 scores[viewCount].m_commentData.m_farming.m_wheat = getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Peaceful);
577 scores[viewCount].m_commentData.m_farming.m_mushroom = getValue(Stats::blocksMined[Tile::mushroom_brown_Id], eDifficulty_Peaceful);
578 scores[viewCount].m_commentData.m_farming.m_sugarcane = getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Peaceful);
579 scores[viewCount].m_commentData.m_farming.m_milk = getValue(Stats::cowsMilked, eDifficulty_Peaceful);
580 scores[viewCount].m_commentData.m_farming.m_pumpkin = getValue(Stats::itemsCollected[Tile::pumpkin->id], eDifficulty_Peaceful);
581
582 scores[viewCount].m_score = scores[viewCount].m_commentData.m_farming.m_eggs
583 + scores[viewCount].m_commentData.m_farming.m_wheat
584 + scores[viewCount].m_commentData.m_farming.m_mushroom
585 + scores[viewCount].m_commentData.m_farming.m_sugarcane
586 + scores[viewCount].m_commentData.m_farming.m_milk
587 + scores[viewCount].m_commentData.m_farming.m_pumpkin;
588
589 viewCount++;
590 }
591
592 if( modifiedBoards & LEADERBOARD_FARMING_EASY )
593 {
594 scores[viewCount].m_iPad = iPad;
595
596 app.DebugPrintf("Updating leaderboard view LEADERBOARD_FARMING_EASY\n");
597 scores[viewCount].m_difficulty = 1;
598
599 scores[viewCount].m_commentData.m_statsType = LeaderboardManager::eStatsType_Farming;
600
601 scores[viewCount].m_commentData.m_farming.m_eggs = getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Easy);
602 scores[viewCount].m_commentData.m_farming.m_wheat = getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Easy);
603 scores[viewCount].m_commentData.m_farming.m_mushroom = getValue(Stats::blocksMined[Tile::mushroom_brown_Id], eDifficulty_Easy);
604 scores[viewCount].m_commentData.m_farming.m_sugarcane = getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Easy);
605 scores[viewCount].m_commentData.m_farming.m_milk = getValue(Stats::cowsMilked, eDifficulty_Easy);
606 scores[viewCount].m_commentData.m_farming.m_pumpkin = getValue(Stats::itemsCollected[Tile::pumpkin->id], eDifficulty_Easy);
607
608 scores[viewCount].m_score = scores[viewCount].m_commentData.m_farming.m_eggs
609 + scores[viewCount].m_commentData.m_farming.m_wheat
610 + scores[viewCount].m_commentData.m_farming.m_mushroom
611 + scores[viewCount].m_commentData.m_farming.m_sugarcane
612 + scores[viewCount].m_commentData.m_farming.m_milk
613 + scores[viewCount].m_commentData.m_farming.m_pumpkin;
614
615 viewCount++;
616 }
617
618 if( modifiedBoards & LEADERBOARD_FARMING_NORMAL )
619 {
620 scores[viewCount].m_iPad = iPad;
621
622 app.DebugPrintf("Updating leaderboard view LEADERBOARD_FARMING_NORMAL\n");
623 scores[viewCount].m_difficulty = 2;
624
625 scores[viewCount].m_commentData.m_statsType = LeaderboardManager::eStatsType_Farming;
626
627 scores[viewCount].m_commentData.m_farming.m_eggs = getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Normal);
628 scores[viewCount].m_commentData.m_farming.m_wheat = getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Normal);
629 scores[viewCount].m_commentData.m_farming.m_mushroom = getValue(Stats::blocksMined[Tile::mushroom_brown_Id], eDifficulty_Normal);
630 scores[viewCount].m_commentData.m_farming.m_sugarcane = getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Normal);
631 scores[viewCount].m_commentData.m_farming.m_milk = getValue(Stats::cowsMilked, eDifficulty_Normal);
632 scores[viewCount].m_commentData.m_farming.m_pumpkin = getValue(Stats::itemsCollected[Tile::pumpkin->id], eDifficulty_Normal);
633
634 scores[viewCount].m_score = scores[viewCount].m_commentData.m_farming.m_eggs
635 + scores[viewCount].m_commentData.m_farming.m_wheat
636 + scores[viewCount].m_commentData.m_farming.m_mushroom
637 + scores[viewCount].m_commentData.m_farming.m_sugarcane
638 + scores[viewCount].m_commentData.m_farming.m_milk
639 + scores[viewCount].m_commentData.m_farming.m_pumpkin;
640
641 viewCount++;
642 }
643
644 if( modifiedBoards & LEADERBOARD_FARMING_HARD )
645 {
646 scores[viewCount].m_iPad = iPad;
647
648 app.DebugPrintf("Updating leaderboard view LEADERBOARD_FARMING_HARD\n");
649 scores[viewCount].m_difficulty = 3;
650
651 scores[viewCount].m_commentData.m_statsType = LeaderboardManager::eStatsType_Farming;
652
653 scores[viewCount].m_commentData.m_farming.m_eggs = getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Hard);
654 scores[viewCount].m_commentData.m_farming.m_wheat = getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Hard);
655 scores[viewCount].m_commentData.m_farming.m_mushroom = getValue(Stats::blocksMined[Tile::mushroom_brown_Id], eDifficulty_Hard);
656 scores[viewCount].m_commentData.m_farming.m_sugarcane = getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Hard);
657 scores[viewCount].m_commentData.m_farming.m_milk = getValue(Stats::cowsMilked, eDifficulty_Hard);
658 scores[viewCount].m_commentData.m_farming.m_pumpkin = getValue(Stats::itemsCollected[Tile::pumpkin->id], eDifficulty_Hard);
659
660 scores[viewCount].m_score = scores[viewCount].m_commentData.m_farming.m_eggs
661 + scores[viewCount].m_commentData.m_farming.m_wheat
662 + scores[viewCount].m_commentData.m_farming.m_mushroom
663 + scores[viewCount].m_commentData.m_farming.m_sugarcane
664 + scores[viewCount].m_commentData.m_farming.m_milk
665 + scores[viewCount].m_commentData.m_farming.m_pumpkin;
666
667 viewCount++;
668 }
669
670 if( modifiedBoards & LEADERBOARD_TRAVELLING_PEACEFUL )
671 {
672 scores[viewCount].m_iPad = iPad;
673
674 app.DebugPrintf("Updating leaderboard view LEADERBOARD_TRAVELLING_PEACEFUL\n");
675 scores[viewCount].m_difficulty = 0;
676
677 scores[viewCount].m_commentData.m_statsType = LeaderboardManager::eStatsType_Travelling;
678
679 scores[viewCount].m_commentData.m_travelling.m_walked = getValue(Stats::walkOneM, eDifficulty_Peaceful);
680 scores[viewCount].m_commentData.m_travelling.m_fallen = getValue(Stats::fallOneM, eDifficulty_Peaceful);
681 scores[viewCount].m_commentData.m_travelling.m_minecart = getValue(Stats::minecartOneM, eDifficulty_Peaceful);
682 scores[viewCount].m_commentData.m_travelling.m_boat = getValue(Stats::boatOneM, eDifficulty_Peaceful);
683
684 scores[viewCount].m_score = scores[viewCount].m_commentData.m_travelling.m_walked
685 + scores[viewCount].m_commentData.m_travelling.m_fallen
686 + scores[viewCount].m_commentData.m_travelling.m_minecart
687 + scores[viewCount].m_commentData.m_travelling.m_boat;
688
689 viewCount++;
690 }
691
692 if( modifiedBoards & LEADERBOARD_TRAVELLING_EASY )
693 {
694 scores[viewCount].m_iPad = iPad;
695
696 app.DebugPrintf("Updating leaderboard view LEADERBOARD_TRAVELLING_EASY\n");
697 scores[viewCount].m_difficulty = 1;
698
699 scores[viewCount].m_commentData.m_statsType = LeaderboardManager::eStatsType_Travelling;
700
701 scores[viewCount].m_commentData.m_travelling.m_walked = getValue(Stats::walkOneM, eDifficulty_Easy);
702 scores[viewCount].m_commentData.m_travelling.m_fallen = getValue(Stats::fallOneM, eDifficulty_Easy);
703 scores[viewCount].m_commentData.m_travelling.m_minecart = getValue(Stats::minecartOneM, eDifficulty_Easy);
704 scores[viewCount].m_commentData.m_travelling.m_boat = getValue(Stats::boatOneM, eDifficulty_Easy);
705
706 scores[viewCount].m_score = scores[viewCount].m_commentData.m_travelling.m_walked
707 + scores[viewCount].m_commentData.m_travelling.m_fallen
708 + scores[viewCount].m_commentData.m_travelling.m_minecart
709 + scores[viewCount].m_commentData.m_travelling.m_boat;
710
711 viewCount++;
712 }
713
714 if( modifiedBoards & LEADERBOARD_TRAVELLING_NORMAL)
715 {
716 scores[viewCount].m_iPad = iPad;
717
718 app.DebugPrintf("Updating leaderboard view LEADERBOARD_TRAVELLING_NORMAL\n");
719 scores[viewCount].m_difficulty = 2;
720
721 scores[viewCount].m_commentData.m_statsType = LeaderboardManager::eStatsType_Travelling;
722
723 scores[viewCount].m_commentData.m_travelling.m_walked = getValue(Stats::walkOneM, eDifficulty_Normal);
724 scores[viewCount].m_commentData.m_travelling.m_fallen = getValue(Stats::fallOneM, eDifficulty_Normal);
725 scores[viewCount].m_commentData.m_travelling.m_minecart = getValue(Stats::minecartOneM, eDifficulty_Normal);
726 scores[viewCount].m_commentData.m_travelling.m_boat = getValue(Stats::boatOneM, eDifficulty_Normal);
727
728 scores[viewCount].m_score = scores[viewCount].m_commentData.m_travelling.m_walked
729 + scores[viewCount].m_commentData.m_travelling.m_fallen
730 + scores[viewCount].m_commentData.m_travelling.m_minecart
731 + scores[viewCount].m_commentData.m_travelling.m_boat;
732
733 viewCount++;
734 }
735
736 if( modifiedBoards & LEADERBOARD_TRAVELLING_HARD )
737 {
738 scores[viewCount].m_iPad = iPad;
739
740 app.DebugPrintf("Updating leaderboard view LEADERBOARD_TRAVELLING_HARD\n");
741 scores[viewCount].m_difficulty = 3;
742
743 scores[viewCount].m_commentData.m_statsType = LeaderboardManager::eStatsType_Travelling;
744
745 scores[viewCount].m_commentData.m_travelling.m_walked = getValue(Stats::walkOneM, eDifficulty_Hard);
746 scores[viewCount].m_commentData.m_travelling.m_fallen = getValue(Stats::fallOneM, eDifficulty_Hard);
747 scores[viewCount].m_commentData.m_travelling.m_minecart = getValue(Stats::minecartOneM, eDifficulty_Hard);
748 scores[viewCount].m_commentData.m_travelling.m_boat = getValue(Stats::boatOneM, eDifficulty_Hard);
749
750 scores[viewCount].m_score = scores[viewCount].m_commentData.m_travelling.m_walked
751 + scores[viewCount].m_commentData.m_travelling.m_fallen
752 + scores[viewCount].m_commentData.m_travelling.m_minecart
753 + scores[viewCount].m_commentData.m_travelling.m_boat;
754
755 viewCount++;
756 }
757
758 if( modifiedBoards & (LEADERBOARD_TRAVELLING_PEACEFUL | LEADERBOARD_TRAVELLING_EASY | LEADERBOARD_TRAVELLING_NORMAL | LEADERBOARD_TRAVELLING_HARD) )
759 {
760 app.DebugPrintf("Updating leaderboard view LEADERBOARD_TRAVELLING_PEACEFUL | LEADERBOARD_TRAVELLING_EASY | LEADERBOARD_TRAVELLING_NORMAL | LEADERBOARD_TRAVELLING_HARD\n");
761
762 //viewCount++;
763 }
764
765 if( viewCount > 0 )
766 {
767 if( !LeaderboardManager::Instance()->WriteStats(viewCount, scores) )
768 {
769 app.DebugPrintf("Failed to write to leaderboard\n");
770 assert(false);// && "Failed to write to leaderboard");
771 //printf("Failed to write to leaderboard");
772 }
773 else
774 {
775 app.DebugPrintf("Successfully wrote %d leadeboard views\n", viewCount);
776 }
777 }
778 else
779 {
780 delete [] scores;
781 }
782
783#elif defined _XBOX
784
785 LONGLONG rating;
786
787 XSESSION_VIEW_PROPERTIES views[24];
788
789 XUSER_PROPERTY killsEasyProperties[ LeaderboardManager::eProperty_Kills_Max];
790 XUSER_PROPERTY killsNormalProperties[ LeaderboardManager::eProperty_Kills_Max];
791 XUSER_PROPERTY killsHardProperties[ LeaderboardManager::eProperty_Kills_Max];
792 XUSER_PROPERTY miningBlocksPeacefulProperties[ LeaderboardManager::eProperty_Mining_Max];
793 XUSER_PROPERTY miningBlocksEasyProperties[ LeaderboardManager::eProperty_Mining_Max];
794 XUSER_PROPERTY miningBlocksNormalProperties[ LeaderboardManager::eProperty_Mining_Max];
795 XUSER_PROPERTY miningBlocksHardProperties[ LeaderboardManager::eProperty_Mining_Max];
796 XUSER_PROPERTY farmingPeacefulProperties[ LeaderboardManager::eProperty_Farming_Max];
797 XUSER_PROPERTY farmingEasyProperties[ LeaderboardManager::eProperty_Farming_Max];
798 XUSER_PROPERTY farmingNormalProperties[ LeaderboardManager::eProperty_Farming_Max];
799 XUSER_PROPERTY farmingHardProperties[ LeaderboardManager::eProperty_Farming_Max];
800 XUSER_PROPERTY travellingPeacefulProperties[ LeaderboardManager::eProperty_Travelling_Max];
801 XUSER_PROPERTY travellingEasyProperties[ LeaderboardManager::eProperty_Travelling_Max];
802 XUSER_PROPERTY travellingNormalProperties[ LeaderboardManager::eProperty_Travelling_Max];
803 XUSER_PROPERTY travellingHardProperties[ LeaderboardManager::eProperty_Travelling_Max];
804 XUSER_PROPERTY travellingProperties[1]; // arcade leaderboard
805
806 if( modifiedBoards & LEADERBOARD_KILLS_EASY )
807 {
808 app.DebugPrintf("Updating leaderboard view LEADERBOARD_KILLS_EASY\n");
809 views[viewCount].dwViewId = STATS_VIEW_KILLS_EASY;
810 views[viewCount].dwNumProperties = LeaderboardManager::eProperty_Kills_Max;
811 views[viewCount].pProperties = killsEasyProperties;
812
813 rating =
814 getValue(Stats::killsZombie, eDifficulty_Easy) +
815 getValue(Stats::killsSkeleton, eDifficulty_Easy) +
816 getValue(Stats::killsCreeper, eDifficulty_Easy) +
817 getValue(Stats::killsSpider, eDifficulty_Easy) +
818 getValue(Stats::killsSpiderJockey, eDifficulty_Easy) +
819 getValue(Stats::killsZombiePigman, eDifficulty_Easy) +
820 getValue(Stats::killsNetherZombiePigman, eDifficulty_Easy) +
821 getValue(Stats::killsSlime, eDifficulty_Easy);
822
823 setLeaderboardProperty( &killsEasyProperties[LeaderboardManager::eProperty_Kills_Zombie ], PROPERTY_KILLS_ZOMBIE, getValue(Stats::killsZombie, eDifficulty_Easy) );
824 setLeaderboardProperty( &killsEasyProperties[LeaderboardManager::eProperty_Kills_Skeleton ], PROPERTY_KILLS_SKELETON, getValue(Stats::killsSkeleton, eDifficulty_Easy) );
825 setLeaderboardProperty( &killsEasyProperties[LeaderboardManager::eProperty_Kills_Creeper ], PROPERTY_KILLS_CREEPER, getValue(Stats::killsCreeper, eDifficulty_Easy) );
826 setLeaderboardProperty( &killsEasyProperties[LeaderboardManager::eProperty_Kills_Spider ], PROPERTY_KILLS_SPIDER, getValue(Stats::killsSpider, eDifficulty_Easy) );
827 setLeaderboardProperty( &killsEasyProperties[LeaderboardManager::eProperty_Kills_SpiderJockey ], PROPERTY_KILLS_SPIDERJOCKEY, getValue(Stats::killsSpiderJockey, eDifficulty_Easy) );
828 // 4J-PB - this could overflow
829 //setLeaderboardProperty( &killsEasyProperties[LeaderboardManager::eProperty_Kills_ZombiePigman ], PROPERTY_KILLS_ZOMBIEPIGMAN, getValue(Stats::killsZombiePigman, eDifficulty_Easy) + getValue(Stats::killsNetherZombiePigman, eDifficulty_Easy) );
830 ULONGLONG ulTemp=getValue(Stats::killsZombiePigman, eDifficulty_Easy) + getValue(Stats::killsNetherZombiePigman, eDifficulty_Easy);
831 setLeaderboardProperty( &killsEasyProperties[LeaderboardManager::eProperty_Kills_ZombiePigman ], PROPERTY_KILLS_ZOMBIEPIGMAN, (ulTemp>0xFFFFFFFFLL)?0xFFFFFFFF:(unsigned int)ulTemp );
832
833 setLeaderboardProperty( &killsEasyProperties[LeaderboardManager::eProperty_Kills_Slime ], PROPERTY_KILLS_SLIME, getValue(Stats::killsSlime, eDifficulty_Easy) );
834 setLeaderboardRating( &killsEasyProperties[LeaderboardManager::eProperty_Kills_Rating ], rating );
835
836 viewCount++;
837 }
838
839 if( modifiedBoards & LEADERBOARD_KILLS_NORMAL )
840 {
841 app.DebugPrintf("Updating leaderboard view LEADERBOARD_KILLS_NORMAL\n");
842 views[viewCount].dwViewId = STATS_VIEW_KILLS_NORMAL;
843 views[viewCount].dwNumProperties = LeaderboardManager::eProperty_Kills_Max;
844 views[viewCount].pProperties = killsNormalProperties;
845
846 rating =
847 getValue(Stats::killsZombie, eDifficulty_Normal) +
848 getValue(Stats::killsSkeleton, eDifficulty_Normal) +
849 getValue(Stats::killsCreeper, eDifficulty_Normal) +
850 getValue(Stats::killsSpider, eDifficulty_Normal) +
851 getValue(Stats::killsSpiderJockey, eDifficulty_Normal) +
852 getValue(Stats::killsZombiePigman, eDifficulty_Normal) +
853 getValue(Stats::killsNetherZombiePigman, eDifficulty_Normal) +
854 getValue(Stats::killsSlime, eDifficulty_Normal);
855
856 setLeaderboardProperty( &killsNormalProperties[LeaderboardManager::eProperty_Kills_Zombie ], PROPERTY_KILLS_ZOMBIE, getValue(Stats::killsZombie, eDifficulty_Normal) );
857 setLeaderboardProperty( &killsNormalProperties[LeaderboardManager::eProperty_Kills_Skeleton ], PROPERTY_KILLS_SKELETON, getValue(Stats::killsSkeleton, eDifficulty_Normal) );
858 setLeaderboardProperty( &killsNormalProperties[LeaderboardManager::eProperty_Kills_Creeper ], PROPERTY_KILLS_CREEPER, getValue(Stats::killsCreeper, eDifficulty_Normal) );
859 setLeaderboardProperty( &killsNormalProperties[LeaderboardManager::eProperty_Kills_Spider ], PROPERTY_KILLS_SPIDER, getValue(Stats::killsSpider, eDifficulty_Normal) );
860 setLeaderboardProperty( &killsNormalProperties[LeaderboardManager::eProperty_Kills_SpiderJockey ], PROPERTY_KILLS_SPIDERJOCKEY, getValue(Stats::killsSpiderJockey, eDifficulty_Normal) );
861 // 4J-PB - this could overflow
862 ULONGLONG ulTemp=getValue(Stats::killsZombiePigman, eDifficulty_Normal) + getValue(Stats::killsNetherZombiePigman, eDifficulty_Normal);
863 //setLeaderboardProperty( &killsNormalProperties[LeaderboardManager::eProperty_Kills_ZombiePigman ], PROPERTY_KILLS_ZOMBIEPIGMAN, getValue(Stats::killsZombiePigman, eDifficulty_Normal) + getValue(Stats::killsNetherZombiePigman, eDifficulty_Normal) );
864 setLeaderboardProperty( &killsNormalProperties[LeaderboardManager::eProperty_Kills_ZombiePigman ], PROPERTY_KILLS_ZOMBIEPIGMAN, (ulTemp>0xFFFFFFFFLL)?0xFFFFFFFF:(unsigned int)ulTemp );
865
866 setLeaderboardProperty( &killsNormalProperties[LeaderboardManager::eProperty_Kills_Slime ], PROPERTY_KILLS_SLIME, getValue(Stats::killsSlime, eDifficulty_Normal) );
867 setLeaderboardRating( &killsNormalProperties[LeaderboardManager::eProperty_Kills_Rating ], rating );
868
869 viewCount++;
870 }
871
872 if( modifiedBoards & LEADERBOARD_KILLS_HARD )
873 {
874 app.DebugPrintf("Updating leaderboard view LEADERBOARD_KILLS_HARD\n");
875 views[viewCount].dwViewId = STATS_VIEW_KILLS_HARD;
876 views[viewCount].dwNumProperties = LeaderboardManager::eProperty_Kills_Max;
877 views[viewCount].pProperties = killsHardProperties;
878
879 rating =
880 getValue(Stats::killsZombie, eDifficulty_Hard) +
881 getValue(Stats::killsSkeleton, eDifficulty_Hard) +
882 getValue(Stats::killsCreeper, eDifficulty_Hard) +
883 getValue(Stats::killsSpider, eDifficulty_Hard) +
884 getValue(Stats::killsSpiderJockey, eDifficulty_Hard) +
885 getValue(Stats::killsZombiePigman, eDifficulty_Hard) +
886 getValue(Stats::killsNetherZombiePigman, eDifficulty_Hard) +
887 getValue(Stats::killsSlime, eDifficulty_Hard);
888
889 setLeaderboardProperty( &killsHardProperties[LeaderboardManager::eProperty_Kills_Zombie ], PROPERTY_KILLS_ZOMBIE, getValue(Stats::killsZombie, eDifficulty_Hard) );
890 setLeaderboardProperty( &killsHardProperties[LeaderboardManager::eProperty_Kills_Skeleton ], PROPERTY_KILLS_SKELETON, getValue(Stats::killsSkeleton, eDifficulty_Hard) );
891 setLeaderboardProperty( &killsHardProperties[LeaderboardManager::eProperty_Kills_Creeper ], PROPERTY_KILLS_CREEPER, getValue(Stats::killsCreeper, eDifficulty_Hard) );
892 setLeaderboardProperty( &killsHardProperties[LeaderboardManager::eProperty_Kills_Spider ], PROPERTY_KILLS_SPIDER, getValue(Stats::killsSpider, eDifficulty_Hard) );
893 setLeaderboardProperty( &killsHardProperties[LeaderboardManager::eProperty_Kills_SpiderJockey ], PROPERTY_KILLS_SPIDERJOCKEY, getValue(Stats::killsSpiderJockey, eDifficulty_Hard) );
894 // 4J-PB - this could overflow
895 ULONGLONG ulTemp=getValue(Stats::killsZombiePigman, eDifficulty_Hard) + getValue(Stats::killsNetherZombiePigman, eDifficulty_Hard);
896 //setLeaderboardProperty( &killsHardProperties[LeaderboardManager::eProperty_Kills_ZombiePigman ], PROPERTY_KILLS_ZOMBIEPIGMAN, getValue(Stats::killsZombiePigman, eDifficulty_Hard) + getValue(Stats::killsNetherZombiePigman, eDifficulty_Hard) );
897 setLeaderboardProperty( &killsHardProperties[LeaderboardManager::eProperty_Kills_ZombiePigman ], PROPERTY_KILLS_ZOMBIEPIGMAN, (ulTemp>0xFFFFFFFFLL)?0xFFFFFFFF:(unsigned int)ulTemp );
898
899 setLeaderboardProperty( &killsHardProperties[LeaderboardManager::eProperty_Kills_Slime ], PROPERTY_KILLS_SLIME, getValue(Stats::killsSlime, eDifficulty_Hard) );
900 setLeaderboardRating( &killsHardProperties[LeaderboardManager::eProperty_Kills_Rating ], rating );
901
902 viewCount++;
903 }
904
905 if( modifiedBoards & LEADERBOARD_MININGBLOCKS_PEACEFUL )
906 {
907 app.DebugPrintf("Updating leaderboard view LEADERBOARD_MININGBLOCKS_PEACEFUL\n");
908 views[viewCount].dwViewId = STATS_VIEW_MINING_BLOCKS_PEACEFUL;
909 views[viewCount].dwNumProperties = LeaderboardManager::eProperty_Mining_Max;
910 views[viewCount].pProperties = miningBlocksPeacefulProperties;
911
912 rating =
913 getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Peaceful) +
914 getValue(Stats::blocksMined[Tile::cobblestone->id], eDifficulty_Peaceful) +
915 getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Peaceful) +
916 getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Peaceful) +
917 getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Peaceful) +
918 getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Peaceful) +
919 getValue(Stats::blocksMined[Tile::obsidian->id], eDifficulty_Peaceful);
920
921 setLeaderboardProperty( &miningBlocksPeacefulProperties[LeaderboardManager::eProperty_Mining_Dirt ], PROPERTY_MINED_DIRT, getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Peaceful) );
922 setLeaderboardProperty( &miningBlocksPeacefulProperties[LeaderboardManager::eProperty_Mining_Stone ], PROPERTY_MINED_STONE, getValue(Stats::blocksMined[Tile::cobblestone->id], eDifficulty_Peaceful) );
923 setLeaderboardProperty( &miningBlocksPeacefulProperties[LeaderboardManager::eProperty_Mining_Sand ], PROPERTY_MINED_SAND, getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Peaceful) );
924 setLeaderboardProperty( &miningBlocksPeacefulProperties[LeaderboardManager::eProperty_Mining_Cobblestone], PROPERTY_MINED_COBBLESTONE, getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Peaceful) );
925 setLeaderboardProperty( &miningBlocksPeacefulProperties[LeaderboardManager::eProperty_Mining_Gravel ], PROPERTY_MINED_GRAVEL, getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Peaceful) );
926 setLeaderboardProperty( &miningBlocksPeacefulProperties[LeaderboardManager::eProperty_Mining_Clay ], PROPERTY_MINED_CLAY, getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Peaceful) );
927 setLeaderboardProperty( &miningBlocksPeacefulProperties[LeaderboardManager::eProperty_Mining_Obsidian ], PROPERTY_MINED_OBSIDIAN, getValue(Stats::blocksMined[Tile::obsidian->id], eDifficulty_Peaceful) );
928 setLeaderboardRating( &miningBlocksPeacefulProperties[LeaderboardManager::eProperty_Mining_Rating ], rating );
929
930 viewCount++;
931 }
932
933 if( modifiedBoards & LEADERBOARD_MININGBLOCKS_EASY )
934 {
935 app.DebugPrintf("Updating leaderboard view LEADERBOARD_MININGBLOCKS_EASY\n");
936 views[viewCount].dwViewId = STATS_VIEW_MINING_BLOCKS_EASY;
937 views[viewCount].dwNumProperties = LeaderboardManager::eProperty_Mining_Max;
938 views[viewCount].pProperties = miningBlocksEasyProperties;
939
940 rating =
941 getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Easy) +
942 getValue(Stats::blocksMined[Tile::cobblestone->id], eDifficulty_Easy) +
943 getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Easy) +
944 getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Easy) +
945 getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Easy) +
946 getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Easy) +
947 getValue(Stats::blocksMined[Tile::obsidian->id], eDifficulty_Easy);
948
949 setLeaderboardProperty( &miningBlocksEasyProperties[LeaderboardManager::eProperty_Mining_Dirt ], PROPERTY_MINED_DIRT, getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Easy) );
950 setLeaderboardProperty( &miningBlocksEasyProperties[LeaderboardManager::eProperty_Mining_Stone ], PROPERTY_MINED_STONE, getValue(Stats::blocksMined[Tile::cobblestone->id], eDifficulty_Easy) );
951 setLeaderboardProperty( &miningBlocksEasyProperties[LeaderboardManager::eProperty_Mining_Sand ], PROPERTY_MINED_SAND, getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Easy) );
952 setLeaderboardProperty( &miningBlocksEasyProperties[LeaderboardManager::eProperty_Mining_Cobblestone], PROPERTY_MINED_COBBLESTONE, getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Easy) );
953 setLeaderboardProperty( &miningBlocksEasyProperties[LeaderboardManager::eProperty_Mining_Gravel ], PROPERTY_MINED_GRAVEL, getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Easy) );
954 setLeaderboardProperty( &miningBlocksEasyProperties[LeaderboardManager::eProperty_Mining_Clay ], PROPERTY_MINED_CLAY, getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Easy) );
955 setLeaderboardProperty( &miningBlocksEasyProperties[LeaderboardManager::eProperty_Mining_Obsidian ], PROPERTY_MINED_OBSIDIAN, getValue(Stats::blocksMined[Tile::obsidian->id], eDifficulty_Easy) );
956 setLeaderboardRating( &miningBlocksEasyProperties[LeaderboardManager::eProperty_Mining_Rating ], rating );
957
958 viewCount++;
959 }
960
961 if( modifiedBoards & LEADERBOARD_MININGBLOCKS_NORMAL )
962 {
963 app.DebugPrintf("Updating leaderboard view LEADERBOARD_MININGBLOCKS_NORMAL\n");
964 views[viewCount].dwViewId = STATS_VIEW_MINING_BLOCKS_NORMAL;
965 views[viewCount].dwNumProperties = LeaderboardManager::eProperty_Mining_Max;
966 views[viewCount].pProperties = miningBlocksNormalProperties;
967
968 rating =
969 getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Normal) +
970 getValue(Stats::blocksMined[Tile::cobblestone->id], eDifficulty_Normal) +
971 getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Normal) +
972 getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Normal) +
973 getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Normal) +
974 getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Normal) +
975 getValue(Stats::blocksMined[Tile::obsidian->id], eDifficulty_Normal);
976
977 setLeaderboardProperty( &miningBlocksNormalProperties[LeaderboardManager::eProperty_Mining_Dirt ], PROPERTY_MINED_DIRT, getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Normal) );
978 setLeaderboardProperty( &miningBlocksNormalProperties[LeaderboardManager::eProperty_Mining_Stone ], PROPERTY_MINED_STONE, getValue(Stats::blocksMined[Tile::cobblestone->id], eDifficulty_Normal) );
979 setLeaderboardProperty( &miningBlocksNormalProperties[LeaderboardManager::eProperty_Mining_Sand ], PROPERTY_MINED_SAND, getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Normal) );
980 setLeaderboardProperty( &miningBlocksNormalProperties[LeaderboardManager::eProperty_Mining_Cobblestone ], PROPERTY_MINED_COBBLESTONE, getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Normal) );
981 setLeaderboardProperty( &miningBlocksNormalProperties[LeaderboardManager::eProperty_Mining_Gravel ], PROPERTY_MINED_GRAVEL, getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Normal) );
982 setLeaderboardProperty( &miningBlocksNormalProperties[LeaderboardManager::eProperty_Mining_Clay ], PROPERTY_MINED_CLAY, getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Normal) );
983 setLeaderboardProperty( &miningBlocksNormalProperties[LeaderboardManager::eProperty_Mining_Obsidian ], PROPERTY_MINED_OBSIDIAN, getValue(Stats::blocksMined[Tile::obsidian->id], eDifficulty_Normal) );
984 setLeaderboardRating( &miningBlocksNormalProperties[LeaderboardManager::eProperty_Mining_Rating ], rating );
985
986 viewCount++;
987 }
988
989 if( modifiedBoards & LEADERBOARD_MININGBLOCKS_HARD )
990 {
991 app.DebugPrintf("Updating leaderboard view LEADERBOARD_MININGBLOCKS_HARD\n");
992 views[viewCount].dwViewId = STATS_VIEW_MINING_BLOCKS_HARD;
993 views[viewCount].dwNumProperties = LeaderboardManager::eProperty_Mining_Max;
994 views[viewCount].pProperties = miningBlocksHardProperties;
995
996 rating =
997 getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Hard) +
998 getValue(Stats::blocksMined[Tile::cobblestone->id], eDifficulty_Hard) +
999 getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Hard) +
1000 getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Hard) +
1001 getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Hard) +
1002 getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Hard) +
1003 getValue(Stats::blocksMined[Tile::obsidian->id], eDifficulty_Hard);
1004
1005 setLeaderboardProperty( &miningBlocksHardProperties[LeaderboardManager::eProperty_Mining_Dirt ], PROPERTY_MINED_DIRT, getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Hard) );
1006 setLeaderboardProperty( &miningBlocksHardProperties[LeaderboardManager::eProperty_Mining_Stone ], PROPERTY_MINED_STONE, getValue(Stats::blocksMined[Tile::cobblestone->id], eDifficulty_Hard) );
1007 setLeaderboardProperty( &miningBlocksHardProperties[LeaderboardManager::eProperty_Mining_Sand ], PROPERTY_MINED_SAND, getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Hard) );
1008 setLeaderboardProperty( &miningBlocksHardProperties[LeaderboardManager::eProperty_Mining_Cobblestone], PROPERTY_MINED_COBBLESTONE, getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Hard) );
1009 setLeaderboardProperty( &miningBlocksHardProperties[LeaderboardManager::eProperty_Mining_Gravel ], PROPERTY_MINED_GRAVEL, getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Hard) );
1010 setLeaderboardProperty( &miningBlocksHardProperties[LeaderboardManager::eProperty_Mining_Clay ], PROPERTY_MINED_CLAY, getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Hard) );
1011 setLeaderboardProperty( &miningBlocksHardProperties[LeaderboardManager::eProperty_Mining_Obsidian ], PROPERTY_MINED_OBSIDIAN, getValue(Stats::blocksMined[Tile::obsidian->id], eDifficulty_Hard) );
1012 setLeaderboardRating( &miningBlocksHardProperties[LeaderboardManager::eProperty_Mining_Rating ], rating );
1013
1014 viewCount++;
1015 }
1016
1017 if( modifiedBoards & LEADERBOARD_FARMING_PEACEFUL )
1018 {
1019 app.DebugPrintf("Updating leaderboard view LEADERBOARD_FARMING_PEACEFUL\n");
1020 views[viewCount].dwViewId = STATS_VIEW_FARMING_PEACEFUL;
1021 views[viewCount].dwNumProperties = LeaderboardManager::eProperty_Farming_Max;
1022 views[viewCount].pProperties = farmingPeacefulProperties;
1023
1024 rating =
1025 getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Peaceful) +
1026 getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Peaceful) +
1027 getValue(Stats::blocksMined[Tile::mushroom_brown_Id], eDifficulty_Peaceful) +
1028 getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Peaceful) +
1029 getValue(Stats::cowsMilked, eDifficulty_Peaceful) +
1030 getValue(Stats::itemsCollected[Tile::pumpkin->id], eDifficulty_Peaceful);
1031
1032 setLeaderboardProperty( &farmingPeacefulProperties[LeaderboardManager::eProperty_Farming_Egg ], PROPERTY_COLLECTED_EGG, getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Peaceful) );
1033 setLeaderboardProperty( &farmingPeacefulProperties[LeaderboardManager::eProperty_Farming_Wheat ], PROPERTY_COLLECTED_WHEAT, getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Peaceful) );
1034 setLeaderboardProperty( &farmingPeacefulProperties[LeaderboardManager::eProperty_Farming_Mushroom ], PROPERTY_COLLECTED_MUSHROOM, getValue(Stats::blocksMined[Tile::mushroom_brown_Id], eDifficulty_Peaceful) );
1035 setLeaderboardProperty( &farmingPeacefulProperties[LeaderboardManager::eProperty_Farming_Sugarcane ], PROPERTY_COLLECTED_SUGARCANE, getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Peaceful) );
1036 setLeaderboardProperty( &farmingPeacefulProperties[LeaderboardManager::eProperty_Farming_Milk ], PROPERTY_COLLECTED_MILK, getValue(Stats::cowsMilked, eDifficulty_Peaceful) );
1037 setLeaderboardProperty( &farmingPeacefulProperties[LeaderboardManager::eProperty_Farming_Pumpkin ], PROPERTY_COLLECTED_PUMPKIN, getValue(Stats::itemsCollected[Tile::pumpkin->id], eDifficulty_Peaceful) );
1038 setLeaderboardRating( &farmingPeacefulProperties[LeaderboardManager::eProperty_Farming_Rating ], rating );
1039
1040 viewCount++;
1041 }
1042
1043 if( modifiedBoards & LEADERBOARD_FARMING_EASY )
1044 {
1045 app.DebugPrintf("Updating leaderboard view LEADERBOARD_FARMING_EASY\n");
1046 views[viewCount].dwViewId = STATS_VIEW_FARMING_EASY;
1047 views[viewCount].dwNumProperties = LeaderboardManager::eProperty_Farming_Max;
1048 views[viewCount].pProperties = farmingEasyProperties;
1049
1050 rating =
1051 getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Easy) +
1052 getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Easy) +
1053 getValue(Stats::blocksMined[Tile::mushroom_brown_Id], eDifficulty_Easy) +
1054 getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Easy) +
1055 getValue(Stats::cowsMilked, eDifficulty_Easy) +
1056 getValue(Stats::itemsCollected[Tile::pumpkin->id], eDifficulty_Easy);
1057
1058 setLeaderboardProperty( &farmingEasyProperties[LeaderboardManager::eProperty_Farming_Egg ], PROPERTY_COLLECTED_EGG, getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Easy) );
1059 setLeaderboardProperty( &farmingEasyProperties[LeaderboardManager::eProperty_Farming_Wheat ], PROPERTY_COLLECTED_WHEAT, getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Easy) );
1060 setLeaderboardProperty( &farmingEasyProperties[LeaderboardManager::eProperty_Farming_Mushroom ], PROPERTY_COLLECTED_MUSHROOM, getValue(Stats::blocksMined[Tile::mushroom_brown_Id], eDifficulty_Easy) );
1061 setLeaderboardProperty( &farmingEasyProperties[LeaderboardManager::eProperty_Farming_Sugarcane ], PROPERTY_COLLECTED_SUGARCANE, getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Easy) );
1062 setLeaderboardProperty( &farmingEasyProperties[LeaderboardManager::eProperty_Farming_Milk ], PROPERTY_COLLECTED_MILK, getValue(Stats::cowsMilked, eDifficulty_Easy) );
1063 setLeaderboardProperty( &farmingEasyProperties[LeaderboardManager::eProperty_Farming_Pumpkin ], PROPERTY_COLLECTED_PUMPKIN, getValue(Stats::itemsCollected[Tile::pumpkin->id], eDifficulty_Easy) );
1064 setLeaderboardRating( &farmingEasyProperties[LeaderboardManager::eProperty_Farming_Rating ], rating );
1065
1066 viewCount++;
1067 }
1068
1069 if( modifiedBoards & LEADERBOARD_FARMING_NORMAL )
1070 {
1071 app.DebugPrintf("Updating leaderboard view LEADERBOARD_FARMING_NORMAL\n");
1072 views[viewCount].dwViewId = STATS_VIEW_FARMING_NORMAL;
1073 views[viewCount].dwNumProperties = LeaderboardManager::eProperty_Farming_Max;
1074 views[viewCount].pProperties = farmingNormalProperties;
1075
1076 rating =
1077 getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Normal) +
1078 getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Normal) +
1079 getValue(Stats::blocksMined[Tile::mushroom_brown_Id], eDifficulty_Normal) +
1080 getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Normal) +
1081 getValue(Stats::cowsMilked, eDifficulty_Normal) +
1082 getValue(Stats::itemsCollected[Tile::pumpkin->id], eDifficulty_Normal);
1083
1084 setLeaderboardProperty( &farmingNormalProperties[LeaderboardManager::eProperty_Farming_Egg ], PROPERTY_COLLECTED_EGG, getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Normal) );
1085 setLeaderboardProperty( &farmingNormalProperties[LeaderboardManager::eProperty_Farming_Wheat ], PROPERTY_COLLECTED_WHEAT, getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Normal) );
1086 setLeaderboardProperty( &farmingNormalProperties[LeaderboardManager::eProperty_Farming_Mushroom ], PROPERTY_COLLECTED_MUSHROOM, getValue(Stats::blocksMined[Tile::mushroom_brown_Id], eDifficulty_Normal) );
1087 setLeaderboardProperty( &farmingNormalProperties[LeaderboardManager::eProperty_Farming_Sugarcane], PROPERTY_COLLECTED_SUGARCANE, getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Normal) );
1088 setLeaderboardProperty( &farmingNormalProperties[LeaderboardManager::eProperty_Farming_Milk ], PROPERTY_COLLECTED_MILK, getValue(Stats::cowsMilked, eDifficulty_Normal) );
1089 setLeaderboardProperty( &farmingNormalProperties[LeaderboardManager::eProperty_Farming_Pumpkin ], PROPERTY_COLLECTED_PUMPKIN, getValue(Stats::itemsCollected[Tile::pumpkin->id], eDifficulty_Normal) );
1090 setLeaderboardRating( &farmingNormalProperties[LeaderboardManager::eProperty_Farming_Rating ], rating );
1091
1092 viewCount++;
1093 }
1094
1095 if( modifiedBoards & LEADERBOARD_FARMING_HARD )
1096 {
1097 app.DebugPrintf("Updating leaderboard view LEADERBOARD_FARMING_HARD\n");
1098 views[viewCount].dwViewId = STATS_VIEW_FARMING_HARD;
1099 views[viewCount].dwNumProperties = LeaderboardManager::eProperty_Farming_Max;
1100 views[viewCount].pProperties = farmingHardProperties;
1101
1102 rating =
1103 getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Hard) +
1104 getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Hard) +
1105 getValue(Stats::blocksMined[Tile::mushroom_brown_Id], eDifficulty_Hard) +
1106 getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Hard) +
1107 getValue(Stats::cowsMilked, eDifficulty_Hard) +
1108 getValue(Stats::itemsCollected[Tile::pumpkin->id], eDifficulty_Hard);
1109
1110 setLeaderboardProperty( &farmingHardProperties[LeaderboardManager::eProperty_Farming_Egg ], PROPERTY_COLLECTED_EGG, getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Hard) );
1111 setLeaderboardProperty( &farmingHardProperties[LeaderboardManager::eProperty_Farming_Wheat ], PROPERTY_COLLECTED_WHEAT, getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Hard) );
1112 setLeaderboardProperty( &farmingHardProperties[LeaderboardManager::eProperty_Farming_Mushroom ], PROPERTY_COLLECTED_MUSHROOM, getValue(Stats::blocksMined[Tile::mushroom_brown_Id], eDifficulty_Hard) );
1113 setLeaderboardProperty( &farmingHardProperties[LeaderboardManager::eProperty_Farming_Sugarcane ], PROPERTY_COLLECTED_SUGARCANE, getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Hard) );
1114 setLeaderboardProperty( &farmingHardProperties[LeaderboardManager::eProperty_Farming_Milk ], PROPERTY_COLLECTED_MILK, getValue(Stats::cowsMilked, eDifficulty_Hard) );
1115 setLeaderboardProperty( &farmingHardProperties[LeaderboardManager::eProperty_Farming_Pumpkin ], PROPERTY_COLLECTED_PUMPKIN, getValue(Stats::itemsCollected[Tile::pumpkin->id], eDifficulty_Hard) );
1116 setLeaderboardRating( &farmingHardProperties[LeaderboardManager::eProperty_Farming_Rating ], rating );
1117
1118 viewCount++;
1119 }
1120
1121 if( modifiedBoards & LEADERBOARD_TRAVELLING_PEACEFUL )
1122 {
1123 app.DebugPrintf("Updating leaderboard view LEADERBOARD_TRAVELLING_PEACEFUL\n");
1124 views[viewCount].dwViewId = STATS_VIEW_TRAVELLING_PEACEFUL;
1125 views[viewCount].dwNumProperties = LeaderboardManager::eProperty_Travelling_Max;
1126 views[viewCount].pProperties = travellingPeacefulProperties;
1127
1128 rating =
1129 getValue(Stats::walkOneM, eDifficulty_Peaceful) +
1130 getValue(Stats::fallOneM, eDifficulty_Peaceful) +
1131 getValue(Stats::minecartOneM, eDifficulty_Peaceful) +
1132 getValue(Stats::boatOneM, eDifficulty_Peaceful);
1133
1134 setLeaderboardProperty( &travellingPeacefulProperties[LeaderboardManager::eProperty_Travelling_Walked ], PROPERTY_TRAVEL_WALK, getValue(Stats::walkOneM, eDifficulty_Peaceful) );
1135 setLeaderboardProperty( &travellingPeacefulProperties[LeaderboardManager::eProperty_Travelling_Fallen ], PROPERTY_TRAVEL_FALL, getValue(Stats::fallOneM, eDifficulty_Peaceful) );
1136 setLeaderboardProperty( &travellingPeacefulProperties[LeaderboardManager::eProperty_Travelling_Minecart ], PROPERTY_TRAVEL_MINECART, getValue(Stats::minecartOneM, eDifficulty_Peaceful) );
1137 setLeaderboardProperty( &travellingPeacefulProperties[LeaderboardManager::eProperty_Travelling_Boat ], PROPERTY_TRAVEL_BOAT, getValue(Stats::boatOneM, eDifficulty_Peaceful) );
1138 setLeaderboardRating( &travellingPeacefulProperties[LeaderboardManager::eProperty_Travelling_Rating ], rating );
1139
1140 viewCount++;
1141 }
1142
1143 if( modifiedBoards & LEADERBOARD_TRAVELLING_EASY )
1144 {
1145 app.DebugPrintf("Updating leaderboard view LEADERBOARD_TRAVELLING_EASY\n");
1146 views[viewCount].dwViewId = STATS_VIEW_TRAVELLING_EASY;
1147 views[viewCount].dwNumProperties = LeaderboardManager::eProperty_Travelling_Max;
1148 views[viewCount].pProperties = travellingEasyProperties;
1149
1150 rating =
1151 getValue(Stats::walkOneM, eDifficulty_Easy) +
1152 getValue(Stats::fallOneM, eDifficulty_Easy) +
1153 getValue(Stats::minecartOneM, eDifficulty_Easy) +
1154 getValue(Stats::boatOneM, eDifficulty_Easy);
1155
1156 setLeaderboardProperty( &travellingEasyProperties[LeaderboardManager::eProperty_Travelling_Walked ], PROPERTY_TRAVEL_WALK, getValue(Stats::walkOneM, eDifficulty_Easy) );
1157 setLeaderboardProperty( &travellingEasyProperties[LeaderboardManager::eProperty_Travelling_Fallen ], PROPERTY_TRAVEL_FALL, getValue(Stats::fallOneM, eDifficulty_Easy) );
1158 setLeaderboardProperty( &travellingEasyProperties[LeaderboardManager::eProperty_Travelling_Minecart ], PROPERTY_TRAVEL_MINECART, getValue(Stats::minecartOneM, eDifficulty_Easy) );
1159 setLeaderboardProperty( &travellingEasyProperties[LeaderboardManager::eProperty_Travelling_Boat ], PROPERTY_TRAVEL_BOAT, getValue(Stats::boatOneM, eDifficulty_Easy) );
1160 setLeaderboardRating( &travellingEasyProperties[LeaderboardManager::eProperty_Travelling_Rating ], rating );
1161
1162 viewCount++;
1163 }
1164
1165 if( modifiedBoards & LEADERBOARD_TRAVELLING_NORMAL)
1166 {
1167 app.DebugPrintf("Updating leaderboard view LEADERBOARD_TRAVELLING_NORMAL\n");
1168 views[viewCount].dwViewId = STATS_VIEW_TRAVELLING_NORMAL;
1169 views[viewCount].dwNumProperties = LeaderboardManager::eProperty_Travelling_Max;
1170 views[viewCount].pProperties = travellingNormalProperties;
1171
1172 rating =
1173 getValue(Stats::walkOneM, eDifficulty_Normal) +
1174 getValue(Stats::fallOneM, eDifficulty_Normal) +
1175 getValue(Stats::minecartOneM, eDifficulty_Normal) +
1176 getValue(Stats::boatOneM, eDifficulty_Normal);
1177
1178 setLeaderboardProperty( &travellingNormalProperties[LeaderboardManager::eProperty_Travelling_Walked ], PROPERTY_TRAVEL_WALK, getValue(Stats::walkOneM, eDifficulty_Normal) );
1179 setLeaderboardProperty( &travellingNormalProperties[LeaderboardManager::eProperty_Travelling_Fallen ], PROPERTY_TRAVEL_FALL, getValue(Stats::fallOneM, eDifficulty_Normal) );
1180 setLeaderboardProperty( &travellingNormalProperties[LeaderboardManager::eProperty_Travelling_Minecart ], PROPERTY_TRAVEL_MINECART, getValue(Stats::minecartOneM, eDifficulty_Normal) );
1181 setLeaderboardProperty( &travellingNormalProperties[LeaderboardManager::eProperty_Travelling_Boat ], PROPERTY_TRAVEL_BOAT, getValue(Stats::boatOneM, eDifficulty_Normal) );
1182 setLeaderboardRating( &travellingNormalProperties[LeaderboardManager::eProperty_Travelling_Rating ], rating );
1183
1184 viewCount++;
1185 }
1186
1187 if( modifiedBoards & LEADERBOARD_TRAVELLING_HARD )
1188 {
1189 app.DebugPrintf("Updating leaderboard view LEADERBOARD_TRAVELLING_HARD\n");
1190 views[viewCount].dwViewId = STATS_VIEW_TRAVELLING_HARD;
1191 views[viewCount].dwNumProperties = LeaderboardManager::eProperty_Travelling_Max;
1192 views[viewCount].pProperties = travellingHardProperties;
1193
1194 rating =
1195 getValue(Stats::walkOneM, eDifficulty_Hard) +
1196 getValue(Stats::fallOneM, eDifficulty_Hard) +
1197 getValue(Stats::minecartOneM, eDifficulty_Hard) +
1198 getValue(Stats::boatOneM, eDifficulty_Hard);
1199
1200 setLeaderboardProperty( &travellingHardProperties[LeaderboardManager::eProperty_Travelling_Walked ], PROPERTY_TRAVEL_WALK, getValue(Stats::walkOneM, eDifficulty_Hard) );
1201 setLeaderboardProperty( &travellingHardProperties[LeaderboardManager::eProperty_Travelling_Fallen ], PROPERTY_TRAVEL_FALL, getValue(Stats::fallOneM, eDifficulty_Hard) );
1202 setLeaderboardProperty( &travellingHardProperties[LeaderboardManager::eProperty_Travelling_Minecart ], PROPERTY_TRAVEL_MINECART, getValue(Stats::minecartOneM, eDifficulty_Hard) );
1203 setLeaderboardProperty( &travellingHardProperties[LeaderboardManager::eProperty_Travelling_Boat ], PROPERTY_TRAVEL_BOAT, getValue(Stats::boatOneM, eDifficulty_Hard) );
1204 setLeaderboardRating( &travellingHardProperties[LeaderboardManager::eProperty_Travelling_Rating ], rating );
1205
1206 viewCount++;
1207 }
1208
1209 if( modifiedBoards & (LEADERBOARD_TRAVELLING_PEACEFUL | LEADERBOARD_TRAVELLING_EASY | LEADERBOARD_TRAVELLING_NORMAL | LEADERBOARD_TRAVELLING_HARD) )
1210 {
1211 app.DebugPrintf("Updating leaderboard view LEADERBOARD_TRAVELLING_PEACEFUL | LEADERBOARD_TRAVELLING_EASY | LEADERBOARD_TRAVELLING_NORMAL | LEADERBOARD_TRAVELLING_HARD\n");
1212 views[viewCount].dwViewId = STATS_VIEW_TRAVELLING_TOTAL;
1213 views[viewCount].dwNumProperties = 1;
1214 views[viewCount].pProperties = travellingProperties;
1215
1216 rating =
1217 getValue(Stats::walkOneM, eDifficulty_Peaceful) + getValue(Stats::fallOneM, eDifficulty_Peaceful) + getValue(Stats::boatOneM, eDifficulty_Peaceful) + getValue(Stats::minecartOneM, eDifficulty_Peaceful) +
1218 getValue(Stats::walkOneM, eDifficulty_Easy) + getValue(Stats::fallOneM, eDifficulty_Easy) + getValue(Stats::boatOneM, eDifficulty_Easy) + getValue(Stats::minecartOneM, eDifficulty_Easy) +
1219 getValue(Stats::walkOneM, eDifficulty_Normal) + getValue(Stats::fallOneM, eDifficulty_Normal) + getValue(Stats::boatOneM, eDifficulty_Normal) + getValue(Stats::minecartOneM, eDifficulty_Normal) +
1220 getValue(Stats::walkOneM, eDifficulty_Hard) + getValue(Stats::fallOneM, eDifficulty_Hard) + getValue(Stats::boatOneM, eDifficulty_Hard) + getValue(Stats::minecartOneM, eDifficulty_Hard);
1221
1222 setLeaderboardRating( &travellingProperties[0], rating );
1223
1224 viewCount++;
1225 }
1226
1227 if( viewCount > 0 )
1228 {
1229 if( !LeaderboardManager::Instance()->WriteStats(viewCount, views) )
1230 {
1231 assert(false && "Failed to write to leaderboard");
1232 //printf("Failed to write to leaderboard");
1233 }
1234 else
1235 {
1236 app.DebugPrintf("Successfully wrote %d leadeboard views\n", viewCount);
1237 }
1238 }
1239#endif // Xbox
1240#endif // ndef _DURANGO
1241}
1242
1243void StatsCounter::setupStatBoards()
1244{
1245#ifndef _DURANGO
1246 statBoards.insert( make_pair(Stats::killsZombie, LEADERBOARD_KILLS_PEACEFUL) );
1247 statBoards.insert( make_pair(Stats::killsSkeleton, LEADERBOARD_KILLS_PEACEFUL) );
1248 statBoards.insert( make_pair(Stats::killsCreeper, LEADERBOARD_KILLS_PEACEFUL) );
1249 statBoards.insert( make_pair(Stats::killsSpider, LEADERBOARD_KILLS_PEACEFUL) );
1250 statBoards.insert( make_pair(Stats::killsSpiderJockey, LEADERBOARD_KILLS_PEACEFUL) );
1251 statBoards.insert( make_pair(Stats::killsZombiePigman, LEADERBOARD_KILLS_PEACEFUL) );
1252 statBoards.insert( make_pair(Stats::killsNetherZombiePigman, LEADERBOARD_KILLS_PEACEFUL) );
1253 statBoards.insert( make_pair(Stats::killsSlime, LEADERBOARD_KILLS_PEACEFUL) );
1254
1255 statBoards.insert( make_pair(Stats::blocksMined[Tile::dirt->id], LEADERBOARD_MININGBLOCKS_PEACEFUL) );
1256 statBoards.insert( make_pair(Stats::blocksMined[Tile::cobblestone->id], LEADERBOARD_MININGBLOCKS_PEACEFUL) );
1257 statBoards.insert( make_pair(Stats::blocksMined[Tile::sand->id], LEADERBOARD_MININGBLOCKS_PEACEFUL) );
1258 statBoards.insert( make_pair(Stats::blocksMined[Tile::stone->id], LEADERBOARD_MININGBLOCKS_PEACEFUL) );
1259 statBoards.insert( make_pair(Stats::blocksMined[Tile::gravel->id], LEADERBOARD_MININGBLOCKS_PEACEFUL) );
1260 statBoards.insert( make_pair(Stats::blocksMined[Tile::clay->id], LEADERBOARD_MININGBLOCKS_PEACEFUL) );
1261 statBoards.insert( make_pair(Stats::blocksMined[Tile::obsidian->id], LEADERBOARD_MININGBLOCKS_PEACEFUL) );
1262
1263 statBoards.insert( make_pair(Stats::itemsCollected[Item::egg->id], LEADERBOARD_FARMING_PEACEFUL) );
1264 statBoards.insert( make_pair(Stats::blocksMined[Tile::wheat_Id], LEADERBOARD_FARMING_PEACEFUL) );
1265 statBoards.insert( make_pair(Stats::blocksMined[Tile::mushroom_brown_Id], LEADERBOARD_FARMING_PEACEFUL) );
1266 statBoards.insert( make_pair(Stats::blocksMined[Tile::reeds_Id], LEADERBOARD_FARMING_PEACEFUL) );
1267 statBoards.insert( make_pair(Stats::cowsMilked, LEADERBOARD_FARMING_PEACEFUL) );
1268 statBoards.insert( make_pair(Stats::itemsCollected[Tile::pumpkin->id], LEADERBOARD_FARMING_PEACEFUL) );
1269
1270 statBoards.insert( make_pair(Stats::walkOneM, LEADERBOARD_TRAVELLING_PEACEFUL) );
1271 statBoards.insert( make_pair(Stats::fallOneM, LEADERBOARD_TRAVELLING_PEACEFUL) );
1272 statBoards.insert( make_pair(Stats::minecartOneM, LEADERBOARD_TRAVELLING_PEACEFUL) );
1273 statBoards.insert( make_pair(Stats::boatOneM, LEADERBOARD_TRAVELLING_PEACEFUL) );
1274#endif
1275}
1276
1277bool StatsCounter::isLargeStat(Stat* stat)
1278{
1279#ifndef _DURANGO
1280 Stat*** end = &LARGE_STATS[LARGE_STATS_COUNT];
1281 for( Stat*** iter = LARGE_STATS ; iter != end ; ++iter )
1282 if( (*(*iter))->id == stat->id )
1283 return true;
1284#endif
1285 return false;
1286}
1287
1288void StatsCounter::dumpStatsToTTY()
1289{
1290 vector<Stat*>::iterator statsEnd = Stats::all->end();
1291 for( vector<Stat*>::iterator statsIter = Stats::all->begin() ; statsIter!=statsEnd ; ++statsIter )
1292 {
1293 app.DebugPrintf("%ls\t\t%u\t%u\t%u\t%u\n",
1294 (*statsIter)->name.c_str(),
1295 getValue(*statsIter, 0),
1296 getValue(*statsIter, 1),
1297 getValue(*statsIter, 2),
1298 getValue(*statsIter, 3)
1299 );
1300 }
1301}
1302
1303#ifdef _DEBUG
1304
1305//To clear leaderboards set DEBUG_ENABLE_CLEAR_LEADERBOARDS to 1 and set DEBUG_CLEAR_LEADERBOARDS to be the bitmask of what you want to clear
1306//Leaderboards are updated on game exit so enter and exit a level to trigger the clear
1307
1308//#define DEBUG_CLEAR_LEADERBOARDS (LEADERBOARD_KILLS_EASY | LEADERBOARD_KILLS_NORMAL | LEADERBOARD_KILLS_HARD)
1309#define DEBUG_CLEAR_LEADERBOARDS (0xFFFFFFFF)
1310#define DEBUG_ENABLE_CLEAR_LEADERBOARDS
1311
1312void StatsCounter::WipeLeaderboards()
1313{
1314
1315#if defined DEBUG_ENABLE_CLEAR_LEADERBOARDS && defined _XBOX
1316
1317 if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_KILLS_EASY ) XUserResetStatsViewAllUsers(STATS_VIEW_KILLS_EASY, NULL);
1318 if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_KILLS_NORMAL ) XUserResetStatsViewAllUsers(STATS_VIEW_KILLS_NORMAL, NULL);
1319 if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_KILLS_HARD ) XUserResetStatsViewAllUsers(STATS_VIEW_KILLS_HARD, NULL);
1320 if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGBLOCKS_PEACEFUL ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_BLOCKS_PEACEFUL, NULL);
1321 if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGBLOCKS_EASY ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_BLOCKS_EASY, NULL);
1322 if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGBLOCKS_NORMAL ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_BLOCKS_NORMAL, NULL);
1323 if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGBLOCKS_HARD ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_BLOCKS_HARD, NULL);
1324// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGORE_PEACEFUL ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_ORE_PEACEFUL, NULL);
1325// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGORE_EASY ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_ORE_EASY, NULL);
1326// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGORE_NORMAL ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_ORE_NORMAL, NULL);
1327// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGORE_HARD ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_ORE_HARD, NULL);
1328 if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_FARMING_PEACEFUL ) XUserResetStatsViewAllUsers(STATS_VIEW_FARMING_PEACEFUL, NULL);
1329 if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_FARMING_EASY ) XUserResetStatsViewAllUsers(STATS_VIEW_FARMING_EASY, NULL);
1330 if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_FARMING_NORMAL ) XUserResetStatsViewAllUsers(STATS_VIEW_FARMING_NORMAL, NULL);
1331 if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_FARMING_HARD ) XUserResetStatsViewAllUsers(STATS_VIEW_FARMING_HARD, NULL);
1332 if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_PEACEFUL ) XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_PEACEFUL, NULL);
1333 if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_EASY ) XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_EASY, NULL);
1334 if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_NORMAL ) XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_NORMAL, NULL);
1335 if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_HARD ) XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_HARD, NULL);
1336// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_NETHER_PEACEFUL ) XUserResetStatsViewAllUsers(STATS_VIEW_NETHER_PEACEFUL, NULL);
1337// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_NETHER_EASY ) XUserResetStatsViewAllUsers(STATS_VIEW_NETHER_EASY, NULL);
1338// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_NETHER_NORMAL ) XUserResetStatsViewAllUsers(STATS_VIEW_NETHER_NORMAL, NULL);
1339// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_NETHER_HARD ) XUserResetStatsViewAllUsers(STATS_VIEW_NETHER_HARD, NULL);
1340 if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_TOTAL ) XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_TOTAL, NULL);
1341 if( LeaderboardManager::Instance()->OpenSession() )
1342 {
1343 writeStats();
1344 LeaderboardManager::Instance()->CloseSession();
1345 }
1346#endif
1347}
1348#endif