Adding Drone.MAX_VOLUME and Drone.MAX_SIDE properties

This commit is contained in:
walterhiggins 2014-03-13 19:23:32 +00:00
parent 7e435be565
commit 0a506f80ed
2 changed files with 16 additions and 2 deletions

View file

@ -1,7 +1,12 @@
# 2014 03 08
# 2014 03 12
## Version 2.0.6
Added Drone.MAX_VOLUME and Drone.MAX_SIDE properties to specify limits on size of Drone ops.
This is to stop individual players from hogging the CPU in a classrom environment.
# 2014 03 08
Fixed issues #115 #122 #123
Improved background processing of Drone build commands.

View file

@ -1057,6 +1057,15 @@ Drone.prototype.cuboida = function(/* Array */ blocks, w, h, d, overwrite, immed
return this;
};
Drone.MAX_VOLUME = 1000000;
Drone.MAX_SIDE = 1000;
var tooBig = function(w, h, d ) {
return ( w * h * d ) >= Drone.MAX_VOLUME ||
( w >= Drone.MAX_SIDE ) ||
( h >= Drone.MAX_SIDE ) ||
( d >= Drone.MAX_SIDE );
};
/*
faster cuboid because blockid, meta and world must be provided
use this method when you need to repeatedly place blocks
@ -1072,7 +1081,7 @@ Drone.prototype.cuboidX = function( blockType, meta, w, h, d, immediate ) {
if ( typeof w == 'undefined' ) {
w = 1;
}
if ( ( w * h * d ) >= 1000000 ) {
if ( tooBig( w, h, d ) ) {
this.sign([
'Build too Big!',
'width:' + w,