diff --git a/dist/popnhax/popnhax.xml b/dist/popnhax/popnhax.xml index a0baebf..cdd49d5 100644 --- a/dist/popnhax/popnhax.xml +++ b/dist/popnhax/popnhax.xml @@ -131,7 +131,7 @@ THREAD_PRIORITY_TIME_CRITICAL 15 --> 1 - + 1 @@ -143,11 +143,13 @@ 0 - - - 4000 - - 65400 + + + 0 + + 0 + + 0 Customs diff --git a/popnhax/config.h b/popnhax/config.h index dfd9e9d..0014780 100644 --- a/popnhax/config.h +++ b/popnhax/config.h @@ -17,7 +17,6 @@ struct popnhax_config { bool score_challenge; uint8_t custom_categ; uint16_t custom_categ_min_songid; - uint16_t custom_categ_max_songid; bool custom_exclude_from_version; bool custom_exclude_from_level; bool force_hd_timing; @@ -64,6 +63,8 @@ struct popnhax_config { char custom_category_format[64]; char custom_track_title_format[64]; char custom_track_title_format2[64]; + bool exclude_omni; + bool partial_entries; }; #endif diff --git a/popnhax/custom_categs.cc b/popnhax/custom_categs.cc index 8f84226..d508588 100644 --- a/popnhax/custom_categs.cc +++ b/popnhax/custom_categs.cc @@ -36,12 +36,11 @@ char *g_current_friendid; uint32_t g_current_songid; bst_t *g_customs_bst = NULL; +bool g_exclude_omni = false; void (*add_song_in_list)(); bool g_subcategmode = false; -uint32_t g_min_id = 4000; -uint32_t g_max_id = 0; const char *g_categicon; const char *g_categformat; @@ -62,8 +61,12 @@ uint32_t favorites_struct_addr = (uint32_t)&favorites_struct; bool is_a_custom(uint32_t songid) { - return (bst_search(g_customs_bst, songid) != NULL); -// return (songid >= g_min_id && (g_max_id==0 || g_max_id >= songid)); + return (bst_search(g_customs_bst, songid) != NULL); +} + +bool is_excluded_from_level(uint32_t songid) +{ + return ( is_a_custom(songid) && ( g_exclude_omni || songid >= 3000 ) ); } void add_song_to_favorites() @@ -769,7 +772,7 @@ static bool patch_favorite_categ(const char *game_dll_fn) { return true; } -static bool patch_custom_categ(const char *game_dll_fn) { +static bool patch_custom_categ(const char *game_dll_fn, uint16_t min_id) { DWORD dllSize = 0; char *data = getDllData(game_dll_fn, &dllSize); @@ -914,22 +917,21 @@ static bool patch_custom_categ(const char *game_dll_fn) { char formatted_title[128]; sprintf(formatted_title, g_categformat, g_categname); - LOG("popnhax: custom %s \"%s\" injected (for songids ", g_subcategmode? "subcategories":"category", formatted_title); - if (g_max_id) - LOG("between %d and %d (incl.))\n", g_min_id, g_max_id); - else - LOG("%d and up)\n", g_min_id); + LOG("popnhax: custom %s \"%s\" injected", g_subcategmode? "subcategories":"category", formatted_title); + if (min_id) + LOG(" (for songids >= %d)", min_id); + LOG("\n"); return true; } void init_subcategories() { - g_subcategmode = true; - g_subcateg_count = 0; - subcategories = (subcategory_s*)realloc(subcategories, sizeof(subcategory_s)*(1)); - subcategories[0].name = strdup("ALL SONGS"); - subcategories[0].songlist = NULL; - subcategories[0].size = 0; + g_subcategmode = true; + g_subcateg_count = 0; + subcategories = (subcategory_s*)realloc(subcategories, sizeof(subcategory_s)*(1)); + subcategories[0].name = strdup("ALL SONGS"); + subcategories[0].songlist = NULL; + subcategories[0].size = 0; } static void print_databases() { @@ -951,7 +953,7 @@ void hook_after_getlevel() __asm("push ecx\n"); __asm("push edx\n"); __asm("push ebx\n"); - __asm("call %P0" : : "i"(is_a_custom)); + __asm("call %P0" : : "i"(is_excluded_from_level)); __asm("test eax, eax\n"); __asm("pop ebx\n"); __asm("pop edx\n"); @@ -992,8 +994,6 @@ bool patch_exclude(const char *game_dll_fn) bool patch_custom_categs(const char *dllFilename, struct popnhax_config *config) { - g_min_id = config->custom_categ_min_songid; - //g_max_id = config->custom_categ_max_songid; //handled during injection already uint8_t mode = config->custom_categ; char icon_path[64]; @@ -1022,7 +1022,7 @@ bool patch_custom_categs(const char *dllFilename, struct popnhax_config *config) else g_categformat = "%s"; - if (!patch_custom_categ(dllFilename)) + if (!patch_custom_categ(dllFilename, config->custom_categ_min_songid)) return false; if (mode == 2) @@ -1040,8 +1040,12 @@ bool patch_custom_categs(const char *dllFilename, struct popnhax_config *config) if (config->custom_exclude_from_version) LOG("popnhax: Customs excluded from version folders\n"); //musichax_core_init took care of it + if (config->custom_exclude_from_level) + { + g_exclude_omni = config->exclude_omni; patch_exclude(dllFilename); + } return true; } diff --git a/popnhax/dllmain.cc b/popnhax/dllmain.cc index 5140e2a..fc034f7 100644 --- a/popnhax/dllmain.cc +++ b/popnhax/dllmain.cc @@ -187,10 +187,12 @@ PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_S8, struct popnhax_config, base_offset, "/popnhax/base_offset") PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U8, struct popnhax_config, custom_categ, "/popnhax/custom_categ") +PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, exclude_omni, + "/popnhax/exclude_omni") +PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, partial_entries, + "/popnhax/partial_entries") PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U16, struct popnhax_config, custom_categ_min_songid, "/popnhax/custom_categ_min_songid") -PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U16, struct popnhax_config, custom_categ_max_songid, - "/popnhax/custom_categ_max_songid") PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, custom_exclude_from_version, "/popnhax/custom_exclude_from_version") PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, custom_exclude_from_level, diff --git a/popnhax/loader.cc b/popnhax/loader.cc index 5fa0347..7c5b437 100644 --- a/popnhax/loader.cc +++ b/popnhax/loader.cc @@ -888,19 +888,12 @@ void parse_musicdb(const char *input_filename, const char *target, struct popnha bool is_gone = ( m != NULL && strcmp((const char*) m->title_ptr, "\x81\x5D") == 0); // removed entries all have this title (SJIS "-") // Update customs/omni songid list - if ( is_fresh || is_gone ) + if ( is_fresh || is_gone || config->partial_entries ) { - //TODO: remove g_max_id entirely - if (idx > g_max_id) - { - g_max_id = idx; - } - - if ( bst_search(g_customs_bst, idx) == NULL ) + if ( idx >= config->custom_categ_min_songid && bst_search(g_customs_bst, idx) == NULL ) { g_customs_bst = bst_insert(g_customs_bst, idx); //LOG("%d inserted into customs bst\n", idx); - //TODO: (beware: maybe we should still consider !is_gone charts as custom?) if (config->custom_categ == 2) { add_song_to_subcateg(idx, subcateg); @@ -967,8 +960,8 @@ void parse_musicdb(const char *input_filename, const char *target, struct popnha if ( config->custom_categ && config->custom_exclude_from_version && !is_excluded_folder(input_filename) - && idx >= config->custom_categ_min_songid - && (config->custom_categ_max_songid == 0 || idx <= config->custom_categ_max_songid) ) + && idx >= config->custom_categ_min_songid + && ( is_fresh || config->exclude_omni ) ) { m->cs_version = 0; m->folder = 0;