Fix oneliner repetition when candidates are full.
This commit is contained in:
parent
ed3b4f8bdc
commit
4c359063a9
2 changed files with 10 additions and 14 deletions
|
|
@ -66,6 +66,11 @@ extend Class SWWMHandler
|
|||
}
|
||||
if ( !addme )
|
||||
{
|
||||
// clear history up to the last line if full
|
||||
// this guarantees that there's a non-zero number of candidates
|
||||
// and that the same line can't happen twice in a row when "looping"
|
||||
if ( hnd.gdat.lastlines[idx].lines.Size() >= countem )
|
||||
hnd.gdat.lastlines[idx].lines.Delete(0,hnd.gdat.lastlines[idx].lines.Size()-1);
|
||||
// check last lines so we don't repeat
|
||||
Array<int> candidates;
|
||||
for ( int i=1; i<=countem; i++ )
|
||||
|
|
@ -74,19 +79,10 @@ extend Class SWWMHandler
|
|||
continue;
|
||||
candidates.Push(i);
|
||||
}
|
||||
if ( candidates.Size() > 0 )
|
||||
{
|
||||
whichline = candidates[Random[DemoLines](0,candidates.Size()-1)];
|
||||
hnd.gdat.lastlines[idx].lines.Push(whichline);
|
||||
}
|
||||
else
|
||||
{
|
||||
// clear history and go directly to the "easy" option
|
||||
hnd.gdat.lastlines[idx].lines.Clear();
|
||||
addme = true;
|
||||
}
|
||||
whichline = candidates[Random[DemoLines](0,candidates.Size()-1)];
|
||||
hnd.gdat.lastlines[idx].lines.Push(whichline);
|
||||
}
|
||||
if ( addme )
|
||||
else
|
||||
{
|
||||
// ez
|
||||
whichline = Random[DemoLines](1,countem);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue