the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2
3#include "..\Minecraft.World\StringHelpers.h"
4
5#include "..\Minecraft.World\Player.h"
6#include "..\Minecraft.World\Level.h"
7#include "..\Minecraft.World\LevelData.h"
8#include "..\Minecraft.World\LevelSettings.h"
9
10#include "Common\Network\GameNetworkManager.h"
11#include "MultiPlayerLocalPlayer.h"
12
13#include "..\ServiceConfig\Events-XBLA.8-149E11AEEvents.h"
14
15#include "DurangoTelemetry.h"
16
17CTelemetryManager *TelemetryManager = new CDurangoTelemetryManager();
18
19// Empty GUID
20GUID CDurangoTelemetryManager::ZERO_GUID = GUID();
21
22/*
23HRESULT CDurangoTelemetryManager::Init()
24{
25 app.DebugPrintf("[CDurangoTelemetryManager] Init().\n");
26
27 m_initialiseTime = app.getAppTime();
28
29 return S_OK;
30}
31*/
32
33CDurangoTelemetryManager::CDurangoTelemetryManager()
34{
35 m_initialiseTime = app.getAppTime();
36}
37
38/*
39HRESULT CDurangoTelemetryManager::Tick()
40{
41 app.DebugPrintf("[CDurangoTelemetryManager] Tick().\n");
42 return S_OK;
43}
44
45HRESULT CDurangoTelemetryManager::Flush()
46{
47 app.DebugPrintf("[CDurangoTelemetryManager] Flush().\n");
48 return S_OK;
49} */
50
51bool CDurangoTelemetryManager::RecordPlayerSessionStart(int iPad)
52{
53 durangoStats()->generatePlayerSession();
54
55 return true;
56}
57
58bool CDurangoTelemetryManager::RecordPlayerSessionExit(int iPad, int exitStatus)
59{
60 PlayerUID puid; shared_ptr<Player> plr;
61 ProfileManager.GetXUID(iPad, &puid, true);
62 plr = Minecraft::GetInstance()->localplayers[iPad];
63
64 // 4J-JEV: Still needed to flush cached travel stats.
65 DurangoStats::playerSessionEnd(iPad);
66
67 if (plr != NULL && plr->level != NULL && plr->level->getLevelData() != NULL)
68 {
69 ULONG hr = EventWritePlayerSessionEnd(
70 DurangoStats::getUserId(iPad),
71 DurangoStats::getPlayerSession(),
72 DurangoStats::getMultiplayerCorrelationId(),
73 plr->level->getLevelData()->getGameType()->isSurvival(),
74 plr->level->difficulty,
75 exitStatus);
76
77 if (hr == 0) // Debug.
78 {
79 app.DebugPrintf("<%ls> PlayerSessionEnd(%ls,%ls,%i,%i,%i)\n",
80 DurangoStats::getUserId(iPad),
81 guid2str(DurangoStats::getPlayerSession()).c_str(),
82 DurangoStats::getMultiplayerCorrelationId(),
83 plr->level->getLevelData()->getGameType()->isSurvival(),
84 plr->level->difficulty,
85 exitStatus);
86 }
87
88 if ( !g_NetworkManager.IsLocalGame() )
89 {
90 float roundLength = app.getAppTime() - m_multiplayerRoundStartTimes[DurangoStats::getUserId(iPad)];
91
92 hr = EventWriteMultiplayerRoundEnd(
93 DurangoStats::getUserId(iPad),
94 &ZERO_GUID,
95 0,
96 DurangoStats::getPlayerSession(),
97 DurangoStats::getMultiplayerCorrelationId(),
98 plr->level->getLevelData()->getGameType()->isSurvival(), // GameMode
99 0,
100 plr->level->difficulty,
101 roundLength, // Time (seconds)
102 exitStatus
103 );
104
105 if (hr == 0) // Debug.
106 {
107 app.DebugPrintf(
108 "<%ls> MultiplayerRoundEnd(%ls,%ls,%i,%i,%.1f,%i).\n",
109 DurangoStats::getUserId(iPad),
110 guid2str(DurangoStats::getPlayerSession()).c_str(),
111 DurangoStats::getMultiplayerCorrelationId(),
112 plr->level->getLevelData()->getGameType()->isSurvival(),
113 plr->level->difficulty,
114 roundLength,
115 exitStatus);
116 }
117 }
118 }
119
120 return true;
121}
122
123bool CDurangoTelemetryManager::RecordLevelStart(int iPad, ESen_FriendOrMatch friendsOrMatch, ESen_CompeteOrCoop competeOrCoop, int difficulty, int numberOfLocalPlayers, int numberOfOnlinePlayers)
124{
125 CTelemetryManager::RecordLevelStart(iPad, friendsOrMatch, competeOrCoop, difficulty, numberOfLocalPlayers, numberOfOnlinePlayers);
126
127 ULONG hr = 0;
128
129 // Grab player info.
130 PlayerUID puid; shared_ptr<Player> plr;
131 ProfileManager.GetXUID(iPad, &puid, true);
132 plr = Minecraft::GetInstance()->localplayers[iPad];
133
134 if (plr != NULL && plr->level != NULL && plr->level->getLevelData() != NULL)
135 {
136 hr = EventWritePlayerSessionStart(
137 DurangoStats::getUserId(iPad),
138 DurangoStats::getPlayerSession(),
139 DurangoStats::getMultiplayerCorrelationId(),
140 plr->level->getLevelData()->getGameType()->isSurvival(),
141 plr->level->difficulty
142 );
143
144 if (hr == 0) // Debug.
145 {
146 app.DebugPrintf("<%ls> PlayerSessionStart(%ls,%ls,%i,%i)\n",
147 DurangoStats::getUserId(iPad),
148 guid2str(DurangoStats::getPlayerSession()).c_str(),
149 DurangoStats::getMultiplayerCorrelationId(),
150 plr->level->getLevelData()->getGameType()->isSurvival(),
151 plr->level->difficulty);
152 }
153
154 m_multiplayerRoundStartTimes[DurangoStats::getUserId(iPad)] = -1.0f;
155
156 // Send 'MultiplayerRoundStart' if we're starting an online game.
157 if ( !g_NetworkManager.IsLocalGame() )
158 {
159 hr = EventWriteMultiplayerRoundStart(
160 DurangoStats::getUserId(iPad),
161 &ZERO_GUID, // RoundId
162 0, // SectionId
163 DurangoStats::getPlayerSession(),
164 DurangoStats::getMultiplayerCorrelationId(),
165 plr->level->getLevelData()->getGameType()->isSurvival(), // GameMode
166 0, // MatchType
167 plr->level->difficulty);
168
169 if (hr == 0) // Debug.
170 {
171 app.DebugPrintf(
172 "<%ls> MultiplayerRoundStart(%ls,%ls,%i,%i).\n",
173 DurangoStats::getUserId(iPad),
174 guid2str(DurangoStats::getPlayerSession()).c_str(),
175 DurangoStats::getMultiplayerCorrelationId(),
176 plr->level->getLevelData()->getGameType()->isSurvival(),
177 plr->level->difficulty);
178 }
179
180 m_multiplayerRoundStartTimes[DurangoStats::getUserId(iPad)] = app.getAppTime();
181 }
182 }
183
184 hr = EventWriteLevelStart(
185 DurangoStats::getUserId(iPad),
186 DurangoStats::getPlayerSession(),
187 GetSecondsSinceInitialize(),
188 GetMode(iPad),
189 GetSubMode(iPad),
190 GetLevelId(iPad),
191 GetSubLevelId(iPad),
192 GetLevelInstanceID(),
193 &ZERO_GUID,
194 friendsOrMatch,
195 competeOrCoop,
196 difficulty,
197 numberOfLocalPlayers,
198 numberOfOnlinePlayers,
199 &ZERO_GUID
200 );
201
202 if (hr == 0) // Debug.
203 {
204 app.DebugPrintf(
205 "<%ls> RecordLevelStart("
206 "%is,%i,%i,%i,%i,%i,"
207 "%ls,%ls,%i,%i,%i,%i,%i).\n",
208
209 /* WSTR */ DurangoStats::getUserId(iPad),
210
211 // Sentient //
212 /* int */ GetSecondsSinceInitialize(),
213 /* int */ GetMode(iPad),
214 /* int */ GetSubMode(iPad),
215 /* int */ GetLevelId(iPad),
216 /* int */ GetSubLevelId(iPad),
217 /* int */ GetLevelInstanceID(),
218
219 // Durango //
220 /* GUID */ guid2str(DurangoStats::getPlayerSession()).c_str(),
221 /* WSTR */ DurangoStats::getMultiplayerCorrelationId(),
222 /* int */ friendsOrMatch,
223 /* int */ competeOrCoop,
224 /* int */ difficulty,
225 /* int */ numberOfLocalPlayers,
226 /* int */ numberOfOnlinePlayers
227
228 );
229 }
230
231 return true;
232}
233
234bool CDurangoTelemetryManager::RecordLevelExit(int iPad, ESen_LevelExitStatus levelExitStatus)
235{
236 CTelemetryManager::RecordLevelExit(iPad, levelExitStatus);
237
238 ULONG hr = EventWriteLevelExit(
239 DurangoStats::getUserId(iPad),
240 DurangoStats::getPlayerSession(),
241 GetSecondsSinceInitialize(),
242 GetMode(iPad),
243 GetSubMode(iPad),
244 GetLevelId(iPad),
245 GetSubLevelId(iPad),
246 GetLevelInstanceID(),
247 &ZERO_GUID,
248 levelExitStatus,
249 &ZERO_GUID
250 );
251
252 if (hr == 0) // Debug.
253 {
254 app.DebugPrintf(
255 "<%ls> RecordLevelExit(",
256 "%is,%i,%i,%i,%i,%i,"
257 "%ls,%ls,%i).\n",
258
259 /* WSTR */ DurangoStats::getUserId(iPad),
260
261 // Sentient //
262 /* int */ GetSecondsSinceInitialize(),
263 /* int */ GetMode(iPad),
264 /* int */ GetSubMode(iPad),
265 /* int */ GetLevelId(iPad),
266 /* int */ GetSubLevelId(iPad),
267 /* int */ GetLevelInstanceID(),
268
269 // Durango //
270 /* GUID */ guid2str(DurangoStats::getPlayerSession()).c_str(),
271 /* WSTR */ DurangoStats::getMultiplayerCorrelationId(),
272 /* int */ levelExitStatus
273 );
274 }
275
276 return hr == 0;
277}
278
279bool CDurangoTelemetryManager::RecordLevelSaveOrCheckpoint(int iPad, int saveOrCheckPointID, int saveSizeInBytes)
280{
281 CTelemetryManager::RecordLevelSaveOrCheckpoint(iPad, saveOrCheckPointID, saveSizeInBytes);
282
283 ULONG hr = EventWriteLevelSaveOrCheckpoint(
284 DurangoStats::getUserId(iPad),
285 DurangoStats::getPlayerSession(),
286 GetSecondsSinceInitialize(),
287 GetMode(iPad),
288 GetSubMode(iPad),
289 GetLevelId(iPad),
290 GetSubLevelId(iPad),
291 GetLevelInstanceID(),
292 &ZERO_GUID,
293 &ZERO_GUID,
294 saveOrCheckPointID,
295 saveSizeInBytes
296 );
297
298 if (hr == 0)
299 {
300 app.DebugPrintf(
301 "<%ls> RecordLevelSaveOrCheckpoint(",
302 "%is,%i,%i,%i,%i,%i,"
303 "%ls,%ls,%i,%i).\n",
304
305 /* WSTR */ DurangoStats::getUserId(iPad),
306
307 // Sentient //
308 /* int */ GetSecondsSinceInitialize(),
309 /* int */ GetMode(iPad),
310 /* int */ GetSubMode(iPad),
311 /* int */ GetLevelId(iPad),
312 /* int */ GetSubLevelId(iPad),
313 /* int */ GetLevelInstanceID(),
314
315 // Durango //
316 /* GUID */ guid2str(DurangoStats::getPlayerSession()).c_str(),
317 /* WSTR */ DurangoStats::getMultiplayerCorrelationId(),
318 /* int */ saveOrCheckPointID,
319 /* int */ saveSizeInBytes
320 );
321 }
322
323 return hr == 0;
324}
325
326bool CDurangoTelemetryManager::RecordLevelResume(int iPad, ESen_FriendOrMatch friendsOrMatch, ESen_CompeteOrCoop competeOrCoop, int difficulty, int numberOfLocalPlayers, int numberOfOnlinePlayers, int saveOrCheckPointID)
327{
328 CTelemetryManager::RecordLevelResume(iPad, friendsOrMatch, competeOrCoop, difficulty, numberOfLocalPlayers, numberOfOnlinePlayers, saveOrCheckPointID);
329
330 ULONG hr = EventWriteLevelResume(
331 DurangoStats::getUserId(iPad),
332 DurangoStats::getPlayerSession(),
333 GetSecondsSinceInitialize(),
334 GetMode(iPad),
335 GetSubMode(iPad),
336 GetLevelId(iPad),
337 GetSubLevelId(iPad),
338 GetLevelInstanceID(),
339 &ZERO_GUID,
340 &ZERO_GUID,
341 friendsOrMatch,
342 competeOrCoop,
343 difficulty,
344 numberOfLocalPlayers,
345 numberOfOnlinePlayers,
346 saveOrCheckPointID
347 );
348
349 if (hr == 0) // Debug
350 {
351 app.DebugPrintf(
352 "<%ls> RecordLevelResume(",
353 "%is,%i,%i,%i,%i,%i,"
354 "%ls,%ls,%i,%i,%i,%i,%i,%i).\n",
355
356 /* WSTR */ DurangoStats::getUserId(iPad),
357
358 // Sentient //
359 /* int */ GetSecondsSinceInitialize(),
360 /* int */ GetMode(iPad),
361 /* int */ GetSubMode(iPad),
362 /* int */ GetLevelId(iPad),
363 /* int */ GetSubLevelId(iPad),
364 /* int */ GetLevelInstanceID(),
365
366 // Durango //
367 /* GUID */ guid2str(DurangoStats::getPlayerSession()).c_str(),
368 /* WSTR */ DurangoStats::getMultiplayerCorrelationId(),
369 /* int */ friendsOrMatch,
370 /* int */ competeOrCoop,
371 /* int */ difficulty,
372 /* int */ numberOfLocalPlayers,
373 /* int */ numberOfOnlinePlayers,
374 /* int */ saveOrCheckPointID
375 );
376 }
377
378 return hr == 0;
379}
380
381bool CDurangoTelemetryManager::RecordPauseOrInactive(int iPad)
382{
383 CTelemetryManager::RecordPauseOrInactive(iPad);
384
385 ULONG hr = EventWritePauseOrInactive(
386 DurangoStats::getUserId(iPad),
387 DurangoStats::getPlayerSession(),
388 GetSecondsSinceInitialize(),
389 GetMode(iPad),
390 GetSubMode(iPad),
391 GetLevelId(iPad),
392 GetSubLevelId(iPad),
393 GetLevelInstanceID(),
394 &ZERO_GUID,
395 &ZERO_GUID
396 );
397
398 if (hr == 0) // Debug.
399 {
400 app.DebugPrintf(
401 "<%ls> RecordPauseOrInactive(",
402 "%is,%i,%i,%i,%i,%i,"
403 "%ls,%ls).\n",
404
405 /* WSTR */ DurangoStats::getUserId(iPad),
406
407 // Sentient //
408 /* int */ GetSecondsSinceInitialize(),
409 /* int */ GetMode(iPad),
410 /* int */ GetSubMode(iPad),
411 /* int */ GetLevelId(iPad),
412 /* int */ GetSubLevelId(iPad),
413 /* int */ GetLevelInstanceID(),
414
415 // Durango //
416 /* GUID */ guid2str(DurangoStats::getPlayerSession()).c_str(),
417 /* WSTR */ DurangoStats::getMultiplayerCorrelationId()
418 );
419 }
420
421 return hr == 0;
422}
423
424bool CDurangoTelemetryManager::RecordUnpauseOrActive(int iPad)
425{
426 CTelemetryManager::RecordUnpauseOrActive(iPad);
427
428 ULONG hr = EventWriteUnpauseOrActive(
429 DurangoStats::getUserId(iPad),
430 DurangoStats::getPlayerSession(),
431 GetSecondsSinceInitialize(),
432 GetMode(iPad),
433 GetSubMode(iPad),
434 GetLevelId(iPad),
435 GetSubLevelId(iPad),
436 GetLevelInstanceID(),
437 &ZERO_GUID,
438 &ZERO_GUID
439 );
440
441 if (hr == 0) // Debug.
442 {
443 app.DebugPrintf(
444 "<%ls> RecordPauseOrInactive(",
445 "%is,%i,%i,%i,%i,%i,"
446 "%ls,%ls).\n",
447
448 /* WSTR */ DurangoStats::getUserId(iPad),
449
450 // Sentient //
451 /* int */ GetSecondsSinceInitialize(),
452 /* int */ GetMode(iPad),
453 /* int */ GetSubMode(iPad),
454 /* int */ GetLevelId(iPad),
455 /* int */ GetSubLevelId(iPad),
456 /* int */ GetLevelInstanceID(),
457
458 // Durango //
459 /* GUID */ guid2str(DurangoStats::getPlayerSession()).c_str(),
460 /* WSTR */ DurangoStats::getMultiplayerCorrelationId()
461 );
462 }
463
464 return hr == 0;
465}
466
467bool CDurangoTelemetryManager::RecordMenuShown(int iPad, EUIScene menuID, int optionalMenuSubID)
468{
469 CTelemetryManager::RecordMenuShown(iPad, menuID, optionalMenuSubID);
470
471 ULONG hr = EventWriteMenuShown(
472 DurangoStats::getUserId(iPad),
473 DurangoStats::getPlayerSession(),
474 GetSecondsSinceInitialize(),
475 GetMode(iPad),
476 GetSubMode(iPad),
477 GetLevelId(iPad),
478 GetSubLevelId(iPad),
479 GetLevelInstanceID(),
480 &ZERO_GUID,
481 &ZERO_GUID,
482 menuID,
483 optionalMenuSubID
484 );
485
486 if (hr == 0)
487 {
488 app.DebugPrintf(
489 "<%ls> RecordMenuShown(",
490 "%is,%i,%i,%i,%i,%i,"
491 "%ls,%ls,%i,%i).\n",
492
493 /* WSTR */ DurangoStats::getUserId(iPad),
494
495 // Sentient //
496 /* int */ GetSecondsSinceInitialize(),
497 /* int */ GetMode(iPad),
498 /* int */ GetSubMode(iPad),
499 /* int */ GetLevelId(iPad),
500 /* int */ GetSubLevelId(iPad),
501 /* int */ GetLevelInstanceID(),
502
503 // Durango //
504 /* GUID */ guid2str(DurangoStats::getPlayerSession()).c_str(),
505 /* WSTR */ DurangoStats::getMultiplayerCorrelationId(),
506 /* int */ menuID,
507 /* int */ optionalMenuSubID
508 );
509 }
510
511 return hr == 0;
512}
513
514bool CDurangoTelemetryManager::RecordAchievementUnlocked(int iPad, int achievementID, int achievementGamerscore)
515{
516 CTelemetryManager::RecordAchievementUnlocked(iPad, achievementID, achievementGamerscore);
517
518 ULONG hr = EventWriteAchievemntUnlocked(
519 DurangoStats::getUserId(iPad),
520 DurangoStats::getPlayerSession(),
521 GetSecondsSinceInitialize(),
522 GetMode(iPad),
523 GetSubMode(iPad),
524 GetLevelId(iPad),
525 GetSubLevelId(iPad),
526 GetLevelInstanceID(),
527 &ZERO_GUID,
528 &ZERO_GUID,
529 achievementID,
530 achievementGamerscore
531 );
532
533 if (hr == 0) // Debug.
534 {
535 app.DebugPrintf(
536 "<%ls> RecordPauseOrInactive(",
537 "%is,%i,%i,%i,%i,%i,"
538 "%ls,%ls,%i,%i).\n",
539
540 /* WSTR */ DurangoStats::getUserId(iPad),
541
542 // Sentient //
543 /* int */ GetSecondsSinceInitialize(),
544 /* int */ GetMode(iPad),
545 /* int */ GetSubMode(iPad),
546 /* int */ GetLevelId(iPad),
547 /* int */ GetSubLevelId(iPad),
548 /* int */ GetLevelInstanceID(),
549
550 // Durango //
551 /* GUID */ guid2str(DurangoStats::getPlayerSession()).c_str(),
552 /* WSTR */ DurangoStats::getMultiplayerCorrelationId(),
553 /* int */ achievementID,
554 /* int */ achievementGamerscore
555 );
556 }
557
558 return hr == 0;
559}
560
561bool CDurangoTelemetryManager::RecordMediaShareUpload(int iPad, ESen_MediaDestination mediaDestination, ESen_MediaType mediaType)
562{
563 CTelemetryManager::RecordMediaShareUpload(iPad, mediaDestination, mediaType);
564
565#if 0
566 ULONG hr = EventWriteRecordMediaShareUpload(
567 DurangoStats::getUserId(iPad),
568 DurangoStats::getPlayerSession(),
569 GetSecondsSinceInitialize(),
570 GetMode(iPad),
571 GetSubMode(iPad),
572 GetLevelId(iPad),
573 GetSubLevelId(iPad),
574 GetLevelInstanceID(),
575 &ZERO_GUID,
576 &ZERO_GUID,
577 mediaDestination,
578 mediaType
579 );
580#else
581 ULONG hr = -1;
582#endif
583
584 if (hr == 0)
585 {
586 app.DebugPrintf(
587 "<%ls> RecordPauseOrInactive(",
588 "%is,%i,%i,%i,%i,%i,"
589 "%ls,%ls,%i,%i).\n",
590
591 /* WSTR */ DurangoStats::getUserId(iPad),
592
593 // Sentient //
594 /* int */ GetSecondsSinceInitialize(),
595 /* int */ GetMode(iPad),
596 /* int */ GetSubMode(iPad),
597 /* int */ GetLevelId(iPad),
598 /* int */ GetSubLevelId(iPad),
599 /* int */ GetLevelInstanceID(),
600
601 // Durango //
602 /* GUID */ guid2str(DurangoStats::getPlayerSession()).c_str(),
603 /* WSTR */ DurangoStats::getMultiplayerCorrelationId(),
604 /* int */ mediaDestination,
605 /* int */ mediaType
606 );
607 }
608
609 return hr == 0;
610}
611
612bool CDurangoTelemetryManager::RecordUpsellPresented(int iPad, ESen_UpsellID upsellId, int marketplaceOfferID)
613{
614 //CTelemetryManager::RecordUpsellPresented(iPad, upsellId
615
616 ULONG hr = EventWriteUpsellPresented(
617 DurangoStats::getUserId(iPad),
618 DurangoStats::getPlayerSession(),
619 GetSecondsSinceInitialize(),
620 GetMode(iPad),
621 GetSubMode(iPad),
622 GetLevelId(iPad),
623 GetSubLevelId(iPad),
624 GetLevelInstanceID(),
625 &ZERO_GUID,
626 &ZERO_GUID,
627 upsellId,
628 marketplaceOfferID
629 );
630
631 if (hr == 0)
632 {
633 app.DebugPrintf(
634 "<%ls> RecordPauseOrInactive(",
635 "%is,%i,%i,%i,%i,%i,"
636 "%ls,%ls,%i,%i).\n",
637
638 /* WSTR */ DurangoStats::getUserId(iPad),
639
640 // Sentient //
641 /* int */ GetSecondsSinceInitialize(),
642 /* int */ GetMode(iPad),
643 /* int */ GetSubMode(iPad),
644 /* int */ GetLevelId(iPad),
645 /* int */ GetSubLevelId(iPad),
646 /* int */ GetLevelInstanceID(),
647
648 // Durango //
649 /* GUID */ guid2str(DurangoStats::getPlayerSession()).c_str(),
650 /* WSTR */ DurangoStats::getMultiplayerCorrelationId(),
651 /* int */ upsellId,
652 /* int */ marketplaceOfferID
653 );
654 }
655
656 return hr == 0;
657}
658
659bool CDurangoTelemetryManager::RecordUpsellResponded(int iPad, ESen_UpsellID upsellId, int marketplaceOfferID, ESen_UpsellOutcome upsellOutcome)
660{
661 ULONG hr = EventWriteUpsellResponded(
662 DurangoStats::getUserId(iPad),
663 DurangoStats::getPlayerSession(),
664 GetSecondsSinceInitialize(),
665 GetMode(iPad),
666 GetSubMode(iPad),
667 GetLevelId(iPad),
668 GetSubLevelId(iPad),
669 GetLevelInstanceID(),
670 &ZERO_GUID,
671 &ZERO_GUID,
672 upsellId,
673 marketplaceOfferID,
674 upsellOutcome
675 );
676
677 if (hr == 0)
678 {
679 app.DebugPrintf(
680 "<%ls> RecordPauseOrInactive(",
681 "%is,%i,%i,%i,%i,%i,"
682 "%ls,%ls).\n",
683
684 /* WSTR */ DurangoStats::getUserId(iPad),
685
686 // Sentient //
687 /* int */ GetSecondsSinceInitialize(),
688 /* int */ GetMode(iPad),
689 /* int */ GetSubMode(iPad),
690 /* int */ GetLevelId(iPad),
691 /* int */ GetSubLevelId(iPad),
692 /* int */ GetLevelInstanceID(),
693
694 // Durango //
695 /* GUID */ guid2str(DurangoStats::getPlayerSession()).c_str(),
696 /* WSTR */ DurangoStats::getMultiplayerCorrelationId(),
697 /* int */ upsellId,
698 /* int */ marketplaceOfferID,
699 /* int */ upsellOutcome
700 );
701 }
702
703 return hr == 0;
704}
705
706bool CDurangoTelemetryManager::RecordPlayerDiedOrFailed(int iPad, int lowResMapX, int lowResMapY, int lowResMapZ, int mapID, int playerWeaponID, int enemyWeaponID, ETelemetryChallenges enemyTypeID)
707{
708 ULONG hr = EventWritePlayerDiedOrFailed(
709 DurangoStats::getUserId(iPad),
710 DurangoStats::getPlayerSession(),
711 GetSecondsSinceInitialize(),
712 GetMode(iPad),
713 GetSubMode(iPad),
714 GetLevelId(iPad),
715 GetSubLevelId(iPad),
716 GetLevelInstanceID(),
717 &ZERO_GUID,
718 &ZERO_GUID,
719 lowResMapX,
720 lowResMapY,
721 lowResMapZ,
722 mapID,
723 playerWeaponID,
724 enemyWeaponID,
725 enemyTypeID
726 );
727
728 if (hr == 0)
729 {
730 app.DebugPrintf(
731 "<%ls> RecordPauseOrInactive(",
732 "%is,%i,%i,%i,%i,%i,"
733 "%ls,%ls,%i,%i,%i,%i,%i,%i,%i).\n",
734
735 /* WSTR */ DurangoStats::getUserId(iPad),
736
737 // Sentient //
738 /* int */ GetSecondsSinceInitialize(),
739 /* int */ GetMode(iPad),
740 /* int */ GetSubMode(iPad),
741 /* int */ GetLevelId(iPad),
742 /* int */ GetSubLevelId(iPad),
743 /* int */ GetLevelInstanceID(),
744
745 // Durango //
746 /* GUID */ guid2str(DurangoStats::getPlayerSession()).c_str(),
747 /* WSTR */ DurangoStats::getMultiplayerCorrelationId(),
748 /* int */ lowResMapX,
749 /* int */ lowResMapY,
750 /* int */ lowResMapZ,
751 /* int */ mapID,
752 /* int */ playerWeaponID,
753 /* int */ enemyWeaponID,
754 /* int */ enemyTypeID
755 );
756 }
757
758 return hr == 0;
759}
760
761bool CDurangoTelemetryManager::RecordEnemyKilledOrOvercome(int iPad, int lowResMapX, int lowResMapY, int lowResMapZ, int mapID, int playerWeaponID, int enemyWeaponID, ETelemetryChallenges enemyTypeID)
762{
763 ULONG hr = -1;
764
765 if (hr == 0)
766 {
767 app.DebugPrintf(
768 "<%ls> RecordPauseOrInactive(",
769 "%is,%i,%i,%i,%i,%i,"
770 "%ls,%ls,%i,%i,%i,%i,%i,%i,%i).\n",
771
772 /* WSTR */ DurangoStats::getUserId(iPad),
773
774 // Sentient //
775 /* int */ GetSecondsSinceInitialize(),
776 /* int */ GetMode(iPad),
777 /* int */ GetSubMode(iPad),
778 /* int */ GetLevelId(iPad),
779 /* int */ GetSubLevelId(iPad),
780 /* int */ GetLevelInstanceID(),
781
782 // Durango //
783 /* GUID */ guid2str(DurangoStats::getPlayerSession()).c_str(),
784 /* WSTR */ DurangoStats::getMultiplayerCorrelationId(),
785 /* int */ lowResMapX,
786 /* int */ lowResMapY,
787 /* int */ lowResMapZ,
788 /* int */ mapID,
789 /* int */ playerWeaponID,
790 /* int */ enemyWeaponID,
791 /* int */ enemyTypeID
792 );
793 }
794 // NO EVENT TO SEND, ALREADY COVERED BY STATISTIC CODE!
795
796 return hr == 0;
797}
798
799bool CDurangoTelemetryManager::RecordTexturePackLoaded(int iPad, int texturePackId, bool purchased)
800{
801 ULONG hr = EventWriteTexturePackLoaded(
802 DurangoStats::getUserId(iPad),
803 DurangoStats::getPlayerSession(),
804 GetSecondsSinceInitialize(),
805 GetMode(iPad),
806 GetSubMode(iPad),
807 GetLevelId(iPad),
808 GetSubLevelId(iPad),
809 GetLevelInstanceID(),
810 &ZERO_GUID,
811 &ZERO_GUID,
812 texturePackId,
813 purchased
814 );
815
816 if (hr == 0) // Debug.
817 {
818 app.DebugPrintf(
819 "<%ls> RecordPauseOrInactive(",
820 "%is,%i,%i,%i,%i,%i,"
821 "%ls,%ls,%i,%s).\n",
822
823 /* WSTR */ DurangoStats::getUserId(iPad),
824
825 // Sentient //
826 /* int */ GetSecondsSinceInitialize(),
827 /* int */ GetMode(iPad),
828 /* int */ GetSubMode(iPad),
829 /* int */ GetLevelId(iPad),
830 /* int */ GetSubLevelId(iPad),
831 /* int */ GetLevelInstanceID(),
832
833 // Durango //
834 /* GUID */ guid2str(DurangoStats::getPlayerSession()).c_str(),
835 /* WSTR */ DurangoStats::getMultiplayerCorrelationId(),
836 /* int */ texturePackId,
837 /* bool */ (purchased ? "Purchased" : "NotPurchased")
838 );
839 }
840
841 return hr == 0;
842}
843
844bool CDurangoTelemetryManager::RecordSkinChanged(int iPad, int dwSkinId)
845{
846 ULONG hr = EventWriteSkinChanged(
847 DurangoStats::getUserId(iPad),
848 DurangoStats::getPlayerSession(),
849 GetSecondsSinceInitialize(),
850 GetMode(iPad),
851 GetSubMode(iPad),
852 GetLevelId(iPad),
853 GetSubLevelId(iPad),
854 GetLevelInstanceID(),
855 &ZERO_GUID,
856 &ZERO_GUID,
857 dwSkinId
858 );
859
860 if (hr == 0)
861 {
862 app.DebugPrintf(
863 "<%ls> RecordSkinChanged(",
864 "%is,%i,%i,%i,%i,%i,"
865 "%ls,%ls,%i).\n",
866
867 /* WSTR */ DurangoStats::getUserId(iPad),
868
869 // Sentient //
870 /* int */ GetSecondsSinceInitialize(),
871 /* int */ GetMode(iPad),
872 /* int */ GetSubMode(iPad),
873 /* int */ GetLevelId(iPad),
874 /* int */ GetSubLevelId(iPad),
875 /* int */ GetLevelInstanceID(),
876
877 // Durango //
878 /* GUID */ guid2str(DurangoStats::getPlayerSession()).c_str(),
879 /* WSTR */ DurangoStats::getMultiplayerCorrelationId(),
880 /* int */ dwSkinId
881 );
882 }
883
884 return hr == 0;
885}
886
887bool CDurangoTelemetryManager::RecordBanLevel(int iPad)
888{
889 ULONG hr = EventWriteBanLevel(
890 DurangoStats::getUserId(iPad),
891 DurangoStats::getPlayerSession(),
892 GetSecondsSinceInitialize(),
893 GetMode(iPad),
894 GetSubMode(iPad),
895 GetLevelId(iPad),
896 GetSubLevelId(iPad),
897 GetLevelInstanceID(),
898 &ZERO_GUID,
899 &ZERO_GUID
900 );
901
902 if (hr == 0)
903 {
904 app.DebugPrintf(
905 "<%ls> RecordBanLevel(",
906 "%is,%i,%i,%i,%i,%i,"
907 "%ls,%ls).\n",
908
909 /* WSTR */ DurangoStats::getUserId(iPad),
910
911 // Sentient //
912 /* int */ GetSecondsSinceInitialize(),
913 /* int */ GetMode(iPad),
914 /* int */ GetSubMode(iPad),
915 /* int */ GetLevelId(iPad),
916 /* int */ GetSubLevelId(iPad),
917 /* int */ GetLevelInstanceID(),
918
919 // Durango //
920 /* GUID */ guid2str(DurangoStats::getPlayerSession()).c_str(),
921 /* WSTR */ DurangoStats::getMultiplayerCorrelationId()
922 );
923 }
924
925 return hr == 0;
926}
927
928bool CDurangoTelemetryManager::RecordUnBanLevel(int iPad)
929{
930 ULONG hr = EventWriteUnbanLevel(
931 DurangoStats::getUserId(iPad),
932 DurangoStats::getPlayerSession(),
933 GetSecondsSinceInitialize(),
934 GetMode(iPad),
935 GetSubMode(iPad),
936 GetLevelId(iPad),
937 GetSubLevelId(iPad),
938 GetLevelInstanceID(),
939 &ZERO_GUID,
940 &ZERO_GUID
941 );
942
943 if (hr == 0) // Debug.
944 {
945 app.DebugPrintf(
946 "<%ls> RecordUnBanLevel(",
947 "%is,%i,%i,%i,%i,%i,"
948 "%ls,%ls).\n",
949
950 /* WSTR */ DurangoStats::getUserId(iPad),
951
952 // Sentient //
953 /* int */ GetSecondsSinceInitialize(),
954 /* int */ GetMode(iPad),
955 /* int */ GetSubMode(iPad),
956 /* int */ GetLevelId(iPad),
957 /* int */ GetSubLevelId(iPad),
958 /* int */ GetLevelInstanceID(),
959
960 // Durango //
961 /* GUID */ guid2str(DurangoStats::getPlayerSession()).c_str(),
962 /* WSTR */ DurangoStats::getMultiplayerCorrelationId()
963 );
964 }
965
966 return hr == 0;
967}
968
969DurangoStats *CDurangoTelemetryManager::durangoStats()
970{
971 return (DurangoStats*) GenericStats::getInstance();
972}
973
974wstring CDurangoTelemetryManager::guid2str(LPCGUID guid)
975{
976 wstring out = L"GUID<";
977 out += _toString<unsigned long>(guid->Data1);
978 out += L":";
979 out += _toString<unsigned short>(guid->Data2);
980 out += L":";
981 out += _toString<unsigned short>(guid->Data3);
982 //out += L":";
983 //out += convStringToWstring(string((char*)&guid->Data4,8));
984 out += L">";
985 return out;
986}