Skip to content

Commit

Permalink
- don't adjust sprite offsets of IWAD sprites in sequences which have…
Browse files Browse the repository at this point in the history
… been replaced partially. This can be overridden by specifying 'iwadforced' in the SPROFS lump.
  • Loading branch information
coelckers committed Feb 14, 2017
1 parent 3170591 commit a615629
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/gl/data/gl_data.cpp
Expand Up @@ -97,6 +97,28 @@ void gl_CreateSections();
void AdjustSpriteOffsets()
{
int lump, lastlump = 0;
int sprid;
TMap<int, bool> donotprocess;

int numtex = Wads.GetNumLumps();

for (int i = 0; i < numtex; i++)
{
if (Wads.GetLumpFile(i) > 1) break; // we are past the IWAD
if (Wads.GetLumpNamespace(i) == ns_sprites && Wads.GetLumpFile(i) == FWadCollection::IWAD_FILENUM)
{
char str[9];
Wads.GetLumpName(str, i);
FTextureID texid = TexMan.CheckForTexture(str, FTexture::TEX_Sprite, 0);
if (texid.isValid() && Wads.GetLumpFile(TexMan[texid]->SourceLump) > FWadCollection::IWAD_FILENUM)
{
// This texture has been replaced by some PWAD.
memcpy(&sprid, str, 4);
donotprocess[sprid] = true;
}
}
}

while ((lump = Wads.FindLump("SPROFS", &lastlump, false)) != -1)
{
FScanner sc;
Expand All @@ -108,6 +130,7 @@ void AdjustSpriteOffsets()
{
int x,y;
bool iwadonly = false;
bool forced = false;
FTextureID texno = TexMan.CheckForTexture(sc.String, FTexture::TEX_Sprite);
sc.MustGetStringName(",");
sc.MustGetNumber();
Expand All @@ -119,6 +142,7 @@ void AdjustSpriteOffsets()
{
sc.MustGetString();
if (sc.Compare("iwad")) iwadonly = true;
if (sc.Compare("iwadforced")) forced = iwadonly = true;
}
if (texno.isValid())
{
Expand All @@ -131,6 +155,11 @@ void AdjustSpriteOffsets()
int wadno = Wads.GetLumpFile(lumpnum);
if ((iwadonly && wadno==FWadCollection::IWAD_FILENUM) || (!iwadonly && wadno == ofslumpno))
{
if (wadno == FWadCollection::IWAD_FILENUM && !forced && iwadonly)
{
memcpy(&sprid, &tex->Name[0], 4);
if (donotprocess.CheckKey(sprid)) continue; // do not alter sprites that only get partially replaced.
}
tex->LeftOffset=x;
tex->TopOffset=y;
tex->KillNative();
Expand Down

0 comments on commit a615629

Please sign in to comment.