Exemplo n.º 1
0
        private static void RunUnpack(ProgramArgs args, BaseProfile profile)
        {
            var database = new Database(new DatabaseOptions(profile.GetGame(), profile.GetDatabaseType()));
            var files    = profile.LoadFiles(database, args.InputDirectory);

            database.CompleteLoad();
            var stopwatch = Stopwatch.StartNew();

            var serializer = new DatabaseSerializer(database, args.OutputDirectory);

            serializer.Serialize(files);

            stopwatch.Stop();

            Console.WriteLine("Exported database to {2} in {0}ms ({1:f2}s)", stopwatch.ElapsedMilliseconds,
                              stopwatch.ElapsedMilliseconds / 1000f, args.OutputDirectory);
        }
Exemplo n.º 2
0
        private static void RunPack(ProgramArgs args, BaseProfile profile)
        {
            var database     = new Database(new DatabaseOptions(profile.GetGame(), profile.GetDatabaseType()));
            var deserializer = new DatabaseDeserializer(database, args.InputDirectory);

            Stopwatch stopwatch = Stopwatch.StartNew();

            deserializer.Deserialize();
            stopwatch.Stop();

            Console.WriteLine("Loaded database from {2} in {0}ms ({1:f2}s)", stopwatch.ElapsedMilliseconds,
                              stopwatch.ElapsedMilliseconds / 1000f, args.InputDirectory);

            stopwatch.Restart();
            deserializer.GenerateFiles(profile, args.OutputDirectory);
            stopwatch.Stop();
            Console.WriteLine("Exported VLT files to {2} in {0}ms ({1:f2}s)", stopwatch.ElapsedMilliseconds,
                              stopwatch.ElapsedMilliseconds / 1000f, args.OutputDirectory);
        }
Exemplo n.º 3
0
        private static void RunApplyModScript(ProgramArgs args, BaseProfile profile)
        {
            if (string.IsNullOrEmpty(args.ModScriptPath))
            {
                throw new Exception("Missing modscript path!");
            }

            var database     = new Database(new DatabaseOptions(profile.GetGame(), profile.GetDatabaseType()));
            var deserializer = new DatabaseDeserializer(database, args.InputDirectory);

            Stopwatch stopwatch      = Stopwatch.StartNew();
            var       loadedDatabase = deserializer.Deserialize();

            stopwatch.Stop();

            Console.WriteLine("Loaded database from {2} in {0}ms ({1:f2}s)", stopwatch.ElapsedMilliseconds,
                              stopwatch.ElapsedMilliseconds / 1000f, args.InputDirectory);

            stopwatch.Restart();

            var modScriptParser   = new ModScriptParser(args.ModScriptPath);
            var cmdStopwatch      = Stopwatch.StartNew();
            var modScriptDatabase = new ModScriptDatabaseHelper(database);
            int commandCount      = 0;

            foreach (var command in modScriptParser.Parse())
            {
#if !DEBUG
                try
                {
#endif
                cmdStopwatch.Restart();
                command.Execute(modScriptDatabase);
                commandCount++;
                //Console.WriteLine("Executed command in {1}ms: {0}", command.Line, cmdStopwatch.ElapsedMilliseconds);
#if !DEBUG
            }
            catch (Exception e)
            {
                throw new ModScriptCommandExecutionException($"Failed to execute command: {command.Line}", e);
            }
#endif
            }
            stopwatch.Stop();
            float commandsPerSecond = commandCount / (stopwatch.ElapsedMilliseconds / 1000.0f);
            Console.WriteLine("Applied script from {2} in {0}ms ({1:f2}s) ({4} commands @ ~{3:f2} commands/sec)", stopwatch.ElapsedMilliseconds,
                              stopwatch.ElapsedMilliseconds / 1000f, args.ModScriptPath, commandsPerSecond, commandCount);
            stopwatch.Restart();
            Console.WriteLine("Making backup");
            Directory.Move(args.InputDirectory, $"{args.InputDirectory.TrimEnd('/', '\\')}_{DateTimeOffset.Now.ToUnixTimeSeconds()}");
            Directory.CreateDirectory(args.InputDirectory);
            stopwatch.Stop();
            Console.WriteLine("Made backup in {0}ms ({1:f2}s)", stopwatch.ElapsedMilliseconds,
                              stopwatch.ElapsedMilliseconds / 1000f);

            stopwatch.Restart();
            new DatabaseSerializer(database, args.InputDirectory).Serialize(loadedDatabase.Files);

            //deserializer.GenerateFiles(profile, args.OutputDirectory);
            stopwatch.Stop();

            Console.WriteLine("Exported YML files to {2} in {0}ms ({1:f2}s)", stopwatch.ElapsedMilliseconds,
                              stopwatch.ElapsedMilliseconds / 1000f, args.InputDirectory);
            stopwatch.Restart();
            deserializer.GenerateFiles(profile, args.OutputDirectory);
            stopwatch.Stop();

            Console.WriteLine("Exported VLT files to {2} in {0}ms ({1:f2}s)", stopwatch.ElapsedMilliseconds,
                              stopwatch.ElapsedMilliseconds / 1000f, args.OutputDirectory);
        }