Skip to content
Browse files

qtscript: Fix crash bug in findResearch(), if number of requirements …

…is higher

than max number of players. Found by forum member Duha.
  • Loading branch information...
1 parent 2b82a1e commit 08567bebfbc061aaf62f3f151a3526e49fc88b3d @perim perim committed Feb 16, 2013
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/qtscriptfuncs.cpp
View
5 src/qtscriptfuncs.cpp
@@ -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;
@@ -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;
@@ -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;
}

0 comments on commit 08567be

Please sign in to comment.
Something went wrong with that request. Please try again.