raze/source/games/duke/src/global.h

407 lines
11 KiB
C
Raw Normal View History

//-------------------------------------------------------------------------
/*
Copyright (C) 2010 EDuke32 developers and contributors
This file is part of EDuke32.
EDuke32 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#ifndef global_h_
#define global_h_
#include "build.h"
#include "compat.h"
2020-06-21 20:18:12 +00:00
#include "duke3d.h"
#include "mmulti.h"
#include "quotes.h"
#include "sector.h"
#include "sounds.h"
BEGIN_DUKE_NS
#define MAXMINECARTS 16
#define MAXJAILDOORS 32
#define MAXLIGHTNINSECTORS 64
#define MAXTORCHSECTORS 64
#define MAXGEOSECTORS 64
#ifdef global_c_
#define G_EXTERN
#else
#define G_EXTERN extern
#endif
#define MAXINTERPOLATIONS MAXSPRITES
2020-06-21 20:18:12 +00:00
// KEEPINSYNC lunatic/con_lang.lua
// duke3d global soup :(
G_EXTERN int32_t duke3d_globalflags;
// KEEPINSYNC astub.c (used values only)
enum DUKE3D_GLOBALFLAGS {
DUKE3D_NO_WIDESCREEN_PINNING = 1<<0,
DUKE3D_NO_HARDCODED_FOGPALS = 1<<1,
DUKE3D_NO_PALETTE_CHANGES = 1<<2,
};
G_EXTERN actor_t actor[MAXSPRITES];
// actorinfo: tile-specific data THAT DOES NOT CHANGE during the course of a game
G_EXTERN ActorInfo actorinfo[MAXTILES];
G_EXTERN animwalltype animwall[MAXANIMWALLS];
extern char *label;
G_EXTERN char g_loadFromGroupOnly;
G_EXTERN char g_skillCnt;
G_EXTERN char pus,pub;
G_EXTERN char ready2send;
#define MAXPLAYERNAME 32
G_EXTERN char tempbuf[MAXSECTORS<<1],buf[1024];
G_EXTERN uint8_t packbuf[PACKBUF_SIZE];
G_EXTERN input_t localInput;
G_EXTERN input_t recsync[RECSYNCBUFSIZ];
//G_EXTERN uint8_t syncstat, syncval[MAXPLAYERS][MOVEFIFOSIZ];
//G_EXTERN int32_t syncvalhead[MAXPLAYERS], syncvaltail, syncvaltottail;
G_EXTERN int32_t avgfvel, avgsvel, avgbits;
G_EXTERN fix16_t avgavel, avghorz;
G_EXTERN int8_t avgextbits;
G_EXTERN int32_t movefifosendplc;
G_EXTERN int32_t movefifoplc;
G_EXTERN int32_t predictfifoplc;
G_EXTERN vec3_t mypos, omypos, myvel;
2020-05-21 20:40:46 +00:00
#define myx mypos.x
#define myy mypos.y
#define myz mypos.z
#define omyx omypos.x
#define omyy omypos.y
#define omyz omypos.z
G_EXTERN fix16_t myhoriz, omyhoriz, myhorizoff, omyhorizoff, myang, omyang;
G_EXTERN int16_t mycursectnum, myjumpingcounter;
G_EXTERN uint8_t myjumpingtoggle, myonground, myhardlanding, myreturntocenter;
G_EXTERN int16_t my_MotoSpeed;
2020-05-17 21:44:53 +00:00
G_EXTERN uint8_t my_NotOnWater, my_MotoOnGround;
G_EXTERN uint8_t my_moto_do_bump, my_moto_bump_fast, my_moto_on_oil, my_moto_on_mud;
G_EXTERN int16_t my_moto_bump, my_moto_bump_target, my_moto_turb;
G_EXTERN int32_t my_stairs;
G_EXTERN vec3_t myposbak[MOVEFIFOSIZ];
G_EXTERN fix16_t myhorizbak[MOVEFIFOSIZ], myangbak[MOVEFIFOSIZ];
G_EXTERN int32_t myminlag[MAXPLAYERS], mymaxlag, otherminlag, bufferjitter;
G_EXTERN int32_t g_networkBroadcastMode, g_movesPerPacket;
G_EXTERN int32_t g_animWallCnt;
#define numanimwalls g_animWallCnt
G_EXTERN int32_t g_animateCnt;
#define animatecnt g_animateCnt
2020-05-21 09:41:48 +00:00
G_EXTERN int32_t numclouds;
G_EXTERN int32_t g_curViewscreen;
#define camsprite g_curViewscreen
G_EXTERN int32_t g_frameRate;
G_EXTERN int32_t g_cyclerCnt;
2020-05-06 19:11:36 +00:00
#define numcyclers g_cyclerCnt
G_EXTERN int32_t g_damageCameras;
2020-05-08 22:34:48 +00:00
#define camerashitable g_damageCameras
G_EXTERN int32_t g_defaultLabelCnt;
G_EXTERN int32_t g_doQuickSave;
G_EXTERN int32_t g_earthquakeTime;
#define earthquaketime g_earthquakeTime
G_EXTERN int32_t g_freezerSelfDamage;
2020-05-10 18:59:38 +00:00
#define freezerhurtowner g_freezerSelfDamage
G_EXTERN int32_t g_gameQuit;
G_EXTERN int32_t g_globalRandom;
#define global_random g_globalRandom
G_EXTERN int32_t impact_damage;
extern int32_t labelcnt;
G_EXTERN int32_t g_maxPlayerHealth;
2020-05-21 09:41:48 +00:00
G_EXTERN int32_t mirrorcnt;
G_EXTERN int32_t playerswhenstarted;
G_EXTERN int32_t g_musicSize;
G_EXTERN int32_t numplayersprites;
G_EXTERN int32_t g_scriptDebug;
G_EXTERN int32_t g_showShareware;
G_EXTERN int32_t g_spriteDeleteQueuePos;
G_EXTERN int32_t max_player_health;
G_EXTERN int32_t max_armour_amount;
G_EXTERN int32_t lasermode;
G_EXTERN int32_t screenpeek;
G_EXTERN int16_t g_animateSect[MAXANIMATES];
#define animatesect g_animateSect
G_EXTERN int32_t *g_animatePtr[MAXANIMATES];
#define animateptr g_animatePtr
G_EXTERN int32_t g_animateGoal[MAXANIMATES];
#define animategoal g_animateGoal
G_EXTERN int32_t g_animateVel[MAXANIMATES];
#define animatevel g_animateVel
2020-05-21 09:41:48 +00:00
G_EXTERN int16_t clouds[256];
G_EXTERN int16_t g_cloudX;
G_EXTERN int16_t g_cloudY;
G_EXTERN ClockTicks g_cloudClock;
G_EXTERN int16_t SpriteDeletionQueue[1024];
G_EXTERN int16_t g_cyclers[MAXCYCLERS][6];
2020-05-06 19:11:36 +00:00
#define cyclers g_cyclers
2020-05-21 09:41:48 +00:00
G_EXTERN int16_t mirrorsector[64];
G_EXTERN int16_t mirrorwall[64];
G_EXTERN int32_t *labelcode;
#if 0
G_EXTERN int32_t *labeltype;
#endif
G_EXTERN ClockTicks lockclock;
G_EXTERN ClockTicks ototalclock;
G_EXTERN int32_t wupass;
2020-05-21 09:41:48 +00:00
G_EXTERN int32_t chickenplant;
G_EXTERN int32_t thunderon;
G_EXTERN int32_t g_ufoSpawn;
2020-05-10 07:08:02 +00:00
#define ufospawn g_ufoSpawn
G_EXTERN int32_t g_ufoCnt;
2020-05-10 07:08:02 +00:00
#define ufocnt g_ufoCnt
G_EXTERN int32_t g_hulkSpawn;
2020-05-10 07:08:02 +00:00
#define hulkspawn g_hulkSpawn
G_EXTERN int32_t g_lastLevel;
2020-05-10 07:08:02 +00:00
#define lastlevel g_lastLevel
2020-05-21 09:41:48 +00:00
G_EXTERN int32_t geosectorwarp[MAXGEOSECTORS];
G_EXTERN int32_t geosectorwarp2[MAXGEOSECTORS];
G_EXTERN int32_t geosector[MAXGEOSECTORS];
G_EXTERN int32_t geox[MAXGEOSECTORS];
G_EXTERN int32_t geoy[MAXGEOSECTORS];
G_EXTERN int32_t geox2[MAXGEOSECTORS];
G_EXTERN int32_t geoy2[MAXGEOSECTORS];
G_EXTERN uint32_t geocnt;
G_EXTERN int32_t g_thunderFlash;
G_EXTERN int32_t g_thunderTime;
G_EXTERN int32_t g_winderFlash;
G_EXTERN int32_t g_winderTime;
G_EXTERN int32_t g_brightness;
2020-05-14 07:07:07 +00:00
G_EXTERN int16_t ambientlotag[64];
G_EXTERN int16_t ambienthitag[64];
2020-05-21 09:41:48 +00:00
G_EXTERN uint32_t ambientfx;
inline int32_t G_HaveActor(int spriteNum)
{
return actorinfo[spriteNum].scriptaddress != NULL;
}
inline int32_t G_DefaultActorHealth(int spriteNum) // rename!
{
return G_HaveActor(spriteNum) ? ScriptCode[actorinfo[spriteNum].scriptaddress] : 0;
}
G_EXTERN vec2_t g_origins[MAXANIMPOINTS];
2020-05-06 13:20:34 +00:00
struct msx_
{
2020-05-15 20:59:13 +00:00
int &operator[](int v) { return g_origins[v].x; }
2020-05-06 13:20:34 +00:00
};
struct msy_
{
2020-05-15 20:59:13 +00:00
int &operator[](int v) { return g_origins[v].y; }
2020-05-06 13:20:34 +00:00
};
G_EXTERN msx_ msx;
G_EXTERN msy_ msy;
2020-05-14 17:23:36 +00:00
G_EXTERN int32_t WindTime, WindDir;
2020-05-21 09:41:48 +00:00
G_EXTERN int16_t fakebubba_spawn, mamaspawn_count, banjosound, g_bellTime, BellSprite;
#define BellTime g_bellTime
2020-05-21 09:41:48 +00:00
#define word_119BE0 BellSprite
2020-05-10 18:59:38 +00:00
G_EXTERN uint8_t g_spriteExtra[MAXSPRITES], g_sectorExtra[MAXSECTORS]; // move these back into the base structs!
G_EXTERN uint8_t enemysizecheat, ufospawnsminion, pistonsound, chickenphase, RRRA_ExitedLevel, RRRA_EndEpisode, fogactive;
G_EXTERN int32_t g_cdTrack;
2020-05-08 22:34:48 +00:00
#define raat607 enemysizecheat // only as a reminder
#define raat605 chickenphase
#define at59d yeehaa_timer
// XXX: I think this pragma pack is meaningless here.
// MSDN (https://msdn.microsoft.com/en-us/library/2e70t5y1%28VS.80%29.aspx) says:
// "pack takes effect at the first struct, union, or class declaration after
// the pragma is seen; pack has no effect on definitions."
#pragma pack(push,1)
#ifdef global_c_
static playerdata_t g_player_s[1 + MAXPLAYERS];
playerdata_t *const g_player = &g_player_s[1];
#else
extern playerdata_t *const g_player;
#endif
G_EXTERN playerspawn_t g_playerSpawnPoints[MAXPLAYERS];
2020-05-10 07:08:02 +00:00
#define po g_playerSpawnPoints
G_EXTERN input_t inputfifo[MOVEFIFOSIZ][MAXPLAYERS];
#pragma pack(pop)
G_EXTERN int32_t g_noEnemies;
G_EXTERN int32_t restorepalette;
G_EXTERN uint32_t everyothertime;
G_EXTERN uint32_t g_moveThingsCount;
G_EXTERN double g_gameUpdateTime;
G_EXTERN double g_gameUpdateAndDrawTime;
#define GAMEUPDATEAVGTIMENUMSAMPLES 100
extern float g_gameUpdateAvgTime;
#ifndef global_c_
extern char CheatKeys[2];
extern char g_gametypeNames[MAXGAMETYPES][33];
extern int32_t respawnactortime;
extern int32_t g_bouncemineRadius;
2020-05-08 22:34:48 +00:00
#define bouncemineblastradius g_bouncemineRadius
extern int32_t g_deleteQueueSize;
extern int32_t g_gametypeCnt;
extern int32_t respawnitemtime;
extern int32_t g_morterRadius;
2020-05-08 22:34:48 +00:00
#define morterblastradius g_morterRadius
extern int32_t numfreezebounces;
extern int32_t g_pipebombRadius;
#define pipebombblastradius g_pipebombRadius
extern int32_t dukefriction;
extern int32_t rpgblastradius;
extern int32_t g_scriptSize;
extern int32_t g_seenineRadius;
#define seenineblastradius g_seenineRadius
extern int32_t g_shrinkerRadius;
2020-05-07 12:38:01 +00:00
#define shrinkerblastradius g_shrinkerRadius
extern int32_t g_spriteGravity;
extern int32_t g_timerTicsPerSecond;
extern int32_t g_tripbombRadius;
#define tripbombblastradius g_tripbombRadius
2020-05-08 22:34:48 +00:00
#define powderkegblastradius g_tripbombRadius
extern int32_t g_volumeCnt;
#define gc g_spriteGravity
extern int16_t weaponsandammosprites[15];
extern int32_t g_gametypeFlags[MAXGAMETYPES];
extern const char *s_buildDate;
2020-05-10 07:08:02 +00:00
#endif
inline void clearfriction()
{
for (int playerNum = 0; playerNum != -1; playerNum = connectpoint2[playerNum])
{
vec2_t& fric = g_player[playerNum].ps->fric;
fric.x = fric.y = 0;
}
}
enum
{
EF_HIDEFROMSP = 1<<0,
};
// Interpolation code is the same in all games with slightly different naming - this needs to be unified and cleaned up.
2020-05-20 21:39:54 +00:00
extern int32_t numinterpolations;
extern int32_t* curipos[MAXINTERPOLATIONS];
extern int32_t bakipos[MAXINTERPOLATIONS];
2020-06-30 09:55:01 +00:00
// old names as porting help.
2020-06-30 09:55:01 +00:00
void updateinterpolations();
void restoreinterpolations();
void setinterpolation(int* posptr);
void stopinterpolation(int* posptr);
void dointerpolations(int smoothratio);
// Hack struct to allow old code to access the EDuke-style player data without changing it.
struct psaccess
{
DukePlayer_t& operator[](int index)
{
return *g_player[index].ps;
}
};
extern psaccess ps;
2020-05-06 07:56:13 +00:00
#define spriteqamount g_deleteQueueSize
#define spriteq SpriteDeletionQueue
#define spriteqloc g_spriteDeleteQueuePos
2020-05-06 13:20:34 +00:00
inline bool isIn(int value, int first)
{
return value == first;
}
template<typename... Args>
bool isIn(int value, int first, Args... args)
{
return value == first || isIn(value, args...);
}
inline bool isIn(int value, const std::initializer_list<int> &list)
{
for (auto v : list) if (v == value) return true;
return false;
}
2020-05-06 13:20:34 +00:00
// these are mainly here to avoid directly accessing the input data so that it can be more easily refactored later.
2020-05-07 22:03:51 +00:00
inline bool PlayerInput(int pl, int bit)
{
return TEST_SYNC_KEY(g_player[pl].input->bits, bit);
}
2020-05-17 11:25:39 +00:00
inline void PlayerSetInput(int pl, int bit)
{
g_player[pl].input->bits |= (1 << bit);
}
2020-05-17 21:44:53 +00:00
inline void PlayerClearInput(int pl, int bit)
{
g_player[pl].input->bits &= ~(1 << bit);
}
2020-05-17 11:25:39 +00:00
inline int PlayerInputBits(int pl, int bits)
{
return (g_player[pl].input->bits & bits);
}
inline bool PlayerInputSideVel(int pl)
{
return g_player[pl].input->svel;
}
inline bool PlayerInputForwardVel(int pl)
{
return g_player[pl].input->fvel;
}
2020-05-08 22:34:48 +00:00
enum
{
kHitTypeMask = 0xC000,
//kHitIndexMask = 0x3FFF,
kHitSector = 0x4000,
kHitWall = 0x8000,
kHitSprite = 0xC000,
};
2020-05-07 22:03:51 +00:00
END_DUKE_NS
#endif