Skip to content

Commit

Permalink
Die more gracefully when models cannot be loaded. Fixes #1776
Browse files Browse the repository at this point in the history
  • Loading branch information
lhog committed Nov 18, 2024
1 parent 38598d1 commit 7363dbc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions rts/Rendering/Models/IModelParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,16 @@ void CModelLoader::ParseModel(S3DModel& model, const std::string& name, const st
RECOIL_DETAILED_TRACY_ZONE;
try {
auto* parser = GetFormatParser(FileSystem::GetExtension(path));
if (parser == nullptr)
if (parser == nullptr) {
LoadDummyModel(model);
throw content_error(fmt::sprintf("could not find a parser for model \"%s\" (unknown format?)", name));
}

parser->Load(model, path);
if (model.numPieces > 254)
if (model.numPieces > 254) {
LoadDummyModel(model);
throw content_error("A model has too many pieces (>254)" + path);
}

} catch (const content_error& ex) {
auto lock = CModelsLock::GetScopedLock();
Expand Down

0 comments on commit 7363dbc

Please sign in to comment.