From 9099bc842075f312f8b5c84603a6703e63e73aff Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 14 Apr 2020 20:45:26 +0200 Subject: [PATCH] - reworking some lower level texture code. --- src/common/engine/serializer.cpp | 9 ++++--- src/common/filesystem/filesystem.cpp | 6 ++--- src/common/filesystem/filesystem.h | 6 ++--- src/common/filesystem/resourcefile.h | 1 - src/common/fonts/v_font.h | 1 + src/common/scripting/jit/jit_move.cpp | 2 +- src/common/scripting/vm/vmexec.h | 2 +- .../textures/multipatchtexturebuilder.cpp | 6 ++--- src/common/textures/texture.cpp | 4 +-- src/common/textures/texturemanager.cpp | 10 +++---- src/common/textures/textures.h | 11 ++++++++ src/d_main.cpp | 2 +- src/playsim/p_sectors.cpp | 4 +-- .../postprocessing/hw_postprocess.cpp | 5 ++-- src/rendering/hwrenderer/scene/hw_bsp.cpp | 2 +- .../hwrenderer/scene/hw_renderhacks.cpp | 4 +-- src/rendering/hwrenderer/scene/hw_sprites.cpp | 2 +- src/rendering/hwrenderer/scene/hw_walls.cpp | 10 +++---- src/rendering/hwrenderer/scene/hw_weapon.cpp | 2 +- .../hwrenderer/textures/hw_precache.cpp | 26 ++++++++++--------- src/scripting/vmthunks.cpp | 22 ++++++++-------- 21 files changed, 76 insertions(+), 61 deletions(-) diff --git a/src/common/engine/serializer.cpp b/src/common/engine/serializer.cpp index ae2f872f9..d500826ed 100644 --- a/src/common/engine/serializer.cpp +++ b/src/common/engine/serializer.cpp @@ -1081,16 +1081,17 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FTextureID &value, FTe } FTextureID chk = value; if (chk.GetIndex() >= TexMan.NumTextures()) chk.SetNull(); - FTexture *pic = TexMan.GetTexture(chk); + auto pic = TexMan.GetGameTexture(chk); const char *name; + auto lump = pic->GetSourceLump(); - if (fileSystem.GetLinkedTexture(pic->SourceLump) == pic) + if (fileSystem.GetLinkedTexture(lump) == pic) { - name = fileSystem.GetFileFullName(pic->SourceLump); + name = fileSystem.GetFileFullName(lump); } else { - name = pic->Name; + name = pic->GetName(); } arc.WriteKey(key); arc.w->StartArray(); diff --git a/src/common/filesystem/filesystem.cpp b/src/common/filesystem/filesystem.cpp index 2bced8429..12b1d197a 100644 --- a/src/common/filesystem/filesystem.cpp +++ b/src/common/filesystem/filesystem.cpp @@ -57,7 +57,7 @@ extern FILE* hashfile; struct FileSystem::LumpRecord { FResourceLump *lump; - FTexture* linkedTexture; + FGameTexture* linkedTexture; LumpShortName shortName; FString longName; int rfnum; @@ -725,7 +725,7 @@ int FileSystem::GetResource (int resid, const char *type, int filenum) const // //========================================================================== -void FileSystem::SetLinkedTexture(int lump, FTexture *tex) +void FileSystem::SetLinkedTexture(int lump, FGameTexture *tex) { if ((size_t)lump < NumEntries) { @@ -739,7 +739,7 @@ void FileSystem::SetLinkedTexture(int lump, FTexture *tex) // //========================================================================== -FTexture *FileSystem::GetLinkedTexture(int lump) +FGameTexture *FileSystem::GetLinkedTexture(int lump) { if ((size_t)lump < NumEntries) { diff --git a/src/common/filesystem/filesystem.h b/src/common/filesystem/filesystem.h index dd5cc8234..a7c38683f 100644 --- a/src/common/filesystem/filesystem.h +++ b/src/common/filesystem/filesystem.h @@ -16,7 +16,7 @@ class FResourceFile; struct FResourceLump; -class FTexture; +class FGameTexture; union LumpShortName { @@ -124,8 +124,8 @@ public: inline int CheckNumForFullName (const FString &name, int wadfile) { return CheckNumForFullName(name.GetChars(), wadfile); } inline int GetNumForFullName (const FString &name) { return GetNumForFullName(name.GetChars()); } - void SetLinkedTexture(int lump, FTexture *tex); - FTexture *GetLinkedTexture(int lump); + void SetLinkedTexture(int lump, FGameTexture *tex); + FGameTexture *GetLinkedTexture(int lump); void ReadFile (int lump, void *dest); diff --git a/src/common/filesystem/resourcefile.h b/src/common/filesystem/resourcefile.h index 224f20811..4d90f3e2f 100644 --- a/src/common/filesystem/resourcefile.h +++ b/src/common/filesystem/resourcefile.h @@ -19,7 +19,6 @@ struct LumpFilterInfo }; class FResourceFile; -class FTexture; // [RH] Namespaces from BOOM. // These are needed here in the low level part so that WAD files can be properly set up. diff --git a/src/common/fonts/v_font.h b/src/common/fonts/v_font.h index b4d2c753b..ab20edf76 100644 --- a/src/common/fonts/v_font.h +++ b/src/common/fonts/v_font.h @@ -39,6 +39,7 @@ #include "name.h" class DCanvas; +class FTexture; class FGameTexture; struct FRemapTable; diff --git a/src/common/scripting/jit/jit_move.cpp b/src/common/scripting/jit/jit_move.cpp index 584de35a1..a02898ac0 100644 --- a/src/common/scripting/jit/jit_move.cpp +++ b/src/common/scripting/jit/jit_move.cpp @@ -53,7 +53,7 @@ static void CastCo2S(FString *a, int b) { PalEntry c(b); a->Format("%02x %02x %0 static int CastS2So(FString *b) { return FSoundID(*b); } static void CastSo2S(FString* a, int b) { *a = soundEngine->GetSoundName(b); } static void CastSID2S(FString* a, unsigned int b) { VM_CastSpriteIDToString(a, b); } -static void CastTID2S(FString *a, int b) { auto tex = TexMan.GetTexture(*(FTextureID*)&b); *a = (tex == nullptr) ? "(null)" : tex->GetName().GetChars(); } +static void CastTID2S(FString *a, int b) { auto tex = TexMan.GetGameTexture(*(FTextureID*)&b); *a = (tex == nullptr) ? "(null)" : tex->GetName().GetChars(); } void JitCompiler::EmitCAST() { diff --git a/src/common/scripting/vm/vmexec.h b/src/common/scripting/vm/vmexec.h index 72e0d0199..d88945a44 100644 --- a/src/common/scripting/vm/vmexec.h +++ b/src/common/scripting/vm/vmexec.h @@ -1848,7 +1848,7 @@ static void DoCast(const VMRegisters ®, const VMFrame *f, int a, int b, int c case CAST_TID2S: { ASSERTS(a); ASSERTD(b); - auto tex = TexMan.GetTexture(*(FTextureID*)&(reg.d[b])); + auto tex = TexMan.GetGameTexture(*(FTextureID*)&(reg.d[b])); reg.s[a] = tex == nullptr ? "(null)" : tex->GetName().GetChars(); break; } diff --git a/src/common/textures/multipatchtexturebuilder.cpp b/src/common/textures/multipatchtexturebuilder.cpp index 3380968b0..b627bacac 100644 --- a/src/common/textures/multipatchtexturebuilder.cpp +++ b/src/common/textures/multipatchtexturebuilder.cpp @@ -356,7 +356,7 @@ void FMultipatchTextureBuilder::AddTexturesLump(const void *lumpdata, int lumpsi // It still needs to be created in case someone uses it by name. offset = LittleLong(directory[1]); const maptexture_t *tex = (const maptexture_t *)((const uint8_t *)maptex + offset); - FTexture *tex0 = TexMan.ByIndex(0); + auto tex0 = TexMan.GameByIndex(0); tex0->SetSize(SAFESHORT(tex->width), SAFESHORT(tex->height)); } @@ -373,7 +373,7 @@ void FMultipatchTextureBuilder::AddTexturesLump(const void *lumpdata, int lumpsi int j; for (j = (int)TexMan.NumTextures() - 1; j >= firstdup; --j) { - if (strnicmp(TexMan.ByIndex(j)->GetName(), (const char *)maptex + offset, 8) == 0) + if (strnicmp(TexMan.GameByIndex(j)->GetName(), (const char *)maptex + offset, 8) == 0) break; } if (j + 1 == firstdup) @@ -780,7 +780,7 @@ void FMultipatchTextureBuilder::ResolvePatches(BuildInfo &buildinfo) TexMan.ListTextures(buildinfo.Inits[i].TexName, list, true); for (int i = list.Size() - 1; i >= 0; i--) { - if (list[i] != buildinfo.tex->id && !TexMan.GetTexture(list[i])->bMultiPatch) + if (list[i] != buildinfo.tex->id && !TexMan.GetGameTexture(list[i])->isMultiPatch() ) { texno = list[i]; break; diff --git a/src/common/textures/texture.cpp b/src/common/textures/texture.cpp index eeed137ea..57ee44c57 100644 --- a/src/common/textures/texture.cpp +++ b/src/common/textures/texture.cpp @@ -148,8 +148,8 @@ FTexture::FTexture (const char *name, int lumpnum) FTexture::~FTexture () { - FTexture *link = fileSystem.GetLinkedTexture(SourceLump); - if (link == this) fileSystem.SetLinkedTexture(SourceLump, nullptr); + FGameTexture *link = fileSystem.GetLinkedTexture(SourceLump); + if (link->GetTexture() == this) fileSystem.SetLinkedTexture(SourceLump, nullptr); if (areas != nullptr) delete[] areas; areas = nullptr; diff --git a/src/common/textures/texturemanager.cpp b/src/common/textures/texturemanager.cpp index 834f9de48..62eac65c2 100644 --- a/src/common/textures/texturemanager.cpp +++ b/src/common/textures/texturemanager.cpp @@ -220,20 +220,20 @@ FTextureID FTextureManager::CheckForTexture (const char *name, ETextureType uset // Any graphic being placed in the zip's root directory can not be found by this. if (strchr(name, '/')) { - FTexture *const NO_TEXTURE = (FTexture*)-1; + FGameTexture *const NO_TEXTURE = (FGameTexture*)-1; int lump = fileSystem.CheckNumForFullName(name); if (lump >= 0) { - FTexture *tex = fileSystem.GetLinkedTexture(lump); + FGameTexture *tex = fileSystem.GetLinkedTexture(lump); if (tex == NO_TEXTURE) return FTextureID(-1); - if (tex != NULL) return tex->id; + if (tex != NULL) return tex->GetID(); if (flags & TEXMAN_DontCreate) return FTextureID(-1); // we only want to check, there's no need to create a texture if we don't have one yet. - tex = FTexture::CreateTexture("", lump, ETextureType::Override); + tex = reinterpret_cast(FTexture::CreateTexture("", lump, ETextureType::Override)); if (tex != NULL) { tex->AddAutoMaterials(); fileSystem.SetLinkedTexture(lump, tex); - return AddTexture(tex); + return AddTexture(tex->GetTexture()); } else { diff --git a/src/common/textures/textures.h b/src/common/textures/textures.h index 0127e9eff..efa45ec75 100644 --- a/src/common/textures/textures.h +++ b/src/common/textures/textures.h @@ -618,11 +618,13 @@ public: bool isHardwareCanvas() const { return wrapped.isHardwareCanvas(); } // There's two here so that this can deal with software canvases in the hardware renderer later. bool isSoftwareCanvas() const { return wrapped.isCanvas(); } bool isMiscPatch() const { return wrapped.GetUseType() == ETextureType::MiscPatch; } // only used by the intermission screen to decide whether to tile the background image or not. + bool isMultiPatch() const { return wrapped.bMultiPatch; } bool isFullbrightDisabled() const { return wrapped.isFullbrightDisabled(); } bool useWorldPanning() const { return wrapped.UseWorldPanning(); } bool allowNoDecals() const { return wrapped.allowNoDecals(); } void SetTranslucent(bool on) { wrapped.bTranslucent = on; } ETextureType GetUseType() const { return wrapped.GetUseType(); } + void SetUseType(ETextureType type) { wrapped.SetUseType(type); } float GetShaderSpeed() const { return wrapped.GetShaderSpeed(); } uint16_t GetRotations() const { return wrapped.GetRotations(); } void SetRotations(int index) { wrapped.SetRotations(index); } @@ -651,6 +653,10 @@ public: } } + void CopySize(FGameTexture* BaseTexture) + { + wrapped.CopySize(&BaseTexture->wrapped); + } // These substitutions must be done on the material level because their sizes can differ. Substitution must happen before any coordinate calculations take place. FGameTexture* GetPalVersion() { return reinterpret_cast(wrapped.GetPalVersion()); } @@ -669,6 +675,11 @@ public: void SetGlowing(PalEntry color) { auto tex = GetTexture(); tex->bAutoGlowing = false; tex->bGlowing = true; tex->GlowColor = color; } bool isUserContent() const; + void AddAutoMaterials() { wrapped.AddAutoMaterials(); } + int CheckRealHeight() { return wrapped.CheckRealHeight(); } + bool isSkybox() const { return wrapped.isSkybox(); } + void SetSize(int x, int y) { wrapped.SetSize(x, y); } + }; diff --git a/src/d_main.cpp b/src/d_main.cpp index 554ad1a8e..90b94f770 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2642,7 +2642,7 @@ static void PatchTextures() FTextureID tex = TexMan.CheckForTexture("BLANK", ETextureType::Wall, false); if (tex.Exists()) { - auto texture = TexMan.GetTexture(tex, false); + auto texture = TexMan.GetGameTexture(tex, false); texture->SetUseType(ETextureType::Null); } } diff --git a/src/playsim/p_sectors.cpp b/src/playsim/p_sectors.cpp index ae967d2c0..448808265 100644 --- a/src/playsim/p_sectors.cpp +++ b/src/playsim/p_sectors.cpp @@ -513,7 +513,7 @@ double FindShortestTextureAround (sector_t *sec) CheckShortestTex (sec->Level, check->sidedef[1]->GetTexture(side_t::bottom), minsize); } } - return minsize < FLT_MAX ? minsize : TexMan.ByIndex(0)->GetDisplayHeight(); + return minsize < FLT_MAX ? minsize : TexMan.GameByIndex(0)->GetDisplayHeight(); } // @@ -538,7 +538,7 @@ double FindShortestUpperAround (sector_t *sec) CheckShortestTex (sec->Level, check->sidedef[1]->GetTexture(side_t::top), minsize); } } - return minsize < FLT_MAX ? minsize : TexMan.ByIndex(0)->GetDisplayHeight(); + return minsize < FLT_MAX ? minsize : TexMan.GameByIndex(0)->GetDisplayHeight(); } // diff --git a/src/rendering/hwrenderer/postprocessing/hw_postprocess.cpp b/src/rendering/hwrenderer/postprocessing/hw_postprocess.cpp index 9d80fc46c..c8a32f30f 100644 --- a/src/rendering/hwrenderer/postprocessing/hw_postprocess.cpp +++ b/src/rendering/hwrenderer/postprocessing/hw_postprocess.cpp @@ -1000,14 +1000,15 @@ void PPCustomShaderInstance::SetTextures(PPRenderState *renderstate) while (it.NextPair(pair)) { FString name = pair->Value; - FTexture *tex = TexMan.GetTexture(TexMan.CheckForTexture(name, ETextureType::Any), true); - if (tex && tex->isValid()) + auto gtex = TexMan.GetGameTexture(TexMan.CheckForTexture(name, ETextureType::Any), true); + if (gtex && gtex->isValid()) { // Why does this completely circumvent the normal way of handling textures? // This absolutely needs fixing because it will also circumvent any potential caching system that may get implemented. // // To do: fix the above problem by adding PPRenderState::SetInput(FTexture *tex) + auto tex = gtex->GetTexture(); auto &pptex = Textures[tex]; if (!pptex) { diff --git a/src/rendering/hwrenderer/scene/hw_bsp.cpp b/src/rendering/hwrenderer/scene/hw_bsp.cpp index 9c89689b6..d2ce57e4d 100644 --- a/src/rendering/hwrenderer/scene/hw_bsp.cpp +++ b/src/rendering/hwrenderer/scene/hw_bsp.cpp @@ -289,7 +289,7 @@ void HWDrawInfo::AddLine (seg_t *seg, bool portalclip) { if (!seg->linedef->isVisualPortal()) { - FTexture * tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::mid), true); + auto tex = TexMan.GetGameTexture(seg->sidedef->GetTexture(side_t::mid), true); if (!tex || !tex->isValid()) { // nothing to do here! diff --git a/src/rendering/hwrenderer/scene/hw_renderhacks.cpp b/src/rendering/hwrenderer/scene/hw_renderhacks.cpp index 45f48bf0f..6ebdab3f8 100644 --- a/src/rendering/hwrenderer/scene/hw_renderhacks.cpp +++ b/src/rendering/hwrenderer/scene/hw_renderhacks.cpp @@ -351,7 +351,7 @@ bool HWDrawInfo::DoOneSectorUpper(subsector_t * subsec, float Planez, area_t in_ if (sec->GetPlaneTexZ(sector_t::ceiling) == Planez) { // If there's a texture abort - FTexture * tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::top)); + auto tex = TexMan.GetGameTexture(seg->sidedef->GetTexture(side_t::top)); if (!tex || !tex->isValid()) continue; else return false; } @@ -409,7 +409,7 @@ bool HWDrawInfo::DoOneSectorLower(subsector_t * subsec, float Planez, area_t in_ if (sec->GetPlaneTexZ(sector_t::floor) == Planez) { // If there's a texture abort - FTexture * tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::bottom)); + auto tex = TexMan.GetGameTexture(seg->sidedef->GetTexture(side_t::bottom)); if (!tex || !tex->isValid()) continue; else return false; } diff --git a/src/rendering/hwrenderer/scene/hw_sprites.cpp b/src/rendering/hwrenderer/scene/hw_sprites.cpp index fb96034ed..4d6a2bc1e 100644 --- a/src/rendering/hwrenderer/scene/hw_sprites.cpp +++ b/src/rendering/hwrenderer/scene/hw_sprites.cpp @@ -793,7 +793,7 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t if (isPicnumOverride) { // Animate picnum overrides. - auto tex = TexMan.GetTexture(thing->picnum, true); + auto tex = TexMan.GetGameTexture(thing->picnum, true); if (tex == nullptr) return; patch = tex->GetID(); mirror = false; diff --git a/src/rendering/hwrenderer/scene/hw_walls.cpp b/src/rendering/hwrenderer/scene/hw_walls.cpp index 1249a13ce..9b0a5f177 100644 --- a/src/rendering/hwrenderer/scene/hw_walls.cpp +++ b/src/rendering/hwrenderer/scene/hw_walls.cpp @@ -1238,7 +1238,7 @@ void HWWall::DoMidTexture(HWDrawInfo *di, seg_t * seg, bool drawfogboundary, // Set up the top // // - FTexture * tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::top), true); + auto tex = TexMan.GetGameTexture(seg->sidedef->GetTexture(side_t::top), true); if (!tex || !tex->isValid()) { if (front->GetTexture(sector_t::ceiling) == skyflatnum && @@ -1274,7 +1274,7 @@ void HWWall::DoMidTexture(HWDrawInfo *di, seg_t * seg, bool drawfogboundary, // Set up the bottom // // - tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::bottom), true); + tex = TexMan.GetGameTexture(seg->sidedef->GetTexture(side_t::bottom), true); if (!tex || !tex->isValid()) { // texture is missing - use the lower plane @@ -1543,7 +1543,7 @@ void HWWall::BuildFFBlock(HWDrawInfo *di, seg_t * seg, F3DFloor * rover, if (rover->flags&FF_UPPERTEXTURE) { gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::top), false, true); - if (!gltexture) return; + if (!gltexture) return; GetTexCoordInfo(gltexture, &tci, seg->sidedef, side_t::top); } else if (rover->flags&FF_LOWERTEXTURE) @@ -2073,14 +2073,14 @@ void HWWall::Process(HWDrawInfo *di, seg_t *seg, sector_t * frontsector, sector_ sector_t *backsec = isportal? seg->linedef->getPortalDestination()->frontsector : backsector; bool drawfogboundary = !di->isFullbrightScene() && di->CheckFog(frontsector, backsec); - FTexture *tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::mid), true); + auto tex = TexMan.GetGameTexture(seg->sidedef->GetTexture(side_t::mid), true); if (tex != NULL) { if (di->Level->i_compatflags & COMPATF_MASKEDMIDTEX) { tex = tex->GetRawTexture(); } - gltexture = FMaterial::ValidateTexture(tex, false); + gltexture = FMaterial::ValidateTexture(tex->GetTexture(), false); } else gltexture = NULL; diff --git a/src/rendering/hwrenderer/scene/hw_weapon.cpp b/src/rendering/hwrenderer/scene/hw_weapon.cpp index 09881c100..d8cabda51 100644 --- a/src/rendering/hwrenderer/scene/hw_weapon.cpp +++ b/src/rendering/hwrenderer/scene/hw_weapon.cpp @@ -141,7 +141,7 @@ static bool isBright(DPSprite *psp) FTextureID lump = sprites[psp->GetSprite()].GetSpriteFrame(psp->GetFrame(), 0, 0., nullptr); if (lump.isValid()) { - FTexture * tex = TexMan.GetTexture(lump, true); + auto tex = TexMan.GetGameTexture(lump, true); if (tex) disablefullbright = tex->isFullbrightDisabled(); } return psp->GetState()->GetFullbright() && !disablefullbright; diff --git a/src/rendering/hwrenderer/textures/hw_precache.cpp b/src/rendering/hwrenderer/textures/hw_precache.cpp index 9711fe74a..2c442e894 100644 --- a/src/rendering/hwrenderer/textures/hw_precache.cpp +++ b/src/rendering/hwrenderer/textures/hw_precache.cpp @@ -103,10 +103,10 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap &actorhitl // HIT_Wall must be checked for MBF-style sky transfers. if (texhitlist[i] & (FTextureManager::HIT_Sky | FTextureManager::HIT_Wall)) { - FTexture *tex = TexMan.ByIndex(i); + auto tex = TexMan.GameByIndex(i); if (tex->isSkybox()) { - FSkyBox *sb = static_cast(tex); + FSkyBox *sb = static_cast(tex->GetTexture()); for (int i = 0; i<6; i++) { if (sb->faces[i]) @@ -193,12 +193,12 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap &actorhitl // prepare the textures for precaching. First collect all used layer textures so that we know which ones should not be deleted. for (int i = cnt - 1; i >= 0; i--) { - FTexture *tex = TexMan.ByIndex(i); + auto tex = TexMan.GameByIndex(i); if (tex != nullptr) { if (texhitlist[i] & (FTextureManager::HIT_Wall | FTextureManager::HIT_Flat | FTextureManager::HIT_Sky)) { - FMaterial* mat = FMaterial::ValidateTexture(tex, false, false); + FMaterial* mat = FMaterial::ValidateTexture(tex->GetTexture(), false, false); if (mat != nullptr) { for (auto ftex : mat->GetLayerArray()) @@ -209,7 +209,7 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap &actorhitl } if (spritehitlist[i] != nullptr && (*spritehitlist[i]).CountUsed() > 0) { - FMaterial *mat = FMaterial::ValidateTexture(tex, true, false); + FMaterial *mat = FMaterial::ValidateTexture(tex->GetTexture(), true, false); if (mat != nullptr) { for (auto ftex : mat->GetLayerArray()) @@ -224,16 +224,16 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap &actorhitl // delete unused textures (i.e. those which didn't get referenced by any material in the cache list. for (int i = cnt - 1; i >= 0; i--) { - FTexture *tex = TexMan.ByIndex(i); + auto tex = TexMan.GameByIndex(i); if (tex != nullptr && tex->GetUseType() != ETextureType::FontChar) { - if (usedTextures.CheckKey(tex) == nullptr) + if (usedTextures.CheckKey(tex->GetTexture()) == nullptr) { - tex->CleanHardwareTextures(true, false); + tex->GetTexture()->CleanHardwareTextures(true, false); } - if (usedSprites.CheckKey(tex) == nullptr) + if (usedSprites.CheckKey(tex->GetTexture()) == nullptr) { - tex->CleanHardwareTextures(false, true); + tex->GetTexture()->CleanHardwareTextures(false, true); } } } @@ -249,7 +249,8 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap &actorhitl // cache all used textures for (int i = cnt - 1; i >= 0; i--) { - FTexture *tex = TexMan.ByIndex(i); + auto gtex = TexMan.GameByIndex(i); + auto tex = gtex->GetTexture(); if (tex != nullptr && tex->GetImage() != nullptr) { if (texhitlist[i] & (FTextureManager::HIT_Wall | FTextureManager::HIT_Flat | FTextureManager::HIT_Sky)) @@ -271,7 +272,8 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap &actorhitl // cache all used textures for (int i = cnt - 1; i >= 0; i--) { - FTexture *tex = TexMan.ByIndex(i); + auto gtex = TexMan.GameByIndex(i); + auto tex = gtex->GetTexture(); if (tex != nullptr) { PrecacheTexture(tex, texhitlist[i]); diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index 02394188f..497feba3e 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -1630,7 +1630,7 @@ DEFINE_ACTION_FUNCTION(_TexMan, GetName) { PARAM_PROLOGUE; PARAM_INT(texid); - auto tex = TexMan.ByIndex(texid); + auto tex = TexMan.GameByIndex(texid); FString retval; if (tex != nullptr) @@ -1655,12 +1655,12 @@ DEFINE_ACTION_FUNCTION(_TexMan, GetName) static int GetTextureSize(int texid, int* py) { - auto tex = TexMan.ByIndex(texid); + auto tex = TexMan.GameByIndex(texid); int x, y; if (tex != nullptr) { - x = tex->GetDisplayWidth(); - y = tex->GetDisplayHeight(); + x = int(0.5 + tex->GetDisplayWidth()); + y = int(0.5 + tex->GetDisplayHeight()); } else x = y = -1; if (py) *py = y; @@ -1685,12 +1685,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, GetSize, GetTextureSize) //========================================================================== static void GetScaledSize(int texid, DVector2* pvec) { - auto tex = TexMan.ByIndex(texid); + auto tex = TexMan.GameByIndex(texid); double x, y; if (tex != nullptr) { - x = tex->GetDisplayWidthDouble(); - y = tex->GetDisplayHeightDouble(); + x = tex->GetDisplayWidth(); + y = tex->GetDisplayHeight(); } else x = y = -1; if (pvec) @@ -1716,12 +1716,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, GetScaledSize, GetScaledSize) //========================================================================== static void GetScaledOffset(int texid, DVector2* pvec) { - auto tex = TexMan.ByIndex(texid); + auto tex = TexMan.GameByIndex(texid); double x, y; if (tex != nullptr) { - x = tex->GetDisplayLeftOffsetDouble(); - y = tex->GetDisplayTopOffsetDouble(); + x = tex->GetDisplayLeftOffset(); + y = tex->GetDisplayTopOffset(); } else x = y = -1; if (pvec) @@ -1748,7 +1748,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, GetScaledOffset, GetScaledOffset) static int CheckRealHeight(int texid) { - auto tex = TexMan.ByIndex(texid); + auto tex = TexMan.GameByIndex(texid); if (tex != nullptr) return tex->CheckRealHeight(); else return -1; }