Skip to content

Commit

Permalink
Support for 1.48(.5) (#36, #39)
Browse files Browse the repository at this point in the history
Updated DLC guards.
Support for new .mat format
  • Loading branch information
dariowouters committed Oct 19, 2023
1 parent e4b7e96 commit cec1625
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
6 changes: 3 additions & 3 deletions 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.47 Open Beta**
### **Support for 1.48.5**

## Export Maps
Can now export maps as a tiled web map.
Expand Down Expand Up @@ -43,9 +43,9 @@ ATS:

## Supported maps / DLC
- ATS
- All map DLCs up to and including Texas.
- All map DLCs up to and including Oklahoma.
- ETS2
- All map DLCs up to and including Iberia.
- All map DLCs up to and including West Balkans.

#### Dependencies (NuGet)
- [Newtonsoft.Json](https://www.nuget.org/packages/Newtonsoft.Json)
Expand Down
13 changes: 12 additions & 1 deletion TsMap/Common/Consts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ internal static class Consts
new DlcGuard("dlc_mt", 22),
new DlcGuard("dlc_id_and_mt", 23),
new DlcGuard("dlc_mt_and_wy", 24),
new DlcGuard("dlc_ok", 25),
new DlcGuard("dlc_ok_and_co", 26),
new DlcGuard("dlc_ok_and_nm", 27),
new DlcGuard("dlc_ok_and_tx", 28),
new DlcGuard("dlc_ks", 29, false),
new DlcGuard("dlc_ks_and_co", 30, false),
new DlcGuard("dlc_ks_and_ok", 31, false),
};

/// <summary>
Expand All @@ -59,7 +66,11 @@ internal static class Consts
new DlcGuard("dlc_iberia_and_fr", 12),
new DlcGuard("dlc_russia", 13, false),
new DlcGuard("dlc_balt_and_russia", 14, false),
new DlcGuard("dlc_krone", 15)
new DlcGuard("dlc_krone", 15),
new DlcGuard("dlc_blkw", 16),
new DlcGuard("dlc_blkw_and_east", 17),
new DlcGuard("dlc_blkw_and_blke", 18),
new DlcGuard("dlc_feldbinder", 19),
};

public const float LaneWidth = 4.5f;
Expand Down
2 changes: 1 addition & 1 deletion TsMap/Map/Overlays/MapOverlayManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private OverlayImage GetOverlayImageFromMatFile(string matFilePath)
{
var (validLine, key, value) = SiiHelper.ParseLine(line);
if (!validLine) continue;
if (key == "texture")
if ((key == "texture" || key == "source") && value.Contains(".tobj"))
{
var tobjPath =
PathHelper.CombinePath(PathHelper.GetDirectoryPath(matFilePath), value.Split('"')[1]);
Expand Down
23 changes: 22 additions & 1 deletion TsMap/TsItem/TsCompanyItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ public TsCompanyItem(TsSector sector, int startOffset) : base(sector, startOffse
Valid = true;
if (Sector.Version < 858)
TsCompanyItem825(startOffset);
else if (Sector.Version >= 858)
else if (Sector.Version >= 858 && Sector.Version < 900)
TsCompanyItem858(startOffset);
else if (Sector.Version >= 900)
TsCompanyItem900(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()}'");
Expand Down Expand Up @@ -72,6 +74,25 @@ public void TsCompanyItem858(int startOffset)
BlockSize = fileOffset - startOffset;
}

public void TsCompanyItem900(int startOffset)
{
var fileOffset = startOffset + 0x34; // Set position at start of flags
DlcGuard = MemoryHelper.ReadUint8(Sector.Stream, fileOffset + 0x01);

_companyNameToken = MemoryHelper.ReadUInt64(Sector.Stream, fileOffset += 0x05); // 0x05(flags)

_prefabUid = MemoryHelper.ReadUInt64(Sector.Stream, fileOffset += 0x08 + 0x08); // 0x08(_companyNameToken) + 0x08(city_name)

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

var nodeCount = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x08); // count | 0x08 (node_uid)
fileOffset += 0x04 + (0x0C * nodeCount); // 0x04(nodeCount) + 0x0C(node_uid + node_flag)
BlockSize = fileOffset - startOffset;
}

internal override void Update()
{
var prefab = Sector.Mapper.Prefabs.FirstOrDefault(x => x.Uid == _prefabUid);
Expand Down

0 comments on commit cec1625

Please sign in to comment.