From 83f7def14c336ac23638bac78957dec591dd9436 Mon Sep 17 00:00:00 2001 From: korenkonder Date: Wed, 7 Jun 2023 17:25:29 +0300 Subject: [PATCH] Smth big is still coming --- src/CRE/module_table.cpp | 181 ++++++++++++++++++++++++++- src/CRE/module_table.hpp | 30 ++++- src/CRE/pv_db.cpp | 8 ++ src/CRE/pv_db.hpp | 1 + src/ReDIVA/data_initialize.cpp | 2 +- src/ReDIVA/pv_game/pv_game.cpp | 69 +++------- src/ReDIVA/pv_game/pv_game.hpp | 2 +- src/ReDIVA/pv_game/pv_game_music.cpp | 2 +- src/ReDIVA/render.cpp | 2 + src/ReDIVA/system_startup.cpp | 7 -- 10 files changed, 239 insertions(+), 65 deletions(-) diff --git a/src/CRE/module_table.cpp b/src/CRE/module_table.cpp index 1d8a7fb0..e6bbd60c 100644 --- a/src/CRE/module_table.cpp +++ b/src/CRE/module_table.cpp @@ -5,6 +5,7 @@ #include "module_table.hpp" #include "../KKdLib/io/path.hpp" +#include "../KKdLib/prj/vector_pair_combine.hpp" #include "../KKdLib/key_val.hpp" #include "../KKdLib/str_utils.hpp" #include "data.hpp" @@ -31,7 +32,46 @@ struct module_table_handler { void read(); }; +struct module_data_handler { + std::vector modules; + std::vector random_modules; + + module_data_handler(); + ~module_data_handler(); + + void add_all_modules(); + void add_modules(); + void add_random_modules(); + bool get_module(chara_index chara_index, int32_t cos, module_data& data); + bool get_module(int32_t id, module_data& data); +}; + +struct module_data_random { + int32_t id; + int32_t sort_index; + chara_index chara_index; + int32_t spr_sel_mdrchrcmn_spr_set_id; + int32_t spr_sel_mdrchrcmn_md_img_spr_id; + const char* name; +}; + + +module_data_random module_data_random_data[] = { + { -2, 0, CHARA_MIKU , 1935, 35031, "オール ランダム" }, + { -3, 1, CHARA_MIKU , 1947, 35043, "初音ミク ランダム" }, + { -4, 2, CHARA_RIN , 1951, 35047, "鏡音リン ランダム" }, + { -5, 3, CHARA_LEN , 1941, 35037, "鏡音レン ランダム" }, + { -6, 4, CHARA_LUKA , 1943, 35039, "巡音ルカ ランダム" }, + { -7, 8, CHARA_NERU , 1949, 35045, "亞北ネル ランダム" }, + { -8, 7, CHARA_HAKU , 1937, 35033, "弱音ハク ランダム" }, + { -9, 6, CHARA_KAITO , 1939, 35035, "カイト ランダム" }, + { -10, 5, CHARA_MEIKO , 1945, 35041, "メイコ ランダム" }, + { -11, 9, CHARA_SAKINE, 1953, 35049, "咲音メイコ ランダム" }, + { -12, 10, CHARA_TETO , 2400, 35051, "重音テト ランダム" }, +}; + module_table_handler* module_table_handler_data; +module_data_handler* module_data_handler_data; module::module() : sort_index(), chara(), cos() { id = -1; @@ -41,6 +81,19 @@ module::~module() { } +module_data::module_data() : sort_index(), chara_index(), cos(), +sleeve_l(), sleeve_r(), field_78(), field_79(), field_A0() { + id = -1; + spr_sel_md_id_spr_set_id = -1; + spr_sel_md_id_cmn_spr_set_id = -1; + spr_sel_md_id_cmn_md_img_id_spr_id = -1; + spr_sel_md_id_cmn_md_img_spr_id = -1; + name.assign(""); + + field_A8 = prj::time::get_default(); + field_B0 = prj::time::get_default(); +} + void module_table_handler_data_init() { if (!module_table_handler_data) module_table_handler_data = new module_table_handler; @@ -63,13 +116,36 @@ void module_table_handler_data_read() { } void module_table_handler_data_free() { - if (module_table_handler_data) { delete module_table_handler_data; module_table_handler_data = 0; } } +void module_data_handler_data_init() { + if (!module_data_handler_data) + module_data_handler_data = new module_data_handler; +} + +void module_data_handler_data_add_all_modules() { + module_data_handler_data->add_all_modules(); +} + +bool module_data_handler_data_get_module(chara_index chara_index, int32_t cos, module_data& data) { + return module_data_handler_data->get_module(chara_index, cos, data); +} + +bool module_data_handler_data_get_module(int32_t id, module_data& data) { + return module_data_handler_data->get_module(id, data); +} + +void module_data_handler_data_free() { + if (module_data_handler_data) { + delete module_data_handler_data; + module_data_handler_data = 0; + } +} + module_table_handler::module_table_handler() : ready() { name_map.insert({ }); } @@ -228,3 +304,106 @@ void module_table_handler::read() { } } } + +module_data_handler::module_data_handler() { + +} + +module_data_handler::~module_data_handler() { + +} + +void module_data_handler::add_all_modules() { + add_modules(); + add_random_modules(); +} + +void module_data_handler::add_modules() { + modules.clear(); + + data_struct* aft_data = &data_list[DATA_AFT]; + sprite_database* aft_spr_db = &aft_data->data_ft.spr_db; + + char buf[0x80]; + + for (const auto& i : module_table_handler_data_get_modules()) { + module_data mdl; + mdl.id = i.second.id; + mdl.sort_index = i.second.sort_index; + mdl.name.assign(i.second.name); + mdl.chara_index = (chara_index)i.second.chara; + mdl.cos = i.second.cos; + mdl.field_79 = false; + rob_sleeve_handler_data_get_sleeve_data(mdl.chara_index, mdl.cos, mdl.sleeve_l, mdl.sleeve_r); + + sprintf_s(buf, sizeof(0x80), "SPR_SEL_MD%03d", mdl.id); + mdl.spr_sel_md_id_spr_set_id = aft_spr_db->get_spr_set_by_name(buf)->id; + + sprintf_s(buf, sizeof(0x80), "SPR_SEL_MD%03dCMN", mdl.id); + mdl.spr_sel_md_id_cmn_spr_set_id = aft_spr_db->get_spr_set_by_name(buf)->id; + + sprintf_s(buf, sizeof(0x80), "SPR_SEL_MD%03d_MD_IMG_%03d", mdl.id, mdl.id); + mdl.spr_sel_md_id_cmn_md_img_id_spr_id = aft_spr_db->get_spr_set_by_name(buf)->id; + + sprintf_s(buf, sizeof(0x80), "SPR_SEL_MD%03dCMN_MD_IMG", mdl.id); + mdl.spr_sel_md_id_cmn_md_img_spr_id = aft_spr_db->get_spr_set_by_name(buf)->id; + + /*struc_684 v17; + if (sub_1402B7880()->sub_1402B7550(i.second.id, v17)) { + mdl.field_78 = 1; + mdl.field_79 = v17.field_4; + mdl.name.assign(v17.name); + mdl.field_A0 = v17.field_28; + mdl.field_A8 = v17.field_30; + mdl.field_B0 = v17.field_38; + mdl.sort_index = v17.sort_index; + }*/ + + modules.push_back(mdl); + } +} + +void module_data_handler::add_random_modules() { + random_modules.clear(); + + for (module_data_random& i : module_data_random_data) { + module_data mdl; + mdl.id = i.id; + mdl.sort_index = i.sort_index; + mdl.name.assign(i.name); + mdl.chara_index = i.chara_index; + mdl.cos = -1; + mdl.field_79 = false; + mdl.spr_sel_md_id_cmn_spr_set_id = i.spr_sel_mdrchrcmn_spr_set_id; + mdl.spr_sel_md_id_cmn_md_img_spr_id = i.spr_sel_mdrchrcmn_md_img_spr_id; + random_modules.push_back(mdl); + } +} + +bool module_data_handler::get_module(chara_index chara_index, int32_t cos, module_data& data) { + for (module_data& i : modules) + if (i.chara_index == chara_index && i.cos == cos) { + data = i; + return true; + + } + return false; +} + +bool module_data_handler::get_module(int32_t id, module_data& data) { + for (module_data& i : modules) + if (i.id == id) { + data = i; + return true; + + } + + for (module_data& i : random_modules) + if (i.id == id) { + data = i; + return true; + + } + + return false; +} diff --git a/src/CRE/module_table.hpp b/src/CRE/module_table.hpp index c8415693..593a978e 100644 --- a/src/CRE/module_table.hpp +++ b/src/CRE/module_table.hpp @@ -8,7 +8,8 @@ #include #include "../KKdLib/default.hpp" #include "../KKdLib/database/item_table.hpp" -#include "../KKdLib/prj/vector_pair_combine.hpp" +#include "../KKdLib/prj/time.hpp" +#include "rob/rob.hpp" struct module { int32_t id; @@ -21,9 +22,36 @@ struct module { ~module(); }; +struct module_data { + int32_t id; + int32_t sort_index; + chara_index chara_index; + int32_t cos; + rob_sleeve_data sleeve_l; + rob_sleeve_data sleeve_r; + int32_t spr_sel_md_id_spr_set_id; + int32_t spr_sel_md_id_cmn_spr_set_id; + int32_t spr_sel_md_id_cmn_md_img_id_spr_id; + int32_t spr_sel_md_id_cmn_md_img_spr_id; + bool field_78; + bool field_79; + std::string name; + int32_t field_A0; + prj::time field_A8; + prj::time field_B0; + + module_data(); +}; + extern void module_table_handler_data_init(); extern const module* module_table_handler_data_get_module(int32_t id); extern const prj::vector_pair_combine& module_table_handler_data_get_modules(); extern bool module_table_handler_data_load(); extern void module_table_handler_data_read(); extern void module_table_handler_data_free(); + +extern void module_data_handler_data_init(); +extern void module_data_handler_data_add_all_modules(); +extern bool module_data_handler_data_get_module(chara_index chara_index, int32_t cos, module_data& data); +extern bool module_data_handler_data_get_module(int32_t id, module_data& data); +extern void module_data_handler_data_free(); diff --git a/src/CRE/pv_db.cpp b/src/CRE/pv_db.cpp index b73d091f..92012c3b 100644 --- a/src/CRE/pv_db.cpp +++ b/src/CRE/pv_db.cpp @@ -575,6 +575,14 @@ bool pv_db_pv::get_performer_fixed(int32_t performer) const { return this->performer[performer].fixed; } +size_t pv_db_pv::get_performer_fixed_count() const { + size_t count = 0; + for (const pv_db_pv_performer& i : performer) + if (i.fixed) + count++; + return count; +} + int32_t pv_db_pv::get_performer_item(int32_t performer, pv_performer_item item) const { if (performer < 0 || performer >= ROB_CHARA_COUNT || performer >= this->performer.size()) return -1; diff --git a/src/CRE/pv_db.hpp b/src/CRE/pv_db.hpp index c9c1b9ef..c8cfb9aa 100644 --- a/src/CRE/pv_db.hpp +++ b/src/CRE/pv_db.hpp @@ -502,6 +502,7 @@ struct pv_db_pv { size_t get_performer_count() const; int32_t get_performer_exclude(int32_t performer) const; bool get_performer_fixed(int32_t performer) const; + size_t get_performer_fixed_count() const; int32_t get_performer_item(int32_t performer, pv_performer_item item) const; bool get_performer_pseudo_fixed(chara_index chara_index, int32_t performer, bool a4, bool a5) const; int32_t get_performer_pseudo_same_id(int32_t performer) const; diff --git a/src/ReDIVA/data_initialize.cpp b/src/ReDIVA/data_initialize.cpp index 4eec3306..d36d307a 100644 --- a/src/ReDIVA/data_initialize.cpp +++ b/src/ReDIVA/data_initialize.cpp @@ -145,7 +145,7 @@ bool TaskDataInit::Ctrl() { //&& !sub_140388A50() && !hand_item_handler_data_load() && !rob_sleeve_handler_data_load()) { - //sub_1403F8C30()->sub_1403F98D0(); + module_data_handler_data_add_all_modules(); //sub_140234860()->sub_140234DE0(); //sub_140392D10(); //sub_140226760()->sub_140226A80(); diff --git a/src/ReDIVA/pv_game/pv_game.cpp b/src/ReDIVA/pv_game/pv_game.cpp index a441f0ff..34234dd4 100644 --- a/src/ReDIVA/pv_game/pv_game.cpp +++ b/src/ReDIVA/pv_game/pv_game.cpp @@ -93,27 +93,6 @@ struct struc_674 { struc_674(); }; -struct struc_683 { - int32_t id; - int32_t sort_index; - chara_index chara_index; - int32_t cos; - rob_sleeve_data sleeve_l; - rob_sleeve_data sleeve_r; - int32_t spr_sel_md_id_spr_set_id; - int32_t spr_sel_md_id_cmn_spr_set_id; - int32_t spr_sel_md_id_cmn_md_img_id_spr_id; - int32_t spr_sel_md_id_cmn_md_img_spr_id; - bool field_78; - bool field_79; - std::string name; - int32_t field_A0; - time_t field_A8; - time_t field_B0; - - struc_683(); -}; - struct struc_773 { int32_t field_0; bool field_4; @@ -5621,11 +5600,11 @@ bool task_pv_game_init_demo_pv(int32_t pv_id, pv_difficulty difficulty, bool mus pv_db_pv* pv = task_pv_db_get_pv(pv_id); for (int32_t i = 0; i < 6 && (!pv || pv && i < pv->get_performer_count()); i++) { if (pv && pv->get_performer_fixed(i)) { - /*struc_683 v23; - if (sub_1403F8C30()->sub_1403F8BA0(pv->get_performer_chara(i), - pv->get_performer_pv_costume(i, difficulty), &v23)) - task_pv_game->data.init_data.modules[i] = v23.id; - else*/ + module_data mdl; + if (module_data_handler_data_get_module(pv->get_performer_chara(i), + pv->get_performer_pv_costume(i, difficulty), mdl)) + task_pv_game->data.init_data.modules[i] = mdl.id; + else task_pv_game->data.init_data.modules[i] = 0; } else @@ -5864,22 +5843,6 @@ struc_674::struc_674() : performer(), module(), item(), field_1C(), pv() { } -struc_683::struc_683() : sort_index(), chara_index(), cos(), sleeve_l(), sleeve_r() { - id = -1; - spr_sel_md_id_spr_set_id = -1; - spr_sel_md_id_cmn_spr_set_id = -1; - spr_sel_md_id_cmn_md_img_id_spr_id = -1; - spr_sel_md_id_cmn_md_img_spr_id = -1; - field_78 = false; - field_79 = false; - name.assign(""); - field_A0 = 0; - field_A8 = -1; - field_B0 = -1; - //field_A8 = *sub_1404911C0(); - //field_B0 = *sub_1404911C0(); -} - static bool pv_game_parent_ctrl() { if (pv_game_parent_data.init_time) { pv_game_parent_data.init_time = false; @@ -5978,14 +5941,14 @@ static void sub_140105010(pv_game_chara* arr, size_t max_count, pv_game_item_mas pv_game_chara* chr = &arr[performer]; { - /*struc_683 v40; - if (sub_1403F8C30()->sub_1403F8B40(a4.module, v40)) { - chr->chara_index = v40.chara_index; - chr->cos = v40.cos; - chr->pv_data.sleeve_l = v40.sleeve_l; - chr->pv_data.sleeve_r = v40.sleeve_r; + module_data mdl; + if (module_data_handler_data_get_module(a4.module, mdl)) { + chr->chara_index = mdl.chara_index; + chr->cos = mdl.cos; + chr->pv_data.sleeve_l = mdl.sleeve_l; + chr->pv_data.sleeve_r = mdl.sleeve_r; } - else */{ + else { chr->chara_index = CHARA_MIKU; chr->cos = 0; } @@ -6033,10 +5996,10 @@ static void sub_140105010(pv_game_chara* arr, size_t max_count, pv_game_item_mas } if (chara_index != CHARA_MAX) { - //struc_683 v40; - //sub_1403F8C30()->sub_1403F8840(chara_index, costume != -1 ? costume : 0, v40); - chr->chara_index = chara_index;//v40.chara_index; - chr->cos = costume;//v40.cos; + module_data mdl; + module_data_handler_data_get_module(chara_index, costume != -1 ? costume : 0, mdl); + chr->chara_index = mdl.chara_index; + chr->cos = mdl.cos; } pv_performer_item item = PV_PERFORMER_ITEM_ZUJO; diff --git a/src/ReDIVA/pv_game/pv_game.hpp b/src/ReDIVA/pv_game/pv_game.hpp index 8df20064..f191413f 100644 --- a/src/ReDIVA/pv_game/pv_game.hpp +++ b/src/ReDIVA/pv_game/pv_game.hpp @@ -510,7 +510,7 @@ struct struc_677 { bool field_17; int32_t field_18; int32_t field_1C; - int32_t field_20; + bool field_20; int32_t option; }; diff --git a/src/ReDIVA/pv_game/pv_game_music.cpp b/src/ReDIVA/pv_game/pv_game_music.cpp index c4ca15ea..e75b5e3a 100644 --- a/src/ReDIVA/pv_game/pv_game_music.cpp +++ b/src/ReDIVA/pv_game/pv_game_music.cpp @@ -455,7 +455,7 @@ pv_game_music* pv_game_music_get() { return pv_game_music_ptr; } -vool pv_game_music_free() { +bool pv_game_music_free() { if (pv_game_music_ptr) { delete pv_game_music_ptr; pv_game_music_ptr = 0; diff --git a/src/ReDIVA/render.cpp b/src/ReDIVA/render.cpp index f01e9aaf..8eaa6669 100644 --- a/src/ReDIVA/render.cpp +++ b/src/ReDIVA/render.cpp @@ -868,6 +868,7 @@ static render_context* render_context_load() { hand_item_handler_data_init(); module_table_handler_data_init(); + module_data_handler_data_init(); customize_item_table_handler_data_init(); aet_manager_add_aet_sets(aft_aet_db); @@ -1176,6 +1177,7 @@ static void render_context_dispose(render_context* rctx) { aet_manager_remove_aet_sets(aft_aet_db); customize_item_table_handler_data_free(); + module_data_handler_data_free(); module_table_handler_data_free(); hand_item_handler_data_free(); diff --git a/src/ReDIVA/system_startup.cpp b/src/ReDIVA/system_startup.cpp index f4f7bf78..ee5aba1b 100644 --- a/src/ReDIVA/system_startup.cpp +++ b/src/ReDIVA/system_startup.cpp @@ -8,7 +8,6 @@ #include "../CRE/mdata_manager.hpp" #include "../CRE/sprite.hpp" #include "pv_game/pv_game.hpp" -#include "config.hpp" #include "game_state.hpp" system_startup_detail::TaskSystemStartup* task_system_startup; @@ -60,9 +59,7 @@ namespace system_startup_detail { system_startup.state = 4; break; case 4: -#if !PV_DEBUG rctx_ptr->render_manager.set_pass_sw(rndr::RND_PASSID_ALL_3D, false); -#endif task_pv_game_init_test_pv(); system_startup.state = 5; break; @@ -79,9 +76,7 @@ namespace system_startup_detail { system_startup.state = 8; break; case 8: -#if !PV_DEBUG rctx_ptr->render_manager.set_pass_sw(rndr::RND_PASSID_ALL_3D, true); -#endif system_startup_ready = 1; break; } @@ -98,11 +93,9 @@ namespace system_startup_detail { } void TaskSystemStartup::Disp() { -#if !PV_DEBUG resolution_struct* res_wind = res_window_get(); spr::put_sprite_rect({ 0.0f, 0.0f, (float_t)res_wind->width, (float_t)res_wind->height }, res_wind->resolution_mode, spr::SPR_PRIO_25, color_black, 0); -#endif } }