2019-10-26 00:32:49 +02:00
# pragma once
2020-05-22 18:28:03 +02:00
# include <memory>
2019-10-27 08:14:58 +01:00
# include "c_cvars.h"
# include "zstring.h"
2019-10-28 00:24:09 +01:00
# include "inputstate.h"
2019-10-28 22:19:50 +01:00
# include "gamecvars.h"
2019-11-28 01:02:45 +01:00
# include "tarray.h"
# include "name.h"
2019-12-24 18:53:29 +01:00
# include "memarena.h"
2020-08-30 12:02:32 +02:00
# include "stats.h"
2020-08-31 00:16:43 +02:00
# include "i_time.h"
2020-09-05 13:57:26 +02:00
# include "palentry.h"
2019-10-27 08:14:58 +01:00
extern FString currentGame ;
2019-11-02 00:38:30 +01:00
extern FString LumpFilter ;
2021-04-04 10:33:29 +02:00
extern int PlayClock ;
2019-10-28 22:19:50 +01:00
class FArgs ;
2020-04-23 21:18:40 +02:00
extern bool GUICapture ;
2020-08-30 09:32:34 +02:00
extern bool AppActive ;
2020-08-30 12:02:32 +02:00
extern cycle_t drawtime , actortime , thinktime , gameupdatetime ;
2020-08-30 19:59:46 +02:00
extern bool r_NoInterpolate ;
2020-11-08 07:30:48 +11:00
extern bool crouch_toggle ;
2019-10-26 00:32:49 +02:00
2020-09-03 23:10:28 +02:00
struct MapRecord ;
extern MapRecord * g_nextmap ;
2020-10-08 22:20:41 +02:00
extern int g_nextskill ;
2020-09-03 23:10:28 +02:00
2019-12-24 18:53:29 +01: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-11-01 00:32:56 +01:00
int CONFIG_Init ( ) ;
2019-10-26 21:50:49 +02:00
// I am not sure if anything below will survive for long...
# define MAXMOUSEAXES 2
# define MAXMOUSEDIGITAL (MAXMOUSEAXES*2)
2019-10-26 23:45:55 +02:00
// default mouse scale
# define DEFAULTMOUSEANALOGUESCALE 65536
// default joystick settings
# define DEFAULTJOYSTICKANALOGUESCALE 65536
# define DEFAULTJOYSTICKANALOGUEDEAD 1000
# define DEFAULTJOYSTICKANALOGUESATURATE 9500
2019-10-26 21:50:49 +02:00
2019-10-26 23:45:55 +02:00
void CONFIG_SetupJoystick ( void ) ;
void CONFIG_SetGameControllerDefaultsClear ( ) ;
2019-10-28 07:05:32 +01:00
2019-10-27 08:14:58 +01:00
extern FStringCVar * const CombatMacros [ ] ;
void CONFIG_ReadCombatMacros ( ) ;
2019-10-27 13:40:24 +01:00
2019-12-22 20:55:47 +01:00
int GameMain ( ) ;
2020-09-05 00:58:25 +02:00
int GetAutomapZoom ( int gZoom ) ;
2020-09-06 10:42:39 +02:00
2020-09-22 07:29:52 +10:00
void DrawCrosshair ( int deftile , int health , double xdelta , double ydelta , double scale , PalEntry color = 0xffffffff ) ;
2020-08-30 19:59:46 +02:00
void updatePauseStatus ( ) ;
2020-10-10 13:30:23 +02:00
void DeferedStartGame ( MapRecord * map , int skill , bool nostopsound = false ) ;
2020-09-03 23:10:28 +02:00
void ChangeLevel ( MapRecord * map , int skill ) ;
void CompleteLevel ( MapRecord * map ) ;
2019-10-28 22:19:50 +01:00
struct UserConfig
{
FString gamegrp ;
FString CommandMap ;
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 21:36:46 +01:00
TArray < FString > toBeDeleted ;
2019-10-28 22:19:50 +01:00
bool nomonsters = false ;
bool nosound = false ;
2020-04-12 08:07:48 +02:00
//bool nomusic = false;
2019-10-28 22:19:50 +01:00
bool nologo = false ;
int setupstate = - 1 ;
void ProcessOptions ( ) ;
} ;
extern UserConfig userConfig ;
2020-04-12 08:07:48 +02:00
extern int nomusic ;
2020-04-12 08:09:38 +02:00
extern bool nosound ;
2019-10-28 22:19:50 +01:00
inline bool MusicEnabled ( )
{
2020-08-11 19:52:54 +02:00
return mus_enabled & & ! nomusic ;
2019-10-28 22:19:50 +01:00
}
inline bool SoundEnabled ( )
{
2020-04-12 08:09:38 +02:00
return snd_enabled & & ! nosound ;
2019-10-28 22:19:50 +01:00
}
2019-10-30 18:09:00 +01: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 21:04:22 +02:00
GAMEFLAG_PLUTOPAK = 0x00000080 ,
2019-10-30 18:09:00 +01:00
GAMEFLAG_RR = 0x00000100 ,
2019-11-02 18:28:50 +01:00
GAMEFLAG_RRRA = 0x00000200 ,
2020-07-19 21:04:22 +02:00
GAMEFLAG_RRALL = GAMEFLAG_RR | GAMEFLAG_RRRA ,
2020-02-26 20:16:27 +01: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.
2020-05-07 09:49:05 +02:00
GAMEFLAG_WORLDTOUR = 0x00008000 ,
2020-08-05 22:57:45 +02:00
GAMEFLAG_DUKEDC = 0x00010000 ,
2021-02-06 10:56:11 +01:00
GAMEFLAG_DUKECOMPAT = GAMEFLAG_DUKE | GAMEFLAG_NAM | GAMEFLAG_NAPALM | GAMEFLAG_WW2GI | GAMEFLAG_RRALL ,
2020-05-07 09:49:05 +02:00
GAMEFLAGMASK = 0x0000FFFF , // flags allowed from grpinfo
2019-10-30 18:09:00 +01:00
2020-07-19 21:04:22 +02:00
// We still need these for the parsers.
GAMEFLAG_FURY = 0 ,
GAMEFLAG_DEER = 0 ,
2019-10-31 00:41:56 +01:00
} ;
struct GrpInfo
{
FString name ;
FString scriptname ;
FString defname ;
FString rtsname ;
FString gamefilter ;
uint32_t CRC = 0 ;
uint32_t dependencyCRC = 0 ;
size_t size = 0 ;
int flags = 0 ;
2019-11-01 19:25:42 +01:00
bool loaddirectory = false ;
2020-02-01 21:12:09 +01:00
bool isAddon = false ;
2021-03-12 23:45:03 +01:00
int index = - 1 ;
2019-11-01 19:25:42 +01:00
TArray < FString > mustcontain ;
2019-12-26 10:47:10 +01:00
TArray < FString > tobedeleted ;
2019-10-31 00:41:56 +01:00
TArray < FString > loadfiles ;
TArray < FString > loadart ;
} ;
struct GrpEntry
{
FString FileName ;
GrpInfo FileInfo ;
} ;
2019-11-01 19:25:42 +01:00
extern int g_gameType ;
const char * G_DefaultDefFile ( void ) ;
const char * G_DefFile ( void ) ;
2020-09-16 16:42:44 +02:00
void LoadDefinitions ( ) ;
2019-10-31 00:41:56 +01:00
2020-05-06 16:10:44 +02:00
// game check shortcuts
inline bool isNam ( )
{
return g_gameType & ( GAMEFLAG_NAM | GAMEFLAG_NAPALM ) ;
}
2020-05-09 00:34:48 +02:00
inline bool isNamWW2GI ( )
{
return g_gameType & ( GAMEFLAG_NAM | GAMEFLAG_NAPALM | GAMEFLAG_WW2GI ) ;
}
2020-05-06 16:10:44 +02:00
inline bool isWW2GI ( )
{
return g_gameType & ( GAMEFLAG_WW2GI ) ;
}
inline bool isRR ( )
{
return g_gameType & ( GAMEFLAG_RRALL ) ;
}
inline bool isRRRA ( )
{
return g_gameType & ( GAMEFLAG_RRRA ) ;
}
2020-05-07 09:49:05 +02:00
inline bool isWorldTour ( )
{
return g_gameType & GAMEFLAG_WORLDTOUR ;
}
2020-07-19 21:04:22 +02:00
inline bool isPlutoPak ( )
{
return g_gameType & GAMEFLAG_PLUTOPAK ;
}
2020-10-11 11:39:51 +02:00
inline bool isShareware ( )
{
return g_gameType & GAMEFLAG_SHAREWARE ;
}
2021-01-02 14:46:58 +11:00
inline bool isBlood ( )
{
return g_gameType & GAMEFLAG_BLOOD ;
}
2019-10-31 00:41:56 +01:00
TArray < GrpEntry > GrpScan ( ) ;
2020-05-29 09:22:45 +10:00
void S_PauseSound ( bool notmusic , bool notsfx ) ;
void S_ResumeSound ( bool notsfx ) ;
2019-12-22 20:55:47 +01:00
void S_SetSoundPaused ( int state ) ;
2019-12-24 19:59:14 +01:00
2020-07-31 10:35:24 +10:00
enum
{
MaxSmoothRatio = FRACUNIT
} ;
2020-01-11 17:05:25 +01:00
2020-02-05 13:57:17 +02:00
FString G_GetDemoPath ( ) ;
2020-04-12 08:09:38 +02:00
enum
{
PAUSESFX_MENU = 1 ,
PAUSESFX_CONSOLE = 2
} ;
2020-05-29 09:22:45 +10:00
extern int paused ;
2020-07-21 22:59:24 +02:00
extern int chatmodeon ;
2020-08-24 19:31:43 +02:00
2020-08-24 20:34:18 +02:00
extern bool sendPause ;
2020-08-26 09:41:23 +10:00
extern int lastTic ;
2020-12-01 07:31:47 +11:00
2021-02-18 21:46:36 +11:00
extern int PlayClock ;
2020-12-01 07:31:47 +11:00