aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-03-01 22:43:42 +0100
committertomsmeding <tom.smeding@gmail.com>2017-03-01 22:43:42 +0100
commit6149ed650b00dde6b91679880ce8cec66c729f8c (patch)
tree5dad0820445c4698938012975530b56f0e0c9711
parent06afce8c3beb824e9c3d54320c10d1c26448c54d (diff)
Fix bugs
-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);
}