- removed the obsolete Doomsday 1.8-style texture pack support.

This poorly integrated into the texture system and wasn't compatible with modern texture packs anymore so its usefulness was questionable.
This commit is contained in:
Christoph Oelckers 2020-04-04 12:55:24 +02:00
parent b2a17dfdc2
commit 5490ffcd77
11 changed files with 8 additions and 436 deletions

View file

@ -1048,7 +1048,6 @@ set (PCH_SOURCES
gamedata/textures/formats/tgatexture.cpp
gamedata/textures/formats/stbtexture.cpp
gamedata/textures/hires/hqresize.cpp
gamedata/textures/hires/hirestex.cpp
gamedata/fonts/singlelumpfont.cpp
gamedata/fonts/singlepicfont.cpp
gamedata/fonts/specialfont.cpp

View file

@ -1,414 +0,0 @@
//
//---------------------------------------------------------------------------
//
// Copyright(C) 2005-2016 Christoph Oelckers
// All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/
//
//--------------------------------------------------------------------------
//
/*
** external hires texture management (i.e. Doomsday style texture packs)
**
*/
#ifdef _MSC_VER
#include <io.h>
#else
#include <unistd.h>
#endif
#include "w_wad.h"
#include "m_png.h"
#include "sbar.h"
#include "gi.h"
#include "cmdlib.h"
#include "bitmap.h"
#include "image.h"
#ifndef _WIN32
#define _access(a,b) access(a,b)
#endif
static int Doom2Wad = -1;
// quick'n dirty hack. Should be enough here...
static void SetDoom2Wad()
{
if (Doom2Wad == -1)
{
FString iwad = Wads.GetWadFullName(Wads.GetIwadNum());
iwad.ToLower();
if (iwad.IndexOf("plutonia") >= 0) Doom2Wad = 1;
else if (iwad.IndexOf("tnt") >= 0) Doom2Wad = 2;
else Doom2Wad = 0;
}
}
//==========================================================================
//
// Checks for the presence of a hires texture replacement in a Doomsday style PK3
//
//==========================================================================
int FTexture::CheckDDPK3()
{
static const char * doom1texpath[]= {
"data/jdoom/textures/doom/%s.%s", "data/jdoom/textures/doom-ult/%s.%s", "data/jdoom/textures/doom1/%s.%s", "data/jdoom/textures/%s.%s", NULL };
static const char * doom2texpath[]= {
"data/jdoom/textures/doom2/%s.%s", "data/jdoom/textures/%s.%s", NULL };
static const char * pluttexpath[]= {
"data/jdoom/textures/doom2-plut/%s.%s", "data/jdoom/textures/plutonia/%s.%s", "data/jdoom/textures/%s.%s", NULL };
static const char * tnttexpath[]= {
"data/jdoom/textures/doom2-tnt/%s.%s", "data/jdoom/textures/tnt/%s.%s", "data/jdoom/textures/%s.%s", NULL };
static const char * heretictexpath[]= {
"data/jheretic/textures/%s.%s", NULL };
static const char * hexentexpath[]= {
"data/jhexen/textures/%s.%s", NULL };
static const char * strifetexpath[]= {
"data/jstrife/textures/%s.%s", NULL };
static const char * chextexpath[]= {
"data/jchex/textures/%s.%s", NULL };
static const char * doomflatpath[]= {
"data/jdoom/flats/%s.%s", NULL };
static const char * hereticflatpath[]= {
"data/jheretic/flats/%s.%s", NULL };
static const char * hexenflatpath[]= {
"data/jhexen/flats/%s.%s", NULL };
static const char * strifeflatpath[]= {
"data/jstrife/flats/%s.%s", NULL };
static const char * chexflatpath[]= {
"data/jchex/flats/%s.%s", NULL };
FString checkName;
const char ** checklist;
ETextureType useType=UseType;
if (useType==ETextureType::SkinSprite || useType==ETextureType::Decal || useType==ETextureType::FontChar)
{
return -3;
}
bool ispatch = (useType==ETextureType::MiscPatch || useType==ETextureType::Sprite) ;
// for patches this doesn't work yet
if (ispatch) return -3;
if (!gameinfo.ConfigName.CompareNoCase("Doom"))
{
if (!(gameinfo.flags & GI_MAPxx))
{
checklist = useType==ETextureType::Flat? doomflatpath : doom1texpath;
}
else
{
SetDoom2Wad();
if (Doom2Wad == 1)
checklist = useType==ETextureType::Flat? doomflatpath : pluttexpath;
else if (Doom2Wad == 2)
checklist = useType==ETextureType::Flat? doomflatpath : tnttexpath;
else
checklist = useType==ETextureType::Flat? doomflatpath : doom2texpath;
}
}
else if (!gameinfo.ConfigName.CompareNoCase("Heretic"))
{
checklist = useType==ETextureType::Flat? hereticflatpath : heretictexpath;
}
else if (!gameinfo.ConfigName.CompareNoCase("Hexen"))
{
checklist = useType==ETextureType::Flat? hexenflatpath : hexentexpath;
}
else if (!gameinfo.ConfigName.CompareNoCase("Strife"))
{
checklist = useType==ETextureType::Flat? strifeflatpath : strifetexpath;
}
else if (!gameinfo.ConfigName.CompareNoCase("Chex"))
{
checklist = useType==ETextureType::Flat? chexflatpath : chextexpath;
}
else
return -3;
while (*checklist)
{
static const char * extensions[] = { "PNG", "JPG", "TGA", "PCX", NULL };
for (const char ** extp=extensions; *extp; extp++)
{
checkName.Format(*checklist, Name.GetChars(), *extp);
int lumpnum = Wads.CheckNumForFullName(checkName);
if (lumpnum >= 0) return lumpnum;
}
checklist++;
}
return -3;
}
//==========================================================================
//
// Checks for the presence of a hires texture replacement
//
//==========================================================================
int FTexture::CheckExternalFile(bool & hascolorkey)
{
static const char * doom1texpath[]= {
"%stextures/doom/doom1/%s.%s", "%stextures/doom/doom1/%s-ck.%s",
"%stextures/doom/%s.%s", "%stextures/doom/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL
};
static const char * doom2texpath[]= {
"%stextures/doom/doom2/%s.%s", "%stextures/doom/doom2/%s-ck.%s",
"%stextures/doom/%s.%s", "%stextures/doom/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL
};
static const char * pluttexpath[]= {
"%stextures/doom/plut/%s.%s", "%stextures/doom/plut/%s-ck.%s",
"%stextures/doom/doom2-plut/%s.%s", "%stextures/doom/doom2-plut/%s-ck.%s",
"%stextures/doom/%s.%s", "%stextures/doom/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL
};
static const char * tnttexpath[]= {
"%stextures/doom/tnt/%s.%s", "%stextures/doom/tnt/%s-ck.%s",
"%stextures/doom/doom2-tnt/%s.%s", "%stextures/doom/doom2-tnt/%s-ck.%s",
"%stextures/doom/%s.%s", "%stextures/doom/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL
};
static const char * heretictexpath[]= {
"%stextures/heretic/%s.%s", "%stextures/heretic/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL
};
static const char * hexentexpath[]= {
"%stextures/hexen/%s.%s", "%stextures/hexen/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL
};
static const char * strifetexpath[]= {
"%stextures/strife/%s.%s", "%stextures/strife/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL
};
static const char * chextexpath[]= {
"%stextures/chex/%s.%s", "%stextures/chex/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL
};
static const char * doom1flatpath[]= {
"%sflats/doom/doom1/%s.%s", "%stextures/doom/doom1/flat-%s.%s",
"%sflats/doom/%s.%s", "%stextures/doom/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL
};
static const char * doom2flatpath[]= {
"%sflats/doom/doom2/%s.%s", "%stextures/doom/doom2/flat-%s.%s",
"%sflats/doom/%s.%s", "%stextures/doom/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL
};
static const char * plutflatpath[]= {
"%sflats/doom/plut/%s.%s", "%stextures/doom/plut/flat-%s.%s",
"%sflats/doom/doom2-plut/%s.%s", "%stextures/doom/doom2-plut/flat-%s.%s",
"%sflats/doom/%s.%s", "%stextures/doom/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL
};
static const char * tntflatpath[]= {
"%sflats/doom/tnt/%s.%s", "%stextures/doom/tnt/flat-%s.%s",
"%sflats/doom/doom2-tnt/%s.%s", "%stextures/doom/doom2-tnt/flat-%s.%s",
"%sflats/doom/%s.%s", "%stextures/doom/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL
};
static const char * hereticflatpath[]= {
"%sflats/heretic/%s.%s", "%stextures/heretic/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL
};
static const char * hexenflatpath[]= {
"%sflats/hexen/%s.%s", "%stextures/hexen/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL
};
static const char * strifeflatpath[]= {
"%sflats/strife/%s.%s", "%stextures/strife/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL
};
static const char * chexflatpath[]= {
"%sflats/chex/%s.%s", "%stextures/chex/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL
};
static const char * doom1patchpath[]= {
"%spatches/doom/doom1/%s.%s", "%spatches/doom/%s.%s", "%spatches/%s.%s", NULL
};
static const char * doom2patchpath[]= {
"%spatches/doom/doom2/%s.%s", "%spatches/doom/%s.%s", "%spatches/%s.%s", NULL
};
static const char * plutpatchpath[]= {
"%spatches/doom/plut/%s.%s", "%spatches/doom/%s.%s", "%spatches/%s.%s", NULL
};
static const char * tntpatchpath[]= {
"%spatches/doom/tnt/%s.%s", "%spatches/doom/%s.%s", "%spatches/%s.%s", NULL
};
static const char * hereticpatchpath[]= {
"%spatches/heretic/%s.%s", "%spatches/%s.%s", NULL
};
static const char * hexenpatchpath[]= {
"%spatches/hexen/%s.%s", "%spatches/%s.%s", NULL
};
static const char * strifepatchpath[]= {
"%spatches/strife/%s.%s", "%spatches/%s.%s", NULL
};
static const char * chexpatchpath[]= {
"%spatches/chex/%s.%s", "%spatches/%s.%s", NULL
};
FString checkName;
const char ** checklist;
ETextureType useType = UseType;
if (useType == ETextureType::SkinSprite || useType == ETextureType::Decal || useType == ETextureType::FontChar)
{
return -3;
}
bool ispatch = (useType==ETextureType::MiscPatch || useType==ETextureType::Sprite) ;
// for patches this doesn't work yet
if (ispatch) return -3;
if (!gameinfo.ConfigName.CompareNoCase("Doom"))
{
if (!(gameinfo.flags & GI_MAPxx))
{
checklist = ispatch ? doom1patchpath : useType==ETextureType::Flat? doom1flatpath : doom1texpath;
}
else
{
SetDoom2Wad();
if (Doom2Wad == 1)
checklist = ispatch ? plutpatchpath : useType==ETextureType::Flat? plutflatpath : pluttexpath;
else if (Doom2Wad == 2)
checklist = ispatch ? tntpatchpath : useType==ETextureType::Flat? tntflatpath : tnttexpath;
else
checklist = ispatch ? doom2patchpath : useType==ETextureType::Flat? doom2flatpath : doom2texpath;
}
}
else if (!gameinfo.ConfigName.CompareNoCase("Heretic"))
{
checklist = ispatch ? hereticpatchpath : useType==ETextureType::Flat? hereticflatpath : heretictexpath;
}
else if (!gameinfo.ConfigName.CompareNoCase("Hexen"))
{
checklist = ispatch ? hexenpatchpath : useType==ETextureType::Flat? hexenflatpath : hexentexpath;
}
else if (!gameinfo.ConfigName.CompareNoCase("Strife"))
{
checklist = ispatch ?strifepatchpath : useType==ETextureType::Flat? strifeflatpath : strifetexpath;
}
else if (!gameinfo.ConfigName.CompareNoCase("Chex"))
{
checklist = ispatch ?chexpatchpath : useType==ETextureType::Flat? chexflatpath : chextexpath;
}
else
return -3;
while (*checklist)
{
static const char * extensions[] = { "PNG", "JPG", "TGA", "PCX", NULL };
for (const char ** extp=extensions; *extp; extp++)
{
checkName.Format(*checklist, progdir.GetChars(), Name.GetChars(), *extp);
if (_access(checkName, 0) == 0)
{
hascolorkey = !!strstr(checkName, "-ck.");
return Wads.AddExternalFile(checkName);
}
}
checklist++;
}
return -3;
}
//==========================================================================
//
// Checks for the presence of a hires texture replacement and loads it
//
//==========================================================================
bool FTexture::LoadHiresTexture(FTextureBuffer &texbuffer, bool checkonly)
{
if (HiresLump == -1)
{
bHiresHasColorKey = false;
HiresLump = CheckDDPK3();
if (HiresLump < 0) HiresLump = CheckExternalFile(bHiresHasColorKey);
if (HiresLump >= 0)
{
HiresTexture = FTexture::CreateTexture("", HiresLump, ETextureType::Any);
TexMan.AddTexture(HiresTexture); // let the texture manager manage this.
}
}
if (HiresTexture != nullptr)
{
int w = HiresTexture->GetWidth();
int h = HiresTexture->GetHeight();
if (!checkonly)
{
unsigned char * buffer = new unsigned char[w*(h + 1) * 4];
memset(buffer, 0, w * (h + 1) * 4);
FBitmap bmp(buffer, w * 4, w, h);
int trans;
auto Pixels = HiresTexture->GetBgraBitmap(nullptr, &trans);
bmp.Blit(0, 0, Pixels);
HiresTexture->CheckTrans(buffer, w*h, trans);
if (bHiresHasColorKey)
{
// This is a crappy Doomsday color keyed image
// We have to remove the key manually. :(
uint32_t * dwdata = (uint32_t*)buffer;
for (int i = (w*h); i > 0; i--)
{
if (dwdata[i] == 0xffffff00 || dwdata[i] == 0xffff00ff) dwdata[i] = 0;
}
}
texbuffer.mBuffer = buffer;
}
FContentIdBuilder contentId;
contentId.id = 0;
contentId.imageID = HiresTexture->GetImage()->GetId();
texbuffer.mWidth = w;
texbuffer.mHeight = h;
texbuffer.mContentId = contentId.id;
return true;
}
return false;
}

View file

@ -691,11 +691,6 @@ FTextureBuffer FTexture::CreateTexBuffer(int translation, int flags)
int isTransparent = -1;
bool checkonly = !!(flags & CTF_CheckOnly);
if (flags & CTF_CheckHires)
{
// No image means that this cannot be checked,
if (GetImage() && LoadHiresTexture(result, checkonly)) return result;
}
int exx = !!(flags & CTF_Expand);
W = GetWidth() + 2 * exx;

View file

@ -107,7 +107,6 @@ struct FloatRect
enum ECreateTexBufferFlags
{
CTF_CheckHires = 1, // use external hires replacement if found
CTF_Expand = 2, // create buffer with a one-pixel wide border
CTF_ProcessData = 4, // run postprocessing on the generated buffer. This is only needed when using the data for a hardware texture.
CTF_CheckOnly = 8, // Only runs the code to get a content ID but does not create a texture. Can be used to access a caching system for the hardware textures.
@ -385,8 +384,6 @@ protected:
FTexture *OffsetLess = nullptr;
// Paletted variant
FTexture *PalVersion = nullptr;
// External hires texture
FTexture *HiresTexture = nullptr;
// Material layers
FTexture *Brightmap = nullptr;
FTexture *Normal = nullptr; // Normal map texture
@ -504,8 +501,7 @@ public:
private:
int CheckDDPK3();
int CheckExternalFile(bool & hascolorkey);
bool LoadHiresTexture(FTextureBuffer &texbuffer, bool checkonly);
bool bSWSkyColorDone = false;
PalEntry FloorSkyColor;
PalEntry CeilingSkyColor;

View file

@ -319,8 +319,7 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
int usebright = false;
int maxbound = 0;
// Textures that are already scaled in the texture lump will not get replaced by hires textures.
int flags = mat->isExpanded() ? CTF_Expand : (gl_texture_usehires && !tex->isScaled() && clampmode <= CLAMP_XY) ? CTF_CheckHires : 0;
int flags = mat->isExpanded() ? CTF_Expand : 0;
int numLayers = mat->GetLayers();
auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0, translation));

View file

@ -312,8 +312,7 @@ void OpenGLFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
auto tex = mat->tex;
if (tex->isSWCanvas()) return;
// Textures that are already scaled in the texture lump will not get replaced by hires textures.
int flags = mat->isExpanded() ? CTF_Expand : (gl_texture_usehires && !tex->isScaled()) ? CTF_CheckHires : 0;
int flags = mat->isExpanded() ? CTF_Expand : 0;
int numLayers = mat->GetLayers();
auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0, translation));

View file

@ -538,8 +538,7 @@ void PolyFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
auto tex = mat->tex;
if (tex->isSWCanvas()) return;
// Textures that are already scaled in the texture lump will not get replaced by hires textures.
int flags = mat->isExpanded() ? CTF_Expand : (gl_texture_usehires && !tex->isScaled()) ? CTF_CheckHires : 0;
int flags = mat->isExpanded() ? CTF_Expand : 0;
auto base = static_cast<PolyHardwareTexture*>(mat->GetLayer(0, translation));
base->Precache(mat, translation, flags);

View file

@ -89,8 +89,7 @@ DCanvas *PolyHardwareTexture::GetImage(const FMaterialState &state)
if (tex->isHardwareCanvas()) clampmode = CLAMP_CAMTEX;
else if ((tex->isWarped() || tex->shaderindex >= FIRST_USER_SHADER) && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE;
// Textures that are already scaled in the texture lump will not get replaced by hires textures.
int flags = state.mMaterial->isExpanded() ? CTF_Expand : (gl_texture_usehires && !tex->isScaled() && clampmode <= CLAMP_XY) ? CTF_CheckHires : 0;
int flags = state.mMaterial->isExpanded() ? CTF_Expand : 0;
return GetImage(tex, translation, flags);
}

View file

@ -64,7 +64,7 @@ FSoftwareTexture::FSoftwareTexture(FTexture *tex)
mTexture = tex;
mSource = tex;
mBufferFlags = (gl_texture_usehires && !tex->isScaled() && tex->GetImage() && !tex->isSprite() ) ? CTF_CheckHires|CTF_ProcessData : CTF_ProcessData;
mBufferFlags = CTF_ProcessData;
auto info = tex->CreateTexBuffer(0, CTF_CheckOnly| mBufferFlags);
mPhysicalWidth = info.mWidth;
mPhysicalHeight = info.mHeight;

View file

@ -652,7 +652,7 @@ void VulkanFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
if (tex->isSWCanvas()) return;
// Textures that are already scaled in the texture lump will not get replaced by hires textures.
int flags = mat->isExpanded() ? CTF_Expand : (gl_texture_usehires && !tex->isScaled()) ? CTF_CheckHires : 0;
int flags = mat->isExpanded() ? CTF_Expand : 0;
auto base = static_cast<VkHardwareTexture*>(mat->GetLayer(0, translation));
base->Precache(mat, translation, flags);

View file

@ -132,7 +132,7 @@ VulkanDescriptorSet *VkHardwareTexture::GetDescriptorSet(const FMaterialState &s
else if ((tex->isWarped() || tex->shaderindex >= FIRST_USER_SHADER) && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE;
// Textures that are already scaled in the texture lump will not get replaced by hires textures.
int flags = state.mMaterial->isExpanded() ? CTF_Expand : (gl_texture_usehires && !tex->isScaled() && clampmode <= CLAMP_XY) ? CTF_CheckHires : 0;
int flags = state.mMaterial->isExpanded() ? CTF_Expand : 0;
if (tex->isHardwareCanvas()) static_cast<FCanvasTexture*>(tex)->NeedUpdate();