Skip to content

Commit

Permalink
generate music list on client
Browse files Browse the repository at this point in the history
  • Loading branch information
GEEKiDoS committed Aug 7, 2024
1 parent ee15452 commit 6d90702
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/client/component/iidx/chart_modifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>(modifier_flag & ~modifier_t::fixed_random));
avs2::property_node_create(_this->eacnet_property.property, nullptr, avs2::NODE_TYPE_u32, "/p2d/params/modifier", static_cast<uint32_t>(modifier_flag & ~modifier_t::fixed_random));
return iidx::EacnetRequestPost::OnRequestPropertyExported(_this, a1, a2);
}

Expand Down
7 changes: 6 additions & 1 deletion src/client/component/iidx/omnimix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace iidx::omnimix
const size_t id = item["id"].get<size_t>();
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;
Expand Down Expand Up @@ -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"]);
Expand Down
4 changes: 4 additions & 0 deletions src/client/component/iidx/overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,12 @@ namespace iidx::overlay
font_data = utils::memory::allocate<char>(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<int>(font_buffer.size()), 16.0f * scale_factor,
nullptr, io.Fonts->GetGlyphRangesJapanese()
Expand Down
34 changes: 34 additions & 0 deletions src/client/component/iidx/patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/client/component/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace logger
return;

utils::nt::library avs2core{ "avs2-core.dll" };
// utils::hook::jump(avs2core.get_proc<void*>("XCgsqzn0000176"), avs2_log, true);
utils::hook::jump(avs2core.get_proc<void*>("XCgsqzn0000176"), avs2_log, true);
}
};
}
Expand Down
5 changes: 2 additions & 3 deletions src/client/game/iidx/struct.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once
namespace iidx
{
using namespace avs2;
#define CUR_STYLE_ENTRIES (80 * 1000)
#define MAX_ENTRIES (CUR_STYLE_ENTRIES + 1000)

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/client/game/iidx/symbols.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace iidx
WEAK symbol<bool(eacnet_request_post_s*, void*, void*)> OnRequestPropertyExported{ 0x140302FE0 };
}

WEAK symbol<IDirect3DDevice9Ex*> d3d9ex_device{ 0x142AAD408 };
WEAK symbol<IDirect3DDevice9*> d3d9_device{ 0x142AAD408 };
WEAK symbol<IDirect3DDevice9Ex*> d3d9ex_device{ 0x142AAD410 };
WEAK symbol<IDirect3DDevice9*> d3d9_device{ 0x142AAD410 };
WEAK symbol<HWND*> main_hwnd{ 0x142AAD400 };
WEAK symbol<const char> infinitas_id{ 0x141AC5494 };
WEAK symbol<const char> game_version{ 0x141AC54E3 };
Expand Down
2 changes: 1 addition & 1 deletion src/client/launcher/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 6d90702

Please sign in to comment.