aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared
diff options
context:
space:
mode:
authorVincent-Michael <Vincent_Michael@gmx.de>2014-07-30 22:26:59 +0200
committerVincent-Michael <Vincent_Michael@gmx.de>2014-07-30 22:26:59 +0200
commita917b6599f599419767b8683b591a96d9cdb7092 (patch)
tree16af20ae09d8a13eca0f74d00e5027da6ed608be /src/server/shared
parentd89a5d2d176000535ca857ab6ce600607a747358 (diff)
parent01b733eb69691ccd1ac8e9884ff2a4cb4643a7cf (diff)
Merge branch 'master' of github.com:TrinityCore/TrinityCore into 4.3.4
Conflicts: src/server/game/Server/WorldSocket.cpp src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp src/server/scripts/OutdoorPvP/OutdoorPvPEP.h
Diffstat (limited to 'src/server/shared')
-rw-r--r--src/server/shared/Configuration/Config.cpp17
-rw-r--r--src/server/shared/Configuration/Config.h4
-rw-r--r--src/server/shared/Database/Implementation/LoginDatabase.cpp4
3 files changed, 16 insertions, 9 deletions
diff --git a/src/server/shared/Configuration/Config.cpp b/src/server/shared/Configuration/Config.cpp
index ecebf30182e..6b83f562520 100644
--- a/src/server/shared/Configuration/Config.cpp
+++ b/src/server/shared/Configuration/Config.cpp
@@ -25,7 +25,7 @@
using namespace boost::property_tree;
-bool ConfigMgr::LoadInitial(std::string const& file)
+bool ConfigMgr::LoadInitial(std::string const& file, std::string& error)
{
std::lock_guard<std::mutex> lock(_configLock);
@@ -34,25 +34,32 @@ bool ConfigMgr::LoadInitial(std::string const& file)
try
{
ptree fullTree;
- boost::property_tree::ini_parser::read_ini(file, fullTree);
+ ini_parser::read_ini(file, fullTree);
if (fullTree.empty())
+ {
+ error = "empty file (" + file + ")";
return false;
+ }
// Since we're using only one section per config file, we skip the section and have direct property access
_config = fullTree.begin()->second;
}
- catch (std::exception const& /*ex*/)
+ catch (ini_parser::ini_parser_error const& e)
{
+ if (e.line() == 0)
+ error = e.message() + " (" + e.filename() + ")";
+ else
+ error = e.message() + " (" + e.filename() + ":" + std::to_string(e.line()) + ")";
return false;
}
return true;
}
-bool ConfigMgr::Reload()
+bool ConfigMgr::Reload(std::string& error)
{
- return LoadInitial(_filename.c_str());
+ return LoadInitial(_filename.c_str(), error);
}
std::string ConfigMgr::GetStringDefault(std::string const& name, const std::string& def)
diff --git a/src/server/shared/Configuration/Config.h b/src/server/shared/Configuration/Config.h
index 42c3a700f3f..ff0233b5669 100644
--- a/src/server/shared/Configuration/Config.h
+++ b/src/server/shared/Configuration/Config.h
@@ -31,7 +31,7 @@ class ConfigMgr
public:
/// Method used only for loading main configuration files (authserver.conf and worldserver.conf)
- bool LoadInitial(std::string const& file);
+ bool LoadInitial(std::string const& file, std::string& error);
static ConfigMgr* instance()
{
@@ -39,7 +39,7 @@ public:
return &instance;
}
- bool Reload();
+ bool Reload(std::string& error);
std::string GetStringDefault(std::string const& name, const std::string& def);
bool GetBoolDefault(std::string const& name, bool def);
diff --git a/src/server/shared/Database/Implementation/LoginDatabase.cpp b/src/server/shared/Database/Implementation/LoginDatabase.cpp
index f0ab2077662..b9f281d3f2a 100644
--- a/src/server/shared/Database/Implementation/LoginDatabase.cpp
+++ b/src/server/shared/Database/Implementation/LoginDatabase.cpp
@@ -26,13 +26,13 @@ void LoginDatabaseConnection::DoPrepareStatements()
PrepareStatement(LOGIN_DEL_EXPIRED_IP_BANS, "DELETE FROM ip_banned WHERE unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()", CONNECTION_ASYNC);
PrepareStatement(LOGIN_UPD_EXPIRED_ACCOUNT_BANS, "UPDATE account_banned SET active = 0 WHERE active = 1 AND unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()", CONNECTION_SYNCH);
PrepareStatement(LOGIN_SEL_IP_BANNED, "SELECT * FROM ip_banned WHERE ip = ?", CONNECTION_SYNCH);
- PrepareStatement(LOGIN_INS_IP_AUTO_BANNED, "INSERT INTO ip_banned (ip, bandate, unbandate, bannedby, banreason) VALUES (?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, 'Trinity realmd', 'Failed login autoban')", CONNECTION_ASYNC);
+ PrepareStatement(LOGIN_INS_IP_AUTO_BANNED, "INSERT INTO ip_banned (ip, bandate, unbandate, bannedby, banreason) VALUES (?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, 'Trinity Auth', 'Failed login autoban')", CONNECTION_ASYNC);
PrepareStatement(LOGIN_SEL_IP_BANNED_ALL, "SELECT ip, bandate, unbandate, bannedby, banreason FROM ip_banned WHERE (bandate = unbandate OR unbandate > UNIX_TIMESTAMP()) ORDER BY unbandate", CONNECTION_SYNCH);
PrepareStatement(LOGIN_SEL_IP_BANNED_BY_IP, "SELECT ip, bandate, unbandate, bannedby, banreason FROM ip_banned WHERE (bandate = unbandate OR unbandate > UNIX_TIMESTAMP()) AND ip LIKE CONCAT('%%', ?, '%%') ORDER BY unbandate", CONNECTION_SYNCH);
PrepareStatement(LOGIN_SEL_ACCOUNT_BANNED, "SELECT bandate, unbandate FROM account_banned WHERE id = ? AND active = 1", CONNECTION_SYNCH);
PrepareStatement(LOGIN_SEL_ACCOUNT_BANNED_ALL, "SELECT account.id, username FROM account, account_banned WHERE account.id = account_banned.id AND active = 1 GROUP BY account.id", CONNECTION_SYNCH);
PrepareStatement(LOGIN_SEL_ACCOUNT_BANNED_BY_USERNAME, "SELECT account.id, username FROM account, account_banned WHERE account.id = account_banned.id AND active = 1 AND username LIKE CONCAT('%%', ?, '%%') GROUP BY account.id", CONNECTION_SYNCH);
- PrepareStatement(LOGIN_INS_ACCOUNT_AUTO_BANNED, "INSERT INTO account_banned VALUES (?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, 'Trinity realmd', 'Failed login autoban', 1)", CONNECTION_ASYNC);
+ PrepareStatement(LOGIN_INS_ACCOUNT_AUTO_BANNED, "INSERT INTO account_banned VALUES (?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, 'Trinity Auth', 'Failed login autoban', 1)", CONNECTION_ASYNC);
PrepareStatement(LOGIN_DEL_ACCOUNT_BANNED, "DELETE FROM account_banned WHERE id = ?", CONNECTION_ASYNC);
PrepareStatement(LOGIN_SEL_SESSIONKEY, "SELECT a.sessionkey, a.id, aa.gmlevel FROM account a LEFT JOIN account_access aa ON (a.id = aa.id) WHERE username = ?", CONNECTION_SYNCH);
PrepareStatement(LOGIN_UPD_VS, "UPDATE account SET v = ?, s = ? WHERE username = ?", CONNECTION_ASYNC);