internal void AddPlayer(string residentPlayer, string newResident, RegionList region) { Residents.Add(newResident); RegionLoader.Save(region); Log.WritePlayer(residentPlayer, "Region added resident " + newResident); Client nr = PlayerList.GetPlayerByName(newResident); if (nr != null) { nr.TellSystem(Chat.Aqua, residentPlayer + " added you to " + Name); RegionCrossing.SetRegion(nr.Session); } }
void ReceiverRunClientWrapper() { try { ReceiverRunClient(); } catch (ThreadInterruptedException) { return; } #if !DEBUG catch (Exception e) { Log.Write(e, this); } #endif finally { #if DEBUG Console.WriteLine("ClientReceiver Ended: " + this); #endif clientThread.State = "Finally closing down 0"; Phase = Phases.FinalClose; SetWorld(World.Void); clientThread.State = "Finally closing down 1"; SaveProxyPlayer(); clientThread.State = "Finally closing down 2"; PlayerList.LogoutPlayer(this); clientThread.State = "Finally closing down 3"; RegionCrossing.ClearRegion(this); clientThread.State = "Finally closing down 4"; socket.Close(); clientThread.State = "Finally closing down 5"; //clientStream.Flush(); clientStream.Close(); clientThread.State = "Finally closing down -all done"; } }
/// <summary> /// Change the region protection type /// </summary> public void SetType(Client player, string type) { if (ResidentPermissions(player) == false) { player.TellSystem(Chat.Yellow, " You are not a resident of this region"); return; } type = type.ToLowerInvariant().Trim(); switch (type) { case "": //public case PublicType.Type: case Protected.Type: case Adventure.Type: case SpawnRegion.Type: break; //OK default: if (player.Admin() == false) { player.TellSystem(Chat.Red, "Unknown type: " + type); player.TellSystem(Chat.Yellow, "Choose one of: public, protected, adventure, night"); return; } else { player.TellSystem(Chat.Yellow, "Custom type: " + type); } break; } Type = type; player.TellSystem(Chat.Aqua, "Region type is now: " + type); RegionLoader.Save(player.Session.World.Regions); //Update all players foreach (Client c in PlayerList.List) { if (c.Session.CurrentRegion == this) { RegionCrossing.SetRegion(c.Session); } } }
public void Resize(int minX, int maxX, int minY, int maxY, int minZ, int maxZ, Client player) { RegionList regions = player.Session.World.Regions; Region test = new Region(minX, maxX, minY, maxY, minZ, maxZ); WorldRegion parent = RegionCrossing.GetParentRegion(regions.List, this); if (parent == null) { player.TellSystem(Chat.Red, "parent not found"); return; } if (player.Admin() == false) { if ((Donors.IsDonor(player) == false)) { player.TellSystem(Chat.Aqua, "Only for donors and admins may resize a region"); return; } //Useless since when only donors get this far: if (minY < 50 && (!player.Donor)) { player.TellSystem(Chat.Red, "Only admins and donors may make regions below Y=50"); return; } if (ResidentPermissions(player) == false) { player.TellSystem(Chat.Yellow, "You are not a resident of this region"); return; } if (parent.ResidentPermissions(player) == false) { player.TellSystem(Chat.Yellow, "You are not a resident of the parent region"); return; } } List <WorldRegion> list; if (parent == this) { list = player.Session.World.Regions.List; } else { list = parent.SubRegions; } //Make sure the new size overlaps the old one so we don't make huge mistakes if (test.Overlap(this) == false) { player.TellSystem(Chat.Red, "New size must overlap old one"); player.TellSystem(Chat.Red, "New size " + test); player.TellSystem(Chat.Red, "Old size " + this.Coords()); return; } //Check that the new size fits in the parent if (parent != this) { if (parent.Cover(test) == false) { player.TellSystem(Chat.Red, "parent " + parent.Name + " is too small " + parent.Coords()); return; } } //else we are in the top level, no limit there //Make sure new size does not collide with siblings foreach (WorldRegion w in list) { if (w.Dimension != Dimension) //If toplevel "siblings" are all toplevel regions { continue; } if (w == this) { continue; } if (w.Overlap(test)) { player.TellSystem(Chat.Red, "new size overlap sibling " + w); return; } } //Chech that subregions still fit into the new size if (SubRegions != null) { foreach (WorldRegion w in SubRegions) { if (test.Cover(w) == false) { player.TellSystem(Chat.Red, "New size does not cover subregion:"); player.TellSystem(Chat.Red, w.ToString()); return; } } } Log.WritePlayer(player, "Region Resized: from " + this + " to " + test); MinX = test.MinX; MaxX = test.MaxX; MinY = test.MinY; MaxY = test.MaxY; MinZ = test.MinZ; MaxZ = test.MaxZ; RegionLoader.Save(regions); player.TellSystem(Chat.Purple, "Region resized: " + this); }