From 1e302aeb70c3335041e8a831dacc1059ed91f8ce Mon Sep 17 00:00:00 2001 From: H-M-H Date: Sat, 19 Dec 2015 18:26:09 +0100 Subject: [PATCH] 'r' and 'w' instead of 0 and 1 for sql read/write servers --- src/engine/server/server.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 15efbaa17..f73120b20 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -2030,7 +2030,16 @@ void CServer::ConAddSqlServer(IConsole::IResult *pResult, void *pUserData) return; } - bool ReadOnly = !pResult->GetInteger(0); + bool ReadOnly; + if (str_comp_nocase(pResult->GetString(0), "w") == 0) + ReadOnly = false; + else if (str_comp_nocase(pResult->GetString(0), "r") == 0) + ReadOnly = true; + else + { + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "choose either 'r' for SqlReadServer or 'w' for SqlWriteServer"); + return; + } CSqlServer** apSqlServers = ReadOnly ? pSelf->m_apSqlReadServers : pSelf->m_apSqlWriteServers; @@ -2059,7 +2068,16 @@ void CServer::ConDumpSqlServers(IConsole::IResult *pResult, void *pUserData) { CServer *pSelf = (CServer *)pUserData; - bool ReadOnly = !pResult->GetInteger(0); + bool ReadOnly; + if (str_comp_nocase(pResult->GetString(0), "w") == 0) + ReadOnly = false; + else if (str_comp_nocase(pResult->GetString(0), "r") == 0) + ReadOnly = true; + else + { + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "choose either 'r' for SqlReadServer or 'w' for SqlWriteServer"); + return; + } CSqlServer** apSqlServers = ReadOnly ? pSelf->m_apSqlReadServers : pSelf->m_apSqlWriteServers; @@ -2210,8 +2228,8 @@ void CServer::RegisterCommands() #if defined (CONF_SQL) - Console()->Register("add_sqlserver", "isssssi", CFGFLAG_SERVER, ConAddSqlServer, this, "add a sqlserver "); - Console()->Register("dump_sqlservers", "i", CFGFLAG_SERVER, ConDumpSqlServers, this, "dumps all sqlservers readservers = 0, writeservers = 1"); + Console()->Register("add_sqlserver", "ssssssi", CFGFLAG_SERVER, ConAddSqlServer, this, "add a sqlserver "); + Console()->Register("dump_sqlservers", "i", CFGFLAG_SERVER, ConDumpSqlServers, this, "dumps all sqlservers readservers = r, writeservers = w"); #endif