Skip to content

Commit

Permalink
qtscript: Fix crash bug in findResearch(), if number of requirements …
Browse files Browse the repository at this point in the history
…is higher

than max number of players. Found by forum member Duha.
  • Loading branch information
perim committed Feb 16, 2013
1 parent 2b82a1e commit 08567be
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/qtscriptfuncs.cpp
Expand Up @@ -1180,7 +1180,7 @@ static QScriptValue js_activateStructure(QScriptContext *context, QScriptEngine
}

//-- \subsection{findResearch(research)}
//-- Return list of research items remaining to research for the given research item. (3.2+ only)
//-- Return list of research items remaining to be researched for the given research item. (3.2+ only)
static QScriptValue js_findResearch(QScriptContext *context, QScriptEngine *engine)
{
QList<RESEARCH *> list;
Expand All @@ -1193,6 +1193,7 @@ static QScriptValue js_findResearch(QScriptContext *context, QScriptEngine *engi
{
return engine->newArray(0); // return empty array
}
debug(LOG_SCRIPT, "Find reqs for %s for player %d", resName.toUtf8().constData(), player);
// Go down the requirements list for the desired tech
QList<RESEARCH *> reslist;
RESEARCH *cur = psTarget;
Expand Down Expand Up @@ -1222,7 +1223,7 @@ static QScriptValue js_findResearch(QScriptContext *context, QScriptEngine *engi
QScriptValue retval = engine->newArray(list.size());
for (int i = 0; i < list.size(); i++)
{
retval.setProperty(i, convResearch(list[i], engine, i));
retval.setProperty(i, convResearch(list[i], engine, player));
}
return retval;
}
Expand Down

0 comments on commit 08567be

Please sign in to comment.