Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: block re-login with different protocols #1877

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/creatures/players/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ class Player final : public Creature, public Cylinder, public Bankable {
operatingSystem = clientos;
}

bool isOldProtocol() {
return client && client->oldProtocol;
}

uint32_t getProtocolVersion() const {
if (!client) {
return 0;
Expand Down
7 changes: 7 additions & 0 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ void ProtocolGame::login(const std::string &name, uint32_t accountId, OperatingS
writeToOutputBuffer(opcodeMessage);
}

g_logger().debug("Player logging in in version '{}' and oldProtocol '{}'", getVersion(), oldProtocol);

// dispatcher thread
std::shared_ptr<Player> foundPlayer = g_game().getPlayerUniqueLogin(name);
if (!foundPlayer) {
Expand Down Expand Up @@ -734,6 +736,11 @@ void ProtocolGame::onRecvFirstMessage(NetworkMessage &msg) {

std::shared_ptr<Player> foundPlayer = g_game().getPlayerUniqueLogin(characterName);
if (foundPlayer && foundPlayer->client) {
if (foundPlayer->getProtocolVersion() != getVersion() && foundPlayer->isOldProtocol() != oldProtocol) {
disconnectClient(fmt::format("You are already logged in using protocol '{}'. Please log out from the other session to connect here.", foundPlayer->getProtocolVersion()));
return;
}

foundPlayer->client->disconnectClient("You are already connected through another client. Please use only one client at a time!");
}

Expand Down
Loading