2007-09-05 21:56:58 +00:00
|
|
|
// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
|
|
|
|
// Ken Silverman's official web site: "http://www.advsys.net/ken"
|
|
|
|
// See the included license file "BUILDLIC.TXT" for license info.
|
|
|
|
//
|
|
|
|
// This file has been modified from Ken Silverman's original release
|
2012-03-12 04:47:04 +00:00
|
|
|
// by Jonathon Fowler (jf@jonof.id.au)
|
2018-11-05 07:28:01 +00:00
|
|
|
// by the EDuke32 team (development@voidpoint.com)
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2016-03-14 00:07:44 +00:00
|
|
|
#pragma once
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#ifndef build_h_
|
|
|
|
#define build_h_
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2020-05-28 06:31:08 +00:00
|
|
|
#define TRANSPARENT_INDEX 0
|
2020-04-11 22:04:02 +00:00
|
|
|
|
2019-10-16 21:09:02 +00:00
|
|
|
static_assert('\xff' == 255, "Char must be unsigned!");
|
|
|
|
|
2017-07-10 13:44:01 +00:00
|
|
|
#if !defined __cplusplus || (__cplusplus < 201103L && !defined _MSC_VER)
|
|
|
|
# error C++11 or greater is required.
|
|
|
|
#endif
|
|
|
|
|
2008-02-16 22:27:08 +00:00
|
|
|
#include "compat.h"
|
2016-06-21 00:33:06 +00:00
|
|
|
#include "palette.h"
|
2008-02-16 22:27:08 +00:00
|
|
|
|
2020-11-14 09:00:37 +00:00
|
|
|
//Make all variables in BUILD.H defined in the ENGINE,
|
|
|
|
//and externed in GAME
|
|
|
|
#ifdef engine_c_
|
|
|
|
# define EXTERN
|
|
|
|
#else
|
|
|
|
# define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
|
|
|
EXTERN int16_t sintable[2048];
|
2019-12-17 22:25:07 +00:00
|
|
|
|
2020-05-24 05:58:56 +00:00
|
|
|
#include "buildtiles.h"
|
2019-10-23 19:11:37 +00:00
|
|
|
#include "c_cvars.h"
|
2020-04-11 21:39:40 +00:00
|
|
|
#include "cmdlib.h"
|
2020-11-14 09:00:37 +00:00
|
|
|
#include "binaryangle.h"
|
2020-09-08 16:39:47 +00:00
|
|
|
#include "mathutil.h"
|
2019-03-01 08:51:50 +00:00
|
|
|
|
2020-03-29 12:55:09 +00:00
|
|
|
typedef int64_t coord_t;
|
|
|
|
|
2020-10-15 15:02:35 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
MAXSECTORS = 4096,
|
|
|
|
MAXWALLS = 16384,
|
|
|
|
MAXSPRITES = 16384,
|
2012-05-01 12:40:24 +00:00
|
|
|
|
2020-10-15 15:02:35 +00:00
|
|
|
MAXVOXMIPS = 5,
|
2012-05-06 20:23:20 +00:00
|
|
|
|
2020-10-15 15:02:35 +00:00
|
|
|
MAXXDIM = 7680,
|
|
|
|
MAXYDIM = 3200,
|
|
|
|
MINXDIM = 640,
|
|
|
|
MINYDIM = 480,
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2020-10-15 15:02:35 +00:00
|
|
|
MAXWALLSB = ((MAXWALLS >> 2) + (MAXWALLS >> 3)),
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2020-10-15 15:02:35 +00:00
|
|
|
MAXVOXELS = 1024,
|
|
|
|
MAXSTATUS = 1024,
|
|
|
|
// Maximum number of component tiles in a multi-psky:
|
|
|
|
MAXPSKYTILES = 16,
|
|
|
|
MAXSPRITESONSCREEN = 2560,
|
|
|
|
MAXUNIQHUDID = 256, //Extra slots so HUD models can store animation state without messing game sprites
|
2008-07-22 09:05:34 +00:00
|
|
|
|
2020-10-15 15:02:35 +00:00
|
|
|
TSPR_TEMP = 99,
|
2009-04-29 19:43:51 +00:00
|
|
|
|
2020-10-15 15:02:35 +00:00
|
|
|
CLIPMASK0 = (IntToFixed(1)+1),
|
|
|
|
CLIPMASK1 = (IntToFixed(256)+64),
|
|
|
|
};
|
2012-05-29 20:01:48 +00:00
|
|
|
|
|
|
|
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2019-04-18 17:24:26 +00:00
|
|
|
#define POINT2(i) (wall[wall[i].point2])
|
|
|
|
|
2011-02-15 21:02:43 +00:00
|
|
|
|
2013-11-22 19:26:52 +00:00
|
|
|
// rotatesprite 'orientation' (actually much more) bits
|
2012-08-19 13:02:37 +00:00
|
|
|
enum {
|
2013-11-22 19:26:52 +00:00
|
|
|
RS_TRANS1 = 1,
|
|
|
|
RS_AUTO = 2,
|
|
|
|
RS_YFLIP = 4,
|
|
|
|
RS_NOCLIP = 8,
|
|
|
|
RS_TOPLEFT = 16,
|
|
|
|
RS_TRANS2 = 32,
|
|
|
|
RS_NOMASK = 64,
|
|
|
|
RS_PERM = 128,
|
|
|
|
|
|
|
|
RS_ALIGN_L = 256,
|
|
|
|
RS_ALIGN_R = 512,
|
|
|
|
RS_ALIGN_MASK = 768,
|
|
|
|
RS_STRETCH = 1024,
|
|
|
|
|
2020-05-19 22:35:52 +00:00
|
|
|
RS_MODELSUBST= 4096,
|
2012-08-19 13:02:37 +00:00
|
|
|
// ROTATESPRITE_MAX-1 is the mask of all externally available orientation bits
|
2020-05-19 22:35:52 +00:00
|
|
|
ROTATESPRITE_MAX = 8192,
|
2020-08-14 19:01:27 +00:00
|
|
|
RS_XFLIPHUD = RS_YFLIP,
|
|
|
|
RS_YFLIPHUD = 16384, // this is for hud_drawsprite which uses RS_YFLIP for x-flipping but needs both flags
|
2012-08-19 13:02:37 +00:00
|
|
|
|
2020-05-27 21:30:36 +00:00
|
|
|
RS_CENTER = (1<<29), // proper center align.
|
2012-08-19 13:02:37 +00:00
|
|
|
RS_CENTERORIGIN = (1<<30),
|
|
|
|
};
|
2012-08-19 12:57:57 +00:00
|
|
|
|
Lose the 'packed' attribute for types declared in build.h.
Most of them are already aligned to their natural boundaries, so lowering
the alignment to 1 byte can only worsen things by making the C compiler
generate poorer (unaligned access) code for some platforms.
The layout of structures is not specified by the C Standard, but is rather
given by a particular platform + toolchain's ABI (application binary interface).
Most ABIs follow the expected pattern "alignment of scalars is their size,
alignment of arrays is that of its element type, alignment of structs is the
maximum alignment of its members". A couple of links to particular ABIs are
given in build.h.
Problems are expected with archs that care about unaligned access when a pointer
to a non-packed struct is taken that resides in a packed aggregate, but these
uses should be weeded out (I'm not sure if there are any in our codebase).
The following types are affected, only hitdata_t changes its size:
sectortype, walltype, spritetype, spriteext_t, spritesmooth_t,
struct validmode_t, picanm_t, palette_t, vec2_t, vec3_t, hitdata_t.
git-svn-id: https://svn.eduke32.com/eduke32@3455 1a8010ca-5511-0410-912e-c29ae57300e0
2013-02-03 12:48:11 +00:00
|
|
|
|
2013-05-16 21:54:52 +00:00
|
|
|
enum {
|
|
|
|
SPR_XFLIP = 4,
|
|
|
|
SPR_YFLIP = 8,
|
|
|
|
|
|
|
|
SPR_WALL = 16,
|
|
|
|
SPR_FLOOR = 32,
|
|
|
|
SPR_ALIGN_MASK = 32+16,
|
|
|
|
};
|
|
|
|
|
2018-03-17 03:25:57 +00:00
|
|
|
#include "buildtypes.h"
|
2015-01-19 00:11:25 +00:00
|
|
|
|
2020-10-11 16:10:52 +00:00
|
|
|
using usectortype = sectortype;
|
|
|
|
using uwalltype = walltype;
|
2020-10-02 20:14:01 +00:00
|
|
|
using uspritetype = spritetype;
|
2019-04-18 17:25:14 +00:00
|
|
|
|
|
|
|
using uspriteptr_t = uspritetype const *;
|
|
|
|
using uwallptr_t = uwalltype const *;
|
|
|
|
using usectorptr_t = usectortype const *;
|
|
|
|
using tspriteptr_t = tspritetype *;
|
2018-03-17 03:25:57 +00:00
|
|
|
|
2018-01-31 04:13:25 +00:00
|
|
|
|
2013-04-09 17:35:11 +00:00
|
|
|
|
2017-01-05 05:29:11 +00:00
|
|
|
#include "clip.h"
|
|
|
|
|
2019-08-27 06:52:42 +00:00
|
|
|
int32_t getwalldist(vec2_t const in, int const wallnum);
|
|
|
|
int32_t getwalldist(vec2_t const in, int const wallnum, vec2_t * const out);
|
2019-08-04 02:51:59 +00:00
|
|
|
|
2009-07-09 02:29:48 +00:00
|
|
|
typedef struct {
|
2009-01-09 09:29:17 +00:00
|
|
|
uint32_t mdanimtims;
|
|
|
|
int16_t mdanimcur;
|
2010-05-02 23:27:30 +00:00
|
|
|
int16_t angoff, pitch, roll;
|
2019-12-31 19:35:28 +00:00
|
|
|
vec3_t pivot_offset, position_offset;
|
2009-01-10 07:38:50 +00:00
|
|
|
uint8_t flags;
|
2009-04-24 02:53:50 +00:00
|
|
|
float alpha;
|
2009-01-10 07:38:50 +00:00
|
|
|
} spriteext_t;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2009-07-09 02:29:48 +00:00
|
|
|
typedef struct {
|
2008-05-31 01:57:14 +00:00
|
|
|
float smoothduration;
|
2009-01-09 09:29:17 +00:00
|
|
|
int16_t mdcurframe, mdoldframe;
|
|
|
|
int16_t mdsmooth;
|
2009-01-10 07:38:50 +00:00
|
|
|
uint8_t filler[2];
|
|
|
|
} spritesmooth_t;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
|
|
|
#define SPREXT_NOTMD 1
|
|
|
|
#define SPREXT_NOMDANIM 2
|
2007-12-20 19:14:38 +00:00
|
|
|
#define SPREXT_AWAY1 4
|
|
|
|
#define SPREXT_AWAY2 8
|
2008-08-23 23:37:01 +00:00
|
|
|
#define SPREXT_TSPRACCESS 16
|
2011-08-17 18:52:16 +00:00
|
|
|
#define SPREXT_TEMPINVISIBLE 32
|
2008-07-12 10:57:52 +00:00
|
|
|
|
2020-03-04 23:58:38 +00:00
|
|
|
#define NEG_ALPHA_TO_BLEND(alpha, blend, orientation) do { \
|
|
|
|
if ((alpha) < 0) { (blend) = -(alpha); (alpha) = 0; (orientation) |= RS_TRANS1; } \
|
|
|
|
} while (0)
|
|
|
|
|
2019-12-26 06:28:03 +00:00
|
|
|
// using the clipdist field
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
TSPR_FLAGS_MDHACK = 1u<<0u,
|
2019-12-26 06:28:08 +00:00
|
|
|
TSPR_FLAGS_DRAW_LAST = 1u<<1u,
|
|
|
|
TSPR_FLAGS_NO_SHADOW = 1u<<2u,
|
|
|
|
TSPR_FLAGS_INVISIBLE_WITH_SHADOW = 1u<<3u,
|
2019-12-26 06:28:03 +00:00
|
|
|
};
|
2013-03-21 10:19:32 +00:00
|
|
|
|
Inreased debugging level for catching oob accesses to 'main' arrays.
If enabled, this makes the following arrays be allocated statically:
spriteext, spritesmooth, sector, wall, sprite, tsprite, while
necessarily disabling the clipshape feature (because it relies on
setting sector/wall to different malloc'd block temporarily).
To compile, pass DEBUGANYWAY=1 in addition to RELEASE=0 to 'make',
and it's really only useful with CC=clang, of course.
git-svn-id: https://svn.eduke32.com/eduke32@2270 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-19 23:17:34 +00:00
|
|
|
EXTERN int32_t guniqhudid;
|
|
|
|
EXTERN int32_t spritesortcnt;
|
2015-01-08 15:14:00 +00:00
|
|
|
|
2020-09-13 11:01:44 +00:00
|
|
|
struct usermaphack_t
|
|
|
|
{
|
|
|
|
FString mhkfile;
|
|
|
|
FString title;
|
|
|
|
uint8_t md4[16]{};
|
|
|
|
};
|
2015-01-18 20:31:37 +00:00
|
|
|
|
2009-01-10 07:38:50 +00:00
|
|
|
EXTERN spriteext_t *spriteext;
|
|
|
|
EXTERN spritesmooth_t *spritesmooth;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2020-10-13 22:58:21 +00:00
|
|
|
// Wrapper that makes an array of pointers look like an array of references. (Refactoring helper.)
|
|
|
|
|
|
|
|
template<class T, int size>
|
|
|
|
class ReferenceArray
|
|
|
|
{
|
|
|
|
T* data[size];
|
|
|
|
public:
|
|
|
|
T& operator[](size_t index)
|
|
|
|
{
|
|
|
|
assert(index < size);
|
|
|
|
return *data[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
void set(int pos, T* spr)
|
|
|
|
{
|
|
|
|
data[pos] = spr;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-09-06 10:43:42 +00:00
|
|
|
EXTERN sectortype *sector;
|
|
|
|
EXTERN walltype *wall;
|
Inreased debugging level for catching oob accesses to 'main' arrays.
If enabled, this makes the following arrays be allocated statically:
spriteext, spritesmooth, sector, wall, sprite, tsprite, while
necessarily disabling the clipshape feature (because it relies on
setting sector/wall to different malloc'd block temporarily).
To compile, pass DEBUGANYWAY=1 in addition to RELEASE=0 to 'make',
and it's really only useful with CC=clang, of course.
git-svn-id: https://svn.eduke32.com/eduke32@2270 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-19 23:17:34 +00:00
|
|
|
EXTERN spritetype *sprite;
|
2019-04-18 17:25:24 +00:00
|
|
|
EXTERN tspriteptr_t tsprite;
|
2020-10-11 18:57:20 +00:00
|
|
|
|
|
|
|
extern sectortype sectorbackup[MAXSECTORS];
|
|
|
|
extern walltype wallbackup[MAXWALLS];
|
2012-11-09 22:31:02 +00:00
|
|
|
|
2013-04-09 17:35:11 +00:00
|
|
|
|
2019-12-26 06:27:58 +00:00
|
|
|
static inline tspriteptr_t renderMakeTSpriteFromSprite(tspriteptr_t const tspr, uint16_t const spritenum)
|
|
|
|
{
|
2020-07-14 11:51:03 +00:00
|
|
|
auto const spr = &sprite[spritenum];
|
2019-12-26 06:27:58 +00:00
|
|
|
|
2020-10-11 18:57:20 +00:00
|
|
|
*tspr = *spr;
|
2019-12-26 06:27:58 +00:00
|
|
|
|
|
|
|
tspr->clipdist = 0;
|
|
|
|
tspr->owner = spritenum;
|
|
|
|
|
|
|
|
return tspr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline tspriteptr_t renderAddTSpriteFromSprite(uint16_t const spritenum)
|
|
|
|
{
|
|
|
|
return renderMakeTSpriteFromSprite(&tsprite[spritesortcnt++], spritenum);
|
|
|
|
}
|
|
|
|
|
2014-10-25 03:36:34 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
EXTERN int16_t maskwall[MAXWALLSB], maskwallcnt;
|
|
|
|
EXTERN int16_t thewall[MAXWALLSB];
|
2019-04-18 17:25:24 +00:00
|
|
|
EXTERN tspriteptr_t tspriteptr[MAXSPRITESONSCREEN + 1];
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2021-02-25 11:16:21 +00:00
|
|
|
EXTERN int32_t xdim, ydim;
|
2009-01-09 09:29:17 +00:00
|
|
|
EXTERN int32_t yxaspect, viewingrange;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2012-03-14 22:30:24 +00:00
|
|
|
EXTERN int32_t Numsprites;
|
2009-01-09 09:29:17 +00:00
|
|
|
EXTERN int16_t numsectors, numwalls;
|
2019-05-19 03:55:19 +00:00
|
|
|
EXTERN int32_t display_mirror;
|
2014-07-28 06:43:16 +00:00
|
|
|
|
2020-08-23 16:08:08 +00:00
|
|
|
EXTERN int32_t randomseed;
|
2015-09-23 17:54:50 +00:00
|
|
|
|
2012-03-20 18:32:00 +00:00
|
|
|
EXTERN int16_t numshades;
|
2015-09-23 17:54:50 +00:00
|
|
|
EXTERN uint8_t paletteloaded;
|
|
|
|
|
2020-07-31 18:58:55 +00:00
|
|
|
// Return type is int because this gets passed to variadic functions where structs may produce undefined behavior.
|
|
|
|
inline int shadeToLight(int shade)
|
|
|
|
{
|
|
|
|
shade = clamp(shade, 0, numshades-1);
|
2021-01-04 12:34:55 +00:00
|
|
|
int light = Scale(numshades-1-shade, 255, numshades-1);
|
2020-07-31 18:58:55 +00:00
|
|
|
return PalEntry(255,light,light,light);
|
|
|
|
}
|
2020-05-23 12:40:54 +00:00
|
|
|
|
2017-07-08 19:42:11 +00:00
|
|
|
EXTERN int32_t maxspritesonscreen;
|
2017-07-08 19:41:49 +00:00
|
|
|
|
2015-09-23 17:54:50 +00:00
|
|
|
enum {
|
|
|
|
PALETTE_MAIN = 1<<0,
|
|
|
|
PALETTE_SHADE = 1<<1,
|
|
|
|
PALETTE_TRANSLUC = 1<<2,
|
|
|
|
};
|
|
|
|
|
2012-12-14 19:28:05 +00:00
|
|
|
EXTERN int32_t g_visibility, parallaxvisibility;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2015-04-09 07:51:48 +00:00
|
|
|
// blendtable[1] to blendtable[numalphatabs] are considered to be
|
|
|
|
// alpha-blending tables:
|
|
|
|
EXTERN uint8_t numalphatabs;
|
|
|
|
|
2016-06-21 00:34:18 +00:00
|
|
|
EXTERN vec2_t windowxy1, windowxy2;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2013-08-04 20:37:45 +00:00
|
|
|
// The maximum tile offset ever used in any tiled parallaxed multi-sky.
|
2020-01-02 12:33:41 +00:00
|
|
|
#define PSKYOFF_MAX 16
|
2015-05-27 08:47:34 +00:00
|
|
|
#define DEFAULTPSKY -1
|
2013-08-04 20:37:45 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2020-07-14 22:06:19 +00:00
|
|
|
int tilenum;
|
2013-08-04 20:37:45 +00:00
|
|
|
// The proportion at which looking up/down affects the apparent 'horiz' of
|
|
|
|
// a parallaxed sky, scaled by 65536 (so, a value of 65536 makes it align
|
|
|
|
// with the drawn surrounding scene):
|
|
|
|
int32_t horizfrac;
|
|
|
|
|
|
|
|
// The texel index offset in the y direction of a parallaxed sky:
|
|
|
|
// XXX: currently always 0.
|
|
|
|
int32_t yoffs;
|
|
|
|
|
2013-11-22 19:26:44 +00:00
|
|
|
int8_t lognumtiles; // 1<<lognumtiles: number of tiles in multi-sky
|
2020-07-14 22:06:19 +00:00
|
|
|
int16_t tileofs[MAXPSKYTILES]; // for 0 <= j < (1<<lognumtiles): tile offset relative to basetile
|
2017-11-29 07:29:48 +00:00
|
|
|
|
|
|
|
int32_t yscale;
|
2013-08-04 20:37:45 +00:00
|
|
|
} psky_t;
|
|
|
|
|
Clean up parallaxed sky functionality, part 2.
- Rename sky_t members: yscale -> horizfrac, bits -> lognumtiles.
- Add default sky (8 tiles, horizfrac=32768 (i.e. 1/2 the scene horiz), offsets
all zero) and CLOUDYOCEAN sky (8 tiles, horizfrac=65536, offsets all zero)
to multipsky[].
- Get rid of "psky_t g_psky", merely maintaining a g_pskyidx instead. Set it up
at map load time so as to keep the behavior of the legacy per-map psky:
the last sector index with a matching psky ceiling wins.
- In mapstate_t, save g_pskyidx too, not (former) pskybits and pskyoffs[].
- Make on-map-load global psky setup consistent for the game and editor by
factoring it out into common.c: G_SetupGlobalPsky().
- Remove a couple of useless initializations, add some static assertions.
This commit is more likely to introduce subtle differences in behavior.
Specifically, getpsky() now always returns the default sky properties instead of
the global sky ones (but with all-zero offsets) when no match for a suiting
multi-psky is found. This is only likely to affect the yscale/horizfrac of
non-multi-pskies when a global non-default multi-psky has been set up.
Bump BYTEVERSION again.
git-svn-id: https://svn.eduke32.com/eduke32@3976 1a8010ca-5511-0410-912e-c29ae57300e0
2013-08-04 20:37:48 +00:00
|
|
|
// Index of map-global (legacy) multi-sky:
|
2015-05-27 08:47:34 +00:00
|
|
|
// New multi-psky
|
2020-07-14 22:06:19 +00:00
|
|
|
EXTERN TArray<psky_t> multipskies;
|
2013-08-04 20:37:45 +00:00
|
|
|
|
2020-10-15 15:02:35 +00:00
|
|
|
static inline psky_t *getpskyidx(int32_t picnum)
|
2013-08-11 15:28:51 +00:00
|
|
|
{
|
2020-07-14 22:06:19 +00:00
|
|
|
for (auto& sky : multipskies)
|
|
|
|
if (picnum == sky.tilenum) return &sky;
|
2013-08-11 15:28:51 +00:00
|
|
|
|
2020-07-14 22:06:19 +00:00
|
|
|
return &multipskies[0];
|
2013-08-11 15:28:51 +00:00
|
|
|
}
|
|
|
|
|
2020-07-14 22:06:19 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
EXTERN psky_t * tileSetupSky(int32_t tilenum);
|
2020-07-14 22:06:19 +00:00
|
|
|
psky_t* defineSky(int32_t const tilenum, int horiz, int lognumtiles, const uint16_t* tileofs, int yoff = 0);
|
2015-05-27 08:47:34 +00:00
|
|
|
|
2013-08-04 20:37:45 +00:00
|
|
|
EXTERN char parallaxtype;
|
2015-05-19 22:05:20 +00:00
|
|
|
EXTERN int32_t parallaxyoffs_override, parallaxyscale_override;
|
|
|
|
extern int16_t pskybits_override;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2020-12-04 21:29:25 +00:00
|
|
|
// last sprite in the freelist, that is the spritenum for which
|
2012-03-13 20:07:17 +00:00
|
|
|
// .statnum==MAXSTATUS && nextspritestat[spritenum]==-1
|
|
|
|
// (or -1 if freelist is empty):
|
|
|
|
EXTERN int16_t tailspritefree;
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
EXTERN int16_t headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1];
|
|
|
|
EXTERN int16_t prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES];
|
|
|
|
EXTERN int16_t nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES];
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2019-10-15 18:02:37 +00:00
|
|
|
EXTERN uint8_t gotpic[(MAXTILES+7)>>3];
|
2007-09-05 21:56:58 +00:00
|
|
|
EXTERN char gotsector[(MAXSECTORS+7)>>3];
|
|
|
|
|
2008-12-23 23:27:53 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
extern uint32_t drawlinepat;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2012-02-27 19:40:28 +00:00
|
|
|
extern int32_t novoxmips;
|
2010-08-26 15:24:12 +00:00
|
|
|
|
2012-01-19 21:57:46 +00:00
|
|
|
extern int16_t tiletovox[MAXTILES];
|
2019-10-23 19:11:37 +00:00
|
|
|
extern int32_t voxscale[MAXVOXELS];
|
2019-08-13 02:53:38 +00:00
|
|
|
extern char g_haveVoxels;
|
2011-03-04 08:50:58 +00:00
|
|
|
|
2018-02-15 03:49:23 +00:00
|
|
|
extern uint8_t globalr, globalg, globalb;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2015-03-09 20:32:36 +00:00
|
|
|
enum {
|
|
|
|
GLOBAL_NO_GL_TILESHADES = 1<<0,
|
|
|
|
GLOBAL_NO_GL_FULLBRIGHT = 1<<1,
|
2017-12-12 05:14:06 +00:00
|
|
|
GLOBAL_NO_GL_FOGSHADE = 1<<2,
|
2015-03-09 20:32:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern int32_t globalflags;
|
|
|
|
|
2011-02-21 23:08:21 +00:00
|
|
|
extern const char *engineerrstr;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
EXTERN int32_t editorzrange[2];
|
2008-11-05 11:49:13 +00:00
|
|
|
|
2019-09-22 19:26:07 +00:00
|
|
|
enum {
|
|
|
|
ENGINECOMPATIBILITY_NONE = 0,
|
|
|
|
ENGINECOMPATIBILITY_19950829, // Powerslave/Exhumed
|
|
|
|
ENGINECOMPATIBILITY_19960925, // Blood v1.21
|
|
|
|
ENGINECOMPATIBILITY_19961112, // Duke 3d v1.5, Redneck Rampage
|
|
|
|
};
|
|
|
|
|
|
|
|
EXTERN int32_t enginecompatibility_mode;
|
2019-09-21 11:02:17 +00:00
|
|
|
|
2007-09-05 21:56:58 +00:00
|
|
|
/*************************************************************************
|
|
|
|
POSITION VARIABLES:
|
|
|
|
|
|
|
|
POSX is your x - position ranging from 0 to 65535
|
|
|
|
POSY is your y - position ranging from 0 to 65535
|
|
|
|
(the length of a side of the grid in EDITBORD would be 1024)
|
|
|
|
POSZ is your z - position (height) ranging from 0 to 65535, 0 highest.
|
|
|
|
ANG is your angle ranging from 0 to 2047. Instead of 360 degrees, or
|
|
|
|
2 * PI radians, I use 2048 different angles, so 90 degrees would
|
|
|
|
be 512 in my system.
|
|
|
|
|
|
|
|
SPRITE VARIABLES:
|
|
|
|
|
|
|
|
EXTERN short headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1];
|
|
|
|
EXTERN short prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES];
|
|
|
|
EXTERN short nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES];
|
|
|
|
|
|
|
|
Example: if the linked lists look like the following:
|
2009-11-14 02:30:47 +00:00
|
|
|
????????????????
|
2016-06-05 04:46:28 +00:00
|
|
|
Sector lists: Status lists:
|
2009-11-14 02:30:47 +00:00
|
|
|
????????????????J
|
2016-06-05 04:46:28 +00:00
|
|
|
Sector0: 4, 5, 8 Status0: 2, 0, 8
|
|
|
|
Sector1: 16, 2, 0, 7 Status1: 4, 5, 16, 7, 3, 9
|
|
|
|
Sector2: 3, 9
|
2009-11-14 02:30:47 +00:00
|
|
|
????????????????
|
2007-09-05 21:56:58 +00:00
|
|
|
Notice that each number listed above is shown exactly once on both the
|
|
|
|
left and right side. This is because any sprite that exists must
|
|
|
|
be in some sector, and must have some kind of status that you define.
|
|
|
|
|
|
|
|
|
|
|
|
TILE VARIABLES:
|
|
|
|
NUMTILES - the number of tiles found TILES.DAT.
|
|
|
|
|
|
|
|
TIMING VARIABLES:
|
|
|
|
NUMFRAMES - The number of times the draw3dscreen function was called
|
|
|
|
since the engine was initialized. This helps to determine frame
|
2020-08-25 23:19:21 +00:00
|
|
|
rate. (Frame rate = numframes * 120 / I_GetBuildTime().)
|
2007-09-05 21:56:58 +00:00
|
|
|
|
|
|
|
OTHER VARIABLES:
|
|
|
|
|
|
|
|
STARTUMOST[320] is an array of the highest y-coordinates on each column
|
|
|
|
that my engine is allowed to write to. You need to set it only
|
|
|
|
once.
|
|
|
|
STARTDMOST[320] is an array of the lowest y-coordinates on each column
|
|
|
|
that my engine is allowed to write to. You need to set it only
|
|
|
|
once.
|
|
|
|
SINTABLE[2048] is a sin table with 2048 angles rather than the
|
|
|
|
normal 360 angles for higher precision. Also since SINTABLE is in
|
|
|
|
all integers, the range is multiplied by 16383, so instead of the
|
|
|
|
normal -1<sin(x)<1, the range of sintable is -16383<sintable[]<16383
|
|
|
|
If you use this sintable, you can possibly speed up your code as
|
|
|
|
well as save space in memory. If you plan to use sintable, 2
|
|
|
|
identities you may want to keep in mind are:
|
|
|
|
sintable[ang&2047] = sin(ang * (3.141592/1024)) * 16383
|
|
|
|
sintable[(ang+512)&2047] = cos(ang * (3.141592/1024)) * 16383
|
|
|
|
NUMSECTORS - the total number of existing sectors. Modified every time
|
|
|
|
you call the loadboard function.
|
|
|
|
***************************************************************************/
|
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
typedef struct {
|
|
|
|
vec3_t pos;
|
2012-08-10 19:12:01 +00:00
|
|
|
int16_t sprite, wall, sect;
|
2009-01-13 12:23:18 +00:00
|
|
|
} hitdata_t;
|
|
|
|
|
2015-04-12 08:07:10 +00:00
|
|
|
typedef struct artheader_t {
|
|
|
|
int32_t tilestart, tileend, numtiles;
|
|
|
|
} artheader_t;
|
2019-11-03 12:31:03 +00:00
|
|
|
#define ARTv1_UNITOFFSET 24 // using sizeof does not work because picanm_t is not the in-file format.
|
2009-07-24 02:31:34 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
int32_t enginePreInit(void); // a partial setup of the engine used for launch windows
|
|
|
|
int32_t engineInit(void);
|
|
|
|
void engineUnInit(void);
|
2007-09-05 21:56:58 +00:00
|
|
|
void initspritelists(void);
|
2015-09-23 17:54:50 +00:00
|
|
|
|
2020-09-22 19:44:33 +00:00
|
|
|
void engineLoadBoard(const char *filename, int flags, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum);
|
2020-10-11 18:57:20 +00:00
|
|
|
void loadMapBackup(const char* filename);
|
2021-03-07 08:39:16 +00:00
|
|
|
void G_LoadMapHack(const char* filename, const unsigned char*);
|
2015-04-12 08:07:10 +00:00
|
|
|
|
2011-01-16 00:23:39 +00:00
|
|
|
int32_t qloadkvx(int32_t voxindex, const char *filename);
|
2016-10-25 05:43:50 +00:00
|
|
|
void vox_undefine(int32_t const);
|
2019-12-25 07:57:58 +00:00
|
|
|
void vox_deinit();
|
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
void videoSetCorrectedAspect();
|
|
|
|
void videoSetViewableArea(int32_t x1, int32_t y1, int32_t x2, int32_t y2);
|
2018-04-12 21:03:47 +00:00
|
|
|
void renderSetAspect(int32_t daxrange, int32_t daaspect);
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void plotpixel(int32_t x, int32_t y, char col);
|
2020-06-14 19:57:21 +00:00
|
|
|
FCanvasTexture *renderSetTarget(int16_t tilenume);
|
2020-03-29 12:01:46 +00:00
|
|
|
void renderRestoreTarget();
|
2020-09-01 13:00:35 +00:00
|
|
|
void renderPrepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang, fixed_t dahoriz, int16_t dawall,
|
|
|
|
int32_t *tposx, int32_t *tposy, fixed_t *tang);
|
2018-04-12 21:03:47 +00:00
|
|
|
void renderCompleteMirror(void);
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2020-09-01 13:00:35 +00:00
|
|
|
int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, fixed_t daang, fixed_t dahoriz, int16_t dacursectnum);
|
2018-03-09 05:55:50 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
void renderDrawMasks(void);
|
2021-02-25 11:16:21 +00:00
|
|
|
void setVideoMode();
|
2020-04-28 20:55:37 +00:00
|
|
|
void videoInit();
|
2018-04-12 21:02:51 +00:00
|
|
|
void videoClearViewableArea(int32_t dacol);
|
|
|
|
void videoClearScreen(int32_t dacol);
|
2018-04-12 21:03:47 +00:00
|
|
|
void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang);
|
2009-01-09 09:29:17 +00:00
|
|
|
|
2020-05-19 22:35:52 +00:00
|
|
|
class F2DDrawer;
|
2020-08-23 12:59:34 +00:00
|
|
|
|
2012-02-04 21:35:00 +00:00
|
|
|
|
2018-10-16 06:09:20 +00:00
|
|
|
void getzrange(const vec3_t *pos, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz,
|
2012-08-16 21:48:08 +00:00
|
|
|
int32_t *florhit, int32_t walldist, uint32_t cliptype) ATTRIBUTE((nonnull(1,3,4,5,6)));
|
2020-05-13 22:04:14 +00:00
|
|
|
inline void getzrange(int x, int y, int z, int16_t sectnum, int32_t* ceilz, int32_t* ceilhit, int32_t* florz,
|
|
|
|
int32_t* florhit, int32_t walldist, uint32_t cliptype)
|
|
|
|
{
|
|
|
|
vec3_t v = { x, y, z };
|
|
|
|
getzrange(&v, sectnum, ceilz, ceilhit, florz, florhit, walldist, cliptype);
|
|
|
|
}
|
2019-12-18 09:31:21 +00:00
|
|
|
extern vec2_t hitscangoal;
|
2012-08-16 21:48:08 +00:00
|
|
|
int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32_t vz,
|
|
|
|
hitdata_t *hitinfo, uint32_t cliptype) ATTRIBUTE((nonnull(1,6)));
|
2020-05-13 22:04:14 +00:00
|
|
|
inline int hitscan(int x, int y, int z, int16_t sectnum, int32_t vx, int32_t vy, int32_t vz,
|
|
|
|
short* hitsect, short* hitwall, short* hitspr, int* hitx, int* hity, int* hitz, uint32_t cliptype)
|
|
|
|
{
|
|
|
|
vec3_t v{ x,y,z };
|
|
|
|
hitdata_t hd{};
|
|
|
|
int res = hitscan(&v, sectnum, vx, vy, vz, &hd, cliptype);
|
|
|
|
*hitsect = hd.sect;
|
|
|
|
*hitwall = hd.wall;
|
|
|
|
*hitspr = hd.sprite;
|
|
|
|
*hitx = hd.pos.x;
|
|
|
|
*hity = hd.pos.y;
|
|
|
|
*hitz = hd.pos.z ;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2012-02-20 19:54:24 +00:00
|
|
|
void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange,
|
|
|
|
int16_t *neartagsector, int16_t *neartagwall, int16_t *neartagsprite,
|
|
|
|
int32_t *neartaghitdist, int32_t neartagrange, uint8_t tagsearch,
|
2020-05-10 20:20:49 +00:00
|
|
|
int32_t (*blacklist_sprite_func)(int32_t) = nullptr) ATTRIBUTE((nonnull(6,7,8)));
|
2012-08-16 21:48:08 +00:00
|
|
|
int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1,
|
|
|
|
int32_t x2, int32_t y2, int32_t z2, int16_t sect2);
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t inside(int32_t x, int32_t y, int16_t sectnum);
|
2020-05-06 13:20:34 +00:00
|
|
|
void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day, uint8_t flags = 0);
|
2019-08-09 09:28:27 +00:00
|
|
|
int32_t try_facespr_intersect(uspriteptr_t const spr, vec3_t const in,
|
2019-03-19 17:08:59 +00:00
|
|
|
int32_t vx, int32_t vy, int32_t vz,
|
2019-08-09 09:28:27 +00:00
|
|
|
vec3_t * const intp, int32_t strictly_smaller_than_p);
|
2011-05-15 22:37:24 +00:00
|
|
|
|
2019-07-19 01:46:32 +00:00
|
|
|
#define MAXUPDATESECTORDIST 1536
|
|
|
|
#define INITIALUPDATESECTORDIST 256
|
|
|
|
void updatesector(int32_t const x, int32_t const y, int16_t * const sectnum) ATTRIBUTE((nonnull(3)));
|
|
|
|
void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int16_t * const sectnum) ATTRIBUTE((nonnull(4)));
|
2019-07-19 03:14:53 +00:00
|
|
|
void updatesectorneighbor(int32_t const x, int32_t const y, int16_t * const sectnum, int32_t initialMaxDistance = INITIALUPDATESECTORDIST, int32_t maxDistance = MAXUPDATESECTORDIST) ATTRIBUTE((nonnull(3)));
|
|
|
|
void updatesectorneighborz(int32_t const x, int32_t const y, int32_t const z, int16_t * const sectnum, int32_t initialMaxDistance = INITIALUPDATESECTORDIST, int32_t maxDistance = MAXUPDATESECTORDIST) ATTRIBUTE((nonnull(4)));
|
2019-07-19 01:46:32 +00:00
|
|
|
|
2019-04-19 08:31:42 +00:00
|
|
|
int findwallbetweensectors(int sect1, int sect2);
|
2019-12-07 23:49:56 +00:00
|
|
|
static FORCE_INLINE int sectoradjacent(int sect1, int sect2) { return findwallbetweensectors(sect1, sect2) != -1; }
|
2019-08-27 06:52:42 +00:00
|
|
|
int32_t getsectordist(vec2_t const in, int const sectnum, vec2_t * const out = nullptr);
|
2011-05-15 22:37:24 +00:00
|
|
|
extern const int16_t *chsecptr_onextwall;
|
2011-01-16 00:23:39 +00:00
|
|
|
int32_t checksectorpointer(int16_t i, int16_t sectnum);
|
2009-01-09 09:29:17 +00:00
|
|
|
|
2020-05-17 18:40:10 +00:00
|
|
|
#if !KRANDDEBUG
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE int32_t krand(void)
|
2014-11-22 12:28:52 +00:00
|
|
|
{
|
|
|
|
randomseed = (randomseed * 1664525ul) + 221297ul;
|
2020-09-06 06:37:04 +00:00
|
|
|
return ((uint32_t) randomseed)>>16;
|
2014-11-22 12:28:52 +00:00
|
|
|
}
|
|
|
|
#else
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t krand(void);
|
2014-11-22 12:28:52 +00:00
|
|
|
#endif
|
|
|
|
|
2021-03-14 22:38:39 +00:00
|
|
|
inline int32_t ksqrt(uint32_t num)
|
|
|
|
{
|
|
|
|
return int(sqrt((float)num));
|
|
|
|
}
|
|
|
|
|
2020-08-30 21:34:40 +00:00
|
|
|
int32_t getangle(int32_t xvect, int32_t yvect);
|
2020-09-01 13:00:35 +00:00
|
|
|
fixed_t gethiq16angle(int32_t xvect, int32_t yvect);
|
2020-04-17 13:21:22 +00:00
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
static FORCE_INLINE constexpr uint32_t uhypsq(int32_t const dx, int32_t const dy)
|
2012-07-01 22:11:14 +00:00
|
|
|
{
|
|
|
|
return (uint32_t)dx*dx + (uint32_t)dy*dy;
|
|
|
|
}
|
|
|
|
|
2019-04-18 17:24:10 +00:00
|
|
|
static FORCE_INLINE int32_t logapproach(int32_t const val, int32_t const targetval)
|
2014-03-23 14:29:09 +00:00
|
|
|
{
|
2019-04-18 17:24:10 +00:00
|
|
|
int32_t const dif = targetval - val;
|
2014-03-23 14:29:09 +00:00
|
|
|
return (dif>>1) ? val + (dif>>1) : targetval;
|
|
|
|
}
|
|
|
|
|
2019-04-18 17:24:10 +00:00
|
|
|
void rotatepoint(vec2_t const pivot, vec2_t p, int16_t const daang, vec2_t * const p2) ATTRIBUTE((nonnull(4)));
|
2020-05-06 13:20:34 +00:00
|
|
|
inline void rotatepoint(int px, int py, int ptx, int pty, int daang, int* resx, int* resy)
|
|
|
|
{
|
|
|
|
vec2_t pivot = { px, py };
|
|
|
|
vec2_t point = { ptx, pty };
|
|
|
|
vec2_t result;
|
|
|
|
rotatepoint(pivot, point, daang, &result);
|
|
|
|
*resx = result.x;
|
|
|
|
*resy = result.y;
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t lastwall(int16_t point);
|
2014-03-25 21:04:33 +00:00
|
|
|
int32_t nextsectorneighborz(int16_t sectnum, int32_t refz, int16_t topbottom, int16_t direction);
|
2012-12-28 17:17:58 +00:00
|
|
|
|
2019-04-18 17:25:24 +00:00
|
|
|
int32_t getceilzofslopeptr(usectorptr_t sec, int32_t dax, int32_t day) ATTRIBUTE((nonnull(1)));
|
|
|
|
int32_t getflorzofslopeptr(usectorptr_t sec, int32_t dax, int32_t day) ATTRIBUTE((nonnull(1)));
|
|
|
|
void getzsofslopeptr(usectorptr_t sec, int32_t dax, int32_t day,
|
2012-12-28 17:17:58 +00:00
|
|
|
int32_t *ceilz, int32_t *florz) ATTRIBUTE((nonnull(1,4,5)));
|
2019-09-17 03:20:38 +00:00
|
|
|
void yax_getzsofslope(int sectNum, int playerX, int playerY, int32_t* pCeilZ, int32_t* pFloorZ);
|
2012-12-28 17:17:58 +00:00
|
|
|
|
2020-05-13 23:55:58 +00:00
|
|
|
int32_t yax_getceilzofslope(int const sectnum, vec2_t const vect);
|
|
|
|
int32_t yax_getflorzofslope(int const sectnum, vec2_t const vect);
|
|
|
|
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE int32_t getceilzofslope(int16_t sectnum, int32_t dax, int32_t day)
|
2012-12-28 17:17:58 +00:00
|
|
|
{
|
2019-04-18 17:25:24 +00:00
|
|
|
return getceilzofslopeptr((usectorptr_t)§or[sectnum], dax, day);
|
2012-12-28 17:17:58 +00:00
|
|
|
}
|
|
|
|
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE int32_t getflorzofslope(int16_t sectnum, int32_t dax, int32_t day)
|
2012-12-28 17:17:58 +00:00
|
|
|
{
|
2019-04-18 17:25:24 +00:00
|
|
|
return getflorzofslopeptr((usectorptr_t)§or[sectnum], dax, day);
|
2012-12-28 17:17:58 +00:00
|
|
|
}
|
|
|
|
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE void getzsofslope(int16_t sectnum, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz)
|
2012-12-28 17:17:58 +00:00
|
|
|
{
|
2019-04-18 17:25:24 +00:00
|
|
|
getzsofslopeptr((usectorptr_t)§or[sectnum], dax, day, ceilz, florz);
|
2012-12-28 17:17:58 +00:00
|
|
|
}
|
|
|
|
|
2019-07-24 01:37:35 +00:00
|
|
|
static FORCE_INLINE void getcorrectzsofslope(int16_t sectnum, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz)
|
|
|
|
{
|
|
|
|
vec2_t closest = { dax, day };
|
|
|
|
getsectordist(closest, sectnum, &closest);
|
|
|
|
getzsofslopeptr((usectorptr_t)§or[sectnum], closest.x, closest.y, ceilz, florz);
|
|
|
|
}
|
|
|
|
|
|
|
|
static FORCE_INLINE int32_t getcorrectceilzofslope(int16_t sectnum, int32_t dax, int32_t day)
|
|
|
|
{
|
|
|
|
vec2_t closest = { dax, day };
|
|
|
|
getsectordist(closest, sectnum, &closest);
|
|
|
|
return getceilzofslopeptr((usectorptr_t)§or[sectnum], closest.x, closest.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
static FORCE_INLINE int32_t getcorrectflorzofslope(int16_t sectnum, int32_t dax, int32_t day)
|
|
|
|
{
|
|
|
|
vec2_t closest = { dax, day };
|
|
|
|
getsectordist(closest, sectnum, &closest);
|
|
|
|
return getflorzofslopeptr((usectorptr_t)§or[sectnum], closest.x, closest.y);
|
|
|
|
}
|
|
|
|
|
2013-04-16 20:08:45 +00:00
|
|
|
// Is <wal> a red wall in a safe fashion, i.e. only if consistency invariant
|
|
|
|
// ".nextsector >= 0 iff .nextwall >= 0" holds.
|
2020-09-04 19:24:48 +00:00
|
|
|
static FORCE_INLINE int32_t redwallp(uwallptr_t wal)
|
2013-01-01 15:24:42 +00:00
|
|
|
{
|
|
|
|
return (wal->nextwall >= 0 && wal->nextsector >= 0);
|
|
|
|
}
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
static FORCE_INLINE int32_t E_SpriteIsValid(const int32_t i)
|
2014-01-31 21:12:56 +00:00
|
|
|
{
|
|
|
|
return ((unsigned)i < MAXSPRITES && sprite[i].statnum != MAXSTATUS);
|
|
|
|
}
|
|
|
|
|
2014-08-17 19:42:01 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void alignceilslope(int16_t dasect, int32_t x, int32_t y, int32_t z);
|
|
|
|
void alignflorslope(int16_t dasect, int32_t x, int32_t y, int32_t z);
|
2011-04-14 20:48:08 +00:00
|
|
|
void setslope(int32_t sectnum, int32_t cf, int16_t slope);
|
2009-01-09 09:29:17 +00:00
|
|
|
|
2019-04-05 17:45:16 +00:00
|
|
|
int32_t lintersect(int32_t originX, int32_t originY, int32_t originZ,
|
|
|
|
int32_t destX, int32_t destY, int32_t destZ,
|
|
|
|
int32_t lineStartX, int32_t lineStartY, int32_t lineEndX, int32_t lineEndY,
|
|
|
|
int32_t *intersectionX, int32_t *intersectionY, int32_t *intersectionZ);
|
2010-09-27 21:52:04 +00:00
|
|
|
|
|
|
|
int32_t rayintersect(int32_t x1, int32_t y1, int32_t z1, int32_t vx, int32_t vy, int32_t vz, int32_t x3,
|
|
|
|
int32_t y3, int32_t x4, int32_t y4, int32_t *intx, int32_t *inty, int32_t *intz);
|
2013-12-31 11:51:54 +00:00
|
|
|
#if !defined NETCODE_DISABLE
|
2013-01-28 22:00:37 +00:00
|
|
|
void do_insertsprite_at_headofstat(int16_t spritenum, int16_t statnum);
|
|
|
|
int32_t insertspritestat(int16_t statnum);
|
2018-12-08 00:40:39 +00:00
|
|
|
void do_deletespritestat(int16_t deleteme);
|
2013-01-28 22:00:37 +00:00
|
|
|
void do_insertsprite_at_headofsect(int16_t spritenum, int16_t sectnum);
|
|
|
|
void do_deletespritesect(int16_t deleteme);
|
2013-12-31 11:51:54 +00:00
|
|
|
#endif
|
2012-03-13 20:05:51 +00:00
|
|
|
int32_t insertsprite(int16_t sectnum, int16_t statnum);
|
|
|
|
int32_t deletesprite(int16_t spritenum);
|
2009-02-28 07:44:54 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t changespritesect(int16_t spritenum, int16_t newsectnum);
|
|
|
|
int32_t changespritestat(int16_t spritenum, int16_t newstatnum);
|
2012-11-05 02:49:08 +00:00
|
|
|
int32_t setsprite(int16_t spritenum, const vec3_t *) ATTRIBUTE((nonnull(2)));
|
2020-05-06 07:15:15 +00:00
|
|
|
inline int32_t setsprite(int16_t spritenum, int x, int y, int z)
|
|
|
|
{
|
|
|
|
vec3_t v = { x,y,z };
|
|
|
|
return setsprite(spritenum, &v);
|
|
|
|
}
|
|
|
|
|
2020-05-14 10:52:59 +00:00
|
|
|
inline void setspritepos(int spnum, int x, int y, int z)
|
2020-05-14 07:07:07 +00:00
|
|
|
{
|
|
|
|
sprite[spnum].pos = { x,y,z };
|
|
|
|
}
|
2012-11-05 02:49:08 +00:00
|
|
|
int32_t setspritez(int16_t spritenum, const vec3_t *) ATTRIBUTE((nonnull(2)));
|
2009-01-09 09:29:17 +00:00
|
|
|
|
2019-04-18 17:25:24 +00:00
|
|
|
int32_t spriteheightofsptr(uspriteptr_t spr, int32_t *height, int32_t alsotileyofs);
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE int32_t spriteheightofs(int16_t i, int32_t *height, int32_t alsotileyofs)
|
2012-11-25 13:18:57 +00:00
|
|
|
{
|
2019-04-18 17:25:24 +00:00
|
|
|
return spriteheightofsptr((uspriteptr_t)&sprite[i], height, alsotileyofs);
|
2012-11-25 13:18:57 +00:00
|
|
|
}
|
2011-03-02 21:21:47 +00:00
|
|
|
|
2019-11-02 11:59:59 +00:00
|
|
|
int videoCaptureScreen();
|
2007-09-05 21:56:58 +00:00
|
|
|
|
|
|
|
// PLAG: line utility functions
|
2019-04-18 17:24:10 +00:00
|
|
|
typedef struct s_equation
|
|
|
|
{
|
|
|
|
float a, b, c;
|
|
|
|
} _equation;
|
|
|
|
|
2011-03-04 08:50:58 +00:00
|
|
|
#ifdef USE_OPENGL
|
2020-05-13 04:42:47 +00:00
|
|
|
void renderSetRollAngle(float rolla);
|
2008-07-24 11:16:20 +00:00
|
|
|
#endif
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2019-10-14 22:54:14 +00:00
|
|
|
void PrecacheHardwareTextures(int nTile);
|
2019-12-24 23:30:13 +00:00
|
|
|
void Polymost_Startup();
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2019-10-23 19:11:37 +00:00
|
|
|
EXTERN_CVAR(Bool, hw_animsmoothing)
|
|
|
|
EXTERN_CVAR(Bool, hw_hightile)
|
|
|
|
EXTERN_CVAR(Bool, hw_models)
|
|
|
|
EXTERN_CVAR(Float, hw_shadescale)
|
2020-05-28 21:48:50 +00:00
|
|
|
EXTERN_CVAR(Float, gl_texture_filter_anisotropic)
|
|
|
|
EXTERN_CVAR(Int, gl_texture_filter)
|
2020-02-04 19:40:10 +00:00
|
|
|
extern bool hw_int_useindexedcolortextures;
|
2019-10-23 19:11:37 +00:00
|
|
|
EXTERN_CVAR(Bool, hw_useindexedcolortextures)
|
|
|
|
EXTERN_CVAR(Bool, hw_parallaxskypanning)
|
|
|
|
EXTERN_CVAR(Bool, r_voxels)
|
2015-02-11 05:23:04 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t mdtims, omdtims;
|
2019-09-19 20:02:45 +00:00
|
|
|
|
|
|
|
extern int32_t r_rortexture;
|
|
|
|
extern int32_t r_rortexturerange;
|
|
|
|
extern int32_t r_rorphase;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
|
|
|
// flags bitset: 1 = don't compress
|
2018-10-16 06:09:20 +00:00
|
|
|
int32_t Ptile2tile(int32_t tile, int32_t palette) ATTRIBUTE((pure));
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t md_loadmodel(const char *fn);
|
2012-01-17 04:31:59 +00:00
|
|
|
int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, float yoffset, int32_t flags);
|
2009-02-28 07:44:54 +00:00
|
|
|
// int32_t md_tilehasmodel(int32_t tilenume, int32_t pal);
|
|
|
|
|
2019-12-22 10:20:22 +00:00
|
|
|
EXTERN int32_t nextvoxid;
|
2019-10-23 11:23:36 +00:00
|
|
|
EXTERN int8_t voxreserve[(MAXVOXELS+7)>>3];
|
|
|
|
EXTERN int8_t voxrotate[(MAXVOXELS+7)>>3];
|
|
|
|
|
2011-03-04 08:50:58 +00:00
|
|
|
#ifdef USE_OPENGL
|
2015-03-24 00:40:48 +00:00
|
|
|
// TODO: dynamically allocate this
|
|
|
|
|
|
|
|
typedef struct { vec3f_t add; int16_t angadd, flags, fov; } hudtyp;
|
|
|
|
|
2009-02-28 07:44:54 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
// maps build tiles to particular animation frames of a model
|
2015-03-24 00:40:48 +00:00
|
|
|
int16_t modelid;
|
|
|
|
int16_t framenum; // calculate the number from the name when declaring
|
|
|
|
int16_t nexttile;
|
|
|
|
uint16_t smoothduration;
|
|
|
|
hudtyp *hudmem[2];
|
|
|
|
int8_t skinnum;
|
|
|
|
char pal;
|
2009-02-28 07:44:54 +00:00
|
|
|
} tile2model_t;
|
|
|
|
|
2012-01-19 21:58:06 +00:00
|
|
|
# define EXTRATILES (MAXTILES/8)
|
2009-02-28 07:44:54 +00:00
|
|
|
|
|
|
|
EXTERN int32_t mdinited;
|
|
|
|
EXTERN tile2model_t tile2model[MAXTILES+EXTRATILES];
|
|
|
|
|
2019-04-18 17:24:10 +00:00
|
|
|
static FORCE_INLINE int32_t md_tilehasmodel(int32_t const tilenume, int32_t const pal)
|
2009-02-28 07:44:54 +00:00
|
|
|
{
|
2015-01-11 04:55:07 +00:00
|
|
|
return mdinited ? tile2model[Ptile2tile(tilenume,pal)].modelid : -1;
|
2009-02-28 07:44:54 +00:00
|
|
|
}
|
2012-01-10 23:44:35 +00:00
|
|
|
#endif // defined USE_OPENGL
|
2009-02-28 07:44:54 +00:00
|
|
|
|
2019-12-07 23:49:56 +00:00
|
|
|
static FORCE_INLINE int tilehasmodelorvoxel(int const tilenume, int pal)
|
2019-07-06 17:54:43 +00:00
|
|
|
{
|
2019-09-08 01:01:22 +00:00
|
|
|
UNREFERENCED_PARAMETER(pal);
|
2019-07-06 17:54:43 +00:00
|
|
|
return
|
2020-08-22 16:12:19 +00:00
|
|
|
(mdinited && hw_models && tile2model[Ptile2tile(tilenume, pal)].modelid != -1) ||
|
|
|
|
(r_voxels && tiletovox[tilenume] != -1);
|
2019-07-06 17:54:43 +00:00
|
|
|
}
|
|
|
|
|
2012-08-16 21:48:08 +00:00
|
|
|
int32_t md_defineframe(int32_t modelid, const char *framename, int32_t tilenume,
|
|
|
|
int32_t skinnum, float smoothduration, int32_t pal);
|
|
|
|
int32_t md_defineanimation(int32_t modelid, const char *framestart, const char *frameend,
|
|
|
|
int32_t fps, int32_t flags);
|
|
|
|
int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32_t skinnum,
|
2015-03-28 09:49:11 +00:00
|
|
|
int32_t surfnum, float param, float specpower, float specfactor, int32_t flags);
|
2015-03-24 00:40:48 +00:00
|
|
|
int32_t md_definehud (int32_t modelid, int32_t tilex, vec3f_t add,
|
2014-09-30 04:06:57 +00:00
|
|
|
int32_t angadd, int32_t flags, int32_t fov);
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t md_undefinetile(int32_t tile);
|
|
|
|
int32_t md_undefinemodel(int32_t modelid);
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2020-09-16 14:42:44 +00:00
|
|
|
int32_t loaddefinitionsfile(const char *fn, bool loadadds = false);
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2018-03-21 20:41:26 +00:00
|
|
|
#ifdef USE_OPENGL
|
|
|
|
# include "polymost.h"
|
2009-02-14 14:31:58 +00:00
|
|
|
#endif
|
|
|
|
|
2020-05-28 22:44:13 +00:00
|
|
|
extern int skiptile;
|
2017-06-05 10:04:56 +00:00
|
|
|
|
2015-05-26 00:47:54 +00:00
|
|
|
static vec2_t const zerovec = { 0, 0 };
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
static FORCE_INLINE int inside_p(int32_t const x, int32_t const y, int const sectnum) { return (sectnum >= 0 && inside(x, y, sectnum) == 1); }
|
2019-04-09 19:21:22 +00:00
|
|
|
|
|
|
|
#define SET_AND_RETURN(Lval, Rval) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
(Lval) = (Rval); \
|
|
|
|
return; \
|
|
|
|
} while (0)
|
|
|
|
|
2019-09-22 19:26:07 +00:00
|
|
|
static inline int64_t compat_maybe_truncate_to_int32(int64_t val)
|
2019-07-29 15:43:16 +00:00
|
|
|
{
|
2019-09-22 19:26:07 +00:00
|
|
|
return enginecompatibility_mode != ENGINECOMPATIBILITY_NONE ? (int32_t)val : val;
|
2019-07-29 15:43:16 +00:00
|
|
|
}
|
|
|
|
|
SW: setsprite, setspritez, getzrange, clipmove, pushmove, neartag, dragpoint, screencapture, md_tilehasmodel, preparemirror, saveboard, loadboard, pos
git-svn-id: https://svn.eduke32.com/eduke32@5201 1a8010ca-5511-0410-912e-c29ae57300e0
2015-05-19 22:00:38 +00:00
|
|
|
static inline int32_t clipmove_old(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t xvect, int32_t yvect, int32_t walldist,
|
|
|
|
int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2,3,4)));
|
|
|
|
|
|
|
|
static inline int32_t clipmove_old(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t xvect, int32_t yvect, int32_t walldist,
|
|
|
|
int32_t ceildist, int32_t flordist, uint32_t cliptype)
|
|
|
|
{
|
|
|
|
vec3_t vector = { *x, *y, *z };
|
|
|
|
|
|
|
|
int32_t result = clipmove(&vector, sectnum, xvect, yvect, walldist, ceildist, flordist, cliptype);
|
|
|
|
|
|
|
|
*x = vector.x;
|
|
|
|
*y = vector.y;
|
|
|
|
*z = vector.z;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int32_t pushmove_old(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t walldist,
|
|
|
|
int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2,3,4)));
|
|
|
|
|
|
|
|
static inline int32_t pushmove_old(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t walldist,
|
|
|
|
int32_t ceildist, int32_t flordist, uint32_t cliptype)
|
|
|
|
{
|
|
|
|
vec3_t vector = { *x, *y, *z };
|
|
|
|
|
|
|
|
int32_t result = pushmove(&vector, sectnum, walldist, ceildist, flordist, cliptype);
|
|
|
|
|
|
|
|
*x = vector.x;
|
|
|
|
*y = vector.y;
|
|
|
|
*z = vector.z;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void getzrange_old(int32_t x, int32_t y, int32_t z, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz,
|
|
|
|
int32_t *florhit, int32_t walldist, uint32_t cliptype) ATTRIBUTE((nonnull(5,6,7,8)));
|
|
|
|
|
|
|
|
static inline void getzrange_old(int32_t x, int32_t y, int32_t z, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz,
|
|
|
|
int32_t *florhit, int32_t walldist, uint32_t cliptype)
|
|
|
|
{
|
|
|
|
const vec3_t vector = { x, y, z };
|
|
|
|
getzrange(&vector, sectnum, ceilz, ceilhit, florz, florhit, walldist, cliptype);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int32_t setspritez_old(int16_t spritenum, int32_t x, int32_t y, int32_t z)
|
|
|
|
{
|
|
|
|
const vec3_t vector = { x, y, z };
|
|
|
|
return setspritez(spritenum, &vector);
|
|
|
|
}
|
|
|
|
|
2016-06-21 00:33:30 +00:00
|
|
|
extern int32_t rintersect(int32_t x1, int32_t y1, int32_t z1,
|
|
|
|
int32_t vx_, int32_t vy_, int32_t vz,
|
|
|
|
int32_t x3, int32_t y3, int32_t x4, int32_t y4,
|
|
|
|
int32_t *intx, int32_t *inty, int32_t *intz);
|
|
|
|
|
2020-05-20 17:29:25 +00:00
|
|
|
void markTileForPrecache(int tilenum, int palnum);
|
|
|
|
void precacheMarkedTiles();
|
|
|
|
|
2019-09-19 20:02:45 +00:00
|
|
|
extern int32_t(*animateoffs_replace)(int const tilenum, int fakevar);
|
|
|
|
extern void(*initspritelists_replace)(void);
|
|
|
|
extern int32_t(*insertsprite_replace)(int16_t sectnum, int16_t statnum);
|
|
|
|
extern int32_t(*deletesprite_replace)(int16_t spritenum);
|
|
|
|
extern int32_t(*changespritesect_replace)(int16_t spritenum, int16_t newsectnum);
|
|
|
|
extern int32_t(*changespritestat_replace)(int16_t spritenum, int16_t newstatnum);
|
|
|
|
#ifdef USE_OPENGL
|
|
|
|
extern void(*PolymostProcessVoxels_Callback)(void);
|
|
|
|
#endif
|
|
|
|
|
2020-10-18 07:45:41 +00:00
|
|
|
// Masking these into the object index to keep it in 16 bit was probably the single most dumbest and pointless thing Build ever did.
|
|
|
|
// Gonna be fun to globally replace these to finally lift the limit this imposes on map size.
|
|
|
|
// Names taken from DukeGDX
|
|
|
|
enum EHitBits
|
|
|
|
{
|
2020-10-24 07:31:15 +00:00
|
|
|
kHitNone = 0,
|
2020-10-18 07:45:41 +00:00
|
|
|
kHitTypeMask = 0xE000,
|
|
|
|
kHitIndexMask = 0x1FFF,
|
|
|
|
kHitSector = 0x4000,
|
|
|
|
kHitWall = 0x8000,
|
|
|
|
kHitSprite = 0xC000,
|
|
|
|
};
|
|
|
|
|
2020-12-01 23:19:22 +00:00
|
|
|
void updateModelInterpolation();
|
|
|
|
|
2021-03-15 22:46:03 +00:00
|
|
|
int32_t renderAddTsprite(int16_t z, int16_t sectnum);
|
|
|
|
|
|
|
|
inline void tileUpdatePicnum(int* const tileptr, int const obj, int stat)
|
|
|
|
{
|
|
|
|
auto& tile = *tileptr;
|
|
|
|
|
|
|
|
if (picanm[tile].sf & PICANM_ANIMTYPE_MASK)
|
|
|
|
tile += animateoffs(tile, obj);
|
|
|
|
|
|
|
|
if (((obj & 16384) == 16384) && (stat & CSTAT_WALL_ROTATE_90) && RotTile(tile).newtile != -1)
|
|
|
|
tile = RotTile(tile).newtile;
|
|
|
|
}
|
|
|
|
|
2021-03-20 11:47:51 +00:00
|
|
|
inline void setgotpic(int32_t tilenume)
|
|
|
|
{
|
|
|
|
gotpic[tilenume >> 3] |= pow2char[tilenume & 7];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-24 07:31:15 +00:00
|
|
|
|
2020-10-15 15:15:45 +00:00
|
|
|
#include "iterators.h"
|
2020-10-13 22:05:25 +00:00
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#endif // build_h_
|