3
0
mirror of https://github.com/CrazyRedMachine/popnhax.git synced 2024-11-27 23:40:50 +01:00

remove max_song_id, add partial_entries and exclude_omni

This commit is contained in:
CrazyRedMachine 2024-05-23 23:46:27 +02:00
parent c65106127a
commit 32f7c5bd36
5 changed files with 42 additions and 40 deletions

View File

@ -131,7 +131,7 @@
THREAD_PRIORITY_TIME_CRITICAL 15 --> THREAD_PRIORITY_TIME_CRITICAL 15 -->
<enhanced_polling_priority __type="s8">1</enhanced_polling_priority> <enhanced_polling_priority __type="s8">1</enhanced_polling_priority>
<!-- Song db patches --> <!-- Song db patches (requires patch_db) -->
<!-- Auto select patch file from data_mods folder based on music limit, or datecode otherwise (will detect datecode from ea3-config or force_datecode option) --> <!-- Auto select patch file from data_mods folder based on music limit, or datecode otherwise (will detect datecode from ea3-config or force_datecode option) -->
<patch_xml_auto __type="bool">1</patch_xml_auto> <patch_xml_auto __type="bool">1</patch_xml_auto>
<!-- Manually set XML file containing patches (requires patch_xml_auto to be disabled) --> <!-- Manually set XML file containing patches (requires patch_xml_auto to be disabled) -->
@ -143,11 +143,13 @@
<!-- Do not perform music limit checks for patch_xml_auto (not recommended) --> <!-- Do not perform music limit checks for patch_xml_auto (not recommended) -->
<ignore_music_limit __type="bool">0</ignore_music_limit> <ignore_music_limit __type="bool">0</ignore_music_limit>
<!-- Custom category options --> <!-- Custom category options (requires patch_db) -->
<!-- minimum songid for a song to be seen as "custom" --> <!-- Also exclude omnimix (song id < 3000) tracks from version/level (requires custom_exclude_from_level or custom_exclude_from_version) -->
<custom_categ_min_songid __type="u16">4000</custom_categ_min_songid> <exclude_omni __type="bool">0</exclude_omni>
<!-- maximum songid for a song to be seen as "custom" (0 = no limit, not recommended since "random" category will use fake song ids in the 65400+ range) --> <!-- New chart added to existing song moves the song to custom folder -->
<custom_categ_max_songid __type="u16">65400</custom_categ_max_songid> <partial_entries __type="bool">0</partial_entries>
<!-- Minimum songid for a song to be seen as "custom" (e.g. use 4000 for real customs only) -->
<custom_categ_min_songid __type="u16">0</custom_categ_min_songid>
<!-- Category title for customs --> <!-- Category title for customs -->
<custom_category_title __type="str">Customs</custom_category_title> <custom_category_title __type="str">Customs</custom_category_title>
<!-- Format used for category title (in BM2DXFontScript format, refer to BM2DXFontScript.md in popnhax_tools repo) --> <!-- Format used for category title (in BM2DXFontScript format, refer to BM2DXFontScript.md in popnhax_tools repo) -->

View File

@ -17,7 +17,6 @@ struct popnhax_config {
bool score_challenge; bool score_challenge;
uint8_t custom_categ; uint8_t custom_categ;
uint16_t custom_categ_min_songid; uint16_t custom_categ_min_songid;
uint16_t custom_categ_max_songid;
bool custom_exclude_from_version; bool custom_exclude_from_version;
bool custom_exclude_from_level; bool custom_exclude_from_level;
bool force_hd_timing; bool force_hd_timing;
@ -64,6 +63,8 @@ struct popnhax_config {
char custom_category_format[64]; char custom_category_format[64];
char custom_track_title_format[64]; char custom_track_title_format[64];
char custom_track_title_format2[64]; char custom_track_title_format2[64];
bool exclude_omni;
bool partial_entries;
}; };
#endif #endif

View File

@ -36,12 +36,11 @@ char *g_current_friendid;
uint32_t g_current_songid; uint32_t g_current_songid;
bst_t *g_customs_bst = NULL; bst_t *g_customs_bst = NULL;
bool g_exclude_omni = false;
void (*add_song_in_list)(); void (*add_song_in_list)();
bool g_subcategmode = false; bool g_subcategmode = false;
uint32_t g_min_id = 4000;
uint32_t g_max_id = 0;
const char *g_categicon; const char *g_categicon;
const char *g_categformat; const char *g_categformat;
@ -62,8 +61,12 @@ uint32_t favorites_struct_addr = (uint32_t)&favorites_struct;
bool is_a_custom(uint32_t songid) bool is_a_custom(uint32_t songid)
{ {
return (bst_search(g_customs_bst, songid) != NULL); return (bst_search(g_customs_bst, songid) != NULL);
// return (songid >= g_min_id && (g_max_id==0 || g_max_id >= songid)); }
bool is_excluded_from_level(uint32_t songid)
{
return ( is_a_custom(songid) && ( g_exclude_omni || songid >= 3000 ) );
} }
void add_song_to_favorites() void add_song_to_favorites()
@ -769,7 +772,7 @@ static bool patch_favorite_categ(const char *game_dll_fn) {
return true; 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; DWORD dllSize = 0;
char *data = getDllData(game_dll_fn, &dllSize); 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]; char formatted_title[128];
sprintf(formatted_title, g_categformat, g_categname); sprintf(formatted_title, g_categformat, g_categname);
LOG("popnhax: custom %s \"%s\" injected (for songids ", g_subcategmode? "subcategories":"category", formatted_title); LOG("popnhax: custom %s \"%s\" injected", g_subcategmode? "subcategories":"category", formatted_title);
if (g_max_id) if (min_id)
LOG("between %d and %d (incl.))\n", g_min_id, g_max_id); LOG(" (for songids >= %d)", min_id);
else LOG("\n");
LOG("%d and up)\n", g_min_id);
return true; return true;
} }
void init_subcategories() { void init_subcategories() {
g_subcategmode = true; g_subcategmode = true;
g_subcateg_count = 0; g_subcateg_count = 0;
subcategories = (subcategory_s*)realloc(subcategories, sizeof(subcategory_s)*(1)); subcategories = (subcategory_s*)realloc(subcategories, sizeof(subcategory_s)*(1));
subcategories[0].name = strdup("ALL SONGS"); subcategories[0].name = strdup("ALL SONGS");
subcategories[0].songlist = NULL; subcategories[0].songlist = NULL;
subcategories[0].size = 0; subcategories[0].size = 0;
} }
static void print_databases() { static void print_databases() {
@ -951,7 +953,7 @@ void hook_after_getlevel()
__asm("push ecx\n"); __asm("push ecx\n");
__asm("push edx\n"); __asm("push edx\n");
__asm("push ebx\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("test eax, eax\n");
__asm("pop ebx\n"); __asm("pop ebx\n");
__asm("pop edx\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) 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; uint8_t mode = config->custom_categ;
char icon_path[64]; char icon_path[64];
@ -1022,7 +1022,7 @@ bool patch_custom_categs(const char *dllFilename, struct popnhax_config *config)
else else
g_categformat = "%s"; g_categformat = "%s";
if (!patch_custom_categ(dllFilename)) if (!patch_custom_categ(dllFilename, config->custom_categ_min_songid))
return false; return false;
if (mode == 2) if (mode == 2)
@ -1040,8 +1040,12 @@ bool patch_custom_categs(const char *dllFilename, struct popnhax_config *config)
if (config->custom_exclude_from_version) if (config->custom_exclude_from_version)
LOG("popnhax: Customs excluded from version folders\n"); //musichax_core_init took care of it LOG("popnhax: Customs excluded from version folders\n"); //musichax_core_init took care of it
if (config->custom_exclude_from_level) if (config->custom_exclude_from_level)
{
g_exclude_omni = config->exclude_omni;
patch_exclude(dllFilename); patch_exclude(dllFilename);
}
return true; return true;
} }

View File

@ -188,10 +188,12 @@ PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_S8, struct popnhax_config, base_offset,
"/popnhax/base_offset") "/popnhax/base_offset")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U8, struct popnhax_config, custom_categ, PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U8, struct popnhax_config, custom_categ,
"/popnhax/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, PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U16, struct popnhax_config, custom_categ_min_songid,
"/popnhax/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, PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, custom_exclude_from_version,
"/popnhax/custom_exclude_from_version") "/popnhax/custom_exclude_from_version")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, custom_exclude_from_level, PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, custom_exclude_from_level,

View File

@ -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 "-") 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 // 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 >= config->custom_categ_min_songid && bst_search(g_customs_bst, idx) == NULL )
if (idx > g_max_id)
{
g_max_id = idx;
}
if ( bst_search(g_customs_bst, idx) == NULL )
{ {
g_customs_bst = bst_insert(g_customs_bst, idx); g_customs_bst = bst_insert(g_customs_bst, idx);
//LOG("%d inserted into customs bst\n", 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) if (config->custom_categ == 2)
{ {
add_song_to_subcateg(idx, subcateg); 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 if ( config->custom_categ
&& config->custom_exclude_from_version && config->custom_exclude_from_version
&& !is_excluded_folder(input_filename) && !is_excluded_folder(input_filename)
&& idx >= config->custom_categ_min_songid && idx >= config->custom_categ_min_songid
&& (config->custom_categ_max_songid == 0 || idx <= config->custom_categ_max_songid) ) && ( is_fresh || config->exclude_omni ) )
{ {
m->cs_version = 0; m->cs_version = 0;
m->folder = 0; m->folder = 0;