예제 #1
0
        void LoadTerrain(int terrain)
        {
            //Load one of the numbered terrains from file
            ITerrainModule terrainmod = m_scene.RequestModuleInterface <ITerrainModule>();

            try
            {
                terrainmod.LoadFromFile(String.Format("terrain/Terrain{0}.png", terrain));
                Alert("Loading terrain.  Please wait...");
                //Ugly hack to solve problem of clients not consistently receiving terrain updates.
                //Pause and send it a second time.
                Thread.Sleep(3000);
                terrainmod.LoadFromFile(String.Format("terrain/Terrain{0}.png", terrain));
                Alert("Loaded terrain...");
            }
            catch
            {
                Alert("Error - Requested file not found!");
            }
        }
예제 #2
0
        private void HandleTerrainApplication(string filename, byte[] terrainData, IClientAPI remoteClient)
        {
            lock (TerrainUploader)
            {
                remoteClient.OnXferReceive        -= TerrainUploader.XferReceive;
                remoteClient.OnAbortXfer          -= AbortTerrainXferHandler;
                TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;

                TerrainUploader = null;
            }
            remoteClient.SendAlertMessage("Terrain Upload Complete. Loading....");
            ITerrainModule terr = m_scene.RequestModuleInterface <ITerrainModule>();

            if (terr != null)
            {
                m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + m_scene.RegionInfo.RegionName);
                if (File.Exists(Util.dataDir() + "/terrain.raw"))
                {
                    File.Delete(Util.dataDir() + "/terrain.raw");
                }
                try
                {
                    FileStream input = new FileStream(Util.dataDir() + "/terrain.raw", FileMode.CreateNew);
                    input.Write(terrainData, 0, terrainData.Length);
                    input.Close();
                }
                catch (IOException e)
                {
                    m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools.  It gave us the following error: {0}", e.ToString());
                    remoteClient.SendAlertMessage("There was an IO Exception loading your terrain.  Please check free space");

                    return;
                }
                catch (SecurityException e)
                {
                    m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools.  It gave us the following error: {0}", e.ToString());
                    remoteClient.SendAlertMessage("There was a security Exception loading your terrain.  Please check the security on the simulator drive");

                    return;
                }
                catch (UnauthorizedAccessException e)
                {
                    m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools.  It gave us the following error: {0}", e.ToString());
                    remoteClient.SendAlertMessage("There was a security Exception loading your terrain.  Please check the security on the simulator drive");

                    return;
                }



                try
                {
                    terr.LoadFromFile(Util.dataDir() + "/terrain.raw");
                    remoteClient.SendAlertMessage("Your terrain was loaded. Give it a minute or two to apply");
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat("[TERRAIN]: Error loading a terrain file uploaded via the estate tools.  It gave us the following error: {0}", e.ToString());
                    remoteClient.SendAlertMessage("There was a general error loading your terrain.  Please fix the terrain file and try again");
                }
            }
            else
            {
                remoteClient.SendAlertMessage("Unable to apply terrain.  Cannot get an instance of the terrain module");
            }
        }