From 825ef1e963fd8a30e04e69f676eecc90e601f4e1 Mon Sep 17 00:00:00 2001 From: jak1 Date: Sun, 6 Jun 2021 14:24:49 +0200 Subject: added exitcode 7 to unique sessions (-S) --- src/net/eathena/generalrecv.cpp | 15 +++++++++++++++ src/net/tmwa/generalrecv.cpp | 17 +++++++++++++++++ src/progs/manaplus/actions/actions.cpp | 11 ++++++++--- src/progs/manaplus/client.cpp | 2 +- src/settings.h | 4 +++- 5 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/net/eathena/generalrecv.cpp b/src/net/eathena/generalrecv.cpp index f1a6654dc..c3dc4b4b8 100644 --- a/src/net/eathena/generalrecv.cpp +++ b/src/net/eathena/generalrecv.cpp @@ -24,6 +24,7 @@ #include "client.h" #include "logger.h" +#include "settings.h" #include "net/messagein.h" @@ -78,6 +79,20 @@ void GeneralRecv::processConnectionProblem(Net::MessageIn &msg) // TRANSLATORS: error message errorMessage = _("Sorry, you are underaged."); break; + // all launcher (-S) cases should be added here (exitcode = code) + case 7: + if (settings.options.uniqueSession) + { + settings.exitcode = code; + client->setState(State::EXIT); + return; + } + else + { + // TRANSLATORS: error message + errorMessage = _("Unique Session required."); + } + break; case 8: // TRANSLATORS: error message errorMessage = _("Duplicated login."); diff --git a/src/net/tmwa/generalrecv.cpp b/src/net/tmwa/generalrecv.cpp index 711e627c6..7cc386c67 100644 --- a/src/net/tmwa/generalrecv.cpp +++ b/src/net/tmwa/generalrecv.cpp @@ -24,6 +24,8 @@ #include "client.h" #include "logger.h" +#include "settings.h" + #include "net/messagein.h" @@ -70,6 +72,21 @@ void GeneralRecv::processConnectionProblem(Net::MessageIn &msg) // TRANSLATORS: error message errorMessage = _("Speed hack detected."); break; + // all launcher (-S) cases should be added here (exitcode = code) + case 7: + if (settings.options.uniqueSession) + { + settings.exitcode = code; + client->setState(State::EXIT); + return; + } + else + { + // TRANSLATORS: error message + errorMessage = _("Wrong Argument set! " + "(launcher option)"); + } + break; case 8: // TRANSLATORS: error message errorMessage = _("Duplicated login."); diff --git a/src/progs/manaplus/actions/actions.cpp b/src/progs/manaplus/actions/actions.cpp index 6f9bf56b9..52eca62d9 100644 --- a/src/progs/manaplus/actions/actions.cpp +++ b/src/progs/manaplus/actions/actions.cpp @@ -1236,9 +1236,14 @@ impHandler0(cacheInfo) impHandler0(disconnect) { - if (gameHandler != nullptr) - gameHandler->disconnect2(); - return true; + if (!settings.options.uniqueSession) + { + if (gameHandler != nullptr) + gameHandler->disconnect2(); + return true; + } + else + return false; } impHandler(undress) diff --git a/src/progs/manaplus/client.cpp b/src/progs/manaplus/client.cpp index 5b86774b4..d8ba7e1c2 100644 --- a/src/progs/manaplus/client.cpp +++ b/src/progs/manaplus/client.cpp @@ -1700,7 +1700,7 @@ int Client::gameExec() PROFILER_END(); } - return 0; + return settings.exitcode; } void Client::optionChanged(const std::string &name) diff --git a/src/settings.h b/src/settings.h index 2e34780d9..7b76534bf 100644 --- a/src/settings.h +++ b/src/settings.h @@ -96,7 +96,8 @@ class Settings final uselonglivesprites(false), unknownSkillsAutoTab(true), enableNewMailSystem(true), - showButtonIcons(false) + showButtonIcons(false), + exitcode(0) { } A_DELETE_COPY(Settings) @@ -163,6 +164,7 @@ class Settings final bool unknownSkillsAutoTab; bool enableNewMailSystem; bool showButtonIcons; + int exitcode; }; extern Settings settings; -- cgit v1.2.3-70-g09d2