Răsfoiți Sursa

Read error message from translate.json

nordsoft 3 ani în urmă
părinte
comite
8f6f9707a6
3 a modificat fișierele cu 6 adăugiri și 5 ștergeri
  1. 2 1
      config/translate.json
  2. 1 3
      lib/CModHandler.h
  3. 3 1
      server/CGameHandler.cpp

+ 2 - 1
config/translate.json

@@ -31,7 +31,8 @@
 	{
 		"errors" :
 		{
-			"existingProcess" : "Another vcmiserver process is running, please terminate it first"
+			"existingProcess" : "Another vcmiserver process is running, please terminate it first",
+			"modsIncompatibility" : "Mods are required to load game:"
 		}
 	},
 	"systemOptions" :

+ 1 - 3
lib/CModHandler.h

@@ -276,18 +276,16 @@ class DLL_LINKAGE CModHandler
 	void loadOneMod(std::string modName, std::string parent, const JsonNode & modSettings, bool enableMods);
 public:
 	
-	class DLL_LINKAGE Incompatibility: public std::logic_error
+	class DLL_LINKAGE Incompatibility: public std::exception
 	{
 	public:
 		using StringPair = std::pair<const std::string, const std::string>;
 		using ModList = std::list<StringPair>;
 		
 		Incompatibility(ModList && _missingMods):
-			std::logic_error("Mods are required to load game"),
 			missingMods(std::move(_missingMods))
 		{
 			std::ostringstream _ss;
-			_ss << std::logic_error::what() << std::endl;
 			for(auto & m : missingMods)
 				_ss << m.first << ' ' << m.second << std::endl;
 			message = _ss.str();

+ 3 - 1
server/CGameHandler.cpp

@@ -2987,7 +2987,9 @@ bool CGameHandler::load(const std::string & filename)
 	catch(const CModHandler::Incompatibility & e)
 	{
 		logGlobal->error("Failed to load game: %s", e.what());
-		lobby->announceMessage(e.what());
+		auto errorMsg = VLC->generaltexth->localizedTexts["server"]["errors"]["modsIncompatibility"].String() + '\n';
+		errorMsg += e.what();
+		lobby->announceMessage(errorMsg);
 		return false;
 	}
 	catch(const std::exception & e)