forked from Popn_Tools/popnhax
different favorite files per game version
This commit is contained in:
parent
f0daa9e761
commit
0b88b1253d
@ -4,6 +4,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
struct popnhax_config {
|
||||
uint8_t game_version;
|
||||
bool practice_mode;
|
||||
bool hidden_is_offset;
|
||||
bool iidx_hard_gauge;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "minhook/hde32.h"
|
||||
#include "minhook/include/MinHook.h"
|
||||
|
||||
uint8_t g_game_version;
|
||||
uint32_t g_playerdata_ptr_addr; //pointer to the playerdata memory zone (offset 0x08 is popn friend ID as ascii (12 char long), offset 0x1A5 is "is logged in" flag)
|
||||
char *g_current_friendid;
|
||||
uint32_t g_current_songid;
|
||||
@ -78,7 +79,7 @@ void remove_song_from_favorites()
|
||||
void prepare_favorite_list(){
|
||||
|
||||
char fav_filepath[64];
|
||||
sprintf(fav_filepath, "data_mods\\%s.fav", g_current_friendid);
|
||||
sprintf(fav_filepath, "data_mods\\%d.%s.fav", g_game_version, g_current_friendid);
|
||||
FILE *file = fopen(fav_filepath, "rb");
|
||||
|
||||
favorites_count = 0;
|
||||
@ -111,7 +112,7 @@ void commit_favorites()
|
||||
return;
|
||||
|
||||
char fav_filepath[64];
|
||||
sprintf(fav_filepath, "data_mods\\%s.fav", g_current_friendid);
|
||||
sprintf(fav_filepath, "data_mods\\%d.%s.fav", g_game_version, g_current_friendid);
|
||||
FILE *file = fopen(fav_filepath, "w");
|
||||
|
||||
if ( file == NULL )
|
||||
@ -964,37 +965,6 @@ static void load_databases() {
|
||||
}
|
||||
LOG("\n");
|
||||
}
|
||||
/*
|
||||
bool load_favorites(){
|
||||
favorites_count = subcategories[0].size;
|
||||
favorites = subcategories[0].songlist;
|
||||
return true;
|
||||
}*/
|
||||
|
||||
bool load_favorites(){
|
||||
FILE *file = fopen("data_mods\\default.fav", "rb");
|
||||
|
||||
if (file == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
char line[32];
|
||||
|
||||
while (fgets(line, sizeof(line), file)) {
|
||||
/* note that fgets don't strip the terminating \n, checking its
|
||||
presence would allow to handle lines longer that sizeof(line) */
|
||||
int songid = strtol(line, NULL, 10);
|
||||
if ( songid != 0 )
|
||||
{
|
||||
favorites = (uint32_t *) realloc(favorites, sizeof(uint32_t)*(favorites_count+5));
|
||||
favorites[favorites_count++] = songid | 0x00060000; // game wants this otherwise only easy difficulty will appear
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
LOG("added %d songs to favorites\n",favorites_count);
|
||||
return true;
|
||||
}
|
||||
|
||||
void (*real_getversion)();
|
||||
void hook_getversion()
|
||||
@ -1106,8 +1076,8 @@ LOG("custom title format is %s\n", g_customformat);
|
||||
return patch_custom_categ(dllFilename);
|
||||
}
|
||||
|
||||
bool patch_local_favorites(const char *dllFilename)
|
||||
bool patch_local_favorites(const char *dllFilename, uint8_t version)
|
||||
{
|
||||
//load_favorites();
|
||||
g_game_version = version;
|
||||
return patch_favorite_categ(dllFilename);
|
||||
}
|
@ -5,6 +5,6 @@
|
||||
#include "popnhax/config.h"
|
||||
|
||||
bool patch_custom_categs(const char *dllFilename, struct popnhax_config *config);
|
||||
bool patch_local_favorites(const char *dllFilename);
|
||||
bool patch_local_favorites(const char *dllFilename, uint8_t version);
|
||||
|
||||
#endif
|
||||
|
@ -5303,6 +5303,22 @@ static bool option_net_ojama_off(){
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t get_version()
|
||||
{
|
||||
DWORD dllSize = 0;
|
||||
char *data = getDllData(g_game_dll_fn, &dllSize);
|
||||
{
|
||||
int64_t pattern_offset = search(data, dllSize, "\x00\x8B\x56\x04\x0F\xB7\x02\xE8", 8, 0);
|
||||
if (pattern_offset == -1) {
|
||||
LOG("popnhax: get_version: cannot retrieve game version (eclale or less?)\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t version = *(uint8_t*)(data + pattern_offset + 14);
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
|
||||
switch (ul_reason_for_call) {
|
||||
case DLL_PROCESS_ATTACH: {
|
||||
@ -5374,7 +5390,9 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
||||
free(tmp_name);
|
||||
}
|
||||
|
||||
LOG("popnhax: game dll: %s\n",g_game_dll_fn);
|
||||
uint8_t game_version = get_version();
|
||||
|
||||
LOG("popnhax: game dll: %s (popn%d)\n",g_game_dll_fn, game_version);
|
||||
LOG("popnhax: config file: %s\n",g_config_fn);
|
||||
|
||||
if (!_load_config(g_config_fn, &config, config_psmap))
|
||||
@ -5383,12 +5401,15 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
config.game_version = game_version;
|
||||
|
||||
if (force_trans_debug)
|
||||
config.translation_debug = true;
|
||||
|
||||
if (force_no_omni)
|
||||
config.patch_db = false;
|
||||
|
||||
|
||||
if (!config.disable_multiboot)
|
||||
{
|
||||
/* automatically force datecode based on dll name when applicable (e.g. popn22_2022061300.dll and no force_datecode) */
|
||||
@ -5398,21 +5419,26 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
||||
LOG("popnhax: multiboot autotune activated (custom game dll, force_datecode off)\n");
|
||||
memcpy(config.force_datecode, g_game_dll_fn+7, 10);
|
||||
LOG("popnhax: multiboot: auto set datecode to %s\n", config.force_datecode);
|
||||
if (config.score_challenge && ( strcmp(config.force_datecode,"2020092800") <= 0 ) )
|
||||
if (config.score_challenge && ( config.game_version < 26 || strcmp(config.force_datecode,"2020092800") <= 0 ) )
|
||||
{
|
||||
LOG("popnhax: multiboot: auto disable score challenge patch (already ingame)\n");
|
||||
config.score_challenge = false;
|
||||
}
|
||||
if (config.patch_db && ( strcmp(config.force_datecode,"2016121400") < 0 ) )
|
||||
if (config.patch_db && ( config.game_version == 0 || strcmp(config.force_datecode,"2016121400") < 0 ) )
|
||||
{
|
||||
LOG("popnhax: multiboot: auto disable omnimix patch (not compatible)\n");
|
||||
config.patch_db = false;
|
||||
}
|
||||
if (config.guidese_off && ( strcmp(config.force_datecode,"2016121400") < 0 ) )
|
||||
if (config.guidese_off && ( config.game_version == 0 || strcmp(config.force_datecode,"2016121400") < 0 ) )
|
||||
{
|
||||
LOG("popnhax: multiboot: auto disable Guide SE patch (not compatible)\n");
|
||||
config.guidese_off = false;
|
||||
}
|
||||
if (config.local_favorites && ( config.game_version == 0 || strcmp(config.force_datecode,"2016121400") < 0 ) )
|
||||
{
|
||||
LOG("popnhax: multiboot: auto disable local favorites patch (not compatible)\n");
|
||||
config.local_favorites = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5616,7 +5642,14 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
||||
}
|
||||
|
||||
if (config.local_favorites)
|
||||
patch_local_favorites(g_game_dll_fn);
|
||||
{
|
||||
if ( config.game_version == 0 )
|
||||
{
|
||||
LOG("popnhax: local_favorites: patch is not compatible with your game version.\n");
|
||||
} else {
|
||||
patch_local_favorites(g_game_dll_fn, config.game_version);
|
||||
}
|
||||
}
|
||||
|
||||
if (config.force_full_opt)
|
||||
option_full();
|
||||
|
Loading…
Reference in New Issue
Block a user