diff options
author | Bottinator22 <bottinator22@gmail.com> | 2025-04-25 00:27:10 -0700 |
---|---|---|
committer | Bottinator22 <bottinator22@gmail.com> | 2025-04-25 00:27:10 -0700 |
commit | 621864b9b00ba7a9ae0fceb0a7db3ace6d4906b9 (patch) | |
tree | 6e85c4e1980fb648772446c8f8db994e5a71fdc2 | |
parent | 6369ba9ec72f097d8cc9ab06bed0c6816da516c8 (diff) |
allow forcing legacy connections
-rw-r--r-- | assets/opensb/interface/windowconfig/multiplayer.config.patch | 22 | ||||
-rw-r--r-- | source/client/StarClientApplication.cpp | 11 | ||||
-rw-r--r-- | source/client/StarClientApplication.hpp | 1 | ||||
-rw-r--r-- | source/frontend/StarTitleScreen.cpp | 17 | ||||
-rw-r--r-- | source/frontend/StarTitleScreen.hpp | 4 | ||||
-rw-r--r-- | source/game/StarUniverseClient.cpp | 12 | ||||
-rw-r--r-- | source/game/StarUniverseClient.hpp | 2 |
7 files changed, 58 insertions, 11 deletions
diff --git a/assets/opensb/interface/windowconfig/multiplayer.config.patch b/assets/opensb/interface/windowconfig/multiplayer.config.patch index 8bd27c1..bfd6297 100644 --- a/assets/opensb/interface/windowconfig/multiplayer.config.patch +++ b/assets/opensb/interface/windowconfig/multiplayer.config.patch @@ -4,5 +4,25 @@ "anchor" : "center", "positionLocked" : true }, + "connect": { + "position" : [34, 32] + }, + "legacyLabel" : { + "type" : "label", + "position" : [130, 34], + "hAnchor" : "left", + "value" : "FORCE LEGACY" + }, + "legacyCheckbox" : { + "type" : "button", + "pressedOffset" : [0, 0], + "position" : [120, 34], + "base" : "/interface/optionsmenu/checkboxnocheck.png", + "hover" : "/interface/optionsmenu/checkboxnocheckhover.png", + "baseImageChecked" : "/interface/optionsmenu/checkboxcheck.png", + "hoverImageChecked" : "/interface/optionsmenu/checkboxcheckhover.png", + "checkable" : true, + "checked": false + }, "password" : { "hidden" : true } -}
\ No newline at end of file +} diff --git a/source/client/StarClientApplication.cpp b/source/client/StarClientApplication.cpp index a86a574..f79226e 100644 --- a/source/client/StarClientApplication.cpp +++ b/source/client/StarClientApplication.cpp @@ -73,7 +73,8 @@ Json const AdditionalDefaultConfiguration = Json::parseJson(R"JSON( "title" : { "multiPlayerAddress" : "", "multiPlayerPort" : "", - "multiPlayerAccount" : "" + "multiPlayerAccount" : "", + "multiPlayerForceLegacy" : false }, "bindings" : { @@ -638,6 +639,7 @@ void ClientApplication::changeState(MainAppState newState) { m_titleScreen->setMultiPlayerAddress(toString(address->address())); m_titleScreen->setMultiPlayerPort(toString(address->port())); m_titleScreen->setMultiPlayerAccount(configuration->getPath("title.multiPlayerAccount").toString()); + m_titleScreen->setMultiPlayerForceLegacy(configuration->getPath("title.multiPlayerForceLegacy").optBool().value(false)); m_titleScreen->goToMultiPlayerSelectCharacter(false); } else { m_titleScreen->goToMultiPlayerSelectCharacter(true); @@ -646,6 +648,7 @@ void ClientApplication::changeState(MainAppState newState) { m_titleScreen->setMultiPlayerAddress(configuration->getPath("title.multiPlayerAddress").toString()); m_titleScreen->setMultiPlayerPort(configuration->getPath("title.multiPlayerPort").toString()); m_titleScreen->setMultiPlayerAccount(configuration->getPath("title.multiPlayerAccount").toString()); + m_titleScreen->setMultiPlayerForceLegacy(configuration->getPath("title.multiPlayerForceLegacy").optBool().value(false)); } } @@ -710,7 +713,7 @@ void ClientApplication::changeState(MainAppState newState) { bool allowAssetsMismatch = m_root->configuration()->get("allowAssetsMismatch").toBool(); if (auto errorMessage = m_universeClient->connect(UniverseConnection(std::move(packetSocket)), allowAssetsMismatch, - multiPlayerConnection.account, multiPlayerConnection.password)) { + multiPlayerConnection.account, multiPlayerConnection.password, multiPlayerConnection.forceLegacy)) { setError(*errorMessage); return; } @@ -882,13 +885,15 @@ void ClientApplication::updateTitle(float dt) { m_pendingMultiPlayerConnection = PendingMultiPlayerConnection{ address.right(), m_titleScreen->multiPlayerAccount(), - m_titleScreen->multiPlayerPassword() + m_titleScreen->multiPlayerPassword(), + m_titleScreen->multiPlayerForceLegacy() }; auto configuration = m_root->configuration(); configuration->setPath("title.multiPlayerAddress", m_titleScreen->multiPlayerAddress()); configuration->setPath("title.multiPlayerPort", m_titleScreen->multiPlayerPort()); configuration->setPath("title.multiPlayerAccount", m_titleScreen->multiPlayerAccount()); + configuration->setPath("title.multiPlayerForceLegacy", m_titleScreen->multiPlayerForceLegacy()); changeState(MainAppState::MultiPlayer); } diff --git a/source/client/StarClientApplication.hpp b/source/client/StarClientApplication.hpp index 2fcddb7..8824ea0 100644 --- a/source/client/StarClientApplication.hpp +++ b/source/client/StarClientApplication.hpp @@ -57,6 +57,7 @@ private: Variant<P2PNetworkingPeerId, HostAddressWithPort> server; String account; String password; + bool forceLegacy; }; struct PostProcessGroup { diff --git a/source/frontend/StarTitleScreen.cpp b/source/frontend/StarTitleScreen.cpp index a32b51a..f1ffcd9 100644 --- a/source/frontend/StarTitleScreen.cpp +++ b/source/frontend/StarTitleScreen.cpp @@ -213,6 +213,15 @@ void TitleScreen::setMultiPlayerPassword(String password) { m_password = std::move(password); } +bool TitleScreen::multiPlayerForceLegacy() const { + return m_forceLegacy; +} + +void TitleScreen::setMultiPlayerForceLegacy(bool const& forceLegacy) { + m_multiPlayerMenu->fetchChild<ButtonWidget>("legacyCheckbox")->setChecked(forceLegacy); + m_forceLegacy = forceLegacy; +} + void TitleScreen::initMainMenu() { m_mainMenu = make_shared<Pane>(); auto backMenu = make_shared<Pane>(); @@ -347,7 +356,8 @@ void TitleScreen::initMultiPlayerMenu() { {"address", multiPlayerAddress()}, {"account", multiPlayerAccount()}, {"port", multiPlayerPort()}, - //{"password", multiPlayerPassword()} + //{"password", multiPlayerPassword()}, + {"forceLegacy",multiPlayerForceLegacy()} }; auto serverList = m_serverSelectPane->fetchChild<ListWidget>("serverSelectArea.serverList"); @@ -384,6 +394,7 @@ void TitleScreen::initMultiPlayerMenu() { setMultiPlayerPort(data.getString("port", "")); setMultiPlayerAccount(data.getString("account", "")); setMultiPlayerPassword(data.getString("password", "")); + setMultiPlayerForceLegacy(data.getBool("forceLegacy", false)); if (auto passwordWidget = m_multiPlayerMenu->fetchChild("password")) passwordWidget->focus(); @@ -406,6 +417,10 @@ void TitleScreen::initMultiPlayerMenu() { readerConnect.registerCallback("password", [=](Widget* obj) { m_password = convert<TextBoxWidget>(obj)->getText().trim(); }); + + readerConnect.registerCallback("legacyCheckbox", [=](Widget* obj) { + m_forceLegacy = convert<ButtonWidget>(obj)->isChecked(); + }); readerConnect.registerCallback("connect", [=](Widget*) { switchState(TitleState::StartMultiPlayer); diff --git a/source/frontend/StarTitleScreen.hpp b/source/frontend/StarTitleScreen.hpp index 3199247..095774f 100644 --- a/source/frontend/StarTitleScreen.hpp +++ b/source/frontend/StarTitleScreen.hpp @@ -77,6 +77,9 @@ public: String multiPlayerPassword() const; void setMultiPlayerPassword(String password); + bool multiPlayerForceLegacy() const; + void setMultiPlayerForceLegacy(bool const& forceLegacy); + private: void initMainMenu(); void initCharSelectionMenu(); @@ -122,6 +125,7 @@ private: String m_connectionPort; String m_account; String m_password; + bool m_forceLegacy; CelestialMasterDatabasePtr m_celestialDatabase; diff --git a/source/game/StarUniverseClient.cpp b/source/game/StarUniverseClient.cpp index f33c953..b41d19e 100644 --- a/source/game/StarUniverseClient.cpp +++ b/source/game/StarUniverseClient.cpp @@ -71,7 +71,7 @@ PlayerPtr UniverseClient::mainPlayer() const { return m_mainPlayer; } -Maybe<String> UniverseClient::connect(UniverseConnection connection, bool allowAssetsMismatch, String const& account, String const& password) { +Maybe<String> UniverseClient::connect(UniverseConnection connection, bool allowAssetsMismatch, String const& account, String const& password, bool const& forceLegacy) { auto& root = Root::singleton(); auto assets = root.assets(); @@ -85,9 +85,11 @@ Maybe<String> UniverseClient::connect(UniverseConnection connection, bool allowA { auto protocolRequest = make_shared<ProtocolRequestPacket>(StarProtocolVersion); - protocolRequest->setCompressionMode(PacketCompressionMode::Enabled); - // Signal that we're OpenStarbound. Vanilla Starbound only compresses - // packets above 64 bytes - by forcing it, we can communicate this. + if (!forceLegacy) { + protocolRequest->setCompressionMode(PacketCompressionMode::Enabled); + // Signal that we're OpenStarbound. Vanilla Starbound only compresses + // packets above 64 bytes - by forcing it, we can communicate this. + } connection.pushSingle(protocolRequest); } connection.sendAll(timeout); @@ -101,7 +103,7 @@ Maybe<String> UniverseClient::connect(UniverseConnection connection, bool allowA NetCompatibilityRules compatibilityRules; compatibilityRules.setVersion(LegacyVersion); - bool legacyServer = protocolResponsePacket->compressionMode() != PacketCompressionMode::Enabled; + bool legacyServer = forceLegacy || (protocolResponsePacket->compressionMode() != PacketCompressionMode::Enabled); if (!legacyServer) { auto compressedSocket = as<CompressedPacketSocket>(&connection.packetSocket()); if (protocolResponsePacket->info) { diff --git a/source/game/StarUniverseClient.hpp b/source/game/StarUniverseClient.hpp index 1cb3bfa..b1c589f 100644 --- a/source/game/StarUniverseClient.hpp +++ b/source/game/StarUniverseClient.hpp @@ -41,7 +41,7 @@ public: PlayerPtr mainPlayer() const; // Returns error if connection failed - Maybe<String> connect(UniverseConnection connection, bool allowAssetsMismatch, String const& account = "", String const& password = ""); + Maybe<String> connect(UniverseConnection connection, bool allowAssetsMismatch, String const& account = "", String const& password = "", bool const& forceLegacy = false); bool isConnected() const; void disconnect(); Maybe<String> disconnectReason() const; |