From 72bdc57b259630ad37bc7da8a45865ed03456566 Mon Sep 17 00:00:00 2001 From: wootguy Date: Thu, 25 Apr 2024 01:46:08 -0700 Subject: [PATCH] misc fixes - the RAD compiler would not run if the map textures did not have the palette color count correct (even though it's always 256) - fix map name not updated after doing Save As - fix transformation crash --- src/bsp/Bsp.cpp | 7 ++++--- src/editor/Gui.cpp | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/bsp/Bsp.cpp b/src/bsp/Bsp.cpp index 5a62b0a2..7eb6adfe 100644 --- a/src/bsp/Bsp.cpp +++ b/src/bsp/Bsp.cpp @@ -2721,7 +2721,7 @@ bool Bsp::downscale_texture(int textureId, int newWidth, int newHeight) { int lastMipSize = (oldWidth >> 3) * (oldHeight >> 3); byte* pixels = (byte*)(textures + texOffset + tex.nOffsets[0]); - byte* palette = (byte*)(textures + texOffset + tex.nOffsets[3] + lastMipSize + 2); + byte* palette = (byte*)(textures + texOffset + tex.nOffsets[3] + lastMipSize); int oldWidths[4]; int oldHeights[4]; @@ -2741,7 +2741,7 @@ bool Bsp::downscale_texture(int textureId, int newWidth, int newHeight) { newOffset[i] = sizeof(BSPMIPTEX); } } - byte* newPalette = (byte*)(textures + texOffset + newOffset[3] + newWidths[3] * newHeights[3] + 2); + byte* newPalette = (byte*)(textures + texOffset + newOffset[3] + newWidths[3] * newHeights[3]); float srcScale = (float)oldWidth / tex.nWidth; @@ -2761,7 +2761,8 @@ bool Bsp::downscale_texture(int textureId, int newWidth, int newHeight) { } } } - memcpy(newPalette, palette, 256 * sizeof(COLOR3)); + // 2 = palette color count (should always be 256) + memcpy(newPalette, palette, 256 * sizeof(COLOR3) + 2); for (int i = 0; i < 4; i++) { tex.nOffsets[i] = newOffset[i]; diff --git a/src/editor/Gui.cpp b/src/editor/Gui.cpp index b9a607cb..6a48f403 100644 --- a/src/editor/Gui.cpp +++ b/src/editor/Gui.cpp @@ -702,6 +702,7 @@ void Gui::drawMenuBar() { if (fname) { map->update_ent_lump(); map->path = fname; + map->name = stripExt(basename(fname)); map->write(map->path); } } @@ -2580,7 +2581,7 @@ void Gui::drawTransformWidget() { inputsAreDragging = true; if (inputsWereDragged && !inputsAreDragging) { - if (app->undoEntityState->getOrigin() != app->pickInfo.ent->getOrigin()) { + if (app->undoEntityState && app->undoEntityState->getOrigin() != app->pickInfo.ent->getOrigin()) { app->pushEntityUndoState("Move Entity"); }