aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/GridManager.cs
diff options
context:
space:
mode:
authorMW2007-02-04 11:36:35 +0000
committerMW2007-02-04 11:36:35 +0000
commit8c80d98252f376a815e522c705a3c576dfc16f75 (patch)
tree89e779435d3e9ea2a58b814d81a64e44e4067cc6 /GridManager.cs
parentBasic Inventory support and clean up (diff)
downloadopensim-SC-8c80d98252f376a815e522c705a3c576dfc16f75.zip
opensim-SC-8c80d98252f376a815e522c705a3c576dfc16f75.tar.gz
opensim-SC-8c80d98252f376a815e522c705a3c576dfc16f75.tar.bz2
opensim-SC-8c80d98252f376a815e522c705a3c576dfc16f75.tar.xz
Clean up
Diffstat (limited to '')
-rw-r--r--GridManager.cs226
1 files changed, 113 insertions, 113 deletions
diff --git a/GridManager.cs b/GridManager.cs
index c6b7c49..c52bd51 100644
--- a/GridManager.cs
+++ b/GridManager.cs
@@ -44,21 +44,21 @@ namespace OpenSim
44 /// </summary> 44 /// </summary>
45 public class GridManager 45 public class GridManager
46 { 46 {
47 private Server server; 47 private Server _server;
48 private System.Text.Encoding enc = System.Text.Encoding.ASCII; 48 private System.Text.Encoding _enc = System.Text.Encoding.ASCII;
49 private AgentManager AgentManager; 49 private AgentManager _agentManager;
50 private Dictionary<ulong,RegionInfo> Grid; 50 public Dictionary<ulong,RegionInfo> Grid;
51 51
52 /// <summary> 52 /// <summary>
53 /// 53 ///
54 /// </summary> 54 /// </summary>
55 /// <param name="serve"></param> 55 /// <param name="serve"></param>
56 /// <param name="agentManager"></param> 56 /// <param name="agentManager"></param>
57 public GridManager(Server serve, AgentManager agentManager) 57 public GridManager(Server server, AgentManager agentManager)
58 { 58 {
59 Grid=new Dictionary<ulong, RegionInfo>(); 59 Grid = new Dictionary<ulong, RegionInfo>();
60 server=serve; 60 _server = server;
61 AgentManager=agentManager; 61 _agentManager = agentManager;
62 LoadGrid(); 62 LoadGrid();
63 } 63 }
64 64
@@ -66,20 +66,20 @@ namespace OpenSim
66 /// 66 ///
67 /// </summary> 67 /// </summary>
68 /// <param name="UserInfo"></param> 68 /// <param name="UserInfo"></param>
69 public void RequestMapLayer(User_Agent_info UserInfo) 69 public void RequestMapLayer(UserAgentInfo userInfo)
70 { 70 {
71 //send a layer covering the 800,800 - 1200,1200 area 71 //send a layer covering the 800,800 - 1200,1200 area
72 MapLayerReplyPacket MapReply=new MapLayerReplyPacket(); 72 MapLayerReplyPacket MapReply = new MapLayerReplyPacket();
73 MapReply.AgentData.AgentID=UserInfo.AgentID; 73 MapReply.AgentData.AgentID = userInfo.AgentID;
74 MapReply.AgentData.Flags=0; 74 MapReply.AgentData.Flags = 0;
75 MapReply.LayerData=new MapLayerReplyPacket.LayerDataBlock[1]; 75 MapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
76 MapReply.LayerData[0]=new MapLayerReplyPacket.LayerDataBlock(); 76 MapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
77 MapReply.LayerData[0].Bottom=800; 77 MapReply.LayerData[0].Bottom = 800;
78 MapReply.LayerData[0].Left=800; 78 MapReply.LayerData[0].Left = 800;
79 MapReply.LayerData[0].Top=1200; 79 MapReply.LayerData[0].Top = 1200;
80 MapReply.LayerData[0].Right=1200; 80 MapReply.LayerData[0].Right = 1200;
81 MapReply.LayerData[0].ImageID=new LLUUID("00000000-0000-0000-7007-000000000006"); 81 MapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-7007-000000000006");
82 server.SendPacket(MapReply,true,UserInfo); 82 _server.SendPacket(MapReply, true, userInfo);
83 } 83 }
84 84
85 /// <summary> 85 /// <summary>
@@ -90,28 +90,28 @@ namespace OpenSim
90 /// <param name="MinY"></param> 90 /// <param name="MinY"></param>
91 /// <param name="MaxX"></param> 91 /// <param name="MaxX"></param>
92 /// <param name="MaxY"></param> 92 /// <param name="MaxY"></param>
93 public void RequestMapBlock(User_Agent_info UserInfo, int MinX, int MinY,int MaxX,int MaxY) 93 public void RequestMapBlock(UserAgentInfo userInfo, int minX, int minY,int maxX,int maxY)
94 { 94 {
95 foreach (KeyValuePair<ulong,RegionInfo> RegionPair in this.Grid) 95 foreach (KeyValuePair<ulong, RegionInfo> RegionPair in this.Grid)
96 { 96 {
97 //check Region is inside the requested area 97 //check Region is inside the requested area
98 RegionInfo Region=RegionPair.Value; 98 RegionInfo Region = RegionPair.Value;
99 if(((Region.X>MinX) && (Region.X<MaxX)) && ((Region.Y>MinY) && (Region.Y<MaxY))) 99 if(((Region.X > minX) && (Region.X < maxX)) && ((Region.Y > minY) && (Region.Y < maxY)))
100 { 100 {
101 MapBlockReplyPacket MapReply=new MapBlockReplyPacket(); 101 MapBlockReplyPacket MapReply = new MapBlockReplyPacket();
102 MapReply.AgentData.AgentID=UserInfo.AgentID; 102 MapReply.AgentData.AgentID = userInfo.AgentID;
103 MapReply.AgentData.Flags=0; 103 MapReply.AgentData.Flags = 0;
104 MapReply.Data=new MapBlockReplyPacket.DataBlock[1]; 104 MapReply.Data = new MapBlockReplyPacket.DataBlock[1];
105 MapReply.Data[0]=new MapBlockReplyPacket.DataBlock(); 105 MapReply.Data[0] = new MapBlockReplyPacket.DataBlock();
106 MapReply.Data[0].MapImageID=Region.ImageID; 106 MapReply.Data[0].MapImageID = Region.ImageID;
107 MapReply.Data[0].X=Region.X; 107 MapReply.Data[0].X = Region.X;
108 MapReply.Data[0].Y=Region.Y; 108 MapReply.Data[0].Y = Region.Y;
109 MapReply.Data[0].WaterHeight=Region.WaterHeight; 109 MapReply.Data[0].WaterHeight = Region.WaterHeight;
110 MapReply.Data[0].Name=enc.GetBytes( Region.Name); 110 MapReply.Data[0].Name = _enc.GetBytes( Region.Name);
111 MapReply.Data[0].RegionFlags=72458694; 111 MapReply.Data[0].RegionFlags = 72458694;
112 MapReply.Data[0].Access=13; 112 MapReply.Data[0].Access = 13;
113 MapReply.Data[0].Agents=1; 113 MapReply.Data[0].Agents = 1;
114 server.SendPacket(MapReply,true,UserInfo); 114 _server.SendPacket(MapReply, true, userInfo);
115 } 115 }
116 } 116 }
117 117
@@ -122,35 +122,35 @@ namespace OpenSim
122 /// </summary> 122 /// </summary>
123 /// <param name="UserInfo"></param> 123 /// <param name="UserInfo"></param>
124 /// <param name="Request"></param> 124 /// <param name="Request"></param>
125 public void RequestTeleport(User_Agent_info UserInfo, TeleportLocationRequestPacket Request) 125 public void RequestTeleport(UserAgentInfo userInfo, TeleportLocationRequestPacket request)
126 { 126 {
127 if(Grid.ContainsKey(Request.Info.RegionHandle)) 127 if(Grid.ContainsKey(request.Info.RegionHandle))
128 { 128 {
129 RegionInfo Region=Grid[Request.Info.RegionHandle]; 129 RegionInfo Region = Grid[request.Info.RegionHandle];
130 libsecondlife.Packets.TeleportStartPacket TeleportStart=new TeleportStartPacket(); 130 libsecondlife.Packets.TeleportStartPacket TeleportStart = new TeleportStartPacket();
131 TeleportStart.Info.TeleportFlags=16; 131 TeleportStart.Info.TeleportFlags = 16;
132 server.SendPacket(TeleportStart,true,UserInfo); 132 _server.SendPacket(TeleportStart, true, userInfo);
133 133
134 libsecondlife.Packets.TeleportFinishPacket Teleport=new TeleportFinishPacket(); 134 libsecondlife.Packets.TeleportFinishPacket Teleport = new TeleportFinishPacket();
135 Teleport.Info.AgentID=UserInfo.AgentID; 135 Teleport.Info.AgentID = userInfo.AgentID;
136 Teleport.Info.RegionHandle=Request.Info.RegionHandle; 136 Teleport.Info.RegionHandle = request.Info.RegionHandle;
137 Teleport.Info.SimAccess=13; 137 Teleport.Info.SimAccess = 13;
138 Teleport.Info.SeedCapability=new byte[0]; 138 Teleport.Info.SeedCapability = new byte[0];
139 139
140 System.Net.IPAddress oIP=System.Net.IPAddress.Parse(Region.IPAddress.Address); 140 System.Net.IPAddress oIP = System.Net.IPAddress.Parse(Region.IPAddress.Address);
141 byte[] byteIP=oIP.GetAddressBytes(); 141 byte[] byteIP = oIP.GetAddressBytes();
142 uint ip=(uint)byteIP[3]<<24; 142 uint ip=(uint)byteIP[3]<<24;
143 ip+=(uint)byteIP[2]<<16; 143 ip+=(uint)byteIP[2]<<16;
144 ip+=(uint)byteIP[1]<<8; 144 ip+=(uint)byteIP[1]<<8;
145 ip+=(uint)byteIP[0]; 145 ip+=(uint)byteIP[0];
146 146
147 Teleport.Info.SimIP=ip; 147 Teleport.Info.SimIP = ip;
148 Teleport.Info.SimPort=Region.IPAddress.Port; 148 Teleport.Info.SimPort = Region.IPAddress.Port;
149 Teleport.Info.LocationID=4; 149 Teleport.Info.LocationID = 4;
150 Teleport.Info.TeleportFlags= 1 << 4;; 150 Teleport.Info.TeleportFlags = 1 << 4;;
151 server.SendPacket(Teleport,true,UserInfo); 151 _server.SendPacket(Teleport, true, userInfo);
152 152
153 this.AgentManager.RemoveAgent(UserInfo); 153 this._agentManager.RemoveAgent(userInfo);
154 } 154 }
155 155
156 } 156 }
@@ -162,13 +162,13 @@ namespace OpenSim
162 { 162 {
163 //should connect to a space server to see what grids there are 163 //should connect to a space server to see what grids there are
164 //but for now we read static xml files 164 //but for now we read static xml files
165 ulong CurrentHandle=0; 165 ulong CurrentHandle = 0;
166 bool Login=true; 166 bool Login = true;
167 167
168 XmlDocument doc = new XmlDocument(); 168 XmlDocument doc = new XmlDocument();
169 169
170 try { 170 try {
171 doc.Load(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory,"Grid.ini" )); 171 doc.Load(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Grid.ini" ));
172 } 172 }
173 catch ( Exception e) 173 catch ( Exception e)
174 { 174 {
@@ -189,102 +189,102 @@ namespace OpenSim
189 if (nodes.HasChildNodes) { 189 if (nodes.HasChildNodes) {
190 foreach( XmlNode xmlnc in nodes.ChildNodes) 190 foreach( XmlNode xmlnc in nodes.ChildNodes)
191 { 191 {
192 if(xmlnc.Name=="Region") 192 if(xmlnc.Name == "Region")
193 { 193 {
194 string xmlAttri; 194 string xmlAttri;
195 RegionInfo Region=new RegionInfo(); 195 RegionInfo Region = new RegionInfo();
196 if(xmlnc.Attributes["Name"]!=null) 196 if(xmlnc.Attributes["Name"] != null)
197 { 197 {
198 xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("Name")).Value; 198 xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("Name")).Value;
199 Region.Name=xmlAttri+" \0"; 199 Region.Name = xmlAttri+" \0";
200 } 200 }
201 if(xmlnc.Attributes["ImageID"]!=null) 201 if(xmlnc.Attributes["ImageID"] != null)
202 { 202 {
203 xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("ImageID")).Value; 203 xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("ImageID")).Value;
204 Region.ImageID=new LLUUID(xmlAttri); 204 Region.ImageID = new LLUUID(xmlAttri);
205 } 205 }
206 if(xmlnc.Attributes["IP_Address"]!=null) 206 if(xmlnc.Attributes["IP_Address"] != null)
207 { 207 {
208 xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("IP_Address")).Value; 208 xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("IP_Address")).Value;
209 Region.IPAddress.Address=xmlAttri; 209 Region.IPAddress.Address = xmlAttri;
210 } 210 }
211 if(xmlnc.Attributes["IP_Port"]!=null) 211 if(xmlnc.Attributes["IP_Port"] != null)
212 { 212 {
213 xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("IP_Port")).Value; 213 xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("IP_Port")).Value;
214 Region.IPAddress.Port=Convert.ToUInt16(xmlAttri); 214 Region.IPAddress.Port = Convert.ToUInt16(xmlAttri);
215 } 215 }
216 if(xmlnc.Attributes["Location_X"]!=null) 216 if(xmlnc.Attributes["Location_X"] != null)
217 { 217 {
218 xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("Location_X")).Value; 218 xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("Location_X")).Value;
219 Region.X=Convert.ToUInt16(xmlAttri); 219 Region.X = Convert.ToUInt16(xmlAttri);
220 } 220 }
221 if(xmlnc.Attributes["Location_Y"]!=null) 221 if(xmlnc.Attributes["Location_Y"] != null)
222 { 222 {
223 xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("Location_Y")).Value; 223 xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("Location_Y")).Value;
224 Region.Y=Convert.ToUInt16(xmlAttri); 224 Region.Y = Convert.ToUInt16(xmlAttri);
225 } 225 }
226 226
227 this.Grid.Add(Region.Handle,Region); 227 this.Grid.Add(Region.Handle, Region);
228 228
229 } 229 }
230 if(xmlnc.Name=="CurrentRegion") 230 if(xmlnc.Name == "CurrentRegion")
231 { 231 {
232 232
233 string xmlAttri; 233 string xmlAttri;
234 uint Rx=0,Ry=0; 234 uint Rx = 0, Ry = 0;
235 if(xmlnc.Attributes["RegionHandle"]!=null) 235 if(xmlnc.Attributes["RegionHandle"] != null)
236 { 236 {
237 xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("RegionHandle")).Value; 237 xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("RegionHandle")).Value;
238 CurrentHandle=Convert.ToUInt64(xmlAttri); 238 CurrentHandle = Convert.ToUInt64(xmlAttri);
239 239
240 } 240 }
241 else 241 else
242 { 242 {
243 if(xmlnc.Attributes["Region_X"]!=null) 243 if(xmlnc.Attributes["Region_X"] != null)
244 { 244 {
245 xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("Region_X")).Value; 245 xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("Region_X")).Value;
246 Rx=Convert.ToUInt32(xmlAttri); 246 Rx = Convert.ToUInt32(xmlAttri);
247 } 247 }
248 if(xmlnc.Attributes["Region_Y"]!=null) 248 if(xmlnc.Attributes["Region_Y"] != null)
249 { 249 {
250 xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("Region_Y")).Value; 250 xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("Region_Y")).Value;
251 Ry=Convert.ToUInt32(xmlAttri); 251 Ry = Convert.ToUInt32(xmlAttri);
252 } 252 }
253 } 253 }
254 if(xmlnc.Attributes["LoginServer"]!=null) 254 if(xmlnc.Attributes["LoginServer"] != null)
255 { 255 {
256 xmlAttri=((XmlAttribute)xmlnc.Attributes.GetNamedItem("LoginServer")).Value; 256 xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("LoginServer")).Value;
257 Login=Convert.ToBoolean(xmlAttri); 257 Login = Convert.ToBoolean(xmlAttri);
258 258
259 } 259 }
260 if(CurrentHandle==0) 260 if(CurrentHandle == 0)
261 { 261 {
262 //no RegionHandle set 262 //no RegionHandle set
263 //so check for Region X and Y 263 //so check for Region X and Y
264 if((Rx >0) && (Ry>0)) 264 if((Rx > 0) && (Ry > 0))
265 { 265 {
266 CurrentHandle=Helpers.UIntsToLong((Rx*256),(Ry*256)); 266 CurrentHandle = Helpers.UIntsToLong((Rx*256), (Ry*256));
267 } 267 }
268 else 268 else
269 { 269 {
270 //seems to be no Region location set 270 //seems to be no Region location set
271 // so set default 271 // so set default
272 CurrentHandle=1096213093147648; 272 CurrentHandle = 1096213093147648;
273 } 273 }
274 } 274 }
275 } 275 }
276 } 276 }
277 277
278 //finished loading grid, now set Globals to current region 278 //finished loading grid, now set Globals to current region
279 if(CurrentHandle!=0) 279 if(CurrentHandle != 0)
280 { 280 {
281 if(Grid.ContainsKey(CurrentHandle)) 281 if(Grid.ContainsKey(CurrentHandle))
282 { 282 {
283 RegionInfo Region=Grid[CurrentHandle]; 283 RegionInfo Region = Grid[CurrentHandle];
284 Globals.Instance.RegionHandle=Region.Handle; 284 Globals.Instance.RegionHandle = Region.Handle;
285 Globals.Instance.RegionName=Region.Name; 285 Globals.Instance.RegionName = Region.Name;
286 Globals.Instance.IpPort=Region.IPAddress.Port; 286 Globals.Instance.IpPort = Region.IPAddress.Port;
287 Globals.Instance.LoginSever=Login; 287 Globals.Instance.LoginSever = Login;
288 } 288 }
289 } 289 }
290 290
@@ -317,8 +317,8 @@ namespace OpenSim
317 } 317 }
318 set 318 set
319 { 319 {
320 x=value; 320 x = value;
321 Handle=Helpers.UIntsToLong((((uint)x)*256),(((uint)y)*256)); 321 Handle = Helpers.UIntsToLong((((uint)x)*256), (((uint)y)*256));
322 } 322 }
323 } 323 }
324 public ushort Y 324 public ushort Y
@@ -329,33 +329,33 @@ namespace OpenSim
329 } 329 }
330 set 330 set
331 { 331 {
332 y=value; 332 y = value;
333 Handle=Helpers.UIntsToLong((((uint)x)*256),(((uint)y)*256)); 333 Handle = Helpers.UIntsToLong((((uint)x)*256), (((uint)y)*256));
334 } 334 }
335 } 335 }
336 public ulong Handle 336 public ulong Handle
337 { 337 {
338 get 338 get
339 { 339 {
340 if(handle>0) 340 if(handle > 0)
341 { 341 {
342 return(handle); 342 return(handle);
343 } 343 }
344 else 344 else
345 { 345 {
346 return(Helpers.UIntsToLong((((uint)x)*256),(((uint)y)*256))); 346 return(Helpers.UIntsToLong((((uint)x)*256), (((uint)y)*256)));
347 } 347 }
348 } 348 }
349 set 349 set
350 { 350 {
351 handle=value; 351 handle = value;
352 } 352 }
353 353
354 } 354 }
355 355
356 public RegionInfo() 356 public RegionInfo()
357 { 357 {
358 this.IPAddress=new RegionIP(); 358 this.IPAddress = new RegionIP();
359 } 359 }
360 } 360 }
361 public class RegionIP 361 public class RegionIP