Skip to content

Commit

Permalink
- fixed: The multipatch texture builder may not store the texture IDs…
Browse files Browse the repository at this point in the history
… on assignment.

Between creation and resolving the texture manager will resort the textures and after that the old ids are no longer valid. The textures themselves have the correct one, so that should be used.
  • Loading branch information
coelckers committed Dec 14, 2018
1 parent 1e84433 commit bd6ba47
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/textures/formats/multipatchtexture.h
Expand Up @@ -86,7 +86,6 @@ struct BuildInfo
bool bNoDecals = false;
int LeftOffset[2] = {};
int TopOffset[2] = {};
FTextureID id = {};
FImageTexture *tex = nullptr;
};

Expand Down
11 changes: 5 additions & 6 deletions src/textures/multipatchtexturebuilder.cpp
Expand Up @@ -160,7 +160,6 @@ void FMultipatchTextureBuilder::MakeTexture(BuildInfo &buildinfo, ETextureType u
tex->bWorldPanning = buildinfo.bWorldPanning;
tex->bNoDecals = buildinfo.bNoDecals;
tex->SourceLump = buildinfo.DefinitionLump;
buildinfo.id = TexMan.AddTexture(tex);
buildinfo.tex = tex;
}

Expand Down Expand Up @@ -833,19 +832,19 @@ void FMultipatchTextureBuilder::ResolvePatches(BuildInfo &buildinfo)
for (unsigned i = 0; i < buildinfo.Inits.Size(); i++)
{
FTextureID texno = TexMan.CheckForTexture(buildinfo.Inits[i].TexName, buildinfo.Inits[i].UseType);
if (texno == buildinfo.id) // we found ourselves. Try looking for another one with the same name which is not a multipatch texture itself.
if (texno == buildinfo.tex->id) // we found ourselves. Try looking for another one with the same name which is not a multipatch texture itself.
{
TArray<FTextureID> list;
TexMan.ListTextures(buildinfo.Inits[i].TexName, list, true);
for (int i = list.Size() - 1; i >= 0; i--)
{
if (list[i] != buildinfo.id && !TexMan.GetTexture(list[i])->bMultiPatch)
if (list[i] != buildinfo.tex->id && !TexMan.GetTexture(list[i])->bMultiPatch)
{
texno = list[i];
break;
}
}
if (texno == buildinfo.id)
if (texno == buildinfo.tex->id)
{
if (buildinfo.Inits[i].HasLine) buildinfo.Inits[i].sc.Message(MSG_WARNING, "Texture '%s' references itself as patch\n", buildinfo.Inits[i].TexName.GetChars());
else Printf(TEXTCOLOR_YELLOW "Texture '%s' references itself as patch\n", buildinfo.Inits[i].TexName.GetChars());
Expand Down Expand Up @@ -964,10 +963,10 @@ void FMultipatchTextureBuilder::ResolveAllPatches()
}
if (!donesomething)
{
Printf(PRINT_LOG, "%d Unresolved textures remain\n", BuiltTextures.Size());
Printf("%d Unresolved textures remain\n", BuiltTextures.Size());
for (auto &b : BuiltTextures)
{
Printf(PRINT_LOG, "%s\n", b.Name.GetChars());
Printf("%s\n", b.Name.GetChars());
}
break;
}
Expand Down

0 comments on commit bd6ba47

Please sign in to comment.