Esempio n. 1
0
        public static void read(RobotFile f, Stream s)
        {
            MacBinary mbin = new MacBinary(s);

            f.name = mbin.filename;

            if (mbin.res.Contains(resPasswordType) && mbin.res[resPasswordType].Contains(resPasswordID))
            {
                byte[] passbytes = mbin.res[resPasswordType][resPasswordID].data;
                f.password = MacUtil.readString(passbytes, 0, passbytes.Length);
                f.locked = true;
            }
            else
                f.locked = false;

            if (mbin.res.Contains(resCodeLengthType) && mbin.res[resCodeLengthType].Contains(resCodeLengthID) &&
                mbin.res.Contains(resRobotCodeType) && mbin.res[resRobotCodeType].Contains(resRobotCodeID))
            {
                //int codelen = Util.read16(mbin.res[resCodeLengthType][resCodeLengthID].data, 0);
                f.program = mbin.res[resRobotCodeType][resRobotCodeID].data;
            }

            if (mbin.res.Contains(resColorIconType))
            {
                MacResourceType t = mbin.res[resColorIconType];
                for (int i = 0; i < 10; i++)
                {
                    if (!t.Contains(resIconMinID + i))
                        continue;

                    byte[] iconbytes = t[resIconMinID + i].data;
                    // FIXME: set up icon
                }
            }
            if (mbin.res.Contains(resIconType))
            {
                MacResourceType t = mbin.res[resIconType];
                for (int i = 0; i < 10; i++)
                {
                    if (f.icons[i] != null || !t.Contains(resIconMinID + i))
                        continue;

                    byte[] iconbytes = t[resIconMinID + i].data;
                    // FIXME: set up icon
                }
            }

            if (mbin.res.Contains(resSoundType))
            {
                MacResourceType t = mbin.res[resSoundType];
                for (int i = 0; i < 10; i++)
                {
                    if (!t.Contains(resSoundMinID + i))
                        continue;

                    byte[] soundbytes = t[resSoundMinID + i].data;
                    // FIXME: set up sound
                }
            }

            if (mbin.res.Contains(resHardwareType) && mbin.res[resHardwareType].Contains(resHardwareID))
            {
                byte[] hardbytes = mbin.res[resHardwareType][resHardwareID].data;
                if (hardbytes.Length >= 40)
                {
                    f.hardware.energyMax = MacUtil.read16(hardbytes, 0);
                    f.hardware.damageMax = MacUtil.read16(hardbytes, 2);
                    f.hardware.shieldMax = MacUtil.read16(hardbytes, 4);
                    f.hardware.processorSpeed = MacUtil.read16(hardbytes, 6);
                    int gun = MacUtil.read16(hardbytes, 8);
                    switch (gun)
                    {
                    case 1: f.hardware.gunType = BulletType.Rubber; break;
                    case 3: f.hardware.gunType = BulletType.Explosive; break;
                    case 2:
                    default: f.hardware.gunType = BulletType.Normal; break;
                    }
                    f.hardware.hasMissiles = MacUtil.read16(hardbytes, 10) > 0;
                    f.hardware.hasTacNukes = MacUtil.read16(hardbytes, 12) > 0;
                    // ignore advantages
                    f.hardware.hasLasers = MacUtil.read16(hardbytes, 16) > 0;
                    f.hardware.hasHellbores = MacUtil.read16(hardbytes, 18) > 0;
                    f.hardware.hasDrones = MacUtil.read16(hardbytes, 20) > 0;
                    f.hardware.hasMines = MacUtil.read16(hardbytes, 22) > 0;
                    f.hardware.hasStunners = MacUtil.read16(hardbytes, 24) > 0;
                    f.hardware.noNegEnergy = MacUtil.read16(hardbytes, 26) > 0;
                    f.hardware.probeFlag = MacUtil.read16(hardbytes, 28) > 0;
                    f.hardware.deathIconFlag = MacUtil.read16(hardbytes, 30) > 0;
                    f.hardware.collisionIconFlag = MacUtil.read16(hardbytes, 32) > 0;
                    f.hardware.shieldHitIconFlag = MacUtil.read16(hardbytes, 34) > 0;
                    f.hardware.hitIconFlag = MacUtil.read16(hardbytes, 36) > 0;
                    f.hardware.shieldOnIconFlag = MacUtil.read16(hardbytes, 38) > 0;
                }
            }

            if (mbin.res.Contains(resTurretType) && mbin.res[resTurretType].Contains(resTurretID))
            {
                byte[] turtbytes = mbin.res[resTurretType][resTurretID].data;
                if (turtbytes.Length >= 2)
                {
                    int turt = MacUtil.read16(turtbytes, 0);
                    switch (turt)
                    {
                        case 2: f.turretType = TurretType.Dot; break;
                        case 3: f.turretType = TurretType.None; break;
                        case 1:
                        default: f.turretType = TurretType.Line; break;
                    }
                }
            }
        }
Esempio n. 2
0
        public static void read(RobotFile f, Stream s)
        {
            MacBinary mbin = new MacBinary(s);

            f.name = mbin.filename;

            if (mbin.res.Contains(resPasswordType) && mbin.res[resPasswordType].Contains(resPasswordID))
            {
                byte[] passbytes = mbin.res[resPasswordType][resPasswordID].data;
                f.password = MacUtil.readString(passbytes, 0, passbytes.Length);
                f.locked   = true;
            }
            else
            {
                f.locked = false;
            }

            if (mbin.res.Contains(resCodeLengthType) && mbin.res[resCodeLengthType].Contains(resCodeLengthID) &&
                mbin.res.Contains(resRobotCodeType) && mbin.res[resRobotCodeType].Contains(resRobotCodeID))
            {
                //int codelen = Util.read16(mbin.res[resCodeLengthType][resCodeLengthID].data, 0);
                f.program = mbin.res[resRobotCodeType][resRobotCodeID].data;
            }

            if (mbin.res.Contains(resColorIconType))
            {
                MacResourceType t = mbin.res[resColorIconType];
                for (int i = 0; i < 10; i++)
                {
                    if (!t.Contains(resIconMinID + i))
                    {
                        continue;
                    }

                    byte[] iconbytes = t[resIconMinID + i].data;
                    // FIXME: set up icon
                }
            }
            if (mbin.res.Contains(resIconType))
            {
                MacResourceType t = mbin.res[resIconType];
                for (int i = 0; i < 10; i++)
                {
                    if (f.icons[i] != null || !t.Contains(resIconMinID + i))
                    {
                        continue;
                    }

                    byte[] iconbytes = t[resIconMinID + i].data;
                    // FIXME: set up icon
                }
            }

            if (mbin.res.Contains(resSoundType))
            {
                MacResourceType t = mbin.res[resSoundType];
                for (int i = 0; i < 10; i++)
                {
                    if (!t.Contains(resSoundMinID + i))
                    {
                        continue;
                    }

                    byte[] soundbytes = t[resSoundMinID + i].data;
                    // FIXME: set up sound
                }
            }

            if (mbin.res.Contains(resHardwareType) && mbin.res[resHardwareType].Contains(resHardwareID))
            {
                byte[] hardbytes = mbin.res[resHardwareType][resHardwareID].data;
                if (hardbytes.Length >= 40)
                {
                    f.hardware.energyMax      = MacUtil.read16(hardbytes, 0);
                    f.hardware.damageMax      = MacUtil.read16(hardbytes, 2);
                    f.hardware.shieldMax      = MacUtil.read16(hardbytes, 4);
                    f.hardware.processorSpeed = MacUtil.read16(hardbytes, 6);
                    int gun = MacUtil.read16(hardbytes, 8);
                    switch (gun)
                    {
                    case 1: f.hardware.gunType = BulletType.Rubber; break;

                    case 3: f.hardware.gunType = BulletType.Explosive; break;

                    case 2:
                    default: f.hardware.gunType = BulletType.Normal; break;
                    }
                    f.hardware.hasMissiles = MacUtil.read16(hardbytes, 10) > 0;
                    f.hardware.hasTacNukes = MacUtil.read16(hardbytes, 12) > 0;
                    // ignore advantages
                    f.hardware.hasLasers         = MacUtil.read16(hardbytes, 16) > 0;
                    f.hardware.hasHellbores      = MacUtil.read16(hardbytes, 18) > 0;
                    f.hardware.hasDrones         = MacUtil.read16(hardbytes, 20) > 0;
                    f.hardware.hasMines          = MacUtil.read16(hardbytes, 22) > 0;
                    f.hardware.hasStunners       = MacUtil.read16(hardbytes, 24) > 0;
                    f.hardware.noNegEnergy       = MacUtil.read16(hardbytes, 26) > 0;
                    f.hardware.probeFlag         = MacUtil.read16(hardbytes, 28) > 0;
                    f.hardware.deathIconFlag     = MacUtil.read16(hardbytes, 30) > 0;
                    f.hardware.collisionIconFlag = MacUtil.read16(hardbytes, 32) > 0;
                    f.hardware.shieldHitIconFlag = MacUtil.read16(hardbytes, 34) > 0;
                    f.hardware.hitIconFlag       = MacUtil.read16(hardbytes, 36) > 0;
                    f.hardware.shieldOnIconFlag  = MacUtil.read16(hardbytes, 38) > 0;
                }
            }

            if (mbin.res.Contains(resTurretType) && mbin.res[resTurretType].Contains(resTurretID))
            {
                byte[] turtbytes = mbin.res[resTurretType][resTurretID].data;
                if (turtbytes.Length >= 2)
                {
                    int turt = MacUtil.read16(turtbytes, 0);
                    switch (turt)
                    {
                    case 2: f.turretType = TurretType.Dot; break;

                    case 3: f.turretType = TurretType.None; break;

                    case 1:
                    default: f.turretType = TurretType.Line; break;
                    }
                }
            }
        }