Skip to content
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: 2 additions & 2 deletions include/Network/PingedCompatibleServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ struct PingedCompatibleServer {
unsigned short mPort;
unsigned int mPing;
int mProtocolVersion;
int mGameModeId;
int mServerAvailability;
int mCurrentPlayers;
int mMaxPlayers;
unsigned long long mServerId;

PingedCompatibleServer()
: mPort(0), mPing(0), mProtocolVersion(0), mGameModeId(0), mCurrentPlayers(0), mMaxPlayers(0),
: mPort(0), mPing(0), mProtocolVersion(0), mServerAvailability(1), mCurrentPlayers(0), mMaxPlayers(0),
mServerId(0) {}

std::string toAnnouncement(unsigned short portV4, unsigned short portV6) const;
Expand Down
10 changes: 3 additions & 7 deletions src/Network/PingedCompatibleServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ static std::vector<std::string> splitAnnouncement(const std::string &raw) {
return fields;
}

static int announcementGameModeId(const std::string &gameMode) {
if (gameMode == "Creative")
return 2;
if (gameMode == "Adventure")
return 3;
static int serverAvailability() {
return 1;
}

Expand All @@ -38,7 +34,7 @@ std::string PingedCompatibleServer::toAnnouncement(unsigned short portV4, unsign
std::to_string(mServerId) + ";" +
mSubName + ";" +
mGameMode + ";" +
std::to_string(announcementGameModeId(mGameMode)) + ";" +
std::to_string(serverAvailability()) + ";" +
std::to_string(portV4) + ";" +
std::to_string(portV6) + ";";
}
Expand All @@ -62,7 +58,7 @@ bool PingedCompatibleServer::parse(const std::string &rawAnnouncement, PingedCom
if (fields.size() > 8)
outServer.mGameMode = fields[8];
if (fields.size() > 9)
outServer.mGameModeId = atoi(fields[9].c_str());
outServer.mServerAvailability = atoi(fields[9].c_str());
if (fields.size() > 10)
outServer.mPort = (unsigned short) atoi(fields[10].c_str());

Expand Down
4 changes: 2 additions & 2 deletions src/Network/Server/BedrockListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace {

const int LISTENER_IDLE_WAIT_MS = 1;
const char *GAME_MODE_NAME = "Survival";
const int GAME_MODE_ID = 1;
const int SERVER_AVAILABILITY = 1;
const char *GAME_VERSION_KEY = "GameVersion";
const char *NONCE_KEY = "Nonce";

Expand Down Expand Up @@ -111,7 +111,7 @@ bool BedrockListener::_addConnector(TransportLayer layer, std::string &outError)
announcement.mSubName = settings.mSubName;
announcement.mGameVersion = settings.mGameVersion;
announcement.mGameMode = GAME_MODE_NAME;
announcement.mGameModeId = GAME_MODE_ID;
announcement.mServerAvailability = SERVER_AVAILABILITY;
announcement.mProtocolVersion = settings.mProtocolVersion;
announcement.mMaxPlayers = settings.mMaxPlayers;
announcement.mPort = settings.mPort;
Expand Down