diff options
author | Subv <subv2112@gmail.com> | 2014-07-06 17:03:54 -0500 |
---|---|---|
committer | Subv <subv2112@gmail.com> | 2014-07-06 17:04:42 -0500 |
commit | 77caf33debab6153da46da11ff8aff5142b42b2a (patch) | |
tree | d8f21b5a64089c03b4f9cdc373b5f7c14286674c | |
parent | 59c8ffe4b3fec5979926d991c17cae84b41e46e2 (diff) |
Removed some unneeded boost dependencies.
Ensure that the correct packet sizes are read in the authserver.
Added some try catch to the authserver to deal with boost exceptions (this part is not finished)
-rw-r--r-- | cmake/macros/ConfigureBoost.cmake | 4 | ||||
-rw-r--r-- | src/server/authserver/Realms/RealmList.cpp | 46 | ||||
-rw-r--r-- | src/server/authserver/Server/AuthSession.cpp | 7 | ||||
-rw-r--r-- | src/server/game/World/World.cpp | 2 |
4 files changed, 35 insertions, 24 deletions
diff --git a/cmake/macros/ConfigureBoost.cmake b/cmake/macros/ConfigureBoost.cmake index 8ade7a0db5b..0e654ada86d 100644 --- a/cmake/macros/ConfigureBoost.cmake +++ b/cmake/macros/ConfigureBoost.cmake @@ -27,7 +27,9 @@ if(WIN32) add_definitions(-D_WIN32_WINNT=${ver})
endif()
-find_package(Boost 1.55 REQUIRED atomic chrono date_time exception regex system thread)
+find_package(Boost 1.55 REQUIRED system thread)
+add_definitions(-DBOOST_DATE_TIME_NO_LIB)
+add_definitions(-DBOOST_REGEX_NO_LIB)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
diff --git a/src/server/authserver/Realms/RealmList.cpp b/src/server/authserver/Realms/RealmList.cpp index bf097abff9a..392d86b5621 100644 --- a/src/server/authserver/Realms/RealmList.cpp +++ b/src/server/authserver/Realms/RealmList.cpp @@ -83,25 +83,33 @@ void RealmList::UpdateRealms(bool init) { do { - Field* fields = result->Fetch(); - uint32 realmId = fields[0].GetUInt32(); - std::string name = fields[1].GetString(); - ip::address externalAddress = ip::address::from_string(fields[2].GetString()); - ip::address localAddress = ip::address::from_string(fields[3].GetString()); - ip::address localSubmask = ip::address::from_string(fields[4].GetString()); - uint16 port = fields[5].GetUInt16(); - uint8 icon = fields[6].GetUInt8(); - RealmFlags flag = RealmFlags(fields[7].GetUInt8()); - uint8 timezone = fields[8].GetUInt8(); - uint8 allowedSecurityLevel = fields[9].GetUInt8(); - float pop = fields[10].GetFloat(); - uint32 build = fields[11].GetUInt32(); - - UpdateRealm(realmId, name, externalAddress, localAddress, localSubmask, port, icon, flag, timezone, - (allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), pop, build); - - if (init) - TC_LOG_INFO("server.authserver", "Added realm \"%s\" at %s:%u.", name.c_str(), m_realms[name].ExternalAddress.to_string().c_str(), port); + try + { + Field* fields = result->Fetch(); + uint32 realmId = fields[0].GetUInt32(); + std::string name = fields[1].GetString(); + ip::address externalAddress = ip::address::from_string(fields[2].GetString()); + ip::address localAddress = ip::address::from_string(fields[3].GetString()); + ip::address localSubmask = ip::address::from_string(fields[4].GetString()); + uint16 port = fields[5].GetUInt16(); + uint8 icon = fields[6].GetUInt8(); + RealmFlags flag = RealmFlags(fields[7].GetUInt8()); + uint8 timezone = fields[8].GetUInt8(); + uint8 allowedSecurityLevel = fields[9].GetUInt8(); + float pop = fields[10].GetFloat(); + uint32 build = fields[11].GetUInt32(); + + UpdateRealm(realmId, name, externalAddress, localAddress, localSubmask, port, icon, flag, timezone, + (allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), pop, build); + + if (init) + TC_LOG_INFO("server.authserver", "Added realm \"%s\" at %s:%u.", name.c_str(), m_realms[name].ExternalAddress.to_string().c_str(), port); + } + catch (std::exception& ex) + { + TC_LOG_ERROR("server.authserver", "Realmlist::UpdateRealms has thrown an exception: %s", ex.what()); + ASSERT(false); + } } while (result->NextRow()); } diff --git a/src/server/authserver/Server/AuthSession.cpp b/src/server/authserver/Server/AuthSession.cpp index f518dc7593b..df90339222d 100644 --- a/src/server/authserver/Server/AuthSession.cpp +++ b/src/server/authserver/Server/AuthSession.cpp @@ -19,6 +19,7 @@ #include <memory> #include <boost/lexical_cast.hpp> #include <boost/asio/write.hpp> +#include <boost/asio/read.hpp> #include <AuthSession.h> #include <Log.h> #include "ByteBuffer.h" @@ -136,7 +137,7 @@ void AuthSession::AsyncReadHeader() { auto self(shared_from_this()); - _socket.async_read_some(boost::asio::buffer(_readBuffer, 1), [this, self](boost::system::error_code error, size_t transferedBytes) + boost::asio::async_read(_socket, boost::asio::buffer(_readBuffer, 1), [this, self](boost::system::error_code error, size_t transferedBytes) { if (!error && transferedBytes == 1) { @@ -147,7 +148,7 @@ void AuthSession::AsyncReadHeader() // Handle dynamic size packet if (_readBuffer[0] == AUTH_LOGON_CHALLENGE) { - _socket.read_some(boost::asio::buffer(&_readBuffer[1], sizeof(uint8) + sizeof(uint16))); //error + size + boost::asio::read(_socket, boost::asio::buffer(&_readBuffer[1], sizeof(uint8) + sizeof(uint16))); //error + size AsyncReadData(entry.handler, *reinterpret_cast<uint16*>(&_readBuffer[2]), sizeof(uint8) + sizeof(uint8) + sizeof(uint16)); // cmd + error + size } @@ -170,7 +171,7 @@ void AuthSession::AsyncReadData(bool (AuthSession::*handler)(), size_t dataSize, { auto self(shared_from_this()); - _socket.async_read_some(boost::asio::buffer(&_readBuffer[bufferOffSet], dataSize), [handler, this, self](boost::system::error_code error, size_t transferedBytes) + boost::asio::async_read(_socket, boost::asio::buffer(&_readBuffer[bufferOffSet], dataSize), [handler, this, self](boost::system::error_code error, size_t transferedBytes) { if (!error && transferedBytes > 0) { diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index ad23e016e32..741b12f30dc 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1316,7 +1316,7 @@ void World::SetInitialWorldSettings() ///- Update the realm entry in the database with the realm type from the config file //No SQL injection as values are treated as integers - + // not send custom type REALM_FFA_PVP to realm list uint32 server_type = IsFFAPvPRealm() ? uint32(REALM_TYPE_PVP) : getIntConfig(CONFIG_GAME_TYPE); uint32 realm_zone = getIntConfig(CONFIG_REALM_ZONE); |