Use macros so we can use more properties (#1640)

makes it so we can adjust many more settings since the segfault only happens in windows debug, why remove the functionality for all users?
Tested that windows debug, windows RelWithDebInfo and ubuntu default all build and run without issues (will contact luxaritas about pipe testing)
This commit is contained in:
David Markowitz 2024-10-30 07:45:40 -07:00 committed by GitHub
parent bfe6900c26
commit af943278fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,6 +4,7 @@
#include "Game.h" #include "Game.h"
#include "dConfig.h" #include "dConfig.h"
#include "Logger.h" #include "Logger.h"
#include "dPlatforms.h"
namespace { namespace {
std::string databaseName; std::string databaseName;
@ -39,14 +40,13 @@ void MySQLDatabase::Connect() {
properties["autoReconnect"] = "true"; properties["autoReconnect"] = "true";
databaseName = Game::config->GetValue("mysql_database").c_str(); databaseName = Game::config->GetValue("mysql_database").c_str();
// `connect(const Properties& props)` segfaults in windows debug, but // `connect(const Properties& props)` segfaults in windows debug, but
// `connect(const SQLString& host, const SQLString& user, const SQLString& pwd)` doesn't handle pipes/unix sockets correctly // `connect(const SQLString& host, const SQLString& user, const SQLString& pwd)` doesn't handle pipes/unix sockets correctly
if (properties.find("localSocket") != properties.end() || properties.find("pipe") != properties.end()) { #if defined(DARKFLAME_PLATFORM_WIN32) && defined(_DEBUG)
con = driver->connect(properties);
} else {
con = driver->connect(properties["hostName"].c_str(), properties["user"].c_str(), properties["password"].c_str()); con = driver->connect(properties["hostName"].c_str(), properties["user"].c_str(), properties["password"].c_str());
} #else
con = driver->connect(properties);
#endif
con->setSchema(databaseName.c_str()); con->setSchema(databaseName.c_str());
} }