Switch to cppan.

This commit is contained in:
lzwdgc 2018-07-31 01:28:23 +03:00
parent d3aa6a395f
commit dc81075ee1
34 changed files with 342 additions and 662 deletions

12
.gitignore vendored
View file

@ -1,3 +1,9 @@
win*
build
.cppan
win*
build
bin
.cppan
*.dll
*.lnk
*.exe
*.bat

0
.gitmodules vendored
View file

View file

@ -1,48 +0,0 @@
#
# A.I.M. Tools
#
cmake_minimum_required(VERSION 2.8)
set(output_dir ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${output_dir})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${output_dir})
# Use solution folders.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake Targets")
project(aim_tools)
find_package(BISON 3.0 REQUIRED)
find_package(FLEX 2.5.35 REQUIRED)
find_package(Git)
if (MSVC)
set(disable_msvc_warnings "/W1 /wd4996")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP ${disable_msvc_warnings}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP ${disable_msvc_warnings} /std:c++17")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++17")
endif(MSVC)
add_definitions(-DPOLYGON4_TOOLS=1)
add_definitions(-DPOLYGON4_STATIC=1)
set(CPPAN_BUILD_SHARED_LIBS 0)
add_subdirectory(.cppan)
if (Git_FOUND)
add_custom_target(version ALL
COMMAND git rev-list HEAD --count > ${CMAKE_CURRENT_BINARY_DIR}/version.h_
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/version.h_ ${CMAKE_CURRENT_BINARY_DIR}/version.h.in
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
set_target_properties(version PROPERTIES FOLDER Helpers)
else()
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/version.h.in "0")
endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_subdirectory(src)

172
cppan.yml
View file

@ -6,3 +6,175 @@ local_settings:
- pvt.egorpugin.primitives.executor: master
- pvt.cppan.demo.unicode.icu.i18n: "*"
- pvt.cppan.demo.taywee.args: "*"
#build_dir_type: local
use_shared_libs: false
rc_enabled: false
builds:
vs_release:
generator: Visual Studio 15 2017
vs_release64:
generator: Visual Studio 15 2017 Win64
vs_preview:
c_compiler: c:/Program Files (x86)/Microsoft Visual Studio/Preview/Community/VC/Tools/MSVC/14.11.25325/bin/HostX64/x86/cl.exe
cxx_compiler: c:/Program Files (x86)/Microsoft Visual Studio/Preview/Community/VC/Tools/MSVC/14.11.25325/bin/HostX64/x86/cl.exe
cxx_flags: /std:c++17
gcc8:
c_compiler: gcc-8
cxx_compiler: g++-8
#generator: Ninja
macos:
c_compiler: clang
cxx_compiler: clang++
vs_llvm:
toolset: LLVM-vs2014
win_clang_ninja:
generator: Ninja
c_compiler: clang-cl
cxx_compiler: clang-cl
use_cache: false
add_directories:
- d:/dev/primitives
- dir: d:/dev/ue4/AIM/DataManager
name: data_manager
common_settings:
c++: 17
projects:
common:
type: lib
static_only: true
root_dir: src/common
dependencies:
- name: pvt.egorpugin.primitives.filesystem
version: master
local: primitives.filesystem
- name: pvt.egorpugin.primitives.sw.main
version: master
local: primitives.sw.main
db_add_language:
root_dir: src/db_add_language
dependencies:
- common
- name: pvt.lzwdgc.polygon4.data_manager.data_manager
version: master
local: data_manager.data_manager
- name: pvt.egorpugin.primitives.executor
version: master
local: primitives.executor
db_extractor:
root_dir: src/db_extractor
dependencies:
- common
unpaker:
root_dir: src/unpaker
mmm_extractor:
root_dir: src/mmm_extractor
dependencies:
- common
- name: pvt.lzwdgc.polygon4.data_manager.data_manager
version: master
local: data_manager.data_manager
mmo_extractor:
root_dir: src/mmo_extractor
dependencies:
- common
- name: pvt.lzwdgc.polygon4.data_manager.data_manager
version: master
local: data_manager.data_manager
mmp_extractor:
root_dir: src/mmp_extractor
dependencies:
- common
model:
type: lib
static_only: true
root_dir: src/model
dependencies:
- common
- pvt.cppan.demo.unicode.icu.i18n: "*"
mod_converter:
root_dir: src/mod_converter
dependencies:
- model
post_sources: |
set(FBX_SDK_ROOT "d:/arh/apps/Autodesk/FBX/FBX SDK/2019.0/")
target_link_libraries(${this} PUBLIC
debug "${FBX_SDK_ROOT}/lib/vs2015/x86/debug/libfbxsdk-md.lib"
optimized "${FBX_SDK_ROOT}/lib/vs2015/x86/release/libfbxsdk-md.lib"
)
target_include_directories(${this} PUBLIC
"${FBX_SDK_ROOT}/include"
)
mod_reader:
root_dir: src/mod_reader
dependencies:
- model
mpj_loader:
root_dir: src/mpj_loader
dependencies:
- common
tm_converter:
root_dir: src/tm_converter
dependencies:
- common
name_generator:
root_dir: src/name_generator
save_loader:
root_dir: src/save_loader
dependencies:
- common
script2txt:
root_dir: src/script2txt
files: .*
dependencies:
- common
- name: pvt.lzwdgc.polygon4.data_manager.schema
version: master
local: data_manager.schema
- name: pvt.cppan.demo.lexxmark.winflexbison.flex
version: master
ref: flex
condition:
- WIN32
- name: pvt.cppan.demo.lexxmark.winflexbison.bison
version: master
ref: bison
condition:
- WIN32
post_target: |
cppan_flex_bison_pair(LALR1_CPP_VARIANT_PARSER script2txt)

View file

@ -1,92 +0,0 @@
file(GLOB common_src "common/*")
add_library(common ${common_src})
target_include_directories(common PUBLIC common)
target_link_libraries(common
pvt.egorpugin.primitives.filesystem
pvt.egorpugin.primitives.executor
)
add_dependencies(common version)
if (WIN32)
file(GLOB db_add_language_src "db_add_language/*")
add_executable(db_add_language ${db_add_language_src} db_extractor/db.cpp)
target_link_libraries(db_add_language
common
pvt.lzwdgc.polygon4.data_manager.data_manager
)
file(GLOB db_extractor_src "db_extractor/*")
add_executable(db_extractor ${db_extractor_src})
target_link_libraries(db_extractor common)
file(GLOB unpaker_src "unpaker/*")
add_executable(unpaker ${unpaker_src})
endif()
file(GLOB mmm_extractor_src "mmm_extractor/*")
add_executable(mmm_extractor ${mmm_extractor_src})
target_link_libraries(mmm_extractor
common
pvt.lzwdgc.polygon4.data_manager.data_manager
)
file(GLOB mmo_extractor_src "mmo_extractor/*")
add_executable(mmo_extractor ${mmo_extractor_src})
target_link_libraries(mmo_extractor
common
pvt.lzwdgc.polygon4.data_manager.data_manager
pvt.cppan.demo.taywee.args
)
file(GLOB mmp_extractor_src "mmp_extractor/*")
add_executable(mmp_extractor ${mmp_extractor_src})
target_link_libraries(mmp_extractor
common
)
file(GLOB model_src "model/*")
add_library(model ${model_src})
target_link_libraries(model
common
pvt.cppan.demo.unicode.icu.i18n
)
target_include_directories(model PUBLIC model)
if (DEFINED FBX_SDK_ROOT)
file(GLOB mod_converter_src "mod_converter/*")
add_executable(mod_converter ${mod_converter_src})
target_link_libraries(mod_converter
common
model
#pvt.cppan.demo.eigen
pvt.cppan.demo.taywee.args
debug "${FBX_SDK_ROOT}/lib/vs2015/x86/debug/libfbxsdk-md.lib"
optimized "${FBX_SDK_ROOT}/lib/vs2015/x86/release/libfbxsdk-md.lib"
)
target_include_directories(mod_converter
PUBLIC "${FBX_SDK_ROOT}/include"
)
else()
message(STATUS "provide fbx sdk path to build mod converter")
endif()
file(GLOB mod_reader_src "mod_reader/*")
add_executable(mod_reader ${mod_reader_src})
target_link_libraries(mod_reader model)
file(GLOB mpj_loader_src "mpj_loader/*")
add_executable(mpj_loader ${mpj_loader_src})
target_link_libraries(mpj_loader common)
file(GLOB tm_converter_src "tm_converter/*")
add_executable(tm_converter ${tm_converter_src})
target_link_libraries(tm_converter common)
file(GLOB name_generator_src "name_generator/*")
add_executable(name_generator ${name_generator_src})
file(GLOB save_loader_src "save_loader/*")
add_executable(save_loader ${save_loader_src})
target_link_libraries(save_loader common)
add_subdirectory(script2txt)

View file

@ -24,10 +24,11 @@
#include <Windows.h>
const int build_version =
#include <version.h.in>
const int build_version = 0
//#include <version.h.in>
;
// use as getVersionString() from settings?
std::string version()
{
using namespace std;

View file

@ -60,19 +60,19 @@ struct dxt5_block
a[1] = this->a[1];
if (a[0] > a[1])
{
a[2] = double(6 * a[0] + 1 * a[1]) / 7.0;
a[3] = double(5 * a[0] + 2 * a[1]) / 7.0;
a[4] = double(4 * a[0] + 3 * a[1]) / 7.0;
a[5] = double(3 * a[0] + 4 * a[1]) / 7.0;
a[6] = double(2 * a[0] + 5 * a[1]) / 7.0;
a[7] = double(1 * a[0] + 6 * a[1]) / 7.0;
a[2] = (uint8_t)(double(6 * a[0] + 1 * a[1]) / 7.0);
a[3] = (uint8_t)(double(5 * a[0] + 2 * a[1]) / 7.0);
a[4] = (uint8_t)(double(4 * a[0] + 3 * a[1]) / 7.0);
a[5] = (uint8_t)(double(3 * a[0] + 4 * a[1]) / 7.0);
a[6] = (uint8_t)(double(2 * a[0] + 5 * a[1]) / 7.0);
a[7] = (uint8_t)(double(1 * a[0] + 6 * a[1]) / 7.0);
}
else
{
a[2] = double(4 * a[0] + 1 * a[1]) / 5.0;
a[3] = double(3 * a[0] + 2 * a[1]) / 5.0;
a[4] = double(2 * a[0] + 3 * a[1]) / 5.0;
a[5] = double(1 * a[0] + 4 * a[1]) / 5.0;
a[2] = (uint8_t)(double(4 * a[0] + 1 * a[1]) / 5.0);
a[3] = (uint8_t)(double(3 * a[0] + 2 * a[1]) / 5.0);
a[4] = (uint8_t)(double(2 * a[0] + 3 * a[1]) / 5.0);
a[5] = (uint8_t)(double(1 * a[0] + 4 * a[1]) / 5.0);
a[6] = 0;
a[7] = 255;
}
@ -103,7 +103,7 @@ struct dxt5_block
{
color r;
for (int i = 0; i < 4; i++)
r.byte[i] = c0.byte[i] * m + c1.byte[i] * (1 - m);
r.byte[i] = uint8_t(c0.byte[i] * m + c1.byte[i] * (1 - m));
return r;
}
};
@ -134,7 +134,7 @@ struct dxt5
mat<uint32_t> m(width, height);
auto big_xsegs = width / 64;
auto big_ysegs = height / 64;
for (int seg = 0; seg < blocks.size(); seg++)
for (size_t seg = 0; seg < blocks.size(); seg++)
{
auto &d = blocks[seg];
int big_seg = seg / 256;
@ -151,7 +151,7 @@ struct dxt5
{
mat<uint32_t> m(width, height);
auto xsegs = width / 4;
for (int seg = 0; seg < blocks.size(); seg++)
for (size_t seg = 0; seg < blocks.size(); seg++)
{
auto &d = blocks[seg];
auto xseg = seg % xsegs;

View file

@ -86,7 +86,7 @@ void Objects::load(const buffer &b)
uint32_t n_segments = 0;
READ(b, n_segments);
for (int s = 0; s < n_segments; s++)
for (uint32_t s = 0; s < n_segments; s++)
{
auto seg = Segment::create_segment(b);
if (!seg)

View file

@ -80,7 +80,7 @@ struct SegmentObjects : public Segment
virtual void load(const buffer &b)
{
for (int i = 0; i < n_objects; i++)
for (uint32_t i = 0; i < n_objects; i++)
{
T* o = new T;
o->load(b);
@ -126,7 +126,7 @@ struct MapObjectWithArray : public MapObject
READ(b, len);
unk0.resize(len);
for (int i = 0; i < len; i++)
for (uint32_t i = 0; i < len; i++)
READ(b, unk0[i]);
}
};

View file

@ -6,8 +6,8 @@
#pragma pack(push, 1)
// http://paulbourke.net/dataformats/tga/
struct tga
// http://paulbourke.net/dataformats/tga/
struct tga
{
uint8_t idlength; // label length
uint8_t colourmaptype = 0;
@ -20,33 +20,33 @@ struct tga
uint16_t width;
uint16_t height;
uint8_t bitsperpixel = 32;
uint8_t imagedescriptor = 0x28;
tga()
{
idlength = strlen(label());
}
constexpr const char *label() const
{
return "AIMTMConverter";
}
void write(buffer &b)
{
b.write(idlength);
b.write(colourmaptype);
b.write(datatypecode);
b.write(colourmaporigin);
b.write(colourmaplength);
b.write(colourmapdepth);
b.write(x_origin);
b.write(y_origin);
b.write(width);
b.write(height);
b.write(bitsperpixel);
b.write(imagedescriptor);
b.write(label(), idlength);
}
};
#pragma pack(pop)
uint8_t imagedescriptor = 0x28;
tga()
{
idlength = (uint8_t)strlen(label());
}
constexpr const char *label() const
{
return "AIMTMConverter";
}
void write(buffer &b)
{
b.write(idlength);
b.write(colourmaptype);
b.write(datatypecode);
b.write(colourmaporigin);
b.write(colourmaplength);
b.write(colourmapdepth);
b.write(x_origin);
b.write(y_origin);
b.write(width);
b.write(height);
b.write(bitsperpixel);
b.write(imagedescriptor);
b.write(label(), idlength);
}
};
#pragma pack(pop)

View file

@ -193,7 +193,7 @@ struct BuildingGoods
READ_STRING(b, name);
READ(b, n);
for (int i = 0; i < n; i++)
for (uint32_t i = 0; i < n; i++)
{
Good g;
g.load(b);
@ -217,7 +217,7 @@ struct MapMusic
auto read_values = [&b](auto &v, auto &n)
{
for (int i = 0; i < n; i++)
for (uint32_t i = 0; i < n; i++)
v.push_back(b.read_string());
};
@ -240,7 +240,7 @@ struct OrganizationConfig
{
READ(b, n_configs);
configs.resize(n_configs, std::string(0x20, 0));
for (int i = 0; i < n_configs; i++)
for (uint32_t i = 0; i < n_configs; i++)
READ_N(b, configs[i][0], 0x20);
}
};
@ -272,7 +272,7 @@ struct Organizations
READ(b, len);
uint32_t n = 0;
READ(b, n);
for (int i = 0; i < n; i++)
for (uint32_t i = 0; i < n; i++)
{
Organization s;
s.load(b);
@ -303,7 +303,7 @@ struct OrganizationBases
{
uint32_t n = 0;
READ(b, n);
for (int i = 0; i < n; i++)
for (uint32_t i = 0; i < n; i++)
{
OrganizationBase s;
s.load(b);

View file

@ -16,15 +16,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../db_extractor/db.h"
#include <common.h>
#include <db.h>
#include <Polygon4/DataManager/Localization.h>
#include <Polygon4/DataManager/Storage.h>
#include <Polygon4/DataManager/Types.h>
#include <primitives/filesystem.h>
#include <primitives/executor.h>
#include <primitives/sw/main.h>
#include <algorithm>
#include <fstream>
@ -284,7 +284,6 @@ void process_lang(polygon4::Storage &s, const path &p, polygon4::String polygon4
}
int main(int argc, char *argv[])
try
{
if (argc != 3)
{
@ -321,13 +320,3 @@ try
return 0;
}
catch (std::exception &e)
{
printf("error: %s\n", e.what());
return 1;
}
catch (...)
{
printf("error: unknown exception\n");
return 1;
}

View file

@ -18,11 +18,13 @@
#include "db.h"
#include <fstream>
#include <buffer.h>
#include <common.h>
#include <primitives/sw/main.h>
#include <fstream>
void create_sql(std::string path, const db &db)
{
std::ofstream ofile(path + ".sql");
@ -122,7 +124,6 @@ void create_sql(std::string path, const db &db)
}
int main(int argc, char *argv[])
try
{
if (argc != 2)
{
@ -135,13 +136,3 @@ try
create_sql(p.string(), db);
return 0;
}
catch (std::exception &e)
{
printf("error: %s\n", e.what());
return 1;
}
catch (...)
{
printf("error: unknown exception\n");
return 1;
}

View file

@ -25,6 +25,7 @@
#include <dxt5.h>
#include <primitives/filesystem.h>
#include <primitives/sw/main.h>
using namespace std;
@ -64,7 +65,6 @@ void process_mmm(const path &fn)
}
int main(int argc, char *argv[])
try
{
if (argc != 2)
{
@ -78,7 +78,7 @@ try
{
auto files = enumerate_files_like(p, ".*\\.mmm", false);
for (auto &f : files)
{
{
std::cout << "processing: " << f << "\n";
process_mmm(f);
}
@ -87,13 +87,3 @@ try
throw std::runtime_error("Bad fs object");
return 0;
}
catch (std::exception &e)
{
printf("error: %s\n", e.what());
return 1;
}
catch (...)
{
printf("error: unknown exception\n");
return 1;
}

View file

@ -33,7 +33,8 @@
#include <Polygon4/DataManager/Storage.h>
#include <Polygon4/DataManager/Types.h>
#include <primitives/filesystem.h>
#include <args.hxx>
#include <primitives/sw/main.h>
#include <primitives/sw/settings.h>
#include <buffer.h>
#include <types.h>
@ -229,7 +230,7 @@ void write_mmo(Storage *storage, const mmo_storage &s)
// protect against nans
object->m_rotate_z[2].z = ASSIGN(object->m_rotate_z[2].z, 1);
detail::MapObject mb;
polygon4::detail::MapObject mb;
mb.text_id = object->name2;
mb.map = this_map;
mb.object = storage->objects[bld_ids[object->name1]];
@ -268,19 +269,15 @@ void write_mmo(Storage *storage, const mmo_storage &s)
}
int main(int argc, char *argv[])
try
{
args::ArgumentParser parser("mmo extractor");
args::HelpFlag help(parser, "help", "Display this help menu", { 'h', "help" });
args::Flag m2(parser, "m2", "m2 .mmo file", { "m2" });
args::Flag print_mechanoids(parser, "print_mechanoids", "Print mechanoids", { "print_mechanoids" });
args::ValueFlag<std::string> db_path(parser, "db_path", "Database file", {'d', "db"});
args::Positional<std::string> file_path(parser, "file or directory", ".mmo file or directory with .mmo files");
parser.Prog(argv[0]);
cl::opt<bool> m2("m2", cl::desc("m2 .mmo file"));
cl::opt<bool> print_mechanoids("print_mechanoids", cl::desc("print mechanoids"));
cl::opt<path> db_path("db", cl::desc("database file"));
cl::alias db_pathA("d", cl::aliasopt(db_path));
cl::opt<path> p(cl::Positional, cl::desc(".mmo file or directory with .mmo files"), cl::value_desc("file or directory"), cl::Required);
parser.ParseCLI(argc, argv);
cl::ParseCommandLineOptions(argc, argv);
const path p = file_path.Get();
gameType = m2 ? GameType::Aim2 : GameType::Aim1;
/*{
@ -320,7 +317,7 @@ try
}
else
{
auto storage = initStorage(db_path.Get());
auto storage = initStorage(db_path.u8string());
storage->load();
action([&storage](const path &, const auto &m) {write_mmo(storage.get(), m); });
if (inserted_all)
@ -329,13 +326,3 @@ try
return 0;
}
catch (std::exception &e)
{
printf("error: %s\n", e.what());
return 1;
}
catch (...)
{
printf("error: unknown exception\n");
return 1;
}

View file

@ -76,7 +76,7 @@ struct MechGroup
uint32_t len = 0;
READ(b, len);
t.resize(len);
for (int i = 0; i < len; i++)
for (uint32_t i = 0; i < len; i++)
READ(b, t[i]);
type_data = t;
}
@ -93,7 +93,7 @@ struct MechGroup
assert(false);
}
for (int i = 0; i < number_of_mechanoids; i++)
for (uint32_t i = 0; i < number_of_mechanoids; i++)
{
std::string t;
READ_STRING_N(b, t, 0x20);
@ -119,7 +119,7 @@ struct MechGroups
READ(b, n);
READ(b, unk0);
for (int s = 0; s < n; s++)
for (uint32_t s = 0; s < n; s++)
{
MechGroup mg;
mg.load(b);
@ -145,7 +145,7 @@ struct MapGoods
uint32_t n = 0;
READ(b, n);
for (int i = 0; i < n; i++)
for (uint32_t i = 0; i < n; i++)
{
BuildingGoods bg;
bg.load(b);

View file

@ -146,7 +146,7 @@ void mmp::process()
textures.erase(0);
auto textures_per_color = std::max(1U, textures.size() / 3);
auto color_step = 200 / std::max(1U, textures.size());
for (int i = 0; i < textures.size(); i++)
for (size_t i = 0; i < textures.size(); i++)
{
int color_id = i / textures_per_color;
color c = { 0 };
@ -185,14 +185,14 @@ void mmp::process()
const auto &data = s.d;
int y1 = s.desc.min.y / 10;
int y2 = s.desc.max.y / 10;
if (y2 > h.length)
if (y2 > (int)h.length)
y2 = h.length;
for (int y = 0; y1 < y2; y1++, y++)
{
int x1 = s.desc.min.x / 10;
int x2 = s.desc.max.x / 10;
auto dx = x2 - x1;
if (x2 > h.width)
if (x2 >(int)h.width)
x2 = h.width;
for (int x = 0; x1 < x2; x1++, x++)
{
@ -232,14 +232,14 @@ void mmp::process()
{
int y1 = s.desc.min.y / 10;
int y2 = s.desc.max.y / 10;
if (y2 > h.length)
if (y2 > (int)h.length)
y2 = h.length;
for (int y = 0; y1 < y2; y1++, y++)
{
int x1 = s.desc.min.x / 10;
int x2 = s.desc.max.x / 10;
auto dx = x2 - x1;
if (x2 > h.width)
if (x2 > (int)h.width)
x2 = h.width;
for (int x = 0; x1 < x2; x1++, x++)
{
@ -319,7 +319,16 @@ void mmp::writeTextureAlphaMaps()
{
for (auto &t : alpha_maps)
{
auto fn = filename + ".texmap." + std::to_string(t.first) + ".bmp";
int tex_id = 0;
for (auto &[tid, tex] : textures_map)
{
if (tex.g == t.first)
{
tex_id = tid;
break;
}
}
auto fn = filename + ".texmap." + std::to_string(t.first) + "." + std::to_string(tex_id) + ".bmp";
write_mat_bmp(fn, t.second);
}
}

View file

@ -19,6 +19,7 @@
#include "mmp.h"
#include <primitives/filesystem.h>
#include <primitives/sw/main.h>
#include <iostream>
#include <set>
@ -29,7 +30,6 @@
using namespace std;
int main(int argc, char *argv[])
try
{
if (argc < 2 || argc > 3)
{
@ -45,7 +45,7 @@ try
m.load(p.string());
m.process();
m.writeFileInfo();
//m.writeTexturesList();
m.writeTexturesList();
m.writeHeightMap();
//m.writeHeightMapSegmented();
m.writeTextureMap();
@ -73,13 +73,3 @@ try
return 0;
}
catch (std::exception &e)
{
printf("error: %s\n", e.what());
return 1;
}
catch (...)
{
printf("error: unknown exception\n");
return 1;
}

View file

@ -51,7 +51,7 @@ void DestroySdkObjects(FbxManager* pManager, bool pExitStatus)
bool SaveScene(FbxManager* pManager, FbxDocument* pScene, const char* pFilename, bool blender = false)
{
int lMajor, lMinor, lRevision;
//int lMajor, lMinor, lRevision;
bool lStatus = true;
// Create an exporter.

View file

@ -21,7 +21,8 @@
#include "model.h"
#include <primitives/filesystem.h>
#include <args.hxx>
#include <primitives/sw/main.h>
#include <primitives/sw/settings.h>
#include <algorithm>
#include <fstream>
@ -36,9 +37,7 @@ using namespace std;
// options
bool silent = false;
bool printMaxPolygonBlock = false;
path p;
bool parse_cmd(int argc, char *argv[]);
cl::opt<path> p(cl::Positional, cl::desc("MOD_ file or directory with MOD_ files"), cl::value_desc("file or directory"), cl::Required);
void convert_model(const path &fn)
{
@ -60,23 +59,17 @@ void convert_model(const path &fn)
}
int main(int argc, char *argv[])
try
{
args::ArgumentParser parser("mmo extractor");
args::HelpFlag help(parser, "help", "Display this help menu", { 'h', "help" });
args::Flag af(parser, "a", "All formats", { 'a' });
args::Flag mr(parser, "mr", "AIM Racing MOD file", { "mr" });
args::Positional<std::string> file_path(parser, "file or directory", "MOD_ file or directory with MOD_ files");
parser.Prog(argv[0]);
cl::opt<bool> af("a", cl::desc("All formats"));
cl::opt<bool> mr("mr", cl::desc("AIM Racing MOD file"));
parser.ParseCLI(argc, argv);
cl::ParseCommandLineOptions(argc, argv);
if (mr)
gameType = GameType::AimR;
if (af)
all_formats = true;
p = file_path.Get();
if (fs::is_regular_file(p))
convert_model(p);
else if (fs::is_directory(p))
@ -101,61 +94,3 @@ try
throw std::runtime_error("Bad fs object");
return 0;
}
/*catch (std::runtime_error &e)
{
if (silent)
return 1;
string error;
error += p.string();
error += "\n";
error += "fatal error: ";
error += e.what();
error += "\n";
ofstream ofile(p.string() + ".error.txt");
ofile << error;
return 1;
}*/
catch (std::exception &e)
{
if (silent)
return 1;
printf("%s\n", p.string().c_str());
printf("error: %s\n", e.what());
return 1;
}
catch (...)
{
if (silent)
return 1;
printf("%s\n", p.string().c_str());
printf("error: unknown exception\n");
return 1;
}
bool parse_cmd(int argc, char *argv[])
{
for (int i = 1; i < argc; i++)
{
auto arg = argv[i];
if (*arg != '-')
{
if (i != argc - 1)
return false;
p = arg;
continue;
}
switch (arg[1])
{
case 'a':
all_formats = true;
break;
case 's':
silent = true;
break;
case 'm':
printMaxPolygonBlock = true;
break;
}
}
return true;
}

View file

@ -16,6 +16,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <buffer.h>
#include <model.h>
#include <primitives/filesystem.h>
#include <primitives/sw/main.h>
#include <algorithm>
#include <fstream>
#include <iostream>
@ -24,11 +30,6 @@
#include <stdint.h>
#include <string>
#include <buffer.h>
#include <model.h>
#include <primitives/filesystem.h>
using namespace std;
// options
@ -54,7 +55,6 @@ void convert_model(const path &fn)
}
int main(int argc, char *argv[])
try
{
if (argc < 2 || !parse_cmd(argc, argv))
{
@ -67,9 +67,9 @@ try
{
auto files = enumerate_files(p, false);
for (auto &f : files)
{
if (f.has_extension())
continue;
{
if (f.has_extension())
continue;
std::cout << "processing: " << f << "\n";
convert_model(f);
}
@ -78,36 +78,6 @@ try
throw std::runtime_error("Bad fs object");
return 0;
}
catch (std::runtime_error &e)
{
if (silent)
return 1;
string error;
error += p.string();
error += "\n";
error += "fatal error: ";
error += e.what();
error += "\n";
ofstream ofile(p.string() + ".error.txt");
ofile << error;
return 1;
}
catch (std::exception &e)
{
if (silent)
return 1;
printf("%s\n", p.string().c_str());
printf("error: %s\n", e.what());
return 1;
}
catch (...)
{
if (silent)
return 1;
printf("%s\n", p.string().c_str());
printf("error: unknown exception\n");
return 1;
}
bool parse_cmd(int argc, char *argv[])
{

View file

@ -16,18 +16,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "mpj.h"
#include <primitives/sw/main.h>
#include <iostream>
#include <set>
#include <stdint.h>
#include <string>
#include <sstream>
#include "mpj.h"
using namespace std;
int main(int argc, char *argv[])
try
{
if (argc != 2)
{
@ -38,13 +39,3 @@ try
m.load(argv[1]);
return 0;
}
catch (std::exception &e)
{
printf("error: %s\n", e.what());
return 1;
}
catch (...)
{
printf("error: unknown exception\n");
return 1;
}

View file

@ -23,6 +23,8 @@
#include <objects.h>
#include <types.h>
#include <iostream>
// possible save operations
struct changes

View file

@ -16,14 +16,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "save.h"
#include <primitives/filesystem.h>
#include <primitives/sw/main.h>
#include <iostream>
#include <string>
#include "save.h"
#include <primitives/filesystem.h>
int main(int argc, char *argv[])
try
{
if (argc != 2)
{
@ -53,7 +54,7 @@ try
{
auto files = enumerate_files_like(p, ".*\\.sav", false);
for (auto &f : files)
{
{
std::cout << "processing: " << f << "\n";
func(f);
}
@ -63,15 +64,3 @@ try
return 0;
}
catch (std::exception &e)
{
printf("%s\n", argv[1]);
printf("error: %s\n", e.what());
return 1;
}
catch (...)
{
printf("%s\n", argv[1]);
printf("error: unknown exception\n");
return 1;
}

View file

@ -1,48 +0,0 @@
#
# Polygon-4 Data generator
#
set(BSRC ${CMAKE_CURRENT_BINARY_DIR})
set(_CPP ".*\\.cpp")
set(CPP "${_CPP}$")
set(_H "(.*\\.h|.*\\.hpp)")
set(H "${_H}$")
set(H_CPP "(${H}|${CPP})")
source_group("Generated" "${BSRC}/${H_CPP}")
BISON_TARGET(grammar
"${CMAKE_CURRENT_SOURCE_DIR}/grammar.yy"
"${CMAKE_CURRENT_BINARY_DIR}/grammar.cpp"
)
FLEX_TARGET(lexer
"${CMAKE_CURRENT_SOURCE_DIR}/lexer.ll"
"${CMAKE_CURRENT_BINARY_DIR}/lexer.cpp"
COMPILE_FLAGS --header-file=${CMAKE_CURRENT_BINARY_DIR}/lexer.h
)
ADD_FLEX_BISON_DEPENDENCY(lexer grammar)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set(parser_src
${BISON_grammar_OUTPUTS}
${FLEX_lexer_OUTPUTS}
${CMAKE_CURRENT_BINARY_DIR}/lexer.h
)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/lexer.h PROPERTIES GENERATED TRUE)
file(GLOB script2txt_src "*.cpp" "*.h")
set(script2txt_src ${script2txt_src}
grammar.yy
lexer.ll
${parser_src}
${SCHEMA_FILE}
)
add_executable (script2txt ${script2txt_src} ${script2txt_inc})
target_link_libraries (script2txt common pvt.lzwdgc.polygon4.data_manager.schema)

View file

@ -1,62 +0,0 @@
/*
* Polygon-4 script2txt
* Copyright (C) 2015-2016 lzwdgc
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ParserDriver.h"
#include <algorithm>
#include <fstream>
// Prevent using <unistd.h> because of bug in flex.
#define YY_NO_UNISTD_H 1
#define YY_DECL 1
#include <lexer.h>
extern yy::parser::symbol_type yylex(yyscan_t yyscanner, yy::location &loc);
ParserDriver::ParserDriver()
{
debug = false;
}
yy::parser::symbol_type ParserDriver::lex()
{
return yylex(scanner, location);
}
int ParserDriver::parse(const std::string &s)
{
yylex_init(&scanner);
yy_scan_string(s.c_str(), scanner);
yy::parser parser(*this);
parser.set_debug_level(debug);
int res = parser.parse();
yylex_destroy(scanner);
return res;
}
void ParserDriver::error(const yy::location &l, const std::string &m)
{
std::cerr << l << " " << m << std::endl;
}
void ParserDriver::error(const std::string& m)
{
std::cerr << m << std::endl;
}

View file

@ -1,54 +0,0 @@
/*
* Polygon-4 script2txt
* Copyright (C) 2015-2016 lzwdgc
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <set>
#include <string>
#include <vector>
#include <grammar.hpp>
class ParserDriver
{
public:
ParserDriver();
yy::parser::symbol_type lex();
int parse(const std::string &s);
void error(const yy::location &l, const std::string &m);
void error(const std::string &m);
void setContext(Context &&ctx) { context = std::move(ctx); }
const Context &getContext() const { return context; }
// lex & parse
private:
void *scanner;
yy::location location;
bool debug;
// data
private:
Context context;
// other
public:
std::set<std::string> functions;
};

View file

@ -18,11 +18,11 @@
#pragma once
#include <sstream>
#include <buffer.h>
#include <common.h>
#include <sstream>
template <typename T>
inline bool replace_all(T &str, const T &from, const T &to)
{

View file

@ -16,19 +16,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "script.h"
#include <script2txt_parser.h>
#include <primitives/filesystem.h>
#include <primitives/sw/main.h>
#include <fstream>
#include <iostream>
#include <stdint.h>
#include "ParserDriver.h"
#include "script.h"
#include <primitives/filesystem.h>
using std::cout;
using std::string;
int main(int argc, char *argv[])
try
{
if (argc != 2)
{
@ -44,7 +46,7 @@ try
s.load(b);
auto str = s.get_text();
ParserDriver driver;
Script2txtParserDriver driver;
if (driver.parse(str))
{
throw std::runtime_error("error during parsing input file");
@ -83,7 +85,7 @@ try
auto files2 = enumerate_files_like(p, ".*\\.QST", false);
files.insert(files2.begin(), files2.end());
for (auto &f : files)
{
{
std::cout << "processing: " << f << "\n";
func(f.string());
}
@ -93,13 +95,3 @@ try
return 0;
}
catch (std::exception &e)
{
printf("error: %s\n", e.what());
return 1;
}
catch (...)
{
printf("error: unknown exception\n");
return 1;
}

View file

@ -17,20 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma warning(disable: 4005)
#include <string>
#include "grammar.hpp"
#define YY_USER_ACTION loc.columns(yyleng);
#define PUSH_STATE(x) BEGIN(x)
#define POP_STATE() BEGIN(0)
#define YY_DECL yy::parser::symbol_type yylex(yyscan_t yyscanner, yy::location &loc)
#define MAKE(x) yy::parser::make_ ## x(loc)
#define MAKE_VALUE(x, v) yy::parser::make_ ## x((v), loc)
#include <script2txt_parser.h>
%}
%option nounistd
@ -41,17 +28,14 @@
%option reentrant
%option noyywrap
DIGIT [0-9]
DIGITS {DIGIT}{DIGIT}*
INTEGER {DIGITS}[Ff]?
STRING [[:alpha:]_-][[:alnum:]_-]*
%x user_string
%%
%{

View file

@ -17,45 +17,48 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <iostream>
#include <string>
#include "ParserDriver.h"
#define yylex(p) p.lex()
#include <script2txt_parser.h>
%}
////////////////////////////////////////
// general settings
%require "3.0"
%debug
//%debug
%start file
%locations
%verbose
%no-lines
//%no-lines
%error-verbose
////////////////////////////////////////
// c++ skeleton and options
%skeleton "lalr1.cc"
%define api.value.type variant
%define api.token.constructor // C++ style of handling variants
%define parse.assert // check C++ variant types
%code provides { #include <primitives/helper/bison_yy.h> }
%parse-param { MY_PARSER_DRIVER &driver } // param to yy::parser() constructor (the parsing context)
%code requires // forward decl of C++ driver (our parser) in HPP
{
#include <Polygon4/DataManager/Schema/Context.h>
class ParserDriver;
}
// param to yy::parser() constructor
// the parsing context
%param { ParserDriver &driver }
#include <set>
}
%code provides
{
struct MY_PARSER_DRIVER : MY_PARSER
{
void setContext(Context &&ctx) { context = std::move(ctx); }
const Context &getContext() const { return context; }
Context context;
std::set<std::string> functions;
};
}
////////////////////////////////////////
@ -327,8 +330,3 @@ integer: INTEGER
;
%%
void yy::parser::error(const location_type& l, const std::string& m)
{
driver.error(l, m);
}

View file

@ -16,6 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bmp.h>
#include <buffer.h>
#include <dxt5.h>
#include <primitives/filesystem.h>
#include <primitives/sw/main.h>
#include <algorithm>
#include <fstream>
#include <iostream>
@ -24,12 +31,6 @@
#include <stdint.h>
#include <string>
#include <bmp.h>
#include <buffer.h>
#include <dxt5.h>
#include <primitives/filesystem.h>
using namespace std;
void convert_simple(buffer &dst, const buffer &src, int width, int height)
@ -80,7 +81,6 @@ void convert(const path &fn)
}
int main(int argc, char *argv[])
try
{
if (argc != 2)
{
@ -103,15 +103,3 @@ try
throw std::runtime_error("Bad fs object");
return 0;
}
catch (std::exception &e)
{
printf("%s\n", argv[1]);
printf("error: %s\n", e.what());
return 1;
}
catch (...)
{
printf("%s\n", argv[1]);
printf("error: unknown exception\n");
return 1;
}