Exemple #1
0
        private SC3Module(Stream stream, bool leaveOpen)
        {
            _leaveOpen   = leaveOpen;
            ModuleStream = stream;
            ModuleReader = new BinaryReader(ModuleStream);
            ModuleWriter = new BinaryWriter(ModuleStream);

            _stringTable          = new List <StringHandle>();
            _pendingStringUpdates = new Dictionary <int, byte[]>();

            var headerBytes = ModuleReader.ReadBytes(HeaderSize);

            try
            {
                Game             = IdentifySC3Game(headerBytes);
                GameSpecificData = GameSpecificData.For(Game);
            }
            catch
            {
                ReleaseResources();
                throw new InvalidDataException("The specified file is not a supported SC3 module.");
            }

            ParseHeader(headerBytes);
            ReadMetadata();

            ModuleStream.Position = 0;
        }
Exemple #2
0
        private SC3Game IdentifySC3Game(byte[] headerBytes)
        {
            string strHeader      = BinaryUtils.BytesToHexString(headerBytes);
            var    supportedGames = GameSpecificData.SupportedGames;

            return(supportedGames.Single(game => GameSpecificData.For(game).SupportedModules.Contains(strHeader)));
        }