Only remove -vis from name if it is part of the name. (#3257)

During level extraction, the last 4 characters of the level name are
always removed, because it is assumed that '-vis' is there. But it isn't
always there. This is especially true in post-TPL games.

This causes multiple problems:
- There can be levels in the extraction that will miss their last 4
characters from their name, which is sad, and may make it harder to
identify them.
- If there are '-vis'-less levels whose names are identical apart from
the last 4 characters, the extractor will only get the last one (it
probably extracts all but overwrites everything but the last one). For
example 'ctyasha' and 'ctykora'.

This issue affects the glb extraction and the entities json extraction.

I personally think that just keeping the -vis in the name would be the
best solution, but I guess there was a reason why it was decided that it
should be removed from the name. So to adapt to this, my implementation
will still remove '-vis' from the name, but only if it is actually in
the name - otherwise it won't remove anything.

I hope my changes didn't break anything. Extraction seemed to run fine
after my changes, and I was able to see both ctyasha and ctykora json
files. And didn't see any '-vis', so it is still properly removed.

---------

Co-authored-by: Tyler Wilding <xtvaser@gmail.com>
This commit is contained in:
Luminar Light 2024-02-24 20:13:48 +01:00 committed by GitHub
parent db66ae4627
commit 0ae0938965
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 6 additions and 6 deletions

View file

@ -634,7 +634,7 @@
// there are some missing textures. I don't know what the game actually does here. // there are some missing textures. I don't know what the game actually does here.
// the format for entries is [level, tpage, index] // the format for entries is [level, tpage, index]
"missing_textures": [["finalboss", 1419, 3]], "missing_textures": [["finalboss-vis", 1419, 3]],
// some object files have garbage pad data at the end which makes the decompiler // some object files have garbage pad data at the end which makes the decompiler
// assume they must be different files, such as the art group for orb-cache-top. // assume they must be different files, such as the art group for orb-cache-top.

View file

@ -769,7 +769,7 @@
// there are some missing textures. I don't know what the game actually does here. // there are some missing textures. I don't know what the game actually does here.
// the format for entries is [level, tpage, index] // the format for entries is [level, tpage, index]
"missing_textures": [ "missing_textures": [
["vinroom", 0, 0], ["vinroom-vis", 0, 0],
["ctyfence", 0, 0] ["ctyfence", 0, 0]
], ],

View file

@ -142,7 +142,7 @@ std::vector<level_tools::TextureRemap> extract_tex_remap(const ObjectFileDB& db,
lg::warn("Skipping extract for {} because the BSP file was not found", dgo_name); lg::warn("Skipping extract for {} because the BSP file was not found", dgo_name);
return {}; return {};
} }
std::string level_name = bsp_rec->name.substr(0, bsp_rec->name.length() - 4); std::string level_name = bsp_rec->name;
lg::info("Processing level {} ({})", dgo_name, level_name); lg::info("Processing level {} ({})", dgo_name, level_name);
const auto& bsp_file = db.lookup_record(*bsp_rec); const auto& bsp_file = db.lookup_record(*bsp_rec);
@ -167,7 +167,7 @@ level_tools::BspHeader extract_bsp_from_level(const ObjectFileDB& db,
lg::warn("Skipping extract for {} because the BSP file was not found", dgo_name); lg::warn("Skipping extract for {} because the BSP file was not found", dgo_name);
return {}; return {};
} }
std::string level_name = bsp_rec->name.substr(0, bsp_rec->name.length() - 4); std::string level_name = bsp_rec->name;
lg::info("Processing level {} ({})", dgo_name, level_name); lg::info("Processing level {} ({})", dgo_name, level_name);
const auto& bsp_file = db.lookup_record(*bsp_rec); const auto& bsp_file = db.lookup_record(*bsp_rec);

View file

@ -40,7 +40,7 @@ DebugSettings::DebugSettings() {
if (!file_util::file_exists(file_path)) { if (!file_util::file_exists(file_path)) {
return; return;
} }
lg::info("Loading display settings at {}", file_path); lg::info("Loading debug settings at {}", file_path);
auto raw = file_util::read_text_file(file_path); auto raw = file_util::read_text_file(file_path);
from_json(parse_commented_json(raw, "debug-settings.json"), *this); from_json(parse_commented_json(raw, "debug-settings.json"), *this);
} catch (std::exception& e) { } catch (std::exception& e) {
@ -123,7 +123,7 @@ InputSettings::InputSettings() {
if (!file_util::file_exists(file_path)) { if (!file_util::file_exists(file_path)) {
return; return;
} }
lg::info("Loading display settings at {}", file_path); lg::info("Loading input settings at {}", file_path);
auto raw = file_util::read_text_file(file_path); auto raw = file_util::read_text_file(file_path);
from_json(parse_commented_json(raw, "input-settings.json"), *this); from_json(parse_commented_json(raw, "input-settings.json"), *this);
} catch (std::exception& e) { } catch (std::exception& e) {