Some more work on SceneObject/primitive rewrites (AllNewSceneObjectGroup2 /Part2).

Updated the JavaVM to a later version I did (basically some clean up and a little bit more functional).
Added SendLoadURL method to IClientAPI.
afrisby
MW 2007-08-01 16:50:20 +00:00
parent 2e6505f38e
commit edc572dacf
19 changed files with 580 additions and 135 deletions

View File

@ -48,7 +48,7 @@ namespace OpenSim.Region.Capabilities
private string m_requestPath = "0000/";
private string m_mapLayerPath = "0001/";
private string m_newInventory = "0002/";
// private string m_requestTexture = "0003/";
//private string m_requestTexture = "0003/";
private string m_notecardUpdatePath = "0004/";
//private string eventQueue = "0100/";
private BaseHttpServer httpListener;
@ -79,6 +79,7 @@ namespace OpenSim.Region.Capabilities
httpListener.AddStreamHandler( new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST", capsBase + m_newInventory, this.NewAgentInventoryRequest));
AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest);
//AddLegacyCapsHandler(httpListener, m_requestTexture , RequestTexture);
AddLegacyCapsHandler(httpListener, m_notecardUpdatePath, NoteCardAgentInventory);
}
@ -116,7 +117,6 @@ namespace OpenSim.Region.Capabilities
string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath;
caps.MapLayer = capsBaseUrl + m_mapLayerPath;
caps.NewFileAgentInventory = capsBaseUrl + m_newInventory;
//caps.RequestTextureDownload = capsBaseUrl + m_requestTexture;
caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath;
return caps;
}
@ -299,7 +299,7 @@ namespace OpenSim.Region.Capabilities
private LLUUID newAssetID;
private LLUUID inventoryItemID;
private BaseHttpServer httpListener;
private bool SaveImages = false;
private bool SaveAssets = false;
private string m_assetName = "";
/// <summary>
@ -338,8 +338,8 @@ namespace OpenSim.Region.Capabilities
httpListener.RemoveStreamHandler("POST", uploaderPath);
if(this.SaveImages)
this.SaveImageToFile(m_assetName + ".jp2", data);
if(this.SaveAssets)
this.SaveAssetToFile(m_assetName + ".jp2", data);
if (OnUpLoad != null)
{
@ -349,7 +349,7 @@ namespace OpenSim.Region.Capabilities
return res;
}
private void SaveImageToFile(string filename, byte[] data)
private void SaveAssetToFile(string filename, byte[] data)
{
FileStream fs = File.Create(filename);
BinaryWriter bw = new BinaryWriter(fs);
@ -360,3 +360,4 @@ namespace OpenSim.Region.Capabilities
}
}
}

View File

@ -6,9 +6,10 @@ namespace OpenSim.Region.Capabilities
public string MapLayer = "";
public string NewFileAgentInventory = "";
//public string EventQueueGet = "";
//public string RequestTextureDownload = "";
//public string ChatSessionRequest = "";
// public string RequestTextureDownload = "";
// public string ChatSessionRequest = "";
public string UpdateNotecardAgentInventory = "";
// public string ParcelVoiceInfoRequest = "";
public LLSDCapsDetails()
{
@ -16,3 +17,5 @@ namespace OpenSim.Region.Capabilities
}
}
}

View File

@ -211,5 +211,6 @@ namespace OpenSim.Framework.Interfaces
void SendNameReply(LLUUID profileId, string firstname, string lastname);
void SendAlertMessage(string message);
void SendAgentAlertMessage(string message, bool modal);
void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url);
}
}

View File

@ -142,5 +142,8 @@ namespace OpenSim.Framework
public virtual void SendNameReply(LLUUID profileId, string firstname, string lastname){}
public void SendAlertMessage(string message) { }
public void SendAgentAlertMessage(string message, bool modal) { }
public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url) { }
}
}

View File

@ -658,6 +658,19 @@ namespace OpenSim.Region.ClientStack
OutPacket(alertPack);
}
public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url)
{
LoadURLPacket loadURL = new LoadURLPacket();
loadURL.Data.ObjectName = Helpers.StringToField(objectname);
loadURL.Data.ObjectID = objectID;
loadURL.Data.OwnerID = ownerID;
loadURL.Data.OwnerIsGroup = groupOwned;
loadURL.Data.Message = Helpers.StringToField(message);
loadURL.Data.URL = Helpers.StringToField(url);
OutPacket(loadURL);
}
#region Appearance/ Wearables Methods
/// <summary>

View File

@ -15,6 +15,7 @@ namespace OpenSim.Region.Communications.Local
private NetworkServersInfo serversInfo;
private uint defaultHomeX ;
private uint defaultHomeY;
public LocalUserServices(CommunicationsLocal parent, NetworkServersInfo serversData)
{
m_Parent = parent;

View File

@ -152,7 +152,6 @@ namespace OpenSim.Region.Communications.OGS1
{
return this.regions[regionHandle];
}
//TODO not a region in this instance so ask remote grid server
Hashtable requestData = new Hashtable();
requestData["region_handle"] = regionHandle.ToString();

View File

@ -23,7 +23,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <summary>
///
/// </summary>
public int primCount
public int PrimCount
{
get
{
@ -99,7 +99,7 @@ namespace OpenSim.Region.Environment.Scenes
{
foreach (AllNewSceneObjectPart2 part in this.m_parts.Values)
{
if (part.m_localID == localID)
if (part.LocalID == localID)
{
return part;
}
@ -185,7 +185,7 @@ namespace OpenSim.Region.Environment.Scenes
AllNewSceneObjectPart2 part = this.GetChildPrim(localID);
if (part != null)
{
if (part.uuid == this.m_rootPart.uuid)
if (part.UUID == this.m_rootPart.UUID)
{
this.UpdateRootPosition(pos);
}
@ -210,7 +210,7 @@ namespace OpenSim.Region.Environment.Scenes
foreach (AllNewSceneObjectPart2 obPart in this.m_parts.Values)
{
if (obPart.uuid != this.m_rootPart.uuid)
if (obPart.UUID != this.m_rootPart.UUID)
{
obPart.OffsetPosition = obPart.OffsetPosition + diff;
}
@ -244,7 +244,7 @@ namespace OpenSim.Region.Environment.Scenes
AllNewSceneObjectPart2 part = this.GetChildPrim(localID);
if (part != null)
{
if (part.uuid == this.m_rootPart.uuid)
if (part.UUID == this.m_rootPart.UUID)
{
this.UpdateRootRotation(rot);
}
@ -262,7 +262,7 @@ namespace OpenSim.Region.Environment.Scenes
foreach (AllNewSceneObjectPart2 prim in this.m_parts.Values)
{
if (prim.uuid != this.m_rootPart.uuid)
if (prim.UUID != this.m_rootPart.UUID)
{
Vector3 axPos = new Vector3(prim.OffsetPosition.X, prim.OffsetPosition.Y, prim.OffsetPosition.Z);
axPos = oldParentRot * axPos;
@ -283,8 +283,8 @@ namespace OpenSim.Region.Environment.Scenes
private void SetPartAsRoot(AllNewSceneObjectPart2 part)
{
this.m_rootPart = part;
this.m_uuid = part.uuid;
this.m_localId = part.m_localID;
this.m_uuid = part.UUID;
this.m_localId = part.LocalID;
}
/// <summary>

View File

@ -14,21 +14,15 @@ namespace OpenSim.Region.Environment.Scenes
{
private const uint FULL_MASK_PERMISSIONS = 2147483647;
private uint m_flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128;
private ulong m_regionHandle;
public string SitName = "";
public string TouchName = "";
public string Text = "";
public LLUUID CreatorID;
public LLUUID OwnerID;
public LLUUID GroupID;
public LLUUID LastOwnerID;
public Int32 CreationDate;
public LLUUID uuid;
public uint m_localID;
public uint ParentID = 0;
public uint OwnerMask = FULL_MASK_PERMISSIONS;
@ -43,6 +37,33 @@ namespace OpenSim.Region.Environment.Scenes
#region Properties
protected LLUUID m_uuid;
public LLUUID UUID
{
get
{
return m_uuid;
}
set
{
value = m_uuid;
}
}
protected uint m_localID;
public uint LocalID
{
get
{
return m_localID;
}
set
{
m_localID = value;
}
}
protected string m_name;
/// <summary>
///
@ -53,6 +74,32 @@ namespace OpenSim.Region.Environment.Scenes
set { m_name = value; }
}
protected LLObject.ObjectFlags m_flags = (LLObject.ObjectFlags) 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128;
public uint ObjectFlags
{
get
{
return (uint)m_flags;
}
set
{
m_flags =(LLObject.ObjectFlags) value;
}
}
protected ulong m_regionHandle;
public ulong RegionHandle
{
get
{
return m_regionHandle;
}
set
{
m_regionHandle = value;
}
}
protected LLVector3 m_offset;
public LLVector3 OffsetPosition
{
@ -79,6 +126,48 @@ namespace OpenSim.Region.Environment.Scenes
}
}
protected LLVector3 m_velocity;
/// <summary></summary>
public LLVector3 Velocity
{
get
{
return m_velocity;
}
set
{
m_velocity = value;
}
}
protected LLVector3 m_angularVelocity;
/// <summary></summary>
public LLVector3 AngularVelocity
{
get
{
return m_angularVelocity;
}
set
{
m_angularVelocity = value;
}
}
protected LLVector3 m_acceleration;
/// <summary></summary>
public LLVector3 Acceleration
{
get
{
return m_acceleration;
}
set
{
m_acceleration = value;
}
}
private string m_description = "";
public string Description
{
@ -123,14 +212,14 @@ namespace OpenSim.Region.Environment.Scenes
this.OwnerID = ownerID;
this.CreatorID = this.OwnerID;
this.LastOwnerID = LLUUID.Zero;
this.uuid = LLUUID.Random();
this.m_localID = (uint)(localID);
this.UUID = LLUUID.Random();
this.LocalID = (uint)(localID);
this.m_Shape = shape;
this.OffsetPosition = position;
//temporary code just so the m_flags field doesn't give a compiler warning
if (m_flags == 1)
if (m_flags ==LLObject.ObjectFlags.AllowInventoryDrop)
{
}

View File

@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Serialization;
using Axiom.Math;
using libsecondlife;
using libsecondlife.Packets;
@ -27,6 +29,7 @@ namespace OpenSim.Region.Environment.Scenes
public LLUUID CreatorID;
public LLUUID OwnerID;
public LLUUID LastOwnerID;
public Int32 CreationDate;
public uint ParentID = 0;

View File

@ -550,7 +550,7 @@ namespace OpenSim.Region.Environment.Scenes
m_estateManager.sendRegionHandshake(client);
CreateAndAddScenePresence(client);
m_LandManager.sendParcelOverlay(client);
// commsManager.UserProfiles.AddNewUser(client.AgentId);
//commsManager.UserProfiles.AddNewUser(client.AgentId);
}
protected virtual void SubscribeToClientEvents(IClientAPI client)

View File

@ -27,6 +27,9 @@
*/
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.Framework.Interfaces;
@ -93,7 +96,6 @@ namespace OpenSim.Region.Environment.Scenes
this.CreateRootFromShape(ownerID, localID, shape, pos);
registerEvents();
}
/// <summary>
@ -182,6 +184,14 @@ namespace OpenSim.Region.Environment.Scenes
return dupe;
}
/// <summary>
///
/// </summary>
public void Serialise()
{
}
/// <summary>
///
/// </summary>

View File

@ -443,10 +443,13 @@ namespace OpenSim.Region.Environment.Scenes
foreach (ScenePresence avatar in this.m_scene.RequestAvatarList())
{
this.SendFullUpdateToOtherClient(avatar);
if (avatar.LocalId != this.LocalId)
{
avatar.SendFullUpdateToOtherClient(this);
avatar.SendAppearanceToOtherAgent(this);
}
}
}
/// <summary>
///

View File

@ -35,6 +35,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public class ClassInstance : Object
{
public int size;
public ClassRecord ClassRec;
public Dictionary<string, BaseType> Fields = new Dictionary<string, BaseType>();
public ClassInstance()

View File

@ -30,6 +30,7 @@ using System.IO;
using System.Collections.Generic;
using System.Text;
using OpenSim.Region.Scripting.EmbeddedJVM.Types;
using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
namespace OpenSim.Region.Scripting.EmbeddedJVM
{
@ -60,7 +61,11 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public ClassInstance CreateNewInstance()
{
return new ClassInstance();
ClassInstance classInst = new ClassInstance();
classInst.ClassRec = this;
//TODO: set fields
return classInst;
}
public void LoadClassFromFile(string fileName)
@ -75,20 +80,20 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{
int i = 0;
i += 4;
_minorVersion = (ushort)((data[i++] << 8) + data[i++] );
_majorVersion = (ushort)((data[i++] << 8) + data[i++] );
_constantPoolCount = (ushort)((data[i++] << 8) + data[i++] );
// Console.WriteLine("there should be " + _constantPoolCount + " items in the pool");
for (int count = 0; count < _constantPoolCount -1 ; count++)
_minorVersion = (ushort)((data[i++] << 8) + data[i++]);
_majorVersion = (ushort)((data[i++] << 8) + data[i++]);
_constantPoolCount = (ushort)((data[i++] << 8) + data[i++]);
Console.WriteLine("there should be " + _constantPoolCount + " items in the pool");
for (int count = 0; count < (_constantPoolCount - 1); count++)
{
//read in the constant pool
byte pooltype = data[i++];
//Console.WriteLine("#" +count +": new constant type = " +pooltype);
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++] );
ushort uLength = (ushort)((data[i++] << 8) + data[i++]);
// Console.WriteLine("new utf8 type, length is " + uLength);
PoolUtf8 utf8 = new PoolUtf8();
@ -97,11 +102,18 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
break;
case 3: //Int
break;
case 4: //Float
break;
case 7: //Class
PoolClass pClass = new PoolClass(this);
pClass.readValue(data, ref i);
this._constantsPool.Add(pClass);
break;
case 9: //FieldRef
PoolFieldRef pField = new PoolFieldRef(this);
pField.readValue(data, ref i);
this._constantsPool.Add(pField);
break;
case 10: //Method
PoolMethodRef pMeth = new PoolMethodRef(this);
pMeth.readValue(data, ref i);
@ -115,9 +127,9 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
}
_accessFlags = (ushort)((data[i++] << 8) + data[i++] );
_thisClass = (ushort)((data[i++] << 8) + data[i++] );
_supperClass = (ushort)((data[i++] << 8) + data[i++] );
_accessFlags = (ushort)((data[i++] << 8) + data[i++]);
_thisClass = (ushort)((data[i++] << 8) + data[i++]);
_supperClass = (ushort)((data[i++] << 8) + data[i++]);
if (this._constantsPool[this._thisClass - 1] is PoolClass)
{
@ -126,8 +138,16 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
_interfaceCount = (ushort)((data[i++] << 8) + data[i++]);
//should now read in the info for each interface
_fieldCount = (ushort)((data[i++] << 8) + data[i++]);
//should now read in the info for each field
for (int count = 0; count < _fieldCount; count++)
{
FieldInfo fieldInf = new FieldInfo(this);
fieldInf.ReadData(data, ref i);
this._fieldList.Add(fieldInf);
}
_methodCount = (ushort)((data[i++] << 8) + data[i++]);
for (int count = 0; count < _methodCount; count++)
{
@ -149,9 +169,9 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{
for (int count = 0; count < _methodCount; count++)
{
if (this._constantsPool[this._methodsList[count].NameIndex-1] is PoolUtf8)
if (this._constantsPool[this._methodsList[count].NameIndex - 1] is PoolUtf8)
{
if (((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex-1]).Value == methodName)
if (((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value == methodName)
{
//Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value);
thread.SetPC(this._methodsList[count].CodePointer);
@ -175,9 +195,15 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
Console.WriteLine("Access flags: " + _accessFlags);
Console.WriteLine("This class: " + _thisClass );
Console.WriteLine("This class: " + _thisClass);
Console.WriteLine("Super class: " + _supperClass);
for (int count = 0; count < _fieldCount; count++)
{
Console.WriteLine();
this._fieldList[count].Print();
}
for (int count = 0; count < _methodCount; count++)
{
Console.WriteLine();
@ -215,18 +241,18 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{
public string Value = "";
public void readValue(byte[] data,ref int pointer , int length)
public void readValue(byte[] data, ref int pointer, int length)
{
for (int i = 0; i < length; i++)
{
int a =(int) data[pointer++];
int a = (int)data[pointer++];
if ((a & 0x80) == 0)
{
Value = Value + (char)a;
}
else if ((a & 0x20) == 0)
{
int b = (int) data[pointer++];
int b = (int)data[pointer++];
Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f));
}
else
@ -263,7 +289,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public void readValue(byte[] data, ref int pointer)
{
namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] );
namePointer = (ushort)((data[pointer++] << 8) + data[pointer++]);
}
public override void Print()
@ -275,6 +301,33 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
}
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._constantsPool[nameTypePointer - 1]);
this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]);
Console.WriteLine("FieldRef type: " + classPointer + " , " + nameTypePointer);
}
}
public class PoolMethodRef : PoolItem
{
public ushort classPointer = 0;
@ -317,16 +370,16 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public void readValue(byte[] data, ref int pointer)
{
namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] );
typePointer = (ushort)((data[pointer++] << 8) + data[pointer++] );
namePointer = (ushort)((data[pointer++] << 8) + data[pointer++]);
typePointer = (ushort)((data[pointer++] << 8) + data[pointer++]);
}
public override void Print()
{
Name = ((PoolUtf8)this.parent._constantsPool[namePointer-1]);
Type = ((PoolUtf8)this.parent._constantsPool[typePointer-1]);
Console.Write("Named type: " + namePointer + " , " + typePointer );
Console.WriteLine(" // "+ ((PoolUtf8)this.parent._constantsPool[namePointer-1]).Value);
Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]);
Type = ((PoolUtf8)this.parent._constantsPool[typePointer - 1]);
Console.Write("Named type: " + namePointer + " , " + typePointer);
Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value);
}
}
@ -361,7 +414,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
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++)
for (int i = 0; i < AttributeCount; i++)
{
MethodAttribute attri = new MethodAttribute(this.parent);
attri.ReadData(data, ref pointer);
@ -373,8 +426,8 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{
Console.WriteLine("Method Info Struct: ");
Console.WriteLine("AccessFlags: " + AccessFlags);
Console.WriteLine("NameIndex: " + NameIndex +" // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value);
Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[DescriptorIndex-1]).Value);
Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value);
Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent._constantsPool[DescriptorIndex - 1]).Value);
Console.WriteLine("Attribute Count:" + AttributeCount);
for (int i = 0; i < AttributeCount; i++)
{
@ -427,7 +480,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public void Print()
{
Console.WriteLine("Method Attribute: ");
Console.WriteLine("Name Index: " + NameIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value);
Console.WriteLine("Name Index: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value);
Console.WriteLine("Length: " + Length);
Console.WriteLine("MaxStack: " + MaxStack);
Console.WriteLine("MaxLocals: " + MaxLocals);
@ -483,13 +536,97 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
}
private class FieldInfo
public class FieldInfo
{
public void ReadData(byte[] data, ref int i)
public ushort AccessFlags = 0;
public ushort NameIndex = 0;
public string Name = "";
public ushort DescriptorIndex = 0;
public ushort AttributeCount = 0;
public List<FieldAttribute> Attributes = new List<FieldAttribute>();
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._constantsPool[NameIndex - 1]).Value);
Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent._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._constantsPool[DescriptorIndex - 1]).Value)
{
case "I":
Int newin = new Int();
this.parent.StaticFields.Add(((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value, newin);
break;
case "F":
Float newfl = new Float();
this.parent.StaticFields.Add(((PoolUtf8)this.parent._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._constantsPool[NameIndex - 1]).Value);
}
}
}
private class AttributeInfo
{
public void ReadData(byte[] data, ref int i)

View File

@ -42,66 +42,66 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
bool result = false;
switch (opcode)
{
case 2:
Int m_int= new Int();
case (byte)(byte)OpCode.iconst_m1:
Int m_int = new Int();
m_int.mValue = -1;
this._mThread.currentFrame.OpStack.Push(m_int);
result = true;
break;
case 3:
m_int= new Int();
case (byte)(byte)OpCode.iconst_0:
m_int = new Int();
m_int.mValue = 0;
this._mThread.currentFrame.OpStack.Push(m_int);
result = true;
break;
case 4:
case (byte)(byte)OpCode.iconst_1:
m_int = new Int();
m_int.mValue = 1;
this._mThread.currentFrame.OpStack.Push(m_int);
result = true;
break;
case 5:
case (byte)(byte)OpCode.iconst_2:
m_int = new Int();
m_int.mValue = 2;
this._mThread.currentFrame.OpStack.Push(m_int);
result = true;
break;
case 6:
case (byte)(byte)OpCode.iconst_3:
m_int = new Int();
m_int.mValue = 3;
this._mThread.currentFrame.OpStack.Push(m_int);
break;
case 7:
case (byte)(byte)OpCode.iconst_4:
m_int = new Int();
m_int.mValue = 4;
this._mThread.currentFrame.OpStack.Push(m_int);
result = true;
break;
case 8:
case (byte)OpCode.iconst_5:
m_int = new Int();
m_int.mValue = 5;
this._mThread.currentFrame.OpStack.Push(m_int);
result = true;
break;
case 11:
case (byte)OpCode.fconst_0:
Float m_float = new Float();
m_float.mValue = 0.0f;
this._mThread.currentFrame.OpStack.Push(m_float);
result = true;
break;
case 12:
case (byte)OpCode.fconst_1:
m_float = new Float();
m_float.mValue = 1.0f;
this._mThread.currentFrame.OpStack.Push(m_float);
result = true;
break;
case 13:
case (byte)OpCode.fconst_2:
m_float = new Float();
m_float.mValue = 2.0f;
this._mThread.currentFrame.OpStack.Push(m_float);
result = true;
break;
case 16:
case (byte)OpCode.bipush: //is this right? this should be pushing a byte onto stack not int?
int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC];
Int pushInt = new Int();
pushInt.mValue = pushvalue;
@ -109,7 +109,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
this._mThread.PC++;
result = true;
break;
case 17:
case (byte)OpCode.sipush:
short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
Int pushInt2 = new Int();
pushInt2.mValue = pushvalue2;
@ -117,7 +117,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
this._mThread.PC += 2;
result = true;
break;
case 23:
case (byte)OpCode.fload:
short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]));
Float fload = new Float();
if (this._mThread.currentFrame.LocalVariables[findex1] != null)
@ -131,7 +131,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
this._mThread.PC++;
result = true;
break;
case 26:
case (byte)OpCode.iload_0:
if (this._mThread.currentFrame.LocalVariables[0] != null)
{
if (this._mThread.currentFrame.LocalVariables[0] is Int)
@ -143,7 +143,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 27:
case (byte)OpCode.iload_1:
if (this._mThread.currentFrame.LocalVariables[1] != null)
{
if (this._mThread.currentFrame.LocalVariables[1] is Int)
@ -155,7 +155,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 34:
case (byte)OpCode.fload_0:
if (this._mThread.currentFrame.LocalVariables[0] != null)
{
if (this._mThread.currentFrame.LocalVariables[0] is Float)
@ -167,7 +167,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 35:
case (byte)OpCode.fload_1:
if (this._mThread.currentFrame.LocalVariables[1] != null)
{
if (this._mThread.currentFrame.LocalVariables[1] is Float)
@ -179,7 +179,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 36:
case (byte)OpCode.fload_2:
if (this._mThread.currentFrame.LocalVariables[2] != null)
{
if (this._mThread.currentFrame.LocalVariables[2] is Float)
@ -191,7 +191,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 37:
case (byte)OpCode.fload_3:
if (this._mThread.currentFrame.LocalVariables[3] != null)
{
if (this._mThread.currentFrame.LocalVariables[3] is Float)
@ -203,8 +203,18 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 56:
short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] ));
case (byte)OpCode.istore:
short findex3 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]));
BaseType istor = this._mThread.currentFrame.OpStack.Pop();
if (istor is Int)
{
this._mThread.currentFrame.LocalVariables[findex3] = (Int)istor;
}
this._mThread.PC++;
result = true;
break;
case (byte)OpCode.fstore:
short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]));
BaseType fstor = this._mThread.currentFrame.OpStack.Pop();
if (fstor is Float)
{
@ -213,7 +223,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
this._mThread.PC++;
result = true;
break;
case 59:
case (byte)OpCode.istore_0:
BaseType baset = this._mThread.currentFrame.OpStack.Pop();
if (baset is Int)
{
@ -221,7 +231,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 60:
case (byte)OpCode.istore_1:
baset = this._mThread.currentFrame.OpStack.Pop();
if (baset is Int)
{
@ -229,7 +239,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 67:
case (byte)OpCode.fstore_0:
baset = this._mThread.currentFrame.OpStack.Pop();
if (baset is Float)
{
@ -237,7 +247,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 68:
case (byte)OpCode.fstore_1:
baset = this._mThread.currentFrame.OpStack.Pop();
if (baset is Float)
{
@ -245,7 +255,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 69:
case (byte)OpCode.fstore_2:
baset = this._mThread.currentFrame.OpStack.Pop();
if (baset is Float)
{
@ -253,7 +263,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 70:
case (byte)OpCode.fstore_3:
baset = this._mThread.currentFrame.OpStack.Pop();
if (baset is Float)
{
@ -261,11 +271,11 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 87:
case (byte)OpCode.pop:
this._mThread.currentFrame.OpStack.Pop();
result = true;
break;
case 98:
case (byte)OpCode.fadd:
BaseType bf2 = this._mThread.currentFrame.OpStack.Pop();
BaseType bf1 = this._mThread.currentFrame.OpStack.Pop();
if (bf1 is Float && bf2 is Float)
@ -276,7 +286,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 102:
case (byte)OpCode.fsub:
BaseType bsf2 = this._mThread.currentFrame.OpStack.Pop();
BaseType bsf1 = this._mThread.currentFrame.OpStack.Pop();
if (bsf1 is Float && bsf2 is Float)
@ -287,7 +297,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 104: //check the order of the two values off the stack is correct
case (byte)OpCode.imul: //check the order of the two values off the stack is correct
BaseType bs2 = this._mThread.currentFrame.OpStack.Pop();
BaseType bs1 = this._mThread.currentFrame.OpStack.Pop();
if (bs1 is Int && bs2 is Int)
@ -298,18 +308,18 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 132:
case (byte)OpCode.iinc:
if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] != null)
{
if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] is Int)
{
((Int)this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]]).mValue += (sbyte) GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1];
((Int)this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]]).mValue += (sbyte)GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1];
}
}
this._mThread.PC += 2;
result = true;
break;
case 139:
case (byte)OpCode.f2i:
BaseType conv1 = this._mThread.currentFrame.OpStack.Pop();
if (conv1 is Float)
{
@ -319,7 +329,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 149:
case (byte)OpCode.fcmpl:
BaseType flcom2 = this._mThread.currentFrame.OpStack.Pop();
BaseType flcom1 = this._mThread.currentFrame.OpStack.Pop();
if (flcom1 is Float && flcom2 is Float)
@ -341,7 +351,49 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 158:
case (byte)OpCode.fcmpg:
flcom2 = this._mThread.currentFrame.OpStack.Pop();
flcom1 = this._mThread.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._mThread.currentFrame.OpStack.Push(compres);
}
result = true;
break;
case (byte)OpCode.ifge:
short compareoffset2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
BaseType compe1 = this._mThread.currentFrame.OpStack.Pop();
if (compe1 is Int)
{
if (((Int)compe1).mValue >= 0)
{
this._mThread.PC += -1 + compareoffset2;
}
else
{
this._mThread.PC += 2;
}
}
else
{
this._mThread.PC += 2;
}
result = true;
break;
case (byte)OpCode.ifle:
short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
BaseType comp1 = this._mThread.currentFrame.OpStack.Pop();
if (comp1 is Int)
@ -361,7 +413,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 162:
case (byte)OpCode.if_icmpge:
short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
BaseType bc2 = this._mThread.currentFrame.OpStack.Pop();
BaseType bc1 = this._mThread.currentFrame.OpStack.Pop();
@ -387,7 +439,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 164:
case (byte)OpCode.if_icmple:
short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
BaseType bcl2 = this._mThread.currentFrame.OpStack.Pop();
BaseType bcl1 = this._mThread.currentFrame.OpStack.Pop();
@ -413,11 +465,83 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
}
result = true;
break;
case 167:
short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]);
case (byte)OpCode._goto:
short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
this._mThread.PC += -1 + offset;
result = true;
break;
case (byte)OpCode.getstatic:
short fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
if (this._mThread.currentClass._constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef)
{
if (((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value)
{
//from this class
if (this._mThread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value))
{
if (this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float)
{
Float retFloat = new Float();
retFloat.mValue = ((Float)this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue;
this._mThread.currentFrame.OpStack.Push(retFloat);
}
else if (this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int)
{
Int retInt = new Int();
retInt.mValue = ((Int)this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue;
// Console.WriteLine("getting static field, " + retInt.mValue);
this._mThread.currentFrame.OpStack.Push(retInt);
}
}
}
else
{
//get from a different class
}
}
this._mThread.PC += 2;
result = true;
break;
case (byte)OpCode.putstatic:
fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
BaseType addstatic = this._mThread.currentFrame.OpStack.Pop();
if (this._mThread.currentClass._constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef)
{
if (((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value)
{
// this class
if (this._mThread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value))
{
if (addstatic is Float)
{
if (this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float)
{
Float newf = new Float();
newf.mValue = ((Float)addstatic).mValue;
this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newf;
}
}
else if (addstatic is Int)
{
if (this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._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._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newi;
}
}
}
}
else
{
// a different class
}
}
this._mThread.PC += 2;
result = true;
break;
}
return result;

View File

@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Region.Scripting.EmbeddedJVM
{
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
}
}

View File

@ -157,6 +157,7 @@ namespace SimpleApp
public void SendAlertMessage(string message) { }
public void SendAgentAlertMessage(string message, bool modal) { }
public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url) { }
public virtual void SendRegionHandshake(RegionInfo regionInfo)
{