Connection changes
This commit is contained in:
parent
b39072f071
commit
8bef4abdbc
@ -360,7 +360,7 @@ void ClientApplication::update() {
|
|||||||
|
|
||||||
m_guiContext->cleanup();
|
m_guiContext->cleanup();
|
||||||
m_edgeKeyEvents.clear();
|
m_edgeKeyEvents.clear();
|
||||||
m_input->reset();
|
m_input->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientApplication::render() {
|
void ClientApplication::render() {
|
||||||
|
@ -404,10 +404,10 @@ ClientConnectPacket::ClientConnectPacket() {}
|
|||||||
|
|
||||||
ClientConnectPacket::ClientConnectPacket(ByteArray assetsDigest, bool allowAssetsMismatch, Uuid playerUuid,
|
ClientConnectPacket::ClientConnectPacket(ByteArray assetsDigest, bool allowAssetsMismatch, Uuid playerUuid,
|
||||||
String playerName, String playerSpecies, WorldChunks shipChunks, ShipUpgrades shipUpgrades,
|
String playerName, String playerSpecies, WorldChunks shipChunks, ShipUpgrades shipUpgrades,
|
||||||
bool introComplete, String account)
|
bool introComplete, String account, Json info)
|
||||||
: assetsDigest(std::move(assetsDigest)), allowAssetsMismatch(allowAssetsMismatch), playerUuid(std::move(playerUuid)),
|
: assetsDigest(std::move(assetsDigest)), allowAssetsMismatch(allowAssetsMismatch), playerUuid(std::move(playerUuid)),
|
||||||
playerName(std::move(playerName)), playerSpecies(std::move(playerSpecies)), shipChunks(std::move(shipChunks)),
|
playerName(std::move(playerName)), playerSpecies(std::move(playerSpecies)), shipChunks(std::move(shipChunks)),
|
||||||
shipUpgrades(std::move(shipUpgrades)), introComplete(std::move(introComplete)), account(std::move(account)) {}
|
shipUpgrades(std::move(shipUpgrades)), introComplete(std::move(introComplete)), account(std::move(account)), info(std::move(info)) {}
|
||||||
|
|
||||||
void ClientConnectPacket::readLegacy(DataStream& ds) {
|
void ClientConnectPacket::readLegacy(DataStream& ds) {
|
||||||
ds.read(assetsDigest);
|
ds.read(assetsDigest);
|
||||||
@ -419,6 +419,7 @@ void ClientConnectPacket::readLegacy(DataStream& ds) {
|
|||||||
ds.read(shipUpgrades);
|
ds.read(shipUpgrades);
|
||||||
ds.read(introComplete);
|
ds.read(introComplete);
|
||||||
ds.read(account);
|
ds.read(account);
|
||||||
|
info = Json();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientConnectPacket::read(DataStream& ds) {
|
void ClientConnectPacket::read(DataStream& ds) {
|
||||||
|
@ -310,7 +310,7 @@ struct ClientConnectPacket : PacketBase<PacketType::ClientConnect> {
|
|||||||
ClientConnectPacket();
|
ClientConnectPacket();
|
||||||
ClientConnectPacket(ByteArray assetsDigest, bool allowAssetsMismatch, Uuid playerUuid, String playerName,
|
ClientConnectPacket(ByteArray assetsDigest, bool allowAssetsMismatch, Uuid playerUuid, String playerName,
|
||||||
String playerSpecies, WorldChunks shipChunks, ShipUpgrades shipUpgrades, bool introComplete,
|
String playerSpecies, WorldChunks shipChunks, ShipUpgrades shipUpgrades, bool introComplete,
|
||||||
String account);
|
String account, Json info = {});
|
||||||
|
|
||||||
void readLegacy(DataStream& ds) override;
|
void readLegacy(DataStream& ds) override;
|
||||||
void read(DataStream& ds) override;
|
void read(DataStream& ds) override;
|
||||||
|
@ -111,10 +111,11 @@ Maybe<String> UniverseClient::connect(UniverseConnection connection, bool allowA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
connection.packetSocket().setLegacy(m_legacyServer);
|
connection.packetSocket().setLegacy(m_legacyServer);
|
||||||
|
auto clientConnect = make_shared<ClientConnectPacket>(Root::singleton().assets()->digest(), allowAssetsMismatch, m_mainPlayer->uuid(), m_mainPlayer->name(),
|
||||||
connection.pushSingle(make_shared<ClientConnectPacket>(Root::singleton().assets()->digest(), allowAssetsMismatch, m_mainPlayer->uuid(), m_mainPlayer->name(),
|
|
||||||
m_mainPlayer->species(), m_playerStorage->loadShipData(m_mainPlayer->uuid()), m_mainPlayer->shipUpgrades(),
|
m_mainPlayer->species(), m_playerStorage->loadShipData(m_mainPlayer->uuid()), m_mainPlayer->shipUpgrades(),
|
||||||
m_mainPlayer->log()->introComplete(), account));
|
m_mainPlayer->log()->introComplete(), account);
|
||||||
|
clientConnect->info = JsonObject{ {"brand", "OpenStarbound"} };
|
||||||
|
connection.pushSingle(std::move(clientConnect));
|
||||||
connection.sendAll(timeout);
|
connection.sendAll(timeout);
|
||||||
|
|
||||||
connection.receiveAny(timeout);
|
connection.receiveAny(timeout);
|
||||||
|
@ -1584,7 +1584,7 @@ void UniverseServer::acceptConnection(UniverseConnection connection, Maybe<HostA
|
|||||||
compressedSocket->setCompressionStreamEnabled(useCompressionStream);
|
compressedSocket->setCompressionStreamEnabled(useCompressionStream);
|
||||||
|
|
||||||
String remoteAddressString = remoteAddress ? toString(*remoteAddress) : "local";
|
String remoteAddressString = remoteAddress ? toString(*remoteAddress) : "local";
|
||||||
Logger::info("UniverseServer: Awaiting connection info from {}, {} client", remoteAddressString, legacyClient ? "Starbound" : "OpenStarbound");
|
Logger::info("UniverseServer: Awaiting connection info from {} ({} client)", remoteAddressString, legacyClient ? "vanilla" : "custom");
|
||||||
|
|
||||||
connection.receiveAny(clientWaitLimit);
|
connection.receiveAny(clientWaitLimit);
|
||||||
auto clientConnect = as<ClientConnectPacket>(connection.pullSingle());
|
auto clientConnect = as<ClientConnectPacket>(connection.pullSingle());
|
||||||
@ -1597,7 +1597,6 @@ void UniverseServer::acceptConnection(UniverseConnection connection, Maybe<HostA
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool administrator = false;
|
bool administrator = false;
|
||||||
|
|
||||||
String accountString = !clientConnect->account.empty() ? strf("'{}'", clientConnect->account) : "<anonymous>";
|
String accountString = !clientConnect->account.empty() ? strf("'{}'", clientConnect->account) : "<anonymous>";
|
||||||
|
|
||||||
auto connectionFail = [&](String message) {
|
auto connectionFail = [&](String message) {
|
||||||
@ -1669,14 +1668,24 @@ void UniverseServer::acceptConnection(UniverseConnection connection, Maybe<HostA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::info("UniverseServer: Logged in account '{}' as player '{}' from address {}",
|
String connectionLog = strf("UniverseServer: Logged in account '{}' as player '{}' from address {}",
|
||||||
accountString, clientConnect->playerName, remoteAddressString);
|
accountString, clientConnect->playerName, remoteAddressString);
|
||||||
|
|
||||||
|
if (Json& info = clientConnect->info) {
|
||||||
|
if (Json brand = info.get("brand", "custom"))
|
||||||
|
connectionLog += strf(" ({} client)", brand.toString());
|
||||||
|
if (info.getBool("legacy", false))
|
||||||
|
connection.packetSocket().setLegacy(legacyClient = true);
|
||||||
|
}
|
||||||
|
Logger::log(LogLevel::Info, connectionLog.utf8Ptr());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mainLocker.lock();
|
mainLocker.lock();
|
||||||
WriteLocker clientsLocker(m_clientsLock);
|
WriteLocker clientsLocker(m_clientsLock);
|
||||||
if (auto clashId = getClientForUuid(clientConnect->playerUuid)) {
|
if (auto clashId = getClientForUuid(clientConnect->playerUuid)) {
|
||||||
if (administrator) {
|
if (administrator) {
|
||||||
doDisconnection(*clashId, "Duplicate Uuid joined and is Administrator so has priority.");
|
doDisconnection(*clashId, "Duplicate UUID joined and is Administrator so has priority.");
|
||||||
} else {
|
} else {
|
||||||
connectionFail("Duplicate player UUID");
|
connectionFail("Duplicate player UUID");
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user