mirror of
https://github.com/ZDoom/zdbsp.git
synced 2024-11-24 12:51:24 +00:00
- Added a reject fixer to correct the reject when sectors are removed instead
of just throwing it away. SVN r174 (trunk)
This commit is contained in:
parent
6a1a0e007a
commit
06d1bf0354
16 changed files with 93 additions and 22 deletions
13
Makefile
13
Makefile
|
@ -27,18 +27,18 @@ else
|
|||
endif
|
||||
|
||||
# To generate profiling information for gprof, pass gprof=1 to make.
|
||||
ifneq ($(gprof),)
|
||||
ifeq ($(gprof),1)
|
||||
CFLAGS += -g -fno-omit-frame-pointer -pg
|
||||
LDFLAGS += -g -pg
|
||||
endif
|
||||
|
||||
# To strip debugging symbols, pass strip=1 to make.
|
||||
ifneq ($(strip),)
|
||||
ifeq ($(strip),1)
|
||||
LDFLAGS += -s
|
||||
endif
|
||||
|
||||
# To use SSE2 math for everything, pass sse=1 to make.
|
||||
ifneq ($(sse),)
|
||||
ifeq ($(sse),1)
|
||||
CFLAGS += -msse -msse2 -mfpmath=sse
|
||||
endif
|
||||
|
||||
|
@ -53,6 +53,10 @@ OBJS = main.o getopt.o getopt1.o blockmapbuilder.o processor.o view.o wad.o \
|
|||
zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/trees.o \
|
||||
zlib/zutil.o
|
||||
|
||||
ifeq (Windows_NT,$(OS))
|
||||
OBJS += resource.o
|
||||
endif
|
||||
|
||||
all: $(EXE)
|
||||
|
||||
profile:
|
||||
|
@ -70,6 +74,9 @@ $(EXE): $(OBJS)
|
|||
nodebuild_classify_sse2.o: nodebuild_classify_sse2.cpp nodebuild.h
|
||||
$(CXX) $(CXXFLAGS) -msse2 -mfpmath=sse -c -o $@ $<
|
||||
|
||||
resource.o: resource.rc
|
||||
windres -o $@ -i $<
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
|
|
|
@ -164,6 +164,8 @@ struct FLevel
|
|||
|
||||
int NumOrgVerts;
|
||||
|
||||
WORD *OrgSectorMap; int NumOrgSectors;
|
||||
|
||||
fixed_t MinX, MinY, MaxX, MaxY;
|
||||
|
||||
void FindMapBounds ();
|
||||
|
|
18
main.cpp
18
main.cpp
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
The main glue for ZDBSP.
|
||||
Copyright (C) 2002,2003 Randy Heit
|
||||
Copyright (C) 2002-2006 Randy Heit
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -49,6 +49,7 @@
|
|||
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -258,11 +259,26 @@ int main (int argc, char **argv)
|
|||
|
||||
END_COUNTER(t1a, t1b, t1c, "\nTotal time: %g seconds.\n")
|
||||
}
|
||||
catch (std::runtime_error msg)
|
||||
{
|
||||
printf ("%s\n", msg.what());
|
||||
return 20;
|
||||
}
|
||||
catch (std::bad_alloc)
|
||||
{
|
||||
printf ("Out of memory\n");
|
||||
return 20;
|
||||
}
|
||||
catch (std::exception msg)
|
||||
{
|
||||
printf ("%s\n", msg.what());
|
||||
return 20;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
printf ("Unhandled exception. ZDBSP cannot continue.\n");
|
||||
return 20;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Most of the logic for the node builder.
|
||||
Copyright (C) 2002,2003 Randy Heit
|
||||
Copyright (C) 2002-2006 Randy Heit
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
A red-black tree implementation for building minisegs.
|
||||
Copyright (C) 2002,2003 Randy Heit
|
||||
Copyright (C) 2002-2006 Randy Heit
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Routines for extracting usable data from the new BSP tree.
|
||||
Copyright (C) 2002,2003 Randy Heit
|
||||
Copyright (C) 2002-2006 Randy Heit
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Routines only necessary for building GL-friendly nodes.
|
||||
Copyright (C) 2002,2003 Randy Heit
|
||||
Copyright (C) 2002-2006 Randy Heit
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Various utility functions.
|
||||
Copyright (C) 2002,2003 Randy Heit
|
||||
Copyright (C) 2002-2006 Randy Heit
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Reads wad files, builds nodes, and saves new wad files.
|
||||
Copyright (C) 2002,2003 Randy Heit
|
||||
Copyright (C) 2002-2006 Randy Heit
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -57,6 +57,7 @@ FLevel::~FLevel ()
|
|||
if (GLSegs) delete[] GLSegs;
|
||||
if (GLNodes) delete[] GLNodes;
|
||||
if (GLPVS) delete[] GLPVS;
|
||||
if (OrgSectorMap) delete[] OrgSectorMap;
|
||||
}
|
||||
|
||||
FProcessor::FProcessor (FWadReader &inwad, int lump)
|
||||
|
@ -330,6 +331,7 @@ void FLevel::RemoveExtraSectors ()
|
|||
// Extra sectors are those that aren't referenced by any sides.
|
||||
// They just waste space, so get rid of them.
|
||||
|
||||
NumOrgSectors = NumSectors;
|
||||
used = new BYTE[NumSectors];
|
||||
memset (used, 0, NumSectors*sizeof(*used));
|
||||
remap = new WORD[NumSectors];
|
||||
|
@ -368,7 +370,6 @@ void FLevel::RemoveExtraSectors ()
|
|||
{
|
||||
int diff = NumSectors - newNumSectors;
|
||||
printf (" Removed %d unused sector%s.\n", diff, diff > 1 ? "s" : "");
|
||||
NumSectors = newNumSectors;
|
||||
|
||||
// Renumber sector references in sides
|
||||
for (i = 0; i < NumSides; ++i)
|
||||
|
@ -378,6 +379,14 @@ void FLevel::RemoveExtraSectors ()
|
|||
Sides[i].sector = remap[Sides[i].sector];
|
||||
}
|
||||
}
|
||||
// Make a reverse map for fixing reject lumps
|
||||
OrgSectorMap = new WORD[newNumSectors];
|
||||
for (i = 0; i < NumSectors; ++i)
|
||||
{
|
||||
OrgSectorMap[remap[i]] = i;
|
||||
}
|
||||
|
||||
NumSectors = newNumSectors;
|
||||
}
|
||||
|
||||
delete[] used;
|
||||
|
@ -572,7 +581,7 @@ void FProcessor::Write (FWadWriter &out)
|
|||
if (lump >= 0)
|
||||
{
|
||||
ReadLump<BYTE> (Wad, lump, Level.Reject, Level.RejectSize);
|
||||
if (Level.RejectSize != (Level.NumSectors*Level.NumSectors + 7) / 8)
|
||||
if (Level.RejectSize != (Level.NumOrgSectors*Level.NumOrgSectors + 7) / 8)
|
||||
{
|
||||
// If the reject is the wrong size, don't use it.
|
||||
delete[] Level.Reject;
|
||||
|
@ -583,6 +592,14 @@ void FProcessor::Write (FWadWriter &out)
|
|||
}
|
||||
Level.RejectSize = 0;
|
||||
}
|
||||
else if (Level.NumOrgSectors != Level.NumSectors)
|
||||
{
|
||||
// Some sectors have been removed, so fix the reject.
|
||||
BYTE *newreject = FixReject (Level.Reject);
|
||||
delete[] Level.Reject;
|
||||
Level.Reject = newreject;
|
||||
Level.RejectSize = (Level.NumSectors * Level.NumSectors + 7) / 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -706,6 +723,33 @@ void FProcessor::Write (FWadWriter &out)
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
BYTE *FProcessor::FixReject (const BYTE *oldreject)
|
||||
{
|
||||
int x, y, ox, oy, pnum, opnum;
|
||||
int rejectSize = (Level.NumSectors*Level.NumSectors + 7) / 8;
|
||||
BYTE *newreject = new BYTE[rejectSize];
|
||||
|
||||
memset (newreject, 0, rejectSize);
|
||||
|
||||
for (y = 0; y < Level.NumSectors; ++y)
|
||||
{
|
||||
oy = Level.OrgSectorMap[y];
|
||||
for (x = 0; x < Level.NumSectors; ++x)
|
||||
{
|
||||
ox = Level.OrgSectorMap[x];
|
||||
pnum = y*Level.NumSectors + x;
|
||||
opnum = oy*Level.NumSectors + ox;
|
||||
|
||||
if (oldreject[opnum >> 3] & (1 << (opnum & 7)))
|
||||
{
|
||||
newreject[pnum >> 3] |= 1 << (pnum & 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
return newreject;
|
||||
}
|
||||
|
||||
MapNodeEx *FProcessor::NodesToEx (const MapNode *nodes, int count)
|
||||
{
|
||||
if (count == 0)
|
||||
|
|
|
@ -54,6 +54,8 @@ private:
|
|||
MapSubsectorEx *SubsectorsToEx (const MapSubsector *ssec, int count);
|
||||
MapSegGLEx *SegGLsToEx (const MapSegGL *segs, int count);
|
||||
|
||||
BYTE *FixReject (const BYTE *oldreject);
|
||||
|
||||
void WriteLines (FWadWriter &out);
|
||||
void WriteVertices (FWadWriter &out, int count);
|
||||
void WriteSectors (FWadWriter &out);
|
||||
|
|
10
resource.rc
10
resource.rc
|
@ -93,8 +93,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,7,0,0
|
||||
PRODUCTVERSION 1,7,0,0
|
||||
FILEVERSION 1,8,0,0
|
||||
PRODUCTVERSION 1,8,0,0
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -110,12 +110,12 @@ BEGIN
|
|||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "ZDBSP Node Builder"
|
||||
VALUE "FileVersion", "1.7"
|
||||
VALUE "FileVersion", "1.8"
|
||||
VALUE "InternalName", "zdbsp"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2002,2003"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2002-2006"
|
||||
VALUE "OriginalFilename", "zdbsp.exe"
|
||||
VALUE "ProductName", "ZDBSP"
|
||||
VALUE "ProductVersion", "1.7"
|
||||
VALUE "ProductVersion", "1.8"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
2
tarray.h
2
tarray.h
|
@ -3,7 +3,7 @@
|
|||
** Templated, automatically resizing array
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 1998-2005 Randy Heit
|
||||
** Copyright 1998-2006 Randy Heit
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
** Some useful template functions
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 1998-2001 Randy Heit
|
||||
** Copyright 1998-2006 Randy Heit
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
|
|
2
view.cpp
2
view.cpp
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
A really crappy viewer module.
|
||||
Copyright (C) 2002,2003 Randy Heit
|
||||
Copyright (C) 2002-2006 Randy Heit
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
2
wad.cpp
2
wad.cpp
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
WAD-handling routines.
|
||||
Copyright (C) 2002,2003 Randy Heit
|
||||
Copyright (C) 2002-2006 Randy Heit
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
2
zdbsp.h
2
zdbsp.h
|
@ -16,7 +16,7 @@ typedef __int32 int32_t;
|
|||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#define ZDBSP_VERSION "1.7"
|
||||
#define ZDBSP_VERSION "1.8"
|
||||
|
||||
enum EBlockmapMode
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue