cleanup for music limit check

This commit is contained in:
CrazyRedMachine 2024-05-01 04:55:37 +02:00
parent 1f630edb10
commit dc63a6df08

View File

@ -1484,20 +1484,6 @@ static bool patch_database() {
DWORD dllSize = 0;
char *data = getDllData(g_game_dll_fn, &dllSize);
patch_purelong();
{
int64_t pattern_offset = search(data, dllSize, "\x8D\x44\x24\x10\x88\x4C\x24\x10\x88\x5C\x24\x11\x8D\x50\x01", 15, 0);
if (pattern_offset != -1) {
uint64_t patch_addr = (int64_t)data + pattern_offset;
MH_CreateHook((LPVOID)patch_addr, (LPVOID)omnimix_patch_jbx,
(void **)&real_omnimix_patch_jbx);
LOG("popnhax: Patched X rev for omnimix\n");
} else {
LOG("popnhax: Couldn't find rev patch\n");
}
}
char *target;
if (config.patch_xml_auto) {
@ -1581,7 +1567,8 @@ static bool patch_database() {
}
if (!found) {
LOG("popnhax: patch_db: matching datecode or limit not found, defaulting to latest patch file (will probably crash).\n");
LOG("popnhax: patch_db: matching %s not found, please add the correct patch xml file in data_mods folder.\n", (music_limit == 0) ? "datecode" : "music limit");
return false;
}
LOG("popnhax: patch_db: using %s\n",filename);
@ -1627,6 +1614,21 @@ static bool patch_database() {
);
limit_table[STYLE_TABLE_IDX] = new_limit_table[STYLE_TABLE_IDX];
patch_purelong();
{
int64_t pattern_offset = search(data, dllSize, "\x8D\x44\x24\x10\x88\x4C\x24\x10\x88\x5C\x24\x11\x8D\x50\x01", 15, 0);
if (pattern_offset != -1) {
uint64_t patch_addr = (int64_t)data + pattern_offset;
MH_CreateHook((LPVOID)patch_addr, (LPVOID)omnimix_patch_jbx,
(void **)&real_omnimix_patch_jbx);
LOG("popnhax: Patched X rev for omnimix\n");
} else {
LOG("popnhax: Couldn't find rev patch\n");
}
}
if (config.disable_redirection) {
LOG("Redirection-related code is disabled, buffer address, buffer size and related patches will not be applied");
printf("Redirection-related code is disabled, buffer address, buffer size and related patches will not be applied");
@ -5683,13 +5685,15 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
}
if (config.patch_db) {
LOG("popnhax: patching songdb\n");
/* must be called after force_datecode */
LOG("popnhax: patching songdb\n");
if ( patch_database() )
{
patch_db_power_points();
patch_db_fix_cursor();
if (config.custom_categ)
patch_custom_categs(g_game_dll_fn, &config);
patch_database();
}
}
if (config.force_unlocks) {