From 76e429bb6d8f292e918d2f36f8c2c1fda48d9e96 Mon Sep 17 00:00:00 2001 From: Latif Khalifa Date: Wed, 11 May 2011 09:52:37 +0000 Subject: [PATCH] LIBOMV-899: Update message template as found in viewer 2.6 git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@3510 52acb1d6-8a22-11de-b505-999d5b087335 --- OpenMetaverse/AgentManager.cs | 18 ++- OpenMetaverse/_Packets_.cs | 224 +++++++++++++++++++++++++++++++++- data/message_template.msg | 34 +++++- 3 files changed, 270 insertions(+), 6 deletions(-) diff --git a/OpenMetaverse/AgentManager.cs b/OpenMetaverse/AgentManager.cs index a3df16ae..b8060405 100644 --- a/OpenMetaverse/AgentManager.cs +++ b/OpenMetaverse/AgentManager.cs @@ -3456,6 +3456,13 @@ namespace OpenMetaverse buttons.Add(Utils.BytesToString(button.ButtonLabel)); } + UUID ownerID = UUID.Zero; + + if (dialog.OwnerData != null && dialog.OwnerData.Length > 0) + { + ownerID = dialog.OwnerData[0].OwnerID; + } + OnScriptDialog(new ScriptDialogEventArgs(Utils.BytesToString(dialog.Data.Message), Utils.BytesToString(dialog.Data.ObjectName), dialog.Data.ImageID, @@ -3463,7 +3470,8 @@ namespace OpenMetaverse Utils.BytesToString(dialog.Data.FirstName), Utils.BytesToString(dialog.Data.LastName), dialog.Data.ChatChannel, - buttons)); + buttons, + ownerID)); } } @@ -4001,6 +4009,7 @@ namespace OpenMetaverse if (!msg.Success) { + RequestJoinGroupChat(msg.SessionID); Logger.Log("Attempt to send group chat to non-existant session for group " + msg.SessionID, Helpers.LogLevel.Info, Client); } @@ -4411,6 +4420,7 @@ namespace OpenMetaverse private readonly string m_LastName; private readonly int m_Channel; private readonly List m_ButtonLabels; + private readonly UUID m_OwnerID; /// Get the dialog message public string Message { get { return m_Message; } } @@ -4429,6 +4439,8 @@ namespace OpenMetaverse public int Channel { get { return m_Channel; } } /// Get the string labels containing the options presented in this dialog public List ButtonLabels { get { return m_ButtonLabels; } } + /// UUID of the scritped object owner + public UUID OwnerID { get { return m_OwnerID; } } /// /// Construct a new instance of the ScriptDialogEventArgs @@ -4441,8 +4453,9 @@ namespace OpenMetaverse /// The last name of the senders owner /// The communication channel the dialog was sent on /// The string labels containing the options presented in this dialog + /// UUID of the scritped object owner public ScriptDialogEventArgs(string message, string objectName, UUID imageID, - UUID objectID, string firstName, string lastName, int chatChannel, List buttons) + UUID objectID, string firstName, string lastName, int chatChannel, List buttons, UUID ownerID) { this.m_Message = message; this.m_ObjectName = objectName; @@ -4452,6 +4465,7 @@ namespace OpenMetaverse this.m_LastName = lastName; this.m_Channel = chatChannel; this.m_ButtonLabels = buttons; + this.m_OwnerID = ownerID; } } diff --git a/OpenMetaverse/_Packets_.cs b/OpenMetaverse/_Packets_.cs index 09313b75..2a83f4cf 100644 --- a/OpenMetaverse/_Packets_.cs +++ b/OpenMetaverse/_Packets_.cs @@ -32014,19 +32014,60 @@ namespace OpenMetaverse.Packets } + /// + public sealed class OwnerDataBlock : PacketBlock + { + public UUID OwnerID; + + public override int Length + { + get + { + return 16; + } + } + + public OwnerDataBlock() { } + public OwnerDataBlock(byte[] bytes, ref int i) + { + FromBytes(bytes, ref i); + } + + public override void FromBytes(byte[] bytes, ref int i) + { + try + { + OwnerID.FromBytes(bytes, i); i += 16; + } + catch (Exception) + { + throw new MalformedDataException(); + } + } + + public override void ToBytes(byte[] bytes, ref int i) + { + OwnerID.ToBytes(bytes, i); i += 16; + } + + } + public override int Length { get { - int length = 11; + int length = 12; length += Data.Length; for (int j = 0; j < Buttons.Length; j++) length += Buttons[j].Length; + for (int j = 0; j < OwnerData.Length; j++) + length += OwnerData[j].Length; return length; } } public DataBlock Data; public ButtonsBlock[] Buttons; + public OwnerDataBlock[] OwnerData; public ScriptDialogPacket() { @@ -32039,6 +32080,7 @@ namespace OpenMetaverse.Packets Header.Zerocoded = true; Data = new DataBlock(); Buttons = null; + OwnerData = null; } public ScriptDialogPacket(byte[] bytes, ref int i) : this() @@ -32064,6 +32106,14 @@ namespace OpenMetaverse.Packets } for (int j = 0; j < count; j++) { Buttons[j].FromBytes(bytes, ref i); } + count = (int)bytes[i++]; + if(OwnerData == null || OwnerData.Length != -1) { + OwnerData = new OwnerDataBlock[count]; + for(int j = 0; j < count; j++) + { OwnerData[j] = new OwnerDataBlock(); } + } + for (int j = 0; j < count; j++) + { OwnerData[j].FromBytes(bytes, ref i); } } public ScriptDialogPacket(Header head, byte[] bytes, ref int i): this() @@ -32084,6 +32134,14 @@ namespace OpenMetaverse.Packets } for (int j = 0; j < count; j++) { Buttons[j].FromBytes(bytes, ref i); } + count = (int)bytes[i++]; + if(OwnerData == null || OwnerData.Length != count) { + OwnerData = new OwnerDataBlock[count]; + for(int j = 0; j < count; j++) + { OwnerData[j] = new OwnerDataBlock(); } + } + for (int j = 0; j < count; j++) + { OwnerData[j].FromBytes(bytes, ref i); } } public override byte[] ToBytes() @@ -32092,6 +32150,8 @@ namespace OpenMetaverse.Packets length += Data.Length; length++; for (int j = 0; j < Buttons.Length; j++) { length += Buttons[j].Length; } + length++; + for (int j = 0; j < OwnerData.Length; j++) { length += OwnerData[j].Length; } if (Header.AckList != null && Header.AckList.Length > 0) { length += Header.AckList.Length * 4 + 1; } byte[] bytes = new byte[length]; int i = 0; @@ -32099,6 +32159,8 @@ namespace OpenMetaverse.Packets Data.ToBytes(bytes, ref i); bytes[i++] = (byte)Buttons.Length; for (int j = 0; j < Buttons.Length; j++) { Buttons[j].ToBytes(bytes, ref i); } + bytes[i++] = (byte)OwnerData.Length; + for (int j = 0; j < OwnerData.Length; j++) { OwnerData[j].ToBytes(bytes, ref i); } if (Header.AckList != null && Header.AckList.Length > 0) { Header.AcksToBytes(bytes, ref i); } return bytes; } @@ -32121,13 +32183,15 @@ namespace OpenMetaverse.Packets byte[] fixedBytes = new byte[fixedLength]; Header.ToBytes(fixedBytes, ref i); Data.ToBytes(fixedBytes, ref i); - fixedLength += 1; + fixedLength += 2; int ButtonsStart = 0; + int OwnerDataStart = 0; do { int variableLength = 0; int ButtonsCount = 0; + int OwnerDataCount = 0; i = ButtonsStart; while (fixedLength + variableLength + acksLength < Packet.MTU && i < Buttons.Length) { @@ -32140,6 +32204,17 @@ namespace OpenMetaverse.Packets ++i; } + i = OwnerDataStart; + while (fixedLength + variableLength + acksLength < Packet.MTU && i < OwnerData.Length) { + int blockLength = OwnerData[i].Length; + if (fixedLength + variableLength + blockLength + acksLength <= MTU) { + variableLength += blockLength; + ++OwnerDataCount; + } + else { break; } + ++i; + } + byte[] packet = new byte[fixedLength + variableLength + acksLength]; int length = fixedBytes.Length; Buffer.BlockCopy(fixedBytes, 0, packet, 0, length); @@ -32149,6 +32224,10 @@ namespace OpenMetaverse.Packets for (i = ButtonsStart; i < ButtonsStart + ButtonsCount; i++) { Buttons[i].ToBytes(packet, ref length); } ButtonsStart += ButtonsCount; + packet[length++] = (byte)OwnerDataCount; + for (i = OwnerDataStart; i < OwnerDataStart + OwnerDataCount; i++) { OwnerData[i].ToBytes(packet, ref length); } + OwnerDataStart += OwnerDataCount; + if (acksLength > 0) { Buffer.BlockCopy(ackBytes, 0, packet, length, acksLength); acksLength = 0; @@ -32156,7 +32235,8 @@ namespace OpenMetaverse.Packets packets.Add(packet); } while ( - ButtonsStart < Buttons.Length); + ButtonsStart < Buttons.Length || + OwnerDataStart < OwnerData.Length); return packets.ToArray(); } @@ -52260,16 +52340,80 @@ namespace OpenMetaverse.Packets } + /// + public sealed class TransactionInfoBlock : PacketBlock + { + public int TransactionType; + public UUID SourceID; + public bool IsSourceGroup; + public UUID DestID; + public bool IsDestGroup; + public int Amount; + public byte[] ItemDescription; + + public override int Length + { + get + { + int length = 43; + if (ItemDescription != null) { length += ItemDescription.Length; } + return length; + } + } + + public TransactionInfoBlock() { } + public TransactionInfoBlock(byte[] bytes, ref int i) + { + FromBytes(bytes, ref i); + } + + public override void FromBytes(byte[] bytes, ref int i) + { + int length; + try + { + TransactionType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SourceID.FromBytes(bytes, i); i += 16; + IsSourceGroup = (bytes[i++] != 0) ? (bool)true : (bool)false; + DestID.FromBytes(bytes, i); i += 16; + IsDestGroup = (bytes[i++] != 0) ? (bool)true : (bool)false; + Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = bytes[i++]; + ItemDescription = new byte[length]; + Buffer.BlockCopy(bytes, i, ItemDescription, 0, length); i += length; + } + catch (Exception) + { + throw new MalformedDataException(); + } + } + + public override void ToBytes(byte[] bytes, ref int i) + { + Utils.IntToBytes(TransactionType, bytes, i); i += 4; + SourceID.ToBytes(bytes, i); i += 16; + bytes[i++] = (byte)((IsSourceGroup) ? 1 : 0); + DestID.ToBytes(bytes, i); i += 16; + bytes[i++] = (byte)((IsDestGroup) ? 1 : 0); + Utils.IntToBytes(Amount, bytes, i); i += 4; + bytes[i++] = (byte)ItemDescription.Length; + Buffer.BlockCopy(ItemDescription, 0, bytes, i, ItemDescription.Length); i += ItemDescription.Length; + } + + } + public override int Length { get { int length = 10; length += MoneyData.Length; + length += TransactionInfo.Length; return length; } } public MoneyDataBlock MoneyData; + public TransactionInfoBlock TransactionInfo; public MoneyBalanceReplyPacket() { @@ -52281,6 +52425,7 @@ namespace OpenMetaverse.Packets Header.Reliable = true; Header.Zerocoded = true; MoneyData = new MoneyDataBlock(); + TransactionInfo = new TransactionInfoBlock(); } public MoneyBalanceReplyPacket(byte[] bytes, ref int i) : this() @@ -52298,6 +52443,7 @@ namespace OpenMetaverse.Packets bytes = zeroBuffer; } MoneyData.FromBytes(bytes, ref i); + TransactionInfo.FromBytes(bytes, ref i); } public MoneyBalanceReplyPacket(Header head, byte[] bytes, ref int i): this() @@ -52310,17 +52456,20 @@ namespace OpenMetaverse.Packets { Header = header; MoneyData.FromBytes(bytes, ref i); + TransactionInfo.FromBytes(bytes, ref i); } public override byte[] ToBytes() { int length = 10; length += MoneyData.Length; + length += TransactionInfo.Length; if (Header.AckList != null && Header.AckList.Length > 0) { length += Header.AckList.Length * 4 + 1; } byte[] bytes = new byte[length]; int i = 0; Header.ToBytes(bytes, ref i); MoneyData.ToBytes(bytes, ref i); + TransactionInfo.ToBytes(bytes, ref i); if (Header.AckList != null && Header.AckList.Length > 0) { Header.AcksToBytes(bytes, ref i); } return bytes; } @@ -52438,6 +52587,68 @@ namespace OpenMetaverse.Packets } + /// + public sealed class TransactionInfoBlock : PacketBlock + { + public int TransactionType; + public UUID SourceID; + public bool IsSourceGroup; + public UUID DestID; + public bool IsDestGroup; + public int Amount; + public byte[] ItemDescription; + + public override int Length + { + get + { + int length = 43; + if (ItemDescription != null) { length += ItemDescription.Length; } + return length; + } + } + + public TransactionInfoBlock() { } + public TransactionInfoBlock(byte[] bytes, ref int i) + { + FromBytes(bytes, ref i); + } + + public override void FromBytes(byte[] bytes, ref int i) + { + int length; + try + { + TransactionType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SourceID.FromBytes(bytes, i); i += 16; + IsSourceGroup = (bytes[i++] != 0) ? (bool)true : (bool)false; + DestID.FromBytes(bytes, i); i += 16; + IsDestGroup = (bytes[i++] != 0) ? (bool)true : (bool)false; + Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = bytes[i++]; + ItemDescription = new byte[length]; + Buffer.BlockCopy(bytes, i, ItemDescription, 0, length); i += length; + } + catch (Exception) + { + throw new MalformedDataException(); + } + } + + public override void ToBytes(byte[] bytes, ref int i) + { + Utils.IntToBytes(TransactionType, bytes, i); i += 4; + SourceID.ToBytes(bytes, i); i += 16; + bytes[i++] = (byte)((IsSourceGroup) ? 1 : 0); + DestID.ToBytes(bytes, i); i += 16; + bytes[i++] = (byte)((IsDestGroup) ? 1 : 0); + Utils.IntToBytes(Amount, bytes, i); i += 4; + bytes[i++] = (byte)ItemDescription.Length; + Buffer.BlockCopy(ItemDescription, 0, bytes, i, ItemDescription.Length); i += ItemDescription.Length; + } + + } + public override int Length { get @@ -52445,11 +52656,13 @@ namespace OpenMetaverse.Packets int length = 10; length += TargetBlock.Length; length += MoneyData.Length; + length += TransactionInfo.Length; return length; } } public TargetBlockBlock TargetBlock; public MoneyDataBlock MoneyData; + public TransactionInfoBlock TransactionInfo; public RoutedMoneyBalanceReplyPacket() { @@ -52462,6 +52675,7 @@ namespace OpenMetaverse.Packets Header.Zerocoded = true; TargetBlock = new TargetBlockBlock(); MoneyData = new MoneyDataBlock(); + TransactionInfo = new TransactionInfoBlock(); } public RoutedMoneyBalanceReplyPacket(byte[] bytes, ref int i) : this() @@ -52480,6 +52694,7 @@ namespace OpenMetaverse.Packets } TargetBlock.FromBytes(bytes, ref i); MoneyData.FromBytes(bytes, ref i); + TransactionInfo.FromBytes(bytes, ref i); } public RoutedMoneyBalanceReplyPacket(Header head, byte[] bytes, ref int i): this() @@ -52493,6 +52708,7 @@ namespace OpenMetaverse.Packets Header = header; TargetBlock.FromBytes(bytes, ref i); MoneyData.FromBytes(bytes, ref i); + TransactionInfo.FromBytes(bytes, ref i); } public override byte[] ToBytes() @@ -52500,12 +52716,14 @@ namespace OpenMetaverse.Packets int length = 10; length += TargetBlock.Length; length += MoneyData.Length; + length += TransactionInfo.Length; if (Header.AckList != null && Header.AckList.Length > 0) { length += Header.AckList.Length * 4 + 1; } byte[] bytes = new byte[length]; int i = 0; Header.ToBytes(bytes, ref i); TargetBlock.ToBytes(bytes, ref i); MoneyData.ToBytes(bytes, ref i); + TransactionInfo.ToBytes(bytes, ref i); if (Header.AckList != null && Header.AckList.Length > 0) { Header.AcksToBytes(bytes, ref i); } return bytes; } diff --git a/data/message_template.msg b/data/message_template.msg index d4f791c2..d292653d 100644 --- a/data/message_template.msg +++ b/data/message_template.msg @@ -2966,7 +2966,7 @@ version 2.0 { BillableFactor F32 } { ObjectBonusFactor F32 } { WaterHeight F32 } - { TerrainRaiseLimit F32 } + { TerrainRaiseLimit F32 } { TerrainLowerLimit F32 } { PricePerMeter S32 } { RedirectGridX S32 } @@ -4242,6 +4242,10 @@ version 2.0 Buttons Variable { ButtonLabel Variable 1 } } + { + OwnerData Variable + { OwnerID LLUUID } + } } @@ -6762,6 +6766,8 @@ version 2.0 } // And, the money transfer +// *NOTE: Unused as of 2010-04-06, because all back-end money transactions +// are done with web services via L$ API. JC { MoneyTransferBackend Low 312 Trusted Zerocoded { @@ -6812,6 +6818,19 @@ version 2.0 { SquareMetersCommitted S32 } { Description Variable 1 } // string } + // For replies that are part of a transaction (buying something) provide + // metadata for localization. If TransactionType is 0, the message is + // purely a balance update. Added for server 1.40 and viewer 2.1. JC + { + TransactionInfo Single + { TransactionType S32 } // lltransactiontype.h + { SourceID LLUUID } + { IsSourceGroup BOOL } + { DestID LLUUID } + { IsDestGroup BOOL } + { Amount S32 } + { ItemDescription Variable 1 } // string + } } @@ -6838,6 +6857,17 @@ version 2.0 { SquareMetersCommitted S32 } { Description Variable 1 } // string } + // See MoneyBalanceReply above. + { + TransactionInfo Single + { TransactionType S32 } // lltransactiontype.h + { SourceID LLUUID } + { IsSourceGroup BOOL } + { DestID LLUUID } + { IsDestGroup BOOL } + { Amount S32 } + { ItemDescription Variable 1 } // string + } } @@ -8972,5 +9002,7 @@ version 2.0 { InvType S8 } { Name Variable 1 } { Description Variable 1 } + } } +