Esempio n. 1
0
        bool readMapSpawns()
        {
            string fname = iSrcDir + "dir_bin";

            if (!File.Exists(fname))
            {
                Console.WriteLine("Could not read dir_bin file!");
                return(false);
            }

            using (BinaryReader binaryReader = new BinaryReader(File.Open(fname, FileMode.Open, FileAccess.Read)))
            {
                Console.WriteLine("Read coordinate mapping...");
                uint       mapID, tileX, tileY;
                ModelSpawn spawn;

                while (binaryReader.BaseStream.Position + 4 < binaryReader.BaseStream.Length)
                {
                    // read mapID, tileX, tileY, Flags, adtID, ID, Pos, Rot, Scale, Bound_lo, Bound_hi, name
                    mapID = binaryReader.ReadUInt32();
                    tileX = binaryReader.ReadUInt32();
                    tileY = binaryReader.ReadUInt32();
                    if (!ModelSpawn.readFromFile(binaryReader, out spawn))
                    {
                        break;
                    }

                    MapSpawns current;
                    if (!mapData.ContainsKey(mapID))
                    {
                        Console.WriteLine($"spawning Map {mapID}");
                        current        = new MapSpawns();
                        mapData[mapID] = current;
                    }
                    else
                    {
                        current = mapData[mapID];
                    }

                    if (!current.UniqueEntries.ContainsKey(spawn.ID))
                    {
                        current.UniqueEntries.Add(spawn.ID, spawn);
                    }
                    current.TileEntries.Add(StaticMapTree.packTileID(tileX, tileY), spawn.ID);
                }
            }

            return(true);
        }
Esempio n. 2
0
        bool readMapSpawns()
        {
            string fname = iSrcDir + "dir_bin";

            if (!File.Exists(fname))
            {
                Console.WriteLine("Could not read dir_bin file!");
                return(false);
            }

            using (BinaryReader binaryReader = new BinaryReader(File.Open(fname, FileMode.Open, FileAccess.Read, FileShare.Read)))
            {
                Console.WriteLine("Read coordinate mapping...");
                long fileLength = binaryReader.BaseStream.Length;
                while (binaryReader.BaseStream.Position + 4 < fileLength)
                {
                    // read mapID, Flags, NameSet, UniqueId, Pos, Rot, Scale, Bound_lo, Bound_hi, name
                    uint mapID = binaryReader.ReadUInt32();

                    ModelSpawn spawn;
                    if (!ModelSpawn.ReadFromFile(binaryReader, out spawn))
                    {
                        break;
                    }

                    if (!mapData.ContainsKey(mapID))
                    {
                        Console.WriteLine($"spawning Map {mapID}");
                        mapData[mapID] = new MapSpawns(mapID);
                    }

                    MapSpawns current = mapData[mapID];
                    if (!current.UniqueEntries.ContainsKey(spawn.ID))
                    {
                        current.UniqueEntries.Add(spawn.ID, spawn);
                    }
                }
            }

            return(true);
        }