Skip to content

Commit

Permalink
Support for 1.47 Open Beta (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
dariowouters committed Mar 27, 2023
1 parent 6f7c310 commit e4b7e96
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This Application reads ATS/ETS2 files to draw roads, prefabs, map overlays, ferr

![Preview of the map](/docs/preview.jpg "Preview of the map")

### **Support for 1.46**
### **Support for 1.47 Open Beta**

## Export Maps
Can now export maps as a tiled web map.
Expand Down
42 changes: 41 additions & 1 deletion TsMap/TsItem/TsMapOverlayItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ public class TsMapOverlayItem : TsItem
public TsMapOverlayItem(TsSector sector, int startOffset) : base(sector, startOffset)
{
Valid = true;
TsMapOverlayItem825(startOffset);
if (Sector.Version < 898)
TsMapOverlayItem825(startOffset);
else if (Sector.Version >= 898)
TsMapOverlayItem898(startOffset);
else
Logger.Instance.Error($"Unknown base file version ({Sector.Version}) for item {Type} " +
$"in file '{Path.GetFileName(Sector.FilePath)}' @ {startOffset} from '{Sector.GetUberFile().Entry.GetArchiveFile().GetPath()}'");
}

public void TsMapOverlayItem825(int startOffset)
Expand Down Expand Up @@ -55,6 +61,40 @@ public void TsMapOverlayItem825(int startOffset)
BlockSize = fileOffset - startOffset;
}

public void TsMapOverlayItem898(int startOffset)
{
var fileOffset = startOffset + 0x34; // Set position at start of flags
_zoomLevelVisibility = MemoryHelper.ReadUint8(Sector.Stream, fileOffset);
DlcGuard = MemoryHelper.ReadUint8(Sector.Stream, fileOffset + 0x01);
Hidden = _zoomLevelVisibility == 255;
_isSecret = MemoryHelper.IsBitSet(MemoryHelper.ReadUint8(Sector.Stream, fileOffset + 0x02), 1);

var type = MemoryHelper.ReadUint8(Sector.Stream, fileOffset) & 0x0F;
var overlayToken = MemoryHelper.ReadUInt64(Sector.Stream, fileOffset += 0x05);
if (type == 1)
{
_overlayName = "parking_ico"; // parking
_type = OverlayType.Map;
}
else if (type == 4)
{
_overlayName = "photo_sight_captured"; // Landmark
_type = OverlayType.Map;
}
else
{
_overlayName = ScsToken.TokenToString(overlayToken);
}

Nodes = new List<ulong>(1)
{
MemoryHelper.ReadUInt64(Sector.Stream, fileOffset += 0x08) // 0x08(overlayToken)
};

fileOffset += 0x08; // 0x08(nodeUid)
BlockSize = fileOffset - startOffset;
}

internal override void Update()
{
if (_overlayName == "") return;
Expand Down

0 comments on commit e4b7e96

Please sign in to comment.