repo: janusweb
action: commit
revision: 
path_from: 
revision_from: e30bb23dc0ca9f082672e92dc43aefc3490f59d7:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit e30bb23dc0ca9f082672e92dc43aefc3490f59d7
Author: James Baicoianu 
Date:   Tue Jun 30 15:52:49 2020 -0700

    Create reciprocal link when traversing portals if the room doesn't already have a link back

diff --git a/scripts/room.js b/scripts/room.js
index 810336cfd66c5c0eaf391e9f561761e4801dfc9e..
index ..8d8cd78416a2a9a167e8e130583e0714f9e75467 100644
--- a/scripts/room.js
+++ b/scripts/room.js
@@ -729,15 +729,25 @@ elation.require([
         }

         // If we have a referrer, check to see if a reciprocal link exists.  If it does, use this as our spawn point.
+        let hasReciprocalLink = false;
         if (roomdata.link && this.referrer) {
           roomdata.link.forEach(link => {
             if (link.url == this.referrer) {
               this.spawnpoint.quaternion.copy(link.orientation.inverse());
               this.spawnpoint.position.fromArray(link.pos);
               this.spawnpoint.position.add(this.spawnpoint.localToWorld(V(0,0,-player.fatness)));
+              hasReciprocalLink = true;
             }
           });
         }
+        if (!hasReciprocalLink) {
+          // If no reciprocal link was found, spawn one so we can find our way back
+          this.createObject('link', {
+            pos: this.spawnpoint.position,
+            orientation: this.spawnpoint.quaternion,
+            url: this.referrer,
+          });
+        }

         if (typeof room.skybox != 'undefined') this.properties.skybox = room.skybox;
         if (room.skybox_left_id) this.properties.skybox_left = room.skybox_left_id;

-----END OF PAGE-----