Fix SDK launcher bugs

Fixed bugs preventing the SDK launcher from working when compiled using the Visual Studio 2017 compiler.
This commit is contained in:
Kawe Mazidjatari 2023-03-19 11:20:04 +01:00
parent 5618efd452
commit 180d762089
3 changed files with 29 additions and 13 deletions

View File

@ -565,6 +565,11 @@ void CUIBaseSurface::LaunchGame(Forms::Control* pSender)
//-----------------------------------------------------------------------------
void CUIBaseSurface::ParseMaps()
{
if (!fs::exists("vpk"))
{
return;
}
fs::directory_iterator fsDir("vpk");
std::regex rgArchiveRegex{ R"([^_]*_(.*)(.bsp.pak000_dir).*)" };
std::smatch smRegexMatches;

View File

@ -32,9 +32,9 @@ void CLauncher::InitConsole()
///////////////////////////////////////////////////////////////////////////////
void CLauncher::InitLogger()
{
wconsole->set_pattern("[%^%l%$] %v");
wconsole->set_level(spdlog::level::trace);
spdlog::set_default_logger(wconsole); // Set as default.
m_pLogger->set_pattern("[%^%l%$] %v");
m_pLogger->set_level(spdlog::level::trace);
spdlog::set_default_logger(m_pLogger); // Set as default.
}
///////////////////////////////////////////////////////////////////////////////
@ -265,7 +265,7 @@ int CLauncher::HandleInput()
}
catch (std::exception& e)
{
g_pLauncher->AddLog(spdlog::level::level_enum::err, "SDK Launcher only takes numerical input. Error: {:s}.\n", e.what());
g_pLauncher->AddLog(spdlog::level::level_enum::err, "SDK Launcher only takes numerical input; error: {:s}.\n", e.what());
Sleep(2000);
return EXIT_FAILURE;
}
@ -285,7 +285,7 @@ int CLauncher::HandleInput()
bool CLauncher::Setup(eLaunchMode lMode, eLaunchState lState)
{
///////////////////////////////////////////////////////////////////////////
std::string svCmdLineArgs = std::string();
std::string svCmdLineArgs;
///////////////////////////////////////////////////////////////////////////
switch (lMode)
@ -612,3 +612,8 @@ int main(int argc, char* argv[], char* envp[])
}
return EXIT_SUCCESS;
}
///////////////////////////////////////////////////////////////////////////////
// Singleton Launcher.
///////////////////////////////////////////////////////////////////////////////
CLauncher* g_pLauncher(new CLauncher("win_console"));

View File

@ -5,20 +5,25 @@
class CLauncher
{
public:
CLauncher()
CLauncher(const char* pszLoggerName)
{
m_svCurrentDir = fs::current_path().u8string();
m_pSurface = nullptr;
m_pLogger = spdlog::stdout_color_mt(pszLoggerName);
m_svCurrentDir = fs::current_path().u8string();
}
~CLauncher()
{
delete[] m_pSurface;
if (m_pSurface)
{
delete m_pSurface;
}
}
template <typename T, typename ...P>
void AddLog(spdlog::level::level_enum nLevel, T&& svFormat, P &&... vParams)
{
String svBuffer = fmt::format(std::forward<T>(svFormat), std::forward<P>(vParams)...).c_str();
wconsole->log(nLevel, svBuffer.ToCString());
wconsole->flush();
m_pLogger->log(nLevel, svBuffer.ToCString());
m_pLogger->flush();
if (m_pSurface)
{
@ -41,12 +46,13 @@ public:
CUIBaseSurface* GetMainSurface() const { return m_pSurface; }
private:
CUIBaseSurface* m_pSurface = nullptr;
std::shared_ptr<spdlog::logger> wconsole = spdlog::stdout_color_mt("win_console");
CUIBaseSurface* m_pSurface;
std::shared_ptr<spdlog::logger> m_pLogger;
string m_svWorkerDll;
string m_svGameExe;
string m_svCmdLine;
string m_svCurrentDir;
};
inline CLauncher* g_pLauncher = new CLauncher();
extern CLauncher* g_pLauncher;