Browse files

make trigger evaluation more robust against scripting errors

When an unfinished OR block was encountered in a condition the
trigger would always evaluate to true. Instead, use the subresult
we got until that point.

This fixes a bug with Viconia in AR1000 in BG2. The vicg1 script
used by the fanatics has a buggy OR block that claims to have 4
conditions but actually only contains 2. Since it would always
evaluate to true, the fanatics escaped the area immediately which
meant that Viconia was never burnt, and if you cut her down from
the stake you'd enter an endlessly repeating dialog
  • Loading branch information...
fizzet committed Apr 27, 2013
1 parent 9ec555c commit 09155cc2da10a18aeb69e52a996f7485337806e1
Showing with 4 additions and 0 deletions.
  1. +4 −0 gemrb/core/GameScript/GameScript.cpp
@@ -2177,6 +2177,9 @@ bool Condition::Evaluate(Scriptable* Sender)
//we started an Or() block
if (ORcount) {
Log(WARNING, "GameScript", "Unfinished OR block encountered!");
+ if (!subresult) {
+ return 0;
+ }
ORcount = result;
subresult = false;
@@ -2195,6 +2198,7 @@ bool Condition::Evaluate(Scriptable* Sender)
if (ORcount) {
Log(WARNING, "GameScript", "Unfinished OR block encountered!");
+ return subresult;
return 1;

0 comments on commit 09155cc

Please sign in to comment.