From 9ca8822b66b3c2bd0d5988e9ab1e4e96c89cf5ce Mon Sep 17 00:00:00 2001 From: wootguy Date: Sat, 8 Jun 2024 19:01:10 -0700 Subject: [PATCH] crash fixes - viewing keyvalues for an entity with more than 64 fgd keys - specific click combination when moving an ent for the first time - selecting an entity in a map without VIS data with the debug widget open --- src/bsp/Bsp.cpp | 4 ++++ src/bsp/bsplimits.h | 2 +- src/editor/Gui.cpp | 4 ++-- src/editor/Renderer.cpp | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/bsp/Bsp.cpp b/src/bsp/Bsp.cpp index 32c776fc..1065fc08 100644 --- a/src/bsp/Bsp.cpp +++ b/src/bsp/Bsp.cpp @@ -4448,6 +4448,10 @@ bool Bsp::is_leaf_visible(int ileaf, vec3 pos) { bool isVisible = false; int numVisible = 0; + if (!pvs) { + return true; + } + //logf("leaf %d can see:", ipvsLeaf); for (int lf = 1; lf < leafCount; p++) diff --git a/src/bsp/bsplimits.h b/src/bsp/bsplimits.h index 9c50bb8c..f9b928b5 100644 --- a/src/bsp/bsplimits.h +++ b/src/bsp/bsplimits.h @@ -5,7 +5,7 @@ #define MAXTEXTURENAME 16 #define MIPLEVELS 4 -#define MAX_KEYS_PER_ENT 64 // just guessing +#define MAX_KEYS_PER_ENT 256 // just guessing #define MAX_KEY_LEN 256 // not sure if this includes the null char #define MAX_VAL_LEN 4096 // not sure if this includes the null char diff --git a/src/editor/Gui.cpp b/src/editor/Gui.cpp index 3a330e0e..532d078d 100644 --- a/src/editor/Gui.cpp +++ b/src/editor/Gui.cpp @@ -2124,10 +2124,10 @@ void Gui::drawKeyvalueEditor_SmartEditTab(Entity* ent) { if (fgdClass != NULL) { - static InputData inputData[128]; + static InputData inputData[MAX_KEYS_PER_ENT]; static int lastPickCount = 0; - for (int i = 0; i < fgdClass->keyvalues.size() && i < 128; i++) { + for (int i = 0; i < fgdClass->keyvalues.size() && i < MAX_KEYS_PER_ENT; i++) { KeyvalueDef& keyvalue = fgdClass->keyvalues[i]; string key = keyvalue.name; if (key == "spawnflags") { diff --git a/src/editor/Renderer.cpp b/src/editor/Renderer.cpp index 41365c7d..bc777226 100644 --- a/src/editor/Renderer.cpp +++ b/src/editor/Renderer.cpp @@ -1001,7 +1001,7 @@ void Renderer::cameraPickingControls() { draggingAxis = -1; applyTransform(); - if (pickInfo.valid && pickInfo.ent && undoEntityState->getOrigin() != pickInfo.ent->getOrigin()) { + if (pickInfo.valid && pickInfo.ent && undoEntityState && undoEntityState->getOrigin() != pickInfo.ent->getOrigin()) { pushEntityUndoState("Move Entity"); } }