mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-14 17:33:25 +00:00
Remove py and bat scripts.
This commit is contained in:
parent
2dfc88e925
commit
986fd859d7
29 changed files with 268 additions and 332 deletions
|
|
@ -2,45 +2,45 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
using BYTE = uint8_t;
|
||||
using WORD = uint16_t;
|
||||
using DWORD = uint32_t;
|
||||
using LONG = uint32_t;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
typedef struct tagBITMAPFILEHEADER {
|
||||
WORD bfType;
|
||||
DWORD bfSize;
|
||||
WORD bfReserved1;
|
||||
WORD bfReserved2;
|
||||
DWORD bfOffBits;
|
||||
} BITMAPFILEHEADER;
|
||||
struct bmp_header
|
||||
{
|
||||
int16_t bfType;
|
||||
int32_t bfSize;
|
||||
int16_t bfReserved1;
|
||||
int16_t bfReserved2;
|
||||
int32_t bfOffBits;
|
||||
};
|
||||
|
||||
typedef struct tagBITMAPINFOHEADER {
|
||||
DWORD biSize;
|
||||
LONG biWidth;
|
||||
LONG biHeight;
|
||||
WORD biPlanes;
|
||||
WORD biBitCount;
|
||||
DWORD biCompression;
|
||||
DWORD biSizeImage;
|
||||
LONG biXPelsPerMeter;
|
||||
LONG biYPelsPerMeter;
|
||||
DWORD biClrUsed;
|
||||
DWORD biClrImportant;
|
||||
} BITMAPINFOHEADER;
|
||||
struct bmp_info_header
|
||||
{
|
||||
int32_t biSize;
|
||||
int32_t biWidth;
|
||||
int32_t biHeight;
|
||||
int16_t biPlanes;
|
||||
int16_t biBitCount;
|
||||
int32_t biCompression;
|
||||
int32_t biSizeImage;
|
||||
int32_t biXPelsPerMeter;
|
||||
int32_t biYPelsPerMeter;
|
||||
int32_t biClrUsed;
|
||||
int32_t biClrImportant;
|
||||
};
|
||||
|
||||
typedef struct tagRGBQUAD {
|
||||
BYTE rgbBlue;
|
||||
BYTE rgbGreen;
|
||||
BYTE rgbRed;
|
||||
BYTE rgbReserved;
|
||||
} RGBQUAD;
|
||||
struct rgb_quad
|
||||
{
|
||||
int8_t rgbBlue;
|
||||
int8_t rgbGreen;
|
||||
int8_t rgbRed;
|
||||
int8_t rgbReserved;
|
||||
};
|
||||
|
||||
typedef struct tagBITMAPINFO {
|
||||
BITMAPINFOHEADER bmiHeader;
|
||||
RGBQUAD bmiColors[1];
|
||||
} BITMAPINFO;
|
||||
struct bmp_info
|
||||
{
|
||||
|
||||
bmp_info_header bmiHeader;
|
||||
rgb_quad bmiColors[1];
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
|
|
|||
|
|
@ -73,6 +73,14 @@ buffer::buffer(size_t size)
|
|||
skip(0);
|
||||
}
|
||||
|
||||
buffer::buffer(const std::string &s)
|
||||
: buf_(new std::vector<uint8_t>(&s[0], &s[s.size()]))
|
||||
{
|
||||
skip(0);
|
||||
size_ = buf_->size();
|
||||
end_ = index_ + size_;
|
||||
}
|
||||
|
||||
buffer::buffer(const std::vector<uint8_t> &buf, uint32_t data_offset)
|
||||
: buf_(new std::vector<uint8_t>(buf)), data_offset(data_offset)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@
|
|||
#define WRITE(b, var) b.write(&var)
|
||||
|
||||
std::string version();
|
||||
std::vector<uint8_t> readFile(const std::string &fn);
|
||||
void writeFile(const std::string &fn, const std::vector<uint8_t> &data);
|
||||
|
||||
class buffer
|
||||
|
|
@ -45,6 +44,7 @@ class buffer
|
|||
public:
|
||||
buffer();
|
||||
buffer(size_t size);
|
||||
buffer(const std::string &s);
|
||||
buffer(const std::vector<uint8_t> &buf, uint32_t data_offset = 0);
|
||||
buffer(const buffer &rhs, uint32_t size);
|
||||
buffer(const buffer &rhs, uint32_t size, uint32_t offset);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <primitives/filesystem.h>
|
||||
|
||||
template <typename T>
|
||||
bool replace_all(T &str, const T &from, const T &to)
|
||||
|
|
|
|||
|
|
@ -118,11 +118,11 @@ inline void write_mat_bmp(const std::string &filename, int width, int height, in
|
|||
FILE *f = fopen(filename.c_str(), "wb");
|
||||
if (f == nullptr)
|
||||
return;
|
||||
BITMAPFILEHEADER h = { 0 };
|
||||
bmp_header h = { 0 };
|
||||
h.bfType = 0x4D42;
|
||||
h.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + s;
|
||||
h.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
|
||||
BITMAPINFOHEADER i = { 0 };
|
||||
h.bfSize = sizeof(bmp_header) + sizeof(bmp_info_header) + s;
|
||||
h.bfOffBits = sizeof(bmp_header) + sizeof(bmp_info_header);
|
||||
bmp_info_header i = { 0 };
|
||||
i.biSize = sizeof(i);
|
||||
i.biWidth = width;
|
||||
i.biHeight = height;
|
||||
|
|
@ -134,8 +134,8 @@ inline void write_mat_bmp(const std::string &filename, int width, int height, in
|
|||
i.biYPelsPerMeter = 0;
|
||||
i.biClrUsed = 0;
|
||||
i.biClrImportant = 0;
|
||||
fwrite(&h, sizeof(BITMAPFILEHEADER), 1, f);
|
||||
fwrite(&i, sizeof(BITMAPINFOHEADER), 1, f);
|
||||
fwrite(&h, sizeof(bmp_header), 1, f);
|
||||
fwrite(&i, sizeof(bmp_info_header), 1, f);
|
||||
fwrite(b, s, 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,14 +21,14 @@
|
|||
#include <fstream>
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
#include <buffer.h>
|
||||
#include <primitives/filesystem.h>
|
||||
|
||||
void open_db(string path, db &db)
|
||||
{
|
||||
db.t.load(buffer(readFile(path + ".tab")));
|
||||
db.load(buffer(readFile(path + ".ind")));
|
||||
buffer b(readFile(path + ".dat"));
|
||||
db.t.load(buffer(read_file(path + ".tab")));
|
||||
db.load(buffer(read_file(path + ".ind")));
|
||||
buffer b(read_file(path + ".dat"));
|
||||
for (auto &v : db.values)
|
||||
v.load_fields(db.t, b);
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ void create_sql(string path, const db &db)
|
|||
ofstream ofile(path + ".sql");
|
||||
if (!ofile)
|
||||
return;
|
||||
|
||||
|
||||
string master_table_name = "DB_TABLE_LIST";
|
||||
const string id = "ID";
|
||||
const string row_type = "TEXT_ID";
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
python mmm_extractor.py --dir h:\Games\AIM\data\minimaps.pak.dir
|
||||
python mmm_extractor.py --dir h:\Games\Steam\steamapps\common\AIM2\Data\DATA\LOCS
|
||||
|
|
@ -44,7 +44,7 @@ struct mmm
|
|||
|
||||
mmm read_mmm(const path &fn)
|
||||
{
|
||||
buffer b(readFile(fn));
|
||||
buffer b(read_file(fn, true));
|
||||
mmm m;
|
||||
m.load(b);
|
||||
|
||||
|
|
@ -59,8 +59,8 @@ mmm read_mmm(const path &fn)
|
|||
|
||||
void process_mmm(const path &fn)
|
||||
{
|
||||
auto m = read_mmm(argv[1]);
|
||||
write_mat_bmp(std::string(argv[1]) + ".bmp", m.data.unpack_mmm());
|
||||
auto m = read_mmm(fn);
|
||||
write_mat_bmp(fn.string() + ".bmp", m.data.unpack_mmm());
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
|
@ -71,13 +71,17 @@ try
|
|||
cout << "Usage:\n" << argv[0] << " {file.mmm,dir}" << "\n";
|
||||
return 1;
|
||||
}
|
||||
auto p = argv[1];
|
||||
path p = argv[1];
|
||||
if (fs::is_regular_file(p))
|
||||
process_mmm(p);
|
||||
else if (fs::is_directory(p))
|
||||
{
|
||||
auto f = enumerate_files(p, false);
|
||||
|
||||
auto files = enumerate_files_like(p, ".*\\.mmm", false);
|
||||
for (auto &f : files)
|
||||
{
|
||||
std::cout << "processing: " << f << "\n";
|
||||
process_mmm(f);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw std::runtime_error("Bad fs object");
|
||||
|
|
@ -92,4 +96,4 @@ catch (...)
|
|||
{
|
||||
printf("error: unknown exception\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Batch models converter')
|
||||
parser.add_argument('--dir', dest='dir', help='path to directory with maps')
|
||||
pargs = parser.parse_args()
|
||||
|
||||
if pargs.dir:
|
||||
run(pargs.dir)
|
||||
|
||||
def run(dir):
|
||||
for file in sorted(os.listdir(dir)):
|
||||
if os.path.isdir(file) or os.path.splitext(file)[1].lower() != ".mmm":
|
||||
continue
|
||||
print('loading: ' + file)
|
||||
p = subprocess.Popen(['mmm_extractor.exe', dir + '/' + file])
|
||||
p.communicate()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
python mmo_extractor.py --db "h:\Games\Epic Games\Projects\Polygon4\Mods\db.sqlite" --dir "h:\Games\AIM\data\maps.pak.dir" --prefix m1
|
||||
python mmo_extractor.py --db "h:\Games\Epic Games\Projects\Polygon4\Mods\db.sqlite" --dir "h:\Games\Steam\steamapps\common\AIM2\Data\mmo.pak\DATA\LOCS" --prefix m2
|
||||
|
|
@ -32,18 +32,23 @@
|
|||
|
||||
#include <Polygon4/DataManager/Storage.h>
|
||||
#include <Polygon4/DataManager/Types.h>
|
||||
#include <primitives/filesystem.h>
|
||||
|
||||
#include <buffer.h>
|
||||
#include <types.h>
|
||||
|
||||
using namespace polygon4;
|
||||
using namespace polygon4::detail;
|
||||
|
||||
#define RAD2GRAD(x) (x) = (x) / M_PI * 180.0
|
||||
#define ASSIGN(x, d) isnan(x) ? d : x
|
||||
|
||||
std::string prefix;
|
||||
int inserted_all = 0;
|
||||
|
||||
struct storage
|
||||
struct mmo_storage
|
||||
{
|
||||
std::string name;
|
||||
path name;
|
||||
Objects objects;
|
||||
MechGroups mechGroups;
|
||||
MapGoods mapGoods;
|
||||
|
|
@ -81,32 +86,18 @@ struct storage
|
|||
}
|
||||
};
|
||||
|
||||
storage read_mmo(std::string fn)
|
||||
mmo_storage read_mmo(const path &fn)
|
||||
{
|
||||
buffer f(readFile(fn));
|
||||
storage s;
|
||||
buffer f(read_file(fn));
|
||||
mmo_storage s;
|
||||
s.name = fn;
|
||||
s.load(f);
|
||||
return s;
|
||||
}
|
||||
|
||||
void write_mmo(std::string db, const storage &s)
|
||||
void write_mmo(Storage *storage, const mmo_storage &s)
|
||||
{
|
||||
using namespace polygon4;
|
||||
using namespace polygon4::detail;
|
||||
|
||||
auto storage = initStorage(db);
|
||||
storage->load();
|
||||
|
||||
auto p1 = s.name.rfind('\\');
|
||||
if (p1 == -1)
|
||||
p1 = 0;
|
||||
auto p2 = s.name.rfind('/');
|
||||
if (p2 == -1)
|
||||
p2 = 0;
|
||||
int p = std::max(p1, p2);
|
||||
std::string map_name = s.name.substr(p + 1);
|
||||
map_name = map_name.substr(0, map_name.find('.'));
|
||||
std::string map_name = s.name.filename().stem().string();
|
||||
if (!prefix.empty())
|
||||
map_name = prefix + "." + map_name;
|
||||
std::transform(map_name.begin(), map_name.end(), map_name.begin(), ::tolower);
|
||||
|
|
@ -256,8 +247,7 @@ void write_mmo(std::string db, const storage &s)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (inserted)
|
||||
storage->save();
|
||||
inserted_all += inserted;
|
||||
std::cout << "inserted: " << inserted << ", exist: " << exist << "\n";
|
||||
}
|
||||
|
||||
|
|
@ -266,7 +256,7 @@ try
|
|||
{
|
||||
if (argc != 4)
|
||||
{
|
||||
std::cout << "Usage:\n" << argv[0] << " db.sqlite file.mmo prefix" << "\n";
|
||||
std::cout << "Usage:\n" << argv[0] << " db.sqlite {file.mmo,mmo_dir} prefix" << "\n";
|
||||
return 1;
|
||||
}
|
||||
prefix = argv[3];
|
||||
|
|
@ -276,8 +266,28 @@ try
|
|||
gameType = GameType::Aim2;
|
||||
else
|
||||
throw std::runtime_error("unknown prefix (game type)");
|
||||
storage s = read_mmo(argv[2]);
|
||||
write_mmo(argv[1], s);
|
||||
|
||||
auto storage = initStorage(argv[1]);
|
||||
storage->load();
|
||||
|
||||
path p = argv[2];
|
||||
if (fs::is_regular_file(p))
|
||||
write_mmo(storage.get(), read_mmo(p));
|
||||
else if (fs::is_directory(p))
|
||||
{
|
||||
auto files = enumerate_files_like(p, ".*\\.mmo", false);
|
||||
for (auto &f : files)
|
||||
{
|
||||
std::cout << "processing: " << f << "\n";
|
||||
write_mmo(storage.get(), read_mmo(f));
|
||||
}
|
||||
}
|
||||
else
|
||||
throw std::runtime_error("Bad fs object");
|
||||
|
||||
if (inserted_all)
|
||||
storage->save();
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (std::exception &e)
|
||||
|
|
@ -289,4 +299,4 @@ catch (...)
|
|||
{
|
||||
printf("error: unknown exception\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Batch models converter')
|
||||
parser.add_argument('--dir', dest='dir', help='path to directory with maps')
|
||||
parser.add_argument('--db', dest='db', help='path to db')
|
||||
parser.add_argument('--prefix', dest='prefix', help='prefix')
|
||||
pargs = parser.parse_args()
|
||||
|
||||
if not pargs.prefix:
|
||||
pargs.prefix = ''
|
||||
|
||||
if pargs.dir:
|
||||
run(pargs.dir, pargs.db, pargs.prefix)
|
||||
|
||||
def run(dir, db, prefix):
|
||||
for file in sorted(os.listdir(dir)):
|
||||
if os.path.isdir(file) or os.path.splitext(file)[1].lower() != ".mmo":
|
||||
continue
|
||||
print('loading: ' + file)
|
||||
p = subprocess.Popen(['mmo_extractor.exe', db, dir + '/' + file, prefix])
|
||||
p.communicate()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -22,6 +22,8 @@
|
|||
#include <fstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <primitives/filesystem.h>
|
||||
|
||||
void water_segment::load(const buffer &b)
|
||||
{
|
||||
wg.load(b);
|
||||
|
|
@ -112,7 +114,7 @@ void mmp::load(const buffer &b)
|
|||
void mmp::load(const std::string &fn)
|
||||
{
|
||||
filename = fn;
|
||||
buffer b(readFile(filename));
|
||||
buffer b(read_file(filename));
|
||||
load(b);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
python mmp_extractor.py --dir "h:\Games\AIM\data\maps.pak.dir" --tex mmp_tex_aim1.txt
|
||||
python mmp_extractor.py --dir "h:\Games\Steam\steamapps\common\AIM2\Data\mmp.pak\DATA\LOCS" --tex mmp_tex_aim2.txt
|
||||
python mmp_extractor.py --dir "h:\Games\Steam\steamapps\common\AIM2\Projects" --tex mmp_tex_aim2.txt
|
||||
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include "mmp.h"
|
||||
|
||||
#include <primitives/filesystem.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
|
@ -31,21 +33,41 @@ try
|
|||
{
|
||||
if (argc < 2 || argc > 3)
|
||||
{
|
||||
cout << "Usage:\n" << argv[0] << " file.mmp [texture_ids.txt]" << "\n";
|
||||
cout << "Usage:\n" << argv[0] << " {file.mmp,mmp_dir} [texture_ids.txt]" << "\n";
|
||||
return 1;
|
||||
}
|
||||
mmp m;
|
||||
if (argc > 2)
|
||||
m.loadTextureNames(argv[2]);
|
||||
m.load(argv[1]);
|
||||
m.process();
|
||||
m.writeFileInfo();
|
||||
m.writeTexturesList();
|
||||
m.writeHeightMap();
|
||||
m.writeTextureMap();
|
||||
m.writeTextureAlphaMaps();
|
||||
m.writeTextureMapColored();
|
||||
m.writeColorMap();
|
||||
|
||||
auto func = [&argc, &argv](auto &p)
|
||||
{
|
||||
mmp m;
|
||||
if (argc > 2)
|
||||
m.loadTextureNames(argv[2]);
|
||||
m.load(p.string());
|
||||
m.process();
|
||||
m.writeFileInfo();
|
||||
m.writeTexturesList();
|
||||
m.writeHeightMap();
|
||||
m.writeTextureMap();
|
||||
m.writeTextureAlphaMaps();
|
||||
m.writeTextureMapColored();
|
||||
m.writeColorMap();
|
||||
};
|
||||
|
||||
path p = argv[1];
|
||||
if (fs::is_regular_file(p))
|
||||
func(p);
|
||||
else if (fs::is_directory(p))
|
||||
{
|
||||
auto files = enumerate_files_like(p, ".*\\.mmp", false);
|
||||
for (auto &f : files)
|
||||
{
|
||||
std::cout << "processing: " << f << "\n";
|
||||
func(f);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw std::runtime_error("Bad fs object");
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (std::exception &e)
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Batch MMP extractor')
|
||||
parser.add_argument('--dir', dest='dir', help='path to directory with maps')
|
||||
parser.add_argument('--tex', dest='tex', help='path to textures ids')
|
||||
pargs = parser.parse_args()
|
||||
|
||||
if pargs.dir:
|
||||
run(pargs.dir, pargs.tex)
|
||||
|
||||
def run(dir, tex):
|
||||
for file in sorted(os.listdir(dir)):
|
||||
if os.path.isdir(file) or os.path.splitext(file)[1].lower() != ".mmp":
|
||||
continue
|
||||
print('processing: ' + file)
|
||||
p = subprocess.Popen(['mmp_extractor.exe', dir + '/' + file, tex])
|
||||
p.communicate()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
|
||||
print(sorted(set(open(sys.argv[1]).readlines())))
|
||||
|
|
@ -1 +0,0 @@
|
|||
python mod_converter.py --dir "h:\\Games\\Epic Games\\Projects\\AIM\\models1\\"
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
|
@ -26,19 +27,21 @@
|
|||
#include <buffer.h>
|
||||
#include "model.h"
|
||||
|
||||
#include <primitives/filesystem.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
// options
|
||||
bool all_formats = false;
|
||||
bool silent = false;
|
||||
bool printMaxPolygonBlock = false;
|
||||
string filename;
|
||||
path p;
|
||||
|
||||
bool parse_cmd(int argc, char *argv[]);
|
||||
|
||||
void convert_model(string fn)
|
||||
void convert_model(const path &fn)
|
||||
{
|
||||
buffer b(readFile(fn));
|
||||
buffer b(read_file(fn));
|
||||
model m;
|
||||
m.load(b);
|
||||
|
||||
|
|
@ -51,8 +54,8 @@ void convert_model(string fn)
|
|||
|
||||
// write all
|
||||
if (all_formats)
|
||||
m.print(filename);
|
||||
m.printFbx(filename);
|
||||
m.print(fn.string());
|
||||
m.printFbx(fn.string());
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
|
@ -60,10 +63,24 @@ try
|
|||
{
|
||||
if (argc < 2 || !parse_cmd(argc, argv))
|
||||
{
|
||||
printf("Usage: %s [OPTIONS] model_file\n", argv[0]);
|
||||
printf("Usage: %s [OPTIONS] {model_file,model_dir}\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
convert_model(filename);
|
||||
if (fs::is_regular_file(p))
|
||||
convert_model(p);
|
||||
else if (fs::is_directory(p))
|
||||
{
|
||||
auto files = enumerate_files(p, false);
|
||||
for (auto &f : files)
|
||||
{
|
||||
if (f.has_extension())
|
||||
continue;
|
||||
std::cout << "processing: " << f << "\n";
|
||||
convert_model(f);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw std::runtime_error("Bad fs object");
|
||||
return 0;
|
||||
}
|
||||
catch (std::runtime_error &e)
|
||||
|
|
@ -71,12 +88,12 @@ catch (std::runtime_error &e)
|
|||
if (silent)
|
||||
return 1;
|
||||
string error;
|
||||
error += filename;
|
||||
error += p.string();
|
||||
error += "\n";
|
||||
error += "fatal error: ";
|
||||
error += e.what();
|
||||
error += "\n";
|
||||
ofstream ofile(filename + ".error.txt");
|
||||
ofstream ofile(p.string() + ".error.txt");
|
||||
ofile << error;
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -84,7 +101,7 @@ catch (std::exception &e)
|
|||
{
|
||||
if (silent)
|
||||
return 1;
|
||||
printf("%s\n", filename.c_str());
|
||||
printf("%s\n", p.string().c_str());
|
||||
printf("error: %s\n", e.what());
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -92,7 +109,7 @@ catch (...)
|
|||
{
|
||||
if (silent)
|
||||
return 1;
|
||||
printf("%s\n", filename.c_str());
|
||||
printf("%s\n", p.string().c_str());
|
||||
printf("error: unknown exception\n");
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -106,7 +123,7 @@ bool parse_cmd(int argc, char *argv[])
|
|||
{
|
||||
if (i != argc - 1)
|
||||
return false;
|
||||
filename = arg;
|
||||
p = arg;
|
||||
continue;
|
||||
}
|
||||
switch (arg[1])
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
banned_ext = [
|
||||
'.obj',
|
||||
'.mtl',
|
||||
'.txt',
|
||||
'.tm',
|
||||
'.TM',
|
||||
'.tga',
|
||||
]
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Batch models converter')
|
||||
parser.add_argument('--dir', dest='dir', help='path to directory with models')
|
||||
pargs = parser.parse_args()
|
||||
|
||||
if pargs.dir:
|
||||
run(pargs.dir)
|
||||
|
||||
def run(dir):
|
||||
for file in sorted(os.listdir(dir)):
|
||||
if os.path.isdir(file) or os.path.splitext(file)[1] in banned_ext:
|
||||
continue
|
||||
p = subprocess.Popen(['mod_converter.exe', '-m', dir + '/' + file])
|
||||
p.communicate()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -23,6 +23,8 @@
|
|||
#include <fstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <primitives/filesystem.h>
|
||||
|
||||
segment *segment::create_segment(const buffer &b)
|
||||
{
|
||||
SegmentType type;
|
||||
|
|
@ -220,6 +222,6 @@ void mpj::load(const buffer &b)
|
|||
void mpj::load(const std::string &fn)
|
||||
{
|
||||
filename = fn;
|
||||
buffer b(readFile(filename));
|
||||
buffer b(read_file(filename));
|
||||
load(b);
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
python save_loader.py --dir "h:\\Games\\Steam\\steamapps\\common\\AIM2\\SAVES\\"
|
||||
|
|
@ -20,13 +20,14 @@
|
|||
#include <string>
|
||||
|
||||
#include "save.h"
|
||||
#include <primitives/filesystem.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
try
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
printf("Usage: %s file.sav\n", argv[0]);
|
||||
printf("Usage: %s {file.sav,saves_dir}\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -34,13 +35,31 @@ try
|
|||
save_changes.money = 999999999.0f;
|
||||
save_changes.upgrade_equ_for_player = true;
|
||||
|
||||
buffer f(readFile(argv[1]));
|
||||
save_changes.out = buffer(f.buf());
|
||||
auto func = [](auto &p)
|
||||
{
|
||||
buffer f(read_file(p));
|
||||
save_changes.out = buffer(f.buf());
|
||||
|
||||
save s;
|
||||
s.load(f);
|
||||
save s;
|
||||
s.load(f);
|
||||
|
||||
writeFile(argv[1], save_changes.out.buf());
|
||||
writeFile(p.string(), save_changes.out.buf());
|
||||
};
|
||||
|
||||
path p = argv[1];
|
||||
if (fs::is_regular_file(p))
|
||||
func(p);
|
||||
else if (fs::is_directory(p))
|
||||
{
|
||||
auto files = enumerate_files_like(p, ".*\\.sav", false);
|
||||
for (auto &f : files)
|
||||
{
|
||||
std::cout << "processing: " << f << "\n";
|
||||
func(f);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw std::runtime_error("Bad fs object");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Batch models converter')
|
||||
parser.add_argument('--dir', dest='dir', help='path to directory with models')
|
||||
pargs = parser.parse_args()
|
||||
|
||||
if pargs.dir:
|
||||
run(pargs.dir)
|
||||
|
||||
def run(dir):
|
||||
for root, subdirs, files in os.walk(dir):
|
||||
for file in files:
|
||||
p = subprocess.Popen(['save_loader.exe', os.path.join(root, file)])
|
||||
p.communicate()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
@for /r %%v in (*.scr) do @script2txt.exe "%%v"
|
||||
@for /r %%v in (*.QST) do @script2txt.exe "%%v"
|
||||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "ParserDriver.h"
|
||||
#include "script.h"
|
||||
#include <primitives/filesystem.h>
|
||||
|
||||
using std::cout;
|
||||
using std::string;
|
||||
|
|
@ -31,46 +32,64 @@ try
|
|||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
cout << "Usage:\n" << argv[0] << " script.scr";
|
||||
cout << "Usage:\n" << argv[0] << " {script.scr,scr_dir}";
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string filename = argv[1];
|
||||
|
||||
// read
|
||||
buffer b(readFile(filename));
|
||||
script s;
|
||||
s.load(b);
|
||||
auto str = s.get_text();
|
||||
|
||||
ParserDriver driver;
|
||||
if (driver.parse(str))
|
||||
auto func = [](auto filename)
|
||||
{
|
||||
throw std::runtime_error("error during parsing input file");
|
||||
}
|
||||
auto &ctx = driver.getContext();
|
||||
// read
|
||||
buffer b(read_file(filename));
|
||||
script s;
|
||||
s.load(b);
|
||||
auto str = s.get_text();
|
||||
|
||||
// write script
|
||||
{
|
||||
filename += ".txt";
|
||||
std::ofstream ofile(filename);
|
||||
if (ofile)
|
||||
ofile << ctx.getText();
|
||||
}
|
||||
|
||||
// write function calls
|
||||
{
|
||||
std::ofstream functions("functions.txt", std::ios::app);
|
||||
if (functions)
|
||||
ParserDriver driver;
|
||||
if (driver.parse(str))
|
||||
{
|
||||
for (auto &f : driver.functions)
|
||||
throw std::runtime_error("error during parsing input file");
|
||||
}
|
||||
auto &ctx = driver.getContext();
|
||||
|
||||
// write script
|
||||
{
|
||||
filename += ".txt";
|
||||
std::ofstream ofile(filename);
|
||||
if (ofile)
|
||||
ofile << ctx.getText();
|
||||
}
|
||||
|
||||
// write function calls
|
||||
{
|
||||
std::ofstream functions("functions.txt", std::ios::app);
|
||||
if (functions)
|
||||
{
|
||||
std::string f2(f.size(), 0);
|
||||
std::transform(f.begin(), f.end(), f2.begin(), tolower);
|
||||
functions << f2 << "\n";
|
||||
for (auto &f : driver.functions)
|
||||
{
|
||||
std::string f2(f.size(), 0);
|
||||
std::transform(f.begin(), f.end(), f2.begin(), tolower);
|
||||
functions << f2 << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
path p = argv[1];
|
||||
if (fs::is_regular_file(p))
|
||||
func(p.string());
|
||||
else if (fs::is_directory(p))
|
||||
{
|
||||
auto files = enumerate_files_like(p, ".*\\.scr", false);
|
||||
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());
|
||||
}
|
||||
}
|
||||
else
|
||||
throw std::runtime_error("Bad fs object");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
python tm_converter.py --dir "h:\\Games\\AIM\\data\\res1.pak.dir\\Data\\TM\\"
|
||||
python tm_converter.py --dir "h:\\Games\\Steam\\steamapps\\common\\AIM2\\Data\\tex.pak\\DATA\\TM\\"
|
||||
|
|
@ -28,6 +28,8 @@
|
|||
#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)
|
||||
|
|
@ -44,19 +46,19 @@ void convert_simple(buffer &dst, const buffer &src, int width, int height)
|
|||
}
|
||||
}
|
||||
|
||||
void convert(string fn)
|
||||
void convert(const path &fn)
|
||||
{
|
||||
int width, height;
|
||||
int dxt5_flag = 0;
|
||||
|
||||
buffer src(readFile(fn));
|
||||
buffer src(read_file(fn));
|
||||
READ(src, width);
|
||||
READ(src, height);
|
||||
src.seek(0x10);
|
||||
src.read(&dxt5_flag, 1);
|
||||
src.seek(0x4C);
|
||||
|
||||
fn = fn + ".bmp";
|
||||
auto s = fn.string() + ".bmp";
|
||||
mat<uint32_t> m(width, height);
|
||||
if (dxt5_flag)
|
||||
{
|
||||
|
|
@ -65,7 +67,6 @@ void convert(string fn)
|
|||
d.height = height;
|
||||
d.load_blocks(src);
|
||||
m = d.unpack_tm();
|
||||
write_mat_bmp(fn, m);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -75,7 +76,7 @@ void convert(string fn)
|
|||
memcpy(&m(0,0), dst2.getPtr(), dst2.size());
|
||||
m = m.flip(); // flip tga (normal rows order) to bmp (inverse rows order)
|
||||
}
|
||||
write_mat_bmp(fn, m);
|
||||
write_mat_bmp(s, m);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
|
@ -86,7 +87,20 @@ try
|
|||
printf("Usage: %s file.tm\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
convert(argv[1]);
|
||||
path p = argv[1];
|
||||
if (fs::is_regular_file(p))
|
||||
convert(p);
|
||||
else if (fs::is_directory(p))
|
||||
{
|
||||
auto files = enumerate_files_like(p, ".*\\.TM", false);
|
||||
for (auto &f : files)
|
||||
{
|
||||
std::cout << "processing: " << f << "\n";
|
||||
convert(f);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw std::runtime_error("Bad fs object");
|
||||
return 0;
|
||||
}
|
||||
catch (std::exception &e)
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Batch textures converter')
|
||||
parser.add_argument('--dir', dest='dir', help='path to directory with textures')
|
||||
pargs = parser.parse_args()
|
||||
|
||||
if pargs.dir:
|
||||
run(pargs.dir)
|
||||
|
||||
def run(dir):
|
||||
for file in sorted(os.listdir(dir)):
|
||||
if os.path.isdir(file) or os.path.splitext(file)[1].lower() != ".tm":
|
||||
continue
|
||||
print('processing: ' + file)
|
||||
p = subprocess.Popen(['tm_converter.exe', dir + '/' + file])
|
||||
p.communicate()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Loading…
Reference in a new issue