From d2634e63ed801e2b1f54fb33531f45a1ac49d91a Mon Sep 17 00:00:00 2001
From: Nick Winter <livelily@gmail.com>
Date: Thu, 9 Jun 2016 17:59:19 -0700
Subject: [PATCH] Fix #3642: AIs using aiSource now don't need API protection
 (with new Aether)

---
 app/views/play/level/tome/Spell.coffee | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/views/play/level/tome/Spell.coffee b/app/views/play/level/tome/Spell.coffee
index aabfa4c96..dd0cf0936 100644
--- a/app/views/play/level/tome/Spell.coffee
+++ b/app/views/play/level/tome/Spell.coffee
@@ -46,6 +46,7 @@ module.exports = class Spell
         @source = sessionSource
     if p.aiSource and not @otherSession and not @canWrite()
       @source = @originalSource = p.aiSource
+      @isAISource = true
     @thangs = {}
     if @canRead()  # We can avoid creating these views if we'll never use them.
       @view = new SpellView {spell: @, level: options.level, session: @session, otherSession: @otherSession, worker: @worker, god: options.god, @supermodel}
@@ -162,7 +163,7 @@ module.exports = class Spell
       cb(aether.hasChangedSignificantly((newSource ? @originalSource), (currentSource ? @source), true, true))
 
   createAether: (thang) ->
-    writable = @permissions.readwrite.length > 0
+    writable = @permissions.readwrite.length > 0 and not @isAISource
     skipProtectAPI = @skipProtectAPI or not writable
     problemContext = @createProblemContext thang
     includeFlow = (@levelType in ['hero', 'hero-ladder', 'hero-coop', 'course', 'course-ladder', 'game-dev']) and not skipProtectAPI