Esempio n. 1
0
        static public void CheckTree(this ZoneTable @this, ISqlCallContext ctx, int zoneId, string tree)
        {
            string dump = @this.DumpTree(ctx, zoneId).TrimEnd();

            tree = tree.Trim().NormalizeEOL().Replace(" ", string.Empty);
            dump.Should().Be(tree);
        }
Esempio n. 2
0
        static public bool CheckTree(this ZoneTable @this, ISqlCallContext ctx, int zoneId, string tree)
        {
            string dump = @this.DumpTree(ctx, zoneId);

            tree = tree.NormalizeEOL().Replace(" ", string.Empty);
            return(dump == tree);
        }
Esempio n. 3
0
 static public string DumpTree(this ZoneTable @this, ISqlCallContext ctx, int zoneId)
 {
     using (var cmd = new SqlCommand($"select ChildId, ChildDepth from CK.vZoneAllChildren where ZoneId={zoneId} order by ChildOrderByKey"))
     {
         return(ctx[@this.Database].ExecuteQuery(cmd, c =>
         {
             using (var r = cmd.ExecuteReader())
             {
                 StringBuilder b = new StringBuilder();
                 int firstDepth = -1;
                 while (r.Read())
                 {
                     int depth = r.GetInt32(1);
                     if (firstDepth < 0)
                     {
                         firstDepth = depth;
                     }
                     depth -= firstDepth;
                     b.Append('+', depth).Append(r.GetInt32(0)).AppendLine();
                 }
                 return b.ToString();
             }
         }));
     }
 }
Esempio n. 4
0
        public async void Start()
        {
            Config.Config config = ServiceProvider.GetService <Config.Config>();
            await config.Initialise();

            await ServiceProvider.GetService <PreReqValidation>().Initialise();

            CharTemplateTable.Initialize();

            // TODO: refactor NetworkBlock
            NetworkBlock.Instance.Initialize();
            GameTime.Initialize();

            await ServiceProvider.GetService <IdFactory>().Initialise();

            L2World.Initialize();

            MapRegionTable.Initialize();
            ZoneTable.Initialize();

            await ServiceProvider.GetService <ItemTable>().Initialise();

            ItemHandler.Initialize();

            NpcTable.Initialize();
            Capsule.Initialize();
            AttackStanceManager.Initialize();
            BlowFishKeygen.GenerateKeys();

            await ServiceProvider.GetService <IAdminCommandHandler>().Initialise();

            await ServiceProvider.GetService <AnnouncementManager>().Initialise();

            StaticObjTable.Initialize();
            await ServiceProvider.GetService <SpawnTable>().Initialise();

            await ServiceProvider.GetService <HtmCache>().Initialise();

            // TODO: review plugin system
            //PluginManager.Instance.Initialize(this);

            ServiceProvider.GetService <AuthThread>().Initialise();

            _listener = new TcpListener(IPAddress.Any, config.ServerConfig.Port);

            try
            {
                _listener.Start();
            }
            catch (SocketException ex)
            {
                Log.Halt($"Socket Error: '{ex.SocketErrorCode}'. Message: '{ex.Message}' (Error Code: '{ex.NativeErrorCode}')");
            }

            Log.Info($"Listening Gameservers on port {config.ServerConfig.Port}");

            Task.Factory.StartNew(WaitForClients);
        }
Esempio n. 5
0
        static string ZoneTableToJson(ZoneTable zt)
        {
            Console.WriteLine("Serializing ItemTable. Please Wait.");
            string json = JsonConvert.SerializeObject(zt, Formatting.Indented);

            Console.WriteLine("Finished serializing JSON File");

            return(json);
        }
Esempio n. 6
0
        static ZoneTable JsonToZoneTable(string json)
        {
            Console.WriteLine("Deserializing JSON File. Please Wait.");
            ZoneTable tl = JsonConvert.DeserializeObject <ZoneTable>(json);

            Console.WriteLine("Finished deserializing JSON File.");

            return(tl);
        }
Esempio n. 7
0
 public static string GetZoneNameForID(string id)
 {
     DataRow[] rows = ZoneTable.Select(DB.COL_ZONE_ID + "='" + id + "'");
     if (rows.Length > 0)
     {
         return(Convert.ToString(rows[0][DB.COL_ZONE_DESCRIPTION]));
     }
     else
     {
         return(id);
     }
 }
Esempio n. 8
0
 static public string DumpTree(this ZoneTable @this, ISqlCallContext ctx, int zoneId)
 {
     using (var c = new SqlConnectionProvider(@this.Database.ConnectionString))
         using (var cmd = new SqlCommand($"select ChildId, ChildDepth from CK.vZoneAllChildren where ZoneId={zoneId} order by ChildOrderByKey"))
             using (var r = c.AcquireReader(cmd))
             {
                 StringBuilder b          = new StringBuilder();
                 int           firstDepth = -1;
                 while (r.Read())
                 {
                     int depth = r.GetInt32(1);
                     if (firstDepth < 0)
                     {
                         firstDepth = depth;
                     }
                     depth -= firstDepth;
                     b.Append('+', depth).Append(r.GetInt32(0)).AppendLine();
                 }
                 return(b.ToString());
             }
 }
Esempio n. 9
0
        static void Main(string[] args)
        {
            Console.Title = "ZoneTable file Converter v1.0 - OpenDarkEden";

            Console.WriteLine("----------------------------------------");
            Console.WriteLine("      ZoneTable file Converter v1.0     ");
            Console.WriteLine("              Open DarkEden             ");
            Console.WriteLine("       Author: Matheus M. Cardoso       ");
            Console.WriteLine("----------------------------------------");

            if (args.Length == 0)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("No valid itemtable or json was passed as an argument to this program.");
                Console.WriteLine("Drag and drop a valid v6 ZoneTable file (.inf) or a valid JSON file (.js)");
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
                return;
            }

            if (!File.Exists(args[0]))
            {
                string   msg  = "File \"{0}\" not found.";
                object[] objs = { args[0] };

                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(String.Format(msg, objs));
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
            }

            DirectoryInfo dir = new DirectoryInfo(args[0]);

            if (dir.Extension != ".inf" && dir.Extension != ".js")
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Not a .inf or .js file.");
                Console.WriteLine("Drag and drop a valid v6 ZoneTable file (.inf) or a valid JSON file (.js)");
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
                return;
            }

            if (dir.Extension == ".inf")
            {
                FileStream file = File.Open(args[0], FileMode.Open);
                ZoneTable  zt   = new ZoneTable(ref file);

                File.WriteAllText(dir.FullName + ".js", ZoneTableToJson(zt));
            }

            if (dir.Extension == ".js")
            {
                try
                {
                    FileStream file = File.Open(Path.ChangeExtension(dir.FullName, null), FileMode.OpenOrCreate);
                    JsonToZoneTable(File.ReadAllText(args[0])).SaveToFile(ref file);
                }
                catch (Exception e)
                {
                    Console.ForegroundColor = ConsoleColor.Red;

                    if (e as JsonException != null)
                    {
                        Console.WriteLine("Could not deserialize JSON File. Check the syntax:");
                        Console.WriteLine(e.Message);
                    }
                    else
                    {
                        Console.WriteLine("Something bad happened:");
                        Console.WriteLine(e.Message);
                    }

                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.WriteLine("Press any key to exit.");
                    Console.ReadKey();
                }
            }
        }
Esempio n. 10
0
 public ZoneReader() : base()
 {
     this._paths.Add("Assets/Data/Zone/XML/Zones.xml");
     this.ZoneTable = ZoneTable.Instance;
 }
Esempio n. 11
0
        public void Start()
        {
            Console.Title = "L2dotNET Gameserver";

            CLogger.form();
            Cfg.init("all");

            CharTemplateTable.Instance.Initialize();

            NetworkBlock.getInstance();
            GameTime.getInstance();

            IdFactory.Instance.Initialize();

            L2World.Instance.Initialize();

            // MapRegionTable.getInstance();
            ZoneTable.getInstance();

            NpcTable.getInstance();
            NpcData.getInstance();
            //  SpawnTable.getInstance();
            StaticObjTable.getInstance().read();
            StructureTable.getInstance().read();
            //  TSkillTable.getInstance();
            ItemTable.getInstance();
            ItemHandler.getInstance();
            MultiSell.getInstance();
            Capsule.getInstance();
            RecipeTable.getInstance();

            MonsterRace.getInstance();

            AIManager.getInstance();


            BlowFishKeygen.genKey();
            CLogger.info("generated 20 blowfish keys");

            AdminAccess.Instance.Initialize();;

            QuestManager.getInstance();

            AnnouncementManager.Instance.Initialize();

            AllianceTable.getInstance();
            ClanTable.getInstance();

            CLogger.info("NpcServer: ");
            StaticObjTable.getInstance().Spawn();
            MonsterRace.getInstance().Spawn();
            //  SpawnTable.getInstance().Spawn();
            StructureTable.getInstance().init();

            HtmCache.getInstance();

            AuthThread.getInstance();

            //   GeoData.getInstance();

            CLogger.extra_info("listening game clients on port " + Cfg.SERVER_PORT);
            _listener = new TcpListener(Cfg.SERVER_PORT);
            _listener.Start();

            TcpClient clientSocket = default(TcpClient);

            while (true)
            {
                clientSocket = _listener.AcceptTcpClient();
                accept(clientSocket);
            }
        }