@@ -1757,15 +1757,15 @@ public void Deserialize(OSDMap map)
17571757 HasModifiedNavmesh = map [ "has_modified_navmesh" ] ;
17581758 if ( map [ "preferences" ] is OSDMap )
17591759 {
1760- var prefs = ( OSDMap ) map [ "preferences" ] ;
1760+ OSDMap prefs = ( OSDMap ) map [ "preferences" ] ;
17611761 AlterNavmeshObjects = prefs [ "alter_navmesh_objects" ] ;
17621762 AlterPermanentObjects = prefs [ "alter_permanent_objects" ] ;
17631763 GodLevel = prefs [ "god_level" ] ;
17641764 Language = prefs [ "language" ] ;
17651765 LanguageIsPublic = prefs [ "language_is_public" ] ;
17661766 if ( prefs [ "access_prefs" ] is OSDMap )
17671767 {
1768- var access = ( OSDMap ) prefs [ "access_prefs" ] ;
1768+ OSDMap access = ( OSDMap ) prefs [ "access_prefs" ] ;
17691769 MaxAccess = access [ "max" ] ;
17701770 }
17711771 }
@@ -4376,11 +4376,10 @@ public OSDMap Serialize()
43764376
43774377 ret [ "ObjectData" ] = array ;
43784378 return ret ;
4379-
43804379 }
43814380
43824381 /// <summary>
4383- /// Deseializes the message
4382+ /// Deserializes the message
43844383 /// </summary>
43854384 /// <param name="map">Incoming data to deserialize</param>
43864385 public void Deserialize ( OSDMap map )
@@ -4406,6 +4405,10 @@ public class RenderMaterialsMessage : IMessage
44064405 {
44074406 public OSD MaterialData ;
44084407
4408+ /// <summary>
4409+ /// Deserializes the message
4410+ /// </summary>
4411+ /// <param name="map">Incoming data to deserialize</param>
44094412 public void Deserialize ( OSDMap map )
44104413 {
44114414 try
@@ -4435,15 +4438,132 @@ public void Deserialize(OSDMap map)
44354438 MaterialData = new OSDMap ( ) ;
44364439 }
44374440 }
4438-
4441+
4442+ /// <summary>
4443+ /// Serializes the message
4444+ /// </summary>
4445+ /// <returns>Serialized OSD</returns>
44394446 public OSDMap Serialize ( )
44404447 {
44414448 return new OSDMap ( ) ;
44424449 }
4450+ }
4451+
4452+ public class GetObjectCostRequest : IMessage
4453+ {
4454+ /// <summary> Object IDs for which to request cost information
4455+ public UUID [ ] ObjectIDs ;
4456+
4457+ /// <summary>
4458+ /// Deserializes the message
4459+ /// </summary>
4460+ /// <param name="map">Incoming data to deserialize</param>
4461+ public void Deserialize ( OSDMap map )
4462+ {
4463+ OSDArray array = map [ "object_ids" ] as OSDArray ;
4464+ if ( array != null )
4465+ {
4466+ ObjectIDs = new UUID [ array . Count ] ;
4467+
4468+ for ( int i = 0 ; i < array . Count ; i ++ )
4469+ {
4470+ ObjectIDs [ i ] = array [ i ] . AsUUID ( ) ;
4471+ }
4472+ }
4473+ else
4474+ {
4475+ ObjectIDs = new UUID [ 0 ] ;
4476+ }
4477+ }
44434478
4479+ /// <summary>
4480+ /// Serializes the message
4481+ /// </summary>
4482+ /// <returns>Serialized OSD</returns>
4483+ public OSDMap Serialize ( )
4484+ {
4485+ OSDMap ret = new OSDMap ( ) ;
4486+ OSDArray array = new OSDArray ( ) ;
44444487
4488+ for ( int i = 0 ; i < ObjectIDs . Length ; i ++ )
4489+ {
4490+ array . Add ( OSD . FromUUID ( ObjectIDs [ i ] ) ) ;
4491+ }
4492+
4493+ ret [ "object_ids" ] = array ;
4494+ return ret ;
4495+ }
44454496 }
44464497
4498+ public class GetObjectCostMessage : IMessage
4499+ {
4500+ public UUID object_id ;
4501+ public double link_cost ;
4502+ public double object_cost ;
4503+ public double physics_cost ;
4504+ public double link_physics_cost ;
4505+
4506+ /// <summary>
4507+ /// Deserializes the message
4508+ /// </summary>
4509+ /// <param name="map">Incoming data to deserialize</param>
4510+ public void Deserialize ( OSDMap map )
4511+ {
4512+ if ( map . Count != 1 )
4513+ Logger . Log ( "GetObjectCostMessage returned values for more than one object! Function needs to be fixed for that!" , Helpers . LogLevel . Error ) ;
4514+
4515+ foreach ( string key in map . Keys )
4516+ {
4517+ UUID . TryParse ( key , out object_id ) ;
4518+ OSDMap values = ( OSDMap ) map [ key ] ;
4519+
4520+ link_cost = values [ "linked_set_resource_cost" ] . AsReal ( ) ;
4521+ object_cost = values [ "resource_cost" ] . AsReal ( ) ;
4522+ physics_cost = values [ "physics_cost" ] . AsReal ( ) ;
4523+ link_physics_cost = values [ "linked_set_physics_cost" ] . AsReal ( ) ;
4524+ // value["resource_limiting_type"].AsString();
4525+ return ;
4526+ }
4527+ }
4528+
4529+ /// <summary>
4530+ /// Serializes the message
4531+ /// </summary>
4532+ /// <returns>Serialized OSD</returns>
4533+ public OSDMap Serialize ( )
4534+ {
4535+ OSDMap values = new OSDMap ( 4 ) ;
4536+ values . Add ( "linked_set_resource_cost" , OSD . FromReal ( link_cost ) ) ;
4537+ values . Add ( "resource_cost" , OSD . FromReal ( object_cost ) ) ;
4538+ values . Add ( "physics_cost" , OSD . FromReal ( physics_cost ) ) ;
4539+ values . Add ( "linked_set_physics_cost" , OSD . FromReal ( link_physics_cost ) ) ;
4540+
4541+ OSDMap map = new OSDMap ( 1 ) ;
4542+ map . Add ( OSD . FromUUID ( object_id ) , values ) ;
4543+ return map ;
4544+ }
4545+
4546+ /// <summary>
4547+ /// Detects which class handles deserialization of this message
4548+ /// </summary>
4549+ /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
4550+ /// <returns>Object capable of decoding this message</returns>
4551+ public static IMessage GetMessageHandler ( OSDMap map )
4552+ {
4553+ if ( map == null )
4554+ {
4555+ return null ;
4556+ }
4557+ else if ( map . ContainsKey ( "object_ids" ) )
4558+ {
4559+ return new GetObjectCostRequest ( ) ;
4560+ }
4561+ else
4562+ {
4563+ return new GetObjectCostMessage ( ) ;
4564+ }
4565+ }
4566+ }
44474567
44484568 #endregion Object Messages
44494569
@@ -5167,7 +5287,9 @@ public class SetDisplayNameMessage : IMessage
51675287 /// <returns>OSD containting the messaage</returns>
51685288 public OSDMap Serialize ( )
51695289 {
5170- OSDArray names = new OSDArray ( 2 ) { OldDisplayName , NewDisplayName } ;
5290+ OSDArray names = new OSDArray ( 2 ) ;
5291+ names . Add ( OldDisplayName ) ;
5292+ names . Add ( NewDisplayName ) ;
51715293
51725294 OSDMap name = new OSDMap ( ) ;
51735295 name [ "display_name" ] = names ;
0 commit comments