From 7ac63cb83886b1c92d570b210a43b0c3cb217b5f Mon Sep 17 00:00:00 2001 From: Zach Toogood Date: Mon, 23 Jan 2023 13:30:06 +0000 Subject: [PATCH 1/2] [core] MOVE MESSAGE SERVER TO XI_WORLD PROCESS - Add stubs for future systems --- .github/workflows/build.yml | 16 ++++++++++++++ src/common/application.cpp | 6 +++--- src/common/application.h | 2 +- src/login/CMakeLists.txt | 2 -- src/login/login.cpp | 9 -------- src/login/login_auth.cpp | 23 -------------------- src/world/CMakeLists.txt | 10 +++++++++ src/world/besieged_system.cpp | 22 +++++++++++++++++++ src/world/besieged_system.h | 28 +++++++++++++++++++++++++ src/world/campaign_system.cpp | 22 +++++++++++++++++++ src/world/campaign_system.h | 28 +++++++++++++++++++++++++ src/world/colonization_system.cpp | 22 +++++++++++++++++++ src/world/colonization_system.h | 28 +++++++++++++++++++++++++ src/world/conquest_system.cpp | 22 +++++++++++++++++++ src/world/conquest_system.h | 28 +++++++++++++++++++++++++ src/{login => world}/message_server.cpp | 12 ++++++++++- src/{login => world}/message_server.h | 28 ++++++++++++++++++------- src/world/world_server.cpp | 4 +--- src/world/world_server.h | 14 ++++++++++++- tools/ci/startup_checks.py | 7 ++++++- 20 files changed, 281 insertions(+), 52 deletions(-) create mode 100644 src/world/besieged_system.cpp create mode 100644 src/world/besieged_system.h create mode 100644 src/world/campaign_system.cpp create mode 100644 src/world/campaign_system.h create mode 100644 src/world/colonization_system.cpp create mode 100644 src/world/colonization_system.h create mode 100644 src/world/conquest_system.cpp create mode 100644 src/world/conquest_system.h rename src/{login => world}/message_server.cpp (97%) rename src/{login => world}/message_server.h (73%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 218aacbc5fc..2d0e9d22033 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -218,6 +218,7 @@ jobs: xi_connect xi_map xi_search + xi_world Linux_GCC11_64bit: needs: Sanity_Checks @@ -300,6 +301,7 @@ jobs: xi_connect.exe xi_map.exe xi_search.exe + xi_world.exe Windows_64bit_Release_Tracy_Modules: needs: Sanity_Checks @@ -421,12 +423,14 @@ jobs: chmod +x xi_connect chmod +x xi_map chmod +x xi_search + chmod +x xi_world ls -l printf "\nStart server processes\n" screen -d -m -S xi_connect ./xi_connect --log login-server.log screen -d -m -S xi_search ./xi_search --log search-server.log screen -d -m -S xi_map ./xi_map --log map-server.log + screen -d -m -S xi_world ./xi_world --log world-server.log printf "\nWaiting 5m for servers to fully start up\n" sleep 300s @@ -482,6 +486,7 @@ jobs: cat login-server*.log cat map-server*.log cat search-server*.log + cat world-server*.log if grep -qi "warning\|error\|crash" login-server*.log; then exit -1 @@ -495,6 +500,10 @@ jobs: exit -1 fi + if grep -qi "warning\|error\|crash" world-server*.log; then + exit -1 + fi + MultiInstance_Startup_Checks_Linux: runs-on: ubuntu-22.04 needs: Linux_Clang14_64bit @@ -542,6 +551,7 @@ jobs: chmod +x xi_connect chmod +x xi_map chmod +x xi_search + chmod +x xi_world ls -l printf "\nStart server processes\n" @@ -549,6 +559,7 @@ jobs: screen -d -m -S xi_search ./xi_search --log search-server.log screen -d -m -S xi_map ./xi_map --log map-server-0.log --ip 127.0.0.1 --port 54230 screen -d -m -S xi_map ./xi_map --log map-server-1.log --ip 127.0.0.1 --port 54231 + screen -d -m -S xi_world ./xi_world --log world-server.log sleep 300s killall screen - name: Check for errors and warnings @@ -558,6 +569,7 @@ jobs: cat search-server*.log cat map-server-0*.log cat map-server-1*.log + cat world-server*.log if grep -qi "warning\|error\|crash" login-server*.log; then exit -1 @@ -575,6 +587,10 @@ jobs: exit -1 fi + if grep -qi "warning\|error\|crash" world-server*.log; then + exit -1 + fi + Full_Startup_Checks_Windows: runs-on: windows-latest needs: Windows_64bit_Debug diff --git a/src/common/application.cpp b/src/common/application.cpp index 3212216d4d0..a6b65cba7dc 100644 --- a/src/common/application.cpp +++ b/src/common/application.cpp @@ -32,7 +32,7 @@ Application::Application(std::string serverName, std::unique_ptr&& pArgParser) : m_ServerName(serverName) -, m_IsRunning(true) +, m_RequestExit(false) , gArgParser(std::move(pArgParser)) { #ifdef _WIN32 @@ -54,14 +54,14 @@ Application::Application(std::string serverName, std::unique_ptrDoTimer(server_clock::now()); } diff --git a/src/common/application.h b/src/common/application.h index 198bfdbaa16..36499b0e5cb 100644 --- a/src/common/application.h +++ b/src/common/application.h @@ -44,7 +44,7 @@ class Application protected: std::string m_ServerName; - std::atomic m_IsRunning; + std::atomic m_RequestExit; std::unique_ptr gArgParser; std::unique_ptr gConsoleService; diff --git a/src/login/CMakeLists.txt b/src/login/CMakeLists.txt index 6c945ab963c..ae7936d1661 100644 --- a/src/login/CMakeLists.txt +++ b/src/login/CMakeLists.txt @@ -10,8 +10,6 @@ set(SOURCES login_session.h login.cpp login.h - message_server.cpp - message_server.h ) if(UNIX) diff --git a/src/login/login.cpp b/src/login/login.cpp index ee436129928..11d5cf738ba 100755 --- a/src/login/login.cpp +++ b/src/login/login.cpp @@ -66,9 +66,6 @@ struct epoll_event login_lobbyviewEpollEvent = { EPOLLIN }; #include "login.h" #include "login_auth.h" #include "login_conf.h" -#include "message_server.h" - -std::thread messageThread; std::unique_ptr sql; @@ -143,7 +140,6 @@ int32 do_init(int32 argc, char** argv) ShowInfo("Character deletion is currently disabled."); } - messageThread = std::thread(message_server_init, std::ref(requestExit)); // clang-format off gConsoleService = std::make_unique(); @@ -206,11 +202,6 @@ int32 do_init(int32 argc, char** argv) void do_final(int code) { requestExit = true; - message_server_close(); - if (messageThread.joinable()) - { - messageThread.join(); - } timer_final(); socket_final(); diff --git a/src/login/login_auth.cpp b/src/login/login_auth.cpp index 9866754e423..aab5e9a7503 100644 --- a/src/login/login_auth.cpp +++ b/src/login/login_auth.cpp @@ -24,7 +24,6 @@ #include "login.h" #include "login_auth.h" -#include "message_server.h" #include #include @@ -132,28 +131,6 @@ int32 login_parse(int32 fd) { fmtQuery = "UPDATE accounts SET accounts.timelastmodify = NULL WHERE accounts.id = %d"; sql->Query(fmtQuery, sd->accid); - fmtQuery = "SELECT charid, server_addr, server_port \ - FROM accounts_sessions JOIN accounts \ - ON accounts_sessions.accid = accounts.id \ - WHERE accounts.id = %d;"; - ret = sql->Query(fmtQuery, sd->accid); - if (ret != SQL_ERROR && sql->NumRows() == 1) - { - while (sql->NextRow() == SQL_SUCCESS) - { - uint32 charid = sql->GetUIntData(0); - uint64 ip = sql->GetUIntData(1); - uint64 port = sql->GetUIntData(2); - - ip |= (port << 32); - - zmq::message_t chardata(sizeof(charid)); - ref((uint8*)chardata.data(), 0) = charid; - zmq::message_t empty(0); - - queue_message(ip, MSG_LOGIN, &chardata, &empty); - } - } memset(&sessions[fd]->wdata[0], 0, 33); sessions[fd]->wdata.resize(33); ref(sessions[fd]->wdata.data(), 0) = LOGIN_SUCCESS; diff --git a/src/world/CMakeLists.txt b/src/world/CMakeLists.txt index d4a954cbded..13908009af1 100644 --- a/src/world/CMakeLists.txt +++ b/src/world/CMakeLists.txt @@ -1,8 +1,18 @@ set(SOURCES ${COMMON_SOURCES} + besieged_system.cpp + besieged_system.h + campaign_system.cpp + campaign_system.h + colonization_system.cpp + colonization_system.h + conquest_system.cpp + conquest_system.h http_server.cpp http_server.h main.cpp + message_server.cpp + message_server.h world_server.cpp world_server.h) diff --git a/src/world/besieged_system.cpp b/src/world/besieged_system.cpp new file mode 100644 index 00000000000..ba6a3b012bf --- /dev/null +++ b/src/world/besieged_system.cpp @@ -0,0 +1,22 @@ +/* +=========================================================================== + +Copyright (c) 2023 LandSandBoat Dev Teams + +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 3 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 "besieged_system.h" diff --git a/src/world/besieged_system.h b/src/world/besieged_system.h new file mode 100644 index 00000000000..d6bdd38166b --- /dev/null +++ b/src/world/besieged_system.h @@ -0,0 +1,28 @@ +/* +=========================================================================== + +Copyright (c) 2023 LandSandBoat Dev Teams + +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 3 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/ + +=========================================================================== +*/ +#pragma once + +class BesiegedSystem +{ +public: + BesiegedSystem() = default; + ~BesiegedSystem() = default; +}; diff --git a/src/world/campaign_system.cpp b/src/world/campaign_system.cpp new file mode 100644 index 00000000000..83a3f9cb38a --- /dev/null +++ b/src/world/campaign_system.cpp @@ -0,0 +1,22 @@ +/* +=========================================================================== + +Copyright (c) 2023 LandSandBoat Dev Teams + +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 3 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 "campaign_system.h" diff --git a/src/world/campaign_system.h b/src/world/campaign_system.h new file mode 100644 index 00000000000..afb7f1bb725 --- /dev/null +++ b/src/world/campaign_system.h @@ -0,0 +1,28 @@ +/* +=========================================================================== + +Copyright (c) 2023 LandSandBoat Dev Teams + +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 3 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/ + +=========================================================================== +*/ +#pragma once + +class CampaignSystem +{ +public: + CampaignSystem() = default; + ~CampaignSystem() = default; +}; diff --git a/src/world/colonization_system.cpp b/src/world/colonization_system.cpp new file mode 100644 index 00000000000..56bb9773a14 --- /dev/null +++ b/src/world/colonization_system.cpp @@ -0,0 +1,22 @@ +/* +=========================================================================== + +Copyright (c) 2023 LandSandBoat Dev Teams + +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 3 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 "colonization_system.h" diff --git a/src/world/colonization_system.h b/src/world/colonization_system.h new file mode 100644 index 00000000000..d7c1170da73 --- /dev/null +++ b/src/world/colonization_system.h @@ -0,0 +1,28 @@ +/* +=========================================================================== + +Copyright (c) 2023 LandSandBoat Dev Teams + +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 3 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/ + +=========================================================================== +*/ +#pragma once + +class ColonizationSystem +{ +public: + ColonizationSystem() = default; + ~ColonizationSystem() = default; +}; diff --git a/src/world/conquest_system.cpp b/src/world/conquest_system.cpp new file mode 100644 index 00000000000..362cb84a44e --- /dev/null +++ b/src/world/conquest_system.cpp @@ -0,0 +1,22 @@ +/* +=========================================================================== + +Copyright (c) 2023 LandSandBoat Dev Teams + +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 3 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 "conquest_system.h" diff --git a/src/world/conquest_system.h b/src/world/conquest_system.h new file mode 100644 index 00000000000..7e3bf8ac693 --- /dev/null +++ b/src/world/conquest_system.h @@ -0,0 +1,28 @@ +/* +=========================================================================== + +Copyright (c) 2023 LandSandBoat Dev Teams + +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 3 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/ + +=========================================================================== +*/ +#pragma once + +class ConquestSystem +{ +public: + ConquestSystem() = default; + ~ConquestSystem() = default; +}; diff --git a/src/login/message_server.cpp b/src/world/message_server.cpp similarity index 97% rename from src/login/message_server.cpp rename to src/world/message_server.cpp index ae33e626073..e0fbc70e116 100644 --- a/src/login/message_server.cpp +++ b/src/world/message_server.cpp @@ -24,12 +24,19 @@ along with this program. If not, see http://www.gnu.org/licenses/ #include #include "common/logging.h" -#include "login.h" #include "message_server.h" zmq::context_t zContext; std::unique_ptr zSocket; +struct chat_message_t +{ + uint64 dest; + MSGSERVTYPE type; + zmq::message_t data; + zmq::message_t packet; +}; + moodycamel::ConcurrentQueue outgoing_queue; std::unique_ptr zmqSql; @@ -256,6 +263,8 @@ void message_server_init(const bool& requestExit) settings::get("network.ZMQ_IP"), settings::get("network.ZMQ_PORT")); + ShowInfo("Starting ZMQ Server on %s", server.c_str()); + try { zSocket->bind(server.c_str()); @@ -265,6 +274,7 @@ void message_server_init(const bool& requestExit) ShowCritical(fmt::format("Unable to bind chat socket: {}", err.what())); } + ShowInfo("ZMQ Server listening..."); message_server_listen(requestExit); } diff --git a/src/login/message_server.h b/src/world/message_server.h similarity index 73% rename from src/login/message_server.h rename to src/world/message_server.h index d53287e5ba4..d21ecf78495 100644 --- a/src/login/message_server.h +++ b/src/world/message_server.h @@ -18,21 +18,33 @@ along with this program. If not, see http://www.gnu.org/licenses/ =========================================================================== */ +#pragma once + #include "common/mmo.h" #include "common/socket.h" #include "common/sql.h" +#include #include #include -struct chat_message_t -{ - uint64 dest; - MSGSERVTYPE type; - zmq::message_t data; - zmq::message_t packet; -}; +void queue_message(uint64 ipp, MSGSERVTYPE type, zmq::message_t* extra, zmq::message_t* packet); void message_server_init(const bool& requestExit); void message_server_close(); -void queue_message(uint64 ipp, MSGSERVTYPE type, zmq::message_t* extra, zmq::message_t* packet); + +struct message_server_wrapper_t +{ + message_server_wrapper_t(const std::atomic_bool& requestExit) + : m_thread(std::make_unique(std::bind(message_server_init, std::ref(requestExit)))) + { + } + + ~message_server_wrapper_t() + { + message_server_close(); + } + +private: + std::unique_ptr m_thread; +}; diff --git a/src/world/world_server.cpp b/src/world/world_server.cpp index f2723def84d..95dde431622 100644 --- a/src/world/world_server.cpp +++ b/src/world/world_server.cpp @@ -24,10 +24,9 @@ along with this program. If not, see http://www.gnu.org/licenses/ #include "common/console_service.h" #include "common/logging.h" -#include "http_server.h" - WorldServer::WorldServer(std::unique_ptr&& pArgParser) : Application("world", std::move(pArgParser)) +, messageServer(std::make_unique(std::ref(m_RequestExit))) , httpServer(std::make_unique()) { } @@ -38,5 +37,4 @@ WorldServer::~WorldServer() void WorldServer::Tick() { - Application::Tick(); } diff --git a/src/world/world_server.h b/src/world/world_server.h index 29b2dd27a83..3bbee9e9bbb 100644 --- a/src/world/world_server.h +++ b/src/world/world_server.h @@ -22,7 +22,12 @@ along with this program. If not, see http://www.gnu.org/licenses/ #include "common/application.h" -class HTTPServer; +#include "besieged_system.h" +#include "campaign_system.h" +#include "colonization_system.h" +#include "conquest_system.h" +#include "http_server.h" +#include "message_server.h" class WorldServer final : public Application { @@ -33,5 +38,12 @@ class WorldServer final : public Application void Tick() override; private: + std::unique_ptr messageServer; + + std::unique_ptr conquestSystem; + std::unique_ptr besiegedSystem; + std::unique_ptr campaignSystem; + std::unique_ptr colonizationSystem; + std::unique_ptr httpServer; }; diff --git a/tools/ci/startup_checks.py b/tools/ci/startup_checks.py index bce3f5f4219..b657485599c 100644 --- a/tools/ci/startup_checks.py +++ b/tools/ci/startup_checks.py @@ -18,6 +18,10 @@ def main(): p2 = subprocess.Popen( ["xi_map", "--log", "game-server.log", "--load_all"], stdout=subprocess.PIPE ) + p3 = subprocess.Popen( + ["xi_world", "--log", "world-server.log"], stdout=subprocess.PIPE + ) + print("Sleeping for 5 minutes...") @@ -26,12 +30,13 @@ def main(): p0.kill() p1.kill() p2.kill() + p3.kill() print("Killing exes and checking logs...") has_seen_output = False error = False - for proc in {p0, p1, p2}: + for proc in {p0, p1, p2, p3}: print(proc.args[0]) for line in io.TextIOWrapper(proc.stdout, encoding="utf-8"): print(line.replace("\n", "")) From 4072f9ba8596ae915b0593a5bd91e9d46f029d42 Mon Sep 17 00:00:00 2001 From: Zach Toogood Date: Fri, 10 Feb 2023 10:14:36 +0000 Subject: [PATCH 2/2] [core] Refactor argparse usage in Application --- src/common/application.cpp | 21 ++++++++++++++++++--- src/common/application.h | 2 +- src/login/login_auth.cpp | 32 ++++++++++++++++++++++++++++++++ src/world/main.cpp | 15 +-------------- src/world/world_server.cpp | 4 ++-- src/world/world_server.h | 2 +- 6 files changed, 55 insertions(+), 21 deletions(-) diff --git a/src/common/application.cpp b/src/common/application.cpp index a6b65cba7dc..ee0d87a70bf 100644 --- a/src/common/application.cpp +++ b/src/common/application.cpp @@ -30,16 +30,31 @@ #include #endif -Application::Application(std::string serverName, std::unique_ptr&& pArgParser) +Application::Application(std::string serverName, int argc, char** argv) : m_ServerName(serverName) , m_RequestExit(false) -, gArgParser(std::move(pArgParser)) +, gArgParser(std::make_unique(argv[0])) { #ifdef _WIN32 SetConsoleTitleA(fmt::format("{}-server", serverName).c_str()); #endif - logging::InitializeLog(serverName, fmt::format("log/{}-server.log", serverName), false); + gArgParser->add_argument("--log") + .default_value(fmt::format("log/{}-server.log", serverName)); + + try + { + gArgParser->parse_args(argc, argv); + } + catch (const std::runtime_error& err) + { + std::cerr << err.what() << std::endl; + std::cerr << *gArgParser; + std::exit(1); + } + + auto logName = gArgParser->get("--log"); + logging::InitializeLog(serverName, logName, false); lua_init(); settings::init(); ShowInfo("Begin %s-server initialisation...", serverName); diff --git a/src/common/application.h b/src/common/application.h index 36499b0e5cb..27fb86210d9 100644 --- a/src/common/application.h +++ b/src/common/application.h @@ -31,7 +31,7 @@ class Application { public: - Application(std::string serverName, std::unique_ptr&& pArgParser); + Application(std::string serverName, int argc, char** argv); virtual ~Application() = default; Application(const Application&) = delete; diff --git a/src/login/login_auth.cpp b/src/login/login_auth.cpp index aab5e9a7503..027c362804b 100644 --- a/src/login/login_auth.cpp +++ b/src/login/login_auth.cpp @@ -22,6 +22,8 @@ #include "common/logging.h" #include "common/socket.h" +#include "map/message.h" + #include "login.h" #include "login_auth.h" @@ -131,6 +133,36 @@ int32 login_parse(int32 fd) { fmtQuery = "UPDATE accounts SET accounts.timelastmodify = NULL WHERE accounts.id = %d"; sql->Query(fmtQuery, sd->accid); + + fmtQuery = "SELECT charid, server_addr, server_port \ + FROM accounts_sessions JOIN accounts \ + ON accounts_sessions.accid = accounts.id \ + WHERE accounts.id = %d;"; + ret = sql->Query(fmtQuery, sd->accid); + if (ret != SQL_ERROR && sql->NumRows() == 1) + { + while (sql->NextRow() == SQL_SUCCESS) + { + uint32 charid = sql->GetUIntData(0); + uint64 ip = sql->GetUIntData(1); + uint64 port = sql->GetUIntData(2); + + ip |= (port << 32); + + std::ignore = ip; + + zmq::message_t chardata(sizeof(charid)); + ref((uint8*)chardata.data(), 0) = charid; + zmq::message_t empty(0); + + // TODO: MSG_LOGIN is a no-op in message_server.cpp, + // : so sending this does nothing? + // : But in the client (message.cpp), it _could_ + // : be used to clear out lingering PChar data. + // queue_message(ipp, MSG_LOGIN, &chardata, &empty); + } + } + memset(&sessions[fd]->wdata[0], 0, 33); sessions[fd]->wdata.resize(33); ref(sessions[fd]->wdata.data(), 0) = LOGIN_SUCCESS; diff --git a/src/world/main.cpp b/src/world/main.cpp index e930dfb924b..632dc1519c3 100644 --- a/src/world/main.cpp +++ b/src/world/main.cpp @@ -25,20 +25,7 @@ std::atomic gRunFlag = true; int main(int argc, char** argv) { - auto argParser = std::make_unique(argv[0]); - - try - { - argParser->parse_args(argc, argv); - } - catch (const std::runtime_error& err) - { - std::cerr << err.what() << std::endl; - std::cerr << *argParser; - std::exit(1); - } - - auto pWorldServer = std::make_unique(std::move(argParser)); + auto pWorldServer = std::make_unique(argc, argv); while (pWorldServer->IsRunning()) { diff --git a/src/world/world_server.cpp b/src/world/world_server.cpp index 95dde431622..044e8a03ea4 100644 --- a/src/world/world_server.cpp +++ b/src/world/world_server.cpp @@ -24,8 +24,8 @@ along with this program. If not, see http://www.gnu.org/licenses/ #include "common/console_service.h" #include "common/logging.h" -WorldServer::WorldServer(std::unique_ptr&& pArgParser) -: Application("world", std::move(pArgParser)) +WorldServer::WorldServer(int argc, char** argv) +: Application("world", argc, argv) , messageServer(std::make_unique(std::ref(m_RequestExit))) , httpServer(std::make_unique()) { diff --git a/src/world/world_server.h b/src/world/world_server.h index 3bbee9e9bbb..60fb0b7d958 100644 --- a/src/world/world_server.h +++ b/src/world/world_server.h @@ -32,7 +32,7 @@ along with this program. If not, see http://www.gnu.org/licenses/ class WorldServer final : public Application { public: - WorldServer(std::unique_ptr&& pArgParser); + WorldServer(int argc, char** argv); ~WorldServer() override; void Tick() override;