Commit 59c4f887 authored by Spencer Alves's avatar Spencer Alves

Fix LastObj and LastTile

parent 1790e394
......@@ -605,7 +605,7 @@ namespace Altar
switch (chunkId)
{
case SectionHeaders.General:
chunkStringOffsetOffsets = SectionWriter.WriteGeneral(chunk, f.General, stringOffsets);
chunkStringOffsetOffsets = SectionWriter.WriteGeneral(chunk, f.General, f.Rooms, stringOffsets);
break;
case SectionHeaders.Options:
chunkStringOffsetOffsets = SectionWriter.WriteOptions(chunk, f.Options, stringOffsets);
......
......@@ -215,7 +215,7 @@ namespace Altar.Repack
return stringOffsets;
}
public static int[] WriteGeneral(BBData data, GeneralInfo ge, IDictionary<string, int> stringOffsets)
public static int[] WriteGeneral(BBData data, GeneralInfo ge, RoomInfo[] rooms, IDictionary<string, int> stringOffsets)
{
var ret = new SectionGeneral
{
......@@ -234,7 +234,10 @@ namespace Altar.Repack
Info = ge.InfoFlags,
ActiveTargets = ge.ActiveTargets,
AppID = ge.SteamAppID
AppID = ge.SteamAppID,
LastObj = 0,
LastTile = 0
};
var stringOffsetOffsets = new int[]
{
......@@ -244,6 +247,26 @@ namespace Altar.Repack
(int)Marshal.OffsetOf(typeof(SectionGeneral), "DisplayNameOffset") - 3
};
foreach (var room in rooms)
{
foreach (var obj in room.Objects)
{
if (obj.InstanceID > ret.LastObj)
{
ret.LastObj = obj.InstanceID;
}
}
foreach (var tile in room.Tiles)
{
if (tile.InstanceID > ret.LastTile)
{
ret.LastTile = tile.InstanceID;
}
}
}
ret.LastObj++;
ret.LastTile++;
for (int i = 0; i < 4; i++)
unsafe
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment