Esempio n. 1
0
 /// <summary>
 /// Creates a new MapHeader object with width and height of zero
 /// </summary>
 public MapHeader()
 {
     Footer      = new MapFooter();
     Events      = new EventHeader();
     MapScripts  = new MapScriptHeader();
     Connections = new ConnectionHeader();
 }
Esempio n. 2
0
        /// <summary>
        /// Reads LevelScript Data from a ROM
        /// </summary>
        /// <param name="reader">BinaryReader object to read from</param>
        /// <param name="levelScriptOffset">Offset of levelscript data in ROM</param>
        /// <param name="prefix">Prefix to put in front of levelscript symbols</param>
        /// <returns>MapScriptHeader object containing the levelscripts of the Map</returns>
        private static MapScriptHeader LevelScriptsFromReader(BinaryReader reader, uint levelScriptOffset, string prefix)
        {
            MapScriptHeader scriptHeader = new MapScriptHeader();

            reader.BaseStream.Seek(levelScriptOffset & 0x1FFFFFF, SeekOrigin.Begin);
            byte scrType;
            int  i = 0;

            while ((scrType = reader.ReadByte()) != 0)
            {
                MapScript script  = new MapScript((MapScript.MapScriptTypes)scrType);
                uint      sIntern = 0;
                switch (script.Layout)
                {
                case MapScript.MapScriptLayout.Script:

                    //TODO: Save internal stuff
                    sIntern = reader.ReadUInt32();
                    break;

                case MapScript.MapScriptLayout.ExtendedScript:
                    long pos = reader.BaseStream.Position + 4;
                    reader.BaseStream.Seek(reader.ReadUInt32() & 0x1FFFFFF, SeekOrigin.Begin);
                    script.Variable = reader.ReadUInt16();
                    script.Value    = reader.ReadUInt16();
                    sIntern         = reader.ReadUInt32();
                    //TODO: Save internal stuff
                    reader.BaseStream.Seek(pos, SeekOrigin.Begin);
                    break;

                case MapScript.MapScriptLayout.None:
                    throw new Exception("invalid code reached");
                }
                script.Script = "0x" + sIntern.ToString("X8");
                scriptHeader.MapScripts.Add(script);
                i++;
            }
            return(scriptHeader);
        }