Exemplo n.º 1
0
        public static SkyTimeOfDay Read(DatReader datReader)
        {
            SkyTimeOfDay obj = new SkyTimeOfDay();

            obj.Begin      = datReader.ReadSingle();
            obj.DirBright  = datReader.ReadSingle();
            obj.DirHeading = datReader.ReadSingle();
            obj.DirPitch   = datReader.ReadSingle();
            obj.DirColor   = datReader.ReadUInt32();

            obj.AmbBright = datReader.ReadSingle();
            obj.AmbColor  = datReader.ReadUInt32();

            obj.MinWorldFog   = datReader.ReadSingle();
            obj.MaxWorldFog   = datReader.ReadSingle();
            obj.WorldFogColor = datReader.ReadUInt32();
            obj.WorldFog      = datReader.ReadUInt32();

            uint num_sky_obj_replace = datReader.ReadUInt32();

            for (uint i = 0; i < num_sky_obj_replace; i++)
            {
                obj.SkyObjReplace.Add(SkyObjectReplace.Read(datReader));
            }

            return(obj);
        }
Exemplo n.º 2
0
        public static Palette ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((Palette)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                Palette   obj       = new Palette();
                obj.Id = datReader.ReadUInt32();

                uint num_colors = datReader.ReadUInt32();
                for (uint i = 0; i < num_colors; i++)
                {
                    obj.Colors.Add(datReader.ReadUInt32());
                }

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = obj;

                return(obj);
            }
        }
Exemplo n.º 3
0
        public static GfxObjDegradeInfo ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((GfxObjDegradeInfo)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader         datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                GfxObjDegradeInfo obj       = new GfxObjDegradeInfo();

                obj.Id = datReader.ReadUInt32();

                uint num_degrades = datReader.ReadUInt32();
                for (uint i = 0; i < num_degrades; i++)
                {
                    obj.Degrades.Add(GfxObjInfo.Read(datReader));
                }

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = obj;

                return(obj);
            }
        }
Exemplo n.º 4
0
        public static Environment ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((Environment)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader   datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                Environment obj       = new Environment();

                obj.Id = datReader.ReadUInt32(); // this will match fileId

                uint numCells = datReader.ReadUInt32();

                for (uint i = 0; i < numCells; i++)
                {
                    uint cellstuctId = datReader.ReadUInt32();
                    obj.Cells.Add(cellstuctId, CellStruct.Read(datReader));
                }

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = obj;

                return(obj);
            }
        }
Exemplo n.º 5
0
        public static Scene ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((Scene)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader datReader = DatManager.PortalDat.GetReaderForFile(fileId);

                Scene obj = new Scene();

                obj.SceneId = datReader.ReadUInt32();

                uint num_objects = datReader.ReadUInt32();
                for (uint i = 0; i < num_objects; i++)
                {
                    obj.Objects.Add(ObjectDesc.Read(datReader));
                }

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = obj;

                return(obj);
            }
        }
Exemplo n.º 6
0
        public static PhysicsScriptTable ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((PhysicsScriptTable)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader          datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                PhysicsScriptTable obj       = new PhysicsScriptTable();
                obj.Id = datReader.ReadUInt32();

                uint script_table_length = datReader.ReadUInt32();
                for (uint i = 0; i < script_table_length; i++)
                {
                    uint key = datReader.ReadUInt32();
                    PhysicsScriptTableData value = PhysicsScriptTableData.Read(datReader);
                    obj.ScriptTable.Add(key, value);
                }

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = obj;

                return(obj);
            }
        }
Exemplo n.º 7
0
        public static MotionData Read(DatReader datReader)
        {
            MotionData md = new Entity.MotionData();

            byte numAnims = datReader.ReadByte();

            md.Bitfield  = datReader.ReadByte();
            md.Bitfield2 = datReader.ReadByte();
            datReader.AlignBoundary();

            for (byte i = 0; i < numAnims; i++)
            {
                AnimData animData = new AnimData();
                animData.AnimId    = datReader.ReadUInt32();
                animData.LowFrame  = datReader.ReadUInt32();
                animData.HighFrame = datReader.ReadUInt32();
                animData.Framerate = datReader.ReadSingle();
                md.Anims.Add(animData);
            }

            if ((md.Bitfield2 & 1) > 0)
            {
                md.Velocity = new AceVector3(datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle());
            }

            if ((md.Bitfield2 & 2) > 0)
            {
                md.Omega = new AceVector3(datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle());
            }

            return(md);
        }
Exemplo n.º 8
0
        public static ContractTable ReadFromDat()
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(CONTRACT_TABLE_ID))
            {
                return((ContractTable)DatManager.PortalDat.FileCache[CONTRACT_TABLE_ID]);
            }
            else
            {
                DatReader     datReader = DatManager.PortalDat.GetReaderForFile(CONTRACT_TABLE_ID);
                ContractTable obj       = new ContractTable();

                obj.Id = datReader.ReadUInt32();

                ushort num_contracts = datReader.ReadUInt16();
                ushort table_size    = datReader.ReadUInt16(); // We don't need this since C# handles it's own memory
                for (ushort i = 0; i < num_contracts; i++)
                {
                    uint     key   = datReader.ReadUInt32();
                    Contract value = Contract.Read(datReader);
                    obj.Contracts.Add(key, value);
                }

                DatManager.PortalDat.FileCache[CONTRACT_TABLE_ID] = obj;
                return(obj);
            }
        }
Exemplo n.º 9
0
        public static PaletteSet ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((PaletteSet)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader  datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                PaletteSet p         = new PaletteSet();
                p.PaletteSetId = datReader.ReadUInt32();

                uint numpalettesets = datReader.ReadUInt32();
                for (int i = 0; i < numpalettesets; i++)
                {
                    p.PaletteList.Add(datReader.ReadUInt32());
                }

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = p;

                return(p);
            }
        }
Exemplo n.º 10
0
        public static Surface ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((Surface)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                Surface   obj       = new Surface();

                obj.Type = (SurfaceType)datReader.ReadUInt32();

                if (((uint)obj.Type & 6) > 0)
                {
                    obj.OrigTextureId = datReader.ReadUInt32();
                    obj.OrigPaletteId = datReader.ReadUInt32();
                }
                else
                {
                    obj.ColorValue = datReader.ReadUInt32();
                }

                obj.Translucency = datReader.ReadSingle();
                obj.Luminosity   = datReader.ReadSingle();
                obj.Diffuse      = datReader.ReadSingle();

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = obj;

                return(obj);
            }
        }
Exemplo n.º 11
0
        public static CombatManeuverTable ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((CombatManeuverTable)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader           datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                CombatManeuverTable obj       = new CombatManeuverTable();

                obj.Id = datReader.ReadUInt32(); // This should always equal the fileId

                uint num_combat_maneuvers = datReader.ReadUInt32();
                for (uint i = 0; i < num_combat_maneuvers; i++)
                {
                    obj.CMT.Add(CombatManeuver.Read(datReader));
                }

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = obj;

                return(obj);
            }
        }
Exemplo n.º 12
0
        public static PhysicsScript ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((PhysicsScript)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader     datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                PhysicsScript obj       = new PhysicsScript();
                obj.Id = datReader.ReadUInt32();

                uint num_script_data = datReader.ReadUInt32();
                for (uint i = 0; i < num_script_data; i++)
                {
                    obj.ScriptData.Add(PhysicsScriptData.Read(datReader));
                }

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = obj;

                return(obj);
            }
        }
Exemplo n.º 13
0
        public static BSPPortal ReadPortal(DatReader datReader, BSPType treeType)
        {
            BSPPortal obj = new BSPPortal();

            obj.Type           = 0x504F5254; // PORT
            obj.SplittingPlane = Plane.Read(datReader);
            obj.PosNode        = BSPNode.Read(datReader, treeType);
            obj.NegNode        = BSPNode.Read(datReader, treeType);

            if (treeType == BSPType.Drawing)
            {
                obj.Sphere = CSphere.Read(datReader);

                uint numPolys   = datReader.ReadUInt32();
                uint numPortals = datReader.ReadUInt32();

                for (uint i = 0; i < numPolys; i++)
                {
                    obj.InPolys.Add(datReader.ReadUInt16());
                }

                for (uint i = 0; i < numPortals; i++)
                {
                    obj.InPortals.Add(PortalPoly.Read(datReader));
                }
            }

            return(obj);
        }
Exemplo n.º 14
0
        public static TerrainAlphaMap Read(DatReader datReader)
        {
            TerrainAlphaMap obj = new TerrainAlphaMap();

            obj.TCode  = datReader.ReadUInt32();
            obj.TexGID = datReader.ReadUInt32();
            return(obj);
        }
Exemplo n.º 15
0
        public static RoadAlphaMap Read(DatReader datReader)
        {
            RoadAlphaMap obj = new RoadAlphaMap();

            obj.RCode      = datReader.ReadUInt32();
            obj.RoadTexGID = datReader.ReadUInt32();
            return(obj);
        }
Exemplo n.º 16
0
        } = new List <ushort>();                                        // List of PolygonIds

        public static BSPNode Read(DatReader datReader, BSPType treeType)
        {
            BSPNode obj = new BSPNode();

            obj.Type = datReader.ReadUInt32();

            switch (obj.Type)
            {
            case PORT:
                return(BSPPortal.ReadPortal(datReader, treeType));

            case LEAF:
                return(BSPLeaf.ReadLeaf(datReader, treeType));
            }

            obj.SplittingPlane = Plane.Read(datReader);

            switch (obj.Type)
            {
            case BPnn:
            case BPIn:
                obj.PosNode = BSPNode.Read(datReader, treeType);
                break;

            case BpIN:
            case BpnN:
                obj.NegNode = BSPNode.Read(datReader, treeType);
                break;

            case BPIN:
            case BPnN:
                obj.PosNode = BSPNode.Read(datReader, treeType);
                obj.NegNode = BSPNode.Read(datReader, treeType);
                break;
            }

            if (treeType == BSPType.Cell)
            {
                return(obj);
            }

            obj.Sphere = CSphere.Read(datReader);

            if (treeType == BSPType.Physics)
            {
                return(obj);
            }

            uint numPolys = datReader.ReadUInt32();

            for (uint i = 0; i < numPolys; i++)
            {
                obj.InPolys.Add(datReader.ReadUInt16());
            }
            return(obj);
        }
Exemplo n.º 17
0
        public static TimeOfDay Read(DatReader datReader)
        {
            TimeOfDay obj = new TimeOfDay();

            obj.Start   = datReader.ReadUInt32();
            obj.IsNight = datReader.ReadUInt32();
            obj.Name    = datReader.ReadPString();
            datReader.AlignBoundary();
            return(obj);
        }
Exemplo n.º 18
0
        public static SkyObjectReplace Read(DatReader datReader)
        {
            SkyObjectReplace obj = new SkyObjectReplace();

            obj.ObjectIndex = datReader.ReadUInt32();
            obj.GFXObjId    = datReader.ReadUInt32();
            obj.Rotate      = datReader.ReadSingle();
            obj.Transparent = datReader.ReadSingle();
            obj.Luminosity  = datReader.ReadSingle();
            obj.MaxBright   = datReader.ReadSingle();
            return(obj);
        }
Exemplo n.º 19
0
        public static CombatManeuver Read(DatReader datReader)
        {
            CombatManeuver obj = new CombatManeuver();

            obj.Style         = datReader.ReadUInt32();
            obj.AttackHeight  = datReader.ReadUInt32();
            obj.AttackType    = datReader.ReadUInt32();
            obj.MinSkillLevel = datReader.ReadUInt32();
            obj.Motion        = datReader.ReadUInt32();

            return(obj);
        }
Exemplo n.º 20
0
        public static RegionDesc ReadFromDat()
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(REGION_ID))
            {
                return((RegionDesc)DatManager.PortalDat.FileCache[REGION_ID]);
            }
            else
            {
                DatReader  datReader = DatManager.PortalDat.GetReaderForFile(REGION_ID);
                RegionDesc region    = new RegionDesc();

                region.FileId     = datReader.ReadUInt32();
                region.BLoaded    = datReader.ReadUInt32();
                region.TimeStamp  = datReader.ReadUInt32();
                region.RegionName = datReader.ReadPString(); // "Dereth"
                datReader.AlignBoundary();
                region.PartsMask = datReader.ReadUInt32();

                // There are 7 x 4 byte entries here that are "unknown". We will just skip them.
                datReader.Offset += (7 * 4);

                region.LandDefs = LandDefs.Read(datReader);
                region.GameTime = GameTime.Read(datReader);

                region.PNext = datReader.ReadUInt32();

                if ((region.PNext & 0x10) > 0)
                {
                    region.SkyInfo = SkyDesc.Read(datReader);
                }

                if ((region.PNext & 0x01) > 0)
                {
                    region.SoundInfo = SoundDesc.Read(datReader);
                }

                if ((region.PNext & 0x02) > 0)
                {
                    region.SceneInfo = SceneDesc.Read(datReader);
                }

                region.TerrainInfo = TerrainDesc.Read(datReader);

                if ((region.PNext & 0x0200) > 0)
                {
                    region.RegionMisc = RegionMisc.Read(datReader);
                }

                DatManager.PortalDat.FileCache[REGION_ID] = region;
                return(region);
            }
        }
Exemplo n.º 21
0
        public static GfxObjInfo Read(DatReader datReader)
        {
            GfxObjInfo obj = new GfxObjInfo();

            obj.Id          = datReader.ReadUInt32();
            obj.DegradeMode = datReader.ReadUInt32();
            obj.MinDist     = datReader.ReadSingle();
            obj.IdealDist   = datReader.ReadSingle();
            obj.MaxDist     = datReader.ReadSingle();

            return(obj);
        }
Exemplo n.º 22
0
        public static CreateParticleHook ReadHookType(DatReader datReader)
        {
            CreateParticleHook hook = new CreateParticleHook();

            hook.EmitterInfoId = datReader.ReadUInt32();

            hook.PartIndex = datReader.ReadUInt32();

            hook.Offset = PositionExtensions.ReadPosition(datReader);

            hook.EmitterId = datReader.ReadUInt32();
            return(hook);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Loads the structure of a CellLandblock from the client_cell.dat
        /// </summary>
        /// <param name="landblockId">Either a full int of the landblock or just the short of the cell itself</param>
        /// <returns></returns>
        public static CellLandblock ReadFromDat(uint landblockId)
        {
            CellLandblock c = new CellLandblock();

            // Check if landblockId is a full dword. We just need the hiword for the landblockId
            if ((landblockId >> 16) != 0)
            {
                landblockId = landblockId >> 16;
            }

            // The file index is CELL + 0xFFFF. e.g. a cell of 1234, the file index would be 0x1234FFFF.
            uint landblockFileIndex = (landblockId << 16) + 0xFFFF;

            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.CellDat.FileCache.ContainsKey(landblockFileIndex))
            {
                return((CellLandblock)DatManager.CellDat.FileCache[landblockFileIndex]);
            }
            else
            {
                if (DatManager.CellDat.AllFiles.ContainsKey(landblockFileIndex))
                {
                    DatReader datReader = DatManager.CellDat.GetReaderForFile(landblockFileIndex);
                    uint      cellId    = datReader.ReadUInt32();

                    uint hasObjects = datReader.ReadUInt32();
                    if (hasObjects == 1)
                    {
                        c.HasObjects = true;
                    }

                    // Read in the terrain. 9x9 so 81 records.
                    for (int i = 0; i < 81; i++)
                    {
                        uint terrain = datReader.ReadUInt16();
                        c.Terrain.Add(terrain);
                    }
                    // Read in the height. 9x9 so 81 records
                    for (int i = 0; i < 81; i++)
                    {
                        ushort height = datReader.ReadByte();
                        c.Height.Add(height);
                    }
                }

                // Store this object in the FileCache
                DatManager.CellDat.FileCache[landblockFileIndex] = c;

                return(c);
            }
        }
Exemplo n.º 24
0
        public static AnimationFrame Read(uint numParts, DatReader datReader)
        {
            AnimationFrame a = new AnimationFrame();

            for (uint i = 0; i < numParts; i++)
            {
                Position p = new Position();
                // Origin
                p.PositionX = datReader.ReadUInt32();
                p.PositionY = datReader.ReadUInt32();
                p.PositionZ = datReader.ReadUInt32();
                p.RotationW = datReader.ReadUInt32();
                p.RotationX = datReader.ReadUInt32();
                p.RotationY = datReader.ReadUInt32();
                p.RotationZ = datReader.ReadUInt32();
                a.Locations.Add(p);
            }

            uint numHooks = datReader.ReadUInt32();

            for (uint i = 0; i < numHooks; i++)
            {
                a.Hooks.Add(AnimationHook.Read(datReader));
            }

            return(a);
        }
Exemplo n.º 25
0
        public static PaletteSet ReadFromDat(DatReader datReader)
        {
            PaletteSet p = new PaletteSet();

            p.PaletteSetId = datReader.ReadUInt32();

            uint numpalettesets = datReader.ReadUInt32();

            for (int i = 0; i < numpalettesets; i++)
            {
                p.PaletteList.Add(datReader.ReadUInt32());
            }

            return(p);
        }
Exemplo n.º 26
0
        public static SkyObject Read(DatReader datReader)
        {
            SkyObject obj = new SkyObject();

            obj.BeginTime          = datReader.ReadSingle();
            obj.EndTime            = datReader.ReadSingle();
            obj.BeginAngle         = datReader.ReadSingle();
            obj.EndAngle           = datReader.ReadSingle();
            obj.TexVelocityX       = datReader.ReadSingle();
            obj.TexVelocityY       = datReader.ReadSingle();
            obj.DefaultGFXObjectId = datReader.ReadUInt32();
            obj.DefaultPESObjectId = datReader.ReadUInt32();
            obj.Properties         = datReader.ReadUInt32();
            return(obj);
        }
Exemplo n.º 27
0
        public static AmbientSTBDesc Read(DatReader datReader)
        {
            AmbientSTBDesc obj = new AmbientSTBDesc();

            obj.STBId = datReader.ReadUInt32();

            uint num_ambient_sounds = datReader.ReadUInt32();

            for (uint i = 0; i < num_ambient_sounds; i++)
            {
                obj.AmbientSounds.Add(AmbientSoundDesc.Read(datReader));
            }

            return(obj);
        }
Exemplo n.º 28
0
        public static SoundHook ReadHookType(DatReader datReader)
        {
            SoundHook s = new SoundHook();

            s.Id = datReader.ReadUInt32();
            return(s);
        }
Exemplo n.º 29
0
        public static PaletteSet ReadFromDat(uint fileId)
        {
            DatReader  datReader = DatManager.PortalDat.GetReaderForFile(fileId);
            PaletteSet p         = new PaletteSet();

            p.PaletteSetId = datReader.ReadUInt32();

            uint numpalettesets = datReader.ReadUInt32();

            for (int i = 0; i < numpalettesets; i++)
            {
                p.PaletteList.Add(datReader.ReadUInt32());
            }

            return(p);
        }
Exemplo n.º 30
0
        public static StopParticleHook ReadHookType(DatReader datReader)
        {
            StopParticleHook sp = new StopParticleHook();

            sp.EmitterId = datReader.ReadUInt32();
            return(sp);
        }