diff options
Diffstat (limited to 'OpenSim/Services/GridService/GridService.cs')
-rw-r--r-- | OpenSim/Services/GridService/GridService.cs | 99 |
1 files changed, 48 insertions, 51 deletions
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index ee3b858..aab403a 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -137,25 +137,20 @@ namespace OpenSim.Services.GridService | |||
137 | if (regionInfos.RegionID == UUID.Zero) | 137 | if (regionInfos.RegionID == UUID.Zero) |
138 | return "Invalid RegionID - cannot be zero UUID"; | 138 | return "Invalid RegionID - cannot be zero UUID"; |
139 | 139 | ||
140 | // This needs better sanity testing. What if regionInfo is registering in | ||
141 | // overlapping coords? | ||
140 | RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); | 142 | RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); |
141 | if ((region != null) && (region.RegionID != regionInfos.RegionID)) | ||
142 | { | ||
143 | m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", | ||
144 | regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); | ||
145 | return "Region overlaps another region"; | ||
146 | } | ||
147 | |||
148 | if (region != null) | 143 | if (region != null) |
149 | { | 144 | { |
150 | // There is a preexisting record | 145 | // There is a preexisting record |
151 | // | 146 | // |
152 | // Get it's flags | 147 | // Get it's flags |
153 | // | 148 | // |
154 | OpenSim.Framework.RegionFlags rflags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(region.Data["flags"]); | 149 | OpenSim.Data.RegionFlags rflags = (OpenSim.Data.RegionFlags)Convert.ToInt32(region.Data["flags"]); |
155 | 150 | ||
156 | // Is this a reservation? | 151 | // Is this a reservation? |
157 | // | 152 | // |
158 | if ((rflags & OpenSim.Framework.RegionFlags.Reservation) != 0) | 153 | if ((rflags & OpenSim.Data.RegionFlags.Reservation) != 0) |
159 | { | 154 | { |
160 | // Regions reserved for the null key cannot be taken. | 155 | // Regions reserved for the null key cannot be taken. |
161 | if ((string)region.Data["PrincipalID"] == UUID.Zero.ToString()) | 156 | if ((string)region.Data["PrincipalID"] == UUID.Zero.ToString()) |
@@ -166,10 +161,10 @@ namespace OpenSim.Services.GridService | |||
166 | // NOTE: Fudging the flags value here, so these flags | 161 | // NOTE: Fudging the flags value here, so these flags |
167 | // should not be used elsewhere. Don't optimize | 162 | // should not be used elsewhere. Don't optimize |
168 | // this with the later retrieval of the same flags! | 163 | // this with the later retrieval of the same flags! |
169 | rflags |= OpenSim.Framework.RegionFlags.Authenticate; | 164 | rflags |= OpenSim.Data.RegionFlags.Authenticate; |
170 | } | 165 | } |
171 | 166 | ||
172 | if ((rflags & OpenSim.Framework.RegionFlags.Authenticate) != 0) | 167 | if ((rflags & OpenSim.Data.RegionFlags.Authenticate) != 0) |
173 | { | 168 | { |
174 | // Can we authenticate at all? | 169 | // Can we authenticate at all? |
175 | // | 170 | // |
@@ -181,36 +176,19 @@ namespace OpenSim.Services.GridService | |||
181 | } | 176 | } |
182 | } | 177 | } |
183 | 178 | ||
184 | // If we get here, the destination is clear. Now for the real check. | 179 | if ((region != null) && (region.RegionID != regionInfos.RegionID)) |
185 | |||
186 | if (!m_AllowDuplicateNames) | ||
187 | { | 180 | { |
188 | List<RegionData> dupe = m_Database.Get(regionInfos.RegionName, scopeID); | 181 | m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", |
189 | if (dupe != null && dupe.Count > 0) | 182 | regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); |
190 | { | 183 | return "Region overlaps another region"; |
191 | foreach (RegionData d in dupe) | ||
192 | { | ||
193 | if (d.RegionID != regionInfos.RegionID) | ||
194 | { | ||
195 | m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register duplicate name with ID {1}.", | ||
196 | regionInfos.RegionName, regionInfos.RegionID); | ||
197 | return "Duplicate region name"; | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | } | 184 | } |
202 | 185 | ||
203 | // If there is an old record for us, delete it if it is elsewhere. | ||
204 | region = m_Database.Get(regionInfos.RegionID, scopeID); | ||
205 | if ((region != null) && (region.RegionID == regionInfos.RegionID) && | 186 | if ((region != null) && (region.RegionID == regionInfos.RegionID) && |
206 | ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) | 187 | ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) |
207 | { | 188 | { |
208 | if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.NoMove) != 0) | 189 | if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.NoMove) != 0) |
209 | return "Can't move this region"; | 190 | return "Can't move this region"; |
210 | 191 | ||
211 | if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.LockedOut) != 0) | ||
212 | return "Region locked out"; | ||
213 | |||
214 | // Region reregistering in other coordinates. Delete the old entry | 192 | // Region reregistering in other coordinates. Delete the old entry |
215 | m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", | 193 | m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", |
216 | regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); | 194 | regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); |
@@ -225,6 +203,23 @@ namespace OpenSim.Services.GridService | |||
225 | } | 203 | } |
226 | } | 204 | } |
227 | 205 | ||
206 | if (!m_AllowDuplicateNames) | ||
207 | { | ||
208 | List<RegionData> dupe = m_Database.Get(regionInfos.RegionName, scopeID); | ||
209 | if (dupe != null && dupe.Count > 0) | ||
210 | { | ||
211 | foreach (RegionData d in dupe) | ||
212 | { | ||
213 | if (d.RegionID != regionInfos.RegionID) | ||
214 | { | ||
215 | m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register duplicate name with ID {1}.", | ||
216 | regionInfos.RegionName, regionInfos.RegionID); | ||
217 | return "Duplicate region name"; | ||
218 | } | ||
219 | } | ||
220 | } | ||
221 | } | ||
222 | |||
228 | // Everything is ok, let's register | 223 | // Everything is ok, let's register |
229 | RegionData rdata = RegionInfo2RegionData(regionInfos); | 224 | RegionData rdata = RegionInfo2RegionData(regionInfos); |
230 | rdata.ScopeID = scopeID; | 225 | rdata.ScopeID = scopeID; |
@@ -232,8 +227,10 @@ namespace OpenSim.Services.GridService | |||
232 | if (region != null) | 227 | if (region != null) |
233 | { | 228 | { |
234 | int oldFlags = Convert.ToInt32(region.Data["flags"]); | 229 | int oldFlags = Convert.ToInt32(region.Data["flags"]); |
230 | if ((oldFlags & (int)OpenSim.Data.RegionFlags.LockedOut) != 0) | ||
231 | return "Region locked out"; | ||
235 | 232 | ||
236 | oldFlags &= ~(int)OpenSim.Framework.RegionFlags.Reservation; | 233 | oldFlags &= ~(int)OpenSim.Data.RegionFlags.Reservation; |
237 | 234 | ||
238 | rdata.Data["flags"] = oldFlags.ToString(); // Preserve flags | 235 | rdata.Data["flags"] = oldFlags.ToString(); // Preserve flags |
239 | } | 236 | } |
@@ -252,7 +249,7 @@ namespace OpenSim.Services.GridService | |||
252 | } | 249 | } |
253 | 250 | ||
254 | int flags = Convert.ToInt32(rdata.Data["flags"]); | 251 | int flags = Convert.ToInt32(rdata.Data["flags"]); |
255 | flags |= (int)OpenSim.Framework.RegionFlags.RegionOnline; | 252 | flags |= (int)OpenSim.Data.RegionFlags.RegionOnline; |
256 | rdata.Data["flags"] = flags.ToString(); | 253 | rdata.Data["flags"] = flags.ToString(); |
257 | 254 | ||
258 | try | 255 | try |
@@ -283,9 +280,9 @@ namespace OpenSim.Services.GridService | |||
283 | 280 | ||
284 | int flags = Convert.ToInt32(region.Data["flags"]); | 281 | int flags = Convert.ToInt32(region.Data["flags"]); |
285 | 282 | ||
286 | if (!m_DeleteOnUnregister || (flags & (int)OpenSim.Framework.RegionFlags.Persistent) != 0) | 283 | if (!m_DeleteOnUnregister || (flags & (int)OpenSim.Data.RegionFlags.Persistent) != 0) |
287 | { | 284 | { |
288 | flags &= ~(int)OpenSim.Framework.RegionFlags.RegionOnline; | 285 | flags &= ~(int)OpenSim.Data.RegionFlags.RegionOnline; |
289 | region.Data["flags"] = flags.ToString(); | 286 | region.Data["flags"] = flags.ToString(); |
290 | region.Data["last_seen"] = Util.UnixTimeSinceEpoch(); | 287 | region.Data["last_seen"] = Util.UnixTimeSinceEpoch(); |
291 | try | 288 | try |
@@ -320,7 +317,7 @@ namespace OpenSim.Services.GridService | |||
320 | if (rdata.RegionID != regionID) | 317 | if (rdata.RegionID != regionID) |
321 | { | 318 | { |
322 | int flags = Convert.ToInt32(rdata.Data["flags"]); | 319 | int flags = Convert.ToInt32(rdata.Data["flags"]); |
323 | if ((flags & (int)Framework.RegionFlags.Hyperlink) == 0) // no hyperlinks as neighbours | 320 | if ((flags & (int)Data.RegionFlags.Hyperlink) == 0) // no hyperlinks as neighbours |
324 | rinfos.Add(RegionData2RegionInfo(rdata)); | 321 | rinfos.Add(RegionData2RegionInfo(rdata)); |
325 | } | 322 | } |
326 | } | 323 | } |
@@ -470,7 +467,7 @@ namespace OpenSim.Services.GridService | |||
470 | 467 | ||
471 | foreach (RegionData r in regions) | 468 | foreach (RegionData r in regions) |
472 | { | 469 | { |
473 | if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.RegionOnline) != 0) | 470 | if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0) |
474 | ret.Add(RegionData2RegionInfo(r)); | 471 | ret.Add(RegionData2RegionInfo(r)); |
475 | } | 472 | } |
476 | 473 | ||
@@ -486,7 +483,7 @@ namespace OpenSim.Services.GridService | |||
486 | 483 | ||
487 | foreach (RegionData r in regions) | 484 | foreach (RegionData r in regions) |
488 | { | 485 | { |
489 | if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.RegionOnline) != 0) | 486 | if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0) |
490 | ret.Add(RegionData2RegionInfo(r)); | 487 | ret.Add(RegionData2RegionInfo(r)); |
491 | } | 488 | } |
492 | 489 | ||
@@ -502,7 +499,7 @@ namespace OpenSim.Services.GridService | |||
502 | 499 | ||
503 | foreach (RegionData r in regions) | 500 | foreach (RegionData r in regions) |
504 | { | 501 | { |
505 | if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.RegionOnline) != 0) | 502 | if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0) |
506 | ret.Add(RegionData2RegionInfo(r)); | 503 | ret.Add(RegionData2RegionInfo(r)); |
507 | } | 504 | } |
508 | 505 | ||
@@ -629,7 +626,7 @@ namespace OpenSim.Services.GridService | |||
629 | 626 | ||
630 | private void OutputRegionToConsole(RegionData r) | 627 | private void OutputRegionToConsole(RegionData r) |
631 | { | 628 | { |
632 | OpenSim.Framework.RegionFlags flags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(r.Data["flags"]); | 629 | OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); |
633 | 630 | ||
634 | ConsoleDisplayList dispList = new ConsoleDisplayList(); | 631 | ConsoleDisplayList dispList = new ConsoleDisplayList(); |
635 | dispList.AddRow("Region Name", r.RegionName); | 632 | dispList.AddRow("Region Name", r.RegionName); |
@@ -659,7 +656,7 @@ namespace OpenSim.Services.GridService | |||
659 | 656 | ||
660 | foreach (RegionData r in regions) | 657 | foreach (RegionData r in regions) |
661 | { | 658 | { |
662 | OpenSim.Framework.RegionFlags flags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(r.Data["flags"]); | 659 | OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); |
663 | dispTable.AddRow( | 660 | dispTable.AddRow( |
664 | r.RegionName, | 661 | r.RegionName, |
665 | r.RegionID.ToString(), | 662 | r.RegionID.ToString(), |
@@ -673,7 +670,7 @@ namespace OpenSim.Services.GridService | |||
673 | 670 | ||
674 | private int ParseFlags(int prev, string flags) | 671 | private int ParseFlags(int prev, string flags) |
675 | { | 672 | { |
676 | OpenSim.Framework.RegionFlags f = (OpenSim.Framework.RegionFlags)prev; | 673 | OpenSim.Data.RegionFlags f = (OpenSim.Data.RegionFlags)prev; |
677 | 674 | ||
678 | string[] parts = flags.Split(new char[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries); | 675 | string[] parts = flags.Split(new char[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries); |
679 | 676 | ||
@@ -685,18 +682,18 @@ namespace OpenSim.Services.GridService | |||
685 | { | 682 | { |
686 | if (p.StartsWith("+")) | 683 | if (p.StartsWith("+")) |
687 | { | 684 | { |
688 | val = (int)Enum.Parse(typeof(OpenSim.Framework.RegionFlags), p.Substring(1)); | 685 | val = (int)Enum.Parse(typeof(OpenSim.Data.RegionFlags), p.Substring(1)); |
689 | f |= (OpenSim.Framework.RegionFlags)val; | 686 | f |= (OpenSim.Data.RegionFlags)val; |
690 | } | 687 | } |
691 | else if (p.StartsWith("-")) | 688 | else if (p.StartsWith("-")) |
692 | { | 689 | { |
693 | val = (int)Enum.Parse(typeof(OpenSim.Framework.RegionFlags), p.Substring(1)); | 690 | val = (int)Enum.Parse(typeof(OpenSim.Data.RegionFlags), p.Substring(1)); |
694 | f &= ~(OpenSim.Framework.RegionFlags)val; | 691 | f &= ~(OpenSim.Data.RegionFlags)val; |
695 | } | 692 | } |
696 | else | 693 | else |
697 | { | 694 | { |
698 | val = (int)Enum.Parse(typeof(OpenSim.Framework.RegionFlags), p); | 695 | val = (int)Enum.Parse(typeof(OpenSim.Data.RegionFlags), p); |
699 | f |= (OpenSim.Framework.RegionFlags)val; | 696 | f |= (OpenSim.Data.RegionFlags)val; |
700 | } | 697 | } |
701 | } | 698 | } |
702 | catch (Exception) | 699 | catch (Exception) |
@@ -728,7 +725,7 @@ namespace OpenSim.Services.GridService | |||
728 | int flags = Convert.ToInt32(r.Data["flags"]); | 725 | int flags = Convert.ToInt32(r.Data["flags"]); |
729 | flags = ParseFlags(flags, cmd[4]); | 726 | flags = ParseFlags(flags, cmd[4]); |
730 | r.Data["flags"] = flags.ToString(); | 727 | r.Data["flags"] = flags.ToString(); |
731 | OpenSim.Framework.RegionFlags f = (OpenSim.Framework.RegionFlags)flags; | 728 | OpenSim.Data.RegionFlags f = (OpenSim.Data.RegionFlags)flags; |
732 | 729 | ||
733 | MainConsole.Instance.Output(String.Format("Set region {0} to {1}", r.RegionName, f)); | 730 | MainConsole.Instance.Output(String.Format("Set region {0} to {1}", r.RegionName, f)); |
734 | m_Database.Store(r); | 731 | m_Database.Store(r); |