From 8c45e22741b197c732ef237580fced30fb76f84d Mon Sep 17 00:00:00 2001
From: Nick Winter <livelily@gmail.com>
Date: Thu, 4 Sep 2014 11:04:16 -0700
Subject: [PATCH] Protection and logging for #1463. Fixed an issue with
 spectate camera script bounds.

---
 app/models/LevelSession.coffee     | 11 +++++++++++
 app/views/play/SpectateView.coffee |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/app/models/LevelSession.coffee b/app/models/LevelSession.coffee
index ba87aef23..5d59d1bc2 100644
--- a/app/models/LevelSession.coffee
+++ b/app/models/LevelSession.coffee
@@ -42,3 +42,14 @@ module.exports = class LevelSession extends CocoModel
 
   completed: ->
     @get('state')?.complete || false
+
+  shouldAvoidCorruptData: (attrs) ->
+    return false unless me.team is 'humans'
+    if _.string.startsWith (attrs?.code ? @get('code'))?.anya?.makeBid ? '', 'var __interceptThis'
+      noty text: "Not saving session--it's trying to overwrite Anya's code with transpiled output. Please let us know and help us reproduce this bug!", layout: 'topCenter', type: 'error', killer: false, timeout: 120000
+      return true
+    false
+
+  save: (attrs, options) ->
+    return if @shouldAvoidCorruptData attrs
+    super attrs, options
diff --git a/app/views/play/SpectateView.coffee b/app/views/play/SpectateView.coffee
index 8cd6a79cb..f4d7514ba 100644
--- a/app/views/play/SpectateView.coffee
+++ b/app/views/play/SpectateView.coffee
@@ -217,7 +217,7 @@ module.exports = class SpectateLevelView extends RootView
   initScriptManager: ->
     if @world.scripts
       nonVictoryPlaybackScripts = _.reject @world.scripts, (script) ->
-        script.id.indexOf('Set Camera Boundaries and Goals') == -1
+        script.id.indexOf('Set Camera Boundaries') is -1
     else
       console.log 'World scripts don\'t exist!'
       nonVictoryPlaybackScripts = []