コード例 #1
0
ファイル: Landmark.cs プロジェクト: TsengSR/Radegast
 void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
 {
     if (transfer.Success && asset.AssetType == AssetType.Landmark)
     {
         decodedLandmark = (AssetLandmark)asset;
         decodedLandmark.Decode();
         localPosition = decodedLandmark.Position;
         client.Grid.RequestRegionHandle(decodedLandmark.RegionID);
     }
 }
コード例 #2
0
        private string grabAsset(LLUUID AssetID)
        {
            AssetRequestDownload request = base.iManager.AssetManager.RequestInventoryAsset(this);

            if (request.Wait(libsecondlife.AssetSystem.AssetManager.DefaultTimeout) != AssetRequestDownload.RequestStatus.Success)
            {
                throw new Exception("Asset (" + AssetID.ToStringHyphenated() + ") unavailable (" + request.StatusMsg + ") for " + this.Name);
            }
            _Asset = new AssetLandmark(AssetID, request.GetAssetData());
            return(((AssetLandmark)Asset).Body);
        }
コード例 #3
0
        /// <summary>
        /// Tries to teleport agent to landmark.
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="regionHandle"></param>
        /// <param name="position"></param>
        public override void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm)
        {
            m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Teleporting agent via landmark to {0} region {1} position {2}",
                              (lm.Gatekeeper == string.Empty) ? "local" : lm.Gatekeeper, lm.RegionID, lm.Position);

            if (lm.Gatekeeper == string.Empty)
            {
                base.RequestTeleportLandmark(remoteClient, lm);
                return;
            }

            GridRegion info = Scene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID);

            // Local region?
            if (info != null)
            {
                ((Scene)(remoteClient.Scene)).RequestTeleportLocation(remoteClient, info.RegionHandle, lm.Position,
                                                                      Vector3.Zero, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark));
            }
            else
            {
                // Foreign region
                Scene scene = (Scene)(remoteClient.Scene);
                GatekeeperServiceConnector gConn = new GatekeeperServiceConnector();
                GridRegion gatekeeper            = new GridRegion();
                gatekeeper.ServerURI = lm.Gatekeeper;
                string homeURI = Scene.GetAgentHomeURI(remoteClient.AgentId);

                string     message;
                GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(lm.RegionID), remoteClient.AgentId, homeURI, out message);

                if (finalDestination != null)
                {
                    ScenePresence         sp          = scene.GetScenePresence(remoteClient.AgentId);
                    IEntityTransferModule transferMod = scene.RequestModuleInterface <IEntityTransferModule>();

                    if (transferMod != null && sp != null)
                    {
                        if (message != null)
                        {
                            sp.ControllingClient.SendAgentAlertMessage(message, true);
                        }

                        transferMod.DoTeleport(
                            sp, gatekeeper, finalDestination, lm.Position, Vector3.UnitX,
                            (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark));
                    }
                }
                else
                {
                    remoteClient.SendTeleportFailed(message);
                }
            }
        }
コード例 #4
0
        public LSL_Key llRequestInventoryData(string name)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return("");
            }


            TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();

            foreach (TaskInventoryItem item in itemDictionary.Values)
            {
                if (item.Type == 3 && item.Name == name)
                {
                    UUID             rq = UUID.Random();
                    DataserverPlugin dataserverPlugin = (DataserverPlugin)m_ScriptEngine.GetScriptPlugin("Dataserver");

                    UUID tid = dataserverPlugin.RegisterRequest(m_host.UUID,
                                                                m_itemID, rq.ToString());

                    Vector3 region = new Vector3(
                        World.RegionInfo.RegionLocX,
                        World.RegionInfo.RegionLocY,
                        0);

                    World.AssetService.Get(item.AssetID.ToString(), this,
                                           delegate(string i, object sender, AssetBase a) {
                        if (a != null)
                        {
                            AssetLandmark lm = new AssetLandmark(a);

                            float rx = (uint)(lm.RegionHandle >> 32);
                            float ry = (uint)lm.RegionHandle;
                            region   = lm.Position + new Vector3(rx, ry, 0) - region;

                            string reply = region.ToString();
                            dataserverPlugin.AddReply(rq.ToString(),
                                                      reply, 1000);
                        }
                    });

                    PScriptSleep(m_sleepMsOnRequestInventoryData);
                    return(tid.ToString());
                }
            }
            PScriptSleep(m_sleepMsOnRequestInventoryData);
            return(string.Empty);
        }
コード例 #5
0
 /// <summary>
 /// </summary>
 /// <param name="assetData"></param>
 override internal void SetAssetData(byte[] assetData)
 {
     if (_Asset == null)
     {
         if (AssetID != null)
         {
             _Asset = new AssetLandmark(AssetID, assetData);
         }
         else
         {
             _Asset   = new AssetLandmark(LLUUID.Random(), assetData);
             _AssetID = _Asset.AssetID;
         }
     }
     else
     {
         _Asset.SetAssetData(assetData);
     }
 }
コード例 #6
0
        /// <summary>
        /// Tries to teleport agent to landmark.
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="regionHandle"></param>
        /// <param name="position"></param>
        public override void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm)
        {
            m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Teleporting agent via landmark to {0} region {1} position {2}",
                              (lm.Gatekeeper == string.Empty) ? "local" : lm.Gatekeeper, lm.RegionID, lm.Position);
            if (lm.Gatekeeper == string.Empty)
            {
                base.RequestTeleportLandmark(remoteClient, lm);
                return;
            }

            GridRegion info = m_aScene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID);

            // Local region?
            if (info != null)
            {
                ((Scene)(remoteClient.Scene)).RequestTeleportLocation(remoteClient, info.RegionHandle, lm.Position,
                                                                      Vector3.Zero, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark));
                return;
            }
            else
            {
                // Foreign region
                Scene scene = (Scene)(remoteClient.Scene);
                GatekeeperServiceConnector gConn = new GatekeeperServiceConnector();
                GridRegion gatekeeper            = new GridRegion();
                gatekeeper.ServerURI = lm.Gatekeeper;
                GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(lm.RegionID));
                if (finalDestination != null)
                {
                    ScenePresence         sp          = scene.GetScenePresence(remoteClient.AgentId);
                    IEntityTransferModule transferMod = scene.RequestModuleInterface <IEntityTransferModule>();
                    IEventQueue           eq          = sp.Scene.RequestModuleInterface <IEventQueue>();
                    if (transferMod != null && sp != null && eq != null)
                    {
                        transferMod.DoTeleport(sp, gatekeeper, finalDestination, lm.Position,
                                               Vector3.UnitX, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark), eq);
                    }
                }
            }

            // can't find the region: Tell viewer and abort
            remoteClient.SendTeleportFailed("The teleport destination could not be found.");
        }
コード例 #7
0
        public void llTeleportAgent(LSL_Key avatar, LSL_String landmark, LSL_Vector position, LSL_Vector look_at)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return;
            }

            UUID invItemID = InventorySelf();

            if (invItemID == UUID.Zero)
            {
                return;
            }

            lock (m_host.TaskInventory) {
                if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
                {
                    Error("llTeleportAgent", "No permissions to teleport the agent");
                    return;
                }

                if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TELEPORT) == 0)
                {
                    Error("llTeleportAgent", "No permissions to teleport the agent");
                    return;
                }
            }

            TaskInventoryItem item = null;

            lock (m_host.TaskInventory) {
                foreach (KeyValuePair <UUID, TaskInventoryItem> inv in m_host.TaskInventory)
                {
                    if (inv.Value.Name == landmark)
                    {
                        item = inv.Value;
                    }
                }
            }
            if (item == null)
            {
                return;
            }

            IScenePresence presence = World.GetScenePresence(m_host.OwnerID);

            if (presence != null)
            {
                IEntityTransferModule module = World.RequestModuleInterface <IEntityTransferModule>();
                if (module != null)
                {
                    if (landmark != "")
                    {
                        var worldAsset = World.AssetService.Get(item.AssetID.ToString());
                        if (worldAsset != null)
                        {
                            var lm = new AssetLandmark(worldAsset);
                            worldAsset.Dispose();

                            module.Teleport(presence, lm.RegionHandle, lm.Position,
                                            look_at.ToVector3(), (uint)TeleportFlags.ViaLocation);
                            lm.Dispose();
                            return;
                        }
                    }
                    // no landmark details
                    module.Teleport(presence, World.RegionInfo.RegionHandle,
                                    position.ToVector3(), look_at.ToVector3(), (uint)TeleportFlags.ViaLocation);
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Tries to teleport agent to landmark.
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="regionHandle"></param>
        /// <param name="position"></param>
        public override void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm, Vector3 lookAt)
        {
            m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Teleporting agent via landmark to {0} region {1} position {2}",
                              (string.IsNullOrEmpty(lm.Gatekeeper)) ? "local" : lm.Gatekeeper, lm.RegionID, lm.Position);

            ScenePresence sp = Scene.GetScenePresence(remoteClient.AgentId);

            if (sp == null || sp.IsDeleted || sp.IsInTransit || sp.IsChildAgent || sp.IsNPC)
            {
                return;
            }

            GridRegion info = Scene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID);

            // Local region?
            if (info != null)
            {
                //check if region on same position and fix local offset
                if (Util.CompareRegionHandles(lm.RegionHandle, lm.Position, info.RegionLocX, info.RegionLocY, info.RegionSizeX, info.RegionSizeY, out Vector3 offset))
                {
                    Scene.RequestTeleportLocation(remoteClient, info.RegionHandle, offset,
                                                  lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark));
                }
                else //region may had move to other grid slot. assume the lm position is good
                {
                    Scene.RequestTeleportLocation(remoteClient, info.RegionHandle, lm.Position,
                                                  lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark));
                }
                return;
            }

            if (string.IsNullOrEmpty(lm.Gatekeeper))
            {
                remoteClient.SendTeleportFailed("Landmark region not found");
                return;
            }

            // Foreign region
            GridRegion gatekeeper = MakeGateKeeperRegion(lm.Gatekeeper);

            if (gatekeeper == null)
            {
                remoteClient.SendTeleportFailed("Could not parse landmark destiny gatekeeper");
                return;
            }

            string homeURI = Scene.GetAgentHomeURI(remoteClient.AgentId);

            GatekeeperServiceConnector gConn = new GatekeeperServiceConnector();
            GridRegion finalDestination      = gConn.GetHyperlinkRegion(gatekeeper, lm.RegionID, remoteClient.AgentId, homeURI, out string message);

            if (finalDestination == null)
            {
                remoteClient.SendTeleportFailed(message);
            }

            // Validate assorted conditions
            if (!ValidateGenericConditions(sp, gatekeeper, finalDestination, 0, out string reason))
            {
                remoteClient.SendTeleportFailed(reason);
                return;
            }

            if (Util.CompareRegionHandles(lm.RegionHandle, lm.Position, finalDestination.RegionLocX, finalDestination.RegionLocY,
                                          finalDestination.RegionSizeX, finalDestination.RegionSizeY, out Vector3 roffset))
            {
                DoTeleport(sp, gatekeeper, finalDestination, roffset, lookAt,
                           (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark));
                return;
            }
            remoteClient.SendTeleportFailed("landmark region not found");
        }
コード例 #9
0
        /// <summary>
        /// Tries to teleport agent to landmark.
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="regionHandle"></param>
        /// <param name="position"></param>
        public override void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm)
        {
            m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Teleporting agent via landmark to {0} region {1} position {2}",
                              (lm.Gatekeeper == string.Empty) ? "local" : lm.Gatekeeper, lm.RegionID, lm.Position);

            if (lm.Gatekeeper == string.Empty)
            {
                base.RequestTeleportLandmark(remoteClient, lm);
                return;
            }

            GridRegion info = Scene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID);

            // Local region?
            if (info != null)
            {
                Scene.RequestTeleportLocation(
                    remoteClient, info.RegionHandle, lm.Position,
                    Vector3.Zero, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark));
            }
            else
            {
                // Foreign region
                GatekeeperServiceConnector gConn = new GatekeeperServiceConnector();
                GridRegion gatekeeper            = MakeGateKeeperRegion(lm.Gatekeeper);
                if (gatekeeper == null)
                {
                    remoteClient.SendTeleportFailed("Could not parse landmark destiny URI");
                    return;
                }

                string homeURI = Scene.GetAgentHomeURI(remoteClient.AgentId);

                GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(lm.RegionID), remoteClient.AgentId, homeURI, out string message);

                if (finalDestination != null)
                {
                    ScenePresence sp = Scene.GetScenePresence(remoteClient.AgentId);

                    if (sp != null)
                    {
                        if (message != null)
                        {
                            sp.ControllingClient.SendAgentAlertMessage(message, true);
                        }

                        // Validate assorted conditions
                        string reason = string.Empty;
                        if (!ValidateGenericConditions(sp, gatekeeper, finalDestination, 0, out reason))
                        {
                            sp.ControllingClient.SendTeleportFailed(reason);
                            return;
                        }

                        DoTeleport(
                            sp, gatekeeper, finalDestination, lm.Position, Vector3.UnitX,
                            (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark));
                    }
                }
                else
                {
                    remoteClient.SendTeleportFailed(message);
                }
            }
        }
コード例 #10
0
        public static Asset CreateAssetWrapper(AssetType type, UUID uuid, byte[] data)
        {
            Asset asset;

            switch (type)
            {
            case AssetType.Animation:
                asset = new AssetAnimation(uuid, data);
                break;

            case AssetType.Gesture:
                asset = new AssetGesture(uuid, data);
                break;

            case AssetType.Landmark:
                asset = new AssetLandmark(uuid, data);
                break;

            case AssetType.Bodypart:
                asset = new AssetBodypart(uuid, data);
                break;

            case AssetType.Clothing:
                asset = new AssetClothing(uuid, data);
                break;

            case AssetType.LSLBytecode:
                asset = new AssetScriptBinary(uuid, data);
                break;

            case AssetType.LSLText:
                asset = new AssetScriptText(uuid, data);
                break;

            case AssetType.Notecard:
                asset = new AssetNotecard(uuid, data);
                break;

            case AssetType.Sound:
                asset = new AssetSound(uuid, data);
                break;

            case AssetType.Texture:
                asset = new AssetTexture(uuid, data);
                break;

#if COGBOT_LIBOMV
            case AssetType.CallingCard:
                asset = new AssetCallingCard(uuid, data);
                break;
#endif
            default:
#if COGBOT_LIBOMV
                asset = new AssetMutable(type, uuid, data);
                Logger.Log("[OarFile] Not Implemented asset type " + type, Helpers.LogLevel.Error);
#else
                throw new NotImplementedException("Unimplemented asset type: " + type);
#endif
                break;
            }
            return(asset);
        }
コード例 #11
0
 public bool UploadAssetData(bool storeLocal)
 {
     if (IsLocalScene)
     {
         ReplaceAll();
         RezRequested = true;
         NewID        = OldID;
         _NewItem     = OldItem;
         return(true);
     }
     if (CogbotHelpers.IsNullOrZero(NewID))
     {
         if (UseUploadKnown)
         {
             AssetUploaded.Reset();
             if (assetType == AssetType.Notecard)
             {
                 Inventory.RequestCreateItem(GetAssetUploadsFolder(), "" + OldID,
                                             Description, assetType, UUID.Zero,
                                             OpenMetaverse.InventoryType.Notecard,
                                             PermissionMask.All, UpdateInvItem);
             }
             else if (assetType == AssetType.Gesture)
             {
                 Inventory.RequestCreateItem(GetAssetUploadsFolder(), "" + OldID,
                                             Description, assetType, UUID.Zero,
                                             OpenMetaverse.InventoryType.Gesture,
                                             PermissionMask.All, UpdateInvItem);
                 // (gesture.Sequence)
             }
             else if (assetType == AssetType.LSLText)
             {
                 Inventory.RequestCreateItem(GetAssetUploadsFolder(), "" + OldID,
                                             Description, assetType, UUID.Zero,
                                             OpenMetaverse.InventoryType.LSL,
                                             PermissionMask.All, UpdateInvItem);
             }
             else if (assetType == AssetType.Landmark)
             {
                 var decodeME = new AssetLandmark(UUID.Zero, AssetData);
                 decodeME.Decode();
                 byte[] bytes = AssetData;
                 Inventory.RequestCreateItem(GetAssetUploadsFolder(), "" + OldID,
                                             "RegionID:" + decodeME.RegionID + ",Postion" + decodeME.Position +
                                             "," + DateTime.Now, assetType, UUID.Zero,
                                             OpenMetaverse.InventoryType.Landmark,
                                             PermissionMask.All, UpdateInvItem);
             }
             else if (assetType == AssetType.CallingCard)
             {
                 var decodeME = new AssetCallingCard(UUID.Zero, AssetData);
                 decodeME.Decode();
                 byte[] bytes = AssetData;
                 Inventory.RequestCreateItem(GetAssetUploadsFolder(), "" + OldID,
                                             "AvatarID:" + decodeME.AvatarID + "," + DateTime.Now,
                                             assetType, UUID.Zero,
                                             OpenMetaverse.InventoryType.CallingCard,
                                             PermissionMask.All, UpdateInvItem);
             }
             else
             {
                 Inventory.RequestCreateItemFromAsset(AssetData, "" + OldID, Description,
                                                      assetType, inventoryType,
                                                      GetAssetUploadsFolder(),
                                                      Permissions.FullPermissions,
                                                      InvItemCreated);
             }
             if (!AssetUploaded.WaitOne(10000))
             {
                 return(false);
             }
             return(true);
         }
         NewID = UUID.Combine(OldID, Importing.Client.Self.SecureSessionID);
         NewUUID2OBJECT[NewID] = this;
         Importing.Client.Assets.RequestUploadKnown(NewID, assetType, AssetData, storeLocal, OldID);
         RezRequested = true;
     }
     return(true);
 }
コード例 #12
0
ファイル: XMRInstBackend.cs プロジェクト: osCore2/xmrengine
        /**
         * @brief llTeleportAgent() is broken in that if you pass it a landmark,
         *        it still subjects the position to spawn points, as it always
         *        calls RequestTeleportLocation() with TeleportFlags.ViaLocation.
         *        See llTeleportAgent() and CheckAndAdjustTelehub().
         *
         * @param agent    = what agent to teleport
         * @param landmark = inventory name or UUID of a landmark object
         * @param lookat   = looking direction after teleport
         */
        public void xmrTeleportAgent2Landmark(string agent, string landmark, LSL_Vector lookat)
        {
            // find out about agent to be teleported
            UUID agentId;

            if (!UUID.TryParse(agent, out agentId))
            {
                throw new ApplicationException("bad agent uuid");
            }

            ScenePresence presence = World.GetScenePresence(agentId);

            if (presence == null)
            {
                throw new ApplicationException("agent not present in scene");
            }
            if (presence.IsNPC)
            {
                throw new ApplicationException("agent is an NPC");
            }
            if (presence.IsGod)
            {
                throw new ApplicationException("agent is a god");
            }

            // prim must be owned by land owner or prim must be attached to agent
            if (m_host.ParentGroup.AttachmentPoint == 0)
            {
                if (m_host.OwnerID != World.LandChannel.GetLandObject(presence.AbsolutePosition).LandData.OwnerID)
                {
                    throw new ApplicationException("prim not owned by land's owner");
                }
            }
            else
            {
                if (m_host.OwnerID != presence.UUID)
                {
                    throw new ApplicationException("prim not attached to agent");
                }
            }

            // find landmark in inventory or by UUID
            UUID assetID = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, landmark);

            if (assetID == UUID.Zero)
            {
                throw new ApplicationException("no such landmark");
            }

            // read it in and make sure it is a landmark
            AssetBase lma = World.AssetService.Get(assetID.ToString());

            if ((lma == null) || (lma.Type != (sbyte)AssetType.Landmark))
            {
                throw new ApplicationException("not a landmark");
            }

            // parse the record
            AssetLandmark lm = new AssetLandmark(lma);

            // the regionhandle (based on region's world X,Y) might be out of date
            // re-read the handle so we can pass it to RequestTeleportLocation()
            var region = World.GridService.GetRegionByUUID(World.RegionInfo.ScopeID, lm.RegionID);

            if (region == null)
            {
                throw new ApplicationException("no such region");
            }

            // finally ready to teleport
            World.RequestTeleportLocation(presence.ControllingClient,
                                          region.RegionHandle,
                                          lm.Position,
                                          lookat,
                                          (uint)TeleportFlags.ViaLandmark);
        }