Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/mangosd/CliService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,20 @@ void CliService::Run()
// Let start-up finish printing before the prompt lands in the middle of it.
std::this_thread::sleep_for(std::chrono::seconds(1));

if (m_beep && !MaNGOS::Console::ConsoleUI::Instance().Active())
// The bell has to bypass the log pipeline entirely. With the full-screen UI
// up, ConsoleLogWriter::Emit() folds a raw record into the UI's scrollback
// as text, so a BEL routed through sLog is displayed rather than sounded --
// which is why gating this on !ConsoleUI::Active() silenced it outright.
if (m_beep)
{
sLog.ConsoleEmitRaw("\a");
#ifdef _WIN32
// The system "default" sound, i.e. what the console bell used to raise.
MessageBeep(MB_OK);
#else
// Straight to the terminal: non-printing, so it cannot disturb a frame.
std::fputs("\a", stdout);
std::fflush(stdout);
#endif
}

Prompt();
Expand Down
38 changes: 38 additions & 0 deletions src/mangosd/Master.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "Log.h"
#include "MapManager.h"
#include "Server/WorldNetwork.h"
#include "SystemConfig.h"
#include "Timer.h"
#include "World.h"

Expand Down Expand Up @@ -98,6 +99,35 @@ namespace

return db.CheckDatabaseVersion(versionKind);
}

#ifdef _WIN32
/**
* @brief Show the live player and connection counts in the window title.
*
* The title belongs to the OS window, not to the console frame, so it stays
* readable while the server is minimised or buried in the taskbar -- which
* the in-frame status bar is not. Rewritten only when the text actually
* changes, because SetConsoleTitleA is a cross-process call.
*
* @param players Currently active sessions.
* @param connections Currently open socket connections.
*/
void UpdateConsoleTitle(uint32 players, uint32 connections)
{
static std::string s_lastTitle;

char title[128];
snprintf(title, sizeof(title), "%s (%u Players - %u Connections)",
MANGOS_PACKAGENAME, players, connections);

std::string newTitle(title);
if (s_lastTitle != newTitle)
{
s_lastTitle = newTitle;
SetConsoleTitleA(title);
}
}
#endif
}

Master::Master()
Expand Down Expand Up @@ -250,6 +280,14 @@ void Master::StopServices()

void Master::PublishConsoleStatus(uint32 diff)
{
#ifdef _WIN32
// Before the early-out below: the window title is owned by the OS rather
// than by the console frame, so it is kept current even when the
// full-screen UI is switched off and there is no status bar to publish to.
UpdateConsoleTitle(sWorld.GetActiveSessionCount(),
sWorldNetwork.GetOpenConnectionCount());
#endif

MaNGOS::Console::ConsoleUI& ui = MaNGOS::Console::ConsoleUI::Instance();
if (!ui.Active())
{
Expand Down
11 changes: 6 additions & 5 deletions src/mangosd/mangosd.conf.dist.in
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,8 @@ SD3ErrorLogFile = "scriptdev3-errors.log"
# Default: 0 (false)
# 1 (true)
#
# BeepAtStart
# Beep at mangosd start finished (mostly work only at Unix/Linux systems)
# Console.BeepAtStart
# Beep once mangosd has finished starting and the console is ready.
# Default: 1 (true)
# 0 (false)
#
Expand All @@ -818,8 +818,9 @@ SD3ErrorLogFile = "scriptdev3-errors.log"
# Default: "auto" (draw the boxed, coloured loading UI when stdout is an
# interactive console; plain text when it is redirected
# to a file or a pipe, or when running as a service)
# "fancy" (force the loading UI on, for a terminal that cannot be
# detected as one)
# "fancy" (currently behaves as "auto": forcing the UI on for a
# terminal that cannot be detected as one is not yet
# implemented)
# "plain" (never; plain text, as older releases printed it)
#
# WaitAtStartupError
Expand Down Expand Up @@ -910,7 +911,7 @@ MailDeliveryDelay = 3600
MassMailer.SendPerTick = 10
PetUnsummonAtMount = 0
Event.Announce = 0
BeepAtStart = 1
Console.BeepAtStart = 1
ShowProgressBars = 1
Console.Style = "auto"
WaitAtStartupError = 10
Expand Down
6 changes: 5 additions & 1 deletion src/mangosd/mangosd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,11 @@ int main(int argc, char** argv)

// Only now: until the writer thread exists, console emits take the
// synchronous path and would write straight over the full-screen frame.
if (sConfig.GetBoolDefault("Console.FullScreen", true) &&
// "plain" never draws the loading UI. "auto" and "fancy" both ask for it,
// and Start() declines on its own when stdout is not a real terminal.
const std::string consoleStyle =
sConfig.GetStringDefault("Console.Style", "auto");
if (consoleStyle != "plain" &&
MaNGOS::Console::ConsoleUI::Instance().Start("MaNGOS Zero", "Vanilla 1.12.x"))
{
MaNGOS::Console::ConsoleUI::Instance().SetHeaderRight(
Expand Down
Loading