public void WriteToFile(XBinWriter writer)
        {
            writer.Write(unk0);
            writer.Write(colors.Length);
            writer.Write(colors.Length);

            foreach (var color in colors)
            {
                writer.Write(color.CarID);
                writer.Write(color.R1);
                writer.Write(color.G1);
                writer.Write(color.B1);
                writer.Write(color.R2);
                writer.Write(color.G2);
                writer.Write(color.B2);
                writer.Write(color.R3);
                writer.Write(color.G3);
                writer.Write(color.B3);
                writer.Write(color.R4);
                writer.Write(color.G4);
                writer.Write(color.B4);
                writer.Write(color.R5);
                writer.Write(color.G5);
                writer.Write(color.B5);

                // Only in M1: DE
                if (gameVersion == GamesEnumerator.MafiaI_DE)
                {
                    writer.Write(color.Alpha);
                }

                writer.Write(color.Desc);
            }
        }
Beispiel #2
0
        public void WriteToFile(XBinWriter writer)
        {
            writer.Write(unk0);
            writer.Write(PaintCombinations.Length);
            writer.Write(PaintCombinations.Length);

            for (int i = 0; i < PaintCombinations.Length; i++)
            {
                PaintCombinationsTableItem Item = PaintCombinations[i];
                writer.Write(Item.ID);
                writer.Write(Item.Unk01);
                writer.Write(Item.MinOccurs);
                writer.Write(Item.MaxOccurs);
                StringHelpers.WriteString32(writer, Item.CarName);
            }

            for (int i = 0; i < PaintCombinations.Length; i++)
            {
                PaintCombinationsTableItem Item = PaintCombinations[i];
                for (int z = 0; z < Item.MaxOccurs; z++)
                {
                    writer.Write(Item.ColorIndex[z]);
                }
            }
        }
Beispiel #3
0
        public void WriteToFile(XBinWriter writer)
        {
            writer.Write(unk0);
            writer.Write(missions.Length);
            writer.Write(missions.Length);
            writer.Write(unk1);

            foreach (var slot in missions)
            {
                MissionItem Item = slot;
                Item.ID.WriteToFile(writer);
                Item.TextID.WriteToFile(writer);
                Item.DescriptionID.WriteToFile(writer);
                writer.Write(Item.IconID);
                writer.Write(Item.CityID);
                writer.Write((int)Item.Type);
                writer.PushStringPtr(Item.MissionID);

                if (gameVersion == GamesEnumerator.MafiaI_DE)
                {
                    writer.PushStringPtr(Item.CheckPointFile);
                    writer.Write(Item.Unknown);
                }
            }

            writer.Write(0); // padding?
            writer.FixUpStringPtrs();
        }
Beispiel #4
0
 public void WriteToFile(FileInfo file)
 {
     using (XBinWriter writer = new XBinWriter(File.Open(file.FullName, FileMode.Create)))
     {
         InternalWriteToFile(writer);
     }
 }
Beispiel #5
0
 private void InternalWriteToFile(XBinWriter writer)
 {
     writer.Write(hash);
     writer.Write(version);
     writer.Write(numTables);
     writer.Write(offset);
     TableInformation.WriteToFile(writer);
 }
Beispiel #6
0
        public void WriteToFile(XBinWriter writer)
        {
            writer.Write(unk0);
            writer.Write(vehicles.Length);
            writer.Write(vehicles.Length);

            foreach (var vehicle in vehicles)
            {
                vehicle.WriteEntry(writer);
            }
        }
        public void WriteToFile(XBinWriter writer)
        {
            writer.Write(unk0);
            writer.Write(charactercinematics.Length);
            writer.Write(charactercinematics.Length);

            foreach (var charactercinematic in charactercinematics)
            {
                writer.Write(charactercinematic.StringId);
                writer.Write(charactercinematic.CharacterId);
            }
        }
Beispiel #8
0
        public void WriteToFile(XBinWriter writer)
        {
            writer.Write(unk0);
            writer.Write(modificators.Length);
            writer.Write(modificators.Length);

            foreach (var modificator in modificators)
            {
                writer.Write(modificator.ID);
                writer.Write(modificator.CarId);
                writer.Write(modificator.ItemId);
                writer.Write(modificator.MemberId);
                writer.Write(modificator.Value);
            }
        }
Beispiel #9
0
        public void WriteToFile(XBinWriter writer)
        {
            writer.Write(unk0);
            writer.Write(bindings.Length);
            writer.Write(bindings.Length);

            foreach (var bind in bindings)
            {
                writer.Write(bind.NameHash);
                writer.Write(bind.SingleMeshIndex);
                writer.Write(bind.HavokIndex);
            }

            writer.Write(unk1);
        }
Beispiel #10
0
        public void WriteToFile(XBinWriter writer)
        {
            writer.Write(unk0);
            writer.Write(Items.Length);
            writer.Write(Items.Length);
            writer.Write(0); // padding

            int i = 0;

            long[] offsets = new long[Items.Length];
            foreach (var tuning in Items)
            {
                CarTrafficTuningItem Item = Items[i];
                Item.CollectionCount1 = Item.TuningItems.Length;
                Item.CollectionCount2 = Item.TuningItems.Length;
                writer.Write(Item.ID);
                offsets[i] = writer.BaseStream.Position;
                writer.Write(0xDEADBEEF); //placeholder
                writer.Write(Item.TuningItems.Length);
                writer.Write(Item.TuningItems.Length);
                writer.Write(Item.VehicleID);
                writer.Write((int)Item.VehicleFlags);
                writer.Write((int)Item.VehicleLookFlags);
                writer.Write(Item.Weight);
                Item.Name.WriteToFile(writer);
                i++;
            }

            for (int j = 0; j < Items.Length; j++)
            {
                CarTrafficTuningItem Item = Items[j];
                uint thisPosition         = (uint)(writer.BaseStream.Position);

                for (int z = 0; z < Item.CollectionCount1; z++)
                {
                    writer.Write(Item.TuningItems[z]);
                }

                long currentPosition = writer.BaseStream.Position;
                writer.BaseStream.Position = offsets[j];
                var offset = (uint)(thisPosition - offsets[j]);
                writer.Write(offset);
                writer.BaseStream.Position = currentPosition;
            }
            offsets = new long[0];
        }
Beispiel #11
0
        public void WriteToFile(XBinWriter writer)
        {
            writer.Write(16);
            writer.Write(availabilitys.Length);
            writer.Write(availabilitys.Length);
            writer.Write(0);

            int i = 0;

            long[] offsets = new long[availabilitys.Length];
            foreach (var availability in availabilitys)
            {
                CarTuningPackAvailabilityItem Item = availabilitys[i];
                writer.Write(Item.ID);
                offsets[i] = writer.BaseStream.Position;
                writer.Write(0); //placeholder
                writer.Write(Item.TuningItemsCount1);
                writer.Write(Item.TuningItemsCount2);
                writer.Write(Item.VehicleID);
                writer.Write(Item.Zero);
                writer.Write(Item.PackageName);
                i++;
            }

            for (int j = 0; j < availabilitys.Length; j++)
            {
                CarTuningPackAvailabilityItem Item = availabilitys[j];

                if (Item.TuningItemsCount1 != 0)
                {
                    uint thisPosition = (uint)(writer.BaseStream.Position);
                    for (int z = 0; z < Item.TuningItemsCount1; z++)
                    {
                        writer.Write(Item.TuningItems[z]);
                    }

                    long currentPosition = writer.BaseStream.Position;
                    writer.BaseStream.Position = offsets[j];
                    var offset = (uint)(thisPosition - offsets[j]);
                    writer.Write(offset);
                    writer.BaseStream.Position = currentPosition;
                }
            }
            offsets = new long[0];
        }
Beispiel #12
0
        public void WriteToFile(XBinWriter writer)
        {
            // Order StringTable entries.
            Items = Items.OrderBy(e => e.StringID.Hash).ToArray();

            writer.Write(unk0);
            writer.Write(Items.Length);
            writer.Write(Items.Length);

            // Idea is to write all entries and come back to replace Ptr(offset).
            long[] positions = new long[Items.Length];
            for (int i = 0; i < Items.Count(); i++)
            {
                LocalisableString Entry = Items[i];
                writer.Write(Entry.Unk0);
                Entry.StringID.WriteToFile(writer);

                positions[i] = writer.BaseStream.Position;
                writer.Write(-1);
            }

            // Seems to be padding. Concerning..
            writer.Write(0);

            for (int i = 0; i < Items.Length; i++)
            {
                LocalisableString Entry = Items[i];

                // We get the position
                uint thisPosition = (uint)(writer.BaseStream.Position);
                StringHelpers.WriteString(writer, Entry.Content);
                long currentPosition = writer.BaseStream.Position;

                // Correct the offset and write to the file
                writer.BaseStream.Position = positions[i];
                var offset = (uint)(thisPosition - positions[i]);
                writer.Write(offset);
                writer.BaseStream.Position = currentPosition;
            }

            positions = new long[0];
        }
Beispiel #13
0
        public void WriteToFile(XBinWriter writer)
        {
            writer.Write(unk0);
            writer.Write(speechsituations.Length);
            writer.Write(speechsituations.Length);

            foreach (var speechsituation in speechsituations)
            {
                writer.Write(speechsituation.SituationID);
                writer.Write(speechsituation.Cooldown);
                writer.Write(speechsituation.PerActorCooldownMin);
                writer.Write(speechsituation.PerActorCooldownMax);
                writer.Write(speechsituation.PerTeamCooldownMin);
                writer.Write(speechsituation.PerTeamCooldownMax);
                writer.Write(speechsituation.IsForeground);
                writer.Write(speechsituation.FNV64InitHash);
            }

            writer.Write(unk1);
        }
Beispiel #14
0
        public void WriteToFile(XBinWriter writer)
        {
            writer.Write(unk0);
            writer.Write(SubtitleItems.Length);
            writer.Write(SubtitleItems.Length);
            writer.Write(0);

            foreach (SubtitleTableItem Item in SubtitleItems)
            {
                writer.Write(Item.SubtitleID.Hash);
                writer.Write(Item.SoundID.Hash);
                writer.Write(Item.FacialAnimName.Hash);
                writer.Write(Item.LongStringID.Hash);
                writer.Write(Item.ShortStringID.Hash);
                writer.Write(Item.SoundPreset);
                writer.Write(Item.VoicePresetOverride.Hash);
                writer.Write(Item.SubtitlePriorityOverride);
                writer.Write(Item.Unk0);
                writer.Write(Item.SubtitleCharacter.Hash);
            }
        }
Beispiel #15
0
        public void WriteToFile(XBinWriter writer)
        {
            writer.Write(unk0);
            writer.Write(Lines.Length);
            writer.Write(Lines.Length);

            for (int i = 0; i < Lines.Length; i++)
            {
                StreamMapLine Line = Lines[i];
                writer.Write((uint)Line.LineType);
                writer.PushStringPtr(Line.GameID);
                writer.PushStringPtr(Line.MissionID);
                writer.PushStringPtr(Line.PartID);
                writer.PushObjectPtr(string.Format("TableOffset_{0}", i));
                writer.Write(Line.TableCommands.Length); // This file stores it twice.
                writer.Write(Line.TableCommands.Length);
                writer.Write(Line.IsAsync);
            }

            for (int i = 0; i < Lines.Length; i++)
            {
                StreamMapLine Line = Lines[i];

                writer.FixUpObjectPtr(string.Format("TableOffset_{0}", i));

                for (int x = 0; x < Line.TableCommands.Length; x++)
                {
                    writer.PushObjectPtr(string.Format("TableCommandsOffset_{0}", x));
                    writer.Write(Line.TableCommands[x].GetMagic());
                }

                for (int x = 0; x < Line.TableCommands.Length; x++)
                {
                    writer.FixUpObjectPtr(string.Format("TableCommandsOffset_{0}", x));
                    Line.TableCommands[x].WriteToFile(writer);
                }
            }

            writer.FixUpStringPtrs();
        }
Beispiel #16
0
        public void WriteToFile(XBinWriter writer)
        {
            writer.Write(unk0);
            writer.Write(gearboxes.Length);
            writer.Write(gearboxes.Length);

            foreach (var gearbox in gearboxes)
            {
                writer.Write(gearbox.ID);
                StringHelpers.WriteStringBuffer(writer, 32, gearbox.Description);
                writer.Write(gearbox.Automatic);
                writer.Write(gearbox.GearCount);
                writer.Write(gearbox.GearReverseCount);
                writer.Write(gearbox.GearRatio0);
                writer.Write(gearbox.RotationsGearUp0);
                writer.Write(gearbox.RotationsGearDown0);
                writer.Write(gearbox.GearRatio1);
                writer.Write(gearbox.RotationsGearUp1);
                writer.Write(gearbox.RotationsGearDown1);
                writer.Write(gearbox.GearRatio2);
                writer.Write(gearbox.RotationsGearUp2);
                writer.Write(gearbox.RotationsGearDown2);
                writer.Write(gearbox.GearRatio3);
                writer.Write(gearbox.RotationsGearUp3);
                writer.Write(gearbox.RotationsGearDown3);
                writer.Write(gearbox.GearRatio4);
                writer.Write(gearbox.RotationsGearUp4);
                writer.Write(gearbox.RotationsGearDown4);
                writer.Write(gearbox.GearRatio5);
                writer.Write(gearbox.RotationsGearUp5);
                writer.Write(gearbox.RotationsGearDown5);
                writer.Write(gearbox.GearRatio6);
                writer.Write(gearbox.RotationsGearUp6);
                writer.Write(gearbox.RotationsGearDown6);
                writer.Write(gearbox.MinClutchGlobal);
                writer.Write(gearbox.MinClutchAngleCoeffGlobal);
                writer.Write(gearbox.ShiftDelayMin);
                writer.Write(gearbox.ShiftDelayMax);
            }
        }
Beispiel #17
0
        public void WriteToFile(XBinWriter writer)
        {
            writer.Write(unk0);
            writer.Write(vehicles.Length);
            writer.Write(vehicles.Length);

            foreach (var vehicle in vehicles)
            {
                writer.Write(vehicle.Unk0);
                writer.Write(vehicle.ID);
                writer.Write((int)vehicle.CommonFlags);
                writer.Write((int)vehicle.VehicleFlags);
                writer.Write((int)vehicle.VehicleLookFlags);
                writer.Write((int)vehicle.VehicleFunctionFlags);
                StringHelpers.WriteStringBuffer(writer, 32, vehicle.ModelName);
                StringHelpers.WriteStringBuffer(writer, 32, vehicle.SoundVehicleSwitch);
                writer.Write((int)vehicle.RadioRandom);
                writer.Write(vehicle.RadioSoundQuality);
                writer.Write(vehicle.TexID);
                writer.Write(vehicle.TexHash);
                StringHelpers.WriteStringBuffer(writer, 32, vehicle.BrandNameUI);
                StringHelpers.WriteStringBuffer(writer, 32, vehicle.ModelNameUI);
                StringHelpers.WriteStringBuffer(writer, 32, vehicle.LogoNameUI);
                writer.Write(vehicle.StealKoeficient);
                writer.Write(vehicle.Price);

                // No support in m3
                if (gameVersion == GamesEnumerator.MafiaI_DE)
                {
                    writer.Write(vehicle.MinDirt);
                    writer.Write(vehicle.MinRust);
                }

                writer.Write(vehicle.MaxDirt);
                writer.Write(vehicle.MaxRust);
                writer.Write((int)vehicle.RaceClass);
                writer.Write(vehicle.TrunkDockOffsetX);
                writer.Write(vehicle.TrunkDockOffsetY);
            }
        }
Beispiel #18
0
        public void WriteToFile(XBinWriter writer)
        {
            writer.Write(unk0);
            writer.Write(slots.Length);
            writer.Write(slots.Length);

            int i = 0;

            long[] offsets = new long[slots.Length];
            foreach (var slot in slots)
            {
                SlotItem Item = slots[i];
                writer.Write(Item.TypeID);
                writer.Write((int)slot.SlotType);
                offsets[i] = writer.BaseStream.Position;
                writer.Write(0xDEADBEEF); // temporary
                writer.Write(Item.RAM_Windows);
                writer.Write(Item.VRAM_Windows);
                writer.Write(Item.RAM_Xbox360);
                writer.Write(Item.VRAM_Xbox360);
                writer.Write(Item.RAM_PS3_DEVKIT);
                writer.Write(Item.VRAM_PS3_DEVKIT);
                writer.Write(Item.RAM_PS3_TESTKIT);
                writer.Write(Item.VRAM_PS3_TESTKIT);
                i++;
            }

            for (int j = 0; j < slots.Length; j++)
            {
                SlotItem Item         = slots[j];
                uint     thisPosition = (uint)(writer.BaseStream.Position);
                StringHelpers.WriteString(writer, Item.BaseName);

                long currentPosition = writer.BaseStream.Position;
                writer.BaseStream.Position = offsets[j];
                var offset = (uint)(thisPosition - offsets[j]);
                writer.Write(offset);
                writer.BaseStream.Position = currentPosition;
            }
        }
        public void WriteToFile(XBinWriter writer)
        {
            writer.Write(unk0);
            writer.Write(missions.Length);
            writer.Write(missions.Length);

            foreach (var slot in missions)
            {
                MissionItem Item = slot;
                writer.Write(Item.ID);
                writer.Write(Item.TextID);
                writer.Write(Item.DescriptionID);
                writer.Write(Item.IconID);
                writer.Write(Item.CityID);
                writer.Write((int)Item.Type);
                writer.Write(Item.Unknown);
                writer.PushStringPtr(Item.MissionID);
                writer.PushStringPtr(Item.CheckPointFile);
            }

            writer.Write(0); // padding?
            writer.FixUpStringPtrs();
        }
Beispiel #20
0
        public void WriteToFile(XBinWriter writer)
        {
            writer.Write(unk0);
            writer.Write(cities.Length);
            writer.Write(cities.Length);
            writer.Write(unk1);

            foreach (var Item in cities)
            {
                writer.PushObjectPtr(string.Format("RespawnPlace_{0}", Item.ID));
                writer.Write(Item.RespawnPlaces.Length);
                writer.Write(Item.RespawnPlaces.Length);
                writer.PushObjectPtr(string.Format("CityArea_{0}", Item.ID));

                writer.Write(Item.ID);
                writer.PushStringPtr(Item.Name);
                writer.PushStringPtr(Item.MissionLine);
                writer.PushStringPtr(Item.SDSPrefix);
                Item.TextID.WriteToFile(writer);
                Item.CarGarageType.WriteToFile(writer);
                Item.BoatGarageType.WriteToFile(writer);

                if (gameVersion == GamesEnumerator.MafiaI_DE)
                {
                    writer.PushStringPtr(Item.Unk01);
                }

                writer.PushStringPtr(Item.Map);

                // Content doesn't exist in M1DE.. Unused?
                if (gameVersion == GamesEnumerator.MafiaIII)
                {
                    writer.Write(0);
                }
            }

            foreach (var Item in Cities)
            {
                writer.FixUpObjectPtr(string.Format("RespawnPlace_{0}", Item.ID));
                foreach (var Respawn in Item.RespawnPlaces)
                {
                    Respawn.PosPlayer.WriteToFile(writer);
                    Respawn.DirPlayer.WriteToFile(writer);
                    writer.Write((int)Respawn.RespawnType);
                    writer.PushStringPtr(Respawn.StreamMapPart);
                }

                writer.FixUpObjectPtr(string.Format("CityArea_{0}", Item.ID));

                writer.PushObjectPtr("CityPointOffset");
                writer.Write(Item.Points.Length);
                writer.Write(Item.Points.Length);
                writer.PushObjectPtr("CityPolygonOffset");
                writer.Write(Item.Polygons.Length);
                writer.Write(Item.Polygons.Length);

                writer.FixUpObjectPtr("CityPointOffset");

                foreach (var Entry in Item.Points)
                {
                    Entry.WriteToFile(writer);
                }

                writer.FixUpObjectPtr("CityPolygonOffset");

                foreach (var Entry in Item.Polygons)
                {
                    writer.PushObjectPtr("PolygonIndexOffset");
                    writer.Write(Entry.Indexes.Length);
                    writer.Write(Entry.Indexes.Length);

                    writer.PushStringPtr(Entry.Name);
                    Entry.TextID.WriteToFile(writer);
                    writer.Write(Entry.Unk0);

                    writer.FixUpObjectPtr("PolygonIndexOffset");
                    foreach (var Index in Entry.Indexes)
                    {
                        writer.Write(Index);
                    }
                }
            }

            writer.FixUpStringPtrs();
        }