1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-11 11:31:52 +02:00

Added information on mod loading failure to inform player on broken mods

This commit is contained in:
Ivan Savenko 2025-01-01 20:59:16 +00:00
parent 657b97202b
commit 485361939a
4 changed files with 42 additions and 1 deletions

View File

@ -222,6 +222,7 @@
"vcmi.client.errors.invalidMap" : "{Invalid map or campaign}\n\nFailed to start game! Selected map or campaign might be invalid or corrupted. Reason:\n%s",
"vcmi.client.errors.missingCampaigns" : "{Missing data files}\n\nCampaigns data files were not found! You may be using incomplete or corrupted Heroes 3 data files. Please reinstall game data.",
"vcmi.client.errors.modLoadingFailure" : "{Mod loading failure}\n\nCritical issues found when loading mods! Game may not work correctly or crash! Please update or disable following mods:\n\n",
"vcmi.server.errors.disconnected" : "{Network Error}\n\nConnection to game server has been lost!",
"vcmi.server.errors.playerLeft" : "{Player Left}\n\n%s player have disconnected from the game!", //%s -> player color
"vcmi.server.errors.existingProcess" : "Another VCMI server process is running. Please terminate it before starting a new game.",

View File

@ -38,7 +38,11 @@
#include "../lib/ExceptionsCommon.h"
#include "../lib/filesystem/Filesystem.h"
#include "../lib/logging/CBasicLogConfigurator.h"
#include "../lib/modding/IdentifierStorage.h"
#include "../lib/modding/CModHandler.h"
#include "../lib/modding/ModDescription.h"
#include "../lib/texts/CGeneralTextHandler.h"
#include "../lib/texts/MetaString.h"
#include "../lib/VCMI_Lib.h"
#include "../lib/VCMIDirs.h"
@ -71,7 +75,7 @@ static void mainLoop();
static CBasicLogConfigurator *logConfig;
void init()
static void init()
{
CStopWatch tmh;
try
@ -92,6 +96,23 @@ void init()
//commandController.processCommand("convert txt", false);
}
static void checkForModLoadingFailure()
{
const auto & brokenMods = VLC->identifiersHandler->getModsWithFailedRequests();
if (!brokenMods.empty())
{
MetaString messageText;
messageText.appendTextID("vcmi.client.errors.modLoadingFailure");
for (const auto & modID : brokenMods)
{
messageText.appendRawString(VLC->modh->getModInfo(modID).getName());
messageText.appendEOL();
}
CInfoWindow::showInfoDialog(messageText.toString(), {});
}
}
static void prog_version()
{
printf("%s\n", GameConstants::VCMI_VERSION.c_str());
@ -386,6 +407,7 @@ int main(int argc, char * argv[])
if(!settings["session"]["headless"].Bool())
{
checkForModLoadingFailure();
mainLoop();
}
else

View File

@ -442,6 +442,7 @@ bool CIdentifierStorage::resolveIdentifier(const ObjectCallback & request) const
}
// error found. Try to generate some debug info
failedRequests.push_back(request);
showIdentifierResolutionErrorDetails(request);
return false;
}
@ -494,4 +495,15 @@ void CIdentifierStorage::debugDumpIdentifiers()
}
}
std::vector<std::string> CIdentifierStorage::getModsWithFailedRequests() const
{
std::vector<std::string> result;
for (const auto & request : failedRequests)
if (!vstd::contains(result, request.localScope))
result.push_back(request.localScope);
return result;
}
VCMI_LIB_NAMESPACE_END

View File

@ -58,6 +58,9 @@ class DLL_LINKAGE CIdentifierStorage
std::multimap<std::string, ObjectData> registeredObjects;
mutable std::vector<ObjectCallback> scheduledRequests;
/// All non-optional requests that have failed to resolve, for debug & error reporting
mutable std::vector<ObjectCallback> failedRequests;
ELoadingState state = ELoadingState::LOADING;
/// Helper method that dumps all registered identifier into log file
@ -101,6 +104,9 @@ public:
/// called at the very end of loading to check for any missing ID's
void finalize();
/// Returns list of all mods, from which at least one identifier has failed to resolve
std::vector<std::string> getModsWithFailedRequests() const;
};
VCMI_LIB_NAMESPACE_END