Optimize wait/message (#9086)

* add `IExecutor.yield` to optimize `wait`

* add MessageType.label. and add outSuccess

* remove `MessageType.label` in support `marks`

* amend

* amend
This commit is contained in:
WayZer
2023-10-06 13:20:53 -04:00
committed by GitHub
parent 5c0c8dcd43
commit 84dc5550ab
3 changed files with 23 additions and 9 deletions
+14 -6
View File
@@ -49,6 +49,7 @@ public class LExecutor{
public Var[] vars = {};
public Var counter;
public int[] binds;
public boolean yield;
public int iptIndex = -1;
public LongSeq graphicsBuffer = new LongSeq();
@@ -1128,6 +1129,7 @@ public class LExecutor{
}else{
//skip back to self.
exec.var(varCounter).numval --;
exec.yield = true;
}
if(state.updateId != frameId){
@@ -1143,6 +1145,7 @@ public class LExecutor{
public void run(LExecutor exec){
//skip back to self.
exec.var(varCounter).numval --;
exec.yield = true;
}
}
@@ -1539,11 +1542,12 @@ public class LExecutor{
public static class FlushMessageI implements LInstruction{
public MessageType type = MessageType.announce;
public int duration;
public int duration, outSuccess;
public FlushMessageI(MessageType type, int duration){
public FlushMessageI(MessageType type, int duration, int outSuccess){
this.type = type;
this.duration = duration;
this.outSuccess = outSuccess;
}
public FlushMessageI(){
@@ -1551,16 +1555,20 @@ public class LExecutor{
@Override
public void run(LExecutor exec){
if(headless && type != MessageType.mission) return;
//set default to succes
exec.setnum(outSuccess, 1);
if(headless && type != MessageType.mission) {
exec.textBuffer.setLength(0);
return;
}
//skip back to self until possible
//TODO this is guaranteed desync on servers - I don't see a good solution
if(
type == MessageType.announce && ui.hasAnnouncement() ||
type == MessageType.notify && ui.hudfrag.hasToast() ||
type == MessageType.toast && ui.hasAnnouncement()
){
exec.var(varCounter).numval --;
//set outSuccess=false to let user retry.
exec.setnum(outSuccess, 0);
return;
}