aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--world.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/world.cpp b/world.cpp
index b1d5e75..17e63a2 100644
--- a/world.cpp
+++ b/world.cpp
@@ -20,10 +20,14 @@ void Robot::load(int idx,const Script &scr){
WorldAction Robot::tick(World &world){
if(active==0)return WorldAction::none; // TODO: check whether `waited` needs to be reset
+ if(!ipInRange()){
+ ip.bank=ip.pos=0;
+ assert(ipInRange());
+ }
waited++;
Instruction ins=resolve(world);
int dur=calcDuration(ins);
- if(dur<waited)return WorldAction::none;
+ if(waited<dur)return WorldAction::none;
waited=0;
return execute(ins,world);
}