Wintermute Engine Forum
Wintermute Engine => Bug reports => Topic started by: eborr on August 14, 2009, 11:17:37 AM
-
Hello I think this is probably a bug, in the sense that it manages to crash the project manager editor.
I am calling the a seperate dialogue branch within a function from an attached script
this is the code for the function.
It works fine if I omit the dialogue branching controls, but of course that then creates a logical problem in that elements with the response box are removed.
The crash occurs exactly at the point where the branch is called. I have tried variations in terms of naming the dlg branch and calling the dlg branch from another dlg branch, and all variants produce the same crash error. I have use dlg branch successfully in the past.
If there is anything that I have done wrong please advise
function testb()
{
Game.StartDlgBranch();
var options;
options[0] = "this is testbline1";
options[1] ="this test line 2";
options[2] ="bye";
var selected;
while (selected !=2)
{
Game.AddResponseOnce(0,options[0]);
Game.AddResponseOnce(1,options[1]);
Game.AddResponseOnce(2,options[2]);
selected = Game.GetResponse();
switch (selected)
{
case 0:
Game.Msg("this is case 0");
break;
case 1:
Game.Msg("this is case 1");
break;
case 2:
Game.Msg("this is the last case");
break;
}
}
Game.EndDlgBranch();
}
-
Taking this a little bit further I built a simple framework to test the concept and get the same result, could the problem be that I am using an attached script or perhaps my installation of WME has become corrupted ! I have also test the script with a "clean " project, of course it may be I have an error in my coding !!
#include "scripts\base.inc"
////////////////////////////////////////////////////////////////////////////////
//on "event"
//{
// ...
//}
var options;
options[0] = "this is top level option 1";
options[1] = "this is top level option 2";
options[2] =" this is top level option 3";
var selected;
while(selected !=2)
{
Game.AddResponseOnce(0,options[0]);
Game.AddResponseOnce(1,options[1]);
Game.AddResponseOnce(2,options[2]);
Game.Interactive = true;
selected = Game.GetResponse();
switch (selected)
{
case 0:
Game.Msg("this is top level case 0");
testb();
break;
case 1:
Game.Msg("this is top level case 1");
break;
case 2:
Game.Msg("this is top level case 2");
break;
}
}
function testb()
{
Game.StartDlgBranch();
var options;
options[0] = "this is testbline1";
options[1] ="this test line 2";
options[2] ="bye";
var selected;
while (selected !=2)
{
Game.AddResponseOnce(0,options[0]);
Game.AddResponseOnce(1,options[1]);
Game.AddResponseOnce(2,options[2]);
selected = Game.GetResponse();
switch (selected)
{
case 0:
Game.Msg("this is case 0");
break;
case 1:
Game.Msg("this is case 1");
break;
case 2:
Game.Msg("this is the last case");
break;
}
}
Game.EndDlgBranch();
}
-
Actually I think the problem is not the dialogue branching, but the fact there's a "switch" command nested in a "while" loop. That's an old bug in the script compiler, where a switch command inside another switch command or inside a loop can cause inpredictable results. Try rewriting the switch into a sequence of if-else-if-else to see if it eliminates the crash.
-
Actually I think the problem is not the dialogue branching, but the fact there's a "switch" command nested in a "while" loop. That's an old bug in the script compiler, where a switch command inside another switch command or inside a loop can cause inpredictable results. Try rewriting the switch into a sequence of if-else-if-else to see if it eliminates the crash.
ok tried that replaced all switch/case with if-then, not else still same windows crash - this problem does not occur in earlier versions of very similar code. I will next try to re-work chuncks of this an see what happens. Have also tried the code on a different machine - same result
-
I have through trial and error come up with a hack fix, immeadaitely before the programme crashed there was a call to a method, if I commented out that line then the function was actioned and the Game.DlgBranch didn't crash WME. The next step was that I introduced a 200 ms sleep statement in between the method and the function call - it now appears to work, or at least not crash - I will now test as to whether the fucntionality works after all my screwing around with it.