diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2017-06-19 23:20:06 -0300 |
|---|---|---|
| committer | ariel- <ariel-@users.noreply.github.com> | 2017-06-19 23:20:06 -0300 |
| commit | 85a7d5ce9ac68b30da2277cc91d4b70358f1880d (patch) | |
| tree | df3d2084ee2e35008903c03178039b9c986e2d08 /src/server/worldserver | |
| parent | 052fc24315ace866ea1cf610e85df119b68100c9 (diff) | |
Core: ported headers cleanup from master branch
Diffstat (limited to 'src/server/worldserver')
| -rw-r--r-- | src/server/worldserver/CommandLine/CliRunnable.cpp | 22 | ||||
| -rw-r--r-- | src/server/worldserver/Main.cpp | 84 | ||||
| -rw-r--r-- | src/server/worldserver/PrecompiledHeaders/worldPCH.cpp | 17 | ||||
| -rw-r--r-- | src/server/worldserver/PrecompiledHeaders/worldPCH.h | 17 | ||||
| -rw-r--r-- | src/server/worldserver/RemoteAccess/RASession.cpp | 18 | ||||
| -rw-r--r-- | src/server/worldserver/RemoteAccess/RASession.h | 4 | ||||
| -rw-r--r-- | src/server/worldserver/TCSoap/TCSoap.h | 4 |
7 files changed, 100 insertions, 66 deletions
diff --git a/src/server/worldserver/CommandLine/CliRunnable.cpp b/src/server/worldserver/CommandLine/CliRunnable.cpp index d5e03edbd04..8c05a47608d 100644 --- a/src/server/worldserver/CommandLine/CliRunnable.cpp +++ b/src/server/worldserver/CommandLine/CliRunnable.cpp @@ -34,10 +34,10 @@ #include <readline/history.h> #include "Chat.h" -char* command_finder(const char* text, int state) +char* command_finder(char const* text, int state) { static size_t idx, len; - const char* ret; + char const* ret; std::vector<ChatCommand> const& cmd = ChatHandler::getCommandTable(); if (!state) @@ -61,12 +61,12 @@ char* command_finder(const char* text, int state) return strdup(ret); } - return ((char*)NULL); + return ((char*)nullptr); } -char** cli_completion(const char* text, int start, int /*end*/) +char** cli_completion(char const* text, int start, int /*end*/) { - char** matches = NULL; + char** matches = nullptr; if (start) rl_bind_key('\t', rl_abort); @@ -84,7 +84,7 @@ int cli_hook_func() #endif -void utf8print(void* /*arg*/, const char* str) +void utf8print(void* /*arg*/, char const* str) { #if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS wchar_t wtemp_buf[6000]; @@ -92,9 +92,7 @@ void utf8print(void* /*arg*/, const char* str) if (!Utf8toWStr(str, strlen(str), wtemp_buf, wtemp_len)) return; - char temp_buf[6000]; - CharToOemBuffW(&wtemp_buf[0], &temp_buf[0], wtemp_len+1); - printf(temp_buf); + wprintf(L"%s", wtemp_buf); #else { printf("%s", str); @@ -119,7 +117,7 @@ int kb_hit_return() tv.tv_usec = 0; FD_ZERO(&fds); FD_SET(STDIN_FILENO, &fds); - select(STDIN_FILENO+1, &fds, NULL, NULL, &tv); + select(STDIN_FILENO+1, &fds, nullptr, nullptr, &tv); return FD_ISSET(STDIN_FILENO, &fds); } #endif @@ -156,7 +154,7 @@ void CliThread() rl_bind_key('\t', rl_complete); #endif - if (command_str != NULL) + if (command_str != nullptr) { for (int x=0; command_str[x]; ++x) if (command_str[x] == '\r' || command_str[x] == '\n') @@ -187,7 +185,7 @@ void CliThread() } fflush(stdout); - sWorld->QueueCliCommand(new CliCommandHolder(NULL, command.c_str(), &utf8print, &commandFinished)); + sWorld->QueueCliCommand(new CliCommandHolder(nullptr, command.c_str(), &utf8print, &commandFinished)); #if TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS add_history(command.c_str()); free(command_str); diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp index 5f0df199418..bbda89aad03 100644 --- a/src/server/worldserver/Main.cpp +++ b/src/server/worldserver/Main.cpp @@ -20,39 +20,43 @@ /// @{ /// \file -#include <openssl/opensslv.h> -#include <openssl/crypto.h> -#include <boost/asio/io_service.hpp> -#include <boost/asio/deadline_timer.hpp> -#include <boost/filesystem/path.hpp> -#include <boost/program_options.hpp> - #include "Common.h" -#include "DatabaseEnv.h" +#include "AppenderDB.h" #include "AsyncAcceptor.h" -#include "RASession.h" -#include "Configuration/Config.h" -#include "OpenSSLCrypto.h" -#include "ProcessPriority.h" +#include "Banner.h" +#include "BattlegroundMgr.h" #include "BigNumber.h" -#include "World.h" -#include "MapManager.h" +#include "CliRunnable.h" +#include "Configuration/Config.h" +#include "DatabaseEnv.h" +#include "DatabaseLoader.h" +#include "GitRevision.h" #include "InstanceSaveMgr.h" +#include "MapManager.h" +#include "Metric.h" +#include "MySQLThreading.h" #include "ObjectAccessor.h" +#include "OpenSSLCrypto.h" +#include "OutdoorPvP/OutdoorPvPMgr.h" +#include "ProcessPriority.h" +#include "RASession.h" +#include "RealmList.h" +#include "ScriptLoader.h" #include "ScriptMgr.h" #include "ScriptReloadMgr.h" -#include "ScriptLoader.h" -#include "OutdoorPvP/OutdoorPvPMgr.h" -#include "BattlegroundMgr.h" #include "TCSoap.h" -#include "CliRunnable.h" -#include "GitRevision.h" +#include "World.h" #include "WorldSocket.h" #include "WorldSocketMgr.h" -#include "Realm/Realm.h" -#include "DatabaseLoader.h" -#include "AppenderDB.h" -#include "Metric.h" +#include <openssl/opensslv.h> +#include <openssl/crypto.h> +#include <boost/asio/io_service.hpp> +#include <boost/asio/deadline_timer.hpp> +#include <boost/asio/signal_set.hpp> +#include <boost/filesystem/operations.hpp> +#include <boost/program_options.hpp> +#include <csignal> +#include <iostream> using namespace boost::program_options; namespace fs = boost::filesystem; @@ -145,20 +149,18 @@ extern int main(int argc, char** argv) // If logs are supposed to be handled async then we need to pass the io_service into the Log singleton sLog->Initialize(sConfigMgr->GetBoolDefault("Log.Async.Enable", false) ? ioService.get() : nullptr); - TC_LOG_INFO("server.worldserver", "%s (worldserver-daemon)", GitRevision::GetFullVersion()); - TC_LOG_INFO("server.worldserver", "<Ctrl-C> to stop.\n"); - TC_LOG_INFO("server.worldserver", " ______ __"); - TC_LOG_INFO("server.worldserver", "/\\__ _\\ __ __/\\ \\__"); - TC_LOG_INFO("server.worldserver", "\\/_/\\ \\/ _ __ /\\_\\ ___ /\\_\\ \\, _\\ __ __"); - TC_LOG_INFO("server.worldserver", " \\ \\ \\/\\`'__\\/\\ \\ /' _ `\\/\\ \\ \\ \\/ /\\ \\/\\ \\"); - TC_LOG_INFO("server.worldserver", " \\ \\ \\ \\ \\/ \\ \\ \\/\\ \\/\\ \\ \\ \\ \\ \\_\\ \\ \\_\\ \\"); - TC_LOG_INFO("server.worldserver", " \\ \\_\\ \\_\\ \\ \\_\\ \\_\\ \\_\\ \\_\\ \\__\\\\/`____ \\"); - TC_LOG_INFO("server.worldserver", " \\/_/\\/_/ \\/_/\\/_/\\/_/\\/_/\\/__/ `/___/> \\"); - TC_LOG_INFO("server.worldserver", " C O R E /\\___/"); - TC_LOG_INFO("server.worldserver", "http://TrinityCore.org \\/__/\n"); - TC_LOG_INFO("server.worldserver", "Using configuration file %s.", sConfigMgr->GetFilename().c_str()); - TC_LOG_INFO("server.worldserver", "Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION)); - TC_LOG_INFO("server.worldserver", "Using Boost version: %i.%i.%i", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100); + Trinity::Banner::Show("worldserver-daemon", + [](char const* text) + { + TC_LOG_INFO("server.worldserver", "%s", text); + }, + []() + { + TC_LOG_INFO("server.worldserver", "Using configuration file %s.", sConfigMgr->GetFilename().c_str()); + TC_LOG_INFO("server.worldserver", "Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION)); + TC_LOG_INFO("server.worldserver", "Using Boost version: %i.%i.%i", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100); + } + ); OpenSSLCrypto::threadsSetup(); @@ -207,7 +209,7 @@ extern int main(int argc, char** argv) threadPool->push_back(std::thread([ioService]() { ioService->run(); })); // Set process priority according to configuration settings - SetProcessPriority("server.worldserver"); + SetProcessPriority("server.worldserver", sConfigMgr->GetIntDefault(CONFIG_PROCESSOR_AFFINITY, 0), sConfigMgr->GetBoolDefault(CONFIG_HIGH_PRIORITY, false)); // Start the databases if (!StartDB()) @@ -513,7 +515,7 @@ bool LoadRealmInfo(boost::asio::io_service& ioService) return false; } - realm.ExternalAddress = (*endPoint).endpoint().address(); + realm.ExternalAddress = Trinity::make_unique<boost::asio::ip::address>((*endPoint).endpoint().address()); boost::asio::ip::tcp::resolver::query localAddressQuery(boost::asio::ip::tcp::v4(), fields[3].GetString(), ""); endPoint = resolver.resolve(localAddressQuery, ec); @@ -523,7 +525,7 @@ bool LoadRealmInfo(boost::asio::io_service& ioService) return false; } - realm.LocalAddress = (*endPoint).endpoint().address(); + realm.LocalAddress = Trinity::make_unique<boost::asio::ip::address>((*endPoint).endpoint().address()); boost::asio::ip::tcp::resolver::query localSubmaskQuery(boost::asio::ip::tcp::v4(), fields[4].GetString(), ""); endPoint = resolver.resolve(localSubmaskQuery, ec); @@ -533,7 +535,7 @@ bool LoadRealmInfo(boost::asio::io_service& ioService) return false; } - realm.LocalSubnetMask = (*endPoint).endpoint().address(); + realm.LocalSubnetMask = Trinity::make_unique<boost::asio::ip::address>((*endPoint).endpoint().address()); realm.Port = fields[5].GetUInt16(); realm.Type = fields[6].GetUInt8(); diff --git a/src/server/worldserver/PrecompiledHeaders/worldPCH.cpp b/src/server/worldserver/PrecompiledHeaders/worldPCH.cpp index 99c2400eccf..c0824b5423f 100644 --- a/src/server/worldserver/PrecompiledHeaders/worldPCH.cpp +++ b/src/server/worldserver/PrecompiledHeaders/worldPCH.cpp @@ -1 +1,18 @@ +/* + * Copyright (C) 2008-2017 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + #include "worldPCH.h" diff --git a/src/server/worldserver/PrecompiledHeaders/worldPCH.h b/src/server/worldserver/PrecompiledHeaders/worldPCH.h index 6407485f70b..09f5e8a9c75 100644 --- a/src/server/worldserver/PrecompiledHeaders/worldPCH.h +++ b/src/server/worldserver/PrecompiledHeaders/worldPCH.h @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2008-2017 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + #include "Common.h" #include "World.h" #include "Log.h" diff --git a/src/server/worldserver/RemoteAccess/RASession.cpp b/src/server/worldserver/RemoteAccess/RASession.cpp index 3df9556c73d..136814743a0 100644 --- a/src/server/worldserver/RemoteAccess/RASession.cpp +++ b/src/server/worldserver/RemoteAccess/RASession.cpp @@ -16,17 +16,17 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <memory> -#include <boost/asio/write.hpp> -#include <boost/asio/read_until.hpp> -#include <boost/array.hpp> #include "RASession.h" #include "AccountMgr.h" -#include "Log.h" +#include "Config.h" #include "DatabaseEnv.h" +#include "Log.h" +#include "Util.h" #include "World.h" -#include "Config.h" #include "ServerMotd.h" +#include <boost/asio/buffer.hpp> +#include <boost/asio/read_until.hpp> +#include <memory> using boost::asio::ip::tcp; @@ -40,7 +40,7 @@ void RASession::Start() if (_socket.available() > 0) { // Handle subnegotiation - boost::array<char, 1024> buf; + char buf[1024] = { }; _socket.read_some(boost::asio::buffer(buf)); // Send the end-of-negotiation packet @@ -89,7 +89,7 @@ void RASession::Start() _socket.close(); } -int RASession::Send(const char* data) +int RASession::Send(char const* data) { std::ostream os(&_writeBuffer); os << data; @@ -205,7 +205,7 @@ bool RASession::ProcessCommand(std::string& command) return false; } -void RASession::CommandPrint(void* callbackArg, const char* text) +void RASession::CommandPrint(void* callbackArg, char const* text) { if (!text || !*text) return; diff --git a/src/server/worldserver/RemoteAccess/RASession.h b/src/server/worldserver/RemoteAccess/RASession.h index be40c80c5d4..a2e39888212 100644 --- a/src/server/worldserver/RemoteAccess/RASession.h +++ b/src/server/worldserver/RemoteAccess/RASession.h @@ -43,13 +43,13 @@ public: unsigned short GetRemotePort() const { return _socket.remote_endpoint().port(); } private: - int Send(const char* data); + int Send(char const* data); std::string ReadString(); bool CheckAccessLevel(const std::string& user); bool CheckPassword(const std::string& user, const std::string& pass); bool ProcessCommand(std::string& command); - static void CommandPrint(void* callbackArg, const char* text); + static void CommandPrint(void* callbackArg, char const* text); static void CommandFinished(void* callbackArg, bool); tcp::socket _socket; diff --git a/src/server/worldserver/TCSoap/TCSoap.h b/src/server/worldserver/TCSoap/TCSoap.h index e342c154964..3ccbe134e21 100644 --- a/src/server/worldserver/TCSoap/TCSoap.h +++ b/src/server/worldserver/TCSoap/TCSoap.h @@ -38,7 +38,7 @@ class SOAPCommand { } - void appendToPrintBuffer(const char* msg) + void appendToPrintBuffer(char const* msg) { m_printBuffer += msg; } @@ -54,7 +54,7 @@ class SOAPCommand return m_success; } - static void print(void* callbackArg, const char* msg) + static void print(void* callbackArg, char const* msg) { ((SOAPCommand*)callbackArg)->appendToPrintBuffer(msg); } |
