Skip to content

Commit

Permalink
Hotfix missing model/sprite renderer in some cases
Browse files Browse the repository at this point in the history
Hotfix missing model/sprite renderer in some cases
  • Loading branch information
UnrealKaraulov committed Dec 30, 2023
1 parent 1f6c7e2 commit 326aa12
Showing 1 changed file with 63 additions and 4 deletions.
67 changes: 63 additions & 4 deletions src/editor/BspRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1741,21 +1741,80 @@ void BspRenderer::refreshEnt(int entIdx)

std::string lowerpath = toLowerCase(fgdClass->sprite);
std::string newModelPath;
if (lowerpath.ends_with(".spr"))
if (lowerpath.ends_with(".mdl"))
{
if (FindPathInAssets(map, fgdClass->sprite, newModelPath))
{
renderEnts[entIdx].spr = AddNewSpriteToRender(newModelPath);
renderEnts[entIdx].mdl = AddNewModelToRender(newModelPath, body + sequence * 100 + skin * 1000);
renderEnts[entIdx].mdl->UpdateModelMeshList();
}
else
{
FindPathInAssets(map, fgdClass->sprite, newModelPath, true);
renderEnts[entIdx].spr = NULL;
renderEnts[entIdx].mdl = NULL;
}
}
else
{
renderEnts[entIdx].spr = NULL;
renderEnts[entIdx].mdl = NULL;
if (lowerpath.ends_with(".spr"))
{
if (FindPathInAssets(map, fgdClass->sprite, newModelPath))
{
renderEnts[entIdx].spr = AddNewSpriteToRender(newModelPath);
}
else
{
FindPathInAssets(map, fgdClass->sprite, newModelPath, true);
renderEnts[entIdx].spr = NULL;
}
}
else
{
renderEnts[entIdx].spr = NULL;
}
}
}
else
{
FgdClass* fgdClass = g_app->fgd->getFgdClass(ent->keyvalues["classname"]);
if (fgdClass && !fgdClass->model.empty())
{
std::string lowerpath = toLowerCase(fgdClass->model);
std::string newModelPath;
if (lowerpath.ends_with(".mdl"))
{
if (FindPathInAssets(map, fgdClass->model, newModelPath))
{
renderEnts[entIdx].mdl = AddNewModelToRender(newModelPath, body + sequence * 100 + skin * 1000);
renderEnts[entIdx].mdl->UpdateModelMeshList();
}
else
{
FindPathInAssets(map, fgdClass->model, newModelPath, true);
renderEnts[entIdx].mdl = NULL;
}
}
else
{
renderEnts[entIdx].mdl = NULL;
if (lowerpath.ends_with(".spr"))
{
if (FindPathInAssets(map, fgdClass->model, newModelPath))
{
renderEnts[entIdx].spr = AddNewSpriteToRender(newModelPath);
}
else
{
FindPathInAssets(map, fgdClass->model, newModelPath, true);
renderEnts[entIdx].spr = NULL;
}
}
else
{
renderEnts[entIdx].spr = NULL;
}
}
}
}
}
Expand Down

0 comments on commit 326aa12

Please sign in to comment.