mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-14 17:33:25 +00:00
Overhaul with modern command lines.
This commit is contained in:
parent
dc81075ee1
commit
f900353090
15 changed files with 167 additions and 192 deletions
|
|
@ -71,9 +71,6 @@ projects:
|
|||
dependencies:
|
||||
- common
|
||||
|
||||
unpaker:
|
||||
root_dir: src/unpaker
|
||||
|
||||
mmm_extractor:
|
||||
root_dir: src/mmm_extractor
|
||||
dependencies:
|
||||
|
|
@ -161,6 +158,9 @@ projects:
|
|||
post_target: |
|
||||
cppan_flex_bison_pair(LALR1_CPP_VARIANT_PARSER script2txt)
|
||||
|
||||
unpaker:
|
||||
root_dir: src/unpaker
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
128
src/common/mat.h
128
src/common/mat.h
|
|
@ -18,13 +18,15 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <bmp.h>
|
||||
#include <tga.h>
|
||||
|
||||
#include <primitives/filesystem.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
|
||||
#include <bmp.h>
|
||||
#include <tga.h>
|
||||
|
||||
template <class T>
|
||||
class mat
|
||||
{
|
||||
|
|
@ -69,13 +71,13 @@ public:
|
|||
int getBytesLength() const { return size() * sizeof(T); }
|
||||
int getPos(const T *const elem) const { return elem - &data[0]; }
|
||||
const std::vector<T> &getData() const { return data; }
|
||||
std::vector<T> &getData() { return data; }
|
||||
|
||||
// left/right
|
||||
mat mirror()
|
||||
std::vector<T> &getData() { return data; }
|
||||
|
||||
// left/right
|
||||
mat mirror()
|
||||
{
|
||||
int cols = width;
|
||||
int rows = height;
|
||||
int rows = height;
|
||||
mat<uint32_t> m(width, height);
|
||||
for (int row = 0; row < rows; row++)
|
||||
{
|
||||
|
|
@ -87,13 +89,13 @@ public:
|
|||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
// up/down
|
||||
mat flip()
|
||||
}
|
||||
|
||||
// up/down
|
||||
mat flip()
|
||||
{
|
||||
int cols = width;
|
||||
int rows = height;
|
||||
int rows = height;
|
||||
mat<uint32_t> m(width, height);
|
||||
for (int row = 0; row < rows; row++)
|
||||
{
|
||||
|
|
@ -111,57 +113,57 @@ private:
|
|||
std::vector<T> data;
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
inline void write_mat_bmp(const std::string &filename, int width, int height, int bits, const uint8_t *b, size_t s)
|
||||
};
|
||||
|
||||
inline void write_mat_bmp(const path &filename, int width, int height, int bits, const uint8_t *b, size_t s)
|
||||
{
|
||||
FILE *f = fopen(filename.c_str(), "wb");
|
||||
if (f == nullptr)
|
||||
return;
|
||||
bmp_header h = { 0 };
|
||||
h.bfType = 0x4D42;
|
||||
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;
|
||||
i.biPlanes = 1;
|
||||
i.biBitCount = bits;
|
||||
i.biCompression = 0;
|
||||
i.biSizeImage = 0;
|
||||
i.biXPelsPerMeter = 0;
|
||||
i.biYPelsPerMeter = 0;
|
||||
i.biClrUsed = 0;
|
||||
i.biClrImportant = 0;
|
||||
fwrite(&h, sizeof(bmp_header), 1, f);
|
||||
fwrite(&i, sizeof(bmp_info_header), 1, f);
|
||||
fwrite(b, s, 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void write_mat_bmp(const std::string &filename, const mat<T> &m)
|
||||
auto f = primitives::filesystem::fopen(filename, "wb");
|
||||
if (f == nullptr)
|
||||
return;
|
||||
bmp_header h = { 0 };
|
||||
h.bfType = 0x4D42;
|
||||
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;
|
||||
i.biPlanes = 1;
|
||||
i.biBitCount = bits;
|
||||
i.biCompression = 0;
|
||||
i.biSizeImage = 0;
|
||||
i.biXPelsPerMeter = 0;
|
||||
i.biYPelsPerMeter = 0;
|
||||
i.biClrUsed = 0;
|
||||
i.biClrImportant = 0;
|
||||
fwrite(&h, sizeof(bmp_header), 1, f);
|
||||
fwrite(&i, sizeof(bmp_info_header), 1, f);
|
||||
fwrite(b, s, 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void write_mat_bmp(const path &filename, const mat<T> &m)
|
||||
{
|
||||
write_mat_bmp(filename, m.getWidth(), m.getHeight(), sizeof(T) * CHAR_BIT, (const uint8_t *)&m(0, 0), m.size() * sizeof(T));
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void write_mat_tga(const path &filename, const mat<T> &m)
|
||||
{
|
||||
write_mat_bmp(filename, m.getWidth(), m.getHeight(), sizeof(T) * CHAR_BIT, (const uint8_t *)&m(0, 0), m.size() * sizeof(T));
|
||||
}
|
||||
auto f = primitives::filesystem::fopen(filename, "wb");
|
||||
if (f == nullptr)
|
||||
return;
|
||||
|
||||
template<class T>
|
||||
inline void write_mat_tga(const std::string &filename, const mat<T> &m)
|
||||
{
|
||||
FILE *f = fopen(filename.c_str(), "wb");
|
||||
if (f == nullptr)
|
||||
return;
|
||||
|
||||
tga t;
|
||||
t.width = m.getWidth();
|
||||
t.height = m.getHeight();
|
||||
|
||||
// header
|
||||
fwrite(&t, sizeof(tga), 1, f);
|
||||
tga t;
|
||||
t.width = m.getWidth();
|
||||
t.height = m.getHeight();
|
||||
|
||||
// header
|
||||
fwrite(&t, sizeof(tga), 1, f);
|
||||
fwrite(t.label(), t.idlength, 1, f);
|
||||
|
||||
// data
|
||||
fwrite(&m(0, 0), m.size() * sizeof(T), 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
// data
|
||||
fwrite(&m(0, 0), m.size() * sizeof(T), 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include <primitives/filesystem.h>
|
||||
#include <primitives/executor.h>
|
||||
#include <primitives/sw/main.h>
|
||||
#include <primitives/sw/settings.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
|
|
@ -285,21 +286,19 @@ void process_lang(polygon4::Storage &s, const path &p, polygon4::String polygon4
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 3)
|
||||
{
|
||||
std::cout << "Usage: prog db.sqlite dir_to_lang_dbs" << "\n";
|
||||
return 1;
|
||||
}
|
||||
path d = argv[2];
|
||||
cl::opt<path> db_fn(cl::Positional, cl::desc("<db file>"), cl::Required);
|
||||
cl::opt<path> dir_to_lang_dbs(cl::Positional, cl::desc("<dir to lang dbs>"), cl::Required);
|
||||
|
||||
auto storage = polygon4::initStorage(argv[1]);
|
||||
cl::ParseCommandLineOptions(argc, argv);
|
||||
|
||||
auto storage = polygon4::initStorage(db_fn);
|
||||
storage->load();
|
||||
kv_resolved = get_kv_resolved(d, *storage.get());
|
||||
kv_resolved = get_kv_resolved(dir_to_lang_dbs, *storage.get());
|
||||
|
||||
// to check correctness
|
||||
process_lang(*storage.get(), d / "ru", &polygon4::LocalizedString::ru);
|
||||
process_lang(*storage.get(), dir_to_lang_dbs / "ru", &polygon4::LocalizedString::ru);
|
||||
|
||||
for (auto &f : fs::directory_iterator(d))
|
||||
for (auto &f : fs::directory_iterator(dir_to_lang_dbs))
|
||||
{
|
||||
if (!fs::is_directory(f))
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -22,12 +22,13 @@
|
|||
#include <common.h>
|
||||
|
||||
#include <primitives/sw/main.h>
|
||||
#include <primitives/sw/settings.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
void create_sql(std::string path, const db &db)
|
||||
void create_sql(path p, const db &db)
|
||||
{
|
||||
std::ofstream ofile(path + ".sql");
|
||||
std::ofstream ofile(p += ".sql");
|
||||
if (!ofile)
|
||||
return;
|
||||
|
||||
|
|
@ -125,14 +126,12 @@ void create_sql(std::string path, const db &db)
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
std::cout << "Usage:\n" << argv[0] << " path/to/aim_game/data/db" << "\n" << argv[0] << " path/to/aim_game/data/quest" << "\n";
|
||||
return 1;
|
||||
}
|
||||
path p = argv[1];
|
||||
cl::opt<path> db_fn(cl::Positional, cl::desc("<db file>"), cl::Required);
|
||||
|
||||
cl::ParseCommandLineOptions(argc, argv);
|
||||
|
||||
db db;
|
||||
db.open(p);
|
||||
create_sql(p.string(), db);
|
||||
db.open(db_fn);
|
||||
create_sql(db_fn, db);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <primitives/filesystem.h>
|
||||
#include <primitives/sw/main.h>
|
||||
#include <primitives/sw/settings.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
@ -66,12 +67,10 @@ void process_mmm(const path &fn)
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
cout << "Usage:\n" << argv[0] << " {file.mmm,dir}" << "\n";
|
||||
return 1;
|
||||
}
|
||||
path p = argv[1];
|
||||
cl::opt<path> p(cl::Positional, cl::desc("<file.mmm or directory>"), cl::Required);
|
||||
|
||||
cl::ParseCommandLineOptions(argc, argv);
|
||||
|
||||
if (fs::is_regular_file(p))
|
||||
process_mmm(p);
|
||||
else if (fs::is_directory(p))
|
||||
|
|
|
|||
|
|
@ -117,14 +117,14 @@ void mmp::load(const buffer &b)
|
|||
}
|
||||
}
|
||||
|
||||
void mmp::load(const std::string &fn)
|
||||
void mmp::load(const path &fn)
|
||||
{
|
||||
filename = fn;
|
||||
buffer b(read_file(filename));
|
||||
load(b);
|
||||
}
|
||||
|
||||
void mmp::loadTextureNames(const std::string &fn)
|
||||
void mmp::loadTextureNames(const path &fn)
|
||||
{
|
||||
std::ifstream ifile(fn);
|
||||
while (ifile)
|
||||
|
|
@ -254,7 +254,8 @@ void mmp::process()
|
|||
|
||||
void mmp::writeFileInfo()
|
||||
{
|
||||
std::ofstream ofile(filename + ".info.txt");
|
||||
auto fn = filename;
|
||||
std::ofstream ofile(fn += ".info.txt");
|
||||
if (!ofile)
|
||||
return;
|
||||
ofile << "width: " << h.width << "\n";
|
||||
|
|
@ -270,7 +271,8 @@ void mmp::writeFileInfo()
|
|||
|
||||
void mmp::writeTexturesList()
|
||||
{
|
||||
std::ofstream ofile(filename + ".textures.txt");
|
||||
auto fn = filename;
|
||||
std::ofstream ofile(fn += ".textures.txt");
|
||||
if (!ofile)
|
||||
return;
|
||||
for (auto &t : textures)
|
||||
|
|
@ -291,8 +293,9 @@ void mmp::writeTexturesList()
|
|||
|
||||
void mmp::writeHeightMap()
|
||||
{
|
||||
auto fn = filename + ".heightmap16.r16";
|
||||
FILE *f = fopen(fn.c_str(), "wb");
|
||||
auto fn = filename;
|
||||
fn += ".heightmap16.r16";
|
||||
auto f = primitives::filesystem::fopen(fn, "wb");
|
||||
if (f == nullptr)
|
||||
return;
|
||||
fwrite(&heightmap(0, 0), heightmap.size() * sizeof(decltype(heightmap)::type), 1, f);
|
||||
|
|
@ -311,7 +314,8 @@ void mmp::writeHeightMapSegmented()
|
|||
|
||||
void mmp::writeTextureMap()
|
||||
{
|
||||
auto fn = filename + ".texmap.bmp";
|
||||
auto fn = filename;
|
||||
fn += ".texmap.bmp";
|
||||
write_mat_bmp(fn, texmap);
|
||||
}
|
||||
|
||||
|
|
@ -328,31 +332,36 @@ void mmp::writeTextureAlphaMaps()
|
|||
break;
|
||||
}
|
||||
}
|
||||
auto fn = filename + ".texmap." + std::to_string(t.first) + "." + std::to_string(tex_id) + ".bmp";
|
||||
auto fn = filename;
|
||||
fn += ".texmap." + std::to_string(t.first) + "." + std::to_string(tex_id) + ".bmp";
|
||||
write_mat_bmp(fn, t.second);
|
||||
}
|
||||
}
|
||||
|
||||
void mmp::writeTextureMapColored()
|
||||
{
|
||||
auto fn = filename + ".texmap.colored.bmp";
|
||||
auto fn = filename;
|
||||
fn += ".texmap.colored.bmp";
|
||||
write_mat_bmp(fn, texmap_colored);
|
||||
}
|
||||
|
||||
void mmp::writeColorMap()
|
||||
{
|
||||
auto fn = filename + ".colormap.bmp";
|
||||
auto fn = filename;
|
||||
fn += ".colormap.bmp";
|
||||
write_mat_bmp(fn, colormap);
|
||||
}
|
||||
|
||||
void mmp::writeShadowMap()
|
||||
{
|
||||
auto fn = filename + ".shadowmap.bmp";
|
||||
auto fn = filename;
|
||||
fn += ".shadowmap.bmp";
|
||||
write_mat_bmp(fn, shadowmap);
|
||||
}
|
||||
|
||||
void mmp::writeNormalMap()
|
||||
{
|
||||
auto fn = filename + ".normalmap.bmp";
|
||||
auto fn = filename;
|
||||
fn += ".normalmap.bmp";
|
||||
write_mat_bmp(fn, normalmap);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,17 +16,19 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <buffer.h>
|
||||
#include <color.h>
|
||||
#include <mat.h>
|
||||
#include <types.h>
|
||||
|
||||
#include <primitives/filesystem.h>
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <buffer.h>
|
||||
#include <color.h>
|
||||
#include <mat.h>
|
||||
#include <types.h>
|
||||
|
||||
using Height = float;
|
||||
|
||||
enum class HeaderSegmentType : uint32_t
|
||||
|
|
@ -165,7 +167,7 @@ struct mmp
|
|||
std::vector<segment> segments;
|
||||
|
||||
//
|
||||
std::string filename;
|
||||
path filename;
|
||||
int xsegs;
|
||||
int ysegs;
|
||||
std::map<int, int /* count */> textures;
|
||||
|
|
@ -186,8 +188,8 @@ struct mmp
|
|||
mat<uint32_t> normalmap;
|
||||
|
||||
void load(const buffer &b);
|
||||
void load(const std::string &filename);
|
||||
void loadTextureNames(const std::string &filename);
|
||||
void load(const path &filename);
|
||||
void loadTextureNames(const path &filename);
|
||||
|
||||
void process();
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include <primitives/filesystem.h>
|
||||
#include <primitives/sw/main.h>
|
||||
#include <primitives/sw/settings.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
|
|
@ -31,18 +32,17 @@ using namespace std;
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 2 || argc > 3)
|
||||
{
|
||||
cout << "Usage:\n" << argv[0] << " {file.mmp,mmp_dir} [texture_ids.txt]" << "\n";
|
||||
return 1;
|
||||
}
|
||||
cl::opt<path> p(cl::Positional, cl::desc("<file.mmp or directory>"), cl::Required);
|
||||
cl::opt<path> texture_ids(cl::Positional, cl::desc("<path to texture_ids.txt>"));
|
||||
|
||||
auto func = [&argc, &argv](auto &p)
|
||||
cl::ParseCommandLineOptions(argc, argv);
|
||||
|
||||
auto func = [&texture_ids](auto &p)
|
||||
{
|
||||
mmp m;
|
||||
if (argc > 2)
|
||||
m.loadTextureNames(argv[2]);
|
||||
m.load(p.string());
|
||||
if (!texture_ids.empty())
|
||||
m.loadTextureNames(texture_ids);
|
||||
m.load(p);
|
||||
m.process();
|
||||
m.writeFileInfo();
|
||||
m.writeTexturesList();
|
||||
|
|
@ -56,7 +56,6 @@ int main(int argc, char *argv[])
|
|||
m.writeNormalMap();
|
||||
};
|
||||
|
||||
path p = argv[1];
|
||||
if (fs::is_regular_file(p))
|
||||
func(p);
|
||||
else if (fs::is_directory(p))
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <primitives/filesystem.h>
|
||||
#include <primitives/sw/main.h>
|
||||
#include <primitives/sw/settings.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
|
|
@ -33,12 +34,9 @@
|
|||
using namespace std;
|
||||
|
||||
// options
|
||||
bool all_formats = false;
|
||||
bool silent = false;
|
||||
bool printMaxPolygonBlock = false;
|
||||
path p;
|
||||
|
||||
bool parse_cmd(int argc, char *argv[]);
|
||||
cl::opt<bool> all_formats("a", cl::desc("all formats"));
|
||||
cl::opt<bool> silent("s", cl::desc("silent"));
|
||||
cl::opt<bool> printMaxPolygonBlock("m", cl::desc("print max polygon block"));
|
||||
|
||||
void convert_model(const path &fn)
|
||||
{
|
||||
|
|
@ -56,11 +54,10 @@ void convert_model(const path &fn)
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 2 || !parse_cmd(argc, argv))
|
||||
{
|
||||
printf("Usage: %s [OPTIONS] {model_file,model_dir}\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
cl::opt<path> p(cl::Positional, cl::desc("<model file or dir>"), cl::Required);
|
||||
|
||||
cl::ParseCommandLineOptions(argc, argv);
|
||||
|
||||
if (fs::is_regular_file(p))
|
||||
convert_model(p);
|
||||
else if (fs::is_directory(p))
|
||||
|
|
@ -78,31 +75,3 @@ int main(int argc, char *argv[])
|
|||
throw std::runtime_error("Bad fs object");
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ void mpj::load(const buffer &b)
|
|||
h.load(b);
|
||||
}
|
||||
|
||||
void mpj::load(const std::string &fn)
|
||||
void mpj::load(const path &fn)
|
||||
{
|
||||
filename = fn;
|
||||
buffer b(read_file(filename));
|
||||
|
|
|
|||
|
|
@ -16,16 +16,18 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <buffer.h>
|
||||
#include <objects.h>
|
||||
#include <types.h>
|
||||
|
||||
#include <primitives/filesystem.h>
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <buffer.h>
|
||||
#include <objects.h>
|
||||
#include <types.h>
|
||||
|
||||
enum class SegmentType : uint32_t
|
||||
{
|
||||
none = 0,
|
||||
|
|
@ -204,8 +206,8 @@ struct mpj
|
|||
header h;
|
||||
|
||||
//
|
||||
std::string filename;
|
||||
path filename;
|
||||
|
||||
void load(const buffer &b);
|
||||
void load(const std::string &filename);
|
||||
void load(const path &filename);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#include "mpj.h"
|
||||
|
||||
#include <primitives/sw/main.h>
|
||||
#include <primitives/sw/settings.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
|
|
@ -30,12 +31,11 @@ using namespace std;
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
cout << "Usage:\n" << argv[0] << " file.mpj" << "\n";
|
||||
return 1;
|
||||
}
|
||||
cl::opt<path> p(cl::Positional, cl::desc("<file.mpj>"), cl::Required);
|
||||
|
||||
cl::ParseCommandLineOptions(argc, argv);
|
||||
|
||||
mpj m;
|
||||
m.load(argv[1]);
|
||||
m.load(p);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,17 +20,16 @@
|
|||
|
||||
#include <primitives/filesystem.h>
|
||||
#include <primitives/sw/main.h>
|
||||
#include <primitives/sw/settings.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
printf("Usage: %s {file.sav,saves_dir}\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
cl::opt<path> p(cl::Positional, cl::desc("<file.sav or saves dir>"), cl::Required);
|
||||
|
||||
cl::ParseCommandLineOptions(argc, argv);
|
||||
|
||||
//save_changes.mech_org = "ORG_PLAYER";
|
||||
save_changes.money = 999999999.0f;
|
||||
|
|
@ -47,7 +46,6 @@ int main(int argc, char *argv[])
|
|||
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))
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <primitives/filesystem.h>
|
||||
#include <primitives/sw/main.h>
|
||||
#include <primitives/sw/settings.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
|
@ -32,11 +33,9 @@ using std::string;
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
cout << "Usage:\n" << argv[0] << " {script.scr,scr_dir}";
|
||||
return 1;
|
||||
}
|
||||
cl::opt<path> p(cl::Positional, cl::desc("<script.scr or scripts dir>"), cl::Required);
|
||||
|
||||
cl::ParseCommandLineOptions(argc, argv);
|
||||
|
||||
auto func = [](auto filename)
|
||||
{
|
||||
|
|
@ -76,7 +75,6 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
};
|
||||
|
||||
path p = argv[1];
|
||||
if (fs::is_regular_file(p))
|
||||
func(p.string());
|
||||
else if (fs::is_directory(p))
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <primitives/filesystem.h>
|
||||
#include <primitives/sw/main.h>
|
||||
#include <primitives/sw/settings.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
|
|
@ -82,12 +83,10 @@ void convert(const path &fn)
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
printf("Usage: %s file.tm\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
path p = argv[1];
|
||||
cl::opt<path> p(cl::Positional, cl::desc("<file.tm>"), cl::Required);
|
||||
|
||||
cl::ParseCommandLineOptions(argc, argv);
|
||||
|
||||
if (fs::is_regular_file(p))
|
||||
convert(p);
|
||||
else if (fs::is_directory(p))
|
||||
|
|
|
|||
Loading…
Reference in a new issue