f1acd22455
Fixing following problems: Issue number one: Enable mod with a23 compatibility in a23b. Save configuration. Start a24. Better result: Mod will be enabled and invisible in mod selection screen producing various errors. Worse result: Game will crash and refuse to start. Issue number two: Mods can silently set loaded mods without restarting the engine, so mods can unlist themselves from compatibility detection. Solution: Enable necessary mods instead if running with gui and open mod page. Open information window on top of mod page to infom why mod page is showing up. On mod page show mods which failed in compatibility check and color the resposnible ones. Disable start button without enabled mods. Show non existed mods if they failed in compatibility check. Else just log to mainlog and close. Another fixes: Display in enabled mods really enabled mods as current logic confuses players about which mods they have enabled and is not helpful (ref #4881) Note: this will not solve issue with mods claiming being compatible with engine version while in fact being incompatible. Comments by: @vladislavbelov, @Stan, @Imarok Tested by: @wraitii Differential revision: D3592 Fixes: #6044 #4881 This was SVN commit r25410.
55 lines
1.8 KiB
C++
55 lines
1.8 KiB
C++
/* Copyright (C) 2021 Wildfire Games.
|
|
* This file is part of 0 A.D.
|
|
*
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "precompiled.h"
|
|
|
|
#include "JSInterface_Mod.h"
|
|
|
|
#include "ps/Mod.h"
|
|
#include "scriptinterface/FunctionWrapper.h"
|
|
#include "scriptinterface/ScriptInterface.h"
|
|
|
|
extern void RestartEngine();
|
|
|
|
namespace
|
|
{
|
|
bool SetModsAndRestartEngine(ScriptInterface::CmptPrivate* pCmptPrivate, const std::vector<CStr>& mods)
|
|
{
|
|
Mod::ClearIncompatibleMods();
|
|
if (!Mod::CheckAndEnableMods(*(pCmptPrivate->pScriptInterface), mods))
|
|
return false;
|
|
|
|
RestartEngine();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
bool HasFailedMods(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
|
|
{
|
|
return Mod::GetFailedMods().size() > 0;
|
|
}
|
|
|
|
void JSI_Mod::RegisterScriptFunctions(const ScriptRequest& rq)
|
|
{
|
|
ScriptFunction::Register<&Mod::GetEngineInfo>(rq, "GetEngineInfo");
|
|
ScriptFunction::Register<&Mod::GetAvailableMods>(rq, "GetAvailableMods");
|
|
ScriptFunction::Register<&Mod::GetEnabledMods>(rq, "GetEnabledMods");
|
|
ScriptFunction::Register<HasFailedMods> (rq, "HasFailedMods");
|
|
ScriptFunction::Register<&Mod::GetFailedMods>(rq, "GetFailedMods");
|
|
ScriptFunction::Register<&SetModsAndRestartEngine>(rq, "SetModsAndRestartEngine");
|
|
}
|