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!");
|
|
|
|
|
2021-05-03 17:16:26 +00:00
|
|
|
#include "printf.h"
|
2016-06-21 00:33:06 +00:00
|
|
|
#include "palette.h"
|
2021-03-22 22:40:25 +00:00
|
|
|
#include "binaryangle.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
|
|
|
|
|
2021-10-30 06:21:27 +00:00
|
|
|
EXTERN int 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-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
|
|
|
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,
|
2021-07-25 05:38:51 +00:00
|
|
|
MAXSPRITESONSCREEN = MAXSPRITES >> 2,
|
2020-10-15 15:02:35 +00:00
|
|
|
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
|
|
|
|
2021-07-04 11:05:33 +00:00
|
|
|
CLIPMASK0 = (1 << 16) + 1,
|
|
|
|
CLIPMASK1 = (256 << 16) + 64
|
2020-10-15 15:02:35 +00:00
|
|
|
};
|
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
|
|
|
|
2018-03-17 03:25:57 +00:00
|
|
|
#include "buildtypes.h"
|
2015-01-19 00:11:25 +00:00
|
|
|
|
2021-03-24 19:28:58 +00:00
|
|
|
using uspriteptr_t = spritetype const *;
|
|
|
|
using uwallptr_t = walltype const *;
|
|
|
|
using usectorptr_t = sectortype const *;
|
2019-04-18 17:25:14 +00:00
|
|
|
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
|
|
|
|
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,
|
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;
|
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
|
|
|
|
2021-05-21 10:53:31 +00:00
|
|
|
extern spriteext_t spriteext[MAXSPRITES];
|
2021-05-22 20:10:58 +00:00
|
|
|
extern spritesmooth_t spritesmooth[MAXSPRITES + MAXUNIQHUDID];
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2021-11-20 22:20:43 +00:00
|
|
|
extern TArray<sectortype> sector;
|
2021-11-20 22:42:01 +00:00
|
|
|
extern TArray<walltype> wall;
|
2021-05-21 10:53:31 +00:00
|
|
|
extern spritetype sprite[MAXSPRITES];
|
2021-03-26 14:06:14 +00:00
|
|
|
EXTERN int leveltimer;
|
2020-10-11 18:57:20 +00:00
|
|
|
|
2021-11-20 22:20:43 +00:00
|
|
|
extern TArray<sectortype> sectorbackup;
|
2021-11-20 22:42:01 +00:00
|
|
|
extern TArray<walltype> wallbackup;
|
2012-11-09 22:31:02 +00:00
|
|
|
|
2021-04-02 08:28:40 +00:00
|
|
|
inline tspriteptr_t renderAddTSpriteFromSprite(spritetype* tsprite, int& spritesortcnt, uint16_t const spritenum)
|
2021-03-25 22:16:32 +00:00
|
|
|
{
|
|
|
|
auto tspr = &tsprite[spritesortcnt++];
|
|
|
|
auto const spr = &sprite[spritenum];
|
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;
|
|
|
|
}
|
|
|
|
|
2021-03-25 22:16:32 +00:00
|
|
|
// returns: 0=continue sprite collecting;
|
|
|
|
// 1=break out of sprite collecting;
|
2021-04-02 08:28:40 +00:00
|
|
|
inline int32_t renderAddTsprite(spritetype* tsprite, int& spritesortcnt, int16_t z, int16_t sectnum)
|
2019-12-26 06:27:58 +00:00
|
|
|
{
|
2021-03-25 22:16:32 +00:00
|
|
|
if (spritesortcnt >= MAXSPRITESONSCREEN) return 1;
|
2021-04-02 08:28:40 +00:00
|
|
|
renderAddTSpriteFromSprite(tsprite, spritesortcnt, z);
|
2021-03-25 22:16:32 +00:00
|
|
|
return 0;
|
2019-12-26 06:27:58 +00:00
|
|
|
}
|
|
|
|
|
2014-10-25 03:36:34 +00:00
|
|
|
|
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;
|
2021-11-20 22:20:43 +00:00
|
|
|
EXTERN int numsectors, numwalls;
|
2019-05-19 03:55:19 +00:00
|
|
|
EXTERN int32_t display_mirror;
|
2014-07-28 06:43:16 +00:00
|
|
|
|
2021-11-07 17:09:19 +00:00
|
|
|
inline bool validSectorIndex(int sectnum)
|
|
|
|
{
|
|
|
|
return sectnum >= 0 && sectnum < numsectors;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool validWallIndex(int wallnum)
|
|
|
|
{
|
|
|
|
return wallnum >= 0 && wallnum < numwalls;
|
|
|
|
}
|
|
|
|
|
2021-11-20 23:59:35 +00:00
|
|
|
|
2020-08-23 16:08:08 +00:00
|
|
|
EXTERN int32_t randomseed;
|
2015-09-23 17:54:50 +00:00
|
|
|
|
|
|
|
EXTERN uint8_t paletteloaded;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PALETTE_MAIN = 1<<0,
|
|
|
|
PALETTE_SHADE = 1<<1,
|
|
|
|
PALETTE_TRANSLUC = 1<<2,
|
|
|
|
};
|
|
|
|
|
2021-04-05 11:55:36 +00:00
|
|
|
EXTERN int32_t g_visibility;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
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):
|
2021-04-12 22:28:51 +00:00
|
|
|
int horizfrac;
|
2013-08-04 20:37:45 +00:00
|
|
|
|
|
|
|
// The texel index offset in the y direction of a parallaxed sky:
|
|
|
|
// XXX: currently always 0.
|
2021-04-12 22:28:51 +00:00
|
|
|
int yoffs;
|
2021-05-08 20:08:05 +00:00
|
|
|
int yoffs2;
|
2013-08-04 20:37:45 +00:00
|
|
|
|
2021-04-12 22:28:51 +00:00
|
|
|
int 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);
|
2021-05-08 20:08:05 +00:00
|
|
|
psky_t* defineSky(int32_t const tilenum, int horiz, int lognumtiles, const uint16_t* tileofs, int yoff = 0, int yoff2 = 0x7fffffff);
|
2015-05-27 08:47:34 +00:00
|
|
|
|
2021-03-21 21:48:01 +00:00
|
|
|
// Get properties of parallaxed sky to draw.
|
|
|
|
// Returns: pointer to tile offset array. Sets-by-pointer the other three.
|
2021-05-08 20:08:05 +00:00
|
|
|
const int16_t* getpsky(int32_t picnum, int32_t* dapyscale, int32_t* dapskybits, int32_t* dapyoffs, int32_t* daptileyscale, bool alt = false);
|
2021-03-21 21:48:01 +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];
|
2021-04-01 18:47:05 +00:00
|
|
|
extern FixedBitArray<MAXSECTORS> gotsector;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
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
|
|
|
|
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
|
|
|
};
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
OTHER VARIABLES:
|
|
|
|
|
|
|
|
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 engineInit(void);
|
|
|
|
void engineUnInit(void);
|
2007-09-05 21:56:58 +00:00
|
|
|
void initspritelists(void);
|
2015-09-23 17:54:50 +00:00
|
|
|
|
2021-11-15 23:30:01 +00:00
|
|
|
void allocateMapArrays(int numsprites);
|
2021-11-09 22:50:02 +00:00
|
|
|
void ValidateSprite(spritetype& spr);
|
2021-11-07 19:14:44 +00:00
|
|
|
void engineLoadBoard(const char *filename, int flags, vec3_t *dapos, int16_t *daang, int *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
|
|
|
|
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
|
|
|
|
2020-06-14 19:57:21 +00:00
|
|
|
FCanvasTexture *renderSetTarget(int16_t tilenume);
|
2020-03-29 12:01:46 +00:00
|
|
|
void renderRestoreTarget();
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2021-02-25 11:16:21 +00:00
|
|
|
void setVideoMode();
|
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)));
|
2021-11-23 23:21:08 +00:00
|
|
|
|
|
|
|
inline void getzrange(const vec3_t* pos, sectortype* sect, int32_t* ceilz, int32_t* ceilhit, int32_t* florz,
|
|
|
|
int32_t* florhit, int32_t walldist, uint32_t cliptype)
|
|
|
|
{
|
|
|
|
getzrange(pos, sector.IndexOf(sect), ceilz, ceilhit, florz, florhit, walldist, cliptype);
|
|
|
|
}
|
|
|
|
|
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);
|
2021-11-17 22:53:11 +00:00
|
|
|
if (hitsect) *hitsect = hd.sect;
|
|
|
|
if (hitwall) *hitwall = hd.wall;
|
|
|
|
if (hitspr) *hitspr = hd.sprite;
|
2020-05-13 22:04:14 +00:00
|
|
|
*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);
|
2021-05-11 23:29:18 +00:00
|
|
|
int32_t inside(int32_t x, int32_t y, int sectnum);
|
2021-11-18 00:15:18 +00:00
|
|
|
void dragpoint(int pointhighlight, int32_t dax, int32_t day);
|
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
|
2021-11-29 23:08:24 +00:00
|
|
|
#define INITIALUPDATESECTORDIST 512 // was 256 which is too low - Exhumed LEV1 has problems with it
|
2021-11-06 14:53:16 +00:00
|
|
|
void updatesector(int const x, int const y, int * const sectnum) ATTRIBUTE((nonnull(3)));
|
2021-11-17 23:43:14 +00:00
|
|
|
inline void updatesector(int const x, int const y, sectortype** const sectp)
|
|
|
|
{
|
2021-11-20 22:20:43 +00:00
|
|
|
int sectno = *sectp? sector.IndexOf(*sectp) : -1;
|
2021-11-17 23:43:14 +00:00
|
|
|
updatesector(x, y, §no);
|
2021-11-30 15:44:52 +00:00
|
|
|
*sectp = sectno == -1? nullptr : §or[sectno];
|
2021-11-17 23:43:14 +00:00
|
|
|
}
|
2021-11-06 18:27:51 +00:00
|
|
|
void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int * const sectnum) ATTRIBUTE((nonnull(4)));
|
|
|
|
|
2021-11-22 23:28:07 +00:00
|
|
|
inline void updatesectorz(int32_t const x, int32_t const y, int32_t const z, sectortype** const sectp)
|
|
|
|
{
|
|
|
|
int sectno = *sectp ? sector.IndexOf(*sectp) : -1;
|
|
|
|
updatesectorz(x, y, z, §no);
|
|
|
|
*sectp = sectno == -1 ? nullptr : §or[sectno];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-11-29 23:08:24 +00:00
|
|
|
void updatesectorneighbor(int32_t const x, int32_t const y, int * const sectnum, int32_t maxDistance = MAXUPDATESECTORDIST) ATTRIBUTE((nonnull(3)));
|
2021-11-22 23:28:07 +00:00
|
|
|
|
2019-07-19 01:46:32 +00:00
|
|
|
|
2019-04-19 08:31:42 +00:00
|
|
|
int findwallbetweensectors(int sect1, int sect2);
|
2021-11-18 18:57:14 +00:00
|
|
|
|
2021-03-24 20:43:36 +00:00
|
|
|
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;
|
2009-01-09 09:29:17 +00:00
|
|
|
|
2021-03-24 20:43:36 +00:00
|
|
|
inline int32_t krand(void)
|
2014-11-22 12:28:52 +00:00
|
|
|
{
|
2021-10-26 16:48:54 +00:00
|
|
|
randomseed = (randomseed * 27584621) + 1;
|
2020-09-06 06:37:04 +00:00
|
|
|
return ((uint32_t) randomseed)>>16;
|
2014-11-22 12:28:52 +00:00
|
|
|
}
|
|
|
|
|
2021-05-11 23:29:18 +00:00
|
|
|
inline int32_t ksqrt(uint64_t num)
|
2021-03-14 22:38:39 +00:00
|
|
|
{
|
2021-05-11 23:29:18 +00:00
|
|
|
return int(sqrt(double(num)));
|
2021-03-14 22:38:39 +00:00
|
|
|
}
|
|
|
|
|
2020-08-30 21:34:40 +00:00
|
|
|
int32_t getangle(int32_t xvect, int32_t yvect);
|
2021-11-24 15:34:21 +00:00
|
|
|
inline int32_t getangle(const vec2_t& vec)
|
|
|
|
{
|
|
|
|
return getangle(vec.x, vec.y);
|
|
|
|
}
|
2020-04-17 13:21:22 +00:00
|
|
|
|
2021-03-24 20:43:36 +00:00
|
|
|
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
|
|
|
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);
|
2021-11-23 20:25:31 +00:00
|
|
|
inline walltype* lastwall(walltype* point)
|
|
|
|
{
|
|
|
|
return &wall[lastwall(wall.IndexOf(point))];
|
|
|
|
}
|
|
|
|
|
2014-03-25 21:04:33 +00:00
|
|
|
int32_t nextsectorneighborz(int16_t sectnum, int32_t refz, int16_t topbottom, int16_t direction);
|
2021-11-07 10:40:55 +00:00
|
|
|
inline sectortype* nextsectorneighborzptr(int16_t sectnum, int32_t refz, int16_t topbottom, int16_t direction)
|
|
|
|
{
|
|
|
|
auto sect = nextsectorneighborz(sectnum, refz, topbottom, direction);
|
2021-11-09 16:29:03 +00:00
|
|
|
return sect == -1? nullptr : §or[sect];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline sectortype* nextsectorneighborzptr(sectortype* sectp, int32_t refz, int16_t topbottom, int16_t direction)
|
|
|
|
{
|
2021-11-20 22:20:43 +00:00
|
|
|
auto sect = nextsectorneighborz(sector.IndexOf(sectp), refz, topbottom, direction);
|
2021-11-09 16:29:03 +00:00
|
|
|
return sect == -1? nullptr : §or[sect];
|
2021-11-07 10:40:55 +00:00
|
|
|
}
|
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);
|
|
|
|
|
2021-05-11 23:29:18 +00:00
|
|
|
inline int32_t getceilzofslope(int 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
|
|
|
}
|
|
|
|
|
2021-05-11 23:29:18 +00:00
|
|
|
inline int32_t getflorzofslope(int 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
|
|
|
}
|
|
|
|
|
2021-05-11 23:29:18 +00:00
|
|
|
inline void getzsofslope(int 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
|
|
|
}
|
|
|
|
|
2021-05-11 23:29:18 +00:00
|
|
|
inline void getcorrectzsofslope(int sectnum, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz)
|
2019-07-24 01:37:35 +00:00
|
|
|
{
|
|
|
|
vec2_t closest = { dax, day };
|
|
|
|
getsectordist(closest, sectnum, &closest);
|
|
|
|
getzsofslopeptr((usectorptr_t)§or[sectnum], closest.x, closest.y, ceilz, florz);
|
|
|
|
}
|
|
|
|
|
2021-05-11 23:29:18 +00:00
|
|
|
inline int32_t getcorrectceilzofslope(int sectnum, int32_t dax, int32_t day)
|
2019-07-24 01:37:35 +00:00
|
|
|
{
|
|
|
|
vec2_t closest = { dax, day };
|
|
|
|
getsectordist(closest, sectnum, &closest);
|
|
|
|
return getceilzofslopeptr((usectorptr_t)§or[sectnum], closest.x, closest.y);
|
|
|
|
}
|
|
|
|
|
2021-05-11 23:29:18 +00:00
|
|
|
inline int32_t getcorrectflorzofslope(int sectnum, int32_t dax, int32_t day)
|
2019-07-24 01:37:35 +00:00
|
|
|
{
|
|
|
|
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.
|
2021-03-24 20:43:36 +00:00
|
|
|
inline int32_t redwallp(uwallptr_t wal)
|
2013-01-01 15:24:42 +00:00
|
|
|
{
|
|
|
|
return (wal->nextwall >= 0 && wal->nextsector >= 0);
|
|
|
|
}
|
|
|
|
|
2021-03-24 20:43:36 +00:00
|
|
|
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);
|
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);
|
|
|
|
}
|
|
|
|
|
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);
|
2021-03-24 20:43:36 +00:00
|
|
|
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
|
|
|
|
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;
|
2021-04-11 16:37:11 +00:00
|
|
|
EXTERN FixedBitArray<MAXVOXELS>voxreserve;
|
2019-10-23 11:23:36 +00:00
|
|
|
|
2011-03-04 08:50:58 +00:00
|
|
|
#ifdef USE_OPENGL
|
2015-03-24 00:40:48 +00:00
|
|
|
// TODO: dynamically allocate this
|
|
|
|
|
2021-12-14 08:58:01 +00:00
|
|
|
typedef struct { FVector3 add; int16_t angadd, flags, fov; } hudtyp;
|
2015-03-24 00:40:48 +00:00
|
|
|
|
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;
|
2021-03-24 20:13:36 +00:00
|
|
|
hudtyp hudmem[2];
|
2015-03-24 00:40:48 +00:00
|
|
|
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];
|
|
|
|
|
2021-03-24 20:43:36 +00:00
|
|
|
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
|
|
|
|
2021-04-05 11:55:36 +00:00
|
|
|
int tilehasmodelorvoxel(int const tilenume, int pal);
|
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);
|
2021-12-14 08:58:01 +00:00
|
|
|
int32_t md_definehud (int32_t modelid, int32_t tilex, FVector3 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
|
|
|
|
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 };
|
|
|
|
|
2021-03-24 20:43:36 +00:00
|
|
|
inline int inside_p(int32_t const x, int32_t const y, int const sectnum) { return (sectnum >= 0 && inside(x, y, sectnum) == 1); }
|
2021-11-29 23:14:45 +00:00
|
|
|
// same as above but with the same signature as inside_z_p for passing to updatesectorneighborz.
|
|
|
|
inline int inside_p0(int32_t const x, int32_t const y, int32_t const z, 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 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);
|
|
|
|
|
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(*changespritesect_replace)(int16_t spritenum, int16_t newsectnum);
|
|
|
|
|
2020-10-18 07:45:41 +00:00
|
|
|
|
2020-12-01 23:19:22 +00:00
|
|
|
void updateModelInterpolation();
|
|
|
|
|
2021-03-15 22:46:03 +00:00
|
|
|
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)
|
|
|
|
{
|
2021-03-24 19:37:20 +00:00
|
|
|
gotpic[tilenume >> 3] |= 1 << (tilenume & 7);
|
2021-03-20 11:47:51 +00:00
|
|
|
}
|
|
|
|
|
2021-05-09 07:05:42 +00:00
|
|
|
inline void cleargotpic(int32_t tilenume)
|
|
|
|
{
|
|
|
|
gotpic[tilenume >> 3] &= ~(1 << (tilenume & 7));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool testgotpic(int32_t tilenume, bool reset = false)
|
|
|
|
{
|
|
|
|
bool res = gotpic[tilenume >> 3] & (1 << (tilenume & 7));
|
|
|
|
if (reset) gotpic[tilenume >> 3] &= ~(1 << (tilenume & 7));
|
|
|
|
return res;
|
|
|
|
}
|
2021-03-20 11:47:51 +00:00
|
|
|
|
2021-11-21 07:42:36 +00:00
|
|
|
inline sectortype* spritetype::sector() const
|
|
|
|
{
|
|
|
|
return !validSectorIndex(sectnum)? nullptr : &::sector[sectnum];
|
|
|
|
}
|
2020-10-24 07:31:15 +00:00
|
|
|
|
2021-11-21 08:15:21 +00:00
|
|
|
inline void spritetype::setsector(sectortype* sect)
|
|
|
|
{
|
|
|
|
// place for asserts.
|
|
|
|
sectnum = sect? ::sector.IndexOf(sect) : -1;
|
|
|
|
}
|
|
|
|
|
2021-12-07 08:56:50 +00:00
|
|
|
inline bool spritetype::insector() const
|
|
|
|
{
|
2021-11-21 07:42:36 +00:00
|
|
|
return validSectorIndex(sectnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline sectortype* walltype::nextSector() const
|
|
|
|
{
|
|
|
|
return !validSectorIndex(nextsector)? nullptr : &::sector[nextsector];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline walltype* walltype::nextWall() const
|
|
|
|
{
|
|
|
|
return !validWallIndex(nextwall)? nullptr : &::wall[nextwall];
|
2021-12-07 08:56:50 +00:00
|
|
|
}
|
|
|
|
|
2021-11-21 07:42:36 +00:00
|
|
|
inline sectortype* walltype::sectorp() const
|
|
|
|
{
|
|
|
|
return &::sector[sector]; // cannot be -1 in a proper map.
|
|
|
|
}
|
|
|
|
|
|
|
|
inline walltype* walltype::point2Wall() const
|
|
|
|
{
|
|
|
|
return &::wall[point2]; // cannot be -1 in a proper map.
|
|
|
|
}
|
|
|
|
|
|
|
|
inline walltype* sectortype::firstWall() const
|
|
|
|
{
|
|
|
|
return &wall[wallptr]; // cannot be -1 in a proper map
|
|
|
|
}
|
|
|
|
|
2021-11-24 15:39:29 +00:00
|
|
|
inline walltype* sectortype::lastWall() const
|
|
|
|
{
|
|
|
|
return &wall[wallptr + wallnum - 1]; // cannot be -1 in a proper map
|
|
|
|
}
|
|
|
|
|
2021-11-21 07:45:07 +00:00
|
|
|
inline int cansee(int x1, int y1, int z1, sectortype* sect1, int x2, int y2, int z2, sectortype* sect2)
|
|
|
|
{
|
|
|
|
return cansee(x1, y1, z1, sector.IndexOf(sect1), x2, y2, z2, sector.IndexOf(sect2));
|
|
|
|
}
|
|
|
|
|
2021-11-21 07:42:36 +00:00
|
|
|
|
2021-12-07 08:56:50 +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_
|