From 9ace31d391875402a6b042e0fa2afd5ca07efc59 Mon Sep 17 00:00:00 2001
From: Scott Erickson <sderickson@gmail.com>
Date: Mon, 19 May 2014 16:17:54 -0700
Subject: [PATCH] Fixed the target mark.

---
 app/lib/surface/CocoSprite.coffee |  4 ++--
 app/lib/surface/Mark.coffee       | 11 +++++++----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/app/lib/surface/CocoSprite.coffee b/app/lib/surface/CocoSprite.coffee
index 31842e602..e047e692e 100644
--- a/app/lib/surface/CocoSprite.coffee
+++ b/app/lib/surface/CocoSprite.coffee
@@ -344,12 +344,12 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
       angle = 180 - angle if angle > 90
       scaleX = 0.5 + 0.5 * (90 - angle) / 90
 
-    console.error "No thang for", @ unless @thang
+#    console.error "No thang for", @ unless @thang
     # TODO: support using scaleFactorX/Y from the thang object
     @imageObject.scaleX = @baseScaleX * @scaleFactor * scaleX
     @imageObject.scaleY = @baseScaleY * @scaleFactor * scaleY
 
-    if (@thang.scaleFactor or 1) isnt @targetScaleFactor
+    if @thang and (@thang.scaleFactor or 1) isnt @targetScaleFactor
       createjs.Tween.removeTweens(@)
       createjs.Tween.get(@).to({scaleFactor:@thang.scaleFactor or 1}, 2000, createjs.Ease.elasticOut)
       @targetScaleFactor = @thang.scaleFactor or 1
diff --git a/app/lib/surface/Mark.coffee b/app/lib/surface/Mark.coffee
index 4d2e554c0..b283e82a4 100644
--- a/app/lib/surface/Mark.coffee
+++ b/app/lib/surface/Mark.coffee
@@ -201,7 +201,8 @@ module.exports = class Mark extends CocoClass
     Backbone.Mediator.publish 'sprite:loaded'
 
   update: (pos=null) ->
-    return false unless @on and @mark and @sprite?.thangType.isFullyLoaded()
+    return false unless @on and @mark
+    return false if @sprite? and not @sprite.thangType.isFullyLoaded()
     @mark.visible = not @hidden
     @updatePosition pos
     @updateRotation()
@@ -250,10 +251,12 @@ module.exports = class Mark extends CocoClass
       scale = size / {selection: 128, target: 128, repair: 320, highlight: 160}[@name]
       if @sprite?.thang.spriteName.search(/(dungeon|indoor).wall/i) isnt -1
         scale *= 2
-    @mark.scaleX = @mark.scaleY = Math.min 1, scale
+    
     if @markSprite?
-      @mark.scaleX *= @markSprite.originalScaleX
-      @mark.scaleY *= @markSprite.originalScaleY
+      @markSprite.scaleFactor = scale
+      @markSprite.updateScale()
+    else
+      @mark.scaleX = @mark.scaleY = Math.min 1, scale
     if @name in ['selection', 'target', 'repair']
       @mark.scaleY *= @camera.y2x  # code applies perspective