- Fixed: Completely empty patches (8 0-bytes) could not be handled by the

texture manager. They now get assigned a new FEmptyTexture object
  that is just a 1x1 pixel transparent texture.
- Fixed: Multiple namespace markers of the same type were no longer detected.
- Fixed sprite renaming.


SVN r1566 (trunk)
This commit is contained in:
Christoph Oelckers 2009-04-30 11:10:38 +00:00
parent 28e9693b79
commit b37d0ba2ea
7 changed files with 267 additions and 93 deletions

View file

@ -1,4 +1,11 @@
April 29, 2009
April 30, 2009 (Changes by Graf Zahl)
- Fixed: Completely empty patches (8 0-bytes) could not be handled by the
texture manager. They now get assigned a new FEmptyTexture object
that is just a 1x1 pixel transparent texture.
- Fixed: Multiple namespace markers of the same type were no longer detected.
- Fixed sprite renaming.
April 29, 2009
- Maps defined with Hexen-style MAPINFOs now run their scripts in the proper
order.
- Fixed: FWadCollection::CheckNumForName() read the lump each iteration before

View file

@ -147,78 +147,109 @@ inline bool FWadFile::IsMarker(int lump, const char *marker)
void FWadFile::SetNamespace(const char *startmarker, const char *endmarker, namespace_t space, bool flathack)
{
int start=-1, end=-1;
bool warned = false;
int numstartmarkers = 0, numendmarkers = 0;
int i;
struct Marker
{
int markertype;
int index;
};
TArray<Marker> markers;
for(i = 0; i < (int)NumLumps; i++)
{
if (IsMarker(i, startmarker))
{
start = i;
break;
Marker m = {0, i };
markers.Push(m);
numstartmarkers++;
}
}
if (!flathack && start == -1) return;
for(i = NumLumps-1; i > start; i--)
{
if (IsMarker(i, endmarker))
else if (IsMarker(i, endmarker))
{
end = i;
break;
Marker m = {1, i };
markers.Push(m);
numendmarkers++;
}
}
if (end == -1)
{
if (start != -1)
{
Printf(TEXTCOLOR_YELLOW"WARNING: %s marker without corresponding %s found.\n", startmarker, endmarker);
}
return;
}
if (start != -1)
{
for(int i = start+1; i < end; i++)
{
if (Lumps[i].Namespace != ns_global)
{
if (!warned)
{
Printf(TEXTCOLOR_YELLOW"WARNING: Overlapping namespaces found.\n");
}
warned = true;
}
else if (IsMarker(i, startmarker))
{
Printf(TEXTCOLOR_YELLOW"WARNING: Multiple %s markers found.\n", startmarker);
}
else if (IsMarker(i, endmarker))
{
Printf(TEXTCOLOR_YELLOW"WARNING: Multiple %s markers found.\n", endmarker);
}
else
{
Lumps[i].Namespace = space;
}
}
}
else
if (numstartmarkers == 0)
{
if (numendmarkers == 0) return; // no markers found
Printf(TEXTCOLOR_YELLOW"WARNING: %s marker without corresponding %s found.\n", endmarker, startmarker);
if (flathack)
{
// We have found no F_START but one or more F_END markers.
// mark all lumps before the last F_END marker as potential flats.
int end = markers[markers.Size()-1].index;
for(int i = 0; i < end; i++)
{
if (Lumps[i].LumpSize == 4096)
{
// We can't add this to the flats namespace but
// it needs to be flagged for the texture manager.
DPrintf("Marking %s as potential flat\n", Lumps[i].Name);
Lumps[i].Flags |= LUMPF_MAYBEFLAT;
}
}
}
return;
}
i = 0;
while (i < markers.Size())
{
int start, end;
if (markers[i].markertype != 0)
{
Printf(TEXTCOLOR_YELLOW"WARNING: %s marker without corresponding %s found.\n", endmarker, startmarker);
i++;
continue;
}
start = i++;
// skip over subsequent x_START markers
while (i < markers.Size() && markers[i].markertype == 0)
{
Printf(TEXTCOLOR_YELLOW"WARNING: duplicate %s marker found.\n", startmarker);
i++;
continue;
}
// same for x_START markers
while (i < markers.Size()-1 && (markers[i].markertype == 1 && markers[i+1].markertype == 1))
{
Printf(TEXTCOLOR_YELLOW"WARNING: duplicate %s marker found.\n", endmarker);
i++;
continue;
}
// We found a starting marker but no end marker. Ignore this block.
if (i >= markers.Size())
{
Printf(TEXTCOLOR_YELLOW"WARNING: %s marker without corresponding %s found.\n", startmarker, endmarker);
return;
}
end = i++;
// we found a marked block
DPrintf("Found %s block at (%d-%d)\n", startmarker, markers[start].index, markers[end].index);
for(int j = markers[start].index+1; j < markers[end].index; j++)
{
if (Lumps[j].Namespace != ns_global)
{
if (!warned)
{
Printf(TEXTCOLOR_YELLOW"WARNING: Overlapping namespaces found (lump %d.)\n", j);
}
warned = true;
}
else
{
Lumps[j].Namespace = space;
}
}
}
}

View file

@ -0,0 +1,125 @@
/*
** flattexture.cpp
** Texture class for empty placeholder textures
** (essentially patches with dimensions and offsets of (0,0) )
**
**---------------------------------------------------------------------------
** Copyright 2009 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
**
*/
#include "doomtype.h"
#include "files.h"
#include "r_data.h"
#include "w_wad.h"
//==========================================================================
//
// A texture defined between F_START and F_END markers
//
//==========================================================================
class FEmptyTexture : public FTexture
{
public:
FEmptyTexture (int lumpnum);
const BYTE *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels ();
void Unload() {}
protected:
BYTE Pixels[1];
Span DummySpans[1];
};
//==========================================================================
//
// Since there is no way to detect the validity of a flat
// they can't be used anywhere else but between F_START and F_END
//
//==========================================================================
FTexture *EmptyTexture_TryCreate(FileReader & file, int lumpnum)
{
char check[8];
if (file.GetLength() != 8) return false;
file.Seek(0, SEEK_SET);
if (file.Read(check, 8) != 8) return false;
if (memcmp(check, "\0\0\0\0\0\0\0\0", 8)) return false;
return new FEmptyTexture(lumpnum);
}
//==========================================================================
//
//
//
//==========================================================================
FEmptyTexture::FEmptyTexture (int lumpnum)
: FTexture(NULL, lumpnum)
{
bMasked = true;
WidthBits = HeightBits = 1;
Width = Height = 1;
WidthMask = 0;
DummySpans[0].TopOffset = 0;
DummySpans[0].Length = 0;
Pixels[0] = 0;
}
//==========================================================================
//
//
//
//==========================================================================
const BYTE *FEmptyTexture::GetColumn (unsigned int column, const Span **spans_out)
{
if (spans_out != NULL)
{
*spans_out = DummySpans;
}
return Pixels;
}
//==========================================================================
//
//
//
//==========================================================================
const BYTE *FEmptyTexture::GetPixels ()
{
return Pixels;
}

View file

@ -71,6 +71,7 @@ FTexture *TGATexture_TryCreate(FileReader &, int lumpnum);
FTexture *RawPageTexture_TryCreate(FileReader &, int lumpnum);
FTexture *FlatTexture_TryCreate(FileReader &, int lumpnum);
FTexture *PatchTexture_TryCreate(FileReader &, int lumpnum);
FTexture *EmptyTexture_TryCreate(FileReader &, int lumpnum);
FTexture *AutomapTexture_TryCreate(FileReader &, int lumpnum);
@ -88,6 +89,7 @@ FTexture * FTexture::CreateTexture (int lumpnum, int usetype)
{ RawPageTexture_TryCreate, TEX_MiscPatch },
{ FlatTexture_TryCreate, TEX_Flat },
{ PatchTexture_TryCreate, TEX_Any },
{ EmptyTexture_TryCreate, TEX_Any },
{ AutomapTexture_TryCreate, TEX_MiscPatch },
};

View file

@ -189,6 +189,7 @@ void FWadCollection::InitMultipleFiles (wadlist_t **filenames)
{
I_FatalError ("W_InitMultipleFiles: no files found");
}
RenameSprites();
// [RH] Set up hash table
FirstLumpIndex = new DWORD[NumLumps];
@ -196,6 +197,8 @@ void FWadCollection::InitMultipleFiles (wadlist_t **filenames)
FirstLumpIndex_FullName = new DWORD[NumLumps];
NextLumpIndex_FullName = new DWORD[NumLumps];
InitHashChains ();
LumpInfo.ShrinkToFit();
Files.ShrinkToFit();
}
//-----------------------------------------------------------------------
@ -667,7 +670,7 @@ void FWadCollection::InitHashChains (void)
//
//==========================================================================
void FWadCollection::RenameSprites (int startlump)
void FWadCollection::RenameSprites ()
{
bool renameAll;
bool MNTRZfound = false;
@ -739,64 +742,66 @@ void FWadCollection::RenameSprites (int startlump)
break;
}
renameAll = !!Args->CheckParm ("-oldsprites");
for (DWORD i = startlump + 1;
i < NumLumps &&
*(DWORD *)LumpInfo[i].lump->Name != MAKE_ID('S','_','E','N') &&
*(((DWORD *)LumpInfo[i].lump->Name) + 1) != MAKE_ID('D',0,0,0);
++i)
for (DWORD i=0; i< LumpInfo.Size(); i++)
{
if (!strncmp(LumpInfo[i].lump->Name, "MNTRZ", 5))
// check for full Minotaur animations. If this is not found
// some frames need to be renamed.
if (LumpInfo[i].lump->Namespace == ns_sprites)
{
MNTRZfound = true;
break;
if (*(DWORD *)LumpInfo[i].lump->Name == MAKE_ID('M', 'N', 'T', 'R') && LumpInfo[i].lump->Name[4] == 'Z' )
{
MNTRZfound = true;
break;
}
}
}
for (DWORD i = startlump + 1;
i < NumLumps &&
*(DWORD *)LumpInfo[i].lump->Name != MAKE_ID('S','_','E','N') &&
*(((DWORD *)LumpInfo[i].lump->Name) + 1) != MAKE_ID('D',0,0,0);
++i)
{
// Only sprites in the IWAD normally get renamed
if (renameAll || LumpInfo[i].wadnum == IWAD_FILENUM)
{
for (int j = 0; j < numrenames; ++j)
{
if (*(DWORD *)LumpInfo[i].lump->Name == renames[j*2])
{
*(DWORD *)LumpInfo[i].lump->Name = renames[j*2+1];
}
}
if (gameinfo.gametype == GAME_Hexen)
{
if (CheckLumpName (i, "ARTIINVU"))
{
LumpInfo[i].lump->Name[4]='D'; LumpInfo[i].lump->Name[5]='E';
LumpInfo[i].lump->Name[6]='F'; LumpInfo[i].lump->Name[7]='N';
}
}
}
if (!MNTRZfound) //gameinfo.gametype == GAME_Hexen && LumpInfo[i].wadnum == IWAD_FILENUM)
{
if (*(DWORD *)LumpInfo[i].lump->Name == MAKE_ID('M', 'N', 'T', 'R'))
{
if (LumpInfo[i].lump->Name[4] >= 'F' && LumpInfo[i].lump->Name[4] <= 'K')
{
LumpInfo[i].lump->Name[4] += 'U' - 'F';
}
}
}
renameAll = !!Args->CheckParm ("-oldsprites");
// When not playing Doom rename all BLOD sprites to BLUD so that
// the same blood states can be used everywhere
if (!(gameinfo.gametype & GAME_DoomChex))
for (DWORD i = 0; i < LumpInfo.Size(); i++)
{
if (LumpInfo[i].lump->Namespace == ns_sprites)
{
if (*(DWORD *)LumpInfo[i].lump->Name == MAKE_ID('B', 'L', 'O', 'D'))
// Only sprites in the IWAD normally get renamed
if (renameAll || LumpInfo[i].wadnum == IWAD_FILENUM)
{
*(DWORD *)LumpInfo[i].lump->Name = MAKE_ID('B', 'L', 'U', 'D');
for (int j = 0; j < numrenames; ++j)
{
if (*(DWORD *)LumpInfo[i].lump->Name == renames[j*2])
{
*(DWORD *)LumpInfo[i].lump->Name = renames[j*2+1];
}
}
if (gameinfo.gametype == GAME_Hexen)
{
if (CheckLumpName (i, "ARTIINVU"))
{
LumpInfo[i].lump->Name[4]='D'; LumpInfo[i].lump->Name[5]='E';
LumpInfo[i].lump->Name[6]='F'; LumpInfo[i].lump->Name[7]='N';
}
}
}
if (!MNTRZfound)
{
if (*(DWORD *)LumpInfo[i].lump->Name == MAKE_ID('M', 'N', 'T', 'R'))
{
if (LumpInfo[i].lump->Name[4] >= 'F' && LumpInfo[i].lump->Name[4] <= 'K')
{
LumpInfo[i].lump->Name[4] += 'U' - 'F';
}
}
}
// When not playing Doom rename all BLOD sprites to BLUD so that
// the same blood states can be used everywhere
if (!(gameinfo.gametype & GAME_DoomChex))
{
if (*(DWORD *)LumpInfo[i].lump->Name == MAKE_ID('B', 'L', 'O', 'D'))
{
*(DWORD *)LumpInfo[i].lump->Name = MAKE_ID('B', 'L', 'U', 'D');
}
}
}
}

View file

@ -232,7 +232,7 @@ protected:
void InitHashChains (); // [RH] Set up the lumpinfo hashing
private:
void RenameSprites (int startlump);
void RenameSprites ();
void DeleteAll();
};

View file

@ -5213,6 +5213,10 @@
RelativePath=".\src\textures\ddstexture.cpp"
>
</File>
<File
RelativePath=".\src\textures\emptytexture.cpp"
>
</File>
<File
RelativePath=".\src\textures\flattexture.cpp"
>