diff --git a/.gitignore b/.gitignore index 60784fe..ee95e39 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ bin *.lnk *.exe *.bat + +.sw diff --git a/src/common/buffer.cpp b/src/common/buffer.cpp index e4743f8..c1140fb 100644 --- a/src/common/buffer.cpp +++ b/src/common/buffer.cpp @@ -157,6 +157,7 @@ void buffer::reset() const { index_ = 0; data_offset = 0; + if (buf_) ptr = (uint8_t *)buf_->data(); } diff --git a/src/mmm_extractor/mmm_extractor.cpp b/src/mmm_extractor/mmm_extractor.cpp index d7064db..0af9081 100644 --- a/src/mmm_extractor/mmm_extractor.cpp +++ b/src/mmm_extractor/mmm_extractor.cpp @@ -46,7 +46,7 @@ struct mmm mmm read_mmm(const path &fn) { - buffer b(read_file(fn, true)); + buffer b(read_file(fn)); mmm m; m.load(b); diff --git a/src/mmp_extractor/mmp.cpp b/src/mmp_extractor/mmp.cpp index edcbdbe..fe65c2b 100644 --- a/src/mmp_extractor/mmp.cpp +++ b/src/mmp_extractor/mmp.cpp @@ -147,8 +147,8 @@ void mmp::process() textures[i.getTexture()]++; } textures.erase(0); - auto textures_per_color = std::max(1U, textures.size() / 3); - auto color_step = 200 / std::max(1U, textures.size()); + auto textures_per_color = std::max(1U, textures.size() / 3); + auto color_step = 200 / std::max(1U, textures.size()); for (size_t i = 0; i < textures.size(); i++) { int color_id = i / textures_per_color; diff --git a/src/unpaker/pak.cpp b/src/unpaker/pak.cpp index ca4dae2..a2769bb 100644 --- a/src/unpaker/pak.cpp +++ b/src/unpaker/pak.cpp @@ -105,12 +105,12 @@ void segment::load_segment() auto f = file; fseek(f, offset, SEEK_SET); - if (algorithm == 0) + /*if (algorithm == 0) { std::cerr << "Something is wrong. Maybe you trying to open aim2 files?\n"; std::cerr << "They can be opened with SDK extractor.\n"; throw std::runtime_error("error"); - } + }*/ FREAD(size1); size2 = size1; @@ -163,6 +163,8 @@ void segment::decompress(int segment_id) decode_rle((char*)encoded, size1, (char*)decoded); } } + if (algorithm == None) + decoded = encoded; } void pak::load(FILE *f) diff --git a/src/unpaker/pak.h b/src/unpaker/pak.h index 15d9217..db08a27 100644 --- a/src/unpaker/pak.h +++ b/src/unpaker/pak.h @@ -57,6 +57,7 @@ struct segment { enum decode_algorithm : uint32_t { + None = 0x0, RLE_2_bytes = 0x1, RLE_1_byte = 0x2, DA_1 = 0x4, diff --git a/src/unpaker/unpaker.cpp b/src/unpaker/unpaker.cpp index d1f48fa..7be1b05 100644 --- a/src/unpaker/unpaker.cpp +++ b/src/unpaker/unpaker.cpp @@ -36,10 +36,8 @@ void unpak(string fn) file.write(fn + ".dir", buf); }; - unpack(p.files["arena.mmp"]); - - //for (auto &[n,f] : p.files) - //unpack(f); + for (auto &[n,f] : p.files) + unpack(f); fclose(f); } diff --git a/sw.cpp b/sw.cpp new file mode 100644 index 0000000..d06c256 --- /dev/null +++ b/sw.cpp @@ -0,0 +1,71 @@ +#pragma sw require header org.sw.demo.lexxmark.winflexbison.bison-master + +void build(Solution &s) +{ + auto &tools = s.addProject("Polygon4.Tools", "master"); + + auto &common = tools.addStaticLibrary("common"); + common.CPPVersion = CPPLanguageStandard::CPP17; + common.setRootDirectory("src/common"); + common.Public += "pub.egorpugin.primitives.filesystem-master"_dep; + common.Public += "pub.egorpugin.primitives.sw.main-master"_dep; + + auto add_exe = [&tools](const String &name) -> decltype(auto) + { + auto &t = tools.addExecutable(name); + t.CPPVersion = CPPLanguageStandard::CPP17; + t.setRootDirectory("src/" + name); + return t; + }; + + auto add_exe_with_common = [&add_exe, &common](const String &name) -> decltype(auto) + { + auto &t = add_exe(name); + t.Public += common; + return t; + }; + + auto add_exe_with_data_manager = [&add_exe_with_common](const String &name) -> decltype(auto) + { + auto &t = add_exe_with_common(name); + t.Public += "pub.lzwdgc.Polygon4.DataManager-master"_dep; + return t; + }; + + add_exe_with_data_manager("db_add_language") += "pub.egorpugin.primitives.executor-master"_dep; + add_exe_with_data_manager("db_extractor"); + add_exe_with_data_manager("mmm_extractor"); + add_exe_with_data_manager("mmo_extractor"); + add_exe_with_common("mmp_extractor") += "org.sw.demo.intel.opencv.highgui-*"_dep; + add_exe_with_common("mpj_loader"); + add_exe_with_common("tm_converter"); + add_exe("name_generator"); + add_exe_with_common("save_loader"); + add_exe("unpaker"); + + // not so simple targets + auto &script2txt = tools.addStaticLibrary("script2txt"); + script2txt.CPPVersion = CPPLanguageStandard::CPP17; + script2txt.setRootDirectory("src/script2txt"); + script2txt += "pub.lzwdgc.Polygon4.DataManager.schema-master"_dep; + gen_flex_bison_pair(script2txt, "LALR1_CPP_VARIANT_PARSER", "script2txt"); + + auto &model = tools.addStaticLibrary("model"); + model.CPPVersion = CPPLanguageStandard::CPP17; + model.setRootDirectory("src/model"); + model.Public += common, "org.sw.demo.unicode.icu.i18n-*"_dep; + + add_exe("mod_reader") += model; + + auto &mod_converter = add_exe("mod_converter"); + mod_converter += model; + path sdk = "d:/arh/apps/Autodesk/FBX/FBX SDK/2019.0"; + mod_converter += IncludeDirectory(sdk / "include"); + String cfg = "release"; + if (s.Settings.Native.ConfigurationType == ConfigurationType::Debug) + cfg = "debug"; + String arch = "x64"; + if (s.Settings.TargetOS.Arch == ArchType::x86) + arch = "x86"; + mod_converter += LinkLibrary(sdk / ("lib/vs2015/" + arch + "/" + cfg + "/libfbxsdk-md.lib")); +}