Skip to content

Commit

Permalink
misc fixes
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
wootguy committed Apr 25, 2024
1 parent 39edb0c commit 3c2b092
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/bsp/Bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;

Expand All @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions src/editor/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -1680,7 +1681,6 @@ void Gui::drawDebugWidget() {

if (app->pickInfo.valid) {
Bsp* map = app->pickInfo.map;
Entity* ent = app->pickInfo.ent;

if (ImGui::CollapsingHeader("Map", ImGuiTreeNodeFlags_DefaultOpen))
{
Expand Down Expand Up @@ -2580,7 +2580,7 @@ void Gui::drawTransformWidget() {
inputsAreDragging = true;

if (inputsWereDragged && !inputsAreDragging) {
if (app->undoEntityState->getOrigin() != app->pickInfo.ent->getOrigin()) {
if (app->undoEntityState && app->pickInfo.ent && app->undoEntityState->getOrigin() != app->pickInfo.ent->getOrigin()) {
app->pushEntityUndoState("Move Entity");
}

Expand Down

0 comments on commit 3c2b092

Please sign in to comment.