-
Notifications
You must be signed in to change notification settings - Fork 8
/
wwfcGPReport.cpp
68 lines (55 loc) · 1.55 KB
/
wwfcGPReport.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "wwfcGPReport.hpp"
#include "import/dwc.h"
#include "import/gamespy.h"
#include "wwfcLibC.hpp"
#include "wwfcLog.hpp"
namespace wwfc::GPReport
{
#if RMC
void Report(const char* key, const char* string)
{
auto connection = DWC::stpMatchCnt->connection;
if (connection == nullptr) {
return;
}
auto iconnection = reinterpret_cast<GameSpy::GPIConnection*>(*connection);
GameSpy::gpiAppendStringToBuffer(
connection, &iconnection->outputBuffer, "\\wwfc_report\\\\"
);
GameSpy::gpiAppendStringToBuffer(
connection, &iconnection->outputBuffer, key
);
GameSpy::gpiAppendStringToBuffer(
connection, &iconnection->outputBuffer, "\\"
);
GameSpy::gpiAppendStringToBuffer(
connection, &iconnection->outputBuffer, string
);
GameSpy::gpiAppendStringToBuffer(
connection, &iconnection->outputBuffer, "\\final\\"
);
}
void ReportU32(const char* key, u32 uint)
{
char buffer[sizeof("4294967295")];
if (snprintf(buffer, sizeof(buffer), "%lu", uint) < 0) {
return;
}
Report(key, buffer);
}
void ReportB64Encode(const char* key, const void* data, size_t dataSize)
{
char b64Data[0x400];
s32 b64Size =
DWC::DWC_Base64Encode(data, dataSize, b64Data, sizeof(b64Data));
if (b64Size == -1 || b64Size == sizeof(b64Data)) {
LOG_ERROR(
"Could not fit the base64-encoded data into the provided buffer!"
);
return;
}
b64Data[b64Size] = '\0';
Report(key, b64Data);
}
#endif
} // namespace wwfc::GPReport