Skip to content

Commit

Permalink
Fix .mdl viewer, fix .mdl crash when open bad file
Browse files Browse the repository at this point in the history
Fix .mdl viewer, fix .mdl open crash
  • Loading branch information
UnrealKaraulov committed Dec 4, 2023
1 parent 3920a01 commit 4cb5425
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/editor/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ void Renderer::renderLoop()
bspShader->bind();
bspShader->modelMat->loadIdentity();
bspShader->updateMatrixes();
SelectedMap->mdl->DrawModel(0);
SelectedMap->mdl->DrawModel();
continue;
}

Expand Down
9 changes: 3 additions & 6 deletions src/gl/shaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,12 @@ namespace Shaders
" gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); \n"
" return;\n"
" }\n"
" }\n"*/
" }\n"
" if (fcolor.g == 6.0)\n"
" {\n"
" color.rgb = color.rgb * fcolor.a;\n"
" }\n"
" if (fcolor.g > 1.0)\n"
" {\n"
" fcolor.g = 1.0;"
" }\n"
" fcolor.g = 1.0;\n"
" }\n"*/
" vec3 lightmap = texture2D(sLightmapTex0, fLightmapTex0.xy).rgb * fLightmapTex0.z;\n"
" lightmap += texture2D(sLightmapTex1, fLightmapTex1.xy).rgb * fLightmapTex1.z;\n"
" lightmap += texture2D(sLightmapTex2, fLightmapTex2.xy).rgb * fLightmapTex2.z;\n"
Expand Down
2 changes: 1 addition & 1 deletion src/mdl/mdl_studio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@ int StudioModel::SetBodygroup(int iGroup, int iValue)

int StudioModel::SetSkin(int iValue)
{
if (iValue < m_pstudiohdr->numskinfamilies)
if (!m_pstudiohdr || iValue < m_pstudiohdr->numskinfamilies)
{
return m_skinnum;
}
Expand Down
2 changes: 1 addition & 1 deletion vs-project/bspguy.vcxproj.user
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerCommandArguments>"d:\SteamLibrary\steamapps\common\Half-Life\valve\maps\c1a0c.bsp"</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>"d:\SteamLibrary\steamapps\common\Half-Life\cstrike\models\hostage03.mdl"</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugGithub|x64'">
Expand Down

0 comments on commit 4cb5425

Please sign in to comment.