aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-10-16 01:53:03 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-10-16 01:53:03 -0300
commit0a82003d870b901b09e25ec29c432af034b1e255 (patch)
treeb0fee5bb08e8c5bdbb960ae4306875f72acce005
parent95022ca95b1d2792bae447d90694dcc0d67b9de2 (diff)
downloadquerymanager-0a82003d870b901b09e25ec29c432af034b1e255.tar.gz
querymanager-0a82003d870b901b09e25ec29c432af034b1e255.zip
allow all database config options to be loaded, even when not used
-rw-r--r--src/querymanager.cc14
-rw-r--r--src/querymanager.hh10
2 files changed, 10 insertions, 14 deletions
diff --git a/src/querymanager.cc b/src/querymanager.cc
index 4f68d5e..5719504 100644
--- a/src/querymanager.cc
+++ b/src/querymanager.cc
@@ -493,12 +493,10 @@ bool ReadConfig(const char *FileName, TConfig *Config){
ParseInteger(&Config->MaxCachedHostNames, Val);
}else if(StringEqCI(Key, "HostNameExpireTime")){
ParseDuration(&Config->HostNameExpireTime, Val);
-#if DATABASE_SQLITE
}else if(StringEqCI(Key, "SQLite.File")){
ParseStringBuf(Config->SQLite.File, Val);
}else if(StringEqCI(Key, "SQLite.MaxCachedStatements")){
ParseInteger(&Config->SQLite.MaxCachedStatements, Val);
-#elif DATABASE_POSTGRESQL
}else if(StringEqCI(Key, "PostgreSQL.Host")){
ParseStringBuf(Config->PostgreSQL.Host, Val);
}else if(StringEqCI(Key, "PostgreSQL.Port")){
@@ -521,7 +519,6 @@ bool ReadConfig(const char *FileName, TConfig *Config){
ParseStringBuf(Config->PostgreSQL.SSLRootCert, Val);
}else if(StringEqCI(Key, "PostgreSQL.MaxCachedStatements")){
ParseInteger(&Config->PostgreSQL.MaxCachedStatements, Val);
-#elif DATABASE_MYSQL
}else if(StringEqCI(Key, "MySQL.Host")){
ParseStringBuf(Config->MySQL.Host, Val);
}else if(StringEqCI(Key, "MySQL.Port")){
@@ -536,7 +533,6 @@ bool ReadConfig(const char *FileName, TConfig *Config){
ParseStringBuf(Config->MySQL.UnixSocket, Val);
}else if(StringEqCI(Key, "MySQL.MaxCachedStatements")){
ParseInteger(&Config->MySQL.MaxCachedStatements, Val);
-#endif
}else if(StringEqCI(Key, "QueryManagerPort")){
ParseInteger(&Config->QueryManagerPort, Val);
}else if(StringEqCI(Key, "QueryManagerPassword")){
@@ -594,11 +590,11 @@ int main(int argc, const char **argv){
g_Config.MaxCachedHostNames = 100;
g_Config.HostNameExpireTime = 60 * 30; // seconds
- // Database Config
-#if DATABASE_SQLITE
+ // SQLite Config
StringBufCopy(g_Config.SQLite.File, "tibia.db");
g_Config.SQLite.MaxCachedStatements = 100;
-#elif DATABASE_POSTGRESQL
+
+ // PostgreSQL Config
StringBufCopy(g_Config.PostgreSQL.Host, "localhost");
StringBufCopy(g_Config.PostgreSQL.Port, "5432");
StringBufCopy(g_Config.PostgreSQL.DBName, "tibia");
@@ -610,7 +606,8 @@ int main(int argc, const char **argv){
StringBufCopy(g_Config.PostgreSQL.SSLMode, "");
StringBufCopy(g_Config.PostgreSQL.SSLRootCert, "");
g_Config.PostgreSQL.MaxCachedStatements = 100;
-#elif DATABASE_MYSQL
+
+ // MySQL/MariaDB Config
StringBufCopy(g_Config.MySQL.Host, "localhost");
StringBufCopy(g_Config.MySQL.Port, "3306");
StringBufCopy(g_Config.MySQL.DBName, "tibia");
@@ -618,7 +615,6 @@ int main(int argc, const char **argv){
StringBufCopy(g_Config.MySQL.Password, "");
StringBufCopy(g_Config.MySQL.UnixSocket, "");
g_Config.MySQL.MaxCachedStatements = 100;
-#endif
// Connection Config
g_Config.QueryManagerPort = 7174;
diff --git a/src/querymanager.hh b/src/querymanager.hh
index 220f69a..1d4b36b 100644
--- a/src/querymanager.hh
+++ b/src/querymanager.hh
@@ -95,13 +95,13 @@ struct TConfig{
int MaxCachedHostNames;
int HostNameExpireTime;
- // Database Config
-#if DATABASE_SQLITE
+ // SQLite Config
struct{
char File[100];
int MaxCachedStatements;
} SQLite;
-#elif DATABASE_POSTGRESQL
+
+ // PostgreSQL Config
struct{
// NOTE(fusion): Most of these are stored as strings because that is the
// format libpq expects for connection parameters.
@@ -117,7 +117,8 @@ struct TConfig{
char SSLRootCert[100];
int MaxCachedStatements;
} PostgreSQL;
-#elif DATABASE_MYSQL
+
+ // MySQL/MariaDB Config
struct{
char Host[100];
char Port[30];
@@ -127,7 +128,6 @@ struct TConfig{
char UnixSocket[100];
int MaxCachedStatements;
} MySQL;
-#endif
// Connection Config
int QueryManagerPort;