- Added ZGL2 output support to ZDBSP for maps with more than 65534 lines.

- Fixed some GCC warnings.



SVN r1483 (trunk)
This commit is contained in:
Randy Heit 2009-03-17 02:02:58 +00:00
parent bf47221046
commit 034d7ab10a
12 changed files with 110 additions and 75 deletions

View file

@ -100,7 +100,7 @@ struct IntSector
{
// none of the sector properties are used by the node builder
// so there's no need to store them in their expanded form for
// UDMF. JUst storing the UDMF keys and leaving the binary fields
// UDMF. Just storing the UDMF keys and leaving the binary fields
// empty is enough
MapSector data;
@ -142,7 +142,7 @@ struct MapSegGLEx
{
DWORD v1;
DWORD v2;
WORD linedef;
DWORD linedef;
WORD side;
DWORD partner;
};

View file

@ -84,8 +84,8 @@ DWORD FNodeBuilder::CreateNode (DWORD set, fixed_t bbox[4])
if ((selstat = SelectSplitter (set, node, splitseg, skip, true)) > 0 ||
(skip > 0 && (selstat = SelectSplitter (set, node, splitseg, 1, true)) > 0) ||
(selstat < 0 && (SelectSplitter (set, node, splitseg, skip, false) > 0) ||
(skip > 0 && SelectSplitter (set, node, splitseg, 1, false))) ||
(selstat < 0 && (SelectSplitter (set, node, splitseg, skip, false) > 0 ||
(skip > 0 && SelectSplitter (set, node, splitseg, 1, false)))) ||
CheckSubsector (set, node, splitseg, count))
{
// Create a normal node
@ -766,8 +766,8 @@ void FNodeBuilder::SplitSegs (DWORD set, node_t &node, DWORD splitseg, DWORD &ou
//Printf ("%u is cut\n", set);
if (seg->loopnum)
{
Printf (" Split seg %u (%d,%d)-(%d,%d) of sector %d on line %d\n",
set,
Printf (" Split seg %lu (%d,%d)-(%d,%d) of sector %d on line %d\n",
(unsigned long)set,
Vertices[seg->v1].x>>16, Vertices[seg->v1].y>>16,
Vertices[seg->v2].x>>16, Vertices[seg->v2].y>>16,
seg->frontsector, seg->linedef);
@ -1014,7 +1014,7 @@ void FNodeBuilder::PrintSet (int l, DWORD set)
Printf ("set %d:\n", l);
for (; set != DWORD_MAX; set = Segs[set].next)
{
Printf ("\t%5u(%d)%c%d(%d,%d)-%d(%d,%d)\n", set,
Printf ("\t%5lu(%d)%c%d(%d,%d)-%d(%d,%d)\n", (unsigned long)set,
Segs[set].frontsector,
Segs[set].linedef == -1 ? '+' : ':',
Segs[set].v1,

View file

@ -200,7 +200,7 @@ void FEventTree::PrintTree (const FEvent *event) const
PrintTree (event->Left);
}
printf (" Distance %g, vertex %d, seg %u\n",
sqrt(event->Distance/4294967296.0), event->Info.Vertex, event->Info.FrontSeg);
sqrt(event->Distance/4294967296.0), event->Info.Vertex, (unsigned)event->Info.FrontSeg);
if (event->Right != &Nil)
{
PrintTree (event->Right);

View file

@ -320,29 +320,31 @@ DWORD FNodeBuilder::PushGLSeg (TArray<MapSegGLEx> &segs, const FPrivSeg *seg)
if (newseg.linedef != NO_INDEX)
{
IntLineDef * ld = &Level.Lines[newseg.linedef];
IntLineDef *ld = &Level.Lines[newseg.linedef];
if (ld->sidenum[0]==ld->sidenum[1])
if (ld->sidenum[0] == ld->sidenum[1])
{
// When both sidedefs are the same a quick check doesn't work so this
// has to be done by comparing the distances of the seg's end point to
// the line's start.
WideVertex * lv1 = &Level.Vertices[ld->v1];
WideVertex * sv1 = &Level.Vertices[seg->v1];
WideVertex * sv2 = &Level.Vertices[seg->v2];
WideVertex *lv1 = &Level.Vertices[ld->v1];
WideVertex *sv1 = &Level.Vertices[seg->v1];
WideVertex *sv2 = &Level.Vertices[seg->v2];
double dist1sq = double(sv1->x-lv1->x)*(sv1->x-lv1->x) + double(sv1->y-lv1->y)*(sv1->y-lv1->y);
double dist2sq = double(sv2->x-lv1->x)*(sv2->x-lv1->x) + double(sv2->y-lv1->y)*(sv2->y-lv1->y);
newseg.side = dist1sq<dist2sq? 0:1;
newseg.side = dist1sq < dist2sq ? 0 : 1;
}
else
{
newseg.side = ld->sidenum[1] == seg->sidedef ? 1 : 0;
}
}
else newseg.side=0;
else
{
newseg.side = 0;
}
newseg.partner = seg->partner;
return segs.Push (newseg);

View file

@ -233,10 +233,16 @@ DWORD FNodeBuilder::AddMiniseg (int v1, int v2, DWORD partner, DWORD seg1, DWORD
FPrivSeg newseg;
newseg.sidedef = NO_INDEX;
newseg.linedef = -1;
newseg.linedef = NO_INDEX;
newseg.loopnum = 0;
newseg.next = DWORD_MAX;
newseg.planefront = true;
newseg.hashnext = NULL;
newseg.storedseg = DWORD_MAX;
newseg.frontsector = NULL;
newseg.backsector = NULL;
newseg.offset = 0;
newseg.angle = 0;
if (splitseg != DWORD_MAX)
{

View file

@ -120,6 +120,10 @@ int FNodeBuilder::CreateSeg (int linenum, int sidenum)
seg.loopnum = 0;
seg.offset = 0;
seg.partner = DWORD_MAX;
seg.hashnext = NULL;
seg.planefront = false;
seg.planenum = DWORD_MAX;
seg.storedseg = DWORD_MAX;
if (sidenum == 0)
{ // front

View file

@ -397,7 +397,7 @@ void FLevel::RemoveExtraSectors ()
// Mark all used sectors
for (i = 0; i < NumSides(); ++i)
{
if (Sides[i].sector != NO_INDEX)
if ((DWORD)Sides[i].sector != NO_INDEX)
{
used[Sides[i].sector] = 1;
}
@ -432,7 +432,7 @@ void FLevel::RemoveExtraSectors ()
// Renumber sector references in sides
for (i = 0; i < NumSides(); ++i)
{
if (Sides[i].sector != NO_INDEX)
if ((DWORD)Sides[i].sector != NO_INDEX)
{
Sides[i].sector = remap[Sides[i].sector];
}
@ -541,7 +541,7 @@ void FProcessor::Write (FWadWriter &out)
return;
}
bool compress, compressGL, gl5;
bool compress, compressGL, gl5 = false;
#ifdef BLOCK_TEST
int size;
@ -1273,7 +1273,7 @@ void FProcessor::WriteGLSegs (FWadWriter &out, bool v5)
{
segdata[i].v2 = LittleShort(0x8000 | (WORD)(Level.GLSegs[i].v2 - Level.NumOrgVerts));
}
segdata[i].linedef = LittleShort(Level.GLSegs[i].linedef);
segdata[i].linedef = LittleShort((WORD)Level.GLSegs[i].linedef);
segdata[i].side = LittleShort(Level.GLSegs[i].side);
segdata[i].partner = LittleShort((WORD)Level.GLSegs[i].partner);
}
@ -1375,7 +1375,14 @@ void FProcessor::WriteGLBSPZ (FWadWriter &out, const char *label)
}
out.StartWritingLump (label);
out.AddToLump ("ZGLN", 4);
if (Level.NumLines() < 65535)
{
out.AddToLump ("ZGLN", 4);
}
else
{
out.AddToLump ("ZGL2", 4);
}
WriteVerticesZ (zout, &Level.GLVertices[Level.NumOrgVerts], Level.NumOrgVerts, Level.NumGLVertices - Level.NumOrgVerts);
WriteSubsectorsZ (zout, Level.GLSubsectors, Level.NumGLSubsectors);
WriteGLSegsZ (zout, Level.GLSegs, Level.NumGLSegs);
@ -1419,12 +1426,25 @@ void FProcessor::WriteGLSegsZ (ZLibOut &out, const MapSegGLEx *segs, int numsegs
{
out << (DWORD)numsegs;
for (int i = 0; i < numsegs; ++i)
if (Level.NumLines() < 65535)
{
out << (DWORD)segs[i].v1
<< (DWORD)segs[i].partner
<< (WORD)segs[i].linedef
<< (BYTE)segs[i].side;
for (int i = 0; i < numsegs; ++i)
{
out << (DWORD)segs[i].v1
<< (DWORD)segs[i].partner
<< (WORD)segs[i].linedef
<< (BYTE)segs[i].side;
}
}
else
{
for (int i = 0; i < numsegs; ++i)
{
out << (DWORD)segs[i].v1
<< (DWORD)segs[i].partner
<< (DWORD)segs[i].linedef
<< (BYTE)segs[i].side;
}
}
}

View file

@ -26,8 +26,8 @@
class StringBuffer
{
const static int BLOCK_SIZE = 100000;
const static int BLOCK_ALIGN = sizeof(size_t);
const static size_t BLOCK_SIZE = 100000;
const static size_t BLOCK_ALIGN = sizeof(size_t);
TDeletingArray<char *> blocks;
size_t currentindex;
@ -493,7 +493,7 @@ void FProcessor::WriteVertexUDMF(FWadWriter &out, IntVertex *vt)
//===========================================================================
//
// writes an UDMF vertex
// writes an UDMF text map
//
//===========================================================================
@ -535,7 +535,7 @@ void FProcessor::WriteTextMap(FWadWriter &out)
//===========================================================================
//
// writes an UDMF vertex
// writes an UDMF map
//
//===========================================================================

View file

@ -37,14 +37,9 @@
#include <stdlib.h>
#include <assert.h>
#include <malloc.h>
#include <new>
#if !defined(_WIN32)
#include <inttypes.h> // for intptr_t
#elif !defined(_MSC_VER)
#include <stdint.h> // for mingw
#endif
// TArray -------------------------------------------------------------------
// T is the type stored in the array.
@ -336,34 +331,4 @@ public:
}
};
// TAutoGrowArray -----------------------------------------------------------
// An array with accessors that automatically grow the array as needed.
// It can still be used as a normal TArray if needed. ACS uses this for
// world and global arrays.
template <class T, class TT=T>
class TAutoGrowArray : public TArray<T, TT>
{
public:
T GetVal (unsigned int index)
{
if (index >= this->Size())
{
return 0;
}
return (*this)[index];
}
void SetVal (unsigned int index, T val)
{
if ((int)index < 0) return; // These always result in an out of memory condition.
if (index >= this->Size())
{
this->Resize (index + 1);
}
(*this)[index] = val;
}
};
#endif //__TARRAY_H__

View file

@ -808,7 +808,7 @@ void SizeView (HWND wnd, bool firstTime)
LRESULT CALLBACK MapViewFunc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static bool dragging = false;
static POINTS dragpos;
static union { POINTS dragpos; LPARAM dragpos_lp; };
static int hitx, hity;
SCROLLINFO sinfo = { sizeof(SCROLLINFO), };
int pos;
@ -935,7 +935,8 @@ LRESULT CALLBACK MapViewFunc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
case WM_RBUTTONDOWN:
dragging = true;
dragpos = MAKEPOINTS(lParam);
dragpos_lp = lParam; // also sets dragpos; avoids type-punned dereference warning from GCC
//dragpos = MAKEPOINTS(lParam);
return 0;
case WM_RBUTTONUP:
@ -949,9 +950,10 @@ LRESULT CALLBACK MapViewFunc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
}
else if (dragging)
{
POINTS newpos = MAKEPOINTS(lParam);
union { POINTS newpos; LPARAM newpos_lp; };
int delta;
newpos_lp = lParam;
delta = (newpos.x - dragpos.x) * 8;
if (delta)
{

View file

@ -165,7 +165,7 @@ bool FWadReader::isUDMF (int index) const
{
index++;
if (strnicmp(Lumps[index].Name, "TEXTMAP", 8) == NULL)
if (strnicmp(Lumps[index].Name, "TEXTMAP", 8) == 0)
{
// UDMF map
return true;
@ -299,7 +299,7 @@ int FWadReader::LumpAfterMap (int i) const
{
// UDMF map
i += 2;
while (strnicmp(Lumps[i].Name, "ENDMAP", 8) != NULL && i < Header.NumLumps)
while (strnicmp(Lumps[i].Name, "ENDMAP", 8) != 0 && i < Header.NumLumps)
{
i++;
}

View file

@ -258,7 +258,10 @@
more than 65535 segs and vertices by storing them using four bytes instead of
two.</p>
<p>The first four bytes of the compressed nodes are a four-character (uncompressed)
signature. This can be either 'ZNOD' for regular nodes or 'ZGLN' for GL nodes.
signature. This can be either 'ZNOD' for regular nodes or 'ZGLN' for GL nodes.
If there are more than 65534 lines in the map, the signature 'ZGL2' is used
for GL nodes instead. (Note that this can only happen with UDMF maps, because
the binary map format does not allow more lines than that.)
Following the signature is the zlib data stream. For a description of its
format, see the zlib documentation. When you decompress it, the following
information is obtained in this order:</p>
@ -405,7 +408,7 @@
<tr>
<td>WORD</td>
<td><i>line</i></td>
<td>The linedef this seg came from (0xFFFFFFFF if none)</td>
<td>The linedef this seg came from (0xFFFF if none)</td>
</tr>
<tr>
<td>BYTE</td>
@ -413,7 +416,38 @@
<td>The linedef's side this seg came from (0=front, 1=back) (ignored if no line)</td>
</tr>
</table>
<p>Unlike standard GL nodes, each seg's second vertex is not stored. This is
<h3>GL nodes ('ZGL2' signature)</h3>
<table>
<tr>
<td>DWORD</td>
<td><i>NumSegs</i></td>
<td>Number of segs</td>
</tr>
<tr>
<td bgcolor="#dddddd" colspan="3">Repeat <i>NumSegs</i> times:</td>
</tr>
<tr>
<td>DWORD</td>
<td><i>v1</i></td>
<td>Seg's first vertex</td>
</tr>
<tr>
<td>DWORD</td>
<td><i>partner</i></td>
<td>Seg's partner seg (0xFFFFFFFF if none)</td>
</tr>
<tr>
<td>DWORD</td>
<td><i>line</i></td>
<td>The linedef this seg came from (0xFFFFFFFF if none)</td>
</tr>
<tr>
<td>BYTE</td>
<td><i>side</i></td>
<td>The linedef's side this seg came from (0=front, 1=back) (ignored if no line)</td>
</tr>
</table>
<p>Unlike standard GL nodes, each seg's second vertex is not stored. This is
because GL subsectors must form a closed area. In other words, one seg's second
vertex is the same as the next seg's first vertex. The subsector information
contains everything you need to know to close each area and start a new one.</p>
@ -488,5 +522,7 @@
find some way to "hijack" this lump in the future, so programs that read
compressed nodes must not assume that if the SEGS lump is non-empty, then
compressed nodes are not used.</p>
<p>For UDMF maps, nodes a stored in the map's ZNODES lump. These will only be
'ZGLN' or 'ZGL2' format nodes. Non-GL nodes are not supported for UDMF.</p>
</BODY>
</HTML>