Simplify connection logic

This commit is contained in:
Akkadius 2020-03-11 04:23:44 -05:00
parent 6af1ae32ae
commit 26b24c02f1
2 changed files with 10 additions and 10 deletions

View File

@ -143,11 +143,11 @@ void LoadDatabaseConnections()
*/
if (!Config->ContentDbHost.empty()) {
if (!content_db.Connect(
!Config->ContentDbHost.empty() ? Config->ContentDbHost.c_str() : Config->DatabaseHost.c_str(),
!Config->ContentDbUsername.empty() ? Config->ContentDbUsername.c_str() : Config->DatabaseUsername.c_str(),
!Config->ContentDbPassword.empty() ? Config->ContentDbPassword.c_str() : Config->DatabasePassword.c_str(),
!Config->ContentDbName.empty() ? Config->ContentDbName.c_str() : Config->DatabaseDB.c_str(),
Config->ContentDbPort != 0 ? Config->ContentDbPort : Config->DatabasePort
Config->ContentDbHost.c_str() ,
Config->ContentDbUsername.c_str(),
Config->ContentDbPassword.c_str(),
Config->ContentDbName.c_str(),
Config->ContentDbPort
)) {
LogError("Cannot continue without a content database connection");
std::exit(1);

View File

@ -242,11 +242,11 @@ int main(int argc, char** argv) {
*/
if (!Config->ContentDbHost.empty()) {
if (!content_db.Connect(
!Config->ContentDbHost.empty() ? Config->ContentDbHost.c_str() : Config->DatabaseHost.c_str(),
!Config->ContentDbUsername.empty() ? Config->ContentDbUsername.c_str() : Config->DatabaseUsername.c_str(),
!Config->ContentDbPassword.empty() ? Config->ContentDbPassword.c_str() : Config->DatabasePassword.c_str(),
!Config->ContentDbName.empty() ? Config->ContentDbName.c_str() : Config->DatabaseDB.c_str(),
Config->ContentDbPort != 0 ? Config->ContentDbPort : Config->DatabasePort
Config->ContentDbHost.c_str() ,
Config->ContentDbUsername.c_str(),
Config->ContentDbPassword.c_str(),
Config->ContentDbName.c_str(),
Config->ContentDbPort
)) {
LogError("Cannot continue without a content database connection");
return 1;