From 022722a19f412ebfa8b6f181d094247b0d32edd5 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Tue, 20 May 2014 09:19:31 -0700 Subject: [PATCH] Fixed cosmetic GoalManager destruction error. --- app/lib/CocoClass.coffee | 5 +++-- app/lib/world/GoalManager.coffee | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/lib/CocoClass.coffee b/app/lib/CocoClass.coffee index f93074e8c..e29298b18 100644 --- a/app/lib/CocoClass.coffee +++ b/app/lib/CocoClass.coffee @@ -9,7 +9,7 @@ module.exports = class CocoClass @nicksUsed: {} @remainingNicks: [] @nextNick: -> - return "CocoClass " + classCount unless @nicks.length + return (@name or "CocoClass") + " " + classCount unless @nicks.length @remainingNicks = if @remainingNicks.length then @remainingNicks else @nicks.slice() baseNick = @remainingNicks.splice(Math.floor(Math.random() * @remainingNicks.length), 1)[0] i = 0 @@ -37,7 +37,7 @@ module.exports = class CocoClass destroy: -> # teardown subscriptions, prevent new ones @stopListening?() - @off() + @off?() @unsubscribeAll() @stopListeningToShortcuts() @constructor.nicksUsed[@nick] = false @@ -65,6 +65,7 @@ module.exports = class CocoClass Backbone.Mediator.subscribe(channel, func, @) unsubscribeAll: -> + return unless Backbone?.Mediator? for channel, func of @subscriptions func = utils.normalizeFunc(func, @) Backbone.Mediator.unsubscribe(channel, func, @) diff --git a/app/lib/world/GoalManager.coffee b/app/lib/world/GoalManager.coffee index 549f4bf30..82b6b58d2 100644 --- a/app/lib/world/GoalManager.coffee +++ b/app/lib/world/GoalManager.coffee @@ -14,6 +14,7 @@ module.exports = class GoalManager extends CocoClass # If you want weird goals or hybrid goals, make a custom goal. nextGoalID: 0 + nicks: ["GoalManager"] constructor: (@world, @initialGoals, @team) -> super()