home *** CD-ROM | disk | FTP | other *** search
/ Doom 2 Explosion / Doom2Explosion.bin / doom2exp / programs / ibsp101s / idbsp.h < prev    next >
C/C++ Source or Header  |  1994-08-05  |  7KB  |  302 lines

  1. #include <stdarg.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include "cmdlib.h"
  6.  
  7. #ifndef __IDBSP__
  8. #define __IDBSP__
  9.  
  10. #define MAX(a,b) ( (a) > (b) ) ? (a) : (b)
  11. #define MIN(a,b) ( (a) < (b) ) ? (a) : (b)
  12.  
  13. typedef struct
  14.     {
  15.     int                 count;
  16.     int                 size;
  17.     void               *data;
  18.     }
  19. STORAGE;
  20.  
  21. #include <math.h>
  22. #include <limits.h>
  23. #include <float.h>
  24. /*#include "cmdlib.h" */
  25. #include "doomdata.h"
  26. #include "wadfile.h"
  27. /* #include "doomdata.h" */
  28.  
  29. /*
  30.    #define SHORT(x)        NXSwapLittleShortToHost((short)x)
  31.    #define LONG(x)         NXSwapLittleLongToHost((long)x)
  32.  */
  33.  
  34. /*
  35.    #define SHORT(x) LittleShort((short)x)
  36.    #define LONG(x)  LittleLong((long)x)
  37.  */
  38. /*
  39.    #define SHORT(x) BigShort((short)x)
  40.    #define LONG(x) BigLong((long)x)
  41.  */
  42. /*
  43.    #define SHORT(x) (short)(x)
  44.    #define LONG(x) (long)(x)
  45.  */
  46.  
  47. #ifndef PI
  48. #define PI   3.14159265359
  49. #endif
  50.  
  51. #define         MAXVERTEX               8192
  52. #define         MAXTOUCHSECS    16
  53. #define         MAXSECTORS              2048
  54. #define         MAXSUBSECTORS   2048
  55.  
  56. typedef struct
  57.     {
  58.     float               x;
  59.     float               y;
  60.     }
  61. NXPoint;
  62.  
  63. typedef struct
  64.     {
  65.     float               width;
  66.     float               height;
  67.     }
  68. NXSize;
  69.  
  70. typedef struct
  71.     {
  72.     NXPoint             origin;
  73.     NXSize              size;
  74.     }
  75. NXRect;
  76.  
  77. /*
  78.    ===============================================================================
  79.  
  80.    map file types
  81.  
  82.    ===============================================================================
  83.  */
  84.  
  85. typedef struct
  86.     {
  87.     int                 floorheight,
  88.                         ceilingheight;
  89.     char                floorflat[9],
  90.                         ceilingflat[9];
  91.     int                 lightlevel;
  92.     int                 special,
  93.                         tag;
  94.     }
  95. sectordef_t;
  96.  
  97. typedef struct
  98.     {
  99.     int                 firstrow;
  100.     int                 firstcollumn;
  101.     char                toptexture[9];
  102.     char                bottomtexture[9];
  103.     char                midtexture[9];
  104.     sectordef_t         sectordef;    /* on the viewers side */
  105.     int                 sector;    /* only used when saving doom map */
  106.     }
  107. worldside_t;
  108.  
  109. typedef struct
  110.     {
  111.     NXPoint             p1,
  112.                         p2;
  113.     int                 special,
  114.                         tag;
  115.     int                 flags;
  116.     worldside_t         side[2];
  117.     }
  118. worldline_t;
  119.  
  120. #define ML_BLOCKMOVE    1
  121. #define ML_TWOSIDED             4       /* backside will not be present at all if not two sided */
  122.  
  123. typedef struct
  124.     {
  125.     NXPoint             origin;
  126.     int                 angle;
  127.     int                 type;
  128.     int                 options;
  129.     int                 area;
  130.     }
  131. worldthing_t;
  132.  
  133. /*
  134.    ===============================================================================
  135.  
  136.    internal types
  137.  
  138.    ===============================================================================
  139.  */
  140.  
  141. typedef struct
  142.     {
  143.     NXPoint             pt;
  144.     float               dx,
  145.                         dy;
  146.     }
  147. divline_t;
  148.  
  149. typedef struct bspstruct_s
  150.     {
  151. /*      id                                              lines_i;                // if non NULL, the node is */
  152.     STORAGE            *lines_i;
  153.     divline_t           divline;    /* terminal and has no children */
  154.     float               bbox[4];
  155.     struct bspstruct_s *side[2];
  156.     }
  157. bspnode_t;
  158.  
  159.  
  160. typedef struct
  161.     {
  162.     NXPoint             p1,
  163.                         p2;
  164.     int                 linedef,
  165.                         side,
  166.                         offset;
  167.     boolean             grouped;    /* internal error check */
  168.     }
  169. line_t;
  170.  
  171.  
  172. /*
  173.    ===============================================================================
  174.  
  175.    idbsp
  176.  
  177.    ===============================================================================
  178.  */
  179.  
  180. extern WADFILE      wad_i;
  181.  
  182. /*extern        boolean         draw; */
  183. void                progress(void);
  184. short               LittleShort(short l);
  185. short               BigShort(short l);
  186. long                LittleLong(long l);
  187. long                BigLong(long l);
  188. void                AddFromFile(char *resname, int size, char *fname);
  189. void                FreeGlobalStorage(void);
  190.  
  191. /*
  192.    ===============================================================================
  193.  
  194.    doomload
  195.  
  196.    ===============================================================================
  197.  */
  198.  
  199. extern STORAGE     *linestore_i,
  200.                    *thingstore_i;
  201.  
  202. /* void LoadDoomMap (char *mapname); */
  203. void                LoadDoomMap(FILE * file);
  204.  
  205.  
  206. /*
  207.    ===============================================================================
  208.  
  209.    drawing
  210.  
  211.    ===============================================================================
  212.  */
  213.  
  214. extern STORAGE     *window_i,
  215.                    *view_i;
  216. extern float        scale;
  217. extern NXRect       worldbounds;
  218.  
  219. void                EraseWindow(void);
  220. void                DrawMap(void);
  221.  
  222. /*void DrawLineStore (id lines_i); */
  223. void                DrawLineStore(STORAGE * lines_i);
  224. void                DrawDivLine(divline_t * div);
  225. void                DrawLineDef(maplinedef_t * ld);
  226.  
  227.  
  228. /*
  229.    ===============================================================================
  230.  
  231.    buildbsp
  232.  
  233.    ===============================================================================
  234.  */
  235.  
  236. extern int          cuts;        /* number of new lines generated by BSP process */
  237. extern bspnode_t   *startnode;
  238.  
  239. void                BuildBSP(void);
  240. void                DivlineFromWorldline(divline_t * d, line_t * w);
  241. int                 PointOnSide(NXPoint * p, divline_t * l);
  242. void                ExecuteSplit(STORAGE * lines_i, line_t * spliton, STORAGE * frontlist_i,
  243.     STORAGE * backlist_i);
  244.  
  245.  
  246. /*
  247.    ===============================================================================
  248.  
  249.    savebsp
  250.  
  251.    ===============================================================================
  252.  */
  253.  
  254. extern STORAGE     *secstore_i;
  255. extern STORAGE     *mapvertexstore_i;
  256. extern STORAGE     *subsecstore_i;
  257. extern STORAGE     *maplinestore_i;
  258. extern STORAGE     *nodestore_i;
  259. extern STORAGE     *mapthingstore_i;
  260. extern STORAGE     *ldefstore_i;
  261. extern STORAGE     *sdefstore_i;
  262.  
  263. void                SaveDoomMap(void);
  264.  
  265. /*
  266.    ===============================================================================
  267.  
  268.    saveblocks
  269.  
  270.    ===============================================================================
  271.  */
  272.  
  273. void                SaveBlocks(void);
  274.  
  275. /* extern short *datalist; */
  276.  
  277. /*
  278.    ===============================================================================
  279.  
  280.    savesectors
  281.  
  282.    ===============================================================================
  283.  */
  284.  
  285. void                ProcessSectors(void);
  286. void                BuildSectordefs(void);
  287.  
  288. /* extern short **vertexsublist; */
  289.  
  290. /*
  291.    ===============================================================================
  292.  
  293.    saveconnect
  294.  
  295.    ===============================================================================
  296.  */
  297.  
  298. void                ProcessConnections(void);
  299. void                OutputConnections(void);
  300.  
  301. #endif
  302.