From dc021055e4f2071282da1afe789281a1d874c45c Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sun, 21 Dec 2025 11:35:21 +0200 Subject: [PATCH] Fixes and workarounds for crashes from Google Play - Added more detailed error message for crash due to potential load of mod with missing dependencies? - Fix crash on shutting down server when playing through online lobby - Log instead of crash when player (somehow) presses update button without mod selected --- launcher/modManager/cmodlistview_moc.cpp | 15 ++++++++++++++- lib/json/JsonValidator.cpp | 12 ++++++++++-- server/CVCMIServer.h | 5 +++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/launcher/modManager/cmodlistview_moc.cpp b/launcher/modManager/cmodlistview_moc.cpp index 1f2f32c18..424eaa295 100644 --- a/launcher/modManager/cmodlistview_moc.cpp +++ b/launcher/modManager/cmodlistview_moc.cpp @@ -727,7 +727,20 @@ QStringList CModListView::getModsToInstall(QString mod) void CModListView::on_updateButton_clicked() { - QString modName = ui->allModsView->currentIndex().data(ModRoles::ModNameRole).toString(); + QModelIndex selectedMod = ui->allModsView->currentIndex(); + if (!selectedMod.isValid()) + { + logGlobal->error("Update failed! Invalid index selected but update button is not locked!"); + return; + } + + QString modName = selectedMod.data(ModRoles::ModNameRole).toString(); + if (modName.isEmpty()) + { + logGlobal->error("Update failed! Model index is valid but mod name is empty!"); + return; + } + doUpdateMod(modName); ui->updateButton->setEnabled(false); diff --git a/lib/json/JsonValidator.cpp b/lib/json/JsonValidator.cpp index 0d516c4cf..f090fad4f 100644 --- a/lib/json/JsonValidator.cpp +++ b/lib/json/JsonValidator.cpp @@ -480,9 +480,17 @@ static bool testFilePresence(const std::string & scope, const ResourcePath & res for(const auto & entry : allowedScopes) { - if (CResourceHandler::get(entry)->existsResource(resource)) - return true; + try + { + if (CResourceHandler::get(entry)->existsResource(resource)) + return true; + } + catch (const std::out_of_range & e) + { + throw std::out_of_range("Failed to find filesystem of mod '" + entry + "' when testing file '" + resource.getOriginalName() + "' for mod '" + scope + "'"); + } } + #endif return false; } diff --git a/server/CVCMIServer.h b/server/CVCMIServer.h index 311e10db2..35cccfe8a 100644 --- a/server/CVCMIServer.h +++ b/server/CVCMIServer.h @@ -36,8 +36,6 @@ class GlobalLobbyProcessor; class CVCMIServer : public LobbyInfo, public INetworkServerListener, public INetworkTimerListener, public IGameServer { - std::unique_ptr lobbyProcessor; - std::chrono::steady_clock::time_point gameplayStartTime; std::chrono::steady_clock::time_point lastTimerUpdateTime; @@ -45,6 +43,9 @@ class CVCMIServer : public LobbyInfo, public INetworkServerListener, public INet /// Network server instance that receives and processes incoming connections on active socket std::unique_ptr networkServer; + /// Handles connection with global lobby. Must be constructed and destroyed after network handler + std::unique_ptr lobbyProcessor; + EServerState state = EServerState::LOBBY; std::shared_ptr findConnection(const std::shared_ptr &);