Fix cooking new world/area data without an underscore in the name

This commit is contained in:
Phillip Stephens 2021-05-30 23:10:59 -07:00
parent 27f25223fb
commit 137e96c732
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
7 changed files with 12 additions and 12 deletions

View File

@ -291,7 +291,7 @@ bool ReadMAPAToBlender(hecl::blender::Connection& conn, const MAPA& mapa, const
/* World background */
hecl::ProjectPath worldDir = outPath.getParentPath().getParentPath();
for (const auto& ent : hecl::DirectoryEnumerator(worldDir.getAbsolutePath())) {
if (hecl::StringUtils::BeginsWith(ent.m_name, _SYS_STR("!world_")) &&
if (hecl::StringUtils::BeginsWith(ent.m_name, _SYS_STR("!world")) &&
hecl::StringUtils::EndsWith(ent.m_name, _SYS_STR(".blend"))) {
hecl::SystemUTF8Conv conv(ent.m_name);
os.linkBackground(fmt::format(FMT_STRING("//../{}"), conv), "World"sv);

View File

@ -115,7 +115,7 @@ bool MAPU::Cook(const hecl::blender::MapUniverse& mapuIn, const hecl::ProjectPat
MAPU::World& wldOut = mapu.worlds.back();
wldOut.name = wld.name;
for (const auto& ent : wld.worldPath.enumerateDir()) {
if (hecl::StringUtils::BeginsWith(ent.m_name, _SYS_STR("!world_")) &&
if (hecl::StringUtils::BeginsWith(ent.m_name, _SYS_STR("!world")) &&
hecl::StringUtils::EndsWith(ent.m_name, _SYS_STR(".blend"))) {
wldOut.mlvl = hecl::ProjectPath(wld.worldPath, ent.m_name);
break;

View File

@ -112,15 +112,15 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
mlvl.magic = 0xDEAFBABE;
mlvl.version = 0x11;
hecl::ProjectPath namePath = GetPathBeginsWith(dEnum, parentPath, _SYS_STR("!name_"));
hecl::ProjectPath namePath = GetPathBeginsWith(dEnum, parentPath, _SYS_STR("!name"));
if (namePath.isFile())
mlvl.worldNameId = namePath;
hecl::ProjectPath savwPath = GetPathBeginsWith(dEnum, parentPath, _SYS_STR("!savw_"));
hecl::ProjectPath savwPath = GetPathBeginsWith(dEnum, parentPath, _SYS_STR("!savw"));
if (savwPath.isFile()) {
CookSAVW(savwPath.getCookedPath(SpecEntMP1), wld);
mlvl.saveWorldId = savwPath;
}
hecl::ProjectPath mapwPath = GetPathBeginsWith(dEnum, parentPath, _SYS_STR("!mapw_"));
hecl::ProjectPath mapwPath = GetPathBeginsWith(dEnum, parentPath, _SYS_STR("!mapw"));
if (mapwPath.isFile()) {
CookMAPW(mapwPath.getCookedPath(SpecEntMP1), wld);
mlvl.worldMap = mapwPath;
@ -133,7 +133,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
continue;
const hecl::DirectoryEnumerator areaDEnum(area.path.getAbsolutePath());
const hecl::ProjectPath areaPath = GetPathBeginsWith(areaDEnum, area.path, _SYS_STR("!area_"));
const hecl::ProjectPath areaPath = GetPathBeginsWith(areaDEnum, area.path, _SYS_STR("!area"));
if (!areaPath.isFile())
continue;
@ -200,7 +200,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
mlvl.areas.emplace_back();
MLVL::Area& areaOut = mlvl.areas.back();
hecl::ProjectPath namePath = GetPathBeginsWith(areaDEnum, area.path, _SYS_STR("!name_"));
namePath = GetPathBeginsWith(areaDEnum, area.path, _SYS_STR("!name"));
if (namePath.isFile())
areaOut.areaNameId = namePath;

View File

@ -536,7 +536,7 @@ void SpecBase::copyBuildListData(std::vector<std::tuple<size_t, size_t, bool>>&
static bool IsWorldBlend(const hecl::ProjectPath& path) {
if (path.isFile()) {
auto lastComp = path.getLastComponent();
return hecl::StringUtils::BeginsWith(lastComp, _SYS_STR("!world_")) &&
return hecl::StringUtils::BeginsWith(lastComp, _SYS_STR("!world")) &&
hecl::StringUtils::EndsWith(lastComp, _SYS_STR(".blend"));
}
return false;
@ -680,7 +680,7 @@ std::optional<hecl::blender::World> SpecBase::compileWorldFromDir(const hecl::Pr
hecl::blender::Token& btok) const {
hecl::ProjectPath asBlend;
for (const auto& ent : hecl::DirectoryEnumerator(dir.getAbsolutePath())) {
if (hecl::StringUtils::BeginsWith(ent.m_name, _SYS_STR("!world_"))) {
if (hecl::StringUtils::BeginsWith(ent.m_name, _SYS_STR("!world"))) {
asBlend = hecl::ProjectPath(dir, ent.m_name).getWithExtension(_SYS_STR(".blend"), true);
break;
}

View File

@ -712,7 +712,7 @@ struct SpecMP1 : SpecBase {
if (ent2.m_isDir) {
hecl::ProjectPath wldDir(pakPath, ent2.m_name);
for (const auto& ent3 : wldDir.enumerateDir()) {
if (hecl::StringUtils::BeginsWith(ent3.m_name, _SYS_STR("!world_")) &&
if (hecl::StringUtils::BeginsWith(ent3.m_name, _SYS_STR("!world")) &&
hecl::StringUtils::EndsWith(ent3.m_name, _SYS_STR(".blend"))) {
hecl::ProjectPath wldPath(wldDir, ent3.m_name);
if (wldPath.isFile()) {

View File

@ -348,7 +348,7 @@ void CMain::AddWorldPaks() {
}
auto pakPrefix = g_tweakGame->GetWorldPrefix();
for (int i = 0; i < 9; ++i) {
for (int i = 0; i < 10; ++i) {
std::string path(pakPrefix);
if (i != 0) {

View File

@ -21,7 +21,7 @@ class ToolPackage final : public ToolBase {
void CheckFile(const hecl::ProjectPath& path) {
auto lastComp = path.getLastComponent();
if (hecl::StringUtils::BeginsWith(lastComp, _SYS_STR("!world_")) &&
if (hecl::StringUtils::BeginsWith(lastComp, _SYS_STR("!world")) &&
hecl::StringUtils::EndsWith(lastComp, _SYS_STR(".blend")))
AddSelectedItem(path);
}