From 6d90702b3c6584221270eb86e5b3e9be858c12f7 Mon Sep 17 00:00:00 2001 From: GEEKiDoS Date: Wed, 7 Aug 2024 14:26:46 +0800 Subject: [PATCH] generate music list on client --- src/client/component/iidx/chart_modifier.cpp | 2 +- src/client/component/iidx/omnimix.cpp | 7 +++- src/client/component/iidx/overlay.cpp | 4 +++ src/client/component/iidx/patches.cpp | 34 ++++++++++++++++++++ src/client/component/logger.cpp | 2 +- src/client/game/iidx/struct.hpp | 5 ++- src/client/game/iidx/symbols.hpp | 4 +-- src/client/launcher/launcher.cpp | 2 +- 8 files changed, 51 insertions(+), 9 deletions(-) diff --git a/src/client/component/iidx/chart_modifier.cpp b/src/client/component/iidx/chart_modifier.cpp index 6562ac1..ac78f73 100644 --- a/src/client/component/iidx/chart_modifier.cpp +++ b/src/client/component/iidx/chart_modifier.cpp @@ -370,7 +370,7 @@ namespace iidx::chart_modifier bool report_result_export_request_property(iidx::eacnet_request_post_s* _this, void* a1, void* a2) { - iidx::property_node_create(_this->eacnet_property.property, nullptr, iidx::NODE_TYPE_u32, "/p2d/params/modifier", static_cast(modifier_flag & ~modifier_t::fixed_random)); + avs2::property_node_create(_this->eacnet_property.property, nullptr, avs2::NODE_TYPE_u32, "/p2d/params/modifier", static_cast(modifier_flag & ~modifier_t::fixed_random)); return iidx::EacnetRequestPost::OnRequestPropertyExported(_this, a1, a2); } diff --git a/src/client/component/iidx/omnimix.cpp b/src/client/component/iidx/omnimix.cpp index 19bb47c..1651417 100644 --- a/src/client/component/iidx/omnimix.cpp +++ b/src/client/component/iidx/omnimix.cpp @@ -78,7 +78,7 @@ namespace iidx::omnimix const size_t id = item["id"].get(); const auto index = music_data->index_table[id]; - if ((id >= CUR_STYLE_ENTRIES && index == 0) || index == 0xffff) + if (index <= 0) continue; auto* const music = music_data->musics + index; @@ -151,6 +151,11 @@ namespace iidx::omnimix LOAD_INT(song_id, ["id"]); + // skip existing song + if (backup->index_table[music.song_id] > 0) { + continue; + } + LOAD_STRING(title, ["title"]); LOAD_STRING(title_ascii, ["englishTitle"]); LOAD_STRING(genre, ["genre"]); diff --git a/src/client/component/iidx/overlay.cpp b/src/client/component/iidx/overlay.cpp index 6751e50..83099f3 100644 --- a/src/client/component/iidx/overlay.cpp +++ b/src/client/component/iidx/overlay.cpp @@ -587,8 +587,12 @@ namespace iidx::overlay font_data = utils::memory::allocate(font_buffer.size()); std::memcpy(font_data, font_buffer.data(), font_buffer.size()); + auto ratio = (custom_resolution::width() * 1.f) / custom_resolution::height(); auto scale_factor = custom_resolution::height() / 1080.f; + if (ratio < (16.f / 9.f)) + scale_factor = custom_resolution::width() / 1920.f; + font_normal = io.Fonts->AddFontFromMemoryTTF( font_data, static_cast(font_buffer.size()), 16.0f * scale_factor, nullptr, io.Fonts->GetGlyphRangesJapanese() diff --git a/src/client/component/iidx/patches.cpp b/src/client/component/iidx/patches.cpp index bb53ac5..f828b30 100644 --- a/src/client/component/iidx/patches.cpp +++ b/src/client/component/iidx/patches.cpp @@ -79,6 +79,36 @@ namespace iidx::patches return request; } + bool generate_music_list(avs2::property_ptr dst_prop, avs2::node_ptr /* dst_node */, avs2::node_ptr /*src_node*/, bool /*deep*/) + { + auto music_data = iidx::get_music_data(); + auto root = avs2::property_node_create(dst_prop, nullptr, avs2::NODE_TYPE_s32, "/music_list", music_data->music_count); + + avs2::property_node_create(dst_prop, root, avs2::NODE_TYPE_s32, "music_num", music_data->music_count); + + for (size_t i = 0; i < music_data->music_count; i++) + { + auto& music = music_data->musics[i]; + auto notebit = 0; + + for (size_t j = 0; j < 10; j++) + { + if (music.level[j]) + notebit |= 1 << j; + } + + static const uint8_t zero_buffer[64]{}; + auto* node = avs2::property_node_create(dst_prop, root, avs2::NODE_TYPE_node, "music", zero_buffer); + + avs2::property_node_create(dst_prop, node, avs2::NODE_TYPE_s32, "music_id", music.song_id); + avs2::property_node_create(dst_prop, node, avs2::NODE_TYPE_s32, "kind", 1); + avs2::property_node_create(dst_prop, node, avs2::NODE_TYPE_s32, "note_bit", notebit); + avs2::property_node_create(dst_prop, node, avs2::NODE_TYPE_str, "music_pack_item_id", ""); + } + + return true; + } + class component final : public component_interface { public: @@ -91,6 +121,10 @@ namespace iidx::patches utils::hook::nop(0x140301992, 2); utils::hook::nop(0x14030199E, 2); + // generate music list from client + utils::hook::nop(0x14030189F, 6); + utils::hook::call(0x14030189F, generate_music_list); + // change server url utils::hook::jump(0x1402F8A60, get_service_url); printf("Using bootstrap url: %s\n", get_service_url(nullptr, false, false)); diff --git a/src/client/component/logger.cpp b/src/client/component/logger.cpp index d18be9a..532fd74 100644 --- a/src/client/component/logger.cpp +++ b/src/client/component/logger.cpp @@ -103,7 +103,7 @@ namespace logger return; utils::nt::library avs2core{ "avs2-core.dll" }; - // utils::hook::jump(avs2core.get_proc("XCgsqzn0000176"), avs2_log, true); + utils::hook::jump(avs2core.get_proc("XCgsqzn0000176"), avs2_log, true); } }; } diff --git a/src/client/game/iidx/struct.hpp b/src/client/game/iidx/struct.hpp index 66ca38e..37afcec 100644 --- a/src/client/game/iidx/struct.hpp +++ b/src/client/game/iidx/struct.hpp @@ -1,7 +1,6 @@ #pragma once namespace iidx { - using namespace avs2; #define CUR_STYLE_ENTRIES (80 * 1000) #define MAX_ENTRIES (CUR_STYLE_ENTRIES + 1000) @@ -354,7 +353,7 @@ namespace iidx struct eacnet_property_s { uintptr_t vfptr; - property_ptr property; + avs2::property_ptr property; }; static_assert(offsetof(eacnet_property_s, property) == 8); @@ -365,7 +364,7 @@ namespace iidx eacnet_property_s eacnet_property; char __gap1[32]; void* data; - psmap_data_ptr psmap; + avs2::psmap_data_ptr psmap; }; static_assert(offsetof(eacnet_request_post_s, data) == 120); diff --git a/src/client/game/iidx/symbols.hpp b/src/client/game/iidx/symbols.hpp index ca5b9b2..d3e2633 100644 --- a/src/client/game/iidx/symbols.hpp +++ b/src/client/game/iidx/symbols.hpp @@ -21,8 +21,8 @@ namespace iidx WEAK symbol OnRequestPropertyExported{ 0x140302FE0 }; } - WEAK symbol d3d9ex_device{ 0x142AAD408 }; - WEAK symbol d3d9_device{ 0x142AAD408 }; + WEAK symbol d3d9ex_device{ 0x142AAD410 }; + WEAK symbol d3d9_device{ 0x142AAD410 }; WEAK symbol main_hwnd{ 0x142AAD400 }; WEAK symbol infinitas_id{ 0x141AC5494 }; WEAK symbol game_version{ 0x141AC54E3 }; diff --git a/src/client/launcher/launcher.cpp b/src/client/launcher/launcher.cpp index 738114c..1a6e0f8 100644 --- a/src/client/launcher/launcher.cpp +++ b/src/client/launcher/launcher.cpp @@ -19,7 +19,7 @@ #include "component/steam_proxy.hpp" -#define USE_EMBEDDED 0 +#define USE_EMBEDDED 1 #if !_DEBUG || USE_EMBEDDED #include "resources/all.hpp"