Beispiel #1
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)));
        }
Beispiel #2
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;
        }
Beispiel #3
0
 static GameSpecificData()
 {
     SupportedGames = Enum.GetValues(typeof(SC3Game)).Cast <SC3Game>().ToImmutableArray();
     s_instances    = new Dictionary <SC3Game, GameSpecificData>();
     foreach (SC3Game game in SupportedGames)
     {
         s_instances[game] = new GameSpecificData(game);
     }
 }