예제 #1
0
        private void HandleCreate(HttpRequest req, Map jsondata)
        {
            var estateInfo = new EstateInfo();

            if (!m_WebIF.TranslateToUUI(jsondata["owner"].ToString(), out estateInfo.Owner))
            {
                m_WebIF.ErrorResponse(req, AdminWebIfErrorResult.InvalidParameter);
                return;
            }
            try
            {
                if (jsondata.ContainsKey("id"))
                {
                    estateInfo.ID = jsondata["id"].AsUInt;
                }
                else
                {
                    var  estateids = m_EstateService.AllIDs;
                    uint id        = 100;
                    while (estateids.Contains(id))
                    {
                        ++id;
                    }
                    estateInfo.ID = id;
                }
                estateInfo.Name  = jsondata["name"].ToString();
                estateInfo.Flags = jsondata.ContainsKey("flags") ?
                                   (RegionOptionFlags)jsondata["flags"].AsUInt :
                                   RegionOptionFlags.AllowVoice | RegionOptionFlags.AllowSetHome | RegionOptionFlags.AllowLandmark | RegionOptionFlags.AllowDirectTeleport | RegionOptionFlags.AllowParcelChanges | RegionOptionFlags.ExternallyVisible;

                estateInfo.PricePerMeter  = jsondata["pricepermeter"].AsInt;
                estateInfo.BillableFactor = jsondata["billablefactor"].AsReal;
                estateInfo.AbuseEmail     = jsondata["abuseemail"].ToString();
                estateInfo.ParentEstateID = jsondata["parentestateid"].AsUInt;
            }
            catch
            {
                m_WebIF.ErrorResponse(req, AdminWebIfErrorResult.InvalidRequest);
                return;
            }

            try
            {
                m_EstateService.Add(estateInfo);
            }
            catch
            {
                m_WebIF.ErrorResponse(req, AdminWebIfErrorResult.NotPossible);
                return;
            }
            m_WebIF.SuccessResponse(req, new Map());
        }
        public bool Run()
        {
            m_Log.Info("Creating estate");
            EstateInfo info = new EstateInfo()
            {
                Name  = "Test Estate",
                ID    = 101,
                Owner = m_EstateOwner
            };

            m_EstateService.Add(info);

            m_Log.Info("Testing non-existence of Estate Accessor 1");
            if (m_EstateService.EstateAccess[info.ID, m_EstateAccessor1])
            {
                return(false);
            }

            m_Log.Info("Testing non-existence of Estate Accessor 2");
            if (m_EstateService.EstateAccess[info.ID, m_EstateAccessor2])
            {
                return(false);
            }

            m_Log.Info("Testing returned entries to match");
            if (m_EstateService.EstateAccess.All[info.ID].Count != 0)
            {
                return(false);
            }

            m_Log.Info("Enabling Estate Accessor 1");
            m_EstateService.EstateAccess[info.ID, m_EstateAccessor1] = true;

            m_Log.Info("Testing existence of Estate Accessor 1");
            if (!m_EstateService.EstateAccess[info.ID, m_EstateAccessor1])
            {
                return(false);
            }

            m_Log.Info("Testing non-existence of Estate Accessor 2");
            if (m_EstateService.EstateAccess[info.ID, m_EstateAccessor2])
            {
                return(false);
            }

            m_Log.Info("Testing returned entries to match");
            if (m_EstateService.EstateAccess.All[info.ID].Count != 1)
            {
                return(false);
            }

            m_Log.Info("Enabling Estate Accessor 2");
            m_EstateService.EstateAccess[info.ID, m_EstateAccessor2] = true;

            m_Log.Info("Testing existence of Estate Accessor 1");
            if (!m_EstateService.EstateAccess[info.ID, m_EstateAccessor1])
            {
                return(false);
            }

            m_Log.Info("Testing existence of Estate Accessor 2");
            if (!m_EstateService.EstateAccess[info.ID, m_EstateAccessor2])
            {
                return(false);
            }

            m_Log.Info("Testing returned entries to match");
            if (m_EstateService.EstateAccess.All[info.ID].Count != 2)
            {
                return(false);
            }

            m_Log.Info("Disabling Estate Accessor 1");
            m_EstateService.EstateAccess[info.ID, m_EstateAccessor1] = false;

            m_Log.Info("Testing non-existence of Estate Accessor 1");
            if (m_EstateService.EstateAccess[info.ID, m_EstateAccessor1])
            {
                return(false);
            }

            m_Log.Info("Testing existence of Estate Accessor 2");
            if (!m_EstateService.EstateAccess[info.ID, m_EstateAccessor2])
            {
                return(false);
            }

            m_Log.Info("Testing returned entries to match");
            if (m_EstateService.EstateAccess.All[info.ID].Count != 1)
            {
                return(false);
            }

            m_Log.Info("Disabling Estate Accessor 2");
            m_EstateService.EstateAccess[info.ID, m_EstateAccessor2] = false;

            m_Log.Info("Testing non-existence of Estate Accessor 1");
            if (m_EstateService.EstateAccess[info.ID, m_EstateAccessor1])
            {
                return(false);
            }

            m_Log.Info("Testing non-existence of Estate Accessor 2");
            if (m_EstateService.EstateAccess[info.ID, m_EstateAccessor2])
            {
                return(false);
            }

            m_Log.Info("Testing returned entries to match");
            if (m_EstateService.EstateAccess.All[info.ID].Count != 0)
            {
                return(false);
            }

            m_Log.Info("Testing deletion");
            if (!m_EstateService.Remove(info.ID))
            {
                return(false);
            }
            return(true);
        }
예제 #3
0
        public bool Run()
        {
            m_Log.InfoFormat("Testing Execution of {1} ({0})", m_AssetID, m_ScriptFile);
            IScriptAssembly scriptAssembly = null;

            try
            {
                using (var reader = new StreamReader(m_ScriptFile, new UTF8Encoding(false)))
                {
                    scriptAssembly = CompilerRegistry.ScriptCompilers.Compile(AppDomain.CurrentDomain, UGUI.Unknown, m_AssetID, reader, includeOpen: OpenFile);
                }
                m_Log.InfoFormat("Compilation of {1} ({0}) successful", m_AssetID, m_ScriptFile);
            }
            catch (CompilerException e)
            {
                m_Log.ErrorFormat("Compilation of {1} ({0}) failed: {2}", m_AssetID, m_ScriptFile, e.Message);
                m_Log.WarnFormat("Stack Trace:\n{0}", e.StackTrace);
                return(false);
            }
            catch (Exception e)
            {
                m_Log.ErrorFormat("Compilation of {1} ({0}) failed: {2}", m_AssetID, m_ScriptFile, e.Message);
                m_Log.WarnFormat("Stack Trace:\n{0}", e.StackTrace);
                return(false);
            }

            RegionInfo rInfo;

            try
            {
                var estate = new EstateInfo
                {
                    ParentEstateID = 1,
                    ID             = m_EstateID,
                    Owner          = m_EstateOwner,
                    Name           = m_EstateName
                };
                m_EstateService.Add(estate);
                m_EstateService.RegionMap[m_RegionID] = m_EstateID;

                rInfo = new RegionInfo
                {
                    Name        = m_RegionName,
                    ID          = m_RegionID,
                    Location    = m_RegionLocation,
                    Size        = m_RegionSize,
                    ProductName = m_ProductName,
                    ServerPort  = (uint)m_RegionPort,
                    Owner       = m_RegionOwner,
                    Flags       = RegionFlags.RegionOnline,
                    Access      = m_RegionAccess,
                    GridURI     = m_GatekeeperURI
                };
                m_RegionStorage.RegisterRegion(rInfo);
            }
            catch (Exception e)
            {
                m_Log.Error("Registration of region failed", e);
                return(false);
            }

            SceneInterface scene;

            try
            {
                scene = m_SceneFactory.Instantiate(rInfo);
            }
            catch (Exception e)
            {
                m_Log.ErrorFormat("Running of {1} ({0}) failed: Failed to start region ID {2}: {3}: {4}\n{5}", m_AssetID, m_ScriptFile, m_RegionID, e.GetType().FullName, e.Message, e.StackTrace);
                return(false);
            }

            try
            {
                m_Scenes.Add(scene);
                scene.LoadSceneSync();
            }
            catch (Exception e)
            {
                m_Log.Error("Starting region failed", e);
                return(false);
            }

            try
            {
                ExperienceServiceInterface experienceService = scene.ExperienceService;
                if (experienceService != null)
                {
                    experienceService.Add(new ExperienceInfo
                    {
                        ID         = m_ExperienceID,
                        Creator    = m_ScriptOwner,
                        Owner      = m_ScriptOwner,
                        Properties = ExperiencePropertyFlags.Grid /* make this grid-wide since otherwise we have to configure a lot more */
                    });
                }
                else
                {
                    m_ExperienceID = UEI.Unknown;
                }
            }
            catch (Exception e)
            {
                m_Log.Error("Creating experience failed", e);
                return(false);
            }

            if (!string.IsNullOrEmpty(m_AssetSourcesConfig))
            {
                AddAssets(scene.AssetService);
            }

            if (!string.IsNullOrEmpty(m_ScriptStatesConfig))
            {
                AddScriptStates();
            }

            if (!string.IsNullOrEmpty(m_LoadOarFileName))
            {
                try
                {
                    using (var s = new FileStream(m_LoadOarFileName, FileMode.Open))
                    {
                        OAR.Load(m_Scenes, scene, OAR.LoadOptions.PersistUuids, s);
                    }
                }
                catch (Exception e)
                {
                    m_Log.Error("Loading oar failed", e);
                    return(false);
                }
            }

            m_Runner.OtherThreadResult = false;

            foreach (string additionalObject in m_AdditionalObjectConfigs)
            {
                m_Log.InfoFormat("Adding object from section {0}", additionalObject);
                if (!TryAddAdditionalObject(scene, additionalObject))
                {
                    m_Log.Info("Failed to add object");
                    return(false);
                }
            }

            try
            {
                var grp = new ObjectGroup
                {
                    RezzingObjectID = m_RezzingObjID
                };
                var part = new ObjectPart(m_ObjectID);
                grp.Add(1, part.ID, part);
                part.ObjectGroup    = grp;
                grp.Owner           = m_ObjectOwner;
                grp.LastOwner       = m_ObjectLastOwner;
                part.Creator        = m_ObjectCreator;
                part.Name           = m_ObjectName;
                part.Description    = m_ObjectDescription;
                part.GlobalPosition = m_Position;
                part.GlobalRotation = m_Rotation;
                part.BaseMask       = m_ObjectPermissionsBase;
                part.OwnerMask      = m_ObjectPermissionsOwner;
                part.NextOwnerMask  = m_ObjectPermissionsNext;
                part.EveryoneMask   = m_ObjectPermissionsEveryone;
                part.GroupMask      = m_ObjectPermissionsGroup;

                var item = new ObjectPartInventoryItem(m_ItemID)
                {
                    AssetType     = AssetType.LSLText,
                    AssetID       = m_AssetID,
                    InventoryType = InventoryType.LSL,
                    LastOwner     = m_ScriptLastOwner,
                    Creator       = m_ScriptCreator,
                    Owner         = m_ScriptOwner,
                    Name          = m_ScriptName,
                    Description   = m_ScriptDescription
                };
                item.Permissions.Base      = m_ScriptPermissionsBase;
                item.Permissions.Current   = m_ScriptPermissionsOwner;
                item.Permissions.EveryOne  = m_ScriptPermissionsEveryone;
                item.Permissions.Group     = m_ScriptPermissionsGroup;
                item.Permissions.NextOwner = m_ScriptPermissionsNext;
                item.ExperienceID          = m_ExperienceID;

                scene.Add(grp);

                foreach (string invconfig in m_AdditionalInventoryConfigs)
                {
                    AddAdditionalInventory(part, invconfig);
                }
                ChatServiceInterface chatService = scene.GetService <ChatServiceInterface>();
                if (chatService != null)
                {
                    chatService.AddRegionListener(PUBLIC_CHANNEL, string.Empty, UUID.Zero, "", GetUUID, null, PublicChannelLog);
                    chatService.AddRegionListener(DEBUG_CHANNEL, string.Empty, UUID.Zero, "", GetUUID, null, DebugChannelLog);
                }
                byte[] serializedState;
                m_ScriptStates.TryGetValue(item.ID, out serializedState);
                ScriptInstance scriptInstance = scriptAssembly.Instantiate(part, item, serializedState);
                part.Inventory.Add(item);
                item.ScriptInstance = scriptInstance;
                item.ScriptInstance.Start(m_StartParameter);
                m_Log.Info("Script started");

                if (Debugger.IsAttached)
                {
                    m_RunTimeoutEvent.WaitOne();
                }
                else
                {
                    m_KillTimer = new Timer(KillTimerCbk, null, m_TimeoutMs + 5000, Timeout.Infinite);
                    m_RunTimeoutEvent.WaitOne(m_TimeoutMs);
                }
                return(m_Runner.OtherThreadResult);
            }
            catch (Exception e)
            {
                m_Log.Error("Starting script failed", e);
                return(false);
            }
        }
예제 #4
0
        public bool Run()
        {
            m_Log.Info("Creating estates");
            EstateInfo info1 = new EstateInfo()
            {
                Name  = "Test Estate 1",
                ID    = 101,
                Owner = m_EstateOwner1
            };

            m_EstateService.Add(info1);

            EstateInfo info2 = new EstateInfo()
            {
                Name  = "Test Estate 2",
                ID    = 102,
                Owner = m_EstateOwner2
            };

            m_EstateService.Add(info2);

            m_Log.Info("Adding regions");
            m_EstateService.RegionMap[m_EstateRegion1] = 101;
            m_EstateService.RegionMap[m_EstateRegion2] = 102;

            m_Log.Info("Test that estate 101 has region 1 on list");
            List <UUID> infoList1 = m_EstateService.RegionMap[101];

            if (infoList1.Count != 1 || !infoList1.Contains(m_EstateRegion1))
            {
                return(false);
            }

            m_Log.Info("Test that estate 101 has region 1 on explicit");
            if (m_EstateService.RegionMap[m_EstateRegion1] != 101)
            {
                return(false);
            }

            m_Log.Info("Test that estate 102 has region 2");
            List <UUID> infoList2 = m_EstateService.RegionMap[102];

            if (infoList2.Count != 1 || !infoList2.Contains(m_EstateRegion2))
            {
                return(false);
            }

            m_Log.Info("Test that estate 102 has region 2 on explicit");
            if (m_EstateService.RegionMap[m_EstateRegion2] != 102)
            {
                return(false);
            }

            m_Log.Info("exchange regions between estates");
            m_EstateService.RegionMap[m_EstateRegion1] = 102;
            m_EstateService.RegionMap[m_EstateRegion2] = 101;

            m_Log.Info("Test that estate 101 has region 2 on list");
            infoList1 = m_EstateService.RegionMap[101];
            if (infoList1.Count != 1 || !infoList1.Contains(m_EstateRegion2))
            {
                return(false);
            }

            m_Log.Info("Test that estate 101 has region 2 on explicit");
            if (m_EstateService.RegionMap[m_EstateRegion2] != 101)
            {
                return(false);
            }

            m_Log.Info("Test that estate 102 has region 1");
            infoList2 = m_EstateService.RegionMap[102];
            if (infoList2.Count != 1 || !infoList2.Contains(m_EstateRegion1))
            {
                return(false);
            }

            m_Log.Info("Test that estate 102 has region 1 on explicit");
            if (m_EstateService.RegionMap[m_EstateRegion2] != 101)
            {
                return(false);
            }

            m_Log.Info("Testing deletion");
            if (!m_EstateService.Remove(info1.ID))
            {
                return(false);
            }
            if (!m_EstateService.Remove(info2.ID))
            {
                return(false);
            }
            return(true);
        }
        public bool Run()
        {
            m_Log.Info("Creating estates");
            EstateInfo info1 = new EstateInfo()
            {
                Name  = "Test Estate 1",
                ID    = 101,
                Owner = m_EstateOwner1
            };

            m_EstateService.Add(info1);

            EstateInfo info2 = new EstateInfo()
            {
                Name  = "Test Estate 2",
                ID    = 102,
                Owner = m_EstateOwner2
            };

            m_EstateService.Add(info2);

            m_Log.Info("Test that owner 1 has estate 101 on list");
            List <uint> infoList1 = m_EstateService.EstateOwner[m_EstateOwner1];

            if (infoList1.Count != 1 || !infoList1.Contains(101))
            {
                return(false);
            }

            m_Log.Info("Test that owner 1 has estate 101 on explicit");
            if (!m_EstateService.EstateOwner[info1.ID].EqualsGrid(m_EstateOwner1))
            {
                return(false);
            }

            m_Log.Info("Test that owner 2 has estate 102");
            List <uint> infoList2 = m_EstateService.EstateOwner[m_EstateOwner2];

            if (infoList2.Count != 1 || !infoList2.Contains(102))
            {
                return(false);
            }

            m_Log.Info("Test that owner 2 has estate 102 on explicit");
            if (!m_EstateService.EstateOwner[info2.ID].EqualsGrid(m_EstateOwner2))
            {
                return(false);
            }

            m_Log.Info("exchange estates between owners");
            m_EstateService.EstateOwner[101] = m_EstateOwner2;
            m_EstateService.EstateOwner[102] = m_EstateOwner1;

            m_Log.Info("check that owner changes on EstateInfo");
            if (!m_EstateService[101].Owner.EqualsGrid(m_EstateOwner2))
            {
                return(false);
            }
            if (!m_EstateService[102].Owner.EqualsGrid(m_EstateOwner1))
            {
                return(false);
            }

            m_Log.Info("Test that owner 1 has estate 102 on list");
            infoList1 = m_EstateService.EstateOwner[m_EstateOwner1];
            if (infoList1.Count != 1 || !infoList1.Contains(102))
            {
                return(false);
            }

            m_Log.Info("Test that owner 1 has estate 102 on explicit");
            if (!m_EstateService.EstateOwner[info2.ID].EqualsGrid(m_EstateOwner1))
            {
                return(false);
            }

            m_Log.Info("Test that owner 2 has estate 101");
            infoList2 = m_EstateService.EstateOwner[m_EstateOwner2];
            if (infoList2.Count != 1 || !infoList2.Contains(101))
            {
                return(false);
            }

            m_Log.Info("Test that owner 2 has estate 101 on explicit");
            if (!m_EstateService.EstateOwner[info1.ID].EqualsGrid(m_EstateOwner2))
            {
                return(false);
            }

            m_Log.Info("Testing deletion");
            if (!m_EstateService.Remove(info1.ID))
            {
                return(false);
            }
            if (!m_EstateService.Remove(info2.ID))
            {
                return(false);
            }
            return(true);
        }
예제 #6
0
        public bool Run()
        {
            string estateName = "Test Estate";
            uint   estateId   = 100;
            UUID   covenantId = UUID.Random;

            m_Log.Info("Testing non-existence of estate via name");
            if (m_EstateService.ContainsKey(estateName))
            {
                return(false);
            }
            m_Log.Info("Testing non-existence of estate via id");
            if (m_EstateService.ContainsKey(estateId))
            {
                return(false);
            }
            m_Log.Info("Creating estate");
            EstateInfo info = new EstateInfo()
            {
                ID             = estateId,
                Name           = estateName,
                Owner          = m_EstateOwner,
                CovenantID     = covenantId,
                AbuseEmail     = "*****@*****.**",
                Flags          = RegionOptionFlags.AllowDirectTeleport,
                BillableFactor = 5,
                PricePerMeter  = 2,
                ParentEstateID = 2
            };

            m_EstateService.Add(info);
            m_Log.Info("Testing existence of estate via name");
            if (!m_EstateService.ContainsKey(estateName))
            {
                return(false);
            }
            m_Log.Info("Testing existence of estate via id");
            if (!m_EstateService.ContainsKey(estateId))
            {
                return(false);
            }

            EstateInfo retrievedInfo;

            m_Log.Info("Testing retrieval via name");
            if (!m_EstateService.TryGetValue(estateName, out retrievedInfo))
            {
                return(false);
            }
            if (!CompareEstates(info, retrievedInfo))
            {
                return(false);
            }

            m_Log.Info("Testing retrieval via id");
            if (!m_EstateService.TryGetValue(estateId, out retrievedInfo))
            {
                return(false);
            }
            if (!CompareEstates(info, retrievedInfo))
            {
                return(false);
            }

            m_Log.Info("Testing update");
            info.Name           = "New Test Estate";
            info.ParentEstateID = 3;
            estateName          = info.Name;
            m_EstateService.Update(info);

            m_Log.Info("Testing retrieval via old name");
            if (m_EstateService.TryGetValue("Test Estate", out retrievedInfo))
            {
                return(false);
            }

            m_Log.Info("Testing retrieval via name");
            if (!m_EstateService.TryGetValue(estateName, out retrievedInfo))
            {
                return(false);
            }
            if (!CompareEstates(info, retrievedInfo))
            {
                return(false);
            }

            m_Log.Info("Testing retrieval via id");
            if (!m_EstateService.TryGetValue(estateId, out retrievedInfo))
            {
                return(false);
            }
            if (!CompareEstates(info, retrievedInfo))
            {
                return(false);
            }

            m_Log.Info("Testing deletion");
            if (!m_EstateService.Remove(estateId))
            {
                return(false);
            }
            m_Log.Info("Testing non-existence of estate via name");
            if (m_EstateService.ContainsKey(estateName))
            {
                return(false);
            }
            m_Log.Info("Testing non-existence of estate via id");
            if (m_EstateService.ContainsKey(estateId))
            {
                return(false);
            }

            return(true);
        }