Add apworld version check on connecting

This commit is contained in:
aMannus
2025-10-18 22:37:22 +02:00
parent 49c74c75b0
commit fbd21bb342
2 changed files with 14 additions and 1 deletions

View File

@@ -81,7 +81,7 @@ bool ArchipelagoClient::StartClient() {
tags.push_back("DeathLink");
}
apClient->ConnectSlot(CVarGetString(CVAR_REMOTE_ARCHIPELAGO("SlotName"), ""), password, 0b0101, tags,
{ 0, 6, 4 });
{ 0, 6, 3 });
});
apClient->set_slot_connected_handler([&](const nlohmann::json data) {
@@ -91,6 +91,18 @@ bool ArchipelagoClient::StartClient() {
slotData = data;
std::string expectedVersion = AP_Client_consts::AP_WORLD_VERSION;
std::string apworldVersion = slotData["apworld_version"];
if (apworldVersion != expectedVersion) {
disconnecting = true;
std::string errorMessage =
"[ERROR] Client version does not match the APWorld's version.\nExpected version is " + expectedVersion +
". APWorld is on version " + apworldVersion +
" instead.\nPlease use the SoH AP client matching the APWorld's version.\nDisconnecting...";
ArchipelagoConsole_SendMessage(errorMessage.c_str());
return;
}
// if we are already in game when we connect
// we won't have to request an itemSynch
if (GameInteractor::IsSaveLoaded(true)) {

View File

@@ -16,6 +16,7 @@ static constexpr int MAX_PLAYER_NAME_LENGHT = 17;
static constexpr int MAX_PASSWORD_LENGTH = 32;
static constexpr char const* AP_GAME_NAME = "Ship of Harkinian";
static constexpr char const* AP_WORLD_VERSION = "0.0.1";
static constexpr int MAX_RETRIES = 3;
} // namespace AP_Client_consts