aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTORS.txt343
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs17
-rw-r--r--OpenSim/Client/MXP/ClientStack/MXPClientView.cs2
-rw-r--r--OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs2
-rw-r--r--OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs13
-rw-r--r--OpenSim/Data/MySQL/MySQLLegacyRegionData.cs196
-rw-r--r--OpenSim/Data/MySQL/Resources/032_RegionStore.sql70
-rw-r--r--OpenSim/Data/Null/NullDataStore.cs11
-rw-r--r--OpenSim/Data/SQLite/SQLiteRegionData.cs11
-rw-r--r--OpenSim/Data/SQLite/SQLiteUserData.cs7
-rw-r--r--OpenSim/Data/Tests/BasicEstateTest.cs7
-rw-r--r--OpenSim/Data/Tests/BasicUserTest.cs9
-rw-r--r--OpenSim/Framework/Communications/Services/LoginService.cs2
-rw-r--r--OpenSim/Framework/Communications/UserManagerBase.cs3
-rw-r--r--OpenSim/Framework/IClientAPI.cs2
-rw-r--r--OpenSim/Framework/RegionInfo.cs69
-rw-r--r--OpenSim/Framework/Servers/BaseOpenSimServer.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs12
-rw-r--r--OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs10
-rw-r--r--OpenSim/Framework/TaskInventoryDictionary.cs10
-rw-r--r--OpenSim/Framework/UserProfileData.cs8
-rw-r--r--OpenSim/Framework/Util.cs24
-rw-r--r--OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs1
-rw-r--r--OpenSim/Region/Application/OpenSim.cs9
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs132
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs5
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs9
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs71
-rw-r--r--OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs1
-rw-r--r--OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs9
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs7
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs50
-rw-r--r--OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs245
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs17
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs32
-rw-r--r--OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/ITerrainModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/EntityManager.cs79
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs21
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs94
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs264
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs543
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs32
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs66
-rw-r--r--OpenSim/Region/Framework/Scenes/SimStatsReporter.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs11
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs9
-rw-r--r--OpenSim/Region/OptionalModules/Python/PythonAPI/Console.cs48
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs2
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsScene.cs4
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs5
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs8
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs10
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs430
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs44
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs20
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs76
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs (renamed from OpenSim/Region/OptionalModules/Python/PythonModule.cs)54
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp2
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs423
-rw-r--r--OpenSim/Server/Base/ServicesServerBase.cs4
-rw-r--r--OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs2
-rw-r--r--OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs (renamed from OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs)4
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs2
-rw-r--r--bin/IronMath.dllbin45056 -> 0 bytes
-rw-r--r--bin/IronPython.dllbin1605632 -> 0 bytes
-rw-r--r--bin/OpenSim.ini.example26
-rw-r--r--prebuild.xml2
78 files changed, 2755 insertions, 1004 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index 8744a08..0d78928 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -1,170 +1,173 @@
1The following people have contributed to OpenSim (Thank you 1The following people have contributed to OpenSim (Thank you
2for your effort!) 2for your effort!)
3 3
4Add your name in here if you have committed to OpenSim 4Add your name in here if you have committed to OpenSim
5 5
6= Current OpenSim Developers (in very rough order of appearance) = 6= Current OpenSim Developers (in very rough order of appearance) =
7These folks represent the current core team for OpenSim, and are the 7These folks represent the current core team for OpenSim, and are the
8people that make the day to day of OpenSim happen. 8people that make the day to day of OpenSim happen.
9 9
10* MW (Tribal Media AB) 10* MW (Tribal Media AB)
11* Adam Frisby (DeepThink Pty Ltd) 11* Adam Frisby (DeepThink Pty Ltd)
12* MingChen (DeepThink Pty Ltd) 12* MingChen (DeepThink Pty Ltd)
13* lbsa71 (Tribal Media AB) 13* lbsa71 (Tribal Media AB)
14* Sean Dague / sdague (IBM) 14* Sean Dague / sdague (IBM)
15* Tedd 15* Tedd
16* justincc 16* justincc
17* Teravus (w3z) 17* Teravus (w3z)
18* Johan Berntsson (3Di) 18* Johan Berntsson (3Di)
19* Ckrinke (Charles Krinke) 19* Ckrinke (Charles Krinke)
20* chi11ken (Genkii) 20* chi11ken (Genkii)
21* adjohn (Genkii) 21* adjohn (Genkii)
22* Dr Scofield aka Dirk Husemann (IBM Research - Zurich) 22* Dr Scofield aka Dirk Husemann (IBM Research - Zurich)
23* dahlia 23* dahlia
24* mikem (3Di) 24* mikem (3Di)
25* Melanie Thielker 25* Melanie Thielker
26* Homer_Horwitz 26* Homer_Horwitz
27* idb (Ian Brown) 27* idb (Ian Brown)
28* Diva (Crista Lopes, University of California, Irvine) 28* Diva (Crista Lopes, University of California, Irvine)
29* nlin (3Di) 29* nlin (3Di)
30* Arthur Rodrigo S Valadares (IBM) 30* Arthur Rodrigo S Valadares (IBM)
31 31
32 32
33= Past Open Sim Developers = 33= Past Open Sim Developers =
34These folks are alumns of the OpenSim core group, but are now 34These folks are alumns of the OpenSim core group, but are now
35currently not active. Their great contributions helped get us to 35currently not active. Their great contributions helped get us to
36where we are today. 36where we are today.
37 37
38* Gareth 38* Gareth
39* Andy- 39* Andy-
40* MorphW 40* MorphW
41* CW 41* CW
42* Babblefrog 42* Babblefrog
43* Danx0r 43* Danx0r
44* Dalien 44* Dalien
45* Darok 45* Darok
46* Alondria 46* Alondria
47 47
48 48
49= Additional OpenSim Contributors = 49= Additional OpenSim Contributors =
50These folks have contributed code patches to OpenSim to help make it 50These folks have contributed code patches to OpenSim to help make it
51what it is today. 51what it is today.
52 52
53* aduffy70 53* aduffy70
54* A_Biondi 54* A_Biondi
55* alex_carnell 55* alex_carnell
56* Alan Webb (IBM) 56* Alan Webb (IBM)
57* BigFootAg 57* BigFootAg
58* BlueWall Slade 58* BlueWall Slade
59* brianw/Sir_Ahzz 59* brianw/Sir_Ahzz
60* CharlieO 60* CharlieO
61* ChrisDown 61* ChrisDown
62* Chris Yeoh (IBM) 62* Chris Yeoh (IBM)
63* coyled 63* coyled
64* Daedius 64* Daedius
65* Dong Jun Lan (IBM) 65* Dong Jun Lan (IBM)
66* DoranZemlja 66* DoranZemlja
67* daTwitch 67* daTwitch
68* devalnor-#708 68* devalnor-#708
69* dmiles (Daxtron Labs) 69* dmiles (Daxtron Labs)
70* dslake (Intel) 70* dslake (Intel)
71* FredoChaplin 71* FredoChaplin
72* Gerhard 72* Gerhard
73* Godfrey 73* Godfrey
74* Grumly57 74* Grumly57
75* Ewe Loon 75* Ewe Loon
76* Fly-Man 76* Fly-Man
77* Flyte Xevious 77* Flyte Xevious
78* Imaze Rhiano 78* Imaze Rhiano
79* Intimidated 79* Intimidated
80* Jeremy Bongio (IBM) 80* Jeremy Bongio (IBM)
81* jhurliman 81* jhurliman
82* John R Sohn (XenReborn) 82* John R Sohn (XenReborn)
83* jonc 83* jonc
84* Junta Kohime 84* Junta Kohime
85* Kayne 85* Kayne
86* Kevin Cozens 86* Kevin Cozens
87* kinoc (Daxtron Labs) 87* kinoc (Daxtron Labs)
88* Kitto Flora 88* Kitto Flora
89* Kurt Taylor (IBM) 89* KittyLiu
90* lulurun 90* Kurt Taylor (IBM)
91* M.Igarashi 91* lulurun
92* maimedleech 92* M.Igarashi
93* Mic Bowman 93* maimedleech
94* Michelle Argus 94* Mic Bowman
95* Michael Cortez (The Flotsam Project, http://osflotsam.org/) 95* Michelle Argus
96* Mike Osias (IBM) 96* Michael Cortez (The Flotsam Project, http://osflotsam.org/)
97* Mike Pitman (IBM) 97* Mike Osias (IBM)
98* mikkopa/_someone - RealXtend 98* Mike Pitman (IBM)
99* Mircea Kitsune 99* mikkopa/_someone - RealXtend
100* mpallari 100* Misterblue (Intel)
101* nornalbion 101* Mircea Kitsune
102* Omar Vera Ustariz (IBM) 102* mpallari
103* openlifegrid.com 103* nornalbion
104* otakup0pe 104* Omar Vera Ustariz (IBM)
105* ralphos 105* openlifegrid.com
106* RemedyTomm 106* otakup0pe
107* Richard Alimi (IBM) 107* ralphos
108* Rick Alther (IBM) 108* RemedyTomm
109* Rob Smart (IBM) 109* Revolution
110* rtomita 110* Richard Alimi (IBM)
111* Ruud Lathorp 111* Rick Alther (IBM)
112* SachaMagne 112* Rob Smart (IBM)
113* Salahzar Stenvaag 113* rtomita
114* sempuki 114* Ruud Lathorp
115* Snoopy 115* SachaMagne
116* Strawberry Fride 116* Salahzar Stenvaag
117* tglion 117* sempuki
118* tlaukkan/Tommil (Tommi S. E. Laukkanen, Bubble Cloud) 118* Snoopy
119* tyre 119* Strawberry Fride
120* Vytek 120* tglion
121* webmage (IBM) 121* tlaukkan/Tommil (Tommi S. E. Laukkanen, Bubble Cloud)
122* Xantor 122* tyre
123* Y. Nitta 123* Vytek
124* YZh 124* webmage (IBM)
125* Zackary Geers aka Kunnis Basiat 125* Xantor
126* Zha Ewry 126* Y. Nitta
127 127* YZh
128 128* Zackary Geers aka Kunnis Basiat
129= LSL Devs = 129* Zha Ewry
130 130
131* Alondria 131
132* CharlieO 132= LSL Devs =
133* Tedd 133
134* Melanie Thielker 134* Alondria
135 135* CharlieO
136 136* Tedd
137= Testers = 137* Melanie Thielker
138 138
139* Ai Austin 139
140* CharlieO (LSL) 140= Testers =
141* Ckrinke 141
142* openlifegrid.com 142* Ai Austin
143 143* CharlieO (LSL)
144 144* Ckrinke
145This software uses components from the following developers: 145* openlifegrid.com
146* Sleepycat Software (Berkeley DB) 146
147* SQLite (Public Domain) 147
148* XmlRpcCS (http://xmlrpccs.sf.net/) 148This software uses components from the following developers:
149* MySQL, Inc. (MySQL Connector/NET) 149* Sleepycat Software (Berkeley DB)
150* NUnit (http://www.nunit.org) 150* SQLite (Public Domain)
151* AGEIA Inc. (PhysX) 151* XmlRpcCS (http://xmlrpccs.sf.net/)
152* Russel L. Smith (ODE) 152* MySQL, Inc. (MySQL Connector/NET)
153* Prebuild (http://sourceforge.net/projects/dnpb/) 153* NUnit (http://www.nunit.org)
154* LibOpenMetaverse (http://lib.openmetaverse.org/) 154* AGEIA Inc. (PhysX)
155* DotNetOpenMail v0.5.8b (http://dotnetopenmail.sourceforge.net) 155* Russel L. Smith (ODE)
156* Prototype JavaScript Framework ajax (http://www.prototypejs.org/) 156* Prebuild (http://sourceforge.net/projects/dnpb/)
157* C5 GENERIC COLLECTION LIBRARY FOR C#/CLI 157* LibOpenMetaverse (http://lib.openmetaverse.org/)
158* Nini (http://nini.sourceforge.net/) 158* DotNetOpenMail v0.5.8b (http://dotnetopenmail.sourceforge.net)
159* log4net (http://logging.apache.org/log4net/) 159* Prototype JavaScript Framework ajax (http://www.prototypejs.org/)
160* GlynnTucker.Cache (http://gtcache.sourceforge.net/) 160* C5 GENERIC COLLECTION LIBRARY FOR C#/CLI
161* NDesk.Options 0.2.1 (http://www.ndesk.org/Options) 161* Nini (http://nini.sourceforge.net/)
162 162* log4net (http://logging.apache.org/log4net/)
163Some plugins are based on Cable Beach 163* GlynnTucker.Cache (http://gtcache.sourceforge.net/)
164Cable Beach is Copyright (c) 2008 Intel Corporation 164* NDesk.Options 0.2.1 (http://www.ndesk.org/Options)
165see http://forge.opensimulator.org/gf/project/assetserver/ 165
166 166Some plugins are based on Cable Beach
167In addition, we would like to thank: 167Cable Beach is Copyright (c) 2008 Intel Corporation
168* The Mono Project 168see http://forge.opensimulator.org/gf/project/assetserver/
169* The NANT Developers 169
170* Microsoft (.NET, MSSQL-Adapters) 170In addition, we would like to thank:
171* The Mono Project
172* The NANT Developers
173* Microsoft (.NET, MSSQL-Adapters)
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index 325816d..b22003c 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -413,8 +413,21 @@ namespace OpenSim.ApplicationPlugins.RemoteController
413 413
414 ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>(); 414 ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>();
415 if (null == terrainModule) throw new Exception("terrain module not available"); 415 if (null == terrainModule) throw new Exception("terrain module not available");
416 terrainModule.LoadFromFile(file); 416 if (Uri.IsWellFormedUriString(file, UriKind.Absolute))
417 417 {
418 m_log.Info("[RADMIN]: Terrain path is URL");
419 Uri result;
420 if (Uri.TryCreate(file, UriKind.RelativeOrAbsolute, out result))
421 {
422 // the url is valid
423 string fileType = file.Substring(file.LastIndexOf('/') + 1);
424 terrainModule.LoadFromStream(fileType, result);
425 }
426 }
427 else
428 {
429 terrainModule.LoadFromFile(file);
430 }
418 responseData["success"] = false; 431 responseData["success"] = false;
419 432
420 response.Value = responseData; 433 response.Value = responseData;
diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
index 0cae3dd..9f9d151 100644
--- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
+++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
@@ -902,7 +902,7 @@ namespace OpenSim.Client.MXP.ClientStack
902 // Need to translate to MXP somehow 902 // Need to translate to MXP somehow
903 } 903 }
904 904
905 public void SendGenericMessage(string method, List<string> message) 905 public void SendGenericMessage(string method, List<byte[]> message)
906 { 906 {
907 // Need to translate to MXP somehow 907 // Need to translate to MXP somehow
908 } 908 }
diff --git a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs
index fb87c15..533475f 100644
--- a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs
+++ b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs
@@ -483,7 +483,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack
483 throw new System.NotImplementedException(); 483 throw new System.NotImplementedException();
484 } 484 }
485 485
486 public void SendGenericMessage(string method, List<string> message) 486 public void SendGenericMessage(string method, List<byte[]> message)
487 { 487 {
488 throw new System.NotImplementedException(); 488 throw new System.NotImplementedException();
489 } 489 }
diff --git a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
index 6371307..0b430c7 100644
--- a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
@@ -671,7 +671,16 @@ VALUES
671 cmd.ExecuteNonQuery(); 671 cmd.ExecuteNonQuery();
672 } 672 }
673 } 673 }
674 674 public RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID)
675 {
676 //This connector doesn't support the windlight module yet
677 //Return default LL windlight settings
678 return new RegionMeta7WindlightData();
679 }
680 public void StoreRegionWindlightSettings(RegionMeta7WindlightData wl)
681 {
682 //This connector doesn't support the windlight module yet
683 }
675 /// <summary> 684 /// <summary>
676 /// Loads the settings of a region. 685 /// Loads the settings of a region.
677 /// </summary> 686 /// </summary>
@@ -696,7 +705,7 @@ VALUES
696 } 705 }
697 } 706 }
698 707
699 //If comes here then there is now region setting for that region 708 //If we reach this point then there are new region settings for that region
700 regionSettings = new RegionSettings(); 709 regionSettings = new RegionSettings();
701 regionSettings.RegionUUID = regionUUID; 710 regionSettings.RegionUUID = regionUUID;
702 regionSettings.OnSave += StoreRegionSettings; 711 regionSettings.OnSave += StoreRegionSettings;
diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
index c49153f..e2a5406 100644
--- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
@@ -479,7 +479,9 @@ namespace OpenSim.Data.MySQL
479 } 479 }
480 else 480 else
481 { 481 {
482 m_log.Warn("[REGION DB]: Database contains an orphan child prim " + prim.UUID + " pointing to missing parent " + prim.ParentUUID); 482 m_log.WarnFormat(
483 "[REGION DB]: Database contains an orphan child prim {0} {1} at {2} in region {3} pointing to missing parent {4}. This prim will not be loaded.",
484 prim.Name, prim.UUID, prim.AbsolutePosition, regionID, prim.ParentUUID);
483 } 485 }
484 } 486 }
485 } 487 }
@@ -691,6 +693,97 @@ namespace OpenSim.Data.MySQL
691 } 693 }
692 } 694 }
693 695
696 public RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID)
697 {
698 RegionMeta7WindlightData nWP = new RegionMeta7WindlightData();
699 nWP.OnSave += StoreRegionWindlightSettings;
700 lock (m_Connection)
701 {
702
703 string command = "select * from `regionwindlight` where region_id = ?regionID";
704
705 MySqlCommand cmd = new MySqlCommand(command);
706
707 cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString());
708
709 IDataReader result = ExecuteReader(cmd);
710 if (!result.Read())
711 {
712 //No result, so store our default windlight profile and return it
713 nWP.regionID = regionUUID;
714 StoreRegionWindlightSettings(nWP);
715 return nWP;
716 }
717 else
718 {
719 UUID.TryParse(result["region_id"].ToString(), out nWP.regionID);
720 nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]);
721 nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]);
722 nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]);
723 nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]);
724 nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]);
725 nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]);
726 nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]);
727 nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]);
728 nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]);
729 nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]);
730 nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]);
731 nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]);
732 nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]);
733 nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]);
734 nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]);
735 nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]);
736 nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]);
737 UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture);
738 nWP.horizon.X = Convert.ToSingle(result["horizon_r"]);
739 nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]);
740 nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]);
741 nWP.horizon.W = Convert.ToSingle(result["horizon_i"]);
742 nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]);
743 nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]);
744 nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]);
745 nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]);
746 nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]);
747 nWP.hazeDensity = Convert.ToSingle(result["haze_density"]);
748 nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]);
749 nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]);
750 nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]);
751 nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]);
752 nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]);
753 nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]);
754 nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]);
755 nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]);
756 nWP.ambient.X = Convert.ToSingle(result["ambient_r"]);
757 nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]);
758 nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]);
759 nWP.ambient.W = Convert.ToSingle(result["ambient_i"]);
760 nWP.eastAngle = Convert.ToSingle(result["east_angle"]);
761 nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]);
762 nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]);
763 nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]);
764 nWP.starBrightness = Convert.ToSingle(result["star_brightness"]);
765 nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]);
766 nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]);
767 nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]);
768 nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]);
769 nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]);
770 nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]);
771 nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]);
772 nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]);
773 nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]);
774 nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]);
775 nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]);
776 nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]);
777 nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]);
778 nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]);
779 nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]);
780 nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]);
781 nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]);
782 }
783 }
784 return nWP;
785 }
786
694 public RegionSettings LoadRegionSettings(UUID regionUUID) 787 public RegionSettings LoadRegionSettings(UUID regionUUID)
695 { 788 {
696 RegionSettings rs = null; 789 RegionSettings rs = null;
@@ -724,6 +817,107 @@ namespace OpenSim.Data.MySQL
724 return rs; 817 return rs;
725 } 818 }
726 819
820 public void StoreRegionWindlightSettings(RegionMeta7WindlightData wl)
821 {
822 lock (m_Connection)
823 {
824 using (MySqlCommand cmd = m_Connection.CreateCommand())
825 {
826 cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, ";
827 cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, ";
828 cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, ";
829 cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, ";
830 cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, ";
831 cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, ";
832 cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, ";
833 cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, ";
834 cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, ";
835 cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, ";
836 cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, ";
837 cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, ";
838 cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, ";
839 cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, ";
840 cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, ";
841 cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, ";
842 cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, ";
843 cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, ";
844 cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, ";
845 cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, ";
846 cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, ";
847 cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, ";
848 cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, ";
849 cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, ";
850 cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)";
851
852 cmd.Parameters.AddWithValue("region_id", wl.regionID);
853 cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X);
854 cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y);
855 cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z);
856 cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent);
857 cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier);
858 cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X);
859 cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y);
860 cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z);
861 cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale);
862 cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset);
863 cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove);
864 cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow);
865 cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier);
866 cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X);
867 cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y);
868 cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X);
869 cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y);
870 cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture);
871 cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X);
872 cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y);
873 cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z);
874 cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W);
875 cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon);
876 cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X);
877 cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y);
878 cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z);
879 cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W);
880 cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity);
881 cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier);
882 cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier);
883 cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude);
884 cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X);
885 cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y);
886 cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z);
887 cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W);
888 cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition);
889 cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X);
890 cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y);
891 cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z);
892 cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W);
893 cmd.Parameters.AddWithValue("east_angle", wl.eastAngle);
894 cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus);
895 cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize);
896 cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma);
897 cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness);
898 cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X);
899 cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y);
900 cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z);
901 cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W);
902 cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X);
903 cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y);
904 cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z);
905 cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage);
906 cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale);
907 cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X);
908 cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y);
909 cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z);
910 cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX);
911 cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock);
912 cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY);
913 cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock);
914 cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds);
915
916 ExecuteNonQuery(cmd);
917 }
918 }
919 }
920
727 public void StoreRegionSettings(RegionSettings rs) 921 public void StoreRegionSettings(RegionSettings rs)
728 { 922 {
729 lock (m_Connection) 923 lock (m_Connection)
diff --git a/OpenSim/Data/MySQL/Resources/032_RegionStore.sql b/OpenSim/Data/MySQL/Resources/032_RegionStore.sql
new file mode 100644
index 0000000..0545ee1
--- /dev/null
+++ b/OpenSim/Data/MySQL/Resources/032_RegionStore.sql
@@ -0,0 +1,70 @@
1BEGIN;
2
3CREATE TABLE `regionwindlight` (
4 `region_id` varchar(36) NOT NULL DEFAULT '000000-0000-0000-0000-000000000000',
5 `water_color_r` float(9,6) unsigned NOT NULL DEFAULT '4.000000',
6 `water_color_g` float(9,6) unsigned NOT NULL DEFAULT '38.000000',
7 `water_color_b` float(9,6) unsigned NOT NULL DEFAULT '64.000000',
8 `water_fog_density_exponent` float(3,1) unsigned NOT NULL DEFAULT '4.0',
9 `underwater_fog_modifier` float(3,2) unsigned NOT NULL DEFAULT '0.25',
10 `reflection_wavelet_scale_1` float(3,1) unsigned NOT NULL DEFAULT '2.0',
11 `reflection_wavelet_scale_2` float(3,1) unsigned NOT NULL DEFAULT '2.0',
12 `reflection_wavelet_scale_3` float(3,1) unsigned NOT NULL DEFAULT '2.0',
13 `fresnel_scale` float(3,2) unsigned NOT NULL DEFAULT '0.40',
14 `fresnel_offset` float(3,2) unsigned NOT NULL DEFAULT '0.50',
15 `refract_scale_above` float(3,2) unsigned NOT NULL DEFAULT '0.03',
16 `refract_scale_below` float(3,2) unsigned NOT NULL DEFAULT '0.20',
17 `blur_multiplier` float(4,3) unsigned NOT NULL DEFAULT '0.040',
18 `big_wave_direction_x` float(3,2) NOT NULL DEFAULT '1.05',
19 `big_wave_direction_y` float(3,2) NOT NULL DEFAULT '-0.42',
20 `little_wave_direction_x` float(3,2) NOT NULL DEFAULT '1.11',
21 `little_wave_direction_y` float(3,2) NOT NULL DEFAULT '-1.16',
22 `normal_map_texture` varchar(36) NOT NULL DEFAULT '822ded49-9a6c-f61c-cb89-6df54f42cdf4',
23 `horizon_r` float(3,2) unsigned NOT NULL DEFAULT '0.26',
24 `horizon_g` float(3,2) unsigned NOT NULL DEFAULT '0.24',
25 `horizon_b` float(3,2) unsigned NOT NULL DEFAULT '0.33',
26 `horizon_i` float(3,2) unsigned NOT NULL DEFAULT '0.33',
27 `haze_horizon` float(3,2) unsigned NOT NULL DEFAULT '0.19',
28 `blue_density_r` float(3,2) unsigned NOT NULL DEFAULT '0.10',
29 `blue_density_g` float(3,2) unsigned NOT NULL DEFAULT '0.93',
30 `blue_density_b` float(3,2) unsigned NOT NULL DEFAULT '0.02',
31 `blue_density_i` float(3,2) unsigned NOT NULL DEFAULT '0.93',
32 `haze_density` float(3,2) unsigned NOT NULL DEFAULT '0.70',
33 `density_multiplier` float(3,2) unsigned NOT NULL DEFAULT '0.18',
34 `distance_multiplier` float(4,1) unsigned NOT NULL DEFAULT '0.8',
35 `max_altitude` int(4) unsigned NOT NULL DEFAULT '1605',
36 `sun_moon_color_r` float(3,2) unsigned NOT NULL DEFAULT '0.24',
37 `sun_moon_color_g` float(3,2) unsigned NOT NULL DEFAULT '0.26',
38 `sun_moon_color_b` float(3,2) unsigned NOT NULL DEFAULT '0.30',
39 `sun_moon_color_i` float(3,2) unsigned NOT NULL DEFAULT '0.30',
40 `sun_moon_position` float(4,3) unsigned NOT NULL DEFAULT '0.335',
41 `ambient_r` float(3,2) unsigned NOT NULL DEFAULT '0.35',
42 `ambient_g` float(3,2) unsigned NOT NULL DEFAULT '0.35',
43 `ambient_b` float(3,2) unsigned NOT NULL DEFAULT '0.35',
44 `ambient_i` float(3,2) unsigned NOT NULL DEFAULT '0.35',
45 `east_angle` float(3,2) unsigned NOT NULL DEFAULT '0.00',
46 `sun_glow_focus` float(3,2) unsigned NOT NULL DEFAULT '0.10',
47 `sun_glow_size` float(3,2) unsigned NOT NULL DEFAULT '1.75',
48 `scene_gamma` float(4,2) unsigned NOT NULL DEFAULT '1.00',
49 `star_brightness` float(3,2) unsigned NOT NULL DEFAULT '0.00',
50 `cloud_color_r` float(3,2) unsigned NOT NULL DEFAULT '0.41',
51 `cloud_color_g` float(3,2) unsigned NOT NULL DEFAULT '0.41',
52 `cloud_color_b` float(3,2) unsigned NOT NULL DEFAULT '0.41',
53 `cloud_color_i` float(3,2) unsigned NOT NULL DEFAULT '0.41',
54 `cloud_x` float(3,2) unsigned NOT NULL DEFAULT '1.00',
55 `cloud_y` float(3,2) unsigned NOT NULL DEFAULT '0.53',
56 `cloud_density` float(3,2) unsigned NOT NULL DEFAULT '1.00',
57 `cloud_coverage` float(3,2) unsigned NOT NULL DEFAULT '0.27',
58 `cloud_scale` float(3,2) unsigned NOT NULL DEFAULT '0.42',
59 `cloud_detail_x` float(3,2) unsigned NOT NULL DEFAULT '1.00',
60 `cloud_detail_y` float(3,2) unsigned NOT NULL DEFAULT '0.53',
61 `cloud_detail_density` float(3,2) unsigned NOT NULL DEFAULT '0.12',
62 `cloud_scroll_x` float(3,2) unsigned NOT NULL DEFAULT '0.20',
63 `cloud_scroll_x_lock` tinyint(1) unsigned NOT NULL DEFAULT '0',
64 `cloud_scroll_y` float(3,2) unsigned NOT NULL DEFAULT '0.01',
65 `cloud_scroll_y_lock` tinyint(1) unsigned NOT NULL DEFAULT '0',
66 `draw_classic_clouds` tinyint(1) unsigned NOT NULL DEFAULT '0',
67 PRIMARY KEY (`region_id`)
68);
69
70COMMIT; \ No newline at end of file
diff --git a/OpenSim/Data/Null/NullDataStore.cs b/OpenSim/Data/Null/NullDataStore.cs
index 427fa0a..4b6d0f3 100644
--- a/OpenSim/Data/Null/NullDataStore.cs
+++ b/OpenSim/Data/Null/NullDataStore.cs
@@ -50,7 +50,16 @@ namespace OpenSim.Data.Null
50 public void StoreRegionSettings(RegionSettings rs) 50 public void StoreRegionSettings(RegionSettings rs)
51 { 51 {
52 } 52 }
53 53 public RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID)
54 {
55 //This connector doesn't support the windlight module yet
56 //Return default LL windlight settings
57 return new RegionMeta7WindlightData();
58 }
59 public void StoreRegionWindlightSettings(RegionMeta7WindlightData wl)
60 {
61 //This connector doesn't support the windlight module yet
62 }
54 public RegionSettings LoadRegionSettings(UUID regionUUID) 63 public RegionSettings LoadRegionSettings(UUID regionUUID)
55 { 64 {
56 return null; 65 return null;
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs
index b68de1a..f1c1f78 100644
--- a/OpenSim/Data/SQLite/SQLiteRegionData.cs
+++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs
@@ -272,7 +272,16 @@ namespace OpenSim.Data.SQLite
272 Commit(); 272 Commit();
273 } 273 }
274 } 274 }
275 275 public RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID)
276 {
277 //This connector doesn't support the windlight module yet
278 //Return default LL windlight settings
279 return new RegionMeta7WindlightData();
280 }
281 public void StoreRegionWindlightSettings(RegionMeta7WindlightData wl)
282 {
283 //This connector doesn't support the windlight module yet
284 }
276 public RegionSettings LoadRegionSettings(UUID regionUUID) 285 public RegionSettings LoadRegionSettings(UUID regionUUID)
277 { 286 {
278 lock (ds) 287 lock (ds)
diff --git a/OpenSim/Data/SQLite/SQLiteUserData.cs b/OpenSim/Data/SQLite/SQLiteUserData.cs
index b9f3515..caddcf8 100644
--- a/OpenSim/Data/SQLite/SQLiteUserData.cs
+++ b/OpenSim/Data/SQLite/SQLiteUserData.cs
@@ -819,7 +819,10 @@ namespace OpenSim.Data.SQLite
819 SQLiteUtil.createCol(users, "homeLookAtZ", typeof (Double)); 819 SQLiteUtil.createCol(users, "homeLookAtZ", typeof (Double));
820 SQLiteUtil.createCol(users, "created", typeof (Int32)); 820 SQLiteUtil.createCol(users, "created", typeof (Int32));
821 SQLiteUtil.createCol(users, "lastLogin", typeof (Int32)); 821 SQLiteUtil.createCol(users, "lastLogin", typeof (Int32));
822
823 //TODO: Please delete this column. It's now a brick
822 SQLiteUtil.createCol(users, "rootInventoryFolderID", typeof (String)); 824 SQLiteUtil.createCol(users, "rootInventoryFolderID", typeof (String));
825
823 SQLiteUtil.createCol(users, "userInventoryURI", typeof (String)); 826 SQLiteUtil.createCol(users, "userInventoryURI", typeof (String));
824 SQLiteUtil.createCol(users, "userAssetURI", typeof (String)); 827 SQLiteUtil.createCol(users, "userAssetURI", typeof (String));
825 SQLiteUtil.createCol(users, "profileCanDoMask", typeof (Int32)); 828 SQLiteUtil.createCol(users, "profileCanDoMask", typeof (Int32));
@@ -980,7 +983,6 @@ namespace OpenSim.Data.SQLite
980 983
981 user.Created = Convert.ToInt32(row["created"]); 984 user.Created = Convert.ToInt32(row["created"]);
982 user.LastLogin = Convert.ToInt32(row["lastLogin"]); 985 user.LastLogin = Convert.ToInt32(row["lastLogin"]);
983 user.RootInventoryFolderID = new UUID((String) row["rootInventoryFolderID"]);
984 user.UserInventoryURI = (String) row["userInventoryURI"]; 986 user.UserInventoryURI = (String) row["userInventoryURI"];
985 user.UserAssetURI = (String) row["userAssetURI"]; 987 user.UserAssetURI = (String) row["userAssetURI"];
986 user.CanDoMask = Convert.ToUInt32(row["profileCanDoMask"]); 988 user.CanDoMask = Convert.ToUInt32(row["profileCanDoMask"]);
@@ -1026,7 +1028,8 @@ namespace OpenSim.Data.SQLite
1026 1028
1027 row["created"] = user.Created; 1029 row["created"] = user.Created;
1028 row["lastLogin"] = user.LastLogin; 1030 row["lastLogin"] = user.LastLogin;
1029 row["rootInventoryFolderID"] = user.RootInventoryFolderID.ToString(); 1031 //TODO: Get rid of rootInventoryFolderID in a safe way.
1032 row["rootInventoryFolderID"] = UUID.Zero.ToString();
1030 row["userInventoryURI"] = user.UserInventoryURI; 1033 row["userInventoryURI"] = user.UserInventoryURI;
1031 row["userAssetURI"] = user.UserAssetURI; 1034 row["userAssetURI"] = user.UserAssetURI;
1032 row["profileCanDoMask"] = user.CanDoMask; 1035 row["profileCanDoMask"] = user.CanDoMask;
diff --git a/OpenSim/Data/Tests/BasicEstateTest.cs b/OpenSim/Data/Tests/BasicEstateTest.cs
index d8e1725..907bb38 100644
--- a/OpenSim/Data/Tests/BasicEstateTest.cs
+++ b/OpenSim/Data/Tests/BasicEstateTest.cs
@@ -154,13 +154,14 @@ namespace OpenSim.Data.Tests
154 ); 154 );
155 } 155 }
156 156
157 //[Test] 157 [Test]
158 // Currently fails occasionally
159 public void T012_EstateSettingsRandomStorage() 158 public void T012_EstateSettingsRandomStorage()
160 { 159 {
161 // Letting estate store generate rows to database for us 160 // Letting estate store generate rows to database for us
162 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); 161 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
163 new PropertyScrambler<EstateSettings>().Scramble(originalSettings); 162 new PropertyScrambler<EstateSettings>()
163 .DontScramble(x=>x.EstateID)
164 .Scramble(originalSettings);
164 165
165 // Saving settings. 166 // Saving settings.
166 db.StoreEstateSettings(originalSettings); 167 db.StoreEstateSettings(originalSettings);
diff --git a/OpenSim/Data/Tests/BasicUserTest.cs b/OpenSim/Data/Tests/BasicUserTest.cs
index 1f472a5..d3b6041 100644
--- a/OpenSim/Data/Tests/BasicUserTest.cs
+++ b/OpenSim/Data/Tests/BasicUserTest.cs
@@ -170,8 +170,8 @@ namespace OpenSim.Data.Tests
170 { 170 {
171 UserProfileData u0 = NewUser(zero,fname0,lname0); 171 UserProfileData u0 = NewUser(zero,fname0,lname0);
172 UserProfileData u4 = NewUser(user4,fname2,lname2); 172 UserProfileData u4 = NewUser(user4,fname2,lname2);
173 db.AddNewUserProfile(u0); 173 db.AddNewUserProfile(u0); //UserID 0 should fail to save.
174 db.AddNewUserProfile(u4); 174 db.AddNewUserProfile(u4); //The first name and last name are already in use (from T010), so this should fail too
175 Assert.That(db.GetUserByUUID(zero),Is.Null); 175 Assert.That(db.GetUserByUUID(zero),Is.Null);
176 Assert.That(db.GetUserByUUID(user4),Is.Null); 176 Assert.That(db.GetUserByUUID(user4),Is.Null);
177 } 177 }
@@ -267,8 +267,6 @@ namespace OpenSim.Data.Tests
267 Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt), "Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt))"); 267 Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt), "Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt))");
268 Assert.That(created,Is.EqualTo(u1a.Created), "Assert.That(created,Is.EqualTo(u1a.Created))"); 268 Assert.That(created,Is.EqualTo(u1a.Created), "Assert.That(created,Is.EqualTo(u1a.Created))");
269 Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin), "Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin))"); 269 Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin), "Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin))");
270 // RootInventoryFolderID is not tested because it is saved in SQLite,
271 // but not in MySQL
272 Assert.That(userinvuri,Is.EqualTo(u1a.UserInventoryURI), "Assert.That(userinvuri,Is.EqualTo(u1a.UserInventoryURI))"); 270 Assert.That(userinvuri,Is.EqualTo(u1a.UserInventoryURI), "Assert.That(userinvuri,Is.EqualTo(u1a.UserInventoryURI))");
273 Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI), "Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI))"); 271 Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI), "Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI))");
274 Assert.That(candomask,Is.EqualTo(u1a.CanDoMask), "Assert.That(candomask,Is.EqualTo(u1a.CanDoMask))"); 272 Assert.That(candomask,Is.EqualTo(u1a.CanDoMask), "Assert.That(candomask,Is.EqualTo(u1a.CanDoMask))");
@@ -367,8 +365,6 @@ namespace OpenSim.Data.Tests
367 Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt), "Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt))"); 365 Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt), "Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt))");
368 Assert.That(created,Is.EqualTo(u1a.Created), "Assert.That(created,Is.EqualTo(u1a.Created))"); 366 Assert.That(created,Is.EqualTo(u1a.Created), "Assert.That(created,Is.EqualTo(u1a.Created))");
369 Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin), "Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin))"); 367 Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin), "Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin))");
370 // RootInventoryFolderID is not tested because it is saved in SQLite,
371 // but not in MySQL
372 Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI), "Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI))"); 368 Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI), "Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI))");
373 Assert.That(candomask,Is.EqualTo(u1a.CanDoMask), "Assert.That(candomask,Is.EqualTo(u1a.CanDoMask))"); 369 Assert.That(candomask,Is.EqualTo(u1a.CanDoMask), "Assert.That(candomask,Is.EqualTo(u1a.CanDoMask))");
374 Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask), "Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask))"); 370 Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask), "Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask))");
@@ -395,7 +391,6 @@ namespace OpenSim.Data.Tests
395 Assert.That(u1a, Constraints.PropertyCompareConstraint(u) 391 Assert.That(u1a, Constraints.PropertyCompareConstraint(u)
396 .IgnoreProperty(x=>x.HomeRegionX) 392 .IgnoreProperty(x=>x.HomeRegionX)
397 .IgnoreProperty(x=>x.HomeRegionY) 393 .IgnoreProperty(x=>x.HomeRegionY)
398 .IgnoreProperty(x=>x.RootInventoryFolderID)
399 ); 394 );
400 } 395 }
401 396
diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs
index b652299..57ca704 100644
--- a/OpenSim/Framework/Communications/Services/LoginService.cs
+++ b/OpenSim/Framework/Communications/Services/LoginService.cs
@@ -244,7 +244,6 @@ namespace OpenSim.Framework.Communications.Services
244 InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); 244 InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString();
245 ArrayList InventoryRoot = new ArrayList(); 245 ArrayList InventoryRoot = new ArrayList();
246 InventoryRoot.Add(InventoryRootHash); 246 InventoryRoot.Add(InventoryRootHash);
247 userProfile.RootInventoryFolderID = inventData.RootFolderID;
248 247
249 logResponse.InventoryRoot = InventoryRoot; 248 logResponse.InventoryRoot = InventoryRoot;
250 logResponse.InventorySkeleton = AgentInventoryArray; 249 logResponse.InventorySkeleton = AgentInventoryArray;
@@ -501,7 +500,6 @@ namespace OpenSim.Framework.Communications.Services
501 InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); 500 InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString();
502 ArrayList InventoryRoot = new ArrayList(); 501 ArrayList InventoryRoot = new ArrayList();
503 InventoryRoot.Add(InventoryRootHash); 502 InventoryRoot.Add(InventoryRootHash);
504 userProfile.RootInventoryFolderID = inventData.RootFolderID;
505 503
506 504
507 // Inventory Library Section 505 // Inventory Library Section
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs
index bf4f331..4f0af06 100644
--- a/OpenSim/Framework/Communications/UserManagerBase.cs
+++ b/OpenSim/Framework/Communications/UserManagerBase.cs
@@ -697,9 +697,6 @@ namespace OpenSim.Framework.Communications
697 // local service (standalone) 697 // local service (standalone)
698 m_log.Debug("[USERSTORAGE]: using IInventoryService to create user's inventory"); 698 m_log.Debug("[USERSTORAGE]: using IInventoryService to create user's inventory");
699 m_InventoryService.CreateUserInventory(userProf.ID); 699 m_InventoryService.CreateUserInventory(userProf.ID);
700 InventoryFolderBase rootfolder = m_InventoryService.GetRootFolder(userProf.ID);
701 if (rootfolder != null)
702 userProf.RootInventoryFolderID = rootfolder.ID;
703 } 700 }
704 else if (m_commsManager.InterServiceInventoryService != null) 701 else if (m_commsManager.InterServiceInventoryService != null)
705 { 702 {
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 04ba9c6..cb136e2 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -1077,7 +1077,7 @@ namespace OpenSim.Framework
1077 1077
1078 void SendInstantMessage(GridInstantMessage im); 1078 void SendInstantMessage(GridInstantMessage im);
1079 1079
1080 void SendGenericMessage(string method, List<string> message); 1080 void SendGenericMessage(string method, List<byte[]> message);
1081 1081
1082 void SendLayerData(float[] map); 1082 void SendLayerData(float[] map);
1083 void SendLayerData(int px, int py, float[] map); 1083 void SendLayerData(int px, int py, float[] map);
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index 721233d..c39cc03 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -36,8 +36,59 @@ using OpenMetaverse;
36using OpenMetaverse.StructuredData; 36using OpenMetaverse.StructuredData;
37using OpenSim.Framework.Console; 37using OpenSim.Framework.Console;
38 38
39
39namespace OpenSim.Framework 40namespace OpenSim.Framework
40{ 41{
42 public class RegionMeta7WindlightData
43 {
44 public UUID regionID = UUID.Zero;
45 public Vector3 waterColor = new Vector3(4.0f,38.0f,64.0f);
46 public float waterFogDensityExponent = 4.0f;
47 public float underwaterFogModifier = 0.25f;
48 public Vector3 reflectionWaveletScale = new Vector3(2.0f,2.0f,2.0f);
49 public float fresnelScale = 0.40f;
50 public float fresnelOffset = 0.50f;
51 public float refractScaleAbove = 0.03f;
52 public float refractScaleBelow = 0.20f;
53 public float blurMultiplier = 0.040f;
54 public Vector2 bigWaveDirection = new Vector2(1.05f,-0.42f);
55 public Vector2 littleWaveDirection = new Vector2(1.11f,-1.16f);
56 public UUID normalMapTexture = new UUID("822ded49-9a6c-f61c-cb89-6df54f42cdf4");
57 public Vector4 horizon = new Vector4(0.26f, 0.24f, 0.34f, 0.33f);
58 public float hazeHorizon = 0.19f;
59 public Vector4 blueDensity = new Vector4(0.10f, 0.93f, 0.02f, 0.93f);
60 public float hazeDensity = 0.70f;
61 public float densityMultiplier = 0.18f;
62 public float distanceMultiplier = 0.8f;
63 public UInt16 maxAltitude = 1605;
64 public Vector4 sunMoonColor = new Vector4(0.24f, 0.26f, 0.30f, 0.30f);
65 public float sunMoonPosition = 0.335f;
66 public Vector4 ambient = new Vector4(0.35f,0.35f,0.35f,0.35f);
67 public float eastAngle = 0.0f;
68 public float sunGlowFocus = 0.10f;
69 public float sunGlowSize = 0.10f;
70 public float sceneGamma = 1.0f;
71 public float starBrightness = 0.0f;
72 public Vector4 cloudColor = new Vector4(0.41f, 0.41f, 0.41f, 0.41f);
73 public Vector3 cloudXYDensity = new Vector3(1.00f, 0.53f, 1.00f);
74 public float cloudCoverage = 0.27f;
75 public float cloudScale = 0.42f;
76 public Vector3 cloudDetailXYDensity = new Vector3(1.00f, 0.53f, 0.12f);
77 public float cloudScrollX = 0.20f;
78 public bool cloudScrollXLock = false;
79 public float cloudScrollY = 0.01f;
80 public bool cloudScrollYLock = false;
81 public bool drawClassicClouds = false;
82
83 public delegate void SaveDelegate(RegionMeta7WindlightData wl);
84 public event SaveDelegate OnSave;
85 public void Save()
86 {
87 if (OnSave != null)
88 OnSave(this);
89 }
90 }
91
41 [Serializable] 92 [Serializable]
42 public class SimpleRegionInfo 93 public class SimpleRegionInfo
43 { 94 {
@@ -304,8 +355,7 @@ namespace OpenSim.Framework
304 private bool m_clampPrimSize = false; 355 private bool m_clampPrimSize = false;
305 private int m_objectCapacity = 0; 356 private int m_objectCapacity = 0;
306 private string m_regionType = String.Empty; 357 private string m_regionType = String.Empty;
307 358 private RegionMeta7WindlightData m_windlight = new RegionMeta7WindlightData();
308
309 // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. 359 // Apparently, we're applying the same estatesettings regardless of whether it's local or remote.
310 360
311 // MT: Yes. Estates can't span trust boundaries. Therefore, it can be 361 // MT: Yes. Estates can't span trust boundaries. Therefore, it can be
@@ -454,6 +504,21 @@ namespace OpenSim.Framework
454 set { m_regionSettings = value; } 504 set { m_regionSettings = value; }
455 } 505 }
456 506
507 public RegionMeta7WindlightData WindlightSettings
508 {
509 get
510 {
511 if (m_windlight == null)
512 {
513 m_windlight = new RegionMeta7WindlightData();
514 }
515
516 return m_windlight;
517 }
518
519 set { m_windlight = value; }
520 }
521
457 public int NonphysPrimMax 522 public int NonphysPrimMax
458 { 523 {
459 get { return m_nonphysPrimMax; } 524 get { return m_nonphysPrimMax; }
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index 0d93ff7..655df9d 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -442,7 +442,7 @@ namespace OpenSim.Framework.Servers
442 if (File.Exists(gitCommitFileName)) 442 if (File.Exists(gitCommitFileName))
443 { 443 {
444 StreamReader CommitFile = File.OpenText(gitCommitFileName); 444 StreamReader CommitFile = File.OpenText(gitCommitFileName);
445 buildVersion = Environment.NewLine + "git# " + CommitFile.ReadLine(); 445 buildVersion = CommitFile.ReadLine();
446 CommitFile.Close(); 446 CommitFile.Close();
447 m_version += buildVersion ?? ""; 447 m_version += buildVersion ?? "";
448 } 448 }
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index bec5ed3..75cdeb4 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -724,12 +724,20 @@ namespace OpenSim.Framework.Servers.HttpServer
724 } 724 }
725 catch(Exception e) 725 catch(Exception e)
726 { 726 {
727 string errorMessage
728 = String.Format(
729 "Requested method [{0}] from {1} threw exception: {2} {3}",
730 methodName, request.RemoteIPEndPoint.Address, e.Message, e.StackTrace);
731
732 m_log.ErrorFormat("[BASE HTTP SERVER]: {0}", errorMessage);
733
727 // if the registered XmlRpc method threw an exception, we pass a fault-code along 734 // if the registered XmlRpc method threw an exception, we pass a fault-code along
728 xmlRpcResponse = new XmlRpcResponse(); 735 xmlRpcResponse = new XmlRpcResponse();
736
729 // Code probably set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php 737 // Code probably set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php
730 xmlRpcResponse.SetFault(-32603, String.Format("Requested method [{0}] threw exception: {1}", 738 xmlRpcResponse.SetFault(-32603, errorMessage);
731 methodName, e.Message));
732 } 739 }
740
733 // if the method wasn't found, we can't determine KeepAlive state anyway, so lets do it only here 741 // if the method wasn't found, we can't determine KeepAlive state anyway, so lets do it only here
734 response.KeepAlive = m_rpcHandlersKeepAlive[methodName]; 742 response.KeepAlive = m_rpcHandlersKeepAlive[methodName];
735 } 743 }
diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs
index c53160f..bcfb0a4 100644
--- a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs
+++ b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs
@@ -188,7 +188,15 @@ namespace OpenSim.Framework.Servers.HttpServer
188 try 188 try
189 { 189 {
190 IPAddress addr = IPAddress.Parse(req.Headers["remote_addr"]); 190 IPAddress addr = IPAddress.Parse(req.Headers["remote_addr"]);
191 int port = Int32.Parse(req.Headers["remote_port"]); 191 // sometimes req.Headers["remote_port"] returns a comma separated list, so use
192 // the first one in the list and log it
193 string[] strPorts = req.Headers["remote_port"].Split(new char[] { ',' });
194 if (strPorts.Length > 1)
195 {
196 _log.ErrorFormat("[OSHttpRequest]: format exception on addr/port {0}:{1}, ignoring",
197 req.Headers["remote_addr"], req.Headers["remote_port"]);
198 }
199 int port = Int32.Parse(strPorts[0]);
192 _remoteIPEndPoint = new IPEndPoint(addr, port); 200 _remoteIPEndPoint = new IPEndPoint(addr, port);
193 } 201 }
194 catch (FormatException) 202 catch (FormatException)
diff --git a/OpenSim/Framework/TaskInventoryDictionary.cs b/OpenSim/Framework/TaskInventoryDictionary.cs
index efe5f0c..4b9a509 100644
--- a/OpenSim/Framework/TaskInventoryDictionary.cs
+++ b/OpenSim/Framework/TaskInventoryDictionary.cs
@@ -109,7 +109,10 @@ namespace OpenSim.Framework
109 } 109 }
110 else 110 else
111 { 111 {
112 m_itemLock.ExitReadLock(); 112 if (m_itemLock.RecursiveReadCount>0)
113 {
114 m_itemLock.ExitReadLock();
115 }
113 } 116 }
114 } 117 }
115 118
@@ -144,7 +147,10 @@ namespace OpenSim.Framework
144 } 147 }
145 else 148 else
146 { 149 {
147 m_itemLock.ExitWriteLock(); 150 if (m_itemLock.RecursiveWriteCount > 0)
151 {
152 m_itemLock.ExitWriteLock();
153 }
148 } 154 }
149 } 155 }
150 156
diff --git a/OpenSim/Framework/UserProfileData.cs b/OpenSim/Framework/UserProfileData.cs
index 413f152..9bac739 100644
--- a/OpenSim/Framework/UserProfileData.cs
+++ b/OpenSim/Framework/UserProfileData.cs
@@ -119,8 +119,6 @@ namespace OpenSim.Framework
119 /// </summary> 119 /// </summary>
120 private string m_profileUrl; 120 private string m_profileUrl;
121 121
122 private UUID m_rootInventoryFolderId;
123
124 /// <summary> 122 /// <summary>
125 /// The second component of a users account name 123 /// The second component of a users account name
126 /// </summary> 124 /// </summary>
@@ -312,12 +310,6 @@ namespace OpenSim.Framework
312 set { m_lastLogin = value; } 310 set { m_lastLogin = value; }
313 } 311 }
314 312
315 public UUID RootInventoryFolderID
316 {
317 get { return m_rootInventoryFolderId; }
318 set { m_rootInventoryFolderId = value; }
319 }
320
321 public string UserInventoryURI 313 public string UserInventoryURI
322 { 314 {
323 get { return m_userInventoryUri; } 315 get { return m_userInventoryUri; }
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index c052745..b5e2872 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1390,5 +1390,29 @@ namespace OpenSim.Framework
1390 } 1390 }
1391 1391
1392 #endregion FireAndForget Threading Pattern 1392 #endregion FireAndForget Threading Pattern
1393 /// <summary>
1394 /// Environment.TickCount is an int but it counts all 32 bits so it goes positive
1395 /// and negative every 24.9 days. This trims down TickCount so it doesn't wrap
1396 /// for the callers.
1397 /// This trims it to a 12 day interval so don't let your frame time get too long.
1398 /// </summary>
1399 /// <returns></returns>
1400 public static Int32 EnvironmentTickCount()
1401 {
1402 return Environment.TickCount & EnvironmentTickCountMask;
1403 }
1404 const Int32 EnvironmentTickCountMask = 0x3fffffff;
1405
1406 /// <summary>
1407 /// Environment.TickCount is an int but it counts all 32 bits so it goes positive
1408 /// and negative every 24.9 days. Subtracts the passed value (previously fetched by
1409 /// 'EnvironmentTickCount()') and accounts for any wrapping.
1410 /// </summary>
1411 /// <returns>subtraction of passed prevValue from current Environment.TickCount</returns>
1412 public static Int32 EnvironmentTickCountSubtract(Int32 prevValue)
1413 {
1414 Int32 diff = EnvironmentTickCount() - prevValue;
1415 return (diff >= 0) ? diff : (diff + EnvironmentTickCountMask + 1);
1416 }
1393 } 1417 }
1394} 1418}
diff --git a/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs b/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs
index f24cef6..3384952 100644
--- a/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs
+++ b/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs
@@ -201,6 +201,7 @@ namespace OpenSim.Grid.UserServer.Modules
201 } 201 }
202 return response; 202 return response;
203 } 203 }
204
204 public XmlRpcResponse XmlRPCUserMovedtoRegion(XmlRpcRequest request, IPEndPoint remoteClient) 205 public XmlRpcResponse XmlRPCUserMovedtoRegion(XmlRpcRequest request, IPEndPoint remoteClient)
205 { 206 {
206 XmlRpcResponse response = new XmlRpcResponse(); 207 XmlRpcResponse response = new XmlRpcResponse();
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 5228e4b..82b2fd4 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -939,8 +939,8 @@ namespace OpenSim
939 m_log.Info(String.Format("\nAgents connected: {0}\n", agents.Count)); 939 m_log.Info(String.Format("\nAgents connected: {0}\n", agents.Count));
940 940
941 m_log.Info( 941 m_log.Info(
942 String.Format("{0,-16}{1,-16}{2,-37}{3,-11}{4,-16}", "Firstname", "Lastname", 942 String.Format("{0,-16}{1,-16}{2,-37}{3,-11}{4,-16}{5,-30}", "Firstname", "Lastname",
943 "Agent ID", "Root/Child", "Region")); 943 "Agent ID", "Root/Child", "Region", "Position"));
944 944
945 foreach (ScenePresence presence in agents) 945 foreach (ScenePresence presence in agents)
946 { 946 {
@@ -958,12 +958,13 @@ namespace OpenSim
958 958
959 m_log.Info( 959 m_log.Info(
960 String.Format( 960 String.Format(
961 "{0,-16}{1,-16}{2,-37}{3,-11}{4,-16}", 961 "{0,-16}{1,-16}{2,-37}{3,-11}{4,-16}{5,-30}",
962 presence.Firstname, 962 presence.Firstname,
963 presence.Lastname, 963 presence.Lastname,
964 presence.UUID, 964 presence.UUID,
965 presence.IsChildAgent ? "Child" : "Root", 965 presence.IsChildAgent ? "Child" : "Root",
966 regionName)); 966 regionName,
967 presence.AbsolutePosition.ToString()));
967 } 968 }
968 969
969 m_log.Info(String.Empty); 970 m_log.Info(String.Empty);
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index ac16b02..2b5e632 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -352,6 +352,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
352 private IHyperAssetService m_hyperAssets; 352 private IHyperAssetService m_hyperAssets;
353 private const bool m_checkPackets = true; 353 private const bool m_checkPackets = true;
354 354
355 private Timer m_propertiesPacketTimer;
356 private List<ObjectPropertiesPacket.ObjectDataBlock> m_propertiesBlocks = new List<ObjectPropertiesPacket.ObjectDataBlock>();
357
355 #endregion Class Members 358 #endregion Class Members
356 359
357 #region Properties 360 #region Properties
@@ -433,6 +436,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
433 m_udpClient.OnQueueEmpty += HandleQueueEmpty; 436 m_udpClient.OnQueueEmpty += HandleQueueEmpty;
434 m_udpClient.OnPacketStats += PopulateStats; 437 m_udpClient.OnPacketStats += PopulateStats;
435 438
439 m_propertiesPacketTimer = new Timer(100);
440 m_propertiesPacketTimer.Elapsed += ProcessObjectPropertiesPacket;
441
436 RegisterLocalPacketHandlers(); 442 RegisterLocalPacketHandlers();
437 } 443 }
438 444
@@ -764,16 +770,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
764 } 770 }
765 } 771 }
766 772
767 public void SendGenericMessage(string method, List<string> message) 773 public void SendGenericMessage(string method, List<byte[]> message)
768 { 774 {
769 GenericMessagePacket gmp = new GenericMessagePacket(); 775 GenericMessagePacket gmp = new GenericMessagePacket();
770 gmp.MethodData.Method = Util.StringToBytes256(method); 776 gmp.MethodData.Method = Util.StringToBytes256(method);
771 gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count]; 777 gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
772 int i = 0; 778 int i = 0;
773 foreach (string val in message) 779 foreach (byte[] val in message)
774 { 780 {
775 gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock(); 781 gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
776 gmp.ParamList[i++].Parameter = Util.StringToBytes256(val); 782 gmp.ParamList[i++].Parameter = val;
777 } 783 }
778 OutPacket(gmp, ThrottleOutPacketType.Task); 784 OutPacket(gmp, ThrottleOutPacketType.Task);
779 } 785 }
@@ -3562,42 +3568,88 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3562 string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask, 3568 string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask,
3563 uint BaseMask, byte saleType, int salePrice) 3569 uint BaseMask, byte saleType, int salePrice)
3564 { 3570 {
3565 ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties); 3571 //ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
3566 // TODO: don't create new blocks if recycling an old packet 3572 // TODO: don't create new blocks if recycling an old packet
3567 3573
3568 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; 3574 ObjectPropertiesPacket.ObjectDataBlock block =
3569 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); 3575 new ObjectPropertiesPacket.ObjectDataBlock();
3570 proper.ObjectData[0].ItemID = ItemID; 3576
3571 proper.ObjectData[0].CreationDate = CreationDate; 3577 block.ItemID = ItemID;
3572 proper.ObjectData[0].CreatorID = CreatorUUID; 3578 block.CreationDate = CreationDate;
3573 proper.ObjectData[0].FolderID = FolderUUID; 3579 block.CreatorID = CreatorUUID;
3574 proper.ObjectData[0].FromTaskID = FromTaskUUID; 3580 block.FolderID = FolderUUID;
3575 proper.ObjectData[0].GroupID = GroupUUID; 3581 block.FromTaskID = FromTaskUUID;
3576 proper.ObjectData[0].InventorySerial = InventorySerial; 3582 block.GroupID = GroupUUID;
3577 3583 block.InventorySerial = InventorySerial;
3578 proper.ObjectData[0].LastOwnerID = LastOwnerUUID; 3584
3585 block.LastOwnerID = LastOwnerUUID;
3579 // proper.ObjectData[0].LastOwnerID = UUID.Zero; 3586 // proper.ObjectData[0].LastOwnerID = UUID.Zero;
3580 3587
3581 proper.ObjectData[0].ObjectID = ObjectUUID; 3588 block.ObjectID = ObjectUUID;
3582 if (OwnerUUID == GroupUUID) 3589 if (OwnerUUID == GroupUUID)
3583 proper.ObjectData[0].OwnerID = UUID.Zero; 3590 block.OwnerID = UUID.Zero;
3584 else 3591 else
3585 proper.ObjectData[0].OwnerID = OwnerUUID; 3592 block.OwnerID = OwnerUUID;
3586 proper.ObjectData[0].TouchName = Util.StringToBytes256(TouchTitle); 3593 block.TouchName = Util.StringToBytes256(TouchTitle);
3587 proper.ObjectData[0].TextureID = TextureID; 3594 block.TextureID = TextureID;
3588 proper.ObjectData[0].SitName = Util.StringToBytes256(SitTitle); 3595 block.SitName = Util.StringToBytes256(SitTitle);
3589 proper.ObjectData[0].Name = Util.StringToBytes256(ItemName); 3596 block.Name = Util.StringToBytes256(ItemName);
3590 proper.ObjectData[0].Description = Util.StringToBytes256(ItemDescription); 3597 block.Description = Util.StringToBytes256(ItemDescription);
3591 proper.ObjectData[0].OwnerMask = OwnerMask; 3598 block.OwnerMask = OwnerMask;
3592 proper.ObjectData[0].NextOwnerMask = NextOwnerMask; 3599 block.NextOwnerMask = NextOwnerMask;
3593 proper.ObjectData[0].GroupMask = GroupMask; 3600 block.GroupMask = GroupMask;
3594 proper.ObjectData[0].EveryoneMask = EveryoneMask; 3601 block.EveryoneMask = EveryoneMask;
3595 proper.ObjectData[0].BaseMask = BaseMask; 3602 block.BaseMask = BaseMask;
3596 // proper.ObjectData[0].AggregatePerms = 53; 3603 // proper.ObjectData[0].AggregatePerms = 53;
3597 // proper.ObjectData[0].AggregatePermTextures = 0; 3604 // proper.ObjectData[0].AggregatePermTextures = 0;
3598 // proper.ObjectData[0].AggregatePermTexturesOwner = 0; 3605 // proper.ObjectData[0].AggregatePermTexturesOwner = 0;
3599 proper.ObjectData[0].SaleType = saleType; 3606 block.SaleType = saleType;
3600 proper.ObjectData[0].SalePrice = salePrice; 3607 block.SalePrice = salePrice;
3608
3609 lock (m_propertiesPacketTimer)
3610 {
3611 m_propertiesBlocks.Add(block);
3612
3613 int length = 0;
3614 foreach (ObjectPropertiesPacket.ObjectDataBlock b in m_propertiesBlocks)
3615 {
3616 length += b.Length;
3617 }
3618 if (length > 1100) // FIXME: use real MTU
3619 {
3620 ProcessObjectPropertiesPacket(null, null);
3621 m_propertiesPacketTimer.Stop();
3622 return;
3623 }
3624
3625 m_propertiesPacketTimer.Stop();
3626 m_propertiesPacketTimer.Start();
3627 }
3628
3629 //proper.Header.Zerocoded = true;
3630 //OutPacket(proper, ThrottleOutPacketType.Task);
3631 }
3632
3633 private void ProcessObjectPropertiesPacket(Object sender, ElapsedEventArgs e)
3634 {
3635 ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
3636
3637 lock (m_propertiesPacketTimer)
3638 {
3639 m_propertiesPacketTimer.Stop();
3640
3641 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[m_propertiesBlocks.Count];
3642
3643 int index = 0;
3644
3645 foreach (ObjectPropertiesPacket.ObjectDataBlock b in m_propertiesBlocks)
3646 {
3647 proper.ObjectData[index++] = b;
3648 }
3649
3650 m_propertiesBlocks.Clear();
3651 }
3652
3601 proper.Header.Zerocoded = true; 3653 proper.Header.Zerocoded = true;
3602 OutPacket(proper, ThrottleOutPacketType.Task); 3654 OutPacket(proper, ThrottleOutPacketType.Task);
3603 } 3655 }
@@ -5504,6 +5556,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5504 5556
5505 if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId) 5557 if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId)
5506 { 5558 {
5559 // Linden Client limitation..
5560 if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f
5561 || avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
5562 {
5563 ScenePresence avatar = null;
5564 if (((Scene)m_scene).TryGetAvatar(AgentId, out avatar))
5565 {
5566 if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f)
5567 {
5568 avSetStartLocationRequestPacket.StartLocationData.LocationPos.X = avatar.AbsolutePosition.X;
5569 }
5570 if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
5571 {
5572 avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y = avatar.AbsolutePosition.Y;
5573 }
5574 }
5575
5576 }
5507 TeleportLocationRequest handlerSetStartLocationRequest = OnSetStartLocationRequest; 5577 TeleportLocationRequest handlerSetStartLocationRequest = OnSetStartLocationRequest;
5508 if (handlerSetStartLocationRequest != null) 5578 if (handlerSetStartLocationRequest != null)
5509 { 5579 {
@@ -13593,7 +13663,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
13593 if (handlerGodKickUser != null) 13663 if (handlerGodKickUser != null)
13594 { 13664 {
13595 handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID, 13665 handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID,
13596 gkupack.UserInfo.AgentID, (uint)0, gkupack.UserInfo.Reason); 13666 gkupack.UserInfo.AgentID, gkupack.UserInfo.KickFlags, gkupack.UserInfo.Reason,gkupack.UserInfo);
13597 } 13667 }
13598 } 13668 }
13599 else 13669 else
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
index 9856a1c..55d9c9c 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Threading;
31using log4net; 32using log4net;
32using OpenSim.Framework; 33using OpenSim.Framework;
33using OpenMetaverse; 34using OpenMetaverse;
@@ -430,6 +431,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
430 m_udpServer.SendPacketFinal(nextPacket); 431 m_udpServer.SendPacketFinal(nextPacket);
431 m_nextPackets[i] = null; 432 m_nextPackets[i] = null;
432 packetSent = true; 433 packetSent = true;
434 this.PacketsSent++;
433 } 435 }
434 } 436 }
435 else 437 else
@@ -446,6 +448,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
446 // Send the packet 448 // Send the packet
447 m_udpServer.SendPacketFinal(packet); 449 m_udpServer.SendPacketFinal(packet);
448 packetSent = true; 450 packetSent = true;
451 this.PacketsSent++;
449 } 452 }
450 else 453 else
451 { 454 {
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 98bb4f7..85961b9 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -138,6 +138,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
138 /// whether or not to sleep</summary> 138 /// whether or not to sleep</summary>
139 private bool m_packetSent; 139 private bool m_packetSent;
140 140
141 /// <summary>Environment.TickCount of the last time that packet stats were reported to the scene</summary>
142 private int m_elapsedMSSinceLastStatReport = 0;
141 /// <summary>Environment.TickCount of the last time the outgoing packet handler executed</summary> 143 /// <summary>Environment.TickCount of the last time the outgoing packet handler executed</summary>
142 private int m_tickLastOutgoingPacketHandler; 144 private int m_tickLastOutgoingPacketHandler;
143 /// <summary>Keeps track of the number of elapsed milliseconds since the last time the outgoing packet handler looped</summary> 145 /// <summary>Keeps track of the number of elapsed milliseconds since the last time the outgoing packet handler looped</summary>
@@ -246,6 +248,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
246 // Start the packet processing threads 248 // Start the packet processing threads
247 Watchdog.StartThread(IncomingPacketHandler, "Incoming Packets (" + m_scene.RegionInfo.RegionName + ")", ThreadPriority.Normal, false); 249 Watchdog.StartThread(IncomingPacketHandler, "Incoming Packets (" + m_scene.RegionInfo.RegionName + ")", ThreadPriority.Normal, false);
248 Watchdog.StartThread(OutgoingPacketHandler, "Outgoing Packets (" + m_scene.RegionInfo.RegionName + ")", ThreadPriority.Normal, false); 250 Watchdog.StartThread(OutgoingPacketHandler, "Outgoing Packets (" + m_scene.RegionInfo.RegionName + ")", ThreadPriority.Normal, false);
251 m_elapsedMSSinceLastStatReport = Environment.TickCount;
249 } 252 }
250 253
251 public new void Stop() 254 public new void Stop()
@@ -737,6 +740,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
737 // We don't need to do anything else with ping checks 740 // We don't need to do anything else with ping checks
738 StartPingCheckPacket startPing = (StartPingCheckPacket)packet; 741 StartPingCheckPacket startPing = (StartPingCheckPacket)packet;
739 CompletePing(udpClient, startPing.PingID.PingID); 742 CompletePing(udpClient, startPing.PingID.PingID);
743
744 if ((Environment.TickCount - m_elapsedMSSinceLastStatReport) >= 3000)
745 {
746 udpClient.SendPacketStats();
747 m_elapsedMSSinceLastStatReport = Environment.TickCount;
748 }
740 return; 749 return;
741 } 750 }
742 else if (packet.Type == PacketType.CompletePingCheck) 751 else if (packet.Type == PacketType.CompletePingCheck)
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
index 273c128..7e1bed5 100644
--- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
@@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
98 /// <param name="godID">The person doing the kicking</param> 98 /// <param name="godID">The person doing the kicking</param>
99 /// <param name="sessionID">The session of the person doing the kicking</param> 99 /// <param name="sessionID">The session of the person doing the kicking</param>
100 /// <param name="agentID">the person that is being kicked</param> 100 /// <param name="agentID">the person that is being kicked</param>
101 /// <param name="kickflags">This isn't used apparently</param> 101 /// <param name="kickflags">Tells what to do to the user</param>
102 /// <param name="reason">The message to send to the user after it's been turned into a field</param> 102 /// <param name="reason">The message to send to the user after it's been turned into a field</param>
103 public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason) 103 public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason)
104 { 104 {
@@ -110,39 +110,56 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
110 { 110 {
111 if (m_scene.Permissions.IsGod(godID)) 111 if (m_scene.Permissions.IsGod(godID))
112 { 112 {
113 if (agentID == kickUserID) 113 if (kickflags == 0)
114 { 114 {
115 string reasonStr = Utils.BytesToString(reason); 115 if (agentID == kickUserID)
116 {
117 string reasonStr = Utils.BytesToString(reason);
116 118
117 m_scene.ForEachClient( 119 m_scene.ForEachClient(
118 delegate(IClientAPI controller) 120 delegate(IClientAPI controller)
119 { 121 {
120 if (controller.AgentId != godID) 122 if (controller.AgentId != godID)
121 controller.Kick(reasonStr); 123 controller.Kick(reasonStr);
122 } 124 }
123 ); 125 );
124 126
125 // This is a bit crude. It seems the client will be null before it actually stops the thread 127 // This is a bit crude. It seems the client will be null before it actually stops the thread
126 // The thread will kill itself eventually :/ 128 // The thread will kill itself eventually :/
127 // Is there another way to make sure *all* clients get this 'inter region' message? 129 // Is there another way to make sure *all* clients get this 'inter region' message?
128 m_scene.ForEachScenePresence( 130 m_scene.ForEachScenePresence(
129 delegate(ScenePresence p) 131 delegate(ScenePresence p)
130 {
131 if (p.UUID != godID && !p.IsChildAgent)
132 { 132 {
133 // Possibly this should really be p.Close() though that method doesn't send a close 133 if (p.UUID != godID && !p.IsChildAgent)
134 // to the client 134 {
135 p.ControllingClient.Close(); 135 // Possibly this should really be p.Close() though that method doesn't send a close
136 // to the client
137 p.ControllingClient.Close();
138 }
136 } 139 }
137 } 140 );
138 ); 141 }
142 else
143 {
144 m_scene.SceneGraph.removeUserCount(!sp.IsChildAgent);
145
146 sp.ControllingClient.Kick(Utils.BytesToString(reason));
147 sp.ControllingClient.Close();
148 }
139 } 149 }
140 else 150
151 if (kickflags == 1)
141 { 152 {
142 m_scene.SceneGraph.removeUserCount(!sp.IsChildAgent); 153 sp.AllowMovement = false;
143 154 m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
144 sp.ControllingClient.Kick(Utils.BytesToString(reason)); 155 m_dialogModule.SendAlertToUser(godID, "User Frozen");
145 sp.ControllingClient.Close(); 156 }
157
158 if (kickflags == 2)
159 {
160 sp.AllowMovement = true;
161 m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
162 m_dialogModule.SendAlertToUser(godID, "User Unfrozen");
146 } 163 }
147 } 164 }
148 else 165 else
diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
index 62500a2..c727cec 100644
--- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
+++ b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
@@ -527,7 +527,6 @@ namespace OpenSim.Region.CoreModules.InterGrid
527 userProfile.Partner = UUID.Zero; 527 userProfile.Partner = UUID.Zero;
528 userProfile.PasswordHash = "$1$"; 528 userProfile.PasswordHash = "$1$";
529 userProfile.PasswordSalt = ""; 529 userProfile.PasswordSalt = "";
530 userProfile.RootInventoryFolderID = UUID.Zero;
531 userProfile.SurName = agentData.lastname; 530 userProfile.SurName = agentData.lastname;
532 userProfile.UserAssetURI = homeScene.CommsManager.NetworkServersInfo.AssetURL; 531 userProfile.UserAssetURI = homeScene.CommsManager.NetworkServersInfo.AssetURL;
533 userProfile.UserFlags = 0; 532 userProfile.UserFlags = 0;
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
index d4a28e2..60df2e7 100644
--- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
@@ -602,9 +602,12 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
602 ListenerInfo info = 602 ListenerInfo info =
603 ListenerInfo.FromData(localID, itemID, hostID, item); 603 ListenerInfo.FromData(localID, itemID, hostID, item);
604 604
605 if (!m_listeners.ContainsKey((int)item[2])) 605 lock (m_listeners)
606 m_listeners.Add((int)item[2], new List<ListenerInfo>()); 606 {
607 m_listeners[(int)item[2]].Add(info); 607 if (!m_listeners.ContainsKey((int)item[2]))
608 m_listeners.Add((int)item[2], new List<ListenerInfo>());
609 m_listeners[(int)item[2]].Add(info);
610 }
608 611
609 idx+=6; 612 idx+=6;
610 } 613 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
index fca2df2..68499f3 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
@@ -70,7 +70,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
70 IConfig authorizationConfig = source.Configs["AuthorizationService"]; 70 IConfig authorizationConfig = source.Configs["AuthorizationService"];
71 if (authorizationConfig == null) 71 if (authorizationConfig == null)
72 { 72 {
73 m_log.Error("[REMOTE AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini"); 73 m_log.Info("[REMOTE AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini");
74 return; 74 return;
75 } 75 }
76 76
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 114dd13..3c0997c 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -453,6 +453,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
453 /// <summary> 453 /// <summary>
454 /// Resolve path to a working FileStream 454 /// Resolve path to a working FileStream
455 /// </summary> 455 /// </summary>
456 /// <param name="path"></param>
457 /// <returns></returns>
456 private Stream GetStream(string path) 458 private Stream GetStream(string path)
457 { 459 {
458 if (File.Exists(path)) 460 if (File.Exists(path))
@@ -499,8 +501,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
499 WebResponse response = request.GetResponse(); 501 WebResponse response = request.GetResponse();
500 Stream file = response.GetResponseStream(); 502 Stream file = response.GetResponseStream();
501 503
502 if (response.ContentType != "application/x-oar") 504 // justincc: gonna ignore the content type for now and just try anything
503 throw new Exception(String.Format("{0} does not identify an OAR file", uri.ToString())); 505 //if (response.ContentType != "application/x-oar")
506 // throw new Exception(String.Format("{0} does not identify an OAR file", uri.ToString()));
504 507
505 if (response.ContentLength == 0) 508 if (response.ContentLength == 0)
506 throw new Exception(String.Format("{0} returned an empty file", uri.ToString())); 509 throw new Exception(String.Format("{0} returned an empty file", uri.ToString()));
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index e3a395e..b1dcb14 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -471,20 +471,45 @@ namespace OpenSim.Region.CoreModules.World.Estate
471 if (terr != null) 471 if (terr != null)
472 { 472 {
473 m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + m_scene.RegionInfo.RegionName); 473 m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + m_scene.RegionInfo.RegionName);
474 if (File.Exists(Util.dataDir() + "/terrain.raw")) 474
475 {
476 File.Delete(Util.dataDir() + "/terrain.raw");
477 }
478 try 475 try
479 { 476 {
480 FileStream input = new FileStream(Util.dataDir() + "/terrain.raw", FileMode.CreateNew); 477
478 string localfilename = "terrain.raw";
479
480 if (terrainData.Length == 851968)
481 {
482 localfilename = Path.Combine(Util.dataDir(),"terrain.raw"); // It's a .LLRAW
483 }
484
485 if (terrainData.Length == 196662) // 24-bit 256x256 Bitmap
486 localfilename = Path.Combine(Util.dataDir(), "terrain.bmp");
487
488 if (terrainData.Length == 256 * 256 * 4) // It's a .R32
489 localfilename = Path.Combine(Util.dataDir(), "terrain.r32");
490
491 if (terrainData.Length == 256 * 256 * 8) // It's a .R64
492 localfilename = Path.Combine(Util.dataDir(), "terrain.r64");
493
494 if (File.Exists(localfilename))
495 {
496 File.Delete(localfilename);
497 }
498
499 FileStream input = new FileStream(localfilename, FileMode.CreateNew);
481 input.Write(terrainData, 0, terrainData.Length); 500 input.Write(terrainData, 0, terrainData.Length);
482 input.Close(); 501 input.Close();
502
503 FileInfo x = new FileInfo(localfilename);
504
505 terr.LoadFromFile(localfilename);
506 remoteClient.SendAlertMessage("Your terrain was loaded as a ." + x.Extension + " file. It may take a few moments to appear.");
507
483 } 508 }
484 catch (IOException e) 509 catch (IOException e)
485 { 510 {
486 m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString()); 511 m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
487 remoteClient.SendAlertMessage("There was an IO Exception loading your terrain. Please check free space"); 512 remoteClient.SendAlertMessage("There was an IO Exception loading your terrain. Please check free space.");
488 513
489 return; 514 return;
490 } 515 }
@@ -502,29 +527,16 @@ namespace OpenSim.Region.CoreModules.World.Estate
502 527
503 return; 528 return;
504 } 529 }
505
506
507
508
509 try
510 {
511 terr.LoadFromFile(Util.dataDir() + "/terrain.raw");
512 remoteClient.SendAlertMessage("Your terrain was loaded. Give it a minute or two to apply");
513 }
514 catch (Exception e) 530 catch (Exception e)
515 { 531 {
516 m_log.ErrorFormat("[TERRAIN]: Error loading a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString()); 532 m_log.ErrorFormat("[TERRAIN]: Error loading a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
517 remoteClient.SendAlertMessage("There was a general error loading your terrain. Please fix the terrain file and try again"); 533 remoteClient.SendAlertMessage("There was a general error loading your terrain. Please fix the terrain file and try again");
518 } 534 }
519
520 } 535 }
521 else 536 else
522 { 537 {
523 remoteClient.SendAlertMessage("Unable to apply terrain. Cannot get an instance of the terrain module"); 538 remoteClient.SendAlertMessage("Unable to apply terrain. Cannot get an instance of the terrain module");
524 } 539 }
525
526
527
528 } 540 }
529 541
530 private void handleUploadTerrain(IClientAPI remote_client, string clientFileName) 542 private void handleUploadTerrain(IClientAPI remote_client, string clientFileName)
diff --git a/OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs b/OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs
new file mode 100644
index 0000000..f180b47
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs
@@ -0,0 +1,245 @@
1/*
2 * Copyright (c) Thomas Grimshaw and Magne Metaverse Research
3 *
4 * This module is not open source. All rights reserved.
5 * Unauthorised copying, distribution or public display is prohibited.
6 *
7 */
8
9using System;
10using System.Collections.Generic;
11using System.IO;
12using System.Reflection;
13using OpenMetaverse;
14using log4net;
15using Nini.Config;
16using OpenSim.Data;
17using OpenSim.Framework;
18using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
19using OpenSim.Region.Framework.Interfaces;
20using OpenSim.Region.Framework.Scenes;
21
22
23namespace OpenSim.Region.CoreModules.World.Meta7Windlight
24{
25 public class Meta7WindlightModule : IRegionModule, ICommandableModule
26 {
27 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
28 private readonly Commander m_commander = new Commander("windlight");
29 private Scene m_scene;
30 private static bool m_enableWindlight;
31
32 #region ICommandableModule Members
33
34 public ICommander CommandInterface
35 {
36 get { return m_commander; }
37 }
38
39 #endregion
40
41 #region IRegionModule Members
42
43 public static bool EnableWindlight
44 {
45 get
46 {
47 return m_enableWindlight;
48 }
49 set
50 {
51 }
52 }
53
54 public void Initialise(Scene scene, IConfigSource config)
55 {
56 m_scene = scene;
57 m_scene.RegisterModuleInterface<IRegionModule>(this);
58 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
59
60 // ini file settings
61 try
62 {
63 m_enableWindlight = config.Configs["Meta7Windlight"].GetBoolean("enable_windlight", false);
64 }
65 catch (Exception)
66 {
67 m_log.Debug("[WINDLIGHT]: ini failure for enable_windlight - using default");
68 }
69
70 if (m_enableWindlight)
71 {
72 m_scene.EventManager.OnMakeRootAgent += EventManager_OnMakeRootAgent;
73 m_scene.EventManager.OnSaveNewWindlightProfile += EventManager_OnSaveNewWindlightProfile;
74 }
75
76 InstallCommands();
77
78 m_log.Debug("[WINDLIGHT]: Initialised windlight module");
79 }
80 public void SendProfileToClient(ScenePresence presence)
81 {
82 if (m_enableWindlight)
83 {
84 if (presence.IsChildAgent == false)
85 {
86 IClientAPI client = presence.ControllingClient;
87 RegionMeta7WindlightData wl = m_scene.RegionInfo.WindlightSettings;
88 byte[] mBlock = new Byte[249];
89 int pos = 0;
90
91 wl.waterColor.ToBytes(mBlock, 0); pos += 12;
92 Utils.FloatToBytes(wl.waterFogDensityExponent).CopyTo(mBlock, pos); pos += 4;
93 Utils.FloatToBytes(wl.underwaterFogModifier).CopyTo(mBlock, pos); pos += 4;
94 wl.reflectionWaveletScale.ToBytes(mBlock, pos); pos += 12;
95 Utils.FloatToBytes(wl.fresnelScale).CopyTo(mBlock, pos); pos += 4;
96 Utils.FloatToBytes(wl.fresnelOffset).CopyTo(mBlock, pos); pos += 4;
97 Utils.FloatToBytes(wl.refractScaleAbove).CopyTo(mBlock, pos); pos += 4;
98 Utils.FloatToBytes(wl.refractScaleBelow).CopyTo(mBlock, pos); pos += 4;
99 Utils.FloatToBytes(wl.blurMultiplier).CopyTo(mBlock, pos); pos += 4;
100 wl.bigWaveDirection.ToBytes(mBlock, pos); pos += 8;
101 wl.littleWaveDirection.ToBytes(mBlock, pos); pos += 8;
102 wl.normalMapTexture.ToBytes(mBlock, pos); pos += 16;
103 wl.horizon.ToBytes(mBlock, pos); pos += 16;
104 Utils.FloatToBytes(wl.hazeHorizon).CopyTo(mBlock, pos); pos += 4;
105 wl.blueDensity.ToBytes(mBlock, pos); pos += 16;
106 Utils.FloatToBytes(wl.hazeDensity).CopyTo(mBlock, pos); pos += 4;
107 Utils.FloatToBytes(wl.densityMultiplier).CopyTo(mBlock, pos); pos += 4;
108 Utils.FloatToBytes(wl.distanceMultiplier).CopyTo(mBlock, pos); pos += 4;
109 wl.sunMoonColor.ToBytes(mBlock, pos); pos += 16;
110 Utils.FloatToBytes(wl.sunMoonPosition).CopyTo(mBlock, pos); pos += 4;
111 wl.ambient.ToBytes(mBlock, pos); pos += 16;
112 Utils.FloatToBytes(wl.eastAngle).CopyTo(mBlock, pos); pos += 4;
113 Utils.FloatToBytes(wl.sunGlowFocus).CopyTo(mBlock, pos); pos += 4;
114 Utils.FloatToBytes(wl.sunGlowSize).CopyTo(mBlock, pos); pos += 4;
115 Utils.FloatToBytes(wl.sceneGamma).CopyTo(mBlock, pos); pos += 4;
116 Utils.FloatToBytes(wl.starBrightness).CopyTo(mBlock, pos); pos += 4;
117 wl.cloudColor.ToBytes(mBlock, pos); pos += 16;
118 wl.cloudXYDensity.ToBytes(mBlock, pos); pos += 12;
119 Utils.FloatToBytes(wl.cloudCoverage).CopyTo(mBlock, pos); pos += 4;
120 Utils.FloatToBytes(wl.cloudScale).CopyTo(mBlock, pos); pos += 4;
121 wl.cloudDetailXYDensity.ToBytes(mBlock, pos); pos += 12;
122 Utils.FloatToBytes(wl.cloudScrollX).CopyTo(mBlock, pos); pos += 4;
123 Utils.FloatToBytes(wl.cloudScrollY).CopyTo(mBlock, pos); pos += 4;
124 Utils.UInt16ToBytes(wl.maxAltitude).CopyTo(mBlock, pos); pos += 2;
125 mBlock[pos] = Convert.ToByte(wl.cloudScrollXLock); pos++;
126 mBlock[pos] = Convert.ToByte(wl.cloudScrollYLock); pos++;
127 mBlock[pos] = Convert.ToByte(wl.drawClassicClouds); pos++;
128 List<byte[]> param = new List<byte[]>();
129 param.Add(mBlock);
130
131 client.SendGenericMessage("Windlight", param);
132 }
133 }
134 else
135 {
136 //We probably don't want to spam chat with this.. probably
137 //m_log.Debug("[WINDLIGHT]: Module disabled");
138 }
139 }
140 private void EventManager_OnMakeRootAgent(ScenePresence presence)
141 {
142 m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client");
143 SendProfileToClient(presence);
144 }
145
146 private void EventManager_OnSaveNewWindlightProfile()
147 {
148 m_scene.ForEachScenePresence(SendProfileToClient);
149 }
150
151 public void PostInitialise()
152 {
153
154 }
155
156 public void Close()
157 {
158 }
159
160 public string Name
161 {
162 get { return "Meta7WindlightModule"; }
163 }
164
165 public bool IsSharedModule
166 {
167 get { return false; }
168 }
169
170 #endregion
171
172 #region events
173
174 #endregion
175
176 #region ICommandableModule Members
177
178 private void InstallCommands()
179 {
180 Command wlload = new Command("load", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleLoad, "Load windlight profile from the database and broadcast");
181 Command wlenable = new Command("enable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleEnable, "Enable the windlight plugin");
182 Command wldisable = new Command("disable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleDisable, "Enable the windlight plugin");
183
184 m_commander.RegisterCommand("load", wlload);
185 m_commander.RegisterCommand("enable", wlenable);
186 m_commander.RegisterCommand("disable", wldisable);
187
188 m_scene.RegisterModuleCommander(m_commander);
189 }
190
191 private void HandleLoad(Object[] args)
192 {
193 if (!m_enableWindlight)
194 {
195 m_log.InfoFormat("[WINDLIGHT]: Cannot load windlight profile, module disabled. Use 'windlight enable' first.");
196 }
197 else
198 {
199 m_log.InfoFormat("[WINDLIGHT]: Loading Windlight profile from database");
200 m_scene.LoadWindlightProfile();
201 m_log.InfoFormat("[WINDLIGHT]: Load complete");
202 }
203 }
204
205 private void HandleDisable(Object[] args)
206 {
207 m_log.InfoFormat("[WINDLIGHT]: Plugin now disabled");
208 m_enableWindlight=false;
209 }
210
211 private void HandleEnable(Object[] args)
212 {
213 m_log.InfoFormat("[WINDLIGHT]: Plugin now enabled");
214 m_enableWindlight = true;
215 }
216
217 /// <summary>
218 /// Processes commandline input. Do not call directly.
219 /// </summary>
220 /// <param name="args">Commandline arguments</param>
221 private void EventManager_OnPluginConsole(string[] args)
222 {
223 if (args[0] == "windlight")
224 {
225 if (args.Length == 1)
226 {
227 m_commander.ProcessConsoleCommand("add", new string[0]);
228 return;
229 }
230
231 string[] tmpArgs = new string[args.Length - 2];
232 int i;
233 for (i = 2; i < args.Length; i++)
234 {
235 tmpArgs[i - 2] = args[i];
236 }
237
238 m_commander.ProcessConsoleCommand(args[1], tmpArgs);
239 }
240 }
241 #endregion
242
243 }
244}
245
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 013a0ef..c9b3071 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -800,30 +800,31 @@ namespace OpenSim.Region.CoreModules.World.Permissions
800 } 800 }
801 801
802 protected bool GenericParcelOwnerPermission(UUID user, ILandObject parcel, ulong groupPowers) 802 protected bool GenericParcelOwnerPermission(UUID user, ILandObject parcel, ulong groupPowers)
803 { 803 {
804 bool permission = false;
805
806 if (parcel.LandData.OwnerID == user) 804 if (parcel.LandData.OwnerID == user)
807 { 805 {
808 permission = true; 806 // Returning immediately so that group deeded objects on group deeded land don't trigger a NRE on
807 // the subsequent redundant checks when using lParcelMediaCommandList()
808 // See http://opensimulator.org/mantis/view.php?id=3999 for more details
809 return true;
809 } 810 }
810 811
811 if (parcel.LandData.IsGroupOwned && IsGroupMember(parcel.LandData.GroupID, user, groupPowers)) 812 if (parcel.LandData.IsGroupOwned && IsGroupMember(parcel.LandData.GroupID, user, groupPowers))
812 { 813 {
813 permission = true; 814 return true;
814 } 815 }
815 816
816 if (IsEstateManager(user)) 817 if (IsEstateManager(user))
817 { 818 {
818 permission = true; 819 return true;
819 } 820 }
820 821
821 if (IsAdministrator(user)) 822 if (IsAdministrator(user))
822 { 823 {
823 permission = true; 824 return true;
824 } 825 }
825 826
826 return permission; 827 return false;
827 } 828 }
828 829
829 protected bool GenericParcelPermission(UUID user, Vector3 pos, ulong groupPowers) 830 protected bool GenericParcelPermission(UUID user, Vector3 pos, ulong groupPowers)
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index ba271fd..a40828b 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -29,6 +29,7 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Reflection; 31using System.Reflection;
32using System.Net;
32using log4net; 33using log4net;
33using Nini.Config; 34using Nini.Config;
34using OpenMetaverse; 35using OpenMetaverse;
@@ -259,6 +260,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain
259 } 260 }
260 261
261 /// <summary> 262 /// <summary>
263 /// Loads a terrain file from the specified URI
264 /// </summary>
265 /// <param name="filename">The name of the terrain to load</param>
266 /// <param name="pathToTerrainHeightmap">The URI to the terrain height map</param>
267 public void LoadFromStream(string filename, Uri pathToTerrainHeightmap)
268 {
269 LoadFromStream(filename, URIFetch(pathToTerrainHeightmap));
270 }
271
272 /// <summary>
262 /// Loads a terrain file from a stream and installs it in the scene. 273 /// Loads a terrain file from a stream and installs it in the scene.
263 /// </summary> 274 /// </summary>
264 /// <param name="filename">Filename to terrain file. Type is determined by extension.</param> 275 /// <param name="filename">Filename to terrain file. Type is determined by extension.</param>
@@ -267,7 +278,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
267 { 278 {
268 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) 279 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
269 { 280 {
270 if (@filename.EndsWith(loader.Key)) 281 if (filename.EndsWith(loader.Key))
271 { 282 {
272 lock (m_scene) 283 lock (m_scene)
273 { 284 {
@@ -295,6 +306,25 @@ namespace OpenSim.Region.CoreModules.World.Terrain
295 throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename)); 306 throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename));
296 } 307 }
297 308
309 private static Stream URIFetch(Uri uri)
310 {
311 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
312
313 // request.Credentials = credentials;
314
315 request.ContentLength = 0;
316 request.KeepAlive = false;
317
318 WebResponse response = request.GetResponse();
319 Stream file = response.GetResponseStream();
320
321 if (response.ContentLength == 0)
322 throw new Exception(String.Format("{0} returned an empty file", uri.ToString()));
323
324 // return new BufferedStream(file, (int) response.ContentLength);
325 return new BufferedStream(file, 1000000);
326 }
327
298 /// <summary> 328 /// <summary>
299 /// Modify Land 329 /// Modify Land
300 /// </summary> 330 /// </summary>
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index 9754da3..816060f 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -433,7 +433,7 @@ namespace OpenSim.Region.Examples.SimpleModule
433 433
434 } 434 }
435 435
436 public void SendGenericMessage(string method, List<string> message) 436 public void SendGenericMessage(string method, List<byte[]> message)
437 { 437 {
438 438
439 } 439 }
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs
index 78bd622..7312799 100644
--- a/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs
+++ b/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs
@@ -103,6 +103,8 @@ namespace OpenSim.Region.Framework.Interfaces
103 103
104 void StoreRegionSettings(RegionSettings rs); 104 void StoreRegionSettings(RegionSettings rs);
105 RegionSettings LoadRegionSettings(UUID regionUUID); 105 RegionSettings LoadRegionSettings(UUID regionUUID);
106 RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID);
107 void StoreRegionWindlightSettings(RegionMeta7WindlightData wl);
106 108
107 void Shutdown(); 109 void Shutdown();
108 } 110 }
diff --git a/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs b/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs
index 2dcba0c..7caac55 100644
--- a/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Region.Framework.Interfaces
51 /// </param> 51 /// </param>
52 /// <param name="stream"></param> 52 /// <param name="stream"></param>
53 void LoadFromStream(string filename, Stream stream); 53 void LoadFromStream(string filename, Stream stream);
54 54 void LoadFromStream(string filename, System.Uri pathToTerrainHeightmap);
55 /// <summary> 55 /// <summary>
56 /// Save a terrain to a stream. 56 /// Save a terrain to a stream.
57 /// </summary> 57 /// </summary>
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index b031f61..50624a1 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -448,5 +448,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation
448 448
449 SendAnimPack(animIDs, sequenceNums, objectIDs); 449 SendAnimPack(animIDs, sequenceNums, objectIDs);
450 } 450 }
451
452 public void Close()
453 {
454 m_animations = null;
455 m_scenePresence = null;
456 }
451 } 457 }
452} 458}
diff --git a/OpenSim/Region/Framework/Scenes/EntityManager.cs b/OpenSim/Region/Framework/Scenes/EntityManager.cs
index 099fcce..c246e32 100644
--- a/OpenSim/Region/Framework/Scenes/EntityManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EntityManager.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Region.Framework.Scenes
40 private readonly Dictionary<UUID,EntityBase> m_eb_uuid = new Dictionary<UUID, EntityBase>(); 40 private readonly Dictionary<UUID,EntityBase> m_eb_uuid = new Dictionary<UUID, EntityBase>();
41 private readonly Dictionary<uint, EntityBase> m_eb_localID = new Dictionary<uint, EntityBase>(); 41 private readonly Dictionary<uint, EntityBase> m_eb_localID = new Dictionary<uint, EntityBase>();
42 //private readonly Dictionary<UUID, ScenePresence> m_pres_uuid = new Dictionary<UUID, ScenePresence>(); 42 //private readonly Dictionary<UUID, ScenePresence> m_pres_uuid = new Dictionary<UUID, ScenePresence>();
43 private readonly Object m_lock = new Object(); 43 private System.Threading.ReaderWriterLockSlim m_lock = new System.Threading.ReaderWriterLockSlim();
44 44
45 [Obsolete("Use Add() instead.")] 45 [Obsolete("Use Add() instead.")]
46 public void Add(UUID id, EntityBase eb) 46 public void Add(UUID id, EntityBase eb)
@@ -50,7 +50,8 @@ namespace OpenSim.Region.Framework.Scenes
50 50
51 public void Add(EntityBase entity) 51 public void Add(EntityBase entity)
52 { 52 {
53 lock (m_lock) 53 m_lock.EnterWriteLock();
54 try
54 { 55 {
55 try 56 try
56 { 57 {
@@ -62,11 +63,16 @@ namespace OpenSim.Region.Framework.Scenes
62 m_log.ErrorFormat("Add Entity failed: {0}", e.Message); 63 m_log.ErrorFormat("Add Entity failed: {0}", e.Message);
63 } 64 }
64 } 65 }
66 finally
67 {
68 m_lock.ExitWriteLock();
69 }
65 } 70 }
66 71
67 public void InsertOrReplace(EntityBase entity) 72 public void InsertOrReplace(EntityBase entity)
68 { 73 {
69 lock (m_lock) 74 m_lock.EnterWriteLock();
75 try
70 { 76 {
71 try 77 try
72 { 78 {
@@ -78,15 +84,24 @@ namespace OpenSim.Region.Framework.Scenes
78 m_log.ErrorFormat("Insert or Replace Entity failed: {0}", e.Message); 84 m_log.ErrorFormat("Insert or Replace Entity failed: {0}", e.Message);
79 } 85 }
80 } 86 }
87 finally
88 {
89 m_lock.ExitWriteLock();
90 }
81 } 91 }
82 92
83 public void Clear() 93 public void Clear()
84 { 94 {
85 lock (m_lock) 95 m_lock.EnterWriteLock();
96 try
86 { 97 {
87 m_eb_uuid.Clear(); 98 m_eb_uuid.Clear();
88 m_eb_localID.Clear(); 99 m_eb_localID.Clear();
89 } 100 }
101 finally
102 {
103 m_lock.ExitWriteLock();
104 }
90 } 105 }
91 106
92 public int Count 107 public int Count
@@ -123,7 +138,8 @@ namespace OpenSim.Region.Framework.Scenes
123 138
124 public bool Remove(uint localID) 139 public bool Remove(uint localID)
125 { 140 {
126 lock (m_lock) 141 m_lock.EnterWriteLock();
142 try
127 { 143 {
128 try 144 try
129 { 145 {
@@ -141,11 +157,16 @@ namespace OpenSim.Region.Framework.Scenes
141 return false; 157 return false;
142 } 158 }
143 } 159 }
160 finally
161 {
162 m_lock.ExitWriteLock();
163 }
144 } 164 }
145 165
146 public bool Remove(UUID id) 166 public bool Remove(UUID id)
147 { 167 {
148 lock (m_lock) 168 m_lock.EnterWriteLock();
169 try
149 { 170 {
150 try 171 try
151 { 172 {
@@ -163,13 +184,18 @@ namespace OpenSim.Region.Framework.Scenes
163 return false; 184 return false;
164 } 185 }
165 } 186 }
187 finally
188 {
189 m_lock.ExitWriteLock();
190 }
166 } 191 }
167 192
168 public List<EntityBase> GetAllByType<T>() 193 public List<EntityBase> GetAllByType<T>()
169 { 194 {
170 List<EntityBase> tmp = new List<EntityBase>(); 195 List<EntityBase> tmp = new List<EntityBase>();
171 196
172 lock (m_lock) 197 m_lock.EnterReadLock();
198 try
173 { 199 {
174 try 200 try
175 { 201 {
@@ -187,23 +213,33 @@ namespace OpenSim.Region.Framework.Scenes
187 tmp = null; 213 tmp = null;
188 } 214 }
189 } 215 }
216 finally
217 {
218 m_lock.ExitReadLock();
219 }
190 220
191 return tmp; 221 return tmp;
192 } 222 }
193 223
194 public List<EntityBase> GetEntities() 224 public List<EntityBase> GetEntities()
195 { 225 {
196 lock (m_lock) 226 m_lock.EnterReadLock();
227 try
197 { 228 {
198 return new List<EntityBase>(m_eb_uuid.Values); 229 return new List<EntityBase>(m_eb_uuid.Values);
199 } 230 }
231 finally
232 {
233 m_lock.ExitReadLock();
234 }
200 } 235 }
201 236
202 public EntityBase this[UUID id] 237 public EntityBase this[UUID id]
203 { 238 {
204 get 239 get
205 { 240 {
206 lock (m_lock) 241 m_lock.EnterReadLock();
242 try
207 { 243 {
208 EntityBase entity; 244 EntityBase entity;
209 if (m_eb_uuid.TryGetValue(id, out entity)) 245 if (m_eb_uuid.TryGetValue(id, out entity))
@@ -211,6 +247,10 @@ namespace OpenSim.Region.Framework.Scenes
211 else 247 else
212 return null; 248 return null;
213 } 249 }
250 finally
251 {
252 m_lock.ExitReadLock();
253 }
214 } 254 }
215 set 255 set
216 { 256 {
@@ -222,7 +262,8 @@ namespace OpenSim.Region.Framework.Scenes
222 { 262 {
223 get 263 get
224 { 264 {
225 lock (m_lock) 265 m_lock.EnterReadLock();
266 try
226 { 267 {
227 EntityBase entity; 268 EntityBase entity;
228 if (m_eb_localID.TryGetValue(localID, out entity)) 269 if (m_eb_localID.TryGetValue(localID, out entity))
@@ -230,6 +271,10 @@ namespace OpenSim.Region.Framework.Scenes
230 else 271 else
231 return null; 272 return null;
232 } 273 }
274 finally
275 {
276 m_lock.ExitReadLock();
277 }
233 } 278 }
234 set 279 set
235 { 280 {
@@ -239,18 +284,28 @@ namespace OpenSim.Region.Framework.Scenes
239 284
240 public bool TryGetValue(UUID key, out EntityBase obj) 285 public bool TryGetValue(UUID key, out EntityBase obj)
241 { 286 {
242 lock (m_lock) 287 m_lock.EnterReadLock();
288 try
243 { 289 {
244 return m_eb_uuid.TryGetValue(key, out obj); 290 return m_eb_uuid.TryGetValue(key, out obj);
245 } 291 }
292 finally
293 {
294 m_lock.ExitReadLock();
295 }
246 } 296 }
247 297
248 public bool TryGetValue(uint key, out EntityBase obj) 298 public bool TryGetValue(uint key, out EntityBase obj)
249 { 299 {
250 lock (m_lock) 300 m_lock.EnterReadLock();
301 try
251 { 302 {
252 return m_eb_localID.TryGetValue(key, out obj); 303 return m_eb_localID.TryGetValue(key, out obj);
253 } 304 }
305 finally
306 {
307 m_lock.ExitReadLock();
308 }
254 } 309 }
255 310
256 /// <summary> 311 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 753344d..a86e263 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -193,7 +193,9 @@ namespace OpenSim.Region.Framework.Scenes
193 public event OnMakeChildAgentDelegate OnMakeChildAgent; 193 public event OnMakeChildAgentDelegate OnMakeChildAgent;
194 194
195 public delegate void OnMakeRootAgentDelegate(ScenePresence presence); 195 public delegate void OnMakeRootAgentDelegate(ScenePresence presence);
196 public delegate void OnSaveNewWindlightProfileDelegate();
196 public event OnMakeRootAgentDelegate OnMakeRootAgent; 197 public event OnMakeRootAgentDelegate OnMakeRootAgent;
198 public event OnSaveNewWindlightProfileDelegate OnSaveNewWindlightProfile;
197 199
198 public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel); 200 public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel);
199 201
@@ -411,6 +413,7 @@ namespace OpenSim.Region.Framework.Scenes
411 private IncomingInstantMessage handlerUnhandledInstantMessage = null; //OnUnhandledInstantMessage; 413 private IncomingInstantMessage handlerUnhandledInstantMessage = null; //OnUnhandledInstantMessage;
412 private ClientClosed handlerClientClosed = null; //OnClientClosed; 414 private ClientClosed handlerClientClosed = null; //OnClientClosed;
413 private OnMakeChildAgentDelegate handlerMakeChildAgent = null; //OnMakeChildAgent; 415 private OnMakeChildAgentDelegate handlerMakeChildAgent = null; //OnMakeChildAgent;
416 private OnSaveNewWindlightProfileDelegate handlerSaveNewWindlightProfile = null; //OnSaveNewWindlightProfile;
414 private OnMakeRootAgentDelegate handlerMakeRootAgent = null; //OnMakeRootAgent; 417 private OnMakeRootAgentDelegate handlerMakeRootAgent = null; //OnMakeRootAgent;
415 private OnTerrainTickDelegate handlerTerrainTick = null; // OnTerainTick; 418 private OnTerrainTickDelegate handlerTerrainTick = null; // OnTerainTick;
416 private RegisterCapsEvent handlerRegisterCaps = null; // OnRegisterCaps; 419 private RegisterCapsEvent handlerRegisterCaps = null; // OnRegisterCaps;
@@ -772,6 +775,15 @@ namespace OpenSim.Region.Framework.Scenes
772 } 775 }
773 } 776 }
774 777
778 public void TriggerOnSaveNewWindlightProfile()
779 {
780 handlerSaveNewWindlightProfile = OnSaveNewWindlightProfile;
781 if (handlerSaveNewWindlightProfile != null)
782 {
783 handlerSaveNewWindlightProfile();
784 }
785 }
786
775 public void TriggerOnMakeRootAgent(ScenePresence presence) 787 public void TriggerOnMakeRootAgent(ScenePresence presence)
776 { 788 {
777 handlerMakeRootAgent = OnMakeRootAgent; 789 handlerMakeRootAgent = OnMakeRootAgent;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 83208e9..7ca779a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1726,10 +1726,19 @@ namespace OpenSim.Region.Framework.Scenes
1726 1726
1727 if (folderID == UUID.Zero && folder == null) 1727 if (folderID == UUID.Zero && folder == null)
1728 { 1728 {
1729 // Catch all. Use lost & found 1729 if (action == DeRezAction.Delete)
1730 // 1730 {
1731 // Deletes go to trash by default
1732 //
1733 folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
1734 }
1735 else
1736 {
1737 // Catch all. Use lost & found
1738 //
1731 1739
1732 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); 1740 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1741 }
1733 } 1742 }
1734 1743
1735 if (folder == null) // None of the above 1744 if (folder == null) // None of the above
@@ -2388,6 +2397,12 @@ namespace OpenSim.Region.Framework.Scenes
2388 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 2397 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2389 item = InventoryService.GetItem(item); 2398 item = InventoryService.GetItem(item);
2390 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); 2399 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
2400
2401 if (m_AvatarFactory != null)
2402 {
2403 m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
2404 }
2405
2391 } 2406 }
2392 } 2407 }
2393 2408
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 3034f9a..1b275b0 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -310,7 +310,7 @@ namespace OpenSim.Region.Framework.Scenes
310 private Thread HeartbeatThread; 310 private Thread HeartbeatThread;
311 private volatile bool shuttingdown; 311 private volatile bool shuttingdown;
312 312
313 private int m_lastUpdate = Environment.TickCount; 313 private int m_lastUpdate;
314 private bool m_firstHeartbeat = true; 314 private bool m_firstHeartbeat = true;
315 315
316 private UpdatePrioritizationSchemes m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time; 316 private UpdatePrioritizationSchemes m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time;
@@ -526,6 +526,7 @@ namespace OpenSim.Region.Framework.Scenes
526 m_regionHandle = m_regInfo.RegionHandle; 526 m_regionHandle = m_regInfo.RegionHandle;
527 m_regionName = m_regInfo.RegionName; 527 m_regionName = m_regInfo.RegionName;
528 m_datastore = m_regInfo.DataStore; 528 m_datastore = m_regInfo.DataStore;
529 m_lastUpdate = Util.EnvironmentTickCount();
529 530
530 m_physicalPrim = physicalPrim; 531 m_physicalPrim = physicalPrim;
531 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; 532 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor;
@@ -538,6 +539,8 @@ namespace OpenSim.Region.Framework.Scenes
538 539
539 // Load region settings 540 // Load region settings
540 m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID); 541 m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID);
542 m_regInfo.WindlightSettings = m_storageManager.DataStore.LoadRegionWindlightSettings(m_regInfo.RegionID);
543
541 if (m_storageManager.EstateDataStore != null) 544 if (m_storageManager.EstateDataStore != null)
542 { 545 {
543 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID); 546 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID);
@@ -735,6 +738,8 @@ namespace OpenSim.Region.Framework.Scenes
735 738
736 m_regInfo = regInfo; 739 m_regInfo = regInfo;
737 m_eventManager = new EventManager(); 740 m_eventManager = new EventManager();
741
742 m_lastUpdate = Util.EnvironmentTickCount();
738 } 743 }
739 744
740 #endregion 745 #endregion
@@ -1101,7 +1106,7 @@ namespace OpenSim.Region.Framework.Scenes
1101 HeartbeatThread.Abort(); 1106 HeartbeatThread.Abort();
1102 HeartbeatThread = null; 1107 HeartbeatThread = null;
1103 } 1108 }
1104 m_lastUpdate = Environment.TickCount; 1109 m_lastUpdate = Util.EnvironmentTickCount();
1105 1110
1106 HeartbeatThread = Watchdog.StartThread(Heartbeat, "Heartbeat for region " + RegionInfo.RegionName, ThreadPriority.Normal, false); 1111 HeartbeatThread = Watchdog.StartThread(Heartbeat, "Heartbeat for region " + RegionInfo.RegionName, ThreadPriority.Normal, false);
1107 } 1112 }
@@ -1142,7 +1147,7 @@ namespace OpenSim.Region.Framework.Scenes
1142 { 1147 {
1143 Update(); 1148 Update();
1144 1149
1145 m_lastUpdate = Environment.TickCount; 1150 m_lastUpdate = Util.EnvironmentTickCount();
1146 m_firstHeartbeat = false; 1151 m_firstHeartbeat = false;
1147 } 1152 }
1148 catch (ThreadAbortException) 1153 catch (ThreadAbortException)
@@ -1170,8 +1175,9 @@ namespace OpenSim.Region.Framework.Scenes
1170 TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; 1175 TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate;
1171 physicsFPS = 0f; 1176 physicsFPS = 0f;
1172 1177
1173 maintc = otherMS = Environment.TickCount; 1178 maintc = Util.EnvironmentTickCount();
1174 int tmpFrameMS = maintc; 1179 int tmpFrameMS = maintc;
1180 tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
1175 1181
1176 // Increment the frame counter 1182 // Increment the frame counter
1177 ++m_frame; 1183 ++m_frame;
@@ -1191,16 +1197,15 @@ namespace OpenSim.Region.Framework.Scenes
1191 if (m_frame % m_update_objects == 0) 1197 if (m_frame % m_update_objects == 0)
1192 m_sceneGraph.UpdateObjectGroups(); 1198 m_sceneGraph.UpdateObjectGroups();
1193 1199
1194 int TempPhysicsMS2 = Environment.TickCount; 1200 int tmpPhysicsMS2 = Util.EnvironmentTickCount();
1195 if ((m_frame % m_update_physics == 0) && m_physics_enabled) 1201 if ((m_frame % m_update_physics == 0) && m_physics_enabled)
1196 m_sceneGraph.UpdatePreparePhysics(); 1202 m_sceneGraph.UpdatePreparePhysics();
1197 TempPhysicsMS2 = Environment.TickCount - TempPhysicsMS2; 1203 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2);
1198 physicsMS2 = TempPhysicsMS2;
1199 1204
1200 if (m_frame % m_update_entitymovement == 0) 1205 if (m_frame % m_update_entitymovement == 0)
1201 m_sceneGraph.UpdateScenePresenceMovement(); 1206 m_sceneGraph.UpdateScenePresenceMovement();
1202 1207
1203 int TempPhysicsMS = Environment.TickCount; 1208 int tmpPhysicsMS = Util.EnvironmentTickCount();
1204 if (m_frame % m_update_physics == 0) 1209 if (m_frame % m_update_physics == 0)
1205 { 1210 {
1206 if (m_physics_enabled) 1211 if (m_physics_enabled)
@@ -1208,57 +1213,49 @@ namespace OpenSim.Region.Framework.Scenes
1208 if (SynchronizeScene != null) 1213 if (SynchronizeScene != null)
1209 SynchronizeScene(this); 1214 SynchronizeScene(this);
1210 } 1215 }
1211 TempPhysicsMS = Environment.TickCount - TempPhysicsMS; 1216 physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS);
1212 physicsMS = TempPhysicsMS;
1213 1217
1214 // Delete temp-on-rez stuff 1218 // Delete temp-on-rez stuff
1215 if (m_frame % m_update_backup == 0) 1219 if (m_frame % m_update_backup == 0)
1216 { 1220 {
1217 int tozMS = Environment.TickCount; 1221 int tmpTempOnRezMS = Util.EnvironmentTickCount();
1218 CleanTempObjects(); 1222 CleanTempObjects();
1219 tozMS -= Environment.TickCount; 1223 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS);
1220 tempOnRezMS = tozMS;
1221 } 1224 }
1222 1225
1223 if (RegionStatus != RegionStatus.SlaveScene) 1226 if (RegionStatus != RegionStatus.SlaveScene)
1224 { 1227 {
1225 if (m_frame % m_update_events == 0) 1228 if (m_frame % m_update_events == 0)
1226 { 1229 {
1227 int evMS = Environment.TickCount; 1230 int evMS = Util.EnvironmentTickCount();
1228 UpdateEvents(); 1231 UpdateEvents();
1229 evMS -= Environment.TickCount; 1232 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1230 eventMS = evMS;
1231 } 1233 }
1232 1234
1233 if (m_frame % m_update_backup == 0) 1235 if (m_frame % m_update_backup == 0)
1234 { 1236 {
1235 int backMS = Environment.TickCount; 1237 int backMS = Util.EnvironmentTickCount();
1236 UpdateStorageBackup(); 1238 UpdateStorageBackup();
1237 backMS -= Environment.TickCount; 1239 backupMS = Util.EnvironmentTickCountSubtract(backMS);
1238 backupMS = backMS;
1239 } 1240 }
1240 1241
1241 if (m_frame % m_update_terrain == 0) 1242 if (m_frame % m_update_terrain == 0)
1242 { 1243 {
1243 int terMS = Environment.TickCount; 1244 int terMS = Util.EnvironmentTickCount();
1244 UpdateTerrain(); 1245 UpdateTerrain();
1245 terMS -= Environment.TickCount; 1246 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1246 terrainMS = terMS;
1247 } 1247 }
1248 1248
1249 if (m_frame % m_update_land == 0) 1249 if (m_frame % m_update_land == 0)
1250 { 1250 {
1251 int ldMS = Environment.TickCount; 1251 int ldMS = Util.EnvironmentTickCount();
1252 UpdateLand(); 1252 UpdateLand();
1253 ldMS -= Environment.TickCount; 1253 landMS = Util.EnvironmentTickCountSubtract(ldMS);
1254 landMS = ldMS;
1255 } 1254 }
1256 1255
1257 int tickCount = Environment.TickCount; 1256 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS);
1258 otherMS = tickCount - otherMS; 1257 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1259 tmpFrameMS -= tickCount; 1258 lastCompletedFrame = Util.EnvironmentTickCount();
1260 frameMS = tmpFrameMS;
1261 lastCompletedFrame = tickCount;
1262 1259
1263 // if (m_frame%m_update_avatars == 0) 1260 // if (m_frame%m_update_avatars == 0)
1264 // UpdateInWorldTime(); 1261 // UpdateInWorldTime();
@@ -1311,8 +1308,8 @@ namespace OpenSim.Region.Framework.Scenes
1311 { 1308 {
1312 m_lastupdate = DateTime.UtcNow; 1309 m_lastupdate = DateTime.UtcNow;
1313 } 1310 }
1314 1311
1315 maintc = Environment.TickCount - maintc; 1312 maintc = Util.EnvironmentTickCountSubtract(maintc);
1316 maintc = (int)(m_timespan * 1000) - maintc; 1313 maintc = (int)(m_timespan * 1000) - maintc;
1317 1314
1318 if ((maintc < (m_timespan * 1000)) && maintc > 0) 1315 if ((maintc < (m_timespan * 1000)) && maintc > 0)
@@ -1323,6 +1320,7 @@ namespace OpenSim.Region.Framework.Scenes
1323 } 1320 }
1324 } 1321 }
1325 1322
1323
1326 1324
1327 public void AddGroupTarget(SceneObjectGroup grp) 1325 public void AddGroupTarget(SceneObjectGroup grp)
1328 { 1326 {
@@ -1506,6 +1504,19 @@ namespace OpenSim.Region.Framework.Scenes
1506 { 1504 {
1507 m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); 1505 m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
1508 } 1506 }
1507
1508 public void StoreWindlightProfile(RegionMeta7WindlightData wl)
1509 {
1510 m_regInfo.WindlightSettings = wl;
1511 m_storageManager.DataStore.StoreRegionWindlightSettings(wl);
1512 m_eventManager.TriggerOnSaveNewWindlightProfile();
1513 }
1514
1515 public void LoadWindlightProfile()
1516 {
1517 m_regInfo.WindlightSettings = m_storageManager.DataStore.LoadRegionWindlightSettings(RegionInfo.RegionID);
1518 m_eventManager.TriggerOnSaveNewWindlightProfile();
1519 }
1509 1520
1510 /// <summary> 1521 /// <summary>
1511 /// Loads the World heightmap 1522 /// Loads the World heightmap
@@ -2599,7 +2610,7 @@ namespace OpenSim.Region.Framework.Scenes
2599 } 2610 }
2600 } 2611 }
2601 2612
2602 m_LastLogin = Environment.TickCount; 2613 m_LastLogin = Util.EnvironmentTickCount();
2603 EventManager.TriggerOnNewClient(client); 2614 EventManager.TriggerOnNewClient(client);
2604 } 2615 }
2605 2616
@@ -3050,6 +3061,7 @@ namespace OpenSim.Region.Framework.Scenes
3050 // TODO: The next line can be removed, as soon as only homeRegionID based UserServers are around. 3061 // TODO: The next line can be removed, as soon as only homeRegionID based UserServers are around.
3051 // TODO: The HomeRegion property can be removed then, too 3062 // TODO: The HomeRegion property can be removed then, too
3052 UserProfile.HomeRegion = RegionInfo.RegionHandle; 3063 UserProfile.HomeRegion = RegionInfo.RegionHandle;
3064
3053 UserProfile.HomeLocation = position; 3065 UserProfile.HomeLocation = position;
3054 UserProfile.HomeLookAt = lookAt; 3066 UserProfile.HomeLookAt = lookAt;
3055 CommsManager.UserService.UpdateUserProfile(UserProfile); 3067 CommsManager.UserService.UpdateUserProfile(UserProfile);
@@ -4410,16 +4422,6 @@ namespace OpenSim.Region.Framework.Scenes
4410 4422
4411 #endregion 4423 #endregion
4412 4424
4413 #region Avatar Appearance Default
4414
4415 public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams)
4416 {
4417 visualParams = AvatarAppearance.GetDefaultVisualParams();
4418 wearables = AvatarWearable.DefaultWearables;
4419 }
4420
4421 #endregion
4422
4423 public void RegionHandleRequest(IClientAPI client, UUID regionID) 4425 public void RegionHandleRequest(IClientAPI client, UUID regionID)
4424 { 4426 {
4425 ulong handle = 0; 4427 ulong handle = 0;
@@ -4678,14 +4680,14 @@ namespace OpenSim.Region.Framework.Scenes
4678 // 4680 //
4679 int health=1; // Start at 1, means we're up 4681 int health=1; // Start at 1, means we're up
4680 4682
4681 if ((Environment.TickCount - m_lastUpdate) < 1000) 4683 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000)
4682 health+=1; 4684 health+=1;
4683 else 4685 else
4684 return health; 4686 return health;
4685 4687
4686 // A login in the last 4 mins? We can't be doing too badly 4688 // A login in the last 4 mins? We can't be doing too badly
4687 // 4689 //
4688 if ((Environment.TickCount - m_LastLogin) < 240000) 4690 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000)
4689 health++; 4691 health++;
4690 else 4692 else
4691 return health; 4693 return health;
@@ -4883,7 +4885,7 @@ namespace OpenSim.Region.Framework.Scenes
4883 if (m_firstHeartbeat) 4885 if (m_firstHeartbeat)
4884 return; 4886 return;
4885 4887
4886 if (System.Environment.TickCount - m_lastUpdate > 2000) 4888 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000)
4887 StartTimer(); 4889 StartTimer();
4888 } 4890 }
4889 } 4891 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 2fdb48d..f74fd5d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Threading;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.Reflection; 31using System.Reflection;
31using OpenMetaverse; 32using OpenMetaverse;
@@ -96,6 +97,8 @@ namespace OpenSim.Region.Framework.Scenes
96 protected internal Dictionary<UUID, SceneObjectGroup> SceneObjectGroupsByFullID = new Dictionary<UUID, SceneObjectGroup>(); 97 protected internal Dictionary<UUID, SceneObjectGroup> SceneObjectGroupsByFullID = new Dictionary<UUID, SceneObjectGroup>();
97 private readonly Object m_dictionary_lock = new Object(); 98 private readonly Object m_dictionary_lock = new Object();
98 99
100 private Object m_updateLock = new Object();
101
99 #endregion 102 #endregion
100 103
101 protected internal SceneGraph(Scene parent, RegionInfo regInfo) 104 protected internal SceneGraph(Scene parent, RegionInfo regInfo)
@@ -369,6 +372,9 @@ namespace OpenSim.Region.Framework.Scenes
369 /// </summary> 372 /// </summary>
370 protected internal void UpdateObjectGroups() 373 protected internal void UpdateObjectGroups()
371 { 374 {
375 if (!Monitor.TryEnter(m_updateLock))
376 return;
377
372 List<SceneObjectGroup> updates; 378 List<SceneObjectGroup> updates;
373 379
374 // Some updates add more updates to the updateList. 380 // Some updates add more updates to the updateList.
@@ -395,6 +401,7 @@ namespace OpenSim.Region.Framework.Scenes
395 "[INNER SCENE]: Failed to update {0}, {1} - {2}", sog.Name, sog.UUID, e); 401 "[INNER SCENE]: Failed to update {0}, {1} - {2}", sog.Name, sog.UUID, e);
396 } 402 }
397 } 403 }
404 Monitor.Exit(m_updateLock);
398 } 405 }
399 406
400 protected internal void AddPhysicalPrim(int number) 407 protected internal void AddPhysicalPrim(int number)
@@ -1555,55 +1562,65 @@ namespace OpenSim.Region.Framework.Scenes
1555 /// <param name="childPrims"></param> 1562 /// <param name="childPrims"></param>
1556 protected internal void LinkObjects(IClientAPI client, uint parentPrimId, List<uint> childPrimIds) 1563 protected internal void LinkObjects(IClientAPI client, uint parentPrimId, List<uint> childPrimIds)
1557 { 1564 {
1558 SceneObjectGroup parentGroup = GetGroupByPrim(parentPrimId); 1565 Monitor.Enter(m_updateLock);
1559 1566 try
1560 List<SceneObjectGroup> childGroups = new List<SceneObjectGroup>();
1561 if (parentGroup != null)
1562 { 1567 {
1563 // We do this in reverse to get the link order of the prims correct 1568 SceneObjectGroup parentGroup = GetGroupByPrim(parentPrimId);
1564 for (int i = childPrimIds.Count - 1; i >= 0; i--) 1569
1570 List<SceneObjectGroup> childGroups = new List<SceneObjectGroup>();
1571 if (parentGroup != null)
1565 { 1572 {
1566 SceneObjectGroup child = GetGroupByPrim(childPrimIds[i]); 1573 // We do this in reverse to get the link order of the prims correct
1567 if (child != null) 1574 for (int i = childPrimIds.Count - 1; i >= 0; i--)
1568 { 1575 {
1569 // Make sure no child prim is set for sale 1576 SceneObjectGroup child = GetGroupByPrim(childPrimIds[i]);
1570 // So that, on delink, no prims are unwittingly 1577 if (child != null)
1571 // left for sale and sold off 1578 {
1572 child.RootPart.ObjectSaleType = 0; 1579 // Make sure no child prim is set for sale
1573 child.RootPart.SalePrice = 10; 1580 // So that, on delink, no prims are unwittingly
1574 childGroups.Add(child); 1581 // left for sale and sold off
1582 child.RootPart.ObjectSaleType = 0;
1583 child.RootPart.SalePrice = 10;
1584 childGroups.Add(child);
1585 }
1575 } 1586 }
1576 } 1587 }
1577 } 1588 else
1578 else 1589 {
1579 { 1590 return; // parent is null so not in this region
1580 return; // parent is null so not in this region 1591 }
1581 }
1582 1592
1583 foreach (SceneObjectGroup child in childGroups) 1593 foreach (SceneObjectGroup child in childGroups)
1584 { 1594 {
1585 parentGroup.LinkToGroup(child); 1595 parentGroup.LinkToGroup(child);
1586 1596
1587 // this is here so physics gets updated! 1597 // this is here so physics gets updated!
1588 // Don't remove! Bad juju! Stay away! or fix physics! 1598 // Don't remove! Bad juju! Stay away! or fix physics!
1589 child.AbsolutePosition = child.AbsolutePosition; 1599 child.AbsolutePosition = child.AbsolutePosition;
1590 } 1600 }
1591 1601
1592 // We need to explicitly resend the newly link prim's object properties since no other actions 1602 // We need to explicitly resend the newly link prim's object properties since no other actions
1593 // occur on link to invoke this elsewhere (such as object selection) 1603 // occur on link to invoke this elsewhere (such as object selection)
1594 parentGroup.RootPart.AddFlag(PrimFlags.CreateSelected); 1604 parentGroup.RootPart.AddFlag(PrimFlags.CreateSelected);
1595 parentGroup.TriggerScriptChangedEvent(Changed.LINK); 1605 parentGroup.TriggerScriptChangedEvent(Changed.LINK);
1596 1606 parentGroup.HasGroupChanged = true;
1597 if (client != null) 1607 parentGroup.ScheduleGroupForFullUpdate();
1598 { 1608
1599 parentGroup.GetProperties(client); 1609// if (client != null)
1610// {
1611// parentGroup.GetProperties(client);
1612// }
1613// else
1614// {
1615// foreach (ScenePresence p in GetScenePresences())
1616// {
1617// parentGroup.GetProperties(p.ControllingClient);
1618// }
1619// }
1600 } 1620 }
1601 else 1621 finally
1602 { 1622 {
1603 foreach (ScenePresence p in GetScenePresences()) 1623 Monitor.Exit(m_updateLock);
1604 {
1605 parentGroup.GetProperties(p.ControllingClient);
1606 }
1607 } 1624 }
1608 } 1625 }
1609 1626
@@ -1618,109 +1635,120 @@ namespace OpenSim.Region.Framework.Scenes
1618 1635
1619 protected internal void DelinkObjects(List<uint> primIds, bool sendEvents) 1636 protected internal void DelinkObjects(List<uint> primIds, bool sendEvents)
1620 { 1637 {
1621 List<SceneObjectPart> childParts = new List<SceneObjectPart>(); 1638 Monitor.Enter(m_updateLock);
1622 List<SceneObjectPart> rootParts = new List<SceneObjectPart>(); 1639 try
1623 List<SceneObjectGroup> affectedGroups = new List<SceneObjectGroup>();
1624 // Look them all up in one go, since that is comparatively expensive
1625 //
1626 foreach (uint primID in primIds)
1627 { 1640 {
1628 SceneObjectPart part = m_parentScene.GetSceneObjectPart(primID); 1641 List<SceneObjectPart> childParts = new List<SceneObjectPart>();
1629 if (part != null) 1642 List<SceneObjectPart> rootParts = new List<SceneObjectPart>();
1643 List<SceneObjectGroup> affectedGroups = new List<SceneObjectGroup>();
1644 // Look them all up in one go, since that is comparatively expensive
1645 //
1646 foreach (uint primID in primIds)
1630 { 1647 {
1631 if (part.LinkNum < 2) // Root or single 1648 SceneObjectPart part = m_parentScene.GetSceneObjectPart(primID);
1632 rootParts.Add(part); 1649 if (part != null)
1650 {
1651 if (part.ParentGroup.Children.Count != 1) // Skip single
1652 {
1653 if (part.LinkNum < 2) // Root
1654 rootParts.Add(part);
1655 else
1656 childParts.Add(part);
1657
1658 SceneObjectGroup group = part.ParentGroup;
1659 if (!affectedGroups.Contains(group))
1660 affectedGroups.Add(group);
1661 }
1662 }
1633 else 1663 else
1634 childParts.Add(part); 1664 {
1635 1665 m_log.ErrorFormat("Viewer requested unlink of nonexistent part {0}", primID);
1636 SceneObjectGroup group = part.ParentGroup; 1666 }
1637 if (!affectedGroups.Contains(group))
1638 affectedGroups.Add(group);
1639 } 1667 }
1640 else 1668
1669 foreach (SceneObjectPart child in childParts)
1641 { 1670 {
1642 m_log.ErrorFormat("Viewer requested unlink of nonexistent part {0}", primID); 1671 // Unlink all child parts from their groups
1672 //
1673 child.ParentGroup.DelinkFromGroup(child, sendEvents);
1643 } 1674 }
1644 }
1645
1646 foreach (SceneObjectPart child in childParts)
1647 {
1648 // Unlink all child parts from their groups
1649 //
1650 child.ParentGroup.DelinkFromGroup(child, sendEvents);
1651 }
1652
1653 foreach (SceneObjectPart root in rootParts)
1654 {
1655 // In most cases, this will run only one time, and the prim
1656 // will be a solo prim
1657 // However, editing linked parts and unlinking may be different
1658 //
1659 SceneObjectGroup group = root.ParentGroup;
1660 List<SceneObjectPart> newSet = new List<SceneObjectPart>(group.Children.Values);
1661 int numChildren = group.Children.Count;
1662 1675
1663 // If there are prims left in a link set, but the root is 1676 foreach (SceneObjectPart root in rootParts)
1664 // slated for unlink, we need to do this
1665 //
1666 if (numChildren != 1)
1667 { 1677 {
1668 // Unlink the remaining set 1678 // In most cases, this will run only one time, and the prim
1679 // will be a solo prim
1680 // However, editing linked parts and unlinking may be different
1669 // 1681 //
1670 bool sendEventsToRemainder = true; 1682 SceneObjectGroup group = root.ParentGroup;
1671 if (numChildren > 1) 1683 List<SceneObjectPart> newSet = new List<SceneObjectPart>(group.Children.Values);
1672 sendEventsToRemainder = false; 1684 int numChildren = group.Children.Count;
1673
1674 foreach (SceneObjectPart p in newSet)
1675 {
1676 if (p != group.RootPart)
1677 group.DelinkFromGroup(p, sendEventsToRemainder);
1678 }
1679 1685
1680 // If there is more than one prim remaining, we 1686 // If there are prims left in a link set, but the root is
1681 // need to re-link 1687 // slated for unlink, we need to do this
1682 // 1688 //
1683 if (numChildren > 2) 1689 if (numChildren != 1)
1684 { 1690 {
1685 // Remove old root 1691 // Unlink the remaining set
1686 // 1692 //
1687 if (newSet.Contains(root)) 1693 bool sendEventsToRemainder = true;
1688 newSet.Remove(root); 1694 if (numChildren > 1)
1695 sendEventsToRemainder = false;
1689 1696
1690 // Preserve link ordering 1697 foreach (SceneObjectPart p in newSet)
1691 //
1692 newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b)
1693 { 1698 {
1694 return a.LinkNum.CompareTo(b.LinkNum); 1699 if (p != group.RootPart)
1695 }); 1700 group.DelinkFromGroup(p, sendEventsToRemainder);
1701 }
1696 1702
1697 // Determine new root 1703 // If there is more than one prim remaining, we
1704 // need to re-link
1698 // 1705 //
1699 SceneObjectPart newRoot = newSet[0]; 1706 if (numChildren > 2)
1700 newSet.RemoveAt(0); 1707 {
1708 // Remove old root
1709 //
1710 if (newSet.Contains(root))
1711 newSet.Remove(root);
1712
1713 // Preserve link ordering
1714 //
1715 newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b)
1716 {
1717 return a.LinkNum.CompareTo(b.LinkNum);
1718 });
1701 1719
1702 List<uint> linkIDs = new List<uint>(); 1720 // Determine new root
1721 //
1722 SceneObjectPart newRoot = newSet[0];
1723 newSet.RemoveAt(0);
1703 1724
1704 foreach (SceneObjectPart newChild in newSet) 1725 List<uint> linkIDs = new List<uint>();
1705 { 1726
1706 newChild.UpdateFlag = 0; 1727 foreach (SceneObjectPart newChild in newSet)
1707 linkIDs.Add(newChild.LocalId); 1728 {
1708 } 1729 newChild.UpdateFlag = 0;
1730 linkIDs.Add(newChild.LocalId);
1731 }
1709 1732
1710 LinkObjects(null, newRoot.LocalId, linkIDs); 1733 LinkObjects(null, newRoot.LocalId, linkIDs);
1711 if (!affectedGroups.Contains(newRoot.ParentGroup)) 1734 if (!affectedGroups.Contains(newRoot.ParentGroup))
1712 affectedGroups.Add(newRoot.ParentGroup); 1735 affectedGroups.Add(newRoot.ParentGroup);
1736 }
1713 } 1737 }
1714 } 1738 }
1715 }
1716 1739
1717 // Finally, trigger events in the roots 1740 // Finally, trigger events in the roots
1718 // 1741 //
1719 foreach (SceneObjectGroup g in affectedGroups) 1742 foreach (SceneObjectGroup g in affectedGroups)
1743 {
1744 g.TriggerScriptChangedEvent(Changed.LINK);
1745 g.HasGroupChanged = true; // Persist
1746 g.ScheduleGroupForFullUpdate();
1747 }
1748 }
1749 finally
1720 { 1750 {
1721 g.TriggerScriptChangedEvent(Changed.LINK); 1751 Monitor.Exit(m_updateLock);
1722 g.HasGroupChanged = true; // Persist
1723 g.ScheduleGroupForFullUpdate();
1724 } 1752 }
1725 } 1753 }
1726 1754
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index f36ff1d..eacd219 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -98,6 +98,72 @@ namespace OpenSim.Region.Framework.Scenes
98 private bool m_hasGroupChanged = false; 98 private bool m_hasGroupChanged = false;
99 private long timeFirstChanged; 99 private long timeFirstChanged;
100 private long timeLastChanged; 100 private long timeLastChanged;
101 private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim();
102
103 public void lockPartsForRead(bool locked)
104 {
105 if (locked)
106 {
107 if (m_partsLock.RecursiveReadCount > 0)
108 {
109 m_log.Error("[SceneObjectGroup.m_parts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue.");
110 m_partsLock.ExitReadLock();
111 }
112 if (m_partsLock.RecursiveWriteCount > 0)
113 {
114 m_log.Error("[SceneObjectGroup.m_parts] Recursive read lock requested. This should not happen and means something needs to be fixed.");
115 m_partsLock.ExitWriteLock();
116 }
117
118 while (!m_partsLock.TryEnterReadLock(60000))
119 {
120 m_log.Error("[SceneObjectGroup.m_parts] Thread lock detected while trying to aquire READ lock of m_parts in SceneObjectGroup. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
121 if (m_partsLock.IsWriteLockHeld)
122 {
123 m_partsLock = new System.Threading.ReaderWriterLockSlim();
124 }
125 }
126 }
127 else
128 {
129 if (m_partsLock.RecursiveReadCount > 0)
130 {
131 m_partsLock.ExitReadLock();
132 }
133 }
134 }
135 public void lockPartsForWrite(bool locked)
136 {
137 if (locked)
138 {
139 if (m_partsLock.RecursiveReadCount > 0)
140 {
141 m_log.Error("[SceneObjectGroup.m_parts] Recursive write lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue.");
142 m_partsLock.ExitReadLock();
143 }
144 if (m_partsLock.RecursiveWriteCount > 0)
145 {
146 m_log.Error("[SceneObjectGroup.m_parts] Recursive write lock requested. This should not happen and means something needs to be fixed.");
147 m_partsLock.ExitWriteLock();
148 }
149
150 while (!m_partsLock.TryEnterWriteLock(60000))
151 {
152 m_log.Error("[SceneObjectGroup.m_parts] Thread lock detected while trying to aquire WRITE lock of m_scripts in XEngine. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
153 if (m_partsLock.IsWriteLockHeld)
154 {
155 m_partsLock = new System.Threading.ReaderWriterLockSlim();
156 }
157 }
158 }
159 else
160 {
161 if (m_partsLock.RecursiveWriteCount > 0)
162 {
163 m_partsLock.ExitWriteLock();
164 }
165 }
166 }
101 167
102 public bool HasGroupChanged 168 public bool HasGroupChanged
103 { 169 {
@@ -243,13 +309,16 @@ namespace OpenSim.Region.Framework.Scenes
243 set 309 set
244 { 310 {
245 m_regionHandle = value; 311 m_regionHandle = value;
246 lock (m_parts) 312 lockPartsForRead(true);
247 { 313 {
248 foreach (SceneObjectPart part in m_parts.Values) 314 foreach (SceneObjectPart part in m_parts.Values)
249 { 315 {
316
250 part.RegionHandle = m_regionHandle; 317 part.RegionHandle = m_regionHandle;
318
251 } 319 }
252 } 320 }
321 lockPartsForRead(false);
253 } 322 }
254 } 323 }
255 324
@@ -275,13 +344,16 @@ namespace OpenSim.Region.Framework.Scenes
275 m_scene.CrossPrimGroupIntoNewRegion(val, this, true); 344 m_scene.CrossPrimGroupIntoNewRegion(val, this, true);
276 } 345 }
277 346
278 lock (m_parts) 347 lockPartsForRead(true);
279 { 348 {
280 foreach (SceneObjectPart part in m_parts.Values) 349 foreach (SceneObjectPart part in m_parts.Values)
281 { 350 {
351
282 part.GroupPosition = val; 352 part.GroupPosition = val;
353
283 } 354 }
284 } 355 }
356 lockPartsForRead(false);
285 357
286 //if (m_rootPart.PhysActor != null) 358 //if (m_rootPart.PhysActor != null)
287 //{ 359 //{
@@ -432,13 +504,16 @@ namespace OpenSim.Region.Framework.Scenes
432 504
433 public void SetFromItemID(UUID AssetId) 505 public void SetFromItemID(UUID AssetId)
434 { 506 {
435 lock (m_parts) 507 lockPartsForRead(true);
436 { 508 {
437 foreach (SceneObjectPart part in m_parts.Values) 509 foreach (SceneObjectPart part in m_parts.Values)
438 { 510 {
511
439 part.FromItemID = AssetId; 512 part.FromItemID = AssetId;
513
440 } 514 }
441 } 515 }
516 lockPartsForRead(false);
442 } 517 }
443 518
444 public UUID GetFromItemID() 519 public UUID GetFromItemID()
@@ -505,10 +580,11 @@ namespace OpenSim.Region.Framework.Scenes
505 Vector3 maxScale = Vector3.Zero; 580 Vector3 maxScale = Vector3.Zero;
506 Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); 581 Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f);
507 582
508 lock (m_parts) 583 lockPartsForRead(true);
509 { 584 {
510 foreach (SceneObjectPart part in m_parts.Values) 585 foreach (SceneObjectPart part in m_parts.Values)
511 { 586 {
587
512 Vector3 partscale = part.Scale; 588 Vector3 partscale = part.Scale;
513 Vector3 partoffset = part.OffsetPosition; 589 Vector3 partoffset = part.OffsetPosition;
514 590
@@ -519,8 +595,11 @@ namespace OpenSim.Region.Framework.Scenes
519 maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X; 595 maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X;
520 maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y; 596 maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y;
521 maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z; 597 maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z;
598
522 } 599 }
523 } 600 }
601 lockPartsForRead(false);
602
524 finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X; 603 finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X;
525 finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; 604 finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y;
526 finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; 605 finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z;
@@ -536,10 +615,11 @@ namespace OpenSim.Region.Framework.Scenes
536 615
537 EntityIntersection result = new EntityIntersection(); 616 EntityIntersection result = new EntityIntersection();
538 617
539 lock (m_parts) 618 lockPartsForRead(true);
540 { 619 {
541 foreach (SceneObjectPart part in m_parts.Values) 620 foreach (SceneObjectPart part in m_parts.Values)
542 { 621 {
622
543 // Temporary commented to stop compiler warning 623 // Temporary commented to stop compiler warning
544 //Vector3 partPosition = 624 //Vector3 partPosition =
545 // new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z); 625 // new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z);
@@ -567,8 +647,10 @@ namespace OpenSim.Region.Framework.Scenes
567 result.distance = inter.distance; 647 result.distance = inter.distance;
568 } 648 }
569 } 649 }
650
570 } 651 }
571 } 652 }
653 lockPartsForRead(false);
572 return result; 654 return result;
573 } 655 }
574 656
@@ -581,10 +663,11 @@ namespace OpenSim.Region.Framework.Scenes
581 public Vector3 GetAxisAlignedBoundingBox(out float offsetHeight) 663 public Vector3 GetAxisAlignedBoundingBox(out float offsetHeight)
582 { 664 {
583 float maxX = -256f, maxY = -256f, maxZ = -256f, minX = 256f, minY = 256f, minZ = 256f; 665 float maxX = -256f, maxY = -256f, maxZ = -256f, minX = 256f, minY = 256f, minZ = 256f;
584 lock (m_parts) 666 lockPartsForRead(true);
585 { 667 {
586 foreach (SceneObjectPart part in m_parts.Values) 668 foreach (SceneObjectPart part in m_parts.Values)
587 { 669 {
670
588 Vector3 worldPos = part.GetWorldPosition(); 671 Vector3 worldPos = part.GetWorldPosition();
589 Vector3 offset = worldPos - AbsolutePosition; 672 Vector3 offset = worldPos - AbsolutePosition;
590 Quaternion worldRot; 673 Quaternion worldRot;
@@ -643,6 +726,8 @@ namespace OpenSim.Region.Framework.Scenes
643 backBottomRight.Y = orig.Y + (part.Scale.Y / 2); 726 backBottomRight.Y = orig.Y + (part.Scale.Y / 2);
644 backBottomRight.Z = orig.Z - (part.Scale.Z / 2); 727 backBottomRight.Z = orig.Z - (part.Scale.Z / 2);
645 728
729
730
646 //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); 731 //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z);
647 //m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); 732 //m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z);
648 //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); 733 //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z);
@@ -814,6 +899,7 @@ namespace OpenSim.Region.Framework.Scenes
814 minZ = backBottomLeft.Z; 899 minZ = backBottomLeft.Z;
815 } 900 }
816 } 901 }
902 lockPartsForRead(false);
817 903
818 Vector3 boundingBox = new Vector3(maxX - minX, maxY - minY, maxZ - minZ); 904 Vector3 boundingBox = new Vector3(maxX - minX, maxY - minY, maxZ - minZ);
819 905
@@ -842,17 +928,20 @@ namespace OpenSim.Region.Framework.Scenes
842 Dictionary<UUID,string> states = new Dictionary<UUID,string>(); 928 Dictionary<UUID,string> states = new Dictionary<UUID,string>();
843 929
844 // Capture script state while holding the lock 930 // Capture script state while holding the lock
845 lock (m_parts) 931 lockPartsForRead(true);
846 { 932 {
847 foreach (SceneObjectPart part in m_parts.Values) 933 foreach (SceneObjectPart part in m_parts.Values)
848 { 934 {
935
849 Dictionary<UUID,string> pstates = part.Inventory.GetScriptStates(); 936 Dictionary<UUID,string> pstates = part.Inventory.GetScriptStates();
850 foreach (UUID itemid in pstates.Keys) 937 foreach (UUID itemid in pstates.Keys)
851 { 938 {
852 states.Add(itemid, pstates[itemid]); 939 states.Add(itemid, pstates[itemid]);
853 } 940 }
941
854 } 942 }
855 } 943 }
944 lockPartsForRead(false);
856 945
857 if (states.Count > 0) 946 if (states.Count > 0)
858 { 947 {
@@ -1014,13 +1103,16 @@ namespace OpenSim.Region.Framework.Scenes
1014 1103
1015 public override void UpdateMovement() 1104 public override void UpdateMovement()
1016 { 1105 {
1017 lock (m_parts) 1106 lockPartsForRead(true);
1018 { 1107 {
1019 foreach (SceneObjectPart part in m_parts.Values) 1108 foreach (SceneObjectPart part in m_parts.Values)
1020 { 1109 {
1110
1021 part.UpdateMovement(); 1111 part.UpdateMovement();
1112
1022 } 1113 }
1023 } 1114 }
1115 lockPartsForRead(false);
1024 } 1116 }
1025 1117
1026 public ushort GetTimeDilation() 1118 public ushort GetTimeDilation()
@@ -1064,7 +1156,7 @@ namespace OpenSim.Region.Framework.Scenes
1064 /// <param name="part"></param> 1156 /// <param name="part"></param>
1065 public void AddPart(SceneObjectPart part) 1157 public void AddPart(SceneObjectPart part)
1066 { 1158 {
1067 lock (m_parts) 1159 lockPartsForWrite(true);
1068 { 1160 {
1069 part.SetParent(this); 1161 part.SetParent(this);
1070 m_parts.Add(part.UUID, part); 1162 m_parts.Add(part.UUID, part);
@@ -1074,6 +1166,7 @@ namespace OpenSim.Region.Framework.Scenes
1074 if (part.LinkNum == 2 && RootPart != null) 1166 if (part.LinkNum == 2 && RootPart != null)
1075 RootPart.LinkNum = 1; 1167 RootPart.LinkNum = 1;
1076 } 1168 }
1169 lockPartsForWrite(false);
1077 } 1170 }
1078 1171
1079 /// <summary> 1172 /// <summary>
@@ -1081,28 +1174,33 @@ namespace OpenSim.Region.Framework.Scenes
1081 /// </summary> 1174 /// </summary>
1082 private void UpdateParentIDs() 1175 private void UpdateParentIDs()
1083 { 1176 {
1084 lock (m_parts) 1177 lockPartsForRead(true);
1085 { 1178 {
1086 foreach (SceneObjectPart part in m_parts.Values) 1179 foreach (SceneObjectPart part in m_parts.Values)
1087 { 1180 {
1181
1088 if (part.UUID != m_rootPart.UUID) 1182 if (part.UUID != m_rootPart.UUID)
1089 { 1183 {
1090 part.ParentID = m_rootPart.LocalId; 1184 part.ParentID = m_rootPart.LocalId;
1091 } 1185 }
1186
1092 } 1187 }
1093 } 1188 }
1189 lockPartsForRead(false);
1094 } 1190 }
1095 1191
1096 public void RegenerateFullIDs() 1192 public void RegenerateFullIDs()
1097 { 1193 {
1098 lock (m_parts) 1194 lockPartsForRead(true);
1099 { 1195 {
1100 foreach (SceneObjectPart part in m_parts.Values) 1196 foreach (SceneObjectPart part in m_parts.Values)
1101 { 1197 {
1198
1102 part.UUID = UUID.Random(); 1199 part.UUID = UUID.Random();
1103 1200
1104 } 1201 }
1105 } 1202 }
1203 lockPartsForRead(false);
1106 } 1204 }
1107 1205
1108 // helper provided for parts. 1206 // helper provided for parts.
@@ -1183,28 +1281,33 @@ namespace OpenSim.Region.Framework.Scenes
1183 1281
1184 DetachFromBackup(); 1282 DetachFromBackup();
1185 1283
1186 lock (m_parts) 1284 lockPartsForRead(true);
1285 List<SceneObjectPart> values = new List<SceneObjectPart>(m_parts.Values);
1286 lockPartsForRead(false);
1287
1288 foreach (SceneObjectPart part in values)
1187 { 1289 {
1188 foreach (SceneObjectPart part in m_parts.Values)
1189 {
1190// part.Inventory.RemoveScriptInstances(); 1290// part.Inventory.RemoveScriptInstances();
1191 1291
1192 ScenePresence[] avatars = Scene.GetScenePresences(); 1292 ScenePresence[] avatars = Scene.GetScenePresences();
1193 for (int i = 0; i < avatars.Length; i++) 1293 for (int i = 0; i < avatars.Length; i++)
1294 {
1295 if (avatars[i].ParentID == LocalId)
1194 { 1296 {
1195 if (avatars[i].ParentID == LocalId) 1297 avatars[i].StandUp();
1196 { 1298 }
1197 avatars[i].StandUp();
1198 }
1199 1299
1200 if (!silent) 1300 if (!silent)
1201 { 1301 {
1202 if (part == m_rootPart) 1302 part.UpdateFlag = 0;
1203 avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalId); 1303 if (part == m_rootPart)
1204 } 1304 avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalId);
1205 } 1305 }
1206 } 1306 }
1307
1207 } 1308 }
1309
1310
1208 } 1311 }
1209 1312
1210 public void AddScriptLPS(int count) 1313 public void AddScriptLPS(int count)
@@ -1229,17 +1332,20 @@ namespace OpenSim.Region.Framework.Scenes
1229 1332
1230 scriptEvents aggregateScriptEvents=0; 1333 scriptEvents aggregateScriptEvents=0;
1231 1334
1232 lock (m_parts) 1335 lockPartsForRead(true);
1233 { 1336 {
1234 foreach (SceneObjectPart part in m_parts.Values) 1337 foreach (SceneObjectPart part in m_parts.Values)
1235 { 1338 {
1339
1236 if (part == null) 1340 if (part == null)
1237 continue; 1341 continue;
1238 if (part != RootPart) 1342 if (part != RootPart)
1239 part.ObjectFlags = objectflagupdate; 1343 part.ObjectFlags = objectflagupdate;
1240 aggregateScriptEvents |= part.AggregateScriptEvents; 1344 aggregateScriptEvents |= part.AggregateScriptEvents;
1345
1241 } 1346 }
1242 } 1347 }
1348 lockPartsForRead(false);
1243 1349
1244 m_scriptListens_atTarget = ((aggregateScriptEvents & scriptEvents.at_target) != 0); 1350 m_scriptListens_atTarget = ((aggregateScriptEvents & scriptEvents.at_target) != 0);
1245 m_scriptListens_notAtTarget = ((aggregateScriptEvents & scriptEvents.not_at_target) != 0); 1351 m_scriptListens_notAtTarget = ((aggregateScriptEvents & scriptEvents.not_at_target) != 0);
@@ -1272,42 +1378,52 @@ namespace OpenSim.Region.Framework.Scenes
1272 /// <param name="m_physicalPrim"></param> 1378 /// <param name="m_physicalPrim"></param>
1273 public void ApplyPhysics(bool m_physicalPrim) 1379 public void ApplyPhysics(bool m_physicalPrim)
1274 { 1380 {
1275 lock (m_parts) 1381 lockPartsForRead(true);
1382
1383 if (m_parts.Count > 1)
1276 { 1384 {
1277 if (m_parts.Count > 1) 1385 List<SceneObjectPart> values = new List<SceneObjectPart>(m_parts.Values);
1386 lockPartsForRead(false);
1387 m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim);
1388 foreach (SceneObjectPart part in values)
1278 { 1389 {
1279 m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim); 1390
1280 foreach (SceneObjectPart part in m_parts.Values) 1391 if (part.LocalId != m_rootPart.LocalId)
1281 { 1392 {
1282 if (part.LocalId != m_rootPart.LocalId) 1393 part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, m_physicalPrim);
1283 {
1284 part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, m_physicalPrim);
1285 }
1286 } 1394 }
1287 1395
1288 // Hack to get the physics scene geometries in the right spot
1289 ResetChildPrimPhysicsPositions();
1290 }
1291 else
1292 {
1293 m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim);
1294 } 1396 }
1397 // Hack to get the physics scene geometries in the right spot
1398 ResetChildPrimPhysicsPositions();
1399 }
1400 else
1401 {
1402 lockPartsForRead(false);
1403 m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim);
1295 } 1404 }
1296 } 1405 }
1297 1406
1298 public void SetOwnerId(UUID userId) 1407 public void SetOwnerId(UUID userId)
1299 { 1408 {
1300 ForEachPart(delegate(SceneObjectPart part) { part.OwnerID = userId; }); 1409 ForEachPart(delegate(SceneObjectPart part)
1410 {
1411
1412 part.OwnerID = userId;
1413
1414 });
1301 } 1415 }
1302 1416
1303 public void ForEachPart(Action<SceneObjectPart> whatToDo) 1417 public void ForEachPart(Action<SceneObjectPart> whatToDo)
1304 { 1418 {
1305 lock (m_parts) 1419 lockPartsForRead(true);
1420 List<SceneObjectPart> values = new List<SceneObjectPart>(m_parts.Values);
1421 lockPartsForRead(false);
1422 foreach (SceneObjectPart part in values)
1306 { 1423 {
1307 foreach (SceneObjectPart part in m_parts.Values) 1424
1308 { 1425 whatToDo(part);
1309 whatToDo(part); 1426
1310 }
1311 } 1427 }
1312 } 1428 }
1313 1429
@@ -1406,14 +1522,17 @@ namespace OpenSim.Region.Framework.Scenes
1406 { 1522 {
1407 SendPartFullUpdate(remoteClient, RootPart, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID)); 1523 SendPartFullUpdate(remoteClient, RootPart, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID));
1408 1524
1409 lock (m_parts) 1525 lockPartsForRead(true);
1410 { 1526 {
1411 foreach (SceneObjectPart part in m_parts.Values) 1527 foreach (SceneObjectPart part in m_parts.Values)
1412 { 1528 {
1529
1413 if (part != RootPart) 1530 if (part != RootPart)
1414 SendPartFullUpdate(remoteClient, part, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID)); 1531 SendPartFullUpdate(remoteClient, part, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID));
1532
1415 } 1533 }
1416 } 1534 }
1535 lockPartsForRead(false);
1417 } 1536 }
1418 1537
1419 /// <summary> 1538 /// <summary>
@@ -1508,10 +1627,11 @@ namespace OpenSim.Region.Framework.Scenes
1508 1627
1509 List<SceneObjectPart> partList; 1628 List<SceneObjectPart> partList;
1510 1629
1511 lock (m_parts) 1630 lockPartsForRead(true);
1512 { 1631
1513 partList = new List<SceneObjectPart>(m_parts.Values); 1632 partList = new List<SceneObjectPart>(m_parts.Values);
1514 } 1633
1634 lockPartsForRead(false);
1515 1635
1516 partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) 1636 partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2)
1517 { 1637 {
@@ -1834,10 +1954,11 @@ namespace OpenSim.Region.Framework.Scenes
1834 SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); 1954 SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed);
1835 newPart.SetParent(this); 1955 newPart.SetParent(this);
1836 1956
1837 lock (m_parts) 1957 lockPartsForWrite(true);
1838 { 1958 {
1839 m_parts.Add(newPart.UUID, newPart); 1959 m_parts.Add(newPart.UUID, newPart);
1840 } 1960 }
1961 lockPartsForWrite(false);
1841 1962
1842 SetPartAsNonRoot(newPart); 1963 SetPartAsNonRoot(newPart);
1843 1964
@@ -1900,7 +2021,7 @@ namespace OpenSim.Region.Framework.Scenes
1900 //if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) 2021 //if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)
1901 // return; 2022 // return;
1902 2023
1903 lock (m_parts) 2024 lockPartsForRead(true);
1904 { 2025 {
1905 bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); 2026 bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0);
1906 2027
@@ -1918,34 +2039,43 @@ namespace OpenSim.Region.Framework.Scenes
1918 2039
1919 foreach (SceneObjectPart part in m_parts.Values) 2040 foreach (SceneObjectPart part in m_parts.Values)
1920 { 2041 {
2042
1921 part.SendScheduledUpdates(); 2043 part.SendScheduledUpdates();
2044
1922 } 2045 }
1923 } 2046 }
2047 lockPartsForRead(false);
1924 } 2048 }
1925 2049
1926 public void ScheduleFullUpdateToAvatar(ScenePresence presence) 2050 public void ScheduleFullUpdateToAvatar(ScenePresence presence)
1927 { 2051 {
1928 RootPart.AddFullUpdateToAvatar(presence); 2052 RootPart.AddFullUpdateToAvatar(presence);
1929 2053
1930 lock (m_parts) 2054 lockPartsForRead(true);
1931 { 2055 {
1932 foreach (SceneObjectPart part in m_parts.Values) 2056 foreach (SceneObjectPart part in m_parts.Values)
1933 { 2057 {
2058
1934 if (part != RootPart) 2059 if (part != RootPart)
1935 part.AddFullUpdateToAvatar(presence); 2060 part.AddFullUpdateToAvatar(presence);
2061
1936 } 2062 }
1937 } 2063 }
2064 lockPartsForRead(false);
1938 } 2065 }
1939 2066
1940 public void ScheduleTerseUpdateToAvatar(ScenePresence presence) 2067 public void ScheduleTerseUpdateToAvatar(ScenePresence presence)
1941 { 2068 {
1942 lock (m_parts) 2069 lockPartsForRead(true);
1943 { 2070 {
1944 foreach (SceneObjectPart part in m_parts.Values) 2071 foreach (SceneObjectPart part in m_parts.Values)
1945 { 2072 {
2073
1946 part.AddTerseUpdateToAvatar(presence); 2074 part.AddTerseUpdateToAvatar(presence);
2075
1947 } 2076 }
1948 } 2077 }
2078 lockPartsForRead(false);
1949 } 2079 }
1950 2080
1951 /// <summary> 2081 /// <summary>
@@ -1956,14 +2086,17 @@ namespace OpenSim.Region.Framework.Scenes
1956 checkAtTargets(); 2086 checkAtTargets();
1957 RootPart.ScheduleFullUpdate(); 2087 RootPart.ScheduleFullUpdate();
1958 2088
1959 lock (m_parts) 2089 lockPartsForRead(true);
1960 { 2090 {
1961 foreach (SceneObjectPart part in m_parts.Values) 2091 foreach (SceneObjectPart part in m_parts.Values)
1962 { 2092 {
2093
1963 if (part != RootPart) 2094 if (part != RootPart)
1964 part.ScheduleFullUpdate(); 2095 part.ScheduleFullUpdate();
2096
1965 } 2097 }
1966 } 2098 }
2099 lockPartsForRead(false);
1967 } 2100 }
1968 2101
1969 /// <summary> 2102 /// <summary>
@@ -1971,13 +2104,16 @@ namespace OpenSim.Region.Framework.Scenes
1971 /// </summary> 2104 /// </summary>
1972 public void ScheduleGroupForTerseUpdate() 2105 public void ScheduleGroupForTerseUpdate()
1973 { 2106 {
1974 lock (m_parts) 2107 lockPartsForRead(true);
1975 { 2108 {
1976 foreach (SceneObjectPart part in m_parts.Values) 2109 foreach (SceneObjectPart part in m_parts.Values)
1977 { 2110 {
2111
1978 part.ScheduleTerseUpdate(); 2112 part.ScheduleTerseUpdate();
2113
1979 } 2114 }
1980 } 2115 }
2116 lockPartsForRead(false);
1981 } 2117 }
1982 2118
1983 /// <summary> 2119 /// <summary>
@@ -1990,14 +2126,17 @@ namespace OpenSim.Region.Framework.Scenes
1990 2126
1991 RootPart.SendFullUpdateToAllClients(); 2127 RootPart.SendFullUpdateToAllClients();
1992 2128
1993 lock (m_parts) 2129 lockPartsForRead(true);
1994 { 2130 {
1995 foreach (SceneObjectPart part in m_parts.Values) 2131 foreach (SceneObjectPart part in m_parts.Values)
1996 { 2132 {
2133
1997 if (part != RootPart) 2134 if (part != RootPart)
1998 part.SendFullUpdateToAllClients(); 2135 part.SendFullUpdateToAllClients();
2136
1999 } 2137 }
2000 } 2138 }
2139 lockPartsForRead(false);
2001 } 2140 }
2002 2141
2003 /// <summary> 2142 /// <summary>
@@ -2028,14 +2167,15 @@ namespace OpenSim.Region.Framework.Scenes
2028 { 2167 {
2029 if (IsDeleted) 2168 if (IsDeleted)
2030 return; 2169 return;
2031 2170
2032 lock (m_parts) 2171 lockPartsForRead(true);
2033 { 2172 {
2034 foreach (SceneObjectPart part in m_parts.Values) 2173 foreach (SceneObjectPart part in m_parts.Values)
2035 { 2174 {
2036 part.SendTerseUpdateToAllClients(); 2175 part.SendTerseUpdateToAllClients();
2037 } 2176 }
2038 } 2177 }
2178 lockPartsForRead(false);
2039 } 2179 }
2040 2180
2041 #endregion 2181 #endregion
@@ -2049,16 +2189,18 @@ namespace OpenSim.Region.Framework.Scenes
2049 /// <returns>null if no child part with that linknum or child part</returns> 2189 /// <returns>null if no child part with that linknum or child part</returns>
2050 public SceneObjectPart GetLinkNumPart(int linknum) 2190 public SceneObjectPart GetLinkNumPart(int linknum)
2051 { 2191 {
2052 lock (m_parts) 2192 lockPartsForRead(true);
2053 { 2193 {
2054 foreach (SceneObjectPart part in m_parts.Values) 2194 foreach (SceneObjectPart part in m_parts.Values)
2055 { 2195 {
2056 if (part.LinkNum == linknum) 2196 if (part.LinkNum == linknum)
2057 { 2197 {
2198 lockPartsForRead(false);
2058 return part; 2199 return part;
2059 } 2200 }
2060 } 2201 }
2061 } 2202 }
2203 lockPartsForRead(false);
2062 2204
2063 return null; 2205 return null;
2064 } 2206 }
@@ -2086,17 +2228,19 @@ namespace OpenSim.Region.Framework.Scenes
2086 public SceneObjectPart GetChildPart(uint localID) 2228 public SceneObjectPart GetChildPart(uint localID)
2087 { 2229 {
2088 //m_log.DebugFormat("Entered looking for {0}", localID); 2230 //m_log.DebugFormat("Entered looking for {0}", localID);
2089 lock (m_parts) 2231 lockPartsForRead(true);
2090 { 2232 {
2091 foreach (SceneObjectPart part in m_parts.Values) 2233 foreach (SceneObjectPart part in m_parts.Values)
2092 { 2234 {
2093 //m_log.DebugFormat("Found {0}", part.LocalId); 2235 //m_log.DebugFormat("Found {0}", part.LocalId);
2094 if (part.LocalId == localID) 2236 if (part.LocalId == localID)
2095 { 2237 {
2238 lockPartsForRead(false);
2096 return part; 2239 return part;
2097 } 2240 }
2098 } 2241 }
2099 } 2242 }
2243 lockPartsForRead(false);
2100 2244
2101 return null; 2245 return null;
2102 } 2246 }
@@ -2126,17 +2270,19 @@ namespace OpenSim.Region.Framework.Scenes
2126 public bool HasChildPrim(uint localID) 2270 public bool HasChildPrim(uint localID)
2127 { 2271 {
2128 //m_log.DebugFormat("Entered HasChildPrim looking for {0}", localID); 2272 //m_log.DebugFormat("Entered HasChildPrim looking for {0}", localID);
2129 lock (m_parts) 2273 lockPartsForRead(true);
2130 { 2274 {
2131 foreach (SceneObjectPart part in m_parts.Values) 2275 foreach (SceneObjectPart part in m_parts.Values)
2132 { 2276 {
2133 //m_log.DebugFormat("Found {0}", part.LocalId); 2277 //m_log.DebugFormat("Found {0}", part.LocalId);
2134 if (part.LocalId == localID) 2278 if (part.LocalId == localID)
2135 { 2279 {
2280 lockPartsForRead(false);
2136 return true; 2281 return true;
2137 } 2282 }
2138 } 2283 }
2139 } 2284 }
2285 lockPartsForRead(false);
2140 2286
2141 return false; 2287 return false;
2142 } 2288 }
@@ -2152,14 +2298,14 @@ namespace OpenSim.Region.Framework.Scenes
2152 public void LinkToGroup(SceneObjectGroup objectGroup) 2298 public void LinkToGroup(SceneObjectGroup objectGroup)
2153 { 2299 {
2154 // Make sure we have sent any pending unlinks or stuff. 2300 // Make sure we have sent any pending unlinks or stuff.
2155 if (objectGroup.RootPart.UpdateFlag > 0) 2301 //if (objectGroup.RootPart.UpdateFlag > 0)
2156 { 2302 //{
2157 m_log.WarnFormat( 2303 // m_log.WarnFormat(
2158 "[SCENE OBJECT GROUP]: Forcing send of linkset {0}, {1} to {2}, {3} as its still waiting.", 2304 // "[SCENE OBJECT GROUP]: Forcing send of linkset {0}, {1} to {2}, {3} as its still waiting.",
2159 objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); 2305 // objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID);
2160 2306
2161 objectGroup.RootPart.SendScheduledUpdates(); 2307 // objectGroup.RootPart.SendScheduledUpdates();
2162 } 2308 //}
2163 2309
2164// m_log.DebugFormat( 2310// m_log.DebugFormat(
2165// "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}", 2311// "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}",
@@ -2186,53 +2332,57 @@ namespace OpenSim.Region.Framework.Scenes
2186 if (m_rootPart.LinkNum == 0) 2332 if (m_rootPart.LinkNum == 0)
2187 m_rootPart.LinkNum = 1; 2333 m_rootPart.LinkNum = 1;
2188 2334
2189 lock (m_parts) 2335 lockPartsForWrite(true);
2190 { 2336
2191 m_parts.Add(linkPart.UUID, linkPart); 2337 m_parts.Add(linkPart.UUID, linkPart);
2338
2339 lockPartsForWrite(false);
2192 2340
2193 // Insert in terms of link numbers, the new links 2341 // Insert in terms of link numbers, the new links
2194 // before the current ones (with the exception of 2342 // before the current ones (with the exception of
2195 // the root prim. Shuffle the old ones up 2343 // the root prim. Shuffle the old ones up
2196 foreach (KeyValuePair<UUID, SceneObjectPart> kvp in m_parts) 2344 lockPartsForRead(true);
2345 foreach (KeyValuePair<UUID, SceneObjectPart> kvp in m_parts)
2346 {
2347 if (kvp.Value.LinkNum != 1)
2197 { 2348 {
2198 if (kvp.Value.LinkNum != 1) 2349 // Don't update root prim link number
2199 { 2350 kvp.Value.LinkNum += objectGroup.PrimCount;
2200 // Don't update root prim link number
2201 kvp.Value.LinkNum += objectGroup.PrimCount;
2202 }
2203 } 2351 }
2352 }
2353 lockPartsForRead(false);
2204 2354
2205 linkPart.LinkNum = 2; 2355 linkPart.LinkNum = 2;
2206 2356
2207 linkPart.SetParent(this); 2357 linkPart.SetParent(this);
2208 linkPart.AddFlag(PrimFlags.CreateSelected); 2358 linkPart.AddFlag(PrimFlags.CreateSelected);
2209 2359
2210 //if (linkPart.PhysActor != null) 2360 //if (linkPart.PhysActor != null)
2211 //{ 2361 //{
2212 // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor); 2362 // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor);
2213 2363
2214 //linkPart.PhysActor = null; 2364 //linkPart.PhysActor = null;
2215 //} 2365 //}
2216 2366
2217 //TODO: rest of parts 2367 //TODO: rest of parts
2218 int linkNum = 3; 2368 int linkNum = 3;
2219 foreach (SceneObjectPart part in objectGroup.Children.Values) 2369 foreach (SceneObjectPart part in objectGroup.Children.Values)
2370 {
2371 if (part.UUID != objectGroup.m_rootPart.UUID)
2220 { 2372 {
2221 if (part.UUID != objectGroup.m_rootPart.UUID) 2373 LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++);
2222 {
2223 LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++);
2224 }
2225 part.ClearUndoState();
2226 } 2374 }
2375 part.ClearUndoState();
2227 } 2376 }
2228 2377
2229 m_scene.UnlinkSceneObject(objectGroup.UUID, true); 2378 m_scene.UnlinkSceneObject(objectGroup.UUID, true);
2230 objectGroup.m_isDeleted = true; 2379 objectGroup.m_isDeleted = true;
2380
2381 objectGroup.lockPartsForWrite(true);
2231 2382
2232 lock (objectGroup.m_parts) 2383 objectGroup.m_parts.Clear();
2233 { 2384
2234 objectGroup.m_parts.Clear(); 2385 objectGroup.lockPartsForWrite(false);
2235 }
2236 2386
2237 // Can't do this yet since backup still makes use of the root part without any synchronization 2387 // Can't do this yet since backup still makes use of the root part without any synchronization
2238// objectGroup.m_rootPart = null; 2388// objectGroup.m_rootPart = null;
@@ -2245,8 +2395,8 @@ namespace OpenSim.Region.Framework.Scenes
2245 // unmoved prims! 2395 // unmoved prims!
2246 ResetChildPrimPhysicsPositions(); 2396 ResetChildPrimPhysicsPositions();
2247 2397
2248 HasGroupChanged = true; 2398 //HasGroupChanged = true;
2249 ScheduleGroupForFullUpdate(); 2399 //ScheduleGroupForFullUpdate();
2250 } 2400 }
2251 2401
2252 /// <summary> 2402 /// <summary>
@@ -2291,11 +2441,12 @@ namespace OpenSim.Region.Framework.Scenes
2291 Quaternion worldRot = linkPart.GetWorldRotation(); 2441 Quaternion worldRot = linkPart.GetWorldRotation();
2292 2442
2293 // Remove the part from this object 2443 // Remove the part from this object
2294 lock (m_parts) 2444 lockPartsForWrite(true);
2295 { 2445 {
2296 m_parts.Remove(linkPart.UUID); 2446 m_parts.Remove(linkPart.UUID);
2297 } 2447 }
2298 2448 lockPartsForWrite(false);
2449 lockPartsForRead(true);
2299 if (m_parts.Count == 1 && RootPart != null) //Single prim is left 2450 if (m_parts.Count == 1 && RootPart != null) //Single prim is left
2300 RootPart.LinkNum = 0; 2451 RootPart.LinkNum = 0;
2301 else 2452 else
@@ -2306,6 +2457,7 @@ namespace OpenSim.Region.Framework.Scenes
2306 p.LinkNum--; 2457 p.LinkNum--;
2307 } 2458 }
2308 } 2459 }
2460 lockPartsForRead(false);
2309 2461
2310 linkPart.ParentID = 0; 2462 linkPart.ParentID = 0;
2311 linkPart.LinkNum = 0; 2463 linkPart.LinkNum = 0;
@@ -2337,8 +2489,8 @@ namespace OpenSim.Region.Framework.Scenes
2337 2489
2338 linkPart.Rezzed = RootPart.Rezzed; 2490 linkPart.Rezzed = RootPart.Rezzed;
2339 2491
2340 HasGroupChanged = true; 2492 //HasGroupChanged = true;
2341 ScheduleGroupForFullUpdate(); 2493 //ScheduleGroupForFullUpdate();
2342 } 2494 }
2343 2495
2344 /// <summary> 2496 /// <summary>
@@ -2623,22 +2775,28 @@ namespace OpenSim.Region.Framework.Scenes
2623 2775
2624 if (selectionPart != null) 2776 if (selectionPart != null)
2625 { 2777 {
2626 lock (m_parts) 2778 lockPartsForRead(true);
2779 List<SceneObjectPart> parts = new List<SceneObjectPart>(m_parts.Values);
2780 lockPartsForRead(false);
2781 foreach (SceneObjectPart part in parts)
2627 { 2782 {
2628 foreach (SceneObjectPart part in m_parts.Values) 2783 if (part.Scale.X > 10.0 || part.Scale.Y > 10.0 || part.Scale.Z > 10.0)
2629 { 2784 {
2630 if (part.Scale.X > 10.0 || part.Scale.Y > 10.0 || part.Scale.Z > 10.0) 2785 if (part.Scale.X > m_scene.RegionInfo.PhysPrimMax ||
2786 part.Scale.Y > m_scene.RegionInfo.PhysPrimMax ||
2787 part.Scale.Z > m_scene.RegionInfo.PhysPrimMax)
2631 { 2788 {
2632 UsePhysics = false; // Reset physics 2789 UsePhysics = false; // Reset physics
2633 break; 2790 break;
2634 } 2791 }
2635 } 2792 }
2793 }
2636 2794
2637 foreach (SceneObjectPart part in m_parts.Values) 2795 foreach (SceneObjectPart part in parts)
2638 { 2796 {
2639 part.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); 2797 part.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect);
2640 }
2641 } 2798 }
2799
2642 } 2800 }
2643 } 2801 }
2644 2802
@@ -2724,11 +2882,9 @@ namespace OpenSim.Region.Framework.Scenes
2724 scale.Y = m_scene.m_maxNonphys; 2882 scale.Y = m_scene.m_maxNonphys;
2725 if (scale.Z > m_scene.m_maxNonphys) 2883 if (scale.Z > m_scene.m_maxNonphys)
2726 scale.Z = m_scene.m_maxNonphys; 2884 scale.Z = m_scene.m_maxNonphys;
2727
2728 SceneObjectPart part = GetChildPart(localID); 2885 SceneObjectPart part = GetChildPart(localID);
2729 if (part != null) 2886 if (part != null)
2730 { 2887 {
2731 part.Resize(scale);
2732 if (part.PhysActor != null) 2888 if (part.PhysActor != null)
2733 { 2889 {
2734 if (part.PhysActor.IsPhysical) 2890 if (part.PhysActor.IsPhysical)
@@ -2743,7 +2899,7 @@ namespace OpenSim.Region.Framework.Scenes
2743 part.PhysActor.Size = scale; 2899 part.PhysActor.Size = scale;
2744 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); 2900 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
2745 } 2901 }
2746 //if (part.UUID != m_rootPart.UUID) 2902 part.Resize(scale);
2747 2903
2748 HasGroupChanged = true; 2904 HasGroupChanged = true;
2749 ScheduleGroupForFullUpdate(); 2905 ScheduleGroupForFullUpdate();
@@ -2784,77 +2940,76 @@ namespace OpenSim.Region.Framework.Scenes
2784 float y = (scale.Y / part.Scale.Y); 2940 float y = (scale.Y / part.Scale.Y);
2785 float z = (scale.Z / part.Scale.Z); 2941 float z = (scale.Z / part.Scale.Z);
2786 2942
2787 lock (m_parts) 2943 lockPartsForRead(true);
2944 if (x > 1.0f || y > 1.0f || z > 1.0f)
2788 { 2945 {
2789 if (x > 1.0f || y > 1.0f || z > 1.0f) 2946 foreach (SceneObjectPart obPart in m_parts.Values)
2790 { 2947 {
2791 foreach (SceneObjectPart obPart in m_parts.Values) 2948 if (obPart.UUID != m_rootPart.UUID)
2792 { 2949 {
2793 if (obPart.UUID != m_rootPart.UUID) 2950 Vector3 oldSize = new Vector3(obPart.Scale);
2794 {
2795 Vector3 oldSize = new Vector3(obPart.Scale);
2796 2951
2797 float f = 1.0f; 2952 float f = 1.0f;
2798 float a = 1.0f; 2953 float a = 1.0f;
2799 2954
2800 if (part.PhysActor != null && part.PhysActor.IsPhysical) 2955 if (part.PhysActor != null && part.PhysActor.IsPhysical)
2956 {
2957 if (oldSize.X*x > m_scene.m_maxPhys)
2801 { 2958 {
2802 if (oldSize.X*x > m_scene.m_maxPhys) 2959 f = m_scene.m_maxPhys / oldSize.X;
2803 { 2960 a = f / x;
2804 f = m_scene.m_maxPhys / oldSize.X; 2961 x *= a;
2805 a = f / x; 2962 y *= a;
2806 x *= a; 2963 z *= a;
2807 y *= a;
2808 z *= a;
2809 }
2810 if (oldSize.Y*y > m_scene.m_maxPhys)
2811 {
2812 f = m_scene.m_maxPhys / oldSize.Y;
2813 a = f / y;
2814 x *= a;
2815 y *= a;
2816 z *= a;
2817 }
2818 if (oldSize.Z*z > m_scene.m_maxPhys)
2819 {
2820 f = m_scene.m_maxPhys / oldSize.Z;
2821 a = f / z;
2822 x *= a;
2823 y *= a;
2824 z *= a;
2825 }
2826 } 2964 }
2827 else 2965 if (oldSize.Y*y > m_scene.m_maxPhys)
2828 { 2966 {
2829 if (oldSize.X*x > m_scene.m_maxNonphys) 2967 f = m_scene.m_maxPhys / oldSize.Y;
2830 { 2968 a = f / y;
2831 f = m_scene.m_maxNonphys / oldSize.X; 2969 x *= a;
2832 a = f / x; 2970 y *= a;
2833 x *= a; 2971 z *= a;
2834 y *= a; 2972 }
2835 z *= a; 2973 if (oldSize.Z*z > m_scene.m_maxPhys)
2836 } 2974 {
2837 if (oldSize.Y*y > m_scene.m_maxNonphys) 2975 f = m_scene.m_maxPhys / oldSize.Z;
2838 { 2976 a = f / z;
2839 f = m_scene.m_maxNonphys / oldSize.Y; 2977 x *= a;
2840 a = f / y; 2978 y *= a;
2841 x *= a; 2979 z *= a;
2842 y *= a; 2980 }
2843 z *= a; 2981 }
2844 } 2982 else
2845 if (oldSize.Z*z > m_scene.m_maxNonphys) 2983 {
2846 { 2984 if (oldSize.X*x > m_scene.m_maxNonphys)
2847 f = m_scene.m_maxNonphys / oldSize.Z; 2985 {
2848 a = f / z; 2986 f = m_scene.m_maxNonphys / oldSize.X;
2849 x *= a; 2987 a = f / x;
2850 y *= a; 2988 x *= a;
2851 z *= a; 2989 y *= a;
2852 } 2990 z *= a;
2991 }
2992 if (oldSize.Y*y > m_scene.m_maxNonphys)
2993 {
2994 f = m_scene.m_maxNonphys / oldSize.Y;
2995 a = f / y;
2996 x *= a;
2997 y *= a;
2998 z *= a;
2999 }
3000 if (oldSize.Z*z > m_scene.m_maxNonphys)
3001 {
3002 f = m_scene.m_maxNonphys / oldSize.Z;
3003 a = f / z;
3004 x *= a;
3005 y *= a;
3006 z *= a;
2853 } 3007 }
2854 } 3008 }
2855 } 3009 }
2856 } 3010 }
2857 } 3011 }
3012 lockPartsForRead(false);
2858 3013
2859 Vector3 prevScale = part.Scale; 3014 Vector3 prevScale = part.Scale;
2860 prevScale.X *= x; 3015 prevScale.X *= x;
@@ -2862,7 +3017,7 @@ namespace OpenSim.Region.Framework.Scenes
2862 prevScale.Z *= z; 3017 prevScale.Z *= z;
2863 part.Resize(prevScale); 3018 part.Resize(prevScale);
2864 3019
2865 lock (m_parts) 3020 lockPartsForRead(true);
2866 { 3021 {
2867 foreach (SceneObjectPart obPart in m_parts.Values) 3022 foreach (SceneObjectPart obPart in m_parts.Values)
2868 { 3023 {
@@ -2881,6 +3036,7 @@ namespace OpenSim.Region.Framework.Scenes
2881 } 3036 }
2882 } 3037 }
2883 } 3038 }
3039 lockPartsForRead(false);
2884 3040
2885 if (part.PhysActor != null) 3041 if (part.PhysActor != null)
2886 { 3042 {
@@ -2961,7 +3117,7 @@ namespace OpenSim.Region.Framework.Scenes
2961 axDiff *= Quaternion.Inverse(partRotation); 3117 axDiff *= Quaternion.Inverse(partRotation);
2962 diff = axDiff; 3118 diff = axDiff;
2963 3119
2964 lock (m_parts) 3120 lockPartsForRead(true);
2965 { 3121 {
2966 foreach (SceneObjectPart obPart in m_parts.Values) 3122 foreach (SceneObjectPart obPart in m_parts.Values)
2967 { 3123 {
@@ -2971,6 +3127,7 @@ namespace OpenSim.Region.Framework.Scenes
2971 } 3127 }
2972 } 3128 }
2973 } 3129 }
3130 lockPartsForRead(false);
2974 3131
2975 AbsolutePosition = newPos; 3132 AbsolutePosition = newPos;
2976 3133
@@ -3088,7 +3245,7 @@ namespace OpenSim.Region.Framework.Scenes
3088 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); 3245 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
3089 } 3246 }
3090 3247
3091 lock (m_parts) 3248 lockPartsForRead(true);
3092 { 3249 {
3093 foreach (SceneObjectPart prim in m_parts.Values) 3250 foreach (SceneObjectPart prim in m_parts.Values)
3094 { 3251 {
@@ -3106,6 +3263,7 @@ namespace OpenSim.Region.Framework.Scenes
3106 } 3263 }
3107 } 3264 }
3108 } 3265 }
3266 lockPartsForRead(false);
3109 3267
3110 m_rootPart.ScheduleTerseUpdate(); 3268 m_rootPart.ScheduleTerseUpdate();
3111 } 3269 }
@@ -3204,7 +3362,7 @@ namespace OpenSim.Region.Framework.Scenes
3204 if (atTargets.Count > 0) 3362 if (atTargets.Count > 0)
3205 { 3363 {
3206 uint[] localids = new uint[0]; 3364 uint[] localids = new uint[0];
3207 lock (m_parts) 3365 lockPartsForRead(true);
3208 { 3366 {
3209 localids = new uint[m_parts.Count]; 3367 localids = new uint[m_parts.Count];
3210 int cntr = 0; 3368 int cntr = 0;
@@ -3214,6 +3372,7 @@ namespace OpenSim.Region.Framework.Scenes
3214 cntr++; 3372 cntr++;
3215 } 3373 }
3216 } 3374 }
3375 lockPartsForRead(false);
3217 3376
3218 for (int ctr = 0; ctr < localids.Length; ctr++) 3377 for (int ctr = 0; ctr < localids.Length; ctr++)
3219 { 3378 {
@@ -3232,7 +3391,7 @@ namespace OpenSim.Region.Framework.Scenes
3232 { 3391 {
3233 //trigger not_at_target 3392 //trigger not_at_target
3234 uint[] localids = new uint[0]; 3393 uint[] localids = new uint[0];
3235 lock (m_parts) 3394 lockPartsForRead(true);
3236 { 3395 {
3237 localids = new uint[m_parts.Count]; 3396 localids = new uint[m_parts.Count];
3238 int cntr = 0; 3397 int cntr = 0;
@@ -3242,7 +3401,8 @@ namespace OpenSim.Region.Framework.Scenes
3242 cntr++; 3401 cntr++;
3243 } 3402 }
3244 } 3403 }
3245 3404 lockPartsForRead(false);
3405
3246 for (int ctr = 0; ctr < localids.Length; ctr++) 3406 for (int ctr = 0; ctr < localids.Length; ctr++)
3247 { 3407 {
3248 m_scene.EventManager.TriggerNotAtTargetEvent(localids[ctr]); 3408 m_scene.EventManager.TriggerNotAtTargetEvent(localids[ctr]);
@@ -3255,19 +3415,20 @@ namespace OpenSim.Region.Framework.Scenes
3255 public float GetMass() 3415 public float GetMass()
3256 { 3416 {
3257 float retmass = 0f; 3417 float retmass = 0f;
3258 lock (m_parts) 3418 lockPartsForRead(true);
3259 { 3419 {
3260 foreach (SceneObjectPart part in m_parts.Values) 3420 foreach (SceneObjectPart part in m_parts.Values)
3261 { 3421 {
3262 retmass += part.GetMass(); 3422 retmass += part.GetMass();
3263 } 3423 }
3264 } 3424 }
3425 lockPartsForRead(false);
3265 return retmass; 3426 return retmass;
3266 } 3427 }
3267 3428
3268 public void CheckSculptAndLoad() 3429 public void CheckSculptAndLoad()
3269 { 3430 {
3270 lock (m_parts) 3431 lockPartsForRead(true);
3271 { 3432 {
3272 if (!IsDeleted) 3433 if (!IsDeleted)
3273 { 3434 {
@@ -3292,6 +3453,7 @@ namespace OpenSim.Region.Framework.Scenes
3292 } 3453 }
3293 } 3454 }
3294 } 3455 }
3456 lockPartsForRead(false);
3295 } 3457 }
3296 3458
3297 protected void AssetReceived(string id, Object sender, AssetBase asset) 3459 protected void AssetReceived(string id, Object sender, AssetBase asset)
@@ -3312,7 +3474,7 @@ namespace OpenSim.Region.Framework.Scenes
3312 /// <param name="client"></param> 3474 /// <param name="client"></param>
3313 public void SetGroup(UUID GroupID, IClientAPI client) 3475 public void SetGroup(UUID GroupID, IClientAPI client)
3314 { 3476 {
3315 lock (m_parts) 3477 lockPartsForRead(true);
3316 { 3478 {
3317 foreach (SceneObjectPart part in m_parts.Values) 3479 foreach (SceneObjectPart part in m_parts.Values)
3318 { 3480 {
@@ -3322,7 +3484,7 @@ namespace OpenSim.Region.Framework.Scenes
3322 3484
3323 HasGroupChanged = true; 3485 HasGroupChanged = true;
3324 } 3486 }
3325 3487 lockPartsForRead(false);
3326 ScheduleGroupForFullUpdate(); 3488 ScheduleGroupForFullUpdate();
3327 } 3489 }
3328 3490
@@ -3341,11 +3503,12 @@ namespace OpenSim.Region.Framework.Scenes
3341 3503
3342 public void SetAttachmentPoint(byte point) 3504 public void SetAttachmentPoint(byte point)
3343 { 3505 {
3344 lock (m_parts) 3506 lockPartsForRead(true);
3345 { 3507 {
3346 foreach (SceneObjectPart part in m_parts.Values) 3508 foreach (SceneObjectPart part in m_parts.Values)
3347 part.SetAttachmentPoint(point); 3509 part.SetAttachmentPoint(point);
3348 } 3510 }
3511 lockPartsForRead(false);
3349 } 3512 }
3350 3513
3351 #region ISceneObject 3514 #region ISceneObject
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index eca8588..b57d912 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -269,8 +269,9 @@ namespace OpenSim.Region.Framework.Scenes
269 { 269 {
270 m_log.ErrorFormat( 270 m_log.ErrorFormat(
271 "[PRIM INVENTORY]: " + 271 "[PRIM INVENTORY]: " +
272 "Couldn't start script {0}, {1} since asset ID {2} could not be found", 272 "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found",
273 item.Name, item.ItemID, item.AssetID); 273 item.Name, item.ItemID, m_part.AbsolutePosition,
274 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID);
274 } 275 }
275 else 276 else
276 { 277 {
@@ -317,9 +318,20 @@ namespace OpenSim.Region.Framework.Scenes
317 m_items.LockItemsForRead(true); 318 m_items.LockItemsForRead(true);
318 if (m_items.ContainsKey(itemId)) 319 if (m_items.ContainsKey(itemId))
319 { 320 {
320 TaskInventoryItem item = m_items[itemId]; 321 if (m_items.ContainsKey(itemId))
321 m_items.LockItemsForRead(false); 322 {
322 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); 323 m_items.LockItemsForRead(false);
324 CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource);
325 }
326 else
327 {
328 m_items.LockItemsForRead(false);
329 m_log.ErrorFormat(
330 "[PRIM INVENTORY]: " +
331 "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
332 itemId, m_part.Name, m_part.UUID,
333 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
334 }
323 } 335 }
324 else 336 else
325 { 337 {
@@ -347,8 +359,9 @@ namespace OpenSim.Region.Framework.Scenes
347 { 359 {
348 m_log.ErrorFormat( 360 m_log.ErrorFormat(
349 "[PRIM INVENTORY]: " + 361 "[PRIM INVENTORY]: " +
350 "Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2}", 362 "Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
351 itemId, m_part.Name, m_part.UUID); 363 itemId, m_part.Name, m_part.UUID,
364 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
352 } 365 }
353 } 366 }
354 367
@@ -542,8 +555,9 @@ namespace OpenSim.Region.Framework.Scenes
542 { 555 {
543 m_log.ErrorFormat( 556 m_log.ErrorFormat(
544 "[PRIM INVENTORY]: " + 557 "[PRIM INVENTORY]: " +
545 "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory", 558 "Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory",
546 item.ItemID, m_part.Name, m_part.UUID); 559 item.ItemID, m_part.Name, m_part.UUID,
560 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
547 } 561 }
548 m_items.LockItemsForWrite(false); 562 m_items.LockItemsForWrite(false);
549 563
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 5d0218f..fbc4ed5 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -791,11 +791,11 @@ namespace OpenSim.Region.Framework.Scenes
791 /// </summary> 791 /// </summary>
792 public void SendPrimUpdates() 792 public void SendPrimUpdates()
793 { 793 {
794 m_perfMonMS = Environment.TickCount; 794 m_perfMonMS = Util.EnvironmentTickCount();
795 795
796 m_sceneViewer.SendPrimUpdates(); 796 m_sceneViewer.SendPrimUpdates();
797 797
798 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 798 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
799 } 799 }
800 800
801 #region Status Methods 801 #region Status Methods
@@ -1143,7 +1143,7 @@ namespace OpenSim.Region.Framework.Scenes
1143 /// <param name="collisionPoint"></param> 1143 /// <param name="collisionPoint"></param>
1144 /// <param name="localid"></param> 1144 /// <param name="localid"></param>
1145 /// <param name="distance"></param> 1145 /// <param name="distance"></param>
1146 public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) 1146 public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal)
1147 { 1147 {
1148 const float POSITION_TOLERANCE = 0.02f; 1148 const float POSITION_TOLERANCE = 0.02f;
1149 const float VELOCITY_TOLERANCE = 0.02f; 1149 const float VELOCITY_TOLERANCE = 0.02f;
@@ -1185,7 +1185,8 @@ namespace OpenSim.Region.Framework.Scenes
1185 // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); 1185 // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent");
1186 // return; 1186 // return;
1187 //} 1187 //}
1188 m_perfMonMS = Environment.TickCount; 1188
1189 m_perfMonMS = Util.EnvironmentTickCount();
1189 1190
1190 ++m_movementUpdateCount; 1191 ++m_movementUpdateCount;
1191 if (m_movementUpdateCount < 1) 1192 if (m_movementUpdateCount < 1)
@@ -1515,7 +1516,7 @@ namespace OpenSim.Region.Framework.Scenes
1515 1516
1516 m_scene.EventManager.TriggerOnClientMovement(this); 1517 m_scene.EventManager.TriggerOnClientMovement(this);
1517 1518
1518 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 1519 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
1519 } 1520 }
1520 1521
1521 public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client) 1522 public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client)
@@ -1831,7 +1832,7 @@ namespace OpenSim.Region.Framework.Scenes
1831 StandUp(); 1832 StandUp();
1832 } 1833 }
1833 m_nextSitAnimation = "SIT"; 1834 m_nextSitAnimation = "SIT";
1834 1835
1835 //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); 1836 //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID);
1836 SceneObjectPart part = FindNextAvailableSitTarget(targetID); 1837 SceneObjectPart part = FindNextAvailableSitTarget(targetID);
1837 1838
@@ -1843,12 +1844,23 @@ namespace OpenSim.Region.Framework.Scenes
1843 } 1844 }
1844 m_requestedSitTargetID = part.LocalId; 1845 m_requestedSitTargetID = part.LocalId;
1845 //m_requestedSitOffset = offset; 1846 //m_requestedSitOffset = offset;
1847 //offset.X += part.Scale.X;// *offset.X;
1848 //offset.Y += part.Scale.Y;// * offset.Y;
1849 //offset.Z += part.Scale.Z;// * offset.Z;
1850 //m_requestedSitOffset = offset;
1851 m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset);
1846 } 1852 }
1847 else 1853 else
1848 { 1854 {
1849 1855
1850 m_log.Warn("Sit requested on unknown object: " + targetID.ToString()); 1856 m_log.Warn("Sit requested on unknown object: " + targetID.ToString());
1851 } 1857 }
1858
1859 if (m_scene.PhysicsScene.SupportsRayCast())
1860 {
1861 //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback());
1862 }
1863
1852 SendSitResponse(remoteClient, targetID, offset); 1864 SendSitResponse(remoteClient, targetID, offset);
1853 } 1865 }
1854 1866
@@ -1966,7 +1978,7 @@ namespace OpenSim.Region.Framework.Scenes
1966 SendFullUpdateToAllClients(); 1978 SendFullUpdateToAllClients();
1967 } 1979 }
1968 1980
1969 public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) // KF: Nov 2009 1981 public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal)
1970 { 1982 {
1971 // KF: 091202 There appears to be a bug in Prim Edit Size - the process sometimes make a prim that RayTrace no longer 1983 // KF: 091202 There appears to be a bug in Prim Edit Size - the process sometimes make a prim that RayTrace no longer
1972 // sees. Take/re-rez, or sim restart corrects the condition. Result of bug is incorrect sit height. 1984 // sees. Take/re-rez, or sim restart corrects the condition. Result of bug is incorrect sit height.
@@ -2046,7 +2058,7 @@ namespace OpenSim.Region.Framework.Scenes
2046 return; 2058 return;
2047 } 2059 }
2048 2060
2049 m_perfMonMS = Environment.TickCount; 2061 m_perfMonMS = Util.EnvironmentTickCount();
2050 2062
2051 Rotation = rotation; 2063 Rotation = rotation;
2052 Vector3 direc = vec * rotation; 2064 Vector3 direc = vec * rotation;
@@ -2088,7 +2100,7 @@ namespace OpenSim.Region.Framework.Scenes
2088 // TODO: Add the force instead of only setting it to support multiple forces per frame? 2100 // TODO: Add the force instead of only setting it to support multiple forces per frame?
2089 m_forceToApply = direc; 2101 m_forceToApply = direc;
2090 m_isNudging = Nudging; 2102 m_isNudging = Nudging;
2091 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2103 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2092 } 2104 }
2093 2105
2094 #endregion 2106 #endregion
@@ -2157,7 +2169,7 @@ namespace OpenSim.Region.Framework.Scenes
2157 // server. 2169 // server.
2158 if (remoteClient.IsActive) 2170 if (remoteClient.IsActive)
2159 { 2171 {
2160 m_perfMonMS = Environment.TickCount; 2172 m_perfMonMS = Util.EnvironmentTickCount();
2161 2173
2162 PhysicsActor actor = m_physicsActor; 2174 PhysicsActor actor = m_physicsActor;
2163 Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero; 2175 Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero;
@@ -2170,7 +2182,7 @@ namespace OpenSim.Region.Framework.Scenes
2170 remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, 2182 remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
2171 pos, velocity, Vector3.Zero, m_bodyRot, CollisionPlane, m_uuid, null, GetUpdatePriority(remoteClient))); 2183 pos, velocity, Vector3.Zero, m_bodyRot, CollisionPlane, m_uuid, null, GetUpdatePriority(remoteClient)));
2172 2184
2173 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2185 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2174 m_scene.StatsReporter.AddAgentUpdates(1); 2186 m_scene.StatsReporter.AddAgentUpdates(1);
2175 } 2187 }
2176 } 2188 }
@@ -2180,11 +2192,11 @@ namespace OpenSim.Region.Framework.Scenes
2180 /// </summary> 2192 /// </summary>
2181 public void SendTerseUpdateToAllClients() 2193 public void SendTerseUpdateToAllClients()
2182 { 2194 {
2183 m_perfMonMS = Environment.TickCount; 2195 m_perfMonMS = Util.EnvironmentTickCount();
2184 2196
2185 m_scene.ForEachClient(SendTerseUpdateToClient); 2197 m_scene.ForEachClient(SendTerseUpdateToClient);
2186 2198
2187 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2199 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2188 } 2200 }
2189 2201
2190 public void SendCoarseLocations() 2202 public void SendCoarseLocations()
@@ -2204,7 +2216,7 @@ namespace OpenSim.Region.Framework.Scenes
2204 2216
2205 public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p) 2217 public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p)
2206 { 2218 {
2207 m_perfMonMS = Environment.TickCount; 2219 m_perfMonMS = Util.EnvironmentTickCount();
2208 2220
2209 List<Vector3> CoarseLocations = new List<Vector3>(); 2221 List<Vector3> CoarseLocations = new List<Vector3>();
2210 List<UUID> AvatarUUIDs = new List<UUID>(); 2222 List<UUID> AvatarUUIDs = new List<UUID>();
@@ -2240,7 +2252,7 @@ namespace OpenSim.Region.Framework.Scenes
2240 2252
2241 m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); 2253 m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations);
2242 2254
2243 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2255 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2244 } 2256 }
2245 2257
2246 public void CoarseLocationChange() 2258 public void CoarseLocationChange()
@@ -2277,7 +2289,7 @@ namespace OpenSim.Region.Framework.Scenes
2277 /// </summary> 2289 /// </summary>
2278 public void SendInitialFullUpdateToAllClients() 2290 public void SendInitialFullUpdateToAllClients()
2279 { 2291 {
2280 m_perfMonMS = Environment.TickCount; 2292 m_perfMonMS = Util.EnvironmentTickCount();
2281 2293
2282 ScenePresence[] avatars = m_scene.GetScenePresences(); 2294 ScenePresence[] avatars = m_scene.GetScenePresences();
2283 2295
@@ -2303,14 +2315,14 @@ namespace OpenSim.Region.Framework.Scenes
2303 } 2315 }
2304 2316
2305 m_scene.StatsReporter.AddAgentUpdates(avatars.Length); 2317 m_scene.StatsReporter.AddAgentUpdates(avatars.Length);
2306 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2318 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2307 2319
2308 //Animator.SendAnimPack(); 2320 //Animator.SendAnimPack();
2309 } 2321 }
2310 2322
2311 public void SendFullUpdateToAllClients() 2323 public void SendFullUpdateToAllClients()
2312 { 2324 {
2313 m_perfMonMS = Environment.TickCount; 2325 m_perfMonMS = Util.EnvironmentTickCount();
2314 2326
2315 // only send update from root agents to other clients; children are only "listening posts" 2327 // only send update from root agents to other clients; children are only "listening posts"
2316 List<ScenePresence> avatars = m_scene.GetAvatars(); 2328 List<ScenePresence> avatars = m_scene.GetAvatars();
@@ -2320,7 +2332,7 @@ namespace OpenSim.Region.Framework.Scenes
2320 2332
2321 } 2333 }
2322 m_scene.StatsReporter.AddAgentUpdates(avatars.Count); 2334 m_scene.StatsReporter.AddAgentUpdates(avatars.Count);
2323 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2335 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2324 2336
2325 Animator.SendAnimPack(); 2337 Animator.SendAnimPack();
2326 } 2338 }
@@ -2362,7 +2374,7 @@ namespace OpenSim.Region.Framework.Scenes
2362 /// </summary> 2374 /// </summary>
2363 public void SendAppearanceToAllOtherAgents() 2375 public void SendAppearanceToAllOtherAgents()
2364 { 2376 {
2365 m_perfMonMS = Environment.TickCount; 2377 m_perfMonMS = Util.EnvironmentTickCount();
2366 2378
2367 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 2379 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
2368 { 2380 {
@@ -2371,8 +2383,8 @@ namespace OpenSim.Region.Framework.Scenes
2371 SendAppearanceToOtherAgent(scenePresence); 2383 SendAppearanceToOtherAgent(scenePresence);
2372 } 2384 }
2373 }); 2385 });
2374 2386
2375 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2387 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2376 } 2388 }
2377 2389
2378 /// <summary> 2390 /// <summary>
@@ -3073,7 +3085,9 @@ namespace OpenSim.Region.Framework.Scenes
3073 3085
3074 // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents( 3086 // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents(
3075 // as of this comment the interval is set in AddToPhysicalScene 3087 // as of this comment the interval is set in AddToPhysicalScene
3076 3088 if (Animator!=null)
3089 Animator.UpdateMovementAnimations();
3090
3077 CollisionEventUpdate collisionData = (CollisionEventUpdate)e; 3091 CollisionEventUpdate collisionData = (CollisionEventUpdate)e;
3078 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; 3092 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList;
3079 3093
@@ -3085,7 +3099,7 @@ namespace OpenSim.Region.Framework.Scenes
3085 m_lastColCount = coldata.Count; 3099 m_lastColCount = coldata.Count;
3086 } 3100 }
3087 3101
3088 if (coldata.Count != 0) 3102 if (coldata.Count != 0 && Animator != null)
3089 { 3103 {
3090 switch (Animator.CurrentMovementAnimation) 3104 switch (Animator.CurrentMovementAnimation)
3091 { 3105 {
@@ -3189,11 +3203,13 @@ namespace OpenSim.Region.Framework.Scenes
3189 3203
3190 // I don't get it but mono crashes when you try to dispose of this timer, 3204 // I don't get it but mono crashes when you try to dispose of this timer,
3191 // unsetting the elapsed callback should be enough to allow for cleanup however. 3205 // unsetting the elapsed callback should be enough to allow for cleanup however.
3192 //m_reprioritizationTimer.Dispose(); 3206 // m_reprioritizationTimer.Dispose();
3193 3207
3194 m_sceneViewer.Close(); 3208 m_sceneViewer.Close();
3195 3209
3196 RemoveFromPhysicalScene(); 3210 RemoveFromPhysicalScene();
3211 m_animator.Close();
3212 m_animator = null;
3197 } 3213 }
3198 3214
3199 public ScenePresence() 3215 public ScenePresence()
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index 56c6ed6..e368c2a 100644
--- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
@@ -75,7 +75,7 @@ namespace OpenSim.Region.Framework.Scenes
75 UnAckedBytes = 24, 75 UnAckedBytes = 24,
76 } 76 }
77 77
78 // Sending a stats update every 3 seconds 78 // Sending a stats update every 3 seconds-
79 private int statsUpdatesEveryMS = 3000; 79 private int statsUpdatesEveryMS = 3000;
80 private float statsUpdateFactor = 0; 80 private float statsUpdateFactor = 0;
81 private float m_timeDilation = 0; 81 private float m_timeDilation = 0;
@@ -193,6 +193,9 @@ namespace OpenSim.Region.Framework.Scenes
193 // / 10 divides the value by the number of times the sim heartbeat runs (10fps) 193 // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
194 // Then we divide the whole amount by the amount of seconds pass in between stats updates. 194 // Then we divide the whole amount by the amount of seconds pass in between stats updates.
195 195
196 // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change
197 // values to X-per-second values.
198
196 for (int i = 0; i<21;i++) 199 for (int i = 0; i<21;i++)
197 { 200 {
198 sb[i] = new SimStatsPacket.StatBlock(); 201 sb[i] = new SimStatsPacket.StatBlock();
@@ -238,7 +241,7 @@ namespace OpenSim.Region.Framework.Scenes
238 sb[12].StatValue = m_otherMS / statsUpdateFactor; 241 sb[12].StatValue = m_otherMS / statsUpdateFactor;
239 242
240 sb[13].StatID = (uint)Stats.InPacketsPerSecond; 243 sb[13].StatID = (uint)Stats.InPacketsPerSecond;
241 sb[13].StatValue = (m_inPacketsPerSecond); 244 sb[13].StatValue = (m_inPacketsPerSecond / statsUpdateFactor);
242 245
243 sb[14].StatID = (uint)Stats.OutPacketsPerSecond; 246 sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
244 sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor); 247 sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor);
@@ -285,8 +288,8 @@ namespace OpenSim.Region.Framework.Scenes
285 m_fps = 0; 288 m_fps = 0;
286 m_pfps = 0; 289 m_pfps = 0;
287 m_agentUpdates = 0; 290 m_agentUpdates = 0;
288 m_inPacketsPerSecond = 0; 291 //m_inPacketsPerSecond = 0;
289 m_outPacketsPerSecond = 0; 292 //m_outPacketsPerSecond = 0;
290 m_unAckedBytes = 0; 293 m_unAckedBytes = 0;
291 m_scriptLinesPerSecond = 0; 294 m_scriptLinesPerSecond = 0;
292 295
@@ -373,12 +376,12 @@ namespace OpenSim.Region.Framework.Scenes
373 376
374 public void AddInPackets(int numPackets) 377 public void AddInPackets(int numPackets)
375 { 378 {
376 m_inPacketsPerSecond += numPackets; 379 m_inPacketsPerSecond = numPackets;
377 } 380 }
378 381
379 public void AddOutPackets(int numPackets) 382 public void AddOutPackets(int numPackets)
380 { 383 {
381 m_outPacketsPerSecond += numPackets; 384 m_outPacketsPerSecond = numPackets;
382 } 385 }
383 386
384 public void AddunAckedBytes(int numBytes) 387 public void AddunAckedBytes(int numBytes)
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
index 8a27b7b..5abbb82 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
@@ -101,7 +101,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests
101 { 101 {
102 throw new NotImplementedException(); 102 throw new NotImplementedException();
103 } 103 }
104 104 public RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID)
105 {
106 //This connector doesn't support the windlight module yet
107 //Return default LL windlight settings
108 return new RegionMeta7WindlightData();
109 }
110 public void StoreRegionWindlightSettings(RegionMeta7WindlightData wl)
111 {
112 //This connector doesn't support the windlight module yet
113 }
105 public RegionSettings LoadRegionSettings(UUID regionUUID) 114 public RegionSettings LoadRegionSettings(UUID regionUUID)
106 { 115 {
107 return null; 116 return null;
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 6c3e7eb..bdf1574 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -936,7 +936,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
936 // TODO 936 // TODO
937 } 937 }
938 938
939 public void SendGenericMessage(string method, List<string> message) 939 public void SendGenericMessage(string method, List<byte[]> message)
940 { 940 {
941 941
942 } 942 }
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs
index 70e80bc..e664b44 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs
@@ -69,13 +69,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
69 m_config = config.Configs["IRC"]; 69 m_config = config.Configs["IRC"];
70 if (m_config == null) 70 if (m_config == null)
71 { 71 {
72 m_log.InfoFormat("[IRC-Bridge] module not configured"); 72// m_log.InfoFormat("[IRC-Bridge] module not configured");
73 return; 73 return;
74 } 74 }
75 75
76 if (!m_config.GetBoolean("enabled", false)) 76 if (!m_config.GetBoolean("enabled", false))
77 { 77 {
78 m_log.InfoFormat("[IRC-Bridge] module disabled in configuration"); 78// m_log.InfoFormat("[IRC-Bridge] module disabled in configuration");
79 return; 79 return;
80 } 80 }
81 81
@@ -85,6 +85,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
85 } 85 }
86 86
87 m_pluginEnabled = true; 87 m_pluginEnabled = true;
88 m_log.InfoFormat("[IRC-Bridge]: Module enabled");
88 } 89 }
89 90
90 public void AddRegion(Scene scene) 91 public void AddRegion(Scene scene)
@@ -143,7 +144,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
143 144
144 public static XmlRpcResponse XmlRpcAdminMethod(XmlRpcRequest request, IPEndPoint remoteClient) 145 public static XmlRpcResponse XmlRpcAdminMethod(XmlRpcRequest request, IPEndPoint remoteClient)
145 { 146 {
146 m_log.Info("[IRC-Bridge]: XML RPC Admin Entry"); 147 m_log.Debug("[IRC-Bridge]: XML RPC Admin Entry");
147 148
148 XmlRpcResponse response = new XmlRpcResponse(); 149 XmlRpcResponse response = new XmlRpcResponse();
149 Hashtable responseData = new Hashtable(); 150 Hashtable responseData = new Hashtable();
@@ -188,7 +189,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
188 } 189 }
189 catch (Exception e) 190 catch (Exception e)
190 { 191 {
191 m_log.InfoFormat("[IRC-Bridge] XML RPC Admin request failed : {0}", e.Message); 192 m_log.ErrorFormat("[IRC-Bridge] XML RPC Admin request failed : {0}", e.Message);
192 193
193 responseData["success"] = "false"; 194 responseData["success"] = "false";
194 responseData["error"] = e.Message; 195 responseData["error"] = e.Message;
diff --git a/OpenSim/Region/OptionalModules/Python/PythonAPI/Console.cs b/OpenSim/Region/OptionalModules/Python/PythonAPI/Console.cs
deleted file mode 100644
index a823ff9..0000000
--- a/OpenSim/Region/OptionalModules/Python/PythonAPI/Console.cs
+++ /dev/null
@@ -1,48 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using log4net;
31
32namespace OpenSim.Region.Modules.Python.PythonAPI
33{
34 class Console
35 {
36 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
37
38 public void WriteLine(string txt)
39 {
40 m_log.Info(txt);
41 }
42
43 public void WriteLine(string txt, params Object[] e)
44 {
45 m_log.Info(String.Format(txt, e));
46 }
47 }
48}
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index cf36d08..975033a 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -522,7 +522,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
522 522
523 } 523 }
524 524
525 public void SendGenericMessage(string method, List<string> message) 525 public void SendGenericMessage(string method, List<byte[]> message)
526 { 526 {
527 527
528 } 528 }
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
index 6d515e9..217d307 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
@@ -36,7 +36,7 @@ namespace OpenSim.Region.Physics.Manager
36{ 36{
37 public delegate void physicsCrash(); 37 public delegate void physicsCrash();
38 38
39 public delegate void RaycastCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance); 39 public delegate void RaycastCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal);
40 40
41 public abstract class PhysicsScene 41 public abstract class PhysicsScene
42 { 42 {
@@ -204,7 +204,7 @@ namespace OpenSim.Region.Physics.Manager
204 public virtual void RaycastWorld(Vector3 position, Vector3 direction, float length, RaycastCallback retMethod) 204 public virtual void RaycastWorld(Vector3 position, Vector3 direction, float length, RaycastCallback retMethod)
205 { 205 {
206 if (retMethod != null) 206 if (retMethod != null)
207 retMethod(false, Vector3.Zero, 0, 999999999999f); 207 retMethod(false, Vector3.Zero, 0, 999999999999f, Vector3.Zero);
208 } 208 }
209 209
210 private class NullPhysicsScene : PhysicsScene 210 private class NullPhysicsScene : PhysicsScene
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 905d3ba..b99baa2 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -1243,7 +1243,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1243 { 1243 {
1244 if (m_eventsubscription > m_requestedUpdateFrequency) 1244 if (m_eventsubscription > m_requestedUpdateFrequency)
1245 { 1245 {
1246 base.SendCollisionUpdate(CollisionEventsThisFrame); 1246 if (CollisionEventsThisFrame != null)
1247 {
1248 base.SendCollisionUpdate(CollisionEventsThisFrame);
1249 }
1247 CollisionEventsThisFrame = new CollisionEventUpdate(); 1250 CollisionEventsThisFrame = new CollisionEventUpdate();
1248 m_eventsubscription = 0; 1251 m_eventsubscription = 0;
1249 } 1252 }
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index b0e9a91..c27c420 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -743,6 +743,8 @@ namespace OpenSim.Region.Physics.OdePlugin
743 break; 743 break;
744 } 744 }
745 } 745 }
746 if (returnMass > _parent_scene.maximumMassObject)
747 returnMass = _parent_scene.maximumMassObject;
746 return returnMass; 748 return returnMass;
747 }// end CalculateMass 749 }// end CalculateMass
748 750
@@ -753,6 +755,7 @@ namespace OpenSim.Region.Physics.OdePlugin
753 if (Body != (IntPtr) 0) 755 if (Body != (IntPtr) 0)
754 { 756 {
755 float newmass = CalculateMass(); 757 float newmass = CalculateMass();
758
756 //m_log.Info("[PHYSICS]: New Mass: " + newmass.ToString()); 759 //m_log.Info("[PHYSICS]: New Mass: " + newmass.ToString());
757 760
758 d.MassSetBoxTotal(out pMass, newmass, _size.X, _size.Y, _size.Z); 761 d.MassSetBoxTotal(out pMass, newmass, _size.X, _size.Y, _size.Z);
@@ -2158,7 +2161,10 @@ Console.WriteLine(" JointCreateFixed");
2158 // Re creates body on size. 2161 // Re creates body on size.
2159 // EnableBody also does setMass() 2162 // EnableBody also does setMass()
2160 enableBody(); 2163 enableBody();
2161 d.BodyEnable(Body); 2164 if (Body != IntPtr.Zero)
2165 {
2166 d.BodyEnable(Body);
2167 }
2162 } 2168 }
2163 _parent_scene.geom_name_map[prim_geom] = oldname; 2169 _parent_scene.geom_name_map[prim_geom] = oldname;
2164 2170
diff --git a/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs
index c8ae229..732e835 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs
@@ -145,6 +145,7 @@ namespace OpenSim.Region.Physics.OdePlugin
145 uint hitConsumerID = 0; 145 uint hitConsumerID = 0;
146 float distance = 999999999999f; 146 float distance = 999999999999f;
147 Vector3 closestcontact = new Vector3(99999f, 99999f, 99999f); 147 Vector3 closestcontact = new Vector3(99999f, 99999f, 99999f);
148 Vector3 snormal = Vector3.Zero;
148 149
149 // Find closest contact and object. 150 // Find closest contact and object.
150 lock (m_contactResults) 151 lock (m_contactResults)
@@ -157,6 +158,7 @@ namespace OpenSim.Region.Physics.OdePlugin
157 hitConsumerID = cResult.ConsumerID; 158 hitConsumerID = cResult.ConsumerID;
158 distance = cResult.Depth; 159 distance = cResult.Depth;
159 hitYN = true; 160 hitYN = true;
161 snormal = cResult.Normal;
160 } 162 }
161 } 163 }
162 164
@@ -165,7 +167,7 @@ namespace OpenSim.Region.Physics.OdePlugin
165 167
166 // Return results 168 // Return results
167 if (req.callbackMethod != null) 169 if (req.callbackMethod != null)
168 req.callbackMethod(hitYN, closestcontact, hitConsumerID, distance); 170 req.callbackMethod(hitYN, closestcontact, hitConsumerID, distance, snormal);
169 } 171 }
170 172
171 // This is the standard Near. Uses space AABBs to speed up detection. 173 // This is the standard Near. Uses space AABBs to speed up detection.
@@ -310,7 +312,8 @@ namespace OpenSim.Region.Physics.OdePlugin
310 collisionresult.ConsumerID = ((OdePrim)p1).m_localID; 312 collisionresult.ConsumerID = ((OdePrim)p1).m_localID;
311 collisionresult.Pos = new Vector3(contacts[i].pos.X, contacts[i].pos.Y, contacts[i].pos.Z); 313 collisionresult.Pos = new Vector3(contacts[i].pos.X, contacts[i].pos.Y, contacts[i].pos.Z);
312 collisionresult.Depth = contacts[i].depth; 314 collisionresult.Depth = contacts[i].depth;
313 315 collisionresult.Normal = new Vector3(contacts[i].normal.X, contacts[i].normal.Y,
316 contacts[i].normal.Z);
314 lock (m_contactResults) 317 lock (m_contactResults)
315 m_contactResults.Add(collisionresult); 318 m_contactResults.Add(collisionresult);
316 } 319 }
@@ -325,6 +328,8 @@ namespace OpenSim.Region.Physics.OdePlugin
325 collisionresult.ConsumerID = ((OdePrim)p2).m_localID; 328 collisionresult.ConsumerID = ((OdePrim)p2).m_localID;
326 collisionresult.Pos = new Vector3(contacts[i].pos.X, contacts[i].pos.Y, contacts[i].pos.Z); 329 collisionresult.Pos = new Vector3(contacts[i].pos.X, contacts[i].pos.Y, contacts[i].pos.Z);
327 collisionresult.Depth = contacts[i].depth; 330 collisionresult.Depth = contacts[i].depth;
331 collisionresult.Normal = new Vector3(contacts[i].normal.X, contacts[i].normal.Y,
332 contacts[i].normal.Z);
328 333
329 lock (m_contactResults) 334 lock (m_contactResults)
330 m_contactResults.Add(collisionresult); 335 m_contactResults.Add(collisionresult);
@@ -358,5 +363,6 @@ namespace OpenSim.Region.Physics.OdePlugin
358 public Vector3 Pos; 363 public Vector3 Pos;
359 public float Depth; 364 public float Depth;
360 public uint ConsumerID; 365 public uint ConsumerID;
366 public Vector3 Normal;
361 } 367 }
362} 368}
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index a0aba2a..0384d6e 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -207,6 +207,7 @@ namespace OpenSim.Region.Physics.OdePlugin
207 private float avMovementDivisorWalk = 1.3f; 207 private float avMovementDivisorWalk = 1.3f;
208 private float avMovementDivisorRun = 0.8f; 208 private float avMovementDivisorRun = 0.8f;
209 private float minimumGroundFlightOffset = 3f; 209 private float minimumGroundFlightOffset = 3f;
210 public float maximumMassObject = 10000.01f;
210 211
211 public bool meshSculptedPrim = true; 212 public bool meshSculptedPrim = true;
212 public bool forceSimplePrimMeshing = false; 213 public bool forceSimplePrimMeshing = false;
@@ -480,6 +481,7 @@ namespace OpenSim.Region.Physics.OdePlugin
480 481
481 m_NINJA_physics_joints_enabled = physicsconfig.GetBoolean("use_NINJA_physics_joints", false); 482 m_NINJA_physics_joints_enabled = physicsconfig.GetBoolean("use_NINJA_physics_joints", false);
482 minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", 3f); 483 minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", 3f);
484 maximumMassObject = physicsconfig.GetFloat("maximum_mass_object", 10000.01f);
483 } 485 }
484 } 486 }
485 487
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
index 9d97cb2..ee32755 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
@@ -236,7 +236,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
236 iHttpReq.StopHttpRequest(localID, itemID); 236 iHttpReq.StopHttpRequest(localID, itemID);
237 237
238 IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>(); 238 IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>();
239 comms.DeleteListener(itemID); 239 if (comms != null)
240 comms.DeleteListener(itemID);
240 241
241 IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>(); 242 IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>();
242 xmlrpc.DeleteChannels(itemID); 243 xmlrpc.DeleteChannels(itemID);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
new file mode 100644
index 0000000..4cc2f0a
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
@@ -0,0 +1,430 @@
1using System;
2using System.Reflection;
3using System.Collections;
4using System.Collections.Generic;
5using System.Runtime.Remoting.Lifetime;
6using OpenMetaverse;
7using Nini.Config;
8using OpenSim;
9using OpenSim.Framework;
10using OpenSim.Region.CoreModules.World.Meta7Windlight;
11using OpenSim.Region.Framework.Interfaces;
12using OpenSim.Region.Framework.Scenes;
13using OpenSim.Region.ScriptEngine.Shared;
14using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
15using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
16using OpenSim.Region.ScriptEngine.Interfaces;
17using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
18
19using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
20using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
21using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
22using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
23using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
24using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
25using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
26
27namespace OpenSim.Region.ScriptEngine.Shared.Api
28{
29 [Serializable]
30 public class CM_Api : MarshalByRefObject, ICM_Api, IScriptApi
31 {
32 internal IScriptEngine m_ScriptEngine;
33 internal SceneObjectPart m_host;
34 internal uint m_localID;
35 internal UUID m_itemID;
36 internal bool m_CMFunctionsEnabled = false;
37 internal IScriptModuleComms m_comms = null;
38
39 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
40 {
41 m_ScriptEngine = ScriptEngine;
42 m_host = host;
43 m_localID = localID;
44 m_itemID = itemID;
45
46 if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false))
47 m_CMFunctionsEnabled = true;
48
49 m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>();
50 if (m_comms == null)
51 m_CMFunctionsEnabled = false;
52 }
53
54 public override Object InitializeLifetimeService()
55 {
56 ILease lease = (ILease)base.InitializeLifetimeService();
57
58 if (lease.CurrentState == LeaseState.Initial)
59 {
60 lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
61 // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
62 // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
63 }
64 return lease;
65 }
66
67 public Scene World
68 {
69 get { return m_ScriptEngine.World; }
70 }
71
72 //
73 //Dumps an error message on the debug console.
74 //
75
76 internal void CMShoutError(string message)
77 {
78 if (message.Length > 1023)
79 message = message.Substring(0, 1023);
80
81 World.SimChat(Utils.StringToBytes(message),
82 ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true);
83
84 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
85 wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
86 }
87
88 /// <summary>
89 /// Get the current Windlight scene
90 /// </summary>
91 /// <returns>List of windlight parameters</returns>
92 public LSL_List cmGetWindlightScene(LSL_List rules)
93 {
94 if (!m_CMFunctionsEnabled)
95 {
96 CMShoutError("Careminster functions are not enabled.");
97 return new LSL_List();
98 }
99 m_host.AddScriptLPS(1);
100 RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
101
102 LSL_List values = new LSL_List();
103 int idx = 0;
104 while (idx < rules.Length)
105 {
106 uint rule = (uint)rules.GetLSLIntegerItem(idx);
107 LSL_List toadd = new LSL_List();
108
109 switch (rule)
110 {
111 case (int)ScriptBaseClass.WL_AMBIENT:
112 toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W));
113 break;
114 case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
115 toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f));
116 break;
117 case (int)ScriptBaseClass.WL_BLUE_DENSITY:
118 toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W));
119 break;
120 case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
121 toadd.Add(new LSL_Float(wl.blurMultiplier));
122 break;
123 case (int)ScriptBaseClass.WL_CLOUD_COLOR:
124 toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W));
125 break;
126 case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
127 toadd.Add(new LSL_Float(wl.cloudCoverage));
128 break;
129 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
130 toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z));
131 break;
132 case (int)ScriptBaseClass.WL_CLOUD_SCALE:
133 toadd.Add(new LSL_Float(wl.cloudScale));
134 break;
135 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
136 toadd.Add(new LSL_Float(wl.cloudScrollX));
137 break;
138 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
139 toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0));
140 break;
141 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
142 toadd.Add(new LSL_Float(wl.cloudScrollY));
143 break;
144 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
145 toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0));
146 break;
147 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
148 toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z));
149 break;
150 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
151 toadd.Add(new LSL_Float(wl.densityMultiplier));
152 break;
153 case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
154 toadd.Add(new LSL_Float(wl.distanceMultiplier));
155 break;
156 case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
157 toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0));
158 break;
159 case (int)ScriptBaseClass.WL_EAST_ANGLE:
160 toadd.Add(new LSL_Float(wl.eastAngle));
161 break;
162 case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
163 toadd.Add(new LSL_Float(wl.fresnelOffset));
164 break;
165 case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
166 toadd.Add(new LSL_Float(wl.fresnelScale));
167 break;
168 case (int)ScriptBaseClass.WL_HAZE_DENSITY:
169 toadd.Add(new LSL_Float(wl.hazeDensity));
170 break;
171 case (int)ScriptBaseClass.WL_HAZE_HORIZON:
172 toadd.Add(new LSL_Float(wl.hazeHorizon));
173 break;
174 case (int)ScriptBaseClass.WL_HORIZON:
175 toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W));
176 break;
177 case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
178 toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f));
179 break;
180 case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
181 toadd.Add(new LSL_Integer(wl.maxAltitude));
182 break;
183 case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
184 toadd.Add(new LSL_Key(wl.normalMapTexture.ToString()));
185 break;
186 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
187 toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z));
188 break;
189 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
190 toadd.Add(new LSL_Float(wl.refractScaleAbove));
191 break;
192 case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
193 toadd.Add(new LSL_Float(wl.refractScaleBelow));
194 break;
195 case (int)ScriptBaseClass.WL_SCENE_GAMMA:
196 toadd.Add(new LSL_Float(wl.sceneGamma));
197 break;
198 case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
199 toadd.Add(new LSL_Float(wl.starBrightness));
200 break;
201 case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
202 toadd.Add(new LSL_Float(wl.sunGlowFocus));
203 break;
204 case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
205 toadd.Add(new LSL_Float(wl.sunGlowSize));
206 break;
207 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
208 toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W));
209 break;
210 case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
211 toadd.Add(new LSL_Float(wl.underwaterFogModifier));
212 break;
213 case (int)ScriptBaseClass.WL_WATER_COLOR:
214 toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z));
215 break;
216 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
217 toadd.Add(new LSL_Float(wl.waterFogDensityExponent));
218 break;
219 }
220
221 if (toadd.Length > 0)
222 {
223 values.Add(rule);
224 values.Add(toadd.Data[0]);
225 }
226 idx++;
227 }
228
229
230 return values;
231
232 }
233
234 /// <summary>
235 /// Set the current Windlight scene
236 /// </summary>
237 /// <param name="rules"></param>
238 /// <returns>success: true or false</returns>
239 public int cmSetWindlightScene(LSL_List rules)
240 {
241 if (!m_CMFunctionsEnabled)
242 {
243 CMShoutError("Careminster functions are not enabled.");
244 return 0;
245 }
246 int success = 0;
247 m_host.AddScriptLPS(1);
248 if (Meta7WindlightModule.EnableWindlight)
249 {
250 RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
251
252 LSL_List values = new LSL_List();
253 int idx = 0;
254 success = 1;
255 while (idx < rules.Length)
256 {
257 uint rule = (uint)rules.GetLSLIntegerItem(idx);
258 LSL_Types.Quaternion iQ;
259 LSL_Types.Vector3 iV;
260 switch (rule)
261 {
262 case (int)ScriptBaseClass.WL_AMBIENT:
263 idx++;
264 iQ = rules.GetQuaternionItem(idx);
265 wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
266 break;
267 case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
268 idx++;
269 iV = rules.GetVector3Item(idx);
270 wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
271 break;
272 case (int)ScriptBaseClass.WL_BLUE_DENSITY:
273 idx++;
274 iQ = rules.GetQuaternionItem(idx);
275 wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
276 break;
277 case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
278 idx++;
279 wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
280 break;
281 case (int)ScriptBaseClass.WL_CLOUD_COLOR:
282 idx++;
283 iQ = rules.GetQuaternionItem(idx);
284 wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
285 break;
286 case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
287 idx++;
288 wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
289 break;
290 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
291 idx++;
292 iV = rules.GetVector3Item(idx);
293 wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
294 break;
295 case (int)ScriptBaseClass.WL_CLOUD_SCALE:
296 idx++;
297 wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
298 break;
299 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
300 idx++;
301 wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
302 break;
303 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
304 idx++;
305 wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
306 break;
307 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
308 idx++;
309 wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
310 break;
311 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
312 idx++;
313 wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
314 break;
315 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
316 idx++;
317 iV = rules.GetVector3Item(idx);
318 wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
319 break;
320 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
321 idx++;
322 wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
323 break;
324 case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
325 idx++;
326 wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
327 break;
328 case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
329 idx++;
330 wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
331 break;
332 case (int)ScriptBaseClass.WL_EAST_ANGLE:
333 idx++;
334 wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
335 break;
336 case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
337 idx++;
338 wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
339 break;
340 case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
341 idx++;
342 wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
343 break;
344 case (int)ScriptBaseClass.WL_HAZE_DENSITY:
345 idx++;
346 wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
347 break;
348 case (int)ScriptBaseClass.WL_HAZE_HORIZON:
349 idx++;
350 wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx);
351 break;
352 case (int)ScriptBaseClass.WL_HORIZON:
353 idx++;
354 iQ = rules.GetQuaternionItem(idx);
355 wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
356 break;
357 case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
358 idx++;
359 iV = rules.GetVector3Item(idx);
360 wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
361 break;
362 case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
363 idx++;
364 wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
365 break;
366 case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
367 idx++;
368 wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
369 break;
370 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
371 idx++;
372 iV = rules.GetVector3Item(idx);
373 wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
374 break;
375 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
376 idx++;
377 wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
378 break;
379 case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
380 idx++;
381 wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
382 break;
383 case (int)ScriptBaseClass.WL_SCENE_GAMMA:
384 idx++;
385 wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
386 break;
387 case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
388 idx++;
389 wl.starBrightness = (float)rules.GetLSLFloatItem(idx);
390 break;
391 case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
392 idx++;
393 wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx);
394 break;
395 case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
396 idx++;
397 wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx);
398 break;
399 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
400 idx++;
401 iQ = rules.GetQuaternionItem(idx);
402 wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
403 break;
404 case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
405 idx++;
406 wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
407 break;
408 case (int)ScriptBaseClass.WL_WATER_COLOR:
409 idx++;
410 iV = rules.GetVector3Item(idx);
411 wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
412 break;
413 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
414 idx++;
415 wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
416 break;
417 default:
418 success = 0;
419 break;
420 }
421 idx++;
422 }
423 m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
424
425 }
426 return success;
427 }
428
429 }
430}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 8274fbf..e694f15 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -749,7 +749,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
749 ChatTypeEnum.Whisper, channelID, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, false); 749 ChatTypeEnum.Whisper, channelID, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, false);
750 750
751 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 751 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
752 wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text); 752 if (wComm != null)
753 wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text);
753 } 754 }
754 755
755 public void llSay(int channelID, string text) 756 public void llSay(int channelID, string text)
@@ -769,7 +770,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
769 ChatTypeEnum.Say, channelID, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, false); 770 ChatTypeEnum.Say, channelID, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, false);
770 771
771 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 772 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
772 wComm.DeliverMessage(ChatTypeEnum.Say, channelID, m_host.Name, m_host.UUID, text); 773 if (wComm != null)
774 wComm.DeliverMessage(ChatTypeEnum.Say, channelID, m_host.Name, m_host.UUID, text);
773 } 775 }
774 } 776 }
775 777
@@ -784,7 +786,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
784 ChatTypeEnum.Shout, channelID, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true); 786 ChatTypeEnum.Shout, channelID, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true);
785 787
786 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 788 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
787 wComm.DeliverMessage(ChatTypeEnum.Shout, channelID, m_host.Name, m_host.UUID, text); 789 if (wComm != null)
790 wComm.DeliverMessage(ChatTypeEnum.Shout, channelID, m_host.Name, m_host.UUID, text);
788 } 791 }
789 792
790 public void llRegionSay(int channelID, string text) 793 public void llRegionSay(int channelID, string text)
@@ -801,7 +804,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
801 m_host.AddScriptLPS(1); 804 m_host.AddScriptLPS(1);
802 805
803 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 806 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
804 wComm.DeliverMessage(ChatTypeEnum.Region, channelID, m_host.Name, m_host.UUID, text); 807 if (wComm != null)
808 wComm.DeliverMessage(ChatTypeEnum.Region, channelID, m_host.Name, m_host.UUID, text);
805 } 809 }
806 810
807 public LSL_Integer llListen(int channelID, string name, string ID, string msg) 811 public LSL_Integer llListen(int channelID, string name, string ID, string msg)
@@ -810,21 +814,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
810 UUID keyID; 814 UUID keyID;
811 UUID.TryParse(ID, out keyID); 815 UUID.TryParse(ID, out keyID);
812 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 816 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
813 return wComm.Listen(m_localID, m_itemID, m_host.UUID, channelID, name, keyID, msg); 817 if (wComm != null)
818 return wComm.Listen(m_localID, m_itemID, m_host.UUID, channelID, name, keyID, msg);
819 else
820 return -1;
814 } 821 }
815 822
816 public void llListenControl(int number, int active) 823 public void llListenControl(int number, int active)
817 { 824 {
818 m_host.AddScriptLPS(1); 825 m_host.AddScriptLPS(1);
819 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 826 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
820 wComm.ListenControl(m_itemID, number, active); 827 if (wComm != null)
828 wComm.ListenControl(m_itemID, number, active);
821 } 829 }
822 830
823 public void llListenRemove(int number) 831 public void llListenRemove(int number)
824 { 832 {
825 m_host.AddScriptLPS(1); 833 m_host.AddScriptLPS(1);
826 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 834 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
827 wComm.ListenRemove(m_itemID, number); 835 if (wComm != null)
836 wComm.ListenRemove(m_itemID, number);
828 } 837 }
829 838
830 public void llSensor(string name, string id, int type, double range, double arc) 839 public void llSensor(string name, string id, int type, double range, double arc)
@@ -1052,7 +1061,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1052 return detectedParams.TouchUV; 1061 return detectedParams.TouchUV;
1053 } 1062 }
1054 1063
1055 public void llDie() 1064 public virtual void llDie()
1056 { 1065 {
1057 m_host.AddScriptLPS(1); 1066 m_host.AddScriptLPS(1);
1058 throw new SelfDeleteException(); 1067 throw new SelfDeleteException();
@@ -2941,8 +2950,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2941 return m_host.OwnerID.ToString(); 2950 return m_host.OwnerID.ToString();
2942 } 2951 }
2943 2952
2953 [DebuggerNonUserCode]
2944 public void llInstantMessage(string user, string message) 2954 public void llInstantMessage(string user, string message)
2945 { 2955 {
2956 UUID result;
2957 if (!UUID.TryParse(user, out result))
2958 {
2959 throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user));
2960 return;
2961 }
2962
2963
2946 m_host.AddScriptLPS(1); 2964 m_host.AddScriptLPS(1);
2947 2965
2948 // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. 2966 // We may be able to use ClientView.SendInstantMessage here, but we need a client instance.
@@ -2957,7 +2975,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2957 UUID friendTransactionID = UUID.Random(); 2975 UUID friendTransactionID = UUID.Random();
2958 2976
2959 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); 2977 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
2960 2978
2961 GridInstantMessage msg = new GridInstantMessage(); 2979 GridInstantMessage msg = new GridInstantMessage();
2962 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; 2980 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid;
2963 msg.toAgentID = new Guid(user); // toAgentID.Guid; 2981 msg.toAgentID = new Guid(user); // toAgentID.Guid;
@@ -3570,6 +3588,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3570 { 3588 {
3571 parentPrim.DelinkFromGroup(part.LocalId, true); 3589 parentPrim.DelinkFromGroup(part.LocalId, true);
3572 } 3590 }
3591 parentPrim.HasGroupChanged = true;
3592 parentPrim.ScheduleGroupForFullUpdate();
3573 parentPrim.TriggerScriptChangedEvent(Changed.LINK); 3593 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
3574 3594
3575 if (parts.Count > 0) 3595 if (parts.Count > 0)
@@ -3581,6 +3601,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3581 part.UpdateFlag = 0; 3601 part.UpdateFlag = 0;
3582 newRoot.ParentGroup.LinkToGroup(part.ParentGroup); 3602 newRoot.ParentGroup.LinkToGroup(part.ParentGroup);
3583 } 3603 }
3604 newRoot.ParentGroup.HasGroupChanged = true;
3605 newRoot.ParentGroup.ScheduleGroupForFullUpdate();
3584 } 3606 }
3585 } 3607 }
3586 else 3608 else
@@ -3589,6 +3611,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3589 return; 3611 return;
3590 3612
3591 parentPrim.DelinkFromGroup(childPrim.LocalId, true); 3613 parentPrim.DelinkFromGroup(childPrim.LocalId, true);
3614 parentPrim.HasGroupChanged = true;
3615 parentPrim.ScheduleGroupForFullUpdate();
3592 parentPrim.TriggerScriptChangedEvent(Changed.LINK); 3616 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
3593 } 3617 }
3594 } 3618 }
@@ -3608,6 +3632,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3608 parentPrim.DelinkFromGroup(part.LocalId, true); 3632 parentPrim.DelinkFromGroup(part.LocalId, true);
3609 parentPrim.TriggerScriptChangedEvent(Changed.LINK); 3633 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
3610 } 3634 }
3635 parentPrim.HasGroupChanged = true;
3636 parentPrim.ScheduleGroupForFullUpdate();
3611 } 3637 }
3612 3638
3613 public LSL_String llGetLinkKey(int linknum) 3639 public LSL_String llGetLinkKey(int linknum)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 7f739b1..836f276 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -1973,6 +1973,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1973 } 1973 }
1974 return ret; 1974 return ret;
1975 } 1975 }
1976
1977 } 1976 }
1978} 1977}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
index 0716d45..eeb59d9 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
@@ -166,7 +166,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
166 ts.next = DateTime.Now.Ticks + (long)data[idx+1]; 166 ts.next = DateTime.Now.Ticks + (long)data[idx+1];
167 idx += 2; 167 idx += 2;
168 168
169 Timers.Add(MakeTimerKey(localID,itemID), ts); 169 lock (TimerListLock)
170 {
171 Timers.Add(MakeTimerKey(localID, itemID), ts);
172 }
170 } 173 }
171 } 174 }
172 } 175 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
new file mode 100644
index 0000000..9dd0b73
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
@@ -0,0 +1,20 @@
1using System.Collections;
2using OpenSim.Region.ScriptEngine.Interfaces;
3
4using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
5using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
6using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
7using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
8using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
9using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
10using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
11
12namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
13{
14 public interface ICM_Api
15 {
16 // Windlight Functions
17 LSL_List cmGetWindlightScene(LSL_List rules);
18 int cmSetWindlightScene(LSL_List rules);
19 }
20}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 0b0dc00..c3bf7d2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -80,7 +80,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
80 // Avatar Info Commands 80 // Avatar Info Commands
81 string osGetAgentIP(string agent); 81 string osGetAgentIP(string agent);
82 LSL_List osGetAgents(); 82 LSL_List osGetAgents();
83 83
84 // Teleport commands 84 // Teleport commands
85 void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); 85 void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
86 void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); 86 void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs
new file mode 100644
index 0000000..7b67fa3
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs
@@ -0,0 +1,76 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
30using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
31using LSLInteger = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
32
33namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
34{
35 public partial class ScriptBaseClass
36 {
37 // Constants for cmWindlight*
38 public const int WL_WATER_COLOR = 0;
39 public const int WL_WATER_FOG_DENSITY_EXPONENT = 1;
40 public const int WL_UNDERWATER_FOG_MODIFIER = 2;
41 public const int WL_REFLECTION_WAVELET_SCALE = 3;
42 public const int WL_FRESNEL_SCALE = 4;
43 public const int WL_FRESNEL_OFFSET = 5;
44 public const int WL_REFRACT_SCALE_ABOVE = 6;
45 public const int WL_REFRACT_SCALE_BELOW = 7;
46 public const int WL_BLUR_MULTIPLIER = 8;
47 public const int WL_BIG_WAVE_DIRECTION = 9;
48 public const int WL_LITTLE_WAVE_DIRECTION = 10;
49 public const int WL_NORMAL_MAP_TEXTURE = 11;
50 public const int WL_HORIZON = 12;
51 public const int WL_HAZE_HORIZON = 13;
52 public const int WL_BLUE_DENSITY = 14;
53 public const int WL_HAZE_DENSITY = 15;
54 public const int WL_DENSITY_MULTIPLIER = 16;
55 public const int WL_DISTANCE_MULTIPLIER = 17;
56 public const int WL_MAX_ALTITUDE = 18;
57 public const int WL_SUN_MOON_COLOR = 19;
58 public const int WL_AMBIENT = 20;
59 public const int WL_EAST_ANGLE = 21;
60 public const int WL_SUN_GLOW_FOCUS = 22;
61 public const int WL_SUN_GLOW_SIZE = 23;
62 public const int WL_SCENE_GAMMA = 24;
63 public const int WL_STAR_BRIGHTNESS = 25;
64 public const int WL_CLOUD_COLOR = 26;
65 public const int WL_CLOUD_XY_DENSITY = 27;
66 public const int WL_CLOUD_COVERAGE = 28;
67 public const int WL_CLOUD_SCALE = 29;
68 public const int WL_CLOUD_DETAIL_XY_DENSITY = 30;
69 public const int WL_CLOUD_SCROLL_X = 31;
70 public const int WL_CLOUD_SCROLL_Y = 32;
71 public const int WL_CLOUD_SCROLL_Y_LOCK = 33;
72 public const int WL_CLOUD_SCROLL_X_LOCK = 34;
73 public const int WL_DRAW_CLASSIC_CLOUDS = 35;
74
75 }
76}
diff --git a/OpenSim/Region/OptionalModules/Python/PythonModule.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
index ce35363..e85d41e 100644
--- a/OpenSim/Region/OptionalModules/Python/PythonModule.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -26,46 +26,46 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Runtime.Remoting.Lifetime;
30using System.Threading;
30using System.Reflection; 31using System.Reflection;
31using System.Security.Policy; 32using System.Collections;
32using System.Text; 33using System.Collections.Generic;
33using IronPython.Hosting; 34using OpenSim.Framework;
34using log4net;
35using Nini.Config;
36using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.ScriptEngine.Interfaces;
37using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
38using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
39using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
40using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
41using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
42using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
43using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
44using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
45using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
38 46
39namespace OpenSim.Region.Modules.Python 47namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
40{ 48{
41 class PythonModule : IRegionModule 49 public partial class ScriptBaseClass : MarshalByRefObject
42 { 50 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 public ICM_Api m_CM_Functions;
44 private PythonEngine m_python;
45 52
46 public void Initialise(Scene scene, IConfigSource source) 53 public void ApiTypeCM(IScriptApi api)
47 { 54 {
48 } 55 if (!(api is ICM_Api))
56 return;
49 57
50 public void PostInitialise() 58 m_CM_Functions = (ICM_Api)api;
51 {
52 m_log.Info("[PYTHON] Initialising IronPython engine.");
53 m_python = new PythonEngine();
54 m_python.AddToPath(System.Environment.CurrentDirectory + System.IO.Path.DirectorySeparatorChar + "Python");
55 }
56
57 public void Close()
58 {
59 } 59 }
60 60
61 public string Name 61 public LSL_List cmGetWindlightScene(LSL_List rules)
62 { 62 {
63 get { return "PythonModule"; } 63 return m_CM_Functions.cmGetWindlightScene(rules);
64 } 64 }
65 65
66 public bool IsSharedModule 66 public int cmSetWindlightScene(LSL_List rules)
67 { 67 {
68 get { return true; } 68 return m_CM_Functions.cmSetWindlightScene(rules);
69 } 69 }
70 } 70 }
71} 71}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp
index 98bbc68..23138ef 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp
@@ -17,6 +17,8 @@
17 <excludeFiles /> 17 <excludeFiles />
18 </DeploymentInformation> 18 </DeploymentInformation>
19 <Contents> 19 <Contents>
20 <File name="./CM_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
21 <File name="./CM_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
20 <File name="./Executor.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 22 <File name="./Executor.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
21 <File name="./LSL_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 23 <File name="./LSL_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
22 <File name="./LSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 24 <File name="./LSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 2fc2ea1..184af19 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -101,6 +101,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
101 private Dictionary<UUID, IScriptInstance> m_Scripts = 101 private Dictionary<UUID, IScriptInstance> m_Scripts =
102 new Dictionary<UUID, IScriptInstance>(); 102 new Dictionary<UUID, IScriptInstance>();
103 103
104 private OpenMetaverse.ReaderWriterLockSlim m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim();
105
104 // Maps the asset ID to the assembly 106 // Maps the asset ID to the assembly
105 107
106 private Dictionary<UUID, string> m_Assemblies = 108 private Dictionary<UUID, string> m_Assemblies =
@@ -122,6 +124,71 @@ namespace OpenSim.Region.ScriptEngine.XEngine
122 private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue(); 124 private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue();
123 IWorkItemResult m_CurrentCompile = null; 125 IWorkItemResult m_CurrentCompile = null;
124 126
127 private void lockScriptsForRead(bool locked)
128 {
129 if (locked)
130 {
131 if (m_scriptsLock.RecursiveReadCount > 0)
132 {
133 m_log.Error("[XEngine.m_Scripts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue.");
134 m_scriptsLock.ExitReadLock();
135 }
136 if (m_scriptsLock.RecursiveWriteCount > 0)
137 {
138 m_log.Error("[XEngine.m_Scripts] Recursive write lock requested. This should not happen and means something needs to be fixed.");
139 m_scriptsLock.ExitWriteLock();
140 }
141
142 while (!m_scriptsLock.TryEnterReadLock(60000))
143 {
144 m_log.Error("[XEngine.m_Scripts] Thread lock detected while trying to aquire READ lock of m_scripts in XEngine. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
145 if (m_scriptsLock.IsWriteLockHeld)
146 {
147 m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim();
148 }
149 }
150 }
151 else
152 {
153 if (m_scriptsLock.RecursiveReadCount > 0)
154 {
155 m_scriptsLock.ExitReadLock();
156 }
157 }
158 }
159 private void lockScriptsForWrite(bool locked)
160 {
161 if (locked)
162 {
163 if (m_scriptsLock.RecursiveReadCount > 0)
164 {
165 m_log.Error("[XEngine.m_Scripts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue.");
166 m_scriptsLock.ExitReadLock();
167 }
168 if (m_scriptsLock.RecursiveWriteCount > 0)
169 {
170 m_log.Error("[XEngine.m_Scripts] Recursive write lock requested. This should not happen and means something needs to be fixed.");
171 m_scriptsLock.ExitWriteLock();
172 }
173
174 while (!m_scriptsLock.TryEnterWriteLock(60000))
175 {
176 m_log.Error("[XEngine.m_Scripts] Thread lock detected while trying to aquire WRITE lock of m_scripts in XEngine. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
177 if (m_scriptsLock.IsWriteLockHeld)
178 {
179 m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim();
180 }
181 }
182 }
183 else
184 {
185 if (m_scriptsLock.RecursiveWriteCount > 0)
186 {
187 m_scriptsLock.ExitWriteLock();
188 }
189 }
190 }
191
125 public string ScriptEngineName 192 public string ScriptEngineName
126 { 193 {
127 get { return "XEngine"; } 194 get { return "XEngine"; }
@@ -261,43 +328,45 @@ namespace OpenSim.Region.ScriptEngine.XEngine
261 328
262 public void RemoveRegion(Scene scene) 329 public void RemoveRegion(Scene scene)
263 { 330 {
264 lock (m_Scripts) 331 lockScriptsForRead(true);
332 foreach (IScriptInstance instance in m_Scripts.Values)
265 { 333 {
266 foreach (IScriptInstance instance in m_Scripts.Values) 334 // Force a final state save
335 //
336 if (m_Assemblies.ContainsKey(instance.AssetID))
267 { 337 {
268 // Force a final state save 338 string assembly = m_Assemblies[instance.AssetID];
269 // 339 instance.SaveState(assembly);
270 if (m_Assemblies.ContainsKey(instance.AssetID)) 340 }
271 {
272 string assembly = m_Assemblies[instance.AssetID];
273 instance.SaveState(assembly);
274 }
275 341
276 // Clear the event queue and abort the instance thread 342 // Clear the event queue and abort the instance thread
277 // 343 //
278 instance.ClearQueue(); 344 instance.ClearQueue();
279 instance.Stop(0); 345 instance.Stop(0);
280 346
281 // Release events, timer, etc 347 // Release events, timer, etc
282 // 348 //
283 instance.DestroyScriptInstance(); 349 instance.DestroyScriptInstance();
284 350
285 // Unload scripts and app domains 351 // Unload scripts and app domains
286 // Must be done explicitly because they have infinite 352 // Must be done explicitly because they have infinite
287 // lifetime 353 // lifetime
288 // 354 //
289 m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); 355 m_DomainScripts[instance.AppDomain].Remove(instance.ItemID);
290 if (m_DomainScripts[instance.AppDomain].Count == 0) 356 if (m_DomainScripts[instance.AppDomain].Count == 0)
291 { 357 {
292 m_DomainScripts.Remove(instance.AppDomain); 358 m_DomainScripts.Remove(instance.AppDomain);
293 UnloadAppDomain(instance.AppDomain); 359 UnloadAppDomain(instance.AppDomain);
294 }
295 } 360 }
296 m_Scripts.Clear();
297 m_PrimObjects.Clear();
298 m_Assemblies.Clear();
299 m_DomainScripts.Clear();
300 } 361 }
362 lockScriptsForRead(false);
363 lockScriptsForWrite(true);
364 m_Scripts.Clear();
365 lockScriptsForWrite(false);
366 m_PrimObjects.Clear();
367 m_Assemblies.Clear();
368 m_DomainScripts.Clear();
369
301 lock (m_ScriptEngines) 370 lock (m_ScriptEngines)
302 { 371 {
303 m_ScriptEngines.Remove(this); 372 m_ScriptEngines.Remove(this);
@@ -356,22 +425,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine
356 425
357 List<IScriptInstance> instances = new List<IScriptInstance>(); 426 List<IScriptInstance> instances = new List<IScriptInstance>();
358 427
359 lock (m_Scripts) 428 lockScriptsForRead(true);
360 { 429 foreach (IScriptInstance instance in m_Scripts.Values)
361 foreach (IScriptInstance instance in m_Scripts.Values)
362 instances.Add(instance); 430 instances.Add(instance);
363 } 431 lockScriptsForRead(false);
364 432
365 foreach (IScriptInstance i in instances) 433 foreach (IScriptInstance i in instances)
366 { 434 {
367 string assembly = String.Empty; 435 string assembly = String.Empty;
368 436
369 lock (m_Scripts) 437
370 {
371 if (!m_Assemblies.ContainsKey(i.AssetID)) 438 if (!m_Assemblies.ContainsKey(i.AssetID))
372 continue; 439 continue;
373 assembly = m_Assemblies[i.AssetID]; 440 assembly = m_Assemblies[i.AssetID];
374 } 441
375 442
376 i.SaveState(assembly); 443 i.SaveState(assembly);
377 } 444 }
@@ -673,172 +740,183 @@ namespace OpenSim.Region.ScriptEngine.XEngine
673 return false; 740 return false;
674 } 741 }
675 742
676 lock (m_Scripts) 743
744
745 ScriptInstance instance = null;
746 // Create the object record
747 lockScriptsForRead(true);
748 if ((!m_Scripts.ContainsKey(itemID)) ||
749 (m_Scripts[itemID].AssetID != assetID))
677 { 750 {
678 ScriptInstance instance = null; 751 lockScriptsForRead(false);
679 // Create the object record
680 752
681 if ((!m_Scripts.ContainsKey(itemID)) || 753 UUID appDomain = assetID;
682 (m_Scripts[itemID].AssetID != assetID))
683 {
684 UUID appDomain = assetID;
685 754
686 if (part.ParentGroup.IsAttachment) 755 if (part.ParentGroup.IsAttachment)
687 appDomain = part.ParentGroup.RootPart.UUID; 756 appDomain = part.ParentGroup.RootPart.UUID;
688 757
689 if (!m_AppDomains.ContainsKey(appDomain)) 758 if (!m_AppDomains.ContainsKey(appDomain))
759 {
760 try
690 { 761 {
691 try 762 AppDomainSetup appSetup = new AppDomainSetup();
692 { 763 // appSetup.ApplicationBase = Path.Combine(
693 AppDomainSetup appSetup = new AppDomainSetup(); 764 // "ScriptEngines",
694// appSetup.ApplicationBase = Path.Combine( 765 // m_Scene.RegionInfo.RegionID.ToString());
695// "ScriptEngines", 766
696// m_Scene.RegionInfo.RegionID.ToString()); 767 Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
697 768 Evidence evidence = new Evidence(baseEvidence);
698 Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; 769
699 Evidence evidence = new Evidence(baseEvidence); 770 AppDomain sandbox;
700 771 if (m_AppDomainLoading)
701 AppDomain sandbox; 772 sandbox = AppDomain.CreateDomain(
702 if (m_AppDomainLoading) 773 m_Scene.RegionInfo.RegionID.ToString(),
703 sandbox = AppDomain.CreateDomain( 774 evidence, appSetup);
704 m_Scene.RegionInfo.RegionID.ToString(), 775 else
705 evidence, appSetup); 776 sandbox = AppDomain.CurrentDomain;
706 else 777
707 sandbox = AppDomain.CurrentDomain; 778 //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel();
708 779 //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition();
709 //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); 780 //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet");
710 //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); 781 //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet);
711 //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); 782 //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement);
712 //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); 783 //sandboxPolicy.RootCodeGroup = sandboxCodeGroup;
713 //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); 784 //sandbox.SetAppDomainPolicy(sandboxPolicy);
714 //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; 785
715 //sandbox.SetAppDomainPolicy(sandboxPolicy); 786 m_AppDomains[appDomain] = sandbox;
716 787
717 m_AppDomains[appDomain] = sandbox; 788 m_AppDomains[appDomain].AssemblyResolve +=
718 789 new ResolveEventHandler(
719 m_AppDomains[appDomain].AssemblyResolve += 790 AssemblyResolver.OnAssemblyResolve);
720 new ResolveEventHandler( 791 m_DomainScripts[appDomain] = new List<UUID>();
721 AssemblyResolver.OnAssemblyResolve);
722 m_DomainScripts[appDomain] = new List<UUID>();
723 }
724 catch (Exception e)
725 {
726 m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString());
727 m_ScriptErrorMessage += "Exception creating app domain:\n";
728 m_ScriptFailCount++;
729 lock (m_AddingAssemblies)
730 {
731 m_AddingAssemblies[assembly]--;
732 }
733 return false;
734 }
735 } 792 }
736 m_DomainScripts[appDomain].Add(itemID); 793 catch (Exception e)
737
738 instance = new ScriptInstance(this, part,
739 itemID, assetID, assembly,
740 m_AppDomains[appDomain],
741 part.ParentGroup.RootPart.Name,
742 item.Name, startParam, postOnRez,
743 stateSource, m_MaxScriptQueue);
744
745 m_log.DebugFormat("[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}",
746 part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, part.ParentGroup.RootPart.AbsolutePosition.ToString());
747
748 if (presence != null)
749 { 794 {
750 ShowScriptSaveResponse(item.OwnerID, 795 m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString());
751 assetID, "Compile successful", true); 796 m_ScriptErrorMessage += "Exception creating app domain:\n";
797 m_ScriptFailCount++;
798 lock (m_AddingAssemblies)
799 {
800 m_AddingAssemblies[assembly]--;
801 }
802 return false;
752 } 803 }
804 }
805 m_DomainScripts[appDomain].Add(itemID);
753 806
754 instance.AppDomain = appDomain; 807 instance = new ScriptInstance(this, part,
755 instance.LineMap = linemap; 808 itemID, assetID, assembly,
809 m_AppDomains[appDomain],
810 part.ParentGroup.RootPart.Name,
811 item.Name, startParam, postOnRez,
812 stateSource, m_MaxScriptQueue);
756 813
757 m_Scripts[itemID] = instance; 814 m_log.DebugFormat("[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}",
758 } 815 part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, part.ParentGroup.RootPart.AbsolutePosition.ToString());
759 816
760 lock (m_PrimObjects) 817 if (presence != null)
761 { 818 {
762 if (!m_PrimObjects.ContainsKey(localID)) 819 ShowScriptSaveResponse(item.OwnerID,
763 m_PrimObjects[localID] = new List<UUID>(); 820 assetID, "Compile successful", true);
821 }
764 822
765 if (!m_PrimObjects[localID].Contains(itemID)) 823 instance.AppDomain = appDomain;
766 m_PrimObjects[localID].Add(itemID); 824 instance.LineMap = linemap;
825 lockScriptsForWrite(true);
826 m_Scripts[itemID] = instance;
827 lockScriptsForWrite(false);
828 }
829 else
830 {
831 lockScriptsForRead(false);
832 }
833 lock (m_PrimObjects)
834 {
835 if (!m_PrimObjects.ContainsKey(localID))
836 m_PrimObjects[localID] = new List<UUID>();
767 837
768 } 838 if (!m_PrimObjects[localID].Contains(itemID))
839 m_PrimObjects[localID].Add(itemID);
769 840
770 if (!m_Assemblies.ContainsKey(assetID)) 841 }
771 m_Assemblies[assetID] = assembly;
772 842
773 lock (m_AddingAssemblies) 843 if (!m_Assemblies.ContainsKey(assetID))
774 { 844 m_Assemblies[assetID] = assembly;
775 m_AddingAssemblies[assembly]--;
776 }
777 845
778 if (instance!=null) 846 lock (m_AddingAssemblies)
779 instance.Init(); 847 {
848 m_AddingAssemblies[assembly]--;
780 } 849 }
850
851 if (instance!=null)
852 instance.Init();
853
781 return true; 854 return true;
782 } 855 }
783 856
784 public void OnRemoveScript(uint localID, UUID itemID) 857 public void OnRemoveScript(uint localID, UUID itemID)
785 { 858 {
786 lock (m_Scripts) 859 lockScriptsForRead(true);
860 // Do we even have it?
861 if (!m_Scripts.ContainsKey(itemID))
787 { 862 {
788 // Do we even have it? 863 lockScriptsForRead(false);
789 if (!m_Scripts.ContainsKey(itemID)) 864 return;
790 return; 865 }
791 866
792 IScriptInstance instance=m_Scripts[itemID];
793 m_Scripts.Remove(itemID);
794 867
795 instance.ClearQueue(); 868 IScriptInstance instance=m_Scripts[itemID];
796 instance.Stop(0); 869 lockScriptsForRead(false);
870 lockScriptsForWrite(true);
871 m_Scripts.Remove(itemID);
872 lockScriptsForWrite(false);
873 instance.ClearQueue();
874 instance.Stop(0);
797 875
798 SceneObjectPart part = 876 SceneObjectPart part =
799 m_Scene.GetSceneObjectPart(localID); 877 m_Scene.GetSceneObjectPart(localID);
800 878
801 if (part != null) 879 if (part != null)
802 part.RemoveScriptEvents(itemID); 880 part.RemoveScriptEvents(itemID);
803 881
804// bool objectRemoved = false; 882// bool objectRemoved = false;
805 883
806 lock (m_PrimObjects) 884 lock (m_PrimObjects)
885 {
886 // Remove the script from it's prim
887 if (m_PrimObjects.ContainsKey(localID))
807 { 888 {
808 // Remove the script from it's prim 889 // Remove inventory item record
809 if (m_PrimObjects.ContainsKey(localID)) 890 if (m_PrimObjects[localID].Contains(itemID))
810 { 891 m_PrimObjects[localID].Remove(itemID);
811 // Remove inventory item record
812 if (m_PrimObjects[localID].Contains(itemID))
813 m_PrimObjects[localID].Remove(itemID);
814 892
815 // If there are no more scripts, remove prim 893 // If there are no more scripts, remove prim
816 if (m_PrimObjects[localID].Count == 0) 894 if (m_PrimObjects[localID].Count == 0)
817 { 895 {
818 m_PrimObjects.Remove(localID); 896 m_PrimObjects.Remove(localID);
819// objectRemoved = true; 897// objectRemoved = true;
820 }
821 } 898 }
822 } 899 }
900 }
823 901
824 instance.RemoveState(); 902 instance.RemoveState();
825 instance.DestroyScriptInstance(); 903 instance.DestroyScriptInstance();
826 904
827 m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); 905 m_DomainScripts[instance.AppDomain].Remove(instance.ItemID);
828 if (m_DomainScripts[instance.AppDomain].Count == 0) 906 if (m_DomainScripts[instance.AppDomain].Count == 0)
829 { 907 {
830 m_DomainScripts.Remove(instance.AppDomain); 908 m_DomainScripts.Remove(instance.AppDomain);
831 UnloadAppDomain(instance.AppDomain); 909 UnloadAppDomain(instance.AppDomain);
832 } 910 }
833 911
834 instance = null; 912 instance = null;
835 913
836 ObjectRemoved handlerObjectRemoved = OnObjectRemoved; 914 ObjectRemoved handlerObjectRemoved = OnObjectRemoved;
837 if (handlerObjectRemoved != null) 915 if (handlerObjectRemoved != null)
838 handlerObjectRemoved(part.UUID); 916 handlerObjectRemoved(part.UUID);
839 917
840 CleanAssemblies(); 918 CleanAssemblies();
841 } 919
842 920
843 ScriptRemoved handlerScriptRemoved = OnScriptRemoved; 921 ScriptRemoved handlerScriptRemoved = OnScriptRemoved;
844 if (handlerScriptRemoved != null) 922 if (handlerScriptRemoved != null)
@@ -1091,12 +1169,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1091 private IScriptInstance GetInstance(UUID itemID) 1169 private IScriptInstance GetInstance(UUID itemID)
1092 { 1170 {
1093 IScriptInstance instance; 1171 IScriptInstance instance;
1094 lock (m_Scripts) 1172 lockScriptsForRead(true);
1173 if (!m_Scripts.ContainsKey(itemID))
1095 { 1174 {
1096 if (!m_Scripts.ContainsKey(itemID)) 1175 lockScriptsForRead(false);
1097 return null; 1176 return null;
1098 instance = m_Scripts[itemID];
1099 } 1177 }
1178 instance = m_Scripts[itemID];
1179 lockScriptsForRead(false);
1100 return instance; 1180 return instance;
1101 } 1181 }
1102 1182
@@ -1200,11 +1280,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1200 { 1280 {
1201 List<IScriptInstance> instances = new List<IScriptInstance>(); 1281 List<IScriptInstance> instances = new List<IScriptInstance>();
1202 1282
1203 lock (m_Scripts) 1283 lockScriptsForRead(true);
1204 { 1284 foreach (IScriptInstance instance in m_Scripts.Values)
1205 foreach (IScriptInstance instance in m_Scripts.Values)
1206 instances.Add(instance); 1285 instances.Add(instance);
1207 } 1286 lockScriptsForRead(false);
1208 1287
1209 foreach (IScriptInstance i in instances) 1288 foreach (IScriptInstance i in instances)
1210 { 1289 {
@@ -1394,7 +1473,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1394 if (rootE.GetAttribute("UUID") != itemID.ToString()) 1473 if (rootE.GetAttribute("UUID") != itemID.ToString())
1395 return; 1474 return;
1396 1475
1397 string assetID = rootE.GetAttribute("Asset"); 1476// string assetID = rootE.GetAttribute("Asset");
1398 1477
1399 XmlNodeList stateL = rootE.GetElementsByTagName("ScriptState"); 1478 XmlNodeList stateL = rootE.GetElementsByTagName("ScriptState");
1400 1479
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs
index 1d9eb0d..63ba673 100644
--- a/OpenSim/Server/Base/ServicesServerBase.cs
+++ b/OpenSim/Server/Base/ServicesServerBase.cs
@@ -226,6 +226,10 @@ namespace OpenSim.Server.Base
226 "quit", 226 "quit",
227 "Quit the application", HandleQuit); 227 "Quit the application", HandleQuit);
228 228
229 MainConsole.Instance.Commands.AddCommand("base", false, "shutdown",
230 "shutdown",
231 "Quit the application", HandleQuit);
232
229 // Allow derived classes to perform initialization that 233 // Allow derived classes to perform initialization that
230 // needs to be done after the console has opened 234 // needs to be done after the console has opened
231 // 235 //
diff --git a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs b/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs
index c2ad9db..a1c032e 100644
--- a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs
@@ -67,7 +67,7 @@ namespace OpenSim.Services.Connectors
67 IConfig authorizationConfig = source.Configs["AuthorizationService"]; 67 IConfig authorizationConfig = source.Configs["AuthorizationService"];
68 if (authorizationConfig == null) 68 if (authorizationConfig == null)
69 { 69 {
70 m_log.Error("[AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini"); 70 m_log.Info("[AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini");
71 throw new Exception("Authorization connector init error"); 71 throw new Exception("Authorization connector init error");
72 } 72 }
73 73
diff --git a/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs
index 20ea18f..cc1dfbf 100644
--- a/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs
@@ -38,10 +38,10 @@ namespace OpenSim.Tests.Common.Mock
38 /// mono addin plugin system starts co-operating with the unit test system. Currently no locking since unit 38 /// mono addin plugin system starts co-operating with the unit test system. Currently no locking since unit
39 /// tests are single threaded. 39 /// tests are single threaded.
40 /// </summary> 40 /// </summary>
41 public class TestAssetDataPlugin : BaseAssetRepository, IAssetDataPlugin 41 public class MockAssetDataPlugin : BaseAssetRepository, IAssetDataPlugin
42 { 42 {
43 public string Version { get { return "0"; } } 43 public string Version { get { return "0"; } }
44 public string Name { get { return "TestAssetDataPlugin"; } } 44 public string Name { get { return "MockAssetDataPlugin"; } }
45 45
46 public void Initialise() {} 46 public void Initialise() {}
47 public void Initialise(string connect) {} 47 public void Initialise(string connect) {}
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 27025d9..5f172c4 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -491,7 +491,7 @@ namespace OpenSim.Tests.Common.Mock
491 491
492 } 492 }
493 493
494 public void SendGenericMessage(string method, List<string> message) 494 public void SendGenericMessage(string method, List<byte[]> message)
495 { 495 {
496 496
497 } 497 }
diff --git a/bin/IronMath.dll b/bin/IronMath.dll
deleted file mode 100644
index 4960cc6..0000000
--- a/bin/IronMath.dll
+++ /dev/null
Binary files differ
diff --git a/bin/IronPython.dll b/bin/IronPython.dll
deleted file mode 100644
index 2efe7ef..0000000
--- a/bin/IronPython.dll
+++ /dev/null
Binary files differ
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index f9d9ca6..04cf8e8 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -91,7 +91,7 @@
91 91
92 ; Maximum total size, and maximum size where a prim can be physical 92 ; Maximum total size, and maximum size where a prim can be physical
93 NonPhysicalPrimMax = 256 93 NonPhysicalPrimMax = 256
94 PhysicalPrimMax = 10 94 PhysicalPrimMax = 10 ; (I think this was moved to the Regions.ini!)
95 ClampPrimSize = false 95 ClampPrimSize = false
96 96
97 ; Region crossing 97 ; Region crossing
@@ -342,7 +342,7 @@
342 342
343 ; The MessagingServer is a companion of the UserServer. It uses 343 ; The MessagingServer is a companion of the UserServer. It uses
344 ; user_send_key and user_recv_key, too 344 ; user_send_key and user_recv_key, too
345 ;messaging_server_url = "http://127.0.0.1:8006" 345 messaging_server_url = "http://127.0.0.1:8006"
346 346
347 ; What is reported as the "X-Secondlife-Shard" 347 ; What is reported as the "X-Secondlife-Shard"
348 ; Defaults to the user server url if not set 348 ; Defaults to the user server url if not set
@@ -597,6 +597,9 @@
597 body_motor_joint_maxforce_tensor_linux = 5 597 body_motor_joint_maxforce_tensor_linux = 5
598 body_motor_joint_maxforce_tensor_win = 5 598 body_motor_joint_maxforce_tensor_win = 5
599 599
600 ; Maximum mass an object can be before it is clamped
601 maximum_mass_object = 10000.01
602
600 ; ## 603 ; ##
601 ; ## Sculpted Prim settings 604 ; ## Sculpted Prim settings
602 ; ## 605 ; ##
@@ -822,6 +825,12 @@
822 ; default is 1000 825 ; default is 1000
823 cloud_update_rate = 1000 826 cloud_update_rate = 1000
824 827
828[Meta7Windlight]
829
830 ; This enables the transmission of Windlight scenes to supporting clients, such as the Meta7 viewer.
831 ; It has no ill effect on viewers which do not support server-side windlight settings.
832 ; Currently we only have support for MySQL databases.
833 enable_windlight = false;
825 834
826[Trees] 835[Trees]
827 ; Enable this to allow the tree module to manage your sim trees, including growing, reproducing and dying 836 ; Enable this to allow the tree module to manage your sim trees, including growing, reproducing and dying
@@ -971,6 +980,9 @@
971 980
972 ; Allow the use of os* functions (some are dangerous) 981 ; Allow the use of os* functions (some are dangerous)
973 AllowOSFunctions = false 982 AllowOSFunctions = false
983
984 ; Allow the user of Careminster functions
985 AllowCareminsterFunctions = false
974 986
975 ; Threat level to allow, one of None, VeryLow, Low, Moderate, High, VeryHigh, Severe 987 ; Threat level to allow, one of None, VeryLow, Low, Moderate, High, VeryHigh, Severe
976 OSFunctionThreatLevel = VeryLow 988 OSFunctionThreatLevel = VeryLow
@@ -1155,7 +1167,6 @@
1155 safemode = false 1167 safemode = false
1156 1168
1157[VivoxVoice] 1169[VivoxVoice]
1158
1159 ; The VivoxVoice module will allow you to provide voice on your 1170 ; The VivoxVoice module will allow you to provide voice on your
1160 ; region(s). It uses the same voice technology as the LL grid and 1171 ; region(s). It uses the same voice technology as the LL grid and
1161 ; works with recent LL clients (we have tested 1.22.9.110075, so 1172 ; works with recent LL clients (we have tested 1.22.9.110075, so
@@ -1296,6 +1307,15 @@
1296 RootReprioritizationDistance = 10.0 1307 RootReprioritizationDistance = 10.0
1297 ChildReprioritizationDistance = 20.0 1308 ChildReprioritizationDistance = 20.0
1298 1309
1310
1311[WebStats]
1312; View region statistics via a web page
1313; See http://opensimulator.org/wiki/FAQ#Region_Statistics_on_a_Web_Page
1314; Use a web browser and type in the "Login URI" + "/SStats/"
1315; For example- http://127.0.0.1:9000/SStats/
1316; enabled=false
1317
1318
1299;; 1319;;
1300;; These are defaults that are overwritten below in [Architecture]. 1320;; These are defaults that are overwritten below in [Architecture].
1301;; These defaults allow OpenSim to work out of the box with 1321;; These defaults allow OpenSim to work out of the box with
diff --git a/prebuild.xml b/prebuild.xml
index ad06938..9d428d1 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -1684,8 +1684,6 @@
1684 <Reference name="OpenMetaverseTypes.dll"/> 1684 <Reference name="OpenMetaverseTypes.dll"/>
1685 <Reference name="OpenMetaverse.StructuredData.dll"/> 1685 <Reference name="OpenMetaverse.StructuredData.dll"/>
1686 <Reference name="OpenMetaverse.dll"/> 1686 <Reference name="OpenMetaverse.dll"/>
1687 <Reference name="IronPython.dll"/>
1688 <Reference name="IronMath.dll"/>
1689 <Reference name="PumaCode.SvnDotNet.dll"/> 1687 <Reference name="PumaCode.SvnDotNet.dll"/>
1690 <Reference name="OpenSim.Framework"/> 1688 <Reference name="OpenSim.Framework"/>
1691 <Reference name="OpenSim.Framework.Communications"/> 1689 <Reference name="OpenSim.Framework.Communications"/>