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
|
|
|
|
{
|
|
|
|
MAXVOXMIPS = 5,
|
2012-05-06 20:23:20 +00:00
|
|
|
|
2021-12-06 19:54:21 +00:00
|
|
|
MAXWALLSB = 6144,
|
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-12-06 19:54:21 +00:00
|
|
|
MAXSPRITESONSCREEN = 4096,
|
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
|
|
|
|
2021-12-17 19:24:48 +00:00
|
|
|
#include "maptypes.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
|
|
|
|
2021-12-17 19:24:48 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SPREXT_NOTMD = 1,
|
|
|
|
SPREXT_NOMDANIM = 2,
|
|
|
|
SPREXT_AWAY1 = 4,
|
|
|
|
SPREXT_AWAY2 = 8,
|
|
|
|
SPREXT_TSPRACCESS = 16,
|
|
|
|
SPREXT_TEMPINVISIBLE = 32,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct spriteext_t
|
|
|
|
{
|
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;
|
2021-12-17 19:24:48 +00:00
|
|
|
};
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2021-12-17 19:24:48 +00:00
|
|
|
struct spritesmooth_t
|
|
|
|
{
|
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;
|
2021-12-17 19:24:48 +00:00
|
|
|
};
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2021-12-17 19:24:48 +00:00
|
|
|
struct SpawnSpriteDef
|
|
|
|
{
|
|
|
|
TArray<spritetype> sprites;
|
|
|
|
TArray<spriteext_t> sprext;
|
|
|
|
};
|
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-03-26 14:06:14 +00:00
|
|
|
EXTERN int leveltimer;
|
2020-10-11 18:57:20 +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;
|
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
|
|
|
|
|
|
|
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 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
|
|
|
|
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
|
|
|
|
2009-07-24 02:31:34 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
int32_t engineInit(void);
|
|
|
|
void engineUnInit(void);
|
2015-09-23 17:54:50 +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
|
|
|
|
2021-12-04 14:37:08 +00:00
|
|
|
void getzrange(const vec3_t& pos, sectortype* sect, int32_t* ceilz, CollisionBase& ceilhit, int32_t* florz,
|
|
|
|
CollisionBase& florhit, int32_t walldist, uint32_t cliptype);
|
2021-11-23 23:21:08 +00:00
|
|
|
|
2019-12-18 09:31:21 +00:00
|
|
|
extern vec2_t hitscangoal;
|
2021-11-25 21:33:55 +00:00
|
|
|
|
2021-12-03 23:38:11 +00:00
|
|
|
struct HitInfoBase;
|
2021-12-03 23:47:08 +00:00
|
|
|
int hitscan(const vec3_t& start, const sectortype* startsect, const vec3_t& direction, HitInfoBase& hitinfo, unsigned cliptype);
|
2021-12-03 23:38:11 +00:00
|
|
|
void neartag(const vec3_t& pos, sectortype* sect, int angle, HitInfoBase& result, int neartagrange, int tagsearch);
|
|
|
|
|
2021-12-05 21:01:02 +00:00
|
|
|
int cansee(int x1, int y1, int z1, sectortype* sect1, int x2, int y2, int z2, sectortype* sect2);
|
2021-12-06 17:17:45 +00:00
|
|
|
int32_t inside(int32_t x, int32_t y, const sectortype* sectnum);
|
2021-12-30 10:28:09 +00:00
|
|
|
int32_t try_facespr_intersect(DCoreActor* 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-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)
|
|
|
|
{
|
2021-12-22 09:28:51 +00:00
|
|
|
return getangle(vec.X, vec.Y);
|
2021-11-24 15:34:21 +00:00
|
|
|
}
|
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)));
|
2021-11-23 20:25:31 +00:00
|
|
|
|
2021-12-11 12:58:37 +00:00
|
|
|
sectortype* nextsectorneighborzptr(sectortype* sectp, int refz, int topbottom, int direction);
|
|
|
|
inline sectortype* safenextsectorneighborzptr(sectortype* sectp, int refz, int topbottom, int direction)
|
2021-11-07 10:40:55 +00:00
|
|
|
{
|
2021-12-11 12:58:37 +00:00
|
|
|
auto sect = nextsectorneighborzptr(sectp, refz, topbottom, direction);
|
|
|
|
return sect == nullptr ? sectp : 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)));
|
|
|
|
|
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);
|
2021-12-22 09:28:51 +00:00
|
|
|
getzsofslopeptr((usectorptr_t)§or[sectnum], closest.X, closest.Y, ceilz, florz);
|
2019-07-24 01:37:35 +00:00
|
|
|
}
|
|
|
|
|
2021-12-17 22:33:16 +00:00
|
|
|
void alignceilslope(sectortype* dasect, int32_t x, int32_t y, int32_t z);
|
|
|
|
void alignflorslope(sectortype* dasect, int32_t x, int32_t y, int32_t z);
|
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
|
|
|
|
2019-04-18 17:25:24 +00:00
|
|
|
int32_t spriteheightofsptr(uspriteptr_t spr, int32_t *height, int32_t alsotileyofs);
|
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-12-06 17:17:45 +00:00
|
|
|
inline int inside_p(int32_t const x, int32_t const y, int const sectnum) { return (sectnum >= 0 && inside(x, y, §or[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.
|
2021-12-06 17:17:45 +00:00
|
|
|
inline int inside_p0(int32_t const x, int32_t const y, int32_t const z, int const sectnum) { return inside_p(x, y, sectnum); }
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#endif // build_h_
|