Fixed crash on game completion without being connected

This commit is contained in:
Jerom Venneker
2025-07-09 19:21:40 +02:00
parent d53afb534d
commit 6df2fd9b8a

View File

@@ -39,7 +39,7 @@ ArchipelagoClient& ArchipelagoClient::GetInstance() {
} }
bool ArchipelagoClient::StartClient() { bool ArchipelagoClient::StartClient() {
if (apClient != NULL) { if (apClient != nullptr) {
apClient.reset(); apClient.reset();
} }
@@ -372,6 +372,10 @@ void ArchipelagoClient::QueueItem(const ApItem item) {
} }
void ArchipelagoClient::SendGameWon() { void ArchipelagoClient::SendGameWon() {
if(apClient == nullptr) {
return;
}
if (!gameWon) { if (!gameWon) {
apClient->StatusUpdate(APClient::ClientStatus::GOAL); apClient->StatusUpdate(APClient::ClientStatus::GOAL);
gameWon = true; gameWon = true;
@@ -425,7 +429,7 @@ bool ArchipelagoClient::isRightSaveLoaded() const {
} }
const std::string ArchipelagoClient::GetSlotName() const { const std::string ArchipelagoClient::GetSlotName() const {
if (apClient == NULL) { if (apClient == nullptr) {
return ""; return "";
} }
@@ -482,7 +486,7 @@ void ArchipelagoClient::OnItemGiven(uint32_t rc, GetItemEntry gi, uint8_t isGiSk
} }
void ArchipelagoClient::SendDeathLink() { void ArchipelagoClient::SendDeathLink() {
if (apClient && CVarGetInteger(CVAR_REMOTE_ARCHIPELAGO("DeathLink"), 0) && !isDeathLinkedDeath) { if (apClient != nullptr && CVarGetInteger(CVAR_REMOTE_ARCHIPELAGO("DeathLink"), 0) && !isDeathLinkedDeath) {
nlohmann::json data{ { "time", apClient->get_server_time() }, nlohmann::json data{ { "time", apClient->get_server_time() },
{ "cause", "Shipwrecked by King Harkinian." }, { "cause", "Shipwrecked by King Harkinian." },
{ "source", apClient->get_slot() } }; { "source", apClient->get_slot() } };