-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDvdArchive.cpp
More file actions
47 lines (39 loc) · 1.68 KB
/
DvdArchive.cpp
File metadata and controls
47 lines (39 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <common/Common.hpp>
#include <egg/core/eggDecomp.hpp>
#include <game/system/DvdArchive.hpp>
#include <game/system/RaceConfig.hpp>
#include <platform/string.h>
#include <revolution/os/OSCache.h>
#include <revolutionex/net/NETDigest.h>
#include <wiimmfi/Reporting.hpp>
///////////////////////
// Wiimmfi Telemetry //
///////////////////////
// DvdArchive::decompress() override
// Hash track file, store the hash and report it to Wiimmfi if necessary
// Credits: Wiimmfi
kmBranchDefCpp(0x80519508, NULL, void, DvdArchive* self, const char* path, EGG::Heap* heap) {
// Get decompressed size
u32 decompressedSize = EGG::Decomp::getExpandSize(self->fileBuffer);
// Allocate the buffer and decode the file in it
void* buffer = heap->alloc(decompressedSize, 0x20);
EGG::Decomp::decodeSZS(self->fileBuffer, buffer);
// Store info and invalidate cache
self->archiveSize = decompressedSize;
self->archiveBuffer = buffer;
self->archiveHeap = heap;
DCStoreRange(buffer, decompressedSize);
self->state = DvdArchive::DECOMPRESSED;
// Check if it's a track file, if not bail
// The path will be null if the course is being loaded from the cache, so check for that as well
if (path && !strstartw(path, "Race/Course/"))
return;
// Check if we're online, if not bail
// We cannot use the isOnline variable since it hasn't been initialized yet
if (!RaceConfig::instance->raceScenario.settings.isOnline())
return;
// We're online, send the track hash to the server
u32 hash[5];
NETCalcSHA1(hash, buffer, decompressedSize);
Wiimmfi::Reporting::ReportTrackHash(hash, RaceConfig::instance->raceScenario.settings.courseId);
}