Skip to content

Commit 4ac91fb

Browse files
G-MorisG-Moris
authored andcommitted
Update
1 parent adbe2cf commit 4ac91fb

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

Client/core/CConnectManager.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,14 @@ bool CConnectManager::Connect(const char* szHost, unsigned short usPort, const c
150150
OpenServerFirewall(m_Address, CServerBrowser::GetSingletonPtr()->FindServerHttpPort(m_strHost, m_usPort), true);
151151

152152
// Display the status box
153-
SString strBuffer(_("Connecting to %s:%u ..."), m_strHost.c_str(), m_usPort);
153+
std::string formatConnecting;
154154
if (m_bReconnect)
155-
strBuffer = SString(_("Reconnecting to %s:%u ..."), m_strHost.c_str(), m_usPort);
156-
CCore::GetSingleton().ShowMessageBox(_("CONNECTING"), strBuffer, MB_BUTTON_CANCEL | MB_ICON_INFO, m_pOnCancelClick);
157-
WriteDebugEvent(SString("Connecting to %s:%u ...", m_strHost.c_str(), m_usPort));
155+
formatConnecting = mtasa::format(_("Reconnecting to {}:{} ..."), m_strHost, m_usPort);
156+
else
157+
formatConnecting = mtasa::format(_("Connecting to {}:{} ..."), m_strHost, m_usPort);
158+
159+
CCore::GetSingleton().ShowMessageBox(_("CONNECTING"), formatConnecting.c_str(), MB_BUTTON_CANCEL | MB_ICON_INFO, m_pOnCancelClick);
160+
WriteDebugEvent(std::format("Connecting to {}:{} ...", m_strHost, m_usPort));
158161

159162
return true;
160163
}

Shared/sdk/SharedUtil.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,21 @@
8585
#define strnicmp strncasecmp
8686
#endif
8787
#endif
88+
89+
// Ensure that the C++ version is at least C++20
90+
#if __cplusplus >= 202002L
91+
92+
/*
93+
The function prevents a compilation error caused by using non-constant format strings and
94+
correctly forwards the arguments to std::format for formatting
95+
*/
96+
namespace mtasa
97+
{
98+
template <class... _Types>
99+
__forceinline std::string format(const std::string_view fmt, _Types&&... _Args)
100+
{
101+
return std::vformat(fmt, std::make_format_args(_Args...));
102+
}
103+
}
104+
105+
#endif

0 commit comments

Comments
 (0)