Skip to content
Browse files

qtscript: Also call the research trigger if research gained from some…

…thing

other than the research lab. Now without crashing.
  • Loading branch information...
1 parent 84a54e7 commit 1d5e81c45ec3a46d413a5e85575f2f82a2455865 @perim perim committed Dec 28, 2011
Showing with 9 additions and 6 deletions.
  1. +7 −4 src/qtscript.cpp
  2. +1 −1 src/qtscript.h
  3. +1 −1 src/research.cpp
View
11 src/qtscript.cpp
@@ -540,17 +540,20 @@ bool triggerStructureAttacked(STRUCTURE *psVictim, BASE_OBJECT *psAttacker)
return true;
}
-bool triggerResearched(STRUCTURE *psStruct)
+bool triggerResearched(STRUCTURE *psStruct, int player)
{
for (int i = 0; i < scripts.size() && psStruct; ++i)
{
QScriptEngine *engine = scripts.at(i);
- int player = engine->globalObject().property("me").toInt32();
- if (player == psStruct->player)
+ int me = engine->globalObject().property("me").toInt32();
+ if (me == player)
{
QScriptEngine *engine = scripts.at(i);
QScriptValueList args;
- args += convStructure(psStruct, engine);
+ if (psStruct)
+ {
+ args += convStructure(psStruct, engine);
+ }
callFunction(engine, "eventResearched", args);
}
}
View
2 src/qtscript.h
@@ -70,7 +70,7 @@ bool triggerEvent(SCRIPT_TRIGGER_TYPE trigger);
// For each trigger with function parameters, a function to trigger it here
bool triggerEventDroidBuilt(DROID *psDroid, STRUCTURE *psFactory);
bool triggerStructureAttacked(STRUCTURE *psVictim, BASE_OBJECT *psAttacker);
-bool triggerResearched(STRUCTURE *psStruct);
+bool triggerResearched(STRUCTURE *psStruct, int player);
// bool triggerEventReachedLocation(ORDER order, DROID *psDroid);
// ...
View
2 src/research.cpp
@@ -1176,7 +1176,7 @@ void researchResult(UDWORD researchIndex, UBYTE player, bool bDisplay, STRUCTURE
CBResFacilityOwner = -1;
psCBLastResearch = NULL;
- triggerResearched(psResearchFacility);
+ triggerResearched(psResearchFacility, player);
}
#ifdef DEBUG

0 comments on commit 1d5e81c

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