From 29399c9be12edf9d4af24a71574054aae1ca9524 Mon Sep 17 00:00:00 2001 From: Unreal Karaulov Date: Sat, 3 Feb 2024 19:43:24 +0300 Subject: [PATCH] crash fix --- src/editor/BspRenderer.cpp | 2 +- src/editor/Gui.cpp | 5 ++++- vs-project/bspguy.vcxproj | 4 ++-- vs-project/fmt/fmt.vcxproj | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/editor/BspRenderer.cpp b/src/editor/BspRenderer.cpp index a8fb38ee..4de71b53 100644 --- a/src/editor/BspRenderer.cpp +++ b/src/editor/BspRenderer.cpp @@ -982,7 +982,7 @@ int BspRenderer::refreshModel(int modelIdx, bool refreshClipnodes, bool noTriang verts[e].g = 0.0f; } verts[e].b = 0.0f; - verts[e].a = isSky || isTrigger || ent->rendermode == 5 ? 1.0f - opacity : 0.0f; + verts[e].a = isSky || isTrigger || ( ent && ent->rendermode == 5 ) ? 1.0f - opacity : 0.0f; // texture coords float tw = 1.0f; diff --git a/src/editor/Gui.cpp b/src/editor/Gui.cpp index 60aa22a3..f8b83050 100644 --- a/src/editor/Gui.cpp +++ b/src/editor/Gui.cpp @@ -2697,11 +2697,13 @@ void Gui::drawMenuBar() std::vector newVertIndexes; size_t newVertCount = map->vertCount + mesh.buffer->numVerts; + vec3* newverts = new vec3[newVertCount]; + memcpy(newverts, map->verts, map->vertCount * sizeof(vec3)); + std::vector newuv; newuv.resize(newVertCount); - memcpy(newverts, map->verts, map->vertCount * sizeof(vec3)); int v = 0; for (v = map->vertCount; v < newVertCount; v++) @@ -2867,6 +2869,7 @@ void Gui::drawMenuBar() vertexes.push_back(vertex1); vertexes.push_back(vertex2); vertexes.push_back(vertex3); + // Texture coordinates std::vector uvs{}; uvs.push_back(newsurfedges[firstEdge] > 0 ? newuv[newedges[abs(newsurfedges[firstEdge])].iVertex[0]] diff --git a/vs-project/bspguy.vcxproj b/vs-project/bspguy.vcxproj index 61b7cbe3..54f46870 100644 --- a/vs-project/bspguy.vcxproj +++ b/vs-project/bspguy.vcxproj @@ -101,7 +101,7 @@ .\..\src;.\..\src\bsp;.\..\src\cli;.\..\src\data;.\..\src\editor;.\..\src\filedialog;.\..\src\gl;.\..\src\qtools;.\..\src\util;.\..\src\mdl;.\..\imgui;.\..\imgui\examples;.\..\imgui\backends;.\..\imgui\misc\cpp;.\..\glew\include;.\..\glfw\include;.\..\fmt\include;%(AdditionalIncludeDirectories) $(IntDir) EnableFastChecks - EditAndContinue + ProgramDatabase 4244;4018 Sync Disabled @@ -162,7 +162,7 @@ false true - true + false false diff --git a/vs-project/fmt/fmt.vcxproj b/vs-project/fmt/fmt.vcxproj index 6d49c4dd..5d32d7f0 100644 --- a/vs-project/fmt/fmt.vcxproj +++ b/vs-project/fmt/fmt.vcxproj @@ -87,7 +87,7 @@ .\..\..\src;.\..\..\src\bsp;.\..\..\src\cli;.\..\..\src\data;.\..\..\src\editor;.\..\..\src\filedialog;.\..\..\src\gl;.\..\..\src\qtools;.\..\..\src\util;.\..\..\src\mdl;.\..\..\imgui;.\..\..\imgui\examples;.\..\..\imgui\misc\cpp;.\..\..\imgui\backends;.\..\..\fmt;.\..\..\fmt\include;.\..\..\glew\include;%(AdditionalIncludeDirectories) $(IntDir) EnableFastChecks - EditAndContinue + ProgramDatabase Sync Disabled Disabled