Skip to content

Commit 6d89a0d

Browse files
committed
add road image names
1 parent f44923d commit 6d89a0d

File tree

5 files changed

+311
-183
lines changed

5 files changed

+311
-183
lines changed

Dat/Loaders/CargoObjectLoader.cs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -132,41 +132,3 @@ internal enum DatCargoCategory : uint16_t
132132
// Note: Mods may (and do) use other numbers not covered by this list
133133
NULL = (uint16_t)0xFFFFU,
134134
}
135-
136-
[TypeConverter(typeof(ExpandableObjectConverter))]
137-
[LocoStructSize(0x1F)]
138-
[LocoStructType(DatObjectType.Cargo)]
139-
internal record DatCargoObject(
140-
[property: LocoStructOffset(0x00), LocoString, Browsable(false)] string_id Name,
141-
[property: LocoStructOffset(0x02)] uint16_t var_02,
142-
[property: LocoStructOffset(0x04)] uint16_t CargoTransferTime,
143-
[property: LocoStructOffset(0x06), LocoString, Browsable(false)] string_id UnitsAndCargoName,
144-
[property: LocoStructOffset(0x08), LocoString, Browsable(false)] string_id UnitNameSingular,
145-
[property: LocoStructOffset(0x0A), LocoString, Browsable(false)] string_id UnitNamePlural,
146-
[property: LocoStructOffset(0x0C), Browsable(false)] image_id UnitInlineSprite,
147-
[property: LocoStructOffset(0x10)] DatCargoCategory CargoCategory,
148-
[property: LocoStructOffset(0x12)] DatCargoObjectFlags Flags,
149-
[property: LocoStructOffset(0x13)] uint8_t NumPlatformVariations,
150-
[property: LocoStructOffset(0x14)] uint8_t StationCargoDensity,
151-
[property: LocoStructOffset(0x15)] uint8_t PremiumDays,
152-
[property: LocoStructOffset(0x16)] uint8_t MaxNonPremiumDays,
153-
[property: LocoStructOffset(0x17)] uint16_t MaxPremiumRate,
154-
[property: LocoStructOffset(0x19)] uint16_t PenaltyRate,
155-
[property: LocoStructOffset(0x1B)] uint16_t PaymentFactor,
156-
[property: LocoStructOffset(0x1D)] uint8_t PaymentIndex,
157-
[property: LocoStructOffset(0x1E)] uint8_t UnitSize
158-
) : IImageTableNameProvider
159-
{
160-
public bool Validate()
161-
=> var_02 <= 3840
162-
&& CargoTransferTime != 0;
163-
164-
public bool TryGetImageName(int id, out string? value)
165-
{
166-
value = id == 0
167-
? "kInlineSprite"
168-
: $"kStationPlatform{id}";
169-
170-
return true;
171-
}
172-
}

Dat/Loaders/LandObjectLoader.cs

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -131,91 +131,3 @@ public static LandObjectFlags Convert(this DatLandObjectFlags datLandObjectFlags
131131
public static DatLandObjectFlags Convert(this LandObjectFlags landObjectFlags)
132132
=> (DatLandObjectFlags)landObjectFlags;
133133
}
134-
135-
[LocoStructSize(0x1E)]
136-
[LocoStructType(DatObjectType.Land)]
137-
internal record DatLandObject(
138-
[property: LocoStructOffset(0x02)] uint8_t CostIndex,
139-
[property: LocoStructOffset(0x03)] uint8_t NumGrowthStages,
140-
[property: LocoStructOffset(0x04)] uint8_t NumImageAngles,
141-
[property: LocoStructOffset(0x05)] DatLandObjectFlags Flags,
142-
[property: LocoStructOffset(0x06), Browsable(false)] object_id CliffEdgeHeader1,
143-
[property: LocoStructOffset(0x07), Browsable(false), LocoPropertyMaybeUnused] object_id CliffEdgeHeader2,
144-
[property: LocoStructOffset(0x08)] int16_t CostFactor,
145-
[property: LocoStructOffset(0x0A), Browsable(false)] image_id Image,
146-
[property: LocoStructOffset(0x0E), Browsable(false)] uint32_t NumImagesPerGrowthStage,
147-
[property: LocoStructOffset(0x12), Browsable(false)] image_id CliffEdgeImage,
148-
[property: LocoStructOffset(0x16), Browsable(false)] image_id MapPixelImage,
149-
[property: LocoStructOffset(0x1A)] uint8_t DistributionPattern,
150-
[property: LocoStructOffset(0x1B)] uint8_t NumVariations,
151-
[property: LocoStructOffset(0x1C)] uint8_t VariationLikelihood,
152-
[property: LocoStructOffset(0x1D), Browsable(false)] uint8_t pad_1D
153-
) : ILocoStruct, ILocoStructVariableData, IImageTableNameProvider
154-
{
155-
public S5Header CliffEdgeHeader { get; set; }
156-
public S5Header UnkObjHeader { get; set; }
157-
158-
public ReadOnlySpan<byte> LoadVariable(ReadOnlySpan<byte> remainingData)
159-
{
160-
// cliff edge header
161-
CliffEdgeHeader = S5Header.Read(remainingData[..S5Header.StructLength]);
162-
remainingData = remainingData[S5Header.StructLength..];
163-
164-
// unused obj
165-
if (Flags.HasFlag(DatLandObjectFlags.HasUnkObjectHeader))
166-
{
167-
UnkObjHeader = S5Header.Read(remainingData[..S5Header.StructLength]);
168-
remainingData = remainingData[S5Header.StructLength..];
169-
}
170-
171-
return remainingData;
172-
}
173-
174-
public ReadOnlySpan<byte> SaveVariable()
175-
{
176-
var variableDataSize = S5Header.StructLength + (Flags.HasFlag(DatLandObjectFlags.HasUnkObjectHeader) ? S5Header.StructLength : 0);
177-
_ = new byte[variableDataSize];
178-
byte[]? data = [.. CliffEdgeHeader.Write()];
179-
180-
if (Flags.HasFlag(DatLandObjectFlags.HasUnkObjectHeader))
181-
{
182-
UnkObjHeader.Write().CopyTo(data.AsSpan()[S5Header.StructLength..]);
183-
}
184-
185-
return data;
186-
}
187-
188-
public bool Validate()
189-
{
190-
if (CostIndex > 32)
191-
{
192-
return false;
193-
}
194-
195-
if (CostFactor <= 0)
196-
{
197-
return false;
198-
}
199-
200-
if (NumGrowthStages < 1)
201-
{
202-
return false;
203-
}
204-
205-
if (NumGrowthStages > 8)
206-
{
207-
return false;
208-
}
209-
210-
return NumImageAngles is 1 or 2 or 4;
211-
}
212-
213-
public bool TryGetImageName(int id, out string? value)
214-
=> ImageIdNameMap.TryGetValue(id, out value);
215-
216-
public static readonly Dictionary<int, string> ImageIdNameMap = new()
217-
{
218-
{ 0, "kFlatSE" },
219-
{ 1, "toolbar_terraform_land" },
220-
};
221-
}

Dat/Loaders/ScaffoldingObjectLoader.cs

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -94,58 +94,3 @@ public static void Save(Stream stream, LocoObject obj)
9494
}
9595
}
9696
}
97-
98-
[LocoStructSize(0x12)]
99-
[LocoStructType(DatObjectType.Scaffolding)]
100-
internal record DatScaffoldingObject(
101-
[property: LocoStructOffset(0x00), LocoString, Browsable(false)] string_id Name,
102-
[property: LocoStructOffset(0x02), Browsable(false)] image_id Image,
103-
[property: LocoStructOffset(0x06), LocoArrayLength(3)] uint16_t[] SegmentHeights,
104-
[property: LocoStructOffset(0x0C), LocoArrayLength(3)] uint16_t[] RoofHeights
105-
) : ILocoStruct, IImageTableNameProvider
106-
{
107-
public bool Validate() => true;
108-
109-
public bool TryGetImageName(int id, out string? value)
110-
=> ImageIdNameMap.TryGetValue(id, out value);
111-
112-
public static Dictionary<int, string> ImageIdNameMap = new()
113-
{
114-
{ 0, "type01x1SegmentBack" },
115-
{ 1, "type01x1SegmentFront" },
116-
{ 2, "type01x1RoofNE" },
117-
{ 3, "type01x1RoofSE" },
118-
{ 4, "type01x1RoofSW" },
119-
{ 5, "type01x1RoofNW" },
120-
{ 6, "type02x2SegmentBack" },
121-
{ 7, "type02x2SegmentFront" },
122-
{ 8, "type02x2RoofNE" },
123-
{ 9, "type02x2RoofSE" },
124-
{ 10, "type02x2RoofSW" },
125-
{ 11, "type02x2RoofNW" },
126-
{ 12, "type11x1SegmentBack" },
127-
{ 13, "type11x1SegmentFront" },
128-
{ 14, "type11x1RoofNE" },
129-
{ 15, "type11x1RoofSE" },
130-
{ 16, "type11x1RoofSW" },
131-
{ 17, "type11x1RoofNW" },
132-
{ 18, "type12x2SegmentBack" },
133-
{ 19, "type12x2SegmentFront" },
134-
{ 20, "type12x2RoofNE" },
135-
{ 21, "type12x2RoofSE" },
136-
{ 22, "type12x2RoofSW" },
137-
{ 23, "type12x2RoofNW" },
138-
{ 24, "type21x1SegmentBack" },
139-
{ 25, "type21x1SegmentFront" },
140-
{ 26, "type21x1RoofNE" },
141-
{ 27, "type21x1RoofSE" },
142-
{ 28, "type21x1RoofSW" },
143-
{ 29, "type21x1RoofNW" },
144-
{ 30, "type22x2SegmentBack" },
145-
{ 31, "type22x2SegmentFront" },
146-
{ 32, "type22x2RoofNE" },
147-
{ 33, "type22x2RoofSE" },
148-
{ 34, "type22x2RoofSW" },
149-
{ 35, "type22x2RoofNW" },
150-
};
151-
}

0 commit comments

Comments
 (0)