コード例 #1
0
ファイル: World.cs プロジェクト: jordsti/TPulse
        private void ReadChests()
        {
            Boolean isChest;
            Byte itemCount;
            Chest theChest = null;
            Item theItem;
            Int32 i, j;
            chests = new List<Chest>();

            if (bw != null)
                bw.ReportProgress((Int32)(((Single)progressPosition / stream.Length) * readWorldPerc)
                    , "Reading Chests");

            for (i = 0; i < 1000; i++)
            {
                isChest = reader.ReadBoolean();

                if (isChest == true)
                {
                    theChest = new Chest();
                    theChest.ChestId = i;
                    theChest.Active = isChest;

                    theChest.Coordinates = new Point(reader.ReadInt32(), reader.ReadInt32());

                    if (chestTypeList != null)
                    {
                        if (chestTypeList.ContainsKey(theChest.Coordinates))
                            theChest.Type = chestTypeList[theChest.Coordinates];
                    }
                    else
                    {
                        theChest.Type = ChestType.Chest;
                    }

                    for (j = 0; j < 20; j++)
                    {
                        itemCount = reader.ReadByte();

                        if (itemCount > 0)
                        {
                            theItem = new Item();
                            theItem.Id = j;
                            theItem.Count = itemCount;

                            if (header.ReleaseNumber >= 0x26)
                            {
                                theItem.Name = Global.Instance.Info.GetItemName(reader.ReadInt32());
                            }
                            else
                            {
                                theItem.Name = reader.ReadString();
                            }

                            if (header.ReleaseNumber >= 0x24)
                                theItem.Prefix = reader.ReadByte();

                            theChest.Items.Add(theItem);
                        }
                    }
                    chests.Add(theChest);
                }

                progressPosition = stream.Position;
            }

            posSigns = stream.Position;
        }
コード例 #2
0
ファイル: BackwardsScanner.cs プロジェクト: jordsti/TPulse
        /// <summary>
        /// Tries to make the next bytes backward in the stream fit into an Chest object.
        /// If it fails sets the position back to where it was.
        /// This does nothing at all for the items in the chest, only the Chest itself.
        /// </summary>
        /// <returns>An Chest object.  Active will be true on any valid Chest.</returns>
        private Chest tryReadChestHeaderBackwards()
        {
            Int32 x, y;
            Int32 strictBool;
            Chest returnChest = new Chest();
            long oldPosition = stream.Position;
            Boolean validChest = false;

            #if (DEBUG == false)
            try
            {
            #endif
                y = backReader.ReadBackwardsInt32();
                x = backReader.ReadBackwardsInt32();

                returnChest.Coordinates = new Point(x, y);

                strictBool = backReader.ReadBackwardsByte();

                if (strictBool == 1)
                    returnChest.Active = true;

                if (returnChest.Active == true && x != 00 && y != 00 && x < MaxX && y < MaxY)
                    validChest = true;
            #if (DEBUG == false)
            }
            catch (EndOfStreamException e)
            {
                e.GetType();
            }
            #endif

            if (validChest == false)
            {
                stream.Seek(oldPosition, SeekOrigin.Begin);
                returnChest.Active = false;
            }

            return returnChest;
        }