Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
- fix texture color count not copied during downscale
- fix map name not updated after doing Save As
  • Loading branch information
wootguy committed Apr 25, 2024
1 parent 39edb0c commit 76e3be6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 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
1 change: 1 addition & 0 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

0 comments on commit 76e3be6

Please sign in to comment.