Report failure when a mission is not found in the mission list

AlumiuN reported a crash when a save game is unable to load the
underlying mission.  The crash is because the game proceeds to load the
savegame onto whatever level was loaded before this mission, which will
usually result in fatal inconsistencies in the data.

This commit does not fix the cause of the inability to load the mission,
but instead fixes the logic so that the user gets a reasonable error
message advising that the mission failed to load.  This was
unintentionally broken in db80a88ad2 when the sense of the return
value was inverted, and the fallthrough case was not adjusted.  This
impacts all uses of `load_mission_by_name`, though in practice restoring
from a savegame is the most obvious way to hit the problem.

Reported-by: AlumiuN <https://github.com/dxx-rebirth/dxx-rebirth/issues/486> (indirectly)
Fixes: db80a88ad2 ("Improve error message on failure to load mission")
This commit is contained in:
Kp 2020-01-06 01:25:35 +00:00
parent 59b94a4dcb
commit ffb4240710

View file

@ -1127,15 +1127,10 @@ static const char *load_mission(const mle *const mission)
const char *load_mission_by_name(const char *const mission_name)
{
auto mission_list = build_mission_list(1);
const char *found = nullptr;
range_for (auto &i, mission_list)
if (!d_stricmp(mission_name, &*i.filename))
{
found = load_mission(&i);
break;
}
return found;
return load_mission(&i);
return "No matching mission found in\ninstalled mission list.";
}
namespace {