wip exclude customs by prepending _

This commit is contained in:
CrazyRedMachine 2024-05-15 20:13:02 +02:00
parent 89e5c8a562
commit 834ec6e9d1
3 changed files with 21 additions and 3 deletions

View File

@ -275,7 +275,7 @@ static void add_song_to_subcateg(uint32_t songid, subcategory_s* subcateg)
} }
} }
static subcategory_s* get_subcateg(char *title) static subcategory_s* get_subcateg(const char *title)
{ {
for (uint32_t i = 0; i < g_subcateg_count; i++) for (uint32_t i = 0; i < g_subcateg_count; i++)
{ {
@ -908,6 +908,12 @@ static char *get_folder_name(const char* path) {
return categ_name; return categ_name;
} }
bool is_excluded_folder(const char *input_filename)
{
return (input_filename[strlen("data_mods/")] == '_');
}
static void parse_musicdb(const char *input_filename) { static void parse_musicdb(const char *input_filename) {
char *title = get_folder_name(input_filename); char *title = get_folder_name(input_filename);
@ -933,6 +939,7 @@ static void parse_musicdb(const char *input_filename) {
add_song_to_subcateg(songid, subcateg); add_song_to_subcateg(songid, subcateg);
} }
} }
free(title);
} }
static void load_databases() { static void load_databases() {
@ -948,8 +955,10 @@ static void load_databases() {
for(uint16_t i=0;i<result.size();i++) for(uint16_t i=0;i<result.size();i++)
{ {
if ( strstr(result[i].c_str(), "musicdb") == NULL ) if ( (strstr(result[i].c_str(), "musicdb") == NULL)
|| is_excluded_folder(result[i].c_str()) )
continue; continue;
parse_musicdb(result[i].c_str()); parse_musicdb(result[i].c_str());
} }
} }
@ -1009,7 +1018,7 @@ 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_min_id = config->custom_categ_min_songid;
g_max_id = config->custom_categ_max_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];

View File

@ -4,6 +4,9 @@
#include <stdint.h> #include <stdint.h>
#include "popnhax/config.h" #include "popnhax/config.h"
extern uint32_t g_max_id;
bool is_excluded_folder(const char *input_filename);
bool patch_custom_categs(const char *dllFilename, struct popnhax_config *config); bool patch_custom_categs(const char *dllFilename, struct popnhax_config *config);
bool patch_local_favorites(const char *dllFilename, uint8_t version); bool patch_local_favorites(const char *dllFilename, uint8_t version);

View File

@ -7,6 +7,7 @@
#include "util/patch.h" #include "util/patch.h"
#include "util/log.h" #include "util/log.h"
#include "xmlhelper.h" #include "xmlhelper.h"
#include "custom_categs.h"
#include "tableinfo.h" #include "tableinfo.h"
#include "loader.h" #include "loader.h"
@ -855,6 +856,10 @@ void parse_musicdb(const char *input_filename, const char *target, struct popnha
sizeof(idxStr)); sizeof(idxStr));
uint32_t idx = atoi(idxStr); uint32_t idx = atoi(idxStr);
if (idx > g_max_id)
{
g_max_id = idx;
}
// Get an existing music entry in memory // Get an existing music entry in memory
// If it exists, return the existing entry // If it exists, return the existing entry
// If it doesn't exist, create a new entry in memory // If it doesn't exist, create a new entry in memory
@ -921,6 +926,7 @@ 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)
&& idx >= config->custom_categ_min_songid && idx >= config->custom_categ_min_songid
&& (config->custom_categ_max_songid == 0 || idx <= config->custom_categ_max_songid) ) && (config->custom_categ_max_songid == 0 || idx <= config->custom_categ_max_songid) )
{ {