Ticket #3359: t3359_move_engine_version_v1.patch
File t3359_move_engine_version_v1.patch, 9.3 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/gui/common/functions_utility_loadsave.js
7 7 { 8 8 var dateTimeString = Engine.FormatMillisecondsIntoDateString(metadata.time*1000, translate("yyyy-MM-dd HH:mm:ss")); 9 9 var dateString = sprintf(translate("\\[%(date)s]"), { date: dateTimeString }); 10 10 if (engineInfo) 11 11 { 12 if (!hasSame Version(metadata, engineInfo))12 if (!hasSameSavegameVersion(metadata, engineInfo) || !hasSameEngineVersion(metadata, engineInfo)) 13 13 dateString = "[color=\"red\"]" + dateString + "[/color]"; 14 14 else if (!hasSameMods(metadata, engineInfo)) 15 15 dateString = "[color=\"orange\"]" + dateString + "[/color]"; 16 16 } 17 17 if (metadata.description) … … 21 21 } 22 22 23 23 /** 24 24 * Check the version compatibility between the saved game to be loaded and the engine 25 25 */ 26 function hasSame Version(metadata, engineInfo)26 function hasSameSavegameVersion(metadata, engineInfo) 27 27 { 28 return (metadata.version_major == engineInfo.version_major); 28 return metadata.version_major == engineInfo.version_major; 29 } 30 31 /** 32 * Check the version compatibility between the saved game to be loaded and the engine 33 */ 34 function hasSameEngineVersion(metadata, engineInfo) 35 { 36 return metadata.engine_version && metadata.engine_version == engineInfo.engine_version; 29 37 } 30 38 31 39 /** 32 40 * Check the mod compatibility between the saved game to be loaded and the engine 33 41 */ 34 42 function hasSameMods(metadata, engineInfo) 35 43 { 36 if (!metadata.mods) // only here for backwards compatibility with previous saved games 37 var gameMods = []; 38 else 39 var gameMods = metadata.mods; 40 41 if (gameMods.length != engineInfo.mods.length) 44 if (!metadata.mods || metadata.mods.length != engineInfo.mods.length) 42 45 return false; 43 for (var i = 0; i < gameMods.length; ++i) 44 if (gameMods[i] != engineInfo.mods[i]) 45 return false; 46 return true; 46 47 return metadata.mods.every((mod, index) => mod == engineInfo.mods[index]); 47 48 } -
binaries/data/mods/public/gui/savedgames/load.js
38 38 var gameLabel = gameSelection.list[gameSelection.selected]; 39 39 var metadata = gameMetadatas[gameSelection.selected]; 40 40 41 41 // check game compatibility before really loading it 42 42 var engineInfo = Engine.GetEngineInfo(); 43 if (!hasSameVersion(metadata, engineInfo) || !hasSameMods(metadata, engineInfo)) 43 var sameMods = hasSameMods(metadata, engineInfo); 44 var sameEngineVersion = hasSameEngineVersion(metadata, engineInfo); 45 var sameSavegameVersion = hasSameSavegameVersion(metadata, engineInfo); 46 if (!sameEngineVersion || !sameSavegameVersion || !sameMods) 44 47 { 45 48 // version not compatible ... ask for confirmation 46 49 var btCaptions = [translate("Yes"), translate("No")]; 47 50 var btCode = [function(){ reallyLoadGame(gameId); }, init]; 48 51 var message = translate("This saved game may not be compatible:"); 49 if (!hasSameVersion(metadata, engineInfo)) 50 message += "\n" + sprintf(translate("It needs 0 A.D. version %(requiredVersion)s, while you are running version %(currentVersion)s."), { 52 53 if (!sameEngineVersion) 54 { 55 if (metadata.engine_version) 56 message += "\n" + sprintf(translate("It needs 0 A.D. version %(requiredVersion)s, while you are running version %(currentVersion)s."), { 57 requiredVersion: metadata.engine_version, 58 currentVersion: engineInfo.engine_version 59 }); 60 else 61 message += "\n" + translate("It needs an older version of 0 A.D."); 62 } 63 64 if (!sameSavegameVersion) 65 message += "\n" + sprintf(translate("It needs 0 A.D. savegame version %(requiredVersion)s, while you are running version %(currentVersion)s."), { 51 66 requiredVersion: metadata.version_major, 52 67 currentVersion: engineInfo.version_major 53 68 }); 54 69 55 if (! hasSameMods(metadata, engineInfo))70 if (!sameMods) 56 71 { 57 72 if (!metadata.mods) // only for backwards compatibility with previous saved games 58 73 metadata.mods = []; 59 74 if (metadata.mods.length == 0) 60 75 message += "\n" + sprintf(translate("It does not need any mod while you are running with \"%(currentMod)s\"."), { -
source/lobby/XmppClient.cpp
22 22 #include "glooxwrapper/glooxwrapper.h" 23 23 #include "i18n/L10n.h" 24 24 #include "lib/utf8.h" 25 25 #include "ps/CLogger.h" 26 26 #include "ps/ConfigDB.h" 27 #include "ps/Pyrogenesis.h" 27 28 #include "scriptinterface/ScriptInterface.h" 28 29 29 30 //debug 30 31 #if 1 31 32 #define DbgXMPP(x) … … 95 96 const int mechs = gloox::SaslMechAll ^ gloox::SaslMechPlain; 96 97 m_client->setSASLMechanisms(mechs); 97 98 98 99 m_client->registerConnectionListener(this); 99 100 m_client->setPresence(gloox::Presence::Available, -1); 100 m_client->disco()->setVersion("Pyrogenesis", "0.0.19");101 m_client->disco()->setVersion("Pyrogenesis", engine_version); 101 102 m_client->disco()->setIdentity("client", "bot"); 102 103 m_client->setCompression(false); 103 104 104 105 m_client->registerStanzaExtension(new GameListQuery()); 105 106 m_client->registerIqHandler(this, EXTGAMELISTQUERY); -
source/ps/Pyrogenesis.cpp
22 22 #include "Pyrogenesis.h" 23 23 24 24 #include "lib/sysdep/sysdep.h" 25 25 #include "lib/svn_revision.h" 26 26 27 const char engine_version[] = "0.0.19"; 28 27 29 // convert contents of file <in_filename> from char to wchar_t and 28 30 // append to <out> file. 29 31 static void AppendAsciiFile(FILE* out, const OsPath& pathname) 30 32 { 31 33 FILE* in = sys_OpenFile(pathname, "rb"); … … 52 54 53 55 // for user convenience, bundle all logs into this file: 54 56 void psBundleLogs(FILE* f) 55 57 { 56 58 fwprintf(f, L"SVN Revision: %ls\n\n", svn_revision); 59 fwprintf(f, L"Engine Version: %hs\n\n", engine_version); 57 60 58 61 fwprintf(f, L"System info:\n\n"); 59 62 OsPath path1 = psLogDir()/"system_info.txt"; 60 63 AppendAsciiFile(f, path1); 61 64 fwprintf(f, L"\n\n====================================\n\n"); -
source/ps/Pyrogenesis.h
24 24 #ifndef INCLUDED_PYROGENESIS 25 25 #define INCLUDED_PYROGENESIS 26 26 27 27 #include "lib/os_path.h" 28 28 29 extern const char engine_version[]; 30 29 31 extern void psBundleLogs(FILE* f); // set during InitVfs 30 32 extern void psSetLogDir(const OsPath& logDir); // set during InitVfs 31 33 extern const OsPath& psLogDir(); // used by AppHooks and engine code when reporting errors 32 34 33 35 #endif -
source/ps/SavedGame.cpp
1 /* Copyright (C) 201 4Wildfire Games.1 /* Copyright (C) 2015 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 5 * it under the terms of the GNU General Public License as published by 6 6 * the Free Software Foundation, either version 2 of the License, or … … 27 27 #include "lib/utf8.h" 28 28 #include "ps/CLogger.h" 29 29 #include "ps/Filesystem.h" 30 30 #include "ps/Game.h" 31 31 #include "ps/Mod.h" 32 #include "ps/Pyrogenesis.h" 32 33 #include "scriptinterface/ScriptInterface.h" 33 34 #include "simulation2/Simulation2.h" 34 35 35 36 static const int SAVED_GAME_VERSION_MAJOR = 1; // increment on incompatible changes to the format 36 37 static const int SAVED_GAME_VERSION_MINOR = 0; // increment on compatible changes to the format … … 84 85 JS::RootedValue metadata(cx); 85 86 JS::RootedValue initAttributes(cx, simulation.GetInitAttributes()); 86 87 simulation.GetScriptInterface().Eval("({})", &metadata); 87 88 simulation.GetScriptInterface().SetProperty(metadata, "version_major", SAVED_GAME_VERSION_MAJOR); 88 89 simulation.GetScriptInterface().SetProperty(metadata, "version_minor", SAVED_GAME_VERSION_MINOR); 90 simulation.GetScriptInterface().SetProperty(metadata, "engine_version", CStr(engine_version)); 89 91 simulation.GetScriptInterface().SetProperty(metadata, "mods", g_modsLoaded); 90 92 simulation.GetScriptInterface().SetProperty(metadata, "time", (double)now); 91 93 simulation.GetScriptInterface().SetProperty(metadata, "player", playerID); 92 94 simulation.GetScriptInterface().SetProperty(metadata, "initAttributes", initAttributes); 93 95 … … 298 300 299 301 JS::RootedValue metainfo(cx); 300 302 scriptInterface.Eval("({})", &metainfo); 301 303 scriptInterface.SetProperty(metainfo, "version_major", SAVED_GAME_VERSION_MAJOR); 302 304 scriptInterface.SetProperty(metainfo, "version_minor", SAVED_GAME_VERSION_MINOR); 303 scriptInterface.SetProperty(metainfo, "mods" , g_modsLoaded); 305 scriptInterface.SetProperty(metainfo, "engine_version", CStr(engine_version)); 306 scriptInterface.SetProperty(metainfo, "mods", g_modsLoaded); 304 307 return metainfo; 305 308 }