diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index 8c63b308ae..e5329ec7cd 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -1,393 +1,393 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.IO; -using System.Threading; -using Db4objects.Db4o; -using Db4objects.Db4o.Query; -using libsecondlife; -using Nini.Config; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; - -namespace OpenSim.Framework.Communications.Caches -{ - - public class LocalAssetServer : IAssetServer - { - private IAssetReceiver _receiver; - private BlockingQueue _assetRequests; - private IObjectContainer db; - private Thread _localAssetServerThread; - - public LocalAssetServer() - { - System.Console.WriteLine("Starting Db4o asset storage system"); - bool yapfile; - this._assetRequests = new BlockingQueue(); - yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); - - MainLog.Instance.Verbose("Local Asset Server class created"); - db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); - MainLog.Instance.Verbose("Db4 Asset database creation"); - - if (!yapfile) - { - this.SetUpAssetDatabase(); - } - - this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); - this._localAssetServerThread.IsBackground = true; - this._localAssetServerThread.Start(); - - } - - public void SetReceiver(IAssetReceiver receiver) - { - this._receiver = receiver; - } - - public void FetchAsset(LLUUID assetID, bool isTexture) - { - ARequest req = new ARequest(); - req.AssetID = assetID; - req.IsTexture = isTexture; - this._assetRequests.Enqueue(req); - } - - public void UpdateAsset(AssetBase asset) - { - - } - - public void CreateAsset(AssetBase asset) - { - AssetStorage store = new AssetStorage(); - store.Data = asset.Data; - store.Name = asset.Name; - store.UUID = asset.FullID; - db.Set(store); - db.Commit(); - } - - public void SetServerInfo(string ServerUrl, string ServerKey) - { - - } - public void Close() - { - if (db != null) - { - MainLog.Instance.Verbose("Closing local asset server database"); - db.Close(); - } - } - - private void RunRequests() - { - while (true) - { - byte[] idata = null; - bool found = false; - AssetStorage foundAsset = null; - ARequest req = this._assetRequests.Dequeue(); - IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); - if (result.Count > 0) - { - foundAsset = (AssetStorage)result.Next(); - found = true; - } - - AssetBase asset = new AssetBase(); - if (found) - { - asset.FullID = foundAsset.UUID; - asset.Type = foundAsset.Type; - asset.InvType = foundAsset.Type; - asset.Name = foundAsset.Name; - idata = foundAsset.Data; - asset.Data = idata; - _receiver.AssetReceived(asset, req.IsTexture); - } - else - { - //asset.FullID = ; - _receiver.AssetNotFound(req.AssetID); - } - - } - - } - - private void SetUpAssetDatabase() - { - MainLog.Instance.Verbose("Setting up asset database"); - - AssetBase Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); - Image.Name = "Bricks"; - this.LoadAsset(Image, true, "bricks.jp2"); - AssetStorage store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); - Image.Name = "Plywood"; - this.LoadAsset(Image, true, "plywood.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); - Image.Name = "Rocks"; - this.LoadAsset(Image, true, "rocks.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); - Image.Name = "Granite"; - this.LoadAsset(Image, true, "granite.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); - Image.Name = "Hardwood"; - this.LoadAsset(Image, true, "hardwood.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); - Image.Name = "Prim Base Texture"; - this.LoadAsset(Image, true, "plywood.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); - Image.Name = "Map Base Texture"; - this.LoadAsset(Image, true, "map_base.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); - Image.Name = "Map Texture"; - this.LoadAsset(Image, true, "map1.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010"); - Image.Name = "Female Body Texture"; - this.LoadAsset(Image, true, "femalebody.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011"); - Image.Name = "Female Bottom Texture"; - this.LoadAsset(Image, true, "femalebottom.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012"); - Image.Name = "Female Face Texture"; - this.LoadAsset(Image, true, "femaleface.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); - Image.Name = "Skin"; - Image.Type = 13; - Image.InvType = 13; - this.LoadAsset(Image, false, "base_skin.dat"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - - Image = new AssetBase(); - Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); - Image.Name = "Shape"; - Image.Type = 13; - Image.InvType = 13; - this.LoadAsset(Image, false, "base_shape.dat"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110"); - Image.Name = "Shirt"; - Image.Type = 5; - Image.InvType = 18; - this.LoadAsset(Image, false, "newshirt.dat"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120"); - Image.Name = "Shirt"; - Image.Type = 5; - Image.InvType = 18; - this.LoadAsset(Image, false, "newpants.dat"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); - if (File.Exists(filePath)) - { - XmlConfigSource source = new XmlConfigSource(filePath); - ReadAssetDetails(source); - } - } - - protected void ReadAssetDetails(IConfigSource source) - { - AssetBase newAsset = null; - for (int i = 0; i < source.Configs.Count; i++) - { - newAsset = new AssetBase(); - newAsset.FullID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); - newAsset.Name = source.Configs[i].GetString("name", ""); - newAsset.Type = (sbyte)source.Configs[i].GetInt("assetType", 0); - newAsset.InvType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); - string fileName = source.Configs[i].GetString("fileName", ""); - if (fileName != "") - { - this.LoadAsset(newAsset, false, fileName); - AssetStorage store = new AssetStorage(); - store.Data = newAsset.Data; - store.Name = newAsset.Name; - store.UUID = newAsset.FullID; - db.Set(store); - db.Commit(); - } - } - } - - private void LoadAsset(AssetBase info, bool image, string filename) - { - //should request Asset from storage manager - //but for now read from file - - string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; - string fileName = Path.Combine(dataPath, filename); - FileInfo fInfo = new FileInfo(fileName); - long numBytes = fInfo.Length; - FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); - byte[] idata = new byte[numBytes]; - BinaryReader br = new BinaryReader(fStream); - idata = br.ReadBytes((int)numBytes); - br.Close(); - fStream.Close(); - info.Data = idata; - //info.loaded=true; - } - } - public class AssetUUIDQuery : Predicate - { - private LLUUID _findID; - - public AssetUUIDQuery(LLUUID find) - { - _findID = find; - } - public bool Match(AssetStorage asset) - { - return (asset.UUID == _findID); - } - } - -} - +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.IO; +using System.Threading; +using Db4objects.Db4o; +using Db4objects.Db4o.Query; +using libsecondlife; +using Nini.Config; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.Communications.Caches +{ + + public class LocalAssetServer : IAssetServer + { + private IAssetReceiver _receiver; + private BlockingQueue _assetRequests; + private IObjectContainer db; + private Thread _localAssetServerThread; + + public LocalAssetServer() + { + System.Console.WriteLine("Starting Db4o asset storage system"); + bool yapfile; + this._assetRequests = new BlockingQueue(); + yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); + + MainLog.Instance.Verbose("Local Asset Server class created"); + db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); + MainLog.Instance.Verbose("Db4 Asset database creation"); + + if (!yapfile) + { + this.SetUpAssetDatabase(); + } + + this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); + this._localAssetServerThread.IsBackground = true; + this._localAssetServerThread.Start(); + + } + + public void SetReceiver(IAssetReceiver receiver) + { + this._receiver = receiver; + } + + public void FetchAsset(LLUUID assetID, bool isTexture) + { + ARequest req = new ARequest(); + req.AssetID = assetID; + req.IsTexture = isTexture; + this._assetRequests.Enqueue(req); + } + + public void UpdateAsset(AssetBase asset) + { + + } + + public void CreateAsset(AssetBase asset) + { + AssetStorage store = new AssetStorage(); + store.Data = asset.Data; + store.Name = asset.Name; + store.UUID = asset.FullID; + db.Set(store); + db.Commit(); + } + + public void SetServerInfo(string ServerUrl, string ServerKey) + { + + } + public void Close() + { + if (db != null) + { + MainLog.Instance.Verbose("Closing local asset server database"); + db.Close(); + } + } + + private void RunRequests() + { + while (true) + { + byte[] idata = null; + bool found = false; + AssetStorage foundAsset = null; + ARequest req = this._assetRequests.Dequeue(); + IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); + if (result.Count > 0) + { + foundAsset = (AssetStorage)result.Next(); + found = true; + } + + AssetBase asset = new AssetBase(); + if (found) + { + asset.FullID = foundAsset.UUID; + asset.Type = foundAsset.Type; + asset.InvType = foundAsset.Type; + asset.Name = foundAsset.Name; + idata = foundAsset.Data; + asset.Data = idata; + _receiver.AssetReceived(asset, req.IsTexture); + } + else + { + //asset.FullID = ; + _receiver.AssetNotFound(req.AssetID); + } + + } + + } + + private void SetUpAssetDatabase() + { + MainLog.Instance.Verbose("Setting up asset database"); + + AssetBase Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); + Image.Name = "Bricks"; + this.LoadAsset(Image, true, "bricks.jp2"); + AssetStorage store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); + Image.Name = "Plywood"; + this.LoadAsset(Image, true, "plywood.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); + Image.Name = "Rocks"; + this.LoadAsset(Image, true, "rocks.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); + Image.Name = "Granite"; + this.LoadAsset(Image, true, "granite.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); + Image.Name = "Hardwood"; + this.LoadAsset(Image, true, "hardwood.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); + Image.Name = "Prim Base Texture"; + this.LoadAsset(Image, true, "plywood.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); + Image.Name = "Map Base Texture"; + this.LoadAsset(Image, true, "map_base.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); + Image.Name = "Map Texture"; + this.LoadAsset(Image, true, "map1.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010"); + Image.Name = "Female Body Texture"; + this.LoadAsset(Image, true, "femalebody.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011"); + Image.Name = "Female Bottom Texture"; + this.LoadAsset(Image, true, "femalebottom.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012"); + Image.Name = "Female Face Texture"; + this.LoadAsset(Image, true, "femaleface.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); + Image.Name = "Skin"; + Image.Type = 13; + Image.InvType = 13; + this.LoadAsset(Image, false, "base_skin.dat"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + + Image = new AssetBase(); + Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); + Image.Name = "Shape"; + Image.Type = 13; + Image.InvType = 13; + this.LoadAsset(Image, false, "base_shape.dat"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110"); + Image.Name = "Shirt"; + Image.Type = 5; + Image.InvType = 18; + this.LoadAsset(Image, false, "newshirt.dat"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120"); + Image.Name = "Shirt"; + Image.Type = 5; + Image.InvType = 18; + this.LoadAsset(Image, false, "newpants.dat"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); + if (File.Exists(filePath)) + { + XmlConfigSource source = new XmlConfigSource(filePath); + ReadAssetDetails(source); + } + } + + protected void ReadAssetDetails(IConfigSource source) + { + AssetBase newAsset = null; + for (int i = 0; i < source.Configs.Count; i++) + { + newAsset = new AssetBase(); + newAsset.FullID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); + newAsset.Name = source.Configs[i].GetString("name", ""); + newAsset.Type = (sbyte)source.Configs[i].GetInt("assetType", 0); + newAsset.InvType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); + string fileName = source.Configs[i].GetString("fileName", ""); + if (fileName != "") + { + this.LoadAsset(newAsset, false, fileName); + AssetStorage store = new AssetStorage(); + store.Data = newAsset.Data; + store.Name = newAsset.Name; + store.UUID = newAsset.FullID; + db.Set(store); + db.Commit(); + } + } + } + + private void LoadAsset(AssetBase info, bool image, string filename) + { + //should request Asset from storage manager + //but for now read from file + + string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; + string fileName = Path.Combine(dataPath, filename); + FileInfo fInfo = new FileInfo(fileName); + long numBytes = fInfo.Length; + FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); + byte[] idata = new byte[numBytes]; + BinaryReader br = new BinaryReader(fStream); + idata = br.ReadBytes((int)numBytes); + br.Close(); + fStream.Close(); + info.Data = idata; + //info.loaded=true; + } + } + public class AssetUUIDQuery : Predicate + { + private LLUUID _findID; + + public AssetUUIDQuery(LLUUID find) + { + _findID = find; + } + public bool Match(AssetStorage asset) + { + return (asset.UUID == _findID); + } + } + +} + diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index a965ee0a75..a64d1959f6 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -44,7 +44,7 @@ namespace OpenSim.Framework.Communications.Caches private IAssetReceiver _receiver; private BlockingQueue _assetRequests; private Thread _localAssetServerThread; - protected IAssetProvider m_plugin; + protected IAssetProvider m_plugin; private object syncLock = new object(); @@ -102,20 +102,20 @@ namespace OpenSim.Framework.Communications.Caches } public void UpdateAsset(AssetBase asset) - { - lock (syncLock) - { - m_plugin.UpdateAsset(asset); - m_plugin.CommitAssets(); + { + lock (syncLock) + { + m_plugin.UpdateAsset(asset); + m_plugin.CommitAssets(); } } public void CreateAsset(AssetBase asset) - { - lock (syncLock) - { - m_plugin.CreateAsset(asset); - m_plugin.CommitAssets(); + { + lock (syncLock) + { + m_plugin.CreateAsset(asset); + m_plugin.CommitAssets(); } } @@ -135,12 +135,12 @@ namespace OpenSim.Framework.Communications.Caches { ARequest req = this._assetRequests.Dequeue(); - MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); - - AssetBase asset = null; - lock (syncLock) - { - asset = m_plugin.FetchAsset(req.AssetID); + MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); + + AssetBase asset = null; + lock (syncLock) + { + asset = m_plugin.FetchAsset(req.AssetID); } if (asset != null) { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs index d47bb0705e..19220ac7b2 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs @@ -1,17 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; - -namespace OpenSim.Region.Capabilities -{ - [LLSDMap] - public class LLSDItemUpdate - { - public LLUUID item_id; - - public LLSDItemUpdate() - { - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Region.Capabilities +{ + [LLSDMap] + public class LLSDItemUpdate + { + public LLUUID item_id; + + public LLSDItemUpdate() + { + } + } +} diff --git a/OpenSim/Framework/General/Interfaces/IAssetProvider.cs b/OpenSim/Framework/General/Interfaces/IAssetProvider.cs index a2ef826462..daf9d6d395 100644 --- a/OpenSim/Framework/General/Interfaces/IAssetProvider.cs +++ b/OpenSim/Framework/General/Interfaces/IAssetProvider.cs @@ -1,18 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Framework.Types; -using libsecondlife; - -namespace OpenSim.Framework.Interfaces -{ - public interface IAssetProvider - { - void Initialise(string dbfile, string dbname); - AssetBase FetchAsset(LLUUID uuid); - void CreateAsset(AssetBase asset); - void UpdateAsset(AssetBase asset); - bool ExistsAsset(LLUUID uuid); - void CommitAssets(); // force a sync to the database - } +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Types; +using libsecondlife; + +namespace OpenSim.Framework.Interfaces +{ + public interface IAssetProvider + { + void Initialise(string dbfile, string dbname); + AssetBase FetchAsset(LLUUID uuid); + void CreateAsset(AssetBase asset); + void UpdateAsset(AssetBase asset); + bool ExistsAsset(LLUUID uuid); + void CommitAssets(); // force a sync to the database + } } \ No newline at end of file diff --git a/OpenSim/Framework/UserManager/CAPSService.cs b/OpenSim/Framework/UserManager/CAPSService.cs index 39af140e3e..a8eac26bea 100644 --- a/OpenSim/Framework/UserManager/CAPSService.cs +++ b/OpenSim/Framework/UserManager/CAPSService.cs @@ -1,38 +1,38 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using System.Security.Cryptography; -using libsecondlife; -using Nwc.XmlRpc; -using OpenSim.Framework.Console; -using OpenSim.Framework.Data; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Inventory; -using OpenSim.Framework.Utilities; -using OpenSim.Framework.Servers; - -namespace OpenSim.Framework.UserManagement -{ - public class CAPSService - { - private BaseHttpServer m_server; - - public CAPSService(BaseHttpServer httpServer) - { - m_server = httpServer; - this.AddCapsSeedHandler("/CapsSeed/", CapsRequest); - } - - private void AddCapsSeedHandler(string path, RestMethod restMethod) - { - m_server.AddStreamHandler(new RestStreamHandler("POST", path, restMethod)); - } - - public string CapsRequest(string request, string path, string param) - { - System.Console.WriteLine("new caps request " + request +" from path "+ path); - return ""; - } - } -} +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using System.Security.Cryptography; +using libsecondlife; +using Nwc.XmlRpc; +using OpenSim.Framework.Console; +using OpenSim.Framework.Data; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Servers; + +namespace OpenSim.Framework.UserManagement +{ + public class CAPSService + { + private BaseHttpServer m_server; + + public CAPSService(BaseHttpServer httpServer) + { + m_server = httpServer; + this.AddCapsSeedHandler("/CapsSeed/", CapsRequest); + } + + private void AddCapsSeedHandler(string path, RestMethod restMethod) + { + m_server.AddStreamHandler(new RestStreamHandler("POST", path, restMethod)); + } + + public string CapsRequest(string request, string path, string param) + { + System.Console.WriteLine("new caps request " + request +" from path "+ path); + return ""; + } + } +} diff --git a/OpenSim/Framework/UserManager/LoginService.cs b/OpenSim/Framework/UserManager/LoginService.cs index 0af341efb6..32f5565c6d 100644 --- a/OpenSim/Framework/UserManager/LoginService.cs +++ b/OpenSim/Framework/UserManager/LoginService.cs @@ -1,290 +1,290 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using System.Security.Cryptography; -using libsecondlife; -using Nwc.XmlRpc; -using OpenSim.Framework.Console; -using OpenSim.Framework.Data; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Inventory; -using OpenSim.Framework.Utilities; - -using OpenSim.Framework.Configuration; -using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; - -namespace OpenSim.Framework.UserManagement -{ - public class LoginService - { - protected string m_welcomeMessage = "Welcome to OpenSim"; - protected UserManagerBase m_userManager = null; - - public LoginService(UserManagerBase userManager, string welcomeMess) - { - m_userManager = userManager; - if (welcomeMess != "") - { - m_welcomeMessage = welcomeMess; - } - } - - /// - /// Main user login function - /// - /// The XMLRPC request - /// The response to send - public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) - { - - System.Console.WriteLine("Attempting login now..."); - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - - bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); - bool GoodLogin = false; - string firstname = ""; - string lastname = ""; - string passwd = ""; - - UserProfileData userProfile; - LoginResponse logResponse = new LoginResponse(); - - if (GoodXML) - { - firstname = (string)requestData["first"]; - lastname = (string)requestData["last"]; - passwd = (string)requestData["passwd"]; - - userProfile = GetTheUser(firstname, lastname); - if (userProfile == null) - return logResponse.CreateLoginFailedResponse(); - - GoodLogin = AuthenticateUser(userProfile, passwd); - } - else - { - return logResponse.CreateGridErrorResponse(); - } - - if (!GoodLogin) - { - return logResponse.CreateLoginFailedResponse(); - } - else - { - // If we already have a session... - if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) - { - // Reject the login - return logResponse.CreateAlreadyLoggedInResponse(); - } - // Otherwise... - // Create a new agent session - CreateAgent(userProfile, request); - - try - { - LLUUID agentID = userProfile.UUID; - - // Inventory Library Section - InventoryData inventData = this.CreateInventoryData(agentID); - ArrayList AgentInventoryArray = inventData.InventoryArray; - - Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); - ArrayList InventoryRoot = new ArrayList(); - InventoryRoot.Add(InventoryRootHash); - userProfile.rootInventoryFolderID = inventData.RootFolderID; - - // Circuit Code - uint circode = (uint)(Util.RandomClass.Next()); - - logResponse.Lastname = userProfile.surname; - logResponse.Firstname = userProfile.username; - logResponse.AgentID = agentID.ToStringHyphenated(); - logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); - logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); - logResponse.InventoryRoot = InventoryRoot; - logResponse.InventorySkeleton = AgentInventoryArray; - logResponse.InventoryLibrary = this.GetInventoryLibrary(); - logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); - logResponse.CircuitCode = (Int32)circode; - //logResponse.RegionX = 0; //overwritten - //logResponse.RegionY = 0; //overwritten - logResponse.Home = "!!null temporary value {home}!!"; // Overwritten - //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; - //logResponse.SimAddress = "127.0.0.1"; //overwritten - //logResponse.SimPort = 0; //overwritten - logResponse.Message = this.GetMessage(); - - try - { - this.CustomiseResponse(logResponse, userProfile); - } - catch (Exception e) - { - System.Console.WriteLine(e.ToString()); - return logResponse.CreateDeadRegionResponse(); - //return logResponse.ToXmlRpcResponse(); - } - CommitAgent(ref userProfile); - return logResponse.ToXmlRpcResponse(); - - } - - catch (Exception E) - { - System.Console.WriteLine(E.ToString()); - } - //} - } - return response; - - } - - /// - /// Customises the login response and fills in missing values. - /// - /// The existing response - /// The user profile - public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser) - { - } - - /// - /// Saves a target agent to the database - /// - /// The users profile - /// Successful? - public bool CommitAgent(ref UserProfileData profile) - { - // Saves the agent to database - return true; - } - - - /// - /// Checks a user against it's password hash - /// - /// The users profile - /// The supplied password - /// Authenticated? - public virtual bool AuthenticateUser(UserProfileData profile, string password) - { - - MainLog.Instance.Verbose( - "Authenticating " + profile.username + " " + profile.surname); - - password = password.Remove(0, 3); //remove $1$ - - string s = Util.Md5Hash(password + ":" + profile.passwordSalt); - - return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); - } - - /// - /// - /// - /// - /// - public void CreateAgent(UserProfileData profile, XmlRpcRequest request) - { - this.m_userManager.CreateAgent(profile, request); - } - - /// - /// - /// - /// - /// - /// - public virtual UserProfileData GetTheUser(string firstname, string lastname) - { - return this.m_userManager.getUserProfile(firstname, lastname); - } - - /// - /// - /// - /// - public virtual string GetMessage() - { - return m_welcomeMessage; - } - - /// - /// - /// - /// - protected virtual ArrayList GetInventoryLibrary() - { - //return new ArrayList(); - Hashtable TempHash = new Hashtable(); - TempHash["name"] = "OpenSim Library"; - TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated(); - TempHash["version"] = 1; - TempHash["type_default"] = -1; - TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; - ArrayList temp = new ArrayList(); - temp.Add(TempHash); - - TempHash = new Hashtable(); - TempHash["name"] = "Texture Library"; - TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; - TempHash["version"] = 1; - TempHash["type_default"] = -1; - TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; - temp.Add(TempHash); - return temp; - } - - /// - /// - /// - /// - protected virtual ArrayList GetLibraryOwner() - { - //for now create random inventory library owner - Hashtable TempHash = new Hashtable(); - TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; - ArrayList inventoryLibOwner = new ArrayList(); - inventoryLibOwner.Add(TempHash); - return inventoryLibOwner; - } - - protected virtual InventoryData CreateInventoryData(LLUUID userID) - { - AgentInventory userInventory = new AgentInventory(); - userInventory.CreateRootFolder(userID, false); - - ArrayList AgentInventoryArray = new ArrayList(); - Hashtable TempHash; - foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) - { - TempHash = new Hashtable(); - TempHash["name"] = InvFolder.FolderName; - TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); - TempHash["version"] = (Int32)InvFolder.Version; - TempHash["type_default"] = (Int32)InvFolder.DefaultType; - TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); - AgentInventoryArray.Add(TempHash); - } - - return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); - } - - public class InventoryData - { - public ArrayList InventoryArray = null; - public LLUUID RootFolderID = LLUUID.Zero; - - public InventoryData(ArrayList invList, LLUUID rootID) - { - InventoryArray = invList; - RootFolderID = rootID; - } - } - } -} +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using System.Security.Cryptography; +using libsecondlife; +using Nwc.XmlRpc; +using OpenSim.Framework.Console; +using OpenSim.Framework.Data; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Utilities; + +using OpenSim.Framework.Configuration; +using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; + +namespace OpenSim.Framework.UserManagement +{ + public class LoginService + { + protected string m_welcomeMessage = "Welcome to OpenSim"; + protected UserManagerBase m_userManager = null; + + public LoginService(UserManagerBase userManager, string welcomeMess) + { + m_userManager = userManager; + if (welcomeMess != "") + { + m_welcomeMessage = welcomeMess; + } + } + + /// + /// Main user login function + /// + /// The XMLRPC request + /// The response to send + public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) + { + + System.Console.WriteLine("Attempting login now..."); + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + + bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); + bool GoodLogin = false; + string firstname = ""; + string lastname = ""; + string passwd = ""; + + UserProfileData userProfile; + LoginResponse logResponse = new LoginResponse(); + + if (GoodXML) + { + firstname = (string)requestData["first"]; + lastname = (string)requestData["last"]; + passwd = (string)requestData["passwd"]; + + userProfile = GetTheUser(firstname, lastname); + if (userProfile == null) + return logResponse.CreateLoginFailedResponse(); + + GoodLogin = AuthenticateUser(userProfile, passwd); + } + else + { + return logResponse.CreateGridErrorResponse(); + } + + if (!GoodLogin) + { + return logResponse.CreateLoginFailedResponse(); + } + else + { + // If we already have a session... + if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) + { + // Reject the login + return logResponse.CreateAlreadyLoggedInResponse(); + } + // Otherwise... + // Create a new agent session + CreateAgent(userProfile, request); + + try + { + LLUUID agentID = userProfile.UUID; + + // Inventory Library Section + InventoryData inventData = this.CreateInventoryData(agentID); + ArrayList AgentInventoryArray = inventData.InventoryArray; + + Hashtable InventoryRootHash = new Hashtable(); + InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); + ArrayList InventoryRoot = new ArrayList(); + InventoryRoot.Add(InventoryRootHash); + userProfile.rootInventoryFolderID = inventData.RootFolderID; + + // Circuit Code + uint circode = (uint)(Util.RandomClass.Next()); + + logResponse.Lastname = userProfile.surname; + logResponse.Firstname = userProfile.username; + logResponse.AgentID = agentID.ToStringHyphenated(); + logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); + logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); + logResponse.InventoryRoot = InventoryRoot; + logResponse.InventorySkeleton = AgentInventoryArray; + logResponse.InventoryLibrary = this.GetInventoryLibrary(); + logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); + logResponse.CircuitCode = (Int32)circode; + //logResponse.RegionX = 0; //overwritten + //logResponse.RegionY = 0; //overwritten + logResponse.Home = "!!null temporary value {home}!!"; // Overwritten + //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; + //logResponse.SimAddress = "127.0.0.1"; //overwritten + //logResponse.SimPort = 0; //overwritten + logResponse.Message = this.GetMessage(); + + try + { + this.CustomiseResponse(logResponse, userProfile); + } + catch (Exception e) + { + System.Console.WriteLine(e.ToString()); + return logResponse.CreateDeadRegionResponse(); + //return logResponse.ToXmlRpcResponse(); + } + CommitAgent(ref userProfile); + return logResponse.ToXmlRpcResponse(); + + } + + catch (Exception E) + { + System.Console.WriteLine(E.ToString()); + } + //} + } + return response; + + } + + /// + /// Customises the login response and fills in missing values. + /// + /// The existing response + /// The user profile + public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser) + { + } + + /// + /// Saves a target agent to the database + /// + /// The users profile + /// Successful? + public bool CommitAgent(ref UserProfileData profile) + { + // Saves the agent to database + return true; + } + + + /// + /// Checks a user against it's password hash + /// + /// The users profile + /// The supplied password + /// Authenticated? + public virtual bool AuthenticateUser(UserProfileData profile, string password) + { + + MainLog.Instance.Verbose( + "Authenticating " + profile.username + " " + profile.surname); + + password = password.Remove(0, 3); //remove $1$ + + string s = Util.Md5Hash(password + ":" + profile.passwordSalt); + + return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); + } + + /// + /// + /// + /// + /// + public void CreateAgent(UserProfileData profile, XmlRpcRequest request) + { + this.m_userManager.CreateAgent(profile, request); + } + + /// + /// + /// + /// + /// + /// + public virtual UserProfileData GetTheUser(string firstname, string lastname) + { + return this.m_userManager.getUserProfile(firstname, lastname); + } + + /// + /// + /// + /// + public virtual string GetMessage() + { + return m_welcomeMessage; + } + + /// + /// + /// + /// + protected virtual ArrayList GetInventoryLibrary() + { + //return new ArrayList(); + Hashtable TempHash = new Hashtable(); + TempHash["name"] = "OpenSim Library"; + TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated(); + TempHash["version"] = 1; + TempHash["type_default"] = -1; + TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; + ArrayList temp = new ArrayList(); + temp.Add(TempHash); + + TempHash = new Hashtable(); + TempHash["name"] = "Texture Library"; + TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; + TempHash["version"] = 1; + TempHash["type_default"] = -1; + TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; + temp.Add(TempHash); + return temp; + } + + /// + /// + /// + /// + protected virtual ArrayList GetLibraryOwner() + { + //for now create random inventory library owner + Hashtable TempHash = new Hashtable(); + TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; + ArrayList inventoryLibOwner = new ArrayList(); + inventoryLibOwner.Add(TempHash); + return inventoryLibOwner; + } + + protected virtual InventoryData CreateInventoryData(LLUUID userID) + { + AgentInventory userInventory = new AgentInventory(); + userInventory.CreateRootFolder(userID, false); + + ArrayList AgentInventoryArray = new ArrayList(); + Hashtable TempHash; + foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) + { + TempHash = new Hashtable(); + TempHash["name"] = InvFolder.FolderName; + TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); + TempHash["version"] = (Int32)InvFolder.Version; + TempHash["type_default"] = (Int32)InvFolder.DefaultType; + TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); + AgentInventoryArray.Add(TempHash); + } + + return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); + } + + public class InventoryData + { + public ArrayList InventoryArray = null; + public LLUUID RootFolderID = LLUUID.Zero; + + public InventoryData(ArrayList invList, LLUUID rootID) + { + InventoryArray = invList; + RootFolderID = rootID; + } + } + } +} diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index 57652b0cdf..38205752c2 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -1,80 +1,80 @@ -using System; -using System.Collections; -using System.Net; -using Nwc.XmlRpc; -using OpenSim.Framework.Data; -using OpenSim.Framework.UserManagement; -using OpenSim.Framework.Utilities; -using OpenSim.Framework.Configuration; - -namespace OpenSim.Grid.UserServer -{ - public class UserLoginService : LoginService - { - public UserConfig m_config; - - public UserLoginService(UserManagerBase userManager, UserConfig config, string welcomeMess) - : base(userManager, welcomeMess) - { - m_config = config; - } - - /// - /// Customises the login response and fills in missing values. - /// - /// The existing response - /// The user profile - public override void CustomiseResponse(LoginResponse response, UserProfileData theUser) - { - // Load information from the gridserver - SimProfileData SimInfo = new SimProfileData(); - SimInfo = SimInfo.RequestSimProfileData(theUser.currentAgent.currentHandle, m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); - - // Customise the response - // Home Location - response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * 256).ToString() + ",r" + (SimInfo.regionLocY * 256).ToString() + "], " + - "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + - "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; - - // Destination - Console.WriteLine("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + SimInfo.regionLocY); - response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString(); - response.SimPort = (Int32)SimInfo.serverPort; - response.RegionX = SimInfo.regionLocX; - response.RegionY = SimInfo.regionLocY; - - //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI - string capsPath = Util.GetRandomCapsPath(); - response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/"; - - // Notify the target of an incoming user - Console.WriteLine("Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")"); - - // Prepare notification - Hashtable SimParams = new Hashtable(); - SimParams["session_id"] = theUser.currentAgent.sessionID.ToString(); - SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString(); - SimParams["firstname"] = theUser.username; - SimParams["lastname"] = theUser.surname; - SimParams["agent_id"] = theUser.UUID.ToString(); - SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode); - SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString(); - SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString(); - SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString(); - SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString(); - SimParams["caps_path"] = capsPath; - ArrayList SendParams = new ArrayList(); - SendParams.Add(SimParams); - - // Update agent with target sim - theUser.currentAgent.currentRegion = SimInfo.UUID; - theUser.currentAgent.currentHandle = SimInfo.regionHandle; - - System.Console.WriteLine("Informing region --> " + SimInfo.httpServerURI); - // Send - XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); - XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 3000); - } - } -} - +using System; +using System.Collections; +using System.Net; +using Nwc.XmlRpc; +using OpenSim.Framework.Data; +using OpenSim.Framework.UserManagement; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Configuration; + +namespace OpenSim.Grid.UserServer +{ + public class UserLoginService : LoginService + { + public UserConfig m_config; + + public UserLoginService(UserManagerBase userManager, UserConfig config, string welcomeMess) + : base(userManager, welcomeMess) + { + m_config = config; + } + + /// + /// Customises the login response and fills in missing values. + /// + /// The existing response + /// The user profile + public override void CustomiseResponse(LoginResponse response, UserProfileData theUser) + { + // Load information from the gridserver + SimProfileData SimInfo = new SimProfileData(); + SimInfo = SimInfo.RequestSimProfileData(theUser.currentAgent.currentHandle, m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); + + // Customise the response + // Home Location + response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * 256).ToString() + ",r" + (SimInfo.regionLocY * 256).ToString() + "], " + + "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + + "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; + + // Destination + Console.WriteLine("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + SimInfo.regionLocY); + response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString(); + response.SimPort = (Int32)SimInfo.serverPort; + response.RegionX = SimInfo.regionLocX; + response.RegionY = SimInfo.regionLocY; + + //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI + string capsPath = Util.GetRandomCapsPath(); + response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/"; + + // Notify the target of an incoming user + Console.WriteLine("Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")"); + + // Prepare notification + Hashtable SimParams = new Hashtable(); + SimParams["session_id"] = theUser.currentAgent.sessionID.ToString(); + SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString(); + SimParams["firstname"] = theUser.username; + SimParams["lastname"] = theUser.surname; + SimParams["agent_id"] = theUser.UUID.ToString(); + SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode); + SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString(); + SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString(); + SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString(); + SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString(); + SimParams["caps_path"] = capsPath; + ArrayList SendParams = new ArrayList(); + SendParams.Add(SimParams); + + // Update agent with target sim + theUser.currentAgent.currentRegion = SimInfo.UUID; + theUser.currentAgent.currentHandle = SimInfo.regionHandle; + + System.Console.WriteLine("Informing region --> " + SimInfo.httpServerURI); + // Send + XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); + XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 3000); + } + } +} + diff --git a/OpenSim/Region/Communications/Local/LocalInventoryService.cs b/OpenSim/Region/Communications/Local/LocalInventoryService.cs index af58d33286..b8f57f644b 100644 --- a/OpenSim/Region/Communications/Local/LocalInventoryService.cs +++ b/OpenSim/Region/Communications/Local/LocalInventoryService.cs @@ -1,72 +1,72 @@ -using System; -using System.Collections.Generic; -using libsecondlife; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Data; -using OpenSim.Framework.Types; -using OpenSim.Framework.UserManagement; -using OpenSim.Framework.Utilities; -using OpenSim.Framework.InventoryServiceBase; -using InventoryFolder = OpenSim.Framework.Communications.Caches.InventoryFolder; - -namespace OpenSim.Region.Communications.Local -{ - public class LocalInventoryService : InventoryServiceBase , IInventoryServices - { - - public LocalInventoryService() - { - - } - - public void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack) - { - List folders = this.RequestFirstLevelFolders(userID); - InventoryFolder rootFolder = null; - - //need to make sure we send root folder first - foreach (InventoryFolderBase folder in folders) - { - if (folder.parentID == libsecondlife.LLUUID.Zero) - { - InventoryFolder newfolder = new InventoryFolder(folder); - rootFolder = newfolder; - folderCallBack(userID, newfolder); - } - } - - if (rootFolder != null) - { - foreach (InventoryFolderBase folder in folders) - { - if (folder.folderID != rootFolder.folderID) - { - InventoryFolder newfolder = new InventoryFolder(folder); - folderCallBack(userID, newfolder); - - List items = this.RequestFolderItems(newfolder.folderID); - foreach (InventoryItemBase item in items) - { - itemCallBack(userID, item); - } - } - } - } - } - - public void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder) - { - this.AddFolder(folder); - } - - public void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) - { - this.AddItem(item); - } - - public void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) - { - this.deleteItem(item); - } - } -} +using System; +using System.Collections.Generic; +using libsecondlife; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Data; +using OpenSim.Framework.Types; +using OpenSim.Framework.UserManagement; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.InventoryServiceBase; +using InventoryFolder = OpenSim.Framework.Communications.Caches.InventoryFolder; + +namespace OpenSim.Region.Communications.Local +{ + public class LocalInventoryService : InventoryServiceBase , IInventoryServices + { + + public LocalInventoryService() + { + + } + + public void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack) + { + List folders = this.RequestFirstLevelFolders(userID); + InventoryFolder rootFolder = null; + + //need to make sure we send root folder first + foreach (InventoryFolderBase folder in folders) + { + if (folder.parentID == libsecondlife.LLUUID.Zero) + { + InventoryFolder newfolder = new InventoryFolder(folder); + rootFolder = newfolder; + folderCallBack(userID, newfolder); + } + } + + if (rootFolder != null) + { + foreach (InventoryFolderBase folder in folders) + { + if (folder.folderID != rootFolder.folderID) + { + InventoryFolder newfolder = new InventoryFolder(folder); + folderCallBack(userID, newfolder); + + List items = this.RequestFolderItems(newfolder.folderID); + foreach (InventoryItemBase item in items) + { + itemCallBack(userID, item); + } + } + } + } + } + + public void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder) + { + this.AddFolder(folder); + } + + public void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) + { + this.AddItem(item); + } + + public void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) + { + this.deleteItem(item); + } + } +} diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs index c4616613ff..3c43d29008 100644 --- a/OpenSim/Region/Communications/Local/LocalLoginService.cs +++ b/OpenSim/Region/Communications/Local/LocalLoginService.cs @@ -1,166 +1,166 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using libsecondlife; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Data; -using OpenSim.Framework.Types; -using OpenSim.Framework.UserManagement; -using OpenSim.Framework.Utilities; -using OpenSim.Framework.Inventory; - -namespace OpenSim.Region.Communications.Local -{ - public class LocalLoginService : LoginService - { - private CommunicationsLocal m_Parent; - - private NetworkServersInfo serversInfo; - private uint defaultHomeX; - private uint defaultHomeY; - private bool authUsers = false; - - public LocalLoginService(UserManagerBase userManager, string welcomeMess, CommunicationsLocal parent, NetworkServersInfo serversInfo, bool authenticate) - : base(userManager, welcomeMess) - { - m_Parent = parent; - this.serversInfo = serversInfo; - defaultHomeX = this.serversInfo.DefaultHomeLocX; - defaultHomeY = this.serversInfo.DefaultHomeLocY; - this.authUsers = authenticate; - } - - - public override UserProfileData GetTheUser(string firstname, string lastname) - { - UserProfileData profile = this.m_userManager.getUserProfile(firstname, lastname); - if (profile != null) - { - - return profile; - } - - if (!authUsers) - { - //no current user account so make one - Console.WriteLine("No User account found so creating a new one "); - this.m_userManager.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY); - - profile = this.m_userManager.getUserProfile(firstname, lastname); - if (profile != null) - { - m_Parent.InvenServices.CreateNewUserInventory(profile.UUID); - } - - return profile; - } - return null; - } - - public override bool AuthenticateUser(UserProfileData profile, string password) - { - if (!authUsers) - { - //for now we will accept any password in sandbox mode - Console.WriteLine("authorising user"); - return true; - } - else - { - Console.WriteLine("Authenticating " + profile.username + " " + profile.surname); - - password = password.Remove(0, 3); //remove $1$ - - string s = Util.Md5Hash(password + ":" + profile.passwordSalt); - - return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); - } - } - - public override void CustomiseResponse(LoginResponse response, UserProfileData theUser) - { - ulong currentRegion = theUser.currentAgent.currentHandle; - RegionInfo reg = m_Parent.GridServer.RequestNeighbourInfo(currentRegion); - - if (reg != null) - { - response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " + - "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + - "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; - string capsPath = Util.GetRandomCapsPath(); - response.SimAddress = reg.ExternalEndPoint.Address.ToString(); - response.SimPort = (Int32)reg.ExternalEndPoint.Port; - response.RegionX = reg.RegionLocX; - response.RegionY = reg.RegionLocY; - - response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/"; - // response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CapsSeed/" + capsPath + "0000/"; - theUser.currentAgent.currentRegion = reg.SimUUID; - theUser.currentAgent.currentHandle = reg.RegionHandle; - - Login _login = new Login(); - //copy data to login object - _login.First = response.Firstname; - _login.Last = response.Lastname; - _login.Agent = response.AgentID; - _login.Session = response.SessionID; - _login.SecureSession = response.SecureSessionID; - _login.CircuitCode = (uint)response.CircuitCode; - _login.CapsPath = capsPath; - - m_Parent.InformRegionOfLogin(currentRegion, _login); - } - else - { - Console.WriteLine("not found region " + currentRegion); - } - - } - - protected override InventoryData CreateInventoryData(LLUUID userID) - { - List folders = this.m_Parent.InvenServices.RequestFirstLevelFolders(userID); - if (folders.Count > 0) - { - LLUUID rootID = LLUUID.Zero; - ArrayList AgentInventoryArray = new ArrayList(); - Hashtable TempHash; - foreach (InventoryFolderBase InvFolder in folders) - { - if (InvFolder.parentID == LLUUID.Zero) - { - rootID = InvFolder.folderID; - } - TempHash = new Hashtable(); - TempHash["name"] = InvFolder.name; - TempHash["parent_id"] = InvFolder.parentID.ToStringHyphenated(); - TempHash["version"] = (Int32)InvFolder.version; - TempHash["type_default"] = (Int32)InvFolder.type; - TempHash["folder_id"] = InvFolder.folderID.ToStringHyphenated(); - AgentInventoryArray.Add(TempHash); - } - return new InventoryData(AgentInventoryArray, rootID); - } - else - { - AgentInventory userInventory = new AgentInventory(); - userInventory.CreateRootFolder(userID, false); - - ArrayList AgentInventoryArray = new ArrayList(); - Hashtable TempHash; - foreach (OpenSim.Framework.Inventory.InventoryFolder InvFolder in userInventory.InventoryFolders.Values) - { - TempHash = new Hashtable(); - TempHash["name"] = InvFolder.FolderName; - TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); - TempHash["version"] = (Int32)InvFolder.Version; - TempHash["type_default"] = (Int32)InvFolder.DefaultType; - TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); - AgentInventoryArray.Add(TempHash); - } - - return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); - } - } - } -} +using System; +using System.Collections; +using System.Collections.Generic; +using libsecondlife; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Data; +using OpenSim.Framework.Types; +using OpenSim.Framework.UserManagement; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Inventory; + +namespace OpenSim.Region.Communications.Local +{ + public class LocalLoginService : LoginService + { + private CommunicationsLocal m_Parent; + + private NetworkServersInfo serversInfo; + private uint defaultHomeX; + private uint defaultHomeY; + private bool authUsers = false; + + public LocalLoginService(UserManagerBase userManager, string welcomeMess, CommunicationsLocal parent, NetworkServersInfo serversInfo, bool authenticate) + : base(userManager, welcomeMess) + { + m_Parent = parent; + this.serversInfo = serversInfo; + defaultHomeX = this.serversInfo.DefaultHomeLocX; + defaultHomeY = this.serversInfo.DefaultHomeLocY; + this.authUsers = authenticate; + } + + + public override UserProfileData GetTheUser(string firstname, string lastname) + { + UserProfileData profile = this.m_userManager.getUserProfile(firstname, lastname); + if (profile != null) + { + + return profile; + } + + if (!authUsers) + { + //no current user account so make one + Console.WriteLine("No User account found so creating a new one "); + this.m_userManager.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY); + + profile = this.m_userManager.getUserProfile(firstname, lastname); + if (profile != null) + { + m_Parent.InvenServices.CreateNewUserInventory(profile.UUID); + } + + return profile; + } + return null; + } + + public override bool AuthenticateUser(UserProfileData profile, string password) + { + if (!authUsers) + { + //for now we will accept any password in sandbox mode + Console.WriteLine("authorising user"); + return true; + } + else + { + Console.WriteLine("Authenticating " + profile.username + " " + profile.surname); + + password = password.Remove(0, 3); //remove $1$ + + string s = Util.Md5Hash(password + ":" + profile.passwordSalt); + + return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); + } + } + + public override void CustomiseResponse(LoginResponse response, UserProfileData theUser) + { + ulong currentRegion = theUser.currentAgent.currentHandle; + RegionInfo reg = m_Parent.GridServer.RequestNeighbourInfo(currentRegion); + + if (reg != null) + { + response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " + + "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + + "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; + string capsPath = Util.GetRandomCapsPath(); + response.SimAddress = reg.ExternalEndPoint.Address.ToString(); + response.SimPort = (Int32)reg.ExternalEndPoint.Port; + response.RegionX = reg.RegionLocX; + response.RegionY = reg.RegionLocY; + + response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/"; + // response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CapsSeed/" + capsPath + "0000/"; + theUser.currentAgent.currentRegion = reg.SimUUID; + theUser.currentAgent.currentHandle = reg.RegionHandle; + + Login _login = new Login(); + //copy data to login object + _login.First = response.Firstname; + _login.Last = response.Lastname; + _login.Agent = response.AgentID; + _login.Session = response.SessionID; + _login.SecureSession = response.SecureSessionID; + _login.CircuitCode = (uint)response.CircuitCode; + _login.CapsPath = capsPath; + + m_Parent.InformRegionOfLogin(currentRegion, _login); + } + else + { + Console.WriteLine("not found region " + currentRegion); + } + + } + + protected override InventoryData CreateInventoryData(LLUUID userID) + { + List folders = this.m_Parent.InvenServices.RequestFirstLevelFolders(userID); + if (folders.Count > 0) + { + LLUUID rootID = LLUUID.Zero; + ArrayList AgentInventoryArray = new ArrayList(); + Hashtable TempHash; + foreach (InventoryFolderBase InvFolder in folders) + { + if (InvFolder.parentID == LLUUID.Zero) + { + rootID = InvFolder.folderID; + } + TempHash = new Hashtable(); + TempHash["name"] = InvFolder.name; + TempHash["parent_id"] = InvFolder.parentID.ToStringHyphenated(); + TempHash["version"] = (Int32)InvFolder.version; + TempHash["type_default"] = (Int32)InvFolder.type; + TempHash["folder_id"] = InvFolder.folderID.ToStringHyphenated(); + AgentInventoryArray.Add(TempHash); + } + return new InventoryData(AgentInventoryArray, rootID); + } + else + { + AgentInventory userInventory = new AgentInventory(); + userInventory.CreateRootFolder(userID, false); + + ArrayList AgentInventoryArray = new ArrayList(); + Hashtable TempHash; + foreach (OpenSim.Framework.Inventory.InventoryFolder InvFolder in userInventory.InventoryFolders.Values) + { + TempHash = new Hashtable(); + TempHash["name"] = InvFolder.FolderName; + TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); + TempHash["version"] = (Int32)InvFolder.Version; + TempHash["type_default"] = (Int32)InvFolder.DefaultType; + TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); + AgentInventoryArray.Add(TempHash); + } + + return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); + } + } + } +} diff --git a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs index 70ab75ea6c..1428639177 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs @@ -1,38 +1,38 @@ -using System; -using System.Collections.Generic; -using libsecondlife; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Data; -using InventoryFolder = OpenSim.Framework.Communications.Caches.InventoryFolder; - -namespace OpenSim.Region.Communications.OGS1 -{ - public class OGS1InventoryService : IInventoryServices - { - - public OGS1InventoryService() - { - - } - - public void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack) - { - - } - - public void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder) - { - - } - - public void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) - { - - } - - public void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) - { - - } - } -} +using System; +using System.Collections.Generic; +using libsecondlife; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Data; +using InventoryFolder = OpenSim.Framework.Communications.Caches.InventoryFolder; + +namespace OpenSim.Region.Communications.OGS1 +{ + public class OGS1InventoryService : IInventoryServices + { + + public OGS1InventoryService() + { + + } + + public void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack) + { + + } + + public void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder) + { + + } + + public void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) + { + + } + + public void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) + { + + } + } +} diff --git a/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs b/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs index 8fdfa8fb5b..727b3868bd 100644 --- a/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs +++ b/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs @@ -1,27 +1,27 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.IO; -using libsecondlife; - -namespace OpenSim.Region.Environment.Interfaces -{ - public interface IDynamicTextureManager - { - void RegisterRender(string handleType, IDynamicTextureRender render); - void ReturnData(LLUUID id, byte[] data); - LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, string extraParams, int updateTimer); - LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, string extraParams, int updateTimer); - } - - public interface IDynamicTextureRender - { - string GetName(); - string GetContentType(); - bool SupportsAsynchronous(); - byte[] ConvertUrl(string url, string extraParams); - byte[] ConvertStream(Stream data, string extraParams); - bool AsyncConvertUrl(LLUUID id, string url, string extraParams); - bool AsyncConvertData(LLUUID id, string bodyData, string extraParams); - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using libsecondlife; + +namespace OpenSim.Region.Environment.Interfaces +{ + public interface IDynamicTextureManager + { + void RegisterRender(string handleType, IDynamicTextureRender render); + void ReturnData(LLUUID id, byte[] data); + LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, string extraParams, int updateTimer); + LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, string extraParams, int updateTimer); + } + + public interface IDynamicTextureRender + { + string GetName(); + string GetContentType(); + bool SupportsAsynchronous(); + byte[] ConvertUrl(string url, string extraParams); + byte[] ConvertStream(Stream data, string extraParams); + bool AsyncConvertUrl(LLUUID id, string url, string extraParams); + bool AsyncConvertData(LLUUID id, string bodyData, string extraParams); + } +} diff --git a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs index 2294631db4..e974e253d6 100644 --- a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs +++ b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs @@ -1,12 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; - -namespace OpenSim.Region.Environment.Interfaces -{ - public interface IHttpRequests - { - LLUUID MakeHttpRequest(string url, string type, string body); - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Region.Environment.Interfaces +{ + public interface IHttpRequests + { + LLUUID MakeHttpRequest(string url, string type, string body); + } +} diff --git a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs index 11989fe355..47f3d92178 100644 --- a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs +++ b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs @@ -1,15 +1,15 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Environment.Interfaces -{ - public interface IRegionModule - { - void Initialise(Scenes.Scene scene); - void PostInitialise(); - void CloseDown(); - string GetName(); - bool IsSharedModule(); - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.Environment.Interfaces +{ + public interface IRegionModule + { + void Initialise(Scenes.Scene scene); + void PostInitialise(); + void CloseDown(); + string GetName(); + bool IsSharedModule(); + } +} diff --git a/OpenSim/Region/Environment/Interfaces/ISimChat.cs b/OpenSim/Region/Environment/Interfaces/ISimChat.cs index 73ef476ec7..f0adabc540 100644 --- a/OpenSim/Region/Environment/Interfaces/ISimChat.cs +++ b/OpenSim/Region/Environment/Interfaces/ISimChat.cs @@ -1,12 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; - -namespace OpenSim.Region.Environment.Interfaces -{ - public interface ISimChat - { - void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, LLUUID fromAgentID); - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Region.Environment.Interfaces +{ + public interface ISimChat + { + void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, LLUUID fromAgentID); + } +} diff --git a/OpenSim/Region/Environment/Interfaces/ITerrain.cs b/OpenSim/Region/Environment/Interfaces/ITerrain.cs index a07168e77d..576c5b4a83 100644 --- a/OpenSim/Region/Environment/Interfaces/ITerrain.cs +++ b/OpenSim/Region/Environment/Interfaces/ITerrain.cs @@ -1,46 +1,46 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Framework.Interfaces; - -namespace OpenSim.Region.Environment.Interfaces -{ - public interface ITerrain - { - bool Tainted(); - bool Tainted(int x, int y); - void ResetTaint(); - void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, IClientAPI remoteUser); - void CheckHeightValues(); - float[] GetHeights1D(); - float[,] GetHeights2D(); - double[,] GetHeights2DD(); - void GetHeights1D(float[] heights); - void SetHeights2D(float[,] heights); - void SetHeights2D(double[,] heights); - void SwapRevertMaps(); - void SaveRevertMap(); - bool RunTerrainCmd(string[] args, ref string resultText, string simName); - void SetRange(float min, float max); - void LoadFromFileF64(string filename); - void LoadFromFileF32(string filename); - void LoadFromFileF32(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY); - void LoadFromFileIMG(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY); - void LoadFromFileSLRAW(string filename); - void WriteToFileF64(string filename); - void WriteToFileF32(string filename); - void WriteToFileRAW(string filename); - void WriteToFileHiRAW(string filename); - void SetSeed(int val); - void RaiseTerrain(double rx, double ry, double size, double amount); - void LowerTerrain(double rx, double ry, double size, double amount); - void FlattenTerrain(double rx, double ry, double size, double amount); - void NoiseTerrain(double rx, double ry, double size, double amount); - void RevertTerrain(double rx, double ry, double size, double amount); - void SmoothTerrain(double rx, double ry, double size, double amount); - void HillsGenerator(); - double GetHeight(int x, int y); - void ExportImage(string filename, string gradientmap); - byte[] ExportJpegImage(string gradientmap); - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Interfaces; + +namespace OpenSim.Region.Environment.Interfaces +{ + public interface ITerrain + { + bool Tainted(); + bool Tainted(int x, int y); + void ResetTaint(); + void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, IClientAPI remoteUser); + void CheckHeightValues(); + float[] GetHeights1D(); + float[,] GetHeights2D(); + double[,] GetHeights2DD(); + void GetHeights1D(float[] heights); + void SetHeights2D(float[,] heights); + void SetHeights2D(double[,] heights); + void SwapRevertMaps(); + void SaveRevertMap(); + bool RunTerrainCmd(string[] args, ref string resultText, string simName); + void SetRange(float min, float max); + void LoadFromFileF64(string filename); + void LoadFromFileF32(string filename); + void LoadFromFileF32(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY); + void LoadFromFileIMG(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY); + void LoadFromFileSLRAW(string filename); + void WriteToFileF64(string filename); + void WriteToFileF32(string filename); + void WriteToFileRAW(string filename); + void WriteToFileHiRAW(string filename); + void SetSeed(int val); + void RaiseTerrain(double rx, double ry, double size, double amount); + void LowerTerrain(double rx, double ry, double size, double amount); + void FlattenTerrain(double rx, double ry, double size, double amount); + void NoiseTerrain(double rx, double ry, double size, double amount); + void RevertTerrain(double rx, double ry, double size, double amount); + void SmoothTerrain(double rx, double ry, double size, double amount); + void HillsGenerator(); + double GetHeight(int x, int y); + void ExportImage(string filename, string gradientmap); + byte[] ExportJpegImage(string gradientmap); + } +} diff --git a/OpenSim/Region/Environment/Interfaces/IXfer.cs b/OpenSim/Region/Environment/Interfaces/IXfer.cs index a19ba8dfd3..7482ec0ba5 100644 --- a/OpenSim/Region/Environment/Interfaces/IXfer.cs +++ b/OpenSim/Region/Environment/Interfaces/IXfer.cs @@ -1,11 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Environment.Interfaces -{ - public interface IXfer - { - bool AddNewFile(string fileName, byte[] data); - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.Environment.Interfaces +{ + public interface IXfer + { + bool AddNewFile(string fileName, byte[] data); + } +} diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs index ea416cb535..5e27f50c95 100644 --- a/OpenSim/Region/Environment/ModuleLoader.cs +++ b/OpenSim/Region/Environment/ModuleLoader.cs @@ -1,160 +1,160 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Text; -using OpenSim.Framework.Console; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Modules; - -namespace OpenSim.Region.Environment -{ - public class ModuleLoader - { - - public Dictionary LoadedAssemblys = new Dictionary(); - - public List LoadedModules = new List(); - public Dictionary LoadedSharedModules = new Dictionary(); - - public ModuleLoader() - { - - } - - /// - /// Should have a module factory? - /// - /// - public void CreateDefaultModules(Scene scene, string exceptModules) - { - IRegionModule module = new XferModule(); - InitialiseModule(module, scene); - - module = new ChatModule(); - InitialiseModule(module, scene); - - module = new AvatarProfilesModule(); - InitialiseModule(module, scene); - - this.LoadRegionModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene); - - string lslPath = System.IO.Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine.DotNetEngine.dll"); - this.LoadRegionModule(lslPath, "LSLScriptingModule", scene); - - } - - - public void LoadDefaultSharedModules(string exceptModules) - { - DynamicTextureModule dynamicModule = new DynamicTextureModule(); - this.LoadedSharedModules.Add(dynamicModule.GetName(), dynamicModule); - } - - public void InitialiseSharedModules(Scene scene) - { - foreach (IRegionModule module in this.LoadedSharedModules.Values) - { - module.Initialise(scene); - scene.AddModule(module.GetName(), module); //should be doing this? - } - } - - private void InitialiseModule(IRegionModule module, Scene scene) - { - module.Initialise(scene); - scene.AddModule(module.GetName(), module); - LoadedModules.Add(module); - } - - /// - /// Loads/initialises a Module instance that can be used by mutliple Regions - /// - /// - /// - /// - public void LoadSharedModule(string dllName, string moduleName) - { - IRegionModule module = this.LoadModule(dllName, moduleName); - if (module != null) - { - this.LoadedSharedModules.Add(module.GetName(), module); - } - } - - public void LoadRegionModule(string dllName, string moduleName, Scene scene) - { - IRegionModule module = this.LoadModule(dllName, moduleName); - if (module != null) - { - this.InitialiseModule(module, scene); - } - } - - /// - /// Loads a external Module (if not already loaded) and creates a new instance of it. - /// - /// - /// - /// - public IRegionModule LoadModule(string dllName, string moduleName) - { - Assembly pluginAssembly = null; - if (LoadedAssemblys.ContainsKey(dllName)) - { - pluginAssembly = LoadedAssemblys[dllName]; - } - else - { - pluginAssembly = Assembly.LoadFrom(dllName); - this.LoadedAssemblys.Add(dllName, pluginAssembly); - } - - IRegionModule module = null; - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (pluginType.IsPublic) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IRegionModule", true); - - if (typeInterface != null) - { - module = (IRegionModule)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - break; - } - typeInterface = null; - } - } - } - pluginAssembly = null; - - if ((module != null ) || (module.GetName() == moduleName)) - { - return module; - } - - return null; - - } - - public void PostInitialise() - { - foreach (IRegionModule module in this.LoadedSharedModules.Values) - { - module.PostInitialise(); - } - - foreach (IRegionModule module in this.LoadedModules) - { - module.PostInitialise(); - } - } - - public void ClearCache() - { - this.LoadedAssemblys.Clear(); - } - } -} +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using OpenSim.Framework.Console; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Modules; + +namespace OpenSim.Region.Environment +{ + public class ModuleLoader + { + + public Dictionary LoadedAssemblys = new Dictionary(); + + public List LoadedModules = new List(); + public Dictionary LoadedSharedModules = new Dictionary(); + + public ModuleLoader() + { + + } + + /// + /// Should have a module factory? + /// + /// + public void CreateDefaultModules(Scene scene, string exceptModules) + { + IRegionModule module = new XferModule(); + InitialiseModule(module, scene); + + module = new ChatModule(); + InitialiseModule(module, scene); + + module = new AvatarProfilesModule(); + InitialiseModule(module, scene); + + this.LoadRegionModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene); + + string lslPath = System.IO.Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine.DotNetEngine.dll"); + this.LoadRegionModule(lslPath, "LSLScriptingModule", scene); + + } + + + public void LoadDefaultSharedModules(string exceptModules) + { + DynamicTextureModule dynamicModule = new DynamicTextureModule(); + this.LoadedSharedModules.Add(dynamicModule.GetName(), dynamicModule); + } + + public void InitialiseSharedModules(Scene scene) + { + foreach (IRegionModule module in this.LoadedSharedModules.Values) + { + module.Initialise(scene); + scene.AddModule(module.GetName(), module); //should be doing this? + } + } + + private void InitialiseModule(IRegionModule module, Scene scene) + { + module.Initialise(scene); + scene.AddModule(module.GetName(), module); + LoadedModules.Add(module); + } + + /// + /// Loads/initialises a Module instance that can be used by mutliple Regions + /// + /// + /// + /// + public void LoadSharedModule(string dllName, string moduleName) + { + IRegionModule module = this.LoadModule(dllName, moduleName); + if (module != null) + { + this.LoadedSharedModules.Add(module.GetName(), module); + } + } + + public void LoadRegionModule(string dllName, string moduleName, Scene scene) + { + IRegionModule module = this.LoadModule(dllName, moduleName); + if (module != null) + { + this.InitialiseModule(module, scene); + } + } + + /// + /// Loads a external Module (if not already loaded) and creates a new instance of it. + /// + /// + /// + /// + public IRegionModule LoadModule(string dllName, string moduleName) + { + Assembly pluginAssembly = null; + if (LoadedAssemblys.ContainsKey(dllName)) + { + pluginAssembly = LoadedAssemblys[dllName]; + } + else + { + pluginAssembly = Assembly.LoadFrom(dllName); + this.LoadedAssemblys.Add(dllName, pluginAssembly); + } + + IRegionModule module = null; + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IRegionModule", true); + + if (typeInterface != null) + { + module = (IRegionModule)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + break; + } + typeInterface = null; + } + } + } + pluginAssembly = null; + + if ((module != null ) || (module.GetName() == moduleName)) + { + return module; + } + + return null; + + } + + public void PostInitialise() + { + foreach (IRegionModule module in this.LoadedSharedModules.Values) + { + module.PostInitialise(); + } + + foreach (IRegionModule module in this.LoadedModules) + { + module.PostInitialise(); + } + } + + public void ClearCache() + { + this.LoadedAssemblys.Clear(); + } + } +} diff --git a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs index 21a7e61a9e..7a53f6ff5c 100644 --- a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs @@ -1,50 +1,50 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - - -namespace OpenSim.Region.Environment.Modules -{ - public class AssetDownloadModule : IRegionModule - { - private Scene m_scene; - - public AssetDownloadModule() - { - - } - - public void Initialise(Scene scene) - { - m_scene = scene; - m_scene.EventManager.OnNewClient += NewClient; - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - } - - public string GetName() - { - return "AssetDownloadModule"; - } - - public bool IsSharedModule() - { - return false; - } - - public void NewClient(IClientAPI client) - { - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; + + +namespace OpenSim.Region.Environment.Modules +{ + public class AssetDownloadModule : IRegionModule + { + private Scene m_scene; + + public AssetDownloadModule() + { + + } + + public void Initialise(Scene scene) + { + m_scene = scene; + m_scene.EventManager.OnNewClient += NewClient; + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + } + + public string GetName() + { + return "AssetDownloadModule"; + } + + public bool IsSharedModule() + { + return false; + } + + public void NewClient(IClientAPI client) + { + } + } +} diff --git a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs index 1ad061ae2d..c349888e71 100644 --- a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs +++ b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs @@ -1,71 +1,71 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - -namespace OpenSim.Region.Environment.Modules -{ - public class AvatarProfilesModule :IRegionModule - { - - private Scene m_scene; - - public AvatarProfilesModule() - { - - } - - public void Initialise(Scene scene) - { - m_scene = scene; - m_scene.EventManager.OnNewClient += NewClient; - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - - } - - public string GetName() - { - return "AvatarProfilesModule"; - } - - public bool IsSharedModule() - { - return false; - } - - public void NewClient(IClientAPI client) - { - client.OnRequestAvatarProperties += RequestAvatarProperty; - } - - public void RemoveClient(IClientAPI client) - { - client.OnRequestAvatarProperties -= RequestAvatarProperty; - } - - /// - /// - /// - /// - /// - public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID) - { - string about = "OpenSim crash test dummy"; - string bornOn = "Before now"; - string flAbout = "First life? What is one of those? OpenSim is my life!"; - LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000"); - remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "", partner); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; + +namespace OpenSim.Region.Environment.Modules +{ + public class AvatarProfilesModule :IRegionModule + { + + private Scene m_scene; + + public AvatarProfilesModule() + { + + } + + public void Initialise(Scene scene) + { + m_scene = scene; + m_scene.EventManager.OnNewClient += NewClient; + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + + } + + public string GetName() + { + return "AvatarProfilesModule"; + } + + public bool IsSharedModule() + { + return false; + } + + public void NewClient(IClientAPI client) + { + client.OnRequestAvatarProperties += RequestAvatarProperty; + } + + public void RemoveClient(IClientAPI client) + { + client.OnRequestAvatarProperties -= RequestAvatarProperty; + } + + /// + /// + /// + /// + /// + public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID) + { + string about = "OpenSim crash test dummy"; + string bornOn = "Before now"; + string flAbout = "First life? What is one of those? OpenSim is my life!"; + LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000"); + remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "", partner); + } + } +} diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index a46343b911..8d3a5536ff 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs @@ -1,216 +1,216 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Net; -using System.Net.Sockets; -using System.Threading; -using System.IO; -using libsecondlife; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Utilities; -using OpenSim.Framework.Console; - -namespace OpenSim.Region.Environment.Modules -{ - public class ChatModule : IRegionModule, ISimChat - { - private Scene m_scene; - - private string m_server = "irc2.choopa.net"; - - // private int m_port = 6668; - //private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot"; - private string m_nick = "OSimBot"; - private string m_channel = "#opensim"; - - // private NetworkStream m_stream; - private TcpClient m_irc; - private StreamWriter m_ircWriter; - private StreamReader m_ircReader; - - // private Thread pingSender; - // private Thread listener; - - private bool connected = false; - - public ChatModule() - { - m_nick = "OSimBot" + Util.RandomClass.Next(1, 99); - m_irc = null; - m_ircWriter = null; - m_ircReader = null; - } - - public void Initialise(Scene scene) - { - m_scene = scene; - m_scene.EventManager.OnNewClient += NewClient; - - m_scene.RegisterModuleInterface(this); - } - - public void PostInitialise() - { - /* - try - { - m_irc = new TcpClient(m_server, m_port); - m_stream = m_irc.GetStream(); - m_ircReader = new StreamReader(m_stream); - m_ircWriter = new StreamWriter(m_stream); - - pingSender = new Thread(new ThreadStart(this.PingRun)); - pingSender.Start(); - - listener = new Thread(new ThreadStart(this.ListenerRun)); - listener.Start(); - - m_ircWriter.WriteLine(m_user); - m_ircWriter.Flush(); - m_ircWriter.WriteLine("NICK " + m_nick); - m_ircWriter.Flush(); - m_ircWriter.WriteLine("JOIN " + m_channel); - m_ircWriter.Flush(); - connected = true; - } - catch (Exception e) - { - Console.WriteLine(e.ToString()); - } - */ - } - - public void CloseDown() - { - m_ircWriter.Close(); - m_ircReader.Close(); - m_irc.Close(); - } - - public string GetName() - { - return "ChatModule"; - } - - public bool IsSharedModule() - { - return false; - } - - public void NewClient(IClientAPI client) - { - client.OnChatFromViewer += SimChat; - } - - public void PingRun() - { - while (true) - { - m_ircWriter.WriteLine("PING :" + m_server); - m_ircWriter.Flush(); - Thread.Sleep(15000); - } - } - - public void ListenerRun() - { - string inputLine; - LLVector3 pos = new LLVector3(128, 128, 20); - while (true) - { - while ((inputLine = m_ircReader.ReadLine()) != null) - { - Console.WriteLine(inputLine); - if (inputLine.Contains(m_channel)) - { - string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); - m_scene.ForEachScenePresence(delegate(ScenePresence presence) - { - presence.ControllingClient.SendChatMessage(Helpers.StringToField(mess), 255, pos, "IRC:", - LLUUID.Zero); - }); - } - } - } - } - - public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, LLUUID fromAgentID) - { - ScenePresence avatar = null; - avatar = m_scene.RequestAvatar(fromAgentID); - if (avatar != null) - { - fromPos = avatar.AbsolutePosition; - fromName = avatar.Firstname + " " + avatar.Lastname; - avatar = null; - } - - if (connected) - { - m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " + - Util.FieldToString(message)); - m_ircWriter.Flush(); - } - - if (channel == 0) - { - m_scene.ForEachScenePresence(delegate(ScenePresence presence) - { - int dis = -1000; - - //err ??? the following code seems to be request a scenePresence when it already has a ref to it - avatar = m_scene.RequestAvatar(presence.ControllingClient.AgentId); - if (avatar != null) - { - dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos); - } - - switch (type) - { - case 0: // Whisper - if ((dis < 10) && (dis > -10)) - { - //should change so the message is sent through the avatar rather than direct to the ClientView - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - case 1: // Say - if ((dis < 30) && (dis > -30)) - { - //Console.WriteLine("sending chat"); - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - case 2: // Shout - if ((dis < 100) && (dis > -100)) - { - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - - case 0xff: // Broadcast - presence.ControllingClient.SendChatMessage(message, type, - fromPos, - fromName, - fromAgentID); - break; - } - }); - } - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Net; +using System.Net.Sockets; +using System.Threading; +using System.IO; +using libsecondlife; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Console; + +namespace OpenSim.Region.Environment.Modules +{ + public class ChatModule : IRegionModule, ISimChat + { + private Scene m_scene; + + private string m_server = "irc2.choopa.net"; + + // private int m_port = 6668; + //private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot"; + private string m_nick = "OSimBot"; + private string m_channel = "#opensim"; + + // private NetworkStream m_stream; + private TcpClient m_irc; + private StreamWriter m_ircWriter; + private StreamReader m_ircReader; + + // private Thread pingSender; + // private Thread listener; + + private bool connected = false; + + public ChatModule() + { + m_nick = "OSimBot" + Util.RandomClass.Next(1, 99); + m_irc = null; + m_ircWriter = null; + m_ircReader = null; + } + + public void Initialise(Scene scene) + { + m_scene = scene; + m_scene.EventManager.OnNewClient += NewClient; + + m_scene.RegisterModuleInterface(this); + } + + public void PostInitialise() + { + /* + try + { + m_irc = new TcpClient(m_server, m_port); + m_stream = m_irc.GetStream(); + m_ircReader = new StreamReader(m_stream); + m_ircWriter = new StreamWriter(m_stream); + + pingSender = new Thread(new ThreadStart(this.PingRun)); + pingSender.Start(); + + listener = new Thread(new ThreadStart(this.ListenerRun)); + listener.Start(); + + m_ircWriter.WriteLine(m_user); + m_ircWriter.Flush(); + m_ircWriter.WriteLine("NICK " + m_nick); + m_ircWriter.Flush(); + m_ircWriter.WriteLine("JOIN " + m_channel); + m_ircWriter.Flush(); + connected = true; + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + } + */ + } + + public void CloseDown() + { + m_ircWriter.Close(); + m_ircReader.Close(); + m_irc.Close(); + } + + public string GetName() + { + return "ChatModule"; + } + + public bool IsSharedModule() + { + return false; + } + + public void NewClient(IClientAPI client) + { + client.OnChatFromViewer += SimChat; + } + + public void PingRun() + { + while (true) + { + m_ircWriter.WriteLine("PING :" + m_server); + m_ircWriter.Flush(); + Thread.Sleep(15000); + } + } + + public void ListenerRun() + { + string inputLine; + LLVector3 pos = new LLVector3(128, 128, 20); + while (true) + { + while ((inputLine = m_ircReader.ReadLine()) != null) + { + Console.WriteLine(inputLine); + if (inputLine.Contains(m_channel)) + { + string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); + m_scene.ForEachScenePresence(delegate(ScenePresence presence) + { + presence.ControllingClient.SendChatMessage(Helpers.StringToField(mess), 255, pos, "IRC:", + LLUUID.Zero); + }); + } + } + } + } + + public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, LLUUID fromAgentID) + { + ScenePresence avatar = null; + avatar = m_scene.RequestAvatar(fromAgentID); + if (avatar != null) + { + fromPos = avatar.AbsolutePosition; + fromName = avatar.Firstname + " " + avatar.Lastname; + avatar = null; + } + + if (connected) + { + m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " + + Util.FieldToString(message)); + m_ircWriter.Flush(); + } + + if (channel == 0) + { + m_scene.ForEachScenePresence(delegate(ScenePresence presence) + { + int dis = -1000; + + //err ??? the following code seems to be request a scenePresence when it already has a ref to it + avatar = m_scene.RequestAvatar(presence.ControllingClient.AgentId); + if (avatar != null) + { + dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos); + } + + switch (type) + { + case 0: // Whisper + if ((dis < 10) && (dis > -10)) + { + //should change so the message is sent through the avatar rather than direct to the ClientView + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + case 1: // Say + if ((dis < 30) && (dis > -30)) + { + //Console.WriteLine("sending chat"); + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + case 2: // Shout + if ((dis < 100) && (dis > -100)) + { + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + + case 0xff: // Broadcast + presence.ControllingClient.SendChatMessage(message, type, + fromPos, + fromName, + fromAgentID); + break; + } + }); + } + } + } +} diff --git a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs index 8223919f53..bbd981094c 100644 --- a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs +++ b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs @@ -1,159 +1,159 @@ -using System.Text; -using System.Net; -using System.Net.Sockets; -using System.Threading; -using System.IO; -using System.Collections.Generic; -using libsecondlife; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Utilities; -using OpenSim.Framework.Console; -using OpenSim.Framework.Types; - -namespace OpenSim.Region.Environment.Modules -{ - public class DynamicTextureModule :IRegionModule, IDynamicTextureManager - { - private Dictionary RegisteredScenes = new Dictionary(); - private Dictionary RenderPlugins= new Dictionary(); - private Dictionary Updaters = new Dictionary(); - - public void Initialise(Scene scene) - { - if (!RegisteredScenes.ContainsKey(scene.RegionInfo.SimUUID)) - { - RegisteredScenes.Add(scene.RegionInfo.SimUUID, scene); - scene.RegisterModuleInterface(this); - } - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - } - - public string GetName() - { - return "DynamicTextureModule"; - } - - public bool IsSharedModule() - { - return true; - } - - public void RegisterRender(string handleType, IDynamicTextureRender render) - { - if (!RenderPlugins.ContainsKey(handleType)) - { - RenderPlugins.Add(handleType, render); - } - } - - public void ReturnData(LLUUID id, byte[] data) - { - if (Updaters.ContainsKey(id)) - { - DynamicTextureUpdater updater = Updaters[id]; - if (RegisteredScenes.ContainsKey(updater.SimUUID)) - { - Scene scene = RegisteredScenes[updater.SimUUID]; - updater.DataReceived(data, scene); - } - } - } - - public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, string extraParams, int updateTimer) - { - System.Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType); - if (this.RenderPlugins.ContainsKey(contentType)) - { - DynamicTextureUpdater updater = new DynamicTextureUpdater(); - updater.SimUUID = simID; - updater.PrimID = primID; - updater.ContentType = contentType; - updater.Url = url; - updater.UpdateTimer = updateTimer; - updater.UpdaterID = LLUUID.Random(); - updater.Params = extraParams; - - if (!this.Updaters.ContainsKey(updater.UpdaterID)) - { - Updaters.Add(updater.UpdaterID, updater); - } - - RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams); - return updater.UpdaterID; - } - return LLUUID.Zero; - } - - public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, string extraParams, int updateTimer) - { - if (this.RenderPlugins.ContainsKey(contentType)) - { - DynamicTextureUpdater updater = new DynamicTextureUpdater(); - updater.SimUUID = simID; - updater.PrimID = primID; - updater.ContentType = contentType; - updater.BodyData = data; - updater.UpdateTimer = updateTimer; - updater.UpdaterID = LLUUID.Random(); - updater.Params = extraParams; - - if (!this.Updaters.ContainsKey(updater.UpdaterID)) - { - Updaters.Add(updater.UpdaterID, updater); - } - - RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); - return updater.UpdaterID; - } - return LLUUID.Zero; - } - - public class DynamicTextureUpdater - { - public LLUUID SimUUID; - public LLUUID UpdaterID; - public string ContentType; - public string Url; - public string BodyData; - public LLUUID PrimID; - public int UpdateTimer; - public LLUUID LastAssetID; - public string Params; - - public DynamicTextureUpdater() - { - LastAssetID = LLUUID.Zero; - UpdateTimer = 0; - BodyData = null; - } - - public void DataReceived(byte[] data, Scene scene) - { - //TODO delete the last asset(data), if it was a dynamic texture - - AssetBase asset = new AssetBase(); - asset.FullID = LLUUID.Random(); - asset.Data = data; - asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000); - asset.Type = 0; - scene.commsManager.AssetCache.AddAsset(asset); - - this.LastAssetID = asset.FullID; - - SceneObjectPart part = scene.GetSceneObjectPart(PrimID); - part.Shape.TextureEntry = new LLObject.TextureEntry(asset.FullID).ToBytes(); - part.ScheduleFullUpdate(); - } - } - } -} +using System.Text; +using System.Net; +using System.Net.Sockets; +using System.Threading; +using System.IO; +using System.Collections.Generic; +using libsecondlife; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Console; +using OpenSim.Framework.Types; + +namespace OpenSim.Region.Environment.Modules +{ + public class DynamicTextureModule :IRegionModule, IDynamicTextureManager + { + private Dictionary RegisteredScenes = new Dictionary(); + private Dictionary RenderPlugins= new Dictionary(); + private Dictionary Updaters = new Dictionary(); + + public void Initialise(Scene scene) + { + if (!RegisteredScenes.ContainsKey(scene.RegionInfo.SimUUID)) + { + RegisteredScenes.Add(scene.RegionInfo.SimUUID, scene); + scene.RegisterModuleInterface(this); + } + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + } + + public string GetName() + { + return "DynamicTextureModule"; + } + + public bool IsSharedModule() + { + return true; + } + + public void RegisterRender(string handleType, IDynamicTextureRender render) + { + if (!RenderPlugins.ContainsKey(handleType)) + { + RenderPlugins.Add(handleType, render); + } + } + + public void ReturnData(LLUUID id, byte[] data) + { + if (Updaters.ContainsKey(id)) + { + DynamicTextureUpdater updater = Updaters[id]; + if (RegisteredScenes.ContainsKey(updater.SimUUID)) + { + Scene scene = RegisteredScenes[updater.SimUUID]; + updater.DataReceived(data, scene); + } + } + } + + public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, string extraParams, int updateTimer) + { + System.Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType); + if (this.RenderPlugins.ContainsKey(contentType)) + { + DynamicTextureUpdater updater = new DynamicTextureUpdater(); + updater.SimUUID = simID; + updater.PrimID = primID; + updater.ContentType = contentType; + updater.Url = url; + updater.UpdateTimer = updateTimer; + updater.UpdaterID = LLUUID.Random(); + updater.Params = extraParams; + + if (!this.Updaters.ContainsKey(updater.UpdaterID)) + { + Updaters.Add(updater.UpdaterID, updater); + } + + RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams); + return updater.UpdaterID; + } + return LLUUID.Zero; + } + + public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, string extraParams, int updateTimer) + { + if (this.RenderPlugins.ContainsKey(contentType)) + { + DynamicTextureUpdater updater = new DynamicTextureUpdater(); + updater.SimUUID = simID; + updater.PrimID = primID; + updater.ContentType = contentType; + updater.BodyData = data; + updater.UpdateTimer = updateTimer; + updater.UpdaterID = LLUUID.Random(); + updater.Params = extraParams; + + if (!this.Updaters.ContainsKey(updater.UpdaterID)) + { + Updaters.Add(updater.UpdaterID, updater); + } + + RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); + return updater.UpdaterID; + } + return LLUUID.Zero; + } + + public class DynamicTextureUpdater + { + public LLUUID SimUUID; + public LLUUID UpdaterID; + public string ContentType; + public string Url; + public string BodyData; + public LLUUID PrimID; + public int UpdateTimer; + public LLUUID LastAssetID; + public string Params; + + public DynamicTextureUpdater() + { + LastAssetID = LLUUID.Zero; + UpdateTimer = 0; + BodyData = null; + } + + public void DataReceived(byte[] data, Scene scene) + { + //TODO delete the last asset(data), if it was a dynamic texture + + AssetBase asset = new AssetBase(); + asset.FullID = LLUUID.Random(); + asset.Data = data; + asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000); + asset.Type = 0; + scene.commsManager.AssetCache.AddAsset(asset); + + this.LastAssetID = asset.FullID; + + SceneObjectPart part = scene.GetSceneObjectPart(PrimID); + part.Shape.TextureEntry = new LLObject.TextureEntry(asset.FullID).ToBytes(); + part.ScheduleFullUpdate(); + } + } + } +} diff --git a/OpenSim/Region/Environment/Modules/EmailModule.cs b/OpenSim/Region/Environment/Modules/EmailModule.cs index 2a90dd3916..fff95390e1 100644 --- a/OpenSim/Region/Environment/Modules/EmailModule.cs +++ b/OpenSim/Region/Environment/Modules/EmailModule.cs @@ -1,10 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Environment.Modules -{ - class EmailModule - { - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.Environment.Modules +{ + class EmailModule + { + } +} diff --git a/OpenSim/Region/Environment/Modules/FriendsModule.cs b/OpenSim/Region/Environment/Modules/FriendsModule.cs index d46039cbe1..411b8382f7 100644 --- a/OpenSim/Region/Environment/Modules/FriendsModule.cs +++ b/OpenSim/Region/Environment/Modules/FriendsModule.cs @@ -1,40 +1,40 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - - -namespace OpenSim.Region.Environment.Modules -{ - public class FriendsModule : IRegionModule - { - private Scene m_scene; - - public void Initialise(Scene scene) - { - m_scene = scene; - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - } - - public string GetName() - { - return "FriendsModule"; - } - - public bool IsSharedModule() - { - return false; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; + + +namespace OpenSim.Region.Environment.Modules +{ + public class FriendsModule : IRegionModule + { + private Scene m_scene; + + public void Initialise(Scene scene) + { + m_scene = scene; + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + } + + public string GetName() + { + return "FriendsModule"; + } + + public bool IsSharedModule() + { + return false; + } + } +} diff --git a/OpenSim/Region/Environment/Modules/GroupsModule.cs b/OpenSim/Region/Environment/Modules/GroupsModule.cs index 8e4b4097de..9ed0e9694b 100644 --- a/OpenSim/Region/Environment/Modules/GroupsModule.cs +++ b/OpenSim/Region/Environment/Modules/GroupsModule.cs @@ -1,40 +1,40 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - -namespace OpenSim.Region.Environment.Modules -{ - public class GroupsModule : IRegionModule - { - private Scene m_scene; - - public void Initialise(Scene scene) - { - m_scene = scene; - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - } - - public string GetName() - { - return "GroupsModule"; - } - - public bool IsSharedModule() - { - return false; - } - } -} - +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; + +namespace OpenSim.Region.Environment.Modules +{ + public class GroupsModule : IRegionModule + { + private Scene m_scene; + + public void Initialise(Scene scene) + { + m_scene = scene; + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + } + + public string GetName() + { + return "GroupsModule"; + } + + public bool IsSharedModule() + { + return false; + } + } +} + diff --git a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs index acf031be08..25c118a6aa 100644 --- a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs +++ b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs @@ -1,40 +1,40 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - - -namespace OpenSim.Region.Environment.Modules -{ - public class InstantMessageModule :IRegionModule - { - private Scene m_scene; - - public void Initialise(Scene scene) - { - m_scene = scene; - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - } - - public string GetName() - { - return "InstantMessageModule"; - } - - public bool IsSharedModule() - { - return false; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; + + +namespace OpenSim.Region.Environment.Modules +{ + public class InstantMessageModule :IRegionModule + { + private Scene m_scene; + + public void Initialise(Scene scene) + { + m_scene = scene; + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + } + + public string GetName() + { + return "InstantMessageModule"; + } + + public bool IsSharedModule() + { + return false; + } + } +} diff --git a/OpenSim/Region/Environment/Modules/InventoryModule.cs b/OpenSim/Region/Environment/Modules/InventoryModule.cs index 00b4d8ecfe..bfcb7d73bb 100644 --- a/OpenSim/Region/Environment/Modules/InventoryModule.cs +++ b/OpenSim/Region/Environment/Modules/InventoryModule.cs @@ -1,40 +1,40 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - - -namespace OpenSim.Region.Environment.Modules -{ - public class InventoryModule :IRegionModule - { - private Scene m_scene; - - public void Initialise(Scene scene) - { - m_scene = scene; - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - } - - public string GetName() - { - return "InventoryModule"; - } - - public bool IsSharedModule() - { - return false; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; + + +namespace OpenSim.Region.Environment.Modules +{ + public class InventoryModule :IRegionModule + { + private Scene m_scene; + + public void Initialise(Scene scene) + { + m_scene = scene; + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + } + + public string GetName() + { + return "InventoryModule"; + } + + public bool IsSharedModule() + { + return false; + } + } +} diff --git a/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs b/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs index 11af7187df..e47cc9ee0a 100644 --- a/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs +++ b/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs @@ -1,10 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Environment.Modules -{ - class ScriptsHttpRequests - { - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.Environment.Modules +{ + class ScriptsHttpRequests + { + } +} diff --git a/OpenSim/Region/Environment/Modules/TeleportModule.cs b/OpenSim/Region/Environment/Modules/TeleportModule.cs index 08fc2023f0..1c01b272d9 100644 --- a/OpenSim/Region/Environment/Modules/TeleportModule.cs +++ b/OpenSim/Region/Environment/Modules/TeleportModule.cs @@ -1,10 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Environment.Modules -{ - class TeleportModule - { - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.Environment.Modules +{ + class TeleportModule + { + } +} diff --git a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs index 7d31644a33..59c0839696 100644 --- a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs @@ -1,54 +1,54 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - -namespace OpenSim.Region.Environment.Modules -{ - public class TextureDownloadModule :IRegionModule - { - private Scene m_scene; - - public TextureDownloadModule() - { - - } - - public void Initialise(Scene scene) - { - m_scene = scene; - m_scene.EventManager.OnNewClient += NewClient; - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - } - - public string GetName() - { - return "TextureDownloadModule"; - } - - public bool IsSharedModule() - { - return false; - } - - public void NewClient(IClientAPI client) - { - } - - public void TextureAssetCallback(LLUUID texture, byte[] data) - { - - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; + +namespace OpenSim.Region.Environment.Modules +{ + public class TextureDownloadModule :IRegionModule + { + private Scene m_scene; + + public TextureDownloadModule() + { + + } + + public void Initialise(Scene scene) + { + m_scene = scene; + m_scene.EventManager.OnNewClient += NewClient; + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + } + + public string GetName() + { + return "TextureDownloadModule"; + } + + public bool IsSharedModule() + { + return false; + } + + public void NewClient(IClientAPI client) + { + } + + public void TextureAssetCallback(LLUUID texture, byte[] data) + { + + } + } +} diff --git a/OpenSim/Region/Environment/Modules/XferModule.cs b/OpenSim/Region/Environment/Modules/XferModule.cs index 44b4d7a759..216d10acb4 100644 --- a/OpenSim/Region/Environment/Modules/XferModule.cs +++ b/OpenSim/Region/Environment/Modules/XferModule.cs @@ -1,180 +1,180 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Utilities; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - -namespace OpenSim.Region.Environment.Modules -{ - public class XferModule : IRegionModule, IXfer - { - public Dictionary NewFiles = new Dictionary(); - public Dictionary Transfers = new Dictionary(); - - private Scene m_scene; - - public XferModule() - { - - } - - public void Initialise(Scene scene) - { - m_scene = scene; - m_scene.EventManager.OnNewClient += NewClient; - - m_scene.RegisterModuleInterface(this); - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - - } - - public string GetName() - { - return "XferModule"; - } - - public bool IsSharedModule() - { - return false; - } - - public void NewClient(IClientAPI client) - { - client.OnRequestXfer += RequestXfer; - client.OnConfirmXfer += AckPacket; - } - - /// - /// - /// - /// - /// - /// - public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName) - { - lock (NewFiles) - { - if (NewFiles.ContainsKey(fileName)) - { - if (!Transfers.ContainsKey(xferID)) - { - byte[] fileData = NewFiles[fileName]; - XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); - Transfers.Add(xferID, transaction); - NewFiles.Remove(fileName); - transaction.StartSend(); - } - } - } - } - - public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet) - { - if (this.Transfers.ContainsKey(xferID)) - { - Transfers[xferID].AckPacket(packet); - } - } - - public bool AddNewFile(string fileName, byte[] data) - { - lock (NewFiles) - { - if (NewFiles.ContainsKey(fileName)) - { - NewFiles[fileName] = data; - } - else - { - NewFiles.Add(fileName, data); - } - } - return true; - } - - - public class XferDownLoad - { - public byte[] Data = new byte[0]; - public string FileName = ""; - public ulong XferID = 0; - public int DataPointer = 0; - public uint Packet = 0; - public IClientAPI Client; - public uint Serial = 1; - private bool complete = false; - - public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) - { - FileName = fileName; - Data = data; - XferID = xferID; - Client = client; - } - - public XferDownLoad() - { - - } - - public void StartSend() - { - if (Data.Length < 1000) - { - // for now (testing ) we only support files under 1000 bytes - byte[] transferData = new byte[Data.Length + 4]; - Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); - Array.Copy(Data, 0, transferData, 4, Data.Length); - Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); - complete = true; - } - else - { - byte[] transferData = new byte[1000 +4]; - Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); - Array.Copy(Data, 0, transferData, 4, 1000); - Client.SendXferPacket(XferID, 0 , transferData); - Packet++; - DataPointer = 1000; - } - } - - public void AckPacket(uint packet) - { - if (!complete) - { - if ((Data.Length - DataPointer) > 1000) - { - byte[] transferData = new byte[1000]; - Array.Copy(Data, DataPointer, transferData, 0, 1000); - Client.SendXferPacket(XferID, Packet, transferData); - Packet++; - DataPointer += 1000; - } - else - { - byte[] transferData = new byte[Data.Length - DataPointer]; - Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer); - uint endPacket = Packet |= (uint)0x80000000; - Client.SendXferPacket(XferID, endPacket, transferData); - Packet++; - DataPointer += (Data.Length - DataPointer); - complete = true; - } - } - } - } - } -} +using System; +using System.Collections.Generic; +using System.Text; + +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Utilities; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; + +namespace OpenSim.Region.Environment.Modules +{ + public class XferModule : IRegionModule, IXfer + { + public Dictionary NewFiles = new Dictionary(); + public Dictionary Transfers = new Dictionary(); + + private Scene m_scene; + + public XferModule() + { + + } + + public void Initialise(Scene scene) + { + m_scene = scene; + m_scene.EventManager.OnNewClient += NewClient; + + m_scene.RegisterModuleInterface(this); + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + + } + + public string GetName() + { + return "XferModule"; + } + + public bool IsSharedModule() + { + return false; + } + + public void NewClient(IClientAPI client) + { + client.OnRequestXfer += RequestXfer; + client.OnConfirmXfer += AckPacket; + } + + /// + /// + /// + /// + /// + /// + public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName) + { + lock (NewFiles) + { + if (NewFiles.ContainsKey(fileName)) + { + if (!Transfers.ContainsKey(xferID)) + { + byte[] fileData = NewFiles[fileName]; + XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); + Transfers.Add(xferID, transaction); + NewFiles.Remove(fileName); + transaction.StartSend(); + } + } + } + } + + public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet) + { + if (this.Transfers.ContainsKey(xferID)) + { + Transfers[xferID].AckPacket(packet); + } + } + + public bool AddNewFile(string fileName, byte[] data) + { + lock (NewFiles) + { + if (NewFiles.ContainsKey(fileName)) + { + NewFiles[fileName] = data; + } + else + { + NewFiles.Add(fileName, data); + } + } + return true; + } + + + public class XferDownLoad + { + public byte[] Data = new byte[0]; + public string FileName = ""; + public ulong XferID = 0; + public int DataPointer = 0; + public uint Packet = 0; + public IClientAPI Client; + public uint Serial = 1; + private bool complete = false; + + public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) + { + FileName = fileName; + Data = data; + XferID = xferID; + Client = client; + } + + public XferDownLoad() + { + + } + + public void StartSend() + { + if (Data.Length < 1000) + { + // for now (testing ) we only support files under 1000 bytes + byte[] transferData = new byte[Data.Length + 4]; + Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); + Array.Copy(Data, 0, transferData, 4, Data.Length); + Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); + complete = true; + } + else + { + byte[] transferData = new byte[1000 +4]; + Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); + Array.Copy(Data, 0, transferData, 4, 1000); + Client.SendXferPacket(XferID, 0 , transferData); + Packet++; + DataPointer = 1000; + } + } + + public void AckPacket(uint packet) + { + if (!complete) + { + if ((Data.Length - DataPointer) > 1000) + { + byte[] transferData = new byte[1000]; + Array.Copy(Data, DataPointer, transferData, 0, 1000); + Client.SendXferPacket(XferID, Packet, transferData); + Packet++; + DataPointer += 1000; + } + else + { + byte[] transferData = new byte[Data.Length - DataPointer]; + Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer); + uint endPacket = Packet |= (uint)0x80000000; + Client.SendXferPacket(XferID, endPacket, transferData); + Packet++; + DataPointer += (Data.Length - DataPointer); + complete = true; + } + } + } + } + } +} diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs index 110a130871..cb455f4239 100644 --- a/OpenSim/Region/Environment/PermissionManager.cs +++ b/OpenSim/Region/Environment/PermissionManager.cs @@ -1,305 +1,305 @@ -using System.Collections.Generic; -using OpenSim.Framework; -using OpenSim.Framework.Types; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Servers; -using OpenSim.Region.Capabilities; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.LandManagement; - -using libsecondlife; - -namespace OpenSim.Region.Environment -{ - public class PermissionManager - { - protected Scene m_scene; - - // Bypasses the permissions engine (always returns OK) - // disable in any production environment - // TODO: Change this to false when permissions are a desired default - // TODO: Move to configuration option. - private bool m_bypassPermissions = true; - public bool BypassPermissions - { - get { return m_bypassPermissions; } - set { m_bypassPermissions = value; } - } - - - public PermissionManager(Scene scene) - { - m_scene = scene; - } - - protected virtual void SendPermissionError(LLUUID user, string reason) - { - m_scene.EventManager.TriggerPermissionError(user, reason); - } - - protected virtual bool IsAdministrator(LLUUID user) - { - if (m_bypassPermissions) - { - return true; - } - - return m_scene.RegionInfo.MasterAvatarAssignedUUID == user; - } - - protected virtual bool IsEstateManager(LLUUID user) - { - if (m_bypassPermissions) - { - return true; - } - - return false; - } - - protected virtual bool IsGridUser(LLUUID user) - { - return true; - } - - protected virtual bool IsGuest(LLUUID user) - { - return false; - } - - public virtual bool CanRezObject(LLUUID user, LLVector3 position) - { - bool permission = false; - - string reason = "Insufficient permission"; - - if (IsAdministrator(user)) - { - permission = true; - } - else - { - reason = "Not an administrator"; - } - - if (GenericParcelPermission(user, position)) - { - permission = true; - } - else - { - reason = "Not the parcel owner"; - } - - if (!permission) - SendPermissionError(user, reason); - - return permission; - } - - #region Object Permissions - - protected virtual bool GenericObjectPermission(LLUUID user, LLUUID objId) - { - // Default: deny - bool permission = false; - - if( !m_scene.Entities.ContainsKey( objId )) - { - return false; - } - - // If it's not an object, we cant edit it. - if (!(m_scene.Entities[objId] is SceneObjectGroup)) - { - return false; - } - - SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objId]; - LLUUID taskOwner = null; - - // Object owners should be able to edit their own content - if (user == taskOwner) - permission = true; - - // Users should be able to edit what is over their land. - if (m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y).landData.ownerID == user) - permission = true; - - // Estate users should be able to edit anything in the sim - if (IsEstateManager(user)) - permission = true; - - // Admin objects should not be editable by the above - if (IsAdministrator(taskOwner)) - permission = false; - - // Admin should be able to edit anything in the sim (including admin objects) - if (IsAdministrator(user)) - permission = true; - - return permission; - } - - /// - /// Permissions check - can user delete an object? - /// - /// User attempting the delete - /// Target object - /// Has permission? - public virtual bool CanDeRezObject(LLUUID user, LLUUID obj) - { - return GenericObjectPermission(user, obj); - } - - public virtual bool CanEditObject(LLUUID user, LLUUID obj) - { - return GenericObjectPermission(user, obj); - } - - public virtual bool CanReturnObject(LLUUID user, LLUUID obj) - { - return GenericObjectPermission(user, obj); - } - - #endregion - - #region Communication Permissions - - public virtual bool GenericCommunicationPermission(LLUUID user, LLUUID target) - { - bool permission = false; - string reason = "Only registered users may communicate with another account."; - - if (IsGridUser(user)) - permission = true; - - if (!IsGridUser(user)) - { - permission = false; - reason = "The person that you are messaging is not a registered user."; - } - if (IsAdministrator(user)) - permission = true; - - if (IsEstateManager(user)) - permission = true; - - if (!permission) - SendPermissionError(user, reason); - - return permission; - } - - public virtual bool CanInstantMessage(LLUUID user, LLUUID target) - { - return GenericCommunicationPermission(user, target); - } - - public virtual bool CanInventoryTransfer(LLUUID user, LLUUID target) - { - return GenericCommunicationPermission(user, target); - } - - #endregion - - public virtual bool CanEditScript(LLUUID user, LLUUID script) - { - return IsAdministrator(user); - } - - public virtual bool CanRunScript(LLUUID user, LLUUID script) - { - return IsAdministrator(user); - } - - public virtual bool CanTerraform(LLUUID user, LLVector3 position) - { - bool permission = false; - - // Estate override - if (GenericEstatePermission(user)) - permission = true; - - // Land owner can terraform too - if (GenericParcelPermission(user, m_scene.LandManager.getLandObject(position.X, position.Y))) - permission = true; - - if (!permission) - SendPermissionError(user, "Not authorized to terraform at this location."); - - return permission; - } - - #region Estate Permissions - - protected virtual bool GenericEstatePermission(LLUUID user) - { - // Default: deny - bool permission = false; - - // Estate admins should be able to use estate tools - if (IsEstateManager(user)) - permission = true; - - // Administrators always have permission - if (IsAdministrator(user)) - permission = true; - - return permission; - } - - public virtual bool CanEditEstateTerrain(LLUUID user) - { - return GenericEstatePermission(user); - } - - #endregion - - #region Parcel Permissions - - protected virtual bool GenericParcelPermission(LLUUID user, Land parcel) - { - bool permission = false; - - if (parcel.landData.ownerID == user) - permission = true; - - if (parcel.landData.isGroupOwned) - { - // TODO: Need to do some extra checks here. Requires group code. - } - - if(IsEstateManager(user)) - permission = true; - - if (IsAdministrator(user)) - permission = true; - - return permission; - } - - protected virtual bool GenericParcelPermission(LLUUID user, LLVector3 pos) - { - return GenericParcelPermission(user, m_scene.LandManager.getLandObject(pos.X, pos.Y)); - } - - public virtual bool CanEditParcel(LLUUID user, Land parcel) - { - return GenericParcelPermission(user, parcel); - } - - public virtual bool CanSellParcel(LLUUID user, Land parcel) - { - return GenericParcelPermission(user, parcel); - } - - public virtual bool CanAbandonParcel(LLUUID user, Land parcel) - { - return GenericParcelPermission(user, parcel); - } - - #endregion - - } -} +using System.Collections.Generic; +using OpenSim.Framework; +using OpenSim.Framework.Types; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Servers; +using OpenSim.Region.Capabilities; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.LandManagement; + +using libsecondlife; + +namespace OpenSim.Region.Environment +{ + public class PermissionManager + { + protected Scene m_scene; + + // Bypasses the permissions engine (always returns OK) + // disable in any production environment + // TODO: Change this to false when permissions are a desired default + // TODO: Move to configuration option. + private bool m_bypassPermissions = true; + public bool BypassPermissions + { + get { return m_bypassPermissions; } + set { m_bypassPermissions = value; } + } + + + public PermissionManager(Scene scene) + { + m_scene = scene; + } + + protected virtual void SendPermissionError(LLUUID user, string reason) + { + m_scene.EventManager.TriggerPermissionError(user, reason); + } + + protected virtual bool IsAdministrator(LLUUID user) + { + if (m_bypassPermissions) + { + return true; + } + + return m_scene.RegionInfo.MasterAvatarAssignedUUID == user; + } + + protected virtual bool IsEstateManager(LLUUID user) + { + if (m_bypassPermissions) + { + return true; + } + + return false; + } + + protected virtual bool IsGridUser(LLUUID user) + { + return true; + } + + protected virtual bool IsGuest(LLUUID user) + { + return false; + } + + public virtual bool CanRezObject(LLUUID user, LLVector3 position) + { + bool permission = false; + + string reason = "Insufficient permission"; + + if (IsAdministrator(user)) + { + permission = true; + } + else + { + reason = "Not an administrator"; + } + + if (GenericParcelPermission(user, position)) + { + permission = true; + } + else + { + reason = "Not the parcel owner"; + } + + if (!permission) + SendPermissionError(user, reason); + + return permission; + } + + #region Object Permissions + + protected virtual bool GenericObjectPermission(LLUUID user, LLUUID objId) + { + // Default: deny + bool permission = false; + + if( !m_scene.Entities.ContainsKey( objId )) + { + return false; + } + + // If it's not an object, we cant edit it. + if (!(m_scene.Entities[objId] is SceneObjectGroup)) + { + return false; + } + + SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objId]; + LLUUID taskOwner = null; + + // Object owners should be able to edit their own content + if (user == taskOwner) + permission = true; + + // Users should be able to edit what is over their land. + if (m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y).landData.ownerID == user) + permission = true; + + // Estate users should be able to edit anything in the sim + if (IsEstateManager(user)) + permission = true; + + // Admin objects should not be editable by the above + if (IsAdministrator(taskOwner)) + permission = false; + + // Admin should be able to edit anything in the sim (including admin objects) + if (IsAdministrator(user)) + permission = true; + + return permission; + } + + /// + /// Permissions check - can user delete an object? + /// + /// User attempting the delete + /// Target object + /// Has permission? + public virtual bool CanDeRezObject(LLUUID user, LLUUID obj) + { + return GenericObjectPermission(user, obj); + } + + public virtual bool CanEditObject(LLUUID user, LLUUID obj) + { + return GenericObjectPermission(user, obj); + } + + public virtual bool CanReturnObject(LLUUID user, LLUUID obj) + { + return GenericObjectPermission(user, obj); + } + + #endregion + + #region Communication Permissions + + public virtual bool GenericCommunicationPermission(LLUUID user, LLUUID target) + { + bool permission = false; + string reason = "Only registered users may communicate with another account."; + + if (IsGridUser(user)) + permission = true; + + if (!IsGridUser(user)) + { + permission = false; + reason = "The person that you are messaging is not a registered user."; + } + if (IsAdministrator(user)) + permission = true; + + if (IsEstateManager(user)) + permission = true; + + if (!permission) + SendPermissionError(user, reason); + + return permission; + } + + public virtual bool CanInstantMessage(LLUUID user, LLUUID target) + { + return GenericCommunicationPermission(user, target); + } + + public virtual bool CanInventoryTransfer(LLUUID user, LLUUID target) + { + return GenericCommunicationPermission(user, target); + } + + #endregion + + public virtual bool CanEditScript(LLUUID user, LLUUID script) + { + return IsAdministrator(user); + } + + public virtual bool CanRunScript(LLUUID user, LLUUID script) + { + return IsAdministrator(user); + } + + public virtual bool CanTerraform(LLUUID user, LLVector3 position) + { + bool permission = false; + + // Estate override + if (GenericEstatePermission(user)) + permission = true; + + // Land owner can terraform too + if (GenericParcelPermission(user, m_scene.LandManager.getLandObject(position.X, position.Y))) + permission = true; + + if (!permission) + SendPermissionError(user, "Not authorized to terraform at this location."); + + return permission; + } + + #region Estate Permissions + + protected virtual bool GenericEstatePermission(LLUUID user) + { + // Default: deny + bool permission = false; + + // Estate admins should be able to use estate tools + if (IsEstateManager(user)) + permission = true; + + // Administrators always have permission + if (IsAdministrator(user)) + permission = true; + + return permission; + } + + public virtual bool CanEditEstateTerrain(LLUUID user) + { + return GenericEstatePermission(user); + } + + #endregion + + #region Parcel Permissions + + protected virtual bool GenericParcelPermission(LLUUID user, Land parcel) + { + bool permission = false; + + if (parcel.landData.ownerID == user) + permission = true; + + if (parcel.landData.isGroupOwned) + { + // TODO: Need to do some extra checks here. Requires group code. + } + + if(IsEstateManager(user)) + permission = true; + + if (IsAdministrator(user)) + permission = true; + + return permission; + } + + protected virtual bool GenericParcelPermission(LLUUID user, LLVector3 pos) + { + return GenericParcelPermission(user, m_scene.LandManager.getLandObject(pos.X, pos.Y)); + } + + public virtual bool CanEditParcel(LLUUID user, Land parcel) + { + return GenericParcelPermission(user, parcel); + } + + public virtual bool CanSellParcel(LLUUID user, Land parcel) + { + return GenericParcelPermission(user, parcel); + } + + public virtual bool CanAbandonParcel(LLUUID user, Land parcel) + { + return GenericParcelPermission(user, parcel); + } + + #endregion + + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 70b34cfe90..a259dd0115 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -1,427 +1,427 @@ -using System; -using System.IO; -using System.Collections.Generic; -using libsecondlife; -using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Communications.Caches; -using OpenSim.Framework.Data; -using OpenSim.Framework.Utilities; -using OpenSim.Region.Physics.Manager; - -namespace OpenSim.Region.Environment.Scenes -{ - public partial class Scene - { - //split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete - // or at least some of they can be moved somewhere else - - public void AddInventoryItem(LLUUID userID, InventoryItemBase item) - { - if (this.Avatars.ContainsKey(userID)) - { - this.AddInventoryItem(this.Avatars[userID].ControllingClient, item); - } - } - - public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item) - { - CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); - if (userInfo != null) - { - userInfo.AddItem(remoteClient.AgentId, item); - remoteClient.SendInventoryItemUpdate(item); - } - } - - public LLUUID CapsUpdateInventoryItemAsset(LLUUID userID, LLUUID itemID, byte[] data) - { - if (this.Avatars.ContainsKey(userID)) - { - return this.CapsUpdateInventoryItemAsset(this.Avatars[userID].ControllingClient, itemID, data); - } - return LLUUID.Zero; - } - - public LLUUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID itemID, byte[] data) - { - CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); - if (userInfo != null) - { - if (userInfo.RootFolder != null) - { - InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); - if (item != null) - { - AssetBase asset; - asset = new AssetBase(); - asset.FullID = LLUUID.Random(); - asset.Type = (sbyte)item.assetType; - asset.InvType = (sbyte)item.invType; - asset.Name = item.inventoryName; - asset.Data = data; - commsManager.AssetCache.AddAsset(asset); - - item.assetID = asset.FullID; - userInfo.UpdateItem(remoteClient.AgentId, item); - - // remoteClient.SendInventoryItemUpdate(item); - if (item.invType == 7) - { - //do we want to know about updated note cards? - } - else if (item.invType == 10) - { - // do we want to know about updated scripts - } - - return (asset.FullID); - } - } - } - return LLUUID.Zero; - } - - public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, LLUUID itemID) - { - CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); - if (userInfo != null) - { - if (userInfo.RootFolder != null) - { - InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); - if (item != null) - { - AgentAssetTransactions transactions = commsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId); - if (transactions != null) - { - AssetBase asset = null; - bool addToCache = false; - - asset = commsManager.AssetCache.GetAsset(assetID); - if (asset == null) - { - asset = transactions.GetTransactionAsset(transactionID); - addToCache = true; - } - - if (asset != null) - { - if (asset.FullID == assetID) - { - asset.Name = item.inventoryName; - asset.Description = item.inventoryDescription; - asset.InvType = (sbyte)item.invType; - asset.Type = (sbyte)item.assetType; - item.assetID = asset.FullID; - - if (addToCache) - { - commsManager.AssetCache.AddAsset(asset); - } - - userInfo.UpdateItem(remoteClient.AgentId, item); - } - } - } - } - } - } - } - - /// - /// temporary method to test out creating new inventory items - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) - { - if (transActionID == LLUUID.Zero) - { - CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); - if (userInfo != null) - { - AssetBase asset = new AssetBase(); - asset.Name = name; - asset.Description = description; - asset.InvType = invType; - asset.Type = type; - asset.FullID = LLUUID.Random(); - asset.Data = new byte[1]; - this.commsManager.AssetCache.AddAsset(asset); - - InventoryItemBase item = new InventoryItemBase(); - item.avatarID = remoteClient.AgentId; - item.creatorsID = remoteClient.AgentId; - item.inventoryID = LLUUID.Random(); - item.assetID = asset.FullID; - item.inventoryDescription = description; - item.inventoryName = name; - item.assetType = invType; - item.invType = invType; - item.parentFolderID = folderID; - item.inventoryCurrentPermissions = 2147483647; - item.inventoryNextPermissions = nextOwnerMask; - - userInfo.AddItem(remoteClient.AgentId, item); - remoteClient.SendInventoryItemUpdate(item); - } - } - else - { - commsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); - //System.Console.WriteLine("request to create inventory item from transaction " + transActionID); - } - } - - /// - /// - /// - /// - /// - public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID) - { - bool hasPrim = false; - foreach (EntityBase ent in Entities.Values) - { - if (ent is SceneObjectGroup) - { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); - if (hasPrim != false) - { - bool fileChange = ((SceneObjectGroup)ent).GetPartInventoryFileName(remoteClient, primLocalID); - if (fileChange) - { - if (this.XferManager != null) - { - ((SceneObjectGroup)ent).RequestInventoryFile(primLocalID, XferManager); - } - } - break; - } - } - } - } - - public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID) - { - bool hasPrim = false; - foreach (EntityBase ent in Entities.Values) - { - if (ent is SceneObjectGroup) - { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); - if (hasPrim != false) - { - int type = ((SceneObjectGroup)ent).RemoveInventoryItem(remoteClient, localID, itemID); - ((SceneObjectGroup)ent).GetProperites(remoteClient); - if (type == 10) - { - this.EventManager.TriggerRemoveScript(localID, itemID); - } - } - } - } - } - - public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID) - { - CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); - LLUUID copyID = LLUUID.Random(); - if (userInfo != null) - { - if (userInfo.RootFolder != null) - { - InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); - if (item != null) - { - bool isTexture = false; - bool rezzed = false; - if (item.invType == 0) - { - isTexture = true; - } - AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture); - if (rezAsset != null) - { - string script = Util.FieldToString(rezAsset.Data); - //Console.WriteLine("rez script "+script); - this.EventManager.TriggerRezScript(localID, copyID, script); - rezzed = true; - } - else - { - //lets try once more incase the asset cache is being slow getting the asset from server - rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture); - if (rezAsset != null) - { - string script = Util.FieldToString(rezAsset.Data); - // Console.WriteLine("rez script " + script); - this.EventManager.TriggerRezScript(localID, copyID, script); - rezzed = true; - } - } - - if (rezzed) - { - bool hasPrim = false; - foreach (EntityBase ent in Entities.Values) - { - if (ent is SceneObjectGroup) - { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); - if (hasPrim != false) - { - - bool added = ((SceneObjectGroup)ent).AddInventoryItem(remoteClient, localID, item, copyID); - ((SceneObjectGroup)ent).GetProperites(remoteClient); - } - } - } - } - } - } - } - } - - /// - /// - /// - /// - /// - public void DeRezObject(Packet packet, IClientAPI remoteClient) - { - DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet; - - if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) - { - //currently following code not used (or don't know of any case of destination being zero - } - else - { - foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) - { - EntityBase selectedEnt = null; - //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); - foreach (EntityBase ent in this.Entities.Values) - { - if (ent.LocalId == Data.ObjectLocalID) - { - selectedEnt = ent; - break; - } - } - if (selectedEnt != null) - { - if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup)selectedEnt).UUID)) - { - string sceneObjectXml = ((SceneObjectGroup)selectedEnt).ToXmlString(); - CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); - if (userInfo != null) - { - AssetBase asset = new AssetBase(); - asset.Name = ((SceneObjectGroup)selectedEnt).GetPartName(selectedEnt.LocalId); - asset.Description = ((SceneObjectGroup)selectedEnt).GetPartDescription(selectedEnt.LocalId); - asset.InvType = 6; - asset.Type = 6; - asset.FullID = LLUUID.Random(); - asset.Data = Helpers.StringToField(sceneObjectXml); - commsManager.AssetCache.AddAsset(asset); - - - InventoryItemBase item = new InventoryItemBase(); - item.avatarID = remoteClient.AgentId; - item.creatorsID = remoteClient.AgentId; - item.inventoryID = LLUUID.Random(); - item.assetID = asset.FullID; - item.inventoryDescription = asset.Description; - item.inventoryName = asset.Name; - item.assetType = asset.Type; - item.invType = asset.InvType; - item.parentFolderID = DeRezPacket.AgentBlock.DestinationID; - item.inventoryCurrentPermissions = 2147483647; - item.inventoryNextPermissions = 2147483647; - - userInfo.AddItem(remoteClient.AgentId, item); - remoteClient.SendInventoryItemUpdate(item); - } - - SceneObjectPart rootPart = ((SceneObjectGroup)selectedEnt).GetChildPart(((SceneObjectGroup)selectedEnt).UUID); - if (rootPart.PhysActor != null) - { - this.phyScene.RemovePrim(rootPart.PhysActor); - rootPart.PhysActor = null; - } - - storageManager.DataStore.RemoveObject(((SceneObjectGroup)selectedEnt).UUID, m_regInfo.SimUUID); - ((SceneObjectGroup)selectedEnt).DeleteGroup(); - - lock (Entities) - { - Entities.Remove(((SceneObjectGroup)selectedEnt).UUID); - } - ((SceneObjectGroup)selectedEnt).DeleteParts(); - } - } - } - } - } - - public void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos) - { - CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); - if (userInfo != null) - { - if (userInfo.RootFolder != null) - { - InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); - if (item != null) - { - AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false); - if (rezAsset != null) - { - this.AddRezObject(Util.FieldToString(rezAsset.Data), pos); - userInfo.DeleteItem(remoteClient.AgentId, item); - remoteClient.SendRemoveInventoryItem(itemID); - } - else - { - //lets try once more incase the asset cache is being slow getting the asset from server - rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false); - if (rezAsset != null) - { - this.AddRezObject(Util.FieldToString(rezAsset.Data), pos); - userInfo.DeleteItem(remoteClient.AgentId, item); - remoteClient.SendRemoveInventoryItem(itemID); - } - } - } - } - } - } - - private void AddRezObject(string xmlData, LLVector3 pos) - { - SceneObjectGroup group = new SceneObjectGroup(this, this.m_regionHandle, xmlData); - this.AddEntity(group); - group.AbsolutePosition = pos; - SceneObjectPart rootPart = group.GetChildPart(group.UUID); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) - rootPart.PhysActor = phyScene.AddPrim( - new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, rootPart.AbsolutePosition.Z), - new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), - new Axiom.Math.Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, - rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); - } - } - -} +using System; +using System.IO; +using System.Collections.Generic; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Communications.Caches; +using OpenSim.Framework.Data; +using OpenSim.Framework.Utilities; +using OpenSim.Region.Physics.Manager; + +namespace OpenSim.Region.Environment.Scenes +{ + public partial class Scene + { + //split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete + // or at least some of they can be moved somewhere else + + public void AddInventoryItem(LLUUID userID, InventoryItemBase item) + { + if (this.Avatars.ContainsKey(userID)) + { + this.AddInventoryItem(this.Avatars[userID].ControllingClient, item); + } + } + + public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item) + { + CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); + if (userInfo != null) + { + userInfo.AddItem(remoteClient.AgentId, item); + remoteClient.SendInventoryItemUpdate(item); + } + } + + public LLUUID CapsUpdateInventoryItemAsset(LLUUID userID, LLUUID itemID, byte[] data) + { + if (this.Avatars.ContainsKey(userID)) + { + return this.CapsUpdateInventoryItemAsset(this.Avatars[userID].ControllingClient, itemID, data); + } + return LLUUID.Zero; + } + + public LLUUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID itemID, byte[] data) + { + CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); + if (userInfo != null) + { + if (userInfo.RootFolder != null) + { + InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); + if (item != null) + { + AssetBase asset; + asset = new AssetBase(); + asset.FullID = LLUUID.Random(); + asset.Type = (sbyte)item.assetType; + asset.InvType = (sbyte)item.invType; + asset.Name = item.inventoryName; + asset.Data = data; + commsManager.AssetCache.AddAsset(asset); + + item.assetID = asset.FullID; + userInfo.UpdateItem(remoteClient.AgentId, item); + + // remoteClient.SendInventoryItemUpdate(item); + if (item.invType == 7) + { + //do we want to know about updated note cards? + } + else if (item.invType == 10) + { + // do we want to know about updated scripts + } + + return (asset.FullID); + } + } + } + return LLUUID.Zero; + } + + public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, LLUUID itemID) + { + CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); + if (userInfo != null) + { + if (userInfo.RootFolder != null) + { + InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); + if (item != null) + { + AgentAssetTransactions transactions = commsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId); + if (transactions != null) + { + AssetBase asset = null; + bool addToCache = false; + + asset = commsManager.AssetCache.GetAsset(assetID); + if (asset == null) + { + asset = transactions.GetTransactionAsset(transactionID); + addToCache = true; + } + + if (asset != null) + { + if (asset.FullID == assetID) + { + asset.Name = item.inventoryName; + asset.Description = item.inventoryDescription; + asset.InvType = (sbyte)item.invType; + asset.Type = (sbyte)item.assetType; + item.assetID = asset.FullID; + + if (addToCache) + { + commsManager.AssetCache.AddAsset(asset); + } + + userInfo.UpdateItem(remoteClient.AgentId, item); + } + } + } + } + } + } + } + + /// + /// temporary method to test out creating new inventory items + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) + { + if (transActionID == LLUUID.Zero) + { + CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); + if (userInfo != null) + { + AssetBase asset = new AssetBase(); + asset.Name = name; + asset.Description = description; + asset.InvType = invType; + asset.Type = type; + asset.FullID = LLUUID.Random(); + asset.Data = new byte[1]; + this.commsManager.AssetCache.AddAsset(asset); + + InventoryItemBase item = new InventoryItemBase(); + item.avatarID = remoteClient.AgentId; + item.creatorsID = remoteClient.AgentId; + item.inventoryID = LLUUID.Random(); + item.assetID = asset.FullID; + item.inventoryDescription = description; + item.inventoryName = name; + item.assetType = invType; + item.invType = invType; + item.parentFolderID = folderID; + item.inventoryCurrentPermissions = 2147483647; + item.inventoryNextPermissions = nextOwnerMask; + + userInfo.AddItem(remoteClient.AgentId, item); + remoteClient.SendInventoryItemUpdate(item); + } + } + else + { + commsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); + //System.Console.WriteLine("request to create inventory item from transaction " + transActionID); + } + } + + /// + /// + /// + /// + /// + public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID) + { + bool hasPrim = false; + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObjectGroup) + { + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); + if (hasPrim != false) + { + bool fileChange = ((SceneObjectGroup)ent).GetPartInventoryFileName(remoteClient, primLocalID); + if (fileChange) + { + if (this.XferManager != null) + { + ((SceneObjectGroup)ent).RequestInventoryFile(primLocalID, XferManager); + } + } + break; + } + } + } + } + + public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID) + { + bool hasPrim = false; + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObjectGroup) + { + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + if (hasPrim != false) + { + int type = ((SceneObjectGroup)ent).RemoveInventoryItem(remoteClient, localID, itemID); + ((SceneObjectGroup)ent).GetProperites(remoteClient); + if (type == 10) + { + this.EventManager.TriggerRemoveScript(localID, itemID); + } + } + } + } + } + + public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID) + { + CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); + LLUUID copyID = LLUUID.Random(); + if (userInfo != null) + { + if (userInfo.RootFolder != null) + { + InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); + if (item != null) + { + bool isTexture = false; + bool rezzed = false; + if (item.invType == 0) + { + isTexture = true; + } + AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture); + if (rezAsset != null) + { + string script = Util.FieldToString(rezAsset.Data); + //Console.WriteLine("rez script "+script); + this.EventManager.TriggerRezScript(localID, copyID, script); + rezzed = true; + } + else + { + //lets try once more incase the asset cache is being slow getting the asset from server + rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture); + if (rezAsset != null) + { + string script = Util.FieldToString(rezAsset.Data); + // Console.WriteLine("rez script " + script); + this.EventManager.TriggerRezScript(localID, copyID, script); + rezzed = true; + } + } + + if (rezzed) + { + bool hasPrim = false; + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObjectGroup) + { + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + if (hasPrim != false) + { + + bool added = ((SceneObjectGroup)ent).AddInventoryItem(remoteClient, localID, item, copyID); + ((SceneObjectGroup)ent).GetProperites(remoteClient); + } + } + } + } + } + } + } + } + + /// + /// + /// + /// + /// + public void DeRezObject(Packet packet, IClientAPI remoteClient) + { + DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet; + + if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) + { + //currently following code not used (or don't know of any case of destination being zero + } + else + { + foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) + { + EntityBase selectedEnt = null; + //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); + foreach (EntityBase ent in this.Entities.Values) + { + if (ent.LocalId == Data.ObjectLocalID) + { + selectedEnt = ent; + break; + } + } + if (selectedEnt != null) + { + if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup)selectedEnt).UUID)) + { + string sceneObjectXml = ((SceneObjectGroup)selectedEnt).ToXmlString(); + CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); + if (userInfo != null) + { + AssetBase asset = new AssetBase(); + asset.Name = ((SceneObjectGroup)selectedEnt).GetPartName(selectedEnt.LocalId); + asset.Description = ((SceneObjectGroup)selectedEnt).GetPartDescription(selectedEnt.LocalId); + asset.InvType = 6; + asset.Type = 6; + asset.FullID = LLUUID.Random(); + asset.Data = Helpers.StringToField(sceneObjectXml); + commsManager.AssetCache.AddAsset(asset); + + + InventoryItemBase item = new InventoryItemBase(); + item.avatarID = remoteClient.AgentId; + item.creatorsID = remoteClient.AgentId; + item.inventoryID = LLUUID.Random(); + item.assetID = asset.FullID; + item.inventoryDescription = asset.Description; + item.inventoryName = asset.Name; + item.assetType = asset.Type; + item.invType = asset.InvType; + item.parentFolderID = DeRezPacket.AgentBlock.DestinationID; + item.inventoryCurrentPermissions = 2147483647; + item.inventoryNextPermissions = 2147483647; + + userInfo.AddItem(remoteClient.AgentId, item); + remoteClient.SendInventoryItemUpdate(item); + } + + SceneObjectPart rootPart = ((SceneObjectGroup)selectedEnt).GetChildPart(((SceneObjectGroup)selectedEnt).UUID); + if (rootPart.PhysActor != null) + { + this.phyScene.RemovePrim(rootPart.PhysActor); + rootPart.PhysActor = null; + } + + storageManager.DataStore.RemoveObject(((SceneObjectGroup)selectedEnt).UUID, m_regInfo.SimUUID); + ((SceneObjectGroup)selectedEnt).DeleteGroup(); + + lock (Entities) + { + Entities.Remove(((SceneObjectGroup)selectedEnt).UUID); + } + ((SceneObjectGroup)selectedEnt).DeleteParts(); + } + } + } + } + } + + public void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos) + { + CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); + if (userInfo != null) + { + if (userInfo.RootFolder != null) + { + InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); + if (item != null) + { + AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false); + if (rezAsset != null) + { + this.AddRezObject(Util.FieldToString(rezAsset.Data), pos); + userInfo.DeleteItem(remoteClient.AgentId, item); + remoteClient.SendRemoveInventoryItem(itemID); + } + else + { + //lets try once more incase the asset cache is being slow getting the asset from server + rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false); + if (rezAsset != null) + { + this.AddRezObject(Util.FieldToString(rezAsset.Data), pos); + userInfo.DeleteItem(remoteClient.AgentId, item); + remoteClient.SendRemoveInventoryItem(itemID); + } + } + } + } + } + } + + private void AddRezObject(string xmlData, LLVector3 pos) + { + SceneObjectGroup group = new SceneObjectGroup(this, this.m_regionHandle, xmlData); + this.AddEntity(group); + group.AbsolutePosition = pos; + SceneObjectPart rootPart = group.GetChildPart(group.UUID); + if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + rootPart.PhysActor = phyScene.AddPrim( + new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, rootPart.AbsolutePosition.Z), + new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), + new Axiom.Math.Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, + rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); + } + } + +} diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index dfac406e68..4a99a80fa7 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -1,237 +1,237 @@ -using System.Collections.Generic; -using System; -using OpenSim.Framework.Console; -using OpenSim.Framework.Types; - -namespace OpenSim.Region.Environment.Scenes -{ - public class SceneManager - { - private readonly List m_localScenes; - private Scene m_currentScene = null; - public Scene CurrentScene - { - get - { - return m_currentScene; - } - } - - private Scene CurrentOrFirstScene - { - get - { - if (m_currentScene == null) - { - return m_localScenes[0]; - } - else - { - return m_currentScene; - } - } - } - - public SceneManager() - { - m_localScenes = new List(); - } - - public void Close() - { - for (int i = 0; i < m_localScenes.Count; i++) - { - m_localScenes[i].Close(); - } - } - - public void Add(Scene scene) - { - m_localScenes.Add(scene); - } - - public void SavePrimsToXml(string filename) - { - CurrentOrFirstScene.SavePrimsToXml(filename); - } - - public void LoadPrimsFromXml(string filename) - { - CurrentOrFirstScene.LoadPrimsFromXml(filename); - } - - public bool RunTerrainCmd(string[] cmdparams, ref string result) - { - if (m_currentScene == null) - { - bool success = true; - foreach (Scene scene in m_localScenes) - { - if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName)) - { - success = false; - } - } - - return success; - } - else - { - return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName); - } - } - - public void SendCommandToScripts(string[] cmdparams) - { - ForEach(delegate(Scene scene) - { - scene.SendCommandToScripts(cmdparams); - }); - } - - public void BypassPermissions(bool bypassPermissions) - { - ForEach(delegate(Scene scene) - { - scene.PermissionsMngr.BypassPermissions = bypassPermissions; - }); - } - - private void ForEach(Action func) - { - if (m_currentScene == null) - { - m_localScenes.ForEach(func); - } - else - { - func(m_currentScene); - } - } - - public void Backup() - { - ForEach(delegate(Scene scene) - { - scene.Backup(); - }); - } - - public void HandleAlertCommand(string[] cmdparams) - { - ForEach(delegate(Scene scene) - { - scene.HandleAlertCommand(cmdparams); - }); - } - - public bool TrySetCurrentRegion(string regionName) - { - if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0)) - { - m_currentScene = null; - return true; - } - else - { - Console.WriteLine("Searching for Region: '" + regionName + "'"); - Scene foundScene = null; - - foreach (Scene scene in m_localScenes) - { - if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) - { - m_currentScene = scene; - return true; - } - } - - return false; - } - } - - public void DebugPacket(LogBase log, int newDebug) - { - ForEach(delegate(Scene scene) - { - foreach (EntityBase entity in scene.Entities.Values) - { - if (entity is ScenePresence) - { - ScenePresence scenePrescence = entity as ScenePresence; - if (!scenePrescence.childAgent) - { - log.Error(String.Format("Packet debug for {0} {1} set to {2}", - scenePrescence.Firstname, scenePrescence.Lastname, - newDebug)); - - scenePrescence.ControllingClient.SetDebug(newDebug); - } - } - } - }); - } - - public List GetAvatars() - { - List avatars = new List(); - - ForEach(delegate(Scene scene) - { - foreach (EntityBase entity in scene.Entities.Values) - { - if (entity is ScenePresence) - { - ScenePresence scenePrescence = entity as ScenePresence; - if (!scenePrescence.childAgent) - { - avatars.Add(scenePrescence); - } - } - } - }); - - return avatars; - } - - public RegionInfo GetRegionInfo(ulong regionHandle) - { - foreach (Scene scene in m_localScenes) - { - if (scene.RegionInfo.RegionHandle == regionHandle) - { - return scene.RegionInfo; - } - } - - return null; - } - - public void SetTimePhase(int timePhase) - { - ForEach(delegate(Scene scene) - { - scene.SetTimePhase( - timePhase) - ; - }); - } - - - public void ForceClientUpdate() - { - ForEach(delegate(Scene scene) - { - scene.ForceClientUpdate(); - }); - } - - public void HandleEditCommand(string[] cmdparams) - { - ForEach(delegate(Scene scene) - { - scene.HandleEditCommand(cmdparams); - }); - } - } -} +using System.Collections.Generic; +using System; +using OpenSim.Framework.Console; +using OpenSim.Framework.Types; + +namespace OpenSim.Region.Environment.Scenes +{ + public class SceneManager + { + private readonly List m_localScenes; + private Scene m_currentScene = null; + public Scene CurrentScene + { + get + { + return m_currentScene; + } + } + + private Scene CurrentOrFirstScene + { + get + { + if (m_currentScene == null) + { + return m_localScenes[0]; + } + else + { + return m_currentScene; + } + } + } + + public SceneManager() + { + m_localScenes = new List(); + } + + public void Close() + { + for (int i = 0; i < m_localScenes.Count; i++) + { + m_localScenes[i].Close(); + } + } + + public void Add(Scene scene) + { + m_localScenes.Add(scene); + } + + public void SavePrimsToXml(string filename) + { + CurrentOrFirstScene.SavePrimsToXml(filename); + } + + public void LoadPrimsFromXml(string filename) + { + CurrentOrFirstScene.LoadPrimsFromXml(filename); + } + + public bool RunTerrainCmd(string[] cmdparams, ref string result) + { + if (m_currentScene == null) + { + bool success = true; + foreach (Scene scene in m_localScenes) + { + if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName)) + { + success = false; + } + } + + return success; + } + else + { + return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName); + } + } + + public void SendCommandToScripts(string[] cmdparams) + { + ForEach(delegate(Scene scene) + { + scene.SendCommandToScripts(cmdparams); + }); + } + + public void BypassPermissions(bool bypassPermissions) + { + ForEach(delegate(Scene scene) + { + scene.PermissionsMngr.BypassPermissions = bypassPermissions; + }); + } + + private void ForEach(Action func) + { + if (m_currentScene == null) + { + m_localScenes.ForEach(func); + } + else + { + func(m_currentScene); + } + } + + public void Backup() + { + ForEach(delegate(Scene scene) + { + scene.Backup(); + }); + } + + public void HandleAlertCommand(string[] cmdparams) + { + ForEach(delegate(Scene scene) + { + scene.HandleAlertCommand(cmdparams); + }); + } + + public bool TrySetCurrentRegion(string regionName) + { + if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0)) + { + m_currentScene = null; + return true; + } + else + { + Console.WriteLine("Searching for Region: '" + regionName + "'"); + Scene foundScene = null; + + foreach (Scene scene in m_localScenes) + { + if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) + { + m_currentScene = scene; + return true; + } + } + + return false; + } + } + + public void DebugPacket(LogBase log, int newDebug) + { + ForEach(delegate(Scene scene) + { + foreach (EntityBase entity in scene.Entities.Values) + { + if (entity is ScenePresence) + { + ScenePresence scenePrescence = entity as ScenePresence; + if (!scenePrescence.childAgent) + { + log.Error(String.Format("Packet debug for {0} {1} set to {2}", + scenePrescence.Firstname, scenePrescence.Lastname, + newDebug)); + + scenePrescence.ControllingClient.SetDebug(newDebug); + } + } + } + }); + } + + public List GetAvatars() + { + List avatars = new List(); + + ForEach(delegate(Scene scene) + { + foreach (EntityBase entity in scene.Entities.Values) + { + if (entity is ScenePresence) + { + ScenePresence scenePrescence = entity as ScenePresence; + if (!scenePrescence.childAgent) + { + avatars.Add(scenePrescence); + } + } + } + }); + + return avatars; + } + + public RegionInfo GetRegionInfo(ulong regionHandle) + { + foreach (Scene scene in m_localScenes) + { + if (scene.RegionInfo.RegionHandle == regionHandle) + { + return scene.RegionInfo; + } + } + + return null; + } + + public void SetTimePhase(int timePhase) + { + ForEach(delegate(Scene scene) + { + scene.SetTimePhase( + timePhase) + ; + }); + } + + + public void ForceClientUpdate() + { + ForEach(delegate(Scene scene) + { + scene.ForceClientUpdate(); + }); + } + + public void HandleEditCommand(string[] cmdparams) + { + ForEach(delegate(Scene scene) + { + scene.HandleEditCommand(cmdparams); + }); + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs b/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs index 2f248cec42..7cf9cb7705 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs @@ -1,20 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; - -namespace OpenSim.Region.Environment.Scenes.Scripting -{ - public interface IScriptHost - { - string Name { get; set;} - string SitName{ get; set;} - string TouchName { get; set;} - string Description { get; set; } - LLUUID UUID { get; } - LLUUID ObjectOwner { get;} - LLUUID ObjectCreator { get; } - LLVector3 AbsolutePosition { get; } - void SetText(string text, Axiom.Math.Vector3 color, double alpha); - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Region.Environment.Scenes.Scripting +{ + public interface IScriptHost + { + string Name { get; set;} + string SitName{ get; set;} + string TouchName { get; set;} + string Description { get; set; } + LLUUID UUID { get; } + LLUUID ObjectOwner { get;} + LLUUID ObjectCreator { get; } + LLVector3 AbsolutePosition { get; } + void SetText(string text, Axiom.Math.Vector3 color, double alpha); + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs b/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs index 5e3dcae924..875e4cb34d 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs @@ -1,56 +1,56 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; - -namespace OpenSim.Region.Environment.Scenes.Scripting -{ - public class NullScriptHost : IScriptHost - { - - LLVector3 m_pos = new LLVector3( 128, 128, 30 ); - public string Name - { - get { return "Object"; } - set { } - } - - public string SitName - { - get { return ""; } - set { } - } - - public string TouchName - { - get { return ""; } - set { } - } - - public string Description - { - get { return ""; } - set { } - } - - public LLUUID UUID - { - get { return LLUUID.Zero; } - } - - public LLUUID ObjectOwner - { get { return LLUUID.Zero; } } - - public LLUUID ObjectCreator { get { return LLUUID.Zero; } } - - public LLVector3 AbsolutePosition - { - get { return m_pos; } - } - - public void SetText(string text, Axiom.Math.Vector3 color, double alpha) - { - Console.WriteLine("Tried to SetText [{0}] on NullScriptHost", text); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Region.Environment.Scenes.Scripting +{ + public class NullScriptHost : IScriptHost + { + + LLVector3 m_pos = new LLVector3( 128, 128, 30 ); + public string Name + { + get { return "Object"; } + set { } + } + + public string SitName + { + get { return ""; } + set { } + } + + public string TouchName + { + get { return ""; } + set { } + } + + public string Description + { + get { return ""; } + set { } + } + + public LLUUID UUID + { + get { return LLUUID.Zero; } + } + + public LLUUID ObjectOwner + { get { return LLUUID.Zero; } } + + public LLUUID ObjectCreator { get { return LLUUID.Zero; } } + + public LLVector3 AbsolutePosition + { + get { return m_pos; } + } + + public void SetText(string text, Axiom.Math.Vector3 color, double alpha) + { + Console.WriteLine("Tried to SetText [{0}] on NullScriptHost", text); + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs index d3d58fea18..5e8ff8705c 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs @@ -1,43 +1,43 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -/* Original code: Tedd Hansen */ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.Environment.Scenes.Scripting; - -//TODO: WHERE TO PLACE THIS? -namespace OpenSim.Region.Environment.Scenes.Scripting -{ - public interface ScriptEngineInterface - { - void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger); - void Shutdown(); -// void StartScript(string ScriptID, IScriptHost ObjectID); - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +/* Original code: Tedd Hansen */ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.Environment.Scenes.Scripting; + +//TODO: WHERE TO PLACE THIS? +namespace OpenSim.Region.Environment.Scenes.Scripting +{ + public interface ScriptEngineInterface + { + void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger); + void Shutdown(); +// void StartScript(string ScriptID, IScriptHost ObjectID); + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs index 35005453c4..83bd0ab5bb 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs @@ -1,124 +1,124 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -/* Original code: Tedd Hansen */ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Reflection; - -namespace OpenSim.Region.Environment.Scenes.Scripting -{ - public class ScriptEngineLoader - { - private OpenSim.Framework.Console.LogBase m_log; - public ScriptEngineLoader(OpenSim.Framework.Console.LogBase logger) - { - m_log = logger; - } - - public ScriptEngineInterface LoadScriptEngine(string EngineName) - { - ScriptEngineInterface ret = null; - try - { - ret = LoadAndInitAssembly(Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine." + EngineName + ".dll"), - "OpenSim.Region.ScriptEngine." + EngineName + ".ScriptEngine"); - } - catch (Exception e) - { - m_log.Error("ScriptEngine", "Error loading assembly \"" + EngineName + "\": " + e.Message + ", " + e.StackTrace.ToString()); - } - return ret; - } - - /// - /// Does actual loading and initialization of script Assembly - /// - /// AppDomain to load script into - /// FileName of script assembly (.dll) - /// - private ScriptEngineInterface LoadAndInitAssembly(string FileName, string NameSpace) - { - //Common.SendToDebug("Loading ScriptEngine Assembly " + FileName); - // Load .Net Assembly (.dll) - // Initialize and return it - - // TODO: Add error handling - - Assembly a; - //try - //{ - - - // Load to default appdomain (temporary) - a = Assembly.LoadFrom(FileName); - // Load to specified appdomain - // TODO: Insert security - //a = FreeAppDomain.Load(FileName); - //} - //catch (Exception e) - //{ - // m_log.Error("ScriptEngine", "Error loading assembly \"" + FileName + "\": " + e.ToString()); - //} - - - //Console.WriteLine("Loading: " + FileName); - //foreach (Type _t in a.GetTypes()) - //{ - // Console.WriteLine("Type: " + _t.ToString()); - //} - - Type t; - //try - //{ - t = a.GetType(NameSpace, true); - //} - //catch (Exception e) - //{ - // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString()); - //} - - ScriptEngineInterface ret; - //try - //{ - ret = (ScriptEngineInterface)Activator.CreateInstance(t); - //} - //catch (Exception e) - //{ - // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString()); - //} - - return ret; - - - } - - - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +/* Original code: Tedd Hansen */ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Reflection; + +namespace OpenSim.Region.Environment.Scenes.Scripting +{ + public class ScriptEngineLoader + { + private OpenSim.Framework.Console.LogBase m_log; + public ScriptEngineLoader(OpenSim.Framework.Console.LogBase logger) + { + m_log = logger; + } + + public ScriptEngineInterface LoadScriptEngine(string EngineName) + { + ScriptEngineInterface ret = null; + try + { + ret = LoadAndInitAssembly(Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine." + EngineName + ".dll"), + "OpenSim.Region.ScriptEngine." + EngineName + ".ScriptEngine"); + } + catch (Exception e) + { + m_log.Error("ScriptEngine", "Error loading assembly \"" + EngineName + "\": " + e.Message + ", " + e.StackTrace.ToString()); + } + return ret; + } + + /// + /// Does actual loading and initialization of script Assembly + /// + /// AppDomain to load script into + /// FileName of script assembly (.dll) + /// + private ScriptEngineInterface LoadAndInitAssembly(string FileName, string NameSpace) + { + //Common.SendToDebug("Loading ScriptEngine Assembly " + FileName); + // Load .Net Assembly (.dll) + // Initialize and return it + + // TODO: Add error handling + + Assembly a; + //try + //{ + + + // Load to default appdomain (temporary) + a = Assembly.LoadFrom(FileName); + // Load to specified appdomain + // TODO: Insert security + //a = FreeAppDomain.Load(FileName); + //} + //catch (Exception e) + //{ + // m_log.Error("ScriptEngine", "Error loading assembly \"" + FileName + "\": " + e.ToString()); + //} + + + //Console.WriteLine("Loading: " + FileName); + //foreach (Type _t in a.GetTypes()) + //{ + // Console.WriteLine("Type: " + _t.ToString()); + //} + + Type t; + //try + //{ + t = a.GetType(NameSpace, true); + //} + //catch (Exception e) + //{ + // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString()); + //} + + ScriptEngineInterface ret; + //try + //{ + ret = (ScriptEngineInterface)Activator.CreateInstance(t); + //} + //catch (Exception e) + //{ + // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString()); + //} + + return ret; + + + } + + + } +} diff --git a/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs b/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs index c7b0524f52..3b4dd9a1ff 100644 --- a/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs +++ b/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs @@ -1,167 +1,167 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.Environment.Types -{ - public class BasicQuadTreeNode - { - private List m_objects = new List(); - private BasicQuadTreeNode[] m_childNodes = null; - private BasicQuadTreeNode m_parent = null; - - private short m_leftX; - private short m_leftY; - private short m_width; - private short m_height; - - public BasicQuadTreeNode(BasicQuadTreeNode parent, short leftX, short leftY, short width, short height) - { - m_parent = parent; - m_leftX = leftX; - m_leftY = leftY; - m_width = width; - m_height = height; - } - - public void AddObject(SceneObjectGroup obj) - { - if (m_childNodes == null) - { - if (!m_objects.Contains(obj)) - { - m_objects.Add(obj); - } - } - else - { - if (obj.AbsolutePosition.X < (m_leftX + (m_width / 2))) - { - if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2))) - { - m_childNodes[0].AddObject(obj); - } - else - { - m_childNodes[2].AddObject(obj); - } - } - else - { - if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2))) - { - m_childNodes[1].AddObject(obj); - } - else - { - m_childNodes[3].AddObject(obj); - } - } - } - } - - public void Subdivide() - { - if (m_childNodes == null) - { - m_childNodes = new BasicQuadTreeNode[4]; - m_childNodes[0] = new BasicQuadTreeNode(this, m_leftX, m_leftY,(short) (m_width / 2), (short)( m_height / 2)); - m_childNodes[1] = new BasicQuadTreeNode(this,(short)( m_leftX + (m_width / 2)), m_leftY,(short)( m_width / 2),(short) (m_height / 2)); - m_childNodes[2] = new BasicQuadTreeNode(this, m_leftX, (short)( m_leftY + (m_height / 2)), (short)(m_width / 2),(short)( m_height / 2)); - m_childNodes[3] = new BasicQuadTreeNode(this, (short)( m_leftX + (m_width / 2)),(short)( m_height + (m_height / 2)),(short)( m_width / 2), (short)(m_height / 2)); - } - else - { - for (int i = 0; i < m_childNodes.Length; i++) - { - m_childNodes[i].Subdivide(); - } - } - } - - public List GetObjectsFrom(int x, int y) - { - if (m_childNodes == null) - { - return m_objects; - } - else - { - if (x < (m_leftX + (m_width / 2))) - { - if (y < (m_leftY + (m_height / 2))) - { - return m_childNodes[0].GetObjectsFrom(x, y); - } - else - { - return m_childNodes[2].GetObjectsFrom(x, y); - } - } - else - { - if (y < (m_leftY + (m_height / 2))) - { - return m_childNodes[1].GetObjectsFrom(x, y); - } - else - { - return m_childNodes[3].GetObjectsFrom(x, y); - } - } - } - } - - public void Update() - { - if (m_childNodes != null) - { - for (int i = 0; i < 4; i++) - { - m_childNodes[i].Update(); - } - } - else - { - List outBounds = new List(); - foreach (SceneObjectGroup group in m_objects) - { - if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) && ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height)))) - { - //still in bounds - } - else - { - outBounds.Add(group); - } - } - - foreach (SceneObjectGroup removee in outBounds) - { - m_objects.Remove(removee); - if (m_parent != null) - { - m_parent.PassUp(removee); - } - } - outBounds.Clear(); - } - } - - public void PassUp(SceneObjectGroup group) - { - if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) && ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height)))) - { - this.AddObject(group); - } - else - { - if (m_parent != null) - { - m_parent.PassUp(group); - } - } - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.Environment.Scenes; + +namespace OpenSim.Region.Environment.Types +{ + public class BasicQuadTreeNode + { + private List m_objects = new List(); + private BasicQuadTreeNode[] m_childNodes = null; + private BasicQuadTreeNode m_parent = null; + + private short m_leftX; + private short m_leftY; + private short m_width; + private short m_height; + + public BasicQuadTreeNode(BasicQuadTreeNode parent, short leftX, short leftY, short width, short height) + { + m_parent = parent; + m_leftX = leftX; + m_leftY = leftY; + m_width = width; + m_height = height; + } + + public void AddObject(SceneObjectGroup obj) + { + if (m_childNodes == null) + { + if (!m_objects.Contains(obj)) + { + m_objects.Add(obj); + } + } + else + { + if (obj.AbsolutePosition.X < (m_leftX + (m_width / 2))) + { + if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2))) + { + m_childNodes[0].AddObject(obj); + } + else + { + m_childNodes[2].AddObject(obj); + } + } + else + { + if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2))) + { + m_childNodes[1].AddObject(obj); + } + else + { + m_childNodes[3].AddObject(obj); + } + } + } + } + + public void Subdivide() + { + if (m_childNodes == null) + { + m_childNodes = new BasicQuadTreeNode[4]; + m_childNodes[0] = new BasicQuadTreeNode(this, m_leftX, m_leftY,(short) (m_width / 2), (short)( m_height / 2)); + m_childNodes[1] = new BasicQuadTreeNode(this,(short)( m_leftX + (m_width / 2)), m_leftY,(short)( m_width / 2),(short) (m_height / 2)); + m_childNodes[2] = new BasicQuadTreeNode(this, m_leftX, (short)( m_leftY + (m_height / 2)), (short)(m_width / 2),(short)( m_height / 2)); + m_childNodes[3] = new BasicQuadTreeNode(this, (short)( m_leftX + (m_width / 2)),(short)( m_height + (m_height / 2)),(short)( m_width / 2), (short)(m_height / 2)); + } + else + { + for (int i = 0; i < m_childNodes.Length; i++) + { + m_childNodes[i].Subdivide(); + } + } + } + + public List GetObjectsFrom(int x, int y) + { + if (m_childNodes == null) + { + return m_objects; + } + else + { + if (x < (m_leftX + (m_width / 2))) + { + if (y < (m_leftY + (m_height / 2))) + { + return m_childNodes[0].GetObjectsFrom(x, y); + } + else + { + return m_childNodes[2].GetObjectsFrom(x, y); + } + } + else + { + if (y < (m_leftY + (m_height / 2))) + { + return m_childNodes[1].GetObjectsFrom(x, y); + } + else + { + return m_childNodes[3].GetObjectsFrom(x, y); + } + } + } + } + + public void Update() + { + if (m_childNodes != null) + { + for (int i = 0; i < 4; i++) + { + m_childNodes[i].Update(); + } + } + else + { + List outBounds = new List(); + foreach (SceneObjectGroup group in m_objects) + { + if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) && ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height)))) + { + //still in bounds + } + else + { + outBounds.Add(group); + } + } + + foreach (SceneObjectGroup removee in outBounds) + { + m_objects.Remove(removee); + if (m_parent != null) + { + m_parent.PassUp(removee); + } + } + outBounds.Clear(); + } + } + + public void PassUp(SceneObjectGroup group) + { + if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) && ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height)))) + { + this.AddObject(group); + } + else + { + if (m_parent != null) + { + m_parent.PassUp(group); + } + } + } + } +} diff --git a/OpenSim/Region/Environment/Types/UpdateQueue.cs b/OpenSim/Region/Environment/Types/UpdateQueue.cs index dab4258cde..3b7c18256e 100644 --- a/OpenSim/Region/Environment/Types/UpdateQueue.cs +++ b/OpenSim/Region/Environment/Types/UpdateQueue.cs @@ -1,54 +1,54 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.Environment.Scenes; -using libsecondlife; - -namespace OpenSim.Region.Environment.Types -{ - public class UpdateQueue - { - private Queue m_queue; - - private List m_ids; - - public int Count - { - get { return m_queue.Count; } - } - - public UpdateQueue() - { - m_queue = new Queue(); - m_ids = new List(); - } - - public void Enqueue(SceneObjectPart part) - { - lock (m_ids) - { - if (!m_ids.Contains(part.UUID)) - { - m_ids.Add(part.UUID); - m_queue.Enqueue(part); - } - } - } - - public SceneObjectPart Dequeue() - { - SceneObjectPart part = null; - if (m_queue.Count > 0) - { - part = m_queue.Dequeue(); - lock (m_ids) - { - m_ids.Remove(part.UUID); - } - } - - return part; - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.Environment.Scenes; +using libsecondlife; + +namespace OpenSim.Region.Environment.Types +{ + public class UpdateQueue + { + private Queue m_queue; + + private List m_ids; + + public int Count + { + get { return m_queue.Count; } + } + + public UpdateQueue() + { + m_queue = new Queue(); + m_ids = new List(); + } + + public void Enqueue(SceneObjectPart part) + { + lock (m_ids) + { + if (!m_ids.Contains(part.UUID)) + { + m_ids.Add(part.UUID); + m_queue.Enqueue(part); + } + } + } + + public SceneObjectPart Dequeue() + { + SceneObjectPart part = null; + if (m_queue.Count > 0) + { + part = m_queue.Dequeue(); + lock (m_ids) + { + m_ids.Remove(part.UUID); + } + } + + return part; + } + + } +} diff --git a/OpenSim/Region/Examples/SimpleApp/ComplexObject.cs b/OpenSim/Region/Examples/SimpleApp/ComplexObject.cs index 01af4f0a2b..50154de74a 100644 --- a/OpenSim/Region/Examples/SimpleApp/ComplexObject.cs +++ b/OpenSim/Region/Examples/SimpleApp/ComplexObject.cs @@ -1,78 +1,78 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.Environment.Scenes; -using Axiom.Math; -using libsecondlife; -using OpenSim.Framework.Types; -using OpenSim.Framework.Interfaces; - -namespace SimpleApp -{ - public class ComplexObject : SceneObjectGroup - { - private LLQuaternion m_rotationDirection; - - private class RotatingWheel : SceneObjectPart - { - private LLQuaternion m_rotationDirection; - - public RotatingWheel(ulong regionHandle, SceneObjectGroup parent, LLUUID ownerID, uint localID, LLVector3 groupPosition, LLVector3 offsetPosition, LLQuaternion rotationDirection) - : base(regionHandle, parent, ownerID, localID, new CylinderShape( 0.5f, 0.2f ), groupPosition, offsetPosition ) - { - m_rotationDirection = rotationDirection; - } - - public override void UpdateMovement() - { - UpdateRotation(RotationOffset * m_rotationDirection); - } - } - - public override void UpdateMovement() - { - UpdateGroupRotation(GroupRotation * m_rotationDirection); - - base.UpdateMovement(); - } - - - - public ComplexObject(Scene scene, ulong regionHandle, LLUUID ownerID, uint localID, LLVector3 pos ) - : base(scene, regionHandle, ownerID, localID, pos, BoxShape.Default ) - { - m_rotationDirection = new LLQuaternion(0.05f, 0.1f, 0.15f); - - AddPart(new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, 0, 0.75f), new LLQuaternion(0.05f,0,0))); - AddPart(new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, 0, -0.75f), new LLQuaternion(-0.05f,0,0))); - - AddPart(new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, 0.75f,0), new LLQuaternion(0.5f, 0, 0.05f))); - AddPart(new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, -0.75f,0), new LLQuaternion(-0.5f, 0, -0.05f))); - - AddPart(new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0.75f, 0, 0), new LLQuaternion(0, 0.5f, 0.05f))); - AddPart(new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(-0.75f, 0, 0), new LLQuaternion(0, -0.5f, -0.05f))); - - UpdateParentIDs(); - } - - public override void OnGrabPart(SceneObjectPart part, LLVector3 offsetPos, IClientAPI remoteClient) - { - m_parts.Remove(part.UUID); - remoteClient.SendKillObject(m_regionHandle, part.LocalID); - remoteClient.AddMoney(1); - remoteClient.SendChatMessage("Poof!", 1, this.AbsolutePosition, "Party Party", LLUUID.Zero); - } - - public override void OnGrabGroup( LLVector3 offsetPos, IClientAPI remoteClient) - { - if( m_parts.Count == 1 ) - { - m_parts.Remove(m_rootPart.UUID); - m_scene.RemoveEntity(this); - remoteClient.SendKillObject(m_regionHandle, m_rootPart.LocalID); - remoteClient.AddMoney(50); - remoteClient.SendChatMessage("KABLAM!!!", 1, AbsolutePosition, "Groupie Groupie", LLUUID.Zero); - } - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.Environment.Scenes; +using Axiom.Math; +using libsecondlife; +using OpenSim.Framework.Types; +using OpenSim.Framework.Interfaces; + +namespace SimpleApp +{ + public class ComplexObject : SceneObjectGroup + { + private LLQuaternion m_rotationDirection; + + private class RotatingWheel : SceneObjectPart + { + private LLQuaternion m_rotationDirection; + + public RotatingWheel(ulong regionHandle, SceneObjectGroup parent, LLUUID ownerID, uint localID, LLVector3 groupPosition, LLVector3 offsetPosition, LLQuaternion rotationDirection) + : base(regionHandle, parent, ownerID, localID, new CylinderShape( 0.5f, 0.2f ), groupPosition, offsetPosition ) + { + m_rotationDirection = rotationDirection; + } + + public override void UpdateMovement() + { + UpdateRotation(RotationOffset * m_rotationDirection); + } + } + + public override void UpdateMovement() + { + UpdateGroupRotation(GroupRotation * m_rotationDirection); + + base.UpdateMovement(); + } + + + + public ComplexObject(Scene scene, ulong regionHandle, LLUUID ownerID, uint localID, LLVector3 pos ) + : base(scene, regionHandle, ownerID, localID, pos, BoxShape.Default ) + { + m_rotationDirection = new LLQuaternion(0.05f, 0.1f, 0.15f); + + AddPart(new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, 0, 0.75f), new LLQuaternion(0.05f,0,0))); + AddPart(new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, 0, -0.75f), new LLQuaternion(-0.05f,0,0))); + + AddPart(new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, 0.75f,0), new LLQuaternion(0.5f, 0, 0.05f))); + AddPart(new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, -0.75f,0), new LLQuaternion(-0.5f, 0, -0.05f))); + + AddPart(new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0.75f, 0, 0), new LLQuaternion(0, 0.5f, 0.05f))); + AddPart(new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(-0.75f, 0, 0), new LLQuaternion(0, -0.5f, -0.05f))); + + UpdateParentIDs(); + } + + public override void OnGrabPart(SceneObjectPart part, LLVector3 offsetPos, IClientAPI remoteClient) + { + m_parts.Remove(part.UUID); + remoteClient.SendKillObject(m_regionHandle, part.LocalID); + remoteClient.AddMoney(1); + remoteClient.SendChatMessage("Poof!", 1, this.AbsolutePosition, "Party Party", LLUUID.Zero); + } + + public override void OnGrabGroup( LLVector3 offsetPos, IClientAPI remoteClient) + { + if( m_parts.Count == 1 ) + { + m_parts.Remove(m_rootPart.UUID); + m_scene.RemoveEntity(this); + remoteClient.SendKillObject(m_regionHandle, m_rootPart.LocalID); + remoteClient.AddMoney(50); + remoteClient.SendChatMessage("KABLAM!!!", 1, AbsolutePosition, "Groupie Groupie", LLUUID.Zero); + } + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs index 1cf2989eb2..d4b27fc8af 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs @@ -1,103 +1,103 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.CodeDom.Compiler; -using System.Collections.Generic; -using Microsoft.CSharp; -using OpenSim.Framework.Console; - -namespace OpenSim.Region.ExtensionsScriptModule.CSharp -{ - public class CSharpScriptEngine : IScriptCompiler - { - public string FileExt() - { - return ".cs"; - } - - private Dictionary LoadDotNetScript(CodeDomProvider compiler, string filename) - { - CompilerParameters compilerParams = new CompilerParameters(); - CompilerResults compilerResults; - compilerParams.GenerateExecutable = false; - compilerParams.GenerateInMemory = true; - compilerParams.IncludeDebugInformation = false; - compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ClientStack.dll"); - compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll"); - compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ExtensionsScriptModule.dll"); - compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); - compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); - compilerParams.ReferencedAssemblies.Add("System.dll"); - - compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename); - - if (compilerResults.Errors.Count > 0) - { - MainLog.Instance.Error("Compile errors"); - foreach (CompilerError error in compilerResults.Errors) - { - MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString()); - } - } - else - { - Dictionary scripts = new Dictionary(); - - foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) - { - Type testInterface = pluginType.GetInterface("IScript", true); - - if (testInterface != null) - { - IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); - - string scriptName = "C#/" + script.Name; - Console.WriteLine("Script: " + scriptName + " loaded."); - - if (!scripts.ContainsKey(scriptName)) - { - scripts.Add(scriptName, script); - } - else - { - scripts[scriptName] = script; - } - } - } - return scripts; - } - return null; - } - - public Dictionary compile(string filename) - { - CSharpCodeProvider csharpProvider = new CSharpCodeProvider(); - return LoadDotNetScript(csharpProvider, filename); - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using Microsoft.CSharp; +using OpenSim.Framework.Console; + +namespace OpenSim.Region.ExtensionsScriptModule.CSharp +{ + public class CSharpScriptEngine : IScriptCompiler + { + public string FileExt() + { + return ".cs"; + } + + private Dictionary LoadDotNetScript(CodeDomProvider compiler, string filename) + { + CompilerParameters compilerParams = new CompilerParameters(); + CompilerResults compilerResults; + compilerParams.GenerateExecutable = false; + compilerParams.GenerateInMemory = true; + compilerParams.IncludeDebugInformation = false; + compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ClientStack.dll"); + compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll"); + compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ExtensionsScriptModule.dll"); + compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); + compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); + compilerParams.ReferencedAssemblies.Add("System.dll"); + + compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename); + + if (compilerResults.Errors.Count > 0) + { + MainLog.Instance.Error("Compile errors"); + foreach (CompilerError error in compilerResults.Errors) + { + MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString()); + } + } + else + { + Dictionary scripts = new Dictionary(); + + foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) + { + Type testInterface = pluginType.GetInterface("IScript", true); + + if (testInterface != null) + { + IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); + + string scriptName = "C#/" + script.Name; + Console.WriteLine("Script: " + scriptName + " loaded."); + + if (!scripts.ContainsKey(scriptName)) + { + scripts.Add(scriptName, script); + } + else + { + scripts[scriptName] = script; + } + } + } + return scripts; + } + return null; + } + + public Dictionary compile(string filename) + { + CSharpCodeProvider csharpProvider = new CSharpCodeProvider(); + return LoadDotNetScript(csharpProvider, filename); + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs index 90d3438229..466a902438 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs @@ -1,72 +1,72 @@ -using OpenSim.Framework.Console; -using OpenSim.Framework; -using OpenSim.Region.Environment; -using OpenSim.Region.Environment.Scenes; - -using System.Collections.Generic; -using libsecondlife; - -namespace OpenSim.Region.ExtensionsScriptModule.CSharp.Examples -{ - public class LSLExportScript : IScript - { - ScriptInfo script; - - public string Name - { - get { return "LSL Export Script 0.1"; } - } - - public void Initialise(ScriptInfo scriptInfo) - { - script = scriptInfo; - - script.events.OnScriptConsole += new EventManager.OnScriptConsoleDelegate(ProcessConsoleMsg); - } - - void ProcessConsoleMsg(string[] args) - { - /*if (args[0].ToLower() == "lslexport") - { - string sequence = ""; - - foreach (KeyValuePair obj in script.world.Objects) - { - SceneObject root = obj.Value; - - sequence += "NEWOBJ::" + obj.Key.ToStringHyphenated() + "\n"; - - string rootPrim = processPrimitiveToString(root.rootPrimitive); - - sequence += "ROOT:" + rootPrim; - - foreach (KeyValuePair prim in root.Children) - { - string child = processPrimitiveToString(prim.Value); - sequence += "CHILD:" + child; - } - } - - System.Console.WriteLine(sequence); - }*/ - } - - string processPrimitiveToString(OpenSim.Region.Environment.Scenes.SceneObjectPart prim) - { - /*string desc = prim.Description; - string name = prim.Name; - LLVector3 pos = prim.Pos; - LLQuaternion rot = new LLQuaternion(prim.Rotation.x, prim.Rotation.y, prim.Rotation.z, prim.Rotation.w); - LLVector3 scale = prim.Scale; - LLVector3 rootPos = prim.WorldPos; - - string setPrimParams = ""; - - setPrimParams += "[PRIM_SCALE, " + scale.ToString() + ", PRIM_POS, " + rootPos.ToString() + ", PRIM_ROTATION, " + rot.ToString() + "]\n"; - - return setPrimParams; - */ - return ""; - } - } +using OpenSim.Framework.Console; +using OpenSim.Framework; +using OpenSim.Region.Environment; +using OpenSim.Region.Environment.Scenes; + +using System.Collections.Generic; +using libsecondlife; + +namespace OpenSim.Region.ExtensionsScriptModule.CSharp.Examples +{ + public class LSLExportScript : IScript + { + ScriptInfo script; + + public string Name + { + get { return "LSL Export Script 0.1"; } + } + + public void Initialise(ScriptInfo scriptInfo) + { + script = scriptInfo; + + script.events.OnScriptConsole += new EventManager.OnScriptConsoleDelegate(ProcessConsoleMsg); + } + + void ProcessConsoleMsg(string[] args) + { + /*if (args[0].ToLower() == "lslexport") + { + string sequence = ""; + + foreach (KeyValuePair obj in script.world.Objects) + { + SceneObject root = obj.Value; + + sequence += "NEWOBJ::" + obj.Key.ToStringHyphenated() + "\n"; + + string rootPrim = processPrimitiveToString(root.rootPrimitive); + + sequence += "ROOT:" + rootPrim; + + foreach (KeyValuePair prim in root.Children) + { + string child = processPrimitiveToString(prim.Value); + sequence += "CHILD:" + child; + } + } + + System.Console.WriteLine(sequence); + }*/ + } + + string processPrimitiveToString(OpenSim.Region.Environment.Scenes.SceneObjectPart prim) + { + /*string desc = prim.Description; + string name = prim.Name; + LLVector3 pos = prim.Pos; + LLQuaternion rot = new LLQuaternion(prim.Rotation.x, prim.Rotation.y, prim.Rotation.z, prim.Rotation.w); + LLVector3 scale = prim.Scale; + LLVector3 rootPos = prim.WorldPos; + + string setPrimParams = ""; + + setPrimParams += "[PRIM_SCALE, " + scale.ToString() + ", PRIM_POS, " + rootPos.ToString() + ", PRIM_ROTATION, " + rot.ToString() + "]\n"; + + return setPrimParams; + */ + return ""; + } + } } \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs index 4750848cd1..4bde721eef 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs @@ -1,103 +1,103 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.CodeDom.Compiler; -using System.Collections.Generic; -using Microsoft.JScript; -using OpenSim.Framework.Console; - -namespace OpenSim.Region.ExtensionsScriptModule.JScript -{ - public class JScriptEngine : IScriptCompiler - { - public string FileExt() - { - return ".js"; - } - - private Dictionary LoadDotNetScript(CodeDomProvider compiler, string filename) - { - CompilerParameters compilerParams = new CompilerParameters(); - CompilerResults compilerResults; - compilerParams.GenerateExecutable = false; - compilerParams.GenerateInMemory = true; - compilerParams.IncludeDebugInformation = false; - compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ClientStack.dll"); - compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll"); - compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ExtensionsScriptModule.dll"); - compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); - compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); - compilerParams.ReferencedAssemblies.Add("System.dll"); - - compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename); - - if (compilerResults.Errors.Count > 0) - { - MainLog.Instance.Error("Compile errors"); - foreach (CompilerError error in compilerResults.Errors) - { - MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString()); - } - } - else - { - Dictionary scripts = new Dictionary(); - - foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) - { - Type testInterface = pluginType.GetInterface("IScript", true); - - if (testInterface != null) - { - IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); - - string scriptName = "JS.NET/" + script.Name; - Console.WriteLine("Script: " + scriptName + " loaded."); - - if (!scripts.ContainsKey(scriptName)) - { - scripts.Add(scriptName, script); - } - else - { - scripts[scriptName] = script; - } - } - } - return scripts; - } - return null; - } - - public Dictionary compile(string filename) - { - JScriptCodeProvider jscriptProvider = new JScriptCodeProvider(); - return LoadDotNetScript(jscriptProvider, filename); - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using Microsoft.JScript; +using OpenSim.Framework.Console; + +namespace OpenSim.Region.ExtensionsScriptModule.JScript +{ + public class JScriptEngine : IScriptCompiler + { + public string FileExt() + { + return ".js"; + } + + private Dictionary LoadDotNetScript(CodeDomProvider compiler, string filename) + { + CompilerParameters compilerParams = new CompilerParameters(); + CompilerResults compilerResults; + compilerParams.GenerateExecutable = false; + compilerParams.GenerateInMemory = true; + compilerParams.IncludeDebugInformation = false; + compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ClientStack.dll"); + compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll"); + compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ExtensionsScriptModule.dll"); + compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); + compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); + compilerParams.ReferencedAssemblies.Add("System.dll"); + + compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename); + + if (compilerResults.Errors.Count > 0) + { + MainLog.Instance.Error("Compile errors"); + foreach (CompilerError error in compilerResults.Errors) + { + MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString()); + } + } + else + { + Dictionary scripts = new Dictionary(); + + foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) + { + Type testInterface = pluginType.GetInterface("IScript", true); + + if (testInterface != null) + { + IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); + + string scriptName = "JS.NET/" + script.Name; + Console.WriteLine("Script: " + scriptName + " loaded."); + + if (!scripts.ContainsKey(scriptName)) + { + scripts.Add(scriptName, script); + } + else + { + scripts[scriptName] = script; + } + } + } + return scripts; + } + return null; + } + + public Dictionary compile(string filename) + { + JScriptCodeProvider jscriptProvider = new JScriptCodeProvider(); + return LoadDotNetScript(jscriptProvider, filename); + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs index a4b940d8ba..6100c674c9 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs @@ -1,46 +1,46 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM -{ - public class ClassInstance : Object - { - public int Size; - public ClassRecord ClassRec; - public Dictionary Fields = new Dictionary(); - - public ClassInstance() - { - - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + public class ClassInstance : Object + { + public int Size; + public ClassRecord ClassRec; + public Dictionary Fields = new Dictionary(); + + public ClassInstance() + { + + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs index 348a452c66..5c3629c42b 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs @@ -1,640 +1,640 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.IO; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM -{ - public class ClassRecord - { - private ushort m_majorVersion; - private ushort m_minorVersion; - private ushort m_constantPoolCount; - private ushort m_accessFlags; - private ushort m_thisClass; - private ushort m_supperClass; - private ushort m_interfaceCount; - private ushort m_fieldCount; - private ushort m_methodCount; - //private ushort _attributeCount; - //private string _name; - public Dictionary StaticFields = new Dictionary(); - public PoolClass MClass; - - public List m_constantsPool = new List(); - private List m_methodsList = new List(); - private List m_fieldList = new List(); - - public ClassRecord() - { - - } - - public ClassInstance CreateNewInstance() - { - ClassInstance classInst = new ClassInstance(); - classInst.ClassRec = this; - //TODO: set fields - - return classInst; - } - - public void LoadClassFromFile(string fileName) - { - Console.WriteLine("loading script " + fileName); - FileStream fs = File.OpenRead(fileName); - this.LoadClassFromBytes(ReadFully(fs)); - fs.Close(); - } - - public void LoadClassFromBytes(byte[] data) - { - int i = 0; - i += 4; - m_minorVersion = (ushort)((data[i++] << 8) + data[i++]); - m_majorVersion = (ushort)((data[i++] << 8) + data[i++]); - m_constantPoolCount = (ushort)((data[i++] << 8) + data[i++]); - Console.WriteLine("there should be " + m_constantPoolCount + " items in the pool"); - for (int count = 0; count < (m_constantPoolCount - 1); count++) - { - //read in the constant pool - byte pooltype = data[i++]; - Console.WriteLine("#" + count + ": new constant type = " + pooltype); - //Console.WriteLine("start position is: " + i); - switch (pooltype) - { - case 1: //Utf8 - ushort uLength = (ushort)((data[i++] << 8) + data[i++]); - - // Console.WriteLine("new utf8 type, length is " + uLength); - PoolUtf8 utf8 = new PoolUtf8(); - utf8.readValue(data, ref i, uLength); - this.m_constantsPool.Add(utf8); - break; - case 3: //Int - break; - case 4: //Float - break; - case 7: //Class - PoolClass pClass = new PoolClass(this); - pClass.readValue(data, ref i); - this.m_constantsPool.Add(pClass); - break; - case 9: //FieldRef - PoolFieldRef pField = new PoolFieldRef(this); - pField.readValue(data, ref i); - this.m_constantsPool.Add(pField); - break; - case 10: //Method - PoolMethodRef pMeth = new PoolMethodRef(this); - pMeth.readValue(data, ref i); - this.m_constantsPool.Add(pMeth); - break; - case 12: //NamedType - PoolNamedType pNamed = new PoolNamedType(this); - pNamed.readValue(data, ref i); - this.m_constantsPool.Add(pNamed); - break; - } - } - - m_accessFlags = (ushort)((data[i++] << 8) + data[i++]); - m_thisClass = (ushort)((data[i++] << 8) + data[i++]); - m_supperClass = (ushort)((data[i++] << 8) + data[i++]); - - if (this.m_constantsPool[this.m_thisClass - 1] is PoolClass) - { - this.MClass = ((PoolClass)this.m_constantsPool[this.m_thisClass - 1]); - } - - m_interfaceCount = (ushort)((data[i++] << 8) + data[i++]); - //should now read in the info for each interface - - m_fieldCount = (ushort)((data[i++] << 8) + data[i++]); - //should now read in the info for each field - for (int count = 0; count < m_fieldCount; count++) - { - FieldInfo fieldInf = new FieldInfo(this); - fieldInf.ReadData(data, ref i); - this.m_fieldList.Add(fieldInf); - } - - m_methodCount = (ushort)((data[i++] << 8) + data[i++]); - for (int count = 0; count < m_methodCount; count++) - { - MethodInfo methInf = new MethodInfo(this); - methInf.ReadData(data, ref i); - this.m_methodsList.Add(methInf); - } - } - - public void AddMethodsToMemory(MethodMemory memory) - { - for (int count = 0; count < m_methodCount; count++) - { - this.m_methodsList[count].AddMethodCode(memory); - } - } - - public bool StartMethod(Thread thread, string methodName) - { - for (int count = 0; count < m_methodCount; count++) - { - if (this.m_constantsPool[this.m_methodsList[count].NameIndex - 1] is PoolUtf8) - { - if (((PoolUtf8)this.m_constantsPool[this.m_methodsList[count].NameIndex - 1]).Value == methodName) - { - //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value); - thread.SetPC(this.m_methodsList[count].CodePointer); - return true; - } - } - } - return false; - } - - public void PrintToConsole() - { - Console.WriteLine("Class File:"); - Console.WriteLine("Major version: " + m_majorVersion); - Console.WriteLine("Minor version: " + m_minorVersion); - Console.WriteLine("Pool size: " + m_constantPoolCount); - - for (int i = 0; i < m_constantsPool.Count; i++) - { - this.m_constantsPool[i].Print(); - } - - Console.WriteLine("Access flags: " + m_accessFlags); - Console.WriteLine("This class: " + m_thisClass); - Console.WriteLine("Super class: " + m_supperClass); - - for (int count = 0; count < m_fieldCount; count++) - { - Console.WriteLine(); - this.m_fieldList[count].Print(); - } - - for (int count = 0; count < m_methodCount; count++) - { - Console.WriteLine(); - this.m_methodsList[count].Print(); - } - - Console.WriteLine("class name is " + this.MClass.Name.Value); - } - - public static byte[] ReadFully(Stream stream) - { - byte[] buffer = new byte[1024]; - using (MemoryStream ms = new MemoryStream()) - { - while (true) - { - int read = stream.Read(buffer, 0, buffer.Length); - if (read <= 0) - return ms.ToArray(); - ms.Write(buffer, 0, read); - } - } - } - - #region nested classes - public class PoolItem - { - public virtual void Print() - { - - } - } - - public class PoolUtf8 : PoolItem - { - public string Value = ""; - - public void readValue(byte[] data, ref int pointer, int length) - { - for (int i = 0; i < length; i++) - { - int a = (int)data[pointer++]; - if ((a & 0x80) == 0) - { - Value = Value + (char)a; - } - else if ((a & 0x20) == 0) - { - int b = (int)data[pointer++]; - Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f)); - } - else - { - int b = (int)data[pointer++]; - int c = (int)data[pointer++]; - Value = Value + (char)(((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f)); - } - } - } - - public override void Print() - { - Console.WriteLine("Utf8 type: " + Value); - } - } - - private class PoolInt : PoolItem - { - - } - - public class PoolClass : PoolItem - { - //public string name = ""; - public ushort namePointer = 0; - private ClassRecord parent; - public PoolUtf8 Name; - - public PoolClass(ClassRecord paren) - { - parent = paren; - } - - public void readValue(byte[] data, ref int pointer) - { - namePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); - } - - public override void Print() - { - this.Name = ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]); - Console.Write("Class type: " + namePointer); - Console.WriteLine(" // " + ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]).Value); - - } - } - - public class PoolFieldRef : PoolItem - { - public ushort classPointer = 0; - public ushort nameTypePointer = 0; - public PoolNamedType mNameType; - public PoolClass mClass; - private ClassRecord parent; - - public PoolFieldRef(ClassRecord paren) - { - parent = paren; - } - - public void readValue(byte[] data, ref int pointer) - { - classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]); - nameTypePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); - } - - public override void Print() - { - this.mNameType = ((PoolNamedType)this.parent.m_constantsPool[nameTypePointer - 1]); - this.mClass = ((PoolClass)this.parent.m_constantsPool[classPointer - 1]); - Console.WriteLine("FieldRef type: " + classPointer + " , " + nameTypePointer); - } - } - - public class PoolMethodRef : PoolItem - { - public ushort classPointer = 0; - public ushort nameTypePointer = 0; - public PoolNamedType mNameType; - public PoolClass mClass; - private ClassRecord parent; - - public PoolMethodRef(ClassRecord paren) - { - parent = paren; - } - - public void readValue(byte[] data, ref int pointer) - { - classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]); - nameTypePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); - } - - public override void Print() - { - this.mNameType = ((PoolNamedType)this.parent.m_constantsPool[nameTypePointer - 1]); - this.mClass = ((PoolClass)this.parent.m_constantsPool[classPointer - 1]); - Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer); - } - } - - public class PoolNamedType : PoolItem - { - public ushort namePointer = 0; - public ushort typePointer = 0; - private ClassRecord parent; - public PoolUtf8 Name; - public PoolUtf8 Type; - - public PoolNamedType(ClassRecord paren) - { - parent = paren; - } - - public void readValue(byte[] data, ref int pointer) - { - namePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); - typePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); - } - - public override void Print() - { - Name = ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]); - Type = ((PoolUtf8)this.parent.m_constantsPool[typePointer - 1]); - Console.Write("Named type: " + namePointer + " , " + typePointer); - Console.WriteLine(" // " + ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]).Value); - } - } - - //*********************** - public class MethodInfo - { - public ushort AccessFlags = 0; - public ushort NameIndex = 0; - public string Name = ""; - public ushort DescriptorIndex = 0; - public ushort AttributeCount = 0; - public List Attributes = new List(); - private ClassRecord parent; - public int CodePointer = 0; - - public MethodInfo(ClassRecord paren) - { - parent = paren; - } - - public void AddMethodCode(MethodMemory memory) - { - Array.Copy(this.Attributes[0].Code, 0, memory.MethodBuffer, memory.NextMethodPC, this.Attributes[0].Code.Length); - memory.Methodcount++; - this.CodePointer = memory.NextMethodPC; - memory.NextMethodPC += this.Attributes[0].Code.Length; - } - - public void ReadData(byte[] data, ref int pointer) - { - AccessFlags = (ushort)((data[pointer++] << 8) + data[pointer++]); - NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); - DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); - AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); - for (int i = 0; i < AttributeCount; i++) - { - MethodAttribute attri = new MethodAttribute(this.parent); - attri.ReadData(data, ref pointer); - this.Attributes.Add(attri); - } - } - - public void Print() - { - Console.WriteLine("Method Info Struct: "); - Console.WriteLine("AccessFlags: " + AccessFlags); - Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); - Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value); - Console.WriteLine("Attribute Count:" + AttributeCount); - for (int i = 0; i < AttributeCount; i++) - { - this.Attributes[i].Print(); - } - } - - public class MethodAttribute - { - public ushort NameIndex = 0; - public string Name = ""; - public Int32 Length = 0; - //for now only support code attribute - public ushort MaxStack = 0; - public ushort MaxLocals = 0; - public Int32 CodeLength = 0; - public byte[] Code; - public ushort ExceptionTableLength = 0; - public ushort SubAttributeCount = 0; - public List SubAttributes = new List(); - private ClassRecord parent; - - public MethodAttribute(ClassRecord paren) - { - parent = paren; - } - - public void ReadData(byte[] data, ref int pointer) - { - NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); - Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); - MaxStack = (ushort)((data[pointer++] << 8) + data[pointer++]); - MaxLocals = (ushort)((data[pointer++] << 8) + data[pointer++]); - CodeLength = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); - Code = new byte[CodeLength]; - for (int i = 0; i < CodeLength; i++) - { - Code[i] = data[pointer++]; - } - ExceptionTableLength = (ushort)((data[pointer++] << 8) + data[pointer++]); - SubAttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); - for (int i = 0; i < SubAttributeCount; i++) - { - SubAttribute subAttri = new SubAttribute(this.parent); - subAttri.ReadData(data, ref pointer); - this.SubAttributes.Add(subAttri); - } - } - - public void Print() - { - Console.WriteLine("Method Attribute: "); - Console.WriteLine("Name Index: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); - Console.WriteLine("Length: " + Length); - Console.WriteLine("MaxStack: " + MaxStack); - Console.WriteLine("MaxLocals: " + MaxLocals); - Console.WriteLine("CodeLength: " + CodeLength); - for (int i = 0; i < Code.Length; i++) - { - Console.WriteLine("OpCode #" + i + " is: " + Code[i]); - } - Console.WriteLine("SubAttributes: " + SubAttributeCount); - for (int i = 0; i < SubAttributeCount; i++) - { - this.SubAttributes[i].Print(); - } - } - - public class SubAttribute - { - public ushort NameIndex = 0; - public string Name = ""; - public Int32 Length = 0; - public byte[] Data; - private ClassRecord parent; - - public SubAttribute(ClassRecord paren) - { - parent = paren; - } - - public void ReadData(byte[] data, ref int pointer) - { - NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); - Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); - Data = new byte[Length]; - for (int i = 0; i < Length; i++) - { - Data[i] = data[pointer++]; - } - } - - public void Print() - { - Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); - } - - } - } - - } - private class InterfaceInfo - { - public void ReadData(byte[] data, ref int i) - { - - } - } - - public class FieldInfo - { - public ushort AccessFlags = 0; - public ushort NameIndex = 0; - public string Name = ""; - public ushort DescriptorIndex = 0; - public ushort AttributeCount = 0; - public List Attributes = new List(); - private ClassRecord parent; - - public FieldInfo(ClassRecord paren) - { - parent = paren; - } - - public void ReadData(byte[] data, ref int pointer) - { - AccessFlags = (ushort)((data[pointer++] << 8) + data[pointer++]); - NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); - DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); - AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); - for (int i = 0; i < AttributeCount; i++) - { - FieldAttribute attri = new FieldAttribute(this.parent); - attri.ReadData(data, ref pointer); - this.Attributes.Add(attri); - } - } - - public void Print() - { - Console.WriteLine("Field Info Struct: "); - Console.WriteLine("AccessFlags: " + AccessFlags); - Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); - Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value); - Console.WriteLine("Attribute Count:" + AttributeCount); - //if static, add to static field list - // if (this.AccessFlags == 9) //public and static - if ((this.AccessFlags & 0x08) != 0) - { - switch (((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value) - { - case "I": - Int newin = new Int(); - this.parent.StaticFields.Add(((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value, newin); - break; - case "F": - Float newfl = new Float(); - this.parent.StaticFields.Add(((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value, newfl); - break; - } - - } - for (int i = 0; i < AttributeCount; i++) - { - this.Attributes[i].Print(); - } - } - - public class FieldAttribute - { - public ushort NameIndex = 0; - public string Name = ""; - public Int32 Length = 0; - public byte[] Data; - private ClassRecord parent; - - public FieldAttribute(ClassRecord paren) - { - parent = paren; - } - - public void ReadData(byte[] data, ref int pointer) - { - NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); - Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); - Data = new byte[Length]; - for (int i = 0; i < Length; i++) - { - Data[i] = data[pointer++]; - } - } - - public void Print() - { - Console.WriteLine("FieldAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); - } - } - } - - private class AttributeInfo - { - public void ReadData(byte[] data, ref int i) - { - - } - } - #endregion - - } +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.IO; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + public class ClassRecord + { + private ushort m_majorVersion; + private ushort m_minorVersion; + private ushort m_constantPoolCount; + private ushort m_accessFlags; + private ushort m_thisClass; + private ushort m_supperClass; + private ushort m_interfaceCount; + private ushort m_fieldCount; + private ushort m_methodCount; + //private ushort _attributeCount; + //private string _name; + public Dictionary StaticFields = new Dictionary(); + public PoolClass MClass; + + public List m_constantsPool = new List(); + private List m_methodsList = new List(); + private List m_fieldList = new List(); + + public ClassRecord() + { + + } + + public ClassInstance CreateNewInstance() + { + ClassInstance classInst = new ClassInstance(); + classInst.ClassRec = this; + //TODO: set fields + + return classInst; + } + + public void LoadClassFromFile(string fileName) + { + Console.WriteLine("loading script " + fileName); + FileStream fs = File.OpenRead(fileName); + this.LoadClassFromBytes(ReadFully(fs)); + fs.Close(); + } + + public void LoadClassFromBytes(byte[] data) + { + int i = 0; + i += 4; + m_minorVersion = (ushort)((data[i++] << 8) + data[i++]); + m_majorVersion = (ushort)((data[i++] << 8) + data[i++]); + m_constantPoolCount = (ushort)((data[i++] << 8) + data[i++]); + Console.WriteLine("there should be " + m_constantPoolCount + " items in the pool"); + for (int count = 0; count < (m_constantPoolCount - 1); count++) + { + //read in the constant pool + byte pooltype = data[i++]; + Console.WriteLine("#" + count + ": new constant type = " + pooltype); + //Console.WriteLine("start position is: " + i); + switch (pooltype) + { + case 1: //Utf8 + ushort uLength = (ushort)((data[i++] << 8) + data[i++]); + + // Console.WriteLine("new utf8 type, length is " + uLength); + PoolUtf8 utf8 = new PoolUtf8(); + utf8.readValue(data, ref i, uLength); + this.m_constantsPool.Add(utf8); + break; + case 3: //Int + break; + case 4: //Float + break; + case 7: //Class + PoolClass pClass = new PoolClass(this); + pClass.readValue(data, ref i); + this.m_constantsPool.Add(pClass); + break; + case 9: //FieldRef + PoolFieldRef pField = new PoolFieldRef(this); + pField.readValue(data, ref i); + this.m_constantsPool.Add(pField); + break; + case 10: //Method + PoolMethodRef pMeth = new PoolMethodRef(this); + pMeth.readValue(data, ref i); + this.m_constantsPool.Add(pMeth); + break; + case 12: //NamedType + PoolNamedType pNamed = new PoolNamedType(this); + pNamed.readValue(data, ref i); + this.m_constantsPool.Add(pNamed); + break; + } + } + + m_accessFlags = (ushort)((data[i++] << 8) + data[i++]); + m_thisClass = (ushort)((data[i++] << 8) + data[i++]); + m_supperClass = (ushort)((data[i++] << 8) + data[i++]); + + if (this.m_constantsPool[this.m_thisClass - 1] is PoolClass) + { + this.MClass = ((PoolClass)this.m_constantsPool[this.m_thisClass - 1]); + } + + m_interfaceCount = (ushort)((data[i++] << 8) + data[i++]); + //should now read in the info for each interface + + m_fieldCount = (ushort)((data[i++] << 8) + data[i++]); + //should now read in the info for each field + for (int count = 0; count < m_fieldCount; count++) + { + FieldInfo fieldInf = new FieldInfo(this); + fieldInf.ReadData(data, ref i); + this.m_fieldList.Add(fieldInf); + } + + m_methodCount = (ushort)((data[i++] << 8) + data[i++]); + for (int count = 0; count < m_methodCount; count++) + { + MethodInfo methInf = new MethodInfo(this); + methInf.ReadData(data, ref i); + this.m_methodsList.Add(methInf); + } + } + + public void AddMethodsToMemory(MethodMemory memory) + { + for (int count = 0; count < m_methodCount; count++) + { + this.m_methodsList[count].AddMethodCode(memory); + } + } + + public bool StartMethod(Thread thread, string methodName) + { + for (int count = 0; count < m_methodCount; count++) + { + if (this.m_constantsPool[this.m_methodsList[count].NameIndex - 1] is PoolUtf8) + { + if (((PoolUtf8)this.m_constantsPool[this.m_methodsList[count].NameIndex - 1]).Value == methodName) + { + //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value); + thread.SetPC(this.m_methodsList[count].CodePointer); + return true; + } + } + } + return false; + } + + public void PrintToConsole() + { + Console.WriteLine("Class File:"); + Console.WriteLine("Major version: " + m_majorVersion); + Console.WriteLine("Minor version: " + m_minorVersion); + Console.WriteLine("Pool size: " + m_constantPoolCount); + + for (int i = 0; i < m_constantsPool.Count; i++) + { + this.m_constantsPool[i].Print(); + } + + Console.WriteLine("Access flags: " + m_accessFlags); + Console.WriteLine("This class: " + m_thisClass); + Console.WriteLine("Super class: " + m_supperClass); + + for (int count = 0; count < m_fieldCount; count++) + { + Console.WriteLine(); + this.m_fieldList[count].Print(); + } + + for (int count = 0; count < m_methodCount; count++) + { + Console.WriteLine(); + this.m_methodsList[count].Print(); + } + + Console.WriteLine("class name is " + this.MClass.Name.Value); + } + + public static byte[] ReadFully(Stream stream) + { + byte[] buffer = new byte[1024]; + using (MemoryStream ms = new MemoryStream()) + { + while (true) + { + int read = stream.Read(buffer, 0, buffer.Length); + if (read <= 0) + return ms.ToArray(); + ms.Write(buffer, 0, read); + } + } + } + + #region nested classes + public class PoolItem + { + public virtual void Print() + { + + } + } + + public class PoolUtf8 : PoolItem + { + public string Value = ""; + + public void readValue(byte[] data, ref int pointer, int length) + { + for (int i = 0; i < length; i++) + { + int a = (int)data[pointer++]; + if ((a & 0x80) == 0) + { + Value = Value + (char)a; + } + else if ((a & 0x20) == 0) + { + int b = (int)data[pointer++]; + Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f)); + } + else + { + int b = (int)data[pointer++]; + int c = (int)data[pointer++]; + Value = Value + (char)(((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f)); + } + } + } + + public override void Print() + { + Console.WriteLine("Utf8 type: " + Value); + } + } + + private class PoolInt : PoolItem + { + + } + + public class PoolClass : PoolItem + { + //public string name = ""; + public ushort namePointer = 0; + private ClassRecord parent; + public PoolUtf8 Name; + + public PoolClass(ClassRecord paren) + { + parent = paren; + } + + public void readValue(byte[] data, ref int pointer) + { + namePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); + } + + public override void Print() + { + this.Name = ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]); + Console.Write("Class type: " + namePointer); + Console.WriteLine(" // " + ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]).Value); + + } + } + + public class PoolFieldRef : PoolItem + { + public ushort classPointer = 0; + public ushort nameTypePointer = 0; + public PoolNamedType mNameType; + public PoolClass mClass; + private ClassRecord parent; + + public PoolFieldRef(ClassRecord paren) + { + parent = paren; + } + + public void readValue(byte[] data, ref int pointer) + { + classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]); + nameTypePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); + } + + public override void Print() + { + this.mNameType = ((PoolNamedType)this.parent.m_constantsPool[nameTypePointer - 1]); + this.mClass = ((PoolClass)this.parent.m_constantsPool[classPointer - 1]); + Console.WriteLine("FieldRef type: " + classPointer + " , " + nameTypePointer); + } + } + + public class PoolMethodRef : PoolItem + { + public ushort classPointer = 0; + public ushort nameTypePointer = 0; + public PoolNamedType mNameType; + public PoolClass mClass; + private ClassRecord parent; + + public PoolMethodRef(ClassRecord paren) + { + parent = paren; + } + + public void readValue(byte[] data, ref int pointer) + { + classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]); + nameTypePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); + } + + public override void Print() + { + this.mNameType = ((PoolNamedType)this.parent.m_constantsPool[nameTypePointer - 1]); + this.mClass = ((PoolClass)this.parent.m_constantsPool[classPointer - 1]); + Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer); + } + } + + public class PoolNamedType : PoolItem + { + public ushort namePointer = 0; + public ushort typePointer = 0; + private ClassRecord parent; + public PoolUtf8 Name; + public PoolUtf8 Type; + + public PoolNamedType(ClassRecord paren) + { + parent = paren; + } + + public void readValue(byte[] data, ref int pointer) + { + namePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); + typePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); + } + + public override void Print() + { + Name = ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]); + Type = ((PoolUtf8)this.parent.m_constantsPool[typePointer - 1]); + Console.Write("Named type: " + namePointer + " , " + typePointer); + Console.WriteLine(" // " + ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]).Value); + } + } + + //*********************** + public class MethodInfo + { + public ushort AccessFlags = 0; + public ushort NameIndex = 0; + public string Name = ""; + public ushort DescriptorIndex = 0; + public ushort AttributeCount = 0; + public List Attributes = new List(); + private ClassRecord parent; + public int CodePointer = 0; + + public MethodInfo(ClassRecord paren) + { + parent = paren; + } + + public void AddMethodCode(MethodMemory memory) + { + Array.Copy(this.Attributes[0].Code, 0, memory.MethodBuffer, memory.NextMethodPC, this.Attributes[0].Code.Length); + memory.Methodcount++; + this.CodePointer = memory.NextMethodPC; + memory.NextMethodPC += this.Attributes[0].Code.Length; + } + + public void ReadData(byte[] data, ref int pointer) + { + AccessFlags = (ushort)((data[pointer++] << 8) + data[pointer++]); + NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); + DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); + AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); + for (int i = 0; i < AttributeCount; i++) + { + MethodAttribute attri = new MethodAttribute(this.parent); + attri.ReadData(data, ref pointer); + this.Attributes.Add(attri); + } + } + + public void Print() + { + Console.WriteLine("Method Info Struct: "); + Console.WriteLine("AccessFlags: " + AccessFlags); + Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); + Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value); + Console.WriteLine("Attribute Count:" + AttributeCount); + for (int i = 0; i < AttributeCount; i++) + { + this.Attributes[i].Print(); + } + } + + public class MethodAttribute + { + public ushort NameIndex = 0; + public string Name = ""; + public Int32 Length = 0; + //for now only support code attribute + public ushort MaxStack = 0; + public ushort MaxLocals = 0; + public Int32 CodeLength = 0; + public byte[] Code; + public ushort ExceptionTableLength = 0; + public ushort SubAttributeCount = 0; + public List SubAttributes = new List(); + private ClassRecord parent; + + public MethodAttribute(ClassRecord paren) + { + parent = paren; + } + + public void ReadData(byte[] data, ref int pointer) + { + NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); + Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); + MaxStack = (ushort)((data[pointer++] << 8) + data[pointer++]); + MaxLocals = (ushort)((data[pointer++] << 8) + data[pointer++]); + CodeLength = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); + Code = new byte[CodeLength]; + for (int i = 0; i < CodeLength; i++) + { + Code[i] = data[pointer++]; + } + ExceptionTableLength = (ushort)((data[pointer++] << 8) + data[pointer++]); + SubAttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); + for (int i = 0; i < SubAttributeCount; i++) + { + SubAttribute subAttri = new SubAttribute(this.parent); + subAttri.ReadData(data, ref pointer); + this.SubAttributes.Add(subAttri); + } + } + + public void Print() + { + Console.WriteLine("Method Attribute: "); + Console.WriteLine("Name Index: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); + Console.WriteLine("Length: " + Length); + Console.WriteLine("MaxStack: " + MaxStack); + Console.WriteLine("MaxLocals: " + MaxLocals); + Console.WriteLine("CodeLength: " + CodeLength); + for (int i = 0; i < Code.Length; i++) + { + Console.WriteLine("OpCode #" + i + " is: " + Code[i]); + } + Console.WriteLine("SubAttributes: " + SubAttributeCount); + for (int i = 0; i < SubAttributeCount; i++) + { + this.SubAttributes[i].Print(); + } + } + + public class SubAttribute + { + public ushort NameIndex = 0; + public string Name = ""; + public Int32 Length = 0; + public byte[] Data; + private ClassRecord parent; + + public SubAttribute(ClassRecord paren) + { + parent = paren; + } + + public void ReadData(byte[] data, ref int pointer) + { + NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); + Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); + Data = new byte[Length]; + for (int i = 0; i < Length; i++) + { + Data[i] = data[pointer++]; + } + } + + public void Print() + { + Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); + } + + } + } + + } + private class InterfaceInfo + { + public void ReadData(byte[] data, ref int i) + { + + } + } + + public class FieldInfo + { + public ushort AccessFlags = 0; + public ushort NameIndex = 0; + public string Name = ""; + public ushort DescriptorIndex = 0; + public ushort AttributeCount = 0; + public List Attributes = new List(); + private ClassRecord parent; + + public FieldInfo(ClassRecord paren) + { + parent = paren; + } + + public void ReadData(byte[] data, ref int pointer) + { + AccessFlags = (ushort)((data[pointer++] << 8) + data[pointer++]); + NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); + DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); + AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); + for (int i = 0; i < AttributeCount; i++) + { + FieldAttribute attri = new FieldAttribute(this.parent); + attri.ReadData(data, ref pointer); + this.Attributes.Add(attri); + } + } + + public void Print() + { + Console.WriteLine("Field Info Struct: "); + Console.WriteLine("AccessFlags: " + AccessFlags); + Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); + Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value); + Console.WriteLine("Attribute Count:" + AttributeCount); + //if static, add to static field list + // if (this.AccessFlags == 9) //public and static + if ((this.AccessFlags & 0x08) != 0) + { + switch (((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value) + { + case "I": + Int newin = new Int(); + this.parent.StaticFields.Add(((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value, newin); + break; + case "F": + Float newfl = new Float(); + this.parent.StaticFields.Add(((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value, newfl); + break; + } + + } + for (int i = 0; i < AttributeCount; i++) + { + this.Attributes[i].Print(); + } + } + + public class FieldAttribute + { + public ushort NameIndex = 0; + public string Name = ""; + public Int32 Length = 0; + public byte[] Data; + private ClassRecord parent; + + public FieldAttribute(ClassRecord paren) + { + parent = paren; + } + + public void ReadData(byte[] data, ref int pointer) + { + NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); + Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); + Data = new byte[Length]; + for (int i = 0; i < Length; i++) + { + Data[i] = data[pointer++]; + } + } + + public void Print() + { + Console.WriteLine("FieldAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); + } + } + } + + private class AttributeInfo + { + public void ReadData(byte[] data, ref int i) + { + + } + } + #endregion + + } } \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs index f681be130c..c76767a2bf 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs @@ -1,43 +1,43 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM -{ - public class Heap - { - public List ClassObjects = new List(); - - public Heap() - { - - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + public class Heap + { + public List ClassObjects = new List(); + + public Heap() + { + + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs index 578dbc2ee5..6b8930e12b 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs @@ -1,551 +1,551 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM -{ - partial class Thread - { - private partial class Interpreter - { - private bool IsLogicOpCode(byte opcode) - { - bool result = false; - switch (opcode) - { - case (byte)(byte)OpCode.iconst_m1: - Int m_int = new Int(); - m_int.mValue = -1; - this.m_thread.m_currentFrame.OpStack.Push(m_int); - result = true; - break; - case (byte)(byte)OpCode.iconst_0: - m_int = new Int(); - m_int.mValue = 0; - this.m_thread.m_currentFrame.OpStack.Push(m_int); - result = true; - break; - case (byte)(byte)OpCode.iconst_1: - m_int = new Int(); - m_int.mValue = 1; - this.m_thread.m_currentFrame.OpStack.Push(m_int); - result = true; - break; - case (byte)(byte)OpCode.iconst_2: - m_int = new Int(); - m_int.mValue = 2; - this.m_thread.m_currentFrame.OpStack.Push(m_int); - result = true; - break; - case (byte)(byte)OpCode.iconst_3: - m_int = new Int(); - m_int.mValue = 3; - this.m_thread.m_currentFrame.OpStack.Push(m_int); - break; - case (byte)(byte)OpCode.iconst_4: - m_int = new Int(); - m_int.mValue = 4; - this.m_thread.m_currentFrame.OpStack.Push(m_int); - result = true; - break; - case (byte)OpCode.iconst_5: - m_int = new Int(); - m_int.mValue = 5; - this.m_thread.m_currentFrame.OpStack.Push(m_int); - result = true; - break; - case (byte)OpCode.fconst_0: - Float m_float = new Float(); - m_float.mValue = 0.0f; - this.m_thread.m_currentFrame.OpStack.Push(m_float); - result = true; - break; - case (byte)OpCode.fconst_1: - m_float = new Float(); - m_float.mValue = 1.0f; - this.m_thread.m_currentFrame.OpStack.Push(m_float); - result = true; - break; - case (byte)OpCode.fconst_2: - m_float = new Float(); - m_float.mValue = 2.0f; - this.m_thread.m_currentFrame.OpStack.Push(m_float); - result = true; - break; - case (byte)OpCode.bipush: //is this right? this should be pushing a byte onto stack not int? - int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]; - Int pushInt = new Int(); - pushInt.mValue = pushvalue; - this.m_thread.m_currentFrame.OpStack.Push(pushInt); - this.m_thread.PC++; - result = true; - break; - case (byte)OpCode.sipush: - short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - Int pushInt2 = new Int(); - pushInt2.mValue = pushvalue2; - this.m_thread.m_currentFrame.OpStack.Push(pushInt2); - this.m_thread.PC += 2; - result = true; - break; - case (byte)OpCode.fload: - short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); - Float fload = new Float(); - if (this.m_thread.m_currentFrame.LocalVariables[findex1] != null) - { - if (this.m_thread.m_currentFrame.LocalVariables[findex1] is Float) - { - fload.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[findex1]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(fload); - } - } - this.m_thread.PC++; - result = true; - break; - case (byte)OpCode.iload_0: - if (this.m_thread.m_currentFrame.LocalVariables[0] != null) - { - if (this.m_thread.m_currentFrame.LocalVariables[0] is Int) - { - Int newInt = new Int(); - newInt.mValue = ((Int)this.m_thread.m_currentFrame.LocalVariables[0]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newInt); - } - } - result = true; - break; - case (byte)OpCode.iload_1: - if (this.m_thread.m_currentFrame.LocalVariables[1] != null) - { - if (this.m_thread.m_currentFrame.LocalVariables[1] is Int) - { - Int newInt = new Int(); - newInt.mValue = ((Int)this.m_thread.m_currentFrame.LocalVariables[1]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newInt); - } - } - result = true; - break; - case (byte)OpCode.fload_0: - if (this.m_thread.m_currentFrame.LocalVariables[0] != null) - { - if (this.m_thread.m_currentFrame.LocalVariables[0] is Float) - { - Float newfloat = new Float(); - newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[0]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newfloat); - } - } - result = true; - break; - case (byte)OpCode.fload_1: - if (this.m_thread.m_currentFrame.LocalVariables[1] != null) - { - if (this.m_thread.m_currentFrame.LocalVariables[1] is Float) - { - Float newfloat = new Float(); - newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[1]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newfloat); - } - } - result = true; - break; - case (byte)OpCode.fload_2: - if (this.m_thread.m_currentFrame.LocalVariables[2] != null) - { - if (this.m_thread.m_currentFrame.LocalVariables[2] is Float) - { - Float newfloat = new Float(); - newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[2]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newfloat); - } - } - result = true; - break; - case (byte)OpCode.fload_3: - if (this.m_thread.m_currentFrame.LocalVariables[3] != null) - { - if (this.m_thread.m_currentFrame.LocalVariables[3] is Float) - { - Float newfloat = new Float(); - newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[3]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newfloat); - } - } - result = true; - break; - case (byte)OpCode.istore: - short findex3 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); - BaseType istor = this.m_thread.m_currentFrame.OpStack.Pop(); - if (istor is Int) - { - this.m_thread.m_currentFrame.LocalVariables[findex3] = (Int)istor; - } - this.m_thread.PC++; - result = true; - break; - case (byte)OpCode.fstore: - short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); - BaseType fstor = this.m_thread.m_currentFrame.OpStack.Pop(); - if (fstor is Float) - { - this.m_thread.m_currentFrame.LocalVariables[findex] = (Float)fstor; - } - this.m_thread.PC++; - result = true; - break; - case (byte)OpCode.istore_0: - BaseType baset = this.m_thread.m_currentFrame.OpStack.Pop(); - if (baset is Int) - { - this.m_thread.m_currentFrame.LocalVariables[0] = (Int)baset; - } - result = true; - break; - case (byte)OpCode.istore_1: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); - if (baset is Int) - { - this.m_thread.m_currentFrame.LocalVariables[1] = (Int)baset; - } - result = true; - break; - case (byte)OpCode.fstore_0: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); - if (baset is Float) - { - this.m_thread.m_currentFrame.LocalVariables[0] = (Float)baset; - } - result = true; - break; - case (byte)OpCode.fstore_1: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); - if (baset is Float) - { - this.m_thread.m_currentFrame.LocalVariables[1] = (Float)baset; - } - result = true; - break; - case (byte)OpCode.fstore_2: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); - if (baset is Float) - { - this.m_thread.m_currentFrame.LocalVariables[2] = (Float)baset; - } - result = true; - break; - case (byte)OpCode.fstore_3: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); - if (baset is Float) - { - this.m_thread.m_currentFrame.LocalVariables[3] = (Float)baset; - } - result = true; - break; - case (byte)OpCode.pop: - this.m_thread.m_currentFrame.OpStack.Pop(); - result = true; - break; - case (byte)OpCode.fadd: - BaseType bf2 = this.m_thread.m_currentFrame.OpStack.Pop(); - BaseType bf1 = this.m_thread.m_currentFrame.OpStack.Pop(); - if (bf1 is Float && bf2 is Float) - { - Float nflt = new Float(); - nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue; - this.m_thread.m_currentFrame.OpStack.Push(nflt); - } - result = true; - break; - case (byte)OpCode.fsub: - BaseType bsf2 = this.m_thread.m_currentFrame.OpStack.Pop(); - BaseType bsf1 = this.m_thread.m_currentFrame.OpStack.Pop(); - if (bsf1 is Float && bsf2 is Float) - { - Float resf = new Float(); - resf.mValue = ((Float)bsf1).mValue - ((Float)bsf2).mValue; - this.m_thread.m_currentFrame.OpStack.Push(resf); - } - result = true; - break; - case (byte)OpCode.imul: //check the order of the two values off the stack is correct - BaseType bs2 = this.m_thread.m_currentFrame.OpStack.Pop(); - BaseType bs1 = this.m_thread.m_currentFrame.OpStack.Pop(); - if (bs1 is Int && bs2 is Int) - { - Int nInt = new Int(); - nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue; - this.m_thread.m_currentFrame.OpStack.Push(nInt); - } - result = true; - break; - case (byte)OpCode.iinc: - if (this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]] != null) - { - if (this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]] is Int) - { - ((Int)this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]]).mValue += (sbyte)GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]; - } - } - this.m_thread.PC += 2; - result = true; - break; - case (byte)OpCode.f2i: - BaseType conv1 = this.m_thread.m_currentFrame.OpStack.Pop(); - if (conv1 is Float) - { - Int newconv = new Int(); - newconv.mValue = (int)((Float)conv1).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newconv); - } - result = true; - break; - case (byte)OpCode.fcmpl: - BaseType flcom2 = this.m_thread.m_currentFrame.OpStack.Pop(); - BaseType flcom1 = this.m_thread.m_currentFrame.OpStack.Pop(); - if (flcom1 is Float && flcom2 is Float) - { - Int compres = new Int(); - if (((Float)flcom1).mValue < ((Float)flcom2).mValue) - { - compres.mValue = -1; - } - else if (((Float)flcom1).mValue > ((Float)flcom2).mValue) - { - compres.mValue = 1; - } - else - { - compres.mValue = 0; - } - this.m_thread.m_currentFrame.OpStack.Push(compres); - } - result = true; - break; - case (byte)OpCode.fcmpg: - flcom2 = this.m_thread.m_currentFrame.OpStack.Pop(); - flcom1 = this.m_thread.m_currentFrame.OpStack.Pop(); - if (flcom1 is Float && flcom2 is Float) - { - Int compres = new Int(); - if (((Float)flcom1).mValue < ((Float)flcom2).mValue) - { - compres.mValue = -1; - } - else if (((Float)flcom1).mValue > ((Float)flcom2).mValue) - { - compres.mValue = 1; - } - else - { - compres.mValue = 0; - } - this.m_thread.m_currentFrame.OpStack.Push(compres); - } - result = true; - break; - case (byte)OpCode.ifge: - short compareoffset2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - BaseType compe1 = this.m_thread.m_currentFrame.OpStack.Pop(); - if (compe1 is Int) - { - if (((Int)compe1).mValue >= 0) - { - this.m_thread.PC += -1 + compareoffset2; - } - else - { - this.m_thread.PC += 2; - } - } - else - { - this.m_thread.PC += 2; - } - result = true; - break; - case (byte)OpCode.ifle: - short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - BaseType comp1 = this.m_thread.m_currentFrame.OpStack.Pop(); - if (comp1 is Int) - { - if (((Int)comp1).mValue <= 0) - { - this.m_thread.PC += -1 + compareoffset1; - } - else - { - this.m_thread.PC += 2; - } - } - else - { - this.m_thread.PC += 2; - } - result = true; - break; - case (byte)OpCode.if_icmpge: - short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - BaseType bc2 = this.m_thread.m_currentFrame.OpStack.Pop(); - BaseType bc1 = this.m_thread.m_currentFrame.OpStack.Pop(); - if (bc1 is Int && bc2 is Int) - { - //Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue); - if (((Int)bc1).mValue >= ((Int)bc2).mValue) - { - // Console.WriteLine("branch compare true , offset is " +compareoffset); - // Console.WriteLine("current PC is " + this._mThread.PC); - this.m_thread.PC += -1 + compareoffset; - //Console.WriteLine("new PC is " + this._mThread.PC); - } - else - { - //Console.WriteLine("branch compare false"); - this.m_thread.PC += 2; - } - } - else - { - this.m_thread.PC += 2; - } - result = true; - break; - case (byte)OpCode.if_icmple: - short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - BaseType bcl2 = this.m_thread.m_currentFrame.OpStack.Pop(); - BaseType bcl1 = this.m_thread.m_currentFrame.OpStack.Pop(); - if (bcl1 is Int && bcl2 is Int) - { - //Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue); - if (((Int)bcl1).mValue <= ((Int)bcl2).mValue) - { - // Console.WriteLine("branch compare true , offset is " + compareloffset); - // Console.WriteLine("current PC is " + this._mThread.PC); - this.m_thread.PC += -1 + compareloffset; - // Console.WriteLine("new PC is " + this._mThread.PC); - } - else - { - //Console.WriteLine("branch compare false"); - this.m_thread.PC += 2; - } - } - else - { - this.m_thread.PC += 2; - } - result = true; - break; - case (byte)OpCode._goto: - short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - this.m_thread.PC += -1 + offset; - result = true; - break; - case (byte)OpCode.getstatic: - short fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - if (this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef) - { - if (((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value) - { - //from this class - if (this.m_thread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value)) - { - if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float) - { - Float retFloat = new Float(); - retFloat.mValue = ((Float)this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(retFloat); - } - else if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int) - { - Int retInt = new Int(); - retInt.mValue = ((Int)this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue; - // Console.WriteLine("getting static field, " + retInt.mValue); - this.m_thread.m_currentFrame.OpStack.Push(retInt); - } - } - } - else - { - //get from a different class - } - } - this.m_thread.PC += 2; - result = true; - break; - case (byte)OpCode.putstatic: - fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - BaseType addstatic = this.m_thread.m_currentFrame.OpStack.Pop(); - if (this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef) - { - if (((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value) - { - // this class - if (this.m_thread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value)) - { - if (addstatic is Float) - { - if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float) - { - Float newf = new Float(); - newf.mValue = ((Float)addstatic).mValue; - this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newf; - } - } - else if (addstatic is Int) - { - if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int) - { - //Console.WriteLine("setting static field to " + ((Int)addstatic).mValue); - Int newi = new Int(); - newi.mValue = ((Int)addstatic).mValue; - this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newi; - } - } - } - } - else - { - // a different class - } - } - this.m_thread.PC += 2; - result = true; - break; - - } - - return result; - } - } - } +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + partial class Thread + { + private partial class Interpreter + { + private bool IsLogicOpCode(byte opcode) + { + bool result = false; + switch (opcode) + { + case (byte)(byte)OpCode.iconst_m1: + Int m_int = new Int(); + m_int.mValue = -1; + this.m_thread.m_currentFrame.OpStack.Push(m_int); + result = true; + break; + case (byte)(byte)OpCode.iconst_0: + m_int = new Int(); + m_int.mValue = 0; + this.m_thread.m_currentFrame.OpStack.Push(m_int); + result = true; + break; + case (byte)(byte)OpCode.iconst_1: + m_int = new Int(); + m_int.mValue = 1; + this.m_thread.m_currentFrame.OpStack.Push(m_int); + result = true; + break; + case (byte)(byte)OpCode.iconst_2: + m_int = new Int(); + m_int.mValue = 2; + this.m_thread.m_currentFrame.OpStack.Push(m_int); + result = true; + break; + case (byte)(byte)OpCode.iconst_3: + m_int = new Int(); + m_int.mValue = 3; + this.m_thread.m_currentFrame.OpStack.Push(m_int); + break; + case (byte)(byte)OpCode.iconst_4: + m_int = new Int(); + m_int.mValue = 4; + this.m_thread.m_currentFrame.OpStack.Push(m_int); + result = true; + break; + case (byte)OpCode.iconst_5: + m_int = new Int(); + m_int.mValue = 5; + this.m_thread.m_currentFrame.OpStack.Push(m_int); + result = true; + break; + case (byte)OpCode.fconst_0: + Float m_float = new Float(); + m_float.mValue = 0.0f; + this.m_thread.m_currentFrame.OpStack.Push(m_float); + result = true; + break; + case (byte)OpCode.fconst_1: + m_float = new Float(); + m_float.mValue = 1.0f; + this.m_thread.m_currentFrame.OpStack.Push(m_float); + result = true; + break; + case (byte)OpCode.fconst_2: + m_float = new Float(); + m_float.mValue = 2.0f; + this.m_thread.m_currentFrame.OpStack.Push(m_float); + result = true; + break; + case (byte)OpCode.bipush: //is this right? this should be pushing a byte onto stack not int? + int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]; + Int pushInt = new Int(); + pushInt.mValue = pushvalue; + this.m_thread.m_currentFrame.OpStack.Push(pushInt); + this.m_thread.PC++; + result = true; + break; + case (byte)OpCode.sipush: + short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); + Int pushInt2 = new Int(); + pushInt2.mValue = pushvalue2; + this.m_thread.m_currentFrame.OpStack.Push(pushInt2); + this.m_thread.PC += 2; + result = true; + break; + case (byte)OpCode.fload: + short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); + Float fload = new Float(); + if (this.m_thread.m_currentFrame.LocalVariables[findex1] != null) + { + if (this.m_thread.m_currentFrame.LocalVariables[findex1] is Float) + { + fload.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[findex1]).mValue; + this.m_thread.m_currentFrame.OpStack.Push(fload); + } + } + this.m_thread.PC++; + result = true; + break; + case (byte)OpCode.iload_0: + if (this.m_thread.m_currentFrame.LocalVariables[0] != null) + { + if (this.m_thread.m_currentFrame.LocalVariables[0] is Int) + { + Int newInt = new Int(); + newInt.mValue = ((Int)this.m_thread.m_currentFrame.LocalVariables[0]).mValue; + this.m_thread.m_currentFrame.OpStack.Push(newInt); + } + } + result = true; + break; + case (byte)OpCode.iload_1: + if (this.m_thread.m_currentFrame.LocalVariables[1] != null) + { + if (this.m_thread.m_currentFrame.LocalVariables[1] is Int) + { + Int newInt = new Int(); + newInt.mValue = ((Int)this.m_thread.m_currentFrame.LocalVariables[1]).mValue; + this.m_thread.m_currentFrame.OpStack.Push(newInt); + } + } + result = true; + break; + case (byte)OpCode.fload_0: + if (this.m_thread.m_currentFrame.LocalVariables[0] != null) + { + if (this.m_thread.m_currentFrame.LocalVariables[0] is Float) + { + Float newfloat = new Float(); + newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[0]).mValue; + this.m_thread.m_currentFrame.OpStack.Push(newfloat); + } + } + result = true; + break; + case (byte)OpCode.fload_1: + if (this.m_thread.m_currentFrame.LocalVariables[1] != null) + { + if (this.m_thread.m_currentFrame.LocalVariables[1] is Float) + { + Float newfloat = new Float(); + newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[1]).mValue; + this.m_thread.m_currentFrame.OpStack.Push(newfloat); + } + } + result = true; + break; + case (byte)OpCode.fload_2: + if (this.m_thread.m_currentFrame.LocalVariables[2] != null) + { + if (this.m_thread.m_currentFrame.LocalVariables[2] is Float) + { + Float newfloat = new Float(); + newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[2]).mValue; + this.m_thread.m_currentFrame.OpStack.Push(newfloat); + } + } + result = true; + break; + case (byte)OpCode.fload_3: + if (this.m_thread.m_currentFrame.LocalVariables[3] != null) + { + if (this.m_thread.m_currentFrame.LocalVariables[3] is Float) + { + Float newfloat = new Float(); + newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[3]).mValue; + this.m_thread.m_currentFrame.OpStack.Push(newfloat); + } + } + result = true; + break; + case (byte)OpCode.istore: + short findex3 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); + BaseType istor = this.m_thread.m_currentFrame.OpStack.Pop(); + if (istor is Int) + { + this.m_thread.m_currentFrame.LocalVariables[findex3] = (Int)istor; + } + this.m_thread.PC++; + result = true; + break; + case (byte)OpCode.fstore: + short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); + BaseType fstor = this.m_thread.m_currentFrame.OpStack.Pop(); + if (fstor is Float) + { + this.m_thread.m_currentFrame.LocalVariables[findex] = (Float)fstor; + } + this.m_thread.PC++; + result = true; + break; + case (byte)OpCode.istore_0: + BaseType baset = this.m_thread.m_currentFrame.OpStack.Pop(); + if (baset is Int) + { + this.m_thread.m_currentFrame.LocalVariables[0] = (Int)baset; + } + result = true; + break; + case (byte)OpCode.istore_1: + baset = this.m_thread.m_currentFrame.OpStack.Pop(); + if (baset is Int) + { + this.m_thread.m_currentFrame.LocalVariables[1] = (Int)baset; + } + result = true; + break; + case (byte)OpCode.fstore_0: + baset = this.m_thread.m_currentFrame.OpStack.Pop(); + if (baset is Float) + { + this.m_thread.m_currentFrame.LocalVariables[0] = (Float)baset; + } + result = true; + break; + case (byte)OpCode.fstore_1: + baset = this.m_thread.m_currentFrame.OpStack.Pop(); + if (baset is Float) + { + this.m_thread.m_currentFrame.LocalVariables[1] = (Float)baset; + } + result = true; + break; + case (byte)OpCode.fstore_2: + baset = this.m_thread.m_currentFrame.OpStack.Pop(); + if (baset is Float) + { + this.m_thread.m_currentFrame.LocalVariables[2] = (Float)baset; + } + result = true; + break; + case (byte)OpCode.fstore_3: + baset = this.m_thread.m_currentFrame.OpStack.Pop(); + if (baset is Float) + { + this.m_thread.m_currentFrame.LocalVariables[3] = (Float)baset; + } + result = true; + break; + case (byte)OpCode.pop: + this.m_thread.m_currentFrame.OpStack.Pop(); + result = true; + break; + case (byte)OpCode.fadd: + BaseType bf2 = this.m_thread.m_currentFrame.OpStack.Pop(); + BaseType bf1 = this.m_thread.m_currentFrame.OpStack.Pop(); + if (bf1 is Float && bf2 is Float) + { + Float nflt = new Float(); + nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue; + this.m_thread.m_currentFrame.OpStack.Push(nflt); + } + result = true; + break; + case (byte)OpCode.fsub: + BaseType bsf2 = this.m_thread.m_currentFrame.OpStack.Pop(); + BaseType bsf1 = this.m_thread.m_currentFrame.OpStack.Pop(); + if (bsf1 is Float && bsf2 is Float) + { + Float resf = new Float(); + resf.mValue = ((Float)bsf1).mValue - ((Float)bsf2).mValue; + this.m_thread.m_currentFrame.OpStack.Push(resf); + } + result = true; + break; + case (byte)OpCode.imul: //check the order of the two values off the stack is correct + BaseType bs2 = this.m_thread.m_currentFrame.OpStack.Pop(); + BaseType bs1 = this.m_thread.m_currentFrame.OpStack.Pop(); + if (bs1 is Int && bs2 is Int) + { + Int nInt = new Int(); + nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue; + this.m_thread.m_currentFrame.OpStack.Push(nInt); + } + result = true; + break; + case (byte)OpCode.iinc: + if (this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]] != null) + { + if (this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]] is Int) + { + ((Int)this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]]).mValue += (sbyte)GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]; + } + } + this.m_thread.PC += 2; + result = true; + break; + case (byte)OpCode.f2i: + BaseType conv1 = this.m_thread.m_currentFrame.OpStack.Pop(); + if (conv1 is Float) + { + Int newconv = new Int(); + newconv.mValue = (int)((Float)conv1).mValue; + this.m_thread.m_currentFrame.OpStack.Push(newconv); + } + result = true; + break; + case (byte)OpCode.fcmpl: + BaseType flcom2 = this.m_thread.m_currentFrame.OpStack.Pop(); + BaseType flcom1 = this.m_thread.m_currentFrame.OpStack.Pop(); + if (flcom1 is Float && flcom2 is Float) + { + Int compres = new Int(); + if (((Float)flcom1).mValue < ((Float)flcom2).mValue) + { + compres.mValue = -1; + } + else if (((Float)flcom1).mValue > ((Float)flcom2).mValue) + { + compres.mValue = 1; + } + else + { + compres.mValue = 0; + } + this.m_thread.m_currentFrame.OpStack.Push(compres); + } + result = true; + break; + case (byte)OpCode.fcmpg: + flcom2 = this.m_thread.m_currentFrame.OpStack.Pop(); + flcom1 = this.m_thread.m_currentFrame.OpStack.Pop(); + if (flcom1 is Float && flcom2 is Float) + { + Int compres = new Int(); + if (((Float)flcom1).mValue < ((Float)flcom2).mValue) + { + compres.mValue = -1; + } + else if (((Float)flcom1).mValue > ((Float)flcom2).mValue) + { + compres.mValue = 1; + } + else + { + compres.mValue = 0; + } + this.m_thread.m_currentFrame.OpStack.Push(compres); + } + result = true; + break; + case (byte)OpCode.ifge: + short compareoffset2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); + BaseType compe1 = this.m_thread.m_currentFrame.OpStack.Pop(); + if (compe1 is Int) + { + if (((Int)compe1).mValue >= 0) + { + this.m_thread.PC += -1 + compareoffset2; + } + else + { + this.m_thread.PC += 2; + } + } + else + { + this.m_thread.PC += 2; + } + result = true; + break; + case (byte)OpCode.ifle: + short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); + BaseType comp1 = this.m_thread.m_currentFrame.OpStack.Pop(); + if (comp1 is Int) + { + if (((Int)comp1).mValue <= 0) + { + this.m_thread.PC += -1 + compareoffset1; + } + else + { + this.m_thread.PC += 2; + } + } + else + { + this.m_thread.PC += 2; + } + result = true; + break; + case (byte)OpCode.if_icmpge: + short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); + BaseType bc2 = this.m_thread.m_currentFrame.OpStack.Pop(); + BaseType bc1 = this.m_thread.m_currentFrame.OpStack.Pop(); + if (bc1 is Int && bc2 is Int) + { + //Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue); + if (((Int)bc1).mValue >= ((Int)bc2).mValue) + { + // Console.WriteLine("branch compare true , offset is " +compareoffset); + // Console.WriteLine("current PC is " + this._mThread.PC); + this.m_thread.PC += -1 + compareoffset; + //Console.WriteLine("new PC is " + this._mThread.PC); + } + else + { + //Console.WriteLine("branch compare false"); + this.m_thread.PC += 2; + } + } + else + { + this.m_thread.PC += 2; + } + result = true; + break; + case (byte)OpCode.if_icmple: + short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); + BaseType bcl2 = this.m_thread.m_currentFrame.OpStack.Pop(); + BaseType bcl1 = this.m_thread.m_currentFrame.OpStack.Pop(); + if (bcl1 is Int && bcl2 is Int) + { + //Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue); + if (((Int)bcl1).mValue <= ((Int)bcl2).mValue) + { + // Console.WriteLine("branch compare true , offset is " + compareloffset); + // Console.WriteLine("current PC is " + this._mThread.PC); + this.m_thread.PC += -1 + compareloffset; + // Console.WriteLine("new PC is " + this._mThread.PC); + } + else + { + //Console.WriteLine("branch compare false"); + this.m_thread.PC += 2; + } + } + else + { + this.m_thread.PC += 2; + } + result = true; + break; + case (byte)OpCode._goto: + short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); + this.m_thread.PC += -1 + offset; + result = true; + break; + case (byte)OpCode.getstatic: + short fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); + if (this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef) + { + if (((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value) + { + //from this class + if (this.m_thread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value)) + { + if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float) + { + Float retFloat = new Float(); + retFloat.mValue = ((Float)this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue; + this.m_thread.m_currentFrame.OpStack.Push(retFloat); + } + else if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int) + { + Int retInt = new Int(); + retInt.mValue = ((Int)this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue; + // Console.WriteLine("getting static field, " + retInt.mValue); + this.m_thread.m_currentFrame.OpStack.Push(retInt); + } + } + } + else + { + //get from a different class + } + } + this.m_thread.PC += 2; + result = true; + break; + case (byte)OpCode.putstatic: + fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); + BaseType addstatic = this.m_thread.m_currentFrame.OpStack.Pop(); + if (this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef) + { + if (((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value) + { + // this class + if (this.m_thread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value)) + { + if (addstatic is Float) + { + if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float) + { + Float newf = new Float(); + newf.mValue = ((Float)addstatic).mValue; + this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newf; + } + } + else if (addstatic is Int) + { + if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int) + { + //Console.WriteLine("setting static field to " + ((Int)addstatic).mValue); + Int newi = new Int(); + newi.mValue = ((Int)addstatic).mValue; + this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newi; + } + } + } + } + else + { + // a different class + } + } + this.m_thread.PC += 2; + result = true; + break; + + } + + return result; + } + } + } } \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs index 3a13fa1ac4..8cde62e4ad 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs @@ -1,96 +1,96 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; -using OpenSim.Framework.Types; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM -{ - partial class Thread - { - private partial class Interpreter - { - private bool IsMethodOpCode(byte opcode) - { - bool result = false; - switch (opcode) - { - case 184: - short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC+1]); - if (this.m_thread.currentClass.m_constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef) - { - string typ = ((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Type.Value; - string typeparam = ""; - string typereturn = ""; - int firstbrak = 0; - int secondbrak = 0; - firstbrak = typ.LastIndexOf('('); - secondbrak = typ.LastIndexOf(')'); - typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1); - typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1); - if (((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value) - { - //calling a method in this class - if (typeparam.Length == 0) - { - this.m_thread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, (this.m_thread.PC + 2)); - } - else - { - this.m_thread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this.m_thread.PC + 2)); - } - } - else - { - //calling a method of a different class - - // OpenSimAPI Class - if (((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI") - { - this.m_thread.scriptInfo.api.CallMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, null); - } - } - } - else - { - this.m_thread.PC += 2; - } - result = true; - break; - } - - return result; - } - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework; +using OpenSim.Framework.Types; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + partial class Thread + { + private partial class Interpreter + { + private bool IsMethodOpCode(byte opcode) + { + bool result = false; + switch (opcode) + { + case 184: + short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC+1]); + if (this.m_thread.currentClass.m_constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef) + { + string typ = ((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Type.Value; + string typeparam = ""; + string typereturn = ""; + int firstbrak = 0; + int secondbrak = 0; + firstbrak = typ.LastIndexOf('('); + secondbrak = typ.LastIndexOf(')'); + typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1); + typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1); + if (((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value) + { + //calling a method in this class + if (typeparam.Length == 0) + { + this.m_thread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, (this.m_thread.PC + 2)); + } + else + { + this.m_thread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this.m_thread.PC + 2)); + } + } + else + { + //calling a method of a different class + + // OpenSimAPI Class + if (((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI") + { + this.m_thread.scriptInfo.api.CallMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, null); + } + } + } + else + { + this.m_thread.PC += 2; + } + result = true; + break; + } + + return result; + } + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs index d1cafa1ad6..5a42285d1d 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs @@ -1,40 +1,40 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM -{ - partial class Thread - { - private partial class Interpreter - { - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + partial class Thread + { + private partial class Interpreter + { + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs index c3611d438f..698a518133 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs @@ -1,135 +1,135 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM -{ - partial class Thread - { - private partial class Interpreter - { - private Thread m_thread; - - public Interpreter(Thread parentThread) - { - m_thread = parentThread; - } - - public bool Excute() - { - bool run = true; - byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC++]; - // Console.WriteLine("opCode is: " + currentOpCode); - bool handled = false; - - handled = this.IsLogicOpCode(currentOpCode); - if (!handled) - { - handled = this.IsMethodOpCode(currentOpCode); - } - if (!handled) - { - if (currentOpCode == 172) - { - if (this.m_thread.stack.StackFrames.Count > 1) - { - Console.WriteLine("returning int from function"); - int retPC1 = this.m_thread.m_currentFrame.ReturnPC; - BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop(); - this.m_thread.stack.StackFrames.Pop(); - this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek(); - this.m_thread.PC = retPC1; - if (bas1 is Int) - { - this.m_thread.m_currentFrame.OpStack.Push((Int)bas1); - } - } - else - { - // Console.WriteLine("No parent function so ending program"); - this.m_thread.stack.StackFrames.Pop(); - run = false; - } - handled = true; - } - if (currentOpCode == 174) - { - if (this.m_thread.stack.StackFrames.Count > 1) - { - Console.WriteLine("returning float from function"); - int retPC1 = this.m_thread.m_currentFrame.ReturnPC; - BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop(); - this.m_thread.stack.StackFrames.Pop(); - this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek(); - this.m_thread.PC = retPC1; - if (bas1 is Float) - { - this.m_thread.m_currentFrame.OpStack.Push((Float)bas1); - } - } - else - { - // Console.WriteLine("No parent function so ending program"); - this.m_thread.stack.StackFrames.Pop(); - run = false; - } - handled = true; - } - if (currentOpCode == 177) - { - if (this.m_thread.stack.StackFrames.Count > 1) - { - Console.WriteLine("returning from function"); - int retPC = this.m_thread.m_currentFrame.ReturnPC; - this.m_thread.stack.StackFrames.Pop(); - this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek(); - this.m_thread.PC = retPC; - } - else - { - // Console.WriteLine("No parent function so ending program"); - this.m_thread.stack.StackFrames.Pop(); - run = false; - } - handled = true; - } - } - if (!handled) - { - Console.WriteLine("opcode " + currentOpCode + " not been handled "); - } - return run; - - } - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + partial class Thread + { + private partial class Interpreter + { + private Thread m_thread; + + public Interpreter(Thread parentThread) + { + m_thread = parentThread; + } + + public bool Excute() + { + bool run = true; + byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC++]; + // Console.WriteLine("opCode is: " + currentOpCode); + bool handled = false; + + handled = this.IsLogicOpCode(currentOpCode); + if (!handled) + { + handled = this.IsMethodOpCode(currentOpCode); + } + if (!handled) + { + if (currentOpCode == 172) + { + if (this.m_thread.stack.StackFrames.Count > 1) + { + Console.WriteLine("returning int from function"); + int retPC1 = this.m_thread.m_currentFrame.ReturnPC; + BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop(); + this.m_thread.stack.StackFrames.Pop(); + this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek(); + this.m_thread.PC = retPC1; + if (bas1 is Int) + { + this.m_thread.m_currentFrame.OpStack.Push((Int)bas1); + } + } + else + { + // Console.WriteLine("No parent function so ending program"); + this.m_thread.stack.StackFrames.Pop(); + run = false; + } + handled = true; + } + if (currentOpCode == 174) + { + if (this.m_thread.stack.StackFrames.Count > 1) + { + Console.WriteLine("returning float from function"); + int retPC1 = this.m_thread.m_currentFrame.ReturnPC; + BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop(); + this.m_thread.stack.StackFrames.Pop(); + this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek(); + this.m_thread.PC = retPC1; + if (bas1 is Float) + { + this.m_thread.m_currentFrame.OpStack.Push((Float)bas1); + } + } + else + { + // Console.WriteLine("No parent function so ending program"); + this.m_thread.stack.StackFrames.Pop(); + run = false; + } + handled = true; + } + if (currentOpCode == 177) + { + if (this.m_thread.stack.StackFrames.Count > 1) + { + Console.WriteLine("returning from function"); + int retPC = this.m_thread.m_currentFrame.ReturnPC; + this.m_thread.stack.StackFrames.Pop(); + this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek(); + this.m_thread.PC = retPC; + } + else + { + // Console.WriteLine("No parent function so ending program"); + this.m_thread.stack.StackFrames.Pop(); + run = false; + } + handled = true; + } + } + if (!handled) + { + Console.WriteLine("opcode " + currentOpCode + " not been handled "); + } + return run; + + } + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs index 5f9202e81d..34d4fc5bd4 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs @@ -1,45 +1,45 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM -{ - public class MainMemory - { - public Heap HeapArea; - public MethodMemory MethodArea; - - public MainMemory() - { - MethodArea = new MethodMemory(); - HeapArea = new Heap(); - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + public class MainMemory + { + public Heap HeapArea; + public MethodMemory MethodArea; + + public MainMemory() + { + MethodArea = new MethodMemory(); + HeapArea = new Heap(); + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs index 58ed915182..f470583505 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs @@ -1,46 +1,46 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM -{ - public class MethodMemory - { - public byte[] MethodBuffer; - public List Classes = new List(); - public int NextMethodPC = 0; - public int Methodcount = 0; - - public MethodMemory() - { - MethodBuffer = new byte[20000]; - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + public class MethodMemory + { + public byte[] MethodBuffer; + public List Classes = new List(); + public int NextMethodPC = 0; + public int Methodcount = 0; + + public MethodMemory() + { + MethodBuffer = new byte[20000]; + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs index bc79ce3eee..21e467a225 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs @@ -1,37 +1,37 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM -{ - public class Object - { - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + public class Object + { + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/OpCodes.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/OpCodes.cs index c6ac987efc..47b9eec0a2 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/OpCodes.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/OpCodes.cs @@ -1,56 +1,56 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM -{ - public enum OpCode : byte - { - iconst_m1 = 2, - iconst_0 = 3, - iconst_1 = 4, - iconst_2 = 5, - iconst_3 = 6, - iconst_4 = 7, - iconst_5 = 8, - fconst_0 = 11, - fconst_1 = 12, - fconst_2 = 13, - bipush = 16, - sipush = 17, - fload = 23, - iload_0 = 26, - iload_1 = 27, - fload_0 = 34, - fload_1 = 35, - fload_2 = 36, - fload_3 = 37, - istore = 54, - fstore = 56, - istore_0 = 59, - istore_1 = 60, - istore_2 = 61, - istore_3 = 62, - fstore_0 = 67, - fstore_1 = 68, - fstore_2 = 69, - fstore_3 = 70, - pop = 87, - fadd = 98, - fsub = 102, - imul = 104, - iinc = 132, - f2i = 139, - fcmpl = 149, - fcmpg = 150, - ifge = 156, - ifgt = 157, - ifle = 158, - if_icmpge = 162, - if_icmpgt = 163, - if_icmple = 164, - _goto = 167, - getstatic = 178, - putstatic = 179 - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + public enum OpCode : byte + { + iconst_m1 = 2, + iconst_0 = 3, + iconst_1 = 4, + iconst_2 = 5, + iconst_3 = 6, + iconst_4 = 7, + iconst_5 = 8, + fconst_0 = 11, + fconst_1 = 12, + fconst_2 = 13, + bipush = 16, + sipush = 17, + fload = 23, + iload_0 = 26, + iload_1 = 27, + fload_0 = 34, + fload_1 = 35, + fload_2 = 36, + fload_3 = 37, + istore = 54, + fstore = 56, + istore_0 = 59, + istore_1 = 60, + istore_2 = 61, + istore_3 = 62, + fstore_0 = 67, + fstore_1 = 68, + fstore_2 = 69, + fstore_3 = 70, + pop = 87, + fadd = 98, + fsub = 102, + imul = 104, + iinc = 132, + f2i = 139, + fcmpl = 149, + fcmpg = 150, + ifge = 156, + ifgt = 157, + ifle = 158, + if_icmpge = 162, + if_icmpgt = 163, + if_icmple = 164, + _goto = 167, + getstatic = 178, + putstatic = 179 + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs index 5d6d63ed90..56e02ff740 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs @@ -1,42 +1,42 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM -{ - public class Stack - { - public Stack StackFrames = new Stack(); - - public Stack() - { - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + public class Stack + { + public Stack StackFrames = new Stack(); + + public Stack() + { + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs index 0a0d20a9ec..a5f902904d 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs @@ -1,49 +1,49 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM -{ - public class StackFrame - { - public BaseType[] LocalVariables; - public Stack OpStack = new Stack(); - - public int ReturnPC = 0; - public ClassRecord CallingClass = null; - - public StackFrame() - { - LocalVariables = new BaseType[20]; - } - - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + public class StackFrame + { + public BaseType[] LocalVariables; + public Stack OpStack = new Stack(); + + public int ReturnPC = 0; + public ClassRecord CallingClass = null; + + public StackFrame() + { + LocalVariables = new BaseType[20]; + } + + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs index b386b826b6..b810676c26 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs @@ -1,119 +1,119 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; -using OpenSim.Framework; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.ExtensionsScriptModule; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM -{ - public partial class Thread - { - // Is this smart? - public static MainMemory GlobalMemory; - public static Scene World; - private int PC = 0; - private Stack stack; - private Interpreter m_Interpreter; - public ClassRecord currentClass; - public ClassInstance currentInstance; - private StackFrame m_currentFrame; - public int excutionCounter = 0; - public bool running = false; - - public ScriptInfo scriptInfo; - - public Thread() - { - this.m_Interpreter = new Interpreter(this); - this.stack = new Stack(); - } - - public void SetPC(int methodpointer) - { - //Console.WriteLine("Thread PC has been set to " + methodpointer); - PC = methodpointer; - } - - public void StartMethod(ClassRecord rec, string methName) - { - m_currentFrame = new StackFrame(); - this.stack.StackFrames.Push(m_currentFrame); - this.currentClass = rec; - currentClass.StartMethod(this, methName); - } - - public void StartMethod( string methName) - { - m_currentFrame = new StackFrame(); - this.stack.StackFrames.Push(m_currentFrame); - currentClass.StartMethod(this, methName); - } - - public void JumpToStaticVoidMethod(string methName, int returnPC) - { - m_currentFrame = new StackFrame(); - m_currentFrame.ReturnPC = returnPC; - this.stack.StackFrames.Push(m_currentFrame); - currentClass.StartMethod(this, methName); - } - - public void JumpToStaticParamMethod(string methName, string param, int returnPC) - { - if (param == "I") - { - BaseType bs1 = m_currentFrame.OpStack.Pop(); - m_currentFrame = new StackFrame(); - m_currentFrame.ReturnPC = returnPC; - this.stack.StackFrames.Push(m_currentFrame); - m_currentFrame.LocalVariables[0] = ((Int)bs1); - currentClass.StartMethod(this, methName); - } - if (param == "F") - { - - } - } - - public void JumpToClassStaticVoidMethod(string className, string methName, int returnPC) - { - - } - - public bool Excute() - { - excutionCounter++; - return this.m_Interpreter.Excute(); - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; +using OpenSim.Framework; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.ExtensionsScriptModule; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + public partial class Thread + { + // Is this smart? + public static MainMemory GlobalMemory; + public static Scene World; + private int PC = 0; + private Stack stack; + private Interpreter m_Interpreter; + public ClassRecord currentClass; + public ClassInstance currentInstance; + private StackFrame m_currentFrame; + public int excutionCounter = 0; + public bool running = false; + + public ScriptInfo scriptInfo; + + public Thread() + { + this.m_Interpreter = new Interpreter(this); + this.stack = new Stack(); + } + + public void SetPC(int methodpointer) + { + //Console.WriteLine("Thread PC has been set to " + methodpointer); + PC = methodpointer; + } + + public void StartMethod(ClassRecord rec, string methName) + { + m_currentFrame = new StackFrame(); + this.stack.StackFrames.Push(m_currentFrame); + this.currentClass = rec; + currentClass.StartMethod(this, methName); + } + + public void StartMethod( string methName) + { + m_currentFrame = new StackFrame(); + this.stack.StackFrames.Push(m_currentFrame); + currentClass.StartMethod(this, methName); + } + + public void JumpToStaticVoidMethod(string methName, int returnPC) + { + m_currentFrame = new StackFrame(); + m_currentFrame.ReturnPC = returnPC; + this.stack.StackFrames.Push(m_currentFrame); + currentClass.StartMethod(this, methName); + } + + public void JumpToStaticParamMethod(string methName, string param, int returnPC) + { + if (param == "I") + { + BaseType bs1 = m_currentFrame.OpStack.Pop(); + m_currentFrame = new StackFrame(); + m_currentFrame.ReturnPC = returnPC; + this.stack.StackFrames.Push(m_currentFrame); + m_currentFrame.LocalVariables[0] = ((Int)bs1); + currentClass.StartMethod(this, methName); + } + if (param == "F") + { + + } + } + + public void JumpToClassStaticVoidMethod(string className, string methName, int returnPC) + { + + } + + public bool Excute() + { + excutionCounter++; + return this.m_Interpreter.Excute(); + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JavaEngine.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JavaEngine.cs index 28b9b33596..82a32dd879 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JavaEngine.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JavaEngine.cs @@ -1,28 +1,28 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using OpenSim.Region.ExtensionsScriptModule; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine -{ - public class JavaEngine : IScriptCompiler - { - public string FileExt() - { - return ".java"; - } - - public Dictionary compile(string filename) - { - JVMScript script = new JVMScript(); - Dictionary returns = new Dictionary(); - - script.LoadScript(filename); - - returns.Add(filename, script); - - return returns; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; + +using OpenSim.Region.ExtensionsScriptModule; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine +{ + public class JavaEngine : IScriptCompiler + { + public string FileExt() + { + return ".java"; + } + + public Dictionary compile(string filename) + { + JVMScript script = new JVMScript(); + Dictionary returns = new Dictionary(); + + script.LoadScript(filename); + + returns.Add(filename, script); + + return returns; + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs index 2abb3b71e9..5d4d4abfb0 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs @@ -1,171 +1,171 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using System.Text; -using System.IO; -using System.Threading; -using OpenSim.Framework; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Utilities; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM; -using Thread = OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM.Thread; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine -{ - public class JVMScript : IScript - { - private List _threads = new List(); - private BlockingQueue CompileScripts = new BlockingQueue(); - private MainMemory _mainMemory; - - ScriptInfo scriptInfo; - - public void Initialise(ScriptInfo info) - { - scriptInfo = info; - - _mainMemory = new MainMemory(); - Thread.GlobalMemory = this._mainMemory; - Thread.World = info.world; - CompileScript(); - - scriptInfo.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame); - scriptInfo.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence); - } - - void events_OnNewPresence(ScenePresence presence) - { - for (int i = 0; i < this._threads.Count; i++) - { - if (!this._threads[i].running) - { - this._threads[i].StartMethod("OnNewPresence"); - bool run = true; - while (run) - { - run = this._threads[i].Excute(); - } - } - } - } - - void events_OnFrame() - { - for (int i = 0; i < this._threads.Count; i++) - { - if (!this._threads[i].running) - { - this._threads[i].StartMethod("OnFrame"); - bool run = true; - while (run) - { - run = this._threads[i].Excute(); - } - } - } - } - - public string Name - { - get { return "JVM Scripting Engine"; } - } - - public void LoadScript(string script) - { - Console.WriteLine("OpenSimJVM - loading new script: " + script); - CompileInfo comp = new CompileInfo(); - comp.script = script; - comp.scriptName = script; - this.CompileScripts.Enqueue(comp); - } - - public void CompileScript() - { - CompileInfo comp = this.CompileScripts.Dequeue(); - string script = comp.script; - string scriptName = comp.scriptName; - try - { - //need to compile the script into a java class file - - //first save it to a java source file - TextWriter tw = new StreamWriter(scriptName + ".java"); - tw.WriteLine(script); - tw.Close(); - - //now compile - System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java"); - // psi.RedirectStandardOutput = true; - psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; - psi.UseShellExecute = false; - - System.Diagnostics.Process javacomp; - javacomp = System.Diagnostics.Process.Start(psi); - javacomp.WaitForExit(); - - - //now load in class file - ClassRecord class1 = new ClassRecord(); - class1.LoadClassFromFile(scriptName + ".class"); - class1.PrintToConsole(); - //Console.WriteLine(); - this._mainMemory.MethodArea.Classes.Add(class1); - class1.AddMethodsToMemory(this._mainMemory.MethodArea); - - Thread newThread = new Thread(); - this._threads.Add(newThread); - newThread.currentClass = class1; - newThread.scriptInfo = scriptInfo; - - //now delete the created files - System.IO.File.Delete(scriptName + ".java"); - System.IO.File.Delete(scriptName + ".class"); - //this.OnFrame(); - } - catch (Exception e) - { - Console.WriteLine("exception"); - Console.WriteLine(e.StackTrace); - Console.WriteLine(e.Message); - } - } - - private class CompileInfo - { - public string script; - public string scriptName; - - public CompileInfo() - { - - } - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using System.Threading; +using OpenSim.Framework; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Utilities; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM; +using Thread = OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM.Thread; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine +{ + public class JVMScript : IScript + { + private List _threads = new List(); + private BlockingQueue CompileScripts = new BlockingQueue(); + private MainMemory _mainMemory; + + ScriptInfo scriptInfo; + + public void Initialise(ScriptInfo info) + { + scriptInfo = info; + + _mainMemory = new MainMemory(); + Thread.GlobalMemory = this._mainMemory; + Thread.World = info.world; + CompileScript(); + + scriptInfo.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame); + scriptInfo.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence); + } + + void events_OnNewPresence(ScenePresence presence) + { + for (int i = 0; i < this._threads.Count; i++) + { + if (!this._threads[i].running) + { + this._threads[i].StartMethod("OnNewPresence"); + bool run = true; + while (run) + { + run = this._threads[i].Excute(); + } + } + } + } + + void events_OnFrame() + { + for (int i = 0; i < this._threads.Count; i++) + { + if (!this._threads[i].running) + { + this._threads[i].StartMethod("OnFrame"); + bool run = true; + while (run) + { + run = this._threads[i].Excute(); + } + } + } + } + + public string Name + { + get { return "JVM Scripting Engine"; } + } + + public void LoadScript(string script) + { + Console.WriteLine("OpenSimJVM - loading new script: " + script); + CompileInfo comp = new CompileInfo(); + comp.script = script; + comp.scriptName = script; + this.CompileScripts.Enqueue(comp); + } + + public void CompileScript() + { + CompileInfo comp = this.CompileScripts.Dequeue(); + string script = comp.script; + string scriptName = comp.scriptName; + try + { + //need to compile the script into a java class file + + //first save it to a java source file + TextWriter tw = new StreamWriter(scriptName + ".java"); + tw.WriteLine(script); + tw.Close(); + + //now compile + System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java"); + // psi.RedirectStandardOutput = true; + psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; + psi.UseShellExecute = false; + + System.Diagnostics.Process javacomp; + javacomp = System.Diagnostics.Process.Start(psi); + javacomp.WaitForExit(); + + + //now load in class file + ClassRecord class1 = new ClassRecord(); + class1.LoadClassFromFile(scriptName + ".class"); + class1.PrintToConsole(); + //Console.WriteLine(); + this._mainMemory.MethodArea.Classes.Add(class1); + class1.AddMethodsToMemory(this._mainMemory.MethodArea); + + Thread newThread = new Thread(); + this._threads.Add(newThread); + newThread.currentClass = class1; + newThread.scriptInfo = scriptInfo; + + //now delete the created files + System.IO.File.Delete(scriptName + ".java"); + System.IO.File.Delete(scriptName + ".class"); + //this.OnFrame(); + } + catch (Exception e) + { + Console.WriteLine("exception"); + Console.WriteLine(e.StackTrace); + Console.WriteLine(e.Message); + } + } + + private class CompileInfo + { + public string script; + public string scriptName; + + public CompileInfo() + { + + } + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ArrayReference.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ArrayReference.cs index 97753cfe0c..b71c473c15 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ArrayReference.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ArrayReference.cs @@ -1,10 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types -{ - public class ArrayReference :BaseType - { - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types +{ + public class ArrayReference :BaseType + { + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/BaseType.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/BaseType.cs index d1689dfbf3..9261e7ccf7 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/BaseType.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/BaseType.cs @@ -1,10 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types -{ - public class BaseType : Object - { - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types +{ + public class BaseType : Object + { + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ObjectReference.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ObjectReference.cs index 8e1d4356d2..a0b35fba02 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ObjectReference.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ObjectReference.cs @@ -1,16 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types -{ - public class ObjectReference : BaseType - { - public ushort Reference; - - public ObjectReference() - { - - } - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types +{ + public class ObjectReference : BaseType + { + public ushort Reference; + + public ObjectReference() + { + + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs index cfbbd19751..4af15f4747 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs @@ -1,11 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes -{ - public class Byte : BaseType - { - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes +{ + public class Byte : BaseType + { + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs index 650e1ed1c4..3c934cf06a 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs @@ -1,11 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes -{ - public class Char : BaseType - { - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes +{ + public class Char : BaseType + { + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs index b5bcc646b3..f7a73664bf 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs @@ -1,17 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes -{ - public class Float : BaseType - { - public float mValue = 0; - - public Float() - { - - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes +{ + public class Float : BaseType + { + public float mValue = 0; + + public Float() + { + + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs index df133afe4f..74e27a1030 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs @@ -1,17 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; - -namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes -{ - public class Int : BaseType - { - public int mValue = 0; - - public Int() - { - - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes +{ + public class Int : BaseType + { + public int mValue = 0; + + public Int() + { + + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Script.cs b/OpenSim/Region/ExtensionsScriptModule/Script.cs index 0a2f3e86a0..251b8c3dcc 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Script.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Script.cs @@ -1,64 +1,64 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.ExtensionsScriptModule -{ - public interface IScript - { - void Initialise(ScriptInfo scriptInfo); - string Name { get; } - } - - public class TestScript : IScript - { - ScriptInfo script; - - public string Name - { - get { return "TestScript 0.1"; } - } - - public void Initialise(ScriptInfo scriptInfo) - { - script = scriptInfo; - script.events.OnFrame += events_OnFrame; - script.events.OnNewPresence += events_OnNewPresence; - } - - void events_OnNewPresence(ScenePresence presence) - { - script.logger.Verbose("Hello " + presence.Firstname.ToString() + "!"); - } - - void events_OnFrame() - { - //script.logger.Verbose("Hello World!"); - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using OpenSim.Region.Environment.Scenes; + +namespace OpenSim.Region.ExtensionsScriptModule +{ + public interface IScript + { + void Initialise(ScriptInfo scriptInfo); + string Name { get; } + } + + public class TestScript : IScript + { + ScriptInfo script; + + public string Name + { + get { return "TestScript 0.1"; } + } + + public void Initialise(ScriptInfo scriptInfo) + { + script = scriptInfo; + script.events.OnFrame += events_OnFrame; + script.events.OnNewPresence += events_OnNewPresence; + } + + void events_OnNewPresence(ScenePresence presence) + { + script.logger.Verbose("Hello " + presence.Firstname.ToString() + "!"); + } + + void events_OnFrame() + { + //script.logger.Verbose("Hello World!"); + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptAPI.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptAPI.cs index d32de7c88b..924a40200f 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptAPI.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptAPI.cs @@ -1,32 +1,32 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Key = libsecondlife.LLUUID; -using Rotation = libsecondlife.LLQuaternion; -using Vector = libsecondlife.LLVector3; -using LSLList = System.Collections.Generic.List; - - -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.ExtensionsScriptModule -{ - // This class is to be used for engines which may not be able to access the Scene directly. - // Scene access is preffered, but obviously not possible on some non-.NET languages. - public class ScriptAPI - { - Scene scene; - ScriptInterpretedAPI interpretedAPI; - - public ScriptAPI(Scene world, Key taskID) - { - scene = world; - interpretedAPI = new ScriptInterpretedAPI(world, taskID); - } - - public Object CallMethod(String method, Object[] args) - { - return null; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using Key = libsecondlife.LLUUID; +using Rotation = libsecondlife.LLQuaternion; +using Vector = libsecondlife.LLVector3; +using LSLList = System.Collections.Generic.List; + + +using OpenSim.Region.Environment.Scenes; + +namespace OpenSim.Region.ExtensionsScriptModule +{ + // This class is to be used for engines which may not be able to access the Scene directly. + // Scene access is preffered, but obviously not possible on some non-.NET languages. + public class ScriptAPI + { + Scene scene; + ScriptInterpretedAPI interpretedAPI; + + public ScriptAPI(Scene world, Key taskID) + { + scene = world; + interpretedAPI = new ScriptInterpretedAPI(world, taskID); + } + + public Object CallMethod(String method, Object[] args) + { + return null; + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs index 01e2e60108..aaadd1fc7e 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs @@ -1,63 +1,63 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using OpenSim.Framework.Console; -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.ExtensionsScriptModule -{ - /// - /// Class which provides access to the world - /// - public class ScriptInfo - { - // Reference to world.eventsManager provided for convenience - public EventManager events; - - // The main world - public Scene world; - - // The console - public LogBase logger; - - // API Access - public ScriptAPI api; - - public ScriptInfo(Scene scene) - { - world = scene; - events = world.EventManager; - logger = MainLog.Instance; - api = new ScriptAPI(world, libsecondlife.LLUUID.Zero); - } - - public void CreateTaskAPI(libsecondlife.LLUUID task) - { - api = new ScriptAPI(world, task); - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using OpenSim.Framework.Console; +using OpenSim.Region.Environment.Scenes; + +namespace OpenSim.Region.ExtensionsScriptModule +{ + /// + /// Class which provides access to the world + /// + public class ScriptInfo + { + // Reference to world.eventsManager provided for convenience + public EventManager events; + + // The main world + public Scene world; + + // The console + public LogBase logger; + + // API Access + public ScriptAPI api; + + public ScriptInfo(Scene scene) + { + world = scene; + events = world.EventManager; + logger = MainLog.Instance; + api = new ScriptAPI(world, libsecondlife.LLUUID.Zero); + } + + public void CreateTaskAPI(libsecondlife.LLUUID task) + { + api = new ScriptAPI(world, task); + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs index c880bce7e8..517b95f836 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs @@ -1,267 +1,267 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Key = libsecondlife.LLUUID; -using Rotation = libsecondlife.LLQuaternion; -using Vector = libsecondlife.LLVector3; -using LSLList = System.Collections.Generic.List; - -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.LandManagement; -using libsecondlife; - -namespace OpenSim.Region.ExtensionsScriptModule -{ - /// - /// A class inteded to act as an API for LSL-styled interpreted languages - /// - /// Avoid at all costs. This should ONLY be used for LSL. - class ScriptInterpretedAPI - { - protected LLUUID m_object; - protected Scene m_scene; - - /// - /// The scene in which this script is acting - /// - public Scene Scene - { - get { return m_scene; } - } - - /// - /// The id of the object our script is supposed to be acting in - /// - public Key ObjectID - { - get { return m_object; } - } - - /// - /// The object our script is supposed to be in - /// - public SceneObjectGroup Task - { - get { return Scene.Objects[ObjectID]; } - } - - /// - /// Creates a new ScriptInterpretedAPI for a specified object - /// - /// The scene the object is located in - /// The specific member being 'occupied' by the script - public ScriptInterpretedAPI(Scene world, libsecondlife.LLUUID member) - { - m_scene = world; - m_object = member; - } - - /// - /// Returns the absolute number of a integer value. - /// - /// Input - /// Absolute number of input - public int osAbs(int val) - { - return Math.Abs(val); - } - - public float osAcos(float val) - { - return (float)Math.Acos(val); - } - - [Obsolete("Unimplemented")] - public void osAddToLandPassList(Key avatar, float hours) - { - Vector myPosition = Task.AbsolutePosition; - Land myParcel = Scene.LandManager.getLandObject(myPosition.X, myPosition.Y); - - OpenSim.Framework.Console.MainLog.Instance.Warn("script", "Unimplemented function called by script: osAddToLandPassList(Key avatar, float hours)"); - return; - } - - [Obsolete("Unimplemented")] - public void osAdjustSoundVolume(float volume) - { - OpenSim.Framework.Console.MainLog.Instance.Warn("script", "Unimplemented function called by script: osAdjustSoundVolume(float volume)"); - return; - } - - [Obsolete("Unimplemented")] - public void osAllowInventoryDrop(int add) - { - return; - } - - [Obsolete("Unimplemented")] - public float osAngleBetween(Rotation a, Rotation b) - { - Axiom.Math.Quaternion axA = new Axiom.Math.Quaternion(a.W, a.X, a.Y, a.Z); - Axiom.Math.Quaternion axB = new Axiom.Math.Quaternion(b.W, b.X, b.Y, b.Z); - - return 0; - } - - [Obsolete("Unimplemented")] - public void osApplyImpulse(Vector force, int local) - { - return; - } - - [Obsolete("Unimplemented")] - public void osApplyRotationalImpulse(Vector force, int local) - { - return; - } - - public float osAsin(float val) - { - return (float)Math.Asin(val); - } - - public float osAtan2(float x, float y) - { - return (float)Math.Atan2(x, y); - } - - [Obsolete("Unimplemented")] - public void osAttachToAvatar(Key avatar, int attachmentPoint) - { - return; - } - - [Obsolete("Unimplemented")] - public Key osAvatarOnSitTarget() - { - //TODO: Follow this as Children is chanced to be of type entity to support ScenePresences - /* - foreach (KeyValuePair Child in Task.Children) - { - if (Child.Value is ScenePresence) - { - return Child.Value.uuid; - } - } - */ - - return Key.Zero; - } - - public Rotation osAxes2Rot(Vector fwd, Vector left, Vector up) - { - Axiom.Math.Quaternion axQ = new Axiom.Math.Quaternion(); - Axiom.Math.Vector3 axFwd = new Axiom.Math.Vector3(fwd.X, fwd.Y, fwd.Z); - Axiom.Math.Vector3 axLeft = new Axiom.Math.Vector3(left.X, left.Y, left.Z); - Axiom.Math.Vector3 axUp = new Axiom.Math.Vector3(up.X, up.Y, up.Z); - - axQ.FromAxes(axFwd, axLeft, axUp); - - return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); - } - - public Rotation osAxisAngle2Rot(Vector axis, float angle) - { - Axiom.Math.Quaternion axQ = Axiom.Math.Quaternion.FromAngleAxis(angle, new Axiom.Math.Vector3(axis.X, axis.Y, axis.Z)); - - return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); - } - - public string osBase64ToString(string str) - { - Encoding enc = System.Text.Encoding.UTF8; - return enc.GetString(Convert.FromBase64String(str)); - } - - [Obsolete("Unimplemented")] - public void osBreakAllLinks() - { - return; - } - - [Obsolete("Unimplemented")] - public void osBreakLink() - { - return; - } - - public LSLList osCSV2List(string src) - { - LSLList retVal = new LSLList(); - retVal.AddRange(src.Split(',')); - - return retVal; - } - - public int osCeil(float val) - { - return (int)Math.Ceiling(val); - } - - [Obsolete("Unimplemented")] - public void osCloseRemoteDataChannel(Key channel) - { - return; - } - - [Obsolete("Unimplemented")] - public float osCloud(Vector offset) - { - return 0.0f; - } - - [Obsolete("Unimplemented")] - public void osCollisionFilter(string name, Key id, int accept) - { - return; - } - - [Obsolete("Unimplemented")] - public void osCollisionSprite(string impact_sprite) - { - return; - } - - public float osCos(float theta) - { - return (float)Math.Cos(theta); - } - - public void osCreateLink(Key target, int parent) - { - if(Scene.Entities[target] is SceneObjectGroup) - Task.LinkToGroup((SceneObjectGroup)Scene.Entities[target]); - - return; - } - - [Obsolete("Partially Unimplemented")] - public LSLList osDeleteSubList(LSLList src, int start, int end) - { - if (start < 0 || end < 0) - { - throw new Exception("Unsupported at this time."); - } - - src.RemoveRange(start, start - end + 1); - return src; - } - - [Obsolete("Partially Unimplemented")] - public string osDeleteSubString(string src, int start, int end) - { - if (start < 0 || end < 0) - { - throw new Exception("Unsupported at this time."); - } - - return src.Remove(start, start - end + 1); - } - - [Obsolete("Unimplemented")] - public void osDetachFromAvatar(Key avatar) - { - return; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using Key = libsecondlife.LLUUID; +using Rotation = libsecondlife.LLQuaternion; +using Vector = libsecondlife.LLVector3; +using LSLList = System.Collections.Generic.List; + +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.LandManagement; +using libsecondlife; + +namespace OpenSim.Region.ExtensionsScriptModule +{ + /// + /// A class inteded to act as an API for LSL-styled interpreted languages + /// + /// Avoid at all costs. This should ONLY be used for LSL. + class ScriptInterpretedAPI + { + protected LLUUID m_object; + protected Scene m_scene; + + /// + /// The scene in which this script is acting + /// + public Scene Scene + { + get { return m_scene; } + } + + /// + /// The id of the object our script is supposed to be acting in + /// + public Key ObjectID + { + get { return m_object; } + } + + /// + /// The object our script is supposed to be in + /// + public SceneObjectGroup Task + { + get { return Scene.Objects[ObjectID]; } + } + + /// + /// Creates a new ScriptInterpretedAPI for a specified object + /// + /// The scene the object is located in + /// The specific member being 'occupied' by the script + public ScriptInterpretedAPI(Scene world, libsecondlife.LLUUID member) + { + m_scene = world; + m_object = member; + } + + /// + /// Returns the absolute number of a integer value. + /// + /// Input + /// Absolute number of input + public int osAbs(int val) + { + return Math.Abs(val); + } + + public float osAcos(float val) + { + return (float)Math.Acos(val); + } + + [Obsolete("Unimplemented")] + public void osAddToLandPassList(Key avatar, float hours) + { + Vector myPosition = Task.AbsolutePosition; + Land myParcel = Scene.LandManager.getLandObject(myPosition.X, myPosition.Y); + + OpenSim.Framework.Console.MainLog.Instance.Warn("script", "Unimplemented function called by script: osAddToLandPassList(Key avatar, float hours)"); + return; + } + + [Obsolete("Unimplemented")] + public void osAdjustSoundVolume(float volume) + { + OpenSim.Framework.Console.MainLog.Instance.Warn("script", "Unimplemented function called by script: osAdjustSoundVolume(float volume)"); + return; + } + + [Obsolete("Unimplemented")] + public void osAllowInventoryDrop(int add) + { + return; + } + + [Obsolete("Unimplemented")] + public float osAngleBetween(Rotation a, Rotation b) + { + Axiom.Math.Quaternion axA = new Axiom.Math.Quaternion(a.W, a.X, a.Y, a.Z); + Axiom.Math.Quaternion axB = new Axiom.Math.Quaternion(b.W, b.X, b.Y, b.Z); + + return 0; + } + + [Obsolete("Unimplemented")] + public void osApplyImpulse(Vector force, int local) + { + return; + } + + [Obsolete("Unimplemented")] + public void osApplyRotationalImpulse(Vector force, int local) + { + return; + } + + public float osAsin(float val) + { + return (float)Math.Asin(val); + } + + public float osAtan2(float x, float y) + { + return (float)Math.Atan2(x, y); + } + + [Obsolete("Unimplemented")] + public void osAttachToAvatar(Key avatar, int attachmentPoint) + { + return; + } + + [Obsolete("Unimplemented")] + public Key osAvatarOnSitTarget() + { + //TODO: Follow this as Children is chanced to be of type entity to support ScenePresences + /* + foreach (KeyValuePair Child in Task.Children) + { + if (Child.Value is ScenePresence) + { + return Child.Value.uuid; + } + } + */ + + return Key.Zero; + } + + public Rotation osAxes2Rot(Vector fwd, Vector left, Vector up) + { + Axiom.Math.Quaternion axQ = new Axiom.Math.Quaternion(); + Axiom.Math.Vector3 axFwd = new Axiom.Math.Vector3(fwd.X, fwd.Y, fwd.Z); + Axiom.Math.Vector3 axLeft = new Axiom.Math.Vector3(left.X, left.Y, left.Z); + Axiom.Math.Vector3 axUp = new Axiom.Math.Vector3(up.X, up.Y, up.Z); + + axQ.FromAxes(axFwd, axLeft, axUp); + + return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); + } + + public Rotation osAxisAngle2Rot(Vector axis, float angle) + { + Axiom.Math.Quaternion axQ = Axiom.Math.Quaternion.FromAngleAxis(angle, new Axiom.Math.Vector3(axis.X, axis.Y, axis.Z)); + + return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); + } + + public string osBase64ToString(string str) + { + Encoding enc = System.Text.Encoding.UTF8; + return enc.GetString(Convert.FromBase64String(str)); + } + + [Obsolete("Unimplemented")] + public void osBreakAllLinks() + { + return; + } + + [Obsolete("Unimplemented")] + public void osBreakLink() + { + return; + } + + public LSLList osCSV2List(string src) + { + LSLList retVal = new LSLList(); + retVal.AddRange(src.Split(',')); + + return retVal; + } + + public int osCeil(float val) + { + return (int)Math.Ceiling(val); + } + + [Obsolete("Unimplemented")] + public void osCloseRemoteDataChannel(Key channel) + { + return; + } + + [Obsolete("Unimplemented")] + public float osCloud(Vector offset) + { + return 0.0f; + } + + [Obsolete("Unimplemented")] + public void osCollisionFilter(string name, Key id, int accept) + { + return; + } + + [Obsolete("Unimplemented")] + public void osCollisionSprite(string impact_sprite) + { + return; + } + + public float osCos(float theta) + { + return (float)Math.Cos(theta); + } + + public void osCreateLink(Key target, int parent) + { + if(Scene.Entities[target] is SceneObjectGroup) + Task.LinkToGroup((SceneObjectGroup)Scene.Entities[target]); + + return; + } + + [Obsolete("Partially Unimplemented")] + public LSLList osDeleteSubList(LSLList src, int start, int end) + { + if (start < 0 || end < 0) + { + throw new Exception("Unsupported at this time."); + } + + src.RemoveRange(start, start - end + 1); + return src; + } + + [Obsolete("Partially Unimplemented")] + public string osDeleteSubString(string src, int start, int end) + { + if (start < 0 || end < 0) + { + throw new Exception("Unsupported at this time."); + } + + return src.Remove(start, start - end + 1); + } + + [Obsolete("Unimplemented")] + public void osDetachFromAvatar(Key avatar) + { + return; + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedEvents.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedEvents.cs index 92c67b7e5a..472dd06314 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedEvents.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedEvents.cs @@ -1,23 +1,23 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.Environment.Scenes; -using libsecondlife; -using Key = libsecondlife.LLUUID; - -namespace OpenSim.Region.ExtensionsScriptModule -{ - - public class ScriptInterpretedEvents - { - public delegate void OnTouchStartDelegate(Key user); - public event OnTouchStartDelegate OnTouchStart; - - - public void TriggerTouchStart(Key user) - { - if (OnTouchStart != null) - OnTouchStart(user); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.Environment.Scenes; +using libsecondlife; +using Key = libsecondlife.LLUUID; + +namespace OpenSim.Region.ExtensionsScriptModule +{ + + public class ScriptInterpretedEvents + { + public delegate void OnTouchStartDelegate(Key user); + public event OnTouchStartDelegate OnTouchStart; + + + public void TriggerTouchStart(Key user) + { + if (OnTouchStart != null) + OnTouchStart(user); + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs index 27b9c00b76..ac5ac89c1a 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs @@ -1,143 +1,143 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System.Collections.Generic; -using OpenSim.Framework.Console; -using OpenSim.Region.Environment; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.ExtensionsScriptModule.CSharp; -using OpenSim.Region.ExtensionsScriptModule.JScript; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine; - -namespace OpenSim.Region.ExtensionsScriptModule -{ - public class ScriptManager : IRegionModule - { - List scripts = new List(); - Scene m_scene; - Dictionary compilers = new Dictionary(); - - private void LoadFromCompiler(Dictionary compiledscripts) - { - foreach (KeyValuePair script in compiledscripts) - { - ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. - MainLog.Instance.Verbose("Loading " + script.Key); - script.Value.Initialise(scriptInfo); - scripts.Add(script.Value); - } - MainLog.Instance.Verbose("Finished loading " + compiledscripts.Count.ToString() + " script(s)"); - } - - public ScriptManager() - { - // Default Engines - CSharpScriptEngine csharpCompiler = new CSharpScriptEngine(); - compilers.Add(csharpCompiler.FileExt(), csharpCompiler); - - JScriptEngine jscriptCompiler = new JScriptEngine(); - compilers.Add(jscriptCompiler.FileExt(), jscriptCompiler); - - JavaEngine javaCompiler = new JavaEngine(); - compilers.Add(javaCompiler.FileExt(), javaCompiler); - } - - public void Initialise(Scene scene) - { - System.Console.WriteLine("Initialising Extensions Scripting Module"); - m_scene = scene; - - m_scene.RegisterAPIMethod("API_CompileExtensionScript", new ModuleAPIMethod1(Compile)); - m_scene.RegisterAPIMethod("API_AddExtensionScript", new ModuleAPIMethod1(AddPreCompiledScript)); - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - - } - - public string GetName() - { - return "ExtensionsScriptingModule"; - } - - public bool IsSharedModule() - { - return false; - } - - public bool Compile(string filename) - { - foreach (KeyValuePair compiler in compilers) - { - if (filename.EndsWith(compiler.Key)) - { - LoadFromCompiler(compiler.Value.compile(filename)); - break; - } - } - - return true; - } - - public void RunScriptCmd(string[] args) - { - switch (args[0]) - { - case "load": - Compile(args[1]); - break; - - default: - MainLog.Instance.Error("Unknown script command"); - break; - } - } - - public bool AddPreCompiledScript(IScript script) - { - MainLog.Instance.Verbose("Loading script " + script.Name); - ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. - script.Initialise(scriptInfo); - scripts.Add(script); - - return true; - } - } - - interface IScriptCompiler - { - Dictionary compile(string filename); - string FileExt(); - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System.Collections.Generic; +using OpenSim.Framework.Console; +using OpenSim.Region.Environment; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.ExtensionsScriptModule.CSharp; +using OpenSim.Region.ExtensionsScriptModule.JScript; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine; + +namespace OpenSim.Region.ExtensionsScriptModule +{ + public class ScriptManager : IRegionModule + { + List scripts = new List(); + Scene m_scene; + Dictionary compilers = new Dictionary(); + + private void LoadFromCompiler(Dictionary compiledscripts) + { + foreach (KeyValuePair script in compiledscripts) + { + ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. + MainLog.Instance.Verbose("Loading " + script.Key); + script.Value.Initialise(scriptInfo); + scripts.Add(script.Value); + } + MainLog.Instance.Verbose("Finished loading " + compiledscripts.Count.ToString() + " script(s)"); + } + + public ScriptManager() + { + // Default Engines + CSharpScriptEngine csharpCompiler = new CSharpScriptEngine(); + compilers.Add(csharpCompiler.FileExt(), csharpCompiler); + + JScriptEngine jscriptCompiler = new JScriptEngine(); + compilers.Add(jscriptCompiler.FileExt(), jscriptCompiler); + + JavaEngine javaCompiler = new JavaEngine(); + compilers.Add(javaCompiler.FileExt(), javaCompiler); + } + + public void Initialise(Scene scene) + { + System.Console.WriteLine("Initialising Extensions Scripting Module"); + m_scene = scene; + + m_scene.RegisterAPIMethod("API_CompileExtensionScript", new ModuleAPIMethod1(Compile)); + m_scene.RegisterAPIMethod("API_AddExtensionScript", new ModuleAPIMethod1(AddPreCompiledScript)); + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + + } + + public string GetName() + { + return "ExtensionsScriptingModule"; + } + + public bool IsSharedModule() + { + return false; + } + + public bool Compile(string filename) + { + foreach (KeyValuePair compiler in compilers) + { + if (filename.EndsWith(compiler.Key)) + { + LoadFromCompiler(compiler.Value.compile(filename)); + break; + } + } + + return true; + } + + public void RunScriptCmd(string[] args) + { + switch (args[0]) + { + case "load": + Compile(args[1]); + break; + + default: + MainLog.Instance.Error("Unknown script command"); + break; + } + } + + public bool AddPreCompiledScript(IScript script) + { + MainLog.Instance.Verbose("Loading script " + script.Name); + ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. + script.Initialise(scriptInfo); + scripts.Add(script); + + return true; + } + } + + interface IScriptCompiler + { + Dictionary compile(string filename); + string FileExt(); + } +} diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs index f7aa634700..ff5c6bffdc 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs @@ -612,7 +612,7 @@ namespace OpenSim.Region.ScriptEngine.Common //wiki: integer llGetRegionFlags() int llGetRegionFlags(); //wiki: string llXorBase64StringsCorrect(string str1, string str2) - string llXorBase64StringsCorrect(string str1, string str2); + string llXorBase64StringsCorrect(string str1, string str2); void llHTTPRequest(string url, List parameters, string body); //wiki: llResetLandBanList() void llResetLandBanList(); diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs index 78cfd214b8..6603323f0c 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs @@ -1,120 +1,120 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.IO; -using Microsoft.CSharp; -using System.CodeDom.Compiler; -using System.Reflection; - -namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL -{ - - public class Compiler - { - private LSL2CSConverter LSL_Converter = new LSL2CSConverter(); - private CSharpCodeProvider codeProvider = new CSharpCodeProvider(); - private static UInt64 scriptCompileCounter = 0; - //private ICodeCompiler icc = codeProvider.CreateCompiler(); - public string CompileFromFile(string LSOFileName) - { - switch (System.IO.Path.GetExtension(LSOFileName).ToLower()) - { - case ".txt": - case ".lsl": - Common.SendToDebug("Source code is LSL, converting to CS"); - return CompileFromLSLText(File.ReadAllText(LSOFileName)); - case ".cs": - Common.SendToDebug("Source code is CS"); - return CompileFromCSText(File.ReadAllText(LSOFileName)); - default: - throw new Exception("Unknown script type."); - } - } - /// - /// Converts script from LSL to CS and calls CompileFromCSText - /// - /// LSL script - /// Filename to .dll assembly - public string CompileFromLSLText(string Script) - { - if (Script.Substring(0, 4).ToLower() == "//c#") - { - return CompileFromCSText( Script ); - } - else - { - return CompileFromCSText(LSL_Converter.Convert(Script)); - } - } - /// - /// Compile CS script to .Net assembly (.dll) - /// - /// CS script - /// Filename to .dll assembly - public string CompileFromCSText(string Script) - { - - - // Output assembly name - scriptCompileCounter++; - string OutFile = Path.Combine("ScriptEngines", "Script_" + scriptCompileCounter + ".dll"); - try - { - System.IO.File.Delete(OutFile); - } - catch (Exception e) - { - Console.WriteLine("Exception attempting to delete old compiled script: " + e.ToString()); - } - //string OutFile = Path.Combine("ScriptEngines", "SecondLife.Script.dll"); - - // DEBUG - write source to disk - try - { - File.WriteAllText(Path.Combine("ScriptEngines", "debug_" + Path.GetFileNameWithoutExtension(OutFile) + ".cs"), Script); - } - catch { } - - // Do actual compile - System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters(); - parameters.IncludeDebugInformation = true; - // Add all available assemblies - foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) - { - //Console.WriteLine("Adding assembly: " + asm.Location); - //parameters.ReferencedAssemblies.Add(asm.Location); - } - - string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); - string rootPathSE = Path.GetDirectoryName(this.GetType().Assembly.Location); - //Console.WriteLine("Assembly location: " + rootPath); - parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Common.dll")); - parameters.ReferencedAssemblies.Add(Path.Combine(rootPathSE, "OpenSim.Region.ScriptEngine.DotNetEngine.dll")); - - //parameters.ReferencedAssemblies.Add("OpenSim.Region.Environment"); - parameters.GenerateExecutable = false; - parameters.OutputAssembly = OutFile; - parameters.IncludeDebugInformation = false; - CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, Script); - - // Go through errors - // TODO: Return errors to user somehow - if (results.Errors.Count > 0) - { - - string errtext = ""; - foreach (CompilerError CompErr in results.Errors) - { - errtext += "Line number " + (CompErr.Line - 1) + - ", Error Number: " + CompErr.ErrorNumber + - ", '" + CompErr.ErrorText + "'\r\n"; - } - throw new Exception(errtext); - } - - - return OutFile; - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using Microsoft.CSharp; +using System.CodeDom.Compiler; +using System.Reflection; + +namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL +{ + + public class Compiler + { + private LSL2CSConverter LSL_Converter = new LSL2CSConverter(); + private CSharpCodeProvider codeProvider = new CSharpCodeProvider(); + private static UInt64 scriptCompileCounter = 0; + //private ICodeCompiler icc = codeProvider.CreateCompiler(); + public string CompileFromFile(string LSOFileName) + { + switch (System.IO.Path.GetExtension(LSOFileName).ToLower()) + { + case ".txt": + case ".lsl": + Common.SendToDebug("Source code is LSL, converting to CS"); + return CompileFromLSLText(File.ReadAllText(LSOFileName)); + case ".cs": + Common.SendToDebug("Source code is CS"); + return CompileFromCSText(File.ReadAllText(LSOFileName)); + default: + throw new Exception("Unknown script type."); + } + } + /// + /// Converts script from LSL to CS and calls CompileFromCSText + /// + /// LSL script + /// Filename to .dll assembly + public string CompileFromLSLText(string Script) + { + if (Script.Substring(0, 4).ToLower() == "//c#") + { + return CompileFromCSText( Script ); + } + else + { + return CompileFromCSText(LSL_Converter.Convert(Script)); + } + } + /// + /// Compile CS script to .Net assembly (.dll) + /// + /// CS script + /// Filename to .dll assembly + public string CompileFromCSText(string Script) + { + + + // Output assembly name + scriptCompileCounter++; + string OutFile = Path.Combine("ScriptEngines", "Script_" + scriptCompileCounter + ".dll"); + try + { + System.IO.File.Delete(OutFile); + } + catch (Exception e) + { + Console.WriteLine("Exception attempting to delete old compiled script: " + e.ToString()); + } + //string OutFile = Path.Combine("ScriptEngines", "SecondLife.Script.dll"); + + // DEBUG - write source to disk + try + { + File.WriteAllText(Path.Combine("ScriptEngines", "debug_" + Path.GetFileNameWithoutExtension(OutFile) + ".cs"), Script); + } + catch { } + + // Do actual compile + System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters(); + parameters.IncludeDebugInformation = true; + // Add all available assemblies + foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) + { + //Console.WriteLine("Adding assembly: " + asm.Location); + //parameters.ReferencedAssemblies.Add(asm.Location); + } + + string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); + string rootPathSE = Path.GetDirectoryName(this.GetType().Assembly.Location); + //Console.WriteLine("Assembly location: " + rootPath); + parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Common.dll")); + parameters.ReferencedAssemblies.Add(Path.Combine(rootPathSE, "OpenSim.Region.ScriptEngine.DotNetEngine.dll")); + + //parameters.ReferencedAssemblies.Add("OpenSim.Region.Environment"); + parameters.GenerateExecutable = false; + parameters.OutputAssembly = OutFile; + parameters.IncludeDebugInformation = false; + CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, Script); + + // Go through errors + // TODO: Return errors to user somehow + if (results.Errors.Count > 0) + { + + string errtext = ""; + foreach (CompilerError CompErr in results.Errors) + { + errtext += "Line number " + (CompErr.Line - 1) + + ", Error Number: " + CompErr.ErrorNumber + + ", '" + CompErr.ErrorText + "'\r\n"; + } + throw new Exception(errtext); + } + + + return OutFile; + } + + } +} diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs index 1294213fd8..18eddd0a34 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs @@ -45,7 +45,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL } } - public LSL_BuiltIn_Commands_Interface m_LSL_Functions; + public LSL_BuiltIn_Commands_Interface m_LSL_Functions; public string SourceCode = ""; public LSL_BaseClass() @@ -453,7 +453,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL public int llGetUnixTime() { return m_LSL_Functions.llGetUnixTime(); } public int llGetParcelFlags(LSL_Types.Vector3 pos) { return m_LSL_Functions.llGetParcelFlags(pos); } public int llGetRegionFlags() { return m_LSL_Functions.llGetRegionFlags(); } - public string llXorBase64StringsCorrect(string str1, string str2) { return m_LSL_Functions.llXorBase64StringsCorrect(str1, str2); } + public string llXorBase64StringsCorrect(string str1, string str2) { return m_LSL_Functions.llXorBase64StringsCorrect(str1, str2); } public void llHTTPRequest(string url, List parameters, string body) { m_LSL_Functions.llHTTPRequest(url, parameters, body); } public void llResetLandBanList() { m_LSL_Functions.llResetLandBanList(); } public void llResetLandPassList() { m_LSL_Functions.llResetLandPassList(); } diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs index eb72d5cf22..a2aa713cf0 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs @@ -1,1031 +1,1031 @@ -using Axiom.Math; -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Scenes.Scripting; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler; -using OpenSim.Region.ScriptEngine.Common; -using OpenSim.Framework.Console; -using OpenSim.Framework.Utilities; -using System.Runtime.Remoting.Lifetime; - -namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler -{ - // - // !!!IMPORTANT!!! - // - // REMEMBER TO UPDATE http://opensimulator.org/wiki/LlFunction_implementation_status - // - - /// - /// Contains all LSL ll-functions. This class will be in Default AppDomain. - /// - public class LSL_BuiltIn_Commands : MarshalByRefObject, LSL_BuiltIn_Commands_Interface - { - - private System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); - private ScriptEngine m_ScriptEngine; - private SceneObjectPart m_host; - private uint m_localID; - private LLUUID m_itemID; - private bool throwErrorOnNotImplemented = true; - - - public LSL_BuiltIn_Commands(ScriptEngine ScriptEngine, SceneObjectPart host, uint localID, LLUUID itemID) - { - m_ScriptEngine = ScriptEngine; - m_host = host; - m_localID = localID; - m_itemID = itemID; - - - //MainLog.Instance.Notice("ScriptEngine", "LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]"); - } - - - private string m_state = "default"; - - public string State() - { - return m_state; - } - - // Object never expires - public override Object InitializeLifetimeService() - { - //Console.WriteLine("LSL_BuiltIn_Commands: InitializeLifetimeService()"); - // return null; - ILease lease = (ILease)base.InitializeLifetimeService(); - - if (lease.CurrentState == LeaseState.Initial) - { - lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1); - // lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); - // lease.RenewOnCallTime = TimeSpan.FromSeconds(2); - } - return lease; - } - - - public Scene World - { - get { return m_ScriptEngine.World; } - } - - //These are the implementations of the various ll-functions used by the LSL scripts. - //starting out, we use the System.Math library for trig functions. - ckrinke 8-14-07 - public double llSin(double f) { return (double)Math.Sin(f); } - public double llCos(double f) { return (double)Math.Cos(f); } - public double llTan(double f) { return (double)Math.Tan(f); } - public double llAtan2(double x, double y) { return (double)Math.Atan2(y, x); } - public double llSqrt(double f) { return (double)Math.Sqrt(f); } - public double llPow(double fbase, double fexponent) { return (double)Math.Pow(fbase, fexponent); } - public int llAbs(int i) { return (int)Math.Abs(i); } - public double llFabs(double f) { return (double)Math.Abs(f); } - - public double llFrand(double mag) - { - lock (Util.RandomClass) - { - return Util.RandomClass.Next((int)mag); - } - } - - public int llFloor(double f) { return (int)Math.Floor(f); } - public int llCeil(double f) { return (int)Math.Ceiling(f); } - public int llRound(double f) { return (int)Math.Round(f, 3); } - - //This next group are vector operations involving squaring and square root. ckrinke - public double llVecMag(LSL_Types.Vector3 v) - { - return (v.X * v.X + v.Y * v.Y + v.Z * v.Z); - } - - public LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v) - { - double mag = v.X * v.X + v.Y * v.Y + v.Z * v.Z; - LSL_Types.Vector3 nor = new LSL_Types.Vector3(); - nor.X = v.X / mag; nor.Y = v.Y / mag; nor.Z = v.Z / mag; - return nor; - } - - public double llVecDist(LSL_Types.Vector3 a, LSL_Types.Vector3 b) - { - double dx = a.X - b.X; double dy = a.Y - b.Y; double dz = a.Z - b.Z; - return Math.Sqrt(dx * dx + dy * dy + dz * dz); - } - - //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke - public LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r) - { - //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke - LSL_Types.Quaternion t = new LSL_Types.Quaternion(r.X * r.X, r.Y * r.Y, r.Z * r.Z, r.R * r.R); - double m = (t.X + t.Y + t.Z + t.R); - if (m == 0) return new LSL_Types.Vector3(); - double n = 2 * (r.Y * r.R + r.X * r.Z); - double p = m * m - n * n; - if (p > 0) - return new LSL_Types.Vector3(Math.Atan2(2.0 * (r.X * r.R - r.Y * r.Z), (-t.X - t.Y + t.Z + t.R)), - Math.Atan2(n, Math.Sqrt(p)), Math.Atan2(2.0 * (r.Z * r.R - r.X * r.Y), (t.X - t.Y - t.Z + t.R))); - else if (n > 0) - return new LSL_Types.Vector3(0.0, Math.PI / 2, Math.Atan2((r.Z * r.R + r.X * r.Y), 0.5 - t.X - t.Z)); - else - return new LSL_Types.Vector3(0.0, -Math.PI / 2, Math.Atan2((r.Z * r.R + r.X * r.Y), 0.5 - t.X - t.Z)); - } - - public LSL_Types.Quaternion llEuler2Rot(LSL_Types.Vector3 v) - { - //this comes from from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions but is incomplete as of 8/19/07 - float err = 0.00001f; - double ax = Math.Sin(v.X / 2); double aw = Math.Cos(v.X / 2); - double by = Math.Sin(v.Y / 2); double bw = Math.Cos(v.Y / 2); - double cz = Math.Sin(v.Z / 2); double cw = Math.Cos(v.Z / 2); - LSL_Types.Quaternion a1 = new LSL_Types.Quaternion(0.0, 0.0, cz, cw); - LSL_Types.Quaternion a2 = new LSL_Types.Quaternion(0.0, by, 0.0, bw); - LSL_Types.Quaternion a3 = new LSL_Types.Quaternion(ax, 0.0, 0.0, aw); - LSL_Types.Quaternion a = new LSL_Types.Quaternion(); - //This multiplication doesnt compile, yet. a = a1 * a2 * a3; - LSL_Types.Quaternion b = new LSL_Types.Quaternion(ax * bw * cw + aw * by * cz, - aw * by * cw - ax * bw * cz, aw * bw * cz + ax * by * cw, aw * bw * cw - ax * by * cz); - LSL_Types.Quaternion c = new LSL_Types.Quaternion(); - //This addition doesnt compile yet c = a + b; - LSL_Types.Quaternion d = new LSL_Types.Quaternion(); - //This addition doesnt compile yet d = a - b; - if ((Math.Abs(c.X) > err && Math.Abs(d.X) > err) || - (Math.Abs(c.Y) > err && Math.Abs(d.Y) > err) || - (Math.Abs(c.Z) > err && Math.Abs(d.Z) > err) || - (Math.Abs(c.R) > err && Math.Abs(d.R) > err)) - { - //return a new Quaternion that is null until I figure this out - // return b; - // return a; - } - return new LSL_Types.Quaternion(); - } - - public LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up) { return new LSL_Types.Quaternion(); } - public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) { return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) { return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r) { return new LSL_Types.Vector3(); } - public LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 start, LSL_Types.Vector3 end) { return new LSL_Types.Quaternion(); } - - public void llWhisper(int channelID, string text) - { - //type for whisper is 0 - World.SimChat(Helpers.StringToField(text), - 0, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); - } - - public void llSay(int channelID, string text) - { - //type for say is 1 - - World.SimChat(Helpers.StringToField(text), - 1, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); - } - - public void llShout(int channelID, string text) - { - //type for shout is 2 - World.SimChat(Helpers.StringToField(text), - 2, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); - } - - public int llListen(int channelID, string name, string ID, string msg) { NotImplemented("llListen"); return 0; } - public void llListenControl(int number, int active) { NotImplemented("llListenControl"); return; } - public void llListenRemove(int number) { NotImplemented("llListenRemove"); return; } - public void llSensor(string name, string id, int type, double range, double arc) { NotImplemented("llSensor"); return; } - public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) { NotImplemented("llSensorRepeat"); return; } - public void llSensorRemove() { NotImplemented("llSensorRemove"); return; } - public string llDetectedName(int number) { NotImplemented("llDetectedName"); return ""; } - public string llDetectedKey(int number) { NotImplemented("llDetectedKey"); return ""; } - public string llDetectedOwner(int number) { NotImplemented("llDetectedOwner"); return ""; } - public int llDetectedType(int number) { NotImplemented("llDetectedType"); return 0; } - public LSL_Types.Vector3 llDetectedPos(int number) { NotImplemented("llDetectedPos"); return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llDetectedVel(int number) { NotImplemented("llDetectedVel"); return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llDetectedGrab(int number) { NotImplemented("llDetectedGrab"); return new LSL_Types.Vector3(); } - public LSL_Types.Quaternion llDetectedRot(int number) { NotImplemented("llDetectedRot"); return new LSL_Types.Quaternion(); } - public int llDetectedGroup(int number) { NotImplemented("llDetectedGroup"); return 0; } - public int llDetectedLinkNumber(int number) { NotImplemented("llDetectedLinkNumber"); return 0; } - public void llDie() { NotImplemented("llDie"); return; } - public double llGround(LSL_Types.Vector3 offset) { NotImplemented("llGround"); return 0; } - public double llCloud(LSL_Types.Vector3 offset) { NotImplemented("llCloud"); return 0; } - public LSL_Types.Vector3 llWind(LSL_Types.Vector3 offset) { NotImplemented("llWind"); return new LSL_Types.Vector3(); } - public void llSetStatus(int status, int value) { NotImplemented("llSetStatus"); return; } - public int llGetStatus(int status) { NotImplemented("llGetStatus"); return 0; } - - public void llSetScale(LSL_Types.Vector3 scale) - { - // TODO: this needs to trigger a persistance save as well - LLVector3 tmp = m_host.Scale; - tmp.X = (float)scale.X; - tmp.Y = (float)scale.Y; - tmp.Z = (float)scale.Z; - m_host.Scale = tmp; - return; - } - public LSL_Types.Vector3 llGetScale() - { - return new LSL_Types.Vector3(m_host.Scale.X, m_host.Scale.Y, m_host.Scale.Z); - } - - public void llSetColor(LSL_Types.Vector3 color, int face) { NotImplemented("llSetColor"); return; } - public double llGetAlpha(int face) { NotImplemented("llGetAlpha"); return 0; } - public void llSetAlpha(double alpha, int face) { NotImplemented("llSetAlpha"); return; } - public LSL_Types.Vector3 llGetColor(int face) { NotImplemented("llGetColor"); return new LSL_Types.Vector3(); } - public void llSetTexture(string texture, int face) { NotImplemented("llSetTexture"); return; } - public void llScaleTexture(double u, double v, int face) { NotImplemented("llScaleTexture"); return; } - public void llOffsetTexture(double u, double v, int face) { NotImplemented("llOffsetTexture"); return; } - public void llRotateTexture(double rotation, int face) { NotImplemented("llRotateTexture"); return; } - - public string llGetTexture(int face) { NotImplemented("llGetTexture"); return ""; } - - public void llSetPos(LSL_Types.Vector3 pos) - { - if (m_host.ParentID != 0) - { - m_host.UpdateOffSet(new LLVector3((float)pos.X, (float)pos.Y, (float)pos.Z)); - } - else - { - m_host.UpdateGroupPosition(new LLVector3((float)pos.X, (float)pos.Y, (float)pos.Z)); - } - } - - public LSL_Types.Vector3 llGetPos() - { - return new LSL_Types.Vector3(m_host.AbsolutePosition.X, - m_host.AbsolutePosition.Y, - m_host.AbsolutePosition.Z); - } - - public LSL_Types.Vector3 llGetLocalPos() - { - if (m_host.ParentID != 0) - { - return new LSL_Types.Vector3(m_host.OffsetPosition.X, - m_host.OffsetPosition.Y, - m_host.OffsetPosition.Z); - } - else - { - return new LSL_Types.Vector3(m_host.AbsolutePosition.X, - m_host.AbsolutePosition.Y, - m_host.AbsolutePosition.Z); - } - } - public void llSetRot(LSL_Types.Quaternion rot) - { - m_host.UpdateRotation(new LLQuaternion((float)rot.X, (float)rot.Y, (float)rot.Z, (float)rot.R)); - } - public LSL_Types.Quaternion llGetRot() - { - LLQuaternion q = m_host.RotationOffset; - return new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); - } - public LSL_Types.Quaternion llGetLocalRot() { NotImplemented("llGetLocalRot"); return new LSL_Types.Quaternion(); } - public void llSetForce(LSL_Types.Vector3 force, int local) { NotImplemented("llSetForce"); } - public LSL_Types.Vector3 llGetForce() { NotImplemented("llGetForce"); return new LSL_Types.Vector3(); } - public int llTarget(LSL_Types.Vector3 position, double range) { NotImplemented("llTarget"); return 0; } - public void llTargetRemove(int number) { NotImplemented("llTargetRemove"); } - public int llRotTarget(LSL_Types.Quaternion rot, double error) { NotImplemented("llRotTarget"); return 0; } - public void llRotTargetRemove(int number) { NotImplemented("llRotTargetRemove"); } - public void llMoveToTarget(LSL_Types.Vector3 target, double tau) { NotImplemented("llMoveToTarget"); } - public void llStopMoveToTarget() { NotImplemented("llStopMoveToTarget"); } - public void llApplyImpulse(LSL_Types.Vector3 force, int local) { NotImplemented("llApplyImpulse"); } - public void llApplyRotationalImpulse(LSL_Types.Vector3 force, int local) { NotImplemented("llApplyRotationalImpulse"); } - public void llSetTorque(LSL_Types.Vector3 torque, int local) { NotImplemented("llSetTorque"); } - public LSL_Types.Vector3 llGetTorque() { NotImplemented("llGetTorque"); return new LSL_Types.Vector3(); } - public void llSetForceAndTorque(LSL_Types.Vector3 force, LSL_Types.Vector3 torque, int local) { NotImplemented("llSetForceAndTorque"); } - public LSL_Types.Vector3 llGetVel() { NotImplemented("llGetVel"); return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llGetAccel() { NotImplemented("llGetAccel"); return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llGetOmega() { NotImplemented("llGetOmega"); return new LSL_Types.Vector3(); } - public double llGetTimeOfDay() { NotImplemented("llGetTimeOfDay"); return 0; } - - public double llGetWallclock() - { - return DateTime.Now.TimeOfDay.TotalSeconds; - } - - public double llGetTime() { NotImplemented("llGetTime"); return 0; } - public void llResetTime() { NotImplemented("llResetTime"); } - public double llGetAndResetTime() { NotImplemented("llGetAndResetTime"); return 0; } - public void llSound() { NotImplemented("llSound"); } - public void llPlaySound(string sound, double volume) { NotImplemented("llPlaySound"); } - public void llLoopSound(string sound, double volume) { NotImplemented("llLoopSound"); } - public void llLoopSoundMaster(string sound, double volume) { NotImplemented("llLoopSoundMaster"); } - public void llLoopSoundSlave(string sound, double volume) { NotImplemented("llLoopSoundSlave"); } - public void llPlaySoundSlave(string sound, double volume) { NotImplemented("llPlaySoundSlave"); } - public void llTriggerSound(string sound, double volume) { NotImplemented("llTriggerSound"); } - public void llStopSound() { NotImplemented("llStopSound"); } - public void llPreloadSound(string sound) { NotImplemented("llPreloadSound"); } - - public string llGetSubString(string src, int start, int end) - { - return src.Substring(start, end); - } - - public string llDeleteSubString(string src, int start, int end) - { - return src.Remove(start, end - start); - } - public string llInsertString(string dst, int position, string src) - { - return dst.Insert(position, src); - } - public string llToUpper(string src) - { - return src.ToUpper(); - } - - public string llToLower(string src) - { - return src.ToLower(); - } - - public int llGiveMoney(string destination, int amount) { NotImplemented("llGiveMoney"); return 0; } - public void llMakeExplosion() { NotImplemented("llMakeExplosion"); } - public void llMakeFountain() { NotImplemented("llMakeFountain"); } - public void llMakeSmoke() { NotImplemented("llMakeSmoke"); } - public void llMakeFire() { NotImplemented("llMakeFire"); } - public void llRezObject(string inventory, LSL_Types.Vector3 pos, LSL_Types.Quaternion rot, int param) { NotImplemented("llRezObject"); } - public void llLookAt(LSL_Types.Vector3 target, double strength, double damping) { NotImplemented("llLookAt"); } - public void llStopLookAt() { NotImplemented("llStopLookAt"); } - - public void llSetTimerEvent(double sec) - { - // Setting timer repeat - m_ScriptEngine.m_LSLLongCmdHandler.SetTimerEvent(m_localID, m_itemID, sec); - } - - public void llSleep(double sec) - { - System.Threading.Thread.Sleep((int)(sec * 1000)); - } - - public double llGetMass() { NotImplemented("llGetMass"); return 0; } - public void llCollisionFilter(string name, string id, int accept) { NotImplemented("llCollisionFilter"); } - public void llTakeControls(int controls, int accept, int pass_on) { NotImplemented("llTakeControls"); } - public void llReleaseControls() { NotImplemented("llReleaseControls"); } - public void llAttachToAvatar(int attachment) { NotImplemented("llAttachToAvatar"); } - public void llDetachFromAvatar() { NotImplemented("llDetachFromAvatar"); } - public void llTakeCamera() { NotImplemented("llTakeCamera"); } - public void llReleaseCamera() { NotImplemented("llReleaseCamera"); } - - public string llGetOwner() - { - return m_host.ObjectOwner.ToStringHyphenated(); - } - - public void llInstantMessage(string user, string message) { NotImplemented("llInstantMessage"); } - public void llEmail(string address, string subject, string message) { NotImplemented("llEmail"); } - public void llGetNextEmail(string address, string subject) { NotImplemented("llGetNextEmail"); } - - public string llGetKey() - { - return m_host.UUID.ToStringHyphenated(); - } - - public void llSetBuoyancy(double buoyancy) { NotImplemented("llSetBuoyancy"); } - public void llSetHoverHeight(double height, int water, double tau) { NotImplemented("llSetHoverHeight"); } - public void llStopHover() { NotImplemented("llStopHover"); } - public void llMinEventDelay(double delay) { NotImplemented("llMinEventDelay"); } - public void llSoundPreload() { NotImplemented("llSoundPreload"); } - public void llRotLookAt(LSL_Types.Quaternion target, double strength, double damping) { NotImplemented("llRotLookAt"); } - - public int llStringLength(string str) - { - if (str.Length > 0) - { - return str.Length; - } - else - { - return 0; - } - } - - public void llStartAnimation(string anim) { NotImplemented("llStartAnimation"); } - public void llStopAnimation(string anim) { NotImplemented("llStopAnimation"); } - public void llPointAt() { NotImplemented("llPointAt"); } - public void llStopPointAt() { NotImplemented("llStopPointAt"); } - public void llTargetOmega(LSL_Types.Vector3 axis, double spinrate, double gain) { NotImplemented("llTargetOmega"); } - public int llGetStartParameter() { NotImplemented("llGetStartParameter"); return 0; } - public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos) { NotImplemented("llGodLikeRezObject"); } - public void llRequestPermissions(string agent, int perm) { NotImplemented("llRequestPermissions"); } - public string llGetPermissionsKey() { NotImplemented("llGetPermissionsKey"); return ""; } - public int llGetPermissions() { NotImplemented("llGetPermissions"); return 0; } - public int llGetLinkNumber() { NotImplemented("llGetLinkNumber"); return 0; } - public void llSetLinkColor(int linknumber, LSL_Types.Vector3 color, int face) { NotImplemented("llSetLinkColor"); } - public void llCreateLink(string target, int parent) { NotImplemented("llCreateLink"); } - public void llBreakLink(int linknum) { NotImplemented("llBreakLink"); } - public void llBreakAllLinks() { NotImplemented("llBreakAllLinks"); } - public string llGetLinkKey(int linknum) { NotImplemented("llGetLinkKey"); return ""; } - public void llGetLinkName(int linknum) { NotImplemented("llGetLinkName"); } - public int llGetInventoryNumber(int type) { NotImplemented("llGetInventoryNumber"); return 0; } - public string llGetInventoryName(int type, int number) { NotImplemented("llGetInventoryName"); return ""; } - public void llSetScriptState(string name, int run) { NotImplemented("llSetScriptState"); } - public double llGetEnergy() { return 1.0f; } - public void llGiveInventory(string destination, string inventory) { NotImplemented("llGiveInventory"); } - public void llRemoveInventory(string item) { NotImplemented("llRemoveInventory"); } - - public void llSetText(string text, LSL_Types.Vector3 color, double alpha) - { - Axiom.Math.Vector3 av3 = new Axiom.Math.Vector3((float)color.X, (float)color.Y, (float)color.Z); - m_host.SetText(text, av3, alpha); - } - - - public double llWater(LSL_Types.Vector3 offset) { NotImplemented("llWater"); return 0; } - public void llPassTouches(int pass) { NotImplemented("llPassTouches"); } - public string llRequestAgentData(string id, int data) { NotImplemented("llRequestAgentData"); return ""; } - public string llRequestInventoryData(string name) { NotImplemented("llRequestInventoryData"); return ""; } - public void llSetDamage(double damage) { NotImplemented("llSetDamage"); } - public void llTeleportAgentHome(string agent) { NotImplemented("llTeleportAgentHome"); } - public void llModifyLand(int action, int brush) { } - public void llCollisionSound(string impact_sound, double impact_volume) { NotImplemented("llCollisionSound"); } - public void llCollisionSprite(string impact_sprite) { NotImplemented("llCollisionSprite"); } - public string llGetAnimation(string id) { NotImplemented("llGetAnimation"); return ""; } - public void llResetScript() - { - m_ScriptEngine.m_ScriptManager.ResetScript(m_localID, m_itemID); - } - public void llMessageLinked(int linknum, int num, string str, string id) { } - public void llPushObject(string target, LSL_Types.Vector3 impulse, LSL_Types.Vector3 ang_impulse, int local) { } - public void llPassCollisions(int pass) { } - public string llGetScriptName() { return ""; } - - public int llGetNumberOfSides() { return 0; } - - public LSL_Types.Quaternion llAxisAngle2Rot(LSL_Types.Vector3 axis, double angle) { return new LSL_Types.Quaternion(); } - public LSL_Types.Vector3 llRot2Axis(LSL_Types.Quaternion rot) { return new LSL_Types.Vector3(); } - public void llRot2Angle() { } - - public double llAcos(double val) - { - return (double)Math.Acos(val); - } - - public double llAsin(double val) - { - return (double)Math.Asin(val); - } - - public double llAngleBetween(LSL_Types.Quaternion a, LSL_Types.Quaternion b) { return 0; } - public string llGetInventoryKey(string name) { return ""; } - public void llAllowInventoryDrop(int add) { } - public LSL_Types.Vector3 llGetSunDirection() { return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llGetTextureOffset(int face) { return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llGetTextureScale(int side) { return new LSL_Types.Vector3(); } - public double llGetTextureRot(int side) { return 0; } - - public int llSubStringIndex(string source, string pattern) - { - return source.IndexOf(pattern); - } - - public string llGetOwnerKey(string id) { NotImplemented("llGetOwnerKey"); return ""; } - - public LSL_Types.Vector3 llGetCenterOfMass() { NotImplemented("llGetCenterOfMass"); return new LSL_Types.Vector3(); } - - public List llListSort(List src, int stride, int ascending) - { - SortedList> sorted = new SortedList>(); - // Add chunks to an array - int s = stride; - if (s < 1) - s = 1; - int c = 0; - List chunk = new List(); - string chunkString = ""; - foreach (string element in src) - { - c++; - if (c > s) - { - sorted.Add(chunkString, chunk); - chunkString = ""; - chunk = new List(); - c = 0; - } - chunk.Add(element); - chunkString += element.ToString(); - } - if (chunk.Count > 0) - sorted.Add(chunkString, chunk); - - List ret = new List(); - foreach (List ls in sorted.Values) - { - ret.AddRange(ls); - } - - if (ascending == LSL.LSL_BaseClass.TRUE) - return ret; - ret.Reverse(); - return ret; - } - - public int llGetListLength(List src) - { - return src.Count; - } - - public int llList2Integer(List src, int index) - { - return Convert.ToInt32(src[index]); - } - - public double llList2double(List src, int index) - { - return Convert.ToDouble(src[index]); - } - - public float llList2Float(List src, int index) - { - return Convert.ToSingle(src[index]); - } - - public string llList2String(List src, int index) - { - return src[index]; - } - - public string llList2Key(List src, int index) - { - //return OpenSim.Framework.Types.ToStringHyphenated(src[index]); - return src[index].ToString(); - } - - public LSL_Types.Vector3 llList2Vector(List src, int index) - { - return new LSL_Types.Vector3(double.Parse(src[index]), double.Parse(src[index + 1]), double.Parse(src[index + 2])); - } - public LSL_Types.Quaternion llList2Rot(List src, int index) - { - return new LSL_Types.Quaternion(double.Parse(src[index]), double.Parse(src[index + 1]), double.Parse(src[index + 2]), double.Parse(src[index + 3])); - } - public List llList2List(List src, int start, int end) - { - if (end > start) - { - // Simple straight forward chunk - return src.GetRange(start, end - start); - } - else - { - // Some of the end + some of the beginning - // First chunk - List ret = new List(); - ret.AddRange(src.GetRange(start, src.Count - start)); - ret.AddRange(src.GetRange(0, end)); - return ret; - } - - - - - } - public List llDeleteSubList(List src, int start, int end) - { - List ret = new List(src); - ret.RemoveRange(start, end - start); - return ret; - } - public int llGetListEntryType(List src, int index) { NotImplemented("llGetListEntryType"); return 0; } - public string llList2CSV(List src) - { - string ret = ""; - foreach (string s in src) - { - if (s.Length > 0) - ret += ","; - ret += s; - } - return ret; - } - public List llCSV2List(string src) - { - List ret = new List(); - foreach (string s in src.Split(",".ToCharArray())) - { - ret.Add(s); - } - return ret; - } - public List llListRandomize(List src, int stride) - { - int s = stride; - if (s < 1) - s = 1; - - // This is a cowardly way of doing it ;) - // TODO: Instead, randomize and check if random is mod stride or if it can not be, then array.removerange - List> tmp = new List>(); - - // Add chunks to an array - int c = 0; - List chunk = new List(); - foreach (string element in src) - { - c++; - if (c > s) - { - tmp.Add(chunk); - chunk = new List(); - c = 0; - } - chunk.Add(element); - } - if (chunk.Count > 0) - tmp.Add(chunk); - - // Decreate (<- what kind of word is that? :D ) array back into a list - int rnd; - List ret = new List(); - while (tmp.Count > 0) - { - rnd = Util.RandomClass.Next(tmp.Count); - foreach (string str in tmp[rnd]) - { - ret.Add(str); - } - tmp.RemoveAt(rnd); - } - - return ret; - - - } - public List llList2ListStrided(List src, int start, int end, int stride) - { - List ret = new List(); - int s = stride; - if (s < 1) - s = 1; - - int sc = s; - for (int i = start; i < src.Count; i++) - { - sc--; - if (sc == 0) - { - sc = s; - // Addthis - ret.Add(src[i]); - } - if (i == end) - break; - } - return ret; - } - - public LSL_Types.Vector3 llGetRegionCorner() - { - return new LSL_Types.Vector3(World.RegionInfo.RegionLocX * 256, World.RegionInfo.RegionLocY * 256, 0); - } - - public List llListInsertList(List dest, List src, int start) - { - - List ret = new List(dest); - //foreach (string s in src.Reverse()) - for (int ci = src.Count - 1; ci > -1; ci--) - { - ret.Insert(start, src[ci]); - } - return ret; - } - public int llListFindList(List src, List test) - { - foreach (string s in test) - { - for (int ci = 0; ci < src.Count; ci++) - { - - if (s == src[ci]) - return ci; - } - } - return -1; - } - - public string llGetObjectName() - { - return m_host.Name; - } - - public void llSetObjectName(string name) - { - m_host.Name = name; - } - - public string llGetDate() - { - DateTime date = DateTime.Now.ToUniversalTime(); - string result = date.ToString("yyyy-MM-dd"); - return result; - } - - public int llEdgeOfWorld(LSL_Types.Vector3 pos, LSL_Types.Vector3 dir) { NotImplemented("llEdgeOfWorld"); return 0; } - public int llGetAgentInfo(string id) { NotImplemented("llGetAgentInfo"); return 0; } - public void llAdjustSoundVolume(double volume) { NotImplemented("llAdjustSoundVolume"); } - public void llSetSoundQueueing(int queue) { NotImplemented("llSetSoundQueueing"); } - public void llSetSoundRadius(double radius) { NotImplemented("llSetSoundRadius"); } - public string llKey2Name(string id) { NotImplemented("llKey2Name"); return ""; } - public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate) { NotImplemented("llSetTextureAnim"); } - public void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east, LSL_Types.Vector3 bottom_south_west) { NotImplemented("llTriggerSoundLimited"); } - public void llEjectFromLand(string pest) { NotImplemented("llEjectFromLand"); } - - public void llParseString2List() { NotImplemented("llParseString2List"); } - - public int llOverMyLand(string id) { NotImplemented("llOverMyLand"); return 0; } - public string llGetLandOwnerAt(LSL_Types.Vector3 pos) { NotImplemented("llGetLandOwnerAt"); return ""; } - public string llGetNotecardLine(string name, int line) { NotImplemented("llGetNotecardLine"); return ""; } - public LSL_Types.Vector3 llGetAgentSize(string id) { NotImplemented("llGetAgentSize"); return new LSL_Types.Vector3(); } - public int llSameGroup(string agent) { NotImplemented("llSameGroup"); return 0; } - public void llUnSit(string id) { NotImplemented("llUnSit"); } - public LSL_Types.Vector3 llGroundSlope(LSL_Types.Vector3 offset) { NotImplemented("llGroundSlope"); return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llGroundNormal(LSL_Types.Vector3 offset) { NotImplemented("llGroundNormal"); return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llGroundContour(LSL_Types.Vector3 offset) { NotImplemented("llGroundContour"); return new LSL_Types.Vector3(); } - public int llGetAttached() { NotImplemented("llGetAttached"); return 0; } - public int llGetFreeMemory() { NotImplemented("llGetFreeMemory"); return 0; } - - public string llGetRegionName() - { - return World.RegionInfo.RegionName; - } - - public double llGetRegionTimeDilation() { return 1.0f; } - public double llGetRegionFPS() { return 10.0f; } - public void llParticleSystem(List rules) { NotImplemented("llParticleSystem"); } - public void llGroundRepel(double height, int water, double tau) { NotImplemented("llGroundRepel"); } - public void llGiveInventoryList() { NotImplemented("llGiveInventoryList"); } - public void llSetVehicleType(int type) { NotImplemented("llSetVehicleType"); } - public void llSetVehicledoubleParam(int param, double value) { NotImplemented("llSetVehicledoubleParam"); } - public void llSetVehicleVectorParam(int param, LSL_Types.Vector3 vec) { NotImplemented("llSetVehicleVectorParam"); } - public void llSetVehicleRotationParam(int param, LSL_Types.Quaternion rot) { NotImplemented("llSetVehicleRotationParam"); } - public void llSetVehicleFlags(int flags) { NotImplemented("llSetVehicleFlags"); } - public void llRemoveVehicleFlags(int flags) { NotImplemented("llRemoveVehicleFlags"); } - public void llSitTarget(LSL_Types.Vector3 offset, LSL_Types.Quaternion rot) { NotImplemented("llSitTarget"); } - public string llAvatarOnSitTarget() { NotImplemented("llAvatarOnSitTarget"); return ""; } - public void llAddToLandPassList(string avatar, double hours) { NotImplemented("llAddToLandPassList"); } - - public void llSetTouchText(string text) - { - m_host.TouchName = text; - } - - public void llSetSitText(string text) - { - m_host.SitName = text; - } - - public void llSetCameraEyeOffset(LSL_Types.Vector3 offset) { NotImplemented("llSetCameraEyeOffset"); } - public void llSetCameraAtOffset(LSL_Types.Vector3 offset) { NotImplemented("llSetCameraAtOffset"); } - public void llDumpList2String() { NotImplemented("llDumpList2String"); } - public void llScriptDanger(LSL_Types.Vector3 pos) { NotImplemented("llScriptDanger"); } - public void llDialog(string avatar, string message, List buttons, int chat_channel) { NotImplemented("llDialog"); } - public void llVolumeDetect(int detect) { NotImplemented("llVolumeDetect"); } - public void llResetOtherScript(string name) { NotImplemented("llResetOtherScript"); } - - public int llGetScriptState(string name) { NotImplemented("llGetScriptState"); return 0; } - - public void llRemoteLoadScript() { NotImplemented("llRemoteLoadScript"); } - public void llSetRemoteScriptAccessPin(int pin) { NotImplemented("llSetRemoteScriptAccessPin"); } - public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) { NotImplemented("llRemoteLoadScriptPin"); } - public void llOpenRemoteDataChannel() { NotImplemented("llOpenRemoteDataChannel"); } - public string llSendRemoteData(string channel, string dest, int idata, string sdata) { NotImplemented("llSendRemoteData"); return ""; } - public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) { NotImplemented("llRemoteDataReply"); } - public void llCloseRemoteDataChannel(string channel) { NotImplemented("llCloseRemoteDataChannel"); } - - public string llMD5String(string src, int nonce) - { - return Util.Md5Hash(src + ":" + nonce.ToString()); - } - - public void llSetPrimitiveParams(List rules) { NotImplemented("llSetPrimitiveParams"); } - public string llStringToBase64(string str) - { - - try - { - byte[] encData_byte = new byte[str.Length]; - encData_byte = System.Text.Encoding.UTF8.GetBytes(str); - string encodedData = Convert.ToBase64String(encData_byte); - return encodedData; - } - catch (Exception e) - { - throw new Exception("Error in base64Encode" + e.Message); - } - } - - public string llBase64ToString(string str) - { - System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding(); - System.Text.Decoder utf8Decode = encoder.GetDecoder(); - try - { - - byte[] todecode_byte = Convert.FromBase64String(str); - int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); - char[] decoded_char = new char[charCount]; - utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0); - string result = new String(decoded_char); - return result; - } - catch (Exception e) - { - throw new Exception("Error in base64Decode" + e.Message); - } - } - public void llXorBase64Strings() { throw new Exception("Command deprecated! Use llXorBase64StringsCorrect instead."); } - public void llRemoteDataSetRegion() { NotImplemented("llRemoteDataSetRegion"); } - public double llLog10(double val) { return (double)Math.Log10(val); } - public double llLog(double val) { return (double)Math.Log(val); } - public List llGetAnimationList(string id) { NotImplemented("llGetAnimationList"); return new List(); } - public void llSetParcelMusicURL(string url) { NotImplemented("llSetParcelMusicURL"); } - - public LSL_Types.Vector3 llGetRootPosition() { NotImplemented("llGetRootPosition"); return new LSL_Types.Vector3(); } - - public LSL_Types.Quaternion llGetRootRotation() { NotImplemented("llGetRootRotation"); return new LSL_Types.Quaternion(); } - - public string llGetObjectDesc() - { - return m_host.Description; - } - - public void llSetObjectDesc(string desc) - { - m_host.Description = desc; - } - - public string llGetCreator() - { - return m_host.ObjectCreator.ToStringHyphenated(); - } - - public string llGetTimestamp() { return DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); } - public void llSetLinkAlpha(int linknumber, double alpha, int face) { NotImplemented("llSetLinkAlpha"); } - public int llGetNumberOfPrims() { NotImplemented("llGetNumberOfPrims"); return 0; } - public string llGetNumberOfNotecardLines(string name) { NotImplemented("llGetNumberOfNotecardLines"); return ""; } - public List llGetBoundingBox(string obj) { NotImplemented("llGetBoundingBox"); return new List(); } - public LSL_Types.Vector3 llGetGeometricCenter() { NotImplemented("llGetGeometricCenter"); return new LSL_Types.Vector3(); } - public void llGetPrimitiveParams() { NotImplemented("llGetPrimitiveParams"); } - public string llIntegerToBase64(int number) - { - NotImplemented("llIntegerToBase64"); return ""; - } - public int llBase64ToInteger(string str) - { - NotImplemented("llBase64ToInteger"); return 0; - } - - public double llGetGMTclock() - { - return DateTime.UtcNow.TimeOfDay.TotalSeconds; - } - - public string llGetSimulatorHostname() - { - return System.Environment.MachineName; - } - - public void llSetLocalRot(LSL_Types.Quaternion rot) { NotImplemented("llSetLocalRot"); } - public List llParseStringKeepNulls(string src, List seperators, List spacers) { NotImplemented("llParseStringKeepNulls"); return new List(); } - public void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity, LSL_Types.Quaternion rot, int param) { NotImplemented("llRezAtRoot"); } - - public int llGetObjectPermMask(int mask) { NotImplemented("llGetObjectPermMask"); return 0; } - - public void llSetObjectPermMask(int mask, int value) { NotImplemented("llSetObjectPermMask"); } - - public void llGetInventoryPermMask(string item, int mask) { NotImplemented("llGetInventoryPermMask"); } - public void llSetInventoryPermMask(string item, int mask, int value) { NotImplemented("llSetInventoryPermMask"); } - public string llGetInventoryCreator(string item) { NotImplemented("llGetInventoryCreator"); return ""; } - public void llOwnerSay(string msg) { NotImplemented("llOwnerSay"); } - public void llRequestSimulatorData(string simulator, int data) { NotImplemented("llRequestSimulatorData"); } - public void llForceMouselook(int mouselook) { NotImplemented("llForceMouselook"); } - public double llGetObjectMass(string id) { NotImplemented("llGetObjectMass"); return 0; } - public void llListReplaceList() { NotImplemented("llListReplaceList"); } - - public void llLoadURL(string avatar_id, string message, string url) - { - LLUUID avatarId = new LLUUID(avatar_id); - m_ScriptEngine.World.SendUrlToUser(avatarId, m_host.Name, m_host.UUID, m_host.ObjectOwner, false, message, url); - } - - public void llParcelMediaCommandList(List commandList) { NotImplemented("llParcelMediaCommandList"); } - public void llParcelMediaQuery() { NotImplemented("llParcelMediaQuery"); } - - public int llModPow(int a, int b, int c) - { - Int64 tmp = 0; - Int64 val = Math.DivRem(Convert.ToInt64(Math.Pow(a, b)), c, out tmp); - return Convert.ToInt32(tmp); - } - - public int llGetInventoryType(string name) { NotImplemented("llGetInventoryType"); return 0; } - - public void llSetPayPrice(int price, List quick_pay_buttons) { NotImplemented("llSetPayPrice"); } - public LSL_Types.Vector3 llGetCameraPos() { NotImplemented("llGetCameraPos"); return new LSL_Types.Vector3(); } - public LSL_Types.Quaternion llGetCameraRot() { NotImplemented("llGetCameraRot"); return new LSL_Types.Quaternion(); } - public void llSetPrimURL() { NotImplemented("llSetPrimURL"); } - public void llRefreshPrimURL() { NotImplemented("llRefreshPrimURL"); } - - public string llEscapeURL(string url) - { - try - { - return Uri.EscapeUriString(url); - } - catch (Exception ex) - { - return "llEscapeURL: " + ex.ToString(); - } - } - - public string llUnescapeURL(string url) - { - try - { - return Uri.UnescapeDataString(url); - } - catch (Exception ex) - { - return "llUnescapeURL: " + ex.ToString(); - } - } - public void llMapDestination(string simname, LSL_Types.Vector3 pos, LSL_Types.Vector3 look_at) { NotImplemented("llMapDestination"); } - public void llAddToLandBanList(string avatar, double hours) { NotImplemented("llAddToLandBanList"); } - public void llRemoveFromLandPassList(string avatar) { NotImplemented("llRemoveFromLandPassList"); } - public void llRemoveFromLandBanList(string avatar) { NotImplemented("llRemoveFromLandBanList"); } - public void llSetCameraParams(List rules) { NotImplemented("llSetCameraParams"); } - public void llClearCameraParams() { NotImplemented("llClearCameraParams"); } - public double llListStatistics(int operation, List src) { NotImplemented("llListStatistics"); return 0; } - - public int llGetUnixTime() - { - return Util.UnixTimeSinceEpoch(); - } - - public int llGetParcelFlags(LSL_Types.Vector3 pos) { NotImplemented("llGetParcelFlags"); return 0; } - public int llGetRegionFlags() { NotImplemented("llGetRegionFlags"); return 0; } - public string llXorBase64StringsCorrect(string str1, string str2) - { - string ret = ""; - string src1 = llBase64ToString(str1); - string src2 = llBase64ToString(str2); - int c = 0; - for (int i = 0; i < src1.Length; i++) - { - ret += src1[i] ^ src2[c]; - - c++; - if (c > src2.Length) - c = 0; - } - return llStringToBase64(ret); - } - public void llHTTPRequest(string url, List parameters, string body) - { - m_ScriptEngine.m_LSLLongCmdHandler.StartHttpRequest(m_localID, m_itemID, url, parameters, body); - } - public void llResetLandBanList() { NotImplemented("llResetLandBanList"); } - public void llResetLandPassList() { NotImplemented("llResetLandPassList"); } - public int llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide) { NotImplemented("llGetParcelPrimCount"); return 0; } - public List llGetParcelPrimOwners(LSL_Types.Vector3 pos) { NotImplemented("llGetParcelPrimOwners"); return new List(); } - public int llGetObjectPrimCount(string object_id) { NotImplemented("llGetObjectPrimCount"); return 0; } - public int llGetParcelMaxPrims(LSL_Types.Vector3 pos, int sim_wide) { NotImplemented("llGetParcelMaxPrims"); return 0; } - public List llGetParcelDetails(LSL_Types.Vector3 pos, List param) { NotImplemented("llGetParcelDetails"); return new List(); } - - // - // OpenSim functions - // - public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer) - { - if (dynamicID == "") - { - IDynamicTextureManager textureManager = this.World.RequestModuleInterface(); - LLUUID createdTexture = textureManager.AddDynamicTextureURL(World.RegionInfo.SimUUID, this.m_host.UUID, contentType, url, extraParams, timer); - return createdTexture.ToStringHyphenated(); - } - else - { - //TODO update existing dynamic textures - } - - return LLUUID.Zero.ToStringHyphenated(); - } - - private void NotImplemented(string Command) - { - if (throwErrorOnNotImplemented) - throw new NotImplementedException("Command not implemented: " + Command); - } - - } -} +using Axiom.Math; +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Scenes.Scripting; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler; +using OpenSim.Region.ScriptEngine.Common; +using OpenSim.Framework.Console; +using OpenSim.Framework.Utilities; +using System.Runtime.Remoting.Lifetime; + +namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler +{ + // + // !!!IMPORTANT!!! + // + // REMEMBER TO UPDATE http://opensimulator.org/wiki/LlFunction_implementation_status + // + + /// + /// Contains all LSL ll-functions. This class will be in Default AppDomain. + /// + public class LSL_BuiltIn_Commands : MarshalByRefObject, LSL_BuiltIn_Commands_Interface + { + + private System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); + private ScriptEngine m_ScriptEngine; + private SceneObjectPart m_host; + private uint m_localID; + private LLUUID m_itemID; + private bool throwErrorOnNotImplemented = true; + + + public LSL_BuiltIn_Commands(ScriptEngine ScriptEngine, SceneObjectPart host, uint localID, LLUUID itemID) + { + m_ScriptEngine = ScriptEngine; + m_host = host; + m_localID = localID; + m_itemID = itemID; + + + //MainLog.Instance.Notice("ScriptEngine", "LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]"); + } + + + private string m_state = "default"; + + public string State() + { + return m_state; + } + + // Object never expires + public override Object InitializeLifetimeService() + { + //Console.WriteLine("LSL_BuiltIn_Commands: InitializeLifetimeService()"); + // return null; + ILease lease = (ILease)base.InitializeLifetimeService(); + + if (lease.CurrentState == LeaseState.Initial) + { + lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1); + // lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); + // lease.RenewOnCallTime = TimeSpan.FromSeconds(2); + } + return lease; + } + + + public Scene World + { + get { return m_ScriptEngine.World; } + } + + //These are the implementations of the various ll-functions used by the LSL scripts. + //starting out, we use the System.Math library for trig functions. - ckrinke 8-14-07 + public double llSin(double f) { return (double)Math.Sin(f); } + public double llCos(double f) { return (double)Math.Cos(f); } + public double llTan(double f) { return (double)Math.Tan(f); } + public double llAtan2(double x, double y) { return (double)Math.Atan2(y, x); } + public double llSqrt(double f) { return (double)Math.Sqrt(f); } + public double llPow(double fbase, double fexponent) { return (double)Math.Pow(fbase, fexponent); } + public int llAbs(int i) { return (int)Math.Abs(i); } + public double llFabs(double f) { return (double)Math.Abs(f); } + + public double llFrand(double mag) + { + lock (Util.RandomClass) + { + return Util.RandomClass.Next((int)mag); + } + } + + public int llFloor(double f) { return (int)Math.Floor(f); } + public int llCeil(double f) { return (int)Math.Ceiling(f); } + public int llRound(double f) { return (int)Math.Round(f, 3); } + + //This next group are vector operations involving squaring and square root. ckrinke + public double llVecMag(LSL_Types.Vector3 v) + { + return (v.X * v.X + v.Y * v.Y + v.Z * v.Z); + } + + public LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v) + { + double mag = v.X * v.X + v.Y * v.Y + v.Z * v.Z; + LSL_Types.Vector3 nor = new LSL_Types.Vector3(); + nor.X = v.X / mag; nor.Y = v.Y / mag; nor.Z = v.Z / mag; + return nor; + } + + public double llVecDist(LSL_Types.Vector3 a, LSL_Types.Vector3 b) + { + double dx = a.X - b.X; double dy = a.Y - b.Y; double dz = a.Z - b.Z; + return Math.Sqrt(dx * dx + dy * dy + dz * dz); + } + + //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke + public LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r) + { + //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke + LSL_Types.Quaternion t = new LSL_Types.Quaternion(r.X * r.X, r.Y * r.Y, r.Z * r.Z, r.R * r.R); + double m = (t.X + t.Y + t.Z + t.R); + if (m == 0) return new LSL_Types.Vector3(); + double n = 2 * (r.Y * r.R + r.X * r.Z); + double p = m * m - n * n; + if (p > 0) + return new LSL_Types.Vector3(Math.Atan2(2.0 * (r.X * r.R - r.Y * r.Z), (-t.X - t.Y + t.Z + t.R)), + Math.Atan2(n, Math.Sqrt(p)), Math.Atan2(2.0 * (r.Z * r.R - r.X * r.Y), (t.X - t.Y - t.Z + t.R))); + else if (n > 0) + return new LSL_Types.Vector3(0.0, Math.PI / 2, Math.Atan2((r.Z * r.R + r.X * r.Y), 0.5 - t.X - t.Z)); + else + return new LSL_Types.Vector3(0.0, -Math.PI / 2, Math.Atan2((r.Z * r.R + r.X * r.Y), 0.5 - t.X - t.Z)); + } + + public LSL_Types.Quaternion llEuler2Rot(LSL_Types.Vector3 v) + { + //this comes from from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions but is incomplete as of 8/19/07 + float err = 0.00001f; + double ax = Math.Sin(v.X / 2); double aw = Math.Cos(v.X / 2); + double by = Math.Sin(v.Y / 2); double bw = Math.Cos(v.Y / 2); + double cz = Math.Sin(v.Z / 2); double cw = Math.Cos(v.Z / 2); + LSL_Types.Quaternion a1 = new LSL_Types.Quaternion(0.0, 0.0, cz, cw); + LSL_Types.Quaternion a2 = new LSL_Types.Quaternion(0.0, by, 0.0, bw); + LSL_Types.Quaternion a3 = new LSL_Types.Quaternion(ax, 0.0, 0.0, aw); + LSL_Types.Quaternion a = new LSL_Types.Quaternion(); + //This multiplication doesnt compile, yet. a = a1 * a2 * a3; + LSL_Types.Quaternion b = new LSL_Types.Quaternion(ax * bw * cw + aw * by * cz, + aw * by * cw - ax * bw * cz, aw * bw * cz + ax * by * cw, aw * bw * cw - ax * by * cz); + LSL_Types.Quaternion c = new LSL_Types.Quaternion(); + //This addition doesnt compile yet c = a + b; + LSL_Types.Quaternion d = new LSL_Types.Quaternion(); + //This addition doesnt compile yet d = a - b; + if ((Math.Abs(c.X) > err && Math.Abs(d.X) > err) || + (Math.Abs(c.Y) > err && Math.Abs(d.Y) > err) || + (Math.Abs(c.Z) > err && Math.Abs(d.Z) > err) || + (Math.Abs(c.R) > err && Math.Abs(d.R) > err)) + { + //return a new Quaternion that is null until I figure this out + // return b; + // return a; + } + return new LSL_Types.Quaternion(); + } + + public LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up) { return new LSL_Types.Quaternion(); } + public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) { return new LSL_Types.Vector3(); } + public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) { return new LSL_Types.Vector3(); } + public LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r) { return new LSL_Types.Vector3(); } + public LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 start, LSL_Types.Vector3 end) { return new LSL_Types.Quaternion(); } + + public void llWhisper(int channelID, string text) + { + //type for whisper is 0 + World.SimChat(Helpers.StringToField(text), + 0, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + } + + public void llSay(int channelID, string text) + { + //type for say is 1 + + World.SimChat(Helpers.StringToField(text), + 1, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + } + + public void llShout(int channelID, string text) + { + //type for shout is 2 + World.SimChat(Helpers.StringToField(text), + 2, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + } + + public int llListen(int channelID, string name, string ID, string msg) { NotImplemented("llListen"); return 0; } + public void llListenControl(int number, int active) { NotImplemented("llListenControl"); return; } + public void llListenRemove(int number) { NotImplemented("llListenRemove"); return; } + public void llSensor(string name, string id, int type, double range, double arc) { NotImplemented("llSensor"); return; } + public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) { NotImplemented("llSensorRepeat"); return; } + public void llSensorRemove() { NotImplemented("llSensorRemove"); return; } + public string llDetectedName(int number) { NotImplemented("llDetectedName"); return ""; } + public string llDetectedKey(int number) { NotImplemented("llDetectedKey"); return ""; } + public string llDetectedOwner(int number) { NotImplemented("llDetectedOwner"); return ""; } + public int llDetectedType(int number) { NotImplemented("llDetectedType"); return 0; } + public LSL_Types.Vector3 llDetectedPos(int number) { NotImplemented("llDetectedPos"); return new LSL_Types.Vector3(); } + public LSL_Types.Vector3 llDetectedVel(int number) { NotImplemented("llDetectedVel"); return new LSL_Types.Vector3(); } + public LSL_Types.Vector3 llDetectedGrab(int number) { NotImplemented("llDetectedGrab"); return new LSL_Types.Vector3(); } + public LSL_Types.Quaternion llDetectedRot(int number) { NotImplemented("llDetectedRot"); return new LSL_Types.Quaternion(); } + public int llDetectedGroup(int number) { NotImplemented("llDetectedGroup"); return 0; } + public int llDetectedLinkNumber(int number) { NotImplemented("llDetectedLinkNumber"); return 0; } + public void llDie() { NotImplemented("llDie"); return; } + public double llGround(LSL_Types.Vector3 offset) { NotImplemented("llGround"); return 0; } + public double llCloud(LSL_Types.Vector3 offset) { NotImplemented("llCloud"); return 0; } + public LSL_Types.Vector3 llWind(LSL_Types.Vector3 offset) { NotImplemented("llWind"); return new LSL_Types.Vector3(); } + public void llSetStatus(int status, int value) { NotImplemented("llSetStatus"); return; } + public int llGetStatus(int status) { NotImplemented("llGetStatus"); return 0; } + + public void llSetScale(LSL_Types.Vector3 scale) + { + // TODO: this needs to trigger a persistance save as well + LLVector3 tmp = m_host.Scale; + tmp.X = (float)scale.X; + tmp.Y = (float)scale.Y; + tmp.Z = (float)scale.Z; + m_host.Scale = tmp; + return; + } + public LSL_Types.Vector3 llGetScale() + { + return new LSL_Types.Vector3(m_host.Scale.X, m_host.Scale.Y, m_host.Scale.Z); + } + + public void llSetColor(LSL_Types.Vector3 color, int face) { NotImplemented("llSetColor"); return; } + public double llGetAlpha(int face) { NotImplemented("llGetAlpha"); return 0; } + public void llSetAlpha(double alpha, int face) { NotImplemented("llSetAlpha"); return; } + public LSL_Types.Vector3 llGetColor(int face) { NotImplemented("llGetColor"); return new LSL_Types.Vector3(); } + public void llSetTexture(string texture, int face) { NotImplemented("llSetTexture"); return; } + public void llScaleTexture(double u, double v, int face) { NotImplemented("llScaleTexture"); return; } + public void llOffsetTexture(double u, double v, int face) { NotImplemented("llOffsetTexture"); return; } + public void llRotateTexture(double rotation, int face) { NotImplemented("llRotateTexture"); return; } + + public string llGetTexture(int face) { NotImplemented("llGetTexture"); return ""; } + + public void llSetPos(LSL_Types.Vector3 pos) + { + if (m_host.ParentID != 0) + { + m_host.UpdateOffSet(new LLVector3((float)pos.X, (float)pos.Y, (float)pos.Z)); + } + else + { + m_host.UpdateGroupPosition(new LLVector3((float)pos.X, (float)pos.Y, (float)pos.Z)); + } + } + + public LSL_Types.Vector3 llGetPos() + { + return new LSL_Types.Vector3(m_host.AbsolutePosition.X, + m_host.AbsolutePosition.Y, + m_host.AbsolutePosition.Z); + } + + public LSL_Types.Vector3 llGetLocalPos() + { + if (m_host.ParentID != 0) + { + return new LSL_Types.Vector3(m_host.OffsetPosition.X, + m_host.OffsetPosition.Y, + m_host.OffsetPosition.Z); + } + else + { + return new LSL_Types.Vector3(m_host.AbsolutePosition.X, + m_host.AbsolutePosition.Y, + m_host.AbsolutePosition.Z); + } + } + public void llSetRot(LSL_Types.Quaternion rot) + { + m_host.UpdateRotation(new LLQuaternion((float)rot.X, (float)rot.Y, (float)rot.Z, (float)rot.R)); + } + public LSL_Types.Quaternion llGetRot() + { + LLQuaternion q = m_host.RotationOffset; + return new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); + } + public LSL_Types.Quaternion llGetLocalRot() { NotImplemented("llGetLocalRot"); return new LSL_Types.Quaternion(); } + public void llSetForce(LSL_Types.Vector3 force, int local) { NotImplemented("llSetForce"); } + public LSL_Types.Vector3 llGetForce() { NotImplemented("llGetForce"); return new LSL_Types.Vector3(); } + public int llTarget(LSL_Types.Vector3 position, double range) { NotImplemented("llTarget"); return 0; } + public void llTargetRemove(int number) { NotImplemented("llTargetRemove"); } + public int llRotTarget(LSL_Types.Quaternion rot, double error) { NotImplemented("llRotTarget"); return 0; } + public void llRotTargetRemove(int number) { NotImplemented("llRotTargetRemove"); } + public void llMoveToTarget(LSL_Types.Vector3 target, double tau) { NotImplemented("llMoveToTarget"); } + public void llStopMoveToTarget() { NotImplemented("llStopMoveToTarget"); } + public void llApplyImpulse(LSL_Types.Vector3 force, int local) { NotImplemented("llApplyImpulse"); } + public void llApplyRotationalImpulse(LSL_Types.Vector3 force, int local) { NotImplemented("llApplyRotationalImpulse"); } + public void llSetTorque(LSL_Types.Vector3 torque, int local) { NotImplemented("llSetTorque"); } + public LSL_Types.Vector3 llGetTorque() { NotImplemented("llGetTorque"); return new LSL_Types.Vector3(); } + public void llSetForceAndTorque(LSL_Types.Vector3 force, LSL_Types.Vector3 torque, int local) { NotImplemented("llSetForceAndTorque"); } + public LSL_Types.Vector3 llGetVel() { NotImplemented("llGetVel"); return new LSL_Types.Vector3(); } + public LSL_Types.Vector3 llGetAccel() { NotImplemented("llGetAccel"); return new LSL_Types.Vector3(); } + public LSL_Types.Vector3 llGetOmega() { NotImplemented("llGetOmega"); return new LSL_Types.Vector3(); } + public double llGetTimeOfDay() { NotImplemented("llGetTimeOfDay"); return 0; } + + public double llGetWallclock() + { + return DateTime.Now.TimeOfDay.TotalSeconds; + } + + public double llGetTime() { NotImplemented("llGetTime"); return 0; } + public void llResetTime() { NotImplemented("llResetTime"); } + public double llGetAndResetTime() { NotImplemented("llGetAndResetTime"); return 0; } + public void llSound() { NotImplemented("llSound"); } + public void llPlaySound(string sound, double volume) { NotImplemented("llPlaySound"); } + public void llLoopSound(string sound, double volume) { NotImplemented("llLoopSound"); } + public void llLoopSoundMaster(string sound, double volume) { NotImplemented("llLoopSoundMaster"); } + public void llLoopSoundSlave(string sound, double volume) { NotImplemented("llLoopSoundSlave"); } + public void llPlaySoundSlave(string sound, double volume) { NotImplemented("llPlaySoundSlave"); } + public void llTriggerSound(string sound, double volume) { NotImplemented("llTriggerSound"); } + public void llStopSound() { NotImplemented("llStopSound"); } + public void llPreloadSound(string sound) { NotImplemented("llPreloadSound"); } + + public string llGetSubString(string src, int start, int end) + { + return src.Substring(start, end); + } + + public string llDeleteSubString(string src, int start, int end) + { + return src.Remove(start, end - start); + } + public string llInsertString(string dst, int position, string src) + { + return dst.Insert(position, src); + } + public string llToUpper(string src) + { + return src.ToUpper(); + } + + public string llToLower(string src) + { + return src.ToLower(); + } + + public int llGiveMoney(string destination, int amount) { NotImplemented("llGiveMoney"); return 0; } + public void llMakeExplosion() { NotImplemented("llMakeExplosion"); } + public void llMakeFountain() { NotImplemented("llMakeFountain"); } + public void llMakeSmoke() { NotImplemented("llMakeSmoke"); } + public void llMakeFire() { NotImplemented("llMakeFire"); } + public void llRezObject(string inventory, LSL_Types.Vector3 pos, LSL_Types.Quaternion rot, int param) { NotImplemented("llRezObject"); } + public void llLookAt(LSL_Types.Vector3 target, double strength, double damping) { NotImplemented("llLookAt"); } + public void llStopLookAt() { NotImplemented("llStopLookAt"); } + + public void llSetTimerEvent(double sec) + { + // Setting timer repeat + m_ScriptEngine.m_LSLLongCmdHandler.SetTimerEvent(m_localID, m_itemID, sec); + } + + public void llSleep(double sec) + { + System.Threading.Thread.Sleep((int)(sec * 1000)); + } + + public double llGetMass() { NotImplemented("llGetMass"); return 0; } + public void llCollisionFilter(string name, string id, int accept) { NotImplemented("llCollisionFilter"); } + public void llTakeControls(int controls, int accept, int pass_on) { NotImplemented("llTakeControls"); } + public void llReleaseControls() { NotImplemented("llReleaseControls"); } + public void llAttachToAvatar(int attachment) { NotImplemented("llAttachToAvatar"); } + public void llDetachFromAvatar() { NotImplemented("llDetachFromAvatar"); } + public void llTakeCamera() { NotImplemented("llTakeCamera"); } + public void llReleaseCamera() { NotImplemented("llReleaseCamera"); } + + public string llGetOwner() + { + return m_host.ObjectOwner.ToStringHyphenated(); + } + + public void llInstantMessage(string user, string message) { NotImplemented("llInstantMessage"); } + public void llEmail(string address, string subject, string message) { NotImplemented("llEmail"); } + public void llGetNextEmail(string address, string subject) { NotImplemented("llGetNextEmail"); } + + public string llGetKey() + { + return m_host.UUID.ToStringHyphenated(); + } + + public void llSetBuoyancy(double buoyancy) { NotImplemented("llSetBuoyancy"); } + public void llSetHoverHeight(double height, int water, double tau) { NotImplemented("llSetHoverHeight"); } + public void llStopHover() { NotImplemented("llStopHover"); } + public void llMinEventDelay(double delay) { NotImplemented("llMinEventDelay"); } + public void llSoundPreload() { NotImplemented("llSoundPreload"); } + public void llRotLookAt(LSL_Types.Quaternion target, double strength, double damping) { NotImplemented("llRotLookAt"); } + + public int llStringLength(string str) + { + if (str.Length > 0) + { + return str.Length; + } + else + { + return 0; + } + } + + public void llStartAnimation(string anim) { NotImplemented("llStartAnimation"); } + public void llStopAnimation(string anim) { NotImplemented("llStopAnimation"); } + public void llPointAt() { NotImplemented("llPointAt"); } + public void llStopPointAt() { NotImplemented("llStopPointAt"); } + public void llTargetOmega(LSL_Types.Vector3 axis, double spinrate, double gain) { NotImplemented("llTargetOmega"); } + public int llGetStartParameter() { NotImplemented("llGetStartParameter"); return 0; } + public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos) { NotImplemented("llGodLikeRezObject"); } + public void llRequestPermissions(string agent, int perm) { NotImplemented("llRequestPermissions"); } + public string llGetPermissionsKey() { NotImplemented("llGetPermissionsKey"); return ""; } + public int llGetPermissions() { NotImplemented("llGetPermissions"); return 0; } + public int llGetLinkNumber() { NotImplemented("llGetLinkNumber"); return 0; } + public void llSetLinkColor(int linknumber, LSL_Types.Vector3 color, int face) { NotImplemented("llSetLinkColor"); } + public void llCreateLink(string target, int parent) { NotImplemented("llCreateLink"); } + public void llBreakLink(int linknum) { NotImplemented("llBreakLink"); } + public void llBreakAllLinks() { NotImplemented("llBreakAllLinks"); } + public string llGetLinkKey(int linknum) { NotImplemented("llGetLinkKey"); return ""; } + public void llGetLinkName(int linknum) { NotImplemented("llGetLinkName"); } + public int llGetInventoryNumber(int type) { NotImplemented("llGetInventoryNumber"); return 0; } + public string llGetInventoryName(int type, int number) { NotImplemented("llGetInventoryName"); return ""; } + public void llSetScriptState(string name, int run) { NotImplemented("llSetScriptState"); } + public double llGetEnergy() { return 1.0f; } + public void llGiveInventory(string destination, string inventory) { NotImplemented("llGiveInventory"); } + public void llRemoveInventory(string item) { NotImplemented("llRemoveInventory"); } + + public void llSetText(string text, LSL_Types.Vector3 color, double alpha) + { + Axiom.Math.Vector3 av3 = new Axiom.Math.Vector3((float)color.X, (float)color.Y, (float)color.Z); + m_host.SetText(text, av3, alpha); + } + + + public double llWater(LSL_Types.Vector3 offset) { NotImplemented("llWater"); return 0; } + public void llPassTouches(int pass) { NotImplemented("llPassTouches"); } + public string llRequestAgentData(string id, int data) { NotImplemented("llRequestAgentData"); return ""; } + public string llRequestInventoryData(string name) { NotImplemented("llRequestInventoryData"); return ""; } + public void llSetDamage(double damage) { NotImplemented("llSetDamage"); } + public void llTeleportAgentHome(string agent) { NotImplemented("llTeleportAgentHome"); } + public void llModifyLand(int action, int brush) { } + public void llCollisionSound(string impact_sound, double impact_volume) { NotImplemented("llCollisionSound"); } + public void llCollisionSprite(string impact_sprite) { NotImplemented("llCollisionSprite"); } + public string llGetAnimation(string id) { NotImplemented("llGetAnimation"); return ""; } + public void llResetScript() + { + m_ScriptEngine.m_ScriptManager.ResetScript(m_localID, m_itemID); + } + public void llMessageLinked(int linknum, int num, string str, string id) { } + public void llPushObject(string target, LSL_Types.Vector3 impulse, LSL_Types.Vector3 ang_impulse, int local) { } + public void llPassCollisions(int pass) { } + public string llGetScriptName() { return ""; } + + public int llGetNumberOfSides() { return 0; } + + public LSL_Types.Quaternion llAxisAngle2Rot(LSL_Types.Vector3 axis, double angle) { return new LSL_Types.Quaternion(); } + public LSL_Types.Vector3 llRot2Axis(LSL_Types.Quaternion rot) { return new LSL_Types.Vector3(); } + public void llRot2Angle() { } + + public double llAcos(double val) + { + return (double)Math.Acos(val); + } + + public double llAsin(double val) + { + return (double)Math.Asin(val); + } + + public double llAngleBetween(LSL_Types.Quaternion a, LSL_Types.Quaternion b) { return 0; } + public string llGetInventoryKey(string name) { return ""; } + public void llAllowInventoryDrop(int add) { } + public LSL_Types.Vector3 llGetSunDirection() { return new LSL_Types.Vector3(); } + public LSL_Types.Vector3 llGetTextureOffset(int face) { return new LSL_Types.Vector3(); } + public LSL_Types.Vector3 llGetTextureScale(int side) { return new LSL_Types.Vector3(); } + public double llGetTextureRot(int side) { return 0; } + + public int llSubStringIndex(string source, string pattern) + { + return source.IndexOf(pattern); + } + + public string llGetOwnerKey(string id) { NotImplemented("llGetOwnerKey"); return ""; } + + public LSL_Types.Vector3 llGetCenterOfMass() { NotImplemented("llGetCenterOfMass"); return new LSL_Types.Vector3(); } + + public List llListSort(List src, int stride, int ascending) + { + SortedList> sorted = new SortedList>(); + // Add chunks to an array + int s = stride; + if (s < 1) + s = 1; + int c = 0; + List chunk = new List(); + string chunkString = ""; + foreach (string element in src) + { + c++; + if (c > s) + { + sorted.Add(chunkString, chunk); + chunkString = ""; + chunk = new List(); + c = 0; + } + chunk.Add(element); + chunkString += element.ToString(); + } + if (chunk.Count > 0) + sorted.Add(chunkString, chunk); + + List ret = new List(); + foreach (List ls in sorted.Values) + { + ret.AddRange(ls); + } + + if (ascending == LSL.LSL_BaseClass.TRUE) + return ret; + ret.Reverse(); + return ret; + } + + public int llGetListLength(List src) + { + return src.Count; + } + + public int llList2Integer(List src, int index) + { + return Convert.ToInt32(src[index]); + } + + public double llList2double(List src, int index) + { + return Convert.ToDouble(src[index]); + } + + public float llList2Float(List src, int index) + { + return Convert.ToSingle(src[index]); + } + + public string llList2String(List src, int index) + { + return src[index]; + } + + public string llList2Key(List src, int index) + { + //return OpenSim.Framework.Types.ToStringHyphenated(src[index]); + return src[index].ToString(); + } + + public LSL_Types.Vector3 llList2Vector(List src, int index) + { + return new LSL_Types.Vector3(double.Parse(src[index]), double.Parse(src[index + 1]), double.Parse(src[index + 2])); + } + public LSL_Types.Quaternion llList2Rot(List src, int index) + { + return new LSL_Types.Quaternion(double.Parse(src[index]), double.Parse(src[index + 1]), double.Parse(src[index + 2]), double.Parse(src[index + 3])); + } + public List llList2List(List src, int start, int end) + { + if (end > start) + { + // Simple straight forward chunk + return src.GetRange(start, end - start); + } + else + { + // Some of the end + some of the beginning + // First chunk + List ret = new List(); + ret.AddRange(src.GetRange(start, src.Count - start)); + ret.AddRange(src.GetRange(0, end)); + return ret; + } + + + + + } + public List llDeleteSubList(List src, int start, int end) + { + List ret = new List(src); + ret.RemoveRange(start, end - start); + return ret; + } + public int llGetListEntryType(List src, int index) { NotImplemented("llGetListEntryType"); return 0; } + public string llList2CSV(List src) + { + string ret = ""; + foreach (string s in src) + { + if (s.Length > 0) + ret += ","; + ret += s; + } + return ret; + } + public List llCSV2List(string src) + { + List ret = new List(); + foreach (string s in src.Split(",".ToCharArray())) + { + ret.Add(s); + } + return ret; + } + public List llListRandomize(List src, int stride) + { + int s = stride; + if (s < 1) + s = 1; + + // This is a cowardly way of doing it ;) + // TODO: Instead, randomize and check if random is mod stride or if it can not be, then array.removerange + List> tmp = new List>(); + + // Add chunks to an array + int c = 0; + List chunk = new List(); + foreach (string element in src) + { + c++; + if (c > s) + { + tmp.Add(chunk); + chunk = new List(); + c = 0; + } + chunk.Add(element); + } + if (chunk.Count > 0) + tmp.Add(chunk); + + // Decreate (<- what kind of word is that? :D ) array back into a list + int rnd; + List ret = new List(); + while (tmp.Count > 0) + { + rnd = Util.RandomClass.Next(tmp.Count); + foreach (string str in tmp[rnd]) + { + ret.Add(str); + } + tmp.RemoveAt(rnd); + } + + return ret; + + + } + public List llList2ListStrided(List src, int start, int end, int stride) + { + List ret = new List(); + int s = stride; + if (s < 1) + s = 1; + + int sc = s; + for (int i = start; i < src.Count; i++) + { + sc--; + if (sc == 0) + { + sc = s; + // Addthis + ret.Add(src[i]); + } + if (i == end) + break; + } + return ret; + } + + public LSL_Types.Vector3 llGetRegionCorner() + { + return new LSL_Types.Vector3(World.RegionInfo.RegionLocX * 256, World.RegionInfo.RegionLocY * 256, 0); + } + + public List llListInsertList(List dest, List src, int start) + { + + List ret = new List(dest); + //foreach (string s in src.Reverse()) + for (int ci = src.Count - 1; ci > -1; ci--) + { + ret.Insert(start, src[ci]); + } + return ret; + } + public int llListFindList(List src, List test) + { + foreach (string s in test) + { + for (int ci = 0; ci < src.Count; ci++) + { + + if (s == src[ci]) + return ci; + } + } + return -1; + } + + public string llGetObjectName() + { + return m_host.Name; + } + + public void llSetObjectName(string name) + { + m_host.Name = name; + } + + public string llGetDate() + { + DateTime date = DateTime.Now.ToUniversalTime(); + string result = date.ToString("yyyy-MM-dd"); + return result; + } + + public int llEdgeOfWorld(LSL_Types.Vector3 pos, LSL_Types.Vector3 dir) { NotImplemented("llEdgeOfWorld"); return 0; } + public int llGetAgentInfo(string id) { NotImplemented("llGetAgentInfo"); return 0; } + public void llAdjustSoundVolume(double volume) { NotImplemented("llAdjustSoundVolume"); } + public void llSetSoundQueueing(int queue) { NotImplemented("llSetSoundQueueing"); } + public void llSetSoundRadius(double radius) { NotImplemented("llSetSoundRadius"); } + public string llKey2Name(string id) { NotImplemented("llKey2Name"); return ""; } + public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate) { NotImplemented("llSetTextureAnim"); } + public void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east, LSL_Types.Vector3 bottom_south_west) { NotImplemented("llTriggerSoundLimited"); } + public void llEjectFromLand(string pest) { NotImplemented("llEjectFromLand"); } + + public void llParseString2List() { NotImplemented("llParseString2List"); } + + public int llOverMyLand(string id) { NotImplemented("llOverMyLand"); return 0; } + public string llGetLandOwnerAt(LSL_Types.Vector3 pos) { NotImplemented("llGetLandOwnerAt"); return ""; } + public string llGetNotecardLine(string name, int line) { NotImplemented("llGetNotecardLine"); return ""; } + public LSL_Types.Vector3 llGetAgentSize(string id) { NotImplemented("llGetAgentSize"); return new LSL_Types.Vector3(); } + public int llSameGroup(string agent) { NotImplemented("llSameGroup"); return 0; } + public void llUnSit(string id) { NotImplemented("llUnSit"); } + public LSL_Types.Vector3 llGroundSlope(LSL_Types.Vector3 offset) { NotImplemented("llGroundSlope"); return new LSL_Types.Vector3(); } + public LSL_Types.Vector3 llGroundNormal(LSL_Types.Vector3 offset) { NotImplemented("llGroundNormal"); return new LSL_Types.Vector3(); } + public LSL_Types.Vector3 llGroundContour(LSL_Types.Vector3 offset) { NotImplemented("llGroundContour"); return new LSL_Types.Vector3(); } + public int llGetAttached() { NotImplemented("llGetAttached"); return 0; } + public int llGetFreeMemory() { NotImplemented("llGetFreeMemory"); return 0; } + + public string llGetRegionName() + { + return World.RegionInfo.RegionName; + } + + public double llGetRegionTimeDilation() { return 1.0f; } + public double llGetRegionFPS() { return 10.0f; } + public void llParticleSystem(List rules) { NotImplemented("llParticleSystem"); } + public void llGroundRepel(double height, int water, double tau) { NotImplemented("llGroundRepel"); } + public void llGiveInventoryList() { NotImplemented("llGiveInventoryList"); } + public void llSetVehicleType(int type) { NotImplemented("llSetVehicleType"); } + public void llSetVehicledoubleParam(int param, double value) { NotImplemented("llSetVehicledoubleParam"); } + public void llSetVehicleVectorParam(int param, LSL_Types.Vector3 vec) { NotImplemented("llSetVehicleVectorParam"); } + public void llSetVehicleRotationParam(int param, LSL_Types.Quaternion rot) { NotImplemented("llSetVehicleRotationParam"); } + public void llSetVehicleFlags(int flags) { NotImplemented("llSetVehicleFlags"); } + public void llRemoveVehicleFlags(int flags) { NotImplemented("llRemoveVehicleFlags"); } + public void llSitTarget(LSL_Types.Vector3 offset, LSL_Types.Quaternion rot) { NotImplemented("llSitTarget"); } + public string llAvatarOnSitTarget() { NotImplemented("llAvatarOnSitTarget"); return ""; } + public void llAddToLandPassList(string avatar, double hours) { NotImplemented("llAddToLandPassList"); } + + public void llSetTouchText(string text) + { + m_host.TouchName = text; + } + + public void llSetSitText(string text) + { + m_host.SitName = text; + } + + public void llSetCameraEyeOffset(LSL_Types.Vector3 offset) { NotImplemented("llSetCameraEyeOffset"); } + public void llSetCameraAtOffset(LSL_Types.Vector3 offset) { NotImplemented("llSetCameraAtOffset"); } + public void llDumpList2String() { NotImplemented("llDumpList2String"); } + public void llScriptDanger(LSL_Types.Vector3 pos) { NotImplemented("llScriptDanger"); } + public void llDialog(string avatar, string message, List buttons, int chat_channel) { NotImplemented("llDialog"); } + public void llVolumeDetect(int detect) { NotImplemented("llVolumeDetect"); } + public void llResetOtherScript(string name) { NotImplemented("llResetOtherScript"); } + + public int llGetScriptState(string name) { NotImplemented("llGetScriptState"); return 0; } + + public void llRemoteLoadScript() { NotImplemented("llRemoteLoadScript"); } + public void llSetRemoteScriptAccessPin(int pin) { NotImplemented("llSetRemoteScriptAccessPin"); } + public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) { NotImplemented("llRemoteLoadScriptPin"); } + public void llOpenRemoteDataChannel() { NotImplemented("llOpenRemoteDataChannel"); } + public string llSendRemoteData(string channel, string dest, int idata, string sdata) { NotImplemented("llSendRemoteData"); return ""; } + public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) { NotImplemented("llRemoteDataReply"); } + public void llCloseRemoteDataChannel(string channel) { NotImplemented("llCloseRemoteDataChannel"); } + + public string llMD5String(string src, int nonce) + { + return Util.Md5Hash(src + ":" + nonce.ToString()); + } + + public void llSetPrimitiveParams(List rules) { NotImplemented("llSetPrimitiveParams"); } + public string llStringToBase64(string str) + { + + try + { + byte[] encData_byte = new byte[str.Length]; + encData_byte = System.Text.Encoding.UTF8.GetBytes(str); + string encodedData = Convert.ToBase64String(encData_byte); + return encodedData; + } + catch (Exception e) + { + throw new Exception("Error in base64Encode" + e.Message); + } + } + + public string llBase64ToString(string str) + { + System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding(); + System.Text.Decoder utf8Decode = encoder.GetDecoder(); + try + { + + byte[] todecode_byte = Convert.FromBase64String(str); + int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); + char[] decoded_char = new char[charCount]; + utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0); + string result = new String(decoded_char); + return result; + } + catch (Exception e) + { + throw new Exception("Error in base64Decode" + e.Message); + } + } + public void llXorBase64Strings() { throw new Exception("Command deprecated! Use llXorBase64StringsCorrect instead."); } + public void llRemoteDataSetRegion() { NotImplemented("llRemoteDataSetRegion"); } + public double llLog10(double val) { return (double)Math.Log10(val); } + public double llLog(double val) { return (double)Math.Log(val); } + public List llGetAnimationList(string id) { NotImplemented("llGetAnimationList"); return new List(); } + public void llSetParcelMusicURL(string url) { NotImplemented("llSetParcelMusicURL"); } + + public LSL_Types.Vector3 llGetRootPosition() { NotImplemented("llGetRootPosition"); return new LSL_Types.Vector3(); } + + public LSL_Types.Quaternion llGetRootRotation() { NotImplemented("llGetRootRotation"); return new LSL_Types.Quaternion(); } + + public string llGetObjectDesc() + { + return m_host.Description; + } + + public void llSetObjectDesc(string desc) + { + m_host.Description = desc; + } + + public string llGetCreator() + { + return m_host.ObjectCreator.ToStringHyphenated(); + } + + public string llGetTimestamp() { return DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); } + public void llSetLinkAlpha(int linknumber, double alpha, int face) { NotImplemented("llSetLinkAlpha"); } + public int llGetNumberOfPrims() { NotImplemented("llGetNumberOfPrims"); return 0; } + public string llGetNumberOfNotecardLines(string name) { NotImplemented("llGetNumberOfNotecardLines"); return ""; } + public List llGetBoundingBox(string obj) { NotImplemented("llGetBoundingBox"); return new List(); } + public LSL_Types.Vector3 llGetGeometricCenter() { NotImplemented("llGetGeometricCenter"); return new LSL_Types.Vector3(); } + public void llGetPrimitiveParams() { NotImplemented("llGetPrimitiveParams"); } + public string llIntegerToBase64(int number) + { + NotImplemented("llIntegerToBase64"); return ""; + } + public int llBase64ToInteger(string str) + { + NotImplemented("llBase64ToInteger"); return 0; + } + + public double llGetGMTclock() + { + return DateTime.UtcNow.TimeOfDay.TotalSeconds; + } + + public string llGetSimulatorHostname() + { + return System.Environment.MachineName; + } + + public void llSetLocalRot(LSL_Types.Quaternion rot) { NotImplemented("llSetLocalRot"); } + public List llParseStringKeepNulls(string src, List seperators, List spacers) { NotImplemented("llParseStringKeepNulls"); return new List(); } + public void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity, LSL_Types.Quaternion rot, int param) { NotImplemented("llRezAtRoot"); } + + public int llGetObjectPermMask(int mask) { NotImplemented("llGetObjectPermMask"); return 0; } + + public void llSetObjectPermMask(int mask, int value) { NotImplemented("llSetObjectPermMask"); } + + public void llGetInventoryPermMask(string item, int mask) { NotImplemented("llGetInventoryPermMask"); } + public void llSetInventoryPermMask(string item, int mask, int value) { NotImplemented("llSetInventoryPermMask"); } + public string llGetInventoryCreator(string item) { NotImplemented("llGetInventoryCreator"); return ""; } + public void llOwnerSay(string msg) { NotImplemented("llOwnerSay"); } + public void llRequestSimulatorData(string simulator, int data) { NotImplemented("llRequestSimulatorData"); } + public void llForceMouselook(int mouselook) { NotImplemented("llForceMouselook"); } + public double llGetObjectMass(string id) { NotImplemented("llGetObjectMass"); return 0; } + public void llListReplaceList() { NotImplemented("llListReplaceList"); } + + public void llLoadURL(string avatar_id, string message, string url) + { + LLUUID avatarId = new LLUUID(avatar_id); + m_ScriptEngine.World.SendUrlToUser(avatarId, m_host.Name, m_host.UUID, m_host.ObjectOwner, false, message, url); + } + + public void llParcelMediaCommandList(List commandList) { NotImplemented("llParcelMediaCommandList"); } + public void llParcelMediaQuery() { NotImplemented("llParcelMediaQuery"); } + + public int llModPow(int a, int b, int c) + { + Int64 tmp = 0; + Int64 val = Math.DivRem(Convert.ToInt64(Math.Pow(a, b)), c, out tmp); + return Convert.ToInt32(tmp); + } + + public int llGetInventoryType(string name) { NotImplemented("llGetInventoryType"); return 0; } + + public void llSetPayPrice(int price, List quick_pay_buttons) { NotImplemented("llSetPayPrice"); } + public LSL_Types.Vector3 llGetCameraPos() { NotImplemented("llGetCameraPos"); return new LSL_Types.Vector3(); } + public LSL_Types.Quaternion llGetCameraRot() { NotImplemented("llGetCameraRot"); return new LSL_Types.Quaternion(); } + public void llSetPrimURL() { NotImplemented("llSetPrimURL"); } + public void llRefreshPrimURL() { NotImplemented("llRefreshPrimURL"); } + + public string llEscapeURL(string url) + { + try + { + return Uri.EscapeUriString(url); + } + catch (Exception ex) + { + return "llEscapeURL: " + ex.ToString(); + } + } + + public string llUnescapeURL(string url) + { + try + { + return Uri.UnescapeDataString(url); + } + catch (Exception ex) + { + return "llUnescapeURL: " + ex.ToString(); + } + } + public void llMapDestination(string simname, LSL_Types.Vector3 pos, LSL_Types.Vector3 look_at) { NotImplemented("llMapDestination"); } + public void llAddToLandBanList(string avatar, double hours) { NotImplemented("llAddToLandBanList"); } + public void llRemoveFromLandPassList(string avatar) { NotImplemented("llRemoveFromLandPassList"); } + public void llRemoveFromLandBanList(string avatar) { NotImplemented("llRemoveFromLandBanList"); } + public void llSetCameraParams(List rules) { NotImplemented("llSetCameraParams"); } + public void llClearCameraParams() { NotImplemented("llClearCameraParams"); } + public double llListStatistics(int operation, List src) { NotImplemented("llListStatistics"); return 0; } + + public int llGetUnixTime() + { + return Util.UnixTimeSinceEpoch(); + } + + public int llGetParcelFlags(LSL_Types.Vector3 pos) { NotImplemented("llGetParcelFlags"); return 0; } + public int llGetRegionFlags() { NotImplemented("llGetRegionFlags"); return 0; } + public string llXorBase64StringsCorrect(string str1, string str2) + { + string ret = ""; + string src1 = llBase64ToString(str1); + string src2 = llBase64ToString(str2); + int c = 0; + for (int i = 0; i < src1.Length; i++) + { + ret += src1[i] ^ src2[c]; + + c++; + if (c > src2.Length) + c = 0; + } + return llStringToBase64(ret); + } + public void llHTTPRequest(string url, List parameters, string body) + { + m_ScriptEngine.m_LSLLongCmdHandler.StartHttpRequest(m_localID, m_itemID, url, parameters, body); + } + public void llResetLandBanList() { NotImplemented("llResetLandBanList"); } + public void llResetLandPassList() { NotImplemented("llResetLandPassList"); } + public int llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide) { NotImplemented("llGetParcelPrimCount"); return 0; } + public List llGetParcelPrimOwners(LSL_Types.Vector3 pos) { NotImplemented("llGetParcelPrimOwners"); return new List(); } + public int llGetObjectPrimCount(string object_id) { NotImplemented("llGetObjectPrimCount"); return 0; } + public int llGetParcelMaxPrims(LSL_Types.Vector3 pos, int sim_wide) { NotImplemented("llGetParcelMaxPrims"); return 0; } + public List llGetParcelDetails(LSL_Types.Vector3 pos, List param) { NotImplemented("llGetParcelDetails"); return new List(); } + + // + // OpenSim functions + // + public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer) + { + if (dynamicID == "") + { + IDynamicTextureManager textureManager = this.World.RequestModuleInterface(); + LLUUID createdTexture = textureManager.AddDynamicTextureURL(World.RegionInfo.SimUUID, this.m_host.UUID, contentType, url, extraParams, timer); + return createdTexture.ToStringHyphenated(); + } + else + { + //TODO update existing dynamic textures + } + + return LLUUID.Zero.ToStringHyphenated(); + } + + private void NotImplemented(string Command) + { + if (throwErrorOnNotImplemented) + throw new NotImplementedException("Command not implemented: " + Command); + } + + } +} diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs index a45de1ef53..8ab0c306b7 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs @@ -1,262 +1,262 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; -using libsecondlife; -using OpenSim.Region.ScriptEngine.Common; - -namespace OpenSim.Region.ScriptEngine.DotNetEngine -{ - /// - /// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc. - /// - class LSLLongCmdHandler - { - private Thread cmdHandlerThread; - private int cmdHandlerThreadCycleSleepms = 100; - - private ScriptEngine m_ScriptEngine; - public LSLLongCmdHandler(ScriptEngine _ScriptEngine) - { - m_ScriptEngine = _ScriptEngine; - - // Start the thread that will be doing the work - cmdHandlerThread = new Thread(CmdHandlerThreadLoop); - cmdHandlerThread.Name = "CmdHandlerThread"; - cmdHandlerThread.Priority = ThreadPriority.BelowNormal; - cmdHandlerThread.IsBackground = true; - cmdHandlerThread.Start(); - } - ~LSLLongCmdHandler() - { - // Shut down thread - try - { - if (cmdHandlerThread != null) - { - if (cmdHandlerThread.IsAlive == true) - { - cmdHandlerThread.Abort(); - cmdHandlerThread.Join(); - } - } - } - catch { } - } - - private void CmdHandlerThreadLoop() - { - while (true) - { - // Check timers - CheckTimerEvents(); - // Check HttpRequests - CheckHttpRequests(); - - // Sleep before next cycle - Thread.Sleep(cmdHandlerThreadCycleSleepms); - } - } - - /// - /// Remove a specific script (and all its pending commands) - /// - /// - /// - public void RemoveScript(uint localID, LLUUID itemID) - { - // Remove a specific script - - // Remove from: Timers - UnSetTimerEvents(localID, itemID); - // Remove from: HttpRequest - StopHttpRequest(localID, itemID); - } - - #region TIMER - - // - // TIMER - // - private class TimerClass - { - public uint localID; - public LLUUID itemID; - public double interval; - public DateTime next; - } - private List Timers = new List(); - private object TimerListLock = new object(); - public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec) - { - Console.WriteLine("SetTimerEvent"); - - // Always remove first, in case this is a re-set - UnSetTimerEvents(m_localID, m_itemID); - if (sec == 0) // Disabling timer - return; - - // Add to timer - TimerClass ts = new TimerClass(); - ts.localID = m_localID; - ts.itemID = m_itemID; - ts.interval = sec; - ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); - lock (TimerListLock) - { - Timers.Add(ts); - } - } - public void UnSetTimerEvents(uint m_localID, LLUUID m_itemID) - { - // Remove from timer - lock (TimerListLock) - { - List NewTimers = new List(); - foreach (TimerClass ts in Timers) - { - if (ts.localID != m_localID && ts.itemID != m_itemID) - { - NewTimers.Add(ts); - } - } - Timers.Clear(); - Timers = NewTimers; - } - } - public void CheckTimerEvents() - { - // Nothing to do here? - if (Timers.Count == 0) - return; - - lock (TimerListLock) - { - - // Go through all timers - foreach (TimerClass ts in Timers) - { - // Time has passed? - if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) - { - // Add it to queue - m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", new object[] { }); - // set next interval - - - ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); - } - } - } // lock - } - #endregion - - #region HTTP REQUEST - - // - // HTTP REAQUEST - // - private class HttpClass - { - public uint localID; - public LLUUID itemID; - public string url; - public List parameters; - public string body; - public DateTime next; - - public string response_request_id; - public int response_status; - public List response_metadata; - public string response_body; - - public void SendRequest() - { - // TODO: SEND REQUEST!!! - } - public void Stop() - { - // TODO: Cancel any ongoing request - } - public bool CheckResponse() - { - // TODO: Check if we got a response yet, return true if so -- false if not - return true; - - // TODO: If we got a response, set the following then return true - //response_request_id - //response_status - //response_metadata - //response_body - - } - } - private List HttpRequests = new List(); - private object HttpListLock = new object(); - public void StartHttpRequest(uint localID, LLUUID itemID, string url, List parameters, string body) - { - Console.WriteLine("StartHttpRequest"); - - HttpClass htc = new HttpClass(); - htc.localID = localID; - htc.itemID = itemID; - htc.url = url; - htc.parameters = parameters; - htc.body = body; - lock (HttpListLock) - { - - //ADD REQUEST - HttpRequests.Add(htc); - } - } - public void StopHttpRequest(uint m_localID, LLUUID m_itemID) - { - // Remove from list - lock (HttpListLock) - { - List NewHttpList = new List(); - foreach (HttpClass ts in HttpRequests) - { - if (ts.localID != m_localID && ts.itemID != m_itemID) - { - // Keeping this one - NewHttpList.Add(ts); - } - else - { - // Shutting this one down - ts.Stop(); - } - } - HttpRequests.Clear(); - HttpRequests = NewHttpList; - } - } - public void CheckHttpRequests() - { - // Nothing to do here? - if (HttpRequests.Count == 0) - return; - - lock (HttpListLock) - { - foreach (HttpClass ts in HttpRequests) - { - - if (ts.CheckResponse() == true) - { - // Add it to event queue - //key request_id, integer status, list metadata, string body - object[] resobj = new object[] { ts.response_request_id, ts.response_status, ts.response_metadata, ts.response_body }; - m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "http_response", resobj); - // Now stop it - StopHttpRequest(ts.localID, ts.itemID); - } - } - } // lock - } - #endregion - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using libsecondlife; +using OpenSim.Region.ScriptEngine.Common; + +namespace OpenSim.Region.ScriptEngine.DotNetEngine +{ + /// + /// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc. + /// + class LSLLongCmdHandler + { + private Thread cmdHandlerThread; + private int cmdHandlerThreadCycleSleepms = 100; + + private ScriptEngine m_ScriptEngine; + public LSLLongCmdHandler(ScriptEngine _ScriptEngine) + { + m_ScriptEngine = _ScriptEngine; + + // Start the thread that will be doing the work + cmdHandlerThread = new Thread(CmdHandlerThreadLoop); + cmdHandlerThread.Name = "CmdHandlerThread"; + cmdHandlerThread.Priority = ThreadPriority.BelowNormal; + cmdHandlerThread.IsBackground = true; + cmdHandlerThread.Start(); + } + ~LSLLongCmdHandler() + { + // Shut down thread + try + { + if (cmdHandlerThread != null) + { + if (cmdHandlerThread.IsAlive == true) + { + cmdHandlerThread.Abort(); + cmdHandlerThread.Join(); + } + } + } + catch { } + } + + private void CmdHandlerThreadLoop() + { + while (true) + { + // Check timers + CheckTimerEvents(); + // Check HttpRequests + CheckHttpRequests(); + + // Sleep before next cycle + Thread.Sleep(cmdHandlerThreadCycleSleepms); + } + } + + /// + /// Remove a specific script (and all its pending commands) + /// + /// + /// + public void RemoveScript(uint localID, LLUUID itemID) + { + // Remove a specific script + + // Remove from: Timers + UnSetTimerEvents(localID, itemID); + // Remove from: HttpRequest + StopHttpRequest(localID, itemID); + } + + #region TIMER + + // + // TIMER + // + private class TimerClass + { + public uint localID; + public LLUUID itemID; + public double interval; + public DateTime next; + } + private List Timers = new List(); + private object TimerListLock = new object(); + public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec) + { + Console.WriteLine("SetTimerEvent"); + + // Always remove first, in case this is a re-set + UnSetTimerEvents(m_localID, m_itemID); + if (sec == 0) // Disabling timer + return; + + // Add to timer + TimerClass ts = new TimerClass(); + ts.localID = m_localID; + ts.itemID = m_itemID; + ts.interval = sec; + ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); + lock (TimerListLock) + { + Timers.Add(ts); + } + } + public void UnSetTimerEvents(uint m_localID, LLUUID m_itemID) + { + // Remove from timer + lock (TimerListLock) + { + List NewTimers = new List(); + foreach (TimerClass ts in Timers) + { + if (ts.localID != m_localID && ts.itemID != m_itemID) + { + NewTimers.Add(ts); + } + } + Timers.Clear(); + Timers = NewTimers; + } + } + public void CheckTimerEvents() + { + // Nothing to do here? + if (Timers.Count == 0) + return; + + lock (TimerListLock) + { + + // Go through all timers + foreach (TimerClass ts in Timers) + { + // Time has passed? + if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) + { + // Add it to queue + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", new object[] { }); + // set next interval + + + ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); + } + } + } // lock + } + #endregion + + #region HTTP REQUEST + + // + // HTTP REAQUEST + // + private class HttpClass + { + public uint localID; + public LLUUID itemID; + public string url; + public List parameters; + public string body; + public DateTime next; + + public string response_request_id; + public int response_status; + public List response_metadata; + public string response_body; + + public void SendRequest() + { + // TODO: SEND REQUEST!!! + } + public void Stop() + { + // TODO: Cancel any ongoing request + } + public bool CheckResponse() + { + // TODO: Check if we got a response yet, return true if so -- false if not + return true; + + // TODO: If we got a response, set the following then return true + //response_request_id + //response_status + //response_metadata + //response_body + + } + } + private List HttpRequests = new List(); + private object HttpListLock = new object(); + public void StartHttpRequest(uint localID, LLUUID itemID, string url, List parameters, string body) + { + Console.WriteLine("StartHttpRequest"); + + HttpClass htc = new HttpClass(); + htc.localID = localID; + htc.itemID = itemID; + htc.url = url; + htc.parameters = parameters; + htc.body = body; + lock (HttpListLock) + { + + //ADD REQUEST + HttpRequests.Add(htc); + } + } + public void StopHttpRequest(uint m_localID, LLUUID m_itemID) + { + // Remove from list + lock (HttpListLock) + { + List NewHttpList = new List(); + foreach (HttpClass ts in HttpRequests) + { + if (ts.localID != m_localID && ts.itemID != m_itemID) + { + // Keeping this one + NewHttpList.Add(ts); + } + else + { + // Shutting this one down + ts.Stop(); + } + } + HttpRequests.Clear(); + HttpRequests = NewHttpList; + } + } + public void CheckHttpRequests() + { + // Nothing to do here? + if (HttpRequests.Count == 0) + return; + + lock (HttpListLock) + { + foreach (HttpClass ts in HttpRequests) + { + + if (ts.CheckResponse() == true) + { + // Add it to event queue + //key request_id, integer status, list metadata, string body + object[] resobj = new object[] { ts.response_request_id, ts.response_status, ts.response_metadata, ts.response_body }; + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "http_response", resobj); + // Now stop it + StopHttpRequest(ts.localID, ts.itemID); + } + } + } // lock + } + #endregion + + } +} diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index 20300c00a8..e1989c4c85 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -246,12 +246,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine ls.localID = localID; ls.itemID = itemID; unloadQueue.Enqueue(ls); - } - public void ResetScript(uint localID, LLUUID itemID) - { - string script = GetScript(localID, itemID).SourceCode; - StopScript(localID, itemID); - StartScript(localID, itemID, script); + } + public void ResetScript(uint localID, LLUUID itemID) + { + string script = GetScript(localID, itemID).SourceCode; + StopScript(localID, itemID); + StartScript(localID, itemID, script); } private void _StartScript(uint localID, LLUUID itemID, string Script) @@ -288,8 +288,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine CompiledScript = m_scriptEngine.m_AppDomainManager.LoadScript(ScriptSource); #if DEBUG Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before); -#endif - +#endif + CompiledScript.SourceCode = ScriptSource; // Add it to our script memstruct SetScript(localID, itemID, CompiledScript); diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Tools.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Tools.cs index 3f7ab6831f..60dbf62145 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Tools.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Tools.cs @@ -1,52 +1,52 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of libTerrain nor the names of - its contributors may be used to endorse or promote products - derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Collections.Generic; -using System.Text; - -namespace libTerrain -{ - class Tools - { - public static double linearInterpolate(double a, double b, double amount) - { - return a + ((b - a) * amount); - } - public static double exponentialInterpolate(double a, double b, double amount) - { - a = Math.Pow(a, amount); - b = Math.Pow(b - a, 1.0 - amount); - return a+b; - } +/* +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of libTerrain nor the names of + its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace libTerrain +{ + class Tools + { + public static double linearInterpolate(double a, double b, double amount) + { + return a + ((b - a) * amount); + } + public static double exponentialInterpolate(double a, double b, double amount) + { + a = Math.Pow(a, amount); + b = Math.Pow(b - a, 1.0 - amount); + return a+b; + } public static int powerOf2Log2(int n) { for (int i = 0; i < 31; i++) { if ((n & 1) == 1) { @@ -55,6 +55,6 @@ namespace libTerrain n >>= 1; } return 0; - } - } -} + } + } +} diff --git a/OpenSim/Tools/OpenSim.GUI/InputTextBoxControl.cs b/OpenSim/Tools/OpenSim.GUI/InputTextBoxControl.cs index 91b3f603d3..47ff65af75 100644 --- a/OpenSim/Tools/OpenSim.GUI/InputTextBoxControl.cs +++ b/OpenSim/Tools/OpenSim.GUI/InputTextBoxControl.cs @@ -1,88 +1,88 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; - -namespace OpenSim.GUI -{ - class InputTextBoxControl:System.Windows.Forms.TextBox - { - public InputTextBoxControl() - { - this.KeyDown += new System.Windows.Forms.KeyEventHandler(TextInputControl_KeyDown); - } - - - private List CommandHistory = new List(); - private bool InHistory = false; - private int HistoryPosition = -1; - - void TextInputControl_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) - { - - - if (e.KeyCode == Keys.Enter && InHistory == false) - { - CommandHistory.Add(this.Text); - } - - - if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down) - { - // if not inside buffer, enter - // InBuffer = true - //Console.WriteLine("History: Check"); - if (InHistory == false) - { - if (this.Text != "") - { - //Console.WriteLine("History: Add"); - CommandHistory.Add(this.Text); - HistoryPosition = CommandHistory.Count; - } - else - { - //HistoryPosition = CommandHistory.Count + 1; - } - //Console.WriteLine("History: InHistory"); - InHistory = true; - } - - if (e.KeyCode == Keys.Up) - HistoryPosition -= 1; - if (e.KeyCode == Keys.Down) - HistoryPosition += 1; - - if (HistoryPosition > CommandHistory.Count - 1) - HistoryPosition = -1; - if (HistoryPosition < -1) - HistoryPosition = CommandHistory.Count - 1; - - //Console.WriteLine("History: Pos: " + HistoryPosition); - //Console.WriteLine("History: HaveInHistCount: " + CommandHistory.Count); - if (CommandHistory.Count != 0) - { - if (HistoryPosition != -1) - { - //Console.WriteLine("History: Getting"); - //this.Text = CommandHistory.Item(HistoryPosition); - this.Text = CommandHistory[HistoryPosition]; - this.SelectionStart = this.Text.Length; - this.SelectionLength = 0; - } - else - { - //Console.WriteLine("History: Nothing"); - this.Text = ""; - } - } - e.Handled = true; - } else { - InHistory = false; - HistoryPosition = -1; - } - } - - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; + +namespace OpenSim.GUI +{ + class InputTextBoxControl:System.Windows.Forms.TextBox + { + public InputTextBoxControl() + { + this.KeyDown += new System.Windows.Forms.KeyEventHandler(TextInputControl_KeyDown); + } + + + private List CommandHistory = new List(); + private bool InHistory = false; + private int HistoryPosition = -1; + + void TextInputControl_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) + { + + + if (e.KeyCode == Keys.Enter && InHistory == false) + { + CommandHistory.Add(this.Text); + } + + + if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down) + { + // if not inside buffer, enter + // InBuffer = true + //Console.WriteLine("History: Check"); + if (InHistory == false) + { + if (this.Text != "") + { + //Console.WriteLine("History: Add"); + CommandHistory.Add(this.Text); + HistoryPosition = CommandHistory.Count; + } + else + { + //HistoryPosition = CommandHistory.Count + 1; + } + //Console.WriteLine("History: InHistory"); + InHistory = true; + } + + if (e.KeyCode == Keys.Up) + HistoryPosition -= 1; + if (e.KeyCode == Keys.Down) + HistoryPosition += 1; + + if (HistoryPosition > CommandHistory.Count - 1) + HistoryPosition = -1; + if (HistoryPosition < -1) + HistoryPosition = CommandHistory.Count - 1; + + //Console.WriteLine("History: Pos: " + HistoryPosition); + //Console.WriteLine("History: HaveInHistCount: " + CommandHistory.Count); + if (CommandHistory.Count != 0) + { + if (HistoryPosition != -1) + { + //Console.WriteLine("History: Getting"); + //this.Text = CommandHistory.Item(HistoryPosition); + this.Text = CommandHistory[HistoryPosition]; + this.SelectionStart = this.Text.Length; + this.SelectionLength = 0; + } + else + { + //Console.WriteLine("History: Nothing"); + this.Text = ""; + } + } + e.Handled = true; + } else { + InHistory = false; + HistoryPosition = -1; + } + } + + + } +} diff --git a/OpenSim/Tools/OpenSim.GUI/Main.Designer.cs b/OpenSim/Tools/OpenSim.GUI/Main.Designer.cs index 6350c5718f..c08f26de93 100644 --- a/OpenSim/Tools/OpenSim.GUI/Main.Designer.cs +++ b/OpenSim/Tools/OpenSim.GUI/Main.Designer.cs @@ -1,393 +1,393 @@ -namespace OpenSim.GUI -{ - partial class Main - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.tabLogs = new System.Windows.Forms.TabControl(); - this.tabMainLog = new System.Windows.Forms.TabPage(); - this.txtMainLog = new System.Windows.Forms.TextBox(); - this.tabRegionServer = new System.Windows.Forms.TabPage(); - this.label1 = new System.Windows.Forms.Label(); - this.txtInputRegionServer = new OpenSim.GUI.InputTextBoxControl(); - this.txtOpenSim = new System.Windows.Forms.TextBox(); - this.tabUserServer = new System.Windows.Forms.TabPage(); - this.label2 = new System.Windows.Forms.Label(); - this.txtInputUserServer = new OpenSim.GUI.InputTextBoxControl(); - this.txtUserServer = new System.Windows.Forms.TextBox(); - this.tabAssetServer = new System.Windows.Forms.TabPage(); - this.label3 = new System.Windows.Forms.Label(); - this.txtInputAssetServer = new OpenSim.GUI.InputTextBoxControl(); - this.txtAssetServer = new System.Windows.Forms.TextBox(); - this.tabGridServer = new System.Windows.Forms.TabPage(); - this.label4 = new System.Windows.Forms.Label(); - this.txtInputGridServer = new OpenSim.GUI.InputTextBoxControl(); - this.txtGridServer = new System.Windows.Forms.TextBox(); - this.gbLog = new System.Windows.Forms.GroupBox(); - this.btnStart = new System.Windows.Forms.Button(); - this.btnStop = new System.Windows.Forms.Button(); - this.rbGridRegionMode = new System.Windows.Forms.RadioButton(); - this.rbStandAloneMode = new System.Windows.Forms.RadioButton(); - this.rbGridServer = new System.Windows.Forms.RadioButton(); - this.tabLogs.SuspendLayout(); - this.tabMainLog.SuspendLayout(); - this.tabRegionServer.SuspendLayout(); - this.tabUserServer.SuspendLayout(); - this.tabAssetServer.SuspendLayout(); - this.tabGridServer.SuspendLayout(); - this.gbLog.SuspendLayout(); - this.SuspendLayout(); - // - // tabLogs - // - this.tabLogs.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tabLogs.Controls.Add(this.tabMainLog); - this.tabLogs.Controls.Add(this.tabRegionServer); - this.tabLogs.Controls.Add(this.tabUserServer); - this.tabLogs.Controls.Add(this.tabAssetServer); - this.tabLogs.Controls.Add(this.tabGridServer); - this.tabLogs.Location = new System.Drawing.Point(6, 19); - this.tabLogs.Name = "tabLogs"; - this.tabLogs.SelectedIndex = 0; - this.tabLogs.Size = new System.Drawing.Size(562, 230); - this.tabLogs.TabIndex = 0; - // - // tabMainLog - // - this.tabMainLog.Controls.Add(this.txtMainLog); - this.tabMainLog.Location = new System.Drawing.Point(4, 22); - this.tabMainLog.Name = "tabMainLog"; - this.tabMainLog.Size = new System.Drawing.Size(554, 204); - this.tabMainLog.TabIndex = 4; - this.tabMainLog.Text = "Main log"; - this.tabMainLog.UseVisualStyleBackColor = true; - // - // txtMainLog - // - this.txtMainLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.txtMainLog.Location = new System.Drawing.Point(6, 5); - this.txtMainLog.Multiline = true; - this.txtMainLog.Name = "txtMainLog"; - this.txtMainLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.txtMainLog.Size = new System.Drawing.Size(542, 195); - this.txtMainLog.TabIndex = 1; - // - // tabRegionServer - // - this.tabRegionServer.Controls.Add(this.label1); - this.tabRegionServer.Controls.Add(this.txtInputRegionServer); - this.tabRegionServer.Controls.Add(this.txtOpenSim); - this.tabRegionServer.Location = new System.Drawing.Point(4, 22); - this.tabRegionServer.Name = "tabRegionServer"; - this.tabRegionServer.Padding = new System.Windows.Forms.Padding(3); - this.tabRegionServer.Size = new System.Drawing.Size(554, 204); - this.tabRegionServer.TabIndex = 0; - this.tabRegionServer.Text = "Region server"; - this.tabRegionServer.UseVisualStyleBackColor = true; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(6, 183); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(57, 13); - this.label1.TabIndex = 4; - this.label1.Text = "Command:"; - // - // txtInputRegionServer - // - this.txtInputRegionServer.Location = new System.Drawing.Point(69, 180); - this.txtInputRegionServer.Name = "txtInputRegionServer"; - this.txtInputRegionServer.Size = new System.Drawing.Size(479, 20); - this.txtInputRegionServer.TabIndex = 0; - // - // txtOpenSim - // - this.txtOpenSim.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.txtOpenSim.Location = new System.Drawing.Point(6, 6); - this.txtOpenSim.Multiline = true; - this.txtOpenSim.Name = "txtOpenSim"; - this.txtOpenSim.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.txtOpenSim.Size = new System.Drawing.Size(542, 168); - this.txtOpenSim.TabIndex = 0; - // - // tabUserServer - // - this.tabUserServer.Controls.Add(this.label2); - this.tabUserServer.Controls.Add(this.txtInputUserServer); - this.tabUserServer.Controls.Add(this.txtUserServer); - this.tabUserServer.Location = new System.Drawing.Point(4, 22); - this.tabUserServer.Name = "tabUserServer"; - this.tabUserServer.Padding = new System.Windows.Forms.Padding(3); - this.tabUserServer.Size = new System.Drawing.Size(554, 204); - this.tabUserServer.TabIndex = 1; - this.tabUserServer.Text = "User server"; - this.tabUserServer.UseVisualStyleBackColor = true; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(6, 181); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(57, 13); - this.label2.TabIndex = 6; - this.label2.Text = "Command:"; - // - // txtInputUserServer - // - this.txtInputUserServer.Location = new System.Drawing.Point(69, 178); - this.txtInputUserServer.Name = "txtInputUserServer"; - this.txtInputUserServer.Size = new System.Drawing.Size(479, 20); - this.txtInputUserServer.TabIndex = 5; - // - // txtUserServer - // - this.txtUserServer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.txtUserServer.Location = new System.Drawing.Point(6, 5); - this.txtUserServer.Multiline = true; - this.txtUserServer.Name = "txtUserServer"; - this.txtUserServer.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.txtUserServer.Size = new System.Drawing.Size(542, 168); - this.txtUserServer.TabIndex = 1; - // - // tabAssetServer - // - this.tabAssetServer.Controls.Add(this.label3); - this.tabAssetServer.Controls.Add(this.txtInputAssetServer); - this.tabAssetServer.Controls.Add(this.txtAssetServer); - this.tabAssetServer.Location = new System.Drawing.Point(4, 22); - this.tabAssetServer.Name = "tabAssetServer"; - this.tabAssetServer.Size = new System.Drawing.Size(554, 204); - this.tabAssetServer.TabIndex = 2; - this.tabAssetServer.Text = "Asset server"; - this.tabAssetServer.UseVisualStyleBackColor = true; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(6, 182); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(57, 13); - this.label3.TabIndex = 6; - this.label3.Text = "Command:"; - // - // txtInputAssetServer - // - this.txtInputAssetServer.Location = new System.Drawing.Point(69, 179); - this.txtInputAssetServer.Name = "txtInputAssetServer"; - this.txtInputAssetServer.Size = new System.Drawing.Size(479, 20); - this.txtInputAssetServer.TabIndex = 5; - // - // txtAssetServer - // - this.txtAssetServer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.txtAssetServer.Location = new System.Drawing.Point(6, 5); - this.txtAssetServer.Multiline = true; - this.txtAssetServer.Name = "txtAssetServer"; - this.txtAssetServer.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.txtAssetServer.Size = new System.Drawing.Size(542, 168); - this.txtAssetServer.TabIndex = 1; - // - // tabGridServer - // - this.tabGridServer.Controls.Add(this.label4); - this.tabGridServer.Controls.Add(this.txtInputGridServer); - this.tabGridServer.Controls.Add(this.txtGridServer); - this.tabGridServer.Location = new System.Drawing.Point(4, 22); - this.tabGridServer.Name = "tabGridServer"; - this.tabGridServer.Size = new System.Drawing.Size(554, 204); - this.tabGridServer.TabIndex = 3; - this.tabGridServer.Text = "Grid server"; - this.tabGridServer.UseVisualStyleBackColor = true; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(6, 182); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(57, 13); - this.label4.TabIndex = 6; - this.label4.Text = "Command:"; - // - // txtInputGridServer - // - this.txtInputGridServer.Location = new System.Drawing.Point(69, 179); - this.txtInputGridServer.Name = "txtInputGridServer"; - this.txtInputGridServer.Size = new System.Drawing.Size(479, 20); - this.txtInputGridServer.TabIndex = 5; - // - // txtGridServer - // - this.txtGridServer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.txtGridServer.Location = new System.Drawing.Point(6, 5); - this.txtGridServer.Multiline = true; - this.txtGridServer.Name = "txtGridServer"; - this.txtGridServer.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.txtGridServer.Size = new System.Drawing.Size(542, 168); - this.txtGridServer.TabIndex = 1; - // - // gbLog - // - this.gbLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.gbLog.Controls.Add(this.tabLogs); - this.gbLog.Location = new System.Drawing.Point(2, 41); - this.gbLog.Name = "gbLog"; - this.gbLog.Size = new System.Drawing.Size(574, 255); - this.gbLog.TabIndex = 1; - this.gbLog.TabStop = false; - this.gbLog.Text = "Logs"; - // - // btnStart - // - this.btnStart.Location = new System.Drawing.Point(8, 12); - this.btnStart.Name = "btnStart"; - this.btnStart.Size = new System.Drawing.Size(75, 23); - this.btnStart.TabIndex = 2; - this.btnStart.Text = "Start"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // - // btnStop - // - this.btnStop.Location = new System.Drawing.Point(89, 12); - this.btnStop.Name = "btnStop"; - this.btnStop.Size = new System.Drawing.Size(75, 23); - this.btnStop.TabIndex = 3; - this.btnStop.Text = "Stop"; - this.btnStop.UseVisualStyleBackColor = true; - this.btnStop.Click += new System.EventHandler(this.btnStop_Click); - // - // rbGridRegionMode - // - this.rbGridRegionMode.AutoSize = true; - this.rbGridRegionMode.Location = new System.Drawing.Point(407, 18); - this.rbGridRegionMode.Name = "rbGridRegionMode"; - this.rbGridRegionMode.Size = new System.Drawing.Size(76, 17); - this.rbGridRegionMode.TabIndex = 4; - this.rbGridRegionMode.Text = "Grid region"; - this.rbGridRegionMode.UseVisualStyleBackColor = true; - this.rbGridRegionMode.CheckedChanged += new System.EventHandler(this.rbGridRegionMode_CheckedChanged); - // - // rbStandAloneMode - // - this.rbStandAloneMode.AutoSize = true; - this.rbStandAloneMode.Checked = true; - this.rbStandAloneMode.Location = new System.Drawing.Point(319, 18); - this.rbStandAloneMode.Name = "rbStandAloneMode"; - this.rbStandAloneMode.Size = new System.Drawing.Size(82, 17); - this.rbStandAloneMode.TabIndex = 5; - this.rbStandAloneMode.TabStop = true; - this.rbStandAloneMode.Text = "Stand alone"; - this.rbStandAloneMode.UseVisualStyleBackColor = true; - this.rbStandAloneMode.CheckedChanged += new System.EventHandler(this.rbStandAloneMode_CheckedChanged); - // - // rbGridServer - // - this.rbGridServer.AutoSize = true; - this.rbGridServer.Location = new System.Drawing.Point(484, 18); - this.rbGridServer.Name = "rbGridServer"; - this.rbGridServer.Size = new System.Drawing.Size(76, 17); - this.rbGridServer.TabIndex = 6; - this.rbGridServer.Text = "Grid server"; - this.rbGridServer.UseVisualStyleBackColor = true; - this.rbGridServer.CheckedChanged += new System.EventHandler(this.rbGridServer_CheckedChanged); - // - // Main - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(583, 299); - this.Controls.Add(this.rbGridServer); - this.Controls.Add(this.rbStandAloneMode); - this.Controls.Add(this.rbGridRegionMode); - this.Controls.Add(this.btnStop); - this.Controls.Add(this.btnStart); - this.Controls.Add(this.gbLog); - this.Name = "Main"; - this.Text = "OpenSim"; - this.Load += new System.EventHandler(this.Main_Load); - this.tabLogs.ResumeLayout(false); - this.tabMainLog.ResumeLayout(false); - this.tabMainLog.PerformLayout(); - this.tabRegionServer.ResumeLayout(false); - this.tabRegionServer.PerformLayout(); - this.tabUserServer.ResumeLayout(false); - this.tabUserServer.PerformLayout(); - this.tabAssetServer.ResumeLayout(false); - this.tabAssetServer.PerformLayout(); - this.tabGridServer.ResumeLayout(false); - this.tabGridServer.PerformLayout(); - this.gbLog.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TabControl tabLogs; - private System.Windows.Forms.TabPage tabRegionServer; - private System.Windows.Forms.TabPage tabUserServer; - private System.Windows.Forms.GroupBox gbLog; - private System.Windows.Forms.TextBox txtOpenSim; - private System.Windows.Forms.TextBox txtUserServer; - private System.Windows.Forms.TabPage tabAssetServer; - private System.Windows.Forms.TextBox txtAssetServer; - private System.Windows.Forms.TabPage tabGridServer; - private System.Windows.Forms.TextBox txtGridServer; - private System.Windows.Forms.TabPage tabMainLog; - private System.Windows.Forms.Button btnStart; - private System.Windows.Forms.Button btnStop; - private System.Windows.Forms.TextBox txtMainLog; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Label label4; - private InputTextBoxControl txtInputRegionServer; - private InputTextBoxControl txtInputUserServer; - private InputTextBoxControl txtInputAssetServer; - private InputTextBoxControl txtInputGridServer; - private System.Windows.Forms.RadioButton rbGridRegionMode; - private System.Windows.Forms.RadioButton rbStandAloneMode; - private System.Windows.Forms.RadioButton rbGridServer; - } -} - +namespace OpenSim.GUI +{ + partial class Main + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.tabLogs = new System.Windows.Forms.TabControl(); + this.tabMainLog = new System.Windows.Forms.TabPage(); + this.txtMainLog = new System.Windows.Forms.TextBox(); + this.tabRegionServer = new System.Windows.Forms.TabPage(); + this.label1 = new System.Windows.Forms.Label(); + this.txtInputRegionServer = new OpenSim.GUI.InputTextBoxControl(); + this.txtOpenSim = new System.Windows.Forms.TextBox(); + this.tabUserServer = new System.Windows.Forms.TabPage(); + this.label2 = new System.Windows.Forms.Label(); + this.txtInputUserServer = new OpenSim.GUI.InputTextBoxControl(); + this.txtUserServer = new System.Windows.Forms.TextBox(); + this.tabAssetServer = new System.Windows.Forms.TabPage(); + this.label3 = new System.Windows.Forms.Label(); + this.txtInputAssetServer = new OpenSim.GUI.InputTextBoxControl(); + this.txtAssetServer = new System.Windows.Forms.TextBox(); + this.tabGridServer = new System.Windows.Forms.TabPage(); + this.label4 = new System.Windows.Forms.Label(); + this.txtInputGridServer = new OpenSim.GUI.InputTextBoxControl(); + this.txtGridServer = new System.Windows.Forms.TextBox(); + this.gbLog = new System.Windows.Forms.GroupBox(); + this.btnStart = new System.Windows.Forms.Button(); + this.btnStop = new System.Windows.Forms.Button(); + this.rbGridRegionMode = new System.Windows.Forms.RadioButton(); + this.rbStandAloneMode = new System.Windows.Forms.RadioButton(); + this.rbGridServer = new System.Windows.Forms.RadioButton(); + this.tabLogs.SuspendLayout(); + this.tabMainLog.SuspendLayout(); + this.tabRegionServer.SuspendLayout(); + this.tabUserServer.SuspendLayout(); + this.tabAssetServer.SuspendLayout(); + this.tabGridServer.SuspendLayout(); + this.gbLog.SuspendLayout(); + this.SuspendLayout(); + // + // tabLogs + // + this.tabLogs.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tabLogs.Controls.Add(this.tabMainLog); + this.tabLogs.Controls.Add(this.tabRegionServer); + this.tabLogs.Controls.Add(this.tabUserServer); + this.tabLogs.Controls.Add(this.tabAssetServer); + this.tabLogs.Controls.Add(this.tabGridServer); + this.tabLogs.Location = new System.Drawing.Point(6, 19); + this.tabLogs.Name = "tabLogs"; + this.tabLogs.SelectedIndex = 0; + this.tabLogs.Size = new System.Drawing.Size(562, 230); + this.tabLogs.TabIndex = 0; + // + // tabMainLog + // + this.tabMainLog.Controls.Add(this.txtMainLog); + this.tabMainLog.Location = new System.Drawing.Point(4, 22); + this.tabMainLog.Name = "tabMainLog"; + this.tabMainLog.Size = new System.Drawing.Size(554, 204); + this.tabMainLog.TabIndex = 4; + this.tabMainLog.Text = "Main log"; + this.tabMainLog.UseVisualStyleBackColor = true; + // + // txtMainLog + // + this.txtMainLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtMainLog.Location = new System.Drawing.Point(6, 5); + this.txtMainLog.Multiline = true; + this.txtMainLog.Name = "txtMainLog"; + this.txtMainLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtMainLog.Size = new System.Drawing.Size(542, 195); + this.txtMainLog.TabIndex = 1; + // + // tabRegionServer + // + this.tabRegionServer.Controls.Add(this.label1); + this.tabRegionServer.Controls.Add(this.txtInputRegionServer); + this.tabRegionServer.Controls.Add(this.txtOpenSim); + this.tabRegionServer.Location = new System.Drawing.Point(4, 22); + this.tabRegionServer.Name = "tabRegionServer"; + this.tabRegionServer.Padding = new System.Windows.Forms.Padding(3); + this.tabRegionServer.Size = new System.Drawing.Size(554, 204); + this.tabRegionServer.TabIndex = 0; + this.tabRegionServer.Text = "Region server"; + this.tabRegionServer.UseVisualStyleBackColor = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(6, 183); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(57, 13); + this.label1.TabIndex = 4; + this.label1.Text = "Command:"; + // + // txtInputRegionServer + // + this.txtInputRegionServer.Location = new System.Drawing.Point(69, 180); + this.txtInputRegionServer.Name = "txtInputRegionServer"; + this.txtInputRegionServer.Size = new System.Drawing.Size(479, 20); + this.txtInputRegionServer.TabIndex = 0; + // + // txtOpenSim + // + this.txtOpenSim.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtOpenSim.Location = new System.Drawing.Point(6, 6); + this.txtOpenSim.Multiline = true; + this.txtOpenSim.Name = "txtOpenSim"; + this.txtOpenSim.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtOpenSim.Size = new System.Drawing.Size(542, 168); + this.txtOpenSim.TabIndex = 0; + // + // tabUserServer + // + this.tabUserServer.Controls.Add(this.label2); + this.tabUserServer.Controls.Add(this.txtInputUserServer); + this.tabUserServer.Controls.Add(this.txtUserServer); + this.tabUserServer.Location = new System.Drawing.Point(4, 22); + this.tabUserServer.Name = "tabUserServer"; + this.tabUserServer.Padding = new System.Windows.Forms.Padding(3); + this.tabUserServer.Size = new System.Drawing.Size(554, 204); + this.tabUserServer.TabIndex = 1; + this.tabUserServer.Text = "User server"; + this.tabUserServer.UseVisualStyleBackColor = true; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(6, 181); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(57, 13); + this.label2.TabIndex = 6; + this.label2.Text = "Command:"; + // + // txtInputUserServer + // + this.txtInputUserServer.Location = new System.Drawing.Point(69, 178); + this.txtInputUserServer.Name = "txtInputUserServer"; + this.txtInputUserServer.Size = new System.Drawing.Size(479, 20); + this.txtInputUserServer.TabIndex = 5; + // + // txtUserServer + // + this.txtUserServer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtUserServer.Location = new System.Drawing.Point(6, 5); + this.txtUserServer.Multiline = true; + this.txtUserServer.Name = "txtUserServer"; + this.txtUserServer.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtUserServer.Size = new System.Drawing.Size(542, 168); + this.txtUserServer.TabIndex = 1; + // + // tabAssetServer + // + this.tabAssetServer.Controls.Add(this.label3); + this.tabAssetServer.Controls.Add(this.txtInputAssetServer); + this.tabAssetServer.Controls.Add(this.txtAssetServer); + this.tabAssetServer.Location = new System.Drawing.Point(4, 22); + this.tabAssetServer.Name = "tabAssetServer"; + this.tabAssetServer.Size = new System.Drawing.Size(554, 204); + this.tabAssetServer.TabIndex = 2; + this.tabAssetServer.Text = "Asset server"; + this.tabAssetServer.UseVisualStyleBackColor = true; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(6, 182); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(57, 13); + this.label3.TabIndex = 6; + this.label3.Text = "Command:"; + // + // txtInputAssetServer + // + this.txtInputAssetServer.Location = new System.Drawing.Point(69, 179); + this.txtInputAssetServer.Name = "txtInputAssetServer"; + this.txtInputAssetServer.Size = new System.Drawing.Size(479, 20); + this.txtInputAssetServer.TabIndex = 5; + // + // txtAssetServer + // + this.txtAssetServer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtAssetServer.Location = new System.Drawing.Point(6, 5); + this.txtAssetServer.Multiline = true; + this.txtAssetServer.Name = "txtAssetServer"; + this.txtAssetServer.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtAssetServer.Size = new System.Drawing.Size(542, 168); + this.txtAssetServer.TabIndex = 1; + // + // tabGridServer + // + this.tabGridServer.Controls.Add(this.label4); + this.tabGridServer.Controls.Add(this.txtInputGridServer); + this.tabGridServer.Controls.Add(this.txtGridServer); + this.tabGridServer.Location = new System.Drawing.Point(4, 22); + this.tabGridServer.Name = "tabGridServer"; + this.tabGridServer.Size = new System.Drawing.Size(554, 204); + this.tabGridServer.TabIndex = 3; + this.tabGridServer.Text = "Grid server"; + this.tabGridServer.UseVisualStyleBackColor = true; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(6, 182); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(57, 13); + this.label4.TabIndex = 6; + this.label4.Text = "Command:"; + // + // txtInputGridServer + // + this.txtInputGridServer.Location = new System.Drawing.Point(69, 179); + this.txtInputGridServer.Name = "txtInputGridServer"; + this.txtInputGridServer.Size = new System.Drawing.Size(479, 20); + this.txtInputGridServer.TabIndex = 5; + // + // txtGridServer + // + this.txtGridServer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtGridServer.Location = new System.Drawing.Point(6, 5); + this.txtGridServer.Multiline = true; + this.txtGridServer.Name = "txtGridServer"; + this.txtGridServer.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtGridServer.Size = new System.Drawing.Size(542, 168); + this.txtGridServer.TabIndex = 1; + // + // gbLog + // + this.gbLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.gbLog.Controls.Add(this.tabLogs); + this.gbLog.Location = new System.Drawing.Point(2, 41); + this.gbLog.Name = "gbLog"; + this.gbLog.Size = new System.Drawing.Size(574, 255); + this.gbLog.TabIndex = 1; + this.gbLog.TabStop = false; + this.gbLog.Text = "Logs"; + // + // btnStart + // + this.btnStart.Location = new System.Drawing.Point(8, 12); + this.btnStart.Name = "btnStart"; + this.btnStart.Size = new System.Drawing.Size(75, 23); + this.btnStart.TabIndex = 2; + this.btnStart.Text = "Start"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // + // btnStop + // + this.btnStop.Location = new System.Drawing.Point(89, 12); + this.btnStop.Name = "btnStop"; + this.btnStop.Size = new System.Drawing.Size(75, 23); + this.btnStop.TabIndex = 3; + this.btnStop.Text = "Stop"; + this.btnStop.UseVisualStyleBackColor = true; + this.btnStop.Click += new System.EventHandler(this.btnStop_Click); + // + // rbGridRegionMode + // + this.rbGridRegionMode.AutoSize = true; + this.rbGridRegionMode.Location = new System.Drawing.Point(407, 18); + this.rbGridRegionMode.Name = "rbGridRegionMode"; + this.rbGridRegionMode.Size = new System.Drawing.Size(76, 17); + this.rbGridRegionMode.TabIndex = 4; + this.rbGridRegionMode.Text = "Grid region"; + this.rbGridRegionMode.UseVisualStyleBackColor = true; + this.rbGridRegionMode.CheckedChanged += new System.EventHandler(this.rbGridRegionMode_CheckedChanged); + // + // rbStandAloneMode + // + this.rbStandAloneMode.AutoSize = true; + this.rbStandAloneMode.Checked = true; + this.rbStandAloneMode.Location = new System.Drawing.Point(319, 18); + this.rbStandAloneMode.Name = "rbStandAloneMode"; + this.rbStandAloneMode.Size = new System.Drawing.Size(82, 17); + this.rbStandAloneMode.TabIndex = 5; + this.rbStandAloneMode.TabStop = true; + this.rbStandAloneMode.Text = "Stand alone"; + this.rbStandAloneMode.UseVisualStyleBackColor = true; + this.rbStandAloneMode.CheckedChanged += new System.EventHandler(this.rbStandAloneMode_CheckedChanged); + // + // rbGridServer + // + this.rbGridServer.AutoSize = true; + this.rbGridServer.Location = new System.Drawing.Point(484, 18); + this.rbGridServer.Name = "rbGridServer"; + this.rbGridServer.Size = new System.Drawing.Size(76, 17); + this.rbGridServer.TabIndex = 6; + this.rbGridServer.Text = "Grid server"; + this.rbGridServer.UseVisualStyleBackColor = true; + this.rbGridServer.CheckedChanged += new System.EventHandler(this.rbGridServer_CheckedChanged); + // + // Main + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(583, 299); + this.Controls.Add(this.rbGridServer); + this.Controls.Add(this.rbStandAloneMode); + this.Controls.Add(this.rbGridRegionMode); + this.Controls.Add(this.btnStop); + this.Controls.Add(this.btnStart); + this.Controls.Add(this.gbLog); + this.Name = "Main"; + this.Text = "OpenSim"; + this.Load += new System.EventHandler(this.Main_Load); + this.tabLogs.ResumeLayout(false); + this.tabMainLog.ResumeLayout(false); + this.tabMainLog.PerformLayout(); + this.tabRegionServer.ResumeLayout(false); + this.tabRegionServer.PerformLayout(); + this.tabUserServer.ResumeLayout(false); + this.tabUserServer.PerformLayout(); + this.tabAssetServer.ResumeLayout(false); + this.tabAssetServer.PerformLayout(); + this.tabGridServer.ResumeLayout(false); + this.tabGridServer.PerformLayout(); + this.gbLog.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TabControl tabLogs; + private System.Windows.Forms.TabPage tabRegionServer; + private System.Windows.Forms.TabPage tabUserServer; + private System.Windows.Forms.GroupBox gbLog; + private System.Windows.Forms.TextBox txtOpenSim; + private System.Windows.Forms.TextBox txtUserServer; + private System.Windows.Forms.TabPage tabAssetServer; + private System.Windows.Forms.TextBox txtAssetServer; + private System.Windows.Forms.TabPage tabGridServer; + private System.Windows.Forms.TextBox txtGridServer; + private System.Windows.Forms.TabPage tabMainLog; + private System.Windows.Forms.Button btnStart; + private System.Windows.Forms.Button btnStop; + private System.Windows.Forms.TextBox txtMainLog; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private InputTextBoxControl txtInputRegionServer; + private InputTextBoxControl txtInputUserServer; + private InputTextBoxControl txtInputAssetServer; + private InputTextBoxControl txtInputGridServer; + private System.Windows.Forms.RadioButton rbGridRegionMode; + private System.Windows.Forms.RadioButton rbStandAloneMode; + private System.Windows.Forms.RadioButton rbGridServer; + } +} + diff --git a/OpenSim/Tools/OpenSim.GUI/Main.cs b/OpenSim/Tools/OpenSim.GUI/Main.cs index 0b5af28bd0..5de4af4144 100644 --- a/OpenSim/Tools/OpenSim.GUI/Main.cs +++ b/OpenSim/Tools/OpenSim.GUI/Main.cs @@ -1,242 +1,242 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; - -namespace OpenSim.GUI -{ - public partial class Main : Form - { - - public ProcessManager proc_OpenSim; - public ProcessManager proc_UserServer; - public ProcessManager proc_GridServer; - public ProcessManager proc_AssetServer; - - public Main() - { - InitializeComponent(); - } - - private void Main_Load(object sender, EventArgs e) - { - txtInputUserServer.KeyPress += new KeyPressEventHandler(txtInputUserServer_KeyPress); - txtInputGridServer.KeyPress += new KeyPressEventHandler(txtInputGridServer_KeyPress); - txtInputAssetServer.KeyPress += new KeyPressEventHandler(txtInputAssetServer_KeyPress); - txtInputRegionServer.KeyPress += new KeyPressEventHandler(txtInputRegionServer_KeyPress); - - tabLogs.Selected += new TabControlEventHandler(tabLogs_Selected); - - UpdateTabVisibility(); - } - - void tabLogs_Selected(object sender, TabControlEventArgs e) - { - if (e.TabPage == tabUserServer) - txtInputUserServer.Focus(); - if (e.TabPage == tabGridServer) - txtInputGridServer.Focus(); - if (e.TabPage == tabAssetServer) - txtInputAssetServer.Focus(); - if (e.TabPage == tabRegionServer) - txtInputRegionServer.Focus(); - } - - void txtInputUserServer_KeyPress(object sender, KeyPressEventArgs e) - { - - if (e.KeyChar == 13) - { - // We got a command - e.Handled = true; - proc_UserServer.StandardInput.WriteLine(txtInputUserServer.Text + "\r\n"); - txtInputUserServer.Text = ""; - } - } - - void txtInputGridServer_KeyPress(object sender, KeyPressEventArgs e) - { - if (e.KeyChar == 13) - { - // We got a command - e.Handled = true; - proc_GridServer.StandardInput.WriteLine(txtInputGridServer.Text + "\r\n"); - txtInputGridServer.Text = ""; - } - } - - void txtInputAssetServer_KeyPress(object sender, KeyPressEventArgs e) - { - if (e.KeyChar == 13) - { - // We got a command - e.Handled = true; - proc_AssetServer.StandardInput.WriteLine(txtInputAssetServer.Text + "\r\n"); - txtInputAssetServer.Text = ""; - } - } - - void txtInputRegionServer_KeyPress(object sender, KeyPressEventArgs e) - { - if (e.KeyChar == 13) - { - // We got a command - e.Handled = true; - proc_OpenSim.StandardInput.WriteLine(txtInputRegionServer.Text + "\r\n"); - txtInputRegionServer.Text = ""; - } - } - - private void btnStart_Click(object sender, EventArgs e) - { - - // - // THIS PART NEEDS TO BE MOVED TO A SEPARATE THREAD OR A TIMER OF SOME SORT - // should not block on wait - // ALSO - IF SOME SERVICES ARE NOT CONFIGURED, POP UP CONFIGURATION BOX FOR THAT SERVICE! - // - - btnStart.Enabled = false; - btnStop.Enabled = false; - - - - if (rbGridServer.Checked) - { - // Start UserServer - proc_UserServer = new ProcessManager("OpenSim.Grid.UserServer.exe", ""); - txtMainLog.AppendText("Starting: User server" + "\r\n"); - proc_UserServer.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_UserServer_DataReceived); - proc_UserServer.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_UserServer_DataReceived); - proc_UserServer.StartProcess(); - System.Threading.Thread.Sleep(3000); - - // Start GridServer - proc_GridServer = new ProcessManager("OpenSim.Grid.GridServer.exe", ""); - txtMainLog.AppendText("Starting: Grid server" + "\r\n"); - proc_GridServer.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_GridServer_DataReceived); - proc_GridServer.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_GridServer_DataReceived); - proc_GridServer.StartProcess(); - System.Threading.Thread.Sleep(3000); - - // Start AssetServer - proc_AssetServer = new ProcessManager("OpenSim.Grid.AssetServer.exe", ""); - txtMainLog.AppendText("Starting: Asset server" + "\r\n"); - proc_AssetServer.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_AssetServer_DataReceived); - proc_AssetServer.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_AssetServer_DataReceived); - proc_AssetServer.StartProcess(); - System.Threading.Thread.Sleep(3000); - } - - // Start OpenSim - string p = ""; - if (rbGridServer.Checked) - p = "-gridmode=true"; - - proc_OpenSim = new ProcessManager("OpenSim.EXE", p); - txtMainLog.AppendText("Starting: OpenSim (Region server)" + "\r\n"); - proc_OpenSim.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_OpenSim_DataReceived); - proc_OpenSim.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_OpenSim_DataReceived); - proc_OpenSim.StartProcess(); - - btnStart.Enabled = false; - btnStop.Enabled = true; - - } - public delegate void AppendText(string Text); - void proc_UserServer_DataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e) - { - this.Invoke(new AppendText(txtUserServer.AppendText), new object[] { e.Data + "\r\n" }); - this.Invoke(new AppendText(txtMainLog.AppendText), new object[] { "UserServer: " + e.Data + "\r\n" }); - } - void proc_GridServer_DataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e) - { - this.Invoke(new AppendText(txtGridServer.AppendText), new object[] { e.Data + "\r\n" }); - this.Invoke(new AppendText(txtMainLog.AppendText), new object[] { "GridServer: " + e.Data + "\r\n" }); - } - void proc_AssetServer_DataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e) - { - this.Invoke(new AppendText(txtAssetServer.AppendText), new object[] { e.Data + "\r\n" }); - this.Invoke(new AppendText(txtMainLog.AppendText), new object[] { "AssetServer: " + e.Data + "\r\n" }); - } - void proc_OpenSim_DataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e) - { - this.Invoke(new AppendText(txtOpenSim.AppendText), new object[] { e.Data + "\r\n" }); - this.Invoke(new AppendText(txtMainLog.AppendText), new object[] { "OpenSim: " + e.Data + "\r\n" }); - } - - private void btnStop_Click(object sender, EventArgs e) - { - btnStart.Enabled = false; - btnStop.Enabled = false; - - if (proc_UserServer != null) - { - txtMainLog.AppendText("Shutting down UserServer. CPU time used: " + proc_UserServer.TotalProcessorTime.ToString() + "\r\n"); - proc_UserServer.StopProcess(); - } - if (proc_GridServer != null) - { - txtMainLog.AppendText("Shutting down GridServer. CPU time used: " + proc_GridServer.TotalProcessorTime.ToString() + "\r\n"); - proc_GridServer.StopProcess(); - } - if (proc_AssetServer != null) - { - txtMainLog.AppendText("Shutting down AssetServer. CPU time used: " + proc_AssetServer.TotalProcessorTime.ToString() + "\r\n"); - proc_AssetServer.StopProcess(); - } - if (proc_OpenSim != null) - { - txtMainLog.AppendText("Shutting down OpenSim. CPU time used: " + proc_OpenSim.TotalProcessorTime.ToString() + "\r\n"); - proc_OpenSim.StopProcess(); - } - - btnStart.Enabled = true; - btnStop.Enabled = false; - - - } - - private void UpdateTabVisibility() - { - if (rbStandAloneMode.Checked) - { - if (tabLogs.TabPages.Contains(tabUserServer)) - tabLogs.TabPages.Remove(tabUserServer); - if (tabLogs.TabPages.Contains(tabGridServer)) - tabLogs.TabPages.Remove(tabGridServer); - if (tabLogs.TabPages.Contains(tabAssetServer)) - tabLogs.TabPages.Remove(tabAssetServer); - } - else - { - if (!tabLogs.TabPages.Contains(tabUserServer)) - tabLogs.TabPages.Add(tabUserServer); - if (!tabLogs.TabPages.Contains(tabGridServer)) - tabLogs.TabPages.Add(tabGridServer); - if (!tabLogs.TabPages.Contains(tabAssetServer)) - tabLogs.TabPages.Add(tabAssetServer); - } - - } - - private void rbStandAloneMode_CheckedChanged(object sender, EventArgs e) - { - UpdateTabVisibility(); - } - - private void rbGridRegionMode_CheckedChanged(object sender, EventArgs e) - { - UpdateTabVisibility(); - } - - private void rbGridServer_CheckedChanged(object sender, EventArgs e) - { - UpdateTabVisibility(); - } - - } +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace OpenSim.GUI +{ + public partial class Main : Form + { + + public ProcessManager proc_OpenSim; + public ProcessManager proc_UserServer; + public ProcessManager proc_GridServer; + public ProcessManager proc_AssetServer; + + public Main() + { + InitializeComponent(); + } + + private void Main_Load(object sender, EventArgs e) + { + txtInputUserServer.KeyPress += new KeyPressEventHandler(txtInputUserServer_KeyPress); + txtInputGridServer.KeyPress += new KeyPressEventHandler(txtInputGridServer_KeyPress); + txtInputAssetServer.KeyPress += new KeyPressEventHandler(txtInputAssetServer_KeyPress); + txtInputRegionServer.KeyPress += new KeyPressEventHandler(txtInputRegionServer_KeyPress); + + tabLogs.Selected += new TabControlEventHandler(tabLogs_Selected); + + UpdateTabVisibility(); + } + + void tabLogs_Selected(object sender, TabControlEventArgs e) + { + if (e.TabPage == tabUserServer) + txtInputUserServer.Focus(); + if (e.TabPage == tabGridServer) + txtInputGridServer.Focus(); + if (e.TabPage == tabAssetServer) + txtInputAssetServer.Focus(); + if (e.TabPage == tabRegionServer) + txtInputRegionServer.Focus(); + } + + void txtInputUserServer_KeyPress(object sender, KeyPressEventArgs e) + { + + if (e.KeyChar == 13) + { + // We got a command + e.Handled = true; + proc_UserServer.StandardInput.WriteLine(txtInputUserServer.Text + "\r\n"); + txtInputUserServer.Text = ""; + } + } + + void txtInputGridServer_KeyPress(object sender, KeyPressEventArgs e) + { + if (e.KeyChar == 13) + { + // We got a command + e.Handled = true; + proc_GridServer.StandardInput.WriteLine(txtInputGridServer.Text + "\r\n"); + txtInputGridServer.Text = ""; + } + } + + void txtInputAssetServer_KeyPress(object sender, KeyPressEventArgs e) + { + if (e.KeyChar == 13) + { + // We got a command + e.Handled = true; + proc_AssetServer.StandardInput.WriteLine(txtInputAssetServer.Text + "\r\n"); + txtInputAssetServer.Text = ""; + } + } + + void txtInputRegionServer_KeyPress(object sender, KeyPressEventArgs e) + { + if (e.KeyChar == 13) + { + // We got a command + e.Handled = true; + proc_OpenSim.StandardInput.WriteLine(txtInputRegionServer.Text + "\r\n"); + txtInputRegionServer.Text = ""; + } + } + + private void btnStart_Click(object sender, EventArgs e) + { + + // + // THIS PART NEEDS TO BE MOVED TO A SEPARATE THREAD OR A TIMER OF SOME SORT + // should not block on wait + // ALSO - IF SOME SERVICES ARE NOT CONFIGURED, POP UP CONFIGURATION BOX FOR THAT SERVICE! + // + + btnStart.Enabled = false; + btnStop.Enabled = false; + + + + if (rbGridServer.Checked) + { + // Start UserServer + proc_UserServer = new ProcessManager("OpenSim.Grid.UserServer.exe", ""); + txtMainLog.AppendText("Starting: User server" + "\r\n"); + proc_UserServer.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_UserServer_DataReceived); + proc_UserServer.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_UserServer_DataReceived); + proc_UserServer.StartProcess(); + System.Threading.Thread.Sleep(3000); + + // Start GridServer + proc_GridServer = new ProcessManager("OpenSim.Grid.GridServer.exe", ""); + txtMainLog.AppendText("Starting: Grid server" + "\r\n"); + proc_GridServer.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_GridServer_DataReceived); + proc_GridServer.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_GridServer_DataReceived); + proc_GridServer.StartProcess(); + System.Threading.Thread.Sleep(3000); + + // Start AssetServer + proc_AssetServer = new ProcessManager("OpenSim.Grid.AssetServer.exe", ""); + txtMainLog.AppendText("Starting: Asset server" + "\r\n"); + proc_AssetServer.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_AssetServer_DataReceived); + proc_AssetServer.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_AssetServer_DataReceived); + proc_AssetServer.StartProcess(); + System.Threading.Thread.Sleep(3000); + } + + // Start OpenSim + string p = ""; + if (rbGridServer.Checked) + p = "-gridmode=true"; + + proc_OpenSim = new ProcessManager("OpenSim.EXE", p); + txtMainLog.AppendText("Starting: OpenSim (Region server)" + "\r\n"); + proc_OpenSim.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_OpenSim_DataReceived); + proc_OpenSim.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_OpenSim_DataReceived); + proc_OpenSim.StartProcess(); + + btnStart.Enabled = false; + btnStop.Enabled = true; + + } + public delegate void AppendText(string Text); + void proc_UserServer_DataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e) + { + this.Invoke(new AppendText(txtUserServer.AppendText), new object[] { e.Data + "\r\n" }); + this.Invoke(new AppendText(txtMainLog.AppendText), new object[] { "UserServer: " + e.Data + "\r\n" }); + } + void proc_GridServer_DataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e) + { + this.Invoke(new AppendText(txtGridServer.AppendText), new object[] { e.Data + "\r\n" }); + this.Invoke(new AppendText(txtMainLog.AppendText), new object[] { "GridServer: " + e.Data + "\r\n" }); + } + void proc_AssetServer_DataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e) + { + this.Invoke(new AppendText(txtAssetServer.AppendText), new object[] { e.Data + "\r\n" }); + this.Invoke(new AppendText(txtMainLog.AppendText), new object[] { "AssetServer: " + e.Data + "\r\n" }); + } + void proc_OpenSim_DataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e) + { + this.Invoke(new AppendText(txtOpenSim.AppendText), new object[] { e.Data + "\r\n" }); + this.Invoke(new AppendText(txtMainLog.AppendText), new object[] { "OpenSim: " + e.Data + "\r\n" }); + } + + private void btnStop_Click(object sender, EventArgs e) + { + btnStart.Enabled = false; + btnStop.Enabled = false; + + if (proc_UserServer != null) + { + txtMainLog.AppendText("Shutting down UserServer. CPU time used: " + proc_UserServer.TotalProcessorTime.ToString() + "\r\n"); + proc_UserServer.StopProcess(); + } + if (proc_GridServer != null) + { + txtMainLog.AppendText("Shutting down GridServer. CPU time used: " + proc_GridServer.TotalProcessorTime.ToString() + "\r\n"); + proc_GridServer.StopProcess(); + } + if (proc_AssetServer != null) + { + txtMainLog.AppendText("Shutting down AssetServer. CPU time used: " + proc_AssetServer.TotalProcessorTime.ToString() + "\r\n"); + proc_AssetServer.StopProcess(); + } + if (proc_OpenSim != null) + { + txtMainLog.AppendText("Shutting down OpenSim. CPU time used: " + proc_OpenSim.TotalProcessorTime.ToString() + "\r\n"); + proc_OpenSim.StopProcess(); + } + + btnStart.Enabled = true; + btnStop.Enabled = false; + + + } + + private void UpdateTabVisibility() + { + if (rbStandAloneMode.Checked) + { + if (tabLogs.TabPages.Contains(tabUserServer)) + tabLogs.TabPages.Remove(tabUserServer); + if (tabLogs.TabPages.Contains(tabGridServer)) + tabLogs.TabPages.Remove(tabGridServer); + if (tabLogs.TabPages.Contains(tabAssetServer)) + tabLogs.TabPages.Remove(tabAssetServer); + } + else + { + if (!tabLogs.TabPages.Contains(tabUserServer)) + tabLogs.TabPages.Add(tabUserServer); + if (!tabLogs.TabPages.Contains(tabGridServer)) + tabLogs.TabPages.Add(tabGridServer); + if (!tabLogs.TabPages.Contains(tabAssetServer)) + tabLogs.TabPages.Add(tabAssetServer); + } + + } + + private void rbStandAloneMode_CheckedChanged(object sender, EventArgs e) + { + UpdateTabVisibility(); + } + + private void rbGridRegionMode_CheckedChanged(object sender, EventArgs e) + { + UpdateTabVisibility(); + } + + private void rbGridServer_CheckedChanged(object sender, EventArgs e) + { + UpdateTabVisibility(); + } + + } } \ No newline at end of file diff --git a/OpenSim/Tools/OpenSim.GUI/ProcessManager.cs b/OpenSim/Tools/OpenSim.GUI/ProcessManager.cs index 0ab074e8d2..8c019fbbfc 100644 --- a/OpenSim/Tools/OpenSim.GUI/ProcessManager.cs +++ b/OpenSim/Tools/OpenSim.GUI/ProcessManager.cs @@ -1,71 +1,71 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Diagnostics; - -namespace OpenSim.GUI -{ - public class ProcessManager : Process - { - private string m_FileName; - private string m_Arguments; - public ProcessManager(string FileName,string Arguments) - { - m_FileName = FileName; - m_Arguments = Arguments; - -// MyProc = new Process(); - StartInfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory; - Console.WriteLine("WorkingDirectory: " + StartInfo.WorkingDirectory); - StartInfo.FileName = m_FileName; - - //p.StartInfo.Arguments = ""; - StartInfo.UseShellExecute = false; - StartInfo.RedirectStandardError = true; - StartInfo.RedirectStandardInput = true; - StartInfo.RedirectStandardOutput = true; - StartInfo.CreateNoWindow = true; - - - - } - - public void StartProcess() - { - try - { - Start(); - BeginOutputReadLine(); - BeginErrorReadLine(); - } - catch (Exception ex) - { - Console.WriteLine("Exception Occurred :{0},{1}", - ex.Message, ex.StackTrace.ToString()); - } - } - public void StopProcess() - { - try - { - CancelErrorRead(); - CancelErrorRead(); - if (!HasExited) - { - StandardInput.WriteLine("quit"); - StandardInput.WriteLine("shutdown"); - System.Threading.Thread.Sleep(500); - if (!HasExited) - { - Kill(); - } - } - } - catch (Exception ex) - { - Console.WriteLine("Exception Occurred :{0},{1}", - ex.Message, ex.StackTrace.ToString()); - } - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Diagnostics; + +namespace OpenSim.GUI +{ + public class ProcessManager : Process + { + private string m_FileName; + private string m_Arguments; + public ProcessManager(string FileName,string Arguments) + { + m_FileName = FileName; + m_Arguments = Arguments; + +// MyProc = new Process(); + StartInfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory; + Console.WriteLine("WorkingDirectory: " + StartInfo.WorkingDirectory); + StartInfo.FileName = m_FileName; + + //p.StartInfo.Arguments = ""; + StartInfo.UseShellExecute = false; + StartInfo.RedirectStandardError = true; + StartInfo.RedirectStandardInput = true; + StartInfo.RedirectStandardOutput = true; + StartInfo.CreateNoWindow = true; + + + + } + + public void StartProcess() + { + try + { + Start(); + BeginOutputReadLine(); + BeginErrorReadLine(); + } + catch (Exception ex) + { + Console.WriteLine("Exception Occurred :{0},{1}", + ex.Message, ex.StackTrace.ToString()); + } + } + public void StopProcess() + { + try + { + CancelErrorRead(); + CancelErrorRead(); + if (!HasExited) + { + StandardInput.WriteLine("quit"); + StandardInput.WriteLine("shutdown"); + System.Threading.Thread.Sleep(500); + if (!HasExited) + { + Kill(); + } + } + } + catch (Exception ex) + { + Console.WriteLine("Exception Occurred :{0},{1}", + ex.Message, ex.StackTrace.ToString()); + } + } + } +} diff --git a/OpenSim/Tools/OpenSim.GUI/Program.cs b/OpenSim/Tools/OpenSim.GUI/Program.cs index a849b1bffd..3766ee6149 100644 --- a/OpenSim/Tools/OpenSim.GUI/Program.cs +++ b/OpenSim/Tools/OpenSim.GUI/Program.cs @@ -1,20 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Windows.Forms; - -namespace OpenSim.GUI -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Main()); - } - } +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace OpenSim.GUI +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Main()); + } + } } \ No newline at end of file diff --git a/OpenSim/Tools/OpenSim.GUI/Properties/AssemblyInfo.cs b/OpenSim/Tools/OpenSim.GUI/Properties/AssemblyInfo.cs index 3e86b1ced0..adc22857a3 100644 --- a/OpenSim/Tools/OpenSim.GUI/Properties/AssemblyInfo.cs +++ b/OpenSim/Tools/OpenSim.GUI/Properties/AssemblyInfo.cs @@ -1,33 +1,33 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("OpenSim.GUI")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.GUI")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("c8dbda49-66bd-476b-93b3-71774870b73e")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.GUI")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OpenSim.GUI")] +[assembly: AssemblyCopyright("Copyright © 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c8dbda49-66bd-476b-93b3-71774870b73e")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Tools/OpenSim.GUI/Properties/Resources.Designer.cs b/OpenSim/Tools/OpenSim.GUI/Properties/Resources.Designer.cs index f7de4f0501..33e67d416a 100644 --- a/OpenSim/Tools/OpenSim.GUI/Properties/Resources.Designer.cs +++ b/OpenSim/Tools/OpenSim.GUI/Properties/Resources.Designer.cs @@ -1,71 +1,71 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.312 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace OpenSim.GUI.Properties -{ - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OpenSim.GUI.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.312 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace OpenSim.GUI.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OpenSim.GUI.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/OpenSim/Tools/OpenSim.GUI/Properties/Settings.Designer.cs b/OpenSim/Tools/OpenSim.GUI/Properties/Settings.Designer.cs index e23862a275..dd1db86566 100644 --- a/OpenSim/Tools/OpenSim.GUI/Properties/Settings.Designer.cs +++ b/OpenSim/Tools/OpenSim.GUI/Properties/Settings.Designer.cs @@ -1,30 +1,30 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.312 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace OpenSim.GUI.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.312 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace OpenSim.GUI.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/OpenSim/Tools/OpenSim.GUI/frmConfiguration.Designer.cs b/OpenSim/Tools/OpenSim.GUI/frmConfiguration.Designer.cs index 1777fbc143..bba93611db 100644 --- a/OpenSim/Tools/OpenSim.GUI/frmConfiguration.Designer.cs +++ b/OpenSim/Tools/OpenSim.GUI/frmConfiguration.Designer.cs @@ -1,61 +1,61 @@ -namespace OpenSim.GUI -{ - partial class frmConfiguration - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmConfiguration)); - this.textBox1 = new System.Windows.Forms.TextBox(); - this.SuspendLayout(); - // - // textBox1 - // - this.textBox1.Location = new System.Drawing.Point(12, 12); - this.textBox1.Multiline = true; - this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(570, 190); - this.textBox1.TabIndex = 0; - this.textBox1.Text = resources.GetString("textBox1.Text"); - // - // frmConfiguration - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(664, 413); - this.Controls.Add(this.textBox1); - this.Name = "frmConfiguration"; - this.Text = "Configuration"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TextBox textBox1; - } +namespace OpenSim.GUI +{ + partial class frmConfiguration + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmConfiguration)); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(12, 12); + this.textBox1.Multiline = true; + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(570, 190); + this.textBox1.TabIndex = 0; + this.textBox1.Text = resources.GetString("textBox1.Text"); + // + // frmConfiguration + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(664, 413); + this.Controls.Add(this.textBox1); + this.Name = "frmConfiguration"; + this.Text = "Configuration"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox textBox1; + } } \ No newline at end of file diff --git a/OpenSim/Tools/OpenSim.GUI/frmConfiguration.cs b/OpenSim/Tools/OpenSim.GUI/frmConfiguration.cs index 9acf3054ac..c305657aee 100644 --- a/OpenSim/Tools/OpenSim.GUI/frmConfiguration.cs +++ b/OpenSim/Tools/OpenSim.GUI/frmConfiguration.cs @@ -1,18 +1,18 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; - -namespace OpenSim.GUI -{ - public partial class frmConfiguration : Form - { - public frmConfiguration() - { - InitializeComponent(); - } - } +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace OpenSim.GUI +{ + public partial class frmConfiguration : Form + { + public frmConfiguration() + { + InitializeComponent(); + } + } } \ No newline at end of file