Fix console colors not working before an iwad has been selected

This commit is contained in:
Magnus Norddahl 2025-01-06 06:22:31 +01:00
commit 306303b9a6
16 changed files with 268 additions and 127 deletions

View file

@ -61,6 +61,7 @@ struct WadStuff
extern FString endoomName;
extern bool batchrun;
extern bool RunningAsTool;
extern float menuBlurAmount;
extern bool generic_ui;
extern bool special_i;

View file

@ -53,6 +53,7 @@
#include "texturemanager.h"
#include "printf.h"
#include "palentry.h"
#include "i_interface.h"
#include "fontinternals.h"
@ -784,6 +785,41 @@ static void CalcDefaultTranslation(FFont* base, int index)
PalEntry V_LogColorFromColorRange (EColorRange range)
{
// Console wants to use colors before we loaded anything and we can't retroactively apply them like we can for the console in the game
if (RunningAsTool)
{
static std::vector<PalEntry> colors =
{
0x00cc3333,
0x00d2b48c,
0x00cccccc,
0x0000cc00,
0x00996633,
0x00ffcc00,
0x00ff5566,
0x009999ff,
0x00ffaa00,
0x00dfdfdf,
0x00eeee33,
0x00dfdfdf,
0x00000000,
0x0033eeff,
0x00ffcc99,
0x00d1d8a8,
0x00008c00,
0x00800000,
0x00663333,
0x009966cc,
0x00808080,
0x0000dddd,
0x007c7c98,
0x00d57604,
0x00506cfc,
0x00236773,
};
return (size_t)range >= colors.size() ? DEFAULT_LOG_COLOR : colors[range];
}
if ((unsigned int)range >= TranslationColors.Size())
{ // Return default color
return DEFAULT_LOG_COLOR;

View file

@ -61,6 +61,9 @@ EXTERN_CVAR(Int, vid_defheight)
EXTERN_CVAR(Bool, vid_vsync )
int GameMain();
extern bool RunningAsTool = false;
// ---------------------------------------------------------------------------
@ -528,9 +531,7 @@ void ReleaseApplicationController()
}
}
} // unnamed namespace
int I_GameMain(int argc, char** argv)
void InitArgs(int argc, char** argv)
{
for (int i = 0; i < argc; ++i)
{
@ -549,6 +550,13 @@ int I_GameMain(int argc, char** argv)
s_argv.Push(argument);
}
}
} // unnamed namespace
int I_GameMain(int argc, char** argv)
{
InitArgs(argc, argv);
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@ -574,7 +582,28 @@ int I_GameMain(int argc, char** argv)
return EXIT_SUCCESS;
}
// Note: no idea if this actually works as I don't have a macOS machine nowadays.
// It is possible this function should do exactly the same as the linux/posix version.
// Not really sure how Cocoa initialization and macOS bundles affects console applications on macOS, if at all.
int I_ToolMain(int argc, char** argv)
{
return I_GameMain(argc, argv);
RunningAsTool = true;
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
seteuid(getuid());
// Set LC_NUMERIC environment variable in case some library decides to
// clear the setlocale call at least this will be correct.
// Note that the LANG environment variable is overridden by LC_*
setenv("LC_NUMERIC", "C", 1);
setlocale(LC_ALL, "C");
Args = new FArgs(argc, argv);
NSString* exePath = [[NSBundle mainBundle] executablePath];
progdir = [[exePath stringByDeletingLastPathComponent] UTF8String];
progdir += "/";
return GameMain();
}

View file

@ -54,7 +54,7 @@ void CalculateCPUSpeed()
PerfToSec = 1.0 / frequency;
PerfToMillisec = 1000.0 / frequency;
if (!batchrun)
if (!batchrun && !RunningAsTool)
{
Printf("CPU speed: %.0f MHz\n", 0.001 / PerfToMillisec);
}

View file

@ -53,13 +53,8 @@
#include "i_interface.h"
#include "printf.h"
// MACROS ------------------------------------------------------------------
// TYPES -------------------------------------------------------------------
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
extern "C" int cc_install_handlers(int, char**, int, int*, const char*, int(*)(char*, char*));
extern bool RunningAsTool;
#ifdef __APPLE__
void Mac_I_FatalError(const char* errortext);
@ -69,26 +64,11 @@ void Mac_I_FatalError(const char* errortext);
void Linux_I_FatalError(const char* errortext);
#endif
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
int GameMain();
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
// PUBLIC DATA DEFINITIONS -------------------------------------------------
FString sys_ostype;
// The command line arguments.
FArgs *Args;
// PRIVATE DATA DEFINITIONS ------------------------------------------------
// CODE --------------------------------------------------------------------
static int GetCrashInfo (char *buffer, char *end)
{
if (sysCallbacks.CrashInfo) sysCallbacks.CrashInfo(buffer, end - buffer, "\n");
@ -146,7 +126,7 @@ void I_DetectOS()
void I_StartupJoysticks();
int I_GameMain(int argc, char** argv)
void InitCrashReporter()
{
#if !defined (__APPLE__)
{
@ -154,35 +134,36 @@ int I_GameMain(int argc, char** argv)
cc_install_handlers(argc, argv, 4, s, GAMENAMELOWERCASE "-crash.log", GetCrashInfo);
}
#endif // !__APPLE__
}
printf(GAMENAME" %s - %s - SDL version\nCompiled on %s\n",
GetVersionString(), GetGitTime(), __DATE__);
void SetEffectiveUser()
{
seteuid(getuid());
}
seteuid (getuid ());
void InitLocale()
{
// Set LC_NUMERIC environment variable in case some library decides to
// clear the setlocale call at least this will be correct.
// Note that the LANG environment variable is overridden by LC_*
setenv ("LC_NUMERIC", "C", 1);
setlocale (LC_ALL, "C");
if (SDL_Init (0) < 0)
{
fprintf (stderr, "Could not initialize SDL:\n%s\n", SDL_GetError());
return -1;
}
printf("\n");
setenv("LC_NUMERIC", "C", 1);
setlocale(LC_ALL, "C");
}
void InitArgs(int argc, char** argv)
{
Args = new FArgs(argc, argv);
}
void InitExePath()
{
#ifdef PROGDIR
progdir = PROGDIR;
#else
char program[PATH_MAX];
if (realpath (argv[0], program) == NULL)
strcpy (program, argv[0]);
char *slash = strrchr (program, '/');
if (realpath(argv[0], program) == NULL)
strcpy(program, argv[0]);
char* slash = strrchr(program, '/');
if (slash != NULL)
{
*(slash + 1) = '\0';
@ -193,6 +174,26 @@ int I_GameMain(int argc, char** argv)
progdir = "./";
}
#endif
}
int I_GameMain(int argc, char** argv)
{
InitCrashReporter();
SetEffectiveUser();
InitLocale();
printf(GAMENAME" %s - %s - SDL version\nCompiled on %s\n", GetVersionString(), GetGitTime(), __DATE__);
if (SDL_Init (0) < 0)
{
fprintf (stderr, "Could not initialize SDL:\n%s\n", SDL_GetError());
return -1;
}
printf("\n");
InitArgs(argc, argv);
InitExePath();
I_StartupJoysticks();
@ -205,5 +206,13 @@ int I_GameMain(int argc, char** argv)
int I_ToolMain(int argc, char** argv)
{
return I_GameMain(argc, argv);
RunningAsTool = true;
InitCrashReporter();
SetEffectiveUser();
InitLocale();
InitArgs(argc, argv);
InitExePath();
return GameMain();
}

View file

@ -196,7 +196,7 @@ void CalculateCPUSpeed()
PerfAvailable = true;
PerfToSec = .000001/mhz;
PerfToMillisec = PerfToSec*1000.;
if (!batchrun) Printf("CPU speed: %.0f MHz\n", mhz);
if (!batchrun && !RunningAsTool) Printf("CPU speed: %.0f MHz\n", mhz);
close(fd);
#endif
}

View file

@ -95,6 +95,7 @@ void DestroyCustomCursor();
int GameMain();
extern UINT TimerPeriod;
extern bool RunningAsTool;
// The command line arguments.
FArgs *Args;
@ -140,16 +141,15 @@ bool isConsoleApp()
return returnvalue;
}
//==========================================================================
int DoMain (HINSTANCE hInstance)
void InitComAndCommonControls()
{
LONG WinWidth, WinHeight;
int height, width, x, y;
RECT cRect;
TIMECAPS tc;
DEVMODE displaysettings;
InitCommonControls();
if (SUCCEEDED(CoInitialize(nullptr)))
atexit([]() { CoUninitialize(); }); // beware of calling convention.
}
void InitArgs()
{
// Do not use the multibyte __argv here because we want UTF-8 arguments
// and those can only be done by converting the Unicode variants.
Args = new FArgs();
@ -159,6 +159,51 @@ int DoMain (HINSTANCE hInstance)
{
Args->AppendArg(FString(wargv[i]));
}
}
void InitTimer()
{
// Set the timer to be as accurate as possible
TIMECAPS tc;
if (timeGetDevCaps(&tc, sizeof(tc)) != TIMERR_NOERROR)
TimerPeriod = 1; // Assume minimum resolution of 1 ms
else
TimerPeriod = tc.wPeriodMin;
timeBeginPeriod(TimerPeriod);
atexit([]() { timeEndPeriod(TimerPeriod); });
}
void InitExePath()
{
// Figure out what directory the program resides in.
WCHAR progbuff[1024];
if (GetModuleFileNameW(nullptr, progbuff, 1024) == 0)
{
MessageBoxA(nullptr, "Fatal", "Could not determine program location.", MB_ICONEXCLAMATION | MB_OK);
exit(-1);
}
progbuff[1023] = '\0';
if (auto lastsep = wcsrchr(progbuff, '\\'))
{
lastsep[1] = '\0';
}
progdir = progbuff;
FixPathSeperator(progdir);
}
//==========================================================================
int DoMain (HINSTANCE hInstance)
{
LONG WinWidth, WinHeight;
int height, width, x, y;
RECT cRect;
DEVMODE displaysettings;
InitArgs();
if (isConsoleApp())
{
@ -171,7 +216,7 @@ int DoMain (HINSTANCE hInstance)
if (GetConsoleMode(StdOut, &mode))
{
if (SetConsoleMode(StdOut, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING))
if (SetConsoleMode(StdOut, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING | ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT))
FancyStdOut = IsWindows10OrGreater(); // Windows 8.1 and lower do not understand ANSI formatting.
}
}
@ -223,31 +268,8 @@ int DoMain (HINSTANCE hInstance)
}
}
// Set the timer to be as accurate as possible
if (timeGetDevCaps (&tc, sizeof(tc)) != TIMERR_NOERROR)
TimerPeriod = 1; // Assume minimum resolution of 1 ms
else
TimerPeriod = tc.wPeriodMin;
timeBeginPeriod (TimerPeriod);
atexit([](){ timeEndPeriod(TimerPeriod); });
// Figure out what directory the program resides in.
WCHAR progbuff[1024];
if (GetModuleFileNameW(nullptr, progbuff, 1024) == 0)
{
MessageBoxA(nullptr, "Fatal", "Could not determine program location.", MB_ICONEXCLAMATION|MB_OK);
exit(-1);
}
progbuff[1023] = '\0';
if (auto lastsep = wcsrchr(progbuff, '\\'))
{
lastsep[1] = '\0';
}
progdir = progbuff;
FixPathSeperator(progdir);
InitTimer();
InitExePath();
HDC screenDC = GetDC(0);
int dpi = GetDeviceCaps(screenDC, LOGPIXELSX);
@ -323,13 +345,13 @@ void I_ShowFatalError(const char *msg)
Printf("%s", CVMAbortException::stacktrace.GetChars());
}
if (!batchrun)
if (!batchrun && !RunningAsTool)
{
mainwindow.ShowErrorPane(msg);
}
else
{
Printf("%s\n", msg);
Printf(TEXTCOLOR_ORANGE "%s\n", msg);
}
}
@ -344,10 +366,7 @@ int I_GameMain(HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int nCmdS
{
g_hInst = hInstance;
InitCommonControls();
if (SUCCEEDED(CoInitialize(nullptr)))
atexit([]() { CoUninitialize(); }); // beware of calling convention.
InitComAndCommonControls();
#if defined(_DEBUG) && defined(_MSC_VER)
// Uncomment this line to make the Visual C++ CRT check the heap before
@ -383,17 +402,33 @@ int I_GameMain(HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int nCmdS
int I_ToolMain(HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int nCmdShow)
{
g_hInst = hInstance;
RunningAsTool = true;
InitCommonControls();
if (SUCCEEDED(CoInitialize(nullptr)))
atexit([]() { CoUninitialize(); }); // beware of calling convention.
InitComAndCommonControls();
FString reportsDirectory = GetKnownFolder(CSIDL_LOCAL_APPDATA, FOLDERID_LocalAppData, true);
reportsDirectory += "/" GAMENAMELOWERCASE;
reportsDirectory += "/crashreports";
CreatePath(reportsDirectory.GetChars());
InitCrashReporter(reportsDirectory.WideString(), {});
return DoMain(hInstance);
InitArgs();
StdOut = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCP(CP_UTF8);
SetConsoleOutputCP(CP_UTF8);
DWORD mode;
if (GetConsoleMode(StdOut, &mode))
{
if (SetConsoleMode(StdOut, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING | ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT))
FancyStdOut = IsWindows10OrGreater(); // Windows 8.1 and lower do not understand ANSI formatting.
}
InitTimer();
InitExePath();
int res = GameMain();
SetConsoleMode(StdOut, mode);
return res;
}

View file

@ -47,6 +47,7 @@
#include "gstrings.h"
#include "i_mainwindow.h"
#include "engineerrors.h"
#include "i_interface.h"
static int isportable = -1;
@ -98,7 +99,7 @@ bool IsPortable()
if (file != INVALID_HANDLE_VALUE)
{
CloseHandle(file);
if (!batchrun) Printf("Using portable configuration\n");
if (!batchrun && !RunningAsTool) Printf("Using portable configuration\n");
isportable = true;
return true;
}

View file

@ -203,7 +203,7 @@ void I_DetectOS(void)
break;
}
if (!batchrun) Printf ("OS: Windows %s (NT %lu.%lu) Build %lu\n %s\n",
if (!batchrun && !RunningAsTool) Printf ("OS: Windows %s (NT %lu.%lu) Build %lu\n %s\n",
osname,
info.dwMajorVersion, info.dwMinorVersion,
info.dwBuildNumber, info.szCSDVersion);
@ -264,7 +264,7 @@ void CalculateCPUSpeed()
PerfToMillisec = PerfToSec * 1000.0;
}
if (!batchrun) Printf ("CPU speed: %.0f MHz\n", 0.001 / PerfToMillisec);
if (!batchrun && !RunningAsTool) Printf ("CPU speed: %.0f MHz\n", 0.001 / PerfToMillisec);
}
//==========================================================================
@ -276,24 +276,40 @@ void CalculateCPUSpeed()
//
//==========================================================================
std::wstring to_utf16(const std::string& str)
{
if (str.empty()) return {};
int needed = MultiByteToWideChar(CP_UTF8, 0, str.data(), (int)str.size(), nullptr, 0);
if (needed == 0)
return {};
std::wstring result;
result.resize(needed);
needed = MultiByteToWideChar(CP_UTF8, 0, str.data(), (int)str.size(), &result[0], (int)result.size());
if (needed == 0)
return {};
return result;
}
static void PrintToStdOut(const char *cpt, HANDLE StdOut)
{
const char* srcp = cpt;
FString printData = "";
bool terminal = FancyStdOut;
bool colorSet = false;
while (*srcp != 0)
{
if (*srcp == 0x1c && terminal)
{
srcp += 1;
const uint8_t* scratch = (const uint8_t*)srcp; // GCC does not like direct casting of the parameter.
const uint8_t* scratch = (const uint8_t*)srcp;
EColorRange range = V_ParseFontColor(scratch, CR_UNTRANSLATED, CR_YELLOW);
srcp = (char*)scratch;
if (range != CR_UNDEFINED)
{
PalEntry color = V_LogColorFromColorRange(range);
printData.AppendFormat("\033[38;2;%u;%u;%um", color.r, color.g, color.b);
printData.AppendFormat("\x1b[38;2;%u;%u;%um", color.r, color.g, color.b);
colorSet = true;
}
}
else if (*srcp != 0x1c && *srcp != 0x1d && *srcp != 0x1e && *srcp != 0x1f)
@ -307,10 +323,11 @@ static void PrintToStdOut(const char *cpt, HANDLE StdOut)
}
}
if (colorSet)
printData += "\x1b[0m";
DWORD bytes_written;
WriteFile(StdOut, printData.GetChars(), (DWORD)printData.Len(), &bytes_written, NULL);
if (terminal)
WriteFile(StdOut, "\033[0m", 4, &bytes_written, NULL);
WriteFile(StdOut, printData.GetChars(), (DWORD)printData.Len(), &bytes_written, nullptr);
}
void I_PrintStr(const char *cp)

View file

@ -757,6 +757,12 @@ int FIWadManager::IdentifyVersion (std::vector<std::string>&wadfiles, const char
if (alwaysshow || picks.Size() > 1)
{
if (RunningAsTool)
{
Printf("Please specify which iwad to use with -iwad\n");
return -1;
}
// Locate the user's prefered IWAD, if it was found.
if (defaultiwad[0] != '\0')
{

View file

@ -313,7 +313,7 @@ CUSTOM_CVAR(Int, I_FriendlyWindowTitle, 1, CVAR_GLOBALCONFIG|CVAR_ARCHIVE|CVAR_N
}
CVAR(Bool, cl_nointros, false, CVAR_ARCHIVE)
bool RunningAsTool = false;
bool hud_toggled = false;
bool wantToRestart;
bool DrawFSHUD; // [RH] Draw fullscreen HUD?
@ -2035,7 +2035,7 @@ static void D_DoomInit()
gamestate = GS_STARTUP;
if (!batchrun) Printf ("M_LoadDefaults: Load system defaults.\n");
if (!batchrun && !RunningAsTool) Printf ("M_LoadDefaults: Load system defaults.\n");
M_LoadDefaults (); // load before initing other systems
}
@ -2126,7 +2126,7 @@ static void CheckCmdLine()
int p;
const char *v;
if (!batchrun) Printf ("Checking cmd-line parameters...\n");
if (!batchrun && !RunningAsTool) Printf ("Checking cmd-line parameters...\n");
if (Args->CheckParm ("-nomonsters")) flags |= DF_NO_MONSTERS;
if (Args->CheckParm ("-respawn")) flags |= DF_MONSTERS_RESPAWN;
if (Args->CheckParm ("-fast")) flags |= DF_FAST_MONSTERS;
@ -3147,7 +3147,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
{
rngseed = staticrngseed = atoi(v);
use_staticrng = true;
if (!batchrun) Printf("D_DoomInit: Static RNGseed %d set.\n", rngseed);
if (!batchrun && !RunningAsTool) Printf("D_DoomInit: Static RNGseed %d set.\n", rngseed);
}
else
{
@ -3184,7 +3184,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
exec->AddPullins(allwads, GameConfig);
}
if (!batchrun) Printf ("W_Init: Init WADfiles.\n");
if (!batchrun && !RunningAsTool) Printf ("W_Init: Init WADfiles.\n");
LumpFilterInfo lfi;
@ -3244,12 +3244,12 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
D_GrabCVarDefaults(); //parse DEFCVARS
InitPalette();
if (!batchrun) Printf("S_Init: Setting up sound.\n");
if (!batchrun && !RunningAsTool) Printf("S_Init: Setting up sound.\n");
S_Init();
int max_progress = TexMan.GuesstimateNumTextures();
int per_shader_progress = 0;//screen->GetShaderCount()? (max_progress / 10 / screen->GetShaderCount()) : 0;
bool nostartscreen = batchrun || restart || Args->CheckParm("-join") || Args->CheckParm("-host") || Args->CheckParm("-norun");
bool nostartscreen = RunningAsTool || batchrun || restart || Args->CheckParm("-join") || Args->CheckParm("-host") || Args->CheckParm("-norun");
if (GameStartupInfo.Type == FStartupInfo::DefaultStartup)
{
@ -3288,7 +3288,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
if (!restart)
{
if (!batchrun) Printf ("I_Init: Setting up machine state.\n");
if (!batchrun && !RunningAsTool) Printf ("I_Init: Setting up machine state.\n");
CheckCPUID(&CPU);
CalculateCPUSpeed();
auto ci = DumpCPUInfo(&CPU);
@ -3297,7 +3297,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
TexMan.Init();
if (!batchrun) Printf ("V_Init: allocate screen.\n");
if (!batchrun && !RunningAsTool) Printf ("V_Init: allocate screen.\n");
if (!restart)
{
screen->CompileNextShader();
@ -3319,7 +3319,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
compatmode = (int)strtoll(compatmodeval, nullptr, 10);
}
if (!batchrun) Printf ("ST_Init: Init startup screen.\n");
if (!batchrun && !RunningAsTool) Printf ("ST_Init: Init startup screen.\n");
if (!restart)
{
StartWindow = FStartupScreen::CreateInstance (TexMan.GuesstimateNumTextures() + 5);
@ -3335,11 +3335,11 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
S_ParseReverbDef ();
// [RH] Parse any SNDINFO lumps
if (!batchrun) Printf ("S_InitData: Load sound definitions.\n");
if (!batchrun && !RunningAsTool) Printf ("S_InitData: Load sound definitions.\n");
S_InitData ();
// [RH] Parse through all loaded mapinfo lumps
if (!batchrun) Printf ("G_ParseMapInfo: Load map definitions.\n");
if (!batchrun && !RunningAsTool) Printf ("G_ParseMapInfo: Load map definitions.\n");
G_ParseMapInfo (iwad_info->MapInfo);
MessageBoxClass = gameinfo.MessageBoxClass;
endoomName = gameinfo.Endoom;
@ -3349,7 +3349,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
// MUSINFO must be parsed after MAPINFO
S_ParseMusInfo();
if (!batchrun) Printf ("Texman.Init: Init texture manager.\n");
if (!batchrun && !RunningAsTool) Printf ("Texman.Init: Init texture manager.\n");
UpdateUpscaleMask();
SpriteFrames.Clear();
TexMan.AddTextures([]()
@ -3371,7 +3371,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
UpdateGenericUI(false);
// [CW] Parse any TEAMINFO lumps.
if (!batchrun) Printf ("ParseTeamInfo: Load team definitions.\n");
if (!batchrun && !RunningAsTool) Printf ("ParseTeamInfo: Load team definitions.\n");
FTeam::ParseTeamInfo ();
R_ParseTrnslate();
@ -3397,13 +3397,13 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
ParseGLDefs();
if (!batchrun) Printf ("R_Init: Init %s refresh subsystem.\n", gameinfo.ConfigName.GetChars());
if (!batchrun && !RunningAsTool) Printf ("R_Init: Init %s refresh subsystem.\n", gameinfo.ConfigName.GetChars());
if (StartScreen) StartScreen->LoadingStatus ("Loading graphics", 0x3f);
if (StartScreen) StartScreen->Progress(1);
StartWindow->Progress();
R_Init ();
if (!batchrun) Printf ("DecalLibrary: Load decals.\n");
if (!batchrun && !RunningAsTool) Printf ("DecalLibrary: Load decals.\n");
DecalLibrary.ReadAllDecals ();
auto numbasesounds = soundEngine->GetNumSounds();
@ -3425,7 +3425,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
{
if (stricmp (key, "Path") == 0 && FileExists (value))
{
if (!batchrun) Printf ("Applying patch %s\n", value);
if (!batchrun && !RunningAsTool) Printf ("Applying patch %s\n", value);
D_LoadDehFile(value, 0);
}
}
@ -3440,7 +3440,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
auto numdehsounds = soundEngine->GetNumSounds();
if (numbasesounds < numdehsounds) S_LockLocalSndinfo(); // DSDHacked sounds are not compatible with map-local SNDINFOs.
if (!batchrun) Printf("M_Init: Init menus.\n");
if (!batchrun && !RunningAsTool) Printf("M_Init: Init menus.\n");
SetDefaultMenuColors();
M_Init();
M_CreateGameMenus();
@ -3465,7 +3465,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
primaryLevel->BotInfo.spawn_tries = 0;
primaryLevel->BotInfo.wanted_botnum = primaryLevel->BotInfo.getspawned.Size();
if (!batchrun) Printf ("P_Init: Init Playloop state.\n");
if (!batchrun && !RunningAsTool) Printf ("P_Init: Init Playloop state.\n");
if (StartScreen) StartScreen->LoadingStatus ("Init game engine", 0x3f);
AM_StaticInit();
P_Init ();
@ -3475,7 +3475,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
//SBarInfo support. Note that the first SBARINFO lump contains the mugshot definition so it even needs to be read when a regular status bar is being used.
SBarInfo::Load();
if (!batchrun)
if (!batchrun && !RunningAsTool)
{
// [RH] User-configurable startup strings. Because BOOM does.
static const char *startupString[5] = {
@ -3494,7 +3494,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
if (!restart)
{
if (!batchrun) Printf ("D_CheckNetGame: Checking network game status.\n");
if (!batchrun && !RunningAsTool) Printf ("D_CheckNetGame: Checking network game status.\n");
if (StartScreen) StartScreen->LoadingStatus ("Checking network game status.", 0x3f);
if (!D_CheckNetGame ())
{
@ -3537,6 +3537,12 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
return 1337; // special exit
}
if (RunningAsTool)
{
// To do: is enough of the engine initialized now for running tool commandlets?
return 0;
}
if (StartScreen)
{
StartScreen->Progress(max_progress); // advance progress bar to the end.

View file

@ -1766,7 +1766,7 @@ bool D_CheckNetGame (void)
Printf("Arbitrator selected " TEXTCOLOR_BLUE "%s" TEXTCOLOR_NORMAL " networking mode.\n", NetMode == NET_PeerToPeer ? "peer to peer" : "packet server");
}
if (!batchrun) Printf ("player %i of %i (%i nodes)\n",
if (!batchrun && !RunningAsTool) Printf ("player %i of %i (%i nodes)\n",
consoleplayer+1, doomcom.numplayers, doomcom.numnodes);
return true;

View file

@ -448,7 +448,7 @@ void SBarInfo::Load()
int lump = fileSystem.CheckNumForFullName(gameinfo.statusbar.GetChars(), true);
if(lump != -1)
{
if (!batchrun) Printf ("ParseSBarInfo: Loading default status bar definition.\n");
if (!batchrun && !RunningAsTool) Printf ("ParseSBarInfo: Loading default status bar definition.\n");
if(SBarInfoScript[SCRIPT_DEFAULT] == NULL)
SBarInfoScript[SCRIPT_DEFAULT] = new SBarInfo(lump);
else
@ -458,7 +458,7 @@ void SBarInfo::Load()
if(fileSystem.CheckNumForName("SBARINFO") != -1)
{
if (!batchrun) Printf ("ParseSBarInfo: Loading custom status bar definition.\n");
if (!batchrun && !RunningAsTool) Printf ("ParseSBarInfo: Loading custom status bar definition.\n");
int lastlump, lump;
lastlump = 0;
while((lump = fileSystem.FindLump("SBARINFO", &lastlump)) != -1)

View file

@ -3225,7 +3225,7 @@ bool D_LoadDehFile(const char *patchfile, int flags)
static bool DoDehPatch(int flags)
{
if (!batchrun) Printf("Adding dehacked patch %s\n", PatchName.GetChars());
if (!batchrun && !RunningAsTool) Printf("Adding dehacked patch %s\n", PatchName.GetChars());
int cont;
@ -3320,7 +3320,7 @@ static bool DoDehPatch(int flags)
PatchName = "";
delete[] PatchFile;
if (!batchrun) Printf ("Patch installed\n");
if (!batchrun && !RunningAsTool) Printf ("Patch installed\n");
return true;
}

View file

@ -393,7 +393,7 @@ void PClassActor::StaticInit()
sprites.Push (temp);
}
if (!batchrun) Printf ("LoadActors: Load actor definitions.\n");
if (!batchrun && !RunningAsTool) Printf ("LoadActors: Load actor definitions.\n");
ClearStrifeTypes();
LoadActors ();
InitServices();

View file

@ -55,6 +55,7 @@
#include "thingdef.h"
#include "zcc_parser.h"
#include "zcc_compile_doom.h"
#include "i_interface.h"
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
void InitThingdef();
@ -545,7 +546,7 @@ void LoadActors()
}
timer.Unclock();
if (!batchrun) Printf("script parsing took %.2f ms\n", timer.TimeMS());
if (!batchrun && !RunningAsTool) Printf("script parsing took %.2f ms\n", timer.TimeMS());
// Now we may call the scripted OnDestroy method.
PClass::bVMOperational = true;