public QuestCompleteObjectiveRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
		{
			XmlElement questEl = xml["quest"];

			ReadType( questEl, "type", ref m_Quest );
			ReadType( questEl, "complete", ref m_Objective );
		}
Exemple #2
0
		public static bool CanSpawn( Region region, params Type[] types )
		{
			while ( region != null )
			{
				if ( !region.AllowSpawn() )
					return false;

				BaseRegion br = region as BaseRegion;

				if ( br != null )
				{
					if ( br.Spawns != null )
					{
						for ( int i = 0; i < br.Spawns.Length; i++ )
						{
							SpawnEntry entry = br.Spawns[i];

							if ( entry.Definition.CanSpawn( types ) )
								return true;
						}
					}

					if ( br.ExcludeFromParentSpawns )
						return false;
				}

				region = region.Parent;
			}

			return false;
		}
		public CampfireRegion( Campfire campfire, Region existingRegion ) : base( "", "", campfire.Map )
		{
			Priority = Region.HousePriority;
			LoadFromXml = false;
			m_Campfire = campfire;
			m_ExistingRegion = existingRegion;
		}
        public GuardedRegion( XmlElement xml, Map map, Region parent )
            : base(xml, map, parent)
        {
            XmlElement el = xml["guards"];

            if ( ReadType( el, "type", ref m_GuardType, false ) )
            {
                if ( !typeof( Mobile ).IsAssignableFrom( m_GuardType ) )
                {
                    Console.WriteLine( "Invalid guard type for region '{0}'", this );
                    m_GuardType = DefaultGuardType;
                }
            }
            else
            {
                m_GuardType = DefaultGuardType;
            }

            bool disabled = false;
            if ( ReadBoolean( el, "disabled", ref disabled, false ) )
                this.Disabled = disabled;

            if ( Name != null )
                RuneName = String.Format( "the city of {0}", Name );
        }
Exemple #5
0
        public static SpawnZone Instantiate(Region region, TileFlag filter, SpawnZoneValidator validator, bool cache)
        {
            var name = region.Name;

            if (region.IsDefault || String.IsNullOrWhiteSpace(name))
            {
                name = "Default";
            }

            var filters = GetFilters(filter);

            var hash = GetHashCode(region.Map, name, filters, validator);

            SpawnZone o;

            if (!_Cache.TryGetValue(hash, out o) || o == null)
            {
                o = new SpawnZone(region.Map, name, filters, validator);

                if (cache)
                {
                    _Cache[hash] = o;
                }

                o.Invalidate();
            }

            return(o);
        }
 public CraftShopRegion( XmlElement xml, Map map, Region parent )
     : base(xml, map, parent)
 {
     int skill = 0;
     ReadInt32( xml, "skill", ref skill, true );
     m_Skills = (CraftSkillType)skill;
 }
Exemple #7
0
 public static bool RegionContains(Server.Region region, Mobile m)
 {
     #if (RunUO_1_Final)
     return(region.Mobiles.Contains(m));
     #elif (RunUO_2_RC1)
     return(region.GetMobiles().Contains(m));
     #endif
 }
Exemple #8
0
 public static bool RegionContains(Region region, Mobile m)
 {
     #if(RunUO_1_Final)
         return region.Mobiles.Contains(m);
     #elif(RunUO_2_RC1)
         return region.GetMobiles().Contains(m);
     #endif
 }
Exemple #9
0
		public QuestNoEntryRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
		{
			XmlElement questEl = xml["quest"];

			ReadType( questEl, "type", ref m_Quest );
			ReadType( questEl, "min", ref m_MinObjective, false );
			ReadType( questEl, "max", ref m_MaxObjective, false );
			ReadInt32( questEl, "message", ref m_Message, false );
		}
        public static void ShowRegionBounds(Region r, Mobile from, bool control, bool active)
        {
            if (r == null)
                return;

            foreach (Rectangle3D rect in r.Area)
            {
                ShowRectBounds(rect, r.Map, from, control, active);
            }
        }
		public DungeonRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
		{
			XmlElement entrEl = xml["entrance"];

			Map entrMap = map;
			ReadMap( entrEl, "map", ref entrMap, false );

			if ( ReadPoint3D( entrEl, entrMap, ref m_EntranceLocation, false ) )
				m_EntranceMap = entrMap;
		}
		public static bool IsMLRegion( Region region )
		{
			return region.IsPartOf( "Twisted Weald" )
				|| region.IsPartOf( "Sanctuary" )
				|| region.IsPartOf( "The Prism of Light" )
				|| region.IsPartOf( "The Citadel" )
				|| region.IsPartOf( "Bedlam" )
				|| region.IsPartOf( "Blighted Grove" )
				|| region.IsPartOf( "The Painted Caves" )
				|| region.IsPartOf( "The Palace of Paroxysmus" )
				|| region.IsPartOf( "Labyrinth" );
		}
Exemple #13
0
		//----------------------------------------------------------------------
		//
		//----------------------------------------------------------------------
		public static string RegionCategory( Region currentRegion )
		{
			string str;

			if( currentRegion is GuardedRegion ) { str = "Guarded"; }
			else if( currentRegion is HouseRegion ) { str = "House"; }
			else if( currentRegion is DungeonRegion ) { str = "Dungeon"; }
			else if( currentRegion is Jail ) { str = "Jail"; }
			else if( currentRegion is GreenAcres ) { str = "GreenAcres"; }
			else { str = "Wilderness"; }

			return str;
		}
        public static void ShowRegionBounds( Region r )
        {
            if( r == null || r.Coords == null || r.Coords.Count == 0)
                return;

            ArrayList c = r.Coords;

            for( int i = 0; i < c.Count; i++ )
            {
                if( c[i] is Rectangle2D )
                    ShowRectBounds( (Rectangle2D)c[i], r.Map );
            }
        }
Exemple #15
0
		public static LootCollection GetRegionCollection( Type type, Region region )
		{
			if ( region is BaseRegion )
			{
				LootCollection coll;

				((BaseRegion)region).LootTable.TryGetValue( type, out coll );

				return coll;
			}

			return null;
		}
		public static string GetRuneNameFor( Region region )
		{
			while ( region != null )
			{
				BaseRegion br = region as BaseRegion;

				if ( br != null && br.m_RuneName != null )
					return br.m_RuneName;

				region = region.Parent;
			}

			return null;
		}
Exemple #17
0
        public ApprenticeObjective( SkillName skill, int cap, string region, object enterRegion, object leaveRegion )
            : base(cap)
        {
            m_Skill = skill;

            if ( region != null )
            {
                m_Region = QuestHelper.FindRegion( region );
                m_Enter = enterRegion;
                m_Leave = leaveRegion;

                if ( m_Region == null )
                    Console.WriteLine( String.Format( "Invalid region name ('{0}') in '{1}' objective!", region, GetType() ) );
            }
        }
		public static Town FromRegion( Region reg )
		{
			if ( reg.Map != Faction.Facet )
				return null;

			TownCollection towns = Towns;

			for ( int i = 0; i < towns.Count; ++i )
			{
				Town town = towns[i];

				if ( town.Definition.Region == reg.Name )
					return town;
			}

			return null;
		}
Exemple #19
0
        public static Rectangle3D[] RegionArea(Server.Region region)
        {
            #if (RunUO_1_Final)
            Rectangle3D[] rects = new Rectangle3D[region.Coords.Count];
            Rectangle2D   rect  = new Rectangle2D(Point2D.Zero, Point2D.Zero);

            for (int i = 0; i < rects.Length && i < region.Coords.Count; ++i)
            {
                rect     = (Rectangle2D)region.Coords[i];
                rects[i] = new Rectangle3D(new Point3D(rect.Start.X, rect.Start.Y, region.MinZ), new Point3D(rect.End.X, rect.End.Y, region.MaxZ));
            }

            return(rects);
            #elif (RunUO_2_RC1)
            return(region.Area);
            #endif
        }
Exemple #20
0
		public static Town FromRegion( Region reg )
		{
			if ( reg.Map != Faction.Facet )
				return null;

			List<Town> towns = Towns;

			for ( int i = 0; i < towns.Count; ++i )
			{
				Town town = towns[i];

				if ( reg.IsPartOf( town.Definition.Region ) )
					return town;
			}

			return null;
		}
Exemple #21
0
        public void ResetLevel3Spawners(Map map)
        {
            Server.Region r = Server.Region.Find(new Point3D(5574, 1859, 0), map);

            foreach (Item item in r.GetEnumeratedItems().Where(i => i is ISpawner &&
                                                               i.X >= 5501 && i.X <= 5627 && i.Y >= 1799 && i.Y <= 1927))
            {
                if (item is XmlSpawner)
                {
                    ((XmlSpawner)item).DoReset = true;
                }
                else if (item is Spawner)
                {
                    ((Spawner)item).RemoveSpawned();
                    ((Spawner)item).Running = false;
                }
            }
        }
Exemple #22
0
        public static Rectangle3D[] RegionArea(Region region)
        {
            #if(RunUO_1_Final)

                Rectangle3D[] rects = new Rectangle3D[region.Coords.Count];
                Rectangle2D rect = new Rectangle2D(Point2D.Zero, Point2D.Zero);

                for (int i = 0; i < rects.Length && i < region.Coords.Count; ++i)
                {
                    rect = (Rectangle2D)region.Coords[i];
                    rects[i] = new Rectangle3D(new Point3D(rect.Start.X, rect.Start.Y, region.MinZ), new Point3D(rect.End.X, rect.End.Y, region.MaxZ));
                }

                return rects;

            #elif(RunUO_2_RC1)
                return region.Area;
            #endif
        }
        public TownRegion( XmlElement xml, Map map, Region parent )
            : base(xml, map, parent)
        {
            string frag = Name.ToLower();
            if (frag == "serpent's hold")
                frag = "serphold";
            else if (frag == "skara brae")
                frag = "skara";
            else if (frag == "nujel'm")
                frag = "nujelm";
            else if (frag == "buccaneer's den")
                frag = "bucden";

            try
            {
                m_Frag = (RegionFragment)Enum.Parse(typeof(RegionFragment), frag, true);
            }
            catch (Exception)
            {
                m_Frag = RegionFragment.Wilderness;
            }
        }
Exemple #24
0
		public virtual bool AcceptsSpawnsFrom(Region region)
		{
			return AllowSpawn() && region != null && (region.IsPartOf(BattleRegion) || region.IsPartOf(SpectateRegion));
		}
        public override void OnRegionChange( Region Old, Region New )
        {
            base.OnRegionChange( Old, New );

            if ( this.Controlled )
            {
                SpawnEntry se = this.Spawner as SpawnEntry;

                if ( se != null && !se.UnlinkOnTaming && ( New == null || !New.AcceptsSpawnsFrom( se.Region ) ) )
                {
                    this.Spawner.Remove( this );
                    this.Spawner = null;
                }
            }
        }
Exemple #26
0
        public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            AppDomain.CurrentDomain.ProcessExit        += CurrentDomain_ProcessExit;

            foreach (string a in args)
            {
                if (Insensitive.Equals(a, "-debug"))
                {
                    Debug = true;
                }
                else if (Insensitive.Equals(a, "-service"))
                {
                    Service = true;
                }
                else if (Insensitive.Equals(a, "-profile"))
                {
                    Profiling = true;
                }
                else if (Insensitive.Equals(a, "-nocache"))
                {
                    _Cache = false;
                }
                else if (Insensitive.Equals(a, "-haltonwarning"))
                {
                    HaltOnWarning = true;
                }
                else if (Insensitive.Equals(a, "-vb"))
                {
                    VBdotNet = true;
                }
                else if (Insensitive.Equals(a, "-usehrt"))
                {
                    _UseHRT = true;
                }
                else if (Insensitive.Equals(a, "-noconsole"))
                {
                    NoConsole = true;
                }
            }

            if (!Environment.UserInteractive || Service)
            {
                NoConsole = true;
            }

            try
            {
                if (Service)
                {
                    if (!Directory.Exists("Logs"))
                    {
                        Directory.CreateDirectory("Logs");
                    }

                    Console.SetOut(MultiConsoleOut = new MultiTextWriter(new FileLogger("Logs/Console.log")));
                }
                else
                {
                    Console.SetOut(MultiConsoleOut = new MultiTextWriter(Console.Out));
                }
            }
            catch
            { }

            Thread   = Thread.CurrentThread;
            Process  = Process.GetCurrentProcess();
            Assembly = Assembly.GetEntryAssembly();

            if (Thread != null)
            {
                Thread.Name = "Core Thread";
            }

            if (BaseDirectory.Length > 0)
            {
                Directory.SetCurrentDirectory(BaseDirectory);
            }

            Timer.TimerThread ttObj = new Timer.TimerThread();

            _TimerThread = new Thread(ttObj.TimerMain)
            {
                Name = "Timer Thread"
            };

            Version ver = Assembly.GetName().Version;

            // Added to help future code support on forums, as a 'check' people can ask for to it see if they recompiled core or not
            Utility.PushColor(ConsoleColor.DarkGreen);
            if (!NoConsole)
            {
                Console.WriteLine(new String('-', Console.BufferWidth));
            }
            else
            {
                Console.WriteLine(new String('-', 10));
            }
            Utility.PopColor();
            Utility.PushColor(ConsoleColor.Cyan);
            Console.WriteLine(
                "ServUO - [https://www.servuo.com] Version {0}.{1}, Build {2}.{3}",
                ver.Major,
                ver.Minor,
                ver.Build,
                ver.Revision);
            Utility.PopColor();

            string s = Arguments;

            if (s.Length > 0)
            {
                Utility.PushColor(ConsoleColor.Yellow);
                Console.WriteLine("Core: Running with arguments: {0}", s);
                Utility.PopColor();
            }

            ProcessorCount = Environment.ProcessorCount;

            if (ProcessorCount > 1)
            {
                MultiProcessor = true;
            }

            if (MultiProcessor || Is64Bit)
            {
                Utility.PushColor(ConsoleColor.Green);
                Console.WriteLine(
                    "Core: Optimizing for {0} {2}processor{1}",
                    ProcessorCount,
                    ProcessorCount == 1 ? "" : "s",
                    Is64Bit ? "64-bit " : "");
                Utility.PopColor();
            }

            int platform = (int)Environment.OSVersion.Platform;

            if (platform == 4 || platform == 128)
            {
                // MS 4, MONO 128
                Unix = true;
                Utility.PushColor(ConsoleColor.Yellow);
                Console.WriteLine("Core: Unix environment detected");
                Utility.PopColor();
            }
            else
            {
                m_ConsoleEventHandler = OnConsoleEvent;
                UnsafeNativeMethods.SetConsoleCtrlHandler(m_ConsoleEventHandler, true);
            }

            if (GCSettings.IsServerGC)
            {
                Utility.PushColor(ConsoleColor.DarkYellow);
                Console.WriteLine("Core: Server garbage collection mode enabled");
                Utility.PopColor();
            }

            if (_UseHRT)
            {
                Utility.PushColor(ConsoleColor.DarkYellow);
                Console.WriteLine(
                    "Core: Requested high resolution timing ({0})",
                    UsingHighResolutionTiming ? "Supported" : "Unsupported");
                Utility.PopColor();
            }

            Utility.PushColor(ConsoleColor.DarkYellow);
            Console.WriteLine("RandomImpl: {0} ({1})", RandomImpl.Type.Name, RandomImpl.IsHardwareRNG ? "Hardware" : "Software");
            Utility.PopColor();

            Utility.PushColor(ConsoleColor.DarkYellow);
            Console.WriteLine("Core: Loading config...");
            Config.Load();
            Utility.PopColor();

            while (!ScriptCompiler.Compile(Debug, _Cache))
            {
                Utility.PushColor(ConsoleColor.Red);
                Console.WriteLine("Scripts: One or more scripts failed to compile or no script files were found.");
                Utility.PopColor();

                if (Service)
                {
                    return;
                }

                Console.WriteLine(" - Press return to exit, or R to try again.");

                if (Insensitive.Equals(Console.ReadLine(), "R"))
                {
                    return;
                }
            }

            ScriptCompiler.Invoke("Configure");

            Region.Load();
            World.Load();

            ScriptCompiler.Invoke("Initialize");

            MessagePump messagePump = MessagePump = new MessagePump();

            _TimerThread.Start();

            foreach (Map m in Map.AllMaps)
            {
                m.Tiles.Force();
            }

            NetState.Initialize();

            EventSink.InvokeServerStarted();

            try
            {
                long now, last = TickCount;

                const int   sampleInterval = 100;
                const float ticksPerSecond = 1000.0f * sampleInterval;

                long sample = 0;

                while (!Closing)
                {
                    _Signal.WaitOne();

                    Mobile.ProcessDeltaQueue();
                    Item.ProcessDeltaQueue();

                    Timer.Slice();
                    messagePump.Slice();

                    NetState.FlushAll();
                    NetState.ProcessDisposedQueue();

                    if (Slice != null)
                    {
                        Slice();
                    }

                    if (sample++ % sampleInterval != 0)
                    {
                        continue;
                    }

                    now = TickCount;
                    _CyclesPerSecond[_CycleIndex++ % _CyclesPerSecond.Length] = ticksPerSecond / (now - last);
                    last = now;
                }
            }
            catch (Exception e)
            {
                CurrentDomain_UnhandledException(null, new UnhandledExceptionEventArgs(e, true));
            }
        }
Exemple #27
0
 public virtual void OnChildAdded(Region child)
 {
 }
Exemple #28
0
 public static bool Contains(this Region r, Point3D p, Map m)
 {
     return(r.Map == m && Contains(r, p));
 }
Exemple #29
0
		// 2004.02.08 :: Omega Red
		public Point2D GetRandomRegionPoint( Region r )
		{
			int count = r.Area.Length;

			int[] FieldArray = new int[count];
			int total = 0;

			// calculate fields of all rectangles (for probability calculating)
			for( int i = 0; i < count; i++ )
			{
				object o = r.Area[i];
				if( o is Rectangle2D )
				{
					total += (FieldArray[i] = ((Rectangle2D)o).Width * ((Rectangle2D)o).Height);
				}
				else
					if( o is Rectangle3D )
					{
						total += (FieldArray[i] = ((Rectangle3D)o).Width * ((Rectangle3D)o).Height);
					}
			}

			int sum = 0;
			int rnd = 0;
			if( total > 0 )
				rnd = Utility.Random( total );
			int x = 0;
			int y = 0;
			for( int i = 0; i < count; i++ )
			{
				sum += FieldArray[i];
				if( sum > rnd )
				{
					object o = r.Area[i];

					if( o is Rectangle2D )
					{
						Rectangle2D r2d = (Rectangle2D)o;
						if( r2d.Width >= 0 )
							x = r2d.X + Utility.Random( r2d.Width + 1 );

						if( r2d.Height >= 0 )
							y = r2d.Y + Utility.Random( r2d.Height + 1 );

						break;
					}
					else
						if( o is Rectangle3D )
						{
							Rectangle3D r3d = (Rectangle3D)o;
							if( r3d.Width >= 0 )
								x = r3d.Start.X + Utility.Random( r3d.Width + 1 );
							if( r3d.Height >= 0 )
								y = r3d.Start.Y + Utility.Random( r3d.Height + 1 );
							break;
						}
				}
			}

			return new Point2D( x, y );
		}
Exemple #30
0
		public bool HasRegionPoints( Region r )
		{
			if( r != null && r.Area.Length > 0 ) return true;
			else
				return false;
		}
Exemple #31
0
 public static bool InRegion(this Mobile m, Region r)
 {
     return(m != null && m.Region != null && m.Region.IsPartOf(r));
 }
Exemple #32
0
 public RegionRect(Region region, Rectangle3D rect)
 {
     m_Region = region;
     m_Rect   = rect;
 }
Exemple #33
0
        public Region(XmlElement xml, Map map, Region parent)
        {
            Map     = map;
            Parent  = parent;
            Dynamic = false;

            if (Parent == null)
            {
                ChildLevel = 0;
                m_Priority = DefaultPriority;
            }
            else
            {
                ChildLevel = Parent.ChildLevel + 1;
                m_Priority = Parent.Priority;
            }

            ReadString(xml, "name", ref m_Name, false);

            if (parent == null)
            {
                ReadInt32(xml, "priority", ref m_Priority, false);
            }


            int minZ = MinZ;
            int maxZ = MaxZ;

            XmlElement zrange = xml["zrange"];

            ReadInt32(zrange, "min", ref minZ, false);
            ReadInt32(zrange, "max", ref maxZ, false);


            List <Rectangle3D> area = new List <Rectangle3D>();

            foreach (XmlElement xmlRect in xml.SelectNodes("rect"))
            {
                Rectangle3D rect = new Rectangle3D();
                if (ReadRectangle3D(xmlRect, minZ, maxZ, ref rect))
                {
                    area.Add(rect);
                }
            }

            Area = area.ToArray();

            if (Area.Length == 0)
            {
                log.Warning("Empty area for region '{0}'", this);
            }


            if (!ReadPoint3D(xml["go"], map, ref m_GoLocation, false) && Area.Length > 0)
            {
                Point3D start = Area[0].Start;
                Point3D end   = Area[0].End;

                int x = start.X + (end.X - start.X) / 2;
                int y = start.Y + (end.Y - start.Y) / 2;

                m_GoLocation = new Point3D(x, y, Map.GetAverageZ(x, y));
            }


            object oMusic = this.DefaultMusic;

            ReadEnum(xml["music"], "name", typeof(MusicName), ref oMusic, false);

            Music = (MusicName)oMusic;

            if (xml.Attributes["CannotDrop"] != null)
            {
                XmlAttribute attr = xml.Attributes["CannotDrop"];
                this.CannotDrop = Convert.ToBoolean(attr.Value);
            }
        }
Exemple #34
0
        public Region(XmlElement xml, Map map, Region parent)
        {
            m_Map     = map;
            m_Parent  = parent;
            m_Dynamic = false;

            if (m_Parent == null)
            {
                m_ChildLevel = 0;
                m_Priority   = DefaultPriority;
            }
            else
            {
                m_ChildLevel = m_Parent.ChildLevel + 1;
                m_Priority   = m_Parent.Priority;
            }

            ReadString(xml, "name", ref m_Name, false);

            if (parent == null)
            {
                ReadInt32(xml, "priority", ref m_Priority, false);
            }


            int minZ = MinZ;
            int maxZ = MaxZ;

            XmlElement zrange = xml["zrange"];

            ReadInt32(zrange, "min", ref minZ, false);
            ReadInt32(zrange, "max", ref maxZ, false);


            List <Rectangle3D> area = new List <Rectangle3D>();

            foreach (XmlElement xmlRect in xml.SelectNodes("rect"))
            {
                Rectangle3D rect = new Rectangle3D();
                if (ReadRectangle3D(xmlRect, minZ, maxZ, ref rect))
                {
                    area.Add(rect);
                }
            }

            m_Area = area.ToArray();

            if (m_Area.Length == 0)
            {
                Console.WriteLine("Empty area for region '{0}'", this);
            }


            if (!ReadPoint3D(xml["go"], map, ref m_GoLocation, false) && m_Area.Length > 0)
            {
                Point3D start = m_Area[0].Start;
                Point3D end   = m_Area[0].End;

                int x = start.X + (end.X - start.X) / 2;
                int y = start.Y + (end.Y - start.Y) / 2;

                m_GoLocation = new Point3D(x, y, m_Map.GetAverageZ(x, y));
            }


            MusicName music = this.DefaultMusic;

            ReadEnum(xml["music"], "name", ref music, false);

            m_Music = music;
        }
Exemple #35
0
        public static PreviewRegion DisplayPreview(
            this Region r,
            int hue             = 85,
            int effect          = 1801,
            EffectRender render = EffectRender.SemiTransparent)
        {
            if (r == null || r.Area == null || r.Area.Length == 0)
            {
                return(null);
            }

            if (hue < 0)
            {
                hue = 0;
            }

            if (effect <= 0)
            {
                effect = 1801;
            }

            PreviewRegion pr;

            if (r is PreviewRegion)
            {
                pr              = (PreviewRegion)r;
                pr.EffectID     = effect;
                pr.EffectHue    = hue;
                pr.EffectRender = render;
                pr.Register();

                return(pr);
            }

            var s = GetSerial(r);

            if (s == null)
            {
                return(null);
            }

            if (_Previews.TryGetValue(s, out pr) && pr != null && pr.Area.GetBoundsHashCode() != r.Area.GetBoundsHashCode())
            {
                pr.Unregister();
                pr = null;
            }

            if (pr == null)
            {
                pr = new PreviewRegion(r)
                {
                    EffectHue    = hue,
                    EffectID     = effect,
                    EffectRender = render
                };
            }

            pr.Register();

            return(pr);
        }
Exemple #36
0
 public Region(string name, Map map, Region parent, params Rectangle2D[] area) : this(name, map, parent, ConvertTo3D(area))
 {
 }
Exemple #37
0
        public static void CheckDrop(BaseCreature bc, Container c)
        {
            if (m_IngredientTable != null)
            {
                foreach (IngredientDropEntry entry in m_IngredientTable)
                {
                    if (entry == null)
                    {
                        continue;
                    }

                    if (entry.Region != null)
                    {
                        string reg = entry.Region;

                        if (reg == "TerMur" && c.Map != Map.TerMur)
                        {
                            continue;
                        }
                        else if (reg == "Abyss" && (c.Map != Map.TerMur || c.X < 235 || c.X > 1155 || c.Y < 40 || c.Y > 1040))
                        {
                            continue;
                        }
                        else if (reg != "TerMur" && reg != "Abyss")
                        {
                            Server.Region r = Server.Region.Find(c.Location, c.Map);

                            if (r == null || !r.IsPartOf(entry.Region))
                            {
                                continue;
                            }
                        }
                    }

                    if (bc.GetType() != entry.CreatureType && !bc.GetType().IsSubclassOf(entry.CreatureType))
                    {
                        continue;
                    }

                    double      toBeat = entry.Chance;
                    List <Item> drops  = new List <Item>();

                    if (bc is BaseVoidCreature)
                    {
                        toBeat *= ((BaseVoidCreature)bc).Stage + 1;
                    }

                    if (entry.DropMultiples)
                    {
                        foreach (Type type in entry.Ingredients)
                        {
                            if (toBeat >= Utility.RandomDouble())
                            {
                                Item drop = Loot.Construct(type);

                                if (drop != null)
                                {
                                    drops.Add(drop);
                                }
                            }
                        }
                    }
                    else if (toBeat >= Utility.RandomDouble())
                    {
                        Item drop = Loot.Construct(entry.Ingredients);

                        if (drop != null)
                        {
                            drops.Add(drop);
                        }
                    }

                    foreach (Item item in drops)
                    {
                        c.DropItem(item);
                    }

                    ColUtility.Free(drops);
                }
            }
        }
Exemple #38
0
		public static void FilterByRegion( Mobile from, ArrayList facetList, Region regr, Map regmap, int page )
		{
			ArrayList filregList = new ArrayList();
			
			foreach( Item regItem in facetList )
			{
				Point2D p2 = new Point2D( regItem.X, regItem.Y );
				Point3D p = new Point3D( p2, regItem.Z );
						
				if( Region.Find( p, regmap ) == regr )
					filregList.Add( regItem );
			}

			from.SendGump( new SpawnEditorGump( from, 0, filregList, 0, null ) );
		}
Exemple #39
0
        public static void Start(bool repair)
        {
            if (!ScriptCompiler.Compile(true))
            {
                return;
            }

            m_ItemCount   = 0;
            m_MobileCount = 0;
            foreach (Library l in ScriptCompiler.Libraries)
            {
                int itemCount = 0, mobileCount = 0;
                l.Verify(ref itemCount, ref mobileCount);
                log.InfoFormat("Library {0} verified: {1} items, {2} mobiles",
                               l.Name, itemCount, mobileCount);
                m_ItemCount   += itemCount;
                m_MobileCount += mobileCount;
            }
            log.InfoFormat("All libraries verified: {0} items, {1} mobiles)",
                           m_ItemCount, m_MobileCount);

            try {
                TileData.Configure();

                ScriptCompiler.Configure();
            } catch (TargetInvocationException e) {
                log.Fatal("Configure exception: {0}", e.InnerException);
                return;
            }

            if (!config.Exists)
            {
                config.Save();
            }

            World.Load();
            if (World.LoadErrors > 0)
            {
                log.ErrorFormat("There were {0} errors during world load.", World.LoadErrors);
                if (repair)
                {
                    log.Error("The world load errors are being ignored for now, and will not reappear once you save this world.");
                }
                else
                {
                    log.Error("Try 'SunUO --repair' to repair this world save, or restore an older non-corrupt save.");
                    return;
                }
            }

            try {
                ScriptCompiler.Initialize();
            } catch (TargetInvocationException e) {
                log.Fatal("Initialize exception: {0}", e.InnerException);
                return;
            }

            Region.Load();

            m_MessagePump = new MessagePump();
            foreach (IPEndPoint ipep in Config.Network.Bind)
            {
                m_MessagePump.AddListener(new Listener(ipep));
            }

            Timer.TimerThread ttObj = new Timer.TimerThread();
            timerThread      = new Thread(new ThreadStart(ttObj.TimerMain));
            timerThread.Name = "Timer Thread";
            timerThread.Start();

            NetState.Initialize();
            Encryption.Initialize();

            EventSink.InvokeServerStarted();

            log.Info("SunUO initialized, entering main loop");

            try
            {
                Run();
            }
            catch (Exception e)
            {
                CurrentDomain_UnhandledException(null, new UnhandledExceptionEventArgs(e, true));
            }

            if (timerThread.IsAlive)
            {
                timerThread.Abort();
            }
        }
Exemple #40
0
		private void FindRegionTileLocations( ref List<Point3D> locations, Region r, List<int> includetilelist, List<int> excludetilelist, TileFlag tileflag )
		{
			if( r == null || r.Area == null ) return;

			int count = r.Area.Length;

			if( locations == null ) locations = new List<Point3D>();

			// calculate fields of all rectangles (for probability calculating)
			for( int n = 0; n < count; n++ )
			{
				object o = r.Area[n];
				int sx = 0;
				int sy = 0;
				int w = -1;
				int h = -1;
				if( o is Rectangle2D )
				{
					sx = ((Rectangle2D)o).X;
					sy = ((Rectangle2D)o).Y;
					w = ((Rectangle2D)o).X + ((Rectangle2D)o).Width;
					h = ((Rectangle2D)o).Y + ((Rectangle2D)o).Height;
				}
				else
					if( o is Rectangle3D )
					{
						sx = ((Rectangle3D)o).Start.X;
						sy = ((Rectangle3D)o).Start.Y;
						w = ((Rectangle3D)o).Width;
						h = ((Rectangle3D)o).Height;
					}

				// find all of the valid tile locations in the area
				FindTileLocations( ref locations, r.Map, sx, sy, w, h, includetilelist, excludetilelist, tileflag );
			}


		}
Exemple #41
0
 public RegionEntry( Region r, long pos, int length )
 {
     m_Region = r;
     m_Position = pos;
     m_Length = length;
 }
Exemple #42
0
 public static bool Contains(this Region r, Point3D p)
 {
     return(r.Area.Contains(p));
 }
Exemple #43
0
		public virtual void CreateRegion()
		{
			if ( m_Region != null )
				return;

			Map map = this.Map;

			if ( map == null || map == Map.Internal )
				return;

			m_Region = new GauntletRegion( this, map );
		}
Exemple #44
0
        public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            AppDomain.CurrentDomain.ProcessExit        += new EventHandler(CurrentDomain_ProcessExit);

            for (int i = 0; i < args.Length; ++i)
            {
                if (Insensitive.Equals(args[i], "-debug"))
                {
                    m_Debug = true;
                }
                else if (Insensitive.Equals(args[i], "-service"))
                {
                    m_Service = true;
                }
                else if (Insensitive.Equals(args[i], "-profile"))
                {
                    Profiling = true;
                }
                else if (Insensitive.Equals(args[i], "-nocache"))
                {
                    m_Cache = false;
                }
                else if (Insensitive.Equals(args[i], "-haltonwarning"))
                {
                    m_HaltOnWarning = true;
                }
                else if (Insensitive.Equals(args[i], "-vb"))
                {
                    m_VBdotNET = true;
                }
            }

            try
            {
                if (m_Service)
                {
                    if (!Directory.Exists("Logs"))
                    {
                        Directory.CreateDirectory("Logs");
                    }

                    Console.SetOut(m_MultiConOut = new MultiTextWriter(new FileLogger("Logs/Console.log")));
                }
                else
                {
                    Console.SetOut(m_MultiConOut = new MultiTextWriter(Console.Out));
                }
            }
            catch
            {
            }

            m_Thread   = Thread.CurrentThread;
            m_Process  = Process.GetCurrentProcess();
            m_Assembly = Assembly.GetEntryAssembly();

            if (m_Thread != null)
            {
                m_Thread.Name = "Core Thread";
            }

            if (BaseDirectory.Length > 0)
            {
                Directory.SetCurrentDirectory(BaseDirectory);
            }

            Timer.TimerThread ttObj = new Timer.TimerThread();
            timerThread      = new Thread(new ThreadStart(ttObj.TimerMain));
            timerThread.Name = "Timer Thread";

            Version ver = m_Assembly.GetName().Version;

            // Added to help future code support on forums, as a 'check' people can ask for to it see if they recompiled core or not
            Console.WriteLine("RunUO - [www.runuo.com] Version {0}.{1}, Build {2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision);
            Console.WriteLine("Core: Running on .NET Framework Version {0}.{1}.{2}", Environment.Version.Major, Environment.Version.Minor, Environment.Version.Build);

            string s = Arguments;

            if (s.Length > 0)
            {
                Console.WriteLine("Core: Running with arguments: {0}", s);
            }

            m_ProcessorCount = Environment.ProcessorCount;

            if (m_ProcessorCount > 1)
            {
                m_MultiProcessor = true;
            }

            if (m_MultiProcessor || Is64Bit)
            {
                Console.WriteLine("Core: Optimizing for {0} {2}processor{1}", m_ProcessorCount, m_ProcessorCount == 1 ? "" : "s", Is64Bit ? "64-bit " : "");
            }

            int platform = (int)Environment.OSVersion.Platform;

            if (platform == 4 || platform == 128)                // MS 4, MONO 128
            {
                m_Unix = true;
                Console.WriteLine("Core: Unix environment detected");
            }
            else
            {
                m_ConsoleEventHandler = new ConsoleEventHandler(OnConsoleEvent);
                SetConsoleCtrlHandler(m_ConsoleEventHandler, true);
            }

            if (GCSettings.IsServerGC)
            {
                Console.WriteLine("Core: Server garbage collection mode enabled");
            }

            while (!ScriptCompiler.Compile(m_Debug, m_Cache))
            {
                Console.WriteLine("Scripts: One or more scripts failed to compile or no script files were found.");

                if (m_Service)
                {
                    return;
                }

                Console.WriteLine(" - Press return to exit, or R to try again.");

                if (Console.ReadKey(true).Key != ConsoleKey.R)
                {
                    return;
                }
            }

            ScriptCompiler.Invoke("Configure");

            Region.Load();
            World.Load();

            ScriptCompiler.Invoke("Initialize");

            MessagePump ms = m_MessagePump = new MessagePump();

            timerThread.Start();

            for (int i = 0; i < Map.AllMaps.Count; ++i)
            {
                Map.AllMaps[i].Tiles.Force();
            }

            NetState.Initialize();

            EventSink.InvokeServerStarted();

            try
            {
                DateTime now, last = DateTime.Now;

                const int   sampleInterval = 100;
                const float ticksPerSecond = (float)(TimeSpan.TicksPerSecond * sampleInterval);

                long sample = 0;

                while (m_Signal.WaitOne())
                {
                    Mobile.ProcessDeltaQueue();
                    Item.ProcessDeltaQueue();

                    Timer.Slice();
                    m_MessagePump.Slice();

                    NetState.FlushAll();
                    NetState.ProcessDisposedQueue();

                    if (Slice != null)
                    {
                        Slice();
                    }

                    if ((++sample % sampleInterval) == 0)
                    {
                        now = DateTime.Now;
                        m_CyclesPerSecond[m_CycleIndex++ % m_CyclesPerSecond.Length] =
                            ticksPerSecond / (now.Ticks - last.Ticks);
                        last = now;
                    }
                }
            }
            catch (Exception e)
            {
                CurrentDomain_UnhandledException(null, new UnhandledExceptionEventArgs(e, true));
            }
        }
Exemple #45
0
 public virtual void OnChildRemoved(Region child)
 {
 }
Exemple #46
0
 public void Clear()
 {
     m_Region = null;
 }
Exemple #47
0
 public static TRegion GetRegion <TRegion>(this Region region)
     where TRegion : Region
 {
     return(region != null?region.GetRegion(typeof(TRegion)) as TRegion : null);
 }
Exemple #48
0
		public virtual void DestroyRegion()
		{
			if ( m_Region != null )
				m_Region.Unregister();

			m_Region = null;
		}
Exemple #49
0
 public static bool IsPartOf <TRegion>(this Region region)
     where TRegion : Region
 {
     return(region != null && region.IsPartOf(typeof(TRegion)));
 }
Exemple #50
0
		public bool HasRegionPoints(Region r)
		{
			if (r != null && r.Coords.Count > 0) return true;
			else
				return false;
		}
Exemple #51
0
        public static void Start(Config.Root _config, bool debug, bool _service, bool _profiling)
        {
            config    = _config;
            m_Service = _service;
            Profiling = _profiling;

            m_Assembly = Assembly.GetEntryAssembly();

            /* prepare SunUO */
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            AppDomain.CurrentDomain.ProcessExit        += new EventHandler(CurrentDomain_ProcessExit);

            /* redirect Console to file in service mode */
            if (m_Service)
            {
                string     filename = Path.Combine(LogDirectoryInfo.FullName, "console.log");
                FileStream stream   = new FileStream(filename, FileMode.Create,
                                                     FileAccess.Write, FileShare.Read);
                StreamWriter writer = new StreamWriter(stream);
                Console.SetOut(writer);
                Console.SetError(writer);
            }

            m_Thread  = Thread.CurrentThread;
            m_Process = Process.GetCurrentProcess();

            if (m_Thread != null)
            {
                m_Thread.Name = "Core Thread";
            }

            if (BaseDirectory.Length > 0)
            {
                Directory.SetCurrentDirectory(BaseDirectory);
            }

            Timer.TimerThread ttObj = new Timer.TimerThread();
            timerThread      = new Thread(new ThreadStart(ttObj.TimerMain));
            timerThread.Name = "Timer Thread";

            if (!ScriptCompiler.Compile(debug))
            {
                return;
            }

            m_ItemCount   = 0;
            m_MobileCount = 0;
            foreach (Library l in ScriptCompiler.Libraries)
            {
                int itemCount = 0, mobileCount = 0;
                l.Verify(ref itemCount, ref mobileCount);
                log.Info(String.Format("Library {0} verified: {1} items, {2} mobiles",
                                       l.Name, itemCount, mobileCount));
                m_ItemCount   += itemCount;
                m_MobileCount += mobileCount;
            }
            log.Info(String.Format("All libraries verified: {0} items, {1} mobiles)",
                                   m_ItemCount, m_MobileCount));

            try {
                ScriptCompiler.Configure();
            } catch (TargetInvocationException e) {
                log.Fatal("Configure exception: {0}", e.InnerException);
                return;
            }

            if (!config.Exists)
            {
                config.Save();
            }

            World.Load();

            try {
                ScriptCompiler.Initialize();
            } catch (TargetInvocationException e) {
                log.Fatal("Initialize exception: {0}", e.InnerException);
                return;
            }

            Region.Load();

            m_MessagePump = new MessagePump(new Listener(Listener.Port));

            timerThread.Start();

            NetState.Initialize();
            Encryption.Initialize();

            EventSink.InvokeServerStarted();

            log.Info("SunUO initialized, entering main loop");

            try
            {
                while (!m_Closing)
                {
                    m_Signal.WaitOne();

                    m_Now = DateTime.Now;

                    Mobile.ProcessDeltaQueue();
                    Item.ProcessDeltaQueue();

                    Timer.Slice();
                    m_MessagePump.Slice();

                    NetState.FlushAll();
                    NetState.ProcessDisposedQueue();

                    if (Slice != null)
                    {
                        Slice();
                    }
                }
            }
            catch (Exception e)
            {
                CurrentDomain_UnhandledException(null, new UnhandledExceptionEventArgs(e, true));
            }

            if (timerThread.IsAlive)
            {
                timerThread.Abort();
            }
        }