Skip to content

Commit

Permalink
Fix music rate to only one decimal (same as ingame) + add "-omni" to …
Browse files Browse the repository at this point in the history
…supported versions
  • Loading branch information
Meta-link committed Dec 26, 2022
1 parent 62521b2 commit f567155
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ A small hook to gather scores from the arcade rhythm game jubeat by reading the

# Planned features

* Local matching support (right now it will send wrong scores for each song)
* Export session scores into a single .json file
* More games support

Expand Down
22 changes: 18 additions & 4 deletions jubeat-hook/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ HardModeData* hardMode = nullptr;
Scores* scores = nullptr;
Results* results = nullptr;
CardData* card = nullptr;
DatecodeData* datecode = nullptr;

AdditionalData additionalData;
int currentSong = 0;
Expand All @@ -35,6 +36,7 @@ json FileContentData;
json KamaiResponse;

int currentGameVersion = -1;
bool isOmni = false;
bool showDebug;
string playerID;
bool exportFile;
Expand Down Expand Up @@ -78,7 +80,7 @@ void ScoreDump()
printf("TOTAL SCORE = %i\n", additionalData.ScoreTotal);
printf("RATING = %s\n", Rating[additionalData.Rating]);
printf("CLEAR = %s\n", ClearType[additionalData.ClearType]);
printf("MUSIC RATE = %f\n\n", additionalData.MusicRate);
printf("MUSIC RATE = %.1f\n\n", additionalData.MusicRate);
}

void SetupJson()
Expand All @@ -90,7 +92,7 @@ void SetupJson()
{"service", "jubeat-hook"},
{"game", "jubeat"},
{"playtype", "Single"},
{"version", VersionName[GameAdresses[currentGameVersion].Version]}
{"version", string(VersionName[GameAdresses[currentGameVersion].Version]) + (isOmni ? "-omni" : "")}
}
},
{
Expand Down Expand Up @@ -172,6 +174,7 @@ void ProcessScore()
}

additionalData.MusicRate = ((scores->ScoresData[currentSong].PerfectCount + 0.2 * scores->ScoresData[currentSong].GreatCount + 0.05 * scores->ScoresData[currentSong].GoodCount) / scores->ScoresData[currentSong].NoteCount) * (hardMode->HardMode ? 120 : 100);
additionalData.MusicRate = ((int)(additionalData.MusicRate * 10)) / 10.0;

if (showDebug)
{
Expand Down Expand Up @@ -294,8 +297,6 @@ DWORD WINAPI InitHook(LPVOID dllInstance)
}
else
{
SetupJson();

if (exportFile)
{
const auto now = chrono::system_clock::now();
Expand Down Expand Up @@ -325,6 +326,19 @@ DWORD WINAPI InitHook(LPVOID dllInstance)
results = (Results*)(jubeatAdress + GameAdresses[currentGameVersion].ResultAdress);
card = (CardData*)(jubeatAdress + GameAdresses[currentGameVersion].CardAdress);

if (GameAdresses[currentGameVersion].DatecodeAdress != 0x0) //Check for omnimix
{
datecode = (DatecodeData*)(jubeatAdress + GameAdresses[currentGameVersion].DatecodeAdress);
while (!strcmp(datecode->Datecode, ""));
if (strchr(datecode->Datecode, 'X') != NULL)
{
printDebug("Omnimix detected");
isOmni = true;
}
}

SetupJson();

do {
if (currentSong != 0 && results->ResultsData[0].Clear == 0) //New credit
{
Expand Down
18 changes: 11 additions & 7 deletions jubeat-hook/jubeat-hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@ struct Adresses {
uintptr_t ResultAdress;
uintptr_t CardAdress;
Version Version;
uintptr_t DatecodeAdress; //Only used for omnimix detection, 0x0 if there is none
};

struct Adresses GameAdresses[] = {
//Qubell
{"2017041500", 0x9BD9B44, 0x9BA9527, 0x9B9D880, 0x9BC02F4, 0x9BAAE90, qubell},
{"2017062001", 0x9BDDC0C, 0x9BAD597, 0x9BA18B0, 0x9BC43BC, 0x9BAEF00, qubell},
{"2017041500", 0x9BD9B44, 0x9BA9527, 0x9B9D880, 0x9BC02F4, 0x9BAAE90, qubell, 0x0},
{"2017062001", 0x9BDDC0C, 0x9BAD597, 0x9BA18B0, 0x9BC43BC, 0x9BAEF00, qubell, 0x0},
//clan
{"2018070901", 0xBDF8B6C, 0xBDC0F5F, 0xBDB4E18, 0xBDDF5B4, 0xBDC2730, clan},
{"2018070901", 0xBDF8B6C, 0xBDC0F5F, 0xBDB4E18, 0xBDDF5B4, 0xBDC2730, clan, 0x0},
//festo
{"2018112702", 0x1074F860, 0xF50A6C, 0x11C5E60, 0x122C104, 0xF579C0, festo},
{"2022052400", 0x107752C0, 0xF93084, 0x120D190, 0x124EC64, 0xF9A6C0, festo},
{"2018112702", 0x1074F860, 0xF50A6C, 0x11C5E60, 0x122C104, 0xF579C0, festo, 0x0},
{"2022052400", 0x107752C0, 0xF93084, 0x120D190, 0x124EC64, 0xF9A6C0, festo, 0xE928DB},
};

const int32_t ScoreSize = 0xA0;
Expand All @@ -51,7 +52,7 @@ struct HardModeData {

struct ScoreData {
int32_t Score; //11C5E60
int32_t LastCombo; //11C5E64 might be last combo before end
int32_t LastCombo; //11C5E64
int32_t MaxCombo; //11C5E68
int32_t Bonus; // 11C5E6C
int32_t NoteCount; //11C5E70
Expand Down Expand Up @@ -83,7 +84,7 @@ struct AdditionalData {
int ScoreTotal;
int Rating;
int ClearType;
float MusicRate;
double MusicRate;
};

struct CardData {
Expand All @@ -94,6 +95,9 @@ struct CardData {
char CardHolder[9]; //F57A34
};

struct DatecodeData {
char Datecode[21]; //E928DB
};

const char* Difficulty[]
{
Expand Down
1 change: 1 addition & 0 deletions jubeat-hook/jubeat-hook.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpplatest</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down

0 comments on commit f567155

Please sign in to comment.