From 8690bf4ca73079e20670080d72a09fb7d5706f88 Mon Sep 17 00:00:00 2001 From: Kp Date: Wed, 13 Jun 2018 02:02:58 +0000 Subject: [PATCH] Change handling of explicitly blank briefings Prior versions of Descent had a bug that specifying `briefing=` did not inhibit a briefing. Instead the directive was completely ignored. The engine would then use the auto-detected briefing if one was found. This quirk was eliminated during refactoring of the mission parsing code. Unfortunately, some published missions relied on this bug: they ship a briefing, but their mission file explicitly states that there is no briefing. Players expect the briefing to play despite the mission stating that there is none. Reorder the logic to restore the bug that `briefing=` is ignored. Reported-by: Calmarius Fixes: 6020c9c013c217ab45c6304a4a0c6bad9915d1db ("Use d_fname for DOS filenames") --- similar/main/mission.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/similar/main/mission.cpp b/similar/main/mission.cpp index 335d1ca10..73ef8302a 100644 --- a/similar/main/mission.cpp +++ b/similar/main/mission.cpp @@ -716,11 +716,14 @@ static void set_briefing_filename(d_fname &f, const char *const v) static void record_briefing(d_fname &f, array &buf) { const auto v = get_value(buf.data()); - std::size_t d; - if (v && (d = std::distance(v, std::find_if(v, buf.end(), null_or_space)))) + if (!v) + return; + const std::size_t d = std::distance(v, std::find_if(v, buf.end(), null_or_space)); + if (d >= FILENAME_LEN) + return; + { set_briefing_filename(f, v, std::min(d, f.size() - sizeof(tex))); - else - f = {}; + } } #undef tex