aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/Scene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs137
1 files changed, 110 insertions, 27 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 46fc86b..b92f8c8 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -78,20 +78,23 @@ namespace OpenSim.Region.Environment.Scenes
78 protected StorageManager storageManager; 78 protected StorageManager storageManager;
79 protected AgentCircuitManager authenticateHandler; 79 protected AgentCircuitManager authenticateHandler;
80 protected RegionCommsListener regionCommsHost; 80 protected RegionCommsListener regionCommsHost;
81 protected CommunicationsManager commsManager; 81 public CommunicationsManager commsManager;
82 // protected XferManager xferManager; 82 // protected XferManager xferManager;
83 83
84 protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>(); 84 protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>();
85 protected BaseHttpServer httpListener; 85 protected BaseHttpServer httpListener;
86 86
87 protected Dictionary<string, IRegionModule> Modules = new Dictionary<string, IRegionModule>(); 87 protected Dictionary<string, IRegionModule> Modules = new Dictionary<string, IRegionModule>();
88 protected Dictionary<string, object> APIMethods = new Dictionary<string, object>(); 88 public Dictionary<Type, object> ModuleInterfaces = new Dictionary<Type, object>();
89 protected Dictionary<string, object> ModuleAPIMethods = new Dictionary<string, object>();
89 90
90 //API method Delegates 91 //API method Delegates and interfaces
91 92
92 // this most likely shouldn't be handled as a API method like this, but doing it for testing purposes 93 // this most likely shouldn't be handled as a API method like this, but doing it for testing purposes
93 public ModuleAPIMethod2<bool, string, byte[]>AddXferFile = null; 94 public ModuleAPIMethod2<bool, string, byte[]> AddXferFile = null;
94 95
96 private ISimChat m_simChatModule = null;
97
95 #region Properties 98 #region Properties
96 99
97 public AgentCircuitManager AuthenticateHandler 100 public AgentCircuitManager AuthenticateHandler
@@ -152,7 +155,7 @@ namespace OpenSim.Region.Environment.Scenes
152 AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, ModuleLoader moduleLoader) 155 AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, ModuleLoader moduleLoader)
153 { 156 {
154 updateLock = new Mutex(false); 157 updateLock = new Mutex(false);
155 158
156 m_moduleLoader = moduleLoader; 159 m_moduleLoader = moduleLoader;
157 authenticateHandler = authen; 160 authenticateHandler = authen;
158 commsManager = commsMan; 161 commsManager = commsMan;
@@ -169,9 +172,6 @@ namespace OpenSim.Region.Environment.Scenes
169 m_eventManager = new EventManager(); 172 m_eventManager = new EventManager();
170 m_permissionManager = new PermissionManager(this); 173 m_permissionManager = new PermissionManager(this);
171 174
172 MainLog.Instance.Verbose("Loading Region Modules");
173 m_moduleLoader.CreateDefaultModules(this);
174
175 m_eventManager.OnParcelPrimCountAdd += 175 m_eventManager.OnParcelPrimCountAdd +=
176 m_LandManager.addPrimToLandPrimCounts; 176 m_LandManager.addPrimToLandPrimCounts;
177 177
@@ -189,13 +189,15 @@ namespace OpenSim.Region.Environment.Scenes
189 189
190 httpListener = httpServer; 190 httpListener = httpServer;
191 191
192 SetMethodDelegates();
193 } 192 }
194 193
195 #endregion 194 #endregion
196 195
197 private void SetMethodDelegates() 196 public void SetModuleInterfaces()
198 { 197 {
198 m_simChatModule = this.RequestModuleInterface<ISimChat>();
199
200 //should change so it uses the module interface functions
199 AddXferFile = (ModuleAPIMethod2<bool, string, byte[]>)this.RequestAPIMethod("API_AddXferFile"); 201 AddXferFile = (ModuleAPIMethod2<bool, string, byte[]>)this.RequestAPIMethod("API_AddXferFile");
200 } 202 }
201 203
@@ -526,7 +528,7 @@ namespace OpenSim.Region.Environment.Scenes
526 MainLog.Instance.Verbose("Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)"); 528 MainLog.Instance.Verbose("Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)");
527 } 529 }
528 530
529 531
530 532
531 /// <summary> 533 /// <summary>
532 /// Returns a new unallocated primitive ID 534 /// Returns a new unallocated primitive ID
@@ -635,12 +637,12 @@ namespace OpenSim.Region.Environment.Scenes
635 //obj.RegenerateFullIDs(); 637 //obj.RegenerateFullIDs();
636 AddEntity(obj); 638 AddEntity(obj);
637 639
638 SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); 640 SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
639 rootPart.PhysActor = phyScene.AddPrim( 641 rootPart.PhysActor = phyScene.AddPrim(
640 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, rootPart.AbsolutePosition.Z), 642 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, rootPart.AbsolutePosition.Z),
641 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), 643 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
642 new Axiom.Math.Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, 644 new Axiom.Math.Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
643 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); 645 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z));
644 primCount++; 646 primCount++;
645 } 647 }
646 } 648 }
@@ -692,7 +694,7 @@ namespace OpenSim.Region.Environment.Scenes
692 694
693 protected virtual void SubscribeToClientEvents(IClientAPI client) 695 protected virtual void SubscribeToClientEvents(IClientAPI client)
694 { 696 {
695 // client.OnStartAnim += StartAnimation; 697 // client.OnStartAnim += StartAnimation;
696 client.OnRegionHandShakeReply += SendLayerData; 698 client.OnRegionHandShakeReply += SendLayerData;
697 //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); 699 //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims);
698 client.OnModifyTerrain += ModifyTerrain; 700 client.OnModifyTerrain += ModifyTerrain;
@@ -742,7 +744,7 @@ namespace OpenSim.Region.Environment.Scenes
742 client.OnRezScript += RezScript; 744 client.OnRezScript += RezScript;
743 client.OnRemoveTaskItem += RemoveTaskInventory; 745 client.OnRemoveTaskItem += RemoveTaskInventory;
744 746
745 // client.OnRequestAvatarProperties += RequestAvatarProperty; 747 // client.OnRequestAvatarProperties += RequestAvatarProperty;
746 748
747 client.OnGrabObject += ProcessObjectGrab; 749 client.OnGrabObject += ProcessObjectGrab;
748 750
@@ -1071,13 +1073,12 @@ namespace OpenSim.Region.Environment.Scenes
1071 AgentCircuitData agent = remoteClient.RequestClientInfo(); 1073 AgentCircuitData agent = remoteClient.RequestClientInfo();
1072 agent.BaseFolder = LLUUID.Zero; 1074 agent.BaseFolder = LLUUID.Zero;
1073 agent.InventoryFolder = LLUUID.Zero; 1075 agent.InventoryFolder = LLUUID.Zero;
1074 // agent.startpos = new LLVector3(128, 128, 70); 1076 // agent.startpos = new LLVector3(128, 128, 70);
1075 agent.startpos = position; 1077 agent.startpos = position;
1076 agent.child = true; 1078 agent.child = true;
1077 commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent); 1079 commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent);
1078 commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position, false); 1080 commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position, false);
1079 1081
1080 //TODO: following line is hard coded to port 9000, really need to change this as soon as possible
1081 AgentCircuitData circuitdata = remoteClient.RequestClientInfo(); 1082 AgentCircuitData circuitdata = remoteClient.RequestClientInfo();
1082 string capsPath = Util.GetCapsURL(remoteClient.AgentId); 1083 string capsPath = Util.GetCapsURL(remoteClient.AgentId);
1083 remoteClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), capsPath); 1084 remoteClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), capsPath);
@@ -1114,23 +1115,45 @@ namespace OpenSim.Region.Environment.Scenes
1114 } 1115 }
1115 } 1116 }
1116 1117
1118 //following delegate methods will be removed, so use the interface methods (below these)
1117 public void RegisterAPIMethod(string name, object method) 1119 public void RegisterAPIMethod(string name, object method)
1118 { 1120 {
1119 if (!this.APIMethods.ContainsKey(name)) 1121 if (!this.ModuleAPIMethods.ContainsKey(name))
1120 { 1122 {
1121 this.APIMethods.Add(name, method); 1123 this.ModuleAPIMethods.Add(name, method);
1122 } 1124 }
1123 } 1125 }
1124 1126
1125 public object RequestAPIMethod(string name) 1127 public object RequestAPIMethod(string name)
1126 { 1128 {
1127 if (this.APIMethods.ContainsKey(name)) 1129 if (this.ModuleAPIMethods.ContainsKey(name))
1128 { 1130 {
1129 return APIMethods[name]; 1131 return ModuleAPIMethods[name];
1130 } 1132 }
1131 return false; 1133 return false;
1132 } 1134 }
1133 1135
1136 public void RegisterModuleInterface<M>( M mod)
1137 {
1138 //Console.WriteLine("registering module interface " + typeof(M));
1139 if (!this.ModuleInterfaces.ContainsKey(typeof(M)))
1140 {
1141 ModuleInterfaces.Add(typeof(M), mod);
1142 }
1143 }
1144
1145 public T RequestModuleInterface<T>()
1146 {
1147 if (ModuleInterfaces.ContainsKey(typeof(T)))
1148 {
1149 return (T)ModuleInterfaces[typeof(T)];
1150 }
1151 else
1152 {
1153 return default(T);
1154 }
1155 }
1156
1134 public void SetTimePhase(int phase) 1157 public void SetTimePhase(int phase)
1135 { 1158 {
1136 m_timePhase = phase; 1159 m_timePhase = phase;
@@ -1205,6 +1228,49 @@ namespace OpenSim.Region.Environment.Scenes
1205 } 1228 }
1206 #endregion 1229 #endregion
1207 1230
1231 public void ProcessConsoleCmd(string command, string[] cmdparams)
1232 {
1233 switch (command)
1234 {
1235 case "save-xml":
1236 if (cmdparams.Length > 0)
1237 {
1238 SavePrimsToXml(cmdparams[0]);
1239 }
1240 else
1241 {
1242 SavePrimsToXml("test.xml");
1243 }
1244 break;
1245
1246 case "load-xml":
1247 if (cmdparams.Length > 0)
1248 {
1249 LoadPrimsFromXml(cmdparams[0]);
1250 }
1251 else
1252 {
1253 LoadPrimsFromXml("test.xml");
1254 }
1255 break;
1256
1257 case "set-time":
1258 break;
1259
1260 case "backup":
1261 Backup();
1262 break;
1263
1264 case "alert":
1265 HandleAlertCommand(cmdparams);
1266 break;
1267
1268 default:
1269 MainLog.Instance.Error("Unknown command: " + command);
1270 break;
1271 }
1272 }
1273
1208 #region Script Engine 1274 #region Script Engine
1209 private List<OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface> ScriptEngines = new List<OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface>(); 1275 private List<OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface> ScriptEngines = new List<OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface>();
1210 public void AddScriptEngine(OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface ScriptEngine, LogBase m_logger) 1276 public void AddScriptEngine(OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface ScriptEngine, LogBase m_logger)
@@ -1248,5 +1314,22 @@ namespace OpenSim.Region.Environment.Scenes
1248 } 1314 }
1249 return null; 1315 return null;
1250 } 1316 }
1317
1318 public SceneObjectPart GetSceneObjectPart(LLUUID fullID)
1319 {
1320 bool hasPrim = false;
1321 foreach (EntityBase ent in Entities.Values)
1322 {
1323 if (ent is SceneObjectGroup)
1324 {
1325 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(fullID);
1326 if (hasPrim != false)
1327 {
1328 return ((SceneObjectGroup)ent).GetChildPart(fullID);
1329 }
1330 }
1331 }
1332 return null;
1333 }
1251 } 1334 }
1252} 1335}