Open BAD-AL opened 3 years ago
Ah yeah, I think I remember someone else bringing this up as well. (But I forgot about it because it was just in passing.) Thanks for opening an issue for it. This is something that definitely should be addressed.
Also... A similar issue exists in .snd files for the property 'Parent'?
I fixed the HUD unmunge in the following way on a local copy (handle_config.cpp) Could be a more general way, I'm not sure but here's a solution for the HUD unmunge (for your consideration).
std::string read_tag_data(Ucfb_reader_strict<"DATA"_mn> data,
const Swbf_fnv_hashes& swbf_hashes,
const std::size_t indention_level)
{
const auto hash = data.read_trivial<std::uint32_t>();
std::string line;
std::string name;
line.append(indention_level, '\t');
name = swbf_hashes.lookup(hash);
line += name;
if (name == "Position" || name == "PositionSmall" || name == "PositionLarge" || name == "PositionSpawn" ) {
line += "("sv;
const auto element_count = data.read_trivial_unaligned<std::uint8_t>();
for (std::size_t i = 0; i < element_count; ++i) {
if (i < 3) {
line += cast_number_value(data.read_trivial_unaligned<float>());
line += ", "sv;
}
else {
auto offset1 = data.read_trivial_unaligned<std::uint32_t>();
auto offset2 = data.read_trivial_unaligned<std::uint32_t>();// used for len
auto str1 = data.read_string_unaligned();
//line += "\"Viewport\""sv;
line += "\""sv;
line += str1;
line += "\""sv;
}
}
line += ");\n"sv;
}
else if (name == "BitmapRect" || name == "Rect") { //BitmapRect(0.212315, 0.016690, "Left", "Top", "Viewport")
line += "("sv;
const auto element_count = data.read_trivial_unaligned<std::uint8_t>();
for (std::size_t i = 0; i < element_count; ++i) {
if (i < 2) {
line += cast_number_value(data.read_trivial_unaligned<float>());
line += ", "sv;
}
else if (i == 2) {
auto offset1 = data.read_trivial_unaligned<std::uint32_t>();
auto offset2 = data.read_trivial_unaligned<std::uint32_t>();
auto offset3 = data.read_trivial_unaligned<std::uint32_t>();
auto offset4 = data.read_trivial_unaligned<std::uint32_t>();
auto str1 = data.read_string_unaligned();
auto str2 = data.read_string_unaligned();
auto str3 = data.read_string_unaligned();
line += "\""sv;
line += str1;
line += "\", \""sv;
line += str2;
line += "\", \""sv;
line += str3;
line += "\""sv;
break;
}
}
line += ");\n"sv;
} else {
// do something, pretty useless though. :(
line += "();\n"sv;
}
return line;
}
Was chatting with AnthonyBF2 on HUD last night and he pointed out that the HUDs are not unmunging totally correctly.