Protecting our replacement of Math.random via Aether.
This commit is contained in:
parent
afc14e593d
commit
f3adc216ed
6 changed files with 8 additions and 4 deletions
app
assets/javascripts/workers
lib
models
schemas/models
views/play/level/tome
headless_client
|
@ -289,6 +289,7 @@ self.setupDebugWorldToRunUntilFrame = function (args) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Math.random = self.debugWorld.rand.randf; // so user code is predictable
|
Math.random = self.debugWorld.rand.randf; // so user code is predictable
|
||||||
|
Aether.replaceBuiltin("Math", Math);
|
||||||
}
|
}
|
||||||
self.debugWorld.totalFrames = args.frame; //hack to work around error checking
|
self.debugWorld.totalFrames = args.frame; //hack to work around error checking
|
||||||
self.currentDebugWorldFrame = args.frame;
|
self.currentDebugWorldFrame = args.frame;
|
||||||
|
@ -343,6 +344,7 @@ self.runWorld = function runWorld(args) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Math.random = self.world.rand.randf; // so user code is predictable
|
Math.random = self.world.rand.randf; // so user code is predictable
|
||||||
|
Aether.replaceBuiltin("Math", Math);
|
||||||
self.postMessage({type: 'start-load-frames'});
|
self.postMessage({type: 'start-load-frames'});
|
||||||
self.world.loadFrames(self.onWorldLoaded, self.onWorldError, self.onWorldLoadProgress);
|
self.world.loadFrames(self.onWorldLoaded, self.onWorldError, self.onWorldLoadProgress);
|
||||||
};
|
};
|
||||||
|
|
|
@ -211,6 +211,7 @@ module.exports = class Angel extends CocoClass
|
||||||
doSimulateWorld: (work) ->
|
doSimulateWorld: (work) ->
|
||||||
work.t1 = now()
|
work.t1 = now()
|
||||||
Math.random = work.testWorld.rand.randf # so user code is predictable
|
Math.random = work.testWorld.rand.randf # so user code is predictable
|
||||||
|
Aether.replaceBuiltin("Math", Math)
|
||||||
i = 0
|
i = 0
|
||||||
while i < work.testWorld.totalFrames
|
while i < work.testWorld.totalFrames
|
||||||
frame = work.testWorld.getFrame i++
|
frame = work.testWorld.getFrame i++
|
||||||
|
|
|
@ -159,7 +159,7 @@ module.exports = class ThangType extends CocoModel
|
||||||
spriteSheet = @builder.build()
|
spriteSheet = @builder.build()
|
||||||
@logBuild @t0, false, @options.portraitOnly
|
@logBuild @t0, false, @options.portraitOnly
|
||||||
@spriteSheets[key] = spriteSheet
|
@spriteSheets[key] = spriteSheet
|
||||||
delete @building[key]
|
@building[key] = false
|
||||||
@builder = null
|
@builder = null
|
||||||
@options = null
|
@options = null
|
||||||
spriteSheet
|
spriteSheet
|
||||||
|
@ -171,7 +171,7 @@ module.exports = class ThangType extends CocoModel
|
||||||
buildQueue[0].t0 = new Date().getTime() if buildQueue[0]
|
buildQueue[0].t0 = new Date().getTime() if buildQueue[0]
|
||||||
buildQueue[0]?.buildAsync()
|
buildQueue[0]?.buildAsync()
|
||||||
@spriteSheets[key] = e.target.spriteSheet
|
@spriteSheets[key] = e.target.spriteSheet
|
||||||
delete @building[key]
|
@building[key] = false
|
||||||
@trigger 'build-complete', {key:key, thangType:@}
|
@trigger 'build-complete', {key:key, thangType:@}
|
||||||
@vectorParser = null
|
@vectorParser = null
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ UserSchema = c.object {},
|
||||||
colorConfig: c.object {additionalProperties: c.colorConfig()}
|
colorConfig: c.object {additionalProperties: c.colorConfig()}
|
||||||
|
|
||||||
aceConfig: c.object {},
|
aceConfig: c.object {},
|
||||||
language: {type: 'string', 'default': 'javascript', 'enum': ['javascript', 'coffeescript', 'clojure', 'lua', 'python', 'io']}
|
language: {type: 'string', 'default': 'javascript', 'enum': ['javascript', 'coffeescript', 'python', 'clojure', 'lua', 'io']}
|
||||||
keyBindings: {type: 'string', 'default': 'default', 'enum': ['default', 'vim', 'emacs']}
|
keyBindings: {type: 'string', 'default': 'default', 'enum': ['default', 'vim', 'emacs']}
|
||||||
invisibles: {type: 'boolean', 'default': false}
|
invisibles: {type: 'boolean', 'default': false}
|
||||||
indentGuides: {type: 'boolean', 'default': false}
|
indentGuides: {type: 'boolean', 'default': false}
|
||||||
|
|
|
@ -18,9 +18,9 @@ module.exports = class SpellView extends View
|
||||||
editModes:
|
editModes:
|
||||||
'javascript': 'ace/mode/javascript'
|
'javascript': 'ace/mode/javascript'
|
||||||
'coffeescript': 'ace/mode/coffee'
|
'coffeescript': 'ace/mode/coffee'
|
||||||
|
'python': 'ace/mode/python'
|
||||||
'clojure': 'ace/mode/clojure'
|
'clojure': 'ace/mode/clojure'
|
||||||
'lua': 'ace/mode/lua'
|
'lua': 'ace/mode/lua'
|
||||||
'python': 'ace/mode/python'
|
|
||||||
'io': 'ace/mode/text'
|
'io': 'ace/mode/text'
|
||||||
|
|
||||||
keyBindings:
|
keyBindings:
|
||||||
|
|
|
@ -91,6 +91,7 @@ work = () ->
|
||||||
self.onWorldError error
|
self.onWorldError error
|
||||||
return
|
return
|
||||||
Math.random = self.world.rand.randf # so user code is predictable
|
Math.random = self.world.rand.randf # so user code is predictable
|
||||||
|
Aether.replaceBuiltin("Math", Math)
|
||||||
console.log "Loading frames."
|
console.log "Loading frames."
|
||||||
|
|
||||||
self.postMessage type: "start-load-frames"
|
self.postMessage type: "start-load-frames"
|
||||||
|
|
Reference in a new issue