17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 01:39:20 +02:00

feat(terrain): binary terrain files (.btf) made out of text terrain files (.txtf) named by terrain directives, checked against length and checksum of the text and loaded section by section when needed; -btf command line conversion; SBT files no longer generated, only loaded

This commit is contained in:
2026-10-06 01:55:38 +02:00
parent e1b91c430b
commit 2e631dcbd6
10 changed files with 1138 additions and 13 deletions

41
export_btf_standalone.cpp Normal file
View File

@@ -0,0 +1,41 @@
#include "stdafx.h"
#include "scene/sceneterrain.h"
#include "utilities/Globals.h"
#include "utilities/utilities.h"
// converts text terrain file to binary format. returns: 0 on success, 1 otherwise
int export_btf_standalone(std::string in, std::string out)
{
if (in.empty())
{
std::printf("usage: -btf -s <text terrain file> [-o <binary terrain file>]\n");
return 1;
}
replace_slashes(in);
replace_slashes(out);
if (false == FileExists(in) && FileExists(Global.asCurrentSceneryPath + in))
{
// the file can be given the way the sceneries refer to it
in = Global.asCurrentSceneryPath + in;
}
if (out.empty())
{
// by default the binary file goes where the sceneries expect to find it, next to the text
out = in;
erase_extension(out);
out += ".btf";
}
std::string message;
auto const result{scene::terrain_file::convert(in, out, &message)};
// NOTE: the log service doesn't run in this mode, the outcome is reported directly
if (result)
{
std::printf("%s -> %s: %s\n", in.c_str(), out.c_str(), message.c_str());
}
else
{
std::printf("%s: conversion failed, %s\n", in.c_str(), message.c_str());
}
return (result ? 0 : 1);
}