/// <summary>
        /// This method patches the third and fourth lines in the intro text.
        /// </summary>
        /// <remarks>
        /// Intro Screen Line 3: 0x036EE0 - 0x036EEA (11 chars)
        /// Intro Screen Line 4: 0x036EEE - 0x036F06 (25 chars)
        /// </remarks>
        public static void PatchForUse(Patch in_Patch, ISeed in_Seed)
        {
            const String INTRO_LINE3_PREFIX  = "FOR USE ";
            const Int32  INTRO_LINE3_ADDRESS = 0x036EE0;
            const Int32  INTRO_LINE4_ADDRESS = 0x036EEE;

            CountryNameSet            countryNameSet = Properties.Resources.CountryNameConfig.Deserialize <CountryNameSet>();
            IEnumerable <CountryName> countryNames   = countryNameSet.Where(x => true == x.Enabled);
            CountryName countryName = in_Seed.NextElement(countryNames);

            Int32 line3NextCharacterAddress = in_Patch.Add(
                INTRO_LINE3_ADDRESS,
                INTRO_LINE3_PREFIX.AsIntroString(),
                $"Splash Text: {INTRO_LINE3_PREFIX}");

            in_Patch.Add(
                line3NextCharacterAddress,
                countryName.GetFormattedPrefix(),
                $"Splash Text: {countryName.Prefix}");

            in_Patch.Add(
                INTRO_LINE4_ADDRESS,
                countryName.GetFormattedName(),
                $"Splash Text: {countryName.Name}");
        }
        //
        // IRandomizer Methods
        //

        public void Randomize(Patch in_Patch, ISeed in_Seed)
        {
            CompanyNameSet            companyNameSet      = Properties.Resources.CompanyNameConfig.Deserialize <CompanyNameSet>();
            IEnumerable <CompanyName> enabledCompanyNames = companyNameSet.Where(x => true == x.Enabled);
            CompanyName companyName = in_Seed.NextElement(enabledCompanyNames);

            // Write the intro text

            //       ©1988 CAPCOM CO.LTD
            // TM AND ©1989 CAPCOM U.S.A.,INC.
            //   MEGA MAN 2 RANDOMIZER 0.3.2
            //           LICENSED BY
            //    NINTENDO OF AMERICA. INC.

            RText.PatchCompanyName(in_Patch, companyName);
            RText.PatchIntroVersion(in_Patch);
            RText.PatchForUse(in_Patch, in_Seed);
            RText.PatchIntroStory(in_Patch, in_Seed);


            // Write the new weapons names
            RText.PatchWeaponNames(in_Patch, in_Seed, out List <Char> newWeaponLetters);

            // This is a hack to get around the strange interdependency that
            // the randomizer interfaces have
            this.mNewWeaponLetters = newWeaponLetters;

            // Write the credits
            RText.PatchCredits(in_Patch, companyName);
        }
Exemple #3
0
        public void Randomize(Patch in_Patch, ISeed in_Seed)
        {
            //ReadLevelComponentJSON(p, r);

            RTilemap.ChangeW4FloorsBeforeSpikes(in_Patch, in_Seed);
            RTilemap.ChangeW4FloorsSpikePit(in_Patch, in_Seed);
        }
Exemple #4
0
        /// <summary>
        /// Reset the DGCPrng instance
        /// </summary>
        public void Reset()
        {
            if (m_digestEngine != null)
            {
                m_digestEngine.Dispose();
                m_digestEngine = null;
            }
            if (m_seedGenerator != null)
            {
                m_seedGenerator.Dispose();
                m_seedGenerator = null;
            }

            m_digestEngine = GetDigest(m_digestType);
            m_rngGenerator = new DGC(m_digestEngine);

            if (m_stateSeed != null)
            {
                m_rngGenerator.Initialize(m_stateSeed);
            }
            else
            {
                m_seedGenerator = GetSeedGenerator(m_seedType);
                m_rngGenerator.Initialize(m_seedGenerator.GetBytes((m_digestEngine.BlockSize * 2) + 8));   // 2 * block + counter (2*bsz+8)
            }

            m_rngGenerator.Generate(m_byteBuffer);
            m_bufferIndex = 0;
        }
        public override async IAsyncEnumerable <SeedTree> ScrapeAsync(ISeed parent,
                                                                      ILookup <string, SeedContent> rootSeeds, ILookup <string, SeedContent> childSeeds,
                                                                      ILookup <string, SeedContent> siblingSeeds, [EnumeratorCancellation] CancellationToken cancellationToken)
        {
            PlatformId platformId        = rootSeeds["platform"].First().Value;
            bool       platformSupported = platformMap.TryGetValue(platformId, out int giantBombPlatformId);

            if (!platformSupported)
            {
                yield break;
            }
            string searchQuery = parent.Content.Value;
            var    results     = (await this.GiantBombClient.SearchForGamesAsync(searchQuery).ConfigureAwait(false)) ?? Enumerable.Empty <GameResult>();

            foreach (var result in results.Where(r => r.Platforms?.Select(p => p.Id).Contains(giantBombPlatformId) ?? false))
            {
                yield return("result", result.Name, _(
                                 ("title", result?.Name ?? ""),
                                 ("description", result?.Deck ?? ""),
                                 ("publisher", result?.Publishers != null ? String.Join(", ", result.Publishers.Select(p => p.Name)) : ""),
                                 ("giantbomb_id", result?.Id.ToString() ?? "0"),
                                 ("boxart", result?.Image?.SuperUrl ?? "")
                                 ));
            }
        }
Exemple #6
0
        /// <summary>
        /// Reset the SP20Prng instance
        /// </summary>
        public void Reset()
        {
            if (m_seedGenerator != null)
            {
                m_seedGenerator.Dispose();
                m_seedGenerator = null;
            }
            if (m_rngGenerator != null)
            {
                m_rngGenerator.Dispose();
                m_rngGenerator = null;
            }

            m_seedGenerator = GetSeedGenerator(m_seedType);
            m_rngGenerator  = new SBG(m_rndCount);

            if (m_seedGenerator != null)
            {
                m_rngGenerator.Initialize(m_seedGenerator.GetBytes(m_keySize));
            }
            else
            {
                m_rngGenerator.Initialize(m_stateSeed);
            }

            m_rngGenerator.Generate(m_byteBuffer);
            m_bufferIndex = 0;
        }
        public void Randomize(Patch in_Patch, ISeed in_Seed)
        {
            // Create list of default teleporter position values
            List <Position> DEFAULT_TELEPORTER_POSITIONS = new List <Position>
            {
                new Position(0x20, 0x3B), // Teleporter X, Y (top-left)
                new Position(0x20, 0x7B),
                new Position(0x20, 0xBB),
                new Position(0x70, 0xBB),
                new Position(0x90, 0xBB),
                new Position(0xE0, 0x3B),
                new Position(0xE0, 0x7B),
                new Position(0xE0, 0xBB),
            };

            IList <Position> newTeleporterPositions = in_Seed.Shuffle(DEFAULT_TELEPORTER_POSITIONS);

            // Write the new x-coordinates
            for (Int32 index = 0; index < newTeleporterPositions.Count; ++index)
            {
                in_Patch.Add(
                    (Int32)(EMiscAddresses.WarpXCoordinateStartAddress + index),
                    newTeleporterPositions[index].X,
                    String.Format("Teleporter {0} X-Pos", index));

                in_Patch.Add(
                    (Int32)(EMiscAddresses.WarpYCoordinateStartAddress + index),
                    newTeleporterPositions[index].Y,
                    String.Format("Teleporter {0} Y-Pos", index));
            }

            // These values will be copied over to $04b0 (y) and $0470 (x), which will be checked
            // for in real time to determine where Mega will teleport to
        }
Exemple #8
0
 public Seed(SeedContent content, ISeed parent, string source)
 {
     this.Content = content;
     this.Guid    = Guid.NewGuid();
     this.Parent  = parent.Guid;
     this.Source  = source;
 }
Exemple #9
0
        /// <summary>
        /// Shuffle which Robot Master awards Items 1, 2, and 3.
        /// </summary>
        public void Randomize(Patch in_Patch, ISeed in_Seed)
        {
            // 0x03C291 - Item # from Heat Man
            // 0x03C292 - Item # from Air Man
            // 0x03C293 - Item # from Wood Man
            // 0x03C294 - Item # from Bubble Man
            // 0x03C295 - Item # from Quick Man
            // 0x03C296 - Item # from Flash Man
            // 0x03C297 - Item # from Metal Man
            // 0x03C298 - Item # from Crash Man
            List <EItemNumber> itemGetList = new List <EItemNumber>()
            {
                EItemNumber.None,
                EItemNumber.None,
                EItemNumber.None,
                EItemNumber.None,
                EItemNumber.None,
                EItemNumber.One,
                EItemNumber.Two,
                EItemNumber.Three,
            };

            IList <EItemNumber> itemGetOrder = in_Seed.Shuffle(itemGetList);

            for (Int32 index = 0; index < itemGetOrder.Count; ++index)
            {
                in_Patch.Add(
                    (Int32)EItemStageAddress.HeatMan + index,
                    (Byte)itemGetOrder[index],
                    String.Format("{0}man Item Get", ((EDmgVsBoss.Offset)index).ToString()));
            }
        }
Exemple #10
0
        private void Dispose(bool Disposing)
        {
            if (!_isDisposed && Disposing)
            {
                try
                {
                    if (_rngGenerator != null)
                    {
                        _rngGenerator.Dispose();
                        _rngGenerator = null;
                    }
                    if (_seedGenerator != null)
                    {
                        _seedGenerator.Dispose();
                        _seedGenerator = null;
                    }
                    if (_byteBuffer != null)
                    {
                        Array.Clear(_byteBuffer, 0, _byteBuffer.Length);
                        _byteBuffer = null;
                    }
                }
                catch { }

                _isDisposed = true;
            }
        }
Exemple #11
0
        /// <summary>
        /// Reset the CTRPrng instance
        /// </summary>
        public void Reset()
        {
            if (m_rngEngine != null)
            {
                m_rngEngine.Dispose();
                m_rngEngine = null;
            }
            if (m_seedGenerator != null)
            {
                m_seedGenerator.Dispose();
                m_seedGenerator = null;
            }
            if (m_rngGenerator != null)
            {
                m_rngGenerator.Dispose();
                m_rngGenerator = null;
            }

            m_rngEngine     = GetCipher(m_engineType);
            m_seedGenerator = GetSeedGenerator(m_seedType);
            m_rngGenerator  = new CMG(m_rngEngine, true);

            if (m_seedGenerator != null)
            {
                m_rngGenerator.Initialize(m_seedGenerator.GetBytes(m_rngEngine.BlockSize + m_keySize));
            }
            else
            {
                m_rngGenerator.Initialize(m_stateSeed);
            }

            m_rngGenerator.Generate(m_byteBuffer);
            m_bufferIndex = 0;
        }
Exemple #12
0
        private void Dispose(bool Disposing)
        {
            if (!m_isDisposed && Disposing)
            {
                try
                {
                    if (m_rngGenerator != null)
                    {
                        m_rngGenerator.Dispose();
                        m_rngGenerator = null;
                    }
                    if (m_seedGenerator != null)
                    {
                        m_seedGenerator.Dispose();
                        m_seedGenerator = null;
                    }
                    if (m_byteBuffer != null)
                    {
                        Array.Clear(m_byteBuffer, 0, m_byteBuffer.Length);
                        m_byteBuffer = null;
                    }
                }
                catch { }

                m_isDisposed = true;
            }
        }
        public void Randomize(Patch in_Patch, ISeed in_Seed)
        {
            debug     = new StringBuilder();
            sounds    = GetSoundList();
            AmmoUsage = new List <Double>();
            AmmoUsage.Add(0); // Buster is free

            ChangeHeat(in_Patch, in_Seed);
            ChangeAir(in_Patch, in_Seed);
            ChangeWood(in_Patch, in_Seed);
            ChangeBubble(in_Patch, in_Seed);
            ChangeQuick(in_Patch, in_Seed);
            ChangeFlash(in_Patch, in_Seed);
            ChangeMetal(in_Patch, in_Seed);
            ChangeCrash(in_Patch, in_Seed);
            ChangeItem1(in_Patch, in_Seed);

            debug.AppendLine("Ammo Usage");
            debug.AppendLine("P     H     A     W     B     Q     M     C");
            debug.AppendLine("-----------------------------------------------");
            foreach (Double w in AmmoUsage)
            {
                debug.Append(String.Format("{0:0.00}  ", w));
            }
            debug.Append(Environment.NewLine);
        }
Exemple #14
0
        /// <summary>
        /// Reset the RNGCryptoServiceProvider instance.
        /// </summary>
        public void Reset()
        {
            if (_seedGenerator != null)
            {
                _seedGenerator.Dispose();
                _seedGenerator = null;
            }
            if (_rngGenerator != null)
            {
                _rngGenerator.Dispose();
                _rngGenerator = null;
            }

            _seedGenerator = GetSeedGenerator(_seedType);
            _rngGenerator  = new SP20Drbg(_dfnRounds);

            if (_seedGenerator != null)
            {
                _rngGenerator.Initialize(_seedGenerator.GetSeed(_keySize));
            }
            else
            {
                _rngGenerator.Initialize(_stateSeed);
            }

            _rngGenerator.Generate(_byteBuffer);
            _bufferIndex = 0;
        }
Exemple #15
0
        protected void ChangeQuick(Patch in_Patch, ISeed in_Seed)
        {
            // Other addresses with potential:
            //0x02C872 - Projectile type, 0x59

            // Quickman's AI
            //0x02C86E - Number of Boomerangs, 3, do from 1 - 10
            in_Patch.Add(0x02C86E, in_Seed.NextUInt8(1, 11), "Quickman Number of Boomerangs");

            //0x02C882 - Boomerang: delay before arc 37. 0 for no arc, or above like 53. do from 5 to 53.
            in_Patch.Add(0x02C882, in_Seed.NextUInt8(5, 54), "Quickman Boomerang Delay 1");

            //0x02C887 - Boomerang speed when appearing, 4, do from 1 to 7
            in_Patch.Add(0x02C887, in_Seed.NextUInt8(1, 8), "Quickman Boomerang Velocity Integer 1");

            //0x03B726 - Boomerang speed secondary, 4, does this affect anything else?
            in_Patch.Add(0x03B726, in_Seed.NextUInt8(1, 8), "Quickman Boomerang Velocity Integer 2");

            // For all jumps, choose randomly from 2 to 10
            //0x02C8A3 - Middle jump, 7
            in_Patch.Add(0x02C8A3, in_Seed.NextUInt8(2, 11), "Quickman Jump Height 1 Integer");

            //0x02C8A4 - High jump, 8
            in_Patch.Add(0x02C8A4, in_Seed.NextUInt8(2, 11), "Quickman Jump Height 2 Integer");

            //0x02C8A5 - Low jump, 4
            in_Patch.Add(0x02C8A5, in_Seed.NextUInt8(2, 11), "Quickman Jump Height 3 Integer");

            //0x02C8E4 - Running time, 62, do from 24 to 80
            in_Patch.Add(0x02C8E4, in_Seed.NextUInt8(24, 81), "Quickman Running Time");

            //0x02C8DF - Running speed, 2, do from 1 to 5
            in_Patch.Add(0x02C8DF, in_Seed.NextUInt8(1, 6), "Quickman Running Velocity Integer");
        }
 public RecurringTasks(
     ISeed seed,
     ILogger logger)
 {
     this.seed = seed;
     this.log  = logger;
 }
Exemple #17
0
        public IEnumerable <IGameRecord> Traverse(ISeed relativeRoot, ISeedRootContext context)
        {
            string platformId = context.GetAllOfType("platform").FirstOrDefault()?.Content.Value;

            if (!this.StoneProvider.Platforms.Keys.Contains(platformId))
            {
                yield break;
            }

            var platform = this.StoneProvider.Platforms[platformId];

            var fileRecords = this.FileTraverser.Traverse(relativeRoot, context);

            foreach (var resultSeed in context.GetAllOfType("result"))
            {
                var children      = context.GetChildren(resultSeed);
                var metadataSeeds = context.GetDescendants(resultSeed)
                                    .DistinctBy(p => p.Content.Type).Select(p => p.Content);
                var gameRecord = new GameRecord(platform, resultSeed.Content.Value);
                foreach (var content in metadataSeeds)
                {
                    gameRecord.Metadata[$"game_{content.Type}"] = content.Value;
                }

                foreach (var file in fileRecords.Concat(this.FileTraverser.Traverse(resultSeed, context)))
                {
                    gameRecord.Files.Add(file);
                }

                yield return(gameRecord);
            }
        }
Exemple #18
0
        /// <summary>
        /// Reset the RNGCryptoServiceProvider instance.
        /// </summary>
        public void Reset()
        {
            if (_digestEngine != null)
            {
                _digestEngine.Dispose();
                _digestEngine = null;
            }
            if (_seedGenerator != null)
            {
                _seedGenerator.Dispose();
                _seedGenerator = null;
            }

            _digestEngine = GetDigest(_digestType);
            _rngGenerator = new DGCDrbg(_digestEngine);

            if (_stateSeed != null)
            {
                _rngGenerator.Initialize(_stateSeed);
            }
            else
            {
                _seedGenerator = GetSeedGenerator(_seedType);
                _rngGenerator.Initialize(_seedGenerator.GetSeed((_digestEngine.BlockSize * 2) + 8));   // 2 * block + counter (2*bs+8)
            }

            _rngGenerator.Generate(_byteBuffer);
            _bufferIndex = 0;
        }
Exemple #19
0
        /// <summary>
        /// Resize seed image to required dimensions. Convert to JPeg
        /// </summary>
        /// <param name="seed"></param>
        /// <returns></returns>
        public ISeed PrimeSeed(ISeed seed)
        {
            // Resize to required dimensions (converting to JPeg). Resize to width or height whichever is greater, keeping aspect ratio.
            seed.ImageData = ResizeImage(seed.ImageData, seed.Width > seed.Height ? seed.Width : seed.Height, ImageFormat.Jpeg);

            return(seed);
        }
Exemple #20
0
 private void Dispose(bool Disposing)
 {
     if (!m_isDisposed && Disposing)
     {
         try
         {
             if (m_ctrVector != null)
             {
                 Array.Clear(m_ctrVector, 0, m_ctrVector.Length);
                 m_ctrVector = null;
             }
             if (m_hashEngine != null)
             {
                 m_hashEngine.Dispose();
                 m_hashEngine = null;
             }
             if (m_seedEngine != null)
             {
                 m_seedEngine.Dispose();
                 m_seedEngine = null;
             }
         }
         finally
         {
             m_isDisposed = true;
         }
     }
 }
Exemple #21
0
        public ISeed Add(SeedContent content, ISeed parent, string source)
        {
            var seed = new Seed(content, Guid.NewGuid(), parent.Guid, source);

            this.Add(seed);
            return(seed);
        }
Exemple #22
0
        protected void ChangeMetal(Patch in_Patch, ISeed in_Seed)
        {
            // Unused addresses
            //0x02CC2D - Projectile type
            //0x02CC29 - Metal Blade sound effect 0x20

            // Metalman AI

            //0x02CC3F - Speed of Metal blade 4, do 2 to 9
            in_Patch.Add(0x02CC3F, in_Seed.NextUInt8(2, 10), "Metalman Projectile Velocity Integer");

            //0x02CC1D - Odd change to attack behavior, 0x06, only if different than 6. Give 25% chance.
            if (in_Seed.NextDouble() > 0.75)
            {
                in_Patch.Add(0x02CC1D, 0x05, "Metalman Alternate Attack Behavior");
            }

            //0x02CBB5 - Jump Height 1 0x06, do from 03 - 07 ? higher than 7 bonks ceiling
            //0x02CBB6 - Jump Height 2 0x05
            //0x02CBB7 - Jump Height 3 0x04

            // Shuffle the list of jump heights to get three different heights
            List <Byte> jumpHeight = in_Seed.Shuffle(new Byte[] { 3, 4, 5, 6, 7 }).ToList();

            for (Int32 i = 0; i < 3; i++)
            {
                in_Patch.Add(0x02CBB5 + i, jumpHeight[i], String.Format("Metalman Jump {0} Y-Velocity Integer", i + 1));
            }
        }
Exemple #23
0
        protected void ChangeFlash(Patch in_Patch, ISeed in_Seed)
        {
            // Unused addresses
            //0x02CA71 - Projectile type 0x35
            //0x02CA52 - "Length of time stopper / projectile frequency ?"

            // Flashman's AI

            //0x02C982 - Walk velocity integer 1, do from 0 to 3
            in_Patch.Add(0x02C982, in_Seed.NextUInt8(4), "Flashman Walk Velocity Integer");

            //0x02C97D - Walk velocity fraction 6, do 0 to 255
            in_Patch.Add(0x02C97D, in_Seed.NextUInt8(256), "Flashman Walk Velocity Fraction");

            //0x02C98B - Delay before time stopper 187 frames. Do from 30 frames to 240 frames
            in_Patch.Add(0x02C98B, in_Seed.NextUInt8(30, 241), "Flashman Delay Before Time Stopper");

            //0x02CAC6 - Jump distance integer 0, do 0 to 3
            // TODO do fraction also
            in_Patch.Add(0x02CAC6, in_Seed.NextUInt8(4), "Flashman Jump X-Velocity Integer");

            //0x02CACE - Jump height 4, do 3 to 8
            in_Patch.Add(0x02CACE, in_Seed.NextUInt8(3, 9), "Flashman Jump Y-Velocity Integer");

            //0x02CA81 - Projectile speed 8, do 2 to 10
            in_Patch.Add(0x02CA81, in_Seed.NextUInt8(2, 11), "Flashman Projectile Velocity Integer");

            //0x02CA09 - Number of projectiles to shoot 6, do 3 to 16
            in_Patch.Add(0x02CA09, in_Seed.NextUInt8(3, 17), "Flashman Number of Projectiles");
        }
        public override async Task <IEnumerable <SeedTreeAwaitable> > ScrapeAsync(ISeed parent,
                                                                                  ILookup <string, SeedContent> rootSeeds, ILookup <string, SeedContent> childSeeds,
                                                                                  ILookup <string, SeedContent> siblingSeeds)
        {
            string mimeType = childSeeds["mimetype"].First().Value;

            if (!File.Exists(parent.Content.Value) || !this.FileSignatures.Contains(mimeType))
            {
                return(_());
            }

            var signature = this.FileSignatures[mimeType];

            using (FileStream romStream = File.OpenRead(parent.Content.Value))
            {
                string serial       = signature.GetSerial(romStream);
                string internalName = signature.GetInternalName(romStream);

                IList <SeedTreeAwaitable> seedTrees = new List <SeedTreeAwaitable>();
                if (serial != null)
                {
                    seedTrees.Add(("rom_serial", serial));
                }

                if (internalName != null)
                {
                    seedTrees.Add(("rom_internal", internalName));
                }

                return(seedTrees);
            }
        }
Exemple #25
0
        ScrapeAsync(ISeed parent, ILookup <string, SeedContent> rootSeeds,
                    ILookup <string, SeedContent> childSeeds,
                    ILookup <string, SeedContent> siblingSeeds)
        {
            using (FileStream romStream = File.OpenRead(parent.Content.Value))
            {
                string inferredMimeType = this.GetMatchingMimetype(romStream);
                if (inferredMimeType != null)
                {
                    return(_("mimetype", inferredMimeType));
                }
            }

            string platformId = rootSeeds["platform"].First().Value;

            if (!this.StoneProvider.Platforms.TryGetValue(platformId, out var platform))
            {
                return(_());
            }

            if (platform.FileTypes.TryGetValue(Path.GetExtension(parent.Content.Value), out string mimeType))
            {
                return(_("mimetype", mimeType));
            }

            return(_("mimetype", MimeUtility.GetMimeMapping(parent.Content.Value)));
        }
Exemple #26
0
        /// <summary>
        /// Reset the seed <see cref="VTDev.Libraries.CEXEngine.Crypto.Enumeration.SeedGenerators">Seed Generator</see> and the <see cref="VTDev.Libraries.CEXEngine.Crypto.Enumeration.Digests">Digest</see> engines
        /// </summary>
        public void Reset()
        {
            if (m_seedEngine != null)
            {
                m_seedEngine.Dispose();
                m_seedEngine = null;
            }
            m_seedEngine = SeedGeneratorFromName.GetInstance(SeedEngine);

            // reset hash engine
            if (m_hashEngine != null)
            {
                m_hashEngine.Dispose();
                m_hashEngine = null;
            }
            m_hashEngine = DigestFromName.GetInstance(HashEngine);

            // if absent, generate the initial counter
            if (m_ctrLength == 0)
            {
                if (m_hashEngine.BlockSize < 72)
                {
                    m_ctrLength = CTRDEF_SIZE;
                }
                else
                {
                    m_ctrLength = CTRMAX_SIZE;
                }

                m_ctrVector = new byte[m_ctrLength];

                using (CSPRsg pool = new CSPRsg())
                    m_ctrVector = pool.GetBytes(m_ctrLength);
            }
        }
Exemple #27
0
        public static void Main()
        {
            Mapper.Initialize(mapper =>
                              mapper.AddProfiles(
                                  typeof(CommandsToEvents),
                                  typeof(EventsToDomain)));

            MartenDocumentStore.BootMartenDocumentStore();

            MartenDocumentStore.Store.Advanced.Clean.CompletelyRemoveAll();

            var allSeeds = new ISeed[]
            {
                new Countries(),
                new People(),
                new Sites(),
                new Aircraft(),
                //new Speeds(),
                //new VerifyAndRejectSpeedClaims(),
                //new UpdateASite(),
                //new EditSpeeds(),
            };

            using (var session = MartenDocumentStore.Store.LightweightSession())
            {
                foreach (var seed in allSeeds)
                {
                    Console.WriteLine($"Running DB Seed {seed.GetType().Name}");
                    seed.Run(MartenDocumentStore.Store.LightweightSession());
                    session.SaveChanges();
                }

                Console.WriteLine($"Finished running DB Seed...");
            }
        }
Exemple #28
0
        /// <summary>
        /// Reset the RNGCryptoServiceProvider instance.
        /// </summary>
        public void Reset()
        {
            if (_rngEngine != null)
            {
                _rngEngine.Dispose();
                _rngEngine = null;
            }
            if (_seedGenerator != null)
            {
                _seedGenerator.Dispose();
                _seedGenerator = null;
            }
            if (_rngGenerator != null)
            {
                _rngGenerator.Dispose();
                _rngGenerator = null;
            }

            _rngEngine     = GetCipher(_engineType);
            _seedGenerator = GetSeedGenerator(_seedType);
            _rngGenerator  = new CTRDrbg(_rngEngine, true, _keySize);

            if (_seedGenerator != null)
            {
                _rngGenerator.Initialize(_seedGenerator.GetSeed(_rngEngine.BlockSize + _keySize));
            }
            else
            {
                _rngGenerator.Initialize(_stateSeed);
            }

            _rngGenerator.Generate(_byteBuffer);
            _bufferIndex = 0;
        }
Exemple #29
0
        protected void ChangeBubble(Patch in_Patch, ISeed in_Seed)
        {
            // Bubbleman's AI

            //0x02C707 - Y-pos to reach before falling, 0x50.
            Byte[] BUBBLEMAN_HEIGHT_APEX_TABLE = { 80, 64, 80, 64, 96, 128 };
            in_Patch.Add(0x02C707, in_Seed.NextElement(BUBBLEMAN_HEIGHT_APEX_TABLE), "Bubbleman Y Max Height");

            //0x02C70B - Falling speed integer, 0xFF.
            Byte[] BUBBLEMAN_FALL_SPEED_TABLE = { 254, 255, 255, 255, 255 };
            in_Patch.Add(0x02C70B, in_Seed.NextElement(BUBBLEMAN_FALL_SPEED_TABLE), "Bubbleman Y-Velocity Falling");

            //0x02C710 - Landing x-tracking speed, integer, 0x00.
            Byte[] BUBBLEMAN_HORIZONTAL_TRACKING_SPEED_TABLE = { 0, 0, 0, 0, 0, 1 };
            in_Patch.Add(0x02C710, in_Seed.NextElement(BUBBLEMAN_HORIZONTAL_TRACKING_SPEED_TABLE), "Bubbleman X-Velocity Falling");

            //0x02C6D3 - Rising speed integer, 0x01.
            Byte[] BUBBLEMAN_RISING_SPEED_TABLE = { 1, 1, 2, 2, 3 };
            in_Patch.Add(0x02C6D3, in_Seed.NextElement(BUBBLEMAN_RISING_SPEED_TABLE), "Bubbleman Y-Velocity Rising");

            //0x02C745 - Delay between water gun shots, 0x12
            Byte[] BUBBLEMAN_ARM_CANNON_SHOT_DELAY_TABLE = { 4, 8, 12, 16, 18, 20, 24, 28 };
            in_Patch.Add(0x02C745, in_Seed.NextElement(BUBBLEMAN_ARM_CANNON_SHOT_DELAY_TABLE), "Bubbleman Water Gun Cooldown");

            // WARNING: THIS ADDRESS IS SHARED WITH THE VELOCITY OF THE DEATH BEAMS IN QUICKMAN STAGE!!
            ////0x03DA19 - X-Vel water gun, Int 0x04
            //bytes = new Byte[] { 0x02, 0x03, 0x04, 0x05, };
            //rInt = in_Seed.Next(bytes.Length);
            //in_Patch.Add(0x03DA19, bytes[rInt], "Bubbleman X-Vel Water Gun, Int");

            ////0x03DA1A - X-Vel water gun, Frac 0x40
            //bytes = new Byte[] { 0x40, 0x80, 0xC0, 0x00, };
            //rInt = in_Seed.Next(bytes.Length);
            //in_Patch.Add(0x03DA1A, bytes[rInt], "Bubbleman X-Vel Water Gun, Frac");

            //0x03DA25 - X-Vel bubble shot, Int 0x01
            Byte[] BUBBLEMAN_BUBBLE_LEAD_SHOT_X_VELOCITY_TABLE = { 0, 0, 1, 1, 2 };
            in_Patch.Add(0x03DA25, in_Seed.NextElement(BUBBLEMAN_BUBBLE_LEAD_SHOT_X_VELOCITY_TABLE), "Bubbleman X-Vel Bubble, Int");

            //0x03DA26 - X-Vel bubble shot, Frac 0x00
            Byte[] BUBBLEMAN_BUBBLE_LEAD_SHOT_X_VELOCITY_FRACTION_TABLE = { 128, 192, 255 };
            in_Patch.Add(0x03DA26, in_Seed.NextElement(BUBBLEMAN_BUBBLE_LEAD_SHOT_X_VELOCITY_FRACTION_TABLE), "Bubbleman X-Vel Bubble, Frac");

            //0x03DA4D - Y-Vel bubble shot initial, Int (0x03)
            Byte[] BUBBLEMAN_BUBBLE_LEAD_SHOT_Y_VELOCITY_TABLE = { 2, 3, 4, 5 };
            in_Patch.Add(0x03DA4D, in_Seed.NextElement(BUBBLEMAN_BUBBLE_LEAD_SHOT_Y_VELOCITY_TABLE), "Bubbleman Y-Vel Bubble Initial, Int");

            //0x03DA4E - Y-Vel bubble shot initial, Frac (0x76)
            Byte[] BUBBLEMAN_BUBBLE_LEAD_SHOT_Y_VELOCITY_FRACTION_TABLE = { 0, 64, 128, 192 };
            in_Patch.Add(0x03DA4E, in_Seed.NextElement(BUBBLEMAN_BUBBLE_LEAD_SHOT_Y_VELOCITY_FRACTION_TABLE), "Bubbleman Y-Vel Bubble Initial, Frac");

            //0x03B747 - Y-Vel bubble shot bounce, Int (0x03)
            Byte[] BUBBLEMAN_BUBBLE_LEAD_BOUNCE_Y_VELOCITY_TABLE = { 2, 3, 4, 5 };
            in_Patch.Add(0x03B747, in_Seed.NextElement(BUBBLEMAN_BUBBLE_LEAD_BOUNCE_Y_VELOCITY_TABLE), "Bubbleman Y-Vel Bubble Bounce, Int");

            //0x03B74C - Y-Vel bubble shot bounce, Frac (0x76)
            Byte[] BUBBLEMAN_BUBBLE_LEAD_BOUNCE_Y_VELOCITY_FRACTION_TABLE = { 0, 64, 128, 192 };
            in_Patch.Add(0x03B74C, in_Seed.NextElement(BUBBLEMAN_BUBBLE_LEAD_BOUNCE_Y_VELOCITY_FRACTION_TABLE), "Bubbleman Y-Vel Bubble Bounce, Frac");
        }
Exemple #30
0
        public void Randomize(Patch in_Patch, ISeed in_Seed)
        {
            debug.AppendLine();
            debug.AppendLine("Random Music Module");
            debug.AppendLine("--------------------------------------------");

            this.ImportMusic(in_Patch, in_Seed);
        }
Exemple #31
0
        /// <summary>
        /// Resize seed image to required dimensions. Convert to JPeg
        /// </summary>
        /// <param name="seed"></param>
        /// <returns></returns>
        public ISeed PrimeSeed(ISeed seed)
        {
            // Resize to required dimensions (converting to JPeg). Resize to width or height whichever is greater, keeping aspect ratio.
            seed.ImageData = ResizeImage(seed.ImageData, seed.Width > seed.Height ? seed.Width : seed.Height, ImageFormat.Jpeg);

            return seed;
        }
Exemple #32
0
        /// <summary>
        /// Reset the RNGCryptoServiceProvider instance.
        /// </summary>
        public void Reset()
        {
            if (_seedGenerator != null)
            {
                _seedGenerator.Dispose();
                _seedGenerator = null;
            }
            if (_rngGenerator != null)
            {
                _rngGenerator.Dispose();
                _rngGenerator = null;
            }

            _seedGenerator = GetSeedGenerator(_seedType);
            _rngGenerator = new SP20Drbg(_dfnRounds);

            if (_seedGenerator != null)
                _rngGenerator.Initialize(_seedGenerator.GetSeed(_keySize));
            else
                _rngGenerator.Initialize(_stateSeed);

            _rngGenerator.Generate(_byteBuffer);
            _bufferIndex = 0;
        }
Exemple #33
0
        /// <summary>
        /// Reset the CTRPrng instance
        /// </summary>
        public void Reset()
        {
            if (_rngEngine != null)
            {
                _rngEngine.Dispose();
                _rngEngine = null;
            }
            if (_seedGenerator != null)
            {
                _seedGenerator.Dispose();
                _seedGenerator = null;
            }
            if (_rngGenerator != null)
            {
                _rngGenerator.Dispose();
                _rngGenerator = null;
            }

            _rngEngine = GetCipher(_engineType);
            _seedGenerator = GetSeedGenerator(_seedType);
            _rngGenerator = new CTRDrbg(_rngEngine, true, _keySize);

            if (_seedGenerator != null)
                _rngGenerator.Initialize(_seedGenerator.GetSeed(_rngEngine.BlockSize + _keySize));
            else
                _rngGenerator.Initialize(_stateSeed);

            _rngGenerator.Generate(_byteBuffer);
            _bufferIndex = 0;
        }
 public void Setup()
 {
     _seed = new Seed32(999);
     _formatter = TestResourceFactory.CreateJsonFormatterWithoutArrayFormatting();
 }
Exemple #35
0
        /// <summary>
        /// Reset the RNGCryptoServiceProvider instance.
        /// </summary>
        public void Reset()
        {
            if (_digestEngine != null)
            {
                _digestEngine.Dispose();
                _digestEngine = null;
            }
            if (_seedGenerator != null)
            {
                _seedGenerator.Dispose();
                _seedGenerator = null;
            }

            _digestEngine = GetDigest(_digestType);
            _rngGenerator = new DGCDrbg(_digestEngine);

            if (_stateSeed != null)
            {
                _rngGenerator.Initialize(_stateSeed);
            }
            else
            {
                _seedGenerator = GetSeedGenerator(_seedType);
                _rngGenerator.Initialize(_seedGenerator.GetSeed((_digestEngine.BlockSize * 2) + 8));   // 2 * block + counter (2*bs+8)
            }

            _rngGenerator.Generate(_byteBuffer);
            _bufferIndex = 0;
        }
Exemple #36
0
        private void Dispose(bool Disposing)
        {
            if (!_isDisposed && Disposing)
            {
                try
                {
                    if (_rngGenerator != null)
                    {
                        _rngGenerator.Dispose();
                        _rngGenerator = null;
                    }
                    if (_seedGenerator != null)
                    {
                        _seedGenerator.Dispose();
                        _seedGenerator = null;
                    }
                    if (_byteBuffer != null)
                    {
                        Array.Clear(_byteBuffer, 0, _byteBuffer.Length);
                        _byteBuffer = null;
                    }
                }
                catch { }

                _isDisposed = true;
            }
        }
 public void Setup()
 {
     _seed = new Seed32(999);
     _formatter = TestResourceFactory.CreateJsonFormatter();
 }
Exemple #38
0
 /// <summary>
 /// Persist the supplied seed and assign an ID
 /// </summary>
 /// <param name="seed"></param>
 /// <returns></returns>
 public ISeed Save(ISeed seed)
 {
     seed.Id = seed.Id ?? Guid.NewGuid().ToString("N");
       seedCollection.Save(seed.ToBsonDocument());
       return seed;
 }