示例#1
0
        void loadData(bool r, Data data, Data objPlaces)
        {
            HashSet<ushort> ids = new HashSet<ushort>();
            for (uint i = 0; i < romIF.preparedList_count; i++)
            {
                var h = data.getHalf(i * 2);
                if (h == 0xffff) break;
                ids.Add(h);
            }
            oldIDs = ids.OrderBy(x => x).ToList();

            HashSet<ushort> t = r ? resolve(ids, objPlaces) : new HashSet<ushort>();
            newResolved = t.Except(ids).ToList();
            resolved = t.Except(newResolved).ToList();
            additional = ids.Except(t).ToList();
        }
示例#2
0
文件: Map.cs 项目: anta-/YSedit
        /// <summary>
        /// Mapに関してデータを読み、初期化をする
        /// </summary>
        /// <exception cref="ArgumentException">mapNumberが大きすぎた場合</exception>
        /// <exception cref="DataException">mapNumberが無効なマップを指している、またはROMが壊れている場合</exception>
        public Map(ROM rom_, byte mapNumber, MainView mainView)
        {
            rom = rom_;
            romIF = rom.romIF;
            this.mainView = mainView;
            mainView.onChanged += () => { rom.newChange(true); };

            if (romIF.mapNumbers <= mapNumber)
                throw new ArgumentException("map number is too big");

            currentMapNumber = mapNumber;
            ustruct5 = rom.readData(romIF.ustruct5Table + mapNumber * romIF.ustruct5_size, romIF.ustruct5_size);
            var iUStruct3 = ustruct5.getDataID(romIF.uttruct5_iUStruct3);
            ustruct3 = rom.readData(iUStruct3, romIF.ustruct3_size);
            var iiPlaceVector = ustruct3.getDataID(romIF.ustruct3_iiPlaceVector);
            var iPlaceVector = rom.readData(iiPlaceVector, 4).getDataID(0);
            placeVector = rom.readData(iPlaceVector, romIF.placeVector_size);
            var iObjPlaces = placeVector.getDataID(romIF.placeVector_iObjPlaces);
            var objPlaces = rom.readData(iObjPlaces,
                placeVector.getHalf(romIF.placeVector_numberOfObjPlaces) * romIF.objPlaceC_size);

            mainView.setObjPlaces(objPlaces);   //objPlacesはmainViewが持つ
            mainView.size = new System.Drawing.Size(0x2000, 0x200); //TODO: データから読み込む
        }
示例#3
0
        HashSet<ushort> resolve(HashSet<ushort> ids, Data objPlaces)
        {
            HashSet<ushort> s = new HashSet<ushort>();

            Action<ushort,string> addObject = (ushort k, string info) =>
            {
                if (s.Contains(k))
                    return;
                infoText += info + " -> " + k.ToString("x4") + "\n";
                s.Add(k);
            };

            foreach (var k in romIF.basicObjects)
                addObject(k, "basic");

            int numberOfObjs = (int)(objPlaces.Length / romIF.objPlaceC_size);
            for (uint i = 0; i < numberOfObjs; i++)
            {
                var kind = objPlaces.getHalf(i * romIF.objPlaceC_size + romIF.objPlace_kind);
                foreach (var dep in ObjectInfo.getObjectDependents(kind))
                {
                    switch (dep.c)
                    {
                        case ObjectInfo.Dependent.Case.ObjCfg:
                            addObject((ushort)dep.a, "#" + kind.ToString("x4"));
                            break;
                        case ObjectInfo.Dependent.Case.ObjFunc:
                            var ks = ObjectInfo.getFuncObjects(dep.a);
                            if (ks.Count == 0)
                            {
                                //どうしようもない
                                infoText += "!" + kind.ToString("x4") + "->" + dep.a.ToString("x8") + "\n";
                                break;
                            }
                            if (!ks.Any(k => s.Contains(k)))
                            {
                                if (ks.Any(k => ids.Contains(k)))
                                    addObject(ks.Find(k => ids.Contains(k)), "%" + kind.ToString("x4"));
                                else
                                    addObject(ks[0], "$" + kind.ToString("x4"));
                            }
                            break;
                    }
                }
            }

            for (uint i = 0; i < numberOfObjs; i++)
            {
                var kind = objPlaces.getHalf(i * romIF.objPlaceC_size + romIF.objPlace_kind);
                if (s.Remove(kind))
                    infoText += kind.ToString("x4") + " remove" + "\n";
            }

            return s;
        }