shithub: nanobsp

Download patch

ref: 69b170ae025fb1c3702e41af7d03cb89df72ae0e
parent: faf2526174629c68285610615b66fad7d1120510
author: Andrew Apted <ajapted@gmail.com>
date: Sat Dec 9 08:55:13 EST 2023

updated code in "p_setup.c" for subsector_t/node_t changes.

--- a/p_setup.c
+++ b/p_setup.c
@@ -38,7 +38,9 @@
 
 #include "doomstat.h"
 
+#include "nano_bsp.h"
 
+
 void	P_SpawnMapThing (mapthing_t*	mthing);
 
 
@@ -49,18 +51,21 @@
 int		numvertexes;
 vertex_t*	vertexes;
 
-int		numsegs;
-seg_t*		segs;
-
 int		numsectors;
 sector_t*	sectors;
 
-int		numsubsectors;
-subsector_t*	subsectors;
+// andrewj: made these local to this file, added root_node.
+static int		numsegs;
+static seg_t*		segs;
 
-int		numnodes;
-node_t*		nodes;
+static int		numsubsectors;
+static subsector_t*	subsectors;
 
+static int		numnodes;
+static node_t*		nodes;
+
+node_t*		root_node;
+
 int		numlines;
 line_t*		lines;
 
@@ -204,6 +209,8 @@
 //
 void P_LoadSegs (int lump)
 {
+// andrewj: TODO update this code
+#if 0
     byte*		data;
     int			i;
     mapseg_t*		ml;
@@ -268,6 +275,7 @@
     }
 	
     W_ReleaseLumpNum(lump);
+#endif
 }
 
 
@@ -276,6 +284,8 @@
 //
 void P_LoadSubsectors (int lump)
 {
+// andrewj: TODO update this code
+#if 0
     byte*		data;
     int			i;
     mapsubsector_t*	ms;
@@ -296,6 +306,7 @@
     }
 	
     W_ReleaseLumpNum(lump);
+#endif
 }
 
 
@@ -337,6 +348,8 @@
 //
 void P_LoadNodes (int lump)
 {
+// andrewj: TODO update this code
+#if 0
     byte*	data;
     int		i;
     int		j;
@@ -366,6 +379,7 @@
     }
 	
     W_ReleaseLumpNum(lump);
+#endif
 }
 
 
@@ -592,16 +606,14 @@
     line_t*		li;
     sector_t*		sector;
     subsector_t*	ss;
-    seg_t*		seg;
     fixed_t		bbox[4];
     int			block;
-	
+
     // look up sector number for each subsector
     ss = subsectors;
     for (i=0 ; i<numsubsectors ; i++, ss++)
     {
-	seg = &segs[ss->firstline];
-	ss->sector = seg->sidedef->sector;
+	ss->sector = ss->segs->sidedef->sector;
     }
 
     // count number of lines in each sector
@@ -841,11 +853,18 @@
     P_LoadVertexes (lumpnum+ML_VERTEXES);
     P_LoadSectors (lumpnum+ML_SECTORS);
     P_LoadSideDefs (lumpnum+ML_SIDEDEFS);
-
     P_LoadLineDefs (lumpnum+ML_LINEDEFS);
-    P_LoadSubsectors (lumpnum+ML_SSECTORS);
-    P_LoadNodes (lumpnum+ML_NODES);
-    P_LoadSegs (lumpnum+ML_SEGS);
+
+    if (true)
+    {
+        Nano_BuildBSP ();
+    }
+    else
+    {
+        P_LoadSubsectors (lumpnum+ML_SSECTORS);
+        P_LoadNodes (lumpnum+ML_NODES);
+        P_LoadSegs (lumpnum+ML_SEGS);
+    }
 
     P_GroupLines ();
     P_LoadReject (lumpnum+ML_REJECT);
--- a/r_state.h
+++ b/r_state.h
@@ -72,17 +72,10 @@
 extern int		numvertexes;
 extern vertex_t*	vertexes;
 
-extern int		numsegs;
-extern seg_t*		segs;
-
 extern int		numsectors;
 extern sector_t*	sectors;
 
-extern int		numsubsectors;
-extern subsector_t*	subsectors;
-
-extern int		numnodes;
-extern node_t*		nodes;
+extern node_t*		root_node;
 
 extern int		numlines;
 extern line_t*		lines;
--