Skip to content

Commit

Permalink
Quick fix for auto-repair research in campaign.
Browse files Browse the repository at this point in the history
For some reason auto-repair like research does not work
after mission transition. For now, just research it again for each
mission start.
  • Loading branch information
KJeff01 committed Dec 29, 2017
1 parent f00ca92 commit a2445a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions data/base/script/campaign/libcampaign.js
Expand Up @@ -404,6 +404,11 @@ function camCompleteRequiredResearch(items, player)

if (reqRes.length === 0)
{
//HACK: autorepair like upgrades don't work after mission transition.
if (items[i] === "R-Sys-NEXUSrepair")
{
completeResearch("R-Sys-NEXUSrepair", player, true);
}
continue;
}

Expand Down
10 changes: 8 additions & 2 deletions src/qtscriptfuncs.cpp
Expand Up @@ -2901,12 +2901,14 @@ static QScriptValue js_gameOverMessage(QScriptContext *context, QScriptEngine *e
return QScriptValue();
}

//-- \subsection{completeResearch(research[, player])}
//-- \subsection{completeResearch(research[, player [, forceResearch]])}
//-- Finish a research for the given player.
//-- forceResearch will allow a research topic to be researched again. 3.2.4+
static QScriptValue js_completeResearch(QScriptContext *context, QScriptEngine *engine)
{
QString researchName = context->argument(0).toString();
int player;
bool forceIt = false;
if (context->argumentCount() > 1)
{
player = context->argument(1).toInt32();
Expand All @@ -2915,11 +2917,15 @@ static QScriptValue js_completeResearch(QScriptContext *context, QScriptEngine *
{
player = engine->globalObject().property("me").toInt32();
}
if (context->argumentCount() > 2)
{
forceIt = context->argument(2).toBool();
}
RESEARCH *psResearch = getResearch(researchName.toUtf8().constData());
SCRIPT_ASSERT(context, psResearch, "No such research %s for player %d", researchName.toUtf8().constData(), player);
SCRIPT_ASSERT(context, psResearch->index < asResearch.size(), "Research index out of bounds");
PLAYER_RESEARCH *plrRes = &asPlayerResList[player][psResearch->index];
if (IsResearchCompleted(plrRes))
if (!forceIt && IsResearchCompleted(plrRes))
{
return QScriptValue();
}
Expand Down

0 comments on commit a2445a1

Please sign in to comment.