Elevator.stop() followed by Elevator.goToFloor(floorNum, true) creates additional "0" destination
Laogeodritt opened this issue · 4 comments
Issue: After the following sequence of calls:
elevator = elevators[0];
elevator.stop();
elevator.goToFloor(2, true);
the elevator has a destination queue {2, 0}.
Expected result: At the end of the sequence of calls above, the elevator has a destination queue of {2}.
Minimum working example:
{
init: function(elevators, floors) {
var elevator = elevators[0];
elevator.on("idle", function() {
console.log("prequeue{" + elevator.destinationQueue + "}");
elevator.goToFloor(3);
elevator.stop();
elevator.goToFloor(2, true);
console.log("postqueue{" + elevator.destinationQueue + "}");
});
},
update: function(dt, elevators, floors) {
// We normally don't need to do anything here
}
}
Did you previously have an error in your code? Seems like this is similar to this bug:
#88
I think try/catch around all events that reach user code is needed.
Just tried the MWE in an Incognito window and the behaviour is the same, so it doesn't seem to have the same root cause as #88 (prior error in user code causing bad state of core). Also tried Firefox, fresh load of the page.
Perhaps I should have mentioned earlier, my environment is Chrome 41.0.2272.101 m, Win7. Firefox was version 35.0, Win7.
Thanks, will take a look.
Please close if this fixes the problem (it's published in version 1.5.3)