2019-10-25 22:32:49 +00:00
# pragma once
2020-05-22 16:28:03 +00:00
# include <memory>
2019-10-27 07:14:58 +00:00
# include "c_cvars.h"
# include "zstring.h"
2019-10-27 23:24:09 +00:00
# include "inputstate.h"
2019-10-28 21:19:50 +00:00
# include "gamecvars.h"
2019-11-28 00:02:45 +00:00
# include "tarray.h"
# include "name.h"
2019-12-24 17:53:29 +00:00
# include "memarena.h"
2020-08-30 10:02:32 +00:00
# include "stats.h"
2020-08-30 22:16:43 +00:00
# include "i_time.h"
2020-09-05 11:57:26 +00:00
# include "palentry.h"
2021-05-03 22:03:01 +00:00
# include "build.h"
2019-10-27 07:14:58 +00:00
2021-05-26 22:32:57 +00:00
EXTERN_CVAR ( Bool , hud_textfont )
2021-05-11 22:21:26 +00:00
extern bool sendsave ;
extern FString savedescription ;
extern FString savegamefile ;
2019-10-27 07:14:58 +00:00
extern FString currentGame ;
2019-11-01 23:38:30 +00:00
extern FString LumpFilter ;
2021-04-04 08:33:29 +00:00
extern int PlayClock ;
2019-10-28 21:19:50 +00:00
class FArgs ;
2020-04-23 19:18:40 +00:00
extern bool GUICapture ;
2020-08-30 07:32:34 +00:00
extern bool AppActive ;
2020-08-30 10:02:32 +00:00
extern cycle_t drawtime , actortime , thinktime , gameupdatetime ;
2020-08-30 17:59:46 +00:00
extern bool r_NoInterpolate ;
2020-11-07 20:30:48 +00:00
extern bool crouch_toggle ;
2019-10-25 22:32:49 +00:00
2020-09-03 21:10:28 +00:00
struct MapRecord ;
extern MapRecord * g_nextmap ;
2020-10-08 20:20:41 +00:00
extern int g_nextskill ;
2021-08-13 20:25:13 +00:00
extern int g_bossexit ;
2020-09-03 21:10:28 +00:00
2019-12-24 17:53:29 +00:00
extern FMemArena dump ; // this is for memory blocks than cannot be deallocated without some huge effort. Put them in here so that they do not register on shutdown.
2019-10-27 07:14:58 +00:00
extern FStringCVar * const CombatMacros [ ] ;
void CONFIG_ReadCombatMacros ( ) ;
2019-10-27 12:40:24 +00:00
2019-12-22 19:55:47 +00:00
int GameMain ( ) ;
2020-09-04 22:58:25 +00:00
int GetAutomapZoom ( int gZoom ) ;
2020-09-06 08:42:39 +00:00
2020-09-21 21:29:52 +00:00
void DrawCrosshair ( int deftile , int health , double xdelta , double ydelta , double scale , PalEntry color = 0xffffffff ) ;
2020-08-30 17:59:46 +00:00
void updatePauseStatus ( ) ;
2021-07-20 08:41:39 +00:00
void DeferredStartGame ( MapRecord * map , int skill , bool nostopsound = false ) ;
2021-08-13 20:25:13 +00:00
void ChangeLevel ( MapRecord * map , int skill , bool bossexit = false ) ;
2020-09-03 21:10:28 +00:00
void CompleteLevel ( MapRecord * map ) ;
2019-10-28 21:19:50 +00:00
struct UserConfig
{
FString gamegrp ;
FString CommandMap ;
2021-04-07 19:46:44 +00:00
FString UserDef ;
2019-10-28 21:19:50 +00:00
FString DefaultDef ;
FString DefaultCon ;
FString CommandDemo ;
FString CommandName ;
FString CommandIni ;
std : : unique_ptr < FArgs > AddDefs ;
std : : unique_ptr < FArgs > AddCons ;
std : : unique_ptr < FArgs > AddFiles ;
std : : unique_ptr < FArgs > AddFilesPre ; //To be added before the main directory. Only for legacy options.
std : : unique_ptr < FArgs > AddArt ;
2020-01-10 20:36:46 +00:00
TArray < FString > toBeDeleted ;
2019-10-28 21:19:50 +00:00
bool nomonsters = false ;
bool nosound = false ;
2020-04-12 06:07:48 +00:00
//bool nomusic = false;
2019-10-28 21:19:50 +00:00
bool nologo = false ;
int setupstate = - 1 ;
void ProcessOptions ( ) ;
} ;
extern UserConfig userConfig ;
2019-10-30 17:09:00 +00:00
enum
{
GAMEFLAG_DUKE = 0x00000001 ,
GAMEFLAG_NAM = 0x00000002 ,
GAMEFLAG_NAPALM = 0x00000004 ,
GAMEFLAG_WW2GI = 0x00000008 ,
GAMEFLAG_ADDON = 0x00000010 ,
GAMEFLAG_SHAREWARE = 0x00000020 ,
GAMEFLAG_DUKEBETA = 0x00000060 , // includes 0x20 since it's a shareware beta
2020-07-19 19:04:22 +00:00
GAMEFLAG_PLUTOPAK = 0x00000080 ,
2019-10-30 17:09:00 +00:00
GAMEFLAG_RR = 0x00000100 ,
2019-11-02 17:28:50 +00:00
GAMEFLAG_RRRA = 0x00000200 ,
2020-07-19 19:04:22 +00:00
GAMEFLAG_RRALL = GAMEFLAG_RR | GAMEFLAG_RRRA ,
2020-02-26 19:16:27 +00:00
GAMEFLAG_BLOOD = 0x00000800 ,
GAMEFLAG_SW = 0x00001000 ,
GAMEFLAG_POWERSLAVE = 0x00002000 ,
GAMEFLAG_EXHUMED = 0x00004000 ,
GAMEFLAG_PSEXHUMED = GAMEFLAG_POWERSLAVE | GAMEFLAG_EXHUMED , // the two games really are the same, except for the name and the publisher.
2021-04-25 23:24:57 +00:00
GAMEFLAG_WORLDTOUR = 0x00008000 ,
GAMEFLAG_DUKEDC = 0x00010000 ,
GAMEFLAG_DUKENW = 0x00020000 ,
GAMEFLAG_DUKEVACA = 0x00040000 ,
GAMEFLAG_BLOODCP = 0x00080000 ,
GAMEFLAG_ROUTE66 = 0x00100000 ,
GAMEFLAG_SWWANTON = 0x00200000 ,
GAMEFLAG_SWTWINDRAG = 0x00400000 ,
2021-02-06 09:56:11 +00:00
GAMEFLAG_DUKECOMPAT = GAMEFLAG_DUKE | GAMEFLAG_NAM | GAMEFLAG_NAPALM | GAMEFLAG_WW2GI | GAMEFLAG_RRALL ,
2020-05-07 07:49:05 +00:00
GAMEFLAGMASK = 0x0000FFFF , // flags allowed from grpinfo
2019-10-30 17:09:00 +00:00
2020-07-19 19:04:22 +00:00
// We still need these for the parsers.
GAMEFLAG_FURY = 0 ,
GAMEFLAG_DEER = 0 ,
2019-10-30 23:41:56 +00:00
} ;
struct GrpInfo
{
FString name ;
FString scriptname ;
FString defname ;
FString rtsname ;
FString gamefilter ;
2021-04-13 15:05:53 +00:00
FString gameid ;
2019-10-30 23:41:56 +00:00
uint32_t CRC = 0 ;
uint32_t dependencyCRC = 0 ;
size_t size = 0 ;
int flags = 0 ;
2019-11-01 18:25:42 +00:00
bool loaddirectory = false ;
2020-02-01 20:12:09 +00:00
bool isAddon = false ;
2021-03-12 22:45:03 +00:00
int index = - 1 ;
2019-11-01 18:25:42 +00:00
TArray < FString > mustcontain ;
2019-12-26 09:47:10 +00:00
TArray < FString > tobedeleted ;
2019-10-30 23:41:56 +00:00
TArray < FString > loadfiles ;
TArray < FString > loadart ;
2021-07-19 02:24:47 +00:00
TArray < FString > exclepisodes ;
2021-04-10 17:14:30 +00:00
uint32_t FgColor = 0 , BgColor = 0 ;
2019-10-30 23:41:56 +00:00
} ;
struct GrpEntry
{
FString FileName ;
GrpInfo FileInfo ;
} ;
2019-11-01 18:25:42 +00:00
extern int g_gameType ;
const char * G_DefaultDefFile ( void ) ;
const char * G_DefFile ( void ) ;
2020-09-16 14:42:44 +00:00
void LoadDefinitions ( ) ;
2019-10-30 23:41:56 +00:00
2020-05-06 14:10:44 +00:00
// game check shortcuts
inline bool isNam ( )
{
return g_gameType & ( GAMEFLAG_NAM | GAMEFLAG_NAPALM ) ;
}
2020-05-08 22:34:48 +00:00
inline bool isNamWW2GI ( )
{
return g_gameType & ( GAMEFLAG_NAM | GAMEFLAG_NAPALM | GAMEFLAG_WW2GI ) ;
}
2020-05-06 14:10:44 +00:00
inline bool isWW2GI ( )
{
return g_gameType & ( GAMEFLAG_WW2GI ) ;
}
2021-04-24 18:00:54 +00:00
inline bool isDuke ( )
{
return g_gameType & ( GAMEFLAG_DUKE ) ;
}
2020-05-06 14:10:44 +00:00
inline bool isRR ( )
{
return g_gameType & ( GAMEFLAG_RRALL ) ;
}
inline bool isRRRA ( )
{
return g_gameType & ( GAMEFLAG_RRRA ) ;
}
2020-05-07 07:49:05 +00:00
inline bool isWorldTour ( )
{
return g_gameType & GAMEFLAG_WORLDTOUR ;
}
2020-07-19 19:04:22 +00:00
inline bool isPlutoPak ( )
{
return g_gameType & GAMEFLAG_PLUTOPAK ;
}
2020-10-11 09:39:51 +00:00
inline bool isShareware ( )
{
return g_gameType & GAMEFLAG_SHAREWARE ;
}
2021-01-02 03:46:58 +00:00
inline bool isBlood ( )
{
return g_gameType & GAMEFLAG_BLOOD ;
}
2021-07-11 02:08:12 +00:00
inline bool isSWALL ( )
{
return g_gameType & ( GAMEFLAG_SW | GAMEFLAG_SWWANTON | GAMEFLAG_SWTWINDRAG ) ;
}
2019-10-30 23:41:56 +00:00
TArray < GrpEntry > GrpScan ( ) ;
2020-05-28 23:22:45 +00:00
void S_PauseSound ( bool notmusic , bool notsfx ) ;
void S_ResumeSound ( bool notsfx ) ;
2019-12-22 19:55:47 +00:00
void S_SetSoundPaused ( int state ) ;
2019-12-24 18:59:14 +00:00
2020-07-31 00:35:24 +00:00
enum
{
MaxSmoothRatio = FRACUNIT
} ;
2020-01-11 16:05:25 +00:00
2020-02-05 11:57:17 +00:00
FString G_GetDemoPath ( ) ;
2020-04-12 06:09:38 +00:00
enum
{
PAUSESFX_MENU = 1 ,
PAUSESFX_CONSOLE = 2
} ;
2020-05-28 23:22:45 +00:00
extern int paused ;
2020-07-21 20:59:24 +00:00
extern int chatmodeon ;
2020-08-24 17:31:43 +00:00
2020-08-24 18:34:18 +00:00
extern bool sendPause ;
2020-08-25 23:41:23 +00:00
extern int lastTic ;
2020-11-30 20:31:47 +00:00
2021-02-18 10:46:36 +00:00
extern int PlayClock ;
2020-11-30 20:31:47 +00:00
2021-05-22 11:02:34 +00:00
enum gameaction_t : int
{
ga_nothing ,
ga_level , // Switch to play mode without any initialization
ga_intro ,
ga_intermission ,
ga_startup , // go back to intro after uninitializing the game state
ga_mainmenu , // go back to main menu after uninitializing the game state
ga_mainmenunostopsound , // Same but doesn't stop playing sounds.
ga_creditsmenu , // go to the credits menu after uninitializing the game state
ga_newgame , // start a new game
ga_recordgame , // start a new demo recording (later)
ga_loadgame , // load a savegame and resume play.
ga_loadgameplaydemo , // load a savegame and play a demo.
ga_autoloadgame , // load last autosave and resume play.
ga_savegame , // save the game
ga_autosave , // autosave the game (for triggering a save from within the game.)
ga_completed , // Level was exited.
ga_nextlevel , // Actually start the next level.
ga_loadgamehidecon ,
ga_newgamenostopsound , // start a new game
ga_endscreenjob ,
ga_fullconsole ,
} ;
extern gameaction_t gameaction ;