Commit Graph

584 Commits

Author SHA1 Message Date
Kevin Shanahan b9fa895988 qbsp: replace enum errors in portals.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 18:47:36 +09:30
Kevin Shanahan 15da0d818a qbsp: replace enum errors in parser.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 18:40:13 +09:30
Kevin Shanahan 0e586916b1 qbsp: replace error enums in outside.c, merge.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 18:32:52 +09:30
Kevin Shanahan c01397ed5b qbsp: replace enum errors in file.c and wad.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 18:23:24 +09:30
Kevin Shanahan 02e81df39b qbsp: replace error enums in csg4.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 18:20:02 +09:30
Kevin Shanahan 58b33cc3d4 qbsp: remplace error enums in bspfile.c
Overlapped with outside.c and portals.c for some of the file errors.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 18:15:38 +09:30
Kevin Shanahan 7203d3407b qbsp: replace enum errors in brush.c
One shared message in surfaces.c replaced as well.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 17:59:36 +09:30
Kevin Shanahan d5adbcd8ca qbsp: replace enum errors in qbsp.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 17:39:56 +09:30
Kevin Shanahan 30caae09e5 qbsp: re-factor ParseBrush into smaller pieces
Factor out some of the processing involved with parsing a brush.  When
checking for duplicate planes, use the same "PlaneEqual" functions as
used in brush.c.

Replace the enum style errors with the new Error_ function for all of
map.c so the error string is at the call site.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 17:33:16 +09:30
Kevin Shanahan 5082e3ffaa light: reduce "no model has face" to a warning
Since the newskip.exe tool leaves the faces in the bsp but removes
references, we will just skip over lighting such faces.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 13:11:22 +09:30
Kevin Shanahan 4a49552904 bsputil: add missing stdint.h include
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 12:51:33 +09:30
Kevin Shanahan 39ccae145a qbsp: create an Error() function similar to the other tools
Call it Error_() for now while I work on transitioning away from the
arrays of global strings hidden away by error enums.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 11:40:22 +09:30
Kevin Shanahan bb02e6d20a qbsp: fix portal generation mixed water/empty detail clusters
We don't want to terminate the recursion in ClusterContents when we reach
a non-detail separator because we need to know the contents of the leafs!
This was working okay for simple cases but fails when the detail clusters
become more complex.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-21 13:05:11 +09:30
Kevin Shanahan d3a75f6c1a vis: use uintptr for FreeStackWinding index check
Just in case unsigned long isn't big enough to capture the pointer
offsets. Also, cast STACK_WINDINGS to the correct type before doing the
comparison.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-21 10:17:40 +09:30
Kevin Shanahan 97371bc6ab vis: allocate extra dist/sides slot in ClipStackWinding
We use one extra to simplify checking when an edge crosses the split
plane.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-21 10:14:54 +09:30
Kevin Shanahan ba88986462 vis: fix portal stack corruption in ClipStackWinding
Need to re-check numpoints before we add a split point.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-21 10:13:27 +09:30
Kevin Shanahan 186ca8863b vis: fix stack separator cache overflow check
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-21 10:10:13 +09:30
Kevin Shanahan fa93a21598 qbsp: fix surfedge corruption when using skip surfaces
Don't count skip surface verticies at all in CountData_r because this
count actually gets used as the surfedge count and we need that to be
precise.

Don't try to save memory be allocating less verticies than edges, even
though many will probably be shared.  The saving is not that significant
anyway.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-21 10:05:17 +09:30
Kevin Shanahan 195f5869e2 bsputil: add --check option to check internal consistency
First pass, checks most of the data structures actually reference within
the valid ranges.  Will add more soon...

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 21:11:21 +09:30
Kevin Shanahan 264f613760 bsputil: pass bspdata_t into ExportWad
No longer require the bspfile globals.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 17:22:10 +09:30
Kevin Shanahan b484603871 trivial: remove old comment about removing plane type
On disk formats are pretty final at this point...

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 16:58:54 +09:30
Kevin Shanahan d14793f7ab common: make LoadBSPFile take a bspdata struct
No longer update the globals in this function - make the callers do it
instead.

bspinfo no longer refers to the globals at all.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 16:51:45 +09:30
Kevin Shanahan 35024bfa7d common: make dtexdata a union
Just having one base pointer was kind of annoying because you have to cast
to get to the lump offsets, then cast to byte * to find the miptex, etc.
Now we can access the same pointer using the correct types in each case.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 16:34:30 +09:30
Kevin Shanahan 37a3a98eff common: make WriteBSPFile take a bspdata struct as input
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 15:52:31 +09:30
Kevin Shanahan 6bf97a2cb0 common: convert PrintBSPFileSizes to use the bspdata struct
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 13:27:25 +09:30
Kevin Shanahan 3e660b291a common: zero the bsp structure before calling CopyLump
Stops CopyLump from trying to free using random pointers.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 13:24:09 +09:30
Kevin Shanahan bc0de585ff common: fix use after free in LoadBSPFile
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 13:23:34 +09:30
Kevin Shanahan 23d938a822 common: fix reference to plane data in SwapBSPFile
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 13:22:31 +09:30
Kevin Shanahan d4aba2ce58 common: convert LoadBSPFile to work on a bspdata struct internally
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 12:44:48 +09:30
Kevin Shanahan 00850d9db8 common: convert SwapBSPFile to work on a bspdata_t struct
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 12:02:09 +09:30
Kevin Shanahan 89074e10e9 common: create a struct for instanced bsp data
I'd like to be able to control visibility of the global bsp data as well
as having the ability to load two bsp files and do comparisons, etc.  Set
up a structure to hold all the bsp data and a couple of helper functions
to enable a smooth transition for the utils.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 12:00:07 +09:30
Kevin Shanahan 0258b441c1 common: use a swap type enum for SwapBSPFile
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 11:25:18 +09:30
Kevin Shanahan 5943c71c98 common: pass file handle and header into AddLump
Instead of passing parameters via globals.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 10:53:34 +09:30
Kevin Shanahan d7611d6b1b common: change loadfile argument to avoid casts in callers
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 10:26:08 +09:30
Kevin Shanahan df0aa44310 common: create a lumpspec structure with lump data names/sizes
Copylump now doesn't need the size passed in, just the type.  Also, pass
the file header into CopyLump while we're at it.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 10:21:53 +09:30
Kevin Shanahan 9580d04f45 common: minor cleanups in SwapBSPFile
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 07:43:24 +09:30
Kevin Shanahan 4b10bd23d9 qbsp: remove global progress counter for MakeFaceEdges
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-19 16:53:54 +09:30
Kevin Shanahan 022b927d79 trivial: fix typo in error message
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-19 15:08:55 +09:30
Kevin Shanahan 207f5c6386 common: interrupt thread progress before printing error
Still racy, but better than printing on the same line as the progress
indicator line...

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-19 15:00:21 +09:30
Kevin Shanahan 4275149cee light: improve "bad surface extents" error info
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-19 14:59:35 +09:30
Kevin Shanahan 2a93375e0e qbsp: small cleanup in MakeFaceEdges
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-19 14:43:35 +09:30
Kevin Shanahan 683a894290 qbsp: trivial cleanups in GrowNodeRegion_r
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-19 11:28:54 +09:30
Kevin Shanahan 8e57b7c9e6 qbsp: factor out special texture name recognition
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-19 11:28:11 +09:30
Kevin Shanahan 3dc06c6f21 qbsp: add a -noskip option for troubleshooting skip related problems
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-19 09:48:43 +09:30
Kevin Shanahan 7e6474c03d qbsp: keep verticies from skip/hint faces in vertex count
We still end up short if we just discard these counts - still don't
need faces for them, but every edge could be real unless it's shared
with another skip face.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-18 12:58:46 +09:30
Kevin Shanahan f20033fdd7 light: dynamically allocate entities and entstring
Removes the MAX_MAP_ENTITIES and MAX_MAP_ENTSTRING limitations by
counting how much space we will need before parsing/writing.

Now that I look at it, I'm not sure why we should even be re-writing
the entity string in the new bsp file, but I'll leave that behaviour
alone... for now.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-18 09:45:52 +09:30
Kevin Shanahan cd188ebc99 qbsp: increase unique vertex estimate to cope with skip faces
The old assumption about unique verticies is sometimes untrue when
skip faces are included in the map.  Be more generous with the vertex
memory allocation. This is not an area of peak memory usage anyway, so
shouldn't be a big deal.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-18 08:21:27 +09:30
Ozkan Sezer 828a34a959 common: fix undefined array reference behavior in SwapBSPFile
Thanks to a -Waggressive-loop-optimizations warning from gcc-4.8:

common/bspfile.c: In function 'SwapBSPFile':
common/bspfile.c:121:41: warning: iteration 4u invokes undefined behavior [-Waggressive-loop-optimizations]
      texinfo[i].vecs[0][j] = LittleFloat(texinfo[i].vecs[0][j]);
                                         ^
common/bspfile.c:120:2: note: containing loop
  for (j = 0; j < 8; j++)
  ^

Signed-off-by: Ozkan Sezer <sezero@users.sourceforge.net>
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-14 09:12:31 +09:30
Kevin Shanahan 99d9bccb4e Merge branch 'master' of ssh://tuon/~/scm/tyrutils 2013-04-14 09:06:49 +09:30
Ozkan Sezer 3eff2401a9 common: fix parsing quoted strings when EOF is reached mid-string
Signed-off-by: Ozkan Sezer <sezero@users.sourceforge.net>
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-14 09:05:58 +09:30