diff --git a/src/CRE/customize_item_table.cpp b/src/CRE/customize_item_table.cpp index 2c00d172..7d4c0df9 100644 --- a/src/CRE/customize_item_table.cpp +++ b/src/CRE/customize_item_table.cpp @@ -285,8 +285,7 @@ void customize_item_table_handler::read() { data_struct* aft_data = &data_list[DATA_AFT]; for (const std::string& i : mdata_manager_get()->GetPrefixes()) { - std::string farc_file; - farc_file.assign(i); + std::string farc_file(i); farc_file.append("gm_customize_item_tbl.farc"); if (aft_data->check_file_exists("rom/", farc_file.c_str())) { diff --git a/src/CRE/data.cpp b/src/CRE/data.cpp index a807b15f..cd8138a8 100644 --- a/src/CRE/data.cpp +++ b/src/CRE/data.cpp @@ -61,8 +61,7 @@ void data_struct_load_db() { data_ft* d = &ds->data_ft; for (const std::string& i : mdata_manager_get()->GetPrefixes()) { - std::string file; - file.assign(i); + std::string file(i); file.append("aet_db.bin"); aet_database_file aet_db_file; @@ -73,8 +72,7 @@ void data_struct_load_db() { } for (const std::string& i : mdata_manager_get()->GetPrefixes()) { - std::string file; - file.assign(i); + std::string file(i); file.append("auth_3d_db.bin"); auth_3d_database_file auth_3d_db_file; @@ -92,8 +90,7 @@ void data_struct_load_db() { } for (const std::string& i : mdata_manager_get()->GetPrefixes()) { - std::string file; - file.assign(i); + std::string file(i); file.append("mot_db.farc"); motion_database_file mot_db_file; @@ -103,8 +100,7 @@ void data_struct_load_db() { } for (const std::string& i : mdata_manager_get()->GetPrefixes()) { - std::string file; - file.assign(i); + std::string file(i); file.append("obj_db.bin"); object_database_file obj_db_file; @@ -115,8 +111,7 @@ void data_struct_load_db() { } for (const std::string& i : mdata_manager_get()->GetPrefixes()) { - std::string file; - file.assign(i); + std::string file(i); file.append("spr_db.bin"); sprite_database_file spr_db_file; @@ -127,8 +122,7 @@ void data_struct_load_db() { } for (const std::string& i : mdata_manager_get()->GetPrefixes()) { - std::string file; - file.assign(i); + std::string file(i); file.append("stage_data.bin"); stage_database_file stage_data_file; @@ -139,8 +133,7 @@ void data_struct_load_db() { } for (const std::string& i : mdata_manager_get()->GetPrefixes()) { - std::string file; - file.assign(i); + std::string file(i); file.append("tex_db.bin"); texture_database_file tex_db_file; @@ -447,10 +440,8 @@ bool data_struct::check_file_exists(const char* dir, uint32_t hash) { return false; } -void data_struct::get_directory_files(const char* dir, std::vector& data_files) { - data_files.clear(); - data_files.shrink_to_fit(); - +std::vector data_struct::get_directory_files(const char* dir) { + std::vector files; size_t dir_len = utf8_length(dir); if (dir_len >= 2 && !memcmp(dir, "./", 2)) { dir += 2; @@ -468,7 +459,7 @@ void data_struct::get_directory_files(const char* dir, std::vector files = path_get_files(temp.c_str()); - if (!files.size()) + std::vector path_files = path_get_files(temp.c_str()); + if (!path_files.size()) continue; - for (std::string& k : files) { + files.reserve(path_files.size()); + for (std::string& k : path_files) { bool found = false; - for (data_struct_file& l : data_files) + for (data_struct_file& l : files) if (k == l.name) { found = true; break; @@ -506,9 +498,11 @@ void data_struct::get_directory_files(const char* dir, std::vector= 2 && !memcmp(dir, "./", 2)) { + dir += 2; + dir_len -= 2; + } + + bool f2 = false; + if (dir_len >= 5 && !memcmp(dir, "root+", 5)) { + dir += 5; + dir_len -= 5; + f2 = true; + } + else if (dir_len >= 3 && !memcmp(dir, "rom", 3)) { + dir += 3; + dir_len -= 3; + } + else + return false; + + while (*dir == '/' || *dir == '\\') { + dir++; + dir_len--; + } + + std::string dir_temp(dir, dir_len); + + char* t = (char*)dir_temp.c_str(); + while (t = strchr(t, '/')) + *t = '\\'; + + std::string temp; + for (data_struct_path& i : data_paths) + for (data_struct_directory& j : i.data) { + temp.assign(j.path); + temp.push_back('\\'); + temp.append(dir_temp); + temp.append(file, file_len); + + if (path_check_file_exists(temp.c_str())) { + path.assign(temp); + return true; + } + } + + if (f2) + return get_file_path("rom/data/", file, path); + return false; +} + bool data_struct::load_file(void* data, const char* path, - bool (*load_func)(void* data, const char* path, const char* file, uint32_t hash)) { + bool (*load_func)(void* data, const char* dir, const char* file, uint32_t hash)) { const char* t = strrchr(path, '/'); if (t) { std::string dir(path, t - path + 1); @@ -592,7 +672,7 @@ bool data_struct::load_file(void* data, const char* path, } bool data_struct::load_file(void* data, const char* dir, const char* file, - bool (*load_func)(void* data, const char* path, const char* file, uint32_t hash)) { + bool (*load_func)(void* data, const char* dir, const char* file, uint32_t hash)) { size_t file_len = utf8_length(file); if (path_check_directory_exists(dir)) { @@ -670,7 +750,7 @@ bool data_struct::load_file(void* data, const char* dir, const char* file, } bool data_struct::load_file(void* data, const char* dir, uint32_t hash, const char* ext, - bool (*load_func)(void* data, const char* path, const char* file, uint32_t hash)) { + bool (*load_func)(void* data, const char* dir, const char* file, uint32_t hash)) { size_t dir_len = utf8_length(dir); if (dir_len >= 2 && !memcmp(dir, "./", 2)) { dir += 2; diff --git a/src/CRE/data.hpp b/src/CRE/data.hpp index 5b631d22..fa189a36 100644 --- a/src/CRE/data.hpp +++ b/src/CRE/data.hpp @@ -112,14 +112,16 @@ struct data_struct { bool check_file_exists(const char* path); bool check_file_exists(const char* dir, const char* file); bool check_file_exists(const char* dir, uint32_t hash); - void get_directory_files(const char* dir, std::vector& data_files); + std::vector get_directory_files(const char* dir); bool get_file(const char* dir, uint32_t hash, const char* ext, std::string& file); + bool get_file_path(std::string& path); + bool get_file_path(const char* dir, const char* file, std::string& path); bool load_file(void* data, const char* path, - bool (*load_func)(void* data, const char* path, const char* file, uint32_t hash)); + bool (*load_func)(void* data, const char* dir, const char* file, uint32_t hash)); bool load_file(void* data, const char* dir, const char* file, - bool (*load_func)(void* data, const char* path, const char* file, uint32_t hash)); + bool (*load_func)(void* data, const char* dir, const char* file, uint32_t hash)); bool load_file(void* data, const char* dir, uint32_t hash, const char* ext, - bool (*load_func)(void* data, const char* path, const char* file, uint32_t hash)); + bool (*load_func)(void* data, const char* dir, const char* file, uint32_t hash)); }; extern data_struct* data_list; diff --git a/src/CRE/hand_item.cpp b/src/CRE/hand_item.cpp index b7bdee47..1311d66a 100644 --- a/src/CRE/hand_item.cpp +++ b/src/CRE/hand_item.cpp @@ -154,8 +154,7 @@ void hand_item_handler::read() { data_struct* aft_data = &data_list[DATA_AFT]; for (const std::string& i : mdata_manager_get()->GetPrefixes()) { - std::string file; - file.assign(i); + std::string file(i); file.append("hand_item_data.txt"); if (aft_data->check_file_exists("rom/", file.c_str())) { diff --git a/src/CRE/item_table.cpp b/src/CRE/item_table.cpp index b23fabdd..094349e2 100644 --- a/src/CRE/item_table.cpp +++ b/src/CRE/item_table.cpp @@ -230,8 +230,7 @@ void item_table_handler::read() { data_struct* aft_data = &data_list[DATA_AFT]; for (const std::string& i : mdata_manager_get()->GetPrefixes()) { - std::string farc_file; - farc_file.assign(i); + std::string farc_file(i); farc_file.append("chritm_prop.farc"); if (aft_data->check_file_exists("rom/", farc_file.c_str())) { diff --git a/src/CRE/module_table.cpp b/src/CRE/module_table.cpp index b32823be..c356b912 100644 --- a/src/CRE/module_table.cpp +++ b/src/CRE/module_table.cpp @@ -312,8 +312,7 @@ void module_table_handler::read() { data_struct* aft_data = &data_list[DATA_AFT]; for (const std::string& i : mdata_manager_get()->GetPrefixes()) { - std::string farc_file; - farc_file.assign(i); + std::string farc_file(i); farc_file.append("gm_module_tbl.farc"); if (aft_data->check_file_exists("rom/", farc_file.c_str())) { diff --git a/src/CRE/pv_db.cpp b/src/CRE/pv_db.cpp index 778b0753..ebbd4655 100644 --- a/src/CRE/pv_db.cpp +++ b/src/CRE/pv_db.cpp @@ -2273,14 +2273,12 @@ void task_pv_db_init() { void task_pv_db_add_paths() { pv_db::TaskPvDB* task_pv_db = task_pv_db_get(); for (const std::string& i : mdata_manager_get()->GetPrefixes()) { - std::string pv_db_file; - pv_db_file.assign(i); + std::string pv_db_file(i); pv_db_file.append("pv_db.txt"); if (data_list[DATA_AFT].check_file_exists("rom/", pv_db_file.c_str())) task_pv_db->paths.push_back({ "rom/", pv_db_file }); - std::string pv_field_file; - pv_field_file.assign(i); + std::string pv_field_file(i); pv_field_file.append("pv_field.txt"); if (data_list[DATA_AFT].check_file_exists("rom/", pv_field_file.c_str())) task_pv_db->paths.push_back({ "rom/", pv_field_file }); diff --git a/src/CRE/rob/rob.cpp b/src/CRE/rob/rob.cpp index a4dc79ba..e2b540d1 100644 --- a/src/CRE/rob/rob.cpp +++ b/src/CRE/rob/rob.cpp @@ -5004,11 +5004,11 @@ osage_init_data::osage_init_data(rob_chara* rob_chr, uint32_t motion_id) { } osage_init_data::osage_init_data(rob_chara* rob_chr, int32_t pv_id, - uint32_t motion_id, std::string&& path, int32_t frame) { + uint32_t motion_id, const std::string& dir, int32_t frame) { this->rob_chr = rob_chr; this->pv_id = pv_id; this->motion_id = motion_id; - this->path.assign(path); + this->dir.assign(dir); this->frame = frame; } @@ -18183,8 +18183,7 @@ void rob_sleeve_handler::read() { data_struct* aft_data = &data_list[DATA_AFT]; for (const std::string& i : mdata_manager_get()->GetPrefixes()) { - std::string file; - file.assign(i); + std::string file(i); file.append("rob_sleeve_data.txt"); if (aft_data->check_file_exists("rom/", file.c_str())) { diff --git a/src/CRE/rob/rob.hpp b/src/CRE/rob/rob.hpp index 4b93ff19..dde2799a 100644 --- a/src/CRE/rob/rob.hpp +++ b/src/CRE/rob/rob.hpp @@ -3564,13 +3564,13 @@ struct osage_init_data { rob_chara* rob_chr; int32_t pv_id; uint32_t motion_id; - std::string path; + std::string dir; int32_t frame; osage_init_data(); osage_init_data(rob_chara* rob_chr, uint32_t motion_id = -1); osage_init_data(rob_chara* rob_chr, int32_t pv_id, - uint32_t motion_id, std::string&& path = "", int32_t frame = -1); + uint32_t motion_id, const std::string& dir = "", int32_t frame = -1); ~osage_init_data(); }; diff --git a/src/CRE/rob/skin_param.cpp b/src/CRE/rob/skin_param.cpp index d51024f6..a5ef2b9c 100644 --- a/src/CRE/rob/skin_param.cpp +++ b/src/CRE/rob/skin_param.cpp @@ -59,7 +59,7 @@ struct SkinParamManager : public app::Task { void AddFiles(); bool AddTask(std::vector& vec); bool CtrlFiles(); - int32_t GetExtSkpFile(const osage_init_data& osage_init, const std::string& path, + int32_t GetExtSkpFile(const osage_init_data& osage_init, const std::string& dir, std::string& file, void* data, motion_database* mot_db, object_database* obj_db); std::vector* GetSkinParamFileData( object_info obj_info, uint32_t motion_id, int32_t frame); @@ -84,11 +84,11 @@ struct sp_skp_db { void* data, motion_database* mot_db, object_database* obj_db); }; -static bool osage_setting_data_load_file(void* data, const char* path, const char* file, uint32_t hash); +static bool osage_setting_data_load_file(void* data, const char* dir, const char* file, uint32_t hash); static SkinParamManager* skin_param_manager_get(int32_t chara_id); -static bool sp_skp_db_load_file(void* data, const char* path, const char* file, uint32_t hash); +static bool sp_skp_db_load_file(void* data, const char* dir, const char* file, uint32_t hash); osage_setting* osage_setting_data; sp_skp_db* sp_skp_db_data; @@ -581,11 +581,9 @@ void osage_setting::load() { data_struct* aft_data = &data_list[DATA_AFT]; for (const std::string& i : mdata_manager_get()->GetPrefixes()) { - std::string file; - file.assign(i); + std::string file(i); file.append("osage_setting.txt"); - aft_data->load_file(this, "rom/skin_param/", - file.c_str(), osage_setting_data_load_file); + aft_data->load_file(this, "rom/skin_param/", file.c_str(), osage_setting_data_load_file); } } @@ -750,11 +748,11 @@ void SkinParamManager::AddFiles() { if (!ex_data || !(osage_count + cloth_count)) continue; - std::string path; + std::string dir; std::string farc_file; std::string file; - path.assign("rom/skin_param/"); + dir.assign("rom/skin_param/"); farc_file.assign(""); @@ -770,11 +768,11 @@ void SkinParamManager::AddFiles() { skp_file->rob_chr = i.rob_chr; skp_file->type = -1; - if (i.path.size()) { - skp_file->type = GetExtSkpFile(i, i.path, + if (i.dir.size()) { + skp_file->type = GetExtSkpFile(i, i.dir, file, aft_data, aft_mot_db, aft_obj_db); if (skp_file->type != -1) - path.assign(i.path); + dir.assign(i.dir); } bool read_farc = false; @@ -843,9 +841,9 @@ void SkinParamManager::AddFiles() { p_file_handler* pfhndl = new p_file_handler; if (read_farc) - pfhndl->read_file(aft_data, path.c_str(), farc_file.c_str(), file.c_str(), false); + pfhndl->read_file(aft_data, dir.c_str(), farc_file.c_str(), file.c_str(), false); else - pfhndl->read_file(aft_data, path.c_str(), file.c_str()); + pfhndl->read_file(aft_data, dir.c_str(), file.c_str()); skp_file->file_handler = pfhndl; files.push_back(skp_file); } @@ -909,9 +907,9 @@ bool SkinParamManager::CtrlFiles() { return !!files.size(); } -int32_t SkinParamManager::GetExtSkpFile(const osage_init_data& osage_init, const std::string& path, +int32_t SkinParamManager::GetExtSkpFile(const osage_init_data& osage_init, const std::string& dir, std::string& file, void* data, motion_database* mot_db, object_database* obj_db) { - if (!path.size()) + if (!dir.size()) return -1; char buf0[0x200]; @@ -945,7 +943,7 @@ int32_t SkinParamManager::GetExtSkpFile(const osage_init_data& osage_init, const *i = c; } - if (((data_struct*)data)->check_file_exists(path.c_str(), buf0)) { + if (((data_struct*)data)->check_file_exists(dir.c_str(), buf0)) { file.assign(buf0); return 0; } @@ -963,13 +961,13 @@ int32_t SkinParamManager::GetExtSkpFile(const osage_init_data& osage_init, const *i = c; } - if (((data_struct*)data)->check_file_exists(path.c_str(), buf0)) { + if (((data_struct*)data)->check_file_exists(dir.c_str(), buf0)) { file.assign(buf0); return 1; } } - if (((data_struct*)data)->check_file_exists(path.c_str(), file.c_str())) + if (((data_struct*)data)->check_file_exists(dir.c_str(), file.c_str())) return 2; return -1; @@ -1058,11 +1056,9 @@ void sp_skp_db::clear() { void sp_skp_db::load() { data_struct* aft_data = &data_list[DATA_AFT]; for (const std::string& i : mdata_manager_get()->GetPrefixes()) { - std::string file; - file.assign(i); + std::string file(i); file.append("sp_skp_db.txt"); - aft_data->load_file(this, "rom/skin_param/", - file.c_str(), sp_skp_db_load_file); + aft_data->load_file(this, "rom/skin_param/", file.c_str(), sp_skp_db_load_file); } } @@ -1250,9 +1246,9 @@ int32_t sp_skp_db::get_ext_skp_file(const osage_init_data& osage_init, return type; } -static bool osage_setting_data_load_file(void* data, const char* path, const char* file, uint32_t hash) { +static bool osage_setting_data_load_file(void* data, const char* dir, const char* file, uint32_t hash) { key_val kv; - if (key_val::load_file(&kv, path, file, hash)) { + if (key_val::load_file(&kv, dir, file, hash)) { ((osage_setting*)data)->parse(&kv); return true; } @@ -1265,9 +1261,9 @@ static SkinParamManager* skin_param_manager_get(int32_t chara_id) { return &skin_param_manager[chara_id]; } -static bool sp_skp_db_load_file(void* data, const char* path, const char* file, uint32_t hash) { +static bool sp_skp_db_load_file(void* data, const char* dir, const char* file, uint32_t hash) { key_val kv; - if (key_val::load_file(&kv, path, file, hash)) { + if (key_val::load_file(&kv, dir, file, hash)) { ((sp_skp_db*)data)->parse(&kv); return true; } diff --git a/src/KKdLib/a3da.cpp b/src/KKdLib/a3da.cpp index 30d3d108..d7c50f35 100644 --- a/src/KKdLib/a3da.cpp +++ b/src/KKdLib/a3da.cpp @@ -392,19 +392,18 @@ void a3da::write(void** data, size_t* size) { s.copy(data, size); } -bool a3da::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool a3da::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); a3da* a = (a3da*)data; - a->read(s.c_str()); + a->read(path.c_str()); return a->ready; } diff --git a/src/KKdLib/a3da.hpp b/src/KKdLib/a3da.hpp index 080085df..f8bb431c 100644 --- a/src/KKdLib/a3da.hpp +++ b/src/KKdLib/a3da.hpp @@ -519,5 +519,5 @@ struct a3da { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/database/aet.cpp b/src/KKdLib/database/aet.cpp index 266971e1..136f28b9 100644 --- a/src/KKdLib/database/aet.cpp +++ b/src/KKdLib/database/aet.cpp @@ -219,19 +219,18 @@ void aet_database_file::write(void** data, size_t* size) { s.copy(data, size); } -bool aet_database_file::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool aet_database_file::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); aet_database_file* aet_db = (aet_database_file*)data; - aet_db->read(s.c_str(), aet_db->modern); + aet_db->read(path.c_str(), aet_db->modern); return aet_db->ready; } diff --git a/src/KKdLib/database/aet.hpp b/src/KKdLib/database/aet.hpp index ee82c7a0..2ba96121 100644 --- a/src/KKdLib/database/aet.hpp +++ b/src/KKdLib/database/aet.hpp @@ -118,7 +118,7 @@ struct aet_database_file { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; struct aet_database { diff --git a/src/KKdLib/database/auth_3d.cpp b/src/KKdLib/database/auth_3d.cpp index e6ac4b70..82da02ca 100644 --- a/src/KKdLib/database/auth_3d.cpp +++ b/src/KKdLib/database/auth_3d.cpp @@ -127,19 +127,18 @@ void auth_3d_database_file::write(void** data, size_t* size) { s.copy(data, size); } -bool auth_3d_database_file::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool auth_3d_database_file::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); auth_3d_database_file* auth_3d_db = (auth_3d_database_file*)data; - auth_3d_db->read(s.c_str()); + auth_3d_db->read(path.c_str()); return auth_3d_db->ready; } diff --git a/src/KKdLib/database/auth_3d.hpp b/src/KKdLib/database/auth_3d.hpp index 21bf937c..3181d7ec 100644 --- a/src/KKdLib/database/auth_3d.hpp +++ b/src/KKdLib/database/auth_3d.hpp @@ -65,7 +65,7 @@ struct auth_3d_database_file { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; struct auth_3d_database { diff --git a/src/KKdLib/database/bone.cpp b/src/KKdLib/database/bone.cpp index abc776c2..187f1ed5 100644 --- a/src/KKdLib/database/bone.cpp +++ b/src/KKdLib/database/bone.cpp @@ -357,19 +357,18 @@ const float_t* bone_database::get_skeleton_heel_height(const char* name) const { return 0; } -bool bone_database::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool bone_database::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); bone_database* bone_data = (bone_database*)data; - bone_data->read(s.c_str(), bone_data->modern); + bone_data->read(path.c_str(), bone_data->modern); return bone_data->ready; } diff --git a/src/KKdLib/database/bone.hpp b/src/KKdLib/database/bone.hpp index 552ed130..dcd516ba 100644 --- a/src/KKdLib/database/bone.hpp +++ b/src/KKdLib/database/bone.hpp @@ -98,7 +98,7 @@ struct bone_database { const std::vector* get_skeleton_parent_indices(const char* name) const; const float_t* get_skeleton_heel_height(const char* name) const; - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; extern void bone_database_bones_calculate_count(const std::vector* bones, diff --git a/src/KKdLib/database/hand_item.cpp b/src/KKdLib/database/hand_item.cpp index fd45d6f4..dcdcd537 100644 --- a/src/KKdLib/database/hand_item.cpp +++ b/src/KKdLib/database/hand_item.cpp @@ -103,19 +103,18 @@ void hnd_itm::write(void** data, size_t* size) { s.copy(data, size); } -bool hnd_itm::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool hnd_itm::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); hnd_itm* itm_tbl = (hnd_itm*)data; - itm_tbl->read(s.c_str()); + itm_tbl->read(path.c_str()); return itm_tbl->ready; } diff --git a/src/KKdLib/database/hand_item.hpp b/src/KKdLib/database/hand_item.hpp index a191b479..3ec8fa44 100644 --- a/src/KKdLib/database/hand_item.hpp +++ b/src/KKdLib/database/hand_item.hpp @@ -42,5 +42,5 @@ struct hnd_itm { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/database/item_table.cpp b/src/KKdLib/database/item_table.cpp index a90a59d5..56bdd314 100644 --- a/src/KKdLib/database/item_table.cpp +++ b/src/KKdLib/database/item_table.cpp @@ -274,19 +274,18 @@ void itm_table::write(void** data, size_t* size) { s.copy(data, size); } -bool itm_table::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool itm_table::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); itm_table* itm_tbl = (itm_table*)data; - itm_tbl->read(s.c_str()); + itm_tbl->read(path.c_str()); return itm_tbl->ready; } diff --git a/src/KKdLib/database/item_table.hpp b/src/KKdLib/database/item_table.hpp index 0282f963..2eea46bb 100644 --- a/src/KKdLib/database/item_table.hpp +++ b/src/KKdLib/database/item_table.hpp @@ -194,7 +194,7 @@ struct itm_table { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; extern const char* chara_auth_3d_names[]; diff --git a/src/KKdLib/database/motion.cpp b/src/KKdLib/database/motion.cpp index eeffef0b..4302f70e 100644 --- a/src/KKdLib/database/motion.cpp +++ b/src/KKdLib/database/motion.cpp @@ -150,19 +150,18 @@ void motion_database_file::write(void** data, size_t* size) { s.copy(data, size); } -bool motion_database_file::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool motion_database_file::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); motion_database_file* mot_db = (motion_database_file*)data; - mot_db->read(s.c_str()); + mot_db->read(path.c_str()); return mot_db->ready; } diff --git a/src/KKdLib/database/motion.hpp b/src/KKdLib/database/motion.hpp index ddbd1390..27f10fd9 100644 --- a/src/KKdLib/database/motion.hpp +++ b/src/KKdLib/database/motion.hpp @@ -63,7 +63,7 @@ struct motion_database_file { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; struct motion_database { diff --git a/src/KKdLib/database/object.cpp b/src/KKdLib/database/object.cpp index ec7bea53..3a1437ec 100644 --- a/src/KKdLib/database/object.cpp +++ b/src/KKdLib/database/object.cpp @@ -212,19 +212,18 @@ void object_database_file::write(void** data, size_t* size) { s.copy(data, size); } -bool object_database_file::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool object_database_file::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); object_database_file* obj_db = (object_database_file*)data; - obj_db->read(s.c_str(), obj_db->modern); + obj_db->read(path.c_str(), obj_db->modern); return obj_db->ready; } diff --git a/src/KKdLib/database/object.hpp b/src/KKdLib/database/object.hpp index 64f4c373..fcb68d5a 100644 --- a/src/KKdLib/database/object.hpp +++ b/src/KKdLib/database/object.hpp @@ -132,7 +132,7 @@ struct object_database_file { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; struct object_database { diff --git a/src/KKdLib/database/sprite.cpp b/src/KKdLib/database/sprite.cpp index eefc9dda..d5993ef6 100644 --- a/src/KKdLib/database/sprite.cpp +++ b/src/KKdLib/database/sprite.cpp @@ -216,19 +216,18 @@ void sprite_database_file::write(void** data, size_t* size) { s.copy(data, size); } -bool sprite_database_file::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool sprite_database_file::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); sprite_database_file* spr_db = (sprite_database_file*)data; - spr_db->read(s.c_str(), spr_db->modern); + spr_db->read(path.c_str(), spr_db->modern); return spr_db->ready; } diff --git a/src/KKdLib/database/sprite.hpp b/src/KKdLib/database/sprite.hpp index c0d5413e..718d4a90 100644 --- a/src/KKdLib/database/sprite.hpp +++ b/src/KKdLib/database/sprite.hpp @@ -117,7 +117,7 @@ struct sprite_database_file { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; struct sprite_database { diff --git a/src/KKdLib/database/stage.cpp b/src/KKdLib/database/stage.cpp index b30eaffc..adfe2c07 100644 --- a/src/KKdLib/database/stage.cpp +++ b/src/KKdLib/database/stage.cpp @@ -241,19 +241,18 @@ void stage_database_file::write(void** data, size_t* size) { s.copy(data, size); } -bool stage_database_file::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool stage_database_file::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); stage_database_file* stage_data = (stage_database_file*)data; - stage_data->read(s.c_str(), stage_data->modern); + stage_data->read(path.c_str(), stage_data->modern); return stage_data->ready; } diff --git a/src/KKdLib/database/stage.hpp b/src/KKdLib/database/stage.hpp index 18b6c4fe..f88433f8 100644 --- a/src/KKdLib/database/stage.hpp +++ b/src/KKdLib/database/stage.hpp @@ -262,7 +262,7 @@ struct stage_database_file { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; struct stage_database { diff --git a/src/KKdLib/database/texture.cpp b/src/KKdLib/database/texture.cpp index 61a84d0c..cda40666 100644 --- a/src/KKdLib/database/texture.cpp +++ b/src/KKdLib/database/texture.cpp @@ -196,19 +196,18 @@ void texture_database_file::write(void** data, size_t* size) { s.copy(data, size); } -bool texture_database_file::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool texture_database_file::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); texture_database_file* tex_db = (texture_database_file*)data; - tex_db->read(s.c_str(), tex_db->modern); + tex_db->read(path.c_str(), tex_db->modern); return tex_db->ready; } diff --git a/src/KKdLib/database/texture.hpp b/src/KKdLib/database/texture.hpp index db9e8feb..c4f03c2f 100644 --- a/src/KKdLib/database/texture.hpp +++ b/src/KKdLib/database/texture.hpp @@ -45,7 +45,7 @@ struct texture_database_file { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; struct texture_database { diff --git a/src/KKdLib/default.cpp b/src/KKdLib/default.cpp index 526ec0b2..2301dc29 100644 --- a/src/KKdLib/default.cpp +++ b/src/KKdLib/default.cpp @@ -5,6 +5,76 @@ #include "default.hpp" +const char string_upper_to_lower_table[0x100] = { + (char)0x00, (char)0x01, (char)0x02, (char)0x03, (char)0x04, (char)0x05, (char)0x06, (char)0x07, + (char)0x08, (char)0x09, (char)0x0A, (char)0x0B, (char)0x0C, (char)0x0D, (char)0x0E, (char)0x0F, + (char)0x10, (char)0x11, (char)0x12, (char)0x13, (char)0x14, (char)0x15, (char)0x16, (char)0x17, + (char)0x18, (char)0x19, (char)0x1A, (char)0x1B, (char)0x1C, (char)0x1D, (char)0x1E, (char)0x1F, + (char)0x20, (char)0x21, (char)0x22, (char)0x23, (char)0x24, (char)0x25, (char)0x26, (char)0x27, + (char)0x28, (char)0x29, (char)0x2A, (char)0x2B, (char)0x2C, (char)0x2D, (char)0x2E, (char)0x2F, + (char)0x30, (char)0x31, (char)0x32, (char)0x33, (char)0x34, (char)0x35, (char)0x36, (char)0x37, + (char)0x38, (char)0x39, (char)0x3A, (char)0x3B, (char)0x3C, (char)0x3D, (char)0x3E, (char)0x3F, + (char)0x40, (char)0x61, (char)0x62, (char)0x63, (char)0x64, (char)0x65, (char)0x66, (char)0x67, + (char)0x68, (char)0x69, (char)0x6A, (char)0x6B, (char)0x6C, (char)0x6D, (char)0x6E, (char)0x6F, + (char)0x70, (char)0x71, (char)0x72, (char)0x73, (char)0x74, (char)0x75, (char)0x76, (char)0x77, + (char)0x78, (char)0x79, (char)0x7A, (char)0x5B, (char)0x5C, (char)0x5D, (char)0x5E, (char)0x5F, + (char)0x60, (char)0x61, (char)0x62, (char)0x63, (char)0x64, (char)0x65, (char)0x66, (char)0x67, + (char)0x68, (char)0x69, (char)0x6A, (char)0x6B, (char)0x6C, (char)0x6D, (char)0x6E, (char)0x6F, + (char)0x70, (char)0x71, (char)0x72, (char)0x73, (char)0x74, (char)0x75, (char)0x76, (char)0x77, + (char)0x78, (char)0x79, (char)0x7A, (char)0x7B, (char)0x7C, (char)0x7D, (char)0x7E, (char)0x7F, + (char)0x80, (char)0x81, (char)0x82, (char)0x83, (char)0x84, (char)0x85, (char)0x86, (char)0x87, + (char)0x88, (char)0x89, (char)0x8A, (char)0x8B, (char)0x8C, (char)0x8D, (char)0x8E, (char)0x8F, + (char)0x90, (char)0x91, (char)0x92, (char)0x93, (char)0x94, (char)0x95, (char)0x96, (char)0x97, + (char)0x98, (char)0x99, (char)0x9A, (char)0x9B, (char)0x9C, (char)0x9D, (char)0x9E, (char)0x9F, + (char)0xA0, (char)0xA1, (char)0xA2, (char)0xA3, (char)0xA4, (char)0xA5, (char)0xA6, (char)0xA7, + (char)0xA8, (char)0xA9, (char)0xAA, (char)0xAB, (char)0xAC, (char)0xAD, (char)0xAE, (char)0xAF, + (char)0xB0, (char)0xB1, (char)0xB2, (char)0xB3, (char)0xB4, (char)0xB5, (char)0xB6, (char)0xB7, + (char)0xB8, (char)0xB9, (char)0xBA, (char)0xBB, (char)0xBC, (char)0xBD, (char)0xBE, (char)0xBF, + (char)0xC0, (char)0xC1, (char)0xC2, (char)0xC3, (char)0xC4, (char)0xC5, (char)0xC6, (char)0xC7, + (char)0xC8, (char)0xC9, (char)0xCA, (char)0xCB, (char)0xCC, (char)0xCD, (char)0xCE, (char)0xCF, + (char)0xD0, (char)0xD1, (char)0xD2, (char)0xD3, (char)0xD4, (char)0xD5, (char)0xD6, (char)0xD7, + (char)0xD8, (char)0xD9, (char)0xDA, (char)0xDB, (char)0xDC, (char)0xDD, (char)0xDE, (char)0xDF, + (char)0xE0, (char)0xE1, (char)0xE2, (char)0xE3, (char)0xE4, (char)0xE5, (char)0xE6, (char)0xE7, + (char)0xE8, (char)0xE9, (char)0xEA, (char)0xEB, (char)0xEC, (char)0xED, (char)0xEE, (char)0xEF, + (char)0xF0, (char)0xF1, (char)0xF2, (char)0xF3, (char)0xF4, (char)0xF5, (char)0xF6, (char)0xF7, + (char)0xF8, (char)0xF9, (char)0xFA, (char)0xFB, (char)0xFC, (char)0xFD, (char)0xFE, (char)0xFF, +}; + +const char string_lower_to_upper_table[0x100] = { + (char)0x00, (char)0x01, (char)0x02, (char)0x03, (char)0x04, (char)0x05, (char)0x06, (char)0x07, + (char)0x08, (char)0x09, (char)0x0A, (char)0x0B, (char)0x0C, (char)0x0D, (char)0x0E, (char)0x0F, + (char)0x10, (char)0x11, (char)0x12, (char)0x13, (char)0x14, (char)0x15, (char)0x16, (char)0x17, + (char)0x18, (char)0x19, (char)0x1A, (char)0x1B, (char)0x1C, (char)0x1D, (char)0x1E, (char)0x1F, + (char)0x20, (char)0x21, (char)0x22, (char)0x23, (char)0x24, (char)0x25, (char)0x26, (char)0x27, + (char)0x28, (char)0x29, (char)0x2A, (char)0x2B, (char)0x2C, (char)0x2D, (char)0x2E, (char)0x2F, + (char)0x30, (char)0x31, (char)0x32, (char)0x33, (char)0x34, (char)0x35, (char)0x36, (char)0x37, + (char)0x38, (char)0x39, (char)0x3A, (char)0x3B, (char)0x3C, (char)0x3D, (char)0x3E, (char)0x3F, + (char)0x40, (char)0x41, (char)0x42, (char)0x43, (char)0x44, (char)0x45, (char)0x46, (char)0x47, + (char)0x48, (char)0x49, (char)0x4A, (char)0x4B, (char)0x4C, (char)0x4D, (char)0x4E, (char)0x4F, + (char)0x50, (char)0x51, (char)0x52, (char)0x53, (char)0x54, (char)0x55, (char)0x56, (char)0x57, + (char)0x58, (char)0x59, (char)0x5A, (char)0x5B, (char)0x5C, (char)0x5D, (char)0x5E, (char)0x5F, + (char)0x60, (char)0x41, (char)0x42, (char)0x43, (char)0x44, (char)0x45, (char)0x46, (char)0x47, + (char)0x48, (char)0x49, (char)0x4A, (char)0x4B, (char)0x4C, (char)0x4D, (char)0x4E, (char)0x4F, + (char)0x50, (char)0x51, (char)0x52, (char)0x53, (char)0x54, (char)0x55, (char)0x56, (char)0x57, + (char)0x58, (char)0x59, (char)0x5A, (char)0x7B, (char)0x7C, (char)0x7D, (char)0x7E, (char)0x7F, + (char)0x80, (char)0x81, (char)0x82, (char)0x83, (char)0x84, (char)0x85, (char)0x86, (char)0x87, + (char)0x88, (char)0x89, (char)0x8A, (char)0x8B, (char)0x8C, (char)0x8D, (char)0x8E, (char)0x8F, + (char)0x90, (char)0x91, (char)0x92, (char)0x93, (char)0x94, (char)0x95, (char)0x96, (char)0x97, + (char)0x98, (char)0x99, (char)0x9A, (char)0x9B, (char)0x9C, (char)0x9D, (char)0x9E, (char)0x9F, + (char)0xA0, (char)0xA1, (char)0xA2, (char)0xA3, (char)0xA4, (char)0xA5, (char)0xA6, (char)0xA7, + (char)0xA8, (char)0xA9, (char)0xAA, (char)0xAB, (char)0xAC, (char)0xAD, (char)0xAE, (char)0xAF, + (char)0xB0, (char)0xB1, (char)0xB2, (char)0xB3, (char)0xB4, (char)0xB5, (char)0xB6, (char)0xB7, + (char)0xB8, (char)0xB9, (char)0xBA, (char)0xBB, (char)0xBC, (char)0xBD, (char)0xBE, (char)0xBF, + (char)0xC0, (char)0xC1, (char)0xC2, (char)0xC3, (char)0xC4, (char)0xC5, (char)0xC6, (char)0xC7, + (char)0xC8, (char)0xC9, (char)0xCA, (char)0xCB, (char)0xCC, (char)0xCD, (char)0xCE, (char)0xCF, + (char)0xD0, (char)0xD1, (char)0xD2, (char)0xD3, (char)0xD4, (char)0xD5, (char)0xD6, (char)0xD7, + (char)0xD8, (char)0xD9, (char)0xDA, (char)0xDB, (char)0xDC, (char)0xDD, (char)0xDE, (char)0xDF, + (char)0xE0, (char)0xE1, (char)0xE2, (char)0xE3, (char)0xE4, (char)0xE5, (char)0xE6, (char)0xE7, + (char)0xE8, (char)0xE9, (char)0xEA, (char)0xEB, (char)0xEC, (char)0xED, (char)0xEE, (char)0xEF, + (char)0xF0, (char)0xF1, (char)0xF2, (char)0xF3, (char)0xF4, (char)0xF5, (char)0xF6, (char)0xF7, + (char)0xF8, (char)0xF9, (char)0xFA, (char)0xFB, (char)0xFC, (char)0xFD, (char)0xFE, (char)0xFF, +}; + void* force_malloc(size_t size) { if (!size) return 0; @@ -343,3 +413,61 @@ std::string utf16_to_utf8(const std::wstring& s) { *_str++ = 0; return str; } + +std::string string_to_lower(const std::string& str) { + std::string _str(str); + for (char& c : _str) + c = string_upper_to_lower_table[c]; + return _str; +} + +std::string string_to_upper(const std::string& str) { + std::string _str(str); + for (char& c : _str) + c = string_lower_to_upper_table[c]; + return _str; +} + +std::string sprintf_s_string(const char* fmt, ...) { + va_list args; + va_start(args, fmt); + std::string buf = vsprintf_s_string(fmt, args); + va_end(args); + return buf; +} + +std::wstring swprintf_s_string(const wchar_t* fmt, ...) { + va_list args; + va_start(args, fmt); + std::wstring buf = vswprintf_s_string(fmt, args); + va_end(args); + return buf; +} + +std::string vsprintf_s_string(const char* fmt, va_list args) { + char _buf[0x100]; + int32_t len = sprintf_s(_buf, sizeof(_buf), fmt, args); + if (len < 0) + return {}; + else if (len < sizeof(_buf)) + return std::string(_buf, len); + + std::string buf(len, 0); + if (sprintf_s((char*)buf.data(), buf.size(), fmt, args) != len) + return {}; + return buf; +} + +std::wstring vswprintf_s_string(const wchar_t* fmt, va_list args) { + wchar_t _buf[0x100]; + int32_t len = vswprintf_s(_buf, sizeof(_buf) / sizeof(wchar_t), fmt, args); + if (len < 0) + return {}; + else if (len < sizeof(_buf)) + return std::wstring(_buf, len); + + std::wstring buf(len, 0); + if (vswprintf_s((wchar_t*)buf.data(), buf.size(), fmt, args) != len) + return {}; + return buf; +} diff --git a/src/KKdLib/default.hpp b/src/KKdLib/default.hpp index ad90eea0..c696cd06 100644 --- a/src/KKdLib/default.hpp +++ b/src/KKdLib/default.hpp @@ -535,9 +535,20 @@ inline constexpr size_t utf16_to_utf8_length(const wchar_t* s, size_t length) { return _length; } +extern const char string_upper_to_lower_table[0x100]; +extern const char string_lower_to_upper_table[0x100]; + extern wchar_t* utf8_to_utf16(const char* s); extern wchar_t* utf8_to_utf16(const char* s, size_t length); extern char* utf16_to_utf8(const wchar_t* s); extern char* utf16_to_utf8(const wchar_t* s, size_t length); extern std::wstring utf8_to_utf16(const std::string& s); extern std::string utf16_to_utf8(const std::wstring& s); + +extern std::string string_to_lower(const std::string& str); +extern std::string string_to_upper(const std::string& str); + +extern std::string sprintf_s_string(const char* fmt, ...); +extern std::wstring swprintf_s_string(const wchar_t* fmt, ...); +extern std::string vsprintf_s_string(const char* fmt, va_list args); +extern std::wstring vswprintf_s_string(const wchar_t* fmt, va_list args); diff --git a/src/KKdLib/dsc.cpp b/src/KKdLib/dsc.cpp index 61acd174..9db4b3b4 100644 --- a/src/KKdLib/dsc.cpp +++ b/src/KKdLib/dsc.cpp @@ -3264,13 +3264,12 @@ int32_t dsc::calculate_target_flying_time(int32_t bpm, int32_t time_signature) { return (int32_t)((float_t)time_signature * (60.0f / (float_t)bpm) * 1000.0f); } -bool dsc::load_file(void* data, const char* path, const char* file, uint32_t hash) { - std::string s; - s.assign(path); - s.append(file); +bool dsc::load_file(void* data, const char* dir, const char* file, uint32_t hash) { + std::string path(dir); + path.append(file); file_stream dsc_s; - dsc_s.open(s.c_str(), "rb"); + dsc_s.open(path.c_str(), "rb"); void* dsc_data = force_malloc(dsc_s.length); size_t dsc_length = dsc_s.length; dsc_s.read(dsc_data, dsc_length); diff --git a/src/KKdLib/dsc.hpp b/src/KKdLib/dsc.hpp index 4888ae3f..9c530934 100644 --- a/src/KKdLib/dsc.hpp +++ b/src/KKdLib/dsc.hpp @@ -308,7 +308,7 @@ struct dsc { void unparse(void** data, size_t* size); static int32_t calculate_target_flying_time(int32_t bpm, int32_t time_signature); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); dsc& operator=(const dsc& d); }; diff --git a/src/KKdLib/farc.cpp b/src/KKdLib/farc.cpp index 4acc65d5..d773ecb6 100644 --- a/src/KKdLib/farc.cpp +++ b/src/KKdLib/farc.cpp @@ -378,18 +378,18 @@ void farc::write(void** data, size_t* size, farc_signature signature, farc_flags farc_pack_files(this, s, signature, flags); } -bool farc::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool farc::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); if (file_len < 5 || memcmp(&file[file_len - 5], ".farc", 6)) return false; - size_t path_len = utf8_length(path); - if (path_len + file_len + 2 > 0x1000) + size_t dir_len = utf8_length(dir); + if (dir_len + file_len + 2 > 0x1000) return false; char buf[0x1000]; - memcpy(buf, path, path_len); - memcpy(buf + path_len, file, file_len + 1); + memcpy(buf, dir, dir_len); + memcpy(buf + dir_len, file, file_len + 1); if (!path_check_file_exists(buf)) return false; diff --git a/src/KKdLib/farc.hpp b/src/KKdLib/farc.hpp index 423f7aec..09af3e80 100644 --- a/src/KKdLib/farc.hpp +++ b/src/KKdLib/farc.hpp @@ -80,5 +80,5 @@ struct farc { void write(void** data, size_t* size, farc_signature signature = FARC_FArC, farc_flags flags = FARC_NONE); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/key_val.cpp b/src/KKdLib/key_val.cpp index 3314ab10..c8f8e60c 100644 --- a/src/KKdLib/key_val.cpp +++ b/src/KKdLib/key_val.cpp @@ -679,13 +679,12 @@ bool key_val::read(const char* key0, const char* key1, vec3& value) { return false; } -bool key_val::load_file(void* data, const char* path, const char* file, uint32_t hash) { - std::string s; - s.assign(path); - s.append(file); +bool key_val::load_file(void* data, const char* dir, const char* file, uint32_t hash) { + std::string path(dir); + path.append(file); key_val* kv = (key_val*)data; - kv->file_read(s.c_str()); + kv->file_read(path.c_str()); return kv->buf ? true : false; } diff --git a/src/KKdLib/key_val.hpp b/src/KKdLib/key_val.hpp index 4d40e634..003d9e0b 100644 --- a/src/KKdLib/key_val.hpp +++ b/src/KKdLib/key_val.hpp @@ -84,7 +84,7 @@ struct key_val { bool read(const char* key0, const char* key1, vec3& value); bool read(std::string& key0, std::string& key1, vec3& value); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; struct key_val_out { diff --git a/src/KKdLib/light_param/face.cpp b/src/KKdLib/light_param/face.cpp index c56f2ff4..0ba1825b 100644 --- a/src/KKdLib/light_param/face.cpp +++ b/src/KKdLib/light_param/face.cpp @@ -85,19 +85,18 @@ void light_param_face::write(void** data, size_t* size) { s.copy(data, size); } -bool light_param_face::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool light_param_face::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); light_param_face* face = (light_param_face*)data; - face->read(s.c_str()); + face->read(path.c_str()); return face->ready; } diff --git a/src/KKdLib/light_param/face.hpp b/src/KKdLib/light_param/face.hpp index 0cc7fe7a..fb441a65 100644 --- a/src/KKdLib/light_param/face.hpp +++ b/src/KKdLib/light_param/face.hpp @@ -26,5 +26,5 @@ struct light_param_face { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/light_param/fog.cpp b/src/KKdLib/light_param/fog.cpp index 10f21aaa..85de927f 100644 --- a/src/KKdLib/light_param/fog.cpp +++ b/src/KKdLib/light_param/fog.cpp @@ -85,19 +85,18 @@ void light_param_fog::write(void** data, size_t* size) { s.copy(data, size); } -bool light_param_fog::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool light_param_fog::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); light_param_fog* fog = (light_param_fog*)data; - fog->read(s.c_str()); + fog->read(path.c_str()); return fog->ready; } diff --git a/src/KKdLib/light_param/fog.hpp b/src/KKdLib/light_param/fog.hpp index 140a211a..c82f5eec 100644 --- a/src/KKdLib/light_param/fog.hpp +++ b/src/KKdLib/light_param/fog.hpp @@ -51,5 +51,5 @@ struct light_param_fog { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/light_param/glow.cpp b/src/KKdLib/light_param/glow.cpp index 8dab7967..f32d693b 100644 --- a/src/KKdLib/light_param/glow.cpp +++ b/src/KKdLib/light_param/glow.cpp @@ -89,19 +89,18 @@ void light_param_glow::write(void** data, size_t* size) { s.copy(data, size); } -bool light_param_glow::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool light_param_glow::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); light_param_glow* glow = (light_param_glow*)data; - glow->read(s.c_str()); + glow->read(path.c_str()); return glow->ready; } diff --git a/src/KKdLib/light_param/glow.hpp b/src/KKdLib/light_param/glow.hpp index e1df8518..70c4adaa 100644 --- a/src/KKdLib/light_param/glow.hpp +++ b/src/KKdLib/light_param/glow.hpp @@ -53,5 +53,5 @@ struct light_param_glow { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/light_param/ibl.cpp b/src/KKdLib/light_param/ibl.cpp index 4083df38..46f1943c 100644 --- a/src/KKdLib/light_param/ibl.cpp +++ b/src/KKdLib/light_param/ibl.cpp @@ -50,19 +50,18 @@ void light_param_ibl::read(const void* data, size_t size) { light_param_ibl_read_inner(this, s); } -bool light_param_ibl::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool light_param_ibl::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); light_param_ibl* ibl = (light_param_ibl*)data; - ibl->read(s.c_str()); + ibl->read(path.c_str()); return ibl->ready; } diff --git a/src/KKdLib/light_param/ibl.hpp b/src/KKdLib/light_param/ibl.hpp index a5066e69..b576d972 100644 --- a/src/KKdLib/light_param/ibl.hpp +++ b/src/KKdLib/light_param/ibl.hpp @@ -45,5 +45,5 @@ struct light_param_ibl { void read(const wchar_t* path); void read(const void* data, size_t size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/light_param/light.cpp b/src/KKdLib/light_param/light.cpp index ac37ea81..64da58cb 100644 --- a/src/KKdLib/light_param/light.cpp +++ b/src/KKdLib/light_param/light.cpp @@ -85,19 +85,18 @@ void light_param_light::write(void** data, size_t* size) { s.copy(data, size); } -bool light_param_light::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool light_param_light::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); light_param_light* light = (light_param_light*)data; - light->read(s.c_str()); + light->read(path.c_str()); return light->ready; } diff --git a/src/KKdLib/light_param/light.hpp b/src/KKdLib/light_param/light.hpp index 1d162532..9f7c0f7c 100644 --- a/src/KKdLib/light_param/light.hpp +++ b/src/KKdLib/light_param/light.hpp @@ -96,5 +96,5 @@ struct light_param_light { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/light_param/wind.cpp b/src/KKdLib/light_param/wind.cpp index 698492a7..6aa89750 100644 --- a/src/KKdLib/light_param/wind.cpp +++ b/src/KKdLib/light_param/wind.cpp @@ -86,19 +86,18 @@ void light_param_wind::write(void** data, size_t* size) { s.copy(data, size); } -bool light_param_wind::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool light_param_wind::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); light_param_wind* wind = (light_param_wind*)data; - wind->read(s.c_str()); + wind->read(path.c_str()); return wind->ready; } diff --git a/src/KKdLib/light_param/wind.hpp b/src/KKdLib/light_param/wind.hpp index 8b4e815b..a6db4d4b 100644 --- a/src/KKdLib/light_param/wind.hpp +++ b/src/KKdLib/light_param/wind.hpp @@ -40,5 +40,5 @@ struct light_param_wind { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/post_process_table/dof.cpp b/src/KKdLib/post_process_table/dof.cpp index e648b177..12aef3e2 100644 --- a/src/KKdLib/post_process_table/dof.cpp +++ b/src/KKdLib/post_process_table/dof.cpp @@ -107,19 +107,18 @@ void dof::write(void** data, size_t* size) { s.copy(data, size); } -bool dof::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool dof::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); dof* d = (dof*)data; - d->read(s.c_str()); + d->read(path.c_str()); return d->ready; } diff --git a/src/KKdLib/post_process_table/dof.hpp b/src/KKdLib/post_process_table/dof.hpp index d8266230..fceb859b 100644 --- a/src/KKdLib/post_process_table/dof.hpp +++ b/src/KKdLib/post_process_table/dof.hpp @@ -45,5 +45,5 @@ struct dof { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/pvpp.cpp b/src/KKdLib/pvpp.cpp index b88065fa..dced7ab6 100644 --- a/src/KKdLib/pvpp.cpp +++ b/src/KKdLib/pvpp.cpp @@ -116,19 +116,18 @@ void pvpp::read(const void* data, size_t size) { pvpp_read_inner(this, s); } -bool pvpp::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool pvpp::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); pvpp* pp = (pvpp*)data; - pp->read(s.c_str()); + pp->read(path.c_str()); return pp->ready; } diff --git a/src/KKdLib/pvpp.hpp b/src/KKdLib/pvpp.hpp index f9e4d90e..15f9d901 100644 --- a/src/KKdLib/pvpp.hpp +++ b/src/KKdLib/pvpp.hpp @@ -120,6 +120,6 @@ struct pvpp { void read(const wchar_t* path); void read(const void* data, size_t size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/pvsr.cpp b/src/KKdLib/pvsr.cpp index 418890af..8c6ed80e 100644 --- a/src/KKdLib/pvsr.cpp +++ b/src/KKdLib/pvsr.cpp @@ -144,19 +144,18 @@ void pvsr::read(const void* data, size_t size) { pvsr_read_inner(this, s); } -bool pvsr::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool pvsr::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); pvsr* sr = (pvsr*)data; - sr->read(s.c_str()); + sr->read(path.c_str()); return sr->ready; } diff --git a/src/KKdLib/pvsr.hpp b/src/KKdLib/pvsr.hpp index 0958865e..0f55510a 100644 --- a/src/KKdLib/pvsr.hpp +++ b/src/KKdLib/pvsr.hpp @@ -145,5 +145,5 @@ struct pvsr { void read(const wchar_t* path); void read(const void* data, size_t size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/stage_param/fog_ring.cpp b/src/KKdLib/stage_param/fog_ring.cpp index 8ccb477b..e872a91e 100644 --- a/src/KKdLib/stage_param/fog_ring.cpp +++ b/src/KKdLib/stage_param/fog_ring.cpp @@ -88,19 +88,18 @@ void stage_param_fog_ring::write(void** data, size_t* size) { s.copy(data, size); } -bool stage_param_fog_ring::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool stage_param_fog_ring::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); stage_param_fog_ring* fog_ring = (stage_param_fog_ring*)data; - fog_ring->read(s.c_str()); + fog_ring->read(path.c_str()); return fog_ring->ready; } diff --git a/src/KKdLib/stage_param/fog_ring.hpp b/src/KKdLib/stage_param/fog_ring.hpp index 7d6b9232..53eccac2 100644 --- a/src/KKdLib/stage_param/fog_ring.hpp +++ b/src/KKdLib/stage_param/fog_ring.hpp @@ -31,5 +31,5 @@ struct stage_param_fog_ring { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/stage_param/leaf.cpp b/src/KKdLib/stage_param/leaf.cpp index bc43c01c..02f82473 100644 --- a/src/KKdLib/stage_param/leaf.cpp +++ b/src/KKdLib/stage_param/leaf.cpp @@ -92,19 +92,18 @@ void stage_param_leaf::write(void** data, size_t* size) { s.copy(data, size); } -bool stage_param_leaf::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool stage_param_leaf::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); stage_param_leaf* leaf = (stage_param_leaf*)data; - leaf->read(s.c_str()); + leaf->read(path.c_str()); return leaf->ready; } diff --git a/src/KKdLib/stage_param/leaf.hpp b/src/KKdLib/stage_param/leaf.hpp index 5ec76554..46b1db2c 100644 --- a/src/KKdLib/stage_param/leaf.hpp +++ b/src/KKdLib/stage_param/leaf.hpp @@ -43,5 +43,5 @@ struct stage_param_leaf { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/stage_param/litproj.cpp b/src/KKdLib/stage_param/litproj.cpp index 606eb468..97f0994d 100644 --- a/src/KKdLib/stage_param/litproj.cpp +++ b/src/KKdLib/stage_param/litproj.cpp @@ -85,19 +85,18 @@ void stage_param_litproj::write(void** data, size_t* size) { s.copy(data, size); } -bool stage_param_litproj::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool stage_param_litproj::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); stage_param_litproj* litproj = (stage_param_litproj*)data; - litproj->read(s.c_str()); + litproj->read(path.c_str()); return litproj->ready; } diff --git a/src/KKdLib/stage_param/litproj.hpp b/src/KKdLib/stage_param/litproj.hpp index ab7159c0..0790dcd7 100644 --- a/src/KKdLib/stage_param/litproj.hpp +++ b/src/KKdLib/stage_param/litproj.hpp @@ -23,5 +23,5 @@ struct stage_param_litproj { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/stage_param/rain.cpp b/src/KKdLib/stage_param/rain.cpp index d60b3ed2..a57dbbf9 100644 --- a/src/KKdLib/stage_param/rain.cpp +++ b/src/KKdLib/stage_param/rain.cpp @@ -87,19 +87,18 @@ void stage_param_rain::write(void** data, size_t* size) { s.copy(data, size); } -bool stage_param_rain::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool stage_param_rain::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); stage_param_rain* rain = (stage_param_rain*)data; - rain->read(s.c_str()); + rain->read(path.c_str()); return rain->ready; } diff --git a/src/KKdLib/stage_param/rain.hpp b/src/KKdLib/stage_param/rain.hpp index 80763705..d440e700 100644 --- a/src/KKdLib/stage_param/rain.hpp +++ b/src/KKdLib/stage_param/rain.hpp @@ -31,5 +31,5 @@ struct stage_param_rain { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/stage_param/ripple.cpp b/src/KKdLib/stage_param/ripple.cpp index 4cfc9781..573c460c 100644 --- a/src/KKdLib/stage_param/ripple.cpp +++ b/src/KKdLib/stage_param/ripple.cpp @@ -90,19 +90,18 @@ void stage_param_ripple::write(void** data, size_t* size) { s.copy(data, size); } -bool stage_param_ripple::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool stage_param_ripple::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); stage_param_ripple* ripple = (stage_param_ripple*)data; - ripple->read(s.c_str()); + ripple->read(path.c_str()); return ripple->ready; } diff --git a/src/KKdLib/stage_param/ripple.hpp b/src/KKdLib/stage_param/ripple.hpp index 49a95d9b..1c349d23 100644 --- a/src/KKdLib/stage_param/ripple.hpp +++ b/src/KKdLib/stage_param/ripple.hpp @@ -38,5 +38,5 @@ struct stage_param_ripple { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/stage_param/snow.cpp b/src/KKdLib/stage_param/snow.cpp index 3034df6d..57685954 100644 --- a/src/KKdLib/stage_param/snow.cpp +++ b/src/KKdLib/stage_param/snow.cpp @@ -92,19 +92,18 @@ void stage_param_snow::write(void** data, size_t* size) { s.copy(data, size); } -bool stage_param_snow::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool stage_param_snow::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); stage_param_snow* snow = (stage_param_snow*)data; - snow->read(s.c_str()); + snow->read(path.c_str()); return snow->ready; } diff --git a/src/KKdLib/stage_param/snow.hpp b/src/KKdLib/stage_param/snow.hpp index 0ee2efa6..9a233126 100644 --- a/src/KKdLib/stage_param/snow.hpp +++ b/src/KKdLib/stage_param/snow.hpp @@ -44,5 +44,5 @@ struct stage_param_snow { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/stage_param/splash.cpp b/src/KKdLib/stage_param/splash.cpp index bfd22aea..0d6bd046 100644 --- a/src/KKdLib/stage_param/splash.cpp +++ b/src/KKdLib/stage_param/splash.cpp @@ -88,19 +88,18 @@ void stage_param_splash::write(void** data, size_t* size) { s.copy(data, size); } -bool stage_param_splash::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool stage_param_splash::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); stage_param_splash* splash = (stage_param_splash*)data; - splash->read(s.c_str()); + splash->read(path.c_str()); return splash->ready; } diff --git a/src/KKdLib/stage_param/splash.hpp b/src/KKdLib/stage_param/splash.hpp index 6bf10227..ca401f6e 100644 --- a/src/KKdLib/stage_param/splash.hpp +++ b/src/KKdLib/stage_param/splash.hpp @@ -33,5 +33,5 @@ struct stage_param_splash { void write(const wchar_t* path); void write(void** data, size_t* size); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); }; diff --git a/src/KKdLib/stage_param/star.cpp b/src/KKdLib/stage_param/star.cpp index 864fd2ae..2ce572fa 100644 --- a/src/KKdLib/stage_param/star.cpp +++ b/src/KKdLib/stage_param/star.cpp @@ -170,19 +170,18 @@ void stage_param_star::get_mat(mat4& mat, const float_t observer_north_latitude, mat4_transpose(&temp, &mat); } -bool stage_param_star::load_file(void* data, const char* path, const char* file, uint32_t hash) { +bool stage_param_star::load_file(void* data, const char* dir, const char* file, uint32_t hash) { size_t file_len = utf8_length(file); const char* t = strrchr(file, '.'); if (t) file_len = t - file; - std::string s; - s.assign(path); - s.append(file, file_len); + std::string path(dir); + path.append(file, file_len); stage_param_star* star = (stage_param_star*)data; - star->read(s.c_str()); + star->read(path.c_str()); return star->ready; } diff --git a/src/KKdLib/stage_param/star.hpp b/src/KKdLib/stage_param/star.hpp index 12b4dd97..51fba49d 100644 --- a/src/KKdLib/stage_param/star.hpp +++ b/src/KKdLib/stage_param/star.hpp @@ -55,7 +55,7 @@ struct stage_param_star { static void get_mat(mat4& mat, const float_t observer_north_latitude, const float_t observer_east_longitude, const stage_param_star_utc& utc, const float_t rotation_y); - static bool load_file(void* data, const char* path, const char* file, uint32_t hash); + static bool load_file(void* data, const char* dir, const char* file, uint32_t hash); stage_param_star& operator=(const stage_param_star& star); }; diff --git a/src/ReDIVA/data_test/glitter_test.cpp b/src/ReDIVA/data_test/glitter_test.cpp index f75544dc..aea4b4b9 100644 --- a/src/ReDIVA/data_test/glitter_test.cpp +++ b/src/ReDIVA/data_test/glitter_test.cpp @@ -325,8 +325,7 @@ void DataTestGlitterParticleDw::Init() { chara->SetValue(false); list->ClearItems(); - std::vector files; - data_list[DATA_AFT].get_directory_files("rom/particle/", files); + std::vector files = data_list[DATA_AFT].get_directory_files("rom/particle/"); for (data_struct_file& i : files) { size_t pos = i.name.find(".farc"); if (pos == i.name.size() - 5) diff --git a/src/ReDIVA/pv_game/pv_game.cpp b/src/ReDIVA/pv_game/pv_game.cpp index 61c511f4..49a1c081 100644 --- a/src/ReDIVA/pv_game/pv_game.cpp +++ b/src/ReDIVA/pv_game/pv_game.cpp @@ -4337,7 +4337,7 @@ void pv_game::set_osage_init(const pv_game_chara& chr) { osage_init.rob_chr = chr.rob_chr; osage_init.pv_id = pv->id; osage_init.motion_id = motion_id; - osage_init.path.assign(pv->mdata.dir); + osage_init.dir.assign(pv->mdata.dir); osage_init.frame = i.frame; vec.push_back(osage_init); }