Permalink
Browse files

determine initial dialog state only once

When recalculating things in DialogChoose, state may already have changed,
possibly making the dialog invalid.

Fixes the bandit plot in BG2 (JAHEIRA.BCS, JAHEIRAJ.DLG states 201-204),
this time without affecting other scripts negatively.
  • Loading branch information...
1 parent bb674c2 commit 91a23713fa1e4e019fa5692a9b9de4575bfa11ec @fizzet fizzet committed Jun 14, 2013
Showing with 5 additions and 3 deletions.
  1. +4 −3 gemrb/core/DialogHandler.cpp
  2. +1 −0 gemrb/core/DialogHandler.h
@@ -47,6 +47,7 @@ DialogHandler::DialogHandler(void)
targetID = 0;
originalTargetID = 0;
speakerID = 0;
+ initialState = -1;
if (core->HasFeature(GF_JOURNAL_HAS_SECTIONS) ) {
memcpy(sectionMap, bg2Sections, sizeof(sectionMap) );
} else {
@@ -114,8 +115,8 @@ bool DialogHandler::InitDialog(Scriptable* spk, Scriptable* tgt, const char* dlg
return true;
}
- int si = dlg->FindFirstState( tgt );
- if (si < 0) {
+ initialState = dlg->FindFirstState( tgt );
+ if (initialState < 0) {
return false;
}
@@ -218,7 +219,7 @@ void DialogHandler::DialogChoose(unsigned int choose)
if (choose == (unsigned int) -1) {
//increasing talkcount after top level condition was determined
- si = dlg->FindFirstState( tgt );
+ si = initialState;
if (si<0) {
EndDialog();
return;
@@ -37,6 +37,7 @@ class GEM_EXPORT DialogHandler {
private:
DialogState* ds;
Dialog* dlg;
+ int initialState;
public:
ieDword speakerID;
ieDword targetID;

0 comments on commit 91a2371

Please sign in to comment.