diff --git a/language.version b/language.version index 62b224873..6be0d1fdf 100644 --- a/language.version +++ b/language.version @@ -1,3 +1,3 @@ [default] -SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r283 \cu(Tue 9 Aug 14:02:28 CEST 2022)\c-"; -SWWM_SHORTVER="\cw1.3pre r283 \cu(2022-08-09 14:02:28)\c-"; +SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r284 \cu(Tue 9 Aug 14:09:22 CEST 2022)\c-"; +SWWM_SHORTVER="\cw1.3pre r284 \cu(2022-08-09 14:09:22)\c-"; diff --git a/zscript/handler/swwm_handler_oneliners.zsc b/zscript/handler/swwm_handler_oneliners.zsc index 529bd0a7e..df18c64f9 100644 --- a/zscript/handler/swwm_handler_oneliners.zsc +++ b/zscript/handler/swwm_handler_oneliners.zsc @@ -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 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);