示例#1
0
        public static GameTime Read(DatReader datReader)
        {
            GameTime obj = new GameTime();

            obj.ZeroTimeOfYear = datReader.ReadUInt64();
            obj.ZeroYear       = datReader.ReadUInt32();
            obj.DayLength      = datReader.ReadUInt32();
            obj.DaysPerYear    = datReader.ReadUInt32();
            obj.YearSpec       = datReader.ReadPString();
            datReader.AlignBoundary();

            uint numTimesOfDay = datReader.ReadUInt32();

            for (uint i = 0; i < numTimesOfDay; i++)
            {
                obj.TimesOfDay.Add(TimeOfDay.Read(datReader));
            }

            uint numDaysOfTheWeek = datReader.ReadUInt32();

            for (uint i = 0; i < numDaysOfTheWeek; i++)
            {
                obj.DaysOfTheWeek.Add(datReader.ReadPString());
                datReader.AlignBoundary();
            }

            uint numSeasons = datReader.ReadUInt32();

            for (uint i = 0; i < numSeasons; i++)
            {
                obj.Seasons.Add(Season.Read(datReader));
            }

            return(obj);
        }
示例#2
0
        public static Season Read(DatReader datReader)
        {
            Season obj = new Season();

            obj.StartDate = datReader.ReadUInt32();
            obj.Name      = datReader.ReadPString();
            datReader.AlignBoundary();
            return(obj);
        }
示例#3
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);
        }
示例#4
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);
            }
        }
示例#5
0
        public static TerrainType Read(DatReader datReader)
        {
            TerrainType obj = new TerrainType();

            obj.TerrainName = datReader.ReadPString();
            datReader.AlignBoundary();

            obj.TerrainColor = datReader.ReadUInt32();

            uint num_stypes = datReader.ReadUInt32();

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

            return(obj);
        }
示例#6
0
        public static DayGroup Read(DatReader datReader)
        {
            DayGroup obj = new DayGroup();

            obj.ChanceOfOccur = datReader.ReadSingle();
            obj.DayName       = datReader.ReadPString();
            datReader.AlignBoundary();

            uint num_sky_objects = datReader.ReadUInt32();

            for (uint i = 0; i < num_sky_objects; i++)
            {
                obj.SkyObjects.Add(SkyObject.Read(datReader));
            }

            uint num_sky_times = datReader.ReadUInt32();

            for (uint i = 0; i < num_sky_times; i++)
            {
                obj.SkyTime.Add(SkyTimeOfDay.Read(datReader));
            }

            return(obj);
        }
示例#7
0
        public static Contract Read(DatReader datReader)
        {
            Contract obj = new Contract();

            obj.Version      = datReader.ReadUInt32();
            obj.ContractId   = datReader.ReadUInt32();
            obj.ContractName = datReader.ReadPString();
            datReader.AlignBoundary();

            obj.Description = datReader.ReadPString();
            datReader.AlignBoundary();
            obj.DescriptionProgress = datReader.ReadPString();
            datReader.AlignBoundary();

            obj.NameNPCStart = datReader.ReadPString();
            datReader.AlignBoundary();
            obj.NameNPCEnd = datReader.ReadPString();
            datReader.AlignBoundary();

            obj.QuestflagStamped = datReader.ReadPString();
            datReader.AlignBoundary();
            obj.QuestflagStarted = datReader.ReadPString();
            datReader.AlignBoundary();
            obj.QuestflagFinished = datReader.ReadPString();
            datReader.AlignBoundary();
            obj.QuestflagProgress = datReader.ReadPString();
            datReader.AlignBoundary();
            obj.QuestflagTimer = datReader.ReadPString();
            datReader.AlignBoundary();
            obj.QuestflagRepeatTime = datReader.ReadPString();
            datReader.AlignBoundary();

            obj.LocationNPCStart  = PositionExtensions.ReadLandblockPosition(datReader);
            obj.LocationNPCEnd    = PositionExtensions.ReadLandblockPosition(datReader);
            obj.LocationQuestArea = PositionExtensions.ReadLandblockPosition(datReader);

            return(obj);
        }
示例#8
0
        public static CharGen ReadFromDat()
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(0x0E000002))
            {
                return((CharGen)DatManager.PortalDat.FileCache[0x0E000002]);
            }
            else
            {
                // Create the datReader for the proper file
                DatReader datReader = DatManager.PortalDat.GetReaderForFile(0x0E000002);
                CharGen   cg        = new CharGen();

                cg.Did           = datReader.ReadInt32();
                datReader.Offset = 8;

                /// STARTER AREAS. There are 5 dungeons per starting city, and one landscape span for Olthoi.
                int numStarterAreas = datReader.ReadByte();
                for (int i = 0; i < numStarterAreas; i++)
                {
                    string starterAreaName = datReader.ReadPString();

                    int        numAreas     = datReader.ReadByte();
                    List <Loc> starterAreas = new List <Loc>();
                    for (int j = 0; j < numAreas; j++)
                    {
                        Loc starterArea = new Loc(datReader.ReadInt32(), datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle());
                        starterAreas.Add(starterArea);
                    }

                    cg.StarterAreas.Add(starterAreas);
                }

                /// HERITAGE GROUPS -- 11 standard player races and 2 Olthoi.
                datReader.Offset++; // Not sure what this byte 0x01 is indicating, but we'll skip it because we can.
                int heritageGroupCount = datReader.ReadByte();
                for (int i = 0; i < heritageGroupCount; i++)
                {
                    HeritageGroupCG heritage      = new HeritageGroupCG();
                    int             heritageIndex = datReader.ReadInt32();
                    heritage.Name               = datReader.ReadPString();
                    heritage.IconImage          = datReader.ReadUInt32();
                    heritage.SetupID            = datReader.ReadUInt32();
                    heritage.EnvironmentSetupID = datReader.ReadUInt32();
                    heritage.AttributeCredits   = datReader.ReadUInt32();
                    heritage.SkillCredits       = datReader.ReadUInt32();

                    // Start Areas correspond go the CG.StarterAreas List.
                    int numPrimaryStartAreas = datReader.ReadByte();
                    for (int j = 0; j < numPrimaryStartAreas; j++)
                    {
                        heritage.PrimaryStartAreaList.Add(datReader.ReadInt32());
                    }

                    int numSecondaryStartAreas = datReader.ReadByte();
                    for (int j = 0; j < numSecondaryStartAreas; j++)
                    {
                        heritage.SecondaryStartAreaList.Add(datReader.ReadInt32());
                    }

                    // Racial Skills
                    int skillCount = datReader.ReadByte();
                    for (int j = 0; j < skillCount; j++)
                    {
                        SkillCG skill = new SkillCG();
                        skill.SkillNum    = datReader.ReadUInt32();
                        skill.NormalCost  = datReader.ReadUInt32();
                        skill.PrimaryCost = datReader.ReadUInt32();
                        heritage.SkillList.Add(skill);
                    }

                    // Adventurer, Bow Hunter, etc.
                    int templateCount = datReader.ReadByte();
                    for (int j = 0; j < templateCount; j++)
                    {
                        TemplateCG template = new TemplateCG();
                        template.Name      = datReader.ReadPString();
                        template.IconImage = datReader.ReadUInt32();
                        template.Title     = datReader.ReadUInt32();
                        // Attributes
                        template.Strength     = datReader.ReadUInt32();
                        template.Endurance    = datReader.ReadUInt32();
                        template.Coordination = datReader.ReadUInt32();
                        template.Quickness    = datReader.ReadUInt32();
                        template.Focus        = datReader.ReadUInt32();
                        template.Self         = datReader.ReadUInt32();

                        skillCount = datReader.ReadByte();
                        for (int k = 0; k < skillCount; k++)
                        {
                            template.NormalSkillsList.Add(datReader.ReadUInt32());
                        }
                        skillCount = datReader.ReadByte();
                        for (int k = 0; k < skillCount; k++)
                        {
                            template.PrimarySkillsList.Add(datReader.ReadUInt32());
                        }

                        heritage.TemplateList.Add(template);
                    }

                    datReader.Offset++;                    // 0x01 byte here. Not sure what/why, so skip it!
                    int numGenders = datReader.ReadByte(); // this is always 2, but let's read it anyways...
                    for (int j = 0; j < numGenders; j++)
                    {
                        SexCG sex      = new SexCG();
                        int   genderID = datReader.ReadInt32();
                        sex.Name         = datReader.ReadPString();
                        sex.Scale        = datReader.ReadUInt32();
                        sex.SetupID      = datReader.ReadUInt32();
                        sex.SoundTable   = datReader.ReadUInt32();
                        sex.IconImage    = datReader.ReadUInt32();
                        sex.BasePalette  = datReader.ReadUInt32();
                        sex.SkinPalSet   = datReader.ReadUInt32();
                        sex.PhysicsTable = datReader.ReadUInt32();
                        sex.MotionTable  = datReader.ReadUInt32();
                        sex.CombatTable  = datReader.ReadUInt32();

                        sex.BaseObjDesc = ObjDesc.ReadFromDat(ref datReader);

                        int numHairColors = datReader.ReadByte();
                        for (int k = 0; k < numHairColors; k++)
                        {
                            sex.HairColorList.Add(datReader.ReadUInt32());
                        }

                        int numHairStyles = datReader.ReadByte();
                        for (int k = 0; k < numHairStyles; k++)
                        {
                            HairStyleCG hairstyle = new HairStyleCG();
                            hairstyle.IconImage      = datReader.ReadUInt32();
                            hairstyle.Bald           = Convert.ToBoolean(datReader.ReadByte());
                            hairstyle.AlternateSetup = datReader.ReadUInt32();
                            hairstyle.ObjDesc        = ObjDesc.ReadFromDat(ref datReader);
                            sex.HairStyleList.Add(hairstyle);
                        }

                        int numEyeColors = datReader.ReadByte();
                        for (int k = 0; k < numEyeColors; k++)
                        {
                            sex.EyeColorList.Add(datReader.ReadUInt32());
                        }

                        int numEyeStrips = datReader.ReadByte();
                        for (int k = 0; k < numEyeStrips; k++)
                        {
                            EyeStripCG eyestrip = new EyeStripCG();
                            eyestrip.IconImage     = datReader.ReadUInt32();
                            eyestrip.IconImageBald = datReader.ReadUInt32();
                            eyestrip.ObjDesc       = ObjDesc.ReadFromDat(ref datReader);
                            eyestrip.ObjDescBald   = ObjDesc.ReadFromDat(ref datReader);
                            sex.EyeStripList.Add(eyestrip);
                        }

                        int numNoseStrips = datReader.ReadByte(); // Breathe Right?
                        for (int k = 0; k < numNoseStrips; k++)
                        {
                            FaceStripCG nosestrip = new FaceStripCG();
                            nosestrip.IconImage = datReader.ReadUInt32();
                            nosestrip.ObjDesc   = ObjDesc.ReadFromDat(ref datReader);
                            sex.NoseStripList.Add(nosestrip);
                        }

                        int numMouthStrips = datReader.ReadByte(); // Breathe Right?
                        for (int k = 0; k < numMouthStrips; k++)
                        {
                            FaceStripCG mouthstrip = new FaceStripCG();
                            mouthstrip.IconImage = datReader.ReadUInt32();
                            mouthstrip.ObjDesc   = ObjDesc.ReadFromDat(ref datReader);
                            sex.MouthStripList.Add(mouthstrip);
                        }

                        int numHeadGear = datReader.ReadByte();
                        for (int k = 0; k < numHeadGear; k++)
                        {
                            GearCG headgear = new GearCG();
                            headgear.Name          = datReader.ReadPString();
                            headgear.ClothingTable = datReader.ReadUInt32();
                            headgear.WeenieDefault = datReader.ReadUInt32();
                            sex.HeadgearList.Add(headgear);
                        }

                        int numShirts = datReader.ReadByte();
                        for (int k = 0; k < numShirts; k++)
                        {
                            GearCG shirt = new GearCG();
                            shirt.Name          = datReader.ReadPString();
                            shirt.ClothingTable = datReader.ReadUInt32();
                            shirt.WeenieDefault = datReader.ReadUInt32();
                            sex.ShirtList.Add(shirt);
                        }

                        int numPants = datReader.ReadByte();
                        for (int k = 0; k < numPants; k++)
                        {
                            GearCG pants = new GearCG();
                            pants.Name          = datReader.ReadPString();
                            pants.ClothingTable = datReader.ReadUInt32();
                            pants.WeenieDefault = datReader.ReadUInt32();
                            sex.PantsList.Add(pants);
                        }

                        int numFootwear = datReader.ReadByte();
                        for (int k = 0; k < numFootwear; k++)
                        {
                            GearCG footwear = new GearCG();
                            footwear.Name          = datReader.ReadPString();
                            footwear.ClothingTable = datReader.ReadUInt32();
                            footwear.WeenieDefault = datReader.ReadUInt32();
                            sex.FootwearList.Add(footwear);
                        }

                        int numClothingColors = datReader.ReadByte();
                        for (int k = 0; k < numClothingColors; k++)
                        {
                            sex.ClothingColorsList.Add(datReader.ReadUInt32());
                        }

                        heritage.SexList.Add(genderID, sex);
                    }

                    cg.HeritageGroups.Add(heritageIndex, heritage);
                }
                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[0x0E000002] = cg;
                return(cg);
            }
        }