From 76d9d4c635b2349bf48057cfcfd0c55bbe6f56b8 Mon Sep 17 00:00:00 2001
From: Howard Stearns <howard@highfidelity.io>
Date: Mon, 3 Oct 2016 10:16:06 -0700
Subject: [PATCH] fix canRez logic in tribble script: only need canRezTemp, and
 fail hard rather than retry

---
 .../developer/tests/performance/tribbles.js   | 76 ++++++++++---------
 1 file changed, 40 insertions(+), 36 deletions(-)

diff --git a/scripts/developer/tests/performance/tribbles.js b/scripts/developer/tests/performance/tribbles.js
index c9ae347a82..4c04f8b5b7 100644
--- a/scripts/developer/tests/performance/tribbles.js
+++ b/scripts/developer/tests/performance/tribbles.js
@@ -54,42 +54,46 @@ function randomVector(range) {
     };
 }
 
-Script.setInterval(function () {
-    if (!Entities.serversExist() || !Entities.canRez()) {
-        return;
-    }
-    if (totalCreated >= NUMBER_TO_CREATE) {
-        print("Created " + totalCreated + " tribbles.");
-        Script.stop();
-    }
+if (!Entities.canRezTmp()) {
+    Window.alert("Cannot create temp objects here.");
+    Script.stop();
+} else {
+    Script.setInterval(function () {
+        if (!Entities.serversExist()) {
+            return;
+        }
+        if (totalCreated >= NUMBER_TO_CREATE) {
+            print("Created " + totalCreated + " tribbles.");
+            Script.stop();
+        }
 
-    var i, numToCreate = RATE_PER_SECOND * (SCRIPT_INTERVAL / 1000.0);
-    var parameters = JSON.stringify({
-        moveTimeout: MOVE_TIMEOUT,
-        moveRate: MOVE_RATE,
-        editTimeout: EDIT_TIMEOUT,
-        editRate: EDIT_RATE,
-        debug: {flow: false, send: false, receive: false}
-    });
-    for (i = 0; (i < numToCreate) && (totalCreated < NUMBER_TO_CREATE); i++) {
-        Entities.addEntity({
-            userData: parameters,
-            type: TYPE,
-            name: "tribble-" + totalCreated,
-            position: Vec3.sum(center, randomVector({ x: RANGE, y: RANGE, z: RANGE })),
-            dimensions: {x: SIZE, y: SIZE, z: SIZE},
-            color: {red: Math.random() * 255, green: Math.random() * 255, blue: Math.random() * 255},
-            velocity: VELOCITY,
-            angularVelocity: Vec3.multiply(Math.random(), ANGULAR_VELOCITY),
-            damping: DAMPING,
-            angularDamping: ANGULAR_DAMPING,
-            gravity: GRAVITY,
-            collisionsWillMove: true,
-            lifetime: LIFETIME,
-            script: Script.resolvePath("tribbleEntity.js")
+        var i, numToCreate = RATE_PER_SECOND * (SCRIPT_INTERVAL / 1000.0);
+        var parameters = JSON.stringify({
+            moveTimeout: MOVE_TIMEOUT,
+            moveRate: MOVE_RATE,
+            editTimeout: EDIT_TIMEOUT,
+            editRate: EDIT_RATE,
+            debug: {flow: false, send: false, receive: false}
         });
+        for (i = 0; (i < numToCreate) && (totalCreated < NUMBER_TO_CREATE); i++) {
+            Entities.addEntity({
+                userData: parameters,
+                type: TYPE,
+                name: "tribble-" + totalCreated,
+                position: Vec3.sum(center, randomVector({ x: RANGE, y: RANGE, z: RANGE })),
+                dimensions: {x: SIZE, y: SIZE, z: SIZE},
+                color: {red: Math.random() * 255, green: Math.random() * 255, blue: Math.random() * 255},
+                velocity: VELOCITY,
+                angularVelocity: Vec3.multiply(Math.random(), ANGULAR_VELOCITY),
+                damping: DAMPING,
+                angularDamping: ANGULAR_DAMPING,
+                gravity: GRAVITY,
+                collisionsWillMove: true,
+                lifetime: LIFETIME,
+                script: Script.resolvePath("tribbleEntity.js")
+            });
 
-        totalCreated++;
-    }
-}, SCRIPT_INTERVAL);
-
+            totalCreated++;
+        }
+    }, SCRIPT_INTERVAL);
+}