forked from Popn_Tools/popnhax
music limit check
This commit is contained in:
parent
c18656658c
commit
1f630edb10
6
dist/popnhax/popnhax.xml
vendored
6
dist/popnhax/popnhax.xml
vendored
@ -6,9 +6,9 @@
|
|||||||
<!-- Force unlock music, charts, characters, and deco parts when applicable -->
|
<!-- Force unlock music, charts, characters, and deco parts when applicable -->
|
||||||
<force_unlocks __type="bool">0</force_unlocks>
|
<force_unlocks __type="bool">0</force_unlocks>
|
||||||
<!-- Put customs into their own category (0: no, 1: simple category with all customs, 2: subcategories by folder name) -->
|
<!-- Put customs into their own category (0: no, 1: simple category with all customs, 2: subcategories by folder name) -->
|
||||||
<custom_categ __type="u8">0</custom_categ>
|
<custom_categ __type="u8">2</custom_categ>
|
||||||
<!-- Prevent customs from showing up in version folders -->
|
<!-- Prevent customs from showing up in version folders -->
|
||||||
<custom_exclude_from_version __type="bool">0</custom_exclude_from_version>
|
<custom_exclude_from_version __type="bool">1</custom_exclude_from_version>
|
||||||
<!-- Prevent customs from showing up in level folders -->
|
<!-- Prevent customs from showing up in level folders -->
|
||||||
<custom_exclude_from_level __type="bool">0</custom_exclude_from_level>
|
<custom_exclude_from_level __type="bool">0</custom_exclude_from_level>
|
||||||
|
|
||||||
@ -140,6 +140,8 @@
|
|||||||
<disable_expansions __type="bool">0</disable_expansions>
|
<disable_expansions __type="bool">0</disable_expansions>
|
||||||
<!-- Copy the new table information over top the old tables (automatically enables disable_expansions) -->
|
<!-- Copy the new table information over top the old tables (automatically enables disable_expansions) -->
|
||||||
<disable_redirection __type="bool">0</disable_redirection>
|
<disable_redirection __type="bool">0</disable_redirection>
|
||||||
|
<!-- Do not perform music limit checks for patch_xml_auto (not recommended) -->
|
||||||
|
<ignore_music_limit __type="bool">0</ignore_music_limit>
|
||||||
|
|
||||||
<!-- Custom category options -->
|
<!-- Custom category options -->
|
||||||
<!-- minimum songid for a song to be seen as "custom" -->
|
<!-- minimum songid for a song to be seen as "custom" -->
|
||||||
|
@ -39,6 +39,7 @@ struct popnhax_config {
|
|||||||
bool disable_redirection;
|
bool disable_redirection;
|
||||||
bool disable_multiboot;
|
bool disable_multiboot;
|
||||||
bool patch_xml_auto;
|
bool patch_xml_auto;
|
||||||
|
bool ignore_music_limit;
|
||||||
char patch_xml_filename[MAX_PATH];
|
char patch_xml_filename[MAX_PATH];
|
||||||
char force_datecode[11];
|
char force_datecode[11];
|
||||||
bool network_datecode;
|
bool network_datecode;
|
||||||
|
@ -203,6 +203,8 @@ PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_STR, struct popnhax_config, custom_track_ti
|
|||||||
"/popnhax/custom_track_title_format")
|
"/popnhax/custom_track_title_format")
|
||||||
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, local_favorites,
|
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, local_favorites,
|
||||||
"/popnhax/local_favorites")
|
"/popnhax/local_favorites")
|
||||||
|
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, ignore_music_limit,
|
||||||
|
"/popnhax/ignore_music_limit")
|
||||||
PSMAP_END
|
PSMAP_END
|
||||||
|
|
||||||
enum BufferIndexes {
|
enum BufferIndexes {
|
||||||
@ -1453,12 +1455,36 @@ static bool patch_datecode(char *datecode) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool get_music_limit(uint32_t* limit) {
|
||||||
|
DWORD dllSize = 0;
|
||||||
|
char *data = getDllData(g_game_dll_fn, &dllSize);
|
||||||
|
|
||||||
|
{
|
||||||
|
int64_t string_loc = search(data, dllSize, "Illegal music no %d", 19, 0);
|
||||||
|
if (string_loc == -1) {
|
||||||
|
LOG("popnhax: patch_db: could not retrieve music limit error string\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
string_loc += 0x10000000; //entrypoint
|
||||||
|
char *as_hex = (char *) &string_loc;
|
||||||
|
int64_t pattern_offset = search(data, dllSize, as_hex, 4, 0);
|
||||||
|
if (pattern_offset == -1) {
|
||||||
|
LOG("popnhax: patch_db: could not retrieve music limit test function\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t patch_addr = (int64_t)data + pattern_offset - 0x1F;
|
||||||
|
*limit = *(uint32_t*)patch_addr;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool patch_database() {
|
static bool patch_database() {
|
||||||
DWORD dllSize = 0;
|
DWORD dllSize = 0;
|
||||||
char *data = getDllData(g_game_dll_fn, &dllSize);
|
char *data = getDllData(g_game_dll_fn, &dllSize);
|
||||||
|
|
||||||
patch_purelong();
|
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);
|
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) {
|
if (pattern_offset != -1) {
|
||||||
@ -1479,6 +1505,13 @@ static bool patch_database() {
|
|||||||
SearchFile s;
|
SearchFile s;
|
||||||
uint8_t *datecode = NULL;
|
uint8_t *datecode = NULL;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
uint32_t music_limit = 0;
|
||||||
|
if ( !config.ignore_music_limit && !get_music_limit(&music_limit) )
|
||||||
|
{
|
||||||
|
LOG("WARNING: could not retrieve music limit\n");
|
||||||
|
} else {
|
||||||
|
LOG("popnhax: patch_db: music limit : %d\n", music_limit);
|
||||||
|
}
|
||||||
|
|
||||||
if (config.force_datecode[0] != '\0')
|
if (config.force_datecode[0] != '\0')
|
||||||
{
|
{
|
||||||
@ -1487,7 +1520,7 @@ static bool patch_database() {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG("popnhax: auto detect patch file from ea3-config\n");
|
LOG("popnhax: auto detect patch file with datecode from ea3-config\n");
|
||||||
property *config_xml = load_prop_file("prop/ea3-config.xml");
|
property *config_xml = load_prop_file("prop/ea3-config.xml");
|
||||||
READ_STR_OPT(config_xml, property_search(config_xml, NULL, "/ea3/soft"), "ext", datecode)
|
READ_STR_OPT(config_xml, property_search(config_xml, NULL, "/ea3/soft"), "ext", datecode)
|
||||||
free(config_xml);
|
free(config_xml);
|
||||||
@ -1505,26 +1538,57 @@ static bool patch_database() {
|
|||||||
|
|
||||||
LOG("popnhax: patch_db: found %d xml files in data_mods\n",result.size());
|
LOG("popnhax: patch_db: found %d xml files in data_mods\n",result.size());
|
||||||
for (uint16_t i=0; i<result.size(); i++) {
|
for (uint16_t i=0; i<result.size(); i++) {
|
||||||
|
|
||||||
filename = result[i].c_str()+10; // strip "data_mods\" since parsedb will prepend it...
|
filename = result[i].c_str()+10; // strip "data_mods\" since parsedb will prepend it...
|
||||||
LOG("%d : %s\n",i,filename);
|
LOG("%d : %s\n",i,filename);
|
||||||
if (strstr(result[i].c_str(), (const char *)datecode) != NULL) {
|
bool datecode_match = (strstr(result[i].c_str(), (const char *)datecode) != NULL);
|
||||||
|
bool limit_match = false;
|
||||||
|
if ( music_limit != 0 )
|
||||||
|
{
|
||||||
|
uint32_t found_limit = 0;
|
||||||
|
LOG(" check music limit... ");
|
||||||
|
property *patch_xml = load_prop_file(result[i].c_str());
|
||||||
|
READ_U32_OPT(patch_xml, property_search(patch_xml, NULL, "/patches/limits"), "music", found_limit)
|
||||||
|
free(patch_xml);
|
||||||
|
LOG("%d\n",found_limit);
|
||||||
|
if ( found_limit == music_limit )
|
||||||
|
{
|
||||||
|
limit_match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( limit_match )
|
||||||
|
{
|
||||||
|
LOG("popnhax: patch_db: found matching music limit, end search\n");
|
||||||
|
if ( !datecode_match )
|
||||||
|
{
|
||||||
|
LOG("WARNING: datecode did NOT match, please update your %s\n", (config.force_datecode[0] != '\0') ? "force_datecode value" : "ea3-config.xml");
|
||||||
|
}
|
||||||
found = true;
|
found = true;
|
||||||
LOG("popnhax: patch_db: found matching datecode, end search\n");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( datecode_match )
|
||||||
|
{
|
||||||
|
if ( music_limit == 0 )
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
LOG("popnhax: patch_db: found matching datecode (no music limit check), end search\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
LOG("WARNING: found matching datecode but music limit doesn't check out, continue search\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
LOG("popnhax: patch_db: matching datecode not found, defaulting to latest patch file.\n");
|
LOG("popnhax: patch_db: matching datecode or limit not found, defaulting to latest patch file (will probably crash).\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG("popnhax: patch_db: using %s\n",filename);
|
LOG("popnhax: patch_db: using %s\n",filename);
|
||||||
target = parse_patchdb(filename, data);
|
target = parse_patchdb(filename, data);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
target = parse_patchdb(config.patch_xml_filename, data);
|
target = parse_patchdb(config.patch_xml_filename, data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.disable_redirection) {
|
if (config.disable_redirection) {
|
||||||
|
@ -1049,10 +1049,9 @@ void musichax_core_init(struct popnhax_config *config,
|
|||||||
|
|
||||||
uint64_t chara_size, uint64_t *new_chara_size, char *orig_chara_data,
|
uint64_t chara_size, uint64_t *new_chara_size, char *orig_chara_data,
|
||||||
uint8_t **new_chara_table) {
|
uint8_t **new_chara_table) {
|
||||||
|
bool force_unlocks = config->force_unlocks;
|
||||||
bool force_unlocks = config->force_unlocks;
|
bool is_expansion_allowed = !config->disable_expansions;
|
||||||
bool is_expansion_allowed = !config->disable_expansions;
|
bool is_redirection_allowed = !config->disable_redirection;
|
||||||
bool is_redirection_allowed = !config->disable_redirection;
|
|
||||||
|
|
||||||
if (style_size > fontstyle_table_size) {
|
if (style_size > fontstyle_table_size) {
|
||||||
fontstyle_table_size = style_size;
|
fontstyle_table_size = style_size;
|
||||||
|
Loading…
Reference in New Issue
Block a user