From 8f85e3771336582cb89292ef68ab8e8c3d3fe03d Mon Sep 17 00:00:00 2001
From: Matt Lott <mattlott@live.com>
Date: Mon, 29 Sep 2014 17:31:58 -0700
Subject: [PATCH] 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.
---
 app/lib/Angel.coffee        | 6 +++++-
 app/models/CocoModel.coffee | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/app/lib/Angel.coffee b/app/lib/Angel.coffee
index a1bdb196f..c504ee802 100644
--- a/app/lib/Angel.coffee
+++ b/app/lib/Angel.coffee
@@ -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()
diff --git a/app/models/CocoModel.coffee b/app/models/CocoModel.coffee
index dcbd39263..0c347b8c6 100644
--- a/app/models/CocoModel.coffee
+++ b/app/models/CocoModel.coffee
@@ -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