Skip to content

Commit

Permalink
more build flag complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
LAK132 committed Oct 31, 2023
1 parent a2b7bc2 commit ab9d0af
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/ctf/chunks/extended_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ namespace SourceExplorer

ImGui::Text("Flags: 0x%zX", (size_t)flags);
ImGui::Text("Build Type: 0x%zX", (size_t)build_type);
ImGui::Text("Build Flags: 0x%zX", (size_t)build_flags);
ImGui::Text("Build Flags: %s (0x%zX)",
GetBuildFlagsString(build_flags).c_str(),
(size_t)build_flags);
ImGui::Text("Screen Ratio Tolerance: 0x%zX",
(size_t)screen_ratio_tolerance);
ImGui::Text("Screen Angle: 0x%zX", (size_t)screen_angle);
Expand Down
12 changes: 10 additions & 2 deletions src/ctf/chunks/image_bank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ namespace SourceExplorer
bool optimised_image =
game.game.extended_header &&
((game.game.extended_header->build_flags &
build_flags_t::optimize_image_size) != build_flags_t::none);
build_flags_t::optimize_image_size) != build_flags_t::none) &&
((game.game.extended_header->build_flags & build_flags_t::unknown3) ==
build_flags_t::none);

const auto strm_start = strm.position();
if (game.ccn)
{
CHECKPOINT();

RES_TRY(entry.read(game, strm, true, 10)
.RES_ADD_TRACE("image::item_t::read"));

Expand Down Expand Up @@ -61,7 +65,9 @@ namespace SourceExplorer
data_ref_span_t span;
if (optimised_image)
{
const size_t header_size = 36;
CHECKPOINT();

const size_t header_size = 0x24;
RES_TRY(entry.read(game, strm, false, header_size)
.RES_ADD_TRACE("image::item_t::read"));

Expand All @@ -76,6 +82,8 @@ namespace SourceExplorer
}
else
{
CHECKPOINT();

RES_TRY(
entry.read(game, strm, true).RES_ADD_TRACE("image::item_t::read"));

Expand Down
40 changes: 40 additions & 0 deletions src/ctf/explorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,46 @@ namespace SourceExplorer
return result;
}

lak::astring GetBuildFlagsString(build_flags_t flags)
{
lak::astring result;

if (flags == build_flags_t::none)
result = "none";
else
{
if ((flags & build_flags_t::compression_level_max) !=
build_flags_t::none)
result += "compression_level_max | ";
if ((flags & build_flags_t::compress_sounds) != build_flags_t::none)
result += "compress_sounds | ";
if ((flags & build_flags_t::include_external_files) !=
build_flags_t::none)
result += "include_external_files | ";
if ((flags & build_flags_t::no_auto_image_filters) !=
build_flags_t::none)
result += "no_auto_image_filters | ";
if ((flags & build_flags_t::no_auto_sound_filters) !=
build_flags_t::none)
result += "no_auto_sound_filters | ";
if ((flags & build_flags_t::unknown1) != build_flags_t::none)
result += "unknown1 | ";
if ((flags & build_flags_t::unknown2) != build_flags_t::none)
result += "unknown2 | ";
if ((flags & build_flags_t::unknown3) != build_flags_t::none)
result += "unknown3 | ";
if ((flags & build_flags_t::dont_display_build_warnings) !=
build_flags_t::none)
result += "dont_display_build_warnings | ";
if ((flags & build_flags_t::optimize_image_size) != build_flags_t::none)
result += "optimize_image_size | ";

result.resize(result.size() - 3);
}

return result;
}

result_t<data_ref_span_t> Decode(data_ref_span_t encoded,
chunk_t id,
encoding_t mode)
Expand Down
2 changes: 2 additions & 0 deletions src/ctf/explorer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ namespace SourceExplorer

lak::astring GetImageFlagString(image_flag_t flags);

lak::astring GetBuildFlagsString(build_flags_t flags);

result_t<data_ref_span_t> Decode(data_ref_span_t encoded,
chunk_t ID,
encoding_t mode);
Expand Down

0 comments on commit ab9d0af

Please sign in to comment.