mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 00:09:18 +02:00
Add binary scenery format (eu7 v3) with async baking, replacing SBT
Text scenery component files (.scn/.inc/.scm/.ctr) are compiled into per-file binary twins (.scnb/.incb/.scmb/.ctrb), handled transparently at the cParser layer: a fresh twin (mtime-checked, version-matched) is replayed instead of re-tokenizing text; otherwise the text is parsed and a twin is compiled alongside it for next time. Format details: - per-file string interning: keywords/paths stored once, referenced by varint index (so node/endmodel/... are not repeated as text) - numeric tokens stored as 8-byte IEEE doubles, not ASCII - includes kept as references with parameters; random sets stored verbatim and re-evaluated on every load (choice not frozen at compile time) - twin writing offloaded to a bounded thread pool so baking overlaps scene construction instead of blocking the load The legacy terrain-only .sbt path is removed; terrain now loads as ordinary scenery content. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -471,4 +471,54 @@ std::string deserialize_random_set(cParser &Input, char const *Break)
|
||||
// shouldn't ever get here but, eh
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
std::string deserialize_random_set_capture(cParser &Input, std::vector<std::string> &Raw, char const *Break)
|
||||
{
|
||||
auto token{Input.getToken<std::string>(true, Break)};
|
||||
std::replace(token.begin(), token.end(), '\\', '/');
|
||||
Raw.emplace_back(token); // record the raw token verbatim (incl. brackets / "")
|
||||
if (token != "[")
|
||||
{
|
||||
// simple case, single token
|
||||
return token;
|
||||
}
|
||||
// random set: recurse for entries, recording every token, until the closing ']'
|
||||
std::vector<std::string> tokens;
|
||||
std::string entry;
|
||||
while (((entry = deserialize_random_set_capture(Input, Raw, Break)) != "") && (entry != "]"))
|
||||
{
|
||||
tokens.emplace_back(entry);
|
||||
}
|
||||
if (false == tokens.empty())
|
||||
{
|
||||
std::shuffle(std::begin(tokens), std::end(tokens), Global.random_engine);
|
||||
return tokens.front();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string resolve_random_set(std::vector<std::string> const &Raw, std::size_t &Pos)
|
||||
{
|
||||
if (Pos >= Raw.size())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
auto token{Raw[Pos++]};
|
||||
if (token != "[")
|
||||
{
|
||||
return token;
|
||||
}
|
||||
std::vector<std::string> tokens;
|
||||
std::string entry;
|
||||
while (((entry = resolve_random_set(Raw, Pos)) != "") && (entry != "]"))
|
||||
{
|
||||
tokens.emplace_back(entry);
|
||||
}
|
||||
if (false == tokens.empty())
|
||||
{
|
||||
std::shuffle(std::begin(tokens), std::end(tokens), Global.random_engine);
|
||||
return tokens.front();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
Reference in New Issue
Block a user