mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 14:31:50 +00:00
Updated Visplane Explorer plugin to v1.0. Visplanes of Hexen maps can now be explored.
Map Options Form: example map name now uses current game's naming scheme.
This commit is contained in:
parent
422c605bc7
commit
a7488939af
33 changed files with 8103 additions and 7726 deletions
|
@ -701,7 +701,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
}
|
||||
|
||||
// Check if we have at least one activation flag when there's an action in UDMF map format (mxd)
|
||||
if (General.Map.UDMF && !action.Empty && action.Value != 0)
|
||||
if (General.Map.UDMF && action.Value != 0)
|
||||
{
|
||||
bool haveactivationflag = false;
|
||||
foreach (CheckBox c in udmfactivates.Checkboxes)
|
||||
|
|
16
Source/Core/Windows/MapOptionsForm.Designer.cs
generated
16
Source/Core/Windows/MapOptionsForm.Designer.cs
generated
|
@ -42,6 +42,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
this.panelres = new System.Windows.Forms.GroupBox();
|
||||
this.strictpatches = new System.Windows.Forms.CheckBox();
|
||||
this.datalocations = new CodeImp.DoomBuilder.Controls.ResourceListEditor();
|
||||
this.examplelabel = new System.Windows.Forms.Label();
|
||||
label3 = new System.Windows.Forms.Label();
|
||||
label2 = new System.Windows.Forms.Label();
|
||||
label1 = new System.Windows.Forms.Label();
|
||||
|
@ -56,9 +57,9 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
label3.AutoSize = true;
|
||||
label3.Location = new System.Drawing.Point(239, 83);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new System.Drawing.Size(90, 14);
|
||||
label3.Size = new System.Drawing.Size(53, 14);
|
||||
label3.TabIndex = 9;
|
||||
label3.Text = "example: MAP01";
|
||||
label3.Text = "example: ";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
|
@ -82,6 +83,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
//
|
||||
panelsettings.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
panelsettings.Controls.Add(this.examplelabel);
|
||||
panelsettings.Controls.Add(this.scriptcompiler);
|
||||
panelsettings.Controls.Add(this.scriptcompilerlabel);
|
||||
panelsettings.Controls.Add(label3);
|
||||
|
@ -206,6 +208,15 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
this.datalocations.Size = new System.Drawing.Size(368, 130);
|
||||
this.datalocations.TabIndex = 0;
|
||||
//
|
||||
// examplelabel
|
||||
//
|
||||
this.examplelabel.AutoSize = true;
|
||||
this.examplelabel.Location = new System.Drawing.Point(288, 83);
|
||||
this.examplelabel.Name = "examplelabel";
|
||||
this.examplelabel.Size = new System.Drawing.Size(41, 14);
|
||||
this.examplelabel.TabIndex = 12;
|
||||
this.examplelabel.Text = "MAP01";
|
||||
//
|
||||
// MapOptionsForm
|
||||
//
|
||||
this.AcceptButton = this.apply;
|
||||
|
@ -247,6 +258,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
private System.Windows.Forms.CheckBox strictpatches;
|
||||
private System.Windows.Forms.ComboBox scriptcompiler;
|
||||
private System.Windows.Forms.Label scriptcompilerlabel;
|
||||
private System.Windows.Forms.Label examplelabel;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -293,6 +293,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
{
|
||||
// Get default lump name from configuration
|
||||
levelname.Text = ci.DefaultLumpName;
|
||||
examplelabel.Text = ci.DefaultLumpName; //mxd
|
||||
}
|
||||
|
||||
//mxd
|
||||
|
|
Binary file not shown.
|
@ -50,7 +50,7 @@ namespace CodeImp.DoomBuilder.Plugins.VisplaneExplorer
|
|||
private delegate int VPO_LoadWAD(string filename);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
private delegate int VPO_OpenMap(string mapname);
|
||||
private delegate int VPO_OpenMap(string mapname, ref bool isHexen);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
private delegate void VPO_FreeWAD();
|
||||
|
@ -151,8 +151,9 @@ namespace CodeImp.DoomBuilder.Plugins.VisplaneExplorer
|
|||
try
|
||||
{
|
||||
// Load the map
|
||||
bool isHexen = (General.Map.Config.FormatInterface == "HexenMapSetIO");
|
||||
if(LoadWAD(filename) != 0) throw new Exception("VPO is unable to read this file.");
|
||||
if(OpenMap(mapname) != 0) throw new Exception("VPO is unable to open this map.");
|
||||
if(OpenMap(mapname, ref isHexen) != 0) throw new Exception("VPO is unable to open this map.");
|
||||
|
||||
// Processing
|
||||
Queue<TilePoint> todo = new Queue<TilePoint>(POINTS_PER_ITERATION);
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace CodeImp.DoomBuilder.Plugins.VisplaneExplorer
|
|||
ButtonGroup = "002_tools",
|
||||
Volatile = true,
|
||||
UseByDefault = true,
|
||||
SupportedMapFormats = new[] { "DoomMapSetIO" }, //mxd
|
||||
SupportedMapFormats = new[] { "DoomMapSetIO", "HexenMapSetIO" }, //mxd
|
||||
AllowCopyPaste = false)]
|
||||
public class VisplaneExplorerMode : ClassicMode
|
||||
{
|
||||
|
|
|
@ -1,221 +1,235 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// all external data is defined here
|
||||
// most of the data is loaded into different structures at run time
|
||||
// some internal structures shared by many modules are here
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __DOOMDATA__
|
||||
#define __DOOMDATA__
|
||||
|
||||
// The most basic types we use, portability.
|
||||
#include "doomtype.h"
|
||||
|
||||
// Some global defines, that configure the game.
|
||||
#include "doomdef.h"
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Map level types.
|
||||
// The following data structures define the persistent format
|
||||
// used in the lumps of the WAD files.
|
||||
//
|
||||
|
||||
// Lump order in a map WAD: each map needs a couple of lumps
|
||||
// to provide a complete scene geometry description.
|
||||
enum
|
||||
{
|
||||
ML_LABEL, // A separator, name, ExMx or MAPxx
|
||||
ML_THINGS, // Monsters, items..
|
||||
ML_LINEDEFS, // LineDefs, from editing
|
||||
ML_SIDEDEFS, // SideDefs, from editing
|
||||
ML_VERTEXES, // Vertices, edited and BSP splits generated
|
||||
ML_SEGS, // LineSegs, from LineDefs split by BSP
|
||||
ML_SSECTORS, // SubSectors, list of LineSegs
|
||||
ML_NODES, // BSP nodes
|
||||
ML_SECTORS, // Sectors, from editing
|
||||
ML_REJECT, // LUT, sector-sector visibility
|
||||
ML_BLOCKMAP // LUT, motion clipping, walls/grid element
|
||||
};
|
||||
|
||||
|
||||
// A single Vertex.
|
||||
typedef struct
|
||||
{
|
||||
short x;
|
||||
short y;
|
||||
} PACKEDATTR mapvertex_t;
|
||||
|
||||
|
||||
// A SideDef, defining the visual appearance of a wall,
|
||||
// by setting textures and offsets.
|
||||
typedef struct
|
||||
{
|
||||
short textureoffset;
|
||||
short rowoffset;
|
||||
char toptexture[8];
|
||||
char bottomtexture[8];
|
||||
char midtexture[8];
|
||||
// Front sector, towards viewer.
|
||||
short sector;
|
||||
} PACKEDATTR mapsidedef_t;
|
||||
|
||||
|
||||
|
||||
// A LineDef, as used for editing, and as input
|
||||
// to the BSP builder.
|
||||
typedef struct
|
||||
{
|
||||
short v1;
|
||||
short v2;
|
||||
short flags;
|
||||
short special;
|
||||
short tag;
|
||||
// sidenum[1] will be -1 if one sided
|
||||
short sidenum[2];
|
||||
} PACKEDATTR maplinedef_t;
|
||||
|
||||
|
||||
//
|
||||
// LineDef attributes.
|
||||
//
|
||||
|
||||
// Solid, is an obstacle.
|
||||
#define ML_BLOCKING 1
|
||||
|
||||
// Blocks monsters only.
|
||||
#define ML_BLOCKMONSTERS 2
|
||||
|
||||
// Backside will not be present at all
|
||||
// if not two sided.
|
||||
#define ML_TWOSIDED 4
|
||||
|
||||
// If a texture is pegged, the texture will have
|
||||
// the end exposed to air held constant at the
|
||||
// top or bottom of the texture (stairs or pulled
|
||||
// down things) and will move with a height change
|
||||
// of one of the neighbor sectors.
|
||||
// Unpegged textures allways have the first row of
|
||||
// the texture at the top pixel of the line for both
|
||||
// top and bottom textures (use next to windows).
|
||||
|
||||
// upper texture unpegged
|
||||
#define ML_DONTPEGTOP 8
|
||||
|
||||
// lower texture unpegged
|
||||
#define ML_DONTPEGBOTTOM 16
|
||||
|
||||
// In AutoMap: don't map as two sided: IT'S A SECRET!
|
||||
#define ML_SECRET 32
|
||||
|
||||
// Sound rendering: don't let sound cross two of these.
|
||||
#define ML_SOUNDBLOCK 64
|
||||
|
||||
// Don't draw on the automap at all.
|
||||
#define ML_DONTDRAW 128
|
||||
|
||||
// Set if already seen, thus drawn in automap.
|
||||
#define ML_MAPPED 256
|
||||
|
||||
|
||||
|
||||
|
||||
// Sector definition, from editing.
|
||||
typedef struct
|
||||
{
|
||||
short floorheight;
|
||||
short ceilingheight;
|
||||
char floorpic[8];
|
||||
char ceilingpic[8];
|
||||
short lightlevel;
|
||||
short special;
|
||||
short tag;
|
||||
} PACKEDATTR mapsector_t;
|
||||
|
||||
// SubSector, as generated by BSP.
|
||||
typedef struct
|
||||
{
|
||||
short numsegs;
|
||||
// Index of first one, segs are stored sequentially.
|
||||
short firstseg;
|
||||
} PACKEDATTR mapsubsector_t;
|
||||
|
||||
|
||||
// LineSeg, generated by splitting LineDefs
|
||||
// using partition lines selected by BSP builder.
|
||||
typedef struct
|
||||
{
|
||||
short v1;
|
||||
short v2;
|
||||
short angle;
|
||||
short linedef;
|
||||
short side;
|
||||
short offset;
|
||||
} PACKEDATTR mapseg_t;
|
||||
|
||||
|
||||
|
||||
// BSP node structure.
|
||||
|
||||
// Indicate a leaf.
|
||||
#define NF_SUBSECTOR 0x8000
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Partition line from (x,y) to x+dx,y+dy)
|
||||
short x;
|
||||
short y;
|
||||
short dx;
|
||||
short dy;
|
||||
|
||||
// Bounding box for each child,
|
||||
// clip against view frustum.
|
||||
short bbox[2][4];
|
||||
|
||||
// If NF_SUBSECTOR its a subsector,
|
||||
// else it's a node of another subtree.
|
||||
unsigned short children[2];
|
||||
|
||||
} PACKEDATTR mapnode_t;
|
||||
|
||||
|
||||
|
||||
|
||||
// Thing definition, position, orientation and type,
|
||||
// plus skill/visibility flags and attributes.
|
||||
typedef struct
|
||||
{
|
||||
short x;
|
||||
short y;
|
||||
short angle;
|
||||
short type;
|
||||
short options;
|
||||
} PACKEDATTR mapthing_t;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // __DOOMDATA__
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// all external data is defined here
|
||||
// most of the data is loaded into different structures at run time
|
||||
// some internal structures shared by many modules are here
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __DOOMDATA__
|
||||
#define __DOOMDATA__
|
||||
|
||||
// The most basic types we use, portability.
|
||||
#include "doomtype.h"
|
||||
|
||||
// Some global defines, that configure the game.
|
||||
#include "doomdef.h"
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Map level types.
|
||||
// The following data structures define the persistent format
|
||||
// used in the lumps of the WAD files.
|
||||
//
|
||||
|
||||
// Lump order in a map WAD: each map needs a couple of lumps
|
||||
// to provide a complete scene geometry description.
|
||||
enum
|
||||
{
|
||||
ML_LABEL, // A separator, name, ExMx or MAPxx
|
||||
ML_THINGS, // Monsters, items..
|
||||
ML_LINEDEFS, // LineDefs, from editing
|
||||
ML_SIDEDEFS, // SideDefs, from editing
|
||||
ML_VERTEXES, // Vertices, edited and BSP splits generated
|
||||
ML_SEGS, // LineSegs, from LineDefs split by BSP
|
||||
ML_SSECTORS, // SubSectors, list of LineSegs
|
||||
ML_NODES, // BSP nodes
|
||||
ML_SECTORS, // Sectors, from editing
|
||||
ML_REJECT, // LUT, sector-sector visibility
|
||||
ML_BLOCKMAP, // LUT, motion clipping, walls/grid element
|
||||
|
||||
ML_BEHAVIOR // HEXEN ONLY: compiled ACS scripts
|
||||
};
|
||||
|
||||
|
||||
// A single Vertex.
|
||||
typedef struct
|
||||
{
|
||||
short x;
|
||||
short y;
|
||||
} PACKEDATTR mapvertex_t;
|
||||
|
||||
|
||||
// A SideDef, defining the visual appearance of a wall,
|
||||
// by setting textures and offsets.
|
||||
typedef struct
|
||||
{
|
||||
short textureoffset;
|
||||
short rowoffset;
|
||||
char toptexture[8];
|
||||
char bottomtexture[8];
|
||||
char midtexture[8];
|
||||
// Front sector, towards viewer.
|
||||
short sector;
|
||||
} PACKEDATTR mapsidedef_t;
|
||||
|
||||
|
||||
|
||||
// A LineDef, as used for editing, and as input
|
||||
// to the BSP builder.
|
||||
typedef struct
|
||||
{
|
||||
short v1;
|
||||
short v2;
|
||||
short flags;
|
||||
short special;
|
||||
short tag;
|
||||
// sidenum[1] will be -1 if one sided
|
||||
short sidenum[2];
|
||||
} PACKEDATTR maplinedef_t;
|
||||
|
||||
|
||||
// the Hexen LineDef structure [andrewj: added this]
|
||||
typedef struct
|
||||
{
|
||||
short v1;
|
||||
short v2;
|
||||
short flags;
|
||||
unsigned char special;
|
||||
unsigned char args[5];
|
||||
short sidenum[2];
|
||||
} PACKEDATTR maplinedef_hexen_t;
|
||||
|
||||
|
||||
//
|
||||
// LineDef attributes.
|
||||
//
|
||||
|
||||
// Solid, is an obstacle.
|
||||
#define ML_BLOCKING 1
|
||||
|
||||
// Blocks monsters only.
|
||||
#define ML_BLOCKMONSTERS 2
|
||||
|
||||
// Backside will not be present at all
|
||||
// if not two sided.
|
||||
#define ML_TWOSIDED 4
|
||||
|
||||
// If a texture is pegged, the texture will have
|
||||
// the end exposed to air held constant at the
|
||||
// top or bottom of the texture (stairs or pulled
|
||||
// down things) and will move with a height change
|
||||
// of one of the neighbor sectors.
|
||||
// Unpegged textures allways have the first row of
|
||||
// the texture at the top pixel of the line for both
|
||||
// top and bottom textures (use next to windows).
|
||||
|
||||
// upper texture unpegged
|
||||
#define ML_DONTPEGTOP 8
|
||||
|
||||
// lower texture unpegged
|
||||
#define ML_DONTPEGBOTTOM 16
|
||||
|
||||
// In AutoMap: don't map as two sided: IT'S A SECRET!
|
||||
#define ML_SECRET 32
|
||||
|
||||
// Sound rendering: don't let sound cross two of these.
|
||||
#define ML_SOUNDBLOCK 64
|
||||
|
||||
// Don't draw on the automap at all.
|
||||
#define ML_DONTDRAW 128
|
||||
|
||||
// Set if already seen, thus drawn in automap.
|
||||
#define ML_MAPPED 256
|
||||
|
||||
|
||||
|
||||
|
||||
// Sector definition, from editing.
|
||||
typedef struct
|
||||
{
|
||||
short floorheight;
|
||||
short ceilingheight;
|
||||
char floorpic[8];
|
||||
char ceilingpic[8];
|
||||
short lightlevel;
|
||||
short special;
|
||||
short tag;
|
||||
} PACKEDATTR mapsector_t;
|
||||
|
||||
// SubSector, as generated by BSP.
|
||||
typedef struct
|
||||
{
|
||||
short numsegs;
|
||||
// Index of first one, segs are stored sequentially.
|
||||
short firstseg;
|
||||
} PACKEDATTR mapsubsector_t;
|
||||
|
||||
|
||||
// LineSeg, generated by splitting LineDefs
|
||||
// using partition lines selected by BSP builder.
|
||||
typedef struct
|
||||
{
|
||||
short v1;
|
||||
short v2;
|
||||
short angle;
|
||||
short linedef;
|
||||
short side;
|
||||
short offset;
|
||||
} PACKEDATTR mapseg_t;
|
||||
|
||||
|
||||
|
||||
// BSP node structure.
|
||||
|
||||
// Indicate a leaf.
|
||||
#define NF_SUBSECTOR 0x8000
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Partition line from (x,y) to x+dx,y+dy)
|
||||
short x;
|
||||
short y;
|
||||
short dx;
|
||||
short dy;
|
||||
|
||||
// Bounding box for each child,
|
||||
// clip against view frustum.
|
||||
short bbox[2][4];
|
||||
|
||||
// If NF_SUBSECTOR its a subsector,
|
||||
// else it's a node of another subtree.
|
||||
unsigned short children[2];
|
||||
|
||||
} PACKEDATTR mapnode_t;
|
||||
|
||||
|
||||
|
||||
|
||||
// Thing definition, position, orientation and type,
|
||||
// plus skill/visibility flags and attributes.
|
||||
typedef struct
|
||||
{
|
||||
short x;
|
||||
short y;
|
||||
short angle;
|
||||
short type;
|
||||
short options;
|
||||
} PACKEDATTR mapthing_t;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // __DOOMDATA__
|
||||
|
|
|
@ -1,258 +1,258 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Internally used data structures for virtually everything,
|
||||
// lots of other stuff.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __DOOMDEF__
|
||||
#define __DOOMDEF__
|
||||
|
||||
|
||||
// #define macros to provide functions missing in Windows.
|
||||
// Outside Windows, we use strings.h for str[n]casecmp.
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#define snprintf _snprintf
|
||||
#define vsnprintf _vsnprintf
|
||||
#define strcasecmp stricmp
|
||||
#define strncasecmp strnicmp
|
||||
|
||||
#else
|
||||
|
||||
#include <strings.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// The packed attribute forces structures to be packed into the minimum
|
||||
// space necessary. If this is not done, the compiler may align structure
|
||||
// fields differently to optimize memory access, inflating the overall
|
||||
// structure size. It is important to use the packed attribute on certain
|
||||
// structures where alignment is important, particularly data read/written
|
||||
// to disk.
|
||||
//
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define PACKEDATTR __attribute__((packed))
|
||||
#else
|
||||
#define PACKEDATTR
|
||||
#endif
|
||||
|
||||
//
|
||||
// Global parameters/defines.
|
||||
//
|
||||
// DOOM version
|
||||
#define DOOM_VERSION 109
|
||||
|
||||
// Version code for cph's longtics hack ("v1.91")
|
||||
#define DOOM_191_VERSION 111
|
||||
|
||||
|
||||
// Game mode handling - identify IWAD version
|
||||
// to handle IWAD dependend animations etc.
|
||||
typedef enum
|
||||
{
|
||||
shareware, // DOOM 1 shareware, E1, M9
|
||||
registered, // DOOM 1 registered, E3, M27
|
||||
commercial, // DOOM 2 retail, E1 M34
|
||||
// DOOM 2 german edition not handled
|
||||
retail, // DOOM 1 retail, E4, M36
|
||||
indetermined // Well, no IWAD found.
|
||||
|
||||
} GameMode_t;
|
||||
|
||||
|
||||
// Mission packs - might be useful for TC stuff?
|
||||
typedef enum
|
||||
{
|
||||
doom, // DOOM 1
|
||||
doom2, // DOOM 2
|
||||
pack_tnt, // TNT mission pack
|
||||
pack_plut, // Plutonia pack
|
||||
none
|
||||
|
||||
} GameMission_t;
|
||||
|
||||
// What version are we emulating?
|
||||
|
||||
typedef enum
|
||||
{
|
||||
exe_doom_1_9, // Doom 1.9: used for shareware, registered and commercial
|
||||
exe_hacx, // Hacx executable (Doom 1.9 with patch applied)
|
||||
exe_ultimate, // Ultimate Doom (retail)
|
||||
exe_final, // Final Doom
|
||||
exe_final2, // Final Doom (alternate exe)
|
||||
exe_chex, // Chex Quest executable (based on Final Doom)
|
||||
} GameVersion_t;
|
||||
|
||||
|
||||
// If rangecheck is undefined,
|
||||
// most parameter validation debugging code will not be compiled
|
||||
#define RANGECHECK
|
||||
|
||||
|
||||
|
||||
// Screen width and height.
|
||||
|
||||
#define SCREENWIDTH 320
|
||||
#define SCREENHEIGHT 200
|
||||
|
||||
// Screen width used for "squash" scale functions
|
||||
|
||||
#define SCREENWIDTH_4_3 256
|
||||
|
||||
// Screen height used for "stretch" scale functions.
|
||||
|
||||
#define SCREENHEIGHT_4_3 240
|
||||
|
||||
// The maximum number of players, multiplayer/networking.
|
||||
#define MAXPLAYERS 4
|
||||
|
||||
// State updates, number of tics / second.
|
||||
#define TICRATE 35
|
||||
|
||||
// The current state of the game: whether we are
|
||||
// playing, gazing at the intermission screen,
|
||||
// the game final animation, or a demo.
|
||||
typedef enum
|
||||
{
|
||||
GS_LEVEL,
|
||||
GS_INTERMISSION,
|
||||
GS_FINALE,
|
||||
GS_DEMOSCREEN,
|
||||
} gamestate_t;
|
||||
|
||||
//
|
||||
// Difficulty/skill settings/filters.
|
||||
//
|
||||
|
||||
// Skill flags.
|
||||
#define MTF_EASY 1
|
||||
#define MTF_NORMAL 2
|
||||
#define MTF_HARD 4
|
||||
|
||||
// Deaf monsters/do not react to sound.
|
||||
#define MTF_AMBUSH 8
|
||||
|
||||
typedef enum
|
||||
{
|
||||
sk_noitems = -1, // the "-skill 0" hack
|
||||
sk_baby = 0,
|
||||
sk_easy,
|
||||
sk_medium,
|
||||
sk_hard,
|
||||
sk_nightmare
|
||||
} skill_t;
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Key cards.
|
||||
//
|
||||
typedef enum
|
||||
{
|
||||
it_bluecard,
|
||||
it_yellowcard,
|
||||
it_redcard,
|
||||
it_blueskull,
|
||||
it_yellowskull,
|
||||
it_redskull,
|
||||
|
||||
NUMCARDS
|
||||
|
||||
} card_t;
|
||||
|
||||
|
||||
|
||||
// The defined weapons,
|
||||
// including a marker indicating
|
||||
// user has not changed weapon.
|
||||
typedef enum
|
||||
{
|
||||
wp_fist,
|
||||
wp_pistol,
|
||||
wp_shotgun,
|
||||
wp_chaingun,
|
||||
wp_missile,
|
||||
wp_plasma,
|
||||
wp_bfg,
|
||||
wp_chainsaw,
|
||||
wp_supershotgun,
|
||||
|
||||
NUMWEAPONS,
|
||||
|
||||
// No pending weapon change.
|
||||
wp_nochange
|
||||
|
||||
} weapontype_t;
|
||||
|
||||
|
||||
// Ammunition types defined.
|
||||
typedef enum
|
||||
{
|
||||
am_clip, // Pistol / chaingun ammo.
|
||||
am_shell, // Shotgun / double barreled shotgun.
|
||||
am_cell, // Plasma rifle, BFG.
|
||||
am_misl, // Missile launcher.
|
||||
NUMAMMO,
|
||||
am_noammo // Unlimited for chainsaw / fist.
|
||||
|
||||
} ammotype_t;
|
||||
|
||||
|
||||
// Power up artifacts.
|
||||
typedef enum
|
||||
{
|
||||
pw_invulnerability,
|
||||
pw_strength,
|
||||
pw_invisibility,
|
||||
pw_ironfeet,
|
||||
pw_allmap,
|
||||
pw_infrared,
|
||||
NUMPOWERS
|
||||
|
||||
} powertype_t;
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Power up durations,
|
||||
// how many seconds till expiration,
|
||||
// assuming TICRATE is 35 ticks/second.
|
||||
//
|
||||
typedef enum
|
||||
{
|
||||
INVULNTICS = (30*TICRATE),
|
||||
INVISTICS = (60*TICRATE),
|
||||
INFRATICS = (120*TICRATE),
|
||||
IRONTICS = (60*TICRATE)
|
||||
|
||||
} powerduration_t;
|
||||
|
||||
|
||||
#endif // __DOOMDEF__
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Internally used data structures for virtually everything,
|
||||
// lots of other stuff.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __DOOMDEF__
|
||||
#define __DOOMDEF__
|
||||
|
||||
|
||||
// #define macros to provide functions missing in Windows.
|
||||
// Outside Windows, we use strings.h for str[n]casecmp.
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#define snprintf _snprintf
|
||||
#define vsnprintf _vsnprintf
|
||||
#define strcasecmp stricmp
|
||||
#define strncasecmp strnicmp
|
||||
|
||||
#else
|
||||
|
||||
#include <strings.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// The packed attribute forces structures to be packed into the minimum
|
||||
// space necessary. If this is not done, the compiler may align structure
|
||||
// fields differently to optimize memory access, inflating the overall
|
||||
// structure size. It is important to use the packed attribute on certain
|
||||
// structures where alignment is important, particularly data read/written
|
||||
// to disk.
|
||||
//
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define PACKEDATTR __attribute__((packed))
|
||||
#else
|
||||
#define PACKEDATTR
|
||||
#endif
|
||||
|
||||
//
|
||||
// Global parameters/defines.
|
||||
//
|
||||
// DOOM version
|
||||
#define DOOM_VERSION 109
|
||||
|
||||
// Version code for cph's longtics hack ("v1.91")
|
||||
#define DOOM_191_VERSION 111
|
||||
|
||||
|
||||
// Game mode handling - identify IWAD version
|
||||
// to handle IWAD dependend animations etc.
|
||||
typedef enum
|
||||
{
|
||||
shareware, // DOOM 1 shareware, E1, M9
|
||||
registered, // DOOM 1 registered, E3, M27
|
||||
commercial, // DOOM 2 retail, E1 M34
|
||||
// DOOM 2 german edition not handled
|
||||
retail, // DOOM 1 retail, E4, M36
|
||||
indetermined // Well, no IWAD found.
|
||||
|
||||
} GameMode_t;
|
||||
|
||||
|
||||
// Mission packs - might be useful for TC stuff?
|
||||
typedef enum
|
||||
{
|
||||
doom, // DOOM 1
|
||||
doom2, // DOOM 2
|
||||
pack_tnt, // TNT mission pack
|
||||
pack_plut, // Plutonia pack
|
||||
none
|
||||
|
||||
} GameMission_t;
|
||||
|
||||
// What version are we emulating?
|
||||
|
||||
typedef enum
|
||||
{
|
||||
exe_doom_1_9, // Doom 1.9: used for shareware, registered and commercial
|
||||
exe_hacx, // Hacx executable (Doom 1.9 with patch applied)
|
||||
exe_ultimate, // Ultimate Doom (retail)
|
||||
exe_final, // Final Doom
|
||||
exe_final2, // Final Doom (alternate exe)
|
||||
exe_chex, // Chex Quest executable (based on Final Doom)
|
||||
} GameVersion_t;
|
||||
|
||||
|
||||
// If rangecheck is undefined,
|
||||
// most parameter validation debugging code will not be compiled
|
||||
#define RANGECHECK
|
||||
|
||||
|
||||
|
||||
// Screen width and height.
|
||||
|
||||
#define SCREENWIDTH 320
|
||||
#define SCREENHEIGHT 200
|
||||
|
||||
// Screen width used for "squash" scale functions
|
||||
|
||||
#define SCREENWIDTH_4_3 256
|
||||
|
||||
// Screen height used for "stretch" scale functions.
|
||||
|
||||
#define SCREENHEIGHT_4_3 240
|
||||
|
||||
// The maximum number of players, multiplayer/networking.
|
||||
#define MAXPLAYERS 4
|
||||
|
||||
// State updates, number of tics / second.
|
||||
#define TICRATE 35
|
||||
|
||||
// The current state of the game: whether we are
|
||||
// playing, gazing at the intermission screen,
|
||||
// the game final animation, or a demo.
|
||||
typedef enum
|
||||
{
|
||||
GS_LEVEL,
|
||||
GS_INTERMISSION,
|
||||
GS_FINALE,
|
||||
GS_DEMOSCREEN,
|
||||
} gamestate_t;
|
||||
|
||||
//
|
||||
// Difficulty/skill settings/filters.
|
||||
//
|
||||
|
||||
// Skill flags.
|
||||
#define MTF_EASY 1
|
||||
#define MTF_NORMAL 2
|
||||
#define MTF_HARD 4
|
||||
|
||||
// Deaf monsters/do not react to sound.
|
||||
#define MTF_AMBUSH 8
|
||||
|
||||
typedef enum
|
||||
{
|
||||
sk_noitems = -1, // the "-skill 0" hack
|
||||
sk_baby = 0,
|
||||
sk_easy,
|
||||
sk_medium,
|
||||
sk_hard,
|
||||
sk_nightmare
|
||||
} skill_t;
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Key cards.
|
||||
//
|
||||
typedef enum
|
||||
{
|
||||
it_bluecard,
|
||||
it_yellowcard,
|
||||
it_redcard,
|
||||
it_blueskull,
|
||||
it_yellowskull,
|
||||
it_redskull,
|
||||
|
||||
NUMCARDS
|
||||
|
||||
} card_t;
|
||||
|
||||
|
||||
|
||||
// The defined weapons,
|
||||
// including a marker indicating
|
||||
// user has not changed weapon.
|
||||
typedef enum
|
||||
{
|
||||
wp_fist,
|
||||
wp_pistol,
|
||||
wp_shotgun,
|
||||
wp_chaingun,
|
||||
wp_missile,
|
||||
wp_plasma,
|
||||
wp_bfg,
|
||||
wp_chainsaw,
|
||||
wp_supershotgun,
|
||||
|
||||
NUMWEAPONS,
|
||||
|
||||
// No pending weapon change.
|
||||
wp_nochange
|
||||
|
||||
} weapontype_t;
|
||||
|
||||
|
||||
// Ammunition types defined.
|
||||
typedef enum
|
||||
{
|
||||
am_clip, // Pistol / chaingun ammo.
|
||||
am_shell, // Shotgun / double barreled shotgun.
|
||||
am_cell, // Plasma rifle, BFG.
|
||||
am_misl, // Missile launcher.
|
||||
NUMAMMO,
|
||||
am_noammo // Unlimited for chainsaw / fist.
|
||||
|
||||
} ammotype_t;
|
||||
|
||||
|
||||
// Power up artifacts.
|
||||
typedef enum
|
||||
{
|
||||
pw_invulnerability,
|
||||
pw_strength,
|
||||
pw_invisibility,
|
||||
pw_ironfeet,
|
||||
pw_allmap,
|
||||
pw_infrared,
|
||||
NUMPOWERS
|
||||
|
||||
} powertype_t;
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Power up durations,
|
||||
// how many seconds till expiration,
|
||||
// assuming TICRATE is 35 ticks/second.
|
||||
//
|
||||
typedef enum
|
||||
{
|
||||
INVULNTICS = (30*TICRATE),
|
||||
INVISTICS = (60*TICRATE),
|
||||
INFRATICS = (120*TICRATE),
|
||||
IRONTICS = (60*TICRATE)
|
||||
|
||||
} powerduration_t;
|
||||
|
||||
|
||||
#endif // __DOOMDEF__
|
||||
|
|
|
@ -1,84 +1,84 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Simple basic typedefs, isolated here to make it easier
|
||||
// separating modules.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __DOOMTYPE__
|
||||
#define __DOOMTYPE__
|
||||
|
||||
// Windows CE is missing some vital ANSI C functions. We have to
|
||||
// use our own replacements.
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
#include "libc_wince.h"
|
||||
#endif
|
||||
|
||||
// C99 integer types; with gcc we just use this. Other compilers
|
||||
// should add conditional statements that define the C99 types.
|
||||
|
||||
// What is really wanted here is stdint.h; however, some old versions
|
||||
// of Solaris don't have stdint.h and only have inttypes.h (the
|
||||
// pre-standardisation version). inttypes.h is also in the C99
|
||||
// standard and defined to include stdint.h, so include this.
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
// Use builtin bool type with C++.
|
||||
|
||||
typedef bool boolean;
|
||||
|
||||
#else
|
||||
|
||||
typedef enum
|
||||
{
|
||||
false,
|
||||
true
|
||||
} boolean;
|
||||
|
||||
#endif
|
||||
|
||||
typedef uint8_t byte;
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#define DIR_SEPARATOR '\\'
|
||||
#define PATH_SEPARATOR ';'
|
||||
|
||||
#else
|
||||
|
||||
#define DIR_SEPARATOR '/'
|
||||
#define PATH_SEPARATOR ':'
|
||||
|
||||
#endif
|
||||
|
||||
#define arrlen(array) (sizeof(array) / sizeof(*array))
|
||||
|
||||
#endif
|
||||
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Simple basic typedefs, isolated here to make it easier
|
||||
// separating modules.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __DOOMTYPE__
|
||||
#define __DOOMTYPE__
|
||||
|
||||
// Windows CE is missing some vital ANSI C functions. We have to
|
||||
// use our own replacements.
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
#include "libc_wince.h"
|
||||
#endif
|
||||
|
||||
// C99 integer types; with gcc we just use this. Other compilers
|
||||
// should add conditional statements that define the C99 types.
|
||||
|
||||
// What is really wanted here is stdint.h; however, some old versions
|
||||
// of Solaris don't have stdint.h and only have inttypes.h (the
|
||||
// pre-standardisation version). inttypes.h is also in the C99
|
||||
// standard and defined to include stdint.h, so include this.
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
// Use builtin bool type with C++.
|
||||
|
||||
typedef bool boolean;
|
||||
|
||||
#else
|
||||
|
||||
typedef enum
|
||||
{
|
||||
false,
|
||||
true
|
||||
} boolean;
|
||||
|
||||
#endif
|
||||
|
||||
typedef uint8_t byte;
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#define DIR_SEPARATOR '\\'
|
||||
#define PATH_SEPARATOR ';'
|
||||
|
||||
#else
|
||||
|
||||
#define DIR_SEPARATOR '/'
|
||||
#define PATH_SEPARATOR ':'
|
||||
|
||||
#endif
|
||||
|
||||
#define arrlen(array) (sizeof(array) / sizeof(*array))
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,61 +1,61 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Main loop menu stuff.
|
||||
// Random number LUT.
|
||||
// Default Config File.
|
||||
// PCX Screenshots.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "vpo_local.h"
|
||||
|
||||
namespace vpo
|
||||
{
|
||||
|
||||
|
||||
void M_ClearBox (fixed_t *box)
|
||||
{
|
||||
box[BOXTOP] = box[BOXRIGHT] = INT_MIN;
|
||||
box[BOXBOTTOM] = box[BOXLEFT] = INT_MAX;
|
||||
}
|
||||
|
||||
void
|
||||
M_AddToBox
|
||||
( fixed_t* box,
|
||||
fixed_t x,
|
||||
fixed_t y )
|
||||
{
|
||||
if (x<box[BOXLEFT])
|
||||
box[BOXLEFT] = x;
|
||||
else if (x>box[BOXRIGHT])
|
||||
box[BOXRIGHT] = x;
|
||||
if (y<box[BOXBOTTOM])
|
||||
box[BOXBOTTOM] = y;
|
||||
else if (y>box[BOXTOP])
|
||||
box[BOXTOP] = y;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace vpo
|
||||
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Main loop menu stuff.
|
||||
// Random number LUT.
|
||||
// Default Config File.
|
||||
// PCX Screenshots.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "vpo_local.h"
|
||||
|
||||
namespace vpo
|
||||
{
|
||||
|
||||
|
||||
void M_ClearBox (fixed_t *box)
|
||||
{
|
||||
box[BOXTOP] = box[BOXRIGHT] = INT_MIN;
|
||||
box[BOXBOTTOM] = box[BOXLEFT] = INT_MAX;
|
||||
}
|
||||
|
||||
void
|
||||
M_AddToBox
|
||||
( fixed_t* box,
|
||||
fixed_t x,
|
||||
fixed_t y )
|
||||
{
|
||||
if (x<box[BOXLEFT])
|
||||
box[BOXLEFT] = x;
|
||||
else if (x>box[BOXRIGHT])
|
||||
box[BOXRIGHT] = x;
|
||||
if (y<box[BOXBOTTOM])
|
||||
box[BOXBOTTOM] = y;
|
||||
else if (y>box[BOXTOP])
|
||||
box[BOXTOP] = y;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace vpo
|
||||
|
||||
|
|
|
@ -1,55 +1,55 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Nil.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __M_BBOX__
|
||||
#define __M_BBOX__
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "m_fixed.h"
|
||||
|
||||
|
||||
// Bounding box coordinate storage.
|
||||
enum
|
||||
{
|
||||
BOXTOP,
|
||||
BOXBOTTOM,
|
||||
BOXLEFT,
|
||||
BOXRIGHT
|
||||
}; // bbox coordinates
|
||||
|
||||
// Bounding box functions.
|
||||
void M_ClearBox (fixed_t* box);
|
||||
|
||||
void
|
||||
M_AddToBox
|
||||
( fixed_t* box,
|
||||
fixed_t x,
|
||||
fixed_t y );
|
||||
|
||||
|
||||
#endif
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Nil.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __M_BBOX__
|
||||
#define __M_BBOX__
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "m_fixed.h"
|
||||
|
||||
|
||||
// Bounding box coordinate storage.
|
||||
enum
|
||||
{
|
||||
BOXTOP,
|
||||
BOXBOTTOM,
|
||||
BOXLEFT,
|
||||
BOXRIGHT
|
||||
}; // bbox coordinates
|
||||
|
||||
// Bounding box functions.
|
||||
void M_ClearBox (fixed_t* box);
|
||||
|
||||
void
|
||||
M_AddToBox
|
||||
( fixed_t* box,
|
||||
fixed_t x,
|
||||
fixed_t y );
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,66 +1,66 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Fixed point implementation.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "vpo_local.h"
|
||||
|
||||
namespace vpo
|
||||
{
|
||||
|
||||
// Fixme. __USE_C_FIXED__ or something.
|
||||
|
||||
fixed_t
|
||||
FixedMul
|
||||
( fixed_t a,
|
||||
fixed_t b )
|
||||
{
|
||||
return ((int64_t) a * (int64_t) b) >> FRACBITS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// FixedDiv, C version.
|
||||
//
|
||||
|
||||
fixed_t FixedDiv(fixed_t a, fixed_t b)
|
||||
{
|
||||
if ((abs(a) >> 14) >= abs(b))
|
||||
{
|
||||
return (a^b) < 0 ? INT_MIN : INT_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
int64_t result;
|
||||
|
||||
result = ((int64_t) a << 16) / b;
|
||||
|
||||
return (fixed_t) result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace vpo
|
||||
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Fixed point implementation.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "vpo_local.h"
|
||||
|
||||
namespace vpo
|
||||
{
|
||||
|
||||
// Fixme. __USE_C_FIXED__ or something.
|
||||
|
||||
fixed_t
|
||||
FixedMul
|
||||
( fixed_t a,
|
||||
fixed_t b )
|
||||
{
|
||||
return ((int64_t) a * (int64_t) b) >> FRACBITS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// FixedDiv, C version.
|
||||
//
|
||||
|
||||
fixed_t FixedDiv(fixed_t a, fixed_t b)
|
||||
{
|
||||
if ((abs(a) >> 14) >= abs(b))
|
||||
{
|
||||
return (a^b) < 0 ? INT_MIN : INT_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
int64_t result;
|
||||
|
||||
result = ((int64_t) a << 16) / b;
|
||||
|
||||
return (fixed_t) result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace vpo
|
||||
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Fixed point arithemtics, implementation.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __M_FIXED__
|
||||
#define __M_FIXED__
|
||||
|
||||
//
|
||||
// Fixed point, 32bit as 16.16.
|
||||
//
|
||||
#define FRACBITS 16
|
||||
#define FRACUNIT (1<<FRACBITS)
|
||||
|
||||
typedef int fixed_t;
|
||||
|
||||
fixed_t FixedMul (fixed_t a, fixed_t b);
|
||||
fixed_t FixedDiv (fixed_t a, fixed_t b);
|
||||
|
||||
#endif
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Fixed point arithemtics, implementation.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __M_FIXED__
|
||||
#define __M_FIXED__
|
||||
|
||||
//
|
||||
// Fixed point, 32bit as 16.16.
|
||||
//
|
||||
#define FRACBITS 16
|
||||
#define FRACUNIT (1<<FRACBITS)
|
||||
|
||||
typedef int fixed_t;
|
||||
|
||||
fixed_t FixedMul (fixed_t a, fixed_t b);
|
||||
fixed_t FixedDiv (fixed_t a, fixed_t b);
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,57 +1,57 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Refresh module, BSP traversal and handling.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __R_BSP__
|
||||
#define __R_BSP__
|
||||
|
||||
extern seg_t* curline;
|
||||
extern side_t* sidedef;
|
||||
extern line_t* linedef;
|
||||
extern sector_t* frontsector;
|
||||
extern sector_t* backsector;
|
||||
|
||||
extern int rw_x;
|
||||
extern int rw_stopx;
|
||||
|
||||
extern boolean segtextured;
|
||||
|
||||
// false if the back side is the same plane
|
||||
extern boolean markfloor;
|
||||
extern boolean markceiling;
|
||||
|
||||
extern boolean skymap;
|
||||
|
||||
extern drawseg_t drawsegs[MAXDRAWSEGS+10];
|
||||
extern drawseg_t* ds_p;
|
||||
|
||||
|
||||
// BSP?
|
||||
void R_ClearClipSegs (void);
|
||||
void R_ClearDrawSegs (void);
|
||||
|
||||
void R_RenderBSPNode (int bspnum);
|
||||
|
||||
#endif
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Refresh module, BSP traversal and handling.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __R_BSP__
|
||||
#define __R_BSP__
|
||||
|
||||
extern seg_t* curline;
|
||||
extern side_t* sidedef;
|
||||
extern line_t* linedef;
|
||||
extern sector_t* frontsector;
|
||||
extern sector_t* backsector;
|
||||
|
||||
extern int rw_x;
|
||||
extern int rw_stopx;
|
||||
|
||||
extern boolean segtextured;
|
||||
|
||||
// false if the back side is the same plane
|
||||
extern boolean markfloor;
|
||||
extern boolean markceiling;
|
||||
|
||||
extern boolean skymap;
|
||||
|
||||
extern drawseg_t drawsegs[MAXDRAWSEGS+10];
|
||||
extern drawseg_t* ds_p;
|
||||
|
||||
|
||||
// BSP?
|
||||
void R_ClearClipSegs (void);
|
||||
void R_ClearDrawSegs (void);
|
||||
|
||||
void R_RenderBSPNode (int bspnum);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,321 +1,308 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Refresh/rendering module, shared data struct definitions.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __R_DEFS__
|
||||
#define __R_DEFS__
|
||||
|
||||
|
||||
// Silhouette, needed for clipping Segs (mainly)
|
||||
// and sprites representing things.
|
||||
#define SIL_NONE 0
|
||||
#define SIL_BOTTOM 1
|
||||
#define SIL_TOP 2
|
||||
#define SIL_BOTH 3
|
||||
|
||||
// #define MAXDRAWSEGS 256
|
||||
#define MAXDRAWSEGS 1024 // andrewj: increased for Visplane Explorer
|
||||
|
||||
|
||||
#define skyflatnum 2
|
||||
|
||||
|
||||
//
|
||||
// INTERNAL MAP TYPES
|
||||
// used by play and refresh
|
||||
//
|
||||
|
||||
//
|
||||
// Your plain vanilla vertex.
|
||||
// Note: transformed values not buffered locally,
|
||||
// like some DOOM-alikes ("wt", "WebView") did.
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
fixed_t x;
|
||||
fixed_t y;
|
||||
|
||||
} vertex_t;
|
||||
|
||||
|
||||
// Forward of LineDefs, for Sectors.
|
||||
struct line_s;
|
||||
|
||||
|
||||
//
|
||||
// The SECTORS record, at runtime.
|
||||
// Stores things/mobjs.
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
fixed_t floorheight;
|
||||
fixed_t ceilingheight;
|
||||
|
||||
short floorpic;
|
||||
short ceilingpic;
|
||||
short lightlevel;
|
||||
short special;
|
||||
short tag;
|
||||
|
||||
// 0 = untraversed, 1,2 = sndlines -1
|
||||
int soundtraversed;
|
||||
|
||||
/// // thing that made a sound (or null)
|
||||
/// mobj_t* soundtarget;
|
||||
|
||||
/// // mapblock bounding box for height changes
|
||||
/// int blockbox[4];
|
||||
|
||||
// origin for any sounds played by the sector
|
||||
/// degenmobj_t soundorg;
|
||||
|
||||
// if == validcount, already checked
|
||||
int validcount;
|
||||
|
||||
/// // list of mobjs in sector
|
||||
/// mobj_t* thinglist;
|
||||
|
||||
// thinker_t for reversable actions
|
||||
void* specialdata;
|
||||
|
||||
int linecount;
|
||||
struct line_s** lines; // [linecount] size
|
||||
|
||||
} sector_t;
|
||||
|
||||
|
||||
|
||||
//
|
||||
// The SideDef.
|
||||
//
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// add this to the calculated texture column
|
||||
fixed_t textureoffset;
|
||||
|
||||
// add this to the calculated texture top
|
||||
fixed_t rowoffset;
|
||||
|
||||
// Texture indices.
|
||||
// We do not maintain names here.
|
||||
short toptexture;
|
||||
short bottomtexture;
|
||||
short midtexture;
|
||||
|
||||
// Sector the SideDef is facing.
|
||||
sector_t* sector;
|
||||
|
||||
} side_t;
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Move clipping aid for LineDefs.
|
||||
//
|
||||
typedef enum
|
||||
{
|
||||
ST_HORIZONTAL,
|
||||
ST_VERTICAL,
|
||||
ST_POSITIVE,
|
||||
ST_NEGATIVE
|
||||
|
||||
} slopetype_t;
|
||||
|
||||
|
||||
|
||||
typedef struct line_s
|
||||
{
|
||||
// Vertices, from v1 to v2.
|
||||
vertex_t* v1;
|
||||
vertex_t* v2;
|
||||
|
||||
// Precalculated v2 - v1 for side checking.
|
||||
fixed_t dx;
|
||||
fixed_t dy;
|
||||
|
||||
// Animation related.
|
||||
short flags;
|
||||
short special;
|
||||
short tag;
|
||||
|
||||
// Visual appearance: SideDefs.
|
||||
// sidenum[1] will be -1 if one sided
|
||||
short sidenum[2];
|
||||
|
||||
// Neat. Another bounding box, for the extent
|
||||
// of the LineDef.
|
||||
fixed_t bbox[4];
|
||||
|
||||
// To aid move clipping.
|
||||
slopetype_t slopetype;
|
||||
|
||||
// Front and back sector.
|
||||
// Note: redundant? Can be retrieved from SideDefs.
|
||||
sector_t* frontsector;
|
||||
sector_t* backsector;
|
||||
|
||||
// if == validcount, already checked
|
||||
int validcount;
|
||||
|
||||
// thinker_t for reversable actions
|
||||
void* specialdata;
|
||||
} line_t;
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// A SubSector.
|
||||
// References a Sector.
|
||||
// Basically, this is a list of LineSegs,
|
||||
// indicating the visible walls that define
|
||||
// (all or some) sides of a convex BSP leaf.
|
||||
//
|
||||
typedef struct subsector_s
|
||||
{
|
||||
sector_t* sector;
|
||||
|
||||
short numlines;
|
||||
short firstline;
|
||||
|
||||
} subsector_t;
|
||||
|
||||
|
||||
|
||||
//
|
||||
// The LineSeg.
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
vertex_t* v1;
|
||||
vertex_t* v2;
|
||||
|
||||
fixed_t offset;
|
||||
|
||||
angle_t angle;
|
||||
|
||||
side_t* sidedef;
|
||||
line_t* linedef;
|
||||
|
||||
// Sector references.
|
||||
// Could be retrieved from linedef, too.
|
||||
// backsector is NULL for one sided lines
|
||||
sector_t* frontsector;
|
||||
sector_t* backsector;
|
||||
|
||||
} seg_t;
|
||||
|
||||
|
||||
|
||||
//
|
||||
// BSP node.
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
// Partition line.
|
||||
fixed_t x;
|
||||
fixed_t y;
|
||||
fixed_t dx;
|
||||
fixed_t dy;
|
||||
|
||||
// Bounding box for each child.
|
||||
fixed_t bbox[2][4];
|
||||
|
||||
// If NF_SUBSECTOR its a subsector.
|
||||
unsigned short children[2];
|
||||
|
||||
} node_t;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// OTHER TYPES
|
||||
//
|
||||
|
||||
|
||||
|
||||
//
|
||||
// ?
|
||||
//
|
||||
typedef struct drawseg_s
|
||||
{
|
||||
seg_t* curline;
|
||||
int x1;
|
||||
int x2;
|
||||
|
||||
fixed_t scale1;
|
||||
fixed_t scale2;
|
||||
fixed_t scalestep;
|
||||
|
||||
// 0=none, 1=bottom, 2=top, 3=both
|
||||
int silhouette;
|
||||
|
||||
// do not clip sprites above this
|
||||
fixed_t bsilheight;
|
||||
|
||||
// do not clip sprites below this
|
||||
fixed_t tsilheight;
|
||||
|
||||
// Pointers to lists for sprite clipping,
|
||||
// all three adjusted so [x1] is first value.
|
||||
short* sprtopclip;
|
||||
short* sprbottomclip;
|
||||
short* maskedtexturecol;
|
||||
|
||||
} drawseg_t;
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Now what is a visplane, anyway?
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
fixed_t height;
|
||||
int picnum;
|
||||
int lightlevel;
|
||||
int minx;
|
||||
int maxx;
|
||||
|
||||
// leave pads for [minx-1]/[maxx+1]
|
||||
|
||||
byte pad1;
|
||||
// Here lies the rub for all
|
||||
// dynamic resize/change of resolution.
|
||||
byte top[SCREENWIDTH];
|
||||
byte pad2;
|
||||
byte pad3;
|
||||
// See above.
|
||||
byte bottom[SCREENWIDTH];
|
||||
byte pad4;
|
||||
|
||||
} visplane_t;
|
||||
|
||||
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Refresh/rendering module, shared data struct definitions.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __R_DEFS__
|
||||
#define __R_DEFS__
|
||||
|
||||
|
||||
// Silhouette, needed for clipping Segs (mainly)
|
||||
// and sprites representing things.
|
||||
#define SIL_NONE 0
|
||||
#define SIL_BOTTOM 1
|
||||
#define SIL_TOP 2
|
||||
#define SIL_BOTH 3
|
||||
|
||||
// andrewj: increased for Visplane Explorer (was 256)
|
||||
#define MAXDRAWSEGS 1024
|
||||
|
||||
|
||||
#define skyflatnum 2
|
||||
|
||||
|
||||
extern fixed_t Map_bbox[4];
|
||||
|
||||
|
||||
//
|
||||
// INTERNAL MAP TYPES
|
||||
// used by play and refresh
|
||||
//
|
||||
|
||||
//
|
||||
// Your plain vanilla vertex.
|
||||
// Note: transformed values not buffered locally,
|
||||
// like some DOOM-alikes ("wt", "WebView") did.
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
fixed_t x;
|
||||
fixed_t y;
|
||||
|
||||
} vertex_t;
|
||||
|
||||
|
||||
// Forward of LineDefs, for Sectors.
|
||||
struct line_s;
|
||||
|
||||
|
||||
//
|
||||
// The SECTORS record, at runtime.
|
||||
// Stores things/mobjs.
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
fixed_t floorheight;
|
||||
fixed_t ceilingheight;
|
||||
|
||||
short floorpic;
|
||||
short ceilingpic;
|
||||
short lightlevel;
|
||||
short special;
|
||||
short tag;
|
||||
|
||||
// 0 = untraversed, 1,2 = sndlines -1
|
||||
int soundtraversed;
|
||||
|
||||
// if == validcount, already checked
|
||||
int validcount;
|
||||
|
||||
// thinker_t for reversable actions
|
||||
void* specialdata;
|
||||
|
||||
int linecount;
|
||||
struct line_s** lines; // [linecount] size
|
||||
|
||||
// andrewj: added these two field for Visplane Explorer.
|
||||
// is_door is normally 0,
|
||||
// can be +1 for a door (ceiling goes up)
|
||||
// or -1 for a lowering floor (e.g. MAP12 of DOOM 2)
|
||||
int is_door;
|
||||
fixed_t alt_height;
|
||||
|
||||
} sector_t;
|
||||
|
||||
|
||||
//
|
||||
// The SideDef.
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
// add this to the calculated texture column
|
||||
fixed_t textureoffset;
|
||||
|
||||
// add this to the calculated texture top
|
||||
fixed_t rowoffset;
|
||||
|
||||
// Texture indices.
|
||||
// We do not maintain names here.
|
||||
short toptexture;
|
||||
short bottomtexture;
|
||||
short midtexture;
|
||||
|
||||
// Sector the SideDef is facing.
|
||||
sector_t* sector;
|
||||
|
||||
} side_t;
|
||||
|
||||
|
||||
//
|
||||
// Move clipping aid for LineDefs.
|
||||
//
|
||||
typedef enum
|
||||
{
|
||||
ST_HORIZONTAL,
|
||||
ST_VERTICAL,
|
||||
ST_POSITIVE,
|
||||
ST_NEGATIVE
|
||||
|
||||
} slopetype_t;
|
||||
|
||||
|
||||
typedef struct line_s
|
||||
{
|
||||
// Vertices, from v1 to v2.
|
||||
vertex_t* v1;
|
||||
vertex_t* v2;
|
||||
|
||||
// Precalculated v2 - v1 for side checking.
|
||||
fixed_t dx;
|
||||
fixed_t dy;
|
||||
|
||||
// Animation related.
|
||||
short flags;
|
||||
short special;
|
||||
short tag;
|
||||
|
||||
// Visual appearance: SideDefs.
|
||||
// sidenum[1] will be -1 if one sided
|
||||
short sidenum[2];
|
||||
|
||||
// Neat. Another bounding box, for the extent
|
||||
// of the LineDef.
|
||||
fixed_t bbox[4];
|
||||
|
||||
// To aid move clipping.
|
||||
slopetype_t slopetype;
|
||||
|
||||
// Front and back sector.
|
||||
// Note: redundant? Can be retrieved from SideDefs.
|
||||
sector_t* frontsector;
|
||||
sector_t* backsector;
|
||||
|
||||
// if == validcount, already checked
|
||||
int validcount;
|
||||
|
||||
// thinker_t for reversable actions
|
||||
void* specialdata;
|
||||
|
||||
// andrewj: added the following Hexen stuff
|
||||
unsigned char args[5];
|
||||
} line_t;
|
||||
|
||||
|
||||
//
|
||||
// A SubSector.
|
||||
// References a Sector.
|
||||
// Basically, this is a list of LineSegs,
|
||||
// indicating the visible walls that define
|
||||
// (all or some) sides of a convex BSP leaf.
|
||||
//
|
||||
typedef struct subsector_s
|
||||
{
|
||||
sector_t* sector;
|
||||
|
||||
short numlines;
|
||||
short firstline;
|
||||
|
||||
} subsector_t;
|
||||
|
||||
|
||||
//
|
||||
// The LineSeg.
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
vertex_t* v1;
|
||||
vertex_t* v2;
|
||||
|
||||
fixed_t offset;
|
||||
|
||||
angle_t angle;
|
||||
|
||||
side_t* sidedef;
|
||||
line_t* linedef;
|
||||
|
||||
// Sector references.
|
||||
// Could be retrieved from linedef, too.
|
||||
// backsector is NULL for one sided lines
|
||||
sector_t* frontsector;
|
||||
sector_t* backsector;
|
||||
|
||||
} seg_t;
|
||||
|
||||
|
||||
//
|
||||
// BSP node.
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
// Partition line.
|
||||
fixed_t x;
|
||||
fixed_t y;
|
||||
fixed_t dx;
|
||||
fixed_t dy;
|
||||
|
||||
// Bounding box for each child.
|
||||
fixed_t bbox[2][4];
|
||||
|
||||
// If NF_SUBSECTOR its a subsector.
|
||||
unsigned short children[2];
|
||||
|
||||
} node_t;
|
||||
|
||||
|
||||
//
|
||||
// OTHER TYPES
|
||||
//
|
||||
|
||||
|
||||
typedef struct drawseg_s
|
||||
{
|
||||
seg_t* curline;
|
||||
int x1;
|
||||
int x2;
|
||||
|
||||
fixed_t scale1;
|
||||
fixed_t scale2;
|
||||
fixed_t scalestep;
|
||||
|
||||
// 0=none, 1=bottom, 2=top, 3=both
|
||||
int silhouette;
|
||||
|
||||
// do not clip sprites above this
|
||||
fixed_t bsilheight;
|
||||
|
||||
// do not clip sprites below this
|
||||
fixed_t tsilheight;
|
||||
|
||||
// Pointers to lists for sprite clipping,
|
||||
// all three adjusted so [x1] is first value.
|
||||
short* sprtopclip;
|
||||
short* sprbottomclip;
|
||||
short* maskedtexturecol;
|
||||
|
||||
} drawseg_t;
|
||||
|
||||
|
||||
//
|
||||
// Now what is a visplane, anyway?
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
fixed_t height;
|
||||
int picnum;
|
||||
int lightlevel;
|
||||
int minx;
|
||||
int maxx;
|
||||
|
||||
// leave pads for [minx-1]/[maxx+1]
|
||||
|
||||
byte pad1;
|
||||
// Here lies the rub for all
|
||||
// dynamic resize/change of resolution.
|
||||
byte top[SCREENWIDTH];
|
||||
byte pad2;
|
||||
byte pad3;
|
||||
// See above.
|
||||
byte bottom[SCREENWIDTH];
|
||||
byte pad4;
|
||||
|
||||
} visplane_t;
|
||||
|
||||
|
||||
#endif /* __R_DEFS__ */
|
||||
|
||||
//--- editor settings ---
|
||||
// vi:ts=4:sw=4:noexpandtab
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,113 +1,113 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// System specific interface stuff.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __R_MAIN__
|
||||
#define __R_MAIN__
|
||||
|
||||
|
||||
//
|
||||
// POV related.
|
||||
//
|
||||
extern fixed_t viewcos;
|
||||
extern fixed_t viewsin;
|
||||
|
||||
extern int viewwidth;
|
||||
extern int viewheight;
|
||||
extern int viewwindowx;
|
||||
extern int viewwindowy;
|
||||
|
||||
|
||||
extern int centerx;
|
||||
extern int centery;
|
||||
|
||||
extern fixed_t centerxfrac;
|
||||
extern fixed_t centeryfrac;
|
||||
extern fixed_t projection;
|
||||
|
||||
extern int validcount;
|
||||
|
||||
extern int linecount;
|
||||
extern int loopcount;
|
||||
|
||||
|
||||
//
|
||||
// Lighting LUT.
|
||||
// Used for z-depth cuing per column/row,
|
||||
// and other lighting effects (sector ambient, flash).
|
||||
//
|
||||
|
||||
// Lighting constants.
|
||||
// Now why not 32 levels here?
|
||||
#define LIGHTLEVELS 16
|
||||
#define LIGHTSEGSHIFT 4
|
||||
|
||||
#define MAXLIGHTSCALE 48
|
||||
#define LIGHTSCALESHIFT 12
|
||||
#define MAXLIGHTZ 128
|
||||
#define LIGHTZSHIFT 20
|
||||
|
||||
|
||||
// Number of diminishing brightness levels.
|
||||
// There a 0-31, i.e. 32 LUT in the COLORMAP lump.
|
||||
#define NUMCOLORMAPS 32
|
||||
|
||||
|
||||
//
|
||||
// Utility functions.
|
||||
int R_PointOnSide ( fixed_t x, fixed_t y, node_t* node );
|
||||
|
||||
int R_PointOnSegSide ( fixed_t x, fixed_t y, seg_t* line );
|
||||
|
||||
angle_t R_PointToAngle ( fixed_t x, fixed_t y );
|
||||
|
||||
angle_t R_PointToAngle2 ( fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2 );
|
||||
|
||||
fixed_t R_PointToDist ( fixed_t x, fixed_t y );
|
||||
|
||||
|
||||
fixed_t R_ScaleFromGlobalAngle (angle_t visangle);
|
||||
|
||||
subsector_t* R_PointInSubsector ( fixed_t x, fixed_t y );
|
||||
|
||||
void R_AddPointToBox ( int x, int y, fixed_t* box );
|
||||
|
||||
|
||||
|
||||
// R_THINGS
|
||||
|
||||
extern short screenheightarray[SCREENWIDTH];
|
||||
extern short negonearray[SCREENWIDTH];
|
||||
|
||||
|
||||
//
|
||||
// REFRESH - the actual rendering functions.
|
||||
//
|
||||
|
||||
void R_Init (void);
|
||||
|
||||
void R_RenderView (fixed_t x, fixed_t y, fixed_t z, angle_t angle);
|
||||
|
||||
#endif
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// System specific interface stuff.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __R_MAIN__
|
||||
#define __R_MAIN__
|
||||
|
||||
|
||||
//
|
||||
// POV related.
|
||||
//
|
||||
extern fixed_t viewcos;
|
||||
extern fixed_t viewsin;
|
||||
|
||||
extern int viewwidth;
|
||||
extern int viewheight;
|
||||
extern int viewwindowx;
|
||||
extern int viewwindowy;
|
||||
|
||||
|
||||
extern int centerx;
|
||||
extern int centery;
|
||||
|
||||
extern fixed_t centerxfrac;
|
||||
extern fixed_t centeryfrac;
|
||||
extern fixed_t projection;
|
||||
|
||||
extern int validcount;
|
||||
|
||||
extern int linecount;
|
||||
extern int loopcount;
|
||||
|
||||
|
||||
//
|
||||
// Lighting LUT.
|
||||
// Used for z-depth cuing per column/row,
|
||||
// and other lighting effects (sector ambient, flash).
|
||||
//
|
||||
|
||||
// Lighting constants.
|
||||
// Now why not 32 levels here?
|
||||
#define LIGHTLEVELS 16
|
||||
#define LIGHTSEGSHIFT 4
|
||||
|
||||
#define MAXLIGHTSCALE 48
|
||||
#define LIGHTSCALESHIFT 12
|
||||
#define MAXLIGHTZ 128
|
||||
#define LIGHTZSHIFT 20
|
||||
|
||||
|
||||
// Number of diminishing brightness levels.
|
||||
// There a 0-31, i.e. 32 LUT in the COLORMAP lump.
|
||||
#define NUMCOLORMAPS 32
|
||||
|
||||
|
||||
//
|
||||
// Utility functions.
|
||||
int R_PointOnSide ( fixed_t x, fixed_t y, node_t* node );
|
||||
|
||||
int R_PointOnSegSide ( fixed_t x, fixed_t y, seg_t* line );
|
||||
|
||||
angle_t R_PointToAngle ( fixed_t x, fixed_t y );
|
||||
|
||||
angle_t R_PointToAngle2 ( fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2 );
|
||||
|
||||
fixed_t R_PointToDist ( fixed_t x, fixed_t y );
|
||||
|
||||
|
||||
fixed_t R_ScaleFromGlobalAngle (angle_t visangle);
|
||||
|
||||
subsector_t* R_PointInSubsector ( fixed_t x, fixed_t y );
|
||||
|
||||
void R_AddPointToBox ( int x, int y, fixed_t* box );
|
||||
|
||||
|
||||
|
||||
// R_THINGS
|
||||
|
||||
extern short screenheightarray[SCREENWIDTH];
|
||||
extern short negonearray[SCREENWIDTH];
|
||||
|
||||
|
||||
//
|
||||
// REFRESH - the actual rendering functions.
|
||||
//
|
||||
|
||||
void R_Init (void);
|
||||
|
||||
void R_RenderView (fixed_t x, fixed_t y, fixed_t z, angle_t angle);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,355 +1,355 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Here is a core component: drawing the floors and ceilings,
|
||||
// while maintaining a per column clipping list only.
|
||||
// Moreover, the sky areas have to be determined.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "vpo_local.h"
|
||||
|
||||
namespace vpo
|
||||
{
|
||||
|
||||
|
||||
//
|
||||
// opening
|
||||
//
|
||||
|
||||
// Here comes the obnoxious "visplane".
|
||||
visplane_t visplanes[MAXVISPLANES+10];
|
||||
visplane_t* lastvisplane;
|
||||
visplane_t* floorplane;
|
||||
visplane_t* ceilingplane;
|
||||
|
||||
int total_visplanes;
|
||||
|
||||
short openings[MAXOPENINGS+400];
|
||||
short* lastopening;
|
||||
|
||||
int total_openings;
|
||||
|
||||
|
||||
//
|
||||
// Clip values are the solid pixel bounding the range.
|
||||
// floorclip starts out SCREENHEIGHT
|
||||
// ceilingclip starts out -1
|
||||
//
|
||||
short floorclip[SCREENWIDTH];
|
||||
short ceilingclip[SCREENWIDTH];
|
||||
|
||||
//
|
||||
// spanstart holds the start of a plane span
|
||||
// initialized to 0 at start
|
||||
//
|
||||
int spanstart[SCREENHEIGHT];
|
||||
int spanstop[SCREENHEIGHT];
|
||||
|
||||
//
|
||||
// texture mapping
|
||||
//
|
||||
fixed_t planeheight;
|
||||
|
||||
fixed_t yslope[SCREENHEIGHT];
|
||||
fixed_t distscale[SCREENWIDTH];
|
||||
fixed_t basexscale;
|
||||
fixed_t baseyscale;
|
||||
|
||||
fixed_t cachedheight[SCREENHEIGHT];
|
||||
fixed_t cacheddistance[SCREENHEIGHT];
|
||||
fixed_t cachedxstep[SCREENHEIGHT];
|
||||
fixed_t cachedystep[SCREENHEIGHT];
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
//
|
||||
// R_MapPlane
|
||||
//
|
||||
// Uses global vars:
|
||||
// planeheight
|
||||
// ds_source
|
||||
// basexscale
|
||||
// baseyscale
|
||||
// viewx
|
||||
// viewy
|
||||
//
|
||||
// BASIC PRIMITIVE
|
||||
//
|
||||
void R_MapPlane ( int y, int x1, int x2 )
|
||||
{
|
||||
angle_t angle;
|
||||
fixed_t distance;
|
||||
fixed_t length;
|
||||
unsigned index;
|
||||
|
||||
#ifdef RANGECHECK
|
||||
if (x2 < x1
|
||||
|| x1 < 0
|
||||
|| x2 >= viewwidth
|
||||
|| y > viewheight)
|
||||
{
|
||||
I_Error ("R_MapPlane: %i, %i at %i",x1,x2,y);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (planeheight != cachedheight[y])
|
||||
{
|
||||
cachedheight[y] = planeheight;
|
||||
distance = cacheddistance[y] = FixedMul (planeheight, yslope[y]);
|
||||
ds_xstep = cachedxstep[y] = FixedMul (distance,basexscale);
|
||||
ds_ystep = cachedystep[y] = FixedMul (distance,baseyscale);
|
||||
}
|
||||
else
|
||||
{
|
||||
distance = cacheddistance[y];
|
||||
ds_xstep = cachedxstep[y];
|
||||
ds_ystep = cachedystep[y];
|
||||
}
|
||||
|
||||
length = FixedMul (distance,distscale[x1]);
|
||||
angle = (viewangle + xtoviewangle[x1])>>ANGLETOFINESHIFT;
|
||||
ds_xfrac = viewx + FixedMul(finecosine[angle], length);
|
||||
ds_yfrac = -viewy - FixedMul(finesine[angle], length);
|
||||
|
||||
if (fixedcolormap)
|
||||
ds_colormap = fixedcolormap;
|
||||
else
|
||||
{
|
||||
index = distance >> LIGHTZSHIFT;
|
||||
|
||||
if (index >= MAXLIGHTZ )
|
||||
index = MAXLIGHTZ-1;
|
||||
|
||||
ds_colormap = planezlight[index];
|
||||
}
|
||||
|
||||
ds_y = y;
|
||||
ds_x1 = x1;
|
||||
ds_x2 = x2;
|
||||
|
||||
// high or low detail
|
||||
spanfunc ();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// R_ClearPlanes
|
||||
// At begining of frame.
|
||||
//
|
||||
void R_ClearPlanes (void)
|
||||
{
|
||||
int i;
|
||||
angle_t angle;
|
||||
|
||||
// opening / clipping determination
|
||||
for (i=0 ; i<viewwidth ; i++)
|
||||
{
|
||||
floorclip[i] = viewheight;
|
||||
ceilingclip[i] = -1;
|
||||
}
|
||||
|
||||
total_visplanes = 0;
|
||||
total_openings = 0;
|
||||
|
||||
lastvisplane = visplanes;
|
||||
lastopening = openings;
|
||||
|
||||
// texture calculation
|
||||
memset (cachedheight, 0, sizeof(cachedheight));
|
||||
|
||||
// left to right mapping
|
||||
angle = (viewangle-ANG90)>>ANGLETOFINESHIFT;
|
||||
|
||||
// scale will be unit scale at SCREENWIDTH/2 distance
|
||||
basexscale = FixedDiv (finecosine[angle],centerxfrac);
|
||||
baseyscale = -FixedDiv (finesine[angle],centerxfrac);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// R_FindPlane
|
||||
//
|
||||
visplane_t* R_FindPlane ( fixed_t height, int picnum, int lightlevel )
|
||||
{
|
||||
visplane_t* check;
|
||||
|
||||
if (picnum == skyflatnum)
|
||||
{
|
||||
height = 0; // all skys map together
|
||||
lightlevel = 0;
|
||||
}
|
||||
|
||||
for (check=visplanes; check<lastvisplane; check++)
|
||||
{
|
||||
if (height == check->height
|
||||
&& picnum == check->picnum
|
||||
&& lightlevel == check->lightlevel)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (check < lastvisplane)
|
||||
return check;
|
||||
|
||||
if (total_visplanes >= MAXVISPLANES)
|
||||
throw overflow_exception(); // I_Error ("R_FindPlane: no more visplanes");
|
||||
|
||||
total_visplanes++;
|
||||
lastvisplane++;
|
||||
|
||||
check->height = height;
|
||||
check->picnum = picnum;
|
||||
check->lightlevel = lightlevel;
|
||||
check->minx = SCREENWIDTH;
|
||||
check->maxx = -1;
|
||||
|
||||
memset (check->top,0xff,sizeof(check->top));
|
||||
|
||||
return check;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// R_CheckPlane
|
||||
//
|
||||
visplane_t* R_CheckPlane ( visplane_t* pl, int start, int stop )
|
||||
{
|
||||
int intrl;
|
||||
int intrh;
|
||||
int unionl;
|
||||
int unionh;
|
||||
int x;
|
||||
|
||||
if (start < pl->minx)
|
||||
{
|
||||
intrl = pl->minx;
|
||||
unionl = start;
|
||||
}
|
||||
else
|
||||
{
|
||||
unionl = pl->minx;
|
||||
intrl = start;
|
||||
}
|
||||
|
||||
if (stop > pl->maxx)
|
||||
{
|
||||
intrh = pl->maxx;
|
||||
unionh = stop;
|
||||
}
|
||||
else
|
||||
{
|
||||
unionh = pl->maxx;
|
||||
intrh = stop;
|
||||
}
|
||||
|
||||
for (x=intrl ; x<= intrh ; x++)
|
||||
if (pl->top[x] != 0xff)
|
||||
break;
|
||||
|
||||
if (x > intrh)
|
||||
{
|
||||
pl->minx = unionl;
|
||||
pl->maxx = unionh;
|
||||
|
||||
// use the same one
|
||||
return pl;
|
||||
}
|
||||
|
||||
// make a new visplane
|
||||
lastvisplane->height = pl->height;
|
||||
lastvisplane->picnum = pl->picnum;
|
||||
lastvisplane->lightlevel = pl->lightlevel;
|
||||
|
||||
if (total_visplanes >= MAXVISPLANES)
|
||||
throw overflow_exception(); // I_Error ("R_FindPlane: no more visplanes");
|
||||
|
||||
total_visplanes++;
|
||||
|
||||
pl = lastvisplane++;
|
||||
pl->minx = start;
|
||||
pl->maxx = stop;
|
||||
|
||||
memset (pl->top,0xff,sizeof(pl->top));
|
||||
|
||||
return pl;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
//
|
||||
// R_MakeSpans
|
||||
//
|
||||
void R_MakeSpans ( int x, int t1, int b1, int t2, int b2 )
|
||||
{
|
||||
while (t1 < t2 && t1<=b1)
|
||||
{
|
||||
R_MapPlane (t1,spanstart[t1],x-1);
|
||||
t1++;
|
||||
}
|
||||
while (b1 > b2 && b1>=t1)
|
||||
{
|
||||
R_MapPlane (b1,spanstart[b1],x-1);
|
||||
b1--;
|
||||
}
|
||||
|
||||
while (t2 < t1 && t2<=b2)
|
||||
{
|
||||
spanstart[t2] = x;
|
||||
t2++;
|
||||
}
|
||||
while (b2 > b1 && b2>=t2)
|
||||
{
|
||||
spanstart[b2] = x;
|
||||
b2--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
was: R_DrawPlanes()
|
||||
|
||||
|
||||
if (ds_p - drawsegs > MAXDRAWSEGS)
|
||||
I_Error ("R_DrawPlanes: drawsegs overflow (%i)",
|
||||
ds_p - drawsegs);
|
||||
|
||||
if (lastvisplane - visplanes > MAXVISPLANES)
|
||||
I_Error ("R_DrawPlanes: visplane overflow (%i)",
|
||||
lastvisplane - visplanes);
|
||||
|
||||
if (lastopening - openings > MAXOPENINGS)
|
||||
I_Error ("R_DrawPlanes: opening overflow (%i)",
|
||||
lastopening - openings);
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace vpo
|
||||
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Here is a core component: drawing the floors and ceilings,
|
||||
// while maintaining a per column clipping list only.
|
||||
// Moreover, the sky areas have to be determined.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "vpo_local.h"
|
||||
|
||||
namespace vpo
|
||||
{
|
||||
|
||||
|
||||
//
|
||||
// opening
|
||||
//
|
||||
|
||||
// Here comes the obnoxious "visplane".
|
||||
visplane_t visplanes[MAXVISPLANES+10];
|
||||
visplane_t* lastvisplane;
|
||||
visplane_t* floorplane;
|
||||
visplane_t* ceilingplane;
|
||||
|
||||
int total_visplanes;
|
||||
|
||||
short openings[MAXOPENINGS+400];
|
||||
short* lastopening;
|
||||
|
||||
int total_openings;
|
||||
|
||||
|
||||
//
|
||||
// Clip values are the solid pixel bounding the range.
|
||||
// floorclip starts out SCREENHEIGHT
|
||||
// ceilingclip starts out -1
|
||||
//
|
||||
short floorclip[SCREENWIDTH];
|
||||
short ceilingclip[SCREENWIDTH];
|
||||
|
||||
//
|
||||
// spanstart holds the start of a plane span
|
||||
// initialized to 0 at start
|
||||
//
|
||||
int spanstart[SCREENHEIGHT];
|
||||
int spanstop[SCREENHEIGHT];
|
||||
|
||||
//
|
||||
// texture mapping
|
||||
//
|
||||
fixed_t planeheight;
|
||||
|
||||
fixed_t yslope[SCREENHEIGHT];
|
||||
fixed_t distscale[SCREENWIDTH];
|
||||
fixed_t basexscale;
|
||||
fixed_t baseyscale;
|
||||
|
||||
fixed_t cachedheight[SCREENHEIGHT];
|
||||
fixed_t cacheddistance[SCREENHEIGHT];
|
||||
fixed_t cachedxstep[SCREENHEIGHT];
|
||||
fixed_t cachedystep[SCREENHEIGHT];
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
//
|
||||
// R_MapPlane
|
||||
//
|
||||
// Uses global vars:
|
||||
// planeheight
|
||||
// ds_source
|
||||
// basexscale
|
||||
// baseyscale
|
||||
// viewx
|
||||
// viewy
|
||||
//
|
||||
// BASIC PRIMITIVE
|
||||
//
|
||||
void R_MapPlane ( int y, int x1, int x2 )
|
||||
{
|
||||
angle_t angle;
|
||||
fixed_t distance;
|
||||
fixed_t length;
|
||||
unsigned index;
|
||||
|
||||
#ifdef RANGECHECK
|
||||
if (x2 < x1
|
||||
|| x1 < 0
|
||||
|| x2 >= viewwidth
|
||||
|| y > viewheight)
|
||||
{
|
||||
I_Error ("R_MapPlane: %i, %i at %i",x1,x2,y);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (planeheight != cachedheight[y])
|
||||
{
|
||||
cachedheight[y] = planeheight;
|
||||
distance = cacheddistance[y] = FixedMul (planeheight, yslope[y]);
|
||||
ds_xstep = cachedxstep[y] = FixedMul (distance,basexscale);
|
||||
ds_ystep = cachedystep[y] = FixedMul (distance,baseyscale);
|
||||
}
|
||||
else
|
||||
{
|
||||
distance = cacheddistance[y];
|
||||
ds_xstep = cachedxstep[y];
|
||||
ds_ystep = cachedystep[y];
|
||||
}
|
||||
|
||||
length = FixedMul (distance,distscale[x1]);
|
||||
angle = (viewangle + xtoviewangle[x1])>>ANGLETOFINESHIFT;
|
||||
ds_xfrac = viewx + FixedMul(finecosine[angle], length);
|
||||
ds_yfrac = -viewy - FixedMul(finesine[angle], length);
|
||||
|
||||
if (fixedcolormap)
|
||||
ds_colormap = fixedcolormap;
|
||||
else
|
||||
{
|
||||
index = distance >> LIGHTZSHIFT;
|
||||
|
||||
if (index >= MAXLIGHTZ )
|
||||
index = MAXLIGHTZ-1;
|
||||
|
||||
ds_colormap = planezlight[index];
|
||||
}
|
||||
|
||||
ds_y = y;
|
||||
ds_x1 = x1;
|
||||
ds_x2 = x2;
|
||||
|
||||
// high or low detail
|
||||
spanfunc ();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// R_ClearPlanes
|
||||
// At begining of frame.
|
||||
//
|
||||
void R_ClearPlanes (void)
|
||||
{
|
||||
int i;
|
||||
angle_t angle;
|
||||
|
||||
// opening / clipping determination
|
||||
for (i=0 ; i<viewwidth ; i++)
|
||||
{
|
||||
floorclip[i] = viewheight;
|
||||
ceilingclip[i] = -1;
|
||||
}
|
||||
|
||||
total_visplanes = 0;
|
||||
total_openings = 0;
|
||||
|
||||
lastvisplane = visplanes;
|
||||
lastopening = openings;
|
||||
|
||||
// texture calculation
|
||||
memset (cachedheight, 0, sizeof(cachedheight));
|
||||
|
||||
// left to right mapping
|
||||
angle = (viewangle-ANG90)>>ANGLETOFINESHIFT;
|
||||
|
||||
// scale will be unit scale at SCREENWIDTH/2 distance
|
||||
basexscale = FixedDiv (finecosine[angle],centerxfrac);
|
||||
baseyscale = -FixedDiv (finesine[angle],centerxfrac);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// R_FindPlane
|
||||
//
|
||||
visplane_t* R_FindPlane ( fixed_t height, int picnum, int lightlevel )
|
||||
{
|
||||
visplane_t* check;
|
||||
|
||||
if (picnum == skyflatnum)
|
||||
{
|
||||
height = 0; // all skys map together
|
||||
lightlevel = 0;
|
||||
}
|
||||
|
||||
for (check=visplanes; check<lastvisplane; check++)
|
||||
{
|
||||
if (height == check->height
|
||||
&& picnum == check->picnum
|
||||
&& lightlevel == check->lightlevel)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (check < lastvisplane)
|
||||
return check;
|
||||
|
||||
if (total_visplanes >= MAXVISPLANES)
|
||||
throw overflow_exception(); // I_Error ("R_FindPlane: no more visplanes");
|
||||
|
||||
total_visplanes++;
|
||||
lastvisplane++;
|
||||
|
||||
check->height = height;
|
||||
check->picnum = picnum;
|
||||
check->lightlevel = lightlevel;
|
||||
check->minx = SCREENWIDTH;
|
||||
check->maxx = -1;
|
||||
|
||||
memset (check->top,0xff,sizeof(check->top));
|
||||
|
||||
return check;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// R_CheckPlane
|
||||
//
|
||||
visplane_t* R_CheckPlane ( visplane_t* pl, int start, int stop )
|
||||
{
|
||||
int intrl;
|
||||
int intrh;
|
||||
int unionl;
|
||||
int unionh;
|
||||
int x;
|
||||
|
||||
if (start < pl->minx)
|
||||
{
|
||||
intrl = pl->minx;
|
||||
unionl = start;
|
||||
}
|
||||
else
|
||||
{
|
||||
unionl = pl->minx;
|
||||
intrl = start;
|
||||
}
|
||||
|
||||
if (stop > pl->maxx)
|
||||
{
|
||||
intrh = pl->maxx;
|
||||
unionh = stop;
|
||||
}
|
||||
else
|
||||
{
|
||||
unionh = pl->maxx;
|
||||
intrh = stop;
|
||||
}
|
||||
|
||||
for (x=intrl ; x<= intrh ; x++)
|
||||
if (pl->top[x] != 0xff)
|
||||
break;
|
||||
|
||||
if (x > intrh)
|
||||
{
|
||||
pl->minx = unionl;
|
||||
pl->maxx = unionh;
|
||||
|
||||
// use the same one
|
||||
return pl;
|
||||
}
|
||||
|
||||
// make a new visplane
|
||||
lastvisplane->height = pl->height;
|
||||
lastvisplane->picnum = pl->picnum;
|
||||
lastvisplane->lightlevel = pl->lightlevel;
|
||||
|
||||
if (total_visplanes >= MAXVISPLANES)
|
||||
throw overflow_exception(); // I_Error ("R_FindPlane: no more visplanes");
|
||||
|
||||
total_visplanes++;
|
||||
|
||||
pl = lastvisplane++;
|
||||
pl->minx = start;
|
||||
pl->maxx = stop;
|
||||
|
||||
memset (pl->top,0xff,sizeof(pl->top));
|
||||
|
||||
return pl;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
//
|
||||
// R_MakeSpans
|
||||
//
|
||||
void R_MakeSpans ( int x, int t1, int b1, int t2, int b2 )
|
||||
{
|
||||
while (t1 < t2 && t1<=b1)
|
||||
{
|
||||
R_MapPlane (t1,spanstart[t1],x-1);
|
||||
t1++;
|
||||
}
|
||||
while (b1 > b2 && b1>=t1)
|
||||
{
|
||||
R_MapPlane (b1,spanstart[b1],x-1);
|
||||
b1--;
|
||||
}
|
||||
|
||||
while (t2 < t1 && t2<=b2)
|
||||
{
|
||||
spanstart[t2] = x;
|
||||
t2++;
|
||||
}
|
||||
while (b2 > b1 && b2>=t2)
|
||||
{
|
||||
spanstart[b2] = x;
|
||||
b2--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
was: R_DrawPlanes()
|
||||
|
||||
|
||||
if (ds_p - drawsegs > MAXDRAWSEGS)
|
||||
I_Error ("R_DrawPlanes: drawsegs overflow (%i)",
|
||||
ds_p - drawsegs);
|
||||
|
||||
if (lastvisplane - visplanes > MAXVISPLANES)
|
||||
I_Error ("R_DrawPlanes: visplane overflow (%i)",
|
||||
lastvisplane - visplanes);
|
||||
|
||||
if (lastopening - openings > MAXOPENINGS)
|
||||
I_Error ("R_DrawPlanes: opening overflow (%i)",
|
||||
lastopening - openings);
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace vpo
|
||||
|
||||
|
|
|
@ -1,64 +1,64 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Refresh, visplane stuff (floor, ceilings).
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __R_PLANE__
|
||||
#define __R_PLANE__
|
||||
|
||||
|
||||
// Visplane related.
|
||||
extern short * lastopening;
|
||||
|
||||
|
||||
typedef void (*planefunction_t) (int top, int bottom);
|
||||
|
||||
extern short floorclip[SCREENWIDTH];
|
||||
extern short ceilingclip[SCREENWIDTH];
|
||||
|
||||
extern fixed_t yslope[SCREENHEIGHT];
|
||||
extern fixed_t distscale[SCREENWIDTH];
|
||||
|
||||
void R_ClearPlanes (void);
|
||||
|
||||
void R_MapPlane ( int y, int x1, int x2 );
|
||||
void R_MakeSpans ( int x, int t1, int b1, int t2, int b2 );
|
||||
void R_DrawPlanes (void);
|
||||
|
||||
visplane_t* R_FindPlane ( fixed_t height, int picnum, int lightlevel );
|
||||
visplane_t* R_CheckPlane ( visplane_t* pl, int start, int stop );
|
||||
|
||||
// #define MAXVISPLANES 128
|
||||
#define MAXVISPLANES 512 // andrewj: increased for Visplane Explorer
|
||||
|
||||
// #define MAXOPENINGS SCREENWIDTH*64
|
||||
#define MAXOPENINGS SCREENWIDTH*256 // andrewj: increased for Visplane Explorer
|
||||
|
||||
extern int total_visplanes;
|
||||
extern int total_drawsegs;
|
||||
extern int total_openings;
|
||||
extern int max_solidsegs;
|
||||
|
||||
|
||||
#endif
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Refresh, visplane stuff (floor, ceilings).
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __R_PLANE__
|
||||
#define __R_PLANE__
|
||||
|
||||
|
||||
// Visplane related.
|
||||
extern short * lastopening;
|
||||
|
||||
|
||||
typedef void (*planefunction_t) (int top, int bottom);
|
||||
|
||||
extern short floorclip[SCREENWIDTH];
|
||||
extern short ceilingclip[SCREENWIDTH];
|
||||
|
||||
extern fixed_t yslope[SCREENHEIGHT];
|
||||
extern fixed_t distscale[SCREENWIDTH];
|
||||
|
||||
void R_ClearPlanes (void);
|
||||
|
||||
void R_MapPlane ( int y, int x1, int x2 );
|
||||
void R_MakeSpans ( int x, int t1, int b1, int t2, int b2 );
|
||||
void R_DrawPlanes (void);
|
||||
|
||||
visplane_t* R_FindPlane ( fixed_t height, int picnum, int lightlevel );
|
||||
visplane_t* R_CheckPlane ( visplane_t* pl, int start, int stop );
|
||||
|
||||
// #define MAXVISPLANES 128
|
||||
#define MAXVISPLANES 512 // andrewj: increased for Visplane Explorer
|
||||
|
||||
// #define MAXOPENINGS SCREENWIDTH*64
|
||||
#define MAXOPENINGS SCREENWIDTH*256 // andrewj: increased for Visplane Explorer
|
||||
|
||||
extern int total_visplanes;
|
||||
extern int total_drawsegs;
|
||||
extern int total_openings;
|
||||
extern int max_solidsegs;
|
||||
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,107 +1,107 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Refresh/render internal state variables (global).
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __R_STATE__
|
||||
#define __R_STATE__
|
||||
|
||||
|
||||
//
|
||||
// Refresh internal data structures,
|
||||
// for rendering.
|
||||
//
|
||||
|
||||
// needed for pre rendering (fracs)
|
||||
extern fixed_t* spritewidth;
|
||||
|
||||
extern fixed_t* spriteoffset;
|
||||
extern fixed_t* spritetopoffset;
|
||||
|
||||
extern int viewwidth;
|
||||
extern int scaledviewwidth;
|
||||
extern int viewheight;
|
||||
|
||||
extern int firstflat;
|
||||
|
||||
|
||||
//
|
||||
// Lookup tables for map data.
|
||||
//
|
||||
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 int numlines;
|
||||
extern line_t* lines;
|
||||
|
||||
extern int numsides;
|
||||
extern side_t* sides;
|
||||
|
||||
|
||||
//
|
||||
// POV data.
|
||||
//
|
||||
extern fixed_t viewx;
|
||||
extern fixed_t viewy;
|
||||
extern fixed_t viewz;
|
||||
|
||||
extern angle_t viewangle;
|
||||
|
||||
|
||||
// ?
|
||||
extern angle_t clipangle;
|
||||
|
||||
extern int viewangletox[FINEANGLES/2];
|
||||
extern angle_t xtoviewangle[SCREENWIDTH+1];
|
||||
//extern fixed_t finetangent[FINEANGLES/2];
|
||||
|
||||
extern fixed_t rw_distance;
|
||||
extern angle_t rw_normalangle;
|
||||
|
||||
|
||||
|
||||
// angle to line origin
|
||||
extern int rw_angle1;
|
||||
|
||||
// Segs count?
|
||||
extern int sscount;
|
||||
|
||||
extern visplane_t* floorplane;
|
||||
extern visplane_t* ceilingplane;
|
||||
|
||||
|
||||
#endif
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Refresh/render internal state variables (global).
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __R_STATE__
|
||||
#define __R_STATE__
|
||||
|
||||
|
||||
//
|
||||
// Refresh internal data structures,
|
||||
// for rendering.
|
||||
//
|
||||
|
||||
// needed for pre rendering (fracs)
|
||||
extern fixed_t* spritewidth;
|
||||
|
||||
extern fixed_t* spriteoffset;
|
||||
extern fixed_t* spritetopoffset;
|
||||
|
||||
extern int viewwidth;
|
||||
extern int scaledviewwidth;
|
||||
extern int viewheight;
|
||||
|
||||
extern int firstflat;
|
||||
|
||||
|
||||
//
|
||||
// Lookup tables for map data.
|
||||
//
|
||||
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 int numlines;
|
||||
extern line_t* lines;
|
||||
|
||||
extern int numsides;
|
||||
extern side_t* sides;
|
||||
|
||||
|
||||
//
|
||||
// POV data.
|
||||
//
|
||||
extern fixed_t viewx;
|
||||
extern fixed_t viewy;
|
||||
extern fixed_t viewz;
|
||||
|
||||
extern angle_t viewangle;
|
||||
|
||||
|
||||
// ?
|
||||
extern angle_t clipangle;
|
||||
|
||||
extern int viewangletox[FINEANGLES/2];
|
||||
extern angle_t xtoviewangle[SCREENWIDTH+1];
|
||||
//extern fixed_t finetangent[FINEANGLES/2];
|
||||
|
||||
extern fixed_t rw_distance;
|
||||
extern angle_t rw_normalangle;
|
||||
|
||||
|
||||
|
||||
// angle to line origin
|
||||
extern int rw_angle1;
|
||||
|
||||
// Segs count?
|
||||
extern int sscount;
|
||||
|
||||
extern visplane_t* floorplane;
|
||||
extern visplane_t* ceilingplane;
|
||||
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,94 +1,94 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Lookup tables.
|
||||
// Do not try to look them up :-).
|
||||
// In the order of appearance:
|
||||
//
|
||||
// int finetangent[4096] - Tangens LUT.
|
||||
// Should work with BAM fairly well (12 of 16bit,
|
||||
// effectively, by shifting).
|
||||
//
|
||||
// int finesine[10240] - Sine lookup.
|
||||
// Guess what, serves as cosine, too.
|
||||
// Remarkable thing is, how to use BAMs with this?
|
||||
//
|
||||
// int tantoangle[2049] - ArcTan LUT,
|
||||
// maps tan(angle) to angle fast. Gotta search.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __TABLES__
|
||||
#define __TABLES__
|
||||
|
||||
|
||||
|
||||
#include "m_fixed.h"
|
||||
|
||||
#define FINEANGLES 8192
|
||||
#define FINEMASK (FINEANGLES-1)
|
||||
|
||||
|
||||
// 0x100000000 to 0x2000
|
||||
#define ANGLETOFINESHIFT 19
|
||||
|
||||
// Effective size is 10240.
|
||||
extern const fixed_t finesine[5*FINEANGLES/4];
|
||||
|
||||
// Re-use data, is just PI/2 pahse shift.
|
||||
extern const fixed_t *finecosine;
|
||||
|
||||
|
||||
// Effective size is 4096.
|
||||
extern const fixed_t finetangent[FINEANGLES/2];
|
||||
|
||||
// Binary Angle Measument, BAM.
|
||||
#define ANG45 0x20000000
|
||||
#define ANG90 0x40000000
|
||||
#define ANG180 0x80000000
|
||||
#define ANG270 0xc0000000
|
||||
|
||||
|
||||
#define SLOPERANGE 2048
|
||||
#define SLOPEBITS 11
|
||||
#define DBITS (FRACBITS-SLOPEBITS)
|
||||
|
||||
typedef unsigned angle_t;
|
||||
|
||||
|
||||
// Effective size is 2049;
|
||||
// The +1 size is to handle the case when x==y
|
||||
// without additional checking.
|
||||
extern const angle_t tantoangle[SLOPERANGE+1];
|
||||
|
||||
|
||||
// Utility function,
|
||||
// called by R_PointToAngle.
|
||||
int
|
||||
SlopeDiv
|
||||
( unsigned num,
|
||||
unsigned den);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Lookup tables.
|
||||
// Do not try to look them up :-).
|
||||
// In the order of appearance:
|
||||
//
|
||||
// int finetangent[4096] - Tangens LUT.
|
||||
// Should work with BAM fairly well (12 of 16bit,
|
||||
// effectively, by shifting).
|
||||
//
|
||||
// int finesine[10240] - Sine lookup.
|
||||
// Guess what, serves as cosine, too.
|
||||
// Remarkable thing is, how to use BAMs with this?
|
||||
//
|
||||
// int tantoangle[2049] - ArcTan LUT,
|
||||
// maps tan(angle) to angle fast. Gotta search.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __TABLES__
|
||||
#define __TABLES__
|
||||
|
||||
|
||||
|
||||
#include "m_fixed.h"
|
||||
|
||||
#define FINEANGLES 8192
|
||||
#define FINEMASK (FINEANGLES-1)
|
||||
|
||||
|
||||
// 0x100000000 to 0x2000
|
||||
#define ANGLETOFINESHIFT 19
|
||||
|
||||
// Effective size is 10240.
|
||||
extern const fixed_t finesine[5*FINEANGLES/4];
|
||||
|
||||
// Re-use data, is just PI/2 pahse shift.
|
||||
extern const fixed_t *finecosine;
|
||||
|
||||
|
||||
// Effective size is 4096.
|
||||
extern const fixed_t finetangent[FINEANGLES/2];
|
||||
|
||||
// Binary Angle Measument, BAM.
|
||||
#define ANG45 0x20000000
|
||||
#define ANG90 0x40000000
|
||||
#define ANG180 0x80000000
|
||||
#define ANG270 0xc0000000
|
||||
|
||||
|
||||
#define SLOPERANGE 2048
|
||||
#define SLOPEBITS 11
|
||||
#define DBITS (FRACBITS-SLOPEBITS)
|
||||
|
||||
typedef unsigned angle_t;
|
||||
|
||||
|
||||
// Effective size is 2049;
|
||||
// The +1 size is to handle the case when x==y
|
||||
// without additional checking.
|
||||
extern const angle_t tantoangle[SLOPERANGE+1];
|
||||
|
||||
|
||||
// Utility function,
|
||||
// called by R_PointToAngle.
|
||||
int
|
||||
SlopeDiv
|
||||
( unsigned num,
|
||||
unsigned den);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,84 +1,98 @@
|
|||
//------------------------------------------------------------------------
|
||||
// Visplane Overflow Library
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 Id Software, Inc.
|
||||
// Copyright (C) 2005 Simon Howard
|
||||
// Copyright (C) 2012 Andrew Apted
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#ifndef __VPO_API_H__
|
||||
#define __VPO_API_H__
|
||||
|
||||
|
||||
// return error message when something fails
|
||||
// (this will be a static buffer, so is not guaranteed to remain valid
|
||||
// after any other API call)
|
||||
const char* APIENTRY VPO_GetError(void);
|
||||
|
||||
// try to load a wad file
|
||||
// returns 0 on success, negative value on error
|
||||
int APIENTRY VPO_LoadWAD(const char *wad_filename);
|
||||
|
||||
// free all data associated with the wad file
|
||||
// can be safely called without any loaded wad file
|
||||
void APIENTRY VPO_FreeWAD(void);
|
||||
|
||||
// retrieve the map names in the wad, one at a time
|
||||
// index starts at 0
|
||||
// returns NULL when index is past the end of the list
|
||||
// NOTE: return pointer may be a static buffer, not guaranteed to
|
||||
// remain valid once this function is called again
|
||||
const char* APIENTRY VPO_GetMapName(unsigned int index);
|
||||
|
||||
// try to open a map from the current wad file
|
||||
// returns 0 on success, negative value on error
|
||||
int APIENTRY VPO_OpenMap(const char *map_name);
|
||||
|
||||
// free all data associated with a map
|
||||
// can be safely called without any opened map
|
||||
void APIENTRY VPO_CloseMap(void);
|
||||
|
||||
// retrieve the linedefs in the current map, one at a time
|
||||
// index starts at 0
|
||||
// returns number of sides (0 to 2), or -1 for invalid index
|
||||
int APIENTRY VPO_GetLinedef(unsigned int index, int *x1, int *y1, int *x2, int *y2);
|
||||
|
||||
// test a spot and angle, returning the number of visplanes
|
||||
// dz is the height above the floor (or offset from ceiling if < 0)
|
||||
// angle is in degrees (0 to 360), 0 is east, 90 is north
|
||||
// returns RESULT_OK on success, or a negative value spot was in the
|
||||
// void or an error occurred -- see the RESULT_* values below
|
||||
//
|
||||
// the num_xxx parameters point to variables which get _updated_ by
|
||||
// this call (i.e. new value is maximum of old value + checked value).
|
||||
// hence you need to set those variables to zero before the first
|
||||
// call at a particular (X Y) location.
|
||||
//
|
||||
// RESULT_OVERFLOW means that an internal limit overflowed (which are
|
||||
// four times or more the actual DOOM limits).
|
||||
|
||||
#define RESULT_OK 0
|
||||
#define RESULT_BAD_Z -1
|
||||
#define RESULT_IN_VOID -2
|
||||
#define RESULT_OVERFLOW -3
|
||||
|
||||
int APIENTRY VPO_TestSpot(int x, int y, int dz, int angle,
|
||||
int *num_visplanes,
|
||||
int *num_drawsegs,
|
||||
int *num_openings,
|
||||
int *num_solidsegs);
|
||||
|
||||
#endif /* __VPO_API_H__ */
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Visplane Overflow Library
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 Id Software, Inc.
|
||||
// Copyright (C) 2005 Simon Howard
|
||||
// Copyright (C) 2012-2014 Andrew Apted
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#ifndef __VPO_API_H__
|
||||
#define __VPO_API_H__
|
||||
|
||||
|
||||
// return error message when something fails
|
||||
// (this will be a static buffer, so is not guaranteed to remain valid
|
||||
// after any other API call)
|
||||
const char *VPO_GetError(void);
|
||||
|
||||
// try to load a wad file
|
||||
// returns 0 on success, negative value on error
|
||||
int VPO_LoadWAD(const char *wad_filename);
|
||||
|
||||
// free all data associated with the wad file
|
||||
// can be safely called without any loaded wad file
|
||||
void VPO_FreeWAD(void);
|
||||
|
||||
// retrieve the map names in the wad, one at a time
|
||||
// index starts at 0
|
||||
// returns NULL when index is past the end of the list
|
||||
// NOTE: return pointer is a static buffer, and is NOT guaranteed to
|
||||
// remain valid once this function is called again
|
||||
const char * VPO_GetMapName(unsigned int index, bool *is_hexen = NULL);
|
||||
|
||||
// try to open a map from the current wad file
|
||||
// returns 0 on success, negative value on error
|
||||
int VPO_OpenMap(const char *map_name, bool *is_hexen = NULL);
|
||||
|
||||
// free all data associated with a map
|
||||
// can be safely called without any opened map
|
||||
void VPO_CloseMap(void);
|
||||
|
||||
// retrieve the linedefs in the current map, one at a time
|
||||
// index starts at 0
|
||||
// returns number of sides (0 to 2), or -1 for invalid index
|
||||
int VPO_GetLinedef(unsigned int index, int *x1, int *y1, int *x2, int *y2);
|
||||
|
||||
// retrieve a seg for the current map
|
||||
// index starts at 0
|
||||
// side value will be 0 for front/right, 1 for back/left
|
||||
// returns a value >= 0 if valid, otherwise -1
|
||||
int VPO_GetSeg(unsigned int index, int *linedef, int *side,
|
||||
int *x1, int *y1, int *x2, int *y2);
|
||||
|
||||
// retrieve the bounding box of the map
|
||||
void VPO_GetBBox(int *x1, int *y1, int *x2, int *y2);
|
||||
|
||||
// open or close all sectors which seem to be doors
|
||||
// dir must be > 0 to open them, or -1 to close them
|
||||
void VPO_OpenDoorSectors(int dir);
|
||||
|
||||
// test a spot and angle, returning the number of visplanes
|
||||
// dz is the height above the floor (or offset from ceiling if < 0)
|
||||
// angle is in degrees (0 to 360), 0 is east, 90 is north
|
||||
// returns RESULT_OK on success, or a negative value spot was in the
|
||||
// void or an error occurred -- see the RESULT_* values below
|
||||
//
|
||||
// the num_xxx parameters point to variables which get _updated_ by
|
||||
// this call (i.e. new value is maximum of old value + checked value).
|
||||
// hence you need to set those variables to zero before the first
|
||||
// call at a particular (X Y) location.
|
||||
//
|
||||
// RESULT_OVERFLOW means that an internal limit overflowed (which are
|
||||
// four times or more the actual DOOM limits).
|
||||
|
||||
#define RESULT_OK 0
|
||||
#define RESULT_BAD_Z -1
|
||||
#define RESULT_IN_VOID -2
|
||||
#define RESULT_OVERFLOW -3
|
||||
|
||||
int VPO_TestSpot(int x, int y, int dz, int angle,
|
||||
int *num_visplanes,
|
||||
int *num_drawsegs,
|
||||
int *num_openings,
|
||||
int *num_solidsegs);
|
||||
|
||||
#endif /* __VPO_API_H__ */
|
||||
|
||||
|
|
|
@ -1,80 +1,78 @@
|
|||
//------------------------------------------------------------------------
|
||||
// Visplane Overflow Library
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 Id Software, Inc.
|
||||
// Copyright (C) 2005 Simon Howard
|
||||
// Copyright (C) 2012 Andrew Apted
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#ifndef __VPO_LOCAL_H__
|
||||
#define __VPO_LOCAL_H__
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "sys_type.h"
|
||||
#include "sys_macro.h"
|
||||
#include "sys_endian.h"
|
||||
|
||||
namespace vpo
|
||||
{
|
||||
|
||||
#include "doomtype.h"
|
||||
#include "doomdef.h"
|
||||
#include "doomdata.h"
|
||||
|
||||
#include "m_bbox.h"
|
||||
#include "m_fixed.h"
|
||||
|
||||
#include "w_file.h"
|
||||
#include "w_wad.h"
|
||||
|
||||
#include "tables.h"
|
||||
#include "r_defs.h"
|
||||
#include "r_state.h"
|
||||
|
||||
#include "r_main.h"
|
||||
#include "r_bsp.h"
|
||||
#include "r_plane.h"
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
#define SHORT(x) LE_S16(x)
|
||||
#define LONG(x) LE_S32(x)
|
||||
|
||||
void P_SetupLevel (const char *lumpname );
|
||||
void P_FreeLevelData (void);
|
||||
|
||||
void I_Error (const char *error, ...);
|
||||
|
||||
sector_t * X_SectorForPoint(fixed_t x, fixed_t y);
|
||||
|
||||
// exceptions thrown on overflows
|
||||
class overflow_exception { };
|
||||
|
||||
} // namespace vpo
|
||||
|
||||
|
||||
#endif /* __VPO_LOCAL_H__ */
|
||||
|
||||
//--- editor settings ---
|
||||
// vi:ts=4:sw=4:noexpandtab
|
||||
//------------------------------------------------------------------------
|
||||
// Visplane Overflow Library
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 Id Software, Inc.
|
||||
// Copyright (C) 2005 Simon Howard
|
||||
// Copyright (C) 2012 Andrew Apted
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#ifndef __VPO_LOCAL_H__
|
||||
#define __VPO_LOCAL_H__
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "sys_type.h"
|
||||
#include "sys_macro.h"
|
||||
#include "sys_endian.h"
|
||||
|
||||
namespace vpo
|
||||
{
|
||||
|
||||
#include "doomtype.h"
|
||||
#include "doomdef.h"
|
||||
#include "doomdata.h"
|
||||
|
||||
#include "m_bbox.h"
|
||||
#include "m_fixed.h"
|
||||
|
||||
#include "w_file.h"
|
||||
#include "w_wad.h"
|
||||
|
||||
#include "tables.h"
|
||||
#include "r_defs.h"
|
||||
#include "r_state.h"
|
||||
|
||||
#include "r_main.h"
|
||||
#include "r_bsp.h"
|
||||
#include "r_plane.h"
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
#define SHORT(x) LE_S16(x)
|
||||
#define LONG(x) LE_S32(x)
|
||||
|
||||
const char * P_SetupLevel (const char *lumpname, bool *is_hexen );
|
||||
void P_FreeLevelData (void);
|
||||
|
||||
void I_Error (const char *error, ...);
|
||||
|
||||
sector_t * X_SectorForPoint(fixed_t x, fixed_t y);
|
||||
|
||||
// exceptions thrown on overflows
|
||||
class overflow_exception { };
|
||||
|
||||
} // namespace vpo
|
||||
|
||||
|
||||
#endif /* __VPO_LOCAL_H__ */
|
||||
|
||||
//--- editor settings ---
|
||||
// vi:ts=4:sw=4:noexpandtab
|
||||
|
|
|
@ -1,294 +1,369 @@
|
|||
//------------------------------------------------------------------------
|
||||
// Visplane Overflow Library
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 Id Software, Inc.
|
||||
// Copyright (C) 2005 Simon Howard
|
||||
// Copyright (C) 2012 Andrew Apted
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#include "vpo_local.h"
|
||||
#include "vpo_api.h"
|
||||
|
||||
|
||||
static char error_buffer[1024];
|
||||
|
||||
// cache for the sector lookup
|
||||
static int last_x, last_y;
|
||||
static vpo::sector_t *last_sector;
|
||||
|
||||
|
||||
static void ClearError(void)
|
||||
{
|
||||
strcpy(error_buffer, "(No Error)");
|
||||
}
|
||||
|
||||
static void SetError(const char *msg, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
|
||||
va_start(argptr, msg);
|
||||
memset(error_buffer, 0, sizeof(error_buffer));
|
||||
vsnprintf(error_buffer, sizeof(error_buffer) - 1, msg, argptr);
|
||||
va_end(argptr);
|
||||
}
|
||||
|
||||
|
||||
const char* APIENTRY VPO_GetError(void)
|
||||
{
|
||||
return error_buffer;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
int APIENTRY VPO_LoadWAD(const char *wad_filename)
|
||||
{
|
||||
ClearError();
|
||||
|
||||
// free any previously loaded wad
|
||||
VPO_FreeWAD();
|
||||
|
||||
vpo::R_Init();
|
||||
|
||||
if (! vpo::W_AddFile(wad_filename))
|
||||
{
|
||||
SetError("Could not open/read the file: %s", wad_filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0; // OK !
|
||||
}
|
||||
|
||||
|
||||
int APIENTRY VPO_OpenMap(const char *map_name)
|
||||
{
|
||||
// check a wad is loaded
|
||||
if (vpo::numlumps <= 0)
|
||||
{
|
||||
SetError("VPO_OpenMap called without any loaded map");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ClearError();
|
||||
|
||||
// close any previously loaded map
|
||||
VPO_CloseMap();
|
||||
|
||||
if (vpo::W_CheckNumForName(map_name) < 0)
|
||||
{
|
||||
SetError("No such map in wad: %s", map_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
vpo::P_SetupLevel(map_name);
|
||||
|
||||
return 0; // OK !
|
||||
}
|
||||
|
||||
|
||||
void APIENTRY VPO_FreeWAD(void)
|
||||
{
|
||||
VPO_CloseMap();
|
||||
|
||||
vpo::W_RemoveFile();
|
||||
}
|
||||
|
||||
|
||||
void APIENTRY VPO_CloseMap(void)
|
||||
{
|
||||
ClearError();
|
||||
|
||||
last_x = -77777;
|
||||
last_y = -77777;
|
||||
last_sector = NULL;
|
||||
|
||||
vpo::P_FreeLevelData();
|
||||
}
|
||||
|
||||
|
||||
const char* APIENTRY VPO_GetMapName(unsigned int index)
|
||||
{
|
||||
static char buffer[16];
|
||||
|
||||
for (unsigned int lump_i = 0 ; lump_i < vpo::numlumps ; lump_i++)
|
||||
{
|
||||
if (! vpo::lumpinfo[lump_i].is_map_header)
|
||||
continue;
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
// found it
|
||||
memcpy(buffer, vpo::lumpinfo[lump_i].name, 8);
|
||||
buffer[8] = 0;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
index--;
|
||||
}
|
||||
|
||||
// not found
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int APIENTRY VPO_GetLinedef(unsigned int index, int *x1, int *y1, int *x2, int *y2)
|
||||
{
|
||||
if (index >= (unsigned int)vpo::numlines)
|
||||
return -1;
|
||||
|
||||
const vpo::line_t *L = &vpo::lines[index];
|
||||
|
||||
*x1 = L->v1->x >> FRACBITS;
|
||||
*y1 = L->v1->y >> FRACBITS;
|
||||
|
||||
*x2 = L->v2->x >> FRACBITS;
|
||||
*y2 = L->v2->y >> FRACBITS;
|
||||
|
||||
return L->backsector ? 2 : 1;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
int APIENTRY VPO_TestSpot(int x, int y, int dz, int angle,
|
||||
int *num_visplanes, int *num_drawsegs,
|
||||
int *num_openings, int *num_solidsegs)
|
||||
{
|
||||
// the actual spot we will use
|
||||
// (this prevents issues with X_SectorForPoint getting the wrong
|
||||
// value when the casted ray hits a vertex)
|
||||
vpo::fixed_t rx = (x << FRACBITS) + (FRACUNIT / 2);
|
||||
vpo::fixed_t ry = (y << FRACBITS) + (FRACUNIT / 2);
|
||||
|
||||
vpo::sector_t *sec;
|
||||
|
||||
// optimization: we cache the last sector lookup
|
||||
if (x == last_x && y == last_y)
|
||||
sec = last_sector;
|
||||
else
|
||||
{
|
||||
sec = vpo::X_SectorForPoint(rx, ry);
|
||||
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
last_sector = sec;
|
||||
}
|
||||
|
||||
if (! sec)
|
||||
return RESULT_IN_VOID;
|
||||
|
||||
vpo::fixed_t rz;
|
||||
|
||||
if (dz < 0)
|
||||
rz = sec->ceilingheight + (dz << FRACBITS);
|
||||
else
|
||||
rz = sec->floorheight + (dz << FRACBITS);
|
||||
|
||||
if (rz <= sec->floorheight || rz >= sec->ceilingheight)
|
||||
return RESULT_BAD_Z;
|
||||
|
||||
// convert angle to the 32-bit BAM representation
|
||||
if (angle == 360)
|
||||
angle = 0;
|
||||
|
||||
vpo::fixed_t ang2 = vpo::FixedDiv(angle << FRACBITS, 360 << FRACBITS);
|
||||
|
||||
vpo::angle_t r_ang = (vpo::angle_t) (ang2 << 16);
|
||||
|
||||
int result = RESULT_OK;
|
||||
|
||||
// perform a no-draw render and see how many visplanes were needed
|
||||
try
|
||||
{
|
||||
vpo::R_RenderView(rx, ry, rz, r_ang);
|
||||
}
|
||||
catch (vpo::overflow_exception& e)
|
||||
{
|
||||
result = RESULT_OVERFLOW;
|
||||
}
|
||||
|
||||
*num_visplanes = MAX(*num_visplanes, vpo::total_visplanes);
|
||||
*num_drawsegs = MAX(*num_drawsegs, vpo::total_drawsegs);
|
||||
*num_openings = MAX(*num_openings, vpo::total_openings);
|
||||
*num_solidsegs = MAX(*num_solidsegs, vpo::max_solidsegs);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#ifdef VPO_TEST_PROGRAM
|
||||
|
||||
#define EYE_HEIGHT 41
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
printf("----------------\n");
|
||||
printf("VPO TEST PROGRAM\n");
|
||||
printf("----------------\n");
|
||||
printf("\n");
|
||||
|
||||
if (argc < 5 ||
|
||||
(strcmp (argv[1], "-h") == 0 ||
|
||||
strcmp (argv[1], "--help") == 0 ||
|
||||
strcmp (argv[1], "/?") == 0) )
|
||||
{
|
||||
printf("Usage: vpotest file.wad MAP01 x y angle\n");
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *filename = argv[1];
|
||||
const char *map = argv[2];
|
||||
|
||||
int x = atoi(argv[3]);
|
||||
int y = atoi(argv[4]);
|
||||
int angle = atoi(argv[5]);
|
||||
|
||||
printf("Loading file: %s [%s]\n", filename, map);
|
||||
|
||||
if (VPO_LoadWAD(filename) != 0)
|
||||
{
|
||||
printf("ERROR: %s\n", VPO_GetError());
|
||||
fflush(stdout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (VPO_OpenMap(map) != 0)
|
||||
{
|
||||
printf("ERROR: %s\n", VPO_GetError());
|
||||
fflush(stdout);
|
||||
VPO_FreeWAD();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int vp_num = VPO_TestSpot(TEST_VISPLANES, x, y, EYE_HEIGHT, angle);
|
||||
|
||||
printf("\n");
|
||||
printf("Visplanes @ (%d %d) ---> %d\n", x, y, vp_num);
|
||||
fflush(stdout);
|
||||
|
||||
VPO_CloseMap();
|
||||
VPO_FreeWAD();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // VPO_TEST_PROGRAM
|
||||
|
||||
//--- editor settings ---
|
||||
// vi:ts=4:sw=4:noexpandtab
|
||||
//------------------------------------------------------------------------
|
||||
// Visplane Overflow Library
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 Id Software, Inc.
|
||||
// Copyright (C) 2005 Simon Howard
|
||||
// Copyright (C) 2012-2014 Andrew Apted
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#include "vpo_local.h"
|
||||
#include "vpo_api.h"
|
||||
|
||||
|
||||
static char error_buffer[1024];
|
||||
|
||||
// cache for the sector lookup
|
||||
static int last_x, last_y;
|
||||
static vpo::sector_t *last_sector;
|
||||
|
||||
|
||||
static void ClearError(void)
|
||||
{
|
||||
strcpy(error_buffer, "(No Error)");
|
||||
}
|
||||
|
||||
static void SetError(const char *msg, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
|
||||
va_start(argptr, msg);
|
||||
memset(error_buffer, 0, sizeof(error_buffer));
|
||||
vsnprintf(error_buffer, sizeof(error_buffer) - 1, msg, argptr);
|
||||
va_end(argptr);
|
||||
}
|
||||
|
||||
|
||||
const char *VPO_GetError(void)
|
||||
{
|
||||
return error_buffer;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
int VPO_LoadWAD(const char *wad_filename)
|
||||
{
|
||||
ClearError();
|
||||
|
||||
// free any previously loaded wad
|
||||
VPO_FreeWAD();
|
||||
|
||||
vpo::R_Init();
|
||||
|
||||
if (! vpo::W_AddFile(wad_filename))
|
||||
{
|
||||
SetError("Missing or invalid wad file: %s", wad_filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0; // OK !
|
||||
}
|
||||
|
||||
|
||||
int VPO_OpenMap(const char *map_name, bool *is_hexen)
|
||||
{
|
||||
// check a wad is loaded
|
||||
if (vpo::numlumps <= 0)
|
||||
{
|
||||
SetError("VPO_OpenMap called without any loaded wad");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ClearError();
|
||||
|
||||
// close any previously loaded map
|
||||
VPO_CloseMap();
|
||||
|
||||
const char *err_msg = vpo::P_SetupLevel(map_name, is_hexen);
|
||||
|
||||
if (err_msg)
|
||||
{
|
||||
SetError("%s", err_msg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0; // OK !
|
||||
}
|
||||
|
||||
|
||||
void VPO_FreeWAD(void)
|
||||
{
|
||||
VPO_CloseMap();
|
||||
|
||||
vpo::W_RemoveFile();
|
||||
}
|
||||
|
||||
|
||||
void VPO_CloseMap(void)
|
||||
{
|
||||
ClearError();
|
||||
|
||||
last_x = -77777;
|
||||
last_y = -77777;
|
||||
last_sector = NULL;
|
||||
|
||||
vpo::P_FreeLevelData();
|
||||
}
|
||||
|
||||
|
||||
const char * VPO_GetMapName(unsigned int index, bool *is_hexen)
|
||||
{
|
||||
static char buffer[16];
|
||||
|
||||
for (int lump_i = 0 ; lump_i < vpo::numlumps ; lump_i++)
|
||||
{
|
||||
if (! vpo::lumpinfo[lump_i].is_map_header)
|
||||
continue;
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
// found it
|
||||
memcpy(buffer, vpo::lumpinfo[lump_i].name, 8);
|
||||
buffer[8] = 0;
|
||||
|
||||
if (is_hexen)
|
||||
*is_hexen = vpo::lumpinfo[lump_i].is_hexen;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
index--;
|
||||
}
|
||||
|
||||
// not found
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int VPO_GetLinedef(unsigned int index, int *x1, int *y1, int *x2, int *y2)
|
||||
{
|
||||
if (index >= (unsigned int)vpo::numlines)
|
||||
return -1;
|
||||
|
||||
const vpo::line_t *L = &vpo::lines[index];
|
||||
|
||||
*x1 = L->v1->x >> FRACBITS;
|
||||
*y1 = L->v1->y >> FRACBITS;
|
||||
|
||||
*x2 = L->v2->x >> FRACBITS;
|
||||
*y2 = L->v2->y >> FRACBITS;
|
||||
|
||||
return L->backsector ? 2 : 1;
|
||||
}
|
||||
|
||||
|
||||
int VPO_GetSeg(unsigned int index, int *linedef, int *side,
|
||||
int *x1, int *y1, int *x2, int *y2)
|
||||
{
|
||||
if (index >= (unsigned int)vpo::numsegs)
|
||||
return -1;
|
||||
|
||||
const vpo::seg_t *seg = &vpo::segs[index];
|
||||
const vpo::line_t *L = seg->linedef;
|
||||
|
||||
*x1 = seg->v1->x >> FRACBITS;
|
||||
*y1 = seg->v1->y >> FRACBITS;
|
||||
|
||||
*x2 = seg->v2->x >> FRACBITS;
|
||||
*y2 = seg->v2->y >> FRACBITS;
|
||||
|
||||
*linedef = (L - vpo::lines);
|
||||
*side = 0;
|
||||
|
||||
if (L->sidenum[1] >= 0 && seg->sidedef == &vpo::sides[L->sidenum[1]])
|
||||
*side = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void VPO_GetBBox(int *x1, int *y1, int *x2, int *y2)
|
||||
{
|
||||
*x1 = (vpo::Map_bbox[vpo::BOXLEFT] >> FRACBITS);
|
||||
*y1 = (vpo::Map_bbox[vpo::BOXBOTTOM] >> FRACBITS);
|
||||
*x2 = (vpo::Map_bbox[vpo::BOXRIGHT] >> FRACBITS);
|
||||
*y2 = (vpo::Map_bbox[vpo::BOXTOP] >> FRACBITS);
|
||||
}
|
||||
|
||||
|
||||
void VPO_OpenDoorSectors(int dir)
|
||||
{
|
||||
for (int i = 0 ; i < vpo::numsectors ; i++)
|
||||
{
|
||||
vpo::sector_t *sec = &vpo::sectors[i];
|
||||
|
||||
if (sec->is_door == 0)
|
||||
continue;
|
||||
|
||||
if (dir > 0) // open them
|
||||
{
|
||||
if (sec->is_door > 0)
|
||||
sec->ceilingheight = sec->alt_height;
|
||||
else
|
||||
sec->floorheight = sec->alt_height;
|
||||
}
|
||||
else if (dir < 0) // close them
|
||||
{
|
||||
if (sec->is_door > 0)
|
||||
sec->ceilingheight = sec->floorheight;
|
||||
else
|
||||
sec->floorheight = sec->ceilingheight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
int VPO_TestSpot(int x, int y, int dz, int angle,
|
||||
int *num_visplanes, int *num_drawsegs,
|
||||
int *num_openings, int *num_solidsegs)
|
||||
{
|
||||
// the actual spot we will use
|
||||
// (this prevents issues with X_SectorForPoint getting the wrong
|
||||
// value when the casted ray hits a vertex)
|
||||
vpo::fixed_t rx = (x << FRACBITS) + (FRACUNIT / 2);
|
||||
vpo::fixed_t ry = (y << FRACBITS) + (FRACUNIT / 2);
|
||||
|
||||
// check if spot is outside the map
|
||||
if (rx < vpo::Map_bbox[vpo::BOXLEFT] ||
|
||||
rx > vpo::Map_bbox[vpo::BOXRIGHT] ||
|
||||
ry < vpo::Map_bbox[vpo::BOXBOTTOM] ||
|
||||
ry > vpo::Map_bbox[vpo::BOXTOP])
|
||||
{
|
||||
return RESULT_IN_VOID;
|
||||
}
|
||||
|
||||
// optimization: we cache the last sector lookup
|
||||
vpo::sector_t *sec;
|
||||
|
||||
if (x == last_x && y == last_y)
|
||||
sec = last_sector;
|
||||
else
|
||||
{
|
||||
sec = vpo::X_SectorForPoint(rx, ry);
|
||||
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
last_sector = sec;
|
||||
}
|
||||
|
||||
if (! sec)
|
||||
return RESULT_IN_VOID;
|
||||
|
||||
vpo::fixed_t rz;
|
||||
|
||||
if (dz < 0)
|
||||
rz = sec->ceilingheight + (dz << FRACBITS);
|
||||
else
|
||||
rz = sec->floorheight + (dz << FRACBITS);
|
||||
|
||||
if (rz <= sec->floorheight || rz >= sec->ceilingheight)
|
||||
return RESULT_BAD_Z;
|
||||
|
||||
// convert angle to the 32-bit BAM representation
|
||||
if (angle == 360)
|
||||
angle = 0;
|
||||
|
||||
vpo::fixed_t ang2 = vpo::FixedDiv(angle << FRACBITS, 360 << FRACBITS);
|
||||
|
||||
vpo::angle_t r_ang = (vpo::angle_t) (ang2 << 16);
|
||||
|
||||
int result = RESULT_OK;
|
||||
|
||||
// perform a no-draw render and see how many visplanes were needed
|
||||
try
|
||||
{
|
||||
vpo::R_RenderView(rx, ry, rz, r_ang);
|
||||
}
|
||||
catch (vpo::overflow_exception& e)
|
||||
{
|
||||
result = RESULT_OVERFLOW;
|
||||
}
|
||||
|
||||
*num_visplanes = MAX(*num_visplanes, vpo::total_visplanes);
|
||||
*num_drawsegs = MAX(*num_drawsegs, vpo::total_drawsegs);
|
||||
*num_openings = MAX(*num_openings, vpo::total_openings);
|
||||
*num_solidsegs = MAX(*num_solidsegs, vpo::max_solidsegs);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#if 0 // VPO_TEST_PROGRAM
|
||||
|
||||
// NOTE: this is out of date and will not compile
|
||||
|
||||
#define EYE_HEIGHT 41
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
printf("----------------\n");
|
||||
printf("VPO TEST PROGRAM\n");
|
||||
printf("----------------\n");
|
||||
printf("\n");
|
||||
|
||||
if (argc < 5 ||
|
||||
(strcmp (argv[1], "-h") == 0 ||
|
||||
strcmp (argv[1], "--help") == 0 ||
|
||||
strcmp (argv[1], "/?") == 0) )
|
||||
{
|
||||
printf("Usage: vpotest file.wad MAP01 x y angle\n");
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *filename = argv[1];
|
||||
const char *map = argv[2];
|
||||
|
||||
int x = atoi(argv[3]);
|
||||
int y = atoi(argv[4]);
|
||||
int angle = atoi(argv[5]);
|
||||
|
||||
printf("Loading file: %s [%s]\n", filename, map);
|
||||
|
||||
if (VPO_LoadWAD(filename) != 0)
|
||||
{
|
||||
printf("ERROR: %s\n", VPO_GetError());
|
||||
fflush(stdout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (VPO_OpenMap(map) != 0)
|
||||
{
|
||||
printf("ERROR: %s\n", VPO_GetError());
|
||||
fflush(stdout);
|
||||
VPO_FreeWAD();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int vp_num = VPO_TestSpot(TEST_VISPLANES, x, y, EYE_HEIGHT, angle);
|
||||
|
||||
printf("\n");
|
||||
printf("Visplanes @ (%d %d) ---> %d\n", x, y, vp_num);
|
||||
fflush(stdout);
|
||||
|
||||
VPO_CloseMap();
|
||||
VPO_FreeWAD();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // VPO_TEST_PROGRAM
|
||||
|
||||
//--- editor settings ---
|
||||
// vi:ts=4:sw=4:noexpandtab
|
||||
|
|
|
@ -1,113 +1,113 @@
|
|||
//------------------------------------------------------------------------
|
||||
// VPO_LIB : misc stuff
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 Id Software, Inc.
|
||||
// Copyright (C) 2005 Simon Howard
|
||||
// Copyright (C) 2012 Andrew Apted
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#include "vpo_local.h"
|
||||
|
||||
namespace vpo
|
||||
{
|
||||
|
||||
|
||||
void I_Error (const char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
|
||||
va_start(argptr, error);
|
||||
vfprintf(stderr, error, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
fprintf(stderr, "\n\n");
|
||||
fflush(stderr);
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
static int ClosestLine_CastingHoriz(fixed_t x, fixed_t y, int *side)
|
||||
{
|
||||
int best_match = -1;
|
||||
fixed_t best_dist = 32000 << FRACBITS;
|
||||
|
||||
for (int n = 0 ; n < numlines ; n++)
|
||||
{
|
||||
fixed_t ly1 = lines[n].v1->y;
|
||||
fixed_t ly2 = lines[n].v2->y;
|
||||
|
||||
// ignore purely horizontal lines
|
||||
if (ly1 == ly2)
|
||||
continue;
|
||||
|
||||
// does the linedef cross the horizontal ray?
|
||||
if ( (y < ly1) && (y < ly2) ) continue;
|
||||
if ( (y > ly1) && (y > ly2) ) continue;
|
||||
|
||||
fixed_t lx1 = lines[n].v1->x;
|
||||
fixed_t lx2 = lines[n].v2->x;
|
||||
|
||||
fixed_t quot = FixedDiv(y - ly1, ly2 - ly1);
|
||||
fixed_t dist = lx1 - x + FixedMul(lx2 - lx1, quot);
|
||||
|
||||
if (abs(dist) < best_dist)
|
||||
{
|
||||
best_match = n;
|
||||
best_dist = abs(dist);
|
||||
|
||||
if (side)
|
||||
{
|
||||
if (best_dist < FRACUNIT / 8)
|
||||
*side = 0; // on the line
|
||||
else if ( (ly1 > ly2) == (dist > 0))
|
||||
*side = 1; // right side
|
||||
else
|
||||
*side = -1; // left side
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return best_match;
|
||||
}
|
||||
|
||||
|
||||
sector_t * X_SectorForPoint(fixed_t x, fixed_t y)
|
||||
{
|
||||
/* hack, hack... I look for the first LineDef crossing
|
||||
an horizontal half-line drawn from the cursor */
|
||||
|
||||
int sd = 0;
|
||||
int ld = ClosestLine_CastingHoriz(x, y, &sd);
|
||||
|
||||
// VOID checks
|
||||
if (ld < 0)
|
||||
return NULL;
|
||||
|
||||
if (lines[ld].sidenum[sd <= 0 ? 1 : 0] < 0)
|
||||
return NULL;
|
||||
|
||||
// get sector as DOOM would
|
||||
// (need this to handle self-referencing linedef tricks)
|
||||
subsector_t *sub = R_PointInSubsector(x, y);
|
||||
|
||||
return sub->sector;
|
||||
}
|
||||
|
||||
|
||||
} // namespace vpo
|
||||
|
||||
//--- editor settings ---
|
||||
// vi:ts=4:sw=4:noexpandtab
|
||||
//------------------------------------------------------------------------
|
||||
// VPO_LIB : misc stuff
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 Id Software, Inc.
|
||||
// Copyright (C) 2005 Simon Howard
|
||||
// Copyright (C) 2012 Andrew Apted
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#include "vpo_local.h"
|
||||
|
||||
namespace vpo
|
||||
{
|
||||
|
||||
|
||||
void I_Error (const char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
|
||||
va_start(argptr, error);
|
||||
vfprintf(stderr, error, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
fprintf(stderr, "\n\n");
|
||||
fflush(stderr);
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
static int ClosestLine_CastingHoriz(fixed_t x, fixed_t y, int *side)
|
||||
{
|
||||
int best_match = -1;
|
||||
fixed_t best_dist = 32000 << FRACBITS;
|
||||
|
||||
for (int n = 0 ; n < numlines ; n++)
|
||||
{
|
||||
fixed_t ly1 = lines[n].v1->y;
|
||||
fixed_t ly2 = lines[n].v2->y;
|
||||
|
||||
// ignore purely horizontal lines
|
||||
if (ly1 == ly2)
|
||||
continue;
|
||||
|
||||
// does the linedef cross the horizontal ray?
|
||||
if ( (y < ly1) && (y < ly2) ) continue;
|
||||
if ( (y > ly1) && (y > ly2) ) continue;
|
||||
|
||||
fixed_t lx1 = lines[n].v1->x;
|
||||
fixed_t lx2 = lines[n].v2->x;
|
||||
|
||||
fixed_t quot = FixedDiv(y - ly1, ly2 - ly1);
|
||||
fixed_t dist = lx1 - x + FixedMul(lx2 - lx1, quot);
|
||||
|
||||
if (abs(dist) < best_dist)
|
||||
{
|
||||
best_match = n;
|
||||
best_dist = abs(dist);
|
||||
|
||||
if (side)
|
||||
{
|
||||
if (best_dist < FRACUNIT / 8)
|
||||
*side = 0; // on the line
|
||||
else if ( (ly1 > ly2) == (dist > 0))
|
||||
*side = 1; // right side
|
||||
else
|
||||
*side = -1; // left side
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return best_match;
|
||||
}
|
||||
|
||||
|
||||
sector_t * X_SectorForPoint(fixed_t x, fixed_t y)
|
||||
{
|
||||
/* hack, hack... I look for the first LineDef crossing
|
||||
an horizontal half-line drawn from the cursor */
|
||||
|
||||
int sd = 0;
|
||||
int ld = ClosestLine_CastingHoriz(x, y, &sd);
|
||||
|
||||
// VOID checks
|
||||
if (ld < 0)
|
||||
return NULL;
|
||||
|
||||
if (lines[ld].sidenum[sd <= 0 ? 1 : 0] < 0)
|
||||
return NULL;
|
||||
|
||||
// get sector as DOOM would
|
||||
// (need this to handle self-referencing linedef tricks)
|
||||
subsector_t *sub = R_PointInSubsector(x, y);
|
||||
|
||||
return sub->sector;
|
||||
}
|
||||
|
||||
|
||||
} // namespace vpo
|
||||
|
||||
//--- editor settings ---
|
||||
// vi:ts=4:sw=4:noexpandtab
|
||||
|
|
|
@ -1,85 +1,85 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2008 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// WAD I/O functions.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "vpo_local.h"
|
||||
|
||||
namespace vpo
|
||||
{
|
||||
|
||||
|
||||
wad_file_t *W_OpenFile(const char *path)
|
||||
{
|
||||
wad_file_t *result;
|
||||
|
||||
FILE *fstream = fopen(path, "rb");
|
||||
|
||||
if (fstream == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Create a new wad_file_t to hold the file handle.
|
||||
|
||||
result = new wad_file_t;
|
||||
|
||||
result->fstream = fstream;
|
||||
|
||||
// result->length = M_FileLength(fstream);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void W_CloseFile(wad_file_t *wad)
|
||||
{
|
||||
fclose(wad->fstream);
|
||||
|
||||
delete wad;
|
||||
}
|
||||
|
||||
|
||||
// Read data from the specified position in the file into the
|
||||
// provided buffer. Returns the number of bytes read.
|
||||
|
||||
size_t W_Read(wad_file_t *wad, unsigned int offset,
|
||||
void *buffer, size_t buffer_len)
|
||||
{
|
||||
size_t result;
|
||||
|
||||
// Jump to the specified position in the file.
|
||||
|
||||
fseek(wad->fstream, offset, SEEK_SET);
|
||||
|
||||
// Read into the buffer.
|
||||
|
||||
result = fread(buffer, 1, buffer_len, wad->fstream);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
} // namespace vpo
|
||||
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2008 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// WAD I/O functions.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "vpo_local.h"
|
||||
|
||||
namespace vpo
|
||||
{
|
||||
|
||||
|
||||
wad_file_t *W_OpenFile(const char *path)
|
||||
{
|
||||
wad_file_t *result;
|
||||
|
||||
FILE *fstream = fopen(path, "rb");
|
||||
|
||||
if (fstream == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Create a new wad_file_t to hold the file handle.
|
||||
|
||||
result = new wad_file_t;
|
||||
|
||||
result->fstream = fstream;
|
||||
|
||||
// result->length = M_FileLength(fstream);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void W_CloseFile(wad_file_t *wad)
|
||||
{
|
||||
fclose(wad->fstream);
|
||||
|
||||
delete wad;
|
||||
}
|
||||
|
||||
|
||||
// Read data from the specified position in the file into the
|
||||
// provided buffer. Returns the number of bytes read.
|
||||
|
||||
size_t W_Read(wad_file_t *wad, unsigned int offset,
|
||||
void *buffer, size_t buffer_len)
|
||||
{
|
||||
size_t result;
|
||||
|
||||
// Jump to the specified position in the file.
|
||||
|
||||
fseek(wad->fstream, offset, SEEK_SET);
|
||||
|
||||
// Read into the buffer.
|
||||
|
||||
result = fread(buffer, 1, buffer_len, wad->fstream);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
} // namespace vpo
|
||||
|
||||
|
|
|
@ -1,55 +1,55 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2008 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// WAD I/O functions.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __W_FILE__
|
||||
#define __W_FILE__
|
||||
|
||||
#include <stdio.h>
|
||||
#include "doomtype.h"
|
||||
|
||||
typedef struct _wad_file_s
|
||||
{
|
||||
FILE *fstream;
|
||||
|
||||
} wad_file_t;
|
||||
|
||||
// Open the specified file. Returns a pointer to a new wad_file_t
|
||||
// handle for the WAD file, or NULL if it could not be opened.
|
||||
|
||||
wad_file_t *W_OpenFile(const char *path);
|
||||
|
||||
// Close the specified WAD file.
|
||||
|
||||
void W_CloseFile(wad_file_t *wad);
|
||||
|
||||
// Read data from the specified file into the provided buffer. The
|
||||
// data is read from the specified offset from the start of the file.
|
||||
// Returns the number of bytes read.
|
||||
|
||||
size_t W_Read(wad_file_t *wad, unsigned int offset,
|
||||
void *buffer, size_t buffer_len);
|
||||
|
||||
#endif /* #ifndef __W_FILE__ */
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2008 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// WAD I/O functions.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __W_FILE__
|
||||
#define __W_FILE__
|
||||
|
||||
#include <stdio.h>
|
||||
#include "doomtype.h"
|
||||
|
||||
typedef struct _wad_file_s
|
||||
{
|
||||
FILE *fstream;
|
||||
|
||||
} wad_file_t;
|
||||
|
||||
// Open the specified file. Returns a pointer to a new wad_file_t
|
||||
// handle for the WAD file, or NULL if it could not be opened.
|
||||
|
||||
wad_file_t *W_OpenFile(const char *path);
|
||||
|
||||
// Close the specified WAD file.
|
||||
|
||||
void W_CloseFile(wad_file_t *wad);
|
||||
|
||||
// Read data from the specified file into the provided buffer. The
|
||||
// data is read from the specified offset from the start of the file.
|
||||
// Returns the number of bytes read.
|
||||
|
||||
size_t W_Read(wad_file_t *wad, unsigned int offset,
|
||||
void *buffer, size_t buffer_len);
|
||||
|
||||
#endif /* #ifndef __W_FILE__ */
|
||||
|
|
|
@ -1,359 +1,366 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Handles WAD file header, directory, lump I/O.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "vpo_local.h"
|
||||
|
||||
namespace vpo
|
||||
{
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Should be "IWAD" or "PWAD".
|
||||
char identification[4];
|
||||
int numlumps;
|
||||
int infotableofs;
|
||||
} PACKEDATTR wadinfo_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int filepos;
|
||||
int size;
|
||||
char name[8];
|
||||
} PACKEDATTR filelump_t;
|
||||
|
||||
//
|
||||
// GLOBALS
|
||||
//
|
||||
|
||||
// Location of each lump on disk.
|
||||
|
||||
lumpinfo_t *lumpinfo;
|
||||
unsigned int numlumps = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// LUMP BASED ROUTINES.
|
||||
//
|
||||
|
||||
// andrewj: added this to find level names
|
||||
bool CheckMapHeader(filelump_t *lumps, int num_after)
|
||||
{
|
||||
static const char *level_lumps[] =
|
||||
{
|
||||
"THINGS", "LINEDEFS", "SIDEDEFS", "VERTEXES",
|
||||
"SEGS", "SSECTORS", "NODES", "SECTORS",
|
||||
|
||||
NULL // end of list
|
||||
};
|
||||
|
||||
if (num_after < 4)
|
||||
return false;
|
||||
|
||||
int seen_mask = 0;
|
||||
int seen_count = 0;
|
||||
|
||||
for (int i = 0 ; level_lumps[i] ; i++)
|
||||
{
|
||||
const char *name = level_lumps[i];
|
||||
|
||||
// level lumps are never valid map header names
|
||||
if (strncmp(lumps[0].name, name, 8) == 0)
|
||||
return false;
|
||||
|
||||
for (int pos = 1 ; pos <= 4 ; pos++)
|
||||
{
|
||||
if (strncmp(lumps[pos].name, name, 8) == 0)
|
||||
{
|
||||
int mask = 1 << i;
|
||||
|
||||
// check if name was duplicated
|
||||
if (seen_mask & mask)
|
||||
return false;
|
||||
|
||||
seen_mask |= mask;
|
||||
seen_count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// found enough level lumps
|
||||
if (seen_count >= 4)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// W_AddFile
|
||||
//
|
||||
// All files are optional, but at least one file must be
|
||||
// found (PWAD, if all required lumps are present).
|
||||
// Files with a .wad extension are wadlink files
|
||||
// with multiple lumps.
|
||||
// Other files are single lumps with the base filename
|
||||
// for the lump name.
|
||||
|
||||
wad_file_t *W_AddFile (const char *filename)
|
||||
{
|
||||
wadinfo_t header;
|
||||
lumpinfo_t *lump_p;
|
||||
unsigned int i;
|
||||
wad_file_t *wad_file;
|
||||
int length;
|
||||
int startlump;
|
||||
filelump_t *fileinfo;
|
||||
filelump_t *filerover;
|
||||
|
||||
// open the file and add to directory
|
||||
|
||||
wad_file = W_OpenFile(filename);
|
||||
|
||||
if (wad_file == NULL)
|
||||
{
|
||||
/// printf (" couldn't open %s\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
startlump = numlumps;
|
||||
|
||||
W_Read(wad_file, 0, &header, sizeof(header));
|
||||
|
||||
if (strncmp(header.identification,"IWAD",4))
|
||||
{
|
||||
// Homebrew levels?
|
||||
if (strncmp(header.identification,"PWAD",4))
|
||||
{
|
||||
I_Error ("Wad file %s doesn't have IWAD "
|
||||
"or PWAD id\n", filename);
|
||||
}
|
||||
|
||||
// ???modifiedgame = true;
|
||||
}
|
||||
|
||||
header.numlumps = LONG(header.numlumps);
|
||||
header.infotableofs = LONG(header.infotableofs);
|
||||
|
||||
length = header.numlumps * sizeof(filelump_t);
|
||||
|
||||
fileinfo = new filelump_t[header.numlumps];
|
||||
|
||||
W_Read(wad_file, header.infotableofs, fileinfo, length);
|
||||
numlumps += header.numlumps;
|
||||
|
||||
|
||||
// Fill in lumpinfo
|
||||
lumpinfo = (lumpinfo_t *)realloc(lumpinfo, numlumps * sizeof(lumpinfo_t));
|
||||
|
||||
if (lumpinfo == NULL)
|
||||
{
|
||||
I_Error ("Couldn't realloc lumpinfo");
|
||||
}
|
||||
|
||||
lump_p = &lumpinfo[startlump];
|
||||
|
||||
filerover = fileinfo;
|
||||
|
||||
for (i=startlump; i<numlumps; ++i)
|
||||
{
|
||||
lump_p->wad_file = wad_file;
|
||||
lump_p->position = LONG(filerover->filepos);
|
||||
lump_p->size = LONG(filerover->size);
|
||||
|
||||
strncpy(lump_p->name, filerover->name, 8);
|
||||
|
||||
lump_p->is_map_header = CheckMapHeader(filerover, numlumps - i - 1);
|
||||
|
||||
++lump_p;
|
||||
++filerover;
|
||||
}
|
||||
|
||||
delete[] fileinfo;
|
||||
|
||||
return wad_file;
|
||||
}
|
||||
|
||||
|
||||
void W_RemoveFile(void)
|
||||
{
|
||||
if (lumpinfo)
|
||||
{
|
||||
// andrewj: horrible hack, assumes a single wad file
|
||||
W_CloseFile(lumpinfo[0].wad_file);
|
||||
|
||||
free(lumpinfo);
|
||||
|
||||
lumpinfo = NULL;
|
||||
numlumps = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// W_NumLumps
|
||||
//
|
||||
int W_NumLumps (void)
|
||||
{
|
||||
return numlumps;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// W_CheckNumForName
|
||||
// Returns -1 if name not found.
|
||||
//
|
||||
|
||||
int W_CheckNumForName (const char* name)
|
||||
{
|
||||
int i;
|
||||
|
||||
{
|
||||
// scan backwards so patch lump files take precedence
|
||||
|
||||
for (i=numlumps-1; i >= 0; --i)
|
||||
{
|
||||
if (!strncasecmp(lumpinfo[i].name, name, 8))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TFB. Not found.
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// W_GetNumForName
|
||||
// Calls W_CheckNumForName, but bombs out if not found.
|
||||
//
|
||||
int W_GetNumForName (const char* name)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = W_CheckNumForName (name);
|
||||
|
||||
if (i < 0)
|
||||
{
|
||||
I_Error ("W_GetNumForName: %s not found!", name);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// W_LumpLength
|
||||
// Returns the buffer size needed to load the given lump.
|
||||
//
|
||||
int W_LumpLength (unsigned int lump)
|
||||
{
|
||||
if (lump >= numlumps)
|
||||
{
|
||||
I_Error ("W_LumpLength: %i >= numlumps", lump);
|
||||
}
|
||||
|
||||
return lumpinfo[lump].size;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// W_ReadLump
|
||||
// Loads the lump into the given buffer,
|
||||
// which must be >= W_LumpLength().
|
||||
//
|
||||
void W_ReadLump(unsigned int lump, void *dest)
|
||||
{
|
||||
int c;
|
||||
lumpinfo_t *l;
|
||||
|
||||
if (lump >= numlumps)
|
||||
{
|
||||
I_Error ("W_ReadLump: %i >= numlumps", lump);
|
||||
}
|
||||
|
||||
l = lumpinfo+lump;
|
||||
|
||||
/// I_BeginRead ();
|
||||
|
||||
c = W_Read(l->wad_file, l->position, dest, l->size);
|
||||
|
||||
if (c < l->size)
|
||||
{
|
||||
I_Error ("W_ReadLump: only read %i of %i on lump %i",
|
||||
c, l->size, lump);
|
||||
}
|
||||
|
||||
/// I_EndRead ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// W_LoadLump
|
||||
//
|
||||
// Load a lump into memory and return a pointer to a buffer containing
|
||||
// the lump data.
|
||||
//
|
||||
|
||||
byte * W_LoadLump(int lumpnum)
|
||||
{
|
||||
byte *result;
|
||||
lumpinfo_t *lump;
|
||||
|
||||
if ((unsigned)lumpnum >= numlumps)
|
||||
{
|
||||
I_Error ("W_LoadLump: %i >= numlumps", lumpnum);
|
||||
}
|
||||
|
||||
lump = &lumpinfo[lumpnum];
|
||||
|
||||
// load it now
|
||||
|
||||
result = new byte[W_LumpLength(lumpnum) + 1];
|
||||
|
||||
W_ReadLump (lumpnum, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void W_FreeLump(byte * data)
|
||||
{
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
|
||||
} // namespace vpo
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Handles WAD file header, directory, lump I/O.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "vpo_local.h"
|
||||
|
||||
namespace vpo
|
||||
{
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Should be "IWAD" or "PWAD".
|
||||
char identification[4];
|
||||
int numlumps;
|
||||
int infotableofs;
|
||||
|
||||
} PACKEDATTR wadinfo_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int filepos;
|
||||
int size;
|
||||
char name[8];
|
||||
|
||||
} PACKEDATTR filelump_t;
|
||||
|
||||
//
|
||||
// GLOBALS
|
||||
//
|
||||
|
||||
// Location of each lump on disk.
|
||||
|
||||
lumpinfo_t *lumpinfo;
|
||||
|
||||
int numlumps = 0;
|
||||
|
||||
static char * wad_filename;
|
||||
|
||||
static wad_file_t * current_file;
|
||||
|
||||
|
||||
|
||||
//
|
||||
// LUMP BASED ROUTINES.
|
||||
//
|
||||
|
||||
// andrewj: added this to find level names
|
||||
// returns 0 if not a level, 1 for DOOM, 2 for HEXEN format
|
||||
static int CheckMapHeader(filelump_t *lumps, int num_after)
|
||||
{
|
||||
static const char *level_lumps[] =
|
||||
{
|
||||
"THINGS", "LINEDEFS", "SIDEDEFS", "VERTEXES",
|
||||
"SEGS", "SSECTORS", "NODES", "SECTORS",
|
||||
"REJECT", "BLOCKMAP"
|
||||
};
|
||||
|
||||
if (num_after < 10)
|
||||
return 0;
|
||||
|
||||
for (int i = 0 ; i < 10 ; i++)
|
||||
{
|
||||
const char *name = level_lumps[i];
|
||||
|
||||
// level lumps are never valid map header names
|
||||
if (strncmp(lumps[0].name, name, 8) == 0)
|
||||
return 0;
|
||||
|
||||
// require a one-to-one correspondence
|
||||
// (anything else would crash DOOM)
|
||||
if (strncmp(lumps[1 + i].name, name, 8) != 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// hexen format is distinguished by a following BEHAVIOR lump
|
||||
if (num_after >= 11 && strncmp(lumps[11].name, "BEHAVIOR", 8) == 0)
|
||||
return 2;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// W_AddFile
|
||||
//
|
||||
// All files are optional, but at least one file must be
|
||||
// found (PWAD, if all required lumps are present).
|
||||
// Files with a .wad extension are wadlink files
|
||||
// with multiple lumps.
|
||||
// Other files are single lumps with the base filename
|
||||
// for the lump name.
|
||||
|
||||
bool W_AddFile (const char *filename)
|
||||
{
|
||||
wadinfo_t header;
|
||||
lumpinfo_t *lump_p;
|
||||
wad_file_t *wad_file;
|
||||
|
||||
int i;
|
||||
int length;
|
||||
int startlump;
|
||||
|
||||
filelump_t *fileinfo;
|
||||
filelump_t *filerover;
|
||||
|
||||
// open the file and add to directory
|
||||
|
||||
wad_file = W_OpenFile(filename);
|
||||
|
||||
if (wad_file == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
startlump = numlumps;
|
||||
|
||||
W_Read(wad_file, 0, &header, sizeof(header));
|
||||
|
||||
if (strncmp(header.identification,"IWAD",4) != 0)
|
||||
{
|
||||
// Homebrew levels?
|
||||
if (strncmp(header.identification,"PWAD",4) != 0)
|
||||
{
|
||||
/// I_Error ("Wad file %s doesn't have IWAD "
|
||||
/// "or PWAD id\n", filename);
|
||||
|
||||
W_CloseFile(wad_file);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
header.numlumps = LONG(header.numlumps);
|
||||
header.infotableofs = LONG(header.infotableofs);
|
||||
|
||||
length = header.numlumps * sizeof(filelump_t);
|
||||
|
||||
fileinfo = new filelump_t[header.numlumps];
|
||||
|
||||
W_Read(wad_file, header.infotableofs, fileinfo, length);
|
||||
numlumps += header.numlumps;
|
||||
|
||||
|
||||
// Fill in lumpinfo
|
||||
lumpinfo = (lumpinfo_t *)realloc(lumpinfo, numlumps * sizeof(lumpinfo_t));
|
||||
|
||||
if (! lumpinfo)
|
||||
I_Error ("Out of memory -- could not realloc lumpinfo");
|
||||
|
||||
lump_p = &lumpinfo[startlump];
|
||||
|
||||
filerover = fileinfo;
|
||||
|
||||
for (i=startlump; i < numlumps; ++i)
|
||||
{
|
||||
int map_header;
|
||||
|
||||
lump_p->position = LONG(filerover->filepos);
|
||||
lump_p->size = LONG(filerover->size);
|
||||
|
||||
strncpy(lump_p->name, filerover->name, 8);
|
||||
|
||||
map_header = CheckMapHeader(filerover, numlumps - i - 1);
|
||||
|
||||
lump_p->is_map_header = (map_header >= 1);
|
||||
lump_p->is_hexen = (map_header == 2);
|
||||
|
||||
++lump_p;
|
||||
++filerover;
|
||||
}
|
||||
|
||||
delete[] fileinfo;
|
||||
|
||||
// close the file now, we re-open it later to load the map
|
||||
W_CloseFile(wad_file);
|
||||
|
||||
wad_filename = strdup(filename);
|
||||
|
||||
if (! wad_filename)
|
||||
I_Error ("Out of memory -- could not strdup filename");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void W_RemoveFile(void)
|
||||
{
|
||||
if (wad_filename)
|
||||
{
|
||||
free(wad_filename);
|
||||
|
||||
wad_filename = NULL;
|
||||
|
||||
free(lumpinfo);
|
||||
|
||||
lumpinfo = NULL;
|
||||
numlumps = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// W_NumLumps
|
||||
//
|
||||
int W_NumLumps (void)
|
||||
{
|
||||
return numlumps;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// W_CheckNumForName
|
||||
// Returns -1 if name not found.
|
||||
//
|
||||
int W_CheckNumForName (const char* name)
|
||||
{
|
||||
int i;
|
||||
|
||||
// scan backwards so patch lump files take precedence
|
||||
|
||||
for (i=numlumps-1; i >= 0; --i)
|
||||
{
|
||||
if (strncasecmp(lumpinfo[i].name, name, 8) == 0)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// TFB. Not found.
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// W_LumpLength
|
||||
// Returns the buffer size needed to load the given lump.
|
||||
//
|
||||
int W_LumpLength (int lumpnum)
|
||||
{
|
||||
if (lumpnum >= numlumps)
|
||||
{
|
||||
I_Error ("W_LumpLength: %i >= numlumps", lumpnum);
|
||||
}
|
||||
|
||||
return lumpinfo[lumpnum].size;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// W_ReadLump
|
||||
// Loads the lump into the given buffer,
|
||||
// which must be >= W_LumpLength().
|
||||
//
|
||||
static void W_ReadLump(int lump, void *dest)
|
||||
{
|
||||
int c;
|
||||
lumpinfo_t *l;
|
||||
|
||||
if (lump >= numlumps)
|
||||
{
|
||||
I_Error ("W_ReadLump: %i >= numlumps", lump);
|
||||
}
|
||||
|
||||
l = lumpinfo+lump;
|
||||
|
||||
c = W_Read(current_file, l->position, dest, l->size);
|
||||
|
||||
if (c < l->size)
|
||||
{
|
||||
I_Error ("W_ReadLump: only read %i of %i on lump %i", c, l->size, lump);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// W_LoadLump
|
||||
//
|
||||
// Load a lump into memory and return a pointer to a buffer containing
|
||||
// the lump data.
|
||||
//
|
||||
byte * W_LoadLump(int lumpnum)
|
||||
{
|
||||
byte *result;
|
||||
|
||||
if (lumpnum < 0 || lumpnum >= numlumps)
|
||||
{
|
||||
I_Error ("W_LoadLump: %i >= numlumps", lumpnum);
|
||||
}
|
||||
|
||||
if (! current_file)
|
||||
I_Error ("W_LoadLump: no current file (W_BeginRead not called)");
|
||||
|
||||
// load it now
|
||||
|
||||
result = new byte[W_LumpLength(lumpnum) + 1];
|
||||
|
||||
W_ReadLump (lumpnum, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void W_FreeLump(byte * data)
|
||||
{
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
|
||||
void W_BeginRead(void)
|
||||
{
|
||||
// check API usage
|
||||
if (! wad_filename)
|
||||
I_Error("W_BeginRead called without any wad file!");
|
||||
|
||||
if (current_file)
|
||||
I_Error("W_BeginRead called twice without W_EndRead.");
|
||||
|
||||
current_file = W_OpenFile(wad_filename);
|
||||
|
||||
// it should normally succeed, as it is unlikely the file suddenly
|
||||
// disappears between reading the directory and loading a map.
|
||||
if (! current_file)
|
||||
I_Error("Could not re-open the wad file -- deleted?");
|
||||
}
|
||||
|
||||
|
||||
void W_EndRead()
|
||||
{
|
||||
if (! current_file)
|
||||
I_Error("W_EndRead called without a previous W_BeginRead.");
|
||||
|
||||
W_CloseFile(current_file);
|
||||
|
||||
current_file = NULL;
|
||||
}
|
||||
|
||||
|
||||
} // namespace vpo
|
||||
|
||||
//--- editor settings ---
|
||||
// vi:ts=4:sw=4:noexpandtab
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
|
|
|
@ -1,79 +1,84 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// WAD I/O functions.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __W_WAD__
|
||||
#define __W_WAD__
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "doomtype.h"
|
||||
#include "w_file.h"
|
||||
|
||||
|
||||
//
|
||||
// TYPES
|
||||
//
|
||||
|
||||
//
|
||||
// WADFILE I/O related stuff.
|
||||
//
|
||||
|
||||
typedef struct lumpinfo_s lumpinfo_t;
|
||||
|
||||
struct lumpinfo_s
|
||||
{
|
||||
char name[8];
|
||||
wad_file_t *wad_file;
|
||||
int position;
|
||||
int size;
|
||||
bool is_map_header; // e.g. MAP01 or E1M1
|
||||
|
||||
// Used for hash table lookups
|
||||
|
||||
lumpinfo_t *next;
|
||||
};
|
||||
|
||||
|
||||
extern lumpinfo_t *lumpinfo;
|
||||
extern unsigned int numlumps;
|
||||
|
||||
|
||||
wad_file_t *W_AddFile (const char *filename);
|
||||
|
||||
void W_RemoveFile(void);
|
||||
|
||||
|
||||
int W_CheckNumForName (const char* name);
|
||||
int W_GetNumForName (const char* name);
|
||||
|
||||
int W_LumpLength (unsigned int lump);
|
||||
|
||||
byte * W_LoadLump(int lumpnum);
|
||||
void W_FreeLump(byte * data);
|
||||
|
||||
|
||||
#endif // __W_WAD__
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005 Simon Howard
|
||||
//
|
||||
// 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 the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// WAD I/O functions.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __W_WAD__
|
||||
#define __W_WAD__
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "doomtype.h"
|
||||
#include "w_file.h"
|
||||
|
||||
|
||||
//
|
||||
// TYPES
|
||||
//
|
||||
|
||||
//
|
||||
// WADFILE I/O related stuff.
|
||||
//
|
||||
|
||||
typedef struct lumpinfo_s lumpinfo_t;
|
||||
|
||||
struct lumpinfo_s
|
||||
{
|
||||
char name[8];
|
||||
|
||||
int position;
|
||||
int size;
|
||||
|
||||
bool is_map_header; // e.g. MAP01 or E1M1
|
||||
bool is_hexen;
|
||||
};
|
||||
|
||||
|
||||
extern lumpinfo_t *lumpinfo;
|
||||
extern int numlumps;
|
||||
|
||||
|
||||
// andrewj: only a single file can be added now
|
||||
bool W_AddFile (const char *filename);
|
||||
|
||||
void W_RemoveFile(void);
|
||||
|
||||
|
||||
int W_CheckNumForName (const char *name);
|
||||
|
||||
int W_LumpLength (int lumpnum);
|
||||
|
||||
|
||||
// andrewj: all lump loading must occur between these calls
|
||||
void W_BeginRead(void);
|
||||
void W_EndRead();
|
||||
|
||||
byte * W_LoadLump(int lumpnum);
|
||||
void W_FreeLump(byte * data);
|
||||
|
||||
|
||||
#endif /* __W_WAD__ */
|
||||
|
||||
//--- editor settings ---
|
||||
// vi:ts=4:sw=4:noexpandtab
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
|
|
Loading…
Reference in a new issue