diff --git a/doomdata.h b/doomdata.h index 57e1801..b9ca4ce 100644 --- a/doomdata.h +++ b/doomdata.h @@ -129,6 +129,16 @@ struct MapSeg short offset; }; +struct MapSegEx +{ + DWORD v1; + DWORD v2; + WORD angle; + WORD linedef; + short side; + short offset; +}; + struct MapSegGL { WORD v1; @@ -219,7 +229,7 @@ struct FLevel TArray Sectors; TArray Things; MapSubsectorEx *Subsectors; int NumSubsectors; - MapSeg *Segs; int NumSegs; + MapSegEx *Segs; int NumSegs; MapNodeEx *Nodes; int NumNodes; WORD *Blockmap; int BlockmapSize; BYTE *Reject; int RejectSize; diff --git a/nodebuild.cpp b/nodebuild.cpp index 4f262ce..d7cfdfa 100644 --- a/nodebuild.cpp +++ b/nodebuild.cpp @@ -433,6 +433,8 @@ int FNodeBuilder::SelectSplitter (DWORD set, node_t &node, DWORD &splitseg, int memset (&PlaneChecked[0], 0, PlaneChecked.Size()); + D(printf("Processing set %d\n", set)); + while (seg != DWORD_MAX) { FPrivSeg *pseg = &Segs[seg]; @@ -454,8 +456,8 @@ int FNodeBuilder::SelectSplitter (DWORD set, node_t &node, DWORD &splitseg, int int value = Heuristic (node, set, nosplit); - D(Printf ("Seg %5d%c(%5d,%5d)-(%5d,%5d) scores %d\n", seg, - Segs[seg].linedef == -1 ? '+' : ' ', + D(Printf ("Seg %5d, ld %d (%5d,%5d)-(%5d,%5d) scores %d\n", seg, + Segs[seg].linedef, node.x>>16, node.y>>16, (node.x+node.dx)>>16, (node.y+node.dy)>>16, value)); diff --git a/nodebuild.h b/nodebuild.h index c3738d2..541cf85 100644 --- a/nodebuild.h +++ b/nodebuild.h @@ -143,7 +143,7 @@ public: void GetVertices (WideVertex *&verts, int &count); void GetNodes (MapNodeEx *&nodes, int &nodeCount, - MapSeg *&segs, int &segCount, + MapSegEx *&segs, int &segCount, MapSubsectorEx *&ssecs, int &subCount); void GetGLNodes (MapNodeEx *&nodes, int &nodeCount, @@ -231,8 +231,8 @@ private: DWORD AddMiniseg (int v1, int v2, DWORD partner, DWORD seg1, DWORD splitseg); void SetNodeFromSeg (node_t &node, const FPrivSeg *pseg) const; - int RemoveMinisegs (MapNodeEx *nodes, TArray &segs, MapSubsectorEx *subs, int node, short bbox[4]); - int StripMinisegs (TArray &segs, int subsector, short bbox[4]); + int RemoveMinisegs (MapNodeEx *nodes, TArray &segs, MapSubsectorEx *subs, int node, short bbox[4]); + int StripMinisegs (TArray &segs, int subsector, short bbox[4]); void AddSegToShortBBox (short bbox[4], const FPrivSeg *seg); int CloseSubsector (TArray &segs, int subsector); DWORD PushGLSeg (TArray &segs, const FPrivSeg *seg); diff --git a/nodebuild_extract.cpp b/nodebuild_extract.cpp index d2f9882..7a541d8 100644 --- a/nodebuild_extract.cpp +++ b/nodebuild_extract.cpp @@ -27,8 +27,10 @@ #if 0 #define D(x) x +#define DD 1 #else #define D(x) do{}while(0) +#undef DD #endif void FNodeBuilder::GetGLNodes (MapNodeEx *&outNodes, int &nodeCount, @@ -126,7 +128,7 @@ int FNodeBuilder::CloseSubsector (TArray &segs, int subsector) prev = seg; firstVert = seg->v1; -#if 0 +#ifdef DD printf("--%d--\n", subsector); for (j = first; j < max; ++j) { @@ -180,7 +182,7 @@ int FNodeBuilder::CloseSubsector (TArray &segs, int subsector) PushConnectingGLSeg (subsector, segs, prev->v2, seg->v1); count++; } -#if 0 +#ifdef DD printf ("+%d\n", bestj); #endif prevAngle -= bestdiff; @@ -193,7 +195,7 @@ int FNodeBuilder::CloseSubsector (TArray &segs, int subsector) break; } } -#if 0 +#ifdef DD printf ("\n"); #endif } @@ -224,7 +226,7 @@ int FNodeBuilder::CloseSubsector (TArray &segs, int subsector) PushConnectingGLSeg (subsector, segs, prev->v2, firstVert); count++; } -#if 0 +#ifdef DD printf ("Output GL subsector %d:\n", subsector); for (i = segs.Size() - count; i < (int)segs.Size(); ++i) { @@ -380,11 +382,11 @@ void FNodeBuilder::GetVertices (WideVertex *&verts, int &count) } void FNodeBuilder::GetNodes (MapNodeEx *&outNodes, int &nodeCount, - MapSeg *&outSegs, int &segCount, + MapSegEx *&outSegs, int &segCount, MapSubsectorEx *&outSubs, int &subCount) { short bbox[4]; - TArray segs (Segs.Size()); + TArray segs (Segs.Size()); // Walk the BSP and create a new BSP with only the information // suitable for a standard tree. At a minimum, this means removing @@ -401,12 +403,36 @@ void FNodeBuilder::GetNodes (MapNodeEx *&outNodes, int &nodeCount, RemoveMinisegs (outNodes, segs, outSubs, Nodes.Size() - 1, bbox); segCount = segs.Size (); - outSegs = new MapSeg[segCount]; - memcpy (outSegs, &segs[0], segCount*sizeof(MapSeg)); + outSegs = new MapSegEx[segCount]; + memcpy (outSegs, &segs[0], segCount*sizeof(MapSegEx)); + +#ifdef DD + int i, j; + + for (i = 0; i < nodeCount; ++i) + { + printf("Node %d:\n", i); + for (j = 1; j >= 0; --j) + { + if (outNodes[i].children[j] & NFX_SUBSECTOR) + { + printf(" subsector %d\n", outNodes[i].children[j] & ~NFX_SUBSECTOR); + } + else + { + printf(" node %d\n", outNodes[i].children[j]); + } + } + } + for (i = 0; i < segCount; ++i) + { + printf("Seg %d: v1(%d) -> v2(%d)\n", i, outSegs[i].v1, outSegs[i].v2); + } +#endif } int FNodeBuilder::RemoveMinisegs (MapNodeEx *nodes, - TArray &segs, MapSubsectorEx *subs, int node, short bbox[4]) + TArray &segs, MapSubsectorEx *subs, int node, short bbox[4]) { if (node & NFX_SUBSECTOR) { @@ -441,7 +467,7 @@ int FNodeBuilder::RemoveMinisegs (MapNodeEx *nodes, } } -int FNodeBuilder::StripMinisegs (TArray &segs, int subsector, short bbox[4]) +int FNodeBuilder::StripMinisegs (TArray &segs, int subsector, short bbox[4]) { int count, i, max; @@ -468,7 +494,7 @@ int FNodeBuilder::StripMinisegs (TArray &segs, int subsector, short bbox } else { - MapSeg newseg; + MapSegEx newseg; AddSegToShortBBox (bbox, org); diff --git a/processor.cpp b/processor.cpp index f4f39cb..15ca6e3 100644 --- a/processor.cpp +++ b/processor.cpp @@ -1034,26 +1034,31 @@ void FProcessor::WriteSectors (FWadWriter &out) void FProcessor::WriteSegs (FWadWriter &out) { - int i, count; - short *segdata; + int i; + MapSeg *segdata; - segdata = (short *)Level.Segs; - count = Level.NumSegs*sizeof(MapSeg)/sizeof(*segdata); + assert(Level.NumVertices < 65536); - for (i = 0; i < count; ++i) + segdata = new MapSeg[Level.NumSegs]; + + for (i = 0; i < Level.NumSegs; ++i) { - segdata[i] = LittleShort(segdata[i]); + segdata[i].v1 = LittleShort(segdata[i].v1); + segdata[i].v2 = LittleShort(segdata[i].v2); + segdata[i].angle = LittleShort(segdata[i].angle); + segdata[i].linedef = LittleShort(segdata[i].linedef); + segdata[i].side = LittleShort(segdata[i].side); + segdata[i].offset = LittleShort(segdata[i].offset); } - out.WriteLump ("SEGS", segdata, sizeof(*segdata)*count); + out.WriteLump ("SEGS", segdata, sizeof(*segdata)*Level.NumSegs); - count /= sizeof(MapSeg)/sizeof(*segdata); - if (count >= 65536) + if (Level.NumSegs >= 65536) { - printf (" SEGS is too big for any port. (%d segs)\n", count); + printf (" SEGS is too big for any port. (%d segs)\n", Level.NumSegs); } - else if (count >= 32768) + else if (Level.NumSegs >= 32768) { - printf (" SEGS is too big for vanilla Doom and most ports. (%d segs)\n", count); + printf (" SEGS is too big for vanilla Doom and some ports. (%d segs)\n", Level.NumSegs); } } @@ -1414,7 +1419,7 @@ void FProcessor::WriteSubsectorsZ (ZLibOut &out, const MapSubsectorEx *subs, int } } -void FProcessor::WriteSegsZ (ZLibOut &out, const MapSeg *segs, int numsegs) +void FProcessor::WriteSegsZ (ZLibOut &out, const MapSegEx *segs, int numsegs) { out << (DWORD)numsegs; @@ -1532,7 +1537,7 @@ void FProcessor::WriteSubsectorsX (FWadWriter &out, const MapSubsectorEx *subs, } } -void FProcessor::WriteSegsX (FWadWriter &out, const MapSeg *segs, int numsegs) +void FProcessor::WriteSegsX (FWadWriter &out, const MapSegEx *segs, int numsegs) { out << (DWORD)numsegs; diff --git a/processor.h b/processor.h index 68e3022..c9c2550 100644 --- a/processor.h +++ b/processor.h @@ -78,7 +78,7 @@ private: void WriteVerticesZ (ZLibOut &out, const WideVertex *verts, int orgverts, int newverts); void WriteSubsectorsZ (ZLibOut &out, const MapSubsectorEx *subs, int numsubs); - void WriteSegsZ (ZLibOut &out, const MapSeg *segs, int numsegs); + void WriteSegsZ (ZLibOut &out, const MapSegEx *segs, int numsegs); void WriteGLSegsZ (ZLibOut &out, const MapSegGLEx *segs, int numsegs); void WriteNodesZ (ZLibOut &out, const MapNodeEx *nodes, int numnodes); @@ -87,7 +87,7 @@ private: void WriteVerticesX (FWadWriter &out, const WideVertex *verts, int orgverts, int newverts); void WriteSubsectorsX (FWadWriter &out, const MapSubsectorEx *subs, int numsubs); - void WriteSegsX (FWadWriter &out, const MapSeg *segs, int numsegs); + void WriteSegsX (FWadWriter &out, const MapSegEx *segs, int numsegs); void WriteGLSegsX (FWadWriter &out, const MapSegGLEx *segs, int numsegs); void WriteNodesX (FWadWriter &out, const MapNodeEx *nodes, int numnodes); diff --git a/view.cpp b/view.cpp index bcab95a..bb301e9 100644 --- a/view.cpp +++ b/view.cpp @@ -723,7 +723,7 @@ static void DrawLevelPVS (HDC dc) static void SetDesiredSector (int x, int y) { int node = Level->NumNodes - 1; - const MapSeg *seg; + const MapSegEx *seg; while (!(node & NFX_SUBSECTOR)) { diff --git a/zdbsp.h b/zdbsp.h index bf7d46f..c801b38 100644 --- a/zdbsp.h +++ b/zdbsp.h @@ -16,7 +16,7 @@ typedef __int32 int32_t; #include #endif -#define ZDBSP_VERSION "1.15" +#define ZDBSP_VERSION "1.16" enum EBlockmapMode { diff --git a/zdbsp_vs2005.vcproj b/zdbsp_vs2005.vcproj index d272f5c..4278109 100644 --- a/zdbsp_vs2005.vcproj +++ b/zdbsp_vs2005.vcproj @@ -96,6 +96,85 @@ Name="VCPostBuildEventTool" /> + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - @@ -647,6 +631,14 @@ EnableEnhancedInstructionSet="2" /> + + + @@ -655,6 +647,14 @@ EnableEnhancedInstructionSet="2" /> + + + @@ -779,22 +779,6 @@ Name="VCCLCompilerTool" /> - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - @@ -1039,6 +1023,14 @@ DisableSpecificWarnings="4267" /> + + + @@ -1047,6 +1039,14 @@ DisableSpecificWarnings="4267" /> + + + @@ -1077,6 +1077,10 @@ > + + diff --git a/zipbin.bat b/zipbin.bat index 48437df..29e099a 100644 --- a/zipbin.bat +++ b/zipbin.bat @@ -1 +1 @@ -kzip %1 release\zdbsp.exe zdbsp.html *.png \ No newline at end of file +kzip %1 zdbsp.exe zdbsp.html *.png \ No newline at end of file