Fix for main thread GoalManager creation

Using @shared.goalManager.constructor was yielding an incomplete
GoalManager in IE9.

Also fixing up console.debug in CocoModel for IE10 and earlier.
This commit is contained in:
Matt Lott 2014-09-29 17:31:58 -07:00
parent 1e864d49e2
commit 8f85e37713
2 changed files with 6 additions and 1 deletions

View file

@ -4,6 +4,7 @@
{now} = require 'lib/world/world_utils'
World = require 'lib/world/world'
CocoClass = require 'lib/CocoClass'
GoalManager = require 'lib/world/GoalManager'
module.exports = class Angel extends CocoClass
@nicks: ['Archer', 'Lana', 'Cyril', 'Pam', 'Cheryl', 'Woodhouse', 'Ray', 'Krieger']
@ -237,7 +238,10 @@ module.exports = class Angel extends CocoClass
work.testWorld = testWorld = new World work.userCodeMap
testWorld.loadFromLevel work.level
if @shared.goalManager
testGM = new @shared.goalManager.constructor @testWorld
# TODO: Do we need to create testGM via @shared.goalManager.constructor for some scenario?
# TODO: It breaks IE9, because @world is undefined in GoalManager.initThangTeams()
# testGM = new @shared.goalManager.constructor @testWorld
testGM = new GoalManager(work.testWorld)
testGM.setGoals work.goals
testGM.setCode work.userCodeMap
testGM.worldGenerationWillBegin()

View file

@ -19,6 +19,7 @@ class CocoModel extends Backbone.Model
@on 'error', @onError, @
@on 'add', @onLoaded, @
@saveBackup = _.debounce(@saveBackup, 500)
console.debug = console.log unless console.debug # Needed for IE10 and earlier
setProjection: (project) ->
return if project is @project