Move engine version to common file. Patch by elexis. Fixes #3359.
This was SVN commit r16906.
This commit is contained in:
parent
701f1dbb51
commit
94302a4149
@ -9,7 +9,7 @@ function generateLabel(metadata, engineInfo)
|
|||||||
var dateString = sprintf(translate("\\[%(date)s]"), { date: dateTimeString });
|
var dateString = sprintf(translate("\\[%(date)s]"), { date: dateTimeString });
|
||||||
if (engineInfo)
|
if (engineInfo)
|
||||||
{
|
{
|
||||||
if (!hasSameVersion(metadata, engineInfo))
|
if (!hasSameSavegameVersion(metadata, engineInfo) || !hasSameEngineVersion(metadata, engineInfo))
|
||||||
dateString = "[color=\"red\"]" + dateString + "[/color]";
|
dateString = "[color=\"red\"]" + dateString + "[/color]";
|
||||||
else if (!hasSameMods(metadata, engineInfo))
|
else if (!hasSameMods(metadata, engineInfo))
|
||||||
dateString = "[color=\"orange\"]" + dateString + "[/color]";
|
dateString = "[color=\"orange\"]" + dateString + "[/color]";
|
||||||
@ -23,9 +23,17 @@ function generateLabel(metadata, engineInfo)
|
|||||||
/**
|
/**
|
||||||
* Check the version compatibility between the saved game to be loaded and the engine
|
* Check the version compatibility between the saved game to be loaded and the engine
|
||||||
*/
|
*/
|
||||||
function hasSameVersion(metadata, engineInfo)
|
function hasSameSavegameVersion(metadata, engineInfo)
|
||||||
{
|
{
|
||||||
return (metadata.version_major == engineInfo.version_major);
|
return metadata.version_major == engineInfo.version_major;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check the version compatibility between the saved game to be loaded and the engine
|
||||||
|
*/
|
||||||
|
function hasSameEngineVersion(metadata, engineInfo)
|
||||||
|
{
|
||||||
|
return metadata.engine_version && metadata.engine_version == engineInfo.engine_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,15 +41,8 @@ function hasSameVersion(metadata, engineInfo)
|
|||||||
*/
|
*/
|
||||||
function hasSameMods(metadata, engineInfo)
|
function hasSameMods(metadata, engineInfo)
|
||||||
{
|
{
|
||||||
if (!metadata.mods) // only here for backwards compatibility with previous saved games
|
if (!metadata.mods || metadata.mods.length != engineInfo.mods.length)
|
||||||
var gameMods = [];
|
|
||||||
else
|
|
||||||
var gameMods = metadata.mods;
|
|
||||||
|
|
||||||
if (gameMods.length != engineInfo.mods.length)
|
|
||||||
return false;
|
return false;
|
||||||
for (var i = 0; i < gameMods.length; ++i)
|
|
||||||
if (gameMods[i] != engineInfo.mods[i])
|
return metadata.mods.every((mod, index) => mod == engineInfo.mods[index]);
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
@ -40,19 +40,34 @@ function loadGame()
|
|||||||
|
|
||||||
// check game compatibility before really loading it
|
// check game compatibility before really loading it
|
||||||
var engineInfo = Engine.GetEngineInfo();
|
var engineInfo = Engine.GetEngineInfo();
|
||||||
if (!hasSameVersion(metadata, engineInfo) || !hasSameMods(metadata, engineInfo))
|
var sameMods = hasSameMods(metadata, engineInfo);
|
||||||
|
var sameEngineVersion = hasSameEngineVersion(metadata, engineInfo);
|
||||||
|
var sameSavegameVersion = hasSameSavegameVersion(metadata, engineInfo);
|
||||||
|
if (!sameEngineVersion || !sameSavegameVersion || !sameMods)
|
||||||
{
|
{
|
||||||
// version not compatible ... ask for confirmation
|
// version not compatible ... ask for confirmation
|
||||||
var btCaptions = [translate("Yes"), translate("No")];
|
var btCaptions = [translate("Yes"), translate("No")];
|
||||||
var btCode = [function(){ reallyLoadGame(gameId); }, init];
|
var btCode = [function(){ reallyLoadGame(gameId); }, init];
|
||||||
var message = translate("This saved game may not be compatible:");
|
var message = translate("This saved game may not be compatible:");
|
||||||
if (!hasSameVersion(metadata, engineInfo))
|
|
||||||
message += "\n" + sprintf(translate("It needs 0 A.D. version %(requiredVersion)s, while you are running version %(currentVersion)s."), {
|
if (!sameEngineVersion)
|
||||||
|
{
|
||||||
|
if (metadata.engine_version)
|
||||||
|
message += "\n" + sprintf(translate("It needs 0 A.D. version %(requiredVersion)s, while you are running version %(currentVersion)s."), {
|
||||||
|
requiredVersion: metadata.engine_version,
|
||||||
|
currentVersion: engineInfo.engine_version
|
||||||
|
});
|
||||||
|
else
|
||||||
|
message += "\n" + translate("It needs an older version of 0 A.D.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sameSavegameVersion)
|
||||||
|
message += "\n" + sprintf(translate("It needs 0 A.D. savegame version %(requiredVersion)s, while you have savegame version %(currentVersion)s."), {
|
||||||
requiredVersion: metadata.version_major,
|
requiredVersion: metadata.version_major,
|
||||||
currentVersion: engineInfo.version_major
|
currentVersion: engineInfo.version_major
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!hasSameMods(metadata, engineInfo))
|
if (!sameMods)
|
||||||
{
|
{
|
||||||
if (!metadata.mods) // only for backwards compatibility with previous saved games
|
if (!metadata.mods) // only for backwards compatibility with previous saved games
|
||||||
metadata.mods = [];
|
metadata.mods = [];
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "lib/utf8.h"
|
#include "lib/utf8.h"
|
||||||
#include "ps/CLogger.h"
|
#include "ps/CLogger.h"
|
||||||
#include "ps/ConfigDB.h"
|
#include "ps/ConfigDB.h"
|
||||||
|
#include "ps/Pyrogenesis.h"
|
||||||
#include "scriptinterface/ScriptInterface.h"
|
#include "scriptinterface/ScriptInterface.h"
|
||||||
|
|
||||||
//debug
|
//debug
|
||||||
@ -97,7 +98,7 @@ XmppClient::XmppClient(const std::string& sUsername, const std::string& sPasswor
|
|||||||
|
|
||||||
m_client->registerConnectionListener(this);
|
m_client->registerConnectionListener(this);
|
||||||
m_client->setPresence(gloox::Presence::Available, -1);
|
m_client->setPresence(gloox::Presence::Available, -1);
|
||||||
m_client->disco()->setVersion("Pyrogenesis", "0.0.19");
|
m_client->disco()->setVersion("Pyrogenesis", engine_version);
|
||||||
m_client->disco()->setIdentity("client", "bot");
|
m_client->disco()->setIdentity("client", "bot");
|
||||||
m_client->setCompression(false);
|
m_client->setCompression(false);
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include "lib/sysdep/sysdep.h"
|
#include "lib/sysdep/sysdep.h"
|
||||||
#include "lib/svn_revision.h"
|
#include "lib/svn_revision.h"
|
||||||
|
|
||||||
|
const char engine_version[] = "0.0.19";
|
||||||
|
|
||||||
// convert contents of file <in_filename> from char to wchar_t and
|
// convert contents of file <in_filename> from char to wchar_t and
|
||||||
// append to <out> file.
|
// append to <out> file.
|
||||||
static void AppendAsciiFile(FILE* out, const OsPath& pathname)
|
static void AppendAsciiFile(FILE* out, const OsPath& pathname)
|
||||||
@ -54,6 +56,7 @@ static void AppendAsciiFile(FILE* out, const OsPath& pathname)
|
|||||||
void psBundleLogs(FILE* f)
|
void psBundleLogs(FILE* f)
|
||||||
{
|
{
|
||||||
fwprintf(f, L"SVN Revision: %ls\n\n", svn_revision);
|
fwprintf(f, L"SVN Revision: %ls\n\n", svn_revision);
|
||||||
|
fwprintf(f, L"Engine Version: %hs\n\n", engine_version);
|
||||||
|
|
||||||
fwprintf(f, L"System info:\n\n");
|
fwprintf(f, L"System info:\n\n");
|
||||||
OsPath path1 = psLogDir()/"system_info.txt";
|
OsPath path1 = psLogDir()/"system_info.txt";
|
||||||
|
@ -26,6 +26,8 @@ Standard declarations which are included in all projects.
|
|||||||
|
|
||||||
#include "lib/os_path.h"
|
#include "lib/os_path.h"
|
||||||
|
|
||||||
|
extern const char engine_version[];
|
||||||
|
|
||||||
extern void psBundleLogs(FILE* f); // set during InitVfs
|
extern void psBundleLogs(FILE* f); // set during InitVfs
|
||||||
extern void psSetLogDir(const OsPath& logDir); // set during InitVfs
|
extern void psSetLogDir(const OsPath& logDir); // set during InitVfs
|
||||||
extern const OsPath& psLogDir(); // used by AppHooks and engine code when reporting errors
|
extern const OsPath& psLogDir(); // used by AppHooks and engine code when reporting errors
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2014 Wildfire Games.
|
/* Copyright (C) 2015 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -29,6 +29,7 @@
|
|||||||
#include "ps/Filesystem.h"
|
#include "ps/Filesystem.h"
|
||||||
#include "ps/Game.h"
|
#include "ps/Game.h"
|
||||||
#include "ps/Mod.h"
|
#include "ps/Mod.h"
|
||||||
|
#include "ps/Pyrogenesis.h"
|
||||||
#include "scriptinterface/ScriptInterface.h"
|
#include "scriptinterface/ScriptInterface.h"
|
||||||
#include "simulation2/Simulation2.h"
|
#include "simulation2/Simulation2.h"
|
||||||
|
|
||||||
@ -86,6 +87,7 @@ Status SavedGames::Save(const std::wstring& name, const std::wstring& descriptio
|
|||||||
simulation.GetScriptInterface().Eval("({})", &metadata);
|
simulation.GetScriptInterface().Eval("({})", &metadata);
|
||||||
simulation.GetScriptInterface().SetProperty(metadata, "version_major", SAVED_GAME_VERSION_MAJOR);
|
simulation.GetScriptInterface().SetProperty(metadata, "version_major", SAVED_GAME_VERSION_MAJOR);
|
||||||
simulation.GetScriptInterface().SetProperty(metadata, "version_minor", SAVED_GAME_VERSION_MINOR);
|
simulation.GetScriptInterface().SetProperty(metadata, "version_minor", SAVED_GAME_VERSION_MINOR);
|
||||||
|
simulation.GetScriptInterface().SetProperty(metadata, "engine_version", std::string(engine_version));
|
||||||
simulation.GetScriptInterface().SetProperty(metadata, "mods", g_modsLoaded);
|
simulation.GetScriptInterface().SetProperty(metadata, "mods", g_modsLoaded);
|
||||||
simulation.GetScriptInterface().SetProperty(metadata, "time", (double)now);
|
simulation.GetScriptInterface().SetProperty(metadata, "time", (double)now);
|
||||||
simulation.GetScriptInterface().SetProperty(metadata, "player", playerID);
|
simulation.GetScriptInterface().SetProperty(metadata, "player", playerID);
|
||||||
@ -300,7 +302,8 @@ JS::Value SavedGames::GetEngineInfo(ScriptInterface& scriptInterface)
|
|||||||
scriptInterface.Eval("({})", &metainfo);
|
scriptInterface.Eval("({})", &metainfo);
|
||||||
scriptInterface.SetProperty(metainfo, "version_major", SAVED_GAME_VERSION_MAJOR);
|
scriptInterface.SetProperty(metainfo, "version_major", SAVED_GAME_VERSION_MAJOR);
|
||||||
scriptInterface.SetProperty(metainfo, "version_minor", SAVED_GAME_VERSION_MINOR);
|
scriptInterface.SetProperty(metainfo, "version_minor", SAVED_GAME_VERSION_MINOR);
|
||||||
scriptInterface.SetProperty(metainfo, "mods" , g_modsLoaded);
|
scriptInterface.SetProperty(metainfo, "engine_version", std::string(engine_version));
|
||||||
|
scriptInterface.SetProperty(metainfo, "mods", g_modsLoaded);
|
||||||
return metainfo;
|
return metainfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user