mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 01:29:50 +00:00
Get config values without using return parameters
Many temporaries can be removed.
This commit is contained in:
@@ -88,12 +88,14 @@ CCameraController::CCameraController(CCamera& camera)
|
||||
m_RotateX(0, 0, 0.001f),
|
||||
m_RotateY(0, 0, 0.001f)
|
||||
{
|
||||
m_ViewDragInvertedConfigHook = std::make_unique<CConfigDBHook>(g_ConfigDB.RegisterHookAndCall("view.drag.inverted", [this]() {
|
||||
CFG_GET_VAL("view.drag.inverted", m_ViewDragInverted);
|
||||
}));
|
||||
m_ViewDragSpeedConfigHook = std::make_unique<CConfigDBHook>(g_ConfigDB.RegisterHookAndCall("view.drag.speed", [this]() {
|
||||
CFG_GET_VAL("view.drag.speed", m_ViewDragSpeed);
|
||||
}));
|
||||
m_ViewDragInvertedConfigHook =
|
||||
std::make_unique<CConfigDBHook>(g_ConfigDB.RegisterHookAndCall("view.drag.inverted", [this]() {
|
||||
m_ViewDragInverted = g_ConfigDB.Get("view.drag.inverted", m_ViewDragInverted);
|
||||
}));
|
||||
m_ViewDragSpeedConfigHook =
|
||||
std::make_unique<CConfigDBHook>(g_ConfigDB.RegisterHookAndCall("view.drag.speed", [this]() {
|
||||
m_ViewDragSpeed = g_ConfigDB.Get("view.drag.speed", m_ViewDragSpeed);
|
||||
}));
|
||||
|
||||
SViewPort vp;
|
||||
vp.m_X = 0;
|
||||
@@ -111,35 +113,33 @@ CCameraController::~CCameraController() = default;
|
||||
|
||||
void CCameraController::LoadConfig()
|
||||
{
|
||||
CFG_GET_VAL("view.scroll.speed", m_ViewScrollSpeed);
|
||||
CFG_GET_VAL("view.scroll.speed.modifier", m_ViewScrollSpeedModifier);
|
||||
CFG_GET_VAL("view.scroll.mouse.detectdistance", m_ViewScrollMouseDetectDistance);
|
||||
CFG_GET_VAL("view.rotate.x.speed", m_ViewRotateXSpeed);
|
||||
CFG_GET_VAL("view.rotate.x.min", m_ViewRotateXMin);
|
||||
CFG_GET_VAL("view.rotate.x.max", m_ViewRotateXMax);
|
||||
CFG_GET_VAL("view.rotate.x.default", m_ViewRotateXDefault);
|
||||
CFG_GET_VAL("view.rotate.y.speed", m_ViewRotateYSpeed);
|
||||
CFG_GET_VAL("view.rotate.y.speed.wheel", m_ViewRotateYSpeedWheel);
|
||||
CFG_GET_VAL("view.rotate.y.default", m_ViewRotateYDefault);
|
||||
CFG_GET_VAL("view.rotate.speed.modifier", m_ViewRotateSpeedModifier);
|
||||
CFG_GET_VAL("view.drag.speed", m_ViewDragSpeed);
|
||||
CFG_GET_VAL("view.drag.inverted", m_ViewDragInverted);
|
||||
CFG_GET_VAL("view.zoom.speed", m_ViewZoomSpeed);
|
||||
CFG_GET_VAL("view.zoom.speed.wheel", m_ViewZoomSpeedWheel);
|
||||
CFG_GET_VAL("view.zoom.min", m_ViewZoomMin);
|
||||
CFG_GET_VAL("view.zoom.max", m_ViewZoomMax);
|
||||
CFG_GET_VAL("view.zoom.default", m_ViewZoomDefault);
|
||||
CFG_GET_VAL("view.zoom.speed.modifier", m_ViewZoomSpeedModifier);
|
||||
m_ViewScrollSpeed = g_ConfigDB.Get("view.scroll.speed", m_ViewScrollSpeed);
|
||||
m_ViewScrollSpeedModifier = g_ConfigDB.Get("view.scroll.speed.modifier", m_ViewScrollSpeedModifier);
|
||||
m_ViewScrollMouseDetectDistance = g_ConfigDB.Get("view.scroll.mouse.detectdistance",
|
||||
m_ViewScrollMouseDetectDistance);
|
||||
m_ViewRotateXSpeed = g_ConfigDB.Get("view.rotate.x.speed", m_ViewRotateXSpeed);
|
||||
m_ViewRotateXMin = g_ConfigDB.Get("view.rotate.x.min", m_ViewRotateXMin);
|
||||
m_ViewRotateXMax = g_ConfigDB.Get("view.rotate.x.max", m_ViewRotateXMax);
|
||||
m_ViewRotateXDefault = g_ConfigDB.Get("view.rotate.x.default", m_ViewRotateXDefault);
|
||||
m_ViewRotateYSpeed = g_ConfigDB.Get("view.rotate.y.speed", m_ViewRotateYSpeed);
|
||||
m_ViewRotateYSpeedWheel = g_ConfigDB.Get("view.rotate.y.speed.wheel", m_ViewRotateYSpeedWheel);
|
||||
m_ViewRotateYDefault = g_ConfigDB.Get("view.rotate.y.default", m_ViewRotateYDefault);
|
||||
m_ViewRotateSpeedModifier = g_ConfigDB.Get("view.rotate.speed.modifier", m_ViewRotateSpeedModifier);
|
||||
m_ViewDragSpeed = g_ConfigDB.Get("view.drag.speed", m_ViewDragSpeed);
|
||||
m_ViewDragInverted = g_ConfigDB.Get("view.drag.inverted", m_ViewDragInverted);
|
||||
m_ViewZoomSpeed = g_ConfigDB.Get("view.zoom.speed", m_ViewZoomSpeed);
|
||||
m_ViewZoomSpeedWheel = g_ConfigDB.Get("view.zoom.speed.wheel", m_ViewZoomSpeedWheel);
|
||||
m_ViewZoomMin = g_ConfigDB.Get("view.zoom.min", m_ViewZoomMin);
|
||||
m_ViewZoomMax = g_ConfigDB.Get("view.zoom.max", m_ViewZoomMax);
|
||||
m_ViewZoomDefault = g_ConfigDB.Get("view.zoom.default", m_ViewZoomDefault);
|
||||
m_ViewZoomSpeedModifier = g_ConfigDB.Get("view.zoom.speed.modifier", m_ViewZoomSpeedModifier);
|
||||
|
||||
CFG_GET_VAL("view.height.smoothness", m_HeightSmoothness);
|
||||
CFG_GET_VAL("view.height.min", m_HeightMin);
|
||||
m_HeightSmoothness = g_ConfigDB.Get("view.height.smoothness", m_HeightSmoothness);
|
||||
m_HeightMin = g_ConfigDB.Get("view.height.min", m_HeightMin);
|
||||
|
||||
#define SETUP_SMOOTHNESS(CFG_PREFIX, SMOOTHED_VALUE) \
|
||||
{ \
|
||||
float smoothness = SMOOTHED_VALUE.GetSmoothness(); \
|
||||
CFG_GET_VAL(CFG_PREFIX ".smoothness", smoothness); \
|
||||
SMOOTHED_VALUE.SetSmoothness(smoothness); \
|
||||
}
|
||||
SMOOTHED_VALUE.SetSmoothness( \
|
||||
g_ConfigDB.Get(CFG_PREFIX ".smoothness", SMOOTHED_VALUE.GetSmoothness()));
|
||||
|
||||
SETUP_SMOOTHNESS("view.pos", m_PosX);
|
||||
SETUP_SMOOTHNESS("view.pos", m_PosY);
|
||||
@@ -149,9 +149,9 @@ void CCameraController::LoadConfig()
|
||||
SETUP_SMOOTHNESS("view.rotate.y", m_RotateY);
|
||||
#undef SETUP_SMOOTHNESS
|
||||
|
||||
CFG_GET_VAL("view.near", m_ViewNear);
|
||||
CFG_GET_VAL("view.far", m_ViewFar);
|
||||
CFG_GET_VAL("view.fov", m_ViewFOV);
|
||||
m_ViewNear = g_ConfigDB.Get("view.near", m_ViewNear);
|
||||
m_ViewFar = g_ConfigDB.Get("view.far", m_ViewFar);
|
||||
m_ViewFOV = g_ConfigDB.Get("view.fov", m_ViewFOV);
|
||||
|
||||
// Convert to radians
|
||||
m_RotateX.SetValue(DEGTORAD(m_ViewRotateXDefault));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -31,12 +31,9 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
CMaterialManager::CMaterialManager()
|
||||
CMaterialManager::CMaterialManager() :
|
||||
qualityLevel{Clamp(g_ConfigDB.Get("materialmgr.quality", 5.0f), 0.0f, 10.0f)}
|
||||
{
|
||||
qualityLevel = 5.0;
|
||||
CFG_GET_VAL("materialmgr.quality", qualityLevel);
|
||||
qualityLevel = Clamp(qualityLevel, 0.0f, 10.0f);
|
||||
|
||||
if (VfsDirectoryExists(L"art/materials/") &&
|
||||
!g_Xeromyces.AddValidator(g_VFS, "material", "art/materials/material.rng"))
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -194,22 +194,16 @@ CMiniMapTexture::CMiniMapTexture(Renderer::Backend::IDevice* device, CSimulation
|
||||
: m_Simulation(simulation), m_IndexArray(Renderer::Backend::IBuffer::Usage::TRANSFER_DST),
|
||||
m_VertexArray(Renderer::Backend::IBuffer::Type::VERTEX,
|
||||
Renderer::Backend::IBuffer::Usage::DYNAMIC | Renderer::Backend::IBuffer::Usage::TRANSFER_DST),
|
||||
m_InstanceVertexArray(Renderer::Backend::IBuffer::Type::VERTEX, Renderer::Backend::IBuffer::Usage::TRANSFER_DST)
|
||||
m_InstanceVertexArray(Renderer::Backend::IBuffer::Type::VERTEX,
|
||||
Renderer::Backend::IBuffer::Usage::TRANSFER_DST),
|
||||
m_PingDuration{CConfigDB::GetIfInitialised("gui.session.minimap.pingduration", 25.0)},
|
||||
m_HalfBlinkDuration{CConfigDB::GetIfInitialised("gui.session.minimap.blinkduration", 1.0) / 2.0}
|
||||
{
|
||||
// Register Relax NG validator.
|
||||
g_Xeromyces.AddValidator(g_VFS, "pathfinder", "simulation/data/pathfinder.rng");
|
||||
|
||||
m_ShallowPassageHeight = GetShallowPassageHeight();
|
||||
|
||||
double blinkDuration = 1.0;
|
||||
// Tests won't have config initialised
|
||||
if (CConfigDB::IsInitialised())
|
||||
{
|
||||
CFG_GET_VAL("gui.session.minimap.blinkduration", blinkDuration);
|
||||
CFG_GET_VAL("gui.session.minimap.pingduration", m_PingDuration);
|
||||
}
|
||||
m_HalfBlinkDuration = blinkDuration / 2.0;
|
||||
|
||||
m_AttributePos.format = Renderer::Backend::Format::R32G32_SFLOAT;
|
||||
m_VertexArray.AddAttribute(&m_AttributePos);
|
||||
|
||||
@@ -646,12 +640,9 @@ void CMiniMapTexture::UpdateAndUploadEntities(
|
||||
m_NextBlinkTime = currentTime + m_HalfBlinkDuration;
|
||||
}
|
||||
|
||||
bool iconsEnabled = false;
|
||||
CFG_GET_VAL("gui.session.minimap.icons.enabled", iconsEnabled);
|
||||
float iconsOpacity = 1.0f;
|
||||
CFG_GET_VAL("gui.session.minimap.icons.opacity", iconsOpacity);
|
||||
float iconsSizeScale = 1.0f;
|
||||
CFG_GET_VAL("gui.session.minimap.icons.sizescale", iconsSizeScale);
|
||||
const bool iconsEnabled{g_ConfigDB.Get("gui.session.minimap.icons.enabled", false)};
|
||||
const float iconsOpacity{g_ConfigDB.Get("gui.session.minimap.icons.opacity", 1.0f)};
|
||||
const float iconsSizeScale{g_ConfigDB.Get("gui.session.minimap.icons.sizescale", 1.0f)};
|
||||
|
||||
bool iconsCountOverflow = false;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -195,8 +195,7 @@ Status CObjectManager::ReloadChangedFile(const VfsPath& path)
|
||||
|
||||
void CObjectManager::ActorQualityChanged()
|
||||
{
|
||||
int quality;
|
||||
CFG_GET_VAL("max_actor_quality", quality);
|
||||
const int quality{g_ConfigDB.Get("max_actor_quality", 0)};
|
||||
if (quality == m_QualityLevel)
|
||||
return;
|
||||
|
||||
@@ -213,8 +212,7 @@ void CObjectManager::ActorQualityChanged()
|
||||
|
||||
void CObjectManager::VariantDiversityChanged()
|
||||
{
|
||||
CStr value;
|
||||
CFG_GET_VAL("variant_diversity", value);
|
||||
const std::string value{g_ConfigDB.Get("variant_diversity", std::string{})};
|
||||
VariantDiversity variantDiversity = VariantDiversity::FULL;
|
||||
if (value == "none")
|
||||
variantDiversity = VariantDiversity::NONE;
|
||||
|
||||
@@ -541,10 +541,10 @@ public:
|
||||
defaultSamplerDesc.addressModeV = texture->m_Properties.m_AddressModeV;
|
||||
if (texture->m_Properties.m_AnisotropicFilterEnabled && m_Device->GetCapabilities().anisotropicFiltering)
|
||||
{
|
||||
int maxAnisotropy = 1;
|
||||
CFG_GET_VAL("textures.maxanisotropy", maxAnisotropy);
|
||||
const int maxAnisotropy{g_ConfigDB.Get("textures.maxanisotropy", 1)};
|
||||
const int allowedValues[] = {2, 4, 8, 16};
|
||||
if (std::find(std::begin(allowedValues), std::end(allowedValues), maxAnisotropy) != std::end(allowedValues))
|
||||
if (std::find(std::begin(allowedValues), std::end(allowedValues), maxAnisotropy) !=
|
||||
std::end(allowedValues))
|
||||
{
|
||||
defaultSamplerDesc.anisotropyEnabled = true;
|
||||
defaultSamplerDesc.maxAnisotropy = maxAnisotropy;
|
||||
@@ -553,8 +553,7 @@ public:
|
||||
|
||||
if (!texture->m_Properties.m_IgnoreQuality)
|
||||
{
|
||||
int quality = 2;
|
||||
CFG_GET_VAL("textures.quality", quality);
|
||||
const int quality{g_ConfigDB.Get("textures.quality", 2)};
|
||||
if (quality == 1)
|
||||
{
|
||||
if (MIPLevelCount > 1 && std::min(width, height) > 8)
|
||||
|
||||
@@ -50,7 +50,7 @@ CInput::CInput(CGUI& pGUI)
|
||||
m_HorizontalScroll(),
|
||||
m_PrevTime(),
|
||||
m_CursorVisState(true),
|
||||
m_CursorBlinkRate(0.5),
|
||||
m_CursorBlinkRate{g_ConfigDB.Get("gui.cursorblinkrate", 0.5)},
|
||||
m_ComposingText(),
|
||||
m_GeneratedPlaceholderTextValid(false),
|
||||
m_iComposedLength(),
|
||||
@@ -75,7 +75,7 @@ CInput::CInput(CGUI& pGUI)
|
||||
m_PlaceholderText(this, "placeholder_text"),
|
||||
m_PlaceholderColor(this, "placeholder_color")
|
||||
{
|
||||
CFG_GET_VAL("gui.cursorblinkrate", m_CursorBlinkRate);
|
||||
;
|
||||
|
||||
auto bar = std::make_unique<CGUIScrollBarVertical>(pGUI);
|
||||
bar->SetRightAligned(true);
|
||||
|
||||
@@ -141,9 +141,7 @@ L10n::L10n()
|
||||
{
|
||||
// Determine whether or not to print tinygettext messages to the standard
|
||||
// error output, which it tinygettext's default behavior, but not ours.
|
||||
bool tinygettext_debug = false;
|
||||
CFG_GET_VAL("tinygettext.debug", tinygettext_debug);
|
||||
if (!tinygettext_debug)
|
||||
if (!g_ConfigDB.Get("tinygettext.debug", false))
|
||||
{
|
||||
tinygettext::Log::log_info_callback = 0;
|
||||
tinygettext::Log::log_warning_callback = 0;
|
||||
@@ -282,8 +280,7 @@ void L10n::GetDictionaryLocale(const std::string& configLocaleString, icu::Local
|
||||
// Try to find the best dictionary locale based on user configuration and system locale, set the currentLocale and reload the dictionary.
|
||||
void L10n::ReevaluateCurrentLocaleAndReload()
|
||||
{
|
||||
std::string locale;
|
||||
CFG_GET_VAL("locale", locale);
|
||||
const std::string locale{g_ConfigDB.Get("locale", std::string{})};
|
||||
|
||||
GetDictionaryLocale(locale, m_CurrentLocale);
|
||||
m_CurrentLocaleIsOriginalGameLocale = (m_CurrentLocale == icu::Locale::getUS()) == 1;
|
||||
|
||||
@@ -76,8 +76,11 @@ XmppClient::XmppClient(const ScriptInterface* scriptInterface, const std::string
|
||||
m_regOpt(regOpt),
|
||||
m_username(sUsername),
|
||||
m_password(sPassword),
|
||||
m_server{g_ConfigDB.Get("lobby.server", std::string{})},
|
||||
m_room(sRoom),
|
||||
m_nick(sNick),
|
||||
m_xpartamuppId{g_ConfigDB.Get("lobby.xpartamupp", std::string{}) + "@" + m_server + "/CC"},
|
||||
m_echelonId{g_ConfigDB.Get("lobby.echelon", std::string{}) + "@" + m_server + "/CC"},
|
||||
m_initialLoadComplete(false),
|
||||
m_isConnected(false),
|
||||
m_sessionManager(nullptr),
|
||||
@@ -89,15 +92,6 @@ XmppClient::XmppClient(const ScriptInterface* scriptInterface, const std::string
|
||||
if (m_ScriptInterface)
|
||||
JS_AddExtraGCRootsTracer(m_ScriptInterface->GetGeneralJSContext(), XmppClient::Trace, this);
|
||||
|
||||
// Read lobby configuration from default.cfg
|
||||
std::string sXpartamupp;
|
||||
std::string sEchelon;
|
||||
CFG_GET_VAL("lobby.server", m_server);
|
||||
CFG_GET_VAL("lobby.xpartamupp", sXpartamupp);
|
||||
CFG_GET_VAL("lobby.echelon", sEchelon);
|
||||
|
||||
m_xpartamuppId = sXpartamupp + "@" + m_server + "/CC";
|
||||
m_echelonId = sEchelon + "@" + m_server + "/CC";
|
||||
// Generate a unique, unpredictable resource to allow multiple 0 A.D. instances to connect to the lobby.
|
||||
gloox::JID clientJid(sUsername + "@" + m_server + "/0ad-" + ps_generate_guid());
|
||||
gloox::JID roomJid(m_room + "@conference." + m_server + "/" + sNick);
|
||||
@@ -111,9 +105,7 @@ XmppClient::XmppClient(const ScriptInterface* scriptInterface, const std::string
|
||||
|
||||
// Optionally join without a TLS certificate, so a local server can be tested quickly.
|
||||
// Security risks from malicious JS mods can be mitigated if this option and also the hostname and login are shielded from JS access.
|
||||
bool tls = true;
|
||||
CFG_GET_VAL("lobby.tls", tls);
|
||||
m_client->setTls(tls ? gloox::TLSRequired : gloox::TLSDisabled);
|
||||
m_client->setTls(g_ConfigDB.Get("lobby.tls", true) ? gloox::TLSRequired : gloox::TLSDisabled);
|
||||
|
||||
// Disable use of the SASL PLAIN mechanism, to prevent leaking credentials
|
||||
// if the server doesn't list any supported SASL mechanism or the response
|
||||
@@ -304,10 +296,7 @@ bool XmppClient::onTLSConnect(const gloox::CertInfo& info)
|
||||
m_certStatus = static_cast<gloox::CertStatus>(info.status);
|
||||
|
||||
// Optionally accept invalid certificates, see require_tls option.
|
||||
bool verify_certificate = true;
|
||||
CFG_GET_VAL("lobby.verify_certificate", verify_certificate);
|
||||
|
||||
return info.status == gloox::CertOk || !verify_certificate;
|
||||
return info.status == gloox::CertOk || !g_ConfigDB.Get("lobby.verify_certificate", true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+4
-7
@@ -285,8 +285,8 @@ inline static void LimitFPS()
|
||||
if (g_VideoMode.IsVSyncEnabled())
|
||||
return;
|
||||
|
||||
double fpsLimit = 0.0;
|
||||
CFG_GET_VAL(g_Game && g_Game->IsGameStarted() ? "adaptivefps.session" : "adaptivefps.menu", fpsLimit);
|
||||
const double fpsLimit{
|
||||
g_ConfigDB.Get(g_Game && g_Game->IsGameStarted() ? "adaptivefps.session" : "adaptivefps.menu", 0.0)};
|
||||
|
||||
// Keep in sync with options.json
|
||||
if (fpsLimit < 20.0 || fpsLimit >= 360.0)
|
||||
@@ -497,11 +497,8 @@ static std::optional<RL::Interface> CreateRLInterface(const CmdLineArgs& args)
|
||||
if (!args.Has("rl-interface"))
|
||||
return std::nullopt;
|
||||
|
||||
std::string server_address;
|
||||
CFG_GET_VAL("rlinterface.address", server_address);
|
||||
|
||||
if (!args.Get("rl-interface").empty())
|
||||
server_address = args.Get("rl-interface");
|
||||
const std::string server_address{args.Get("rl-interface").empty() ?
|
||||
g_ConfigDB.Get("rlinterface.address", std::string{}) : args.Get("rl-interface")};
|
||||
|
||||
debug_printf("RL interface listening on %s\n", server_address.c_str());
|
||||
return std::make_optional<RL::Interface>(server_address.c_str());
|
||||
|
||||
@@ -48,9 +48,7 @@ ENetHost* CreateHost(const ENetAddress* address, size_t peerCount, size_t channe
|
||||
|
||||
// Public ENet API doesn't offer a means to change MTU, so do it in a
|
||||
// way least likely to break with ENet updates.
|
||||
enet_uint32 mtu = HOST_DEFAULT_MTU;
|
||||
CFG_GET_VAL("network.enetmtu", mtu);
|
||||
host->mtu = mtu;
|
||||
host->mtu = g_ConfigDB.Get("network.enetmtu", HOST_DEFAULT_MTU);
|
||||
for (ENetPeer& p : PS::span{host->peers, host->peerCount})
|
||||
enet_peer_reset(&p);
|
||||
|
||||
|
||||
@@ -235,8 +235,7 @@ void CNetServerWorker::SetupUPnP(const u16 port)
|
||||
};
|
||||
|
||||
// Cached root descriptor URL.
|
||||
std::string rootDescURL;
|
||||
CFG_GET_VAL("network.upnprootdescurl", rootDescURL);
|
||||
const std::string rootDescURL{g_ConfigDB.Get("network.upnprootdescurl", std::string{})};
|
||||
if (!rootDescURL.empty())
|
||||
LOGMESSAGE("Net server: attempting to use cached root descriptor URL: %s", rootDescURL.c_str());
|
||||
|
||||
@@ -1000,12 +999,10 @@ bool CNetServerWorker::OnAuthenticate(CNetServerSession* session, CFsmEvent* eve
|
||||
return true;
|
||||
}
|
||||
|
||||
// Either deduplicate or prohibit join if name is in use
|
||||
bool duplicatePlayernames = false;
|
||||
CFG_GET_VAL("network.duplicateplayernames", duplicatePlayernames);
|
||||
// If lobby authentication is enabled, the clients playername has already been registered.
|
||||
// There also can't be any duplicated names.
|
||||
if (!server.m_LobbyAuth && duplicatePlayernames)
|
||||
// Either deduplicate or prohibit join if name is in use
|
||||
if (!server.m_LobbyAuth && g_ConfigDB.Get("network.duplicateplayernames", false))
|
||||
username = server.DeduplicatePlayerName(username);
|
||||
else
|
||||
{
|
||||
@@ -1028,9 +1025,6 @@ bool CNetServerWorker::OnAuthenticate(CNetServerSession* session, CFsmEvent* eve
|
||||
return true;
|
||||
}
|
||||
|
||||
int maxObservers = 0;
|
||||
CFG_GET_VAL("network.observerlimit", maxObservers);
|
||||
|
||||
bool isRejoining = false;
|
||||
bool serverFull = false;
|
||||
if (server.m_State == SERVER_STATE_PREGAME)
|
||||
@@ -1066,8 +1060,8 @@ bool CNetServerWorker::OnAuthenticate(CNetServerSession* session, CFsmEvent* eve
|
||||
// Optionally allow everyone or only buddies to join after the game has started
|
||||
if (!isRejoining)
|
||||
{
|
||||
CStr observerLateJoin;
|
||||
CFG_GET_VAL("network.lateobservers", observerLateJoin);
|
||||
const std::string observerLateJoin{
|
||||
g_ConfigDB.Get("network.lateobservers", std::string{})};
|
||||
|
||||
if (observerLateJoin == "everyone")
|
||||
{
|
||||
@@ -1075,9 +1069,8 @@ bool CNetServerWorker::OnAuthenticate(CNetServerSession* session, CFsmEvent* eve
|
||||
}
|
||||
else if (observerLateJoin == "buddies")
|
||||
{
|
||||
CStr buddies;
|
||||
CFG_GET_VAL("lobby.buddies", buddies);
|
||||
std::wstringstream buddiesStream(wstring_from_utf8(buddies));
|
||||
std::wstringstream buddiesStream(wstring_from_utf8(
|
||||
g_ConfigDB.Get("lobby.buddies", std::string{})));
|
||||
CStrW buddy;
|
||||
while (std::getline(buddiesStream, buddy, L','))
|
||||
{
|
||||
@@ -1099,7 +1092,8 @@ bool CNetServerWorker::OnAuthenticate(CNetServerSession* session, CFsmEvent* eve
|
||||
|
||||
// Ensure all players will be able to rejoin
|
||||
serverFull = isObserver && (
|
||||
(int) server.m_Sessions.size() - connectedPlayers > maxObservers ||
|
||||
(int) server.m_Sessions.size() - connectedPlayers >
|
||||
g_ConfigDB.Get("network.observerlimit", 0) ||
|
||||
(int) server.m_Sessions.size() + disconnectedPlayers >= MAX_CLIENTS);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -74,8 +74,7 @@ void CNetServerTurnManager::NotifyFinishedClientCommands(CNetServerSession& sess
|
||||
|
||||
void CNetServerTurnManager::CheckClientsReady()
|
||||
{
|
||||
int max_observer_lag = -1;
|
||||
CFG_GET_VAL("network.observermaxlag", max_observer_lag);
|
||||
int max_observer_lag{g_ConfigDB.Get("network.observermaxlag", -1)};
|
||||
// Clamp to 0-10000 turns, below/above that is no limit.
|
||||
max_observer_lag = max_observer_lag < 0 ? -1 : max_observer_lag > 10000 ? -1 : max_observer_lag;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* Copyright (C) 2013-2016 SuperTuxKart-Team.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
@@ -146,10 +146,8 @@ void SendStunRequest(ENetHost& transactionHost, ENetAddress addr)
|
||||
*/
|
||||
bool CreateStunRequest(ENetHost& transactionHost)
|
||||
{
|
||||
CStr server_name;
|
||||
int port;
|
||||
CFG_GET_VAL("lobby.stun.server", server_name);
|
||||
CFG_GET_VAL("lobby.stun.port", port);
|
||||
const std::string server_name{g_ConfigDB.Get("lobby.stun.server", std::string{})};
|
||||
const int port{g_ConfigDB.Get("lobby.stun.port", 0)};
|
||||
|
||||
LOGMESSAGE("StunClient: Using STUN server %s:%d\n", server_name.c_str(), port);
|
||||
|
||||
@@ -183,10 +181,8 @@ bool ReceiveStunResponse(ENetHost& transactionHost, std::vector<u8>& buffer)
|
||||
ENetAddress sender = m_StunServer;
|
||||
int len = enet_socket_receive(transactionHost.socket, &sender, &enetBuffer, 1);
|
||||
|
||||
int delay = 10;
|
||||
CFG_GET_VAL("lobby.stun.delay", delay);
|
||||
int maxTries = 100;
|
||||
CFG_GET_VAL("lobby.stun.max_tries", maxTries);
|
||||
const int delay{g_ConfigDB.Get("lobby.stun.delay", 10)};
|
||||
const int maxTries{g_ConfigDB.Get("lobby.stun.max_tries", 100)};
|
||||
|
||||
// Wait to receive the message because enet sockets are non-blocking
|
||||
for (int count = 0; len <= 0 && (count < maxTries || maxTries == -1); ++count)
|
||||
@@ -359,10 +355,8 @@ void SendHolePunchingMessages(ENetHost& enetClient, const std::string& serverAdd
|
||||
addr.port = serverPort;
|
||||
enet_address_set_host(&addr, serverAddress.c_str());
|
||||
|
||||
int delay = 200;
|
||||
CFG_GET_VAL("lobby.fw_punch.delay", delay);
|
||||
int numMsg = 3;
|
||||
CFG_GET_VAL("lobby.fw_punch.num_msg", numMsg);
|
||||
const int delay{g_ConfigDB.Get("lobby.fw_punch.delay", 200)};
|
||||
const int numMsg{g_ConfigDB.Get("lobby.fw_punch.num_msg", 3)};
|
||||
|
||||
// Send an UDP message from enet host to ip:port
|
||||
for (int i = 0; i < numMsg || numMsg == -1; ++i)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2022 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "scriptinterface/ScriptInterface.h"
|
||||
#include "scriptinterface/JSON.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include <wctype.h>
|
||||
@@ -85,8 +86,7 @@ CConsole::~CConsole() = default;
|
||||
void CConsole::Init()
|
||||
{
|
||||
// Initialise console history file
|
||||
m_MaxHistoryLines = 200;
|
||||
CFG_GET_VAL("console.history.size", m_MaxHistoryLines);
|
||||
m_MaxHistoryLines = g_ConfigDB.Get("console.history.size", 200);
|
||||
|
||||
m_HistoryFile = L"config/console.txt";
|
||||
LoadHistory();
|
||||
@@ -101,8 +101,7 @@ void CConsole::Init()
|
||||
// Offset by an arbitrary amount, to make it fit more nicely
|
||||
m_FontOffset = 7;
|
||||
|
||||
m_CursorBlinkRate = 0.5;
|
||||
CFG_GET_VAL("gui.cursorblinkrate", m_CursorBlinkRate);
|
||||
m_CursorBlinkRate = g_ConfigDB.Get("gui.cursorblinkrate", 0.5);
|
||||
}
|
||||
|
||||
void CConsole::UpdateScreenSize(int w, int h)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -97,7 +97,7 @@ typedef std::map<CStr, CConfigValueSet> TConfigMap;
|
||||
if (it != m_Map[CFG_COMMAND].end())\
|
||||
{\
|
||||
if (!it->second.empty())\
|
||||
Get(it->second[0], value);\
|
||||
::Get(it->second[0], value);\
|
||||
return;\
|
||||
}\
|
||||
for (int search_ns = ns; search_ns >= 0; --search_ns)\
|
||||
@@ -106,7 +106,7 @@ typedef std::map<CStr, CConfigValueSet> TConfigMap;
|
||||
if (it != m_Map[search_ns].end())\
|
||||
{\
|
||||
if (!it->second.empty())\
|
||||
Get(it->second[0], value);\
|
||||
::Get(it->second[0], value);\
|
||||
return;\
|
||||
}\
|
||||
}\
|
||||
|
||||
+18
-8
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2022 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -34,6 +34,8 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
@@ -94,6 +96,21 @@ public:
|
||||
///@copydoc CConfigDB::GetValue
|
||||
void GetValue(EConfigNamespace ns, const CStr& name, std::string& value);
|
||||
|
||||
template<typename T>
|
||||
[[nodiscard]] T Get(std::string name, T value, const EConfigNamespace ns = CFG_USER)
|
||||
{
|
||||
GetValue(ns, std::move(name), value);
|
||||
return value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
[[nodiscard]] static T GetIfInitialised(std::string name, T defaultValue,
|
||||
const EConfigNamespace ns = CFG_USER)
|
||||
{
|
||||
return IsInitialised() ? g_ConfigDB.Get(std::move(name), std::move(defaultValue), ns) :
|
||||
defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if changed with respect to last write on file
|
||||
*/
|
||||
@@ -234,11 +251,4 @@ private:
|
||||
std::multimap<CStr, std::function<void()>>::iterator m_Ptr;
|
||||
CConfigDB& m_ConfigDB;
|
||||
};
|
||||
|
||||
|
||||
// stores the value of the given key into <destination>. this quasi-template
|
||||
// convenience wrapper on top of GetValue simplifies user code
|
||||
#define CFG_GET_VAL(name, destination)\
|
||||
g_ConfigDB.GetValue(CFG_USER, name, destination)
|
||||
|
||||
#endif // INCLUDED_CONFIGDB
|
||||
|
||||
@@ -40,7 +40,7 @@ bool g_DisableAudio = false;
|
||||
// Fill in the globals from the config files.
|
||||
static void LoadGlobals()
|
||||
{
|
||||
CFG_GET_VAL("pauseonfocusloss", g_PauseOnFocusLoss);
|
||||
g_PauseOnFocusLoss = g_ConfigDB.Get("pauseonfocusloss", g_PauseOnFocusLoss);
|
||||
}
|
||||
|
||||
static void ProcessCommandLineArgs(const CmdLineArgs& args)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -100,6 +100,8 @@ extern void RestartEngine();
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
ERROR_GROUP(System);
|
||||
ERROR_TYPE(System, SDLInitFailed);
|
||||
ERROR_TYPE(System, VmodeFailed);
|
||||
@@ -308,9 +310,8 @@ static void InitSDL()
|
||||
#if OS_MACOSX
|
||||
// Some Mac mice only have one button, so they can't right-click
|
||||
// but SDL2 can emulate that with Ctrl+Click
|
||||
bool macMouse = false;
|
||||
CFG_GET_VAL("macmouse", macMouse);
|
||||
SDL_SetHint(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, macMouse ? "1" : "0");
|
||||
SDL_SetHint(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK,
|
||||
g_ConfigDB.Get("macmouse", false) ? "1" : "0");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -551,9 +552,8 @@ bool Init(const CmdLineArgs& args, int flags)
|
||||
mods = args.GetMultiple("mod");
|
||||
else
|
||||
{
|
||||
CStr modsStr;
|
||||
CFG_GET_VAL("mod.enabledmods", modsStr);
|
||||
boost::split(mods, modsStr, boost::algorithm::is_space(), boost::token_compress_on);
|
||||
boost::split(mods, g_ConfigDB.Get("mod.enabledmods", std::string{}),
|
||||
boost::algorithm::is_space(), boost::token_compress_on);
|
||||
}
|
||||
|
||||
if (!g_Mods.EnableMods(mods, flags & INIT_MODS_PUBLIC))
|
||||
@@ -596,9 +596,7 @@ bool Init(const CmdLineArgs& args, int flags)
|
||||
|
||||
// Optionally start profiler HTTP output automatically
|
||||
// (By default it's only enabled by a hotkey, for security/performance)
|
||||
bool profilerHTTPEnable = false;
|
||||
CFG_GET_VAL("profiler2.autoenable", profilerHTTPEnable);
|
||||
if (profilerHTTPEnable)
|
||||
if (g_ConfigDB.Get("profiler2.autoenable", false))
|
||||
g_Profiler2.EnableHTTP();
|
||||
|
||||
// Initialise everything except Win32 sockets (because our networking
|
||||
@@ -629,9 +627,7 @@ void InitGraphics(const CmdLineArgs& args, int flags, const std::vector<CStr>& i
|
||||
|
||||
// Optionally start profiler GPU timings automatically
|
||||
// (By default it's only enabled by a hotkey, for performance/compatibility)
|
||||
bool profilerGPUEnable = false;
|
||||
CFG_GET_VAL("profiler2.autoenable", profilerGPUEnable);
|
||||
if (profilerGPUEnable)
|
||||
if (g_ConfigDB.Get("profiler2.autoenable", false))
|
||||
g_Profiler2.EnableGPU();
|
||||
|
||||
if(g_DisableAudio)
|
||||
@@ -639,9 +635,8 @@ void InitGraphics(const CmdLineArgs& args, int flags, const std::vector<CStr>& i
|
||||
|
||||
g_GUI = new CGUIManager{scriptContext, scriptInterface};
|
||||
|
||||
CStr8 renderPath = "default";
|
||||
CFG_GET_VAL("renderpath", renderPath);
|
||||
if (RenderPathEnum::FromString(renderPath) == FIXED)
|
||||
|
||||
if (RenderPathEnum::FromString(g_ConfigDB.Get("renderpath", "default"s)) == FIXED)
|
||||
{
|
||||
// It doesn't make sense to continue working here, because we're not
|
||||
// able to display anything.
|
||||
|
||||
@@ -32,14 +32,10 @@ CJoystick::CJoystick() :
|
||||
|
||||
void CJoystick::Initialise()
|
||||
{
|
||||
bool joystickEnable = false;
|
||||
if (!CConfigDB::IsInitialised())
|
||||
return;
|
||||
CFG_GET_VAL("joystick.enable", joystickEnable);
|
||||
if (!joystickEnable)
|
||||
if (!CConfigDB::GetIfInitialised("joystick.enable", false))
|
||||
return;
|
||||
|
||||
CFG_GET_VAL("joystick.deadzone", m_Deadzone);
|
||||
m_Deadzone = g_ConfigDB.Get("joystick.deadzone", 0);
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0)
|
||||
{
|
||||
|
||||
@@ -182,15 +182,10 @@ void CProfiler2::EnableHTTP()
|
||||
if (m_MgContext)
|
||||
return;
|
||||
|
||||
CStr listeningPort = "8000";
|
||||
CStr listeningServer = "127.0.0.1";
|
||||
CStr numThreads = "6";
|
||||
if (CConfigDB::IsInitialised())
|
||||
{
|
||||
CFG_GET_VAL("profiler2.server.port", listeningPort);
|
||||
CFG_GET_VAL("profiler2.server", listeningServer);
|
||||
CFG_GET_VAL("profiler2.server.threads", numThreads);
|
||||
}
|
||||
using namespace std::literals;
|
||||
const std::string listeningPort{CConfigDB::GetIfInitialised("profiler2.server.port", "8000"s)};
|
||||
const std::string listeningServer{CConfigDB::GetIfInitialised("profiler2.server", "127.0.0.1"s)};
|
||||
const std::string numThreads{CConfigDB::GetIfInitialised("profiler2.server.threads", "6"s)};
|
||||
|
||||
std::string listening_ports = fmt::format("{0}:{1}", listeningServer, listeningPort);
|
||||
const char* options[] = {
|
||||
|
||||
@@ -253,10 +253,7 @@ private:
|
||||
CProfiler2GPU::CProfiler2GPU(CProfiler2& profiler) :
|
||||
m_Profiler(profiler)
|
||||
{
|
||||
bool enabledARB = false;
|
||||
CFG_GET_VAL("profiler2.gpu.arb.enable", enabledARB);
|
||||
|
||||
if (enabledARB && CProfiler2GPUARB::IsSupported())
|
||||
if (g_ConfigDB.Get("profiler2.gpu.arb.enable", false) && CProfiler2GPUARB::IsSupported())
|
||||
{
|
||||
m_ProfilerARB = std::make_unique<CProfiler2GPUARB>(m_Profiler);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2022 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -518,10 +518,8 @@ CUserReporter::~CUserReporter()
|
||||
|
||||
std::string CUserReporter::LoadUserID()
|
||||
{
|
||||
std::string userID;
|
||||
|
||||
// Read the user ID from user.cfg (if there is one)
|
||||
CFG_GET_VAL("userreport.id", userID);
|
||||
std::string userID{g_ConfigDB.Get("userreport.id", std::string{})};
|
||||
|
||||
// If we don't have a validly-formatted user ID, generate a new one
|
||||
if (userID.length() != 16)
|
||||
@@ -547,9 +545,7 @@ std::string CUserReporter::LoadUserID()
|
||||
|
||||
bool CUserReporter::IsReportingEnabled()
|
||||
{
|
||||
int version = -1;
|
||||
CFG_GET_VAL("userreport.enabledversion", version);
|
||||
return (version >= REPORTER_VERSION);
|
||||
return g_ConfigDB.Get("userreport.enabledversion", -1) >= REPORTER_VERSION;
|
||||
}
|
||||
|
||||
void CUserReporter::SetReportingEnabled(bool enabled)
|
||||
@@ -574,12 +570,8 @@ void CUserReporter::Initialize()
|
||||
{
|
||||
ENSURE(!m_Worker); // must only be called once
|
||||
|
||||
std::string userID = LoadUserID();
|
||||
std::string url;
|
||||
CFG_GET_VAL("userreport.url_upload", url);
|
||||
|
||||
m_Worker = new CUserReporterWorker(userID, url);
|
||||
|
||||
m_Worker = new CUserReporterWorker{LoadUserID(),
|
||||
g_ConfigDB.Get("userreport.url_upload", std::string{})};
|
||||
m_Worker->SetEnabled(IsReportingEnabled());
|
||||
}
|
||||
|
||||
|
||||
+26
-44
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -49,6 +49,8 @@
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@@ -141,9 +143,7 @@ private:
|
||||
|
||||
CVideoMode::CCursor::CCursor()
|
||||
{
|
||||
std::string cursorBackend;
|
||||
CFG_GET_VAL("cursorbackend", cursorBackend);
|
||||
if (cursorBackend == "sdl")
|
||||
if (g_ConfigDB.Get("cursorbackend", std::string{}) == "sdl")
|
||||
m_CursorBackend = CursorBackend::SDL;
|
||||
else
|
||||
m_CursorBackend = CursorBackend::SYSTEM;
|
||||
@@ -275,21 +275,18 @@ CVideoMode::~CVideoMode() = default;
|
||||
|
||||
void CVideoMode::ReadConfig()
|
||||
{
|
||||
bool windowed = !m_ConfigFullscreen;
|
||||
CFG_GET_VAL("windowed", windowed);
|
||||
m_ConfigFullscreen = !windowed;
|
||||
m_ConfigFullscreen = !g_ConfigDB.Get("windowed", !m_ConfigFullscreen);
|
||||
|
||||
CFG_GET_VAL("gui.scale", m_Scale);
|
||||
m_Scale = g_ConfigDB.Get("gui.scale", m_Scale);
|
||||
|
||||
CFG_GET_VAL("xres", m_ConfigW);
|
||||
CFG_GET_VAL("yres", m_ConfigH);
|
||||
CFG_GET_VAL("bpp", m_ConfigBPP);
|
||||
CFG_GET_VAL("display", m_ConfigDisplay);
|
||||
CFG_GET_VAL("hidpi", m_ConfigEnableHiDPI);
|
||||
CFG_GET_VAL("vsync", m_ConfigVSync);
|
||||
m_ConfigW = g_ConfigDB.Get("xres", m_ConfigW);
|
||||
m_ConfigH = g_ConfigDB.Get("yres", m_ConfigH);
|
||||
m_ConfigBPP = g_ConfigDB.Get("bpp", m_ConfigBPP);
|
||||
m_ConfigDisplay = g_ConfigDB.Get("display", m_ConfigDisplay);
|
||||
m_ConfigEnableHiDPI = g_ConfigDB.Get("hidpi", m_ConfigEnableHiDPI);
|
||||
m_ConfigVSync = g_ConfigDB.Get("vsync", m_ConfigVSync);
|
||||
|
||||
CStr rendererBackend;
|
||||
CFG_GET_VAL("rendererbackend", rendererBackend);
|
||||
const std::string rendererBackend{g_ConfigDB.Get("rendererbackend", std::string{})};
|
||||
if (rendererBackend == "glarb")
|
||||
m_Backend = Renderer::Backend::Backend::GL_ARB;
|
||||
else if (rendererBackend == "dummy")
|
||||
@@ -310,17 +307,11 @@ bool CVideoMode::SetVideoMode(int w, int h, int bpp, bool fullscreen)
|
||||
Uint32 flags = 0;
|
||||
if (fullscreen)
|
||||
{
|
||||
bool borderlessFullscreen = true;
|
||||
CFG_GET_VAL("borderless.fullscreen", borderlessFullscreen);
|
||||
flags |= borderlessFullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_FULLSCREEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool borderlessWindow = false;
|
||||
CFG_GET_VAL("borderless.window", borderlessWindow);
|
||||
if (borderlessWindow)
|
||||
flags |= SDL_WINDOW_BORDERLESS;
|
||||
flags |= g_ConfigDB.Get("borderless.fullscreen", true) ? SDL_WINDOW_FULLSCREEN_DESKTOP :
|
||||
SDL_WINDOW_FULLSCREEN;
|
||||
}
|
||||
else if (g_ConfigDB.Get("borderless.window", false))
|
||||
flags |= SDL_WINDOW_BORDERLESS;
|
||||
|
||||
if (!m_Window)
|
||||
{
|
||||
@@ -334,21 +325,14 @@ bool CVideoMode::SetVideoMode(int w, int h, int bpp, bool fullscreen)
|
||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
|
||||
bool debugContext = false;
|
||||
CFG_GET_VAL("renderer.backend.debugcontext", debugContext);
|
||||
if (debugContext)
|
||||
if (g_ConfigDB.Get("renderer.backend.debugcontext", false))
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
|
||||
|
||||
bool forceGLVersion = false;
|
||||
CFG_GET_VAL("forceglversion", forceGLVersion);
|
||||
if (forceGLVersion)
|
||||
if (g_ConfigDB.Get("forceglversion", false))
|
||||
{
|
||||
CStr forceGLProfile = "compatibility";
|
||||
int forceGLMajorVersion = 3;
|
||||
int forceGLMinorVersion = 0;
|
||||
CFG_GET_VAL("forceglprofile", forceGLProfile);
|
||||
CFG_GET_VAL("forceglmajorversion", forceGLMajorVersion);
|
||||
CFG_GET_VAL("forceglminorversion", forceGLMinorVersion);
|
||||
const std::string forceGLProfile{g_ConfigDB.Get("forceglprofile", "compatibility"s)};
|
||||
const int forceGLMajorVersion{g_ConfigDB.Get("forceglmajorversion", 3)};
|
||||
const int forceGLMinorVersion{g_ConfigDB.Get("forceglminorversion", 0)};
|
||||
|
||||
int profile = SDL_GL_CONTEXT_PROFILE_COMPATIBILITY;
|
||||
if (forceGLProfile == "es")
|
||||
@@ -517,13 +501,11 @@ bool CVideoMode::SetVideoMode(int w, int h, int bpp, bool fullscreen)
|
||||
|
||||
// #545: we need to constrain the window in fullscreen mode to avoid mouse
|
||||
// "falling out" of the window in case of multiple displays.
|
||||
bool mouseGrabInFullscreen = true;
|
||||
CFG_GET_VAL("window.mousegrabinfullscreen", mouseGrabInFullscreen);
|
||||
bool mouseGrabInWindowMode = false;
|
||||
CFG_GET_VAL("window.mousegrabinwindowmode", mouseGrabInWindowMode);
|
||||
|
||||
if (fullscreen ? mouseGrabInFullscreen : mouseGrabInWindowMode)
|
||||
if (fullscreen ? g_ConfigDB.Get("window.mousegrabinfullscreen", true) :
|
||||
g_ConfigDB.Get("window.mousegrabinwindowmode", false))
|
||||
{
|
||||
SDL_SetWindowGrab(m_Window, SDL_TRUE);
|
||||
}
|
||||
else
|
||||
SDL_SetWindowGrab(m_Window, SDL_FALSE);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -161,9 +161,7 @@ void CPostprocManager::Initialize()
|
||||
UpdateAntiAliasingTechnique();
|
||||
UpdateSharpeningTechnique();
|
||||
UpdateSharpnessFactor();
|
||||
CStr upscaleName;
|
||||
CFG_GET_VAL("renderer.upscale.technique", upscaleName);
|
||||
SetUpscaleTechnique(upscaleName);
|
||||
SetUpscaleTechnique(g_ConfigDB.Get("renderer.upscale.technique", std::string{}));
|
||||
|
||||
// This might happen after the map is loaded and the effect chosen
|
||||
SetPostEffect(m_PostProcEffect);
|
||||
@@ -762,8 +760,7 @@ void CPostprocManager::UpdateAntiAliasingTechnique()
|
||||
if (m_Device->GetBackend() == Renderer::Backend::Backend::GL_ARB || !m_IsInitialized)
|
||||
return;
|
||||
|
||||
CStr newAAName;
|
||||
CFG_GET_VAL("antialiasing", newAAName);
|
||||
const std::string newAAName{g_ConfigDB.Get("antialiasing", std::string{})};
|
||||
if (m_AAName == newAAName)
|
||||
return;
|
||||
m_AAName = newAAName;
|
||||
@@ -812,8 +809,7 @@ void CPostprocManager::UpdateSharpeningTechnique()
|
||||
if (m_Device->GetBackend() == Renderer::Backend::Backend::GL_ARB || !m_IsInitialized)
|
||||
return;
|
||||
|
||||
CStr newSharpName;
|
||||
CFG_GET_VAL("sharpening", newSharpName);
|
||||
const std::string newSharpName{g_ConfigDB.Get("sharpening", std::string{})};
|
||||
if (m_SharpName == newSharpName)
|
||||
return;
|
||||
m_SharpName = newSharpName;
|
||||
@@ -827,7 +823,7 @@ void CPostprocManager::UpdateSharpeningTechnique()
|
||||
|
||||
void CPostprocManager::UpdateSharpnessFactor()
|
||||
{
|
||||
CFG_GET_VAL("sharpness", m_Sharpness);
|
||||
m_Sharpness = g_ConfigDB.Get("sharpness", m_Sharpness);
|
||||
}
|
||||
|
||||
void CPostprocManager::SetUpscaleTechnique(const CStr& upscaleName)
|
||||
@@ -936,7 +932,7 @@ void CPostprocManager::RecalculateSize(const uint32_t width, const uint32_t heig
|
||||
m_Scale = 1.0f;
|
||||
return;
|
||||
}
|
||||
CFG_GET_VAL("renderer.scale", m_Scale);
|
||||
m_Scale = g_ConfigDB.Get("renderer.scale", m_Scale);
|
||||
if (m_Scale < 0.25f || m_Scale > 2.0f)
|
||||
{
|
||||
LOGWARNING("Invalid renderer scale: %0.2f", m_Scale);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -702,10 +702,9 @@ void CRenderer::RenderBigScreenShot(const bool needsPresent)
|
||||
if (!g_Game)
|
||||
return RenderScreenShot(needsPresent);
|
||||
|
||||
int tiles = 4, tileWidth = 256, tileHeight = 256;
|
||||
CFG_GET_VAL("screenshot.tiles", tiles);
|
||||
CFG_GET_VAL("screenshot.tilewidth", tileWidth);
|
||||
CFG_GET_VAL("screenshot.tileheight", tileHeight);
|
||||
const int tiles{g_ConfigDB.Get("screenshot.tiles", 4)};
|
||||
const int tileWidth{g_ConfigDB.Get("screenshot.tilewidth", 256)};
|
||||
const int tileHeight{g_ConfigDB.Get("screenshot.tileheight", 256)};
|
||||
if (tiles <= 0 || tileWidth <= 0 || tileHeight <= 0 || tileWidth * tiles % 4 != 0 || tileHeight * tiles % 4 != 0)
|
||||
{
|
||||
LOGWARNING("Invalid big screenshot size: tiles=%d tileWidth=%d tileHeight=%d", tiles, tileWidth, tileHeight);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -42,7 +42,9 @@ public:
|
||||
template<typename T>
|
||||
void Setup(CStr8 name, T& variable)
|
||||
{
|
||||
hooks.emplace_back(g_ConfigDB.RegisterHookAndCall(name, [name, &variable]() { CFG_GET_VAL(name, variable); }));
|
||||
hooks.emplace_back(g_ConfigDB.RegisterHookAndCall(name, [name, &variable]() {
|
||||
variable = g_ConfigDB.Get(name, variable);
|
||||
}));
|
||||
}
|
||||
void Setup(CStr8 name, std::function<void()> hook)
|
||||
{
|
||||
@@ -141,9 +143,7 @@ CRenderingOptions::~CRenderingOptions()
|
||||
void CRenderingOptions::ReadConfigAndSetupHooks()
|
||||
{
|
||||
m_ConfigHooks->Setup("renderpath", [this]() {
|
||||
CStr renderPath;
|
||||
CFG_GET_VAL("renderpath", renderPath);
|
||||
SetRenderPath(RenderPathEnum::FromString(renderPath));
|
||||
SetRenderPath(RenderPathEnum::FromString(g_ConfigDB.Get("renderpath", std::string{})));
|
||||
});
|
||||
|
||||
m_ConfigHooks->Setup("shadowquality", []() {
|
||||
@@ -170,14 +170,10 @@ void CRenderingOptions::ReadConfigAndSetupHooks()
|
||||
});
|
||||
|
||||
m_ConfigHooks->Setup("shadows", [this]() {
|
||||
bool enabled;
|
||||
CFG_GET_VAL("shadows", enabled);
|
||||
SetShadows(enabled);
|
||||
SetShadows(g_ConfigDB.Get("shadows", false));
|
||||
});
|
||||
m_ConfigHooks->Setup("shadowpcf", [this]() {
|
||||
bool enabled;
|
||||
CFG_GET_VAL("shadowpcf", enabled);
|
||||
SetShadowPCF(enabled);
|
||||
SetShadowPCF(g_ConfigDB.Get("shadowpcf", false));
|
||||
});
|
||||
|
||||
m_ConfigHooks->Setup("postproc", m_PostProc);
|
||||
@@ -205,64 +201,53 @@ void CRenderingOptions::ReadConfigAndSetupHooks()
|
||||
|
||||
m_ConfigHooks->Setup("renderer.upscale.technique", []()
|
||||
{
|
||||
CStr upscaleName;
|
||||
CFG_GET_VAL("renderer.upscale.technique", upscaleName);
|
||||
if (CRenderer::IsInitialised())
|
||||
g_Renderer.GetPostprocManager().SetUpscaleTechnique(upscaleName);
|
||||
if (!CRenderer::IsInitialised())
|
||||
return;
|
||||
g_Renderer.GetPostprocManager().SetUpscaleTechnique(
|
||||
g_ConfigDB.Get("renderer.upscale.technique", std::string{}));
|
||||
});
|
||||
|
||||
m_ConfigHooks->Setup("smoothlos", m_SmoothLOS);
|
||||
|
||||
m_ConfigHooks->Setup("watereffects", [this]() {
|
||||
bool enabled;
|
||||
CFG_GET_VAL("watereffects", enabled);
|
||||
SetWaterEffects(enabled);
|
||||
SetWaterEffects(g_ConfigDB.Get("watereffects", false));
|
||||
if (CRenderer::IsInitialised())
|
||||
g_Renderer.GetSceneRenderer().GetWaterManager().RecreateOrLoadTexturesIfNeeded();
|
||||
});
|
||||
m_ConfigHooks->Setup("waterfancyeffects", [this]() {
|
||||
bool enabled;
|
||||
CFG_GET_VAL("waterfancyeffects", enabled);
|
||||
SetWaterFancyEffects(enabled);
|
||||
SetWaterFancyEffects(g_ConfigDB.Get("waterfancyeffects", false));
|
||||
if (CRenderer::IsInitialised())
|
||||
g_Renderer.GetSceneRenderer().GetWaterManager().RecreateOrLoadTexturesIfNeeded();
|
||||
});
|
||||
m_ConfigHooks->Setup("waterrealdepth", m_WaterRealDepth);
|
||||
m_ConfigHooks->Setup("waterrefraction", [this]() {
|
||||
bool enabled;
|
||||
CFG_GET_VAL("waterrefraction", enabled);
|
||||
SetWaterRefraction(enabled);
|
||||
SetWaterRefraction(g_ConfigDB.Get("waterrefraction", false));
|
||||
if (CRenderer::IsInitialised())
|
||||
g_Renderer.GetSceneRenderer().GetWaterManager().RecreateOrLoadTexturesIfNeeded();
|
||||
});
|
||||
m_ConfigHooks->Setup("waterreflection", [this]() {
|
||||
bool enabled;
|
||||
CFG_GET_VAL("waterreflection", enabled);
|
||||
SetWaterReflection(enabled);
|
||||
SetWaterReflection(g_ConfigDB.Get("waterreflection", false));
|
||||
if (CRenderer::IsInitialised())
|
||||
g_Renderer.GetSceneRenderer().GetWaterManager().RecreateOrLoadTexturesIfNeeded();
|
||||
});
|
||||
|
||||
m_ConfigHooks->Setup("particles", m_Particles);
|
||||
m_ConfigHooks->Setup("fog", [this]() {
|
||||
bool enabled;
|
||||
CFG_GET_VAL("fog", enabled);
|
||||
SetFog(enabled);
|
||||
SetFog(g_ConfigDB.Get("fog", false));
|
||||
});
|
||||
m_ConfigHooks->Setup("silhouettes", m_Silhouettes);
|
||||
|
||||
m_ConfigHooks->Setup("gpuskinning", [this]() {
|
||||
bool enabled;
|
||||
CFG_GET_VAL("gpuskinning", enabled);
|
||||
;
|
||||
const Renderer::Backend::IDevice::Capabilities& capabilities{
|
||||
g_VideoMode.GetBackendDevice()->GetCapabilities()};
|
||||
if (enabled)
|
||||
{
|
||||
if (capabilities.computeShaders && capabilities.storage)
|
||||
m_GPUSkinning = true;
|
||||
else
|
||||
LOGMESSAGE("GPU skinning isn't supported on the current hardware.");
|
||||
}
|
||||
if (!g_ConfigDB.Get("gpuskinning", false))
|
||||
return;
|
||||
|
||||
if (capabilities.computeShaders && capabilities.storage)
|
||||
m_GPUSkinning = true;
|
||||
else
|
||||
LOGMESSAGE("GPU skinning isn't supported on the current hardware.");
|
||||
});
|
||||
|
||||
m_ConfigHooks->Setup("renderactors", m_RenderActors);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -122,14 +122,12 @@ struct ShadowMapInternals
|
||||
|
||||
void ShadowMapInternals::UpdateCascadesParameters()
|
||||
{
|
||||
CascadeCount = 1;
|
||||
CFG_GET_VAL("shadowscascadecount", CascadeCount);
|
||||
CascadeCount = g_ConfigDB.Get("shadowscascadecount", 1);
|
||||
|
||||
if (CascadeCount < 1 || CascadeCount > MAX_CASCADE_COUNT || Device->GetBackend() == Renderer::Backend::Backend::GL_ARB)
|
||||
CascadeCount = 1;
|
||||
|
||||
ShadowsCoverMap = false;
|
||||
CFG_GET_VAL("shadowscovermap", ShadowsCoverMap);
|
||||
ShadowsCoverMap = g_ConfigDB.Get("shadowscovermap", false);
|
||||
}
|
||||
|
||||
void CalculateBoundsForCascade(
|
||||
@@ -282,8 +280,8 @@ void ShadowMap::SetupFrame(const CCamera& camera, const CVector3D& lightdir)
|
||||
|
||||
m->ShadowsCutoffDistance = DEFAULT_SHADOWS_CUTOFF_DISTANCE;
|
||||
m->CascadeDistanceRatio = DEFAULT_CASCADE_DISTANCE_RATIO;
|
||||
CFG_GET_VAL("shadowscutoffdistance", m->ShadowsCutoffDistance);
|
||||
CFG_GET_VAL("shadowscascadedistanceratio", m->CascadeDistanceRatio);
|
||||
m->ShadowsCutoffDistance = g_ConfigDB.Get("shadowscutoffdistance", m->ShadowsCutoffDistance);
|
||||
m->CascadeDistanceRatio = g_ConfigDB.Get("shadowscascadedistanceratio", m->CascadeDistanceRatio);
|
||||
m->CascadeDistanceRatio = Clamp(m->CascadeDistanceRatio, 1.1f, 16.0f);
|
||||
|
||||
m->Cascades[GetCascadeCount() - 1].Distance = m->ShadowsCutoffDistance;
|
||||
@@ -480,7 +478,7 @@ void ShadowMapInternals::CreateTexture()
|
||||
Texture.reset();
|
||||
DummyTexture.reset();
|
||||
|
||||
CFG_GET_VAL("shadowquality", QualityLevel);
|
||||
QualityLevel = g_ConfigDB.Get("shadowquality", QualityLevel);
|
||||
|
||||
// Get shadow map size as next power of two up from view width/height.
|
||||
int shadowMapSize;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -39,11 +39,11 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
SkyManager::SkyManager()
|
||||
: m_VertexArray(Renderer::Backend::IBuffer::Type::VERTEX,
|
||||
Renderer::Backend::IBuffer::Usage::TRANSFER_DST)
|
||||
SkyManager::SkyManager() :
|
||||
m_VertexArray{Renderer::Backend::IBuffer::Type::VERTEX,
|
||||
Renderer::Backend::IBuffer::Usage::TRANSFER_DST},
|
||||
m_SkyVisible{g_ConfigDB.Get("showsky", true)}
|
||||
{
|
||||
CFG_GET_VAL("showsky", m_SkyVisible);
|
||||
}
|
||||
|
||||
void SkyManager::LoadAndUploadSkyTexturesIfNeeded(
|
||||
|
||||
@@ -347,9 +347,7 @@ std::unique_ptr<IDevice> CDevice::Create(SDL_Window* window, const bool arb)
|
||||
}
|
||||
|
||||
// Some drivers might invalidate an incorrect surface which leads to artifacts.
|
||||
bool enableFramebufferInvalidating = false;
|
||||
CFG_GET_VAL("renderer.backend.gl.enableframebufferinvalidating", enableFramebufferInvalidating);
|
||||
if (enableFramebufferInvalidating)
|
||||
if (g_ConfigDB.Get("renderer.backend.gl.enableframebufferinvalidating", false))
|
||||
{
|
||||
#if CONFIG2_GLES
|
||||
device->m_UseFramebufferInvalidating = ogl_HaveExtension("GL_EXT_discard_framebuffer");
|
||||
@@ -410,12 +408,9 @@ std::unique_ptr<IDevice> CDevice::Create(SDL_Window* window, const bool arb)
|
||||
if (hasDebug)
|
||||
{
|
||||
#ifdef NDEBUG
|
||||
bool enableDebugMessages = false;
|
||||
CFG_GET_VAL("renderer.backend.debugmessages", enableDebugMessages);
|
||||
capabilities.debugLabels = false;
|
||||
CFG_GET_VAL("renderer.backend.debuglabels", capabilities.debugLabels);
|
||||
capabilities.debugScopedLabels = false;
|
||||
CFG_GET_VAL("renderer.backend.debugscopedlabels", capabilities.debugScopedLabels);
|
||||
const bool enableDebugMessages{g_ConfigDB.Get("renderer.backend.debugmessages", false)};
|
||||
capabilities.debugLabels = g_ConfigDB.Get("renderer.backend.debuglabels", false);
|
||||
capabilities.debugScopedLabels = g_ConfigDB.Get("renderer.backend.debugscopedlabels", false);
|
||||
#else
|
||||
const bool enableDebugMessages = true;
|
||||
capabilities.debugLabels = true;
|
||||
@@ -987,10 +982,8 @@ void CDevice::Present()
|
||||
ogl_WarnIfError();
|
||||
}
|
||||
|
||||
bool checkGLErrorAfterSwap = false;
|
||||
CFG_GET_VAL("gl.checkerrorafterswap", checkGLErrorAfterSwap);
|
||||
#if defined(NDEBUG)
|
||||
if (!checkGLErrorAfterSwap)
|
||||
if (!g_ConfigDB.Get("gl.checkerrorafterswap", false))
|
||||
return;
|
||||
#endif
|
||||
PROFILE3("error check");
|
||||
|
||||
@@ -200,12 +200,9 @@ std::unique_ptr<CDevice> CDevice::Create(SDL_Window* window)
|
||||
device->m_Window = window;
|
||||
|
||||
#ifdef NDEBUG
|
||||
bool enableDebugMessages = false;
|
||||
CFG_GET_VAL("renderer.backend.debugmessages", enableDebugMessages);
|
||||
bool enableDebugLabels = false;
|
||||
CFG_GET_VAL("renderer.backend.debuglabels", enableDebugLabels);
|
||||
bool enableDebugScopedLabels = false;
|
||||
CFG_GET_VAL("renderer.backend.debugscopedlabels", enableDebugScopedLabels);
|
||||
bool enableDebugMessages{g_ConfigDB.Get("renderer.backend.debugmessages", false)};
|
||||
bool enableDebugLabels{g_ConfigDB.Get("renderer.backend.debuglabels", false)};
|
||||
bool enableDebugScopedLabels{g_ConfigDB.Get("renderer.backend.debugscopedlabels", false)};
|
||||
#else
|
||||
bool enableDebugMessages = true;
|
||||
bool enableDebugLabels = true;
|
||||
@@ -241,8 +238,7 @@ std::unique_ptr<CDevice> CDevice::Create(SDL_Window* window)
|
||||
};
|
||||
|
||||
#ifdef NDEBUG
|
||||
bool enableDebugContext = false;
|
||||
CFG_GET_VAL("renderer.backend.debugcontext", enableDebugContext);
|
||||
bool enableDebugContext{g_ConfigDB.Get("renderer.backend.debugcontext", false)};
|
||||
#else
|
||||
bool enableDebugContext = true;
|
||||
#endif
|
||||
@@ -389,8 +385,7 @@ std::unique_ptr<CDevice> CDevice::Create(SDL_Window* window)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int deviceIndexOverride = -1;
|
||||
CFG_GET_VAL("renderer.backend.vulkan.deviceindexoverride", deviceIndexOverride);
|
||||
const int deviceIndexOverride{g_ConfigDB.Get("renderer.backend.vulkan.deviceindexoverride", -1)};
|
||||
auto choosedDeviceIt = device->m_AvailablePhysicalDevices.end();
|
||||
if (deviceIndexOverride >= 0)
|
||||
{
|
||||
@@ -613,9 +608,8 @@ std::unique_ptr<CDevice> CDevice::Create(SDL_Window* window)
|
||||
if (!device->m_SubmitScheduler)
|
||||
return nullptr;
|
||||
|
||||
bool disableDescriptorIndexing = false;
|
||||
CFG_GET_VAL("renderer.backend.vulkan.disabledescriptorindexing", disableDescriptorIndexing);
|
||||
const bool useDescriptorIndexing = hasNeededDescriptorIndexingFeatures && !disableDescriptorIndexing;
|
||||
const bool useDescriptorIndexing{hasNeededDescriptorIndexingFeatures &&
|
||||
!g_ConfigDB.Get("renderer.backend.vulkan.disabledescriptorindexing", false)};
|
||||
device->m_DescriptorManager =
|
||||
std::make_unique<CDescriptorManager>(device.get(), useDescriptorIndexing);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -331,7 +331,7 @@ std::unique_ptr<IDeviceCommandContext> CDeviceCommandContext::Create(CDevice* de
|
||||
deviceCommandContext->m_UniformUploadRing = std::make_unique<CUploadRing>(
|
||||
device, IBuffer::Type::UNIFORM, UNIFORM_BUFFER_INITIAL_SIZE);
|
||||
|
||||
CFG_GET_VAL(
|
||||
deviceCommandContext->m_DebugBarrierAfterFramebufferPass = g_ConfigDB.Get(
|
||||
"renderer.backend.vulkan.debugbarrierafterframebufferpass",
|
||||
deviceCommandContext->m_DebugBarrierAfterFramebufferPass);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -73,9 +73,15 @@ std::unique_ptr<CSubmitScheduler> CSubmitScheduler::Create(
|
||||
if (!submitScheduler->m_PresentCommandContext)
|
||||
return nullptr;
|
||||
|
||||
CFG_GET_VAL("renderer.backend.vulkan.debugwaitidlebeforeacquire", submitScheduler->m_DebugWaitIdleBeforeAcquire);
|
||||
CFG_GET_VAL("renderer.backend.vulkan.debugwaitidlebeforepresent", submitScheduler->m_DebugWaitIdleBeforePresent);
|
||||
CFG_GET_VAL("renderer.backend.vulkan.debugwaitidleafterpresent", submitScheduler->m_DebugWaitIdleAfterPresent);
|
||||
submitScheduler->m_DebugWaitIdleBeforeAcquire = g_ConfigDB.Get(
|
||||
"renderer.backend.vulkan.debugwaitidlebeforeacquire",
|
||||
submitScheduler->m_DebugWaitIdleBeforeAcquire);
|
||||
submitScheduler->m_DebugWaitIdleBeforePresent = g_ConfigDB.Get(
|
||||
"renderer.backend.vulkan.debugwaitidlebeforepresent",
|
||||
submitScheduler->m_DebugWaitIdleBeforePresent);
|
||||
submitScheduler->m_DebugWaitIdleAfterPresent = g_ConfigDB.Get(
|
||||
"renderer.backend.vulkan.debugwaitidleafterpresent",
|
||||
submitScheduler->m_DebugWaitIdleAfterPresent);
|
||||
|
||||
return submitScheduler;
|
||||
}
|
||||
@@ -112,7 +118,7 @@ bool CSubmitScheduler::AcquireNextImage(CSwapChain& swapChain)
|
||||
if (!swapChain.AcquireNextImage(frameObject.acquireImageSemaphore))
|
||||
return false;
|
||||
swapChain.SubmitCommandsAfterAcquireNextImage(*m_AcquireCommandContext);
|
||||
|
||||
|
||||
m_NextWaitSemaphore = frameObject.acquireImageSemaphore;
|
||||
m_NextWaitDstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
m_AcquireCommandContext->Flush();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -47,7 +47,7 @@ std::unique_ptr<CSwapChain> CSwapChain::Create(
|
||||
std::unique_ptr<CSwapChain> oldSwapChain)
|
||||
{
|
||||
VkPhysicalDevice physicalDevice = device->GetChoosenPhysicalDevice().device;
|
||||
|
||||
|
||||
VkSurfaceCapabilitiesKHR surfaceCapabilities{};
|
||||
ENSURE_VK_SUCCESS(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
|
||||
physicalDevice, surface, &surfaceCapabilities));
|
||||
@@ -95,9 +95,7 @@ std::unique_ptr<CSwapChain> CSwapChain::Create(
|
||||
{
|
||||
return std::find(presentModes.begin(), presentModes.end(), presentMode) != presentModes.end();
|
||||
};
|
||||
bool vsyncEnabled = true;
|
||||
CFG_GET_VAL("vsync", vsyncEnabled);
|
||||
if (vsyncEnabled)
|
||||
if (g_ConfigDB.Get("vsync", true))
|
||||
{
|
||||
// TODO: use the adaptive one when possible.
|
||||
// https://gitlab.freedesktop.org/mesa/mesa/-/issues/5516
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -56,23 +56,18 @@ public:
|
||||
CSimulation2Impl(CUnitManager* unitManager, ScriptContext& cx, CTerrain* terrain) :
|
||||
m_SimContext{terrain, unitManager},
|
||||
m_ComponentManager{m_SimContext, cx},
|
||||
m_InitAttributes{cx.GetGeneralJSContext()},
|
||||
m_MapSettings{cx.GetGeneralJSContext()},
|
||||
m_InitAttributes{cx.GetGeneralJSContext()}
|
||||
// Tests won't have config initialised
|
||||
m_EnableOOSLog{CConfigDB::GetIfInitialised("ooslog", false)},
|
||||
m_EnableSerializationTest{CConfigDB::GetIfInitialised("serializationtest", false)},
|
||||
// Handle bogus values of the arg
|
||||
m_RejoinTestTurn{std::max(CConfigDB::GetIfInitialised("rejointest", -1), -1)}
|
||||
{
|
||||
m_ComponentManager.LoadComponentTypes();
|
||||
|
||||
RegisterFileReloadFunc(ReloadChangedFileCB, this);
|
||||
|
||||
// Tests won't have config initialised
|
||||
if (CConfigDB::IsInitialised())
|
||||
{
|
||||
CFG_GET_VAL("ooslog", m_EnableOOSLog);
|
||||
CFG_GET_VAL("serializationtest", m_EnableSerializationTest);
|
||||
CFG_GET_VAL("rejointest", m_RejoinTestTurn);
|
||||
if (m_RejoinTestTurn < 0) // Handle bogus values of the arg
|
||||
m_RejoinTestTurn = -1;
|
||||
}
|
||||
|
||||
if (m_EnableOOSLog)
|
||||
{
|
||||
m_OOSLogPath = createDateIndexSubdirectory(psLogDir() / "oos_logs");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -134,8 +134,7 @@ JS::Value GetEdgesOfStaticObstructionsOnScreenNearTo(const ScriptInterface& scri
|
||||
Script::CreateArray(rq, &edgeList);
|
||||
int edgeListIndex = 0;
|
||||
|
||||
float distanceThreshold = 10.0f;
|
||||
CFG_GET_VAL("gui.session.snaptoedgesdistancethreshold", distanceThreshold);
|
||||
const float distanceThreshold{g_ConfigDB.Get("gui.session.snaptoedgesdistancethreshold", 10.0f)};
|
||||
CFixedVector2D entityPos(x, z);
|
||||
|
||||
std::vector<entity_id_t> entities = GetEntitiesWithStaticObstructionOnScreen();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -238,19 +238,17 @@ CSoundManager::CSoundManager(ALCdevice* device)
|
||||
: m_Context(nullptr), m_Device(device), m_ALSourceBuffer(nullptr),
|
||||
m_CurrentTune(nullptr), m_CurrentEnvirons(nullptr),
|
||||
m_Worker(nullptr), m_DistressMutex(), m_PlayListItems(nullptr), m_SoundGroups(),
|
||||
m_Gain(.5f), m_MusicGain(.5f), m_AmbientGain(.5f), m_ActionGain(.5f), m_UIGain(.5f),
|
||||
m_Gain{g_ConfigDB.Get("sound.mastergain", 0.5f)},
|
||||
m_MusicGain{g_ConfigDB.Get("sound.musicgain", 0.5f)},
|
||||
m_AmbientGain{g_ConfigDB.Get("sound.ambientgain", 0.5f)},
|
||||
m_ActionGain{g_ConfigDB.Get("sound.actiongain", 0.5f)},
|
||||
m_UIGain{g_ConfigDB.Get("sound.uigain", 0.5f)},
|
||||
m_Enabled(false), m_BufferSize(98304), m_BufferCount(50),
|
||||
m_SoundEnabled(true), m_MusicEnabled(true), m_MusicPaused(false),
|
||||
m_AmbientPaused(false), m_ActionPaused(false),
|
||||
m_RunningPlaylist(false), m_PlayingPlaylist(false), m_LoopingPlaylist(false),
|
||||
m_PlaylistGap(0), m_DistressErrCount(0), m_DistressTime(0)
|
||||
{
|
||||
CFG_GET_VAL("sound.mastergain", m_Gain);
|
||||
CFG_GET_VAL("sound.musicgain", m_MusicGain);
|
||||
CFG_GET_VAL("sound.ambientgain", m_AmbientGain);
|
||||
CFG_GET_VAL("sound.actiongain", m_ActionGain);
|
||||
CFG_GET_VAL("sound.uigain", m_UIGain);
|
||||
|
||||
AlcInit();
|
||||
|
||||
if (m_Enabled)
|
||||
|
||||
@@ -104,16 +104,10 @@ void CSoundGroup::SetDefaultValues()
|
||||
m_Seed = 0;
|
||||
m_IntensityThreshold = 3.f;
|
||||
|
||||
m_MinDist = 1.f;
|
||||
m_MaxDist = 350.f;
|
||||
m_MinDist = CConfigDB::GetIfInitialised("sound.mindistance", 1.f);
|
||||
m_MaxDist = CConfigDB::GetIfInitialised("sound.maxdistance", 350.f);
|
||||
// This is more than the default camera FOV: for now, our soundscape is not realistic anyways.
|
||||
m_MaxStereoAngle = static_cast<float>(M_PI / 6);
|
||||
if (CConfigDB::IsInitialised())
|
||||
{
|
||||
CFG_GET_VAL("sound.mindistance", m_MinDist);
|
||||
CFG_GET_VAL("sound.maxdistance", m_MaxDist);
|
||||
CFG_GET_VAL("sound.maxstereoangle", m_MaxStereoAngle);
|
||||
}
|
||||
m_MaxStereoAngle = CConfigDB::GetIfInitialised("sound.maxstereoangle", static_cast<float>(M_PI / 6));
|
||||
}
|
||||
|
||||
CSoundGroup::CSoundGroup()
|
||||
|
||||
@@ -405,8 +405,7 @@ void AtlasViewGame::SetBandbox(bool visible, float x0, float y0, float x1, float
|
||||
if (y0 > y1)
|
||||
std::swap(y0, y1);
|
||||
|
||||
float scale;
|
||||
CFG_GET_VAL("gui.scale", scale);
|
||||
const float scale{g_ConfigDB.Get("gui.scale", 0.0f)};
|
||||
m_Bandbox = CRect(x0 / scale, y0 / scale, x1 / scale, y1 / scale);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user