- moved the command line parser out of the game frontends.

Some part are not done yet, and the file system data is currently ignored - there's no way to properly set this up with the file system code Build came with.
This commit is contained in:
Christoph Oelckers 2019-10-28 22:19:50 +01:00
parent 5148fc877d
commit 762f174743
49 changed files with 337 additions and 1529 deletions

View file

@ -54,7 +54,7 @@ int nAmbChannels = 0;
void ambProcess(void)
{
if (!snd_enabled)
if (!SoundEnabled())
return;
for (int nSprite = headspritestat[kStatAmbience]; nSprite >= 0; nSprite = nextspritestat[nSprite])
{

View file

@ -31,7 +31,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "fx_man.h"
#include "common.h"
#include "common_game.h"
#include "gamedefs.h"
#include "asound.h"
#include "db.h"
@ -87,7 +86,6 @@ BEGIN_BLD_NS
extern const char* G_DefaultDefFile(void);
extern const char* G_DefFile(void);
char SetupFilename[BMAX_PATH] = SETUPFILENAME;
int32_t gNoSetup = 0, gCommandSetup = 0;
INPUT_MODE gInputMode;
@ -1088,167 +1086,36 @@ void ProcessFrame(void)
}
}
#if 0
SWITCH switches[] = {
{ "?", 0, 0 },
{ "help", 0, 0 },
{ "broadcast", 1, 0 },
{ "map", 2, 1 },
{ "masterslave", 3, 0 },
//{ "net", 4, 1 },
{ "nodudes", 5, 1 },
{ "playback", 6, 1 },
{ "record", 7, 1 },
{ "robust", 8, 0 },
{ "setupfile", 9, 1 },
{ "skill", 10, 1 },
//{ "nocd", 11, 0 },
//{ "8250", 12, 0 },
{ "ini", 13, 1 },
{ "noaim", 14, 0 },
{ "f", 15, 1 },
{ "control", 16, 1 },
{ "vector", 17, 1 },
{ "quick", 18, 0 },
//{ "getopt", 19, 1 },
//{ "auto", 20, 1 },
{ "pname", 21, 1 },
{ "noresend", 22, 0 },
{ "silentaim", 23, 0 },
{ "nodemo", 25, 0 },
{ "art", 26, 1 },
{ "snd", 27, 1 },
{ "rff", 28, 1 },
#ifdef USE_QHEAP
{ "maxalloc", 29, 1 },
#endif
{ "server", 30, 1 },
{ "client", 31, 1 },
{ "noautoload", 32, 0 },
{ "usecwd", 33, 0 },
{ "cachesize", 34, 1 },
{ "g", 35, 1 },
{ "grp", 35, 1 },
{ "game_dir", 36, 1 },
{ "cfg", 9, 1 },
{ "setup", 37, 0 },
{ "nosetup", 38, 0 },
{ "port", 39, 1 },
{ "h", 40, 1 },
{ "mh", 41, 1 },
{ "j", 42, 1 },
{ "c", 43, 1 },
{ "conf", 43, 1 },
{ "game", 44, 1 },
{ "noconsole", 43, 0 },
{ NULL, 0, 0 }
};
void PrintHelp(void)
{
char tempbuf[128];
static char const s[] = "Usage: " APPBASENAME " [files] [options]\n"
"Example: " APPBASENAME " -usecwd -cfg myconfig.cfg -map nukeland.map\n\n"
"Files can be of type [grp|zip|map|def]\n"
"\n"
"-art [file.art]\tSpecify an art base file name\n"
"-cachesize #\tSet cache size in kB\n"
"-cfg [file.cfg]\tUse an alternate configuration file\n"
"-client [host]\tConnect to a multiplayer game\n"
"-game_dir [dir]\tSpecify game data directory\n"
"-g [file.grp]\tLoad additional game data\n"
"-h [file.def]\tLoad an alternate definitions file\n"
"-ini [file.ini]\tSpecify an INI file name (default is blood.ini)\n"
"-j [dir]\t\tAdd a directory to " APPNAME "'s search list\n"
"-map [file.map]\tLoad an external map file\n"
"-mh [file.def]\tInclude an additional definitions module\n"
"-noautoload\tDisable loading from autoload directory\n"
"-nodemo\t\tNo Demos\n"
"-nodudes\tNo monsters\n"
"-playback\tPlay back a demo\n"
"-pname\t\tOverride player name setting from config file\n"
"-record\t\tRecord demo\n"
"-rff\t\tSpecify an RFF file for Blood game resources\n"
"-server [players]\tStart a multiplayer server\n"
#ifdef STARTUP_SETUP_WINDOW
"-setup/nosetup\tEnable or disable startup window\n"
#endif
"-skill\t\tSet player handicap; Range:0..4; Default:2; (NOT difficulty level.)\n"
"-snd\t\tSpecify an RFF Sound file name\n"
"-usecwd\t\tRead data and configuration from current directory\n"
;
#ifdef WM_MSGBOX_WINDOW
Bsnprintf(tempbuf, sizeof(tempbuf), APPNAME " %s", s_buildRev);
wm_msgbox(tempbuf, s);
#else
initprintf("%s\n", s);
#endif
#if 0
puts("Blood Command-line Options:");
// NUKE-TODO:
puts("-? This help");
//puts("-8250 Enforce obsolete UART I/O");
//puts("-auto Automatic Network start. Implies -quick");
//puts("-getopt Use network game options from file. Implies -auto");
puts("-broadcast Set network to broadcast packet mode");
puts("-masterslave Set network to master/slave packet mode");
//puts("-net Net mode game");
//puts("-noaim Disable auto-aiming");
//puts("-nocd Disable CD audio");
puts("-nodudes No monsters");
puts("-nodemo No Demos");
puts("-robust Robust network sync checking");
puts("-skill Set player handicap; Range:0..4; Default:2; (NOT difficulty level.)");
puts("-quick Skip Intro screens and get right to the game");
puts("-pname Override player name setting from config file");
puts("-map Specify a user map");
puts("-playback Play back a demo");
puts("-record Record a demo");
puts("-art Specify an art base file name");
puts("-snd Specify an RFF Sound file name");
puts("-RFF Specify an RFF file for Blood game resources");
puts("-ini Specify an INI file name (default is blood.ini)");
#endif
exit(0);
}
void ParseOptions(void)
{
// Stuff for later.
#if 0
int option;
while ((option = GetOptions(switches)) != -1)
{
switch (option)
{
case -3:
//ThrowError("Invalid argument: %s", OptFull);
//fallthrough__;
break; // do not error out - this isn't the only code reading the args anymore.
case 29:
#ifdef USE_QHEAP
if (OptArgc < 1)
ThrowError("Missing argument");
nMaxAlloc = atoi(OptArgv[0]);
if (!nMaxAlloc)
nMaxAlloc = 0x2000000;
break;
#endif
case 0:
PrintHelp();
break;
//case 19:
// byte_148eec = 1;
//case 20:
// if (OptArgc < 1)
// ThrowError("Missing argument");
// strncpy(byte_148ef0, OptArgv[0], 13);
// byte_148ef0[12] = 0;
// bQuickStart = 1;
// byte_148eeb = 1;
// if (gGameOptions.gameType == 0)
// gGameOptions.gameType = 2;
// break;
case 25:
bNoDemo = 1;
break;
case 18:
bQuickStart = 1;
break;
@ -1273,12 +1140,6 @@ void ParseOptions(void)
else
gPacketMode = PACKETMODE_1;
break;
case 4:
//if (OptArgc < 1)
// ThrowError("Missing argument");
//if (gGameOptions.nGameType == 0)
// gGameOptions.nGameType = 2;
break;
case 30:
if (OptArgc < 1)
ThrowError("Missing argument");
@ -1291,9 +1152,6 @@ void ParseOptions(void)
gNetMode = NETWORK_CLIENT;
strncpy(gNetAddress, OptArgv[0], sizeof(gNetAddress)-1);
break;
case 14:
cl_autoaim = 0;
break;
case 22:
bNoResend = 0;
break;
@ -1318,41 +1176,6 @@ void ParseOptions(void)
case 8:
gRobust = 1;
break;
case 13:
if (OptArgc < 1)
ThrowError("Missing argument");
levelOverrideINI(OptArgv[0]);
bNoDemo = 1;
break;
case 26:
if (OptArgc < 1)
ThrowError("Missing argument");
pUserTiles = (char*)malloc(strlen(OptArgv[0])+1);
if (!pUserTiles)
return;
strcpy(pUserTiles, OptArgv[0]);
break;
case 27:
if (OptArgc < 1)
ThrowError("Missing argument");
pUserSoundRFF = (char*)malloc(strlen(OptArgv[0])+1);
if (!pUserSoundRFF)
return;
strcpy(pUserSoundRFF, OptArgv[0]);
break;
case 28:
if (OptArgc < 1)
ThrowError("Missing argument");
pUserRFF = (char*)malloc(strlen(OptArgv[0])+1);
if (!pUserRFF)
return;
strcpy(pUserRFF, OptArgv[0]);
break;
case 9:
if (OptArgc < 1)
ThrowError("Missing argument");
strcpy(SetupFilename, OptArgv[0]);
break;
case 10:
if (OptArgc < 1)
ThrowError("Missing argument");
@ -1371,94 +1194,9 @@ void ParseOptions(void)
else if (gPacketMode == PACKETMODE_3)
gSyncRate = 1;
break;
case -2:
{
const char *k = strrchr(OptFull, '.');
if (k)
{
if (!Bstrcasecmp(k, ".map"))
{
strcpy(gUserMapFilename, OptFull);
bAddUserMap = 1;
bNoDemo = 1;
}
else if (!Bstrcasecmp(k, ".grp") || !Bstrcasecmp(k, ".zip") || !Bstrcasecmp(k, ".pk3") || !Bstrcasecmp(k, ".pk4"))
{
G_AddGroup(OptFull);
}
else if (!Bstrcasecmp(k, ".def"))
{
clearDefNamePtr();
g_defNamePtr = dup_filename(OptFull);
initprintf("Using DEF file \"%s\".\n", g_defNamePtr);
continue;
}
}
else
{
strcpy(gUserMapFilename, OptFull);
bAddUserMap = 1;
bNoDemo = 1;
}
break;
}
case 11:
//bNoCDAudio = 1;
break;
case 32:
break;
case 33:
break;
case 34:
{
if (OptArgc < 1)
ThrowError("Missing argument");
// No longer supported.
break;
}
case 35:
if (OptArgc < 1)
ThrowError("Missing argument");
G_AddGroup(OptArgv[0]);
break;
case 36:
if (OptArgc < 1)
ThrowError("Missing argument");
Bstrncpyz(g_modDir, OptArgv[0], sizeof(g_modDir));
G_AddPath(OptArgv[0]);
break;
case 37:
gCommandSetup = true;
break;
case 38:
gNoSetup = true;
gCommandSetup = false;
break;
case 39:
if (OptArgc < 1)
ThrowError("Missing argument");
gNetPort = strtoul(OptArgv[0], NULL, 0);
break;
case 40:
if (OptArgc < 1)
ThrowError("Missing argument");
G_AddDef(OptArgv[0]);
break;
case 41:
if (OptArgc < 1)
ThrowError("Missing argument");
G_AddDefModule(OptArgv[0]);
break;
case 42:
if (OptArgc < 1)
ThrowError("Missing argument");
G_AddPath(OptArgv[0]);
break;
case 43: // conf, noconsole
case 44:
break;
}
}
#endif
#if 0
if (bAddUserMap)
{
@ -1507,6 +1245,8 @@ int app_main(int argc, char const * const * argv)
PrintBuildInfo();
memcpy(&gGameOptions, &gSingleGameOptions, sizeof(GAMEOPTIONS));
gGameOptions.nMonsterSettings = userConfig.nomonsters;
bQuickStart = userConfig.nologo;
ParseOptions();
G_ExtInit();
@ -1526,9 +1266,6 @@ int app_main(int argc, char const * const * argv)
Bexit(2);
}
if (Bstrcmp(SetupFilename, SETUPFILENAME))
initprintf("Using config file \"%s\".\n", SetupFilename);
ScanINIFiles();
#ifdef STARTUP_SETUP_WINDOW

View file

@ -52,7 +52,6 @@ enum INPUT_MODE {
};
extern INPUT_MODE gInputMode;
extern char SetupFilename[BMAX_PATH];
extern int32_t gNoSetup;
extern short BloodVersion;
extern int gNetPlayers;

View file

@ -34,7 +34,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "gamecontrol.h"
#include "blood.h"
#include "config.h"
#include "gamedefs.h"
#include "globals.h"
#include "screen.h"
#include "sound.h"

View file

@ -27,7 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "keyboard.h"
#include "control.h"
#include "_control.h"
#include "gamedefs.h"
#include "hash.h"
#include "gamecvars.h"
#include "gamecontrol.h"

View file

@ -1,44 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2010-2019 EDuke32 developers and contributors
Copyright (C) 2019 Nuke.YKT
This file is part of NBlood.
NBlood 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.
*/
//-------------------------------------------------------------------------
//****************************************************************************
//
// gamedefs.h
//
// common defines between the game and the setup program
//
//****************************************************************************
#ifndef gamedefs_public_h_
#define gamedefs_public_h_
BEGIN_BLD_NS
// config file name
#define SETUPFILENAME APPBASENAME ".cfg"
END_BLD_NS
#endif

View file

@ -1784,14 +1784,14 @@ void PreDrawDisplayPolymost(CGameMenuItem *pItem)
void UpdateSoundToggle(CGameMenuItemZBool *pItem)
{
snd_enabled = pItem->at20;
if (!snd_enabled)
if (!SoundEnabled())
FX_StopAllSounds();
}
void UpdateMusicToggle(CGameMenuItemZBool *pItem)
{
mus_enabled = pItem->at20;
if (!mus_enabled)
if (!MusicEnabled())
sndStopSong();
else
{

View file

@ -432,7 +432,7 @@ static int osdcmd_restartsound(osdcmdptr_t UNUSED(parm))
sndInit();
sfxInit();
if (mus_enabled && (gGameStarted || gDemo.at1))
if (MusicEnabled() && (gGameStarted || gDemo.at1))
sndPlaySong(gGameOptions.zLevelSong, true);
return OSDCMD_OK;

View file

@ -119,7 +119,7 @@ void Calc3DValues(BONKLE *pBonkle)
void sfxPlay3DSound(int x, int y, int z, int soundId, int nSector)
{
if (!snd_enabled || soundId < 0) return;
if (!SoundEnabled() || soundId < 0) return;
DICTNODE *hRes = gSoundRes.Lookup(soundId, "SFX");
if (!hRes)return;
@ -169,7 +169,7 @@ void sfxPlay3DSound(int x, int y, int z, int soundId, int nSector)
void sfxPlay3DSound(spritetype *pSprite, int soundId, int a3, int a4)
{
if (!snd_enabled)
if (!SoundEnabled())
return;
if (!pSprite)
return;
@ -283,7 +283,7 @@ void sfxPlay3DSound(spritetype *pSprite, int soundId, int a3, int a4)
// By NoOne: same as previous, but allows to set custom pitch for sound AND volume. Used by SFX gen now.
void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int a3, int a4, int pitch, int volume)
{
if (!snd_enabled || !pSprite || soundId < 0) return;
if (!SoundEnabled() || !pSprite || soundId < 0) return;
DICTNODE* hRes = gSoundRes.Lookup(soundId, "SFX");
if (!hRes) return;

View file

@ -81,7 +81,7 @@ int nWaveMusicHandle;
int sndPlaySong(const char *songName, bool bLoop)
{
if (!mus_enabled)
if (!MusicEnabled())
return 0;
if (!songName || strlen(songName) == 0)
return 1;
@ -245,7 +245,7 @@ void sndKillSound(SAMPLE2D *pChannel);
void sndStartSample(const char *pzSound, int nVolume, int nChannel)
{
if (!snd_enabled)
if (!SoundEnabled())
return;
if (!strlen(pzSound))
return;
@ -267,7 +267,7 @@ void sndStartSample(const char *pzSound, int nVolume, int nChannel)
void sndStartSample(unsigned int nSound, int nVolume, int nChannel, bool bLoop)
{
if (!snd_enabled)
if (!SoundEnabled())
return;
dassert(nChannel >= -1 && nChannel < kChannelMax);
DICTNODE *hSfx = gSoundRes.Lookup(nSound, "SFX");
@ -311,7 +311,7 @@ void sndStartSample(unsigned int nSound, int nVolume, int nChannel, bool bLoop)
void sndStartWavID(unsigned int nSound, int nVolume, int nChannel)
{
if (!snd_enabled)
if (!SoundEnabled())
return;
dassert(nChannel >= -1 && nChannel < kChannelMax);
SAMPLE2D *pChannel;

View file

@ -77,6 +77,20 @@ void clearDefNamePtr(void)
GrowArray<char *> g_clipMapFiles;
#endif
void SetClipshapes()
{
#ifdef HAVE_CLIPSHAPE_FEATURE
// pre-form the default 10 clipmaps
for (int j = '0'; j <= '9'; ++j)
{
char clipshape[16] = "_clipshape0.map";
clipshape[10] = j;
g_clipMapFiles.append(Xstrdup(clipshape));
}
#endif
}
void G_AddDef(const char *buffer)
{
clearDefNamePtr();

View file

@ -619,10 +619,6 @@ int main(int argc, char *argv[])
FString logpath = M_GetDocumentsPath() + "demolition.log";
OSD_SetLogFile(logpath);
CONFIG_ReadCombatMacros();
// Startup dialog must be presented here so that everything can be set up before reading the keybinds.
G_LoadConfig(currentGame);
CONFIG_Init();
r = gi->app_main(buildargc, (const char**)buildargv);
}

View file

@ -12,9 +12,11 @@
#include "inputstate.h"
#include "_control.h"
#include "control.h"
#include "m_argv.h"
#include "rts.h"
InputState inputState;
void SetClipshapes();
struct GameFuncNameDesc
{
@ -149,6 +151,141 @@ void SetupButtonFunctions()
}
UserConfig userConfig;
void UserConfig::ProcessOptions()
{
// -help etc are omitted
// -cfg / -setupfile refer to Build style config which are not supported.
if (Args->CheckParm("-cfg") || Args->CheckParm("-setupfile"))
{
initprintf("Build-format config files not supported and will be ignored\n");
}
auto v = Args->CheckValue("-port");
if (v) netPort = strtol(v, nullptr, 0);
netServerMode = Args->CheckParm("-server");
netServerAddress = Args->CheckValue("-connect");
netPassword = Args->CheckValue("-password");
v = Args->CheckValue("-addon");
if (v)
{
auto val = strtol(v, nullptr, 0);
static const char* const addons[] = { "DUKE3D.GRP", "DUKEDC.GRP", "NWINTER.GRP", "VACATION.GRP" };
if (val > 0 && val < 4) gamegrp = addons[val];
else initprintf("%s: Unknown Addon\n", v);
}
else if (Args->CheckParm("-nam"))
{
gamegrp = "NAM.GRP";
}
else if (Args->CheckParm("-napalm"))
{
gamegrp = "NAPALM.GRP";
}
else if (Args->CheckParm("-ww2gi"))
{
gamegrp = "WW2GI.GRP";
}
v = Args->CheckValue("-gamegrp"); // Although it says 'grp', this will take a directory as well
if (v)
{
gamegrp = v;
}
else
{
// This is to enable the use of Doom launchers. that are limited to -iwad for specifying the game's main resource.
v = Args->CheckValue("-iwad");
if (v)
{
gamegrp = v;
}
}
Args->CollectFiles("-rts", ".rts");
auto rts = Args->CheckValue("-rts");
if (rts) RTS_Init(rts);
Args->CollectFiles("-map", ".map");
CommandMap = Args->CheckValue("-map");
static const char* defs[] = { "-def", "-h", nullptr };
Args->CollectFiles("-def", defs, ".def");
DefaultDef = Args->CheckValue("-def");
static const char* cons[] = { "-con", "-x", nullptr };
Args->CollectFiles("-con", cons, ".con");
DefaultCon = Args->CheckValue("-con");
static const char* demos[] = { "-playback", "-d", "-demo", nullptr };
Args->CollectFiles("-demo", demos, ".dmo");
CommandDemo = Args->CheckValue("-demo");
static const char* names[] = { "-pname", "-name", nullptr };
Args->CollectFiles("-name", names, ".---"); // this shouldn't collect any file names at all so use a nonsense extension
CommandName = Args->CheckValue("-name");
static const char* nomos[] = { "-nomonsters", "-nodudes", nullptr };
Args->CollectFiles("-nomonsters", nomos, ".---"); // this shouldn't collect any file names at all so use a nonsense extension
nomonsters = Args->CheckParm("-nomonsters");
static const char* acons[] = { "-addcon", "-mx", nullptr };
Args->CollectFiles("-addcon", acons, ".con");
AddCons.reset(Args->GatherFiles("-addcon"));
static const char* adefs[] = { "-adddef", "-mh", nullptr };
Args->CollectFiles("-adddef", adefs, ".def");
AddDefs.reset(Args->GatherFiles("-adddef"));
Args->CollectFiles("-art", ".art");
AddArt.reset(Args->GatherFiles("-art"));
CommandIni = Args->CheckValue("-ini");
nologo = Args->CheckParm("-nologo") || Args->CheckParm("-quick");
nomusic = Args->CheckParm("-nomusic");
nosound = Args->CheckParm("-nosfx");
if (Args->CheckParm("-nosound")) nomusic = nosound = true;
if (Args->CheckParm("-setup")) setupstate = 1;
else if (Args->CheckParm("-nosetup")) setupstate = 0;
if (Args->CheckParm("-file"))
{
// For file loading there's two modes:
// If -file is given, all content will be processed in order and the legacy options be ignored entirely.
//This allows mixing directories and GRP files in arbitrary order.
Args->CollectFiles("-file", NULL);
AddFiles.reset(Args->GatherFiles("-file"));
}
else
{
// Trying to emulate Build. This means to treat RFF special as lowest priority, then all GRPs and then all directories.
// This is only for people depending on lauchers. Since the semantics are so crappy it is strongly recommended to
// use -file instead which gives the user full control about the order in which things are added.
// For single mods this is no problem but don't even think about loading more stuff consistently...
static const char* grps[] = { "-g", "-grp", nullptr };
static const char* dirs[] = { "-game_dir", "-j", nullptr };
static const char* rffs[] = { "-rff", "-snd", nullptr };
static const char* twostep[] = { "-rff", "-grp", nullptr };
// Abuse the inner workings to get the files into proper order. This is not 100% accurate but should work fine for everything that doesn't intentionally fuck things up.
Args->CollectFiles("-rff", rffs, ".rff");
Args->CollectFiles("-grp", grps, nullptr);
Args->CollectFiles("-grp", twostep, nullptr); // The two previous calls have already brought the content in order so collecting it again gives us one list with everything.
AddFilesPre.reset(Args->GatherFiles("-grp"));
Args->CollectFiles("-game_dir", dirs, nullptr);
AddFiles.reset(Args->GatherFiles("-game_dir"));
}
}
//==========================================================================
//
//
@ -157,11 +294,26 @@ void SetupButtonFunctions()
void CONFIG_Init()
{
SetClipshapes();
// This must be done before initializing any data, so doing it late in the startup process won't work.
if (CONTROL_Startup(controltype_keyboardandmouse, BGetTime, gi->TicRate))
{
exit(1);
}
userConfig.ProcessOptions();
CONFIG_ReadCombatMacros();
// Startup dialog must be presented here so that everything can be set up before reading the keybinds.
G_LoadConfig(currentGame);
if (userConfig.CommandName.IsNotEmpty())
{
playername = userConfig.CommandName;
}
int index = 0;
for(auto &gf : gamefuncs)
@ -1009,10 +1161,8 @@ FString CONFIG_GetBoundKeyForLastInput(int gameFunc)
{
return joyname;
}
return "UNBOUND";
}
return "UNBOUND";
}

View file

@ -6,8 +6,10 @@
#include "c_cvars.h"
#include "zstring.h"
#include "inputstate.h"
#include "gamecvars.h"
extern FString currentGame;
class FArgs;
extern uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2];
@ -71,3 +73,44 @@ void CONFIG_ReadCombatMacros();
int32_t CONFIG_GetMapBestTime(char const* const mapname, uint8_t const* const mapmd4);
int CONFIG_SetMapBestTime(uint8_t const* const mapmd4, int32_t tm);
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;
bool nomonsters = false;
bool nosound = false;
bool nomusic = false;
bool nologo = false;
int setupstate = -1;
int netPort = 0; // g_netPort = Batoi(argv[i + 1]);
int netServerMode = -1; // g_networkMode = NET_SERVER; g_noSetup = g_noLogo = TRUE;
FString netServerAddress; // Net_Connect(argv[i + 1]); g_noSetup = g_noLogo = TRUE;
FString netPassword; // Bstrncpyz(g_netPassword, argv[i + 1], sizeof(g_netPassword));
void ProcessOptions();
};
extern UserConfig userConfig;
inline bool MusicEnabled()
{
return mus_enabled && !userConfig.nomusic;
}
inline bool SoundEnabled()
{
return snd_enabled && !userConfig.nosound;
}

View file

@ -139,7 +139,22 @@ void FArgs::FlushArgs()
//
//===========================================================================
int FArgs::CheckParm(const char *check, int start) const
int stricmp(const char** check, const char* str)
{
for (auto c = *check; c; c++)
{
if (!stricmp(c, str)) return 0;
}
return 1; // we do not care about order here.
}
int FArgs::CheckParm(const char* check, int start) const
{
const char* array[] = { check, nullptr };
return CheckParm(array, start);
}
int FArgs::CheckParm(const char** check, int start) const
{
for (unsigned i = start; i < Argv.Size(); ++i)
{
@ -354,7 +369,13 @@ void FArgs::RemoveArg(int argindex)
//
//===========================================================================
void FArgs::CollectFiles(const char *param, const char *extension)
void FArgs::CollectFiles(const char* param, const char* extension)
{
const char* array[] = { param, nullptr };
CollectFiles(param, array, extension);
}
void FArgs::CollectFiles(const char *finalname, const char **param, const char *extension)
{
TArray<FString> work;
unsigned int i;
@ -408,7 +429,7 @@ void FArgs::CollectFiles(const char *param, const char *extension)
// Step 3: Add work back to Argv, as long as it's non-empty.
if (work.Size() > 0)
{
Argv.Push(param);
Argv.Push(finalname);
AppendArgs(work.Size(), &work[0]);
}
}

View file

@ -56,11 +56,13 @@ public:
void RemoveArg(int argindex);
void RemoveArgs(const char *check);
void SetArgs(int argc, char **argv);
void CollectFiles(const char *finalname, const char** param, const char* extension);
void CollectFiles(const char *param, const char *extension);
FArgs *GatherFiles(const char *param) const;
void SetArg(int argnum, const char *arg);
int CheckParm(const char *check, int start=1) const; // Returns the position of the given parameter in the arg list (0 if not found).
int CheckParm(const char** check, int start = 1) const; // Returns the position of the given parameter in the arg list (0 if not found). Allows checking for multiple switches
int CheckParmList(const char *check, FString **strings, int start=1) const;
const char *CheckValue(const char *check) const;
const char *GetArg(int arg) const;

View file

@ -32,95 +32,8 @@ BEGIN_DUKE_NS
int32_t g_commandSetup = 0;
int32_t g_noSetup = 0;
int32_t g_noSound = 0;
int32_t g_noMusic = 0;
const char *CommandMap = NULL;
const char *CommandName = NULL;
int32_t g_fakeMultiMode = 0;
void G_ShowParameterHelp(void)
{
static char const s[] = "Usage: " APPBASENAME " [files] [options]\n"
"Example: " APPBASENAME " -usecwd -cfg myconfig.cfg -map nukeland.map\n\n"
"Files can be of type [grp|zip|map|con|def]\n"
"\n"
"-cfg [file.cfg]\tUse an alternate configuration file\n"
#ifdef HAVE_CLIPSHAPE_FEATURE
"-clipmap [file.map]\tLoad an additional clipping map for use with clipshape\n"
#endif
"-connect [host]\tConnect to a multiplayer game\n"
"-c#\t\tMultiplayer mode #, 1 = DM, 2 = Co-op, 3 = DM(no spawn)\n"
"-d [file.edm or #]\tPlay a demo\n"
"-g [file.grp]\tLoad additional game data\n"
"-h [file.def]\tLoad an alternate definitions file\n"
"-j [dir]\t\tAdd a directory to " APPNAME "'s search list\n"
"-l#\t\tStart game on level #, see -v\n"
"-map [file.map]\tLoad an external map file\n"
"-mh [file.def]\tInclude an additional definitions module\n"
"-mx [file.con]\tInclude an additional CON script module\n"
"-m\t\tDisable enemies\n"
"-noffire\t\tDisable friendly fire\n"
#ifndef EDUKE32_STANDALONE
"-nam\t\tRun in NAM compatibility mode\n"
"-napalm\t\tRun in NAPALM compatibility mode\n"
#endif
"-rts [file.rts]\tLoad a custom Remote Ridicule sound bank\n"
"-r\t\tRecord demo\n"
"-s#\t\tStart game on skill level #\n"
"-server\t\tStart a multiplayer server\n"
#ifdef STARTUP_SETUP_WINDOW
"-setup/nosetup\tEnable or disable startup window\n"
#endif
"-t#\t\tRespawn mode: 1 = enemies, 2 = weapons, 3 = items, x = all\n"
"-usecwd\t\tRead data and configuration from current directory\n"
"-u#########\tUser's favorite weapon order (default: 3425689071)\n"
"-v#\t\tStart game on episode #, see -l\n"
#ifndef EDUKE32_STANDALONE
"-ww2gi\t\tRun in WWII GI compatibility mode\n"
#endif
"-x [game.con]\tLoad custom CON script\n"
"-#\t\tLoad and run a game from slot # (0-9)\n"
// "\n-?/--help\tDisplay this help message and exit\n"
"\nSee " APPBASENAME " -debughelp for additional parameters for debugging"
;
#ifdef WM_MSGBOX_WINDOW
Bsnprintf(tempbuf, sizeof(tempbuf), HEAD2 " %s", s_buildRev);
wm_msgbox(tempbuf, s);
#else
initprintf("%s\n", s);
#endif
}
void G_ShowDebugHelp(void)
{
static char const s[] = "Usage: " APPBASENAME " [files] [options]\n"
"\n"
#if 0
"-a\t\tUse fake player AI (fake multiplayer only)\n"
#endif
"-cachesize #\tSet cache size in kB\n"
"-game_dir [dir]\tSpecify game data directory\n"
"-gamegrp \tSelect main grp file\n"
"-name [name]\tPlayer name in multiplayer\n"
"-noautoload\tDisable loading from autoload directory\n"
#if defined RENDERTYPEWIN
"-nodinput\t\tDisable DirectInput (joystick) support\n"
#endif
"-nologo\t\tSkip intro anim\n"
"-ns\t\tDisable sound\n"
"-nm\t\tDisable music\n"
"-q#\t\tFake multiplayer with # players\n"
"-z#/-condebug\tEnable line-by-line CON compile debugging at level #\n"
"-conversion YYYYMMDD\tSelects CON script version for compatibility with older mods\n"
"-rotatesprite-no-widescreen\tStretch screen drawing from scripts to fullscreen\n"
;
#ifdef WM_MSGBOX_WINDOW
Bsnprintf(tempbuf, sizeof(tempbuf), HEAD2 " %s", s_buildRev);
wm_msgbox(tempbuf, s);
#else
initprintf("%s\n", s);
#endif
}
static void G_AddDemo(const char* param)
{
@ -155,31 +68,11 @@ static void G_AddDemo(const char* param)
void G_CheckCommandLine(int32_t argc, char const * const * argv)
{
// stuff for later
#if 0
int16_t i = 1, j;
const char *c, *k;
ud.fta_on = 1;
ud.god = 0;
ud.m_respawn_items = 0;
ud.m_respawn_monsters = 0;
ud.m_respawn_inventory = 0;
ud.warp_on = 0;
ud.cashman = 0;
ud.m_ffire = 1;
ud.m_player_skill = ud.player_skill = 2;
memcpy(g_player[0].wchoice, "\3\4\5\7\0x8\6\0\2\0x9\1", 10);
wchoice.Callback();
#ifdef HAVE_CLIPSHAPE_FEATURE
// pre-form the default 10 clipmaps
for (j = '0'; j<='9'; ++j)
{
char clipshape[16] = "_clipshape0.map";
clipshape[10] = j;
g_clipMapFiles.append(Xstrdup(clipshape));
}
#endif
if (argc > 1)
{
@ -200,270 +93,12 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
{
shortopt = 0;
if (!Bstrcasecmp(c+1, "?") || !Bstrcasecmp(c+1, "help") || !Bstrcasecmp(c+1, "-help"))
{
G_ShowParameterHelp();
Bexit(EXIT_SUCCESS);
}
if (!Bstrcasecmp(c+1, "addon"))
{
if (argc > i+1)
{
g_addonNum = Batoi(argv[i+1]);
if (g_addonNum > ADDON_NONE && g_addonNum < NUMADDONS)
g_noSetup = 1;
else g_addonNum = ADDON_NONE;
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "debughelp") || !Bstrcasecmp(c+1, "-debughelp"))
{
G_ShowDebugHelp();
Bexit(EXIT_SUCCESS);
}
if (!Bstrcasecmp(c+1, "grp") || !Bstrcasecmp(c+1, "g"))
{
if (argc > i+1)
{
G_AddGroup(argv[i+1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "game_dir"))
{
if (argc > i+1)
{
Bstrncpyz(g_modDir, argv[i+1], sizeof(g_modDir));
G_AddPath(argv[i+1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "cfg"))
{
if (argc > i+1)
{
Bstrcpy(g_setupFileName, argv[i+1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "gamegrp"))
{
if (argc > i+1)
{
clearGrpNamePtr();
g_grpNamePtr = dup_filename(argv[i+1]);
i++;
}
i++;
continue;
}
#ifndef EDUKE32_STANDALONE
if (!Bstrcasecmp(c+1, "nam"))
{
g_gameType = GAMEFLAG_NAM;
i++;
continue;
}
if (!Bstrcasecmp(c+1, "napalm"))
{
g_gameType = GAMEFLAG_NAM|GAMEFLAG_NAPALM;
i++;
continue;
}
if (!Bstrcasecmp(c+1, "ww2gi"))
{
g_gameType = GAMEFLAG_WW2GI;
i++;
continue;
}
#endif
if (!Bstrcasecmp(c+1, "setup"))
{
g_commandSetup = TRUE;
i++;
continue;
}
if (!Bstrcasecmp(c+1, "nosetup"))
{
g_noSetup = 1;
g_commandSetup = 0;
i++;
continue;
}
#if defined RENDERTYPEWIN
if (!Bstrcasecmp(c+1, "nodinput"))
{
initprintf("DirectInput (joystick) support disabled\n");
di_disabled = 1;
i++;
continue;
}
#endif
#ifndef NETCODE_DISABLE
if (!Bstrcasecmp(c+1, "net"))
{
G_GameExit("EDuke32 no longer supports legacy networking.\n\n"
"If using YANG or other launchers that only support legacy netplay, download an older build of EDuke32. "
"Otherwise, run the following:\n\n"
"eduke32 -server\n\n"
"Other clients can then connect by typing \"connect [host]\" in the console.\n\n"
"EDuke32 will now close.");
}
#endif
if (!Bstrcasecmp(c+1, "port"))
{
if (argc > i+1)
{
g_netPort = Batoi(argv[i+1]);
i++;
}
i++;
continue;
}
#ifndef NETCODE_DISABLE
if (!Bstrcasecmp(c+1, "server"))
{
g_networkMode = NET_SERVER;
g_noSetup = g_noLogo = TRUE;
i++;
continue;
}
if (!Bstrcasecmp(c+1, "dedicated"))
{
g_networkMode = NET_DEDICATED_SERVER;
g_noSetup = g_noLogo = TRUE;
i++;
continue;
}
if (!Bstrcasecmp(c+1, "connect"))
{
if (argc > i+1)
{
Net_Connect(argv[i+1]);
g_noSetup = g_noLogo = TRUE;
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "password"))
{
if (argc > i+1)
{
Bstrncpyz(g_netPassword, argv[i+1], sizeof(g_netPassword));
i++;
}
i++;
continue;
}
#endif
if (!Bstrcasecmp(c+1, "name")) // pname in Blood
{
if (argc > i+1)
{
CommandName = argv[i+1];
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "map"))
{
if (argc > i+1)
{
CommandMap = argv[i+1];
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "noffire"))
{
ud.m_ffire = 0;
i++;
continue;
}
if (!Bstrcasecmp(c+1, "rts"))
{
if (argc > i+1)
{
RTS_Init(argv[i+1]);
initprintf("Using RTS file \"%s\".\n", argv[i + 1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "x"))
{
if (argc > i+1)
{
G_AddCon(argv[i+1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "mx"))
{
if (argc > i+1)
{
G_AddConModule(argv[i+1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "h"))
{
if (argc > i+1)
{
G_AddDef(argv[i+1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "mh"))
{
if (argc > i+1)
{
G_AddDefModule(argv[i+1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "j"))
{
if (argc > i+1)
{
G_AddPath(argv[i+1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "d"))
{
if (argc > i+1)
{
G_AddDemo(argv[i+1]);
i++;
}
i++;
continue;
}
#ifdef HAVE_CLIPSHAPE_FEATURE
if (!Bstrcasecmp(c+1, "clipmap"))
{
@ -482,53 +117,6 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
i++;
continue;
}
if (!Bstrcasecmp(c+1, "nologo"))
{
g_noLogo = 1;
i++;
continue;
}
if (!Bstrcasecmp(c+1, "usecwd"))
{
i++;
continue;
}
if (!Bstrcasecmp(c+1, "cachesize"))
{
if (argc > i+1)
{
i++;
// No longer supported.
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "noinstancechecking"))
{
i++;
continue;
}
#if defined(RENDERTYPEWIN) && defined(USE_OPENGL)
if (!Bstrcasecmp(c+1, "forcegl"))
{
forcegl = 1;
i++;
continue;
}
#endif
// the following two dummy entries allow us to serve as a drop-in replacement for NAM on Steam
if (!Bstrcasecmp(c+1, "noconsole"))
{
i++;
continue;
}
if (!Bstrcasecmp(c+1, "conf"))
{
if (argc > i+1)
i++;
i++;
continue;
}
}
if ((*c == '-')
@ -557,63 +145,6 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
}
ud.m_coop--;
break;
case 'd':
{
c++;
if (*c)
G_AddDemo(c);
break;
}
case 'g':
c++;
if (*c)
G_AddGroup(c);
break;
case 'h':
c++;
if (*c)
G_AddDef(c);
break;
case 'j':
c++;
if (*c)
G_AddPath(c);
break;
case 'l':
// NOTE: Overlaid with -Lopts=... options for Lunatic, hence the check.
if (Bisdigit(c[1]))
{
ud.warp_on = 1;
c++;
ud.m_level_number = ud.level_number = ((unsigned) (Batoi(c)-1))%MAXLEVELS;
}
break;
case 'm':
if (*(c+1) != 'a' && *(c+1) != 'A')
{
ud.m_monsters_off = 1;
ud.m_player_skill = ud.player_skill = 0;
initprintf("Monsters off.\n");
}
break;
case 'n':
c++;
if (*c == 's' || *c == 'S')
{
g_noSound = 2;
initprintf("Sound off.\n");
}
else if (*c == 'm' || *c == 'M')
{
g_noMusic = 1;
initprintf("Music off.\n");
}
else
{
G_ShowParameterHelp();
Bexit(EXIT_SUCCESS);
}
break;
case 'q':
if (*(++c) == 0)
{
@ -667,8 +198,6 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
}
initprintf("Respawn on.\n");
break;
case 'u':
break;
case 'v':
c++;
ud.warp_on = 1;
@ -677,11 +206,6 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
case 'w':
cl_showcoords = 1;
break;
case 'x':
c++;
if (*c)
G_AddCon(c);
break;
case 'z':
c++;
g_scriptDebug = Batoi(c);
@ -693,53 +217,13 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
break;
}
}
else
{
shortopt = 0;
k = Bstrrchr(c, '.');
if (k)
{
if (!Bstrcasecmp(k, ".map"))
{
CommandMap = argv[i++];
continue;
}
if (!Bstrcasecmp(k, ".grp") || !Bstrcasecmp(k, ".zip") || !Bstrcasecmp(k, ".pk3") || !Bstrcasecmp(k, ".pk4"))
{
G_AddGroup(argv[i++]);
continue;
}
if (!Bstrcasecmp(k, ".con"))
{
clearScriptNamePtr();
g_scriptNamePtr = dup_filename(argv[i++]);
initprintf("Using CON file \"%s\".\n", g_scriptNamePtr);
continue;
}
if (!Bstrcasecmp(k, ".def"))
{
clearDefNamePtr();
g_defNamePtr = dup_filename(argv[i++]);
initprintf("Using DEF file \"%s\".\n", g_defNamePtr);
continue;
}
if (!Bstrcasecmp(k, ".rts"))
{
RTS_Init(argv[i]);
initprintf("Using RTS file \"%s\".\n", argv[i]);
i++;
continue;
}
}
}
if (!shortopt || ignored_short_opt)
initprintf("Warning: ignored application parameter \"%s\".\n", oc);
i++;
} while (i < argc);
}
#endif
}
END_DUKE_NS

View file

@ -34,10 +34,6 @@ extern void G_ShowDebugHelp(void);
extern int32_t g_commandSetup;
extern int32_t g_noSetup;
extern int32_t g_noSound;
extern int32_t g_noMusic;
extern const char *CommandMap;
extern const char *CommandName;
extern int32_t g_fakeMultiMode;
END_DUKE_NS

View file

@ -102,6 +102,19 @@ void CONFIG_SetDefaults(void)
ud.statusbarscale = 100;
ud.team = 0;
ud.fta_on = 1;
ud.god = 0;
ud.m_respawn_items = 0;
ud.m_respawn_monsters = 0;
ud.m_respawn_inventory = 0;
ud.warp_on = 0;
ud.cashman = 0;
ud.m_ffire = 1;
ud.m_player_skill = ud.player_skill = 2;
memcpy(g_player[0].wchoice, "\3\4\5\7\0x8\6\0\2\0x9\1", 10);
wchoice.Callback();
VM_OnEvent(EVENT_SETDEFAULTS, g_player[myconnectindex].ps->i, myconnectindex);
}

View file

@ -4447,7 +4447,7 @@ static int32_t g_RTSPlaying;
// Returns: started playing?
extern int G_StartRTS(int lumpNum, int localPlayer)
{
if (!adult_lockout && snd_enabled &&
if (!adult_lockout && SoundEnabled() &&
RTS_IsInitialized() && g_RTSPlaying == 0 && (snd_speech & (localPlayer ? 1 : 4)))
{
char *const pData = (char *)RTS_GetSound(lumpNum - 1);
@ -4881,7 +4881,7 @@ FAKE_F3:
Menu_Change(MENU_SOUND_INGAME);
}
if (KB_UnBoundKeyPressed(sc_F5) && mus_enabled)
if (KB_UnBoundKeyPressed(sc_F5) && MusicEnabled())
{
map_t *const pMapInfo = &g_mapInfo[g_musicIndex];
char *const musicString = apStrings[QUOTE_MUSIC];
@ -6034,16 +6034,7 @@ static void G_Startup(void)
#endif
if (g_netServer || ud.multimode > 1) G_CheckGametype();
//errr... what??? Why does this clobber the user setting? Well, it needs to be redone anyway, preferably at a lower level.
//if (g_noSound) snd_enabled = 0;
//if (g_noMusic) mus_enabled = 0;
if (CommandName)
{
playername = CommandName;
}
if (CommandMap)
if (userConfig.CommandMap.IsNotEmpty())
{
if (VOLUMEONE)
{
@ -6056,7 +6047,7 @@ static void G_Startup(void)
boardfilename[0] = '/';
boardfilename[1] = 0;
Bstrcat(boardfilename, CommandMap);
Bstrcat(boardfilename, userConfig.CommandMap);
dot = Bstrrchr(boardfilename,'.');
slash = Bstrrchr(boardfilename,'/');
@ -6302,6 +6293,7 @@ int app_main(int argc, const char * const*argv)
g_skillCnt = 4;
ud.multimode = 1;
ud.m_monsters_off = userConfig.nomonsters;
// This needs to happen before G_CheckCommandLine() because G_GameExit()
// accesses g_player[0].
@ -6334,9 +6326,6 @@ int app_main(int argc, const char * const*argv)
Bexit(2);
}
if (Bstrcmp(g_setupFileName, SETUPFILENAME))
initprintf("Using config file \"%s\".\n",g_setupFileName);
G_ScanGroups();
#ifdef STARTUP_SETUP_WINDOW

View file

@ -1,39 +0,0 @@
//-------------------------------------------------------------------------
/*
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.
*/
//-------------------------------------------------------------------------
//****************************************************************************
//
// gamedefs.h
//
// common defines between the game and the setup program
//
//****************************************************************************
#ifndef gamedefs_public_h_
#define gamedefs_public_h_
// config file name
#define SETUPFILENAME APPBASENAME ".cfg"
#endif

View file

@ -134,7 +134,4 @@ int16_t g_blimpSpawnItems[15] =
char CheatKeys[2] = { sc_D, sc_N };
char g_setupFileName[BMAX_PATH] = SETUPFILENAME;
END_DUKE_NS

View file

@ -163,7 +163,6 @@ extern double g_gameUpdateAvgTime;
#ifndef global_c_
extern char CheatKeys[2];
extern char g_gametypeNames[MAXGAMETYPES][33];
extern char g_setupFileName[BMAX_PATH];
extern char g_skillNames[MAXSKILLS][33];
extern char g_volumeNames[MAXVOLUMES][33];

View file

@ -3215,7 +3215,7 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry)
FX_StopAllSounds();
S_ClearSoundLocks();
if (mus_enabled)
if (MusicEnabled())
S_RestartMusic();
}
else if (entry == &ME_SAVESETUP_CLEANUP)

View file

@ -380,7 +380,7 @@ static int osdcmd_restartsound(osdcmdptr_t UNUSED(parm))
FX_StopAllSounds();
S_ClearSoundLocks();
if (mus_enabled)
if (MusicEnabled())
S_RestartMusic();
return OSDCMD_OK;

View file

@ -1319,7 +1319,7 @@ void G_NewGame(int volumeNum, int levelNum, int skillNum)
gameHandleEvents();
if (ud.skill_voice > 0 && snd_enabled)
if (ud.skill_voice > 0 && SoundEnabled())
{
while (FX_SoundActive(ud.skill_voice))
gameHandleEvents();

View file

@ -2448,7 +2448,7 @@ static void postloadplayer(int32_t savegamep)
else
S_ContinueLevelMusic();
if (mus_enabled)
if (MusicEnabled())
S_PauseMusic(false);
g_player[myconnectindex].ps->gm = MODE_GAME;

View file

@ -2198,7 +2198,7 @@ void G_BonusScreen(int32_t bonusonly)
videoClearScreen(0);
G_DisplayMPResultsScreen();
if (mus_enabled)
if (MusicEnabled())
S_PlaySound(BONUSMUSIC);
videoNextPage();
@ -2239,7 +2239,7 @@ void G_BonusScreen(int32_t bonusonly)
gametext_center_shade(192, "Press any key or button to continue", quotepulseshade);
if (mus_enabled)
if (MusicEnabled())
S_PlaySound(BONUSMUSIC);
videoNextPage();

View file

@ -2605,7 +2605,7 @@ void P_HandleSharedKeys(int playerNum)
}
else
{
if (mus_enabled) S_PauseMusic(false);
if (MusicEnabled()) S_PauseMusic(false);
S_PauseSounds(false);

View file

@ -230,7 +230,7 @@ void S_MenuSound(void)
static int S_PlayMusic(const char *fn)
{
if (!mus_enabled)
if (!MusicEnabled())
return 0;
if (fn == NULL)
@ -664,7 +664,7 @@ int S_PlaySound3D(int num, int spriteNum, const vec3_t *pos)
{
int32_t j = VM_OnEventWithReturn(EVENT_SOUND, spriteNum, screenpeek, num);
if ((j == -1 && num != -1) || !snd_enabled) // check that the user returned -1, but only if -1 wasn't playing already (in which case, warn)
if ((j == -1 && num != -1) || !SoundEnabled()) // check that the user returned -1, but only if -1 wasn't playing already (in which case, warn)
return -1;
int const sndNum = j;
@ -804,7 +804,7 @@ int S_PlaySound(int num)
{
int sndnum = VM_OnEventWithReturn(EVENT_SOUND, g_player[screenpeek].ps->i, screenpeek, num);
if ((sndnum == -1 && num != -1) || !snd_enabled) // check that the user returned -1, but only if -1 wasn't playing already (in which case, warn)
if ((sndnum == -1 && num != -1) || !SoundEnabled()) // check that the user returned -1, but only if -1 wasn't playing already (in which case, warn)
return -1;
num = sndnum;

View file

@ -33,86 +33,8 @@ BEGIN_RR_NS
int32_t g_commandSetup = 0;
int32_t g_noSetup = 0;
int32_t g_noSound = 0;
int32_t g_noMusic = 0;
const char *CommandMap = NULL;
const char *CommandName = NULL;
int32_t g_fakeMultiMode = 0;
void G_ShowParameterHelp(void)
{
static char const s[] = "Usage: " APPBASENAME " [files] [options]\n"
"Example: " APPBASENAME " -usecwd -cfg myconfig.cfg -map nukeland.map\n\n"
"Files can be of type [grp|zip|map|con|def]\n"
"\n"
"-cfg [file.cfg]\tUse an alternate configuration file\n"
#ifdef HAVE_CLIPSHAPE_FEATURE
"-clipmap [file.map]\tLoad an additional clipping map for use with clipshape\n"
#endif
"-connect [host]\tConnect to a multiplayer game\n"
"-c#\t\tMultiplayer mode #, 1 = DM, 2 = Co-op, 3 = DM(no spawn)\n"
"-d [file.edm or #]\tPlay a demo\n"
"-g [file.grp]\tLoad additional game data\n"
"-h [file.def]\tLoad an alternate definitions file\n"
"-j [dir]\t\tAdd a directory to " APPNAME "'s search list\n"
"-l#\t\tStart game on level #, see -v\n"
"-map [file.map]\tLoad an external map file\n"
"-mh [file.def]\tInclude an additional definitions module\n"
"-mx [file.con]\tInclude an additional CON script module\n"
"-m\t\tDisable enemies\n"
"-rts [file.rts]\tLoad a custom Remote Ridicule sound bank\n"
"-r\t\tRecord demo\n"
"-s#\t\tStart game on skill level #\n"
"-server\t\tStart a multiplayer server\n"
#ifdef STARTUP_SETUP_WINDOW
"-setup/nosetup\tEnable or disable startup window\n"
#endif
"-t#\t\tRespawn mode: 1 = enemies, 2 = weapons, 3 = items, x = all\n"
"-usecwd\t\tRead data and configuration from current directory\n"
"-u#########\tUser's favorite weapon order (default: 3425689071)\n"
"-v#\t\tStart game on episode #, see -l\n"
"-x [game.con]\tLoad custom CON script\n"
"-#\t\tLoad and run a game from slot # (0-9)\n"
// "\n-?/--help\tDisplay this help message and exit\n"
"\nSee " APPBASENAME " -debughelp for additional parameters for debugging"
;
#ifdef WM_MSGBOX_WINDOW
Bsnprintf(tempbuf, sizeof(tempbuf), HEAD2 " %s", s_buildRev);
wm_msgbox(tempbuf, s);
#else
initprintf("%s\n", s);
#endif
}
void G_ShowDebugHelp(void)
{
static char const s[] = "Usage: " APPBASENAME " [files] [options]\n"
"\n"
#if 0
"-a\t\tUse fake player AI (fake multiplayer only)\n"
#endif
"-cachesize #\tSet cache size in kB\n"
"-game_dir [dir]\tSpecify game data directory\n"
"-gamegrp \tSelect main grp file\n"
"-name [name]\tPlayer name in multiplayer\n"
"-noautoload\tDisable loading from autoload directory\n"
#if defined RENDERTYPEWIN
"-nodinput\t\tDisable DirectInput (joystick) support\n"
#endif
"-nologo\t\tSkip intro anim\n"
"-ns\t\tDisable sound\n"
"-nm\t\tDisable music\n"
"-q#\t\tFake multiplayer with # players\n"
"-z#/-condebug\tEnable line-by-line CON compile debugging at level #\n"
"-conversion YYYYMMDD\tSelects CON script version for compatibility with older mods\n"
"-rotatesprite-no-widescreen\tStretch screen drawing from scripts to fullscreen\n"
;
#ifdef WM_MSGBOX_WINDOW
Bsnprintf(tempbuf, sizeof(tempbuf), HEAD2 " %s", s_buildRev);
wm_msgbox(tempbuf, s);
#else
initprintf("%s\n", s);
#endif
}
static void G_AddDemo(const char* param)
{
@ -147,31 +69,11 @@ static void G_AddDemo(const char* param)
void G_CheckCommandLine(int32_t argc, char const * const * argv)
{
// Stuff to sort out later.
#if 0
int16_t i = 1, j;
const char *c, *k;
ud.fta_on = 1;
ud.god = 0;
ud.m_respawn_items = 0;
ud.m_respawn_monsters = 0;
ud.m_respawn_inventory = 0;
ud.warp_on = 0;
ud.cashman = 0;
ud.m_player_skill = ud.player_skill = 2;
memcpy(g_player[0].wchoice, "\3\4\5\7\0x8\6\0\2\0x9\1", 10);
wchoice.Callback();
#ifdef HAVE_CLIPSHAPE_FEATURE
// pre-form the default 10 clipmaps
for (j = '0'; j<='9'; ++j)
{
char clipshape[16] = "_clipshape0.map";
clipshape[10] = j;
g_clipMapFiles.append(Xstrdup(clipshape));
}
#endif
if (argc > 1)
{
@ -192,247 +94,6 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
{
shortopt = 0;
if (!Bstrcasecmp(c+1, "?") || !Bstrcasecmp(c+1, "help") || !Bstrcasecmp(c+1, "-help"))
{
G_ShowParameterHelp();
Bexit(0);
}
if (!Bstrcasecmp(c+1, "addon"))
{
if (argc > i+1)
{
g_addonNum = Batoi(argv[i+1]);
if (g_addonNum > ADDON_NONE && g_addonNum < NUMADDONS)
g_noSetup = 1;
else g_addonNum = ADDON_NONE;
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "debughelp") || !Bstrcasecmp(c+1, "-debughelp"))
{
G_ShowDebugHelp();
Bexit(0);
}
if (!Bstrcasecmp(c+1, "grp") || !Bstrcasecmp(c+1, "g"))
{
if (argc > i+1)
{
G_AddGroup(argv[i+1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "game_dir"))
{
if (argc > i+1)
{
Bstrncpyz(g_modDir, argv[i+1], sizeof(g_modDir));
G_AddPath(argv[i+1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "cfg"))
{
if (argc > i+1)
{
Bstrcpy(g_setupFileName, argv[i+1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "gamegrp"))
{
if (argc > i+1)
{
clearGrpNamePtr();
g_grpNamePtr = dup_filename(argv[i+1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "nam"))
{
g_gameType = GAMEFLAG_NAM;
i++;
continue;
}
if (!Bstrcasecmp(c+1, "napalm"))
{
g_gameType = GAMEFLAG_NAM|GAMEFLAG_NAPALM;
i++;
continue;
}
if (!Bstrcasecmp(c+1, "setup"))
{
g_commandSetup = TRUE;
i++;
continue;
}
if (!Bstrcasecmp(c+1, "nosetup"))
{
g_noSetup = 1;
g_commandSetup = 0;
i++;
continue;
}
#ifndef NETCODE_DISABLE
if (!Bstrcasecmp(c+1, "net"))
{
G_GameExit("EDuke32 no longer supports legacy networking.\n\n"
"If using YANG or other launchers that only support legacy netplay, download an older build of EDuke32. "
"Otherwise, run the following:\n\n"
"eduke32 -server\n\n"
"Other clients can then connect by typing \"connect [host]\" in the console.\n\n"
"EDuke32 will now close.");
}
#endif
if (!Bstrcasecmp(c+1, "port"))
{
if (argc > i+1)
{
g_netPort = Batoi(argv[i+1]);
i++;
}
i++;
continue;
}
#ifndef NETCODE_DISABLE
if (!Bstrcasecmp(c+1, "server"))
{
g_networkMode = NET_SERVER;
g_noSetup = g_noLogo = TRUE;
i++;
continue;
}
//if (!Bstrcasecmp(c+1, "dedicated"))
//{
// g_networkMode = NET_DEDICATED_SERVER;
// g_noSetup = g_noLogo = TRUE;
// i++;
// continue;
//}
if (!Bstrcasecmp(c+1, "connect"))
{
if (argc > i+1)
{
Net_Connect(argv[i+1]);
g_noSetup = g_noLogo = TRUE;
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "password"))
{
if (argc > i+1)
{
Bstrncpyz(g_netPassword, argv[i+1], sizeof(g_netPassword));
i++;
}
i++;
continue;
}
#endif
if (!Bstrcasecmp(c+1, "name"))
{
if (argc > i+1)
{
CommandName = argv[i+1];
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "map"))
{
if (argc > i+1)
{
CommandMap = argv[i+1];
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "rts"))
{
if (argc > i+1)
{
RTS_Init(argv[i+1]);
initprintf("Using RTS file \"%s\".\n", argv[i + 1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "x"))
{
if (argc > i+1)
{
G_AddCon(argv[i+1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "mx"))
{
if (argc > i+1)
{
G_AddConModule(argv[i+1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "h"))
{
if (argc > i+1)
{
G_AddDef(argv[i+1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "mh"))
{
if (argc > i+1)
{
G_AddDefModule(argv[i+1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "j"))
{
if (argc > i+1)
{
G_AddPath(argv[i+1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "d"))
{
if (argc > i+1)
{
G_AddDemo(argv[i+1]);
i++;
}
i++;
continue;
}
#ifdef HAVE_CLIPSHAPE_FEATURE
if (!Bstrcasecmp(c+1, "clipmap"))
{
@ -451,53 +112,6 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
i++;
continue;
}
if (!Bstrcasecmp(c+1, "nologo"))
{
g_noLogo = 1;
i++;
continue;
}
if (!Bstrcasecmp(c+1, "usecwd"))
{
i++;
continue;
}
if (!Bstrcasecmp(c+1, "cachesize"))
{
if (argc > i+1)
{
// No longer supported.
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1, "noinstancechecking"))
{
i++;
continue;
}
#if defined(RENDERTYPEWIN) && defined(USE_OPENGL)
if (!Bstrcasecmp(c+1, "forcegl"))
{
forcegl = 1;
i++;
continue;
}
#endif
// the following two dummy entries allow us to serve as a drop-in replacement for NAM on Steam
if (!Bstrcasecmp(c+1, "noconsole"))
{
i++;
continue;
}
if (!Bstrcasecmp(c+1, "conf"))
{
if (argc > i+1)
i++;
i++;
continue;
}
}
if ((*c == '-')
@ -526,63 +140,7 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
}
ud.m_coop--;
break;
case 'd':
{
c++;
if (*c)
G_AddDemo(c);
break;
}
case 'g':
c++;
if (*c)
G_AddGroup(c);
break;
case 'h':
c++;
if (*c)
G_AddDef(c);
break;
case 'j':
c++;
if (*c)
G_AddPath(c);
break;
case 'l':
// NOTE: Overlaid with -Lopts=... options for Lunatic, hence the check.
if (Bisdigit(c[1]))
{
ud.warp_on = 1;
c++;
ud.m_level_number = ud.level_number = ((unsigned) (Batoi(c)-1))%MAXLEVELS;
}
break;
case 'm':
if (*(c+1) != 'a' && *(c+1) != 'A')
{
ud.m_monsters_off = 1;
ud.m_player_skill = ud.player_skill = 0;
initprintf("Monsters off.\n");
}
break;
case 'n':
c++;
if (*c == 's' || *c == 'S')
{
g_noSound = 2;
initprintf("Sound off.\n");
}
else if (*c == 'm' || *c == 'M')
{
g_noMusic = 1;
initprintf("Music off.\n");
}
else
{
G_ShowParameterHelp();
exit(-1);
}
break;
case 'q':
if (*(++c) == 0)
{
@ -636,8 +194,6 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
}
initprintf("Respawn on.\n");
break;
case 'u':
break;
case 'v':
c++;
ud.warp_on = 1;
@ -646,11 +202,6 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
case 'w':
cl_showcoords = 1;
break;
case 'x':
c++;
if (*c)
G_AddCon(c);
break;
case 'z':
c++;
g_scriptDebug = Batoi(c);
@ -662,46 +213,6 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
break;
}
}
else
{
shortopt = 0;
k = Bstrrchr(c, '.');
if (k)
{
if (!Bstrcasecmp(k, ".map"))
{
CommandMap = argv[i++];
continue;
}
if (!Bstrcasecmp(k, ".grp") || !Bstrcasecmp(k, ".zip") || !Bstrcasecmp(k, ".pk3") || !Bstrcasecmp(k, ".pk4"))
{
G_AddGroup(argv[i++]);
continue;
}
if (!Bstrcasecmp(k, ".con"))
{
clearScriptNamePtr();
g_scriptNamePtr = dup_filename(argv[i++]);
initprintf("Using CON file \"%s\".\n", g_scriptNamePtr);
continue;
}
if (!Bstrcasecmp(k, ".def"))
{
clearDefNamePtr();
g_defNamePtr = dup_filename(argv[i++]);
initprintf("Using DEF file \"%s\".\n", g_defNamePtr);
continue;
}
if (!Bstrcasecmp(k, ".rts"))
{
RTS_Init(argv[i]);
initprintf("Using RTS file \"%s\".\n", argv[i]);
i++;
continue;
}
}
}
if (!shortopt || ignored_short_opt)
initprintf("Warning: ignored application parameter \"%s\".\n", oc);
@ -709,5 +220,6 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
i++;
} while (i < argc);
}
#endif
}
END_RR_NS

View file

@ -33,10 +33,6 @@ extern void G_ShowDebugHelp(void);
extern int32_t g_commandSetup;
extern int32_t g_noSetup;
extern int32_t g_noSound;
extern int32_t g_noMusic;
extern const char *CommandMap;
extern const char *CommandName;
extern int32_t g_fakeMultiMode;
END_RR_NS

View file

@ -5961,7 +5961,7 @@ static int32_t g_RTSPlaying;
// Returns: started playing?
extern int G_StartRTS(int lumpNum, int localPlayer)
{
if (!adult_lockout && snd_enabled &&
if (!adult_lockout && SoundEnabled() &&
RTS_IsInitialized() && g_RTSPlaying == 0 && (snd_speech & (localPlayer ? 1 : 4)))
{
char *const pData = (char *)RTS_GetSound(lumpNum - 1);
@ -6394,7 +6394,7 @@ FAKE_F3:
Menu_Change(MENU_SOUND_INGAME);
}
if (KB_UnBoundKeyPressed(sc_F5) && mus_enabled)
if (KB_UnBoundKeyPressed(sc_F5) && MusicEnabled())
{
map_t *const pMapInfo = &g_mapInfo[g_musicIndex];
char *const musicString = apStrings[QUOTE_MUSIC];
@ -7427,17 +7427,8 @@ static void G_Startup(void)
G_PostCreateGameState();
if (g_netServer || ud.multimode > 1) G_CheckGametype();
//errr... what??? Why does this clobber the user setting? Well, it needs to be redone anyway, preferably at a lower level.
//if (g_noSound) snd_enabled = 0;
//if (g_noMusic) mus_enabled = 0;
if (CommandName)
if (userConfig.CommandMap.IsNotEmpty())
{
playername = CommandName;
}
if (CommandMap)
{
if (VOLUMEONE)
{
initprintf("The -map option is available in the registered version only!\n");
@ -7449,7 +7440,7 @@ static void G_Startup(void)
boardfilename[0] = '/';
boardfilename[1] = 0;
Bstrcat(boardfilename, CommandMap);
Bstrcat(boardfilename, userConfig.CommandMap);
dot = Bstrrchr(boardfilename,'.');
slash = Bstrrchr(boardfilename,'/');
@ -7677,6 +7668,7 @@ int app_main(int argc, char const * const * argv)
g_skillCnt = 4;
ud.multimode = 1;
ud.m_monsters_off = userConfig.nomonsters;
g_movesPerPacket = 1;
bufferjitter = 1;
@ -7710,9 +7702,6 @@ int app_main(int argc, char const * const * argv)
Bexit(2);
}
if (Bstrcmp(g_setupFileName, SETUPFILENAME))
initprintf("Using config file \"%s\".\n",g_setupFileName);
G_ScanGroups();
#ifdef STARTUP_SETUP_WINDOW

View file

@ -1,43 +0,0 @@
//-------------------------------------------------------------------------
/*
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.
*/
//-------------------------------------------------------------------------
//****************************************************************************
//
// gamedefs.h
//
// common defines between the game and the setup program
//
//****************************************************************************
#ifndef gamedefs_public_h_
#define gamedefs_public_h_
BEGIN_RR_NS
// config file name
#define SETUPFILENAME APPBASENAME ".cfg"
END_RR_NS
#endif

View file

@ -124,6 +124,4 @@ int16_t g_blimpSpawnItems[15] =
char CheatKeys[2] = { sc_D, sc_N };
char g_setupFileName[BMAX_PATH] = SETUPFILENAME;
END_RR_NS

View file

@ -261,7 +261,6 @@ extern float g_gameUpdateAvgTime;
#ifndef global_c_
extern char CheatKeys[2];
extern char g_gametypeNames[MAXGAMETYPES][33];
extern char g_setupFileName[BMAX_PATH];
extern char g_skillNames[MAXSKILLS][33];
extern char g_volumeNames[MAXVOLUMES][33];

View file

@ -3591,7 +3591,7 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry)
FX_StopAllSounds();
S_ClearSoundLocks();
if (mus_enabled)
if (MusicEnabled())
S_RestartMusic();
}
else if (entry == &ME_SAVESETUP_CLEANUP)
@ -5705,7 +5705,7 @@ static void M_RunMenu_CdPlayer(Menu_t *cm, MenuMenu_t *menu, const vec2_t origin
S_PlaySound(RR ? 341 : PISTOL_BODYHIT);
if (mus_enabled)
if (MusicEnabled())
{
S_StopMusic();
S_PlayRRMusic(2+menu->currentEntry);
@ -7041,7 +7041,7 @@ static void Menu_RunInput(Menu_t *cm)
currentry = Menu_RunInput_Menu_Movement(menu, MM_Up);
if (mus_enabled)
if (MusicEnabled())
{
S_StopMusic();
S_PlayRRMusic(2+menu->currentEntry);
@ -7056,7 +7056,7 @@ static void Menu_RunInput(Menu_t *cm)
currentry = Menu_RunInput_Menu_Movement(menu, MM_Down);
if (mus_enabled)
if (MusicEnabled())
{
S_StopMusic();
S_PlayRRMusic(2+menu->currentEntry);
@ -7068,7 +7068,7 @@ static void Menu_RunInput(Menu_t *cm)
menu->currentEntry = 0;
S_PlaySound(RR ? 335 : KICK_HIT);
if (mus_enabled)
if (MusicEnabled())
{
S_StopMusic();
S_PlayRRMusic(2+menu->currentEntry);
@ -7080,7 +7080,7 @@ static void Menu_RunInput(Menu_t *cm)
menu->currentEntry = 1;
S_PlaySound(RR ? 335 : KICK_HIT);
if (mus_enabled)
if (MusicEnabled())
{
S_StopMusic();
S_PlayRRMusic(2+menu->currentEntry);
@ -7092,7 +7092,7 @@ static void Menu_RunInput(Menu_t *cm)
menu->currentEntry = 2;
S_PlaySound(RR ? 335 : KICK_HIT);
if (mus_enabled)
if (MusicEnabled())
{
S_StopMusic();
S_PlayRRMusic(2+menu->currentEntry);
@ -7104,7 +7104,7 @@ static void Menu_RunInput(Menu_t *cm)
menu->currentEntry = 3;
S_PlaySound(RR ? 335 : KICK_HIT);
if (mus_enabled)
if (MusicEnabled())
{
S_StopMusic();
S_PlayRRMusic(2+menu->currentEntry);
@ -7116,7 +7116,7 @@ static void Menu_RunInput(Menu_t *cm)
menu->currentEntry = 4;
S_PlaySound(RR ? 335 : KICK_HIT);
if (mus_enabled)
if (MusicEnabled())
{
S_StopMusic();
S_PlayRRMusic(2+menu->currentEntry);
@ -7128,7 +7128,7 @@ static void Menu_RunInput(Menu_t *cm)
menu->currentEntry = 5;
S_PlaySound(RR ? 335 : KICK_HIT);
if (mus_enabled)
if (MusicEnabled())
{
S_StopMusic();
S_PlayRRMusic(2+menu->currentEntry);
@ -7140,7 +7140,7 @@ static void Menu_RunInput(Menu_t *cm)
menu->currentEntry = 6;
S_PlaySound(RR ? 335 : KICK_HIT);
if (mus_enabled)
if (MusicEnabled())
{
S_StopMusic();
S_PlayRRMusic(2+menu->currentEntry);
@ -7152,7 +7152,7 @@ static void Menu_RunInput(Menu_t *cm)
menu->currentEntry = 7;
S_PlaySound(RR ? 335 : KICK_HIT);
if (mus_enabled)
if (MusicEnabled())
{
S_StopMusic();
S_PlayRRMusic(2+menu->currentEntry);

View file

@ -375,7 +375,7 @@ static int osdcmd_restartsound(osdcmdptr_t UNUSED(parm))
FX_StopAllSounds();
S_ClearSoundLocks();
if (mus_enabled)
if (MusicEnabled())
S_RestartMusic();
return OSDCMD_OK;

View file

@ -1870,7 +1870,7 @@ void G_NewGame(int volumeNum, int levelNum, int skillNum)
G_HandleAsync();
if (g_skillSoundVoice >= 0 && snd_enabled)
if (g_skillSoundVoice >= 0 && SoundEnabled())
{
while (FX_SoundActive(g_skillSoundVoice))
G_HandleAsync();

View file

@ -1879,7 +1879,7 @@ static void postloadplayer(int32_t savegamep)
S_PlayLevelMusicOrNothing(musicIdx);
}
if (mus_enabled)
if (MusicEnabled())
S_PauseMusic(false);
g_player[myconnectindex].ps->gm = MODE_GAME;

View file

@ -2224,7 +2224,7 @@ void G_BonusScreen(int32_t bonusonly)
videoClearScreen(0);
G_DisplayMPResultsScreen();
if (mus_enabled)
if (MusicEnabled())
S_PlaySound(BONUSMUSIC);
videoNextPage();
@ -2268,7 +2268,7 @@ void G_BonusScreen(int32_t bonusonly)
gametext_center_shade(192, "Press any key or button to continue", quotepulseshade);
if (mus_enabled)
if (MusicEnabled())
S_PlaySound(BONUSMUSIC);
}
else
@ -2818,7 +2818,7 @@ void G_BonusScreenRRRA(int32_t bonusonly)
videoClearScreen(0);
G_DisplayMPResultsScreen();
if (mus_enabled)
if (MusicEnabled())
S_PlaySound(BONUSMUSIC);
videoNextPage();

View file

@ -3653,7 +3653,7 @@ void P_HandleSharedKeys(int playerNum)
}
else
{
if (mus_enabled) S_PauseMusic(false);
if (MusicEnabled()) S_PauseMusic(false);
S_PauseSounds(false);

View file

@ -186,7 +186,7 @@ void S_MenuSound(void)
static int S_PlayMusic(const char *fn, int loop)
{
if (!mus_enabled)
if (!MusicEnabled())
return 0;
if (fn == NULL)
@ -602,7 +602,7 @@ int S_PlaySound3D(int num, int spriteNum, const vec3_t *pos)
{
int32_t j;
if (!snd_enabled) // check that the user returned -1, but only if -1 wasn't playing already (in which case, warn)
if (!SoundEnabled()) // check that the user returned -1, but only if -1 wasn't playing already (in which case, warn)
return -1;
int const sndNum = num;
@ -741,7 +741,7 @@ int S_PlaySound(int num)
{
int sndnum;
if (!snd_enabled) // check that the user returned -1, but only if -1 wasn't playing already (in which case, warn)
if (!SoundEnabled()) // check that the user returned -1, but only if -1 wasn't playing already (in which case, warn)
return -1;
sound_t & snd = g_sounds[num];

View file

@ -109,8 +109,6 @@ const char* G_DefFile(void);
const char* AppProperName = "VoidSW";
const char* AppTechnicalName = "voidsw";
#define SETUPFILENAME "voidsw.cfg"
char setupfilename[BMAX_PATH] = SETUPFILENAME;
#if DEBUG
#define BETA 0
@ -2059,7 +2057,7 @@ MenuLevel(void)
DSPRINTF(ds,"MenuLevel...");
MONO_PRINT(ds);
if (mus_enabled)
if (MusicEnabled())
{
PlaySong(NULL, RedBookSong[0], TRUE, FALSE);
}
@ -2473,7 +2471,7 @@ BonusScreen(PLAYERp pp)
totalclock = ototalclock = 0;
limit = synctics;
if (mus_enabled)
if (MusicEnabled())
{
PlaySong(voc[DIGI_ENDLEV].name, 3, TRUE, TRUE);
}
@ -2791,7 +2789,7 @@ StatScreen(PLAYERp mpp)
inputState.ClearKeyStatus(KEYSC_SPACE);
inputState.ClearKeyStatus(KEYSC_ENTER);
if (mus_enabled)
if (MusicEnabled())
{
PlaySong(voc[DIGI_ENDLEV].name, 3, TRUE, TRUE);
}
@ -3571,6 +3569,7 @@ int32_t app_main(int32_t argc, char const * const * argv)
}
#endif
#if 0
for (cnt = 1; cnt < argc; cnt++)
{
char const *arg = argv[cnt];
@ -4007,7 +4006,7 @@ int32_t app_main(int32_t argc, char const * const * argv)
G_AddDefModule(arg+1);
}
}
#endif
Control(argc, argv);
return 0;

View file

@ -3282,7 +3282,7 @@ MNU_DoButton(MenuItem_p item, SWBOOL draw)
snd_enabled = state = buttonsettings[item->button];
if (snd_enabled != last_value)
{
if (!snd_enabled)
if (!SoundEnabled())
StopFX();
}
break;
@ -3293,7 +3293,7 @@ MNU_DoButton(MenuItem_p item, SWBOOL draw)
{
SWBOOL bak;
if (mus_enabled)
if (MusicEnabled())
{
bak = DemoMode;
PlaySong(LevelSong, RedBookSong[Level], TRUE, TRUE);

View file

@ -34,6 +34,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "actor.h"
#include "track.h"
#include "sector.h"
#include "gamecontrol.h"
BEGIN_SW_NS
@ -818,7 +819,7 @@ int DoDeathSpecial(short SpriteNum)
DoMatchEverything(NULL, sp->lotag, ON);
if (!SW_SHAREWARE && mus_enabled && !alreadydid)
if (!SW_SHAREWARE && MusicEnabled() && !alreadydid)
{
PlaySong(0, RedBookSong[Level], TRUE, TRUE);
alreadydid = TRUE;

View file

@ -408,7 +408,7 @@ extern short Level;
SWBOOL
PlaySong(char *song_file_name, int cdaudio_track, SWBOOL loop, SWBOOL restart)
{
if (!mus_enabled)
if (!MusicEnabled())
{
return FALSE;
}
@ -551,7 +551,7 @@ StopSong(void)
void
PauseSong(SWBOOL pauseon)
{
if (!mus_enabled) return;
if (!MusicEnabled()) return;
if (SongType == SongTypeWave && SongVoice >= 0)
{
@ -816,7 +816,7 @@ PlaySound(int num, int *x, int *y, int *z, Voc3D_Flags flags)
if (Prediction)
return -1;
if (!snd_enabled)
if (!SoundEnabled())
return -1;
PRODUCTION_ASSERT(num >= 0 && num < DIGI_MAX);
@ -1045,7 +1045,7 @@ void PlaySoundRTS(int rts_num)
char *rtsptr;
int voice=-1;
if (!RTS_IsInitialized() || !snd_enabled)
if (!RTS_IsInitialized() || !SoundEnabled())
return;
rtsptr = (char *)RTS_GetSound(rts_num - 1);

View file

@ -37,6 +37,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "track.h"
#include "weapon.h"
#include "sector.h"
#include "gamecontrol.h"
BEGIN_SW_NS
@ -802,7 +803,7 @@ int DoSumoDeathMelt(short SpriteNum)
u->ID = 0;
DoMatchEverything(NULL, sp->lotag, ON);
if (!SW_SHAREWARE && mus_enabled && !alreadydid)
if (!SW_SHAREWARE && MusicEnabled() && !alreadydid)
{
PlaySong(0, RedBookSong[Level], TRUE, TRUE);
alreadydid = TRUE;
@ -881,7 +882,7 @@ BossHealthMeter(void)
if (i == 0 && !serpwasseen)
{
serpwasseen = TRUE;
if (!SW_SHAREWARE && mus_enabled)
if (!SW_SHAREWARE && MusicEnabled())
{
PlaySong(0, 13, TRUE, TRUE);
}
@ -889,7 +890,7 @@ BossHealthMeter(void)
else if (i == 1 && !sumowasseen)
{
sumowasseen = TRUE;
if (!SW_SHAREWARE && mus_enabled)
if (!SW_SHAREWARE && MusicEnabled())
{
PlaySong(0, 13, TRUE, TRUE);
}
@ -897,7 +898,7 @@ BossHealthMeter(void)
else if (i == 2 && !zillawasseen)
{
zillawasseen = TRUE;
if (!SW_SHAREWARE && mus_enabled)
if (!SW_SHAREWARE && MusicEnabled())
{
PlaySong(0, 13, TRUE, TRUE);
}

View file

@ -36,6 +36,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "actor.h"
#include "track.h"
#include "fx_man.h"
#include "gamecontrol.h"
BEGIN_SW_NS
@ -777,7 +778,7 @@ int DoZillaDeathMelt(short SpriteNum)
RESET(u->Flags, SPR_JUMPING|SPR_FALLING|SPR_MOVED);
//DoMatchEverything(NULL, sp->lotag, ON);
if (!SW_SHAREWARE && mus_enabled && !alreadydid)
if (!SW_SHAREWARE && MusicEnabled() && !alreadydid)
{
PlaySong(0, RedBookSong[Level], TRUE, TRUE);
alreadydid = TRUE;